(function(){"Alchemy.js is a graph drawing application for the web.\nCopyright (C) 2014 GraphAlchemist, Inc.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program. If not, see .\nlets";var a,b,c,d,e,f,g;a=function(){function a(){this.version="0.1.2",this.layout={},this.interactions={},this.utils={},this.visControls={},this.styles={},this.drawing={},this.log={}}return a}(),c={},b={},e={},f={},d=null,g=null,"undefined"!=typeof module&&module.exports?module.exports=new a:this.alchemy=new a}).call(this),function(){alchemy.controlDash={init:function(){return alchemy.conf.showControlDash===!0?(d3.select(".alchemy").append("div").attr("id","control-dash-wrapper").attr("class","col-md-4 initial"),d3.select("#control-dash-wrapper").append("i").attr("id","dash-toggle").attr("class","fa fa-flask col-md-offset-12"),d3.select("#control-dash-wrapper").append("div").attr("id","control-dash").attr("class","col-md-12"),d3.select("#dash-toggle").on("click",alchemy.interactions.toggleControlDash),alchemy.controlDash.zoomCtrl(),alchemy.controlDash.search(),alchemy.controlDash.filters(),alchemy.controlDash.stats(),alchemy.controlDash.modifyElements()):void 0},search:function(){return alchemy.conf.search?(d3.select("#control-dash").append("div").attr("id","search").html("
\n
\n
',d3.select("#control-dash").append("div").attr("id","stats").html(a).select("#stats-header").on("click",function(){return d3.select("#all-stats").classed("in")?d3.select("#stats-header>span").attr("class","fa fa-2x fa-caret-right"):d3.select("#stats-header>span").attr("class","fa fa-2x fa-caret-down")}),alchemy.stats.init()):void 0},modifyElements:function(){var a;return alchemy.conf.showEditor?(a='',d3.select("#update-elements").html(a).select("#control-dash").append("div").attr("id","update-elements"),alchemy.modifyElements.init()):void 0}}}.call(this),function(){alchemy.drawing.drawedges=function(a){var b;return console.log(a),b=alchemy.conf.cluster?function(a){var b,c,d;if(a.source.root||a.target.root)d=a.source.root?a.target.cluster:a.source.cluster;else if(a.source.cluster===a.target.cluster)d=a.source.cluster;else if(a.source.cluster!==a.target.cluster)return c=""+a.source.cluster+"-"+a.target.cluster,b="cluster-gradient-"+c,"stroke: url(#"+b+")";return"stroke: "+alchemy.styles.getClusterColour(d)}:alchemy.conf.edgeStyle&&!alchemy.conf.cluster?function(a){return""+alchemy.conf.edgeStyle(a)}:function(){return""},a.enter().insert("line","g.node").attr("class",function(a){return"edge "+a.caption+" active "+(a.shortest?"highlighted":"")}).attr("source-target",function(a){return a.source.id+"-"+a.target.id}).on("click",alchemy.interactions.edgeClick),a.exit().remove(),a.attr("x1",function(a){return a.source.x}).attr("y1",function(a){return a.source.y}).attr("x2",function(a){return a.target.x}).attr("y2",function(a){return a.target.y}).attr("shape-rendering","optimizeSpeed").attr("style",function(a){return b(a)})}}.call(this),function(){alchemy.drawing.drawnodes=function(a){var b,c,d,e;return c=a.enter().append("g").attr("class",function(a){var b,c;return c=alchemy.conf.rootNodes,alchemy.conf.nodeTypes?(b=a[Object.keys(alchemy.conf.nodeTypes)],null!=a[c]&&a[c]?"node root "+b+" active":"node "+b+" active"):null!=a[c]&&a[c]?"node root active":"node active"}).attr("id",function(a){return"node-"+a.id}).on("mousedown",function(a){return a.fixed=!0}).on("mouseover",alchemy.interactions.nodeMouseOver).on("mouseout",alchemy.interactions.nodeMouseOut).on("dblclick",alchemy.interactions.nodeDoubleClick).on("click",alchemy.interactions.nodeClick),alchemy.conf.fixNodes||(d=c.filter(function(a){return a.root!==!0}),d.call(alchemy.interactions.drag)),alchemy.conf.fixRootNodes||(e=c.filter(function(a){return a.root===!0}),e.call(alchemy.interactions.drag)),b=function(a){var b;return alchemy.conf.cluster?(b=isNaN(parseInt(a.cluster))||a.cluster>alchemy.conf.clusterColours.length?alchemy.conf.clusterColours[alchemy.conf.clusterColours.length-1]:alchemy.conf.clusterColours[a.cluster],"fill: "+b+"; stroke: "+b+";"):alchemy.conf.nodeColour?b=alchemy.conf.nodeColour:""},c.append("circle").attr("class",function(a){var b,c;return c=alchemy.conf.rootNodes,alchemy.conf.nodeTypes?(b=a[Object.keys(alchemy.conf.nodeTypes)],null!=a[c]&&a[c]?"root "+b+" active":""+b+" active"):null!=a[c]&&a[c]?"root":"node"}).attr("id",function(a){return"circle-"+a.id}).attr("r",function(a){return alchemy.utils.nodeSize(a)}).attr("shape-rendering","optimizeSpeed").attr("target-id",function(a){return a.id}).attr("style",function(a){var c;return c=d3.select(this).attr("r"),""+b(a)+"; stroke-width: "+c/3}),c.append("svg:text").attr("id",function(a){return"text-"+a.id}).attr("dy",function(a){return a.root?alchemy.conf.rootNodeRadius/2:2*alchemy.conf.nodeRadius-5}).html(function(a){return alchemy.utils.nodeText(a)})}}.call(this),function(){alchemy.filters={init:function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;if(alchemy.filters.show(),alchemy.conf.edgeFilters&&alchemy.filters.showEdgeFilters(),alchemy.conf.nodeFilters&&alchemy.filters.showNodeFilters(),alchemy.conf.nodeTypes){for(e=Object.keys(alchemy.conf.nodeTypes),g="",n=alchemy.conf.nodeTypes[e],h=0,k=n.length;k>h;h++)f=n[h],a=f.replace("_"," "),g+="
"+a+"";$("#node-dropdown").append(g)}if(alchemy.conf.edgeTypes){for(o=d3.selectAll(".edge")[0],i=0,l=o.length;l>i;i++)b=o[i],currentRelationshipTypes[[b].caption]=!0;for(d="",p=alchemy.conf.edgeTypes,j=0,m=p.length;m>j;j++)c=p[j],c&&(a=c.replace("_"," "),d+="
"+a+"");$("#rel-dropdown").append(d)}return alchemy.conf.captionsToggle&&alchemy.filters.captionsToggle(),alchemy.conf.edgesToggle&&alchemy.filters.edgesToggle(),alchemy.conf.nodesToggle&&alchemy.filters.nodesToggle(),alchemy.filters.update()},show:function(){var a;return a='\n
',d3.select("#control-dash #filters").html(a),d3.selectAll("#filter-header").on("click",function(){return d3.select("#filters>form").classed("in")?d3.select("#filter-header>span").attr("class","fa fa-2x fa-caret-right"):d3.select("#filter-header>span").attr("class","fa fa-2x fa-caret-down")}),$("#filters form").submit(!1)},showEdgeFilters:function(){var a;return a='
\n',$("#filters form").append(a),d3.select("#filter-rel-header").on("click",function(){return d3.select("#rel-dropdown").classed("in")?d3.select("#filter-rel-header>span").attr("class","fa fa-lg fa-caret-right"):d3.select("#filter-rel-header>span").attr("class","fa fa-lg fa-caret-down")})},showNodeFilters:function(){var a;return a='
',$("#filters form").append(a),d3.select("#filter-node-header").on("click",function(){return d3.select("#node-dropdown").classed("in")?d3.select("#filter-node-header>span").attr("class","fa fa-lg fa-caret-right"):d3.select("#filter-node-header>span").attr("class","fa fa-lg fa-caret-down")})},captionsToggle:function(){return d3.select("#filters form").append("li").attr({id:"toggle-captions","class":"list-group-item active-label toggle"}).html("Show Captions").on("click",function(){var a;return a=d3.select("g text").attr("style"),"display: block"===a?d3.selectAll("g text").attr("style","display: none"):d3.selectAll("g text").attr("style","display: block")})},edgesToggle:function(){return d3.select("#filters form").append("li").attr({id:"toggle-edges","class":"list-group-item active-label toggle"}).html("Toggle Edges").on("click",function(){return 0===d3.selectAll(".edge.hidden")[0].length?d3.selectAll(".edge").classed("hidden",!0):d3.selectAll(".edge").classed("hidden",!1)})},nodesToggle:function(){return d3.select("#filters form").append("li").attr({id:"toggle-nodes","class":"list-group-item active-label toggle"}).html("Toggle Nodes").on("click",function(){var a;return a=alchemy.conf.toggleRootNodes?".node,.edge":".node:not(.root),.edge",0===d3.selectAll(".node.hidden")[0].length?d3.selectAll(a).classed("hidden",!0):d3.selectAll(a).classed("hidden",!1)})},update:function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(i=alchemy.vis,c={node:i.selectAll("g"),edge:i.selectAll("line")},h=d3.selectAll(".nodeType, .edgeType"),e=function(a,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;if(e=!b.classed("disabled"),h=b.attr("name"),l=e?"active":"inactive",d&&(l+=" highlight"),h=h.replace(/\s+/g,"_"),["node","edge"].forEach(function(a){return c[a].filter("."+h).attr("class",""+a+" "+h+" "+l)}),l=l.replace(/\s+/g,"."),b.classed("nodeType"))for(t=alchemy.node.filter("."+h+"."+l).data(),n=0,q=t.length;q>n;n++)for(i=t[n],j=i.id,u=alchemy.edge.filter("[source-target*='"+j+"']").data(),o=0,r=u.length;r>o;o++)f=u[o],g=f.caption,alchemy.edge.filter("[source-target*='"+j+"']").classed(!d3.select("#li-"+g).empty()&&d3.select("#li-"+g).classed("disabled")?{inactive:!0,active:!1,highlight:!1}:{inactive:!e,active:e,highlight:d});else if(b.classed("edgeType"))for(v=alchemy.edge.filter("."+h+"."+l).data(),p=0,s=v.length;s>p;p++)f=v[p],k=f.source,m=f.target,d3.select("#node-"+m.id).classed("inactive")||d3.select("#node-"+k.id).classed("inactive")?alchemy.edge.filter("[source-target='"+k.id+"-"+m.id+"']").classed({inactive:!0,active:!1,highlight:!1}):alchemy.edge.filter("[source-target='"+k.id+"-"+m.id+"']");else console.log("ERROR tag was neither edgeType nor nodeType");return alchemy.stats.update()},l=h[0],j=0,k=l.length;k>j;j++)g=l[j],b=d3.select(g),d=b.attr("name"),a=!b.classed("disabled"),f=a?"active":"inactive",b.classed({"active-label":a,disabled:!a}),e(b,!1);return h.on("mouseenter",function(){var a;return b=d3.select(this),a=!0,e(b,a)}).on("mouseleave",function(){var a;return b=d3.select(this),a=!1,e(b,a)}).on("click",function(){var c;return b=d3.select(this),a=!b.classed("disabled"),a=!a,b.classed({"active-label":a,disabled:!a}),c=!1,e(b,c)})}}}.call(this),function(){var a,b,c;a=function(){d3.event.sourceEvent.stopPropagation(),d3.select(this).classed("dragging",!0)},c=function(a){return a.x+=d3.event.dx,a.y+=d3.event.dy,a.px+=d3.event.dx,a.py+=d3.event.dy,d3.select(this).attr("transform","translate("+a.x+", "+a.y+")"),alchemy.conf.forceLocked||alchemy.force.start(),alchemy.edge.attr("x1",function(a){return a.source.x}).attr("y1",function(a){return a.source.y}).attr("x2",function(a){return a.target.x}).attr("y2",function(a){return a.target.y}).attr("cx",a.x=d3.event.x).attr("cy",a.y=d3.event.y)},b=function(){return d3.select(this).classed("dragging",!1)},alchemy.interactions={edgeClick:function(){var a;return a=alchemy.vis,a.selectAll("line").classed("highlight",!1),d3.select(this).classed("highlight",!0),d3.event.stopPropagation,"function"==typeof(null!=alchemy.conf.edgeClick)?alchemy.conf.edgeClick():void 0},nodeMouseOver:function(a){return null==alchemy.conf.nodeMouseOver?null:"function"==typeof alchemy.conf.nodeMouseOver?alchemy.conf.nodeMouseOver(a):"number"==typeof alchemy.conf.nodeMouseOver?a[alchemy.conf.nodeMouseOver]:void 0},nodeMouseOut:function(a){return null!=alchemy.conf.nodeMouseOut&&"function"==typeof alchemy.conf.nodeMouseOut?alchemy.conf.nodeMouseOut(a):null},nodeDoubleClick:function(a){var b,c,d;if(d3.event.stopPropagation(),alchemy.conf.extraDataSource&&!a.expanded&&!alchemy.conf.unexpandable.indexOf(a.type===!1)){$('
nner').show(),console.log("loading more data for "+a.id),a.expanded=!0,d3.json(alchemy.conf.extraDataSource+a.id,loadMoreNodes),c=findAllEdges(a),d=[];for(b in edges)d.push(edges[b].distance*=2);return d}},nodeClick:function(a){var b;d3.event.stopPropagation(),b=alchemy.vis.select("#node-"+a.id).classed("selected"),alchemy.vis.select("#node-"+a.id).classed("selected",!b),"function"==typeof alchemy.conf.nodeClick&&alchemy.conf.nodeClick(a)},drag:d3.behavior.drag().origin(Object).on("dragstart",a).on("drag",c).on("dragend",b),zoom:function(a){return null==this._zoomBehavior&&(this._zoomBehavior=d3.behavior.zoom()),this._zoomBehavior.scaleExtent(a).on("zoom",function(){return alchemy.vis.attr("transform","translate("+d3.event.translate+") scale("+d3.event.scale+")")})},clickZoom:function(a){var b,c;return c=alchemy.vis.attr("transform").match(/(-*\d+\.*\d*)/g).map(function(a){return parseFloat(a)}),b=c,alchemy.vis.attr("transform",function(){return"in"===a?"translate("+b.slice(0,2)+") scale("+(b[2]=b[2]+.2)+")":"out"===a?"translate("+b.slice(0,2)+") scale("+(b[2]=b[2]-.2)+")":"reset"===a?"translate(0,0) scale(1)":console.log("error")}),null==this._zoomBehavior&&(this._zoomBehavior=d3.behavior.zoom()),this._zoomBehavior.scale(b[2]).translate(b.slice(0,2))},toggleControlDash:function(){var a;return a=d3.select("#control-dash-wrapper").classed("off-canvas")||d3.select("#control-dash-wrapper").classed("initial"),d3.select("#control-dash-wrapper").classed({"off-canvas":!a,initial:!1,"on-canvas":a})}}}.call(this),function(){alchemy.layout={gravity:function(a){return 8*a},charge:function(a){return alchemy.conf.cluster?-500:-10/a},linkStrength:function(a){return alchemy.conf.cluster?a.source.cluster===a.target.cluster?1:.1:a.source.root||a.target.root?.9:1},friction:function(){return alchemy.conf.cluster?.7:.9},collide:function(a){var b,c,d,e,f;return f=2.2*alchemy.utils.nodeSize(a)+alchemy.conf.nodeOverlap,b=a.x-f,c=a.x+f,d=a.y-f,e=a.y+f,function(g,h,i,j,k){var l,m,n;return g.point&&g.point!==a&&(m=a.x-Math.abs(g.point.x),n=a.y-g.point.y,l=Math.sqrt(m*m+n*n),f=f,f>l&&(l=(l-f)/l*alchemy.conf.alpha,a.x-=m*=l,a.y-=n*=l,g.point.x+=m,g.point.y+=n)),h>c||b>j||i>e||d>k}},tick:function(){var a,b,c,d,e;if(alchemy.conf.collisionDetection)for(b=d3.geom.quadtree(alchemy.nodes),e=alchemy.nodes,c=0,d=e.length;d>c;c++)a=e[c],b.visit(alchemy.layout.collide(a));return alchemy.edge.attr("x1",function(a){return a.source.x}).attr("y1",function(a){return a.source.y}).attr("x2",function(a){return a.target.x}).attr("y2",function(a){return a.target.y}),alchemy.node.attr("transform",function(a){return"translate("+a.x+","+a.y+")"})},positionRootNodes:function(){var a,b,c,d,e,f,g,h,i,j,k;for(a={width:alchemy.conf.graphWidth(),height:alchemy.conf.graphHeight()},e=Array(),j=alchemy.nodes,b=f=0,h=j.length;h>f;b=++f)c=j[b],c[alchemy.conf.rootNodes]&&(c.i=b,e.push(c));if(1!==e.length){for(d=0,k=[],g=0,i=e.length;i>g;g++)c=e[g],d++,alchemy.nodes[c.i].x=a.width/Math.sqrt(e.length*d),alchemy.nodes[c.i].y=a.height/2,k.push(alchemy.nodes[c.i].fixed=!0);return k}c=e[0],alchemy.nodes[c.i].x=a.width/2,alchemy.nodes[c.i].y=a.height/2,alchemy.nodes[c.i].px=a.width/2,alchemy.nodes[c.i].py=a.height/2,alchemy.nodes[c.i].fixed=!0},chargeDistance:function(){var a;return a=500},linkDistancefn:function(a,b){return alchemy.conf.cluster?(a.source.root||a.target.root,a.source.cluster===a.target.cluster?10:600):10/(5*b)}}}.call(this),function(){alchemy.modifyElements={init:function(){return alchemy.conf.removeElement?alchemy.modifyElements.showRemove():void 0},showRemove:function(){var a;return a='
',d3.selectAll("#editor-header").append("div").html(a).on("click",function(){return d3.select("#element-options").classed("in")?d3.select("#editor-header>span").attr("class","fa fa-2x fa-caret-right"):d3.select("#editor-header>span").attr("class","fa fa-2x fa-caret-down")}),d3.select("#remove").on("click",function(){return alchemy.modifyElements.remove()})},remove:function(){var a,b;return b=d3.selectAll(".selected.node").data(),a=d3.selectAll(".selected.edge").data(),alchemy.edges=_.difference(alchemy.edges,a),alchemy.nodes=_.difference(alchemy.nodes,b),alchemy.force.friction(1),alchemy.updateGraph(!1),alchemy.force.resume(),alchemy.force.friction(.9),d3.selectAll(".selected").classed("selected",!1)}}}.call(this),function(){alchemy.search={init:function(){var a;return a=d3.select("#search input"),a.on("keyup",function(){var b;return b=a[0][0].value.toLowerCase(),d3.selectAll(".node").classed("inactive",!1),d3.selectAll("text").attr("style",function(){return""!==b?"display: inline;":void 0}),d3.selectAll(".node").classed("inactive",function(a){var c,d;return c=d3.select(this),"contains"===alchemy.conf.searchMethod&&(d=c.text().toLowerCase().indexOf(b)<0),"begins"===alchemy.conf.searchMethod&&(d=0!==c.text().toLowerCase().indexOf(b)),d?d3.selectAll("[source-target*='"+a.id+"']").classed("inactive",d):d3.selectAll("[source-target*='"+a.id+"']").classed("inactive",function(a){var b,c,d;return b=[a.source.id,a.target.id],c=d3.select("#node-"+b[0]).classed("inactive"),d=d3.select("#node-"+b[1]).classed("inactive"),d||c}),d})})}}}.call(this),function(){alchemy.startGraph=function(a){var b,c,d;return d3.select(alchemy.conf.divSelector).empty()&&console.warn("create an element with the alchemy.conf.divSelector.\ne.g. the defaul #alchemy"),a?(alchemy.nodes=a.nodes,alchemy.edges=a.edges,d=d3.map(),alchemy.nodes.forEach(function(a){return d.set(a.id,a)}),alchemy.edges.forEach(function(a){return a.source=d.get(a.source),a.target=d.get(a.target)}),alchemy.vis=d3.select(alchemy.conf.divSelector).attr("style","width:"+alchemy.conf.graphWidth()+"px; height:"+alchemy.conf.graphHeight()+"px").append("svg").attr("xmlns","http://www.w3.org/2000/svg").attr("pointer-events","all").on("dblclick.zoom",null).on("click",alchemy.utils.deselectAll).call(alchemy.interactions.zoom(alchemy.conf.scaleExtent)).append("g").attr("transform","translate("+alchemy.conf.initialTranslate+") scale("+alchemy.conf.initialScale+")"),b=Math.sqrt(alchemy.nodes.length/(alchemy.conf.graphWidth()*alchemy.conf.graphHeight())),alchemy.force=d3.layout.force().charge(alchemy.layout.charge(b)).linkDistance(function(a){return alchemy.conf.linkDistance(a,b)}).theta(1).gravity(alchemy.layout.gravity(b)).linkStrength(alchemy.layout.linkStrength).friction(alchemy.layout.friction()).chargeDistance(alchemy.layout.chargeDistance()).size([alchemy.conf.graphWidth(),alchemy.conf.graphHeight()]).nodes(alchemy.nodes).links(alchemy.edges).on("tick",alchemy.layout.tick),alchemy.updateGraph(),alchemy.controlDash.init(),alchemy.conf.forceLocked||alchemy.force.on("tick",alchemy.layout.tick).start(),null!=alchemy.conf.afterLoad&&("function"==typeof alchemy.conf.afterLoad?alchemy.conf.afterLoad():"string"==typeof alchemy.conf.afterLoad&&(alchemy[alchemy.conf.afterLoad]=!0)),alchemy.conf.initialScale!==alchemy.defaults.initialScale?void alchemy.interactions.zoom().scale(alchemy.conf.initialScale):void(alchemy.conf.initialTranslate!==alchemy.defaults.initialTranslate&&alchemy.interactions.zoom().translate(alchemy.conf.initialTranslate))):(c='
\n
\n
\n \n
\n
'+alchemy.conf.warningMessage+'
\n
\n \n
\n
\n
',$("body").append(c),$("#no-results").modal("show"),void $("#loading-spinner").hide())}}.call(this),function(){alchemy.stats={init:function(){return alchemy.stats.update()},nodeStats:function(){var a,b,c,d,e,f,g,h,i,j,k,l;if(g="",f=d3.selectAll(".node")[0].length,a=d3.selectAll(".node.active")[0].length,c=d3.selectAll(".node.inactive")[0].length,g+="
Number of nodes: "+f+"",g+="
Number of active nodes: "+a+"",g+="
Number of inactive nodes: "+c+"",alchemy.conf.nodeTypes){for(e=Object.keys(alchemy.conf.nodeTypes),i="",l=alchemy.conf.nodeTypes[e],j=0,k=l.length;k>j;j++)h=l[j],b=h.replace("_"," "),f=d3.selectAll("g.node."+h)[0].length,i+="
Number of nodes of type "+b+": "+f+"";g+=i}return d="
",g+=d,$("#node-stats").html(g)},edgeStats:function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n;if(d=null,f=d3.selectAll(".edge")[0].length,a=d3.selectAll(".edge.active")[0].length,h=d3.selectAll(".edge.inactive")[0].length,e="
Number of relationships: "+f+" Number of active relationships: "+a+" Number of inactive relationships: "+h+" ",alchemy.conf.edgeTypes){for(d=[],m=d3.selectAll(".edge")[0],i=0,k=m.length;k>i;i++)c=m[i],currentRelationshipTypes[[c].caption]=!0;for(n=alchemy.conf.edgeTypes,j=0,l=n.length;l>j;j++)g=n[j],g&&(b=g.replace("_"," "),f=d3.selectAll(".edge."+g)[0].length,d.push([""+b,f]))}return $("#rel-stats").html(e),alchemy.stats.insertSVG("edge",d),d},nodeStats:function(){var a,b,c,d,e,f,g,h,i,j,k;if(c=null,h=d3.selectAll(".node")[0].length,a=d3.selectAll(".node.active")[0].length,b=d3.selectAll(".node.inactive")[0].length,alchemy.conf.nodeTypes)for(c=[],e=Object.keys(alchemy.conf.nodeTypes),k=alchemy.conf.nodeTypes[e],i=0,j=k.length;j>i;i++)g=k[i],f=d3.selectAll("g.node."+g)[0].length,c.push([""+g,f]);return d="
Number of nodes: "+h+" Number of active nodes: "+a+" Number of inactive nodes: "+b+" ",$("#node-stats").html(d),alchemy.stats.insertSVG("node",c),c},insertSVG:function(a,b){var c,d,e,f,g,h,i,j;return null===b?d3.select("#"+a+"-stats-graph").html("
There are no "+a+"Types listed in your conf.
"):(j=.25*alchemy.conf.graphWidth(),f=250,h=j/4,e=d3.scale.category20(),c=d3.svg.arc().outerRadius(h-10).innerRadius(h/2),g=d3.layout.pie().sort(null).value(function(a){return a[1]}),i=d3.select("#"+a+"-stats-graph").append("svg").append("g").style({width:j,height:f}).attr("transform","translate("+j/2+","+f/2+")"),d=i.selectAll(".arc").data(g(b)).enter().append("g").classed("arc",!0).on("mouseover",function(a,c){return d3.select("#"+b[c][0]+"-stat").classed("hidden",!1)}).on("mouseout",function(a,c){return d3.select("#"+b[c][0]+"-stat").classed("hidden",!0)}),d.append("path").attr("d",c).attr("stroke",function(a,b){return e(b)}).attr("stroke-width",2).attr("fill-opacity","0.3"),d.append("text").attr("transform",function(a){return"translate("+c.centroid(a)+")"}).attr("id",function(a,c){return""+b[c][0]+"-stat"}).attr("dy",".35em").classed("hidden",!0).text(function(a,c){return b[c][0]}))},update:function(){return alchemy.conf.nodeStats===!0&&alchemy.stats.nodeStats(),alchemy.conf.edgeStats===!0?alchemy.stats.edgeStats():void 0}}}.call(this),function(){alchemy.updateGraph=function(a){var b;if(null==a&&(a=!0),alchemy.layout.positionRootNodes(),alchemy.edge=alchemy.vis.selectAll("line").data(alchemy.edges),alchemy.node=alchemy.vis.selectAll("g.node").data(alchemy.nodes,function(a){return a.id}),a&&this.force.start(),!b){for(;this.force.alpha()>.005;)alchemy.force.tick();b=!0,console.log(Date()+" completed initial computation"),alchemy.conf.locked&&alchemy.force.stop()}return alchemy.styles.edgeGradient(alchemy.edges),alchemy.drawing.drawedges(alchemy.edge),alchemy.drawing.drawnodes(alchemy.node),alchemy.vis.selectAll("g.node").attr("transform",function(a){return"translate("+a.x+", "+a.y+")"}),alchemy.vis.selectAll(".node text").html(function(a){return function(b){return a.utils.nodeText(b)}}(this)),alchemy.node.exit().remove()}}.call(this),function(){alchemy.defaults={graphWidth:function(){return d3.select(this.divSelector).node().parentElement.clientWidth},graphHeight:function(){return"BODY"===d3.select(this.divSelector).node().parentElement.nodeName?window.innerHeight:d3.select(this.divSelector).node().parentElement.clientHeight},alpha:.5,cluster:!1,clusterColours:d3.shuffle(["#DD79FF","#FFFC00","#00FF30","#5168FF","#00C0FF","#FF004B","#00CDCD","#f83f00","#f800df","#ff8d8f","#ffcd00","#184fff","#ff7e00"]),collisionDetection:!0,fixNodes:!1,fixRootNodes:!1,forceLocked:!0,linkDistance:alchemy.layout.linkDistancefn,nodePositions:null,showEditor:!1,captionToggle:!1,edgesToggle:!1,nodesToggle:!1,toggleRootNodes:!0,removeElement:!1,addNodes:!1,addEdges:!1,showControlDash:!1,showStats:!1,nodeStats:!1,edgeStats:!1,showFilters:!1,edgeFilters:!1,nodeFilters:!1,zoomControls:!1,nodeCaption:"caption",nodeColour:null,nodeMouseOver:"caption",nodeOverlap:25,nodeRadius:10,nodeTypes:null,rootNodes:"root",rootNodeRadius:15,edgeCaption:"caption",edgeStyle:function(){return null},edgeTypes:null,search:!0,searchMethod:"contains",afterLoad:"afterLoad",divSelector:"#alchemy",dataSource:null,initialScale:1,initialTranslate:[0,0],scaleExtent:[.5,2.4],warningMessage:"There be no data! What's going on?"}}.call(this),function(){alchemy.begin=function(a){return alchemy.conf=_.assign({},alchemy.defaults,a),"string"==typeof alchemy.conf.dataSource?d3.json(alchemy.conf.dataSource,alchemy.startGraph):"object"==typeof alchemy.conf.dataSource?alchemy.startGraph(alchemy.conf.dataSource):void 0}}.call(this),function(){alchemy.styles={getClusterColour:function(a){return null!=alchemy.conf.clusterColours[a]?alchemy.conf.clusterColours[a]:"#EBECE4"},edgeGradient:function(a){var b,c,d,e,f,g,h,i,j,k,l,m;for(c=d3.select(""+alchemy.conf.divSelector+" svg").append("svg:defs"),b={},k=0,l=a.length;l>k;k++)if(d=a[k],!d.source.root&&!d.target.root&&d.source.cluster!==d.target.cluster&&d.target.cluster!==d.source.cluster){if(h=d.source.cluster+"-"+d.target.cluster,h in b)continue;h in b||(j=this.getClusterColour(d.target.cluster),e=this.getClusterColour(d.source.cluster),b[h]={startColour:j,endColour:e})}m=[];for(i in b)g="cluster-gradient-"+i,f=c.append("svg:linearGradient").attr("id",g),f.append("svg:stop").attr("offset","0%").attr("stop-color",b[i].startColour),m.push(f.append("svg:stop").attr("offset","100%").attr("stop-color",b[i].endColour));return m}}}.call(this),function(){alchemy.utils={deselectAll:function(){var a;if(null!=(a=d3.event)?!a.defaultPrevented:!0)return alchemy.vis.selectAll(".node, line").classed("selected highlight",!1),d3.select(".alchemy svg").classed({"highlight-active":!1}),alchemy.vis.selectAll("line.edge").classed("highlighted connected unconnected",!1),alchemy.vis.selectAll("g.node,circle,text").classed("selected unselected neighbor unconnected connecting",!1),alchemy.conf.deselectAll?alchemy.conf.deselectAll():void 0},centreView:function(a){var b,c,d,e,f,g,h,i,j;return g=$("#graph").get(0),d=$(a).get(0),h=g.getBoundingClientRect(),e=d.getBoundingClientRect(),b=[h.width/2+h.left-e.left-e.width/2,h.height/2+h.top-e.top-e.height/2],f=getCurrentViewParams(),i=parseFloat(f[0])+b[0],j=parseFloat(f[1])+b[1],c=parseFloat(f[2]),alchemy.vis.transition().attr("transform","translate("+i+", "+j+") scale("+c+")"),zoom.translate([i,j]).scale(c)},nodeText:function(a){var b;return alchemy.conf.nodeCaption&&"string"==typeof alchemy.conf.nodeCaption?null!=a[alchemy.conf.nodeCaption]?a[alchemy.conf.nodeCaption]:"":alchemy.conf.nodeCaption&&"function"==typeof alchemy.conf.nodeCaption?(b=alchemy.conf.nodeCaption(a),(void 0===b||"undefined"===String(b))&&(alchemy.log.caption="At least one caption returned undefined",alchemy.conf.caption=!1),b):void 0},nodeSize:function(a){var b,c;return null==alchemy.conf.nodeRadius?20:(c=alchemy.conf.rootNodes,"function"==typeof alchemy.conf.nodeRadius?null!=a[c]&&a[c]?alchemy.conf.rootNodeRadius:alchemy.conf.nodeRadius(a):"string"==typeof alchemy.conf.nodeRadius?(b=alchemy.conf.nodeRadius,null!=a[c]&&a[c]?alchemy.conf.rootNodeRadius:a.degree):"number"==typeof alchemy.conf.nodeRadius?null!=a[c]&&a[c]?alchemy.conf.rootNodeRadius:alchemy.conf.nodeRadius:void 0)}}}.call(this),function(){alchemy.welcomeConf={forceLocked:!1,captionToggle:!0,edgesToggle:!0,nodesToggle:!0,toggleRootNodes:!0,showControlDash:!0,showStats:!0,nodeStats:!0,edgeStats:!0,showFilters:!0,edgeFilters:!0,nodeFilters:!0,zoomControls:!0,nodeTypes:null}}.call(this);