/** * D3 Force Network Chart - v3.1.0 - 2019-04-28 * https://github.com/ogobrecht/d3-force-apex-plugin * Copyright (c) 2015-2019 Ottmar Gobrecht - MIT license */ function netGobrechtsD3Force(t,e,o,n){"use strict";var g={conf:{},confDefaults:{},data:{},dom:{},events:{},lib:{},main:{},status:{},tools:{},version:"3.1.0"},p={};return g.main.init=function(){g.dom.containerId=t||"D3Force"+Math.floor(1e6*Math.random()),g.confUser=e||{},g.status.apexPluginId=o,g.status.apexPageItemsToSubmit=!(!n||""===n)&&n.replace(/\s/g,"").split(","),g.main.setupConfiguration(),g.main.setupDom(),g.main.setupFunctionReferences()},g.main.setupConfiguration=function(){g.conf.debug=g.status.apexPluginId&&1===apex.jQuery("#pdebug").length,g.status.debugPrefix="D3 Force in DOM container #"+g.dom.containerId+": ",g.status.customize=!1,g.status.customizeCurrentMenu="nodes",g.status.customizeCurrentTabPosition=null,g.status.forceTickCounter=0,g.status.forceStartTime=0,g.status.forceRunning=!1,g.status.graphStarted=!1,g.status.graphRendering=!1,g.status.graphReady=!1,g.status.graphOldPositions=null,g.status.sampleData=!1,g.status.wrapLabelsOnNextTick=!1,g.status.labelFontSize=null,g.status.resizeTriggered=!1,g.confDefaults.minNodeRadius={display:!0,relation:"node",type:"number",val:6,options:[12,11,10,9,8,7,6,5,4,3,2,1]},g.confDefaults.maxNodeRadius={display:!0,relation:"node",type:"number",val:18,options:[36,34,32,30,28,26,24,22,20,18,16,14,12]},g.confDefaults.colorScheme={display:!0,relation:"node",type:"text",val:"color20",options:["color20","color20b","color20c","color10","direct"]},g.confDefaults.dragMode={display:!0,relation:"node",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.pinMode={display:!0,relation:"node",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.nodeEventToStopPinMode={display:!0,relation:"node",type:"text",val:"contextmenu",options:["none","dblclick","contextmenu"]},g.confDefaults.onNodeContextmenuPreventDefault={display:!0,relation:"node",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.nodeEventToOpenLink={display:!0,relation:"node",type:"text",val:"dblclick",options:["none","click","dblclick","contextmenu"]},g.confDefaults.nodeLinkTarget={display:!0,relation:"node",type:"text",val:"_blank",options:["none","_blank","nodeID","domContainerID"]},g.confDefaults.showLabels={display:!0,relation:"label",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.wrapLabels={display:!0,relation:"label",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.labelSplitCharacter={display:!0,relation:"label",type:"text",val:"none",options:["none","^","`","°","\\","|","/","#",":","::"]},g.confDefaults.wrappedLabelWidth={display:!0,relation:"label",type:"number",val:80,options:[200,190,180,170,160,150,140,130,120,110,100,90,80,70,60,50,40]},g.confDefaults.wrappedLabelLineHeight={display:!0,relation:"label",type:"number",val:1.2,options:[1.5,1.4,1.3,1.2,1.1,1]},g.confDefaults.labelsCircular={display:!0,relation:"label",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.labelDistance={display:!0,relation:"label",type:"number",val:12,options:[30,28,26,24,22,20,18,16,14,12,10,8,6,4,2]},g.confDefaults.preventLabelOverlappingOnForceEnd={display:!0,relation:"label",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.labelPlacementIterations={display:!0,relation:"label",type:"number",val:250,options:[2e3,1e3,500,250,125]},g.confDefaults.showTooltips={display:!0,relation:"node",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.tooltipPosition={display:!0,relation:"node",type:"text",val:"svgTopRight",options:["node","svgTopLeft","svgTopRight"]},g.confDefaults.alignFixedNodesToGrid={display:!0,relation:"node",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.gridSize={display:!0,relation:"node",type:"number",val:50,options:[150,140,130,120,110,100,90,80,70,60,50,40,30,20,10]},g.confDefaults.linkDistance={display:!0,relation:"link",type:"number",val:80,options:[120,110,100,90,80,70,60,50,40,30,20]},g.confDefaults.showLinkDirection={display:!0,relation:"link",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.showSelfLinks={display:!0,relation:"link",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.selfLinkDistance={display:!0,relation:"link",type:"number",val:20,options:[30,28,26,24,22,20,18,16,14,12,10,8]},g.confDefaults.useDomParentWidth={display:!0,relation:"graph",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.width={display:!0,relation:"graph",type:"number",val:600,options:[1200,1150,1100,1050,1e3,950,900,850,800,750,700,650,600,550,500,450,400,350,300]},g.confDefaults.height={display:!0,relation:"graph",type:"number",val:400,options:[1200,1150,1100,1050,1e3,950,900,850,800,750,700,650,600,550,500,450,400,350,300]},g.confDefaults.setDomParentPaddingToZero={display:!0,relation:"graph",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.showBorder={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.showLegend={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.showLoadingIndicatorOnAjaxCall={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.lassoMode={display:!0,relation:"graph",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.zoomMode={display:!0,relation:"graph",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.minZoomFactor={display:!0,relation:"graph",type:"number",val:.2,options:[1,.9,.8,.7,.6,.5,.4,.3,.2,.1]},g.confDefaults.maxZoomFactor={display:!0,relation:"graph",type:"number",val:5,options:[10,9,8,7,6,5,4,3,2,1]},g.confDefaults.transform={display:!1,relation:"graph",type:"object",val:{translate:[0,0],scale:1}},g.confDefaults.zoomToFitOnForceEnd={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.zoomToFitOnResize={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.keepAspectRatioOnResize={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.onResizeFunctionTimeout={display:!0,relation:"graph",type:"number",val:300,options:[1e3,900,800,700,600,500,400,300,200,100,0]},g.confDefaults.autoRefresh={display:!0,relation:"graph",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.refreshInterval={display:!0,relation:"graph",type:"number",val:5e3,options:[6e4,3e4,15e3,1e4,5e3,2500]},g.confDefaults.forceTimeLimit={display:!0,relation:"graph",type:"number",val:1/0,options:[1/0,6400,3200,1600,800,400,200,100]},g.confDefaults.chargeDistance={display:!1,relation:"graph",type:"number",val:1/0,options:[1/0,25600,12800,6400,3200,1600,800,400,200,100],internal:!0},g.confDefaults.charge={display:!0,relation:"graph",type:"number",val:-350,options:[-1e3,-950,-900,-850,-800,-750,-700,-650,-600,-550,-500,-450,-400,-350,-300,-250,-200,-150,-100,-50,0],internal:!0},g.confDefaults.gravity={display:!0,relation:"graph",type:"number",val:.1,options:[1,.95,.9,.85,.8,.75,.7,.65,.6,.55,.5,.45,.4,.35,.3,.25,.2,.15,.1,.05,0],internal:!0},g.confDefaults.linkStrength={display:!0,relation:"graph",type:"number",val:1,options:[1,.95,.9,.85,.8,.75,.7,.65,.6,.55,.5,.45,.4,.35,.3,.25,.2,.15,.1,.05,0],internal:!0},g.confDefaults.friction={display:!0,relation:"graph",type:"number",val:.9,options:[1,.95,.9,.85,.8,.75,.7,.65,.6,.55,.5,.45,.4,.35,.3,.25,.2,.15,.1,.05,0],internal:!0},g.confDefaults.theta={display:!0,relation:"graph",type:"number",val:.8,options:[1,.95,.9,.85,.8,.75,.7,.65,.6,.55,.5,.45,.4,.35,.3,.25,.2,.15,.1,.05,0],internal:!0},g.conf.debug=void 0!==g.confUser.debug&&g.tools.parseBool(g.confUser.debug),g.conf.minNodeRadius=g.confUser.minNodeRadius||g.confDefaults.minNodeRadius.val,g.conf.maxNodeRadius=g.confUser.maxNodeRadius||g.confDefaults.maxNodeRadius.val,g.conf.colorScheme=g.confUser.colorScheme||g.confDefaults.colorScheme.val,g.conf.dragMode=void 0!==g.confUser.dragMode?g.tools.parseBool(g.confUser.dragMode):g.confDefaults.dragMode.val,g.conf.pinMode=void 0!==g.confUser.pinMode?g.tools.parseBool(g.confUser.pinMode):g.confDefaults.pinMode.val,g.conf.nodeEventToStopPinMode=g.confUser.nodeEventToStopPinMode||g.confDefaults.nodeEventToStopPinMode.val,g.conf.onNodeContextmenuPreventDefault=void 0!==g.confUser.onNodeContextmenuPreventDefault?g.tools.parseBool(g.confUser.onNodeContextmenuPreventDefault):g.confDefaults.onNodeContextmenuPreventDefault.val,g.conf.nodeEventToOpenLink=g.confUser.nodeEventToOpenLink||g.confDefaults.nodeEventToOpenLink.val,g.conf.nodeLinkTarget=g.confUser.nodeLinkTarget||g.confDefaults.nodeLinkTarget.val,g.conf.showLabels=void 0!==g.confUser.showLabels?g.tools.parseBool(g.confUser.showLabels):g.confDefaults.showLabels.val,g.conf.wrapLabels=void 0!==g.confUser.wrapLabels?g.tools.parseBool(g.confUser.wrapLabels):g.confDefaults.wrapLabels.val,g.conf.labelSplitCharacter=g.confUser.labelSplitCharacter||g.confDefaults.labelSplitCharacter.val,g.conf.wrappedLabelWidth=g.confUser.wrappedLabelWidth||g.confDefaults.wrappedLabelWidth.val,g.conf.wrappedLabelLineHeight=g.confUser.wrappedLabelLineHeight||g.confDefaults.wrappedLabelLineHeight.val,g.conf.labelsCircular=void 0!==g.confUser.labelsCircular?g.tools.parseBool(g.confUser.labelsCircular):g.confDefaults.labelsCircular.val,g.conf.labelDistance=g.confUser.labelDistance||g.confDefaults.labelDistance.val,g.conf.preventLabelOverlappingOnForceEnd=void 0!==g.confUser.preventLabelOverlappingOnForceEnd?g.tools.parseBool(g.confUser.preventLabelOverlappingOnForceEnd):g.confDefaults.preventLabelOverlappingOnForceEnd.val,g.conf.labelPlacementIterations=g.confUser.labelPlacementIterations||g.confDefaults.labelPlacementIterations.val,g.conf.showTooltips=void 0!==g.confUser.showTooltips?g.tools.parseBool(g.confUser.showTooltips):g.confDefaults.showTooltips.val,g.conf.tooltipPosition=g.confUser.tooltipPosition||g.confDefaults.tooltipPosition.val,g.conf.alignFixedNodesToGrid=void 0!==g.confUser.alignFixedNodesToGrid?g.tools.parseBool(g.confUser.alignFixedNodesToGrid):g.confDefaults.alignFixedNodesToGrid.val,g.conf.gridSize=g.confUser.gridSize&&0',g.status.userAgent=navigator.userAgent,g.status.userAgentIe9To11=!1,(-1!==navigator.appVersion.indexOf("MSIE 9")||-1!==navigator.appVersion.indexOf("MSIE 10")||-1!==g.status.userAgent.indexOf("Trident")&&-1!==g.status.userAgent.indexOf("rv:11"))&&(g.status.userAgentIe9To11=!0,g.tools.logError("Houston, we have a problem - user agent is IE 9, 10 or 11 - we have to provide a fix for markers: http://stackoverflow.com/questions/15588478/internet-explorer-10-not-showing-svg-path-d3-js-graph"))},g.main.setupDom=function(){var t,e;g.dom.body=d3.select("body"),null===document.querySelector("#"+g.dom.containerId)?g.dom.container=g.dom.body.append("div").attr("id",g.dom.containerId):(g.dom.container=d3.select("#"+g.dom.containerId),d3.selectAll("#"+g.dom.containerId+"_tooltip, #"+g.dom.containerId+"_customizing").remove()),null===document.querySelector("#"+g.dom.containerId+" svg")?g.dom.svg=g.dom.container.append("svg"):(g.dom.svg=d3.select("#"+g.dom.containerId+" svg"),d3.selectAll("#"+g.dom.containerId+" svg *").remove()),g.dom.svgParent=d3.select(g.dom.svg.node().parentNode),g.conf.setDomParentPaddingToZero&&g.dom.svgParent.style("padding","0"),t=g.tools.getGraphWidth(),e=g.tools.getGraphHeight(),g.dom.svg.attr("class","net_gobrechts_d3_force").classed("border",g.conf.showBorder).attr("width",t).attr("height",e),g.conf.useDomParentWidth&&g.dom.svg.attr("width",g.tools.getSvgParentInnerWidth()),g.dom.defs=g.dom.svg.append("defs"),g.dom.graphOverlay=g.dom.svg.append("g").attr("class","graphOverlay"),g.dom.graphOverlaySizeHelper=g.dom.graphOverlay.append("rect").attr("class","graphOverlaySizeHelper"),g.dom.graph=g.dom.graphOverlay.append("g").attr("class","graph"),g.dom.legend=g.dom.svg.append("g").attr("class","legend"),g.dom.loading=g.dom.svg.append("svg:g").attr("class","loading").style("display","none"),g.dom.loadingRect=g.dom.loading.append("svg:rect").attr("width",t).attr("height",e),g.dom.loadingText=g.dom.loading.append("svg:text").attr("x",t/2).attr("y",e/2).text("Loading..."),g.dom.defs.append("svg:marker").attr("id",g.dom.containerId+"_highlighted").attr("class","highlighted").attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").attr("markerUnits","strokeWidth").append("svg:path").attr("d","M0,0 L10,5 L0,10"),g.dom.defs.append("svg:marker").attr("id",g.dom.containerId+"_normal").attr("class","normal").attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").attr("markerUnits","strokeWidth").append("svg:path").attr("d","M0,0 L10,5 L0,10"),null===document.querySelector("#"+g.dom.containerId+"_tooltip")?g.dom.tooltip=g.dom.body.append("div").attr("id",g.dom.containerId+"_tooltip").attr("class","net_gobrechts_d3_force_tooltip").style("top","0px").style("left","0px"):g.dom.tooltip=d3.select("#"+g.dom.containerId+"_tooltip")},g.main.setupFunctionReferences=function(){g.main.force=d3.layout.force().on("start",function(){g.tools.log("Force started."),g.status.customize&&g.dom.customizePositions&&g.dom.customizePositions.text("Force started - wait for end event to show positions..."),g.status.forceTickCounter=0,g.status.forceStartTime=(new Date).getTime(),g.status.forceRunning=!0,g.tools.log("Event forcestart triggered."),g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"net_gobrechts_d3_force_forcestart"),"function"==typeof g.conf.onForceStartFunction&&g.conf.onForceStartFunction.call(g.dom.svg)}).on("tick",function(){g.status.forceTickCounter+=1,g.status.userAgentIe9To11&&g.conf.showLinkDirection&&(g.main.links.each(function(){this.parentNode.insertBefore(this,this)}),g.main.selfLinks.each(function(){this.parentNode.insertBefore(this,this)})),g.main.selfLinks.attr("transform",function(t){return"translate("+t.source.x+","+t.source.y+")"}),g.main.links.attr("x1",function(t){return g.tools.adjustSourceX(t)}).attr("y1",function(t){return g.tools.adjustSourceY(t)}).attr("x2",function(t){return g.tools.adjustTargetX(t)}).attr("y2",function(t){return g.tools.adjustTargetY(t)}),g.conf.showLabels&&(g.main.labels.attr("x",function(t){return t.x}).attr("y",function(t){return t.y-t.radius-g.conf.labelDistance}),g.status.wrapLabelsOnNextTick&&(g.main.labels.call(g.tools.wrapLabels,g.conf.wrappedLabelWidth),g.status.wrapLabelsOnNextTick=!1),g.conf.wrapLabels&&g.main.labels.each(function(){var t=d3.select(this),e=t.attr("y")-(t.attr("lines")-1)*g.status.labelFontSize*g.conf.wrappedLabelLineHeight;t.attr("y",e).selectAll("tspan").attr("x",t.attr("x")).attr("y",e)}),g.main.labelPaths.attr("transform",function(t){return"translate("+t.x+","+t.y+")"}),g.main.linkLabelPaths.attr("d",function(t){return"M "+t.source.x+" "+t.source.y+" L "+t.target.x+" "+t.target.y}),g.main.linkLabels.attr("transform",function(t,e){if(t.target.xg.conf.forceTimeLimit&&g.main.force.stop()}).on("end",function(){g.conf.showLabels&&g.conf.preventLabelOverlappingOnForceEnd&&(g.data.simulatedAnnealingLabels=[],g.data.simulatedAnnealingAnchors=[],g.main.labels.each(function(t,e){var o=d3.select(this);g.data.simulatedAnnealingLabels[e]={width:this.getBBox().width,height:this.getBBox().height,x:t.x,y:o.attr("y")-(o.attr("lines")-1)*g.status.labelFontSize*g.conf.wrappedLabelLineHeight}}),g.main.nodes.filter(function(t){return!t.LABELCIRCULAR&&!g.conf.labelsCircular}).each(function(t,e){g.data.simulatedAnnealingAnchors[e]={x:t.x,y:t.y-t.radius-g.conf.labelDistance,r:.5}}),g.lib.labelerPlugin().label(g.data.simulatedAnnealingLabels).anchor(g.data.simulatedAnnealingAnchors).width(g.tools.getGraphWidth()).height(g.tools.getGraphHeight()).start(g.conf.labelPlacementIterations),g.main.labels.each(function(t,e){var o=d3.select(this),n=g.data.simulatedAnnealingLabels[e].x,a=g.data.simulatedAnnealingLabels[e].y;g.conf.wrapLabels?(a-=(o.attr("lines")-1)*g.status.labelFontSize*g.conf.wrappedLabelLineHeight,o.transition().duration(800).attr("x",n).attr("y",a).selectAll("tspan").attr("x",n).attr("y",a)):o.transition().duration(800).attr("x",n).attr("y",a)})),g.status.forceRunning=!1;var t=(new Date).getTime()-g.status.forceStartTime,e=(t/1e3).toFixed(1),o=Math.round(g.status.forceTickCounter/(t/1e3)),n=Math.round(t/g.status.forceTickCounter);g.status.customize&&g.dom.customizePositions&&g.dom.customizePositions.text(JSON.stringify(p.positions())),g.tools.log("Force ended."),g.tools.log(e+" seconds, "+g.status.forceTickCounter+" ticks to cool down ("+o+" ticks/s, "+n+" ms/tick)."),g.tools.log("Event forceend triggered."),g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"net_gobrechts_d3_force_forceend"),g.conf.zoomToFitOnForceEnd?p.zoomToFit():g.conf.zoomMode||p.center(),"function"==typeof g.conf.onForceEndFunction&&g.conf.onForceEndFunction.call(g.dom.svg)}),g.main.drag=g.main.force.drag(),g.main.lasso=g.lib.lassoPlugin().closePathDistance(100).closePathSelect(!0).hoverSelect(!0).area(g.dom.graphOverlay).pathContainer(g.dom.svg),g.main.zoom=d3.behavior.zoom(),g.main.zoomed=function(){g.conf.transform={translate:g.main.zoom.translate(),scale:g.main.zoom.scale()},g.dom.graph.attr("transform","translate("+g.main.zoom.translate()+")scale("+g.main.zoom.scale()+")"),g.tools.writeConfObjectIntoWizard()},g.main.interpolateZoom=function(t,n,e){if(g.status.graphStarted)return ng.conf.maxZoomFactor&&(n=g.conf.maxZoomFactor),d3.transition().duration(e).tween("zoom",function(){var e=d3.interpolate(g.main.zoom.translate(),t),o=d3.interpolate(g.main.zoom.scale(),n);return function(t){g.main.zoom.scale(o(t)).translate(e(t)),g.main.zoomed()}})}},g.tools.parseBool=function(t){switch(String(t).trim().toLowerCase()){case"true":case"yes":case"1":return!0;case"false":case"no":case"0":case"":default:return!1}},g.tools.parseXml=function(t){var e=null;if(t)if(window.DOMParser)try{e=(new DOMParser).parseFromString(t,"text/xml")}catch(t){e=null,g.tools.logError("DOMParser - unable to parse XML: "+t.message)}else if(window.ActiveXObject)try{(e=new ActiveXObject("Microsoft.XMLDOM")).async=!1,e.loadXML(t)||g.tools.logError("Microsoft.XMLDOM - unable to parse XML: "+e.parseError.reason+e.parseError.srcText)}catch(t){e=null,g.tools.logError("Microsoft.XMLDOM - unable to parse XML: "+t.message)}return e},g.tools.xmlToJson=function(t){var n,e,a,o,s,r=null,i=function(t){if(n={},0g.conf.gridSize/2?t-o+g.conf.gridSize:t-o:e<=t?(n=e-(o=e%g.conf.gridSize))===e&&(n-=g.conf.gridSize):t<=g.conf.gridSize/2?n=g.conf.gridSize:e<=(n=(o=t%g.conf.gridSize)>g.conf.gridSize/2?t-o+g.conf.gridSize:t-o)&&(n-=g.conf.gridSize),n},g.tools.adjustSourceX=function(t){return t.source.x+Math.cos(g.tools.calcAngle(t))*t.source.radius},g.tools.adjustSourceY=function(t){return t.source.y+Math.sin(g.tools.calcAngle(t))*t.source.radius},g.tools.adjustTargetX=function(t){return t.target.x-Math.cos(g.tools.calcAngle(t))*t.target.radius},g.tools.adjustTargetY=function(t){return t.target.y-Math.sin(g.tools.calcAngle(t))*t.target.radius},g.tools.calcAngle=function(t){return Math.atan2(t.target.y-t.source.y,t.target.x-t.source.x)},g.tools.getSelfLinkPath=function(t){var e=t.source.radius,o=t.source.radius+g.conf.selfLinkDistance,n={source:{x:0,y:0,radius:e},target:{x:0-o/2,y:0+o,radius:e}},a={source:{x:0+o/2,y:0+o,radius:e},target:{x:0,y:0,radius:e}},s="M"+g.tools.adjustSourceX(n)+","+g.tools.adjustSourceY(n);return s+=" L"+(0-o/2)+","+(0+o),s+=" A"+o+","+o+" 0 0,0 "+(0+o/2)+","+(0+o),s+=" L"+g.tools.adjustTargetX(a)+","+g.tools.adjustTargetY(a)},g.tools.getLabelPath=function(t){var e=t.radius+g.conf.labelDistance,o="M"+(0-e)+",0";return o+=" a"+e+","+e+" 0 0,1 "+2*e+",0",o+=" a"+e+","+e+" 0 0,1 -"+2*e+",0"},g.tools.getPatternId=function(t){return g.dom.containerId+"_pattern_"+t.ID},g.tools.getLinkId=function(t){return t.FROMID+"_"+t.TOID},g.tools.getPathId=function(t){return g.dom.containerId+"_path_"+g.tools.getLinkId(t)},g.tools.openLink=function(t){"none"===g.conf.nodeLinkTarget?window.location.assign(t.LINK):"nodeID"===g.conf.nodeLinkTarget?window.open(t.LINK,t.ID).focus():"domContainerID"===g.conf.nodeLinkTarget?window.open(t.LINK,g.dom.containerId).focus():window.open(t.LINK,g.conf.nodeLinkTarget).focus()},g.tools.applyConfigurationObject=function(t){var e;for(e in t)t.hasOwnProperty(e)&&g.conf.hasOwnProperty(e)&&t[e]!==g.conf[e]&&p[e](t[e])},g.tools.zoomEventProxy=function(t){return function(){g.conf.dragMode&&(!g.conf.dragMode||"circle"===d3.event.target.tagName)||!g.conf.zoomMode||d3.event.altKey||d3.event.shiftKey||t.apply(this,arguments)}},g.tools.lassoEventProxy=function(t){return function(){g.conf.dragMode&&"circle"===d3.event.target.tagName||!g.conf.lassoMode||g.conf.zoomMode&&!d3.event.altKey&&!d3.event.shiftKey||t.apply(this,arguments)}},g.tools.showTooltip=function(t){var e;g.dom.tooltip.html(t).style("display","block"),"svgTopLeft"===g.conf.tooltipPosition?(e=g.tools.getOffsetRect(g.dom.svg.node()),g.dom.tooltip.style("top",e.top+(g.dom.svg.style("border-width")?parseInt(g.dom.svg.style("border-width")):1)+"px").style("left",e.left+(g.dom.svg.style("border-width")?parseInt(g.dom.svg.style("border-width")):1)+"px")):"svgTopRight"===g.conf.tooltipPosition?(e=g.tools.getOffsetRect(g.dom.svg.node()),g.dom.tooltip.style("top",e.top+parseInt(g.dom.svg.style("border-width")?parseInt(g.dom.svg.style("border-width")):1)+"px").style("left",e.left+parseInt(g.dom.svg.style("width"))+parseInt(g.dom.svg.style("border-width")?parseInt(g.dom.svg.style("border-width")):1)-parseInt(g.dom.tooltip.style("width"))-2*parseInt(g.dom.tooltip.style("border-width")?parseInt(g.dom.tooltip.style("border-width")):0)-parseInt(g.dom.tooltip.style("padding-left"))-parseInt(g.dom.tooltip.style("padding-right"))+"px")):g.dom.tooltip.style("left",d3.event.pageX+10+"px").style("top",d3.event.pageY+"px")},g.tools.hideTooltip=function(){g.dom.tooltip.style("display","none")},g.tools.onLinkClick=function(t){if(d3.event.defaultPrevented)return null;g.tools.log("Event linkclick triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_linkclick",t),"function"==typeof g.conf.onLinkClickFunction&&g.conf.onLinkClickFunction.call(this,d3.event,t)},g.tools.getMarkerUrl=function(t){return g.conf.showLinkDirection?"url(#"+g.dom.containerId+"_"+(t.COLOR?t.COLOR:"normal")+")":null},g.tools.getMarkerUrlHighlighted=function(){return g.conf.showLinkDirection?"url(#"+g.dom.containerId+"_highlighted)":null},g.tools.onLinkMouseenter=function(t){g.conf.showTooltips&&t.INFOSTRING&&g.tools.showTooltip(t.INFOSTRING)},g.tools.onLinkMouseleave=function(){g.conf.showTooltips&&g.tools.hideTooltip()},g.tools.onNodeMouseenter=function(e){g.main.nodes.classed("highlighted",function(t){return g.tools.neighboring(t,e)}),g.main.links.classed("highlighted",function(t){return t.source.ID===e.ID||t.target.ID===e.ID}).style("marker-end",function(t){return t.source.ID===e.ID||t.target.ID===e.ID?g.tools.getMarkerUrlHighlighted(t):g.tools.getMarkerUrl(t)}),g.main.selfLinks.classed("highlighted",function(t){return t.FROMID===e.ID}).style("marker-end",function(t){return t.source.ID===e.ID||t.target.ID===e.ID?g.tools.getMarkerUrlHighlighted(t):g.tools.getMarkerUrl(t)}),g.conf.showLabels&&(g.main.labels.classed("highlighted",function(t){return t.ID===e.ID}),g.main.labelsCircular.classed("highlighted",function(t){return t.ID===e.ID})),d3.select(this).classed("highlighted",!0),g.tools.log("Event nodemouseenter triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_mouseenter",e),"function"==typeof g.conf.onNodeMouseenterFunction&&g.conf.onNodeMouseenterFunction.call(this,d3.event,e),g.conf.showTooltips&&e.INFOSTRING&&g.tools.showTooltip(e.INFOSTRING)},g.tools.onNodeMouseleave=function(t){g.main.nodes.classed("highlighted",!1),g.main.links.classed("highlighted",!1).style("marker-end",g.tools.getMarkerUrl),g.main.selfLinks.classed("highlighted",!1).style("marker-end",g.tools.getMarkerUrl),g.conf.showLabels&&(g.main.labels.classed("highlighted",!1),g.main.labelsCircular.classed("highlighted",!1)),g.tools.log("Event nodemouseleave triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_mouseleave",t),"function"==typeof g.conf.onNodeMouseleaveFunction&&g.conf.onNodeMouseleaveFunction.call(this,d3.event,t),g.conf.showTooltips&&g.tools.hideTooltip()},g.tools.onNodeClick=function(t){if(d3.event.defaultPrevented)return null;t.LINK&&"click"===g.conf.nodeEventToOpenLink&&g.tools.openLink(t),"click"===g.conf.nodeEventToStopPinMode&&d3.select(this).classed("fixed",t.fixed=0),g.tools.log("Event nodeclick triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_click",t),"function"==typeof g.conf.onNodeClickFunction&&g.conf.onNodeClickFunction.call(this,d3.event,t)},g.tools.onNodeDblclick=function(t){t.LINK&&"dblclick"===g.conf.nodeEventToOpenLink&&g.tools.openLink(t),"dblclick"===g.conf.nodeEventToStopPinMode&&d3.select(this).classed("fixed",t.fixed=0),g.tools.log("Event nodedblclick triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_dblclick",t),"function"==typeof g.conf.onNodeDblclickFunction&&g.conf.onNodeDblclickFunction.call(this,d3.event,t)},g.tools.onNodeContextmenu=function(t){g.conf.onNodeContextmenuPreventDefault&&d3.event.preventDefault(),t.LINK&&"contextmenu"===g.conf.nodeEventToOpenLink&&g.tools.openLink(t),"contextmenu"===g.conf.nodeEventToStopPinMode&&d3.select(this).classed("fixed",t.fixed=0),g.tools.log("Event nodecontextmenu triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_contextmenu",t),"function"==typeof g.conf.onNodeContextmenuFunction&&g.conf.onNodeContextmenuFunction.call(this,d3.event,t)},g.tools.onLassoStart=function(t){var e={numberOfSelectedNodes:0,idsOfSelectedNodes:null};e.numberOfNodes=t.size(),e.nodes=t,g.tools.log("Event lassostart triggered."),g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"net_gobrechts_d3_force_lassostart",e),"function"==typeof g.conf.onLassoStartFunction&&g.conf.onLassoStartFunction.call(g.dom.svg,d3.event,e)},g.tools.onLassoEnd=function(t){var e={numberOfSelectedNodes:0,idsOfSelectedNodes:""};e.numberOfNodes=t.size(),(e.nodes=t).each(function(t){t.selected&&(e.idsOfSelectedNodes+=t.ID+":",e.numberOfSelectedNodes++)}),e.idsOfSelectedNodes=0'+l+""),a=n.append("td"),s=a.append("select").attr("id",g.dom.containerId+"_"+l).attr("name",l).attr("value",g.conf[l]).attr("tabindex",d+1).classed("warning",g.confDefaults[l].internal).on("change",u),i=!1,f(l),i||(s.append("option").attr("value",g.conf[l]).attr("selected","selected").text(g.conf[l]),g.confDefaults[l].options.push(g.conf[l])),"pinMode"===l&&a.append("a").text(" release all").attr("href",null).on("click",c));g.dom.customizeOptionsTable.style("width",d3.select(g.dom.customizeOptionsTable).node()[0][0].clientWidth+"px"),o.append("span").html("
"),(o=e.append("td").style("vertical-align","top").style("padding-left","5px")).append("span").html('Your Configuration Object

'+(g.status.apexPluginId?"To save your options please copy
this to your plugin region attributes.
Only non-default options are shown.

":"Use this to initialize your graph.
Only non-default options are shown.

")),g.dom.customizeConfObject=o.append("textarea").attr("tabindex",d+5).attr("readonly","readonly"),o.append("span").html("

Current Positions
"),g.dom.customizePositions=o.append("textarea").attr("tabindex",d+6).attr("readonly","readonly").text(g.status.forceRunning?"Force started - wait for end event to show positions...":JSON.stringify(p.positions())),o.append("span").html("

Debug Log (descending)
"),g.dom.customizeLog=o.append("textarea").attr("tabindex",d+7).attr("readonly","readonly"),o=(e=t.append("tr")).append("td").attr("colspan",2).html("Copyrights:"),o=(e=t.append("tr")).append("td").attr("colspan",2).html('
D3 Force APEX Plugin ('+g.version+')
Ottmar Gobrecht
D3.js ('+d3.version+') and D3 Lasso Plugin (modified)
Mike Bostock
D3 Labeler Plugin (automatic label placement using simulated annealing)
Evan Wang
'),g.tools.createCustomizeMenu(g.status.customizeCurrentMenu),g.tools.writeConfObjectIntoWizard(),g.status.customizeCurrentTabPosition&&document.getElementById(g.status.customizeCurrentTabPosition).focus()}else g.tools.removeCustomizeWizard(),g.tools.createCustomizeLink()},g.tools.removeCustomizeWizard=function(){d3.select("#"+g.dom.containerId+"_customizing").remove()},g.tools.createCustomizeMenu=function(t){g.status.customizeCurrentMenu=t,g.dom.customizeMenu.selectAll("*").remove(),g.dom.customizeMenu.append("span").text("Show options for:"),"nodes"===g.status.customizeCurrentMenu?(g.dom.customizeMenu.append("span").style("font-weight","bold").style("margin-left","10px").text("NODES"),g.dom.customizeOptionsTable.selectAll("tr.node-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.label-related,tr.link-related,tr.graph-related").classed("hidden",!0)):g.dom.customizeMenu.append("a").style("font-weight","bold").style("margin-left","10px").text("NODES").attr("tabindex",2).on("click",function(){g.tools.createCustomizeMenu("nodes"),g.dom.customizeOptionsTable.selectAll("tr.node-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.label-related,tr.link-related,tr.graph-related").classed("hidden",!0)}).on("keydown",function(){13===d3.event.keyCode&&(g.tools.createCustomizeMenu("nodes"),g.dom.customizeOptionsTable.selectAll("tr.node-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.label-related,tr.link-related,tr.graph-related").classed("hidden",!0))}),"labels"===g.status.customizeCurrentMenu?(g.dom.customizeMenu.append("span").style("font-weight","bold").style("margin-left","10px").text("LABELS"),g.dom.customizeOptionsTable.selectAll("tr.label-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.link-related,tr.graph-related").classed("hidden",!0)):g.dom.customizeMenu.append("a").style("font-weight","bold").style("margin-left","10px").text("LABELS").attr("tabindex",2).on("click",function(){g.tools.createCustomizeMenu("labels"),g.dom.customizeOptionsTable.selectAll("tr.label-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.link-related,tr.graph-related").classed("hidden",!0)}).on("keydown",function(){13===d3.event.keyCode&&(g.tools.createCustomizeMenu("labels"),g.dom.customizeOptionsTable.selectAll("tr.label-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.link-related,tr.graph-related").classed("hidden",!0))}),"links"===g.status.customizeCurrentMenu?(g.dom.customizeMenu.append("span").style("font-weight","bold").style("margin-left","10px").text("LINKS"),g.dom.customizeOptionsTable.selectAll("tr.link-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.graph-related").classed("hidden",!0)):g.dom.customizeMenu.append("a").style("font-weight","bold").style("margin-left","10px").text("LINKS").attr("tabindex",3).on("click",function(){g.tools.createCustomizeMenu("links"),g.dom.customizeOptionsTable.selectAll("tr.link-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.graph-related").classed("hidden",!0)}).on("keydown",function(){13===d3.event.keyCode&&(g.tools.createCustomizeMenu("links"),g.dom.customizeOptionsTable.selectAll("tr.link-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.graph-related").classed("hidden",!0))}),"graph"===g.status.customizeCurrentMenu?(g.dom.customizeMenu.append("span").style("font-weight","bold").style("margin-left","10px").text("GRAPH"),g.dom.customizeOptionsTable.selectAll("tr.graph-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.link-related").classed("hidden",!0)):g.dom.customizeMenu.append("a").style("font-weight","bold").style("margin-left","10px").text("GRAPH").attr("tabindex",4).on("click",function(){g.tools.createCustomizeMenu("graph"),g.dom.customizeOptionsTable.selectAll("tr.graph-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.link-related").classed("hidden",!0)}).on("keydown",function(){13===d3.event.keyCode&&(g.tools.createCustomizeMenu("graph"),g.dom.customizeOptionsTable.selectAll("tr.graph-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.link-related").classed("hidden",!0))}),g.dom.customizeMenu.append("span").html("

")},g.tools.wrapLabels=function(t,u){t.each(function(t,e){var o=d3.select(this);if(0===e&&(g.status.labelFontSize=parseInt(o.style("font-size"))),!this.hasAttribute("lines")){var n,a=o.text().split("none"!==g.conf.labelSplitCharacter?g.conf.labelSplitCharacter:/\s+/).reverse(),s=[],r=0,i=g.status.labelFontSize*g.conf.wrappedLabelLineHeight,l=o.attr("x"),d=o.attr("y"),c=o.text(null).append("tspan").attr("x",l).attr("y",d).attr("dy","0px");if("none"!==g.conf.labelSplitCharacter)for(;n=a.pop();)c=o.append("tspan").attr("x",l).attr("y",d).attr("dy",++r*i+0+"px").text(n);else for(;n=a.pop();)s.push(n),c.text(s.join(" ")),c.node().getComputedTextLength()>u&&(s.pop(),c.text(s.join(" ")),s=[n],c=o.append("tspan").attr("x",l).attr("y",d).attr("dy",++r*i+0+"px").text(n));o.attr("lines",r+1)}})},g.lib.labelerPlugin=function(){var u,h=[],m=[],f=1,g=1,e={},p=!1,L=function(t){var e=h.length,o=0,n=h[t].x-m[t].x,a=m[t].y-h[t].y,s=Math.sqrt(n*n+a*a);0f&&(h[o].x=n),h[o].x<0&&(h[o].x=n),h[o].y>g&&(h[o].y=a),h[o].y<0&&(h[o].y=a);var s=(p?u(o,h,m):L(o))-e;Math.random()f&&(h[o].x=n),h[o].x<0&&(h[o].x=n),h[o].y>g&&(h[o].y=a),h[o].y<0&&(h[o].y=a);var c=(p?u(o,h,m):L(o))-e;Math.random()t.lassoPoint.cx&&(t.lassoPoint.edges.right=t.lassoPoint.edges.right+1),u.xt.lassoPoint.cx&&(t.lassoPoint.close_edges.right=1),Math.round(c.y)!==Math.round(l.y)&&Math.round(c.x)