dc.graph
Version:
Graph visualizations integrated with crossfilter and dc.js
21 lines (20 loc) • 213 kB
JavaScript
/*!
* dc.graph 0.9.8
* http://dc-js.github.io/dc.graph.js/
* Copyright 2015-2019 AT&T Intellectual Property & the dc.graph.js Developers
* https://github.com/dc-js/dc.graph.js/blob/master/AUTHORS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
!function(){function e(re,oe,ae){"use strict";var ie={version:"0.9.8",constants:{CHART_CLASS:"dc-graph"}};function ue(e){return e.orig}function le(e){return e}var ce=function(e,n){void 0===n?n=ue:!1===n&&(n=le);var t=e,r=null,o=[],a=function(e){return arguments.length?(r&&r(e),t=e,this):t};return a.cascade=function(e,t){for(var n=0;n<o.length;++n){if(o[n].n===e)return t?o[n].f=t:o.splice(n,1),a;if(o[n].n>e)return o.splice(n,0,{n:e,f:t}),a}return o.push({n:e,f:t}),a},a._eval=function(e,t){return 0!==t&&o.length?o[t-1].f(e,function(){return a._eval(e,t-1)}):ie.functor_wrap(a(),n)(e)},a.eval=function(e){return a._eval(e,o.length)},a.react=function(e){return arguments.length?(r=e,this):r},a};function se(){var r={},o=function(e,t){if(1===arguments.length)return r[e];if(o.reject){var n=o.reject(e,t);if(n)return console.groupCollapsed(n),console.trace(),console.groupEnd(),this}return r[e]===t||(r[e]&&r[e].parent(null),(r[e]=t)&&t.parent(this)),this};return o.enum=function(){return Object.keys(r)},o.nameOf=function(t){var e=Object.entries(r).find(function(e){return e[1]==t});return e?e[0]:null},o}function de(e,t){var n=ce(t),r=function(){return arguments.length?(console.warn(e),n.apply(ce,arguments),this):n()};return["cascade","_eval","eval","react"].forEach(function(e){r[e]=n[e]}),r}function fe(e,t){var n=!1;return function(){n||("trace"===e?(console.groupCollapsed(t),console.trace(),console.groupEnd()):console[e](t),n=!0)}}function ge(e,t,n){var r=fe(e,t);return function(){return r(),n.apply(this,arguments)}}function pe(e,t){return ge("warn",e,t)}function K(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})}function A(e){try{return e.getBBox()}catch(e){return{x:0,y:0,width:0,height:0}}}function n(n,r){return function(e,t){return n(e)?r(e):t()}}function t(n,r){return function(e,t){return re.interpolate(t(e),r(e))(n(e))}}function f(e,t,n){var r={};for(var o in t)r[o]=n(e,ye(t[o]));return r}function k(e,t){return f(e,t,n)}function w(e,t,n){var r={},o={},a=[];for(var i in n)/^node/.test(i)?r[i]=n[i]:/^edge/.test(i)?o[i]=n[i]:a.push(i);a.length&&console.error('only know how to deal with properties that start with "node" or "edge"',a);var u=e?k(e,r):{};return t&&Object.assign(u,k(t,o)),u}function he(o){return function(e,t,n){for(var r in n){if(!o[r])throw new Error("unknown attribute "+r);o[r].cascade(e,t?n[r]:null)}return o}}function ye(e){return ie.functor_wrap(e,ue)}"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),r=1;r<arguments.length;r++){var o=arguments[r];if(null!=o)for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(n[a]=o[a])}return n},writable:!0,configurable:!0}),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(e,t){if(null==this)throw new TypeError('"this" is null or not defined');var n=Object(this),r=n.length>>>0;if(0===r)return!1;var o,a,i=0|t,u=Math.max(0<=i?i:r-Math.abs(i),0);for(;u<r;){if((o=n[u])===(a=e)||"number"==typeof o&&"number"==typeof a&&isNaN(o)&&isNaN(a))return!0;u++}return!1}}),Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}),Object.values=Object.values?Object.values:function(t){var e=Object.prototype.toString.call(t);if(null==t)throw new TypeError("Cannot convert undefined or null to object");if(~["[object String]","[object Object]","[object Array]","[object Function]"].indexOf(e)){if(Object.keys)return Object.keys(t).map(function(e){return t[e]});var n=[];for(var r in t)t.hasOwnProperty(r)&&n.push(t[r]);return n}return[]},ie.functor_wrap=function(t,n){return"function"==typeof t?n?function(e){return t(n(e))}:t:function(){return t}};var i={1:"L",2:"Q",3:"C"};function g(e,t,n){for(var r=["M",e[0].x,",",e[0].y],o=t,a=1;a<e.length;++a)(isNaN(e[a].x)||isNaN(e[a].y))&&!0,r.push(o===t?i[t]:" ",e[a].x,",",e[a].y),0==--o&&(o=t);return o!=t&&console.log("warning: pts.length didn't match bezian degree",e,t),n&&r.push("Z"),r.join("")}Math.hypot=Math.hypot||function(){for(var e=0,t=arguments.length,n=0;n<t;n++){if(arguments[n]===1/0||arguments[n]===-1/0)return 1/0;e+=arguments[n]*arguments[n]}return Math.sqrt(e)},Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var r=arguments[1],o=0;o<n;){var a=t[o];if(e.call(r,a,o,t))return a;o++}}});var r,o=function(){if(void 0===r){r=null;var e="dc.graph.js",t=document.getElementsByTagName("script");if(t&&0<t.length)for(var n in t)if(t[n].src&&t[n].src.match(new RegExp(e+"$"))){r=t[n].src.replace(new RegExp("(.*)"+e+"$"),"$1");break}}return r};function T(e){return Promise.resolve(e)}ie.event_coords=function(e){var t=e.root().node().getBoundingClientRect();return e.invertCoord([re.event.clientX-t.left,re.event.clientY-t.top])};var E=-1!==navigator.platform.toUpperCase().indexOf("MAC");function a(e,t){return!!re.select(e).classed(t)||e.parentElement&&a(e.parentElement,t)}function ve(r,e,t,o,a,i,n){i||(i=function(e,t){}),n||(n=function(e){});var u={};var l=e.map(function(e){var t=o(e);r[t]||i(t,r[t]={},e);var n=r[t];return a(n,e),u[t]=!0,n});for(var c in t&&t.forEach(function(e){r[e]||(i(e,r[e]={},null),a(r[e],null)),u[e]||(l.push(r[e]),u[e]=!0)}),r)u[c]||(n(c,r[c]),delete r[c]);return l}void 0===SVGElement.prototype.contains&&(SVGElement.prototype.contains=HTMLDivElement.prototype.contains),ie.depth_first_traversal=function(d){return function(e,t){d.init&&d.init(),d.tree&&(t=t.filter(function(e){return d.tree(e)}));var n,i={},u=t.reduce(function(e,t){var n=d.sourceid(t),r=d.targetid(t);return e[n]||(e[n]=[]),e[n].push(t),i[r]=(i[r]||0)+1,e},{}),l=e.reduce(function(e,t){return e[d.nodeid(t)]=t,e},{}),c=[],s={};d.root?n=e.filter(function(e){return d.root(e)}):(n=e.filter(function(e){return!i[d.nodeid(e)]}),e.length&&!n.length&&(n=[e[0]])),n.forEach(function(e,t){t&&d.sib&&d.sib(!0,n[t-1],e),d.push&&d.push(),function r(e,o){var a=d.nodeid(e);s[a]?d.skip&&d.skip(e,i[a]):(c[o]||(c[o]=[]),d.place&&d.place(e,o,c[o]),c[o].push(e),s[a]=!0,u[a]&&u[a].forEach(function(e,t){var n=l[d.targetid(e)];t&&d.sib&&d.sib(!1,l[d.targetid(u[a][t-1])],n),d.push&&d.push(),r(n,o+1)}),d.pop&&d.pop(e))}(e,d.row&&d.row(e)||0)}),d.finish(c)}},ie.undirected_dfs=function(u){return function(e,t){var r=t.reduce(function(e,t){var n=u.sourceid(t),r=u.targetid(t);return e[n]||(e[n]=[]),e[r]||(e[r]=[]),e[n].push(r),e[r].push(n),e},{}),o=e.reduce(function(e,t){return e[u.nodeid(t)]=t,e},{}),a={};var i=0;e.forEach(function(e){a[u.nodeid(e)]||(u.comp&&u.comp(i),function t(e){var n=u.nodeid(e);u.node(i,e),a[n]=!0,r[n]&&r[n].forEach(function(e){a[e]||t(o[e])})}(e),++i)})}};var u=1e-7;function s(e,t,n){return e-u<=t&&t<=n+u}function l(e,t,n,r,o,a,i,u){var l=((e*r-t*n)*(o-i)-(e-n)*(o*u-a*i))/((e-n)*(a-u)-(t-r)*(o-i)),c=((e*r-t*n)*(a-u)-(t-r)*(o*u-a*i))/((e-n)*(a-u)-(t-r)*(o-i));if(isNaN(l)||isNaN(c))return!1;if(n<=e){if(!s(n,l,e))return!1}else if(!s(e,l,n))return!1;if(r<=t){if(!s(r,c,t))return!1}else if(!s(t,c,r))return!1;if(i<=o){if(!s(i,l,o))return!1}else if(!s(o,l,i))return!1;if(u<=a){if(!s(u,c,a))return!1}else if(!s(a,c,u))return!1;return{x:l,y:c}}function c(e,t,n,r,o){for(var a=0;a<e.length;++a){var i=a===e.length-1?0:a+1,u=l(e[a].x,e[a].y,e[i].x,e[i].y,t,n,r,o);if(u)return u}return null}ie.shape_presets={egg:{generator:"polygon",preset:function(){return{sides:100,distortion:-.25}}},triangle:{generator:"polygon",preset:function(){return{sides:3}}},rectangle:{generator:"polygon",preset:function(){return{sides:4}}},diamond:{generator:"polygon",preset:function(){return{sides:4,rotation:45}}},trapezium:{generator:"polygon",preset:function(){return{sides:4,distortion:-.5}}},parallelogram:{generator:"polygon",preset:function(){return{sides:4,skew:.5}}},pentagon:{generator:"polygon",preset:function(){return{sides:5}}},hexagon:{generator:"polygon",preset:function(){return{sides:6}}},septagon:{generator:"polygon",preset:function(){return{sides:7}}},octagon:{generator:"polygon",preset:function(){return{sides:8}}},invtriangle:{generator:"polygon",preset:function(){return{sides:3,rotation:180}}},invtrapezium:{generator:"polygon",preset:function(){return{sides:4,distortion:.5}}},square:{generator:"polygon",preset:function(){return{sides:4,regular:!0}}},plain:{generator:"rounded-rect",preset:function(){return{noshape:!0}}},house:{generator:"elaborated-rect",preset:function(){return{get_points:function(e,t){return[{x:e,y:2*t/3},{x:e,y:-t/2},{x:0,y:-t},{x:-e,y:-t/2},{x:-e,y:2*t/3}]},minrx:30}}},invhouse:{generator:"elaborated-rect",preset:function(){return{get_points:function(e,t){return[{x:e,y:t/2},{x:e,y:2*-t/3},{x:-e,y:2*-t/3},{x:-e,y:t/2},{x:0,y:t}]},minrx:30}}},rarrow:{generator:"elaborated-rect",preset:function(){return{get_points:function(e,t){return[{x:e,y:t},{x:e,y:1.5*t},{x:e+1.5*t,y:0},{x:e,y:1.5*-t},{x:e,y:-t},{x:-e,y:-t},{x:-e,y:t}]},minrx:30}}},larrow:{generator:"elaborated-rect",preset:function(){return{get_points:function(e,t){return[{x:-e,y:t},{x:-e,y:1.5*t},{x:-e-1.5*t,y:0},{x:-e,y:1.5*-t},{x:-e,y:-t},{x:e,y:-t},{x:e,y:t}]},minrx:30}}},rpromoter:{generator:"elaborated-rect",preset:function(){return{get_points:function(e,t){return[{x:e,y:t},{x:e,y:1.5*t},{x:e+1.5*t,y:0},{x:e,y:1.5*-t},{x:e,y:-t},{x:-e,y:-t},{x:-e,y:1.5*t},{x:0,y:1.5*t},{x:0,y:t}]},minrx:30}}},lpromoter:{generator:"elaborated-rect",preset:function(){return{get_points:function(e,t){return[{x:-e,y:t},{x:-e,y:1.5*t},{x:-e-1.5*t,y:0},{x:-e,y:1.5*-t},{x:-e,y:-t},{x:e,y:-t},{x:e,y:1.5*t},{x:0,y:1.5*t},{x:0,y:t}]},minrx:30}}},cds:{generator:"elaborated-rect",preset:function(){return{get_points:function(e,t){return[{x:e,y:t},{x:e+t,y:0},{x:e,y:-t},{x:-e,y:-t},{x:-e,y:t}]},minrx:30}}}},ie.shape_presets.box=ie.shape_presets.rect=ie.shape_presets.rectangle,ie.available_shapes=function(){var e=Object.keys(ie.shape_presets);return e.slice(0,e.length-1)};var me={shape:"ellipse"};function d(e,t){var n=e.nodeShape.eval(t);return n?"string"==typeof n?{shape:n}:n:me}function h(n){return function(e){var t=d(n,e);e.dcg_shape=function(e,t){var n=t.shape,r=Object.assign({},t);if(delete r.shape,"random"===n){var o=ie.available_shapes();n=o[Math.floor(Math.random()*o.length)]}else if(-1!==e.shape.enum().indexOf(n))return e.shape(n).elaborate({shape:n},r);if(!ie.shape_presets[n])return console.warn("unknown shape ",n),me;var a=ie.shape_presets[n].preset(r);return a.shape=ie.shape_presets[n].generator,e.shape(a.shape).elaborate(a,r)}(n,t),e.dcg_shape.abstract=t}}function p(e,t){var n=e.nodeLabelPadding.eval(t);return"number"==typeof n||"string"==typeof n?{x:+n,y:+n}:n}function N(e,t,n){var r=100;if(0<=e(t).val)throw new Error("f(a) must be less than 0");if(e(n).val<=0)throw new Error("f(b) must be greater than 0");for(;;){if(!--r)throw new Error("patience ran out");var o=(t+n)/2,a=e(o),i=a.val;if(Math.abs(i)<.5)return a;0<i?n=o:t=o}}function xe(u,e,t,n,r,o,a,i,l,c,s){var d,f,g,p;if(a){var h,y,v=function(o,a,i){return function(e){var t,n,r=(t=o,n=e,u.shape(t.dcg_shape.shape).intersect_vec(t,1e3*Math.cos(n),1e3*Math.sin(n)));return r?{port:r,val:Math.hypot(r.x-a.x,r.y-a.y)-i,ang:e}:{port:{x:0,y:0},val:0,ang:e}}},m=Math.atan2(a.sourcePort.y,a.sourcePort.x),x=Math.atan2(a.targetPort.y,a.targetPort.x);try{h=N(v(e.source,a.sourcePort,l),m,m+2*i*l/c)}catch(e){h={ang:m,port:a.sourcePort}}try{y=N(v(e.target,a.targetPort,l),x,x-2*i*l/c)}catch(e){y={ang:x,port:a.targetPort}}d=h.port,f=y.port;var _=Math.hypot(d.x,d.y)+c/2,w=Math.hypot(f.x,f.y)+s/2,b=t+_*Math.cos(h.ang),k=n+_*Math.sin(h.ang),E=r+w*Math.cos(y.ang),S=o+w*Math.sin(y.ang);g=[{x:t+d.x,y:n+d.y},{x:b,y:k},{x:E,y:S},{x:r+f.x,y:o+f.y}],p=3}else(d=e.sourcePort.pos)||(d={x:0,y:0}),(f=e.targetPort.pos)||(f={x:0,y:0}),g=[{x:t+d.x,y:n+d.y},{x:r+f.x,y:o+f.y}],p=1;return{sourcePort:d,targetPort:f,points:g,bezDegree:p}}function P(e){return 1===e.bezDegree&&2===e.points.length||3===e.bezDegree&&4===e.points.length}function L(e){var t=e.points;if(3===e.bezDegree)return t;if(1===e.bezDegree)return[{x:t[0].x,y:t[0].y},{x:t[0].x+(t[1].x-t[0].x)/3,y:t[0].y+(t[1].y-t[0].y)/3},{x:t[0].x+2*(t[1].x-t[0].x)/3,y:t[0].y+2*(t[1].y-t[0].y)/3},{x:t[1].x,y:t[1].y}];throw new Error("unknown bezDegree "+e.bezDegree)}function y(e,t){var n=e[0].x,r=e[0].y,o=e[1].x,a=e[1].y,i=e[2].x,u=e[2].y,l=e[3].x,c=e[3].y,s=(o-n)*t+n,d=(a-r)*t+r,f=(i-o)*t+o,g=(u-a)*t+a,p=(l-i)*t+i,h=(c-u)*t+u,y=(f-s)*t+s,v=(g-d)*t+d,m=(p-f)*t+f,x=(h-g)*t+g,_=(m-y)*t+y,w=(x-v)*t+v;return[[{x:n,y:r},{x:s,y:d},{x:y,y:v},{x:_,y:w}],[{x:_,y:w},{x:m,y:x},{x:p,y:h},{x:l,y:c}]]}function O(e,t){for(var n=[];1<t;){var r=y(e,1/t);n.push(r[0][0],r[0][1],r[0][2]),e=r[1],--t}return n.push.apply(n,e),n}function v(e,t,n){var r,o,a,i=n*n;o="head"===t?(r=e[e.length-1],a=e.slice(e.length-4),-1):(r=e[0],a=e.slice(0,4),1);for(var u,l,c,s,d=.5,f=.5;u=y(a,d),f/=2,i<(l=(c=r.x-u[1][0].x)*c+(s=r.y-u[1][0].y)*s)?d-=f*o:d+=f*o,1e-7<f&&.1<Math.abs(l-i););return e=e.slice(),"head"===t?e.slice(0,e.length-4).concat(u[0]):u[1].concat(e.slice(4))}function _e(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}function m(t){return function(e){return{x:e.x+t,y:e.y}}}function j(e,t){for(var n,r,o=[];t&&t.length;){var a=/^o?(?:l|r)?/.exec(t),i=!1,u=null;if(a[0])switch(a=a[0],t=t.slice(a.length),i="o"===a[0],a[a.length-1]){case"l":u="left";break;case"r":u="right"}var l=!1;for(var c in e)if(t.substring(0,c.length)===c){l=!0,o.push((n=i,r=u,e[c](n,r))),t=t.slice(c.length);break}if(!l){console.warn("couldn't find arrow name in "+t);break}}return o}function M(e,t){return[e[0]+t[0],e[1]+t[1]]}function D(e,t){return e.map(function(e){return e*t})}function e(t){return function(e){return e||t}}ie.no_shape=function(){return{parent:ce(null),elaborate:function(e,t){return Object.assign(e,t)},useTextSize:function(){return!1},useRadius:function(){return!1},usePaddingAndStroke:function(){return!1},intersect_vec:function(e,t,n){return{x:0,y:0}},calc_radii:function(e,t,n){return{rx:0,ry:0}},create:function(e){},replace:function(e){},update:function(e){}}},ie.ellipse_shape=function(){var t={parent:ce(null),elaborate:function(e,t){return Object.assign(e,t)},intersect_vec:function(e,t,n){return function(e,t,n,r){var o=Math.tan(Math.atan2(r,n));o*=o;var a={x:e*t/Math.sqrt(t*t+e*e*o),y:e*t/Math.sqrt(e*e+t*t/o)};return n<0&&(a.x=-a.x),r<0&&(a.y=-a.y),a}(e.dcg_rx,e.dcg_ry,t,n)},calc_radii:function(e,t,n){t=Math.max(t,n.height/2+5);var r=n.width/2,o=n.height/2/t;return r/=Math.sqrt(1-o*o),{rx:r=Math.max(r,t),ry:t}},create:function(e){e.insert("ellipse",":first-child").attr("class","node-shape")},update:function(e){e.select("ellipse.node-shape").attr((t.parent(),{rx:function(e){return e.dcg_rx},ry:function(e){return e.dcg_ry}}))}};return t},ie.polygon_shape=function(){var t={parent:ce(null),elaborate:function(e,t){return Object.assign(e,t)},intersect_vec:function(e,t,n){return c(e.dcg_points,0,0,t,n)},calc_radii:function(e,t,n){t=Math.max(t,n.height/2+5);var r=n.width/2;return{rx:r=r*Math.sqrt(2)/Math.cos(Math.PI/(e.dcg_shape.sides||4)),ry:t}},create:function(e){e.insert("path",":first-child").attr("class","node-shape")},update:function(e){e.select("path.node-shape").attr((t.parent(),{d:function(e){var r=e.dcg_rx,o=e.dcg_ry,t=e.dcg_shape,n=t.sides||4,a=t.skew||0,i=t.distortion||0,u=t.rotation||0,l=n%2?0:.5,c=[];u=u/360+.25;for(var s=0;s<n;++s){var d=-((s+l)/n+u)*Math.PI*2;c.push({x:Math.cos(d),y:Math.sin(d)})}var f=re.extent(c,function(e){return e.y});return t.regular?r=o=Math.max(r,o):r<o&&!t.squeeze?r=o:o/=Math.min(-f[0],f[1]),e.dcg_points=c.map(function(e){var t=r*e.x,n=o*e.y;return t*=1+i*((o-n)/o-1),{x:t-=a*n/2,y:n}}),g(e.dcg_points,1,!0)}}))}};return t},ie.rounded_rectangle_shape=function(){return{parent:ce(null),elaborate:function(e,t){return e=Object.assign({rx:10,ry:10},e),Object.assign(e,t)},intersect_vec:function(e,t,n){return c([{x:e.dcg_rx,y:e.dcg_ry},{x:e.dcg_rx,y:-e.dcg_ry},{x:-e.dcg_rx,y:-e.dcg_ry},{x:-e.dcg_rx,y:e.dcg_ry}],0,0,t,n)},useRadius:function(e){return!e.noshape},calc_radii:function(e,t,n){var r=n.height/2;return e.dcg_shape.noshape||(r+=5),{rx:n.width/2,ry:Math.max(t,r)}},create:function(e){e.filter(function(e){return!e.dcg_shape.noshape}).insert("rect",":first-child").attr("class","node-shape")},update:function(e){e.select("rect.node-shape").attr({x:function(e){return-e.dcg_rx},y:function(e){return-e.dcg_ry},width:function(e){return 2*e.dcg_rx},height:function(e){return 2*e.dcg_ry},rx:function(e){return e.dcg_shape.rx+"px"},ry:function(e){return e.dcg_shape.ry+"px"}})}}},ie.elaborated_rectangle_shape=function(){var e=ie.rounded_rectangle_shape();e.intersect_vec=function(e,t,n){return c(e.dcg_shape.get_points(e.dcg_rx,e.dcg_ry),0,0,t,n)},delete e.useRadius;var o=e.calc_radii;return e.calc_radii=function(e,t,n){var r=o(e,t,n);return{rx:Math.max(r.rx,e.dcg_shape.minrx),ry:r.ry}},e.create=function(e){e.insert("path",":first-child").attr("class","node-shape")},e.update=function(e){e.select("path.node-shape").attr("d",function(e){return g(e.dcg_shape.get_points(e.dcg_rx,e.dcg_ry),1,!0)})},e},ie.builtin_arrows={box:function(e,r){return e?{frontRef:[8,0],drawFunction:function(e,t,n){e.append("rect").attr({x:t[0]+.5,y:"right"===r?0:-3.5,width:7,height:r?3.5:7,"stroke-width":1,fill:"none"}),r&&e.append("svg:path").attr({d:["M",t[0],0,"h",8].join(" "),"stroke-width":n,fill:"none"})}}:{frontRef:[8,0],drawFunction:function(e,t,n){e.append("rect").attr({x:t[0],y:"right"===r?-n/2:-4,width:8,height:r?4+n/2:8,"stroke-width":0})}}},curve:function(e,o){return{stems:[!0,!1],kernstems:[0,.25],frontRef:[8,0],drawFunction:function(e,t,n){var r=[];r.push("M",("left"===o?7.5:4)+t[0],"left"===o?n/2:3.5),"left"===o&&r.push("v",-n/2),r.push("A",3.5,3.5,0,0,0,("right"===o?7.5:4)+t[0],"right"===o?0:-3.5),"right"===o&&r.push("v",-n/2),e.append("svg:path").attr({d:r.join(" "),"stroke-width":1,fill:"none"}),e.append("svg:path").attr({d:["M",7+t[0],0,"h -7"].join(" "),"stroke-width":n,fill:"none"})}}},icurve:function(e,o){return{stems:[!1,!0],kernstems:[.25,0],frontRef:[8,0],drawFunction:function(e,t,n){var r=[];r.push("M",("left"===o?.5:4)+t[0],"left"===o?n/2:3.5),"left"===o&&r.push("v",-n/2),r.push("A",3.5,3.5,0,0,1,("right"===o?.5:4)+t[0],"right"===o?0:-3.5),"right"===o&&r.push("v",-n/2),e.append("svg:path").attr({d:r.join(" "),"stroke-width":1,fill:"none"}),e.append("svg:path").attr({d:["M",1+t[0],0,"h 7"].join(" "),"stroke-width":n,fill:"none"})}}},diamond:function(e,a){return e?{frontRef:[a?11.25:12,0],backRef:[a?.75:0,0],viewBox:[0,-4,12,8],stems:[!!a,!!a],kernstems:function(e){return[a?0:.75*e,a?0:.75*e]},drawFunction:function(e,t,n){var r=[{x:.9,y:0}];"left"!==a?r.push({x:6,y:3.4}):r.push({x:6,y:-3.4}),r.push({x:11.1,y:0}),a||r.push({x:6,y:-3.4});var o=r.map(m(t[0]));e.append("svg:path").attr({d:g(o,1,!a),"stroke-width":1,fill:"none"}),a&&e.append("svg:path").attr({d:["M",.75+t[0],0,"h 10.5"].join(" "),"stroke-width":n,fill:"none"})}}:{frontRef:[a?11.25:12,0],backRef:[a?.75:0,0],viewBox:[0,-4,12,8],stems:[!!a,!!a],kernstems:function(e){return[a?0:.75*e,a?0:.75*e]},drawFunction:function(e,t,n){var r=[{x:0,y:0}];"left"!==a?r.push({x:6,y:4}):r.push({x:6,y:-4}),r.push({x:12,y:0}),a||r.push({x:6,y:-4});var o=r.map(m(t[0]));e.append("svg:path").attr({d:g(o,1,!0),"stroke-width":0}),a&&e.append("svg:path").attr({d:["M",.75+t[0],0,"h 10.5"].join(" "),"stroke-width":n,fill:"none"})}}},dot:function(e,r){return e?{frontRef:[8,0],stems:[!!r,!!r],drawFunction:function(e,t,n){r?(e.append("svg:path").attr({d:["M",.5+t[0],0,"A",3.5,3.5,0,0,"left"===r?1:0,7.5+t[0],0].join(" "),"stroke-width":1,fill:"none"}),e.append("svg:path").attr({d:["M",t[0],0,"h 8"].join(" "),"stroke-width":n,fill:"none"})):e.append("svg:circle").attr("r",3.5).attr("cx",4+t[0]).attr("cy",0).attr("fill","none").attr("stroke-width","1px")}}:{frontRef:[8,0],stems:[!!r,!!r],drawFunction:function(e,t,n){r?(e.append("svg:path").attr({d:["M",t[0],0,"A",4,4,0,0,"left"===r?1:0,8+t[0],0].join(" "),"stroke-width":0}),e.append("svg:path").attr({d:["M",t[0],0,"h 8"].join(" "),"stroke-width":n,fill:"none"})):e.append("svg:circle").attr("r",4).attr("cx",4+t[0]).attr("cy",0).attr("stroke-width","0px")}}},normal:function(e,a){return e?{frontRef:[a?8-4/3:8,0],viewBox:[0,-3,8,6],kernstems:function(e){return[0,4*e/3]},drawFunction:function(e,t,n){var r=(a?[{x:.5,y:0},{x:.5,y:"left"===a?-2.28:2.28},{x:8-4/3,y:0}]:[{x:.5,y:2.28},{x:6.57,y:0},{x:.5,y:-2.28}]).map(m(t[0]));e.append("svg:path").attr({d:g(r,1,!a),"stroke-width":1,fill:"none"}),a&&e.append("svg:path").attr({d:["M",t[0],0,"h",8-4/3].join(" "),"stroke-width":n,fill:"none"})}}:{frontRef:[a?8-4/3:8,0],viewBox:[0,-3,8,6],kernstems:function(e){return[0,4*e/3]},drawFunction:function(e,t,n){var r=[];switch("left"===a?r.push({x:0,y:0}):r.push({x:0,y:3}),a){case"left":r.push({x:8-4*n/3,y:-n/2});break;case"right":r.push({x:8-4*n/3,y:n/2});break;default:r.push({x:8,y:0})}"right"===a?r.push({x:0,y:0}):r.push({x:0,y:-3});var o=r.map(m(t[0]));e.append("svg:path").attr("d",g(o,1,!0)).attr("stroke-width","0px"),a&&e.append("svg:path").attr({d:["M",t[0],0,"h",8-4*n/3].join(" "),"stroke-width":n,fill:"none"})}}},inv:function(e,a){return e?{frontRef:[8,0],backRef:[a?4/3:0,0],viewBox:[0,-3,8,6],kernstems:function(e){return[4*e/3,0]},drawFunction:function(e,t,n){var r=(a?[{x:7.5,y:0},{x:7.5,y:"left"===a?-2.28:2.28},{x:1.43,y:0}]:[{x:7.5,y:2.28},{x:1.43,y:0},{x:7.5,y:-2.28}]).map(m(t[0]));e.append("svg:path").attr({d:g(r,1,!a),"stroke-width":1,fill:"none"}),a&&e.append("svg:path").attr({d:["M",4*n/3+t[0],0,"h",8-4/3].join(" "),"stroke-width":n,fill:"none"})}}:{frontRef:[8,0],backRef:[a?4/3:0,0],viewBox:[0,-3,8,6],kernstems:function(e){return[4*e/3,0]},drawFunction:function(e,t,n){var r=[];switch("left"===a?r.push({x:8,y:0}):r.push({x:8,y:3}),a){case"left":r.push({x:4*n/3,y:-n/2});break;case"right":r.push({x:4*n/3,y:n/2});break;default:r.push({x:0,y:0})}"right"===a?r.push({x:8,y:0}):r.push({x:8,y:-3});var o=r.map(m(t[0]));e.append("svg:path").attr("d",g(o,1,!0)).attr("stroke-width","0px"),a&&e.append("svg:path").attr({d:["M",4*n/3+t[0],0,"h",8-4*n/3].join(" "),"stroke-width":n,fill:"none"})}}},tee:function(e,i){return{frontRef:[5,0],viewBox:[0,-5,5,10],stems:[!0,!1],drawFunction:function(e,t,n){var r="right"===i?0:-5,o="left"===i?0:5,a=[{x:2,y:o},{x:5,y:o},{x:5,y:r},{x:2,y:r}].map(m(t[0]));e.append("svg:path").attr("d",g(a,1,!0)).attr("stroke-width","0px"),e.append("svg:path").attr("d",["M",t[0],0,"h",5].join(" ")).attr("stroke-width",n).attr("fill","none")}}},vee:function(e,a){return{stems:[!0,!1],kernstems:function(e){return[0,e]},drawFunction:function(e,t,n){var r=[{x:0,y:-5},{x:10,y:0},{x:0,y:5},{x:5,y:0}];"right"===a?r.splice(0,1,{x:5,y:-n/2},{x:10,y:-n/2}):"left"===a&&r.splice(2,1,{x:10,y:n/2},{x:5,y:n/2});var o=r.map(m(t[0]));e.append("svg:path").attr("d",g(o,1,!0)).attr("stroke-width","0px"),e.append("svg:path").attr("d",["M",t[0]+5,0,"h",-5].join(" ")).attr("stroke-width",n)}}},crow:function(e,a){return{stems:[!1,!0],kernstems:function(e){return[e,0]},drawFunction:function(e,t,n){var r=[{x:10,y:-5},{x:0,y:0},{x:10,y:5},{x:5,y:0}];"right"===a?r.splice(0,1,{x:5,y:-n/2},{x:0,y:-n/2}):"left"===a&&r.splice(2,1,{x:0,y:n/2},{x:5,y:n/2});var o=r.map(m(t[0]));e.append("svg:path").attr("d",g(o,1,!0)).attr("stroke-width","0px"),e.append("svg:path").attr("d",["M",t[0]+5,0,"h",5].join(" ")).attr("stroke-width",n)}}}};var x=e([0,-5,10,10]),R=e([10,0]),C=e([0,0]);function I(d,f){var g=null;return d.map(function(e,t){var n=R(e.frontRef).slice(),r=C(e.backRef).slice();if(e.kernstems){var o=e.kernstems;if("function"==typeof o&&(o=o(f)),0!==t&&o[1]){var a=d[t-1];a.stems&&a.stems[0]&&(n[0]-=o[1])}if(o[0]){var i=!1;if(t===d.length-1)i=!0;else{var u=d[t+1];u.stems&&u.stems[1]&&(i=!0)}i&&(r[0]+=o[0])}}if(0===t)return n,{backRef:g=r,offset:[0,0]};var l,c,s=(c=n,[(l=g)[0]-c[0],l[1]-c[1]]);return{backRef:g=M(r,s),offset:s}})}function b(e,t){var l=null,c=I(e,t);return e.forEach(function(e,t){var n,r,o,a,i=x(e.viewBox),u=c[t].offset;l=l?(n=l,r=[i[0]+u[0],i[1]+u[1],i[2],i[3]],o=Math.min(n[0],r[0]),a=Math.min(n[1],r[1]),[o,a,Math.max(n[0]+n[2],r[0]+r[2])-o,Math.max(n[1]+n[3],r[1]+r[3])-a]):i.slice()}),{offsets:c,viewBox:l}}function S(e,t){if(!e.length)return 0;var n=I(e,t);return R(e[0].frontRef)[0]-n[e.length-1].backRef[0]}function we(e,t){var n=e.edgeArrowSize.eval(t),r=e.edgeStrokeWidth.eval(t)/n;return{headLength:n*(S(j(e.arrows(),e.edgeArrowhead.eval(t)),r)+e.nodeStrokeWidth.eval(t.target)/2),tailLength:n*(S(j(e.arrows(),e.edgeArrowtail.eval(t)),r)+e.nodeStrokeWidth.eval(t.source)/2)}}function be(e,t,n){return{bezDegree:3,points:v(v(L(n),"head",e),"tail",t),sourcePort:n.sourcePort,targetPort:n.targetPort}}function z(e,t){var n=+e.slice(0,-3),r=+t.slice(0,-3);return Math.abs(n-r)>Math.PI&&(n<r?n+=2*Math.PI:n-=2*Math.PI),n}function F(e,t,n,r,o){var a,i,u=e.arrowId(n,r);function l(){return o+"-"+a+"-"+i}if(o&&(a=e.nodeStrokeWidth.eval("tail"===r?n.source:n.target)/2,i=e.edgeStroke.eval(n),n[r+"ArrowLast"]===l()))return u;var c=j(t,o),s=e.addOrRemoveDef(u,!!c.length,"svg:marker");if(c.length){var d=e.edgeArrowSize.eval(n),f=e.edgeStrokeWidth.eval(n)/d,g=b(c,f),p=R(c[0].frontRef);g.viewBox[0]-=a/d,g.viewBox[3]+=a/d,s.attr("viewBox",g.viewBox.join(" ")).attr("refX",p[0]).attr("refY",p[1]).attr("markerUnits","userSpaceOnUse").attr("markerWidth",g.viewBox[2]*d).attr("markerHeight",g.viewBox[3]*d).attr("stroke",i).attr("fill",i),s.html(null),c.forEach(function(e,t){s.call(e.drawFunction,M([-a/d,0],g.offsets[t].offset),f)})}return n[r+"ArrowLast"]=l(),o?u:null}ie.text_contents=function(){var a={parent:ce(null),update:function(e){var t=e.selectAll("text.node-label").data(function(e){return[e]});t.enter().append("text").attr("class","node-label");var n=t.selectAll("tspan").data(function(n){var e=a.parent().nodeLabel.eval(n);if(!e)return[];"string"==typeof e&&(e=[e]);var t,r=a.parent().nodeLineHeight(),o=.5-((e.length-1)*r+1)/2;return(0<(t=window.navigator.userAgent).indexOf("MSIE ")||0<t.indexOf("Trident/")||0<t.indexOf("Edge/")||/^((?!chrome|android).)*safari/i.test(navigator.userAgent))&&(o+=.3),e.map(function(e,t){return{node:n,line:e,yofs:(0==t?o:r)+"em"}})});n.enter().append("tspan"),n.attr({"text-anchor":"start","text-decoration":function(e){return a.parent().nodeLabelDecoration.eval(e.node)},x:0}).html(function(e){return e.line}),t.each(function(e){e.xofs=0}).filter(function(e){return"center"!==a.parent().nodeLabelAlignment.eval(e)}).each(function(e){var t=A(this);switch(e.bbox={x:t.x,y:t.y,width:t.width,height:t.height},a.parent().nodeLabelAlignment.eval(e)){case"left":e.xofs=-e.bbox.width/2;break;case"right":e.xofs=e.bbox.width/2}}).selectAll("tspan"),n.attr({"text-anchor":function(e){switch(a.parent().nodeLabelAlignment.eval(e.node)){case"left":return"start";case"center":return"middle";case"right":return"end"}return null},x:function(e){return e.node.xofs},dy:function(e){return e.yofs}}),n.exit().remove(),t.attr("fill",a.parent().nodeLabelFill.eval)},textbox:function(e){var t=A(this.selectContent(e).node());return{x:t.x,y:t.y,width:t.width,height:t.height}},selectContent:function(e){return e.select("text.node-label")},selectText:function(e){return this.selectContent(e)}};return a},ie.with_icon_contents=function(n,r,o){var a={parent:ce(null).react(function(e){n.parent(e)}),padding:function(e){var t=p(a.parent(),e);return{x:3*t.x,y:3*t.y}},update:function(e){var t=e.selectAll("g.with-icon").data(function(e){return[e]});t.enter().append("g").attr("class","with-icon").append("image").attr({class:"icon",width:r+"px",height:o+"px"}),t.call(n.update),n.selectContent(t).attr("transform","translate("+r/2+")"),t.selectAll("image.icon").attr({href:a.parent().nodeIcon.eval,x:function(e){return-(r+n.textbox(re.select(this.parentNode)).width)/2-p(a.parent(),e).x},y:-o/2})},textbox:function(e){var t=n.textbox(e);return t.x+=r/2,t},selectContent:function(e){return e.select("g.with-icon")},selectText:function(e){return this.selectContent(e).select("text.node-label")}};return a},ie.diagram=function(t,e){var P=ae.marginMixin({});P.__dcFlag__=ae.utils.uniqueId(),P.margins({left:10,top:10,right:10,bottom:10});var a,L,O,n,r,y,o,i,u,l,j=re.dispatch("preDraw","data","end","start","render","drawn","receivedLayout","transitionsStarted","zoomed","reset"),M={},D={},R={},C={},I={},c={},z=!1,s=200,d=function(e){var t=e&&e.getBoundingClientRect&&e.getBoundingClientRect().width;return t&&s<t?t:s},f=200,g=function(e){var t=e&&e.getBoundingClientRect&&e.getBoundingClientRect().height;return t&&f<t?t:f};function p(n){return function(e){P.layoutEngine()||P.layoutAlgorithm("cola",!0);var t=P.layoutEngine();if(t.getEngine&&(t=t.getEngine()),t[n]){if(console.warn("property is deprecated, call on layout engine instead: dc_graph.diagram.%c"+n,"font-weight: bold"),!arguments.length)return t[n]();t[n](e)}else if(console.warn("property is deprecated, and is not supported for Warning: dc_graph.diagram.<b>"+n+'</b> is deprecated, and it is not supported for the "'+t.layoutAlgorithm()+'" layout algorithm: ignored.'),!arguments.length)return null;return this}}function F(e){P.layoutEngine()||P.layoutAlgorithm("cola",!0),(e||P.layoutEngine()).init({width:P.width(),height:P.height()})}function W(e){return!!e.source&&!!e.target}function h(e){return ge("trace",e+"() is specific to the SVG renderer",function(){return P.renderer()[e].apply(this,arguments)})}function v(e){return ge("trace","calling "+e+"() on renderer",function(){return P.renderer()[e].apply(this,arguments)})}P.height=function(e){if(!arguments.length){if(!ae.utils.isNumber(i)){if(l=g(P.root().node()),"auto"===i)return l;i=l}return i}if(ae.utils.isNumber(e)||!e||"auto"===e)i=e;else{if("function"!=typeof e)throw new Error("don't know what to do with height type "+typeof e+" value "+e);g=e,i=void 0}return P},P.minHeight=function(e){return arguments.length?(f=e,P):f},P.width=function(e){if(!arguments.length){if(!ae.utils.isNumber(o)){if(u=d(P.root().node()),"auto"===o)return u;o=u}return o}if(ae.utils.isNumber(e)||!e||"auto"===e)o=e;else{if("function"!=typeof e)throw new Error("don't know what to do with width type "+typeof e+" value "+e);d=e,o=void 0}return P},P.minWidth=function(e){return arguments.length?(s=e,P):s},P.root=ce(null).react(function(e){e.empty()&&console.log("Warning: parent selector "+t+" doesn't seem to exist")}),P.mouseZoomable=ce(!0),P.zoomExtent=ce([.1,2]),P.modKeyZoom=P.altKeyZoom=ce(!1),P.fitStrategy=ce("default"),P.restrictPan=ce(!1),P.autoZoom=ce(null),P.zoomToFit=function(e){X(e)},P.zoomDuration=ce(500),P.nodeDimension=ce(),P.nodeGroup=ce(),P.edgeDimension=ce(),P.edgeGroup=ce(),P.edgesInFront=ce(!1),P.nodeKey=P.nodeKeyAccessor=ce(function(e){return e.key}),P.edgeKey=P.edgeKeyAccessor=ce(function(e){return e.key}),P.edgeSource=P.sourceAccessor=ce(function(e){return e.value.sourcename}),P.edgeTarget=P.targetAccessor=ce(function(e){return e.value.targetname}),P.portDimension=ce(null),P.portGroup=ce(null),P.portNodeKey=ce(null),P.portEdgeKey=ce(null),P.portName=ce(null),P.portStyleName=ce(null),P.portElastic=ce(!0),P.portStyle=se(),P.portBounds=ce(null),P.edgeSourcePortName=ce(null),P.edgeTargetPortName=ce(null),P.clusterDimension=ce(null),P.clusterGroup=ce(null),P.clusterKey=ce(ae.pluck("key")),P.clusterParent=ce(null),P.clusterPadding=ce(8),P.nodeParentCluster=ce(null),P.nodeRadius=P.nodeRadiusAccessor=ce(25),P.nodeStrokeWidth=P.nodeStrokeWidthAccessor=ce(1),P.nodeStroke=P.nodeStrokeAccessor=ce("black"),P.nodeStrokeDashArray=ce(null),P.nodeFillScale=ce(null),P.nodeFill=P.nodeFillAccessor=ce("white"),P.nodeOpacity=ce(1),P.nodePadding=ce(6),P.nodeLabelPadding=ce(0),P.nodeLineHeight=ce(1),P.nodeLabel=P.nodeLabelAccessor=ce(function(e){return e.value.label||e.value.name}),P.nodeLabelAlignment=ce("center"),P.nodeLabelDecoration=ce(null),P.nodeLabelFill=P.nodeLabelFillAccessor=ce(null),P.nodeFitLabel=P.nodeFitLabelAccessor=ce(!0),P.nodeShape=ce(me),P.shape=se(),P.shape("nothing",ie.no_shape()),P.shape("ellipse",ie.ellipse_shape()),P.shape("polygon",ie.polygon_shape()),P.shape("rounded-rect",ie.rounded_rectangle_shape()),P.shape("elaborated-rect",ie.elaborated_rectangle_shape()),P.nodeContent=ce("text"),P.content=se(),P.content("text",ie.text_contents()),P.nodeIcon=ce(null),P.nodeTitle=P.nodeTitleAccessor=ce(function(e){return P.nodeKey()(e)}),P.nodeOrdering=ce(null),P.nodeFixed=P.nodeFixedAccessor=ce(null),P.edgeStroke=P.edgeStrokeAccessor=ce("black"),P.edgeStrokeWidth=P.edgeStrokeWidthAccessor=ce(1),P.edgeStrokeDashArray=ce(null),P.edgeOpacity=P.edgeOpacityAccessor=ce(1),P.edgeLabel=P.edgeLabelAccessor=ce(function(e){return P.edgeKey()(e)}),P.edgeLabelSpacing=ce(12),P.edgeArrowhead=P.edgeArrowheadAccessor=ce("vee"),P.edgeArrowtail=P.edgeArrowtailAccessor=ce(null),P.edgeArrowSize=ce(1),P.edgeIsLayout=P.edgeIsLayoutAccessor=ce(function(e){return!e.value.notLayout}),P.edgeIsShown=ce(!0),P.lengthStrategy=p("lengthStrategy"),P.edgeLength=P.edgeDistanceAccessor=ce(function(e){return e.value.distance}),P.flowLayout=p("flowLayout"),P.rankdir=p("rankdir"),P.baseLength=p("baseLength"),P.transitionDuration=ce(500),P.stageTransitions=ce("none"),P.deleteDelay=ce(0),P.groupConnected=p("groupConnected"),P.timeLimit=ce(0),P.constrain=ce(function(e,t){return[]}),P.parallelEdgeOffset=ce(10),P.edgeOrdering=ce(null),P.edgeSort=ce(null),P.cascade=he(P),P.initLayoutOnRedraw=ce(!1),P.layoutUnchanged=ce(!1),P.nodeChangeSelect=ce(function(){return P.layoutEngine().supportsMoving&&P.layoutEngine().supportsMoving()?_:b}),P.edgeChangeSelect=ce(function(){return P.layoutEngine().supportsMoving&&P.layoutEngine().supportsMoving()?w:k}),P.relayout=function(){return L=O=null,this},P.initialLayout=de("initialLayout is deprecated - use layout algorithms instead",null),P.initialOnly=de("initialOnly is deprecated - see the initialLayout deprecation notice in the documentation",!1),P.induceNodes=ce(!1),P.showLayoutSteps=ce(!1),P.mode=P.child=se(),P.mode.reject=function(e,t){var n=P.renderer().rendererType();if(!t)return!1;if(t.supportsRenderer){if(!t.supportsRenderer(n))return'not installing "'+e+'" because it is not compatible with renderer '+n}else console.log('could not check if "'+e+'" is compatible with '+n);return!1},P.legend=pe(".legend() is deprecated; use .child() for more control & multiple legends",function(e){return arguments.length?(P.child("node-legend",e),P):P.child("node-legend")}),P.layoutAlgorithm=function(e,t){if(!arguments.length)return P.layoutEngine()?P.layoutEngine().layoutAlgorithm():"cola";var n;switch(t||console.warn("dc.graph.diagram.layoutAlgorithm is deprecated - pass the layout engine object to dc_graph.diagram.layoutEngine instead"),e){case"cola":n=ie.cola_layout();break;case"dagre":n=ie.dagre_layout()}return n=ie.webworker_layout(n),P.layoutEngine(n),this},P.layoutEngine=ce(null).react(function(e){e&&e.parent&&e.parent(P),P.renderer().isRendered()&&(Object.keys(D).forEach(function(e){D[e].cola.points=null}),F(e))}),P.renderer=ce(ie.render_svg().parent(P)).react(function(e){P.renderer()&&P.renderer().parent(null),e.parent(P)}),P.enforceEdgeDirection=ce(null),P.tickSize=p("tickSize"),P.uniqueId=function(){return P.anchorName().replace(/[ .#=\[\]"]/g,"-")},P.edgeId=function(e){return"edge-"+P.edgeKey.eval(e).replace(/[^\w-_]/g,"-")},P.arrowId=function(e,t){return"arrow-"+t+"-"+P.uniqueId()+"-"+P.edgeId(e)},P.textpathId=function(e){return"textpath-"+P.uniqueId()+"-"+P.edgeId(e)},P.getNode=function(e){return M[e]?M[e].orig:null},P.getWholeNode=function(e){return M[e]?M[e]:null},P.getEdge=function(e){return D[e]?D[e].orig:null},P.getWholeEdge=function(e){return D[e]?D[e]:null},P.getPort=function(e,t,n){return R[ke(e,t,n)]},P.nodePorts=function(){return a},P.getWholeCluster=function(e){return C[e]||null},P.handleDisconnected=p("handleDisconnected"),P.forEachChild=function(e,n,r,o){n.enum().forEach(function(t){o(n(t),e.filter(function(e){return r(e)===t}))})},P.forEachShape=function(e,t){P.forEachChild(e,P.shape,function(e){return e.dcg_shape.shape},t)},P.forEachContent=function(e,t){P.forEachChild(e,P.content,P.nodeContent.eval,t)},P.stagedDuration=function(){return"none"!==P.stageTransitions()?P.transitionDuration()/2:P.transitionDuration()},P.stagedDelay=function(e){return"none"===P.stageTransitions()||"modins"===P.stageTransitions()==!e?0:P.transitionDuration()/2},P.isRunning=function(){return z},P.svg=h("svg"),P.g=h("g"),P.select=h("select"),P.selectAll=h("selectAll"),P.addOrRemoveDef=h("addOrRemoveDef"),P.selectAllNodes=h("selectAllNodes"),P.selectAllEdges=h("selectAllEdges"),P.selectNodePortsOfStyle=h("selectNodePortsOfStyle"),P.zoom=h("zoom"),P.translate=h("translate"),P.scale=h("scale"),P.renderNode=h("renderNode"),P.renderEdge=h("renderEdge"),P.redrawNode=h("redrawNode"),P.redrawEdge=h("redrawEdge"),P.reposition=v("reposition");var m,H=!1;function G(){var e=u,t=l,n=P.width(),r=P.height();e===n&&t===r||P.renderer().rezoom(e,t,n,r)}function x(e){return Object.entries(e).filter(function(e){return/^dcg_/.test(e[0])}).reduce(function(e,t){return e[t[0]]=t[1],e},{})}function _(e){return{orig:ue(e),cola:x(e.cola)}}function w(e){return{orig:ue(e),cola:x(e.cola)}}function b(e){var t=ue(e);return{orig:{key:t.key,value:Object.fromEntries(Object.entries(t.value).filter(function(e){return"fixedPos"!==e[0]}))}}}function k(e){return{orig:ue(e)}}function B(e){var t,n,r=!0;switch((P.width_is_automatic()||P.height_is_automatic())&&G(),P.autoZoom()){case"always-skipanimonce":r=!1,P.autoZoom("always");case"always":t=!0;break;case"once-noanim":r=!1;case"once":t=!0,P.autoZoom(null);break;default:t=!1}n=e,(P.fitStrategy()||P.restrictPan())&&(m=P.renderer().calculateBounds(n)),t&&X(r)}function E(e,t){var n,r,o=t.target.cola.y-t.source.cola.y,a=t.target.cola.x-t.source.cola.x;return 0===o&&0===a?[1,0]:(t.source!==e&&(o=-o,a=-a),t.parallel&&1<t.parallel.edges.length&&t.source.index>t.target.index&&(o=-o,a=-a),n=[a,o],r=Math.hypot(n[0],n[1]),[n[0]/r,n[1]/r])}function q(e,t){for(var n in a={},t.forEach(function(e){var t=P.nodeKey.eval(e.node);(a[t]=a[t]||[]).push(e)}),a){var r=e[n];a[n].forEach(function(e){if(P.portElastic.eval(e)&&e.edges.length){var t=e.edges.map(E.bind(null,r));e.vec=[re.sum(t,function(e){return e[0]})/t.length,re.sum(t,function(e){return e[1]})/t.length]}else e.vec=e.vec||void 0;e.pos=null})}}function U(e,t,n){for(var r in a){var o=e[r];a[r].forEach(function(e){e.pos||Ee(P,o,e)})}t.forEach(function(e){var t=P.edgeSourcePortName.eval(e);e.sourcePort.pos=t?n[ke(P.nodeKey.eval(e.source),null,t)].pos:n[ke(null,P.edgeKey.eval(e),"source")].pos,t=P.edgeTargetPortName.eval(e),e.targetPort.pos=t?n[ke(P.nodeKey.eval(e.target),null,t)].pos:n[ke(null,P.edgeKey.eval(e),"target")].pos,console.assert(e.sourcePort.pos&&e.targetPort.pos)})}function S(e,t,n){var r=e.points,o=r[0],a=r[r.length-1];switch(P.enforceEdgeDirection()){case"LR":if(t.x>=n.x){var i=o.x-a.x;return{points:[o,{x:o.x+i,y:o.y-i/2},{x:a.x-i,y:a.y-i/2},a],bezDegree:3,sourcePort:e.sourcePort,targetPort:e.targetPort}}break;case"TB":if(t.y>=n.y){var u=o.y-a.y;return{points:[o,{x:o.x+u/2,y:o.y+u},{x:a.x+u/2,y:a.y-u},a],bezDegree:3,sourcePort:e.sourcePort,targetPort:e.targetPort}}}return e}function A(r){var o={left:r.cola.x-r.dcg_rx,top:r.cola.y-r.dcg_ry,right:r.cola.x+r.dcg_rx,bottom:r.cola.y+r.dcg_ry};if(P.portStyle.enum().length){var e=a[P.nodeKey.eval(r)];e&&e.forEach(function(e){var t=P.portStyleName.eval(e);if(t&&P.portStyle(t)){var n=P.portStyle(t).portBounds(e);n.left+=r.cola.x,n.top+=r.cola.y,n.right+=r.cola.x,n.bottom+=r.cola.y,o=K(o,n)}})}return o}function K(e,t){return{left:Math.min(e.left,t.left),top:Math.min(e.top,t.top),right:Math.max(e.right,t.right),bottom:Math.max(e.bottom,t.bottom)}}function T(e){return{left:e.x,top:e.y,right:e.x,bottom:e.y}}function N(e){return e.pos.new.path.points.map(T).reduce(K)}function X(e){if(P.fitStrategy()){if(!m)return;var t=m.right-m.left,n=m.bottom-m.top,r=P.width()-P.margins().left-P.margins().right,o=P.height()-P.margins().top-P.margins().bottom,a=P.fitStrategy(),i=[0,0],u=1;if(0<=["default","vertical","horizontal"].indexOf(a))u=("default"===a?!(n/t<o/r):"vertical"===a)?o/n:r/t,u=Math.max(P.zoomExtent()[0],Math.min(P.zoomExtent()[1],u)),i=[P.margins().left-m.left*u+(r-t*u)/2,P.margins().top-m.top*u+(o-n*u)/2];else if("string"==typeof a&&a.match(/^align_/)){var l=a.split("_")[1].toLowerCase().split("");if(2<l.length)throw new Error("align_ expecting 0-2 sides, not "+l.length);var c=Z();i=P.renderer().translate(),u=P.renderer().scale();var s=!1,d=!1;l.forEach(function(e){switch(e){case"l":i[0]=$(i,c.left),d=!0;break;case"t":i[1]=Q(i,c.top),s=!0;break;case"r":i[0]=ee(i,c.right),d=!0;break;case"b":i[1]=te(i,c.bottom),s=!0;break;case"c":break;default:throw new Error("align_ expecting l t r b or c, not '"+e+"'")}}),l.includes("c")&&(d||(i[0]=($(p=i,(h=c).left)+ee(p,h.right))/2),s||(i[1]=(Q(f=i,(g=c).top)+te(f,g.bottom))/2))}else{if("zoom"!==a)throw new Error("unknown fitStrategy type "+typeof a);u=P.renderer().scale(),i=ne(P.renderer().translate())}y=e,P.renderer().translate(i).scale(u).commitTranslateScale(),y=!1}var f,g,p,h}function Y(r){return function(e,t){var n={};return e[t]=function(e){return n[e]=n[e]||fe("trace",r(e,t))},e}}P.redraw=function(){return z?(H=!0,this):P.startLayout()},P.render=function(){return P.renderer().isRendered()&&j.reset(),P.initLayoutOnRedraw()||F(),M={},D={},R={},C={},P.x(re.scale.linear().domain([0,P.width()]).range([0,P.width()])),P.y(re.scale.linear().domain([0,P.height()]).range([0,P.height()])),P.renderer().initializeDrawing(),j.render(),P.redraw(),this},P.refresh=v("refresh"),P.width_is_automatic=function(){return"auto"===o},P.height_is_automatic=function(){return"auto"===i},P.startLayout=function(){var e=P.nodeGroup().all(),t=P.edgeGroup().all(),n=P.portGroup()?P.portGroup().all():[],r=P.clusterGroup()?P.clusterGroup().all():[];if(z)throw new Error("dc_graph.diagram.redraw already running!");z=!0,P.width_is_automatic()||P.height_is_automatic()?G():P.renderer().resize(),P.initLayoutOnRedraw()&&F(),P.layoutEngine().stop(),j.preDraw(),P.nodeOrdering()&&(e=oe.quicksort.by(P.nodeOrdering())(e.slice(0),0,e.length)),P.edgeOrdering()&&(t=oe.quicksort.by(P.edgeOrdering())(t.slice(0),0,t.length));var o=ve(M,e,null,function(e){return P.nodeKey()(e)},function(e,t){e.orig=t,e.cola=e.cola||{},e.cola.dcg_nodeKey=P.nodeKey.eval(e),e.cola.dcg_nodeParentCluster=P.nodeParentCluster.eval(e),P.layoutEngine().populateLayoutNode(e.cola,e)}),a=ve(D,t,null,function(e){return P.edgeKey()(e)},function(e,t){e.orig=t,e.cola=e.cola||{},e.cola.dcg_edgeKey=P.edgeKey.eval(e),e.cola.dcg_edgeSource=P.edgeSource.eval(e),e.cola.dcg_edgeTarget=P.edgeTarget.eval(e),e.source=M[e.cola.dcg_edgeSource],e.target=M[e.cola.dcg_edgeTarget],e.sourcePort=e.sourcePort||{},e.targetPort=e.targetPort||{},P.layoutEngine().populateLayoutEdge(e.cola,e)}),i=(a=(a=(a=a.filter(W)).filter(function(e){return e.source!==e.target})).filter(P.edgeIsShown.eval)).map(function(e){return P.edgeSourcePortName.eval(e)?ke(P.edgeSource.eval(e),null,P.edgeSourcePortName.eval(e)):ke(null,P.edgeKey.eval(e),"source")});i=i.concat(a.map(function(e){return P.edgeTargetPortName.eval(e)?ke(P.edgeTarget.eval(e),null,P.edgeTargetPortName.eval(e)):ke(null,P.edgeKey.eval(e),"target")})),n=n.filter(function(e){return P.portNodeKey()&&P.portNodeKey()(e)||P.portEdgeKey()&&P.portEdgeKey()(e)});var u=ve(R,n,i,function(e){return ke(P.portNodeKey()&&P.portNodeKey()(e),P.portEdgeKey()&&P.portEdgeKey()(e),P.portName()(e))},function(e,t){e.orig=t,e.named&&(e.edges=[])},function(e,t){console.assert(e,"should have screened out invalid ports");var n,r=(n=e.split("/"),console.assert(3===n.length),"node"===(n=n.map(function(e){return e.replace(/%2F/g,"/")}))[0]?{nodeKey:n[1],name:n[2]}:{edgeKey:n[1],name:n[2]});if(r.nodeKey)t.node=M[r.nodeKey],t.named=!0;else{var o=D[r.edgeKey];t.node=o[r.name],t.edges=[o],t.named=!1}t.name=r.name});if(u=u.filter(function(e){return e.node}),a.forEach(function(e){var t=P.edgeSourcePortName.eval(e);t&&R[ke(P.nodeKey.eval(e.source),null,t)].edges.push(e),(t=P.edgeTargetPortName.eval(e))&&R[ke(P.nodeKey.eval(e.target),null,t)].edges.push(e)}),P.induceNodes()){var l={};for(var c in a.forEach(function(e){l[e.cola.dcg_edgeSource]=!0,l[e.cola.dcg_edgeTarget]=!0}),o=o.filter(function(e){return l[e.cola.dcg_nodeKey]}),M)l[c]||delete M[c]}var s=re.set(o.map(function(e){return P.nodeParentCluster.eval(e)}).filter(le)).values(),d=ve(C,r,s,function(e){return P.clusterKey()(e)},function(e,t){e.orig=t,e.cola=e.cola||{dcg_clusterKey:P.clusterKey.eval(e),dcg_clusterParent:P.clusterParent.eval(e)}},function(e,t){});if(o.forEach(function(e,t){e.index=t}),j.data(P,M,o,D,a,R,u),I={nnodes:o.length,nedges:a.length},o.forEach(function(e){P.nodeFixed()&&(e.cola.dcg_nodeFixed=P.nodeFixed.eval(e))}),P.parallelEdgeOffset()){for(var f=new Array(o.length),g=0;g<o.length;++g)f[g]=new Array(g);a.forEach(function(e){var t,n,r,o;e.pos=e.pos||{},e.source.index<e.target.index?(t=e.source.index,n=e.target.index,r="edgeSourcePortName",o="edgeTargetPortName"):(n=e.source.index,t=e.target.index,o="edgeSourcePortName",r="edgeTargetPortName");var a=P[r].eval(e)||"no port",i=P[o].eval(e)||"no port";f[n][t]=f[n][t]||{},f[n][t][i]=f[n][t][i]||{},e.parallel=f[n][t][i][a]=f[n][t][i][a]||{rev:[],edges:[]},e.parallel.edges.push(e),e.parallel.rev.push(t!==e.source.index)})}var p=P.renderer().startRedraw(j,o,a);P.initialLayout()&&P.initialLayout()(P,o,a);var h=!1;if(!P.layoutUnchanged()){var y=P.nodeChangeSelect()(),v=P.edgeChangeSelect()(),m=JSON.stringify(o.map(y)),x=JSON.stringify(a.map(v));m===L&&x===O&&(h=!0),L=m,O=x}a.forEach(function(e){e.cola.dcg_edgeLength=P.edgeLength.eval(e)});var _=P.constrain()(P,o,a),w=_.reduce(function(t,n){if(n.type)switch(n.type){case"alignment":var r=n.offsets[0].node;t[r]=t[r]||[],n.offsets.slice(1).forEach(function(e){t[r].push({node:e.node,in_constraint:n})})}else n.axis&&(t[n.left]=t[n.left]||[],t[n.left].push({node:n.right,in_constraint:n}));return t},{}),b={};Object.keys(w).forEach(function(e){b[e]||function t(e,n){var r=e.node,o=(n=n||[]).find(function(e){return e.node===r});n=n.concat([e]),o&&console.warn("found a loop in constraints",n),b[r]||(b[r]=!0,w[r]&&w[r].forEach(function(e){t(e,n)}))}({node:e,in_constraint:null})});var k=[];_.forEach(function(e){if(e.type)switch(e.type){case"alignment":e.offsets.forEach(function(e){e.node=M[e.node].index});break;case"circle":e.nodes.forEach(function(e){e.node=M[e.node].index})}else e.axis&&e.left&&e.right?(e.left=M[e.left].index,e.right=M[e.right].index):k.push(e)}),k.length&&console.warn(k.length+" invalid constraints",k);var E=a.filter(P.edgeIsLayout.eval),S=(a.filter(function(e){return!P.edgeIsLayout.eval(e)}),_.filter(function(e){return"circle"===e.type}));_=_.filter(function(e){return"circle"!==e.type}),S.forEach(function(e){var t=(e.distance||4*P.baseLength())/(2*Math.sin(Math.PI/e.nodes.length)),n=e.nodes.map(function(e){return e.node}),r=ie.wheel_edges(function(e){return P.nodeKey.eval(o[e])},n,t).map(function(e){var t={internal:e};return t.source=M[e.sourcename],t.target=M[e.targetname],t});E=E.concat(r)});var A=_.filter(function(e){return"ordering"===e.type});if(_=_.filter(function(e){return"ordering"!==e.type}),A.forEach(function(n){var r,e=n.nodes.map(function(e){return M[e]});n.ordering&&(e=oe.quicksort.by(ye(n.ordering))(e,0,e.length));e.forEach(function(e,t){0===t?r=e:_.push({left:r.index,right:(r=e).index,axis:n.axis,gap:n.gap})})}),h)return z=!1,P.renderer().draw(p,!0),P.renderer().drawPorts(p),P.renderer().fireTSEvent(j,p),B(p),this;var K=Date.now();function T(e,t,n){e.forEach(function(e){var t=M[e.dcg_nodeKey];t?(t.cola.x=e.x,t.cola.y=e.y,t.cola.z=e.z):console.warn('received node "'+e.dcg_nodeKey+'" that we did not send, ignored')}),t.forEach(function(e){var t=D[e.dcg_edgeKey];t?e.points&&(t.cola.points=e.points):console.warn('received edge "'+e.dcg_edgeKey+'" that we did not send, ignored')}),d.forEach(function(e){e.cola.bounds=null}),n&&n.forEach(function(e){var t=C[e.dcg_clusterKey];t?e.bounds&&(t.cola.bounds=e.bounds):console.warn('received cluster "'+e.dcg_clusterKey+'" that we did not send, ignored')})}if(P.layoutEngine().on("tick.diagram",function(e,t,n){var r=Date.now()-K;P.initialOnly()||T(e,t,n),P.showLayoutSteps()&&(q(M,u),j.receivedLayout(P,M,o,D,a,R,u),U(M,a,R),P.renderer().draw(p,!0),P.renderer().drawPorts(p),P.renderer().fireTSEvent(j,p)),(H||P.timeLimit()&&r>P.timeLimit())&&(console.log("cancelled"),P.layoutEngine().stop())}).on("end.diagram",function(e,t,n){P.showLayoutSteps()?P.layoutDone(!0):(P.initialOnly()||T(e,t,n),q(M,u),j.receivedLayout(P,M,o,D,a,R,u),U(M,a,R),P.renderer().draw(p,!0),P.renderer().drawPorts(p),P.renderer().fireTSEvent(j,p)),B(p)}).on("start.diagram",function(){console.log("algo "+P.layoutEngine().layoutAlgorithm()+" started."),j.start()}),P.initialOnly())P.layoutEngine().dispatch().end(o,a);else{j.start();var N=P.layoutEngine();N.data({width:P.width(),height:P.height()},o.map(function(t){var n=Object.assign({},t.cola,t.dcg_shape);return N.annotateNode?N.annotateNode(n,t):N.extractNodeAttrs&&Object.keys(N.extractNod