forked from dc-js/dc.graph.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dc.graph.min.js
22 lines (21 loc) · 208 KB
/
dc.graph.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*!
* 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.extractNodeAttrs()).forEach(function(e){n[e]=N.extractNodeAttrs()[e](t.orig)}),n}),E.map(function(t){var n=t.cola;return N.annotateEdge?N.annotateEdge(n,t):N.extractEdgeAttrs&&Object.keys(N.extractEdgeAttrs()).forEach(function(e){n[e]=N.extractEdgeAttrs()[e](t.orig)}),n}),d.map(function(e){return e.cola}),_),N.start()}return this},P.requestRefresh=function(t){window.requestAnimationFrame(function(){var e;void 0!==t&&(e=P.transitionDuration(),P.transitionDuration(t)),P.renderer().refresh(),void 0!==t&&P.transitionDuration(e)})},P.layoutDone=function(e){j.end(e),z=!1,H&&(H=!1,window.setTimeout(function(){P.isRunning()||P.redraw()},0))},P.calcEdgePath=function(e,t,n,r,o,a){var i,u=e.parallel,l=e.source,c=e.target;1<u.edges.length&&e.source.index>e.target.index&&(i=c,c=l,l=i,i=o,o=n,n=i,i=a,a=r,r=i);for(var s=l.dcg_ry+P.nodeStrokeWidth.eval(l)/2,d=c.dcg_ry+P.nodeStrokeWidth.eval(c)/2,f=0;f<u.edges.length;++f){var g=!!(f%2)==n<o?-1:1,p=0<Math.floor((f+1)/2)?u.edges[2<f?f-2:0].pos[t].path:null,h=xe(P,e,n,r,o,a,p,g,P.parallelEdgeOffset(),s,d);1<u.edges.length&&u.rev[f]&&h.points.reverse(),P.enforceEdgeDirection()&&(h=S(h,l.cola,c.cola));var y={points:h.points,bezDegree:h.bezDegree},v=we(P,u.edges[f]),m=(h=be(v.headLength,v.tailLength,h)).points,x=y.points;u.edges[f].pos[t]={path:h,full:y,orienthead:_e(m[m.length-1],x[x.length-1])+"rad",orienttail:_e(m[0],x[0])+"rad"}}},P.calculateBounds=function(e,t){var n=e.map(A).reduce(K);return t.map(N).reduce(K,n)},P.animateZoom=function(e){return arguments.length?(y=e,P):y};var V=["drawn","transitionsStarted","zoomed"].reduce(Y(function(e,t){return'subscribing "'+e+'" to event "'+t+'" which takes renderer-specific parameters'}),{}),J=["end"].reduce(Y(function(e,t){return'subscribing "'+e+'" to event "'+t+'" which may receive inconsistent arguments'}),{});function Z(){var e=m||{left:0,top:0,right:0,bottom:0},t=P.renderer().scale();return{left:e.left-P.margins().left/t,top:e.top-P.margins().top/t,right:e.right+P.margins().right/t,bottom:e.bottom+P.margins().bottom/t}}function $(e,t){return e[0]-P.x()(t)+P.x().range()[0]}function Q(e,t){return e[1]-P.y()(t)+P.y().range()[0]}function ee(e,t){return e[0]-P.x()(t)+P.x().range()[1]}function te(e,t){return e[1]-P.y()(t)+P.y().range()[1]}function ne(e){var t,n=P.x().domain(),r=P.y().domain(),o=Z(),a=o.left<n[0],i=o.right<n[1],u=o.right-o.left<n[1]-n[0];switch(a&&i?t=u?"left":"right":a||i||(t=u?"right":"left"),t){case"left":e[0]=$(e,o.left);break;case"right":e[0]=ee(e,o.right);break;default:0}switch(a=o.top<r[0],i=o.bottom<r[1],u=o.bottom-o.top<r[1]-r[0],a&&i?t=u?"top":"bottom":a||i||(t=u?"bottom":"top"),t){case"top":e[1]=Q(e,o.top);break;case"bottom":e[1]=te(e,o.bottom);break;default:0}return e}return P.on=function(e,t){if(1===arguments.length)return j.on(e);var n=e.split("."),r=V[n[0]]||J[n[0]];return r&&r(n[1]||"")(),j.on(e,t),this},P.getStats=function(){return I},P.x=ce(null),P.y=ce(null),P.redrawGroup=function(){ae.redrawAll(r)},P.renderGroup=function(){ae.renderAll(r)},P.defineArrow=function(e,t){if("function"!=typeof t)throw new Error("sorry, defineArrow no longer takes specific shape parameters, and the parameters have changed too much to convert them. it takes a name and a function returning a definition - please look at arrows.js for new format");return c[e]=t,P},P.arrows=function(){return c},Object.keys(ie.builtin_arrows).forEach(function(e){var t=ie.builtin_arrows[e];P.defineArrow(e,t)}),P.doZoom=function(){(P.width_is_automatic()||P.height_is_automatic())&&G();var e,t=re.event.scale;P.restrictPan()?P.renderer().translate(e=ne(re.event.translate)):e=re.event.translate,P.renderer().globalTransform(e,t,y),j.zoomed(e,t,P.x().domain(),P.y().domain())},P.invertCoord=function(e){return[P.x().invert(e[0]),P.y().invert(e[1])]},P.anchor=function(e,t){if(!arguments.length)return n;if(!e)throw new ae.errors.BadArgumentException("parent must be defined");return n=e.select&&e.classed?e.node():e,P.root(re.select(n)),P.root().classed(ie.constants.CHART_CLASS,!0),ae.registerChart(P,t),r=t,P},P.chartID=function(){return P.__dcFlag__},P.anchorName=function(){var e=P.anchor();return e&&e.id?e.id:e&&e.replace?e.replace("#",""):"dc-graph"+P.chartID()},P.anchor(t,e)},ie.render_svg=function(){var l,n=null,y=null,o=null,v=null,m=null,_=!1,w={};function x(e){w.redrawEdge(e.edge,e.edgeArrows),w.redrawNode(e.node),w.drawPorts(e)}function b(n,e){var r=e?"full":"path";return function(e){var t=e.pos[n][r];return g(t.points,t.bezDegree)}}function k(n){return function(e){var t=e.pos[n].path;return g(t.points[t.points.length-1].x<t.points[0].x?t.points.slice(0).reverse():t.points,t.bezDegree)}}function E(e,t){return n=z,function(){return n.apply(this,arguments)+"rad"}(e,t);var n}function S(e){return!!e.source&&!!e.target}function u(e,t,n,r,o,a,i,u,l,c,s,d,f){console.assert(n.data().every(S));var g={};t.each(function(e){g[w.parent().nodeKey.eval(e)]=!0}).attr("transform",function(e){return"translate("+e.cola.x+","+e.cola.y+")"});var p=e.transition().duration(w.parent().stagedDuration()).delay(function(e){return w.parent().stagedDelay(g[w.parent().nodeKey.eval(e)])}).attr("opacity",w.parent().nodeOpacity.eval);f&&p.attr("transform",function(e){return"translate("+e.cola.x+","+e.cola.y+")"}).each("end.record",function(e){e.prevX=e.cola.x,e.prevY=e.cola.y}),n.each(function(e){e.pos.new=null}),n.each(function(e){var t,n,r,o,a,i;e.cola.points?e.pos.new=(t=w.parent(),r=(n=e).cola.points,o=we(t,n),a={points:r,bezDegree:3},{path:i=be(o.headLength,o.tailLength,a),full:a,orienthead:_e(i.points[i.points.length-1],a.points[a.points.length-1])+"rad",orienttail:_e(i.points[0],a.points[0])+"rad"}):(e.pos.old||w.parent().calcEdgePath(e,"old",e.source.prevX||e.source.cola.x,e.source.prevY||e.source.cola.y,e.target.prevX||e.target.cola.x,e.target.prevY||e.target.cola.y),e.pos.new||w.parent().calcEdgePath(e,"new",e.source.cola.x,e.source.cola.y,e.target.cola.x,e.target.cola.y)),e.pos.old?e.pos.old.path.bezDegree===e.pos.new.path.bezDegree&&e.pos.old.path.points.length===e.pos.new.path.points.length||(P(e.pos.old.path)?(e.pos.new.path.points=L(e.pos.new.path),e.pos.old.path.points=O(L(e.pos.old.path),(e.pos.new.path.points.length-1)/3),e.pos.old.path.bezDegree=e.pos.new.bezDegree=3):P(e.pos.new.path)?(e.pos.old.path.points=L(e.pos.old.path),e.pos.new.path.points=O(L(e.pos.new.path),(e.pos.old.path.points.length-1)/3),e.pos.old.path.bezDegree=e.pos.new.bezDegree=3):console.warn("don't know how to interpolate two multi-segments")):e.pos.old=e.pos.new});var h={};r.each(function(e){h[w.parent().edgeKey.eval(e)]=!0}).attr("d",b("modins"===w.parent().stageTransitions()?"new":"old")),c.each(function(e){var t="modins"===w.parent().stageTransitions()?"new":"old";w.parent().edgeArrowhead.eval(e)&&w.select("#"+w.parent().arrowId(e,"head")).attr("orient",function(){return e.pos[t].orienthead}),w.parent().edgeArrowtail.eval(e)&&w.select("#"+w.parent().arrowId(e,"tail")).attr("orient",function(){return e.pos[t].orienttail})}).attr("d",b("modins"===w.parent().stageTransitions()?"new":"old",!0)),l.each(function(e){w.parent().edgeArrowhead.eval(e)&&w.select("#"+w.parent().arrowId(e,"head")).attr("orient",E(e.pos.old.orienthead,e.pos.new.orienthead)).transition().duration(w.parent().stagedDuration()).delay(w.parent().stagedDelay(!1)).attr("orient",function(){return e.pos.new.orienthead}),w.parent().edgeArrowtail.eval(e)&&w.select("#"+w.parent().arrowId(e,"tail")).attr("orient",E(e.pos.old.orienttail,e.pos.new.orienttail)).transition().duration(w.parent().stagedDuration()).delay(w.parent().stagedDelay(!1)).attr("orient",function(){return e.pos.new.orienttail})});var y=n.transition().duration(w.parent().stagedDuration()).delay(function(e){return w.parent().stagedDelay(h[w.parent().edgeKey.eval(e)])}).attr("opacity",w.parent().edgeOpacity.eval),v=l.transition().duration(w.parent().stagedDuration()).delay(function(e){return w.parent().stagedDelay(h[w.parent().edgeKey.eval(e)])}).attr("opacity",w.parent().edgeOpacity.eval);(f?y:n).attr("d",function(e){return b("insmod"===w.parent().stageTransitions()&&h[w.parent().edgeKey.eval(e)]?"old":"new")(e)}),(f?v:l).attr("d",function(e){return b("insmod"===w.parent().stageTransitions()&&h[w.parent().edgeKey.eval(e)]?"old":"new",!0)(e)});var m=i.selectAll("text").data(function(e){var t=w.parent().edgeLabel.eval(e);return t?"string"==typeof t?[t]:t:[]});m.enter().append("text").attr({class:"edge-label","text-anchor":"middle",dy:function(e,t){return t*w.parent().edgeLabelSpacing.eval(this.parentNode)-2}}).append("textPath").attr("startOffset","50%"),m.select("textPath").html(function(e){return e}).attr("opacity",function(){return w.parent().edgeOpacity.eval(re.select(this.parentNode.parentNode).datum())}).attr("xlink:href",function(e){var t=w.parent().textpathId(re.select(this.parentNode.parentNode).datum());return window.location.href.split("#")[0]+"#"+t}),d.attr("d",k("modins"===w.parent().stageTransitions()?"new":"old"));var x=s.transition().duration(w.parent().stagedDuration()).delay(function(e){return w.parent().stagedDelay(h[w.parent().edgeKey.eval(e)])});f&&x.attr("d",function(e){return k("insmod"===w.parent().stageTransitions()&&h[w.parent().edgeKey.eval(e)]?"old":"new")(e)}),"insmod"===w.parent().stageTransitions()&&f&&(50<=w.parent().stagedDuration()?(y=y.transition().duration(w.parent().stagedDuration()).attr("d",b("new")),x=x.transition().duration(w.parent().stagedDuration()).attr("d",k("new")),v.transition().duration(w.parent().stagedDuration()).attr("d",b("new",!0))):(y.attr("d",b("new")),x.attr("d",b("new")),v.attr("d",b("new",!0)))),_=!0,w.parent().showLayoutSteps()||function(e,t){e.every(function(e){return 0===e.size()})&&t();var n=0;e.forEach(function(e){e.each(function(){++n}).each("end.all",function(){--n||t()})})}([p,y,x],function(){_=!1,w.parent().layoutDone(!0)}),f&&o.attr("d",b("new")),n.each(function(e){e.pos.old=e.pos.new})}return w.rendererType=function(){return"svg"},w.parent=ce(null),w.renderNode=w._enterNode=function(e){return w.parent().nodeTitle()&&e.append("title"),e.each(h(w.parent())),w.parent().forEachShape(e,function(e,t){t.call(e.create)}),w},w.redrawNode=w._updateNode=function(e){var r,t,n,o=e.filter((r=w.parent(),function(e){var t=d(r,e),n=e.dcg_shape.abstract;return t.shape!==n.shape||"polygon"===t.shape&&(t.shape.sides!==n.sides||t.shape.skew!==n.skew||t.shape.distortion!==n.distortion||t.shape.rotation!==n.rotation)}));return o.selectAll(".node-shape").remove(),o.each(h(w.parent())),w.parent().forEachShape(o,function(e,t){t.call(e.create)}),e.select("title").text(w.parent().nodeTitle.eval),w.parent().forEachContent(e,function(e,t){t.call(e.update),w.parent().forEachShape(e.selectContent(t),function(e,t){var s,d;t.call((s=e,d=w.parent(),function(e){e.each(function(e){var t=null;if((!s.useTextSize||s.useTextSize(e.dcg_shape))&&d.nodeFitLabel.eval(e)){var n;t={x:(t=A(this)).x,y:t.y,width:t.width,height:t.height};var r=d.nodeContent.eval(e);if(r&&d.content(r).padding)n=d.content(r).padding(e);else{var o=p(d,e);n={x:2*o.x,y:2*o.y}}t.width+=n.x,t.height+=n.y,e.bbox=t}var a,i=0;s.useRadius&&!s.useRadius(e.dcg_shape)||(i=d.nodeRadius.eval(e)),a=t&&t.width&&t.height||s.useTextSize&&!s.useTextSize(e.dcg_shape)?s.calc_radii(e,i,t):{rx:i,ry:i},e.dcg_rx=a.rx,e.dcg_ry=a.ry;var u=2*a.rx,l=2*a.ry;if(!s.usePaddingAndStroke||s.usePaddingAndStroke(e.dcg_shape)){var c=d.nodePadding.eval(e)+d.nodeStrokeWidth.eval(e);u+=c,l+=c}e.cola.width=u,e.cola.height=l})}))})}),w.parent().forEachShape(e,function(e,t){t.call(e.update)}),e.select(".node-shape").attr({stroke:w.parent().nodeStroke.eval,"stroke-width":w.parent().nodeStrokeWidth.eval,"stroke-dasharray":w.parent().nodeStrokeDashArray.eval,fill:(t=w.parent().nodeFillScale()||le,n=w.parent().nodeFill.eval,function(){return t(n.apply(null,arguments))})}),w},w.redrawEdge=w._updateEdge=function(e,t){e.attr("stroke",w.parent().edgeStroke.eval).attr("stroke-width",w.parent().edgeStrokeWidth.eval).attr("stroke-dasharray",w.parent().edgeStrokeDashArray.eval),t.attr("marker-end",function(e){var t=w.parent().edgeArrowhead.eval(e),n=F(w.parent(),w.parent().arrows(),e,"head",t);return n?"url(#"+n+")":null}).attr("marker-start",function(e){var t=w.parent().edgeArrowtail.eval(e),n=F(w.parent(),w.parent().arrows(),e,"tail",t);return t?"url(#"+n+")":null}).each(function(e){w.parent().edgeStroke.eval(e);w.selectAll("#"+w.parent().arrowId(e,"head")).attr("fill",w.parent().edgeStroke.eval(e)),w.selectAll("#"+w.parent().arrowId(e,"tail")).attr("fill",w.parent().edgeStroke.eval(e))})},w.selectAllNodes=function(e){return e=e||".node",v&&v.selectAll(e).filter(function(e){return!e.deleted})||re.selectAll(".foo-this-does-not-exist")},w.selectAllEdges=function(e){return e=e||".edge",m&&m.selectAll(e).filter(function(e){return!e.deleted})||re.selectAll(".foo-this-does-not-exist")},w.selectAllDefs=function(e){return y&&y.selectAll(e).filter(function(e){return!e.deleted})||re.selectAll(".foo-this-does-not-exist")},w.resize=function(e,t){return n&&n.attr("width",e||(w.parent().width_is_automatic()?"100%":w.parent().width())).attr("height",t||(w.parent().height_is_automatic()?"100%":w.parent().height())),w},w.rezoom=function(e,t,n,r){var o=l.scale(),a=l.translate();l.scale(1).translate([0,0]);var i=w.parent().x().domain(),u=w.parent().y().domain();w.parent().x().domain([i[0],i[0]+(i[1]-i[0])*n/e]).range([0,n]),w.parent().y().domain([u[0],u[0]+(u[1]-u[0])*r/t]).range([0,r]),l.x(w.parent().x()).y(w.parent().y()).translate(a).scale(o)},w.globalTransform=function(e,t,n){var r=o;n&&(r=o.transition().duration(w.parent().zoomDuration())),r.attr("transform","translate("+e+") scale("+t+")")},w.translate=function(e){return arguments.length?(l.translate(e),this):l.translate()},w.scale=function(e){return arguments.length?(l.scale(e),this):l?l.scale():1},w.commitTranslateScale=function(){l.event(n)},w.zoom=function(e){return arguments.length?(l=e,w):l},w.startRedraw=function(e,t,n){var r=m.selectAll(".edge").data(n,w.parent().edgeKey.eval),o=r.enter().append("svg:path").attr({class:"edge",id:w.parent().edgeId,opacity:0}).each(function(e){e.deleted=!1});r.exit().each(function(e){e.deleted=!0}).transition().duration(w.parent().stagedDuration()).delay(w.parent().deleteDelay()).attr("opacity",0).remove();var a=m.selectAll(".edge-arrows").data(n,w.parent().edgeKey.eval),i=a.enter().append("svg:path").attr({class:"edge-arrows",id:function(e){return w.parent().edgeId(e)+"-arrows"},fill:"none",opacity:0});a.exit().transition().duration(w.parent().stagedDuration()).delay(w.parent().deleteDelay()).attr("opacity",0).remove().each("end.delarrow",function(e){F(w.parent(),w.parent().arrows(),e,"head",null),F(w.parent(),w.parent().arrows(),e,"tail",null)}),w.parent().edgeSort()&&r.sort(function(e,t){var n=w.parent().edgeSort.eval(e),r=w.parent().edgeSort.eval(t);return n<r?-1:r<n?1:0});var u=m.selectAll(".edge-hover").data(n,w.parent().edgeKey.eval),l=u.enter().append("svg:path").attr("class","edge-hover").attr("opacity",0).attr("fill","none").attr("stroke","green").attr("stroke-width",10).on("mouseover.diagram",function(e){w.select("#"+w.parent().edgeId(e)+"-label").attr("visibility","visible")}).on("mouseout.diagram",function(e){w.select("#"+w.parent().edgeId(e)+"-label").attr("visibility","hidden")});u.exit().remove();var c=m.selectAll("g.edge-label-wrapper").data(n,w.parent().edgeKey.eval),s=c.enter().append("g").attr("class","edge-label-wrapper").attr("visibility","hidden").attr("id",function(e){return w.parent().edgeId(e)+"-label"}),d=y.selectAll("path.edge-label-path").data(n,w.parent().textpathId),f=d.enter().append("svg:path").attr({class:"edge-label-path",id:w.parent().textpathId});c.exit().transition().duration(w.parent().stagedDuration()).delay(w.parent().deleteDelay()).attr("opacity",0).remove();var g=v.selectAll(".node").data(t,w.parent().nodeKey.eval),p=g.enter().append("g").attr("class","node").attr("opacity","0").each(function(e){e.deleted=!1});w.renderNode(p),g.exit().each(function(e){e.deleted=!0}).transition().duration(w.parent().stagedDuration()).delay(w.parent().deleteDelay()).attr("opacity",0).remove(),e.drawn(g,r,u);var h={node:g,nodeEnter:p,edge:r,edgeEnter:o,edgeHover:u,edgeHoverEnter:l,edgeLabels:c,edgeLabelsEnter:s,edgeArrows:a,edgeArrowsEnter:i,textPaths:d,textPathsEnter:f};return x(h),h},w.refresh=function(e,t,n,r,o){if(_)return this;e=e||w.selectAllNodes(),t=t||w.selectAllEdges();var a=w.selectAllEdges(".edge-arrows");x({node:e,edge:t,edgeArrows:a}),n=n||w.selectAllEdges(".edge-hover"),r=r||w.selectAllEdges(".edge-label-wrapper"),o=o||w.selectAllDefs("path.edge-label-path");var i=re.select(null);return u(e,i,t,i,n,i,r,i,a,i,o,i,!1),this},w.reposition=function(e,t){return e.attr("transform",function(e){return"translate("+e.cola.x+","+e.cola.y+")"}),t.each(function(e){e.pos.new=null,e.pos.old=null,e.cola.points=null,w.parent().calcEdgePath(e,"new",e.source.cola.x,e.source.cola.y,e.target.cola.x,e.target.cola.y),w.parent().edgeArrowhead.eval(e)&&w.select("#"+w.parent().arrowId(e,"head")).attr("orient",function(){return e.pos.new.orienthead}),w.parent().edgeArrowtail.eval(e)&&w.select("#"+w.parent().arrowId(e,"tail")).attr("orient",function(){return e.pos.new.orienttail}),w.select("#"+w.parent().edgeId(e)+"-arrows").attr("d",b("new",!0))}).attr("d",b("new")),this},w.draw=function(e,t){u(e.node,e.nodeEnter,e.edge,e.edgeEnter,e.edgeHover,e.edgeHoverEnter,e.edgeLabels,e.edgeLabelsEnter,e.edgeArrows,e.edgeArrowsEnter,e.textPaths,e.textPathsEnter,t)},w.isRendered=function(){return!!n},w.initializeDrawing=function(){w.resetSvg(),o=n.append("g").attr("class","draw");var e=["edge-layer","node-layer"];return w.parent().edgesInFront()&&e.reverse(),o.selectAll("g").data(e).enter().append("g").attr("class",function(e){return e}),m=o.selectAll("g.edge-layer"),v=o.selectAll("g.node-layer"),this},w.select=function(e){return w.parent().root().select(e)},w.selectAll=function(e){return w.parent().root()?w.parent().root().selectAll(e):null},w.selectNodePortsOfStyle=function(e,t){return e.selectAll("g.port").filter(function(e){return w.parent().portStyleName.eval(e)===t})},w.drawPorts=function(o){var a=w.parent().nodePorts();a&&w.parent().portStyle.enum().forEach(function(t){var e={};for(var n in a)e[n]=a[n].filter(function(e){return w.parent().portStyleName.eval(e)===t});var r=w.selectNodePortsOfStyle(o.node,t);w.parent().portStyle(t).drawPorts(r,e,o.node)})},w.fireTSEvent=function(e,t){e.transitionsStarted(t.node,t.edge,t.edgeHover)},w.calculateBounds=function(e){return e.node.size()?w.parent().calculateBounds(e.node.data(),e.edge.data()):null},w.svg=function(e){return arguments.length?(n=e,w):n},w.g=function(e){return arguments.length?(o=e,w):o},w.resetSvg=function(){return(n||w.select("svg")).remove(),n=null,function(){if(n=w.parent().root().append("svg"),w.resize(),y=n.append("svg:defs"),l=re.behavior.zoom().on("zoom.diagram",w.parent().doZoom).x(w.parent().x()).y(w.parent().y()).scaleExtent(w.parent().zoomExtent()),w.parent().mouseZoomable()){w.parent().child("brush");var e=w.parent().child("keyboard");e||w.parent().child("keyboard",e=ie.keyboard());var t=function(){e.modKeysMatch(w.parent().modKeyZoom())?(n.call(l),n.on("dblclick.zoom",null)):n.on(".zoom",null)};e.on("modkeyschanged.zoom",t),t()}return n}()},w.addOrRemoveDef=function(e,t,n,r){var o=t?[0]:[],a=y.selectAll("#"+e).data(o),i=a.enter().append(n).attr("id",e);return i.size()&&r&&i.call(r),a.exit().remove(),a},w.animating=function(){return _},w},ie.render_webgl=function(){var t,c,n,r,o,s,d,a={},i={},f=!1,g={};function p(e){return 7===e.length&&"#"===e[0]||(console.warn("don't know how to use color "+e),e="#888888"),parseInt(e.slice(1),16)}function u(){window.requestAnimationFrame(u),n.render(c,t)}return g.rendererType=function(){return"webgl"},g.parent=ce(null),g.isRendered=function(){return!!t},g.resize=function(e,t){return g},g.rezoom=function(e,t,n,r){return g},g.globalTransform=function(e,t,n){return g},g.translate=function(e){return arguments.length?g:[0,0]},g.scale=function(e){return arguments.length?g:1},g.commitTranslateScale=function(){},g.initializeDrawing=function(){if(c)return g;(t=new THREE.PerspectiveCamera(45,window.innerWidth/window.innerHeight,1,1e4)).up=new THREE.Vector3(0,0,1),c=new THREE.Scene,d=new THREE.SphereBufferGeometry(10,32,32),(r=new THREE.DirectionalLight(16777215,1)).position.set(-1,-1,1).normalize(),c.add(r),o=new THREE.AmbientLight(11184810),c.add(o),(n=new THREE.WebGLRenderer({antialias:!0})).setPixelRatio(window.devicePixelRatio);var e=g.parent().root().node().getBoundingClientRect();return n.setSize(e.width,e.height),g.parent().root().node().appendChild(n.domElement),(s=new THREE.OrbitControls(t,n.domElement)).minDistance=300,s.maxDistance=1e3,g},g.startRedraw=function(e,t,n){t.forEach(h(g.parent()));var r=ve(a,t,null,function(e){return g.parent().nodeKey.eval(e)},function(e,t){e.wnode=t},null,function(e,t){c.remove(t.mesh),t.material.dispose()}),o=ve(i,n,null,function(e){return g.parent().edgeKey.eval(e)},function(e,t){e.wedge=t},null,function(e,t){c.remove(t.mesh),t.geometry.dispose(),t.material.dispose()});return u(),{wnodes:t,wedges:n,rnodes:r,redges:o}},g.color_to_int=p,g.draw=function(e,t){e.wedges.forEach(function(e){e.pos.old||g.parent().calcEdgePath(e,"old",e.source.prevX||e.source.cola.x,e.source.prevY||e.source.cola.y,e.target.prevX||e.target.cola.x,e.target.prevY||e.target.cola.y),e.pos.new||g.parent().calcEdgePath(e,"new",e.source.cola.x,e.source.cola.y,e.target.cola.x,e.target.cola.y)});var i=g.multiplier();e.rnodes.forEach(function(e){var t=g.parent().nodeFill.eval(e.wnode),n=!1;if(!e.mesh){n=!0,g.parent().nodeFillScale()&&(t=g.parent().nodeFillScale()(t));var r=p(t);e.material=new THREE.MeshLambertMaterial({color:r}),e.mesh=new THREE.Mesh(d,e.material),e.mesh.name=g.parent().nodeKey.eval(e.wnode)}e.mesh.position.x=e.wnode.cola.x*i,e.mesh.position.y=-e.wnode.cola.y*i,e.mesh.position.z=e.wnode.cola.z*i||0,n&&c.add(e.mesh)});var n=re.extent(e.wnodes,function(e){return e.cola.x*i}),r=re.extent(e.wnodes,function(e){return-e.cola.y*i}),o=re.extent(e.wnodes,function(e){return e.cola.z*i||0}),a=(n[0]+n[1])/2,u=(r[0]+r[1])/2,l=(o[0]+o[1])/2;e.center=[a,u,l],e.extents=[n,r,o],s.target.set(a,u,l),s.update();return e.redges.forEach(function(e){if(e.wedge.source&&e.wedge.target){var t=e.wedge.source.cola,n=e.wedge.target.cola,r=!1,o=g.parent().edgeStrokeWidth.eval(e.wedge);if(e.mesh)e.curve=new THREE.LineCurve3(new THREE.Vector3(t.x*i,-t.y*i,t.z*i||0),new THREE.Vector3(n.x*i,-n.y*i,n.z*i||0)),e.geometry.dispose(),e.geometry=new THREE.TubeBufferGeometry(e.curve,20,o/2,8,!1),e.mesh.geometry=e.geometry;else{r=!0;var a=p(g.parent().edgeStroke.eval(e.wedge));e.material=new THREE.MeshLambertMaterial({color:a}),e.curve=new THREE.LineCurve3(new THREE.Vector3(t.x*i,-t.y*i,t.z*i||0),new THREE.Vector3(n.x*i,-n.y*i,n.z*i||0)),e.geometry=new THREE.TubeBufferGeometry(e.curve,20,o/2,8,!1),e.mesh=new THREE.Mesh(e.geometry,e.material),e.mesh.name=g.parent().edgeKey.eval(e.wedge)}r&&c.add(e.mesh)}}),f=!1,g.parent().layoutDone(!0),g},g.drawPorts=function(r){var o=g.parent().nodePorts();o&&g.parent().portStyle.enum().forEach(function(t){var e={};for(var n in o)e[n]=o[n].filter(function(e){return g.parent().portStyleName.eval(e)===t});g.selectNodePortsOfStyle(r.node,t)})},g.fireTSEvent=function(e,t){e.transitionsStarted(c,t)},g.calculateBounds=function(e){return e.wnodes.length?g.parent().calculateBounds(e.wnodes,e.wedges):null},g.refresh=function(e,t,n,r,o){return g},g.reposition=function(e,t){return g},g.animating=function(){return f},g.multiplier=ce(3),g},ie.spawn_engine=function(e,t,n){t=t||{},n=n&&!!window.Worker;var r=ie.engines.instantiate(e,t,n);return r||(console.warn("layout engine "+e+" not found; using default "+ie._default_engine),r=ie.engines.instantiate(ie._default_engine,t,n)),r},ie._engines=[{name:"dagre",params:["rankdir"],instantiate:function(){return ie.dagre_layout()}},{name:"d3force",instantiate:function(){return ie.d3_force_layout()}},{name:"d3v4force",instantiate:function(){return ie.d3v4_force_layout()}},{name:"tree",instantiate:function(){return ie.tree_layout()}},{names:["circo","dot","neato","osage","twopi","fdp"],instantiate:function(e,t){return ie.graphviz_layout(null,e,t.server)}},{name:"cola",params:["lengthStrategy"],instantiate:function(){return ie.cola_layout()}},{name:"manual",instantiate:function(){return ie.manual_layout()}},{name:"flexbox",instantiate:function(){return ie.flexbox_layout()}},{name:"layered",instantiate:function(){return ie.layered_layout()}}],ie._default_engine="cola",ie.engines={entry_pred:function(t){return function(e){return e.name&&e.name===t||e.names&&e.names.includes(t)}},get:function(e){return ie._engines.find(this.entry_pred(e))},instantiate:function(e,t,n){var r=this.get(e);if(!r)return null;var o=r.instantiate(e,t);return(r.params||[]).forEach(function(e){t[e]&&o[e](t[e])}),o.supportsWebworker&&o.supportsWebworker()&&n&&(o=ie.webworker_layout(o)),o},available:function(){return ie._engines.reduce(function(e,t){return e.concat(t.name?[t.name]:t.names)},[])},unregister:function(e){var t=ie._engines.findIndex(this.entry_pred(e)),n=!1;if(t<0)return!1;var r=ie._engines[t];if(r.name===e)n=!0;else{var o=r.names.indexOf(e);0<=o?r.names.splice(o,1):console.warn("search for engine failed",e),0===r.names.length&&(n=!0)}return n&&ie._engines.splice(t,1),!0},register:function(e){var t=this;if(!e.instantiate)return console.error("engine definition needs instantiate: function(layout, args) { ... }"),this;if(e.name)this.unregister(e.name);else{if(!e.names)return console.error("engine definition needs name or names[]"),this;e.names.forEach(function(e){t.unregister(e)})}return ie._engines.push(e),this}};var W,H,G,B={};function q(e){return e.value.value?e.value.value:e.value}function ke(e,t,n){return e||t?(e&&(e=e.replace(/\//g,"%2F")),t&&(t=t.replace(/\//g,"%2F")),(e?"node/"+e:"edge/"+t)+"/"+n):null}function Ee(e,t,n){if(!n.vec)throw console.assert(!n.edges.length),new Error("port has not been placed, maybe install place_ports? "+n.name);n.pos=e.shape(t.dcg_shape.shape).intersect_vec(t,1e3*n.vec[0],1e3*n.vec[1])}function U(e){var t=function(){return{type:"alignment",axis:e}};return t.listname="offsets",t.wrap=function(e){return{node:e,offset:0}},t}function X(e,t,n){if(t)e(t,null);else{var r,o,a={},i=[];if(graphlibDot.parse){var u=graphlibDot.parse(n),l=u.nodes();r=new Array(l.length),l.forEach(function(e,t){var n=r[t]=u._nodes[l[t]];n.id=t,n.name=e});var c=u.edges();o=[],c.forEach(function(e){var t=u._edges[e];o.push(Object.assign({},t.value,{source:u._nodes[t.u].id,target:u._nodes[t.v].id,sourcename:t.u,targetname:t.v}))})}else{u=graphlibDot.read(n),l=u.nodes(),r=new Array(l.length),l.forEach(function(e,t){var n=r[t]=u._nodes[l[t]];n.id=t,n.name=e}),o=[],u.edges().forEach(function(e){o.push(Object.assign({},u.edge(e.v,e.w),{source:u._nodes[e.v].id,target:u._nodes[e.w].id,sourcename:e.v,targetname:e.w}))});for(var s={},d=u.children().map(function(e){return Object.assign({parent:null,key:e},u.node(e))});d.length;){var f=d.shift(),g=u.children(f.key);g.length?(i.push(f),s[f.key]=!0):a[f.key]=f.parent,d=d.concat(g.map(function(e){return{parent:f.key,key:e}}))}r=r.filter(function(e){return!s[e.name]})}e(null,{nodes:r,links:o,node_cluster:a,clusters:i})}}function Y(e,t,n){if(t)e(t,null);else{var r=Object.keys(n[0]),o=r[0],a=r[1],i=re.set(n.map(function(e){return e[o]}));n.forEach(function(e){i.add(e[a])}),e(null,{nodes:i=i.values().map(function(e){return{name:e}}),links:n.map(function(e,t){return{key:t,sourcename:e[o],targetname:e[a]}})})}}function V(e){var t=e.split(".");return t.length?new Error("do not know how to process graph file extension "+t[t.length-1]):new Error("need file extension to process graph file automatically, filename "+e)}function J(e){return(e.nodes||e.vertices)&&(e.edges||e.links)}ie.webworker_layout=function(a){var n=re.dispatch("init","start","tick","end"),i=function(e){if(!B[e]){var r=B[e]={worker:new Worker(o()+"dc.graph."+e+".worker.js"),layouts:{}};r.worker.onmessage=function(e){var t=e.data.layoutId;if(!r.layouts[t])throw new Error('layoutId "'+t+'" unknown!');var n=r.layouts[t].getEngine();3<e.data.args.length&&n.processExtraWorkerResults&&n.processExtraWorkerResults.apply(n,e.data.args.slice(3)),r.layouts[t].dispatch()[e.data.response].apply(null,e.data.args)}}return B[e]}(a.layoutAlgorithm()),e={};(i.layouts[a.layoutId()]=e).parent=function(e){a.parent&&a.parent(e)},e.init=function(e){return e=a.optionNames().reduce(function(e,t){return e[t]=a[t](),e},e),a.propagateOptions&&a.propagateOptions(e),i.worker.postMessage({command:"init",args:{layoutId:a.layoutId(),options:e}}),this},e.data=function(e,t,n,r,o){i.worker.postMessage({command:"data",args:{layoutId:a.layoutId(),graph:e,nodes:t,edges:n,clusters:r,constraints:o}})},e.start=function(){i.worker.postMessage({command:"start",args:{layoutId:a.layoutId()}})},e.stop=function(){return i.worker.postMessage({command:"stop",args:{layoutId:a.layoutId()}}),this},e.getEngine=function(){return a};return["layoutAlgorithm","populateLayoutNode","populateLayoutEdge","rankdir","ranksep"].concat(a.optionNames(),a.passThru?a.passThru():[]).forEach(function(t){e[t]=function(){var e=a[t].apply(a,arguments);return arguments.length?this:e}}),e.on=function(e,t){return 1===arguments.length?n.on(e):(n.on(e,t),this)},e.dispatch=function(){return n},e},ie.graphviz_attrs=function(){return{rankdir:ce("TB"),nodesep:ce(40),ranksep:ce(40)}},ie.apply_graphviz_accessors=function(t){t.nodeLabel(function(e){var t=q(e).label;return void 0===t&&(t=e.key),t&&t.split(/\n|\\n/)}).nodeRadius(function(e){return q(e).radius||25}).nodeShape(function(e){return q(e).shape}).nodeFill(function(e){return q(e).fillcolor||"white"}).nodeOpacity(function(e){return q(e).opacity||1}).nodeLabelFill(function(e){return q(e).fontcolor||"black"}).nodeTitle(function(e){return q(e).htmltip||q(e).jsontip?null:void 0!==q(e).tooltip?q(e).tooltip:t.nodeLabel()(e)}).nodeStrokeWidth(function(e){var t=q(e).penwidth;return void 0!==t?+t:1}).edgeLabel(function(e){return e.value.label?e.value.label.split(/\n|\\n/):""}).edgeStroke(function(e){return e.value.color||"black"}).edgeOpacity(function(e){return e.value.opacity||1}).edgeArrowSize(function(e){return e.value.arrowsize||1}).edgeArrowhead(function(e){var t=e.value.arrowhead;return void 0!==t?t:"vee"}).edgeArrowtail(function(e){var t=e.value.arrowtail;return void 0!==t?t:null}).edgeStrokeDashArray(function(e){switch(e.value.style){case"dotted":return[1,5]}return null});var e=t.child("draw-clusters");e&&e.clusterStroke(function(e){return e.value.color||"black"}).clusterFill(function(e){return"filled"===e.value.style?e.value.fillcolor||e.value.color||e.value.bgcolor:null}).clusterLabel(function(e){return e.value.label})},ie.snapshot_graphviz=function(t){var e=t.x().domain(),n=t.y().domain();return{nodes:t.nodeGroup().all().map(function(e){return t.getWholeNode(e.key)}).filter(function(e){return e}).map(function(e){return{key:t.nodeKey.eval(e),label:t.nodeLabel.eval(e),fillcolor:t.nodeFillScale()(t.nodeFill.eval(e)),penwidth:t.nodeStrokeWidth.eval(e),radius:t.nodeRadius.eval(e),opacity:t.nodeOpacity.eval(e),x:e.cola.x,y:e.cola.y}}),edges:t.edgeGroup().all().map(function(e){return t.getWholeEdge(e.key)}).map(function(e){return{key:t.edgeKey.eval(e),source:t.edgeSource.eval(e),target:t.edgeTarget.eval(e),color:t.edgeStroke.eval(e),arrowsize:t.edgeArrowSize.eval(e),opacity:t.edgeOpacity.eval(e),arrowhead:t.edgeArrowhead.eval(e),arrowtail:t.edgeArrowtail.eval(e)}}),bounds:{left:e[0],top:n[0],right:e[1],bottom:n[1]}}},ie.cola_layout=function(e){var d,t,f,n=e||K(),g=null,p=re.dispatch("tick","start","end"),h={},y={};var r=ie.graphviz_attrs(),o=Object.keys(r);r.rankdir(null);var v=Object.assign(r,{layoutAlgorithm:function(){return"cola"},layoutId:function(){return n},supportsWebworker:function(){return!0},supportsMoving:function(){return!0},parent:ce(null),on:function(e,t){return 1===arguments.length?p.on(e):(p.on(e,t),this)},init:function(t){return this.optionNames().forEach(function(e){t[e]=t[e]||this[e]()}.bind(this)),this.propagateOptions(t),function(t){switch(f=t,(g=cola.d3adaptor().avoidOverlaps(!0).size([t.width,t.height]).handleDisconnected(t.handleDisconnected)).tickSize&&g.tickSize(t.tickSize),t.lengthStrategy){case"symmetric":g.symmetricDiffLinkLengths(t.baseLength);break;case"jaccard":g.jaccardLinkLengths(t.baseLength);break;case"individual":g.linkDistance(function(e){return e.dcg_edgeLength||t.baseLength})}t.flowLayout&&g.flowLayout(t.flowLayout.axis,t.flowLayout.minSeparation)}(t),this},data:function(e,t,n,r,o){!function(e,t,n,r){var o=ve(h,e,null,function(e){return e.dcg_nodeKey},function(t,n){t.dcg_nodeKey=n.dcg_nodeKey,t.dcg_nodeParentCluster=n.dcg_nodeParentCluster,t.width=n.width,t.height=n.height,t.fixed=!!n.dcg_nodeFixed,f.nodeAttrs.forEach(function(e){t[e]=n[e]}),t.fixed&&"object"==typeof n.dcg_nodeFixed?(t.x=n.dcg_nodeFixed.x,t.y=n.dcg_nodeFixed.y):(void 0!==n.x&&(t.x=n.x),void 0!==n.y&&(t.y=n.y))}),a=ve(y,t,null,function(e){return e.dcg_edgeKey},function(t,n){t.dcg_edgeKey=n.dcg_edgeKey,t.source=h[n.dcg_edgeSource],t.target=h[n.dcg_edgeTarget],t.dcg_edgeLength=n.dcg_edgeLength,f.edgeAttrs.forEach(function(e){t[e]=n[e]})});o.forEach(function(e,t){e.index=t});var i=null;if(v.groupConnected()){var u=cola.separateGraphs(o,a);i=u.map(function(e){return{dcg_autoGroup:!0,leaves:e.array.map(function(e){return e.index})}})}else if(n){var l={};i=n.filter(function(e){return/^cluster/.test(e.dcg_clusterKey)}).map(function(e,t){return l[e.dcg_clusterKey]={dcg_clusterKey:e.dcg_clusterKey,index:t,groups:[],leaves:[]}}),n.forEach(function(e){e.dcg_clusterParent&&l[e.dcg_clusterParent]&&l[e.dcg_clusterParent].groups.push(l[e.dcg_clusterKey].index)}),o.forEach(function(e,t){e.dcg_nodeParentCluster&&l[e.dcg_nodeParentCluster]&&l[e.dcg_nodeParentCluster].leaves.push(t)})}function c(e){o.forEach(function(t){Object.keys(t).forEach(function(e){/^get/.test(e)&&"function"==typeof t[e]&&delete t[e]})}),p[e](o,a.map(function(e){return{dcg_edgeKey:e.dcg_edgeKey}}),i.filter(function(e){return!e.dcg_autoGroup}).map(function(e){return(e=Object.assign({},e)).bounds={left:e.bounds.x,top:e.bounds.y,right:e.bounds.X,bottom:e.bounds.Y},e}),d)}if(g.on("tick",function(){c("tick")}).on("start",function(){p.start()}).on("end",function(){c("end")}),f.setcolaSpec&&"undefined"!=typeof setcola){console.log("generating setcola constrains");var s=setcola.nodes(o).links(a).constraints(f.setcolaSpec).gap(10).layout();d=s.nodes.filter(function(e){return e._cid}),g.nodes(s.nodes).links(s.links).constraints(s.constraints).groups(i)}else g.nodes(o).links(a).constraints(r).groups(i)}(t,n,r,o)},start:function(){g.start(v.unconstrainedIterations(),v.userConstraintIterations(),v.allConstraintsIterations(),v.gridSnapIterations())},stop:function(){g&&g.stop()},optionNames:function(){return["handleDisconnected","lengthStrategy","baseLength","flowLayout","tickSize","groupConnected","setcolaSpec","setcolaNodes"].concat(o)},passThru:function(){return["extractNodeAttrs","extractEdgeAttrs"]},propagateOptions:function(e){e.nodeAttrs||(e.nodeAttrs=Object.keys(v.extractNodeAttrs())),e.edgeAttrs||(e.edgeAttrs=Object.keys(v.extractEdgeAttrs()))},populateLayoutNode:function(){},populateLayoutEdge:function(){},handleDisconnected:ce(!0),lengthStrategy:ce("symmetric"),baseLength:ce(30),flowLayout:function(e){if(!arguments.length){if(t)return t;switch(v.rankdir()){case"LR":return{axis:"x",minSeparation:v.ranksep()+2*v.parent().nodeRadius()};case"TB":return{axis:"y",minSeparation:v.ranksep()+2*v.parent().nodeRadius()};default:return null}}return t=e,this},unconstrainedIterations:ce(10),userConstraintIterations:ce(20),allConstraintsIterations:ce(20),gridSnapIterations:ce(0),tickSize:ce(1),groupConnected:ce(!1),setcolaSpec:ce(null),setcolaNodes:function(){return d},extractNodeAttrs:ce({}),extractEdgeAttrs:ce({}),processExtraWorkerResults:function(e){d=e}});return v},ie.cola_layout.scripts=["d3.js","cola.js"],ie.cola_layout.optional_scripts=["setcola.js"],ie.dagre_layout=function(e){var i,t=e||K(),u=null,l=re.dispatch("tick","start","end"),c={},s={};var n=ie.graphviz_attrs(),r=Object.keys(n);return Object.assign(n,{layoutAlgorithm:function(){return"dagre"},layoutId:function(){return t},supportsWebworker:function(){return!0},on:function(e,t){return 1===arguments.length?l.on(e):(l.on(e,t),this)},init:function(t){var e;return this.optionNames().forEach(function(e){t[e]=t[e]||this[e]()}.bind(this)),e=t,(u=new dagre.graphlib.Graph({multigraph:!0,compound:!0})).setGraph({rankdir:e.rankdir,nodesep:e.nodesep,ranksep:e.ranksep}),u.setDefaultEdgeLabel(function(){return{}}),this},data:function(e,t,n,r){!function(e,t,n){var r=ve(c,e,null,function(e){return e.dcg_nodeKey},function(e,t){e.dcg_nodeKey=t.dcg_nodeKey,e.width=t.width,e.height=t.height},function(e,t){u.setNode(e,t)},function(e){u.removeNode(e)}),o=ve(s,t,null,function(e){return e.dcg_edgeKey},function(e,t){e.dcg_edgeKey=t.dcg_edgeKey,e.dcg_edgeSource=t.dcg_edgeSource,e.dcg_edgeTarget=t.dcg_edgeTarget},function(e,t,n){u.setEdge(n.dcg_edgeSource,n.dcg_edgeTarget,t)},function(e,t){u.removeEdge(t.dcg_edgeSource,t.dcg_edgeTarget,t.dcg_edgeKey)});function a(e){l[e](r,o.map(function(e){return{dcg_edgeKey:e.dcg_edgeKey}}),n.map(function(e){return(e=Object.assign({},u.node(e.dcg_clusterKey))).bounds={left:e.x-e.width/2,top:e.y-e.height/2,right:e.x+e.width/2,bottom:e.y+e.height/2},e}))}(n=n.filter(function(e){return/^cluster/.test(e.dcg_clusterKey)})).forEach(function(e){u.setNode(e.dcg_clusterKey,e)}),n.forEach(function(e){e.dcg_clusterParent&&u.setParent(e.dcg_clusterKey,e.dcg_clusterParent)}),e.forEach(function(e){e.dcg_nodeParentCluster&&u.setParent(e.dcg_nodeKey,e.dcg_nodeParentCluster)}),function(){a("tick")},i=function(){a("end")}}(t,n,r)},start:function(){l.start(),dagre.layout(u),i()},stop:function(){},optionNames:function(){return r},populateLayoutNode:function(){},populateLayoutEdge:function(){}})},ie.dagre_layout.scripts=["d3.js","dagre.js"],ie.tree_layout=function(e){var n,r,o,t=e||K(),a=re.dispatch("tick","start","end");return{layoutAlgorithm:function(){return"tree"},layoutId:function(){return t},supportsWebworker:function(){return!1},on:function(e,t){return 1===arguments.length?a.on(e):(a.on(e,t),this)},init:function(t){return this.optionNames().forEach(function(e){t[e]=t[e]||this[e]()}.bind(this)),function(a){var i,u=re.functor(a.nodeWidth);function f(e,t){return(u(e)+u(t))/2}n=ie.depth_first_traversal({nodeid:function(e){return e.dcg_nodeKey},sourceid:function(e){return e.dcg_edgeSource},targetid:function(e){return e.dcg_edgeTarget},init:function(){i=a.offsetX},row:function(e){return e.dcg_rank},place:function(e,t,n){if(n.length){var r=n[n.length-1],o=(u(r)+u(e))/2;i=Math.max(i,r.left_x+o)}e.left_x=i,e.hit_ins=1,e.y=t*a.gapY+a.offsetY},sib:function(e,t,n){var r=f(t,n);e&&(r*=1.5),i+=r},pop:function(e){e.x=(e.left_x+i)/2},skip:function(e,t){e.x=(e.hit_ins*e.x+i)/++e.hit_ins,e.hit_ins===t&&delete e.hit_ins},finish:function(e){e.forEach(function(e){for(var t,n=e.sort(function(e,t){return e.x-t.x}),r=null,o=null,a=0;a<n.length-1;++a){var i=n[a],u=n[a+1];if(r){if(t+=f(i,u),a<n.length-2&&u.x<o+t)continue;var l,c;if(0<r&&--r,a<n.length-2){var s=u.x-(o+t);l=n[r].x+s/2,c=a+1}else l=Math.max(n[r].x,o-f(n[r],n[r+1])-(t-u.x+o)/2),c=n.length;for(var d=r+1;d<c;++d)l+=f(n[d-1],n[d]),n[d].x=l;r=o=t=null}else u.x-i.x<f(i,u)&&(r=a,o=i.x,t=f(i,u))}})}})}(t),this},data:function(e,t,n){r=t,o=n},start:function(){n(r,o),a.end(r,o)},stop:function(){},optionNames:function(){return["nodeWidth","offsetX","offsetY","rowFunction","gapY"]},populateLayoutNode:function(e,t){this.rowFunction()&&(e.dcg_rank=this.rowFunction.eval(t))},populateLayoutEdge:function(){},nodeWidth:ce(function(e){return e.width}),offsetX:ce(30),offsetY:ce(30),rowFunction:ce(null),gapY:ce(100)}},ie.tree_layout.scripts=[],ie.graphviz_layout=function(e,l,t){var c,s,n=e||K(),i=re.dispatch("tick","start","end");function d(e){return e.replace(/^%/,"%")}function u(e){return e.replace(/^%/,"%")}function f(e,t){return[e,'"'+t+'"'].join("=")}function g(e){return"["+e.join(", ")+"]"}function r(e,t){if(e)console.warn("graphviz layout failed: ",e);else{i.start();var r=t.bb.split(",").map(function(e){return+e}),n=(t.objects||[]).filter(function(e){return e.pos}).map(function(e){var t=e.pos.split(",");return(isNaN(t[0])||isNaN(t[1]))&&(console.warn("got a NaN position from graphviz"),t[0]=t[1]=0),{dcg_nodeKey:u(e.name),x:+t[0],y:r[3]-t[1]}}),o=(t.objects||[]).filter(function(e){return/^cluster/.test(e.name)&&e.bb});o.forEach(function(e){e.dcg_clusterKey=e.name;var t=e.bb.split(",").map(function(e){return+e});e.bounds={left:t[0],top:r[3]-t[3],right:t[2],bottom:r[3]-t[1]}});var a=(t.edges||[]).map(function(e){var t={dcg_edgeKey:u(e.id||"n"+e._gvid)};if(e._draw_){var n=e._draw_.find(function(e){return e.op&&e.points});t.points=n.points.map(function(e){return{x:e[0],y:r[3]-e[1]}})}return t});i.end(n,a,o)}}var p=ie.graphviz_attrs(),o=Object.keys(p);return Object.assign(p,{layoutAlgorithm:function(){return l},layoutId:function(){return n},supportsWebworker:function(){return!1},on:function(e,t){return 1===arguments.length?i.on(e):(i.on(e,t),this)},init:function(t){return this.optionNames().forEach(function(e){t[e]=t[e]||this[e]()}.bind(this)),this},data:function(e,t,n,r){!function(e,t,n){if(c)s=c;else{var o=[],r="neato"!==l;o.push((r?"digraph":"graph")+" g {"),o.push("graph "+g([f("nodesep",p.nodesep()/72),f("ranksep",p.ranksep()/72),f("rankdir",p.rankdir())]));var a={};e.forEach(function(e){var t=e.dcg_nodeParentCluster;t&&(a[t]=a[t]||[],a[t].push(e.dcg_nodeKey))});var i={},u=[];n.forEach(function(e){var t=e.dcg_clusterParent;t?(i[t]=i[t]||[],i[t].push(e.dcg_clusterKey)):u.push(e.dcg_clusterKey)}),u.forEach(function e(t,n){var r=" ".repeat(2*t);o.push(r+'subgraph "'+n+'" {'),i[n]&&i[n].forEach(e.bind(null,t+1)),a[n]&&o.push(r+" "+a[n].map(function(e){return JSON.stringify(e)}).join(" ")),o.push(r+"}")}.bind(null,1)),(o=(o=o.concat(e.map(function(e){var t=[f("width",e.width/72),f("height",e.height/72),f("fixedsize","shape"),f("shape",e.abstract.shape)];return e.dcg_nodeFixed&&t.push(f("pos",[e.dcg_nodeFixed.x,1e3-e.dcg_nodeFixed.y].join(","))),' "'+d(e.dcg_nodeKey)+'" '+g(t)}))).concat(t.map(function(e){return' "'+d(e.dcg_edgeSource)+(r?'" -> "':'" -- "')+d(e.dcg_edgeTarget)+'" '+g([f("id",d(e.dcg_edgeKey)),f("arrowhead","none"),f("arrowtail","none")])}))).push("}"),o.push(""),s=o.join("\n")}}(t,n,r)},dotInput:function(e){return c=e,this},start:function(){!function(){if(t)re.json(t).header("Content-type","application/x-www-form-urlencoded").post("layouttool="+l+"&"+encodeURIComponent(s),r);else{var e=Viz(s,{format:"json",engine:l,totalMemory:1<<25});r(null,e=JSON.parse(e))}}()},stop:function(){},optionNames:function(){return o},populateLayoutNode:function(){},populateLayoutEdge:function(){}})},ie.d3_force_layout=function(e){var t=e||K(),u=null,n=re.dispatch("tick","start","end"),v={},l={},c=[],s=[],m=null,r=null;function o(e){n[e](c,s.map(function(e){return{dcg_edgeKey:e.dcg_edgeKey}}))}function a(){!function(){if(null===r)u.gravity(m.gravityStrength).charge(m.initialCharge);else{if(m.fixOffPathNodes){var t=re.set();r.forEach(function(e){e.forEach(function(e){t.add(e)})}),Object.keys(v).forEach(function(e){t.has(e)?v[e].fixed=!1:v[e].fixed=!0})}u.charge(m.chargeForce)}}(),function(e){if(!e)return o("end");u.start();for(var t=0;t<300;++t)u.tick(),r&&i();u.stop()}(m.iterations)}function i(){function a(e){return Math.sqrt(e.x*e.x+e.y*e.y)}function p(e,t){var n,r,o=(r=t,((n=e).x*r.x+n.y*r.y)/(a(e)*a(t)));return o=Math.min(o,1),o=Math.max(o,-1),Math.acos(o)}function h(e){var t=-e.y/e.x,n=a({x:t,y:1});return{x:t/n,y:1/n}}function y(e,t,n,r){e.x+=n.x*(Math.PI-t)*r,e.y+=n.y*(Math.PI-t)*r}r.forEach(function(e){if(!(e.length<3))for(var t=1;t<e.length-1;++t){var n=v[e[t]],r=v[e[t-1]],o=v[e[t+1]],a={x:r.x-n.x,y:r.y-n.y},i={x:o.x-n.x,y:o.y-n.y},u=p(a,i),l=h(a),c=h(i),s=(r.x+o.x)/2,d=(r.y+o.y)/2,f={x:s-r.x,y:d-r.y},g={x:s-o.x,y:d-o.y};l=p(f,l)>=Math.PI/2?l:{x:-l.x,y:-l.y},c=p(g,c)>=Math.PI/2?c:{x:-c.x,y:-c.y},y(r,u,l,m.angleForce),y(o,u,c,m.angleForce)}})}var d=ie.graphviz_attrs(),f=Object.keys(d);return Object.assign(d,{layoutAlgorithm:function(){return"d3-force"},layoutId:function(){return t},supportsWebworker:function(){return!0},supportsMoving:function(){return!0},parent:ce(null),on:function(e,t){return 1===arguments.length?n.on(e):(n.on(e,t),this)},init:function(t){var e;return this.optionNames().forEach(function(e){t[e]=t[e]||this[e]()}.bind(this)),m=e=t,u=re.layout.force().size([e.width,e.height]),e.linkDistance&&("number"==typeof e.linkDistance?u.linkDistance(e.linkDistance):"auto"===e.linkDistance&&u.linkDistance(function(e){return e.dcg_edgeLength})),u.on("tick",function(){o("tick")}).on("start",function(){n.start()}).on("end",function(){o("end")}),this},data:function(e,t,n,r){var o,a,i;a=n,i={},(o=t).forEach(function(e,t){i[e.dcg_nodeKey]=t}),c=ve(v,o,null,function(e){return e.dcg_nodeKey},function(e,t){e.dcg_nodeKey=t.dcg_nodeKey,e.width=t.width,e.height=t.height,e.id=t.dcg_nodeKey,t.dcg_nodeFixed?(e.fixed=!0,e.x=t.dcg_nodeFixed.x,e.y=t.dcg_nodeFixed.y):e.fixed=!1}),s=ve(l,a,null,function(e){return e.dcg_edgeKey},function(e,t){e.dcg_edgeKey=t.dcg_edgeKey,e.source=v[t.dcg_edgeSource],e.source.id=i[e.source.dcg_nodeKey],e.target=v[t.dcg_edgeTarget],e.target.id=i[e.target.dcg_nodeKey],e.dcg_edgeLength=t.dcg_edgeLength}),u.nodes(c),u.links(s)},start:function(){a()},stop:function(){u&&u.stop()},paths:function(e){r=e},savePositions:function(){var t={};return Object.keys(v).forEach(function(e){t[e]={x:v[e].x,y:v[e].y}}),t},restorePositions:function(t){Object.keys(t).forEach(function(e){v[e]&&(v[e].fixed=!1,v[e].x=t[e].x,v[e].y=t[e].y)})},optionNames:function(){return["iterations","angleForce","chargeForce","gravityStrength","initialCharge","linkDistance","fixOffPathNodes"].concat(f)},iterations:ce(300),angleForce:ce(.02),chargeForce:ce(-500),gravityStrength:ce(1),initialCharge:ce(-400),linkDistance:ce(20),fixOffPathNodes:ce(!1),populateLayoutNode:function(){},populateLayoutEdge:function(){}})},ie.d3_force_layout.scripts=["d3.js"],ie.d3v4_force_layout=function(e){var t=e||K(),u=null,n=re.dispatch("tick","start","end"),l={},c={},s=[],d=[],r=null,o=null;function a(e){n[e](s,d.map(function(e){return{dcg_edgeKey:e.dcg_edgeKey}}))}function i(){n.start(),function(e){e&&(e=e.filter(function(e){return e.nodes.every(function(e){return l[e]})}));if(null!==e&&e.length){var t;r.fixOffPathNodes&&(t=re.set(),e.forEach(function(e){e.nodes.forEach(function(e){t.add(e)})})),Object.keys(l).forEach(function(e){r.fixOffPathNodes&&!t.has(e)?(l[e].fx=l[e].x,l[e].fy=l[e].y):(l[e].fx=null,l[e].fy=null)}),u.force("charge").strength(r.chargeForce),u.force("straighten",d3v4.forceStraightenPaths().id(function(e){return e.dcg_nodeKey}).angleForce(r.angleForce).pathNodes(function(e){return e.nodes}).pathStrength(function(e){return e.strength}).paths(e))}else u.force("charge").strength(r.initialCharge)}(o),function(e){u.alpha(1);for(var t=0;t<e;++t)u.tick(),a("tick");a("end")}(r.iterations)}var f=ie.graphviz_attrs(),g=Object.keys(f),p=Object.assign(f,{layoutAlgorithm:function(){return"d3v4-force"},layoutId:function(){return t},supportsWebworker:function(){return!0},supportsMoving:function(){return!0},parent:ce(null),on:function(e,t){return 1===arguments.length?n.on(e):(n.on(e,t),this)},init:function(t){var e;return this.optionNames().forEach(function(e){t[e]=t[e]||this[e]()}.bind(this)),r=e=t,u=d3v4.forceSimulation().force("link",d3v4.forceLink()).force("center",d3v4.forceCenter(e.width/2,e.height/2)).force("gravityX",d3v4.forceX(e.width/2).strength(r.gravityStrength)).force("gravityY",d3v4.forceY(e.height/2).strength(r.gravityStrength)).force("collision",d3v4.forceCollide(r.collisionRadius)).force("charge",d3v4.forceManyBody()).stop(),this},data:function(e,t,n,r){var o,a,i;a=n,i={},(o=t).forEach(function(e,t){i[e.dcg_nodeKey]=t}),s=ve(l,o,null,function(e){return e.dcg_nodeKey},function(e,t){e.dcg_nodeKey=t.dcg_nodeKey,e.width=t.width,e.height=t.height,e.id=t.dcg_nodeKey,t.dcg_nodeFixed?(e.fx=t.dcg_nodeFixed.x,e.fy=t.dcg_nodeFixed.y):e.fx=e.fy=null}),d=ve(c,a,null,function(e){return e.dcg_edgeKey},function(e,t){e.dcg_edgeKey=t.dcg_edgeKey,e.source=i[l[t.dcg_edgeSource].dcg_nodeKey],e.target=i[l[t.dcg_edgeTarget].dcg_nodeKey],e.dcg_edgeLength=t.dcg_edgeLength}),u.force("straighten",null),u.nodes(s),u.force("link").links(d)},start:function(){i()},stop:function(){},paths:function(e){o=e},savePositions:function(){var t={};return Object.keys(l).forEach(function(e){t[e]={x:l[e].x,y:l[e].y}}),t},restorePositions:function(t){Object.keys(t).forEach(function(e){l[e]&&(l[e].fx=t[e].x,l[e].fy=t[e].y)})},optionNames:function(){return["iterations","angleForce","chargeForce","gravityStrength","collisionRadius","initialCharge","fixOffPathNodes"].concat(g)},iterations:ce(300),angleForce:ce(.01),chargeForce:ce(-600),gravityStrength:ce(.3),collisionRadius:ce(8),initialCharge:ce(-100),fixOffPathNodes:ce(!1),populateLayoutNode:function(){},populateLayoutEdge:function(){}});return p.pathStraightenForce=p.angleForce,p},ie.d3v4_force_layout.scripts=["d3.js","d3v4-force.js"],ie.flexbox_layout=function(e,c){var t=e||K();c=c||{algo:"yoga-layout"};var o,a,i,u=re.dispatch("tick","start","end");function n(e,t){o=e,a={address:[],children:{}},t.forEach(function(e){!function e(t,n,r,o){if(o.address=t.slice(),o.children=o.children||{},n.length){var a=o.children[n[0]]=o.children[n[0]]||{};t.push(n.shift()),e(t,n,r,a)}else o.node=r}([],y.keyToAddress()(e.dcg_nodeKey),e,a)});(function t(n){var e=y.addressToKey()(n.address);return Array.prototype.concat.apply([e],Object.keys(n.children||{}).map(function(e){return t(n.children[e])}))})(a);i=t}function l(e){e.node||(e.node={dcg_nodeKey:e.address.length?e.address[e.address.length-1]:null}),Object.values(e.children).forEach(l)}var s={alignItems:{stretch:yogaLayout.ALIGN_STRETCH,"flex-start":yogaLayout.ALIGN_FLEX_START,center:yogaLayout.ALIGN_CENTER,"flex-end":yogaLayout.ALIGN_FLEX_END,baseline:yogaLayout.ALIGN_BASELINE},alignSelf:{stretch:yogaLayout.ALIGN_STRETCH,"flex-start":yogaLayout.ALIGN_FLEX_START,center:yogaLayout.ALIGN_CENTER,"flex-end":yogaLayout.ALIGN_FLEX_END,baseline:yogaLayout.ALIGN_BASELINE},alignContent:{"flex-start":yogaLayout.ALIGN_FLEX_START,"flex-end":yogaLayout.ALIGN_FLEX_END,stretch:yogaLayout.ALIGN_STRETCH,center:yogaLayout.ALIGN_CENTER,"space-between":yogaLayout.ALIGN_SPACE_BETWEEN,"space-around":yogaLayout.ALIGN_SPACE_AROUND},flexDirection:{column:yogaLayout.FLEX_DIRECTION_COLUMN,"column-reverse":yogaLayout.FLEX_DIRECTION_COLUMN_REVERSE,row:yogaLayout.FLEX_DIRECTION_ROW,"row-reverse":yogaLayout.FLEX_DIRECTION_ROW_REVERSE},justifyContent:{"flex-start":yogaLayout.JUSTIFY_FLEX_START,center:yogaLayout.JUSTIFY_CENTER,"flex-end":yogaLayout.JUSTIFY_FLEX_END,"space-between":yogaLayout.JUSTIFY_SPACE_BETWEEN,"space-around":yogaLayout.JUSTIFY_SPACE_AROUND,"space-evenly":yogaLayout.JUSTIFY_SPACE_EVENLY}};function d(e,t,n){var r="set"+t.charAt(0).toUpperCase()+t.slice(1);if("function"!=typeof e[r])throw new Error('Could not set yoga attr "'+t+'" ('+r+")");s[t]&&(n=s[t][n]),e["set"+t.charAt(0).toUpperCase()+t.slice(1)](n)}function f(e,t){var n="getComputed"+t.charAt(0).toUpperCase()+t.slice(1);if("function"!=typeof e[n])throw new Error('Could not get yoga attr "'+t+'" ('+n+")");return e[n]()}var g=["sort","order","dcg_nodeKey","dcg_nodeParentCluster","shape","abstract","rx","ry","x","y","z"],p=["width","height"];function r(){var e={sort:function(e,t){return re.ascending(e.node.dcg_nodeKey,t.node.dcg_nodeKey)}};l(a);var t,n,r=function t(e,n){var r;switch(c.algo){case"css-layout":r={name:y.addressToKey()(n.address),style:{}};break;case"yoga-layout":r=yogaLayout.Node.create()}var o=Object.assign({},e),a=Object.keys(n.children).length;for(var i in n.node&&Object.assign(e,n.node),e)if(!(g.includes(i)||a&&p.includes(i))){var u=e[i];switch("function"==typeof u&&(u=u(n.node)),c.algo){case"css-layout":r.style[i]=u;break;case"yoga-layout":d(r,i,u)}}if(a){var l=Object.values(n.children).sort(e.sort).map(function(e){return e.address[e.address.length-1]}).map(function(e){return t(Object.assign({},o),n.children[e])});switch(c.algo){case"css-layout":r.children=l;break;case"yoga-layout":l.forEach(function(e,t){r.insertChild(e,t)})}}return n.flexnode=r}(e,a);switch(c.algo){case"css-layout":r.style.width=o.width,r.style.height=o.height;break;case"yoga-layout":d(r,"width",o.width),d(r,"height",o.height)}switch(y.logStuff()&&console.log(JSON.stringify(r,null,2)),c.algo){case"css-layout":computeLayout(r);break;case"yoga-layout":r.calculateLayout()}!function t(n,r){var o,a,e,i;switch(c.algo){case"css-layout":y.logStuff()&&console.log(r.node.dcg_nodeKey+": "+JSON.stringify(r.flexnode.layout)),o=r.flexnode.layout.left,e=r.flexnode.layout.width,a=r.flexnode.layout.top,i=r.flexnode.layout.height;break;case"yoga-layout":o=f(r.flexnode,"left"),e=f(r.flexnode,"width"),a=f(r.flexnode,"top"),i=f(r.flexnode,"height")}r.node.x=n.x+o+e/2,r.node.y=n.y+a+i/2,Object.keys(r.children).map(function(e){return r.children[e]}).forEach(function(e){t({x:n.x+o,y:n.y+a},e)})}({x:0,y:0},a),t=i,n=[],u["end"](t,n.map(function(e){return{dcg_edgeKey:e.dcg_edgeKey}}))}var h=["width","height","minWidth","minHeight","maxWidth","maxHeight","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom","borderWidth","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","flexDirection","justifyContent","alignItems","alignSelf","flex","flexWrap","position"],y={layoutAlgorithm:function(){return"cola"},layoutId:function(){return t},supportsWebworker:function(){return!0},parent:ce(null),on:function(e,t){return 1===arguments.length?u.on(e):(u.on(e,t),this)},init:function(t){return this.optionNames().forEach(function(e){t[e]=t[e]||this[e]()}.bind(this)),this},data:function(e,t){n(e,t)},start:function(){r()},stop:function(){},optionNames:function(){return[]},populateLayoutNode:function(t,n){["sort","order"].concat(h).forEach(function(e){n.orig.value[e]&&(t[e]=n.orig.value[e])})},populateLayoutEdge:function(){},addressToKey:ce(function(e){return e.join(",")}),keyToAddress:ce(function(e){return e.split(",")}),yogaConstants:function(){return s},logStuff:ce(!1)};return y},ie.flexbox_layout.scripts=["css-layout.js"],ie.manual_layout=function(e){var r,t=e||K(),n=re.dispatch("tick","start","end");function o(){var e,t;e=r,t=[],n["end"](e,t.map(function(e){return{dcg_edgeKey:e.dcg_edgeKey}}))}return{layoutAlgorithm:function(){return"manual"},layoutId:function(){return t},supportsWebworker:function(){return!1},parent:ce(null),on:function(e,t){return 1===arguments.length?n.on(e):(n.on(e,t),this)},init:function(t){return this.optionNames().forEach(function(e){t[e]=t[e]||this[e]()}.bind(this)),this},data:function(e,t,n){r=t},start:function(){o()},stop:function(){},optionNames:function(){return[]},populateLayoutNode:function(t,n){["x","y"].forEach(function(e){void 0!==n.orig.value[e]&&(t[e]=n.orig.value[e])})},populateLayoutEdge:function(){},addressToKey:ce(function(e){return e.join(",")}),keyToAddress:ce(function(e){return e.split(",")})}},ie.manual_layout.scripts=["css-layout.js"],ie.layered_layout=function(e){var s,d,f,t=e||K(),g=re.dispatch("tick","start","end"),a=null;function p(e,t,n){if(0===n.length)return Promise.resolve(e);var r=n.shift();return h(r,t).then(function(e){return p(e,r,n)})}function h(t,e){d[t].nodes().forEach(function(e){y.layerAccessor()(e.value())!==t&&void 0!==e.value().x&&void 0!==e.value().y?e.value().dcg_nodeFixed={x:e.value().x,y:e.value().y}:e.value().dcg_nodeFixed=null});var n,r,o=y.engineFactory()();return o.init(a),o.data({},d[t].nodes().map(function(e){return e.value()}),d[t].edges().map(function(e){return e.value()})),n=t,r=o,new Promise(function(n,e){r.on("end",function(e,t){n({nodes:e,edges:t})}),r.start()}).then(function(e){return e.nodes.forEach(function(e){var t=d[n].node(e.dcg_nodeKey);y.layerAccessor()(t.value())===n&&(t.value().x=e.x,t.value().y=e.y,t.value().z=-n*y.layerSeparationZ())}),e})}var n=ie.graphviz_attrs(),r=Object.keys(n),y=Object.assign(n,{layoutAlgorithm:function(){return"layered"},layoutId:function(){return t},supportsWebworker:function(){return!1},parent:ce(null),on:function(e,t){return 1===arguments.length?g.on(e):(g.on(e,t),this)},init:function(t){return this.optionNames().forEach(function(e){t[e]=t[e]||this[e]()}.bind(this)),a=t,this},data:function(e,t,n,r){!function(e,t,n){var r=(s=ie.supergraph({nodes:e,edges:t},{nodeKey:function(e){return e.dcg_nodeKey},edgeKey:function(e){return e.dcg_edgeKey},nodeValue:function(e){return e},edgeValue:function(e){return e},edgeSource:function(e){return e.dcg_edgeSource},edgeTarget:function(e){return e.dcg_edgeTarget}})).nodes().reduce(function(e,t){var n=y.layerAccessor()(t.value());return e[n]=e[n]||[],e[n].push(t),e},{}),o=Object.keys(r).reduce(function(e,t){return e[t]=[],e},{});s.edges().forEach(function(e){var t=y.layerAccessor()(e.source().value()),n=y.layerAccessor()(e.target().value());t!=n&&(r[n].push(e.source()),o[n].push(e),r[t].push(e.target())),o[t].push(e)}),d=Object.keys(r).reduce(function(e,t){return e[t]=s.subgraph(r[t].map(function(e){return e.key()}),o[t].map(function(e){return e.key()})),e},{});var a=null;Object.keys(r).forEach(function(e){(null===a||d[e].nodes().length>d[a].nodes().length)&&(a=+e)});var i=Object.keys(r).map(function(e){return+e}).sort();f=i.map(function(e){return{rank:e,z:-e*y.layerSeparationZ()}});var u=i.indexOf(a),l=i.slice(u+1),c=i.slice(0,u).reverse();h(a).then(function(e){Promise.all([p(e,a,l),p(e,a,c)]).then(function(){g.end(s.nodes().map(function(e){return e.value()}),s.edges().map(function(e){return e.value()}))})})}(t,n)},start:function(){g.start()},stop:function(){},optionNames:function(){return[].concat(r)},engineFactory:ce(null),layerAccessor:ce(null),layerSeparationZ:ce(50),layers:function(){return f},populateLayoutNode:function(){},populateLayoutEdge:function(){},extractNodeAttrs:ce({}),extractEdgeAttrs:ce({})});return y},ie.place_ports=function(){function t(n,e,t,r,o,a,i){var u,l,c=n.nodePorts();function s(e,t){return 0<e[0]*t[1]-e[1]*t[0]}function d(e){return[Math.cos(e),Math.sin(e)]}function f(e){return Math.atan2(e[1],e[0])}function g(e,t){return Math.hypot(t.pos.x-e.pos.x,t.pos.y-e.pos.y)}for(var p in c){var h=e[p],y=c[p];y.forEach(function(e){var t=e.orig&&n.portBounds.eval(e)||[0,2*Math.PI];Array.isArray(t[0])?(e.vbounds=t,e.abounds=t.map(f)):(e.vbounds=t.map(d),e.abounds=t),e.abounds[0]>e.abounds[1]&&(e.abounds[1]+=2*Math.PI),console.assert(e.orig||e.vec,"unplaced unspecified port")});var v=[],m=[],x=[];y.forEach(function(e){var t,n;e.vec?!e.vbounds||(t=e.vec,s((n=e.vbounds)[0],t)&&s(t,n[1]))?v.push(e):m.push(e):x.push(e)}),m.forEach(function(e){var t,n;e.vec=(t=e.vec,n=e.vbounds,s(t,n[0])?n[0]:s(n[1],t)?n[1]:t),v.push(e)});var _={},w={};for(var b in x.forEach(function(e){var t=e.abounds.map(function(e){return e.toFixed(3)}).join(",");_[t]=e.abounds,w[t]=w[t]||[],w[t].push(e)}),w){var k=_[b],E=w[b];if(1===E.length)E[0].vec=d((k[0]+k[1])/2);else{var S=(k[1]-k[0])/(w[b].length-1);w[b].forEach(function(e,t){e.vec=d(k[0]+t*S)})}}v=v.concat(x),x=[],v.forEach(function(e){Ee(n,h,e)});for(var A=0;A<v.length;++A){var K=v[A];if(!x.includes(K))for(var T=A+1;T<v.length;++T){var N=v[T];if(!x.includes(N)&&!(g(K,N)>D.minDistance())){if(!K.edges.length){x.push(K);continue}x.push(N)}}}v=v.filter(function(e){return!x.includes(e)});for(var P,L=D.patience(),O=0;x.length;){var j=x[0];j.vec=d((u=j.abounds[0],l=j.abounds[1],u+Math.random()*(l-u))),Ee(n,h,j);var M=re.min(v,function(e){return g(j,e)});O<M&&(O=M,P=j.vec),(!L--||M>D.minDistance())&&(L<0&&(console.warn("ran out of patience placing a port"),j.vec=P,Ee(n,h,j)),v.push(j),x.shift(),L=D.patience(),O=0)}}}var D={parent:ce(null).react(function(e){e?e.on("receivedLayout.place-ports",t):D.parent()&&D.parent().on("receivedLayout.place-ports",null)}),minDistance:ce(20),patience:ce(20)};return D},ie.grid=function(){var i,u,l,c=null;function o(e,t,n,r){}function o(e){(c=e.g().selectAll("g.grid-layer").data([0])).enter().append("g").attr("class","grid-layer");var t=s.wholeOnLines()?0:.5,n=i>=s.threshold()?re.range(Math.floor(u[0]),Math.ceil(u[1])+1):[],r=c.selectAll("line.grid-line.vertical").data(n,function(e){return e-t});r.exit().remove(),r.enter().append("line").attr({class:"grid-line vertical",x1:function(e){return e-t},x2:function(e){return e-t}}),r.attr({"stroke-width":1/i,y1:l[0],y2:l[1]});var o=i>=s.threshold()?re.range(Math.floor(l[0]),Math.ceil(l[1])+1):[],a=c.selectAll("line.grid-line.horizontal").data(o,function(e){return e-t});a.exit().remove(),a.enter().append("line").attr({class:"grid-line horizontal",y1:function(e){return e-t},y2:function(e){return e-t}}),a.attr({"stroke-width":1/i,x1:u[0],x2:u[1]})}function n(e,t,n,r){e,i=t,u=n,l=r,o(s.parent())}var s=ie.mode("highlight-paths",{draw:o,remove:function(e,t,n,r){c&&c.remove()},parent:function(e){var t;e&&(e.on("zoomed.grid",n),(t=e).translate(),i=t.scale(),u=t.x().domain(),l=t.y().domain(),o(t))}});return s.threshold=ce(4),s.wholeOnLines=ce(!0),s},ie.annotate_layers=function(){var p,h,y=[],v=ie.mode("annotate-layers",{laterDraw:!0,renderers:["svg","webgl"],draw:function(e){var t=v.parent().renderer().rendererType(),n=v.parent().layoutEngine();if("svg"===t){if("cola"===n.layoutAlgorithm()&&n.setcolaSpec()&&n.setcolaNodes()){(p=v.parent().select("g.draw").selectAll("g.divider-layer").data([0])).enter().append("g").attr("class","divider-layer");var r=n.setcolaNodes().filter(function(e){return/^sort_order_boundary/.test(e.name)}),o=p.selectAll("line.divider").data(r);o.exit().remove(),o.enter().append("line").attr("class","divider"),o.attr({stroke:v.stroke(),"stroke-width":v.strokeWidth(),"stroke-dasharray":v.strokeDashArray(),x1:-5e3,y1:function(e){return e.y},x2:5e3,y2:function(e){return e.y}})}}else{if("webgl"!==t)throw new Error("annotate_layers doesn't know how to work with renderer "+t);var a=v.parent().renderer().multiplier(),i=arguments[1],u=arguments[2];if("layered"===n.layoutAlgorithm()&&n.layers()){var l,c=u.extents[0][1]-u.extents[0][0]+v.planePadding()*a*2,s=u.extents[1][1]-u.extents[1][0]+v.planePadding()*a*2,d=new THREE.Shape;d.moveTo(0,0),d.lineTo(0,s),d.lineTo(c,s),d.lineTo(c,0),d.lineTo(0,0),h&&(l=h),h=new THREE.ShapeBufferGeometry(d);var f=n.layers();if(f.length<y.length){for(var g=f.length;g<y.length;++g)i.remove(y[g].mesh);y=y.slice(0,f.length)}f.forEach(function(e,t){y[t]||(y[t]=Object.assign({},e)),y[t].mesh&&i.remove(y[t].mesh);var n=y[t].mesh=new THREE.Mesh(h,new THREE.MeshStandardMaterial({opacity:v.planeOpacity(),transparent:!0,color:v.parent().renderer().color_to_int(v.planeColor()),side:THREE.DoubleSide}));n.position.set(u.extents[0][0]-v.planePadding()*a,u.extents[1][0]-v.planePadding()*a,e.z*a),i.add(n)}),l&&l.dispose()}}},remove:function(){p&&p.remove()}});return v.stroke=ce("black"),v.strokeWidth=ce(2),v.strokeDashArray=ce([5,5]),v.planePadding=ce(5),v.planeOpacity=ce(.2),v.planeColor=ce("#ffffdd"),v},ie.troubleshoot=function(){var v=null,m=1;function o(n,e,t,r){v||(v=n.g().append("g").attr({class:"troubleshoot","pointer-events":"none"}));var o=e.data().map(function(e){return{x:e.cola.x,y:e.cola.y}}),a=v.selectAll("path.nodecenter").data(o);function i(e){return{x:e.cola.x,y:e.cola.y}}a.exit().remove(),a.enter().append("path").attr("class","nodecenter"),a.attr({d:function(e){return"M"+(e.x-A.xhairWidth()/2)+","+e.y+" h"+A.xhairWidth()+" M"+e.x+","+(e.y-A.xhairHeight()/2)+" v"+A.xhairHeight()},opacity:null!==A.xhairOpacity()?A.xhairOpacity():A.opacity(),stroke:A.xhairColor(),"stroke-width":1/m});var u=e.data().map(function(e){return x(i(e),e.cola.width,e.cola.height)});_(v.selectAll("path.colaboundary").data(u),"colaboundary",A.boundsColor());var l=e.data().map(function(e){return e.bbox&&(e.bbox.width||e.bbox.height)?x(i(e),e.bbox.width,e.bbox.height):null}).filter(function(e){return!!e});_(v.selectAll("path.textboundary").data(l),"textboundary",A.boundsColor());var c=e.data().map(function(e){return"number"!=typeof e.dcg_rx?null:x(i(e),2*e.dcg_rx,2*e.dcg_ry)}).filter(function(e){return!!e});_(v.selectAll("path.radiiboundary").data(c),"radiiboundary",A.boundsColor()),n.addOrRemoveDef("debug-orient-marker-head",!0,"svg:marker",k.bind(null,A.arrowHeadColor())),n.addOrRemoveDef("debug-orient-marker-tail",!0,"svg:marker",k.bind(null,A.arrowTailColor()));var s=A.arrowLength()?t.data().map(function(e){return{pos:e.pos.new.path.points[e.pos.new.path.points.length-1],orient:e.pos.new.orienthead}}):[];b(v.selectAll("line.heads").data(s),"heads",A.arrowHeadColor(),"#debug-orient-marker-head");var d=A.arrowLength()?t.data().map(function(e){return{pos:e.pos.new.path.points[0],orient:e.pos.new.orienttail}}):[];b(v.selectAll("line.tails").data(d),"tails",A.arrowTailColor(),"#debug-orient-marker-tail");var f=Array.prototype.concat.apply([],t.data().map(function(e){var t=n.edgeArrowSize.eval(e);return E(n.arrows(),n.edgeArrowhead.eval(e),t,n.edgeStrokeWidth.eval(e)/t,w(e.pos.new.orienthead),e.pos.new.full.points[e.pos.new.full.points.length-1],n.nodeStrokeWidth.eval(e.target))}));S(v.selectAll("path.head-point").data(f),"head-point",A.arrowHeadColor());var g=Array.prototype.concat.apply([],t.data().map(function(e){var t=n.edgeArrowSize.eval(e);return E(n.arrows(),n.edgeArrowtail.eval(e),t,n.edgeStrokeWidth.eval(e)/t,w(e.pos.new.orienttail),e.pos.new.full.points[0],n.nodeStrokeWidth.eval(e.source))}));S(v.selectAll("path.tail-point").data(g),"tail-point",A.arrowTailColor());var p=v.selectAll("rect.domain").data([0]);p.enter().append("rect");var h=A.parent().x().domain(),y=A.parent().y().domain();p.attr({class:"domain",fill:"none",opacity:A.domainOpacity(),stroke:A.domainColor(),"stroke-width":A.domainStrokeWidth()/m,x:h[0],y:y[0],width:h[1]-h[0],height:y[1]-y[0]})}function t(e,t,n,r){e,m=t,n,r,o(A.parent(),A.parent().selectAllNodes(),A.parent().selectAllEdges())}function x(e,t,n){return{left:e.x-t/2,top:e.y-n/2,right:e.x+t/2,bottom:e.y+n/2}}function n(e,t,n,r){return"M"+e+","+(t+r)+" v"+-r+" h"+n}function r(e){return[n(e.left,e.top,A.boundsWidth(),A.boundsHeight()),n(e.right,e.top,-A.boundsWidth(),A.boundsHeight()),n(e.right,e.bottom,-A.boundsWidth(),-A.boundsHeight()),n(e.left,e.bottom,A.boundsWidth(),-A.boundsHeight())].join(" ")}function _(e,t,n){e.exit().remove(),e.enter().append("path").attr("class",t),e.attr({d:r,opacity:null!==A.boundsOpacity()?A.boundsOpacity():A.opacity(),stroke:n,"stroke-width":1/m,fill:"none"})}function w(e){return+e.replace("rad","")}function b(e,t,n,r){e.exit().remove(),e.enter().append("line").attr("class",t),e.attr({x1:function(e){return e.pos.x},y1:function(e){return e.pos.y},x2:function(e){return e.pos.x-Math.cos(w(e.orient))*A.arrowLength()},y2:function(e){return e.pos.y-Math.sin(w(e.orient))*A.arrowLength()},stroke:n,"stroke-width":A.arrowStrokeWidth()/m,opacity:null!==A.arrowOpacity()?A.arrowOpacity():A.opacity(),"marker-end":"url("+r+")"})}function k(e,t){t.attr({viewBox:"0 -3 3 6",refX:3,refY:0,orient:"auto"}),t.append("path").attr("stroke",e).attr("fill","none").attr("d","M0,3 L3,0 L0,-3")}function E(e,t,n,r,o,a,i){var u=j(e,t),l=I(u,r),c=[Math.cos(o),Math.sin(o)];if(a=[a.x,a.y],!u.length)return[[a[0]-c[0]*i/2,a[1]-c[1]*i/2]];var s=M([-i/n/2,0],D(R(u[0].frontRef),-1)),d=l.map(function(e,t){return D([s,R(u[t].frontRef),e.offset].reduce(M),n)});return d.push(D([s,C(u[u.length-1].backRef),l[u.length-1].offset].reduce(M),n)),d.map(function(e){return M(a,[e[0]*c[0]-e[1]*c[1],e[0]*c[1]+e[1]*c[0]])})}function S(e,t,n){var r=A.xWidth()/2,o=A.xHeight()/2;e.exit().remove(),e.enter().append("path").attr("class",t),e.attr({d:function(t){return[[[-r,-o],[r,o]],[[r,-o],[-r,o]]].map(function(e){return"M"+e.map(function(e){return t[0]+e[0]+","+(t[1]+e[1])}).join(" L")}).join(" ")},"stroke-width":2/m,stroke:n,opacity:A.xOpacity()})}var A=ie.mode("highlight-paths",{laterDraw:!0,draw:o,remove:function(e,t,n,r){v&&v.remove()},parent:function(e){e?(e.translate(),m=e.scale(),e.on("zoomed.troubleshoot",t)):A.parent()&&A.parent().on("zoomed.troubleshoot",null)}});return A.opacity=ce(.75),A.xhairOpacity=ce(null),A.xhairWidth=ce(10),A.xhairHeight=ce(10),A.xhairColor=ce("blue"),A.boundsOpacity=ce(null),A.boundsWidth=ce(10),A.boundsHeight=ce(10),A.boundsColor=ce("green"),A.arrowOpacity=ce(null),A.arrowStrokeWidth=ce(3),A.arrowColor=A.arrowHeadColor=ce("darkorange"),A.arrowTailColor=ce("red"),A.arrowLength=ce(100),A.xWidth=ce(1),A.xHeight=ce(1),A.xOpacity=ce(.8),A.domainOpacity=ce(.6),A.domainColor=ce("darkorange"),A.domainStrokeWidth=ce(4),A},ie.validate=function(h){function y(e,t,n,r){var o=e.filter(function(e){return!t(e)});return o.length?[n+" is empty for "+o.length+" of "+e.length+" "+r,o]:null}function v(e,n){return e.reduce(function(e,t){return e[n(t)]=t,e},{})}function m(t,e,n,r,o,a){var i=e.filter(function(e){return!t[n(e)]}).map(function(e){return{key:n(e),value:e}});return i.length?[r+" was not found in "+o,Object.keys(t),"for "+i.length+" of "+e.length+" "+a,i]:null}function t(){var t=x.parent(),e=t.nodeGroup().all(),n=t.edgeGroup().all(),r=t.portGroup()?t.portGroup().all():[],o=[];function a(e){e&&o.push(e)}a(y(e,t.nodeKey(),"nodeKey","nodes")),a(y(n,t.edgeSource(),"edgeSource","edges")),a(y(n,t.edgeTarget(),"edgeTarget","edges"));var i=re.set(t.content.enum()),u=ie.functor_wrap(t.nodeContent()),l=e.filter(function(e){return!i.has(u(e))});l.length&&o.push(["there are "+l.length+" nodes with nodeContent not matching any content",l]);var c=v(e,t.nodeKey()),s=v(n,t.edgeKey());a(m(c,n,t.edgeSource(),"edgeSource","nodes","edges")),a(m(c,n,t.edgeTarget(),"edgeTarget","nodes","edges")),a(y(r,function(e){return t.portNodeKey()&&t.portNodeKey()(e)||t.portEdgeKey()&&t.portEdgeKey()(e)},"portNodeKey||portEdgeKey","ports"));var d=!t.portNodeKey()&&[]||r.filter(function(e){return t.portNodeKey()(e)}),f=!t.portEdgeKey()&&[]||r.filter(function(e){return t.portEdgeKey()(e)});if(a(m(c,d,t.portNodeKey(),"portNodeKey","nodes","ports")),a(m(s,f,t.portEdgeKey(),"portEdgeKey","edges","ports")),t.portName()){var g=v(d,function(e){return t.portNodeKey()(e)+" - "+t.portName()(e)});t.edgeSourcePortName()&&a(m(g,n,function(e){return t.edgeSource()(e)+" - "+re.functor(t.edgeSourcePortName())(e)},"edgeSourcePortName","ports","edges")),t.edgeTargetPortName()&&a(m(g,n,function(e){return t.edgeTarget()(e)+" - "+re.functor(t.edgeTargetPortName())(e)},"edgeTargetPortName","ports","edges"))}function p(){return e.length+" nodes, "+n.length+" edges, "+r.length+" ports"}o.length?(console.warn("validation of "+h+" failed with "+p()+":"),o.forEach(function(e){console.warn.apply(console,e)})):console.log("validation of "+h+" succeeded with "+p()+".")}var x={parent:ce(null).react(function(e){e?e.on("data.validate",t):x.parent().on("data.validate",null)})};return x},ie.legend=function(a){a=a||"node-legend";var i,u,l,c,s=[],d=re.dispatch("filtered");function f(){g.dimension()&&(g.isTagDimension()?g.dimension().filterFunction(function(e){return!s.length||e.filter(function(e){return s.includes(e)}).length}):g.dimension().filterFunction(function(e){return!s.length||s.includes(e)}),g.parent().redraw())}var g=ie.mode(a,{renderers:["svg","webgl"],draw:p,remove:function(){},parent:function(e){e?e.on("render."+a,n).on("data."+a,t):g.parent().on("render."+a,null).on("data."+a,null)}});function t(e,t,n,r,o,a,i){g.counter()&&(l=g.counter()(n.map(ue),o.map(ue),i.map(ue)))}function p(){var e=(c||g.parent()).svg().selectAll("g.dc-graph-legend."+a).data([0]);e.enter().append("g").attr("class","dc-graph-legend "+a).attr("transform","translate("+g.x()+","+g.y()+")");var t=g.omitEmpty()&&l?i.filter(function(e){return s.length&&!s.includes(e.orig.key)||l[e.orig.key]}):i,n=e.selectAll(g.type().itemSelector()).data(t,function(e){return e.name});n.exit().remove();var r=g.type().create(g.parent(),n.enter(),g.itemWidth(),g.itemHeight());if(r.append("text").attr("dy",g.dyLabel()).attr("class","legend-label"),n.attr("transform",function(e,t){return"translate("+g.itemWidth()/2+","+(g.itemHeight()+g.gap())*(t+.5)+")"}),n.select("text.legend-label").attr("transform","translate("+(g.itemWidth()/2+g.gap())+",0)").attr("pointer-events",g.dimension()?"auto":"none").text(function(e){return e.name+(g.counter()&&l?" ("+(l[e.orig.key]||0)+(l[e.orig.key]!==u[e.orig.key]?"/"+(u[e.orig.key]||0):"")+")":"")}),g.type().draw(c||g.parent(),r,n),g.noLabel()&&n.selectAll(g.type().labelSelector()).remove(),g.dropdown()){var o=n.selectAll("text.dropdown-caret").data(function(e){return[e]});o.enter().append("text").attr("dy","0.3em").attr("font-size","75%").attr("fill","blue").attr("class","dropdown-caret").style("visibility","hidden").html(" ▼"),o.attr("dx",function(e){return g.itemWidth()/2+g.gap()+A(re.select(this.parentNode).select("text.legend-label").node()).width}).on("mouseenter."+a,function(e){var t=this.getBoundingClientRect(),n=g.parent().nodeKey.eval(e);g.dropdown().show(n,t.x,t.y)}),n.on("mouseenter."+a,function(e){l&&l[e.orig.key]&&re.select(this).selectAll(".dropdown-caret").style("visibility","visible")}).on("mouseleave."+a,function(e){re.select(this).selectAll(".dropdown-caret").style("visibility","hidden")})}g.dimension()?n.attr("cursor","pointer").on("click."+a,function(e){var t=g.parent().nodeKey.eval(e);s.length||(s=i.map(g.parent().nodeKey.eval)),s.includes(t)?s=s.filter(function(e){return e!==t}):s.push(t),f(),d.filtered(g,t),c&&window.setTimeout(p,250)}):n.attr("cursor","auto").on("click."+a,null),n.transition().duration(1e3).attr("opacity",function(e){return!s.length||s.includes(g.parent().nodeKey.eval(e))?1:.25})}function n(){"svg"!==g.parent().renderer().rendererType()&&(c=ie.render_svg()).parent(g.parent()).svg(g.parent().root().append("svg").style({position:"absolute",left:0,top:0,width:"100%",height:"100%",fill:"wheat","pointer-events":"none"}));var e=g.exemplars();if(g.countBaseline(),e instanceof Array)i=e.map(function(e){return{name:e.name,orig:{key:e.key,value:e.value},cola:{}}});else for(var t in i=[],e)i.push({name:t,orig:{key:t,value:e[t]},cola:{}});p()}return g.type=ce(ie.legend.node_legend()),g.x=ce(0),g.y=ce(0),g.gap=ce(5),g.itemWidth=g.nodeWidth=ce(40),g.itemHeight=g.nodeHeight=ce(40),g.dyLabel=ce("0.3em"),g.omitEmpty=ce(!1),g.noLabel=ce(!0),g.counter=ce(null),g.replaceFilter=function(e){return s=e&&1===e.length?e[0]:[],g},g.filters=function(){return s},g.on=function(e,t){return d.on(e,t),g},g.exemplars=ce({}),g.redraw=pe("dc_graph.legend is an ordinary mode now; redraw will go away soon",p),g.countBaseline=function(){g.counter()&&(u=g.counter()(g.parent().nodeGroup().all(),g.parent().edgeGroup().all(),g.parent().portGroup()&&g.parent().portGroup().all()))},g.render=pe("dc_graph.legend is an ordinary mode now; render will go away soon",n),g.dropdown=ce(null).react(function(e){!!e!=!!g.dropdown()&&g.parent()&&(c||g.parent()).svg()&&window.setTimeout(g.redraw,0)}),g.dimension=ce(null).react(function(e){e||(s=[],f())}),g.isTagDimension=ce(!1),g},ie.legend.node_legend=function(){return{itemSelector:function(){return".node"},labelSelector:function(){return".node-label"},create:function(e,t){return t.append("g").attr("class","node")},draw:function(e,t,n){e.renderNode(t).redrawNode(n)}}},ie.legend.edge_legend=function(){var i={itemSelector:function(){return".edge-container"},labelSelector:function(){return".edge-label"},create:function(e,t,n,r){var o=t.append("g").attr("class","edge-container").attr("opacity",0);o.append("rect").attr({x:-n/2,y:-r/2,width:n,height:r,fill:"green",opacity:0}),o.selectAll("circle").data([-1,1]).enter().append("circle").attr({r:i.fakeNodeRadius(),fill:"none",stroke:"black","stroke-dasharray":"4,4",opacity:.15,transform:function(e){return"translate("+[e*i.length()/2,0].join(",")+")"}});var a=i.length()/2-i.fakeNodeRadius();return o.append("svg:path").attr({class:"edge",id:function(e){return e.name},d:"M"+-a+",0 L"+a+",0",opacity:e.edgeOpacity.eval}),o},fakeNodeRadius:ce(10),length:ce(50),draw:function(e,t,n){e.redrawEdge(t.select("path.edge"),e.selectAllEdges(".edge-arrows"))}};return i},ie.legend.symbol_legend=function(r){return{itemSelector:function(){return".symbol"},labelSelector:function(){return".symbol-label"},create:function(e,t,n,r){return t.append("g").attr("class","symbol")},draw:function(e,t,n){return t.append("text").html(function(e){return r(e.orig.key)}),t}}},ie.constraint_pattern=function(e){var c={},r=[];return e.nodes.forEach(function(t){var e=t.id,n=c[e]||(c[e]={});if(t.partition){var r=t.partition,o=t.value||t.id;t.all||t.typename?(n.match=t.extract?function(e){return t.extract(e.value[r])}:function(e){return e.value[r]},n.typename=t.typename||function(e){return r+"="+e.value[r]}):n.match=function(e){return e.value[r]===o}}else{if(!t.match)throw new Error("couldn't determine matcher for type "+JSON.stringify(t));n.match=t.match}}),e.edges.forEach(function(t){if(!t.disable){var n={source:t.source,target:t.target};n.produce="function"==typeof t.produce?t.produce:function(){return function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(t.produce)},["listname","wrap","reverse"].forEach(function(e){void 0!==t[e]&&(n[e]=t[e])}),r.push(n)}}),function(i,o,a){var u=[],l={};o.forEach(function(e){var t=i.nodeKey.eval(e);for(var n in c){var r=c[n],o=r.match(e.orig);if(o){var a=r.typename?r.typename(n,o):n;l[a]||(l[a]={nodes:[],whether:{}}),l[a].nodes.push(t),l[a].whether[t]=!0}}});var t=r.filter(function(e){return e.source!==e.target}),e=r.filter(function(e){return e.source===e.target});return a.forEach(function(e){var n=i.edgeSource.eval(e),r=i.edgeTarget.eval(e);t.forEach(function(e){if(l[e.source]&&l[e.source].whether[n]&&l[e.target]&&l[e.target].whether[r]){var t=e.produce(l,o,a);e.reverse?(t.left=r,t.right=n):(t.left=n,t.right=r),u.push(t)}})}),e.forEach(function(e){if(l[e.source]){var t=e.produce(),n=e.listname||e.produce.listname||"nodes",r=e.wrap||e.produce.wrap||function(e){return e};t[n]=l[e.source].nodes.map(r),u.push(t)}}),u}},ie.gap_y=function(e,t){return{axis:"y",gap:e,equality:!!t}},ie.gap_x=function(e,t){return{axis:"x",gap:e,equality:!!t}},ie.align_y=function(){return U("y")},ie.align_x=function(){return U("x")},ie.order_x=function(e,t){return{type:"ordering",axis:"x",gap:60,ordering:t}},ie.order_y=function(e,t){return{type:"ordering",axis:"y",gap:60,ordering:t}},ie.tree_positions=function(e,t,n,r,a,i,u){var l;function f(e,t){return(i(e)+i(t))/2}console.warn("dc_graph.tree_positions is deprecated; use the layout engine tree_layout instead"),(e||n)&&console.warn("dc_graph.tree_positions: rootf and treef are ignored"),i=re.functor(i);var o=ie.depth_first_traversal({nodeid:function(e){return e.cola.dcg_nodeKey},sourceid:function(e){return e.cola.dcg_edgeSource},targetid:function(e){return e.cola.dcg_edgeTarget},init:function(){l=r},row:function(e){return t(e.orig)},place:function(e,t,n){if(n.length){var r=n[n.length-1],o=(i(r)+i(e))/2;l=Math.max(l,r.left_x+o)}e.left_x=l,e.hit_ins=1,e.cola.y=t*u+a},sib:function(e,t,n){var r=f(t,n);e&&(r*=1.5),l+=r},pop:function(e){e.cola.x=(e.left_x+l)/2},skip:function(e,t){e.cola.x=(e.hit_ins*e.cola.x+l)/++e.hit_ins,e.hit_ins===t&&delete e.hit_ins},finish:function(e){e.forEach(function(e){for(var t,n=e.sort(function(e,t){return e.cola.x-t.cola.x}),r=null,o=null,a=0;a<n.length-1;++a){var i=n[a],u=n[a+1];if(r){if(t+=f(i,u),a<n.length-2&&u.cola.x<o+t)continue;var l,c;if(0<r&&--r,a<n.length-2){var s=u.cola.x-(o+t);l=n[r].cola.x+s/2,c=a+1}else l=Math.max(n[r].cola.x,o-f(n[r],n[r+1])-(t-u.cola.x+o)/2),c=n.length;for(var d=r+1;d<c;++d)l+=f(n[d-1],n[d]),n[d].cola.x=l;r=o=t=null}else u.cola.x-i.cola.x<f(i,u)&&(r=a,o=i.cola.x,t=f(i,u))}})}});return function(e,t,n){return o(t,n)}},ie.tree_constraints=function(n,r,u,e){return console.warn("dc_graph.tree_constraints is deprecated - it never worked right and may not be a good idea"),function(o,e,t){var a=[],i=0;return ie.depth_first_traversal({root:n,tree:r,place:function(e,t,n){if(n.length){var r=n[n.length-1];a.push({left:o.nodeKey.eval(r),right:o.nodeKey.eval(e),axis:"x",gap:i-r.foo_x,equality:!0})}e.foo_x=i},sib:function(){i+=u}})(o,e,t),a}},ie.mode=function(r,n){var a={},i=n.laterDraw?"transitionsStarted":"drawn",u=n.draw,l=n.remove,t=n.renderers||["svg"];return u||(console.warn("behavior.add_behavior has been replaced by mode.draw"),u=n.add_behavior),l||(console.warn("behavior.remove_behavior has been replaced by mode.remove"),l=n.remove_behavior),a.parent=ce(null).react(function(e){var o;if(e){var t=!0;(o=e).on(i+"."+r,function(){var e=[o].concat(Array.prototype.slice.call(arguments));u.apply(null,e),t&&n.first?(n.first.apply(null,e),t=!1):n.rest&&n.rest.apply(null,e)}),e.on("reset."+r,function(){var e=o.renderer(),t=e.selectAllNodes?e.selectAllNodes():null,n=e.selectAllEdges?e.selectAllEdges():null,r=e.selectAllEdges?e.selectAllEdges(".edge-hover"):null;l(o,t,n,r)})}else a.parent()&&(o=a.parent()).on(i+"."+r,function(e,t,n){l(o,e,t,n),o.on(i+"."+r,null)});n.parent&&n.parent(e)}),a.supportsRenderer=function(e){return t.includes(e)},a},ie.behavior=pe("dc_graph.behavior has been renamed dc_graph.mode",ie.mode),ie.tip=function(a){var r,i,l=(a=a||{}).namespace||"tip",u=null,o=re.dispatch("tipped");function c(t){if(f.disabled()||f.selection().exclude&&f.selection().exclude(re.event.target))s.call(this);else{var n=this,e=function(){f.content()(t,function(e){u.show.call(n,e,n),re.select("div.d3-tip").selectAll("a.tip-link").on("click."+l,function(){re.event.preventDefault(),f.linkCallback()&&f.linkCallback()(this.id)}),o.tipped(t)})};i&&window.clearTimeout(i),f.delay()?(window.clearTimeout(r),r=window.setTimeout(e,f.delay())):e()}}function e(){return!(!(!re.event.relatedTarget||f.selection().exclude&&f.selection().exclude(re.event.target))&&(this&&this.contains(re.event.relatedTarget)||f.clickable()&&re.event.relatedTarget.classList.contains("d3-tip")))}function t(){r&&(window.clearTimeout(r),r=null)}function s(){e.apply(this)&&(t(),u.hide())}function d(){e.apply(this)&&(t(),f.hideDelay()?i=window.setTimeout(function(){u.hide()},f.hideDelay()):u.hide())}var f=ie.mode(l,{draw:function(e,t,n,r){var o;o=e,u||(u=re.tip().attr("class",a.class||"d3-tip").html(function(e){return"<span>"+e+"</span>"}).direction(f.direction()),f.offset()&&u.offset(f.offset()),o.svg().call(u)),f.programmatic()||f.selection().select(e,t,n,r).on("mouseover."+l,c).on("mouseout."+l,d),f.clickable()&&re.select("div.d3-tip").on("mouseover."+l,function(){i&&window.clearTimeout(i)}).on("mouseout."+l,d)},remove:function(e,t,n,r){f.programmatic()||f.selection().select(e,t,n,r).on("mouseover."+l,null).on("mouseout."+l,null)},laterDraw:!0});return f.direction=ce("n"),f.content=ce(function(e,t){t(f.parent()?f.parent().nodeTitle.eval(e):"")}),f.on=function(e,t){return o.on(e,t)},f.disabled=ce(!1),f.programmatic=ce(!1),f.displayTip=function(e,t,n){if("function"!=typeof e){var r=e;e=function(e){return e===r}}var o=f.selection().select(f.parent(),f.parent().selectAllNodes(),f.parent().selectAllEdges(),null).filter(e);if(0<o.size()){var a=c,i=o.reduce(function(e,t){return e.concat(t)},[]),u=(t||0)%i.length;a.call(i[u],re.select(i[u]).datum()),r=re.select(i[u]).datum(),n&&n(r),f.programmatic()&&o.on("mouseout."+l,d)}return f},f.hideTip=function(e){return u&&(e?d():s()),f},f.selection=ce(ie.tip.select_node_and_edge()),f.showDelay=f.delay=ce(0),f.hideDelay=ce(200),f.offset=ce(null),f.clickable=ce(!1),f.linkCallback=ce(null),f},ie.tip.table=function(){var i=function(t,e){if(t=i.fetch()(t)){var n,r;n=Array.isArray(t)?t:"number"==typeof t||"string"==typeof t?[t]:r=Object.keys(t).filter(re.functor(i.filter())).filter(function(e){return void 0!==t[e]});var o=re.select(document.createElement("table")),a=o.selectAll("tr").data(n).enter().append("tr");a.append("td").text(function(e){return r&&"string"==typeof e?e:JSON.stringify(e)}),r&&a.append("td").text(function(e){return JSON.stringify(t[e])}),e(o.node().outerHTML)}};return i.filter=ce(!0),i.fetch=ce(function(e){return e.orig.value}),i},ie.tip.json_table=function(){var n=ie.tip.table().fetch(function(e){var t=n.json()(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return[t]}});return n.json=ce(function(e){return(e.orig.value.value||e.orig.value).jsontip}),n},ie.tip.html_or_json_table=function(){var r=ie.tip.json_table(),o=function(e,t){var n=o.html()(e);n?t(n):r(e,t)};return o.json=r.json,o.html=ce(function(e){return(e.orig.value.value||e.orig.value).htmltip}),o},ie.tip.select_node_and_edge=function(){return{select:function(e,t,n,r){var o=e.selectAll(".foo-this-does-not-exist");return o[0]=t[0].concat(r?r[0]:[]),o},exclude:function(e){return a(e,"port")}}},ie.tip.select_node=function(){return{select:function(e,t,n,r){return t},exclude:function(e){return a(e,"port")}}},ie.tip.select_edge=function(){return{select:function(e,t,n,r){return n}}},ie.tip.select_port=function(){return{select:function(e,t,n,r){return t.selectAll("g.port")}}},ie.dropdown=function(){ie.dropdown.unique_id=(ie.dropdown.unique_id||16)+1;var d={id:"id"+ie.dropdown.unique_id,parent:ce(null),show:function(e,t,n){var r,o=d.parent().root().selectAll("div.dropdown."+d.id).data([0]),a=o.enter().append("div").attr("class","dropdown "+d.id);o.style("visibility","visible").style("left",t+"px").style("top",n+"px");var i=d.hideOn().split("|"),u=d.selectOn().split("|");if(i.includes("leave"))o.on("mouseleave",function(){o.style("visibility","hidden")});else if(i.includes("clickout")){var l=d.parent();r=l.svg().append("rect").attr("x",0).attr("y",0).attr("width",l.width()).attr("height",l.height()).attr("opacity",0).on("click",function(){r.remove(),o.style("visibility","hidden")})}var c=o;if(d.scrollHeight()){var s=d.scrollHeight();"number"==typeof s&&(s+="px"),o.style("max-height",s).property("scrollTop",0),a.style("overflow-y","auto").append("div").attr("class","scroller"),c=o.selectAll("div.scroller")}d.fetchValues()(e,function(e){var t=c.selectAll("div.dropdown-item").data(e);t.enter().append("div").attr("class","dropdown-item"),t.exit().remove();var n=null;u.includes("click")?n="click":u.includes("hover")&&(n="mouseenter"),t.text(function(e){return d.itemText()(e)}),n&&t.on(n+".select",function(e){d.itemSelected()(e)}),i.includes("clickitem")&&t.on("click.hide",function(e){r.remove(),o.style("visibility","hidden")})})},hideOn:ce("clickout|clickitem"),selectOn:ce("click"),height:ce(10),itemText:ce(function(e){return e}),itemSelected:ce(function(){}),fetchValues:ce(function(e,t){t([])}),scrollHeight:ce("12em")};return d},ie.keyboard=function(){var n=re.dispatch("keydown","keyup","modkeyschanged"),t="keyboard"+Math.floor(1e5*Math.random()),e=re.set(["Shift","Control","Alt","Meta"]),r=re.set();function o(){return r.values().sort()}function a(){e.has(re.event.key)&&(r.add(re.event.key),n.modkeyschanged(o())),n.keydown()}function i(){e.has(re.event.key)&&(r.remove(re.event.key),n.modkeyschanged(o())),n.keyup()}function u(){r.empty()||(r=re.set(),n.modkeyschanged(o()))}var l=ie.mode("brush",{draw:function(e){re.select(window).on("keydown."+t,a).on("keyup."+t,i).on("blur."+t,u)},remove:function(e){re.select(window).on("keydown."+t,null).on("keyup."+t,null).on("blur."+t,null)}});return l.on=function(e,t){return 1===arguments.length?n.on(e):(n.on(e,t),this)},l.modKeysPressed=function(){return o()},l.modKeysMatch=function(e){if(!e||e===[])return r.empty();Array.isArray(e)||(e=[e]);var n=o();return n.length===e.length&&e.slice().sort().every(function(e,t){return e===n[t]})},l},ie.edit_text=function(e,t){var n=e.append("foreignObject").attr({height:"100%",width:"100%"}),r=void 0!==t.padding?t.padding:2;function o(){var e;switch(t.align){case"left":e=[t.box.x-r,t.box.y-r];break;default:case"center":e=[t.box.x+(t.box.width-a.node().offsetWidth)/2,t.box.y+(t.box.height-a.node().offsetHeight)/2]}n.attr("transform","translate("+e.join(" ")+")")}var a=n.append("xhtml:div"),i=t.text||"type on me";function u(){re.event.stopPropagation()}function l(){t.cancel&&t.cancel(),a.on("blur.edit-text",null),n.remove(),t.finally&&t.finally()}a.text(i).attr({contenteditable:!0,width:"auto",class:t.class||null}).style({display:"inline-block","background-color":"white",padding:r+"px"}),n.on("mousedown.edit-text",u).on("mousemove.edit-text",u).on("mouseup.edit-text",u).on("dblclick.edit-text",u),a.on("keydown.edit-text",function(){re.event.stopPropagation(),13===re.event.keyCode&&re.event.preventDefault()}).on("keyup.edit-text",function(){re.event.stopPropagation(),13===re.event.keyCode?(t.accept&&t.accept(a.text()),a.on("blur.edit-text",null),n.remove(),t.finally&&t.finally()):27===re.event.keyCode&&l(),o()}).on("blur.edit-text",l),o(),a.node().focus();var c=document.createRange();t.selectText?c.selectNodeContents(a.node()):(c.setStart(a.node(),1),c.setEnd(a.node(),1));var s=window.getSelection();s.removeAllRanges(),s.addRange(c)},ie.brush=function(){var t,n=null,r=re.dispatch("brushstart","brushmove","brushend");function o(){r.brushstart()}function a(){var e=n.extent();r.brushmove(e)}function i(){r.brushend(),t.call(n.clear())}function e(){t&&(t.remove(),t=null)}var u=ie.mode("brush",{draw:function(){},remove:e});return u.on=function(e,t){return 1===arguments.length?r.on(e):(r.on(e,t),this)},u.activate=function(){var e;return e=u.parent(),n||(n=re.svg.brush().x(e.x()).y(e.y()).on("brushstart.brush-mode",o).on("brush.brush-mode",a).on("brushend.brush-mode",i)),t||(t=e.svg().insert("g",":first-child").attr("class","brush").call(n)),this},u.deactivate=function(){return e(),this},u.isActive=function(){return!!t},u},ie.select_things=function(a,i,u){var r,l,c=[],s=null,n=u.keysEqual?function(t){return function(e){return u.keysEqual(t,e)}}:function(t){return function(e){return t===e}};function d(e,t){return!!c.find(n(t))}function f(e){return e.shiftKey}function g(e){return E?e.metaKey:e.ctrlKey}function p(e,t){return d(0,t)?e:e.concat([t])}function h(e,t){return d(0,t)?e.filter(function(e){return e!=t}):e.concat([t])}var o=!1;function y(e,t){o!==t&&(e.svg().on("click."+i,t?function(e){re.event.target===this&&a.set_changed([])}:null),o=t)}function v(){if(_.multipleSelect()){var e=_.parent().child("brush");l.modKeysMatch(_.modKeys())?e.activate():e.deactivate()}}function m(){f(re.event.sourceEvent)||g(re.event.sourceEvent)?r=c.slice():(r=[],a.set_changed([]))}function x(e){if(u.intersectRect){var t,n=u.intersectRect(e);t=f(re.event.sourceEvent)?n.reduce(p,r):g(re.event.sourceEvent)?n.reduce(h,r):n,a.set_changed(t)}}var _=ie.mode(i,{draw:function(e,t,n){var r=_.noneIsAll()?function(e){return!c.length||d(0,u.key(e))}:function(e){return d(0,u.key(e))};if(u.applyStyles(r),u.clickables(e,t,n).on("mousedown."+i,function(e){s=e}),u.clickables(e,t,n).on("mouseup."+i,function(e){if(!(u.excludeClick&&u.excludeClick(re.event.target)||s!==e)){var t,n=u.key(e);_.multipleSelect()&&(f(re.event)?t=p(c,n):g(re.event)&&(t=h(c,n))),t||(t=[n]),a.set_changed(t)}}),_.multipleSelect()?l.modKeysMatch(_.modKeys())&&e.child("brush").activate():y(e,_.clickBackgroundClears()),_.autoCropSelection()){u.clickables(e,t,n).data().map(u.key);var o=c.filter(function(e){return d(0,e)});c.length!==o.length&&a.set_changed(o,!1)}},remove:function(e,t,n){u.clickables(e,t,n).on("click."+i,null),e.svg().on("click."+i,null),u.removeStyles()},parent:function(e){var n;if(a.on("set_changed."+i,e?(n=e,function(e,t){void 0===t&&(t=!0),c=e,t&&n.requestRefresh()}):null),e&&_.multipleSelect()){var t=e.child("brush");t||(t=ie.brush(),e.child("brush",t)),t.on("brushstart."+i,m).on("brushmove."+i,x)}(l=e.child("keyboard"))||e.child("keyboard",l=ie.keyboard()),l.on("modkeyschanged."+i,v)},laterDraw:u.laterDraw||!1});return _.multipleSelect=ce(!0),_.modKeys=ce(null),_.clickBackgroundClears=ce(!0,!1).react(function(e){!_.multipleSelect()&&_.parent()&&y(_.parent(),e)}),_.noneIsAll=ce(!1),_.autoCropSelection=ce(!0),_.thinginess=function(){return u},_},ie.select_things_group=function(e,t){return window.chart_registry.create_type(t,function(){return re.dispatch("set_changed")}),window.chart_registry.create_group(t,e)},ie.select_nodes=function(t,e){e=e||{};var n=ie.select_things_group(e.select_nodes_group||"select-nodes-group","select-nodes"),r={intersectRect:function(t){return o.parent().selectAllNodes().data().filter(function(e){return e&&t[0][0]<e.cola.x&&e.cola.x<t[1][0]&&t[0][1]<e.cola.y&&e.cola.y<t[1][1]}).map(this.key)},clickables:function(e,t,n){return t},excludeClick:function(e){return a(e,"port")},key:function(e){return o.parent().nodeKey.eval(e)},applyStyles:function(e){o.parent().cascade(50,!0,w(e,null,t))},removeStyles:function(){o.parent().cascade(50,!1,t)}},o=ie.select_things(n,"select-nodes",r);return o},ie.select_edges=function(t,e){e=e||{};var n=ie.select_things_group(e.select_edges_group||"select-edges-group","select-edges"),r={intersectRect:function(t){return this.clickables().data().filter(function(e){return[{x:e.source.cola.x+e.sourcePort.pos.x,y:e.source.cola.y+e.sourcePort.pos.y},{x:e.target.cola.x+e.targetPort.pos.x,y:e.target.cola.y+e.targetPort.pos.y}].some(function(e){return t[0][0]<e.x&&e.x<t[1][0]&&t[0][1]<e.y&&e.y<t[1][1]})}).map(this.key)},clickables:function(){return o.parent().selectAllEdges(".edge-hover")},key:function(e){return o.parent().edgeKey.eval(e)},applyStyles:function(e){o.parent().cascade(50,!0,w(null,e,t))},removeStyles:function(){o.parent().cascade(50,!1,t)}},o=ie.select_things(n,"select-edges",r);return o},ie.select_ports=function(t,e){var n=(e=e||{}).portStyle||"symbols",r=ie.select_things_group(e.select_ports_group||"select-ports-group","select-ports"),o={laterDraw:!0,intersectRect:null,clickables:function(){return a.parent().selectAllNodes("g.port")},key:function(e){return e.named?{node:a.parent().nodeKey.eval(e.node),name:e.name}:{edge:a.parent().edgeKey.eval(e.edges[0]),name:e.name}},applyStyles:function(e){a.parent().portStyle(n).cascade(50,!0,k(e,t))},removeStyles:function(){a.parent().portStyle(n).cascade(50,!1,t)},keysEqual:function(e,t){return e.name===t.name&&(e.node?e.node===t.node:e.edge===t.edge)}},a=ie.select_things(r,"select-ports",o);return a},ie.move_nodes=function(e){e=e||{};var c,s,r,o,d,f=ie.select_things_group(e.select_nodes_group||"select-nodes-group","select-nodes"),t=ie.fix_nodes_group(e.fix_nodes_group||"fix-nodes-group"),g=[],p=null,h=null;function y(n,e){(e=e||g).forEach(function(e){var t=v.parent().getWholeNode(e);n(t,e)})}var v=ie.mode("move-nodes",{draw:function(a,i,u){function e(){if(p){if(!(1&re.event.buttons))return void l();h&&f.set_changed([h]);var e=ie.event_coords(a),t=e[0]-p[0],n=e[1]-p[1];if(!s&&Math.hypot(t,n)>v.dragSize()&&(s=!0,c&&c.style("pointer-events","none")),s){y(function(e){e.cola.x=e.original_position[0]+t,e.cola.y=e.original_position[1]+n});var r=i.filter(function(e){return g.includes(e.orig.key)}),o=u.filter(function(e){return g.includes(e.source.orig.key)||g.includes(e.target.orig.key)});a.reposition(r,o)}}}function l(){if(p){if(s){s=!1,c&&(c.style("pointer-events",null),c=null);var n=[];y(function(e,t){n.push({id:t,pos:{x:e.cola.x,y:e.cola.y}})}),t.request_fixes(n)}r&&r.activate(),p=null}}i.on("mousedown.move-nodes",function(e){if(!(o&&o.usePorts()&&o.usePorts().eventPort())&&d.modKeysMatch(v.modKeys())){p=ie.event_coords(a),c=re.select(this);var t=a.nodeKey.eval(e),n=g;h=g.indexOf(t)<0?(n=[t],t):null,y(function(e){e.original_position=[e.cola.x,e.cola.y]},n),r&&r.deactivate()}}),i.on("mousemove.move-nodes",e).on("mouseup.move-nodes",l),a.svg().on("mousemove.move-nodes",e).on("mouseup.move-nodes",l)},remove:function(e,t,n){t.on("mousedown.move-nodes",null),t.on("mousemove.move-nodes",null),t.on("mouseup.move-nodes",null)},parent:function(e){f.on("set_changed.move-nodes",e?function(e,t){void 0===t&&(t=!0),g=e}:null),e?(r=e.child("brush"),o=e.child("draw-graphs"),e.child("select-nodes"),(d=e.child("keyboard"))||e.child("keyboard",d=ie.keyboard())):r=o=null}});return v.dragSize=ce(5),v.modKeys=ce(null),v},ie.fix_nodes=function(e){e=e||{};var d,f,t=ie.fix_nodes_group(e.fix_nodes_group||"fix-nodes-group"),i=e.fixedPosTag||"fixedPos",u=[],g={nodeid:function(e){return y.parent().nodeKey.eval(e)},sourceid:function(e){return y.parent().edgeSource.eval(e)},targetid:function(e){return y.parent().edgeTarget.eval(e)},get_fix:function(e){return y.parent().nodeFixed.eval(e)},fix_node:function(e,t){e[i]=t},unfix_node:function(e){e[i]=null},clear_fixes:function(){u={}},register_fix:function(e,t){u[e]=t}};function n(e){y.strategy().request_fixes(g,e),l(p()).then(function(){y.parent().redraw()})}function r(e,t,n){y.strategy().new_node(g,e,t,n)}function o(e,t,n){var r=d[t],o=d[n];y.strategy().new_edge(g,e,r,o)}function p(){var a=[];return f.forEach(function(e){var t=y.parent().nodeKey.eval(e),n=u[t],r=e.orig.value[i],o=!1;r?n&&n.x===r.x&&n.y===r.y||(o=!0):o=n,o&&a.push({n:e,fixed:n?{x:n.x,y:n.y}:null})}),a}function a(e,t){t?g.fix_node(e.orig.value,t):g.unfix_node(e.orig.value)}function l(e){var n=y.fixNode()||function(e,t){return Promise.resolve(t)},t=e.map(function(t){var e=y.parent().nodeKey.eval(t.n);return n(e,t.fixed).then(function(e){a(t.n,e)})});return Promise.all(t)}function h(e){e.forEach(function(e){a(e.n,e.fixed)})}function c(e,t,n,r,o,a,i){if(d=t,f=n,r,o,y.strategy().on_data){y.strategy().on_data(g,t,n,r,o,a,i);var u=p();h(u),y.reportOverridesAsynchronously()&&(l=u,c=y.fixNode()||function(e,t){return Promise.resolve(t)},s=l.map(function(e){var t=y.parent().nodeKey.eval(e.n);return c(t,e.fixed)}),Promise.all(s))}var l,c,s}var y={parent:ce(null).react(function(e){t.on("request_fixes.fix-nodes",e?n:null).on("new_node.fix_nodes",e?r:null).on("new_edge.fix_nodes",e?o:null),e?e.on("data.fix-nodes",c):y.parent()&&y.parent().on("data.fix-nodes",null)}),fixNode:ce(null),fixAllNodes:function(e){void 0===e&&(e=!0);var t=f.map(function(e){return{n:e,fixed:{x:e.cola.x,y:e.cola.y}}});return e?l(t):(h(t),Promise.resolve(void 0))},clearFixes:function(){y.strategy().clear_all_fixes&&y.strategy().clear_all_fixes(),g.clear_fixes()},strategy:ce(ie.fix_nodes.strategy.fix_last()),reportOverridesAsynchronously:ce(!0)};return y},ie.fix_nodes.strategy={},ie.fix_nodes.strategy.fix_last=function(){return{request_fixes:function(t,e){t.clear_fixes(),e.forEach(function(e){t.register_fix(e.id,e.pos)})},new_node:function(e,t,n,r){e.fix_node(n,r)},new_edge:function(e,t,n,r){e.unfix_node(n.orig.value),e.unfix_node(r.orig.value)}}},ie.fix_nodes.strategy.last_N_per_component=function(l){l=l||1;var c=0,s={};return{clear_all_fixes:function(){s={}},request_fixes:function(e,t){++c,t.forEach(function(e){s[e.id]={id:e.id,age:c,pos:e.pos}})},new_node:function(e,t,n,r){++c,s[t]={id:t,age:c,pos:r},e.fix_node(n,r)},new_edge:function(){},on_data:function(u,e,t,n,r,o,a){++c,t.forEach(function(e){var t=u.nodeid(e),n=u.get_fix(e);n&&!s[t]&&(s[t]={id:t,age:c,pos:n})});var i=[];ie.undirected_dfs({nodeid:u.nodeid,sourceid:u.sourceid,targetid:u.targetid,comp:function(){i.push([])},node:function(e,t){i[e].push(t)}})(t,r),u.clear_fixes(),i.forEach(function(e,n){var r=e.reduce(function(e,t){if(t.last_component){var n=e[t.last_component]=e[t.last_component]||{total:0,fixed:0};n.total++,s[u.nodeid(t)]&&n.fixed++}return e},{}),t=Object.keys(r).reduce(function(e,t){return r[t].fixed&&e.push({compid:+t,total:r[t].total,fixed:r[t].fixed}),e},[]).sort(function(e,t){return t.total-e.total}),o=t.length&&t[0].compid,a=e.filter(function(e){return!e.last_component||e.last_component===o}).map(function(e){return s[u.nodeid(e)]}).filter(function(e){return e});a.length>l&&(a.sort(function(e,t){return t.age-e.age}),a=a.slice(0,l)),a.forEach(function(e){u.register_fix(e.id,e.pos)});var i=a.reduce(function(e,t){return e[t.id]=!0,e},{});e.forEach(function(e){var t=u.nodeid(e);i[t]||(s[t]=null),e.last_component=n+1})})}}},ie.fix_nodes_group=function(e){return window.chart_registry.create_type("fix-nodes",function(){return re.dispatch("request_fixes","new_node","new_edge")}),window.chart_registry.create_group("fix-nodes",e)},ie.filter_selection=function(e,t){t=t||"select-nodes";var r=ie.select_things_group(e||"select-nodes-group",t);var o={parent:ce(null).react(function(e){var n;r.on("set_changed.filter-selection-"+t,e?(n=e,function(e){if(e.length){var t=re.set(e);o.dimensionAccessor()(n).filterFunction(function(e){return t.has(e)})}else o.dimensionAccessor()(n).filter(null);n.redrawGroup()}):null)})};return o.dimensionAccessor=ce(function(e){return e.nodeDimension()}),o},ie.delete_things=function(t,n,r){r=r||"id";var o,a=E?"Backspace":"Delete",i=[];function u(e){i=e}function l(e){return e[r]}function c(e){if(!s.crossfilterAccessor())throw new Error("need crossfilterAccessor");if(!s.dimensionAccessor())throw new Error("need dimensionAccessor");if(0===(e=e||i).length)return Promise.resolve([]);var t=s.preDelete()?s.preDelete()(e):Promise.resolve(e);return s.onDelete()&&(t=t.then(s.onDelete())),t.then(function(t){if(t&&t.length){var e=s.crossfilterAccessor()(s.parent()),n=s.dimensionAccessor()(s.parent()),r=e.all().slice();r.length;n.filter(null),e.remove();var o=r.filter(function(e){return-1===t.indexOf(l(e))});r.length!==o.length+t.length&&console.warn("size after deletion is not previous size minus selection size",o.map(l),r.map(l),t),e.add(o),s.parent().redrawGroup()}return!0})}var s=ie.mode(n,{draw:function(e){o.on("keyup."+n,function(){re.event.code===a&&c()})},remove:function(e){},parent:function(e){t.on("set_changed."+n,u),e&&((o=e.child("keyboard"))||e.child("keyboard",o=ie.keyboard()))}});return s.preDelete=ce(null),s.onDelete=ce(null),s.crossfilterAccessor=ce(null),s.dimensionAccessor=ce(null),s.deleteSelection=c,s},ie.delete_nodes=function(e,t){t=t||{};var n=ie.select_things_group(t.select_nodes_group||"select-nodes-group","select-nodes"),o=ie.select_things_group(t.select_edges_group||"select-edges-group","select-edges"),a=ie.delete_things(n,"delete-nodes",e);return a.preDelete(function(t){var n=a.parent(),r=n.child("delete-edges");return r?Promise.resolve(void 0).then(function(){var e=n.edgeGroup().all().filter(function(e){return-1!==t.indexOf(n.edgeSource()(e))||-1!==t.indexOf(n.edgeTarget()(e))}).map(n.edgeKey());return o.set_changed(e),r.deleteSelection().then(function(){return t})}):null}),a},ie.label_things=function(o){o=o||{};var a,i,t=ie.select_things_group(o.select_group,o.select_type),u=ie.label_things_group(o.label_group,o.label_type),l=[];function r(e,t,n){var r=o.find_thing(l[0],e,t);r.empty()?console.error("couldn't find thing '"+l[0]+"'!"):1<r.size()?console.error("found too many things for '"+l[0]+"' ("+r.size()+")!"):u.edit_label(r,n)}var n=ie.mode(o.label_type,{draw:function(e,t,n){a.on("keyup."+o.label_type,function(){if(l.length){if(1!==re.event.key.length)return;r(t,n,{text:re.event.key,selectText:!1})}}),i&&i.thinginess().clickables(e,t,n).on("dblclick."+o.label_type,function(){r(t,n,{selectText:!0})})},remove:function(e,t,n){},parent:function(e){var r;t.on("set_changed."+o.label_type,e?function(e){l=e}:null),u.on("edit_label."+o.label_type,e?(r=e,function(t,e){var n=o.thing_box(t);o.hide_thing_label(t,!0),ie.edit_text(r.g(),{text:e.text||o.thing_label(t)||o.default_label,align:o.align,class:o.class,box:n,selectText:e.selectText,accept:function(e){return o.accept(t,e)},finally:function(){o.hide_thing_label(t,!1)}})}):null),e&&((a=e.child("keyboard"))||e.child("keyboard",a=ie.keyboard()),i=e.child(o.select_type))}});return n.editSelection=function(e){r(n.parent().selectAllNodes(),n.parent().selectAllEdges(),e)},n},ie.label_things_group=function(e,t){return window.chart_registry.create_type(t,function(){return re.dispatch("edit_label")}),window.chart_registry.create_group(t,e)},ie.label_nodes=function(e){var n=(e=e||{}).labelTag||"label";e.select_group=e.select_group||"select-nodes-group",e.select_type=e.select_type||"select-nodes",e.label_group=e.label_group||"label-nodes-group",e.label_type=e.label_type||"label-nodes",e.default_label="node name",e.find_thing=function(t,e,n){return e.filter(function(e){return r.parent().nodeKey.eval(e)===t})},e.hide_thing_label=function(e,t){r.parent().content(r.parent().nodeContent.eval(e.datum())).selectText(e).attr("visibility",t?"hidden":"visible")},e.thing_box=function(e,t){var n=r.parent().content(r.parent().nodeContent.eval(e.datum())).textbox(e);return n.x+=e.datum().cola.x,n.y+=e.datum().cola.y,n},e.thing_label=function(e){return r.parent().nodeLabel.eval(e.datum())},e.accept=function(t,e){return(r.changeNodeLabel()?r.changeNodeLabel()(r.parent().nodeKey.eval(t.datum()),e):Promise.resolve(e)).then(function(e){t.datum().orig.value[n]=e,r.parent().redrawGroup()})};var r=ie.label_things(e);return r.changeNodeLabel=ce(null),r},ie.label_edges=function(e){var n=(e=e||{}).labelTag||"label";e.select_group=e.select_group||"select-edges-group",e.select_type=e.select_type||"select-edges",e.label_group=e.label_group||"label-edges-group",e.label_type=e.label_type||"label-edges",e.default_label="edge name",e.find_thing=function(t,e,n){return n.filter(function(e){return r.parent().edgeKey.eval(e)===t})},e.hide_thing_label=function(e,t){r.parent().selectAll("#"+r.parent().edgeId(e.datum())+"-label textPath").attr("visibility",t?"hidden":"visible")},e.thing_box=function(e,t){var n=e.datum().pos.new.path.points;return{x:(n[0].x+n[1].x)/2,y:(n[0].y+n[1].y)/2-10,width:0,height:20}},e.thing_label=function(e){return r.parent().edgeLabel.eval(e.datum())},e.accept=function(t,e){return(r.changeEdgeLabel()?r.changeEdgeLabel()(r.parent().edgeKey.eval(t.datum()),e):Promise.resolve(e)).then(function(e){t.datum().orig.value[n]=e,r.parent().redrawGroup()})};var r=ie.label_things(e);return r.changeEdgeLabel=ce(null),r},ie.register_highlight_things_group=function(e){return window.chart_registry.create_type("highlight-things",function(){return re.dispatch("highlight")}),window.chart_registry.create_group("highlight-things",e)},ie.highlight_things=function(t,n,r,e,o){var a,i=ie.register_highlight_things_group(e||"highlight-things-group"),u={},l={};function c(e,t){a=e||t,u=e||{},l=t||{},s.parent().requestRefresh(s.durationOverride())}o=o||150;var s=ie.mode(r,{draw:function(e){e.cascade(o,!0,w(function(e){return u[s.parent().nodeKey.eval(e)]},function(e){return l[s.parent().edgeKey.eval(e)]},t)),e.cascade(o+10,!0,w(function(e){return a&&!u[s.parent().nodeKey.eval(e)]},function(e){return a&&!l[s.parent().edgeKey.eval(e)]},n))},remove:function(e){e.cascade(o,!1,t),e.cascade(o+10,!1,n)},parent:function(e){i.on("highlight."+r,e?c:null)}});return s.durationOverride=ce(void 0),s},ie.register_highlight_neighbors_group=function(e){return window.chart_registry.create_type("highlight-neighbors",function(){return re.dispatch("highlight_node")}),window.chart_registry.create_group("highlight-neighbors",e)},ie.highlight_neighbors=function(t,n,e,r){var o=ie.register_highlight_neighbors_group(e||"highlight-neighbors-group"),a=ie.register_highlight_things_group(r||"highlight-things-group");function i(t){var n=u.parent(),r={},o={};t?(r[t]=!0,u.parent().selectAllEdges().each(function(e){n.nodeKey.eval(e.source)===t&&(o[n.edgeKey.eval(e)]=!0,r[n.nodeKey.eval(e.target)]=!0),n.nodeKey.eval(e.target)===t&&(o[n.edgeKey.eval(e)]=!0,r[n.nodeKey.eval(e.source)]=!0)}),a.highlight(r,o)):a.highlight(null,null)}var u=ie.mode("highlight-neighbors",{draw:function(e,t,n){t.on("mouseover.highlight-neighbors",function(e){o.highlight_node(u.parent().nodeKey.eval(e))}).on("mouseout.highlight-neighbors",function(e){o.highlight_node(null)})},remove:function(e,t,n){t.on("mouseover.highlight-neighbors",null).on("mouseout.highlight-neighbors",null),o.highlight_node(null)},parent:function(e){o.on("highlight_node.highlight-neighbors",e?i:null),e&&!e.child("highlight-things")&&e.child("highlight-things",ie.highlight_things(t,n).durationOverride(u.durationOverride()))}});return u.durationOverride=ce(void 0),u},ie.highlight_radius=function(e){e=e||{};var l,c=ie.select_things_group(e.select_nodes_group||"select-nodes-group","select-nodes"),r=ie.register_highlight_things_group(e.highlight_things_group||"highlight-things-group"),s=[];function t(e){s=e,console.assert(l);var t={},n={};e.forEach(function(e){!function t(e,n,r,o){r[e.key()]=!0,n&&(e.outs().filter(function(e){return!o[e.key()]}).forEach(function(e){o[e.key()]=!0,t(e.target(),n-1,r,o)}),e.ins().filter(function(e){return!o[e.key()]}).forEach(function(e){o[e.key()]=!0,t(e.source(),n-1,r,o)}))}(l.node(e),o.radius(),t,n)}),Object.keys(t).length||Object.keys(n).length||(t=n=null),r.highlight(t,n)}function n(e,t,n,r,o,a,i){l=metagraph.graph(n,o,{nodeKey:e.nodeKey.eval,edgeKey:e.edgeKey.eval,edgeSource:e.edgeSource.eval,edgeTarget:e.edgeTarget.eval});var u=s.filter(function(e){return!!l.node(e)});u.length<s.length&&window.setTimeout(function(){c.set_changed(u)},0)}var o={parent:function(e){e?e.on("data.highlight-radius",n):o.parent()&&o.parent().on("data.highlight-radius",null),c.on("set_changed.highlight-radius",t)}};return o.radius=ce(1),o},ie.register_highlight_paths_group=function(e){return window.chart_registry.create_type("highlight-paths",function(){return re.dispatch("paths_changed","hover_changed","select_changed")}),window.chart_registry.create_group("highlight-paths",e)},ie.highlight_paths=function(o,a,i,e){var u=ie.register_highlight_paths_group(e||"highlight-paths-group");o=o||{},a=a||{},i=i||{};var t,l={},c={},s=null,d=null;function n(){x.doRedraw()?x.parent().relayout().redraw():x.parent().refresh()}function r(e,t){s=d=null,0===Object.keys(l).length&&0===Object.keys(e).length&&0===Object.keys(c).length&&0===Object.keys(t).length||(l=e,c=t,n())}function f(e){e!==d&&(d=e,n())}function g(e){e!==s&&(s=e,n())}function p(t){return function(e){return 0<=t.indexOf(e)}}function h(e){var t=p(e);return function(e){return!t(e)}}function y(e,t){return!(!e||!t)&&e.some(p(t))}function v(e,t){return e?t?t.every(p(e))?e.filter(h(t)):e.concat(t.filter(h(e))):e:t}function m(e,t,n,r){t.on("mouseover.highlight-paths",null).on("mouseout.highlight-paths",null).on("click.highlight-paths",null),r.on("mouseover.highlight-paths",null).on("mouseout.highlight-paths",null).on("click.highlight-paths",null),l={},c={},e.cascade(200,!1,o).cascade(300,!1,i).cascade(400,!1,a)}var x=ie.mode("highlight-paths",{draw:function(t,e,n,r){t.cascade(200,!0,w(function(e){return!!l[t.nodeKey.eval(e)]},function(e){return!!c[t.edgeKey.eval(e)]},o)).cascade(300,!0,w(function(e){return y(l[t.nodeKey.eval(e)],s)},function(e){return y(c[t.edgeKey.eval(e)],s)},i)).cascade(400,!0,w(function(e){return y(l[t.nodeKey.eval(e)],d)},function(e){return y(c[t.edgeKey.eval(e)],d)},a)),e.on("mouseover.highlight-paths",function(e){u.hover_changed(l[t.nodeKey.eval(e)]||null)}).on("mouseout.highlight-paths",function(e){u.hover_changed(null)}).on("click.highlight-paths",function(e){u.select_changed(v(s,l[t.nodeKey.eval(e)]))}),r.on("mouseover.highlight-paths",function(e){u.hover_changed(c[t.edgeKey.eval(e)]||null)}).on("mouseout.highlight-paths",function(e){u.hover_changed(null)}).on("click.highlight-paths",function(e){u.select_changed(v(s,c[t.nodeKey.eval(e)]))})},remove:function(e,t,n,r){return m(e,t,0,r),this},parent:function(e){e&&(t=e.anchorName()),u.on("paths_changed.highlight-paths-"+t,e?r:null),u.on("hover_changed.highlight-paths-"+t,e?f:null),u.on("select_changed.highlight-paths-"+t,e?g:null)}});return x.doRedraw=ce(!1),x},ie.spline_paths=function(i,u,l,c,e){var s=ie.register_highlight_paths_group(e||"highlight-paths-group");u=u||{},l=l||{};var t,d=null,f=null,g=null,p=null,h=null;function n(e,t,n){d=n;var r=x.parent().layoutEngine(),o=n.filter(v);if(o.length){var a=o.map(function(e){var t=i.pathStrength.eval(e);return"number"!=typeof t&&(t=1),g&&-1!==g.indexOf(e)&&(t*=x.selectedStrength()),{nodes:y(e),strength:t}});r.paths(a)}else r.paths(null),h&&r.restorePositions(h);g&&(g=g.filter(function(e){return-1!==o.indexOf(e)})),x.parent().redraw()}function r(e){e!==g&&(g=e,n(0,0,d))}function y(e,t){t=!1!==t;var n,r,o=i.elementList.eval(e).filter(function(e){return"node"===i.elementType.eval(e)}).map(function(e){return i.nodeKey.eval(e)});return t?(r=[],(n=o).forEach(function(e,t){0!==t&&e===n[t-1]||r.push(e)}),r):o}function v(e){return i.elementList.eval(e).every(function(e){return"node"!==i.elementType.eval(e)||x.parent().getWholeNode(i.nodeKey.eval(e))})}var L=function(e,t){return e.x*t.x+e.y*t.y},O=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},j=function(e,t){return Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))};function m(e,t,n,r,o){var a,i=(a=t,y(e,!1).map(function(e){var t=x.parent().getWholeNode(e);return{x:a&&void 0!==t.prevX?t.prevX:t.cola.x,y:a&&void 0!==t.prevY?t.prevY:t.cola.y}}));if(i.length<2)return"";var u="";return u+=function(e,t,n,r){var o=t||0;n=!1!==n,r=r||.02;for(var a=[e[0]],i=1;i<e.length;i++)1e-6<j(e[i],a[a.length-1])&&a.push(e[i]);(e=(e=[a[0]]).concat(a)).push(a[a.length-1]);var u=[];for(i=1;i<e.length-2;i++){var l=(1-o)*(e[i+1].x-e[i-1].x)/2,c=(1-o)*(e[i+1].y-e[i-1].y)/2,s=(1-o)*(e[i+2].x-e[i].x)/2,d=(1-o)*(e[i+2].y-e[i].y)/2,f=e[i],g=e[i+1],p=f;1!==i&&(p={x:f.x+l/3,y:f.y+c/3});var h=g;if(i!==e.length-3&&(h={x:g.x-s/3,y:g.y-d/3}),n){var y={x:e[i-1].x-e[i].x,y:e[i-1].y-e[i].y},v={x:e[i+1].x-e[i].x,y:e[i+1].y-e[i].y},m=L(y,v)/(O(y)*O(v));if(m=Math.max(-1,Math.min(1,m)),Math.acos(m)<=r){var x=(1-o)*(e[i].x-e[i-1].x)/2,_=(1-o)*(e[i].y-e[i-1].y)/2,w={x:f.x+-_/3*2,y:f.y+x/3*2},b={x:f.x- -_/3*2,y:f.y-x/3*2},k={x:w.x-b.x,y:w.y-b.y},E={x:e[i-2].x-e[i+2].x,y:e[i-2].y-e[i+2].y};0<L(k,E)?(p=w,u[u.length-1][1]=b):(p=b,u[u.length-1][1]=w)}}u.push([p,h,g])}var S="M"+e[0].x+","+e[0].y;for(i=0;i<u.length;i++){var A=u[i];S+="C"+A[0].x+","+A[0].y,S+=","+A[1].x+","+A[1].y,S+=","+A[2].x+","+A[2].y}return S}(i,n,r,o),u+=function(e,t,n,r){for(var o=0,a=1,i=[];o<e.length-1&&a<e.length;)if(j(e[o],e[a])<1e-6){for(var u=e[a];a<e.length&&j(e[a],u)<1e-6;)a++;i.push({start:Math.max(0,o-1),end:Math.min(e.length-1,a)}),a=(o=a)+1}else o++,a++;for(var l="",c=0;c<i.length;c++){var s=i[c],d=s.end-s.start-2,f=e[s.start+1],g={x:e[s.end].x-e[s.start].x,y:e[s.end].y-e[s.start].y};0==O(g)&&(g={x:-(e[s.end].y-f.y),y:e[s.end].x-f.x});for(var p,h=g.x/O(g),y=g.y/O(g),v=-g.y/O(g),m=g.x/O(g),x=0;x<d;x++){var _,w,b,k,E=15+2*x;_={x:f.x+E*h,y:f.y+E*y},k={x:f.x-E*h,y:f.y-E*y};var S=25+5*x,A={x:f.x+v*S,y:f.y+m*S},K={x:f.x-v*S,y:f.y-m*S},T={x:e[s.end].x-f.x,y:e[s.end].y-f.y},N={x:A.x-f.x,y:A.y-f.y};p=A,0<L(N,T)&&(p=K),w={x:p.x+E*h,y:p.y+E*y},b={x:p.x-E*h,y:p.y-E*y};var P="M"+f.x+","+f.y;P+="C"+_.x+","+_.y+","+w.x+","+w.y+","+p.x+","+p.y,l+=P+="C"+b.x+","+b.y+","+k.x+","+k.y+","+f.x+","+f.y}}return l}(i)}function o(e){if(null!==e){e=e.filter(v);var t=f||[],n=g||[],r=p.selectAll(".spline-edge").data(e,function(e){return y(e).join(",")});r.exit().remove();r.enter().append("svg:path").attr("class","spline-edge").attr("id",function(e,t){return"spline-path-"+t}).attr("stroke-width",u.edgeStrokeWidth||1).attr("fill","none").attr("d",function(e){return m(e,!0,u.lineTension,x.avoidSharpTurns())});r.attr("stroke",function(e){return-1!==n.indexOf(e)&&c.edgeStroke||-1!==t.indexOf(e)&&l.edgeStroke||u.edgeStroke||"black"}).attr("opacity",function(e){return-1!==n.indexOf(e)&&c.edgeOpacity||-1!==t.indexOf(e)&&l.edgeOpacity||u.edgeOpacity||1}),r.sort(function(e,t){return a(e)-a(t)}),p.selectAll(".spline-edge-hover").each(function(){this.parentNode.appendChild(this)}),r.transition().duration(x.parent().transitionDuration()).attr("d",function(e){return m(e,!1,u.lineTension,x.avoidSharpTurns())});var o=p.selectAll(".spline-edge-hover").data(e,function(e){return y(e).join(",")});o.exit().remove();o.enter().append("svg:path").attr("class","spline-edge-hover").attr("d",function(e){return m(e,!0,u.lineTension,x.avoidSharpTurns())}).attr("opacity",0).attr("stroke","green").attr("stroke-width",(u.edgeStrokeWidth||1)+4).attr("fill","none").on("mouseover.spline-paths",function(e){s.hover_changed([e])}).on("mouseout.spline-paths",function(e){s.hover_changed(null)}).on("click.spline-paths",function(e){var t=g&&g.slice(0)||[],n=t.indexOf(e);-1!==n?t.splice(n,1):re.event.shiftKey?t.push(e):t=[e],s.select_changed(t)});o.transition().duration(x.parent().transitionDuration()).attr("d",function(e){return m(e,!1,u.lineTension,x.avoidSharpTurns())})}else h=x.parent().layoutEngine().savePositions();function a(e){return-1!==t.indexOf(e)?2:-1!==n.indexOf(e)?1:0}}var x=ie.mode("draw-spline-paths",{laterDraw:!0,draw:function(e,t,n,r){(p=x.parent().select("g.draw").selectAll("g.spline-layer").data([0])).enter().append("g").attr("class","spline-layer"),o(d)},remove:function(e,t,n,r){return this},parent:function(e){e&&(t=e.anchorName()),s.on("paths_changed.draw-spline-paths-"+t,e?n:null).on("select_changed.draw-spline-paths-"+t,e?r:null).on("hover_changed.draw-spline-paths-"+t,e?function(e){f=e,o(d)}:null)}});return x.selectedStrength=ce(1),x.avoidSharpTurns=ce(!0),x},ie.draw_spline_paths=pe("draw_spline_paths has been renamed spline_paths, please update",ie.spline_paths),ie.draw_clusters=function(){function o(e){e.attr({x:function(e){return e.cola.bounds.left},y:function(e){return e.cola.bounds.top},width:function(e){return e.cola.bounds.right-e.cola.bounds.left},height:function(e){return e.cola.bounds.bottom-e.cola.bounds.top}})}var a=ie.mode("draw-clusters",{laterDraw:!0,draw:function(e){if(e.clusterGroup()){var t=e.g().selectAll("g.cluster-layer").data([0]);t.enter().insert("g",":first-child").attr("class","cluster-layer");var n=e.clusterGroup().all().map(function(e){return a.parent().getWholeCluster(e.key)}).filter(function(e){return e&&e.cola.bounds}),r=t.selectAll("rect.cluster").data(n,function(e){return e.orig.key});r.exit().remove(),r.enter().append("rect").attr({class:"cluster",opacity:0,stroke:a.clusterStroke.eval,"stroke-width":a.clusterStrokeWidth.eval,fill:function(e){return a.clusterFill.eval(e)||"none"}}).call(o),r.transition().duration(a.parent().stagedDuration()).attr("opacity",a.clusterOpacity.eval).call(o)}},remove:function(e,t,n,r){}});return a.clusterOpacity=ce(.25),a.clusterStroke=ce("black"),a.clusterStrokeWidth=ce(1),a.clusterFill=ce(null),a.clusterLabel=ce(null),a.clusterLabelFill=ce("black"),a.clusterLabelAlignment=ce(["bottom","right"]),a},ie.expand_collapse=function(p){"function"==typeof p&&(p={get_degree:arguments[0],expand:arguments[1],collapse:arguments[2],dirs:arguments[3]});var i,u,l,c,h={},o=ie.register_highlight_things_group(p.expanded_highlight_group||"expanded-highlight-group"),y=ie.register_highlight_things_group(p.collapse_highlight_group||"collapse-highlight-group"),s=ie.register_highlight_things_group(p.hide_highlight_group||"hide-highlight-group");if(p.dirs=p.dirs||["both"],p.dirs.forEach(function(e){h[e]={}}),p.hideKey=p.hideKey||"Alt",p.linkKey=p.linkKey||(E?"Meta":"Control"),2<p.dirs.length)throw new Error("there are only two directions to expand in");var a={};function v(u,e,t,n,l){n&&h[l.dir][u.nodeKey.eval(n)]&&(l=null);var r=e.selectAll("g.spikes").data(function(e){return l&&n===e?[e]:[]});r.exit().remove(),r.enter().insert("g",":first-child").classed("spikes",!0);var o=r.selectAll("rect.spike").data(function(e){u.nodeKey.eval(e);for(var t=l.dir,n=l.n,r=function(e,t,n){if("both"===t)return function(e){return Math.PI*(2*e/n-.5)};var r,o=(n-1)*Math.PI/n;switch(e){case"LR":r=0;break;case"TB":r=Math.PI/2;break;case"RL":r=Math.PI;break;case"BT":r=-Math.PI/2}return"in"===t&&(r+=Math.PI),function(e){return r+o*((1<n?e/(n-1):0)-.5)}}(u.layoutEngine().rankdir(),t,n),o=Array(n),a=0;a<n;++a){var i=r(a);o[a]={a:180*i/Math.PI,x:Math.cos(i)*e.dcg_rx*.9,y:Math.sin(i)*e.dcg_ry*.9,edge:l.invisible?l.invisible[a]:null}}return o});o.enter().append("rect").classed("spike",!0).attr({width:25,height:3,fill:function(e){var t,n,r=e.edge?ie.functor_wrap(u.edgeStroke())(e.edge):"black";return n=u,a[t=r]||(a[t]=!0,n.addOrRemoveDef("spike-gradient-"+t,!0,"linearGradient",function(e){e.attr({x1:"0%",y1:"0%",x2:"100%",y2:"0%",spreadMethod:"pad"}),e.selectAll("stop").data([[0,t,1],[100,t,"0"]]).enter().append("stop").attr({offset:function(e){return e[0]+"%"},"stop-color":function(e){return e[1]},"stop-opacity":function(e){return e[2]}})})),"url(#spike-gradient-"+r+")"},rx:1,ry:1,x:0,y:0}),o.attr("transform",function(e){return"translate("+e.x+","+e.y+") rotate("+e.a+")"}),o.exit().remove()}function d(e,t,n){v(e,t,0,null,null)}function f(e,t,n,r){if(1===n.length)return n[0];var o=e.root().node().getBoundingClientRect(),a=e.invertCoord([t.clientX-o.left,t.clientY-o.top]),i=a[0],u=a[1];switch(e.layoutEngine().rankdir()){case"TB":return u>r.cola.y?"out":"in";case"BT":return u<r.cola.y?"out":"in";case"LR":return i>r.cola.x?"out":"in";case"RL":return i<r.cola.x?"out":"in"}throw new Error("unknown rankdir "+e.layoutEngine().rankdir())}function g(e){switch(e){case"Alt":return re.event.altKey;case"Meta":return re.event.metaKey;case"Shift":return re.event.shiftKey;case"Control":return re.event.ctrlKey}return!1}function m(t,e,n){var r=t.nodeKey.eval(e),o={},a={};o[r]=!0,n.each(function(e){t.edgeSource.eval(e)!==r&&t.edgeTarget.eval(e)!==r||(a[t.edgeKey.eval(e)]=!0)}),s.highlight(o,a)}function x(e,t){var n={};n[e.edgeKey.eval(t)]=!0,s.highlight({},n)}function _(l,c,s,d,f){var g=l.nodeKey.eval(c);(p.get_edges?Promise.resolve(p.get_edges(g,f)):Promise.resolve(p.get_degree(g,f))).then(function(e){var t,n;t="number"==typeof e?e:(n=e).length;var r={dir:f,visible:function(t,e,n,r){var o;switch(n){case"out":o=function(e){return t.edgeSource.eval(e)===r};break;case"in":o=function(e){return t.edgeTarget.eval(e)===r};break;case"both":o=function(e){return t.edgeSource.eval(e)===r||t.edgeTarget.eval(e)===r}}return e.filter(o).data()}(l,d,f,g)};if(r.n=Math.max(0,t-r.visible.length),n){var o=r.visible.reduce(function(e,t){return e[l.edgeKey.eval(t)]=!0,e},{});r.invisible=n.filter(function(e){return!o[l.edgeKey()(e)]})}v(l,s,0,c,r);var a={},i={};if(h[f][g]&&p.collapsibles){var u=p.collapsibles(g,f);a=u.nodes,i=u.edges}y.highlight(a,i)})}function w(e,n,r){var t;"both"!==e||h.both?h[e][n]=r:p.dirs.forEach(function(e){h[e][n]=r}),t=h.both?h.both:Object.keys(h.in).filter(function(e){return h.in[e]&&h.out[e]}).reduce(function(e,t){return e[t]=!0,e},{}),o.highlight(t,{}),"both"!==e||h.both?r?p.expand(n,e):p.collapse(n,e):p.dirs.forEach(function(e,t){r?p.expand(n,e,t!==p.dirs.length-1):p.collapse(n,e,t!==p.dirs.length-1)})}var b=ie.mode("expand-collapse",{draw:function(r,o,n,e){function t(e){var t=f(r,re.event,p.dirs,e);u=e,l=t,p.hideNode&&g(p.hideKey)?m(r,e,n):b.nodeURL.eval(u)&&g(p.linkKey)?(r.selectAllNodes().filter(function(e){return e===u}).attr("cursor","pointer"),r.requestRefresh(0)):_(r,e,o,n,t)}function a(e){var t=r.nodeKey.eval(e);if(p.hideNode&&g(p.hideKey))p.hideNode(t);else if(g(p.linkKey))b.nodeURL.eval(e)&&b.urlOpener&&b.urlOpener()(b,e,b.nodeURL.eval(e));else{d(r,o);var n=f(r,re.event,p.dirs,e);w(n,t,!h[n][t])}}o.on("mouseenter.expand-collapse",t).on("mousemove.expand-collapse",t).on("mouseout.expand-collapse",function(e){r.selectAllNodes().filter(function(e){return e===u}).attr("cursor",null),u=null,d(r,o),y.highlight({},{}),s.highlight({},{})}).on("click.expand-collapse",a).on("dblclick.expand-collapse",a),e.on("mouseenter.expand-collapse",function(e){c=e,p.hideEdge&&g(p.hideKey)&&x(r,e)}).on("mouseout.expand-collapse",function(e){c=null,s.highlight({},{})}).on("click.expand-collapse",function(e){p.hideEdge&&g(p.hideKey)&&p.hideEdge(r.edgeKey.eval(e))}),i.on("keydown.expand-collapse",function(){re.event.key===p.hideKey&&(u&&p.hideNode||c&&p.hideEdge)?(u&&m(r,u,n),c&&x(r,c),d(r,o),y.highlight({},{})):re.event.key===p.linkKey&&u&&(u&&b.nodeURL.eval(u)&&r.selectAllNodes().filter(function(e){return e===u}).attr("cursor","pointer"),s.highlight({},{}),d(r,o),y.highlight({},{}))}).on("keyup.expand_collapse",function(){re.event.key!==p.hideKey&&re.event.key!==p.linkKey||!u&&!c||(s.highlight({},{}),u&&(_(r,u,o,n,l),b.nodeURL.eval(u)&&r.selectAllNodes().filter(function(e){return e===u}).attr("cursor",null)))}),r.cascade(97,!0,k(function(e){return e===u&&e.orig.value.value&&e.orig.value.value.URL},{nodeLabelDecoration:"underline"}))},remove:function(e,t,n,r){t.on("mouseenter.expand-collapse",null).on("mousemove.expand-collapse",null).on("mouseout.expand-collapse",null).on("click.expand-collapse",null).on("dblclick.expand-collapse",null),r.on("mouseenter.expand-collapse",null).on("mouseout.expand-collapse",null).on("click.expand-collapse",null),d(e,t)},parent:function(e){e&&((i=e.child("keyboard"))||e.child("keyboard",i=ie.keyboard()))}});return b.expand=w,b.expandNodes=function(e){var t=e.reduce(function(e,t){return e[t]=!0,e},{});p.dirs.forEach(function(e){h[e]=Object.assign({},t)}),o.highlight(t,{}),p.expandedNodes(t)},b.clickableLinks=de("warning - clickableLinks doesn't belong in collapse_expand and will be moved",!1),b.nodeURL=ce(function(e){return e.value&&e.value.value&&e.value.value.URL}),b.urlTargetWindow=ce("dcgraphlink"),b.urlOpener=ce(ie.expand_collapse.default_url_opener),b},ie.expand_collapse.default_url_opener=function(e,t,n){window.open(e.nodeURL.eval(t),e.urlTargetWindow())},ie.expand_collapse.shown_hidden=function(e){var i=Object.assign({nodeKey:function(e){return e.key},edgeKey:function(e){return e.key},edgeSource:function(e){return e.value.source},edgeTarget:function(e){return e.value.target}},e),o={},r={},t=i.nodeCrossfilter.dimension(i.nodeKey);function a(){t.filterFunction(function(e){return o[e]})}function u(t){return i.edgeGroup.all().filter(function(e){return i.edgeSource(e)===t||i.edgeTarget(e)===t})}function l(t){return i.edgeGroup.all().filter(function(e){return i.edgeSource(e)===t})}function c(t){return i.edgeGroup.all().filter(function(e){return i.edgeTarget(e)===t})}function s(n,r){return i.edgeGroup.all().every(function(e){var t;return i.edgeSource(e)===r?t=i.edgeTarget(e):i.edgeTarget(e)===r&&(t=i.edgeSource(e)),!t||t===n||!o[t]})}a();var n={};return i.directional?Object.assign(n,{get_degree:function(e,t){switch(t){case"out":return l(e).length;case"in":return c(e).length;default:throw new Error("unknown direction "+t)}},expand:function(e,t,n){switch(o[e]=!0,t){case"out":l(e).forEach(function(e){r[i.edgeTarget(e)]||(o[i.edgeTarget(e)]=!0)});break;case"in":c(e).forEach(function(e){r[i.edgeSource(e)]||(o[i.edgeSource(e)]=!0)});break;default:throw new Error("unknown direction "+t)}n||(a(),ae.redrawAll())},expandedNodes:function(e){if(!arguments.length)throw new Error("not supported");var t=this;return o={},Object.keys(e).forEach(function(e){t.expand(e,"out",!0),t.expand(e,"in",!0)}),a(),ae.redrawAll(),this},collapsibles:function(n,r){var o={},a={};return("out"===r?l(n):c(n)).forEach(function(e){var t="out"===r?i.edgeTarget(e):i.edgeSource(e);s(n,t)&&(o[t]=!0,u(t).forEach(function(e){a[i.edgeKey(e)]=!0}))}),{nodes:o,edges:a}},collapse:function(e,t){Object.keys(this.collapsibles(e,t).nodes).forEach(function(e){o[e]=!1}),a(),ae.redrawAll()},hideNode:function(e){r[e]=!0,o[e]=!1,a(),ae.redrawAll()},dirs:["out","in"]}):Object.assign(n,{get_degree:function(e){return u(e).length},expand:function(e){var t;o[e]=!0,(t=e,u(t).map(function(e){return i.edgeSource(e)===t?i.edgeTarget(e):i.edgeSource(e)})).forEach(function(e){r[e]||(o[e]=!0)}),a(),ae.redrawAll()},expandedNodes:function(e){if(!arguments.length)throw new Error("not supported");var t=this;return o={},Object.keys(e).forEach(function(e){t.expand(e)}),this},collapsibles:function(r,e){var t,o={},a={};return(t=r,u(t).map(function(e){return i.edgeSource(e)===t?[e,i.edgeTarget(e)]:[e,i.edgeSource(e)]})).forEach(function(e){var t=e[0],n=e[1];s(r,n)&&(o[n]=!0,a[i.edgeKey(t)]=!0)}),{nodes:o,edges:a}},collapse:function(e,t){Object.keys(n.collapsibles(e,t).nodes).forEach(function(e){o[e]=!1}),a(),ae.redrawAll()},hideNode:function(e){r[e]=!0,o[e]=!1,a(),ae.redrawAll()}}),n},ie.expand_collapse.expanded_hidden=function(e){var i=Object.assign({nodeKey:function(e){return e.key},edgeKey:function(e){return e.key},edgeSource:function(e){return e.value.source},edgeTarget:function(e){return e.value.target}},e),u={},r={},n={},o=i.nodeCrossfilter.dimension(i.nodeKey),a=i.edgeCrossfilter&&i.edgeCrossfilter.dimension(i.edgeRawKey);function l(e){return Object.keys(e).reduce(function(t,e){var n;return t[e]=!0,(n=e,s(n).map(function(e){return i.edgeSource(e)===n?i.edgeTarget(e):i.edgeSource(e)})).forEach(function(e){r[e]||(t[e]=!0)}),t},{})}function c(){var t=l(u);o.filterFunction(function(e){return t[e]}),a&&a.filterFunction(function(e){return!n[e]})}function s(t){return i.edgeGroup.all().filter(function(e){return i.edgeSource(e)===t||i.edgeTarget(e)===t})}return c(),{get_degree:function(e){return s(e).length},get_edges:function(e){return s(e)},expand:function(e){u[e]=!0,c(),ae.redrawAll()},expandedNodes:function(e){return arguments.length?(u=e,c(),ae.redrawAll(),this):u},collapsibles:function(e,t){var n=Object.assign({},u);delete n[e];var r=l(u),o=l(n),a=Object.keys(r).filter(function(e){return!o[e]}).reduce(function(e,t){return e[t]=!0,e},{});return{nodes:a,edges:i.edgeGroup.all().filter(function(e){return a[i.edgeSource(e)]||a[i.edgeTarget(e)]}).reduce(function(e,t){return e[i.edgeKey(t)]=!0,e},{})}},collapse:function(e,t){delete u[e],c(),ae.redrawAll()},hideNode:function(e){r[e]=!0,this.collapse(e)},hideEdge:function(e){i.edgeCrossfilter||console.warn("expanded_hidden needs edgeCrossfilter to hide edges"),n[e]=!0,c(),ae.redrawAll()}}},ie.draw_graphs=function(i){var u,l=ie.select_things_group(i.select_nodes_group||"select-nodes-group","select-nodes"),c=ie.select_things_group(i.select_edges_group||"select-edges-group","select-edges"),s=(ie.label_things_group("label-nodes-group","label-nodes"),ie.label_things_group("label-edges-group","label-edges"),ie.fix_nodes_group("fix-nodes-group")),a=i.idTag||"id",d=i.edgeIdTag||a,f=i.sourceTag||"source",g=i.targetTag||"target",p=i.labelTag||"label",h=i.edgeLabelTag||p,y=null,v=null,m=!1,x=null,_=[];function w(){var e=_.filter(function(e){return e.source&&e.target}),t=x.selectAll("line.hint-edge").data(e);t.exit().remove(),t.enter().append("line").attr("class","hint-edge").style({fill:"none",stroke:"black","pointer-events":"none"}),t.attr({x1:function(e){return e.source.x},y1:function(e){return e.source.y},x2:function(e){return e.target.x},y2:function(e){return e.target.y}})}function b(e){var t=A.parent().portStyle(A.parent().portStyleName.eval(e)).portPosition(e);return t.x+=e.node.cola.x,t.y+=e.node.cola.y,t}function k(){var e;e=u?A.usePorts()?[b(u)]:[{x:u.node.cola.x,y:u.node.cola.y}]:[];var r=A.crossSize(),o=A.crossWidth(),t=x.selectAll("polygon.graph-draw-crossout").data(e);t.exit().remove(),t.enter().append("polygon").attr("class","graph-draw-crossout"),t.attr("points",function(e){var t=e.x,n=e.y;return[[t-r/2,n+r/2],[t-r/2+o,n+r/2],[t,n+o/2],[t+r/2-o,n+r/2],[t+r/2,n+r/2],[t+o/2,n],[t+r/2,n-r/2],[t+r/2-o,n-r/2],[t,n-o/2],[t-r/2+o,n-r/2],[t-r/2,n-r/2],[t-o/2,n]].map(function(e){return e.join(",")}).join(" ")})}function o(){m=!(_=[]),y=v=null,w()}function E(t,e,n){if(!A.nodeCrossfilter())throw new Error("need nodeCrossfilter");var r,o=A.addNode()||T;n?r=n:((r={})[a]=K(),r[p]=""),e&&s.new_node(r[a],r,{x:e[0],y:e[1]}),o(r).then(function(e){e&&(A.nodeCrossfilter().add([e]),t.redrawGroup(),l.set_changed([e[a]]))})}function S(e){var n;if(!(1&re.event.buttons))return u=null,A.conduct().cancelDragEdge&&A.conduct().cancelDragEdge(y),o(),k(),!0;if(!y.started&&Math.hypot(e[0]-_[0].source.x,e[1]-_[0].source.y)>A.dragSize()&&A.conduct().startDragEdge){if(!A.conduct().startDragEdge(y))return A.conduct().invalidSourceMessage&&(n=A.conduct().invalidSourceMessage(y),console.log(n),i.negativeTip&&i.negativeTip.content(function(e,t){t(n)}).displayTip(A.usePorts()?y.port:y.node)),o(),!0;y.started=!0}return!1}var A=ie.mode("highlight-paths",{draw:function(a,e,t,n){var r=a.child("select-nodes");r&&A.clickCreatesNodes()&&r.clickBackgroundClears(!1),e.on("mousedown.draw-graphs",function(e){if(re.event.stopPropagation(),A.dragCreatesEdges())if(i.tipsDisable&&i.tipsDisable.forEach(function(e){e.hideTip().disabled(!0)}),A.usePorts()){var t;if(!(t="object"==typeof A.usePorts()&&A.usePorts().eventPort?A.usePorts().eventPort():a.getPort(a.nodeKey.eval(e),null,"out")||a.getPort(a.nodeKey.eval(e),null,"in")))return;y={node:e,port:t},_=[{source:b(t)}]}else _=[{source:{x:(y={node:e}).node.cola.x,y:y.node.cola.y}}]}).on("mousemove.draw-graphs",function(e){var n;if(re.event.stopPropagation(),y){var t=ie.event_coords(a);if(S(t))return;var r=v;if(e===y.node)A.conduct().invalidTargetMessage&&console.log(A.conduct().invalidTargetMessage(y,y)),v=null,_[0].target=null;else if(A.usePorts()){var o;o="object"==typeof A.usePorts()&&A.usePorts().eventPort?A.usePorts().eventPort():a.getPort(a.nodeKey.eval(e),null,"in")||a.getPort(a.nodeKey.eval(e),null,"out"),v=o?{node:e,port:o}:null}else v&&e===v.node||(v={node:e});if(A.conduct().changeDragTarget)(A.usePorts()?(r&&r.port)!==(v&&v.port):(r&&r.node)!==(v&&v.node))&&(m=A.conduct().changeDragTarget(y,v)?(u=null,i.negativeTip&&i.negativeTip.hideTip(),n=A.conduct().validTargetMessage&&A.conduct().validTargetMessage()||"matches",i.positiveTip&&i.positiveTip.content(function(e,t){t(n)}).displayTip(A.usePorts()?v.port:v.node),!0):(u=A.usePorts()?v&&v.port:v&&v.node,v&&A.conduct().invalidTargetMessage&&(i.positiveTip&&i.positiveTip.hideTip(),n=A.conduct().invalidTargetMessage(y,v),console.log(n),i.negativeTip&&i.negativeTip.content(function(e,t){t(n)}).displayTip(A.usePorts()?v.port:v.node)),!1));else m=!0;v?v.port?_[0].target=b(o):_[0].target={x:e.cola.x,y:e.cola.y}:_[0].target={x:t[0],y:t[1]},w(),k()}}).on("mouseup.draw-graphs",function(e){if(u=null,i.negativeTip&&i.negativeTip.hideTip(!0),i.positiveTip&&i.positiveTip.hideTip(!0),i.tipsDisable&&i.tipsDisable.forEach(function(e){e.disabled(!1)}),y&&m){var t;t=A.conduct().finishDragEdge?A.conduct().finishDragEdge(y,v):Promise.resolve(!0);var n=y,r=v;t.then(function(e){e&&function(t,e,n){if(!A.edgeCrossfilter())throw new Error("need edgeCrossfilter");var r,o={},a=A.addEdge()||T;o[d]=K(),o[h]="",A.conduct().detectReversedEdge&&A.conduct().detectReversedEdge(o,e.port,n.port)?(o[f]=n.node.orig.key,o[g]=e.node.orig.key,r=e,e=n,n=r):(o[f]=e.node.orig.key,o[g]=n.node.orig.key),a(o,e.port,n.port).then(function(e){e&&(s.new_edge(o[d],e[f],e[g]),A.edgeCrossfilter().add([e]),l.set_changed([],!1),c.set_changed([e[d]],!1),t.redrawGroup())})}(a,n,r)})}else y&&A.conduct().cancelDragEdge&&A.conduct().cancelDragEdge(y);o(),k()}),a.svg().on("mousedown.draw-graphs",function(){y=null}).on("mousemove.draw-graphs",function(){if(y){var e=ie.event_coords(a);if(u=null,S(e))return;A.conduct().dragCanvas&&A.conduct().dragCanvas(y,e),A.conduct().changeDragTarget&&v&&A.conduct().changeDragTarget(y,null),v=null,_[0].target={x:e[0],y:e[1]},w(),k()}}).on("mouseup.draw-graphs",function(){u=null,i.negativeTip&&i.negativeTip.hideTip(!0),i.positiveTip&&i.positiveTip.hideTip(!0),i.tipsDisable&&i.tipsDisable.forEach(function(e){e.disabled(!1)}),y?(A.conduct().cancelDragEdge&&A.conduct().cancelDragEdge(y),o()):re.event.target===this&&A.clickCreatesNodes()&&E(a,ie.event_coords(a)),k()}),x||(x=a.g().append("g").attr("class","draw-graphs"))},remove:function(e,t,n,r){t.on("mousedown.draw-graphs",null).on("mousemove.draw-graphs",null).on("mouseup.draw-graphs",null),e.svg().on("mousedown.draw-graphs",null).on("mousemove.draw-graphs",null).on("mouseup.draw-graphs",null)}});return A.nodeCrossfilter=ce(i.nodeCrossfilter),A.edgeCrossfilter=ce(i.edgeCrossfilter),A.usePorts=ce(null),A.clickCreatesNodes=ce(!0),A.dragCreatesEdges=ce(!0),A.dragSize=ce(5),A.crossSize=ce(15),A.crossWidth=ce(5),A.conduct=ce({}),A.addNode=ce(null),A.addEdge=ce(null),A.createNode=function(e,t){E(A.parent(),e,t)},A},ie.match_ports=function(n,a){var u,l,i;function c(e,t){return e.map(function(e){return e.state=t,n.portNodeKey.eval(e)})}function r(e){var t=c(i,"small");e.port.state="small",t.push(n.portNodeKey.eval(e.port)),a.animateNodes(t)}function o(t,n){return l.some(function(e){return 0<=t.edges.indexOf(e)&&0<=n.edges.indexOf(e)})}function s(e,t){return(d.allowParallel()||!o(e,t))&&d.isValid()(e,t)}n.on("data.match-ports",function(e,t,n,r,o,a,i){a,u=i,l=o}),n.on("transitionsStarted.match-ports",function(){a.enableHover(!0)});var d={isValid:ce(function(e,t){return t!==e&&t.name===e.name}),whyInvalid:ce(function(e,t){return t===e?"can't connect port to itself":t.name!==e.name&&"must connect ports of the same type"}),allowParallel:ce(!1),hoverPort:function(e){if(e){if((i=u.filter(s.bind(null,e))).length)return c(i,"shimmer-medium")}else if(i)return c(i,"small");return null},startDragEdge:function(e){var t=c(i=u.filter(s.bind(null,e.port)),"shimmer");return i.length&&(a.enableHover(!1),e.port.state="large",t.push(n.portNodeKey.eval(e.port)),a.animateNodes(t)),console.log("valid targets",t),0!==i.length},invalidSourceMessage:function(e){return"no valid matches for this port"},changeDragTarget:function(e,t){var n,r,o=t&&s(e.port,t.port);return o?(n=c(i,"small"),t.port.state="large"):(n=c(i,"small"),r=a.animateNodes(n),n=c(i,"shimmer")),a.animateNodes(n,r),o},validTargetMessage:function(e,t){return"it's a match!"},invalidTargetMessage:function(e,t){return n=e.port,r=t.port,!d.allowParallel()&&o(n,r)?"can't connect two edges between the same two ports":d.whyInvalid()(n,r);var n,r},finishDragEdge:function(e,t){return a.enableHover(!0),r(e),Promise.resolve(s(e.port,t.port))},cancelDragEdge:function(e){return a.enableHover(!0),r(e),!0}};return d},ie.match_opposites=function(a,e,i){var u,l,c;function s(e){return{x:e.node.cola.x+e.pos.x,y:e.node.cola.y+e.pos.y}}function r(t,n){return(d.allowParallel()||!l.some(function(e){return 0<=t.edges.indexOf(e)&&0<=n.edges.indexOf(e)}))&&d.isValid()(t,n)}function o(e,t){t.forEach(function(e){e.edges.forEach(function(e){e.deleting=0})}),e&&e.port.edges.forEach(function(e){e.deleting=0})}i=Object.assign({multiplier:2,ease:re.ease("cubic")},i),a.cascade(100,!0,f(function(e){return i.ease(e.deleting||0)},e,t)),a.on("data.match-opposites",function(e,t,n,r,o,a,i){a,u=i,l=o});var d={isValid:ce(function(e,t){return"in"===a.portName.eval(e)^"in"===a.portName.eval(t)}),allowParallel:ce(!1),hoverPort:function(e){},startDragEdge:function(e){return c=u.filter(r.bind(null,e.port)),console.log("valid targets",c.map(a.portNodeKey.eval)),0!==c.length},dragCanvas:function(e,n){var t=c.map(function(e){var t=s(e);return{distance:Math.hypot(n[0]-t.x,n[1]-t.y),port:e}}).sort(function(e,t){return e.distance-t.distance}),r=s(t[0].port),o=s(e.port);t.forEach(function(t){t.port.edges.forEach(function(e){e.deleting=1-i.multiplier*t.distance/Math.hypot(r.x-o.x,r.y-o.y)})}),e.port.edges.forEach(function(e){e.deleting=1-i.multiplier*t[0].distance/Math.hypot(r.x-o.x,r.y-o.y)}),a.requestRefresh(0)},changeDragTarget:function(e,t){var n=t&&r(e.port,t.port);return n&&(t.port.edges.forEach(function(e){e.deleting=1}),e.port.edges.forEach(function(e){e.deleting=1}),o(null,c.filter(function(e){return e!==t.port})),a.requestRefresh(0)),n},finishDragEdge:function(e,t){if(r(e.port,t.port)){if(o(null,c.filter(function(e){return e!==t.port})),i.delete_edges){var n=e.port.edges.map(a.edgeKey.eval).concat(t.port.edges.map(a.edgeKey.eval));return i.delete_edges.deleteSelection(n)}return Promise.resolve(!0)}return o(e,c||[]),Promise.resolve(!1)},cancelDragEdge:function(e){return o(e,c||[]),!0},detectReversedEdge:function(e,t,n){return"in"===a.portName.eval(t)}};return d},ie.wildcard_ports=function(e){var a=e.diagram,r=e.get_type||function(e){return e.orig.value.type},l=e.set_type||function(e,t){e.orig.value.type=t.orig.value.type},i=e.get_name||function(e){return e.orig.value.name},c=e.is_wild||function(e){return e.orig.value.wild},s=e.update_ports||function(){},u=e.get_linked||function(){return[]};function d(e,t){if(!a)return[];var n=a.nodeKey.eval(e),r=i(t),o=(u(e)||[]).find(function(e){return e.includes(r)});return o?o.filter(function(e){return e!==r}).map(function(e){return a.getPort(n,null,e)}):[]}function f(e){return e.every(function(e){return 0===e.edges.length})}return{isValid:function(e,t){return null===r(e)^null===r(t)||null!==r(e)&&r(e)===r(t)},whyInvalid:function(e,t){return null===r(e)&&null===r(t)?"can't connect wildcard to wildcard":r(e)!==r(t)&&"the types of ports must match"},copyLinked:function(e,t){d(e,t).forEach(function(e){l(e,t)})},copyType:function(e,t,n){return null===r(t)?(l(t,n),this.copyLinked(t.node,t),s()):null===r(n)&&(l(n,t),this.copyLinked(n.node,n),s()),Promise.resolve(e)},resetTypes:function(e){var u=a;return 2===arguments.length&&(u=arguments[0],e=arguments[1]),e.forEach(function(e){var t=u.getWholeEdge(e),n=u.edgeSourcePortName.eval(t),r=u.edgeTargetPortName.eval(t),o=!1,a=u.getPort(u.nodeKey.eval(t.source),null,n),i=d(t.source,a);c(a)&&1===a.edges.length&&f(i)&&(l(a,null),i.forEach(function(e){l(e,null),o=!0})),a=u.getPort(u.nodeKey.eval(t.target),null,r),i=d(t.target,a),c(a)&&1===a.edges.length&&f(i)&&(l(a,null),i.forEach(function(e){l(e,null),o=!0})),o&&s()}),Promise.resolve(e)}}},ie.symbol_port_style=function(){var s,d,o,f={};function g(e){return e.named?e.name:f.parent().edgeKey.eval(e.edges[0])}function p(e){var t=f.color.eval(e);return t?f.colorScale()?f.colorScale()(t):t:"none"}function h(e){var t=f.portPosition(e);return"translate("+t.x+","+t.y+")"}function y(e){f.symbolScale()||f.symbolScale(re.scale.ordinal().range(re.shuffle(f.content().enum())));var t=f.symbol.eval(e);return t&&(f.symbolScale()?f.symbolScale()(t):t)}function v(e){return e.vec[0]<0}function m(e){switch(e.state){case"large":return f.largeRadius.eval(e);case"medium":return f.mediumRadius.eval(e);case"small":default:return f.smallRadius.eval(e)}}function x(e){return/-medium$/.test(e.state)?f.mediumRadius.eval(e):f.largeRadius.eval(e)}function _(e){var t,n;return"none"===(n=f.outlineFill.eval(e)?(t=f.outlineFillScale()||le,f.outlineFill.eval(e)):(t=f.parent().nodeFillScale()||le,f.parent().nodeFill.eval(e.node)))?"none":t(n)}function w(e){return f.outlineStroke.eval(e)||f.parent().nodeStroke.eval(e.node)}function b(e){var t=f.outlineStrokeWidth.eval(e);return"number"==typeof t?t:f.parent().nodeStrokeWidth.eval(e.node)}return f.symbolScale=ce(null),f.colorScale=ce(re.scale.ordinal().range(re.shuffle(["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"]))),f.symbol=f.portSymbol=ce(g,!1),f.color=f.portColor=ce(g,!1),f.outline=ce(ie.symbol_port_style.outline.circle()),f.content=ce(ie.symbol_port_style.content.d3symbol()),f.smallRadius=f.portRadius=ce(7),f.mediumRadius=f.portHoverNodeRadius=ce(10),f.largeRadius=f.portHoverPortRadius=ce(14),f.displacement=f.portDisplacement=ce(2),f.outlineFillScale=f.portBackgroundScale=ce(null),f.outlineFill=f.portBackgroundFill=ce(null),f.outlineStroke=f.portBackgroundStroke=ce(null),f.outlineStrokeWidth=f.portBackgroundStrokeWidth=ce(null),f.padding=f.portPadding=ce(2),f.label=f.portLabel=f.portText=ce(function(e){return e.name}),f.portLabelPadding=ce({x:5,y:5}),f.cascade=he(f),f.portPosition=function(e){var t=Math.hypot(e.pos.x,e.pos.y),n=e.pos.x/t,r=e.pos.y/t,o=f.displacement.eval(e);return{x:e.pos.x+o*n,y:e.pos.y+o*r}},f.portBounds=function(e){var t=f.largeRadius.eval(e),n=f.portPosition(e);return{left:n.x-t/2,top:n.y-t/2,right:n.x+t/2,bottom:n.y+t/2}},f.animateNodes=function(e,t){var n=re.set(e),r=d.filter(function(e){return n.has(f.parent().nodeKey.eval(e))}),o=f.parent().selectNodePortsOfStyle(r,f.parent().portStyle.nameOf(this)),a=o.filter(function(e){return/^shimmer/.test(e.state)}),i=o.filter(function(e){return!/^shimmer/.test(e.state)});function u(){var e=a.transition().duration(1e3).ease("bounce");e.selectAll(".port-outline").call(f.outline().draw(function(e){return x(e)+f.portPadding.eval(e)})),e.selectAll(".port-symbol").call(f.content().draw(y,x));var t=e.transition().duration(1e3).ease("sin");t.selectAll(".port-outline").call(f.outline().draw(function(e){return f.smallRadius.eval(e)+f.portPadding.eval(e)})),t.selectAll(".port-symbol").call(f.content().draw(y,f.smallRadius.eval)),t.each("end",u)}a.size()&&(t?t.each("end",u):u());var l=i.transition().duration(250);function c(e){return"large"===e.state||"medium"===e.state}return l.selectAll(".port-outline").call(f.outline().draw(function(e){return m(e)+f.portPadding.eval(e)})),l.selectAll(".port-symbol").call(f.content().draw(y,m)),l.selectAll("text.port-label").attr({opacity:function(e){return c(e)?1:0},"pointer-events":function(e){return c(e)?"auto":"none"}}),l.selectAll("rect.port-label-background").attr("opacity",function(e){return c(e)?1:0}),d.filter(function(e){var t=s[f.parent().nodeKey.eval(e)];return t&&t.some(c)}).each(function(){this.parentNode.appendChild(this)}),o.filter(function(e){return"small"!==e.state}).each(function(){this.parentNode.appendChild(this)}),l},f.eventPort=function(){var e=re.select(re.event.target.parentNode);return"g"===re.event.target.parentNode.tagName&&e.classed("port")?e.datum():null},f.drawPorts=function(e,t,n){s=t,d=n;var r=e.data(function(e){return t[f.parent().nodeKey.eval(e)]||[]},g);r.exit().remove();var o=r.enter().append("g").attr({class:"port",transform:h});r.transition("port-position").duration(f.parent().stagedDuration()).delay(f.parent().stagedDelay(!1)).attr({transform:h});var a=r.selectAll(".port-outline").data(function(e){return"none"!==_(e)?[e]:[]});a.exit().remove();var i=a.enter().append(f.outline().tag()).attr({class:"port-outline",fill:_,"stroke-width":b,stroke:w});f.outline().init&&i.call(f.outline().init),i.call(f.outline().draw(function(e){return f.smallRadius.eval(e)+f.portPadding.eval(e)})),a.attr({fill:_,"stroke-width":b,stroke:w}),a.transition().duration(f.parent().stagedDuration()).delay(f.parent().stagedDelay(!1)).call(f.outline().draw(function(e){return f.smallRadius.eval(e)+f.portPadding.eval(e)}));o.append(f.content().tag()).attr("class","port-symbol").call(f.content().draw(y,f.smallRadius.eval));var u=r.select(".port-symbol");u.attr("fill",p),u.transition().duration(f.parent().stagedDuration()).delay(f.parent().stagedDelay(!1)).call(f.content().draw(y,f.smallRadius.eval));var l=r.selectAll("text.port-label").data(function(e){return f.portLabel.eval(e)?[e]:[]});l.exit().remove();var c=l.enter();return c.append("rect").attr({class:"port-label-background","pointer-events":"none"}),c.append("text").attr({class:"port-label","dominant-baseline":"middle","pointer-events":"none",cursor:"default",opacity:0}),l.each(function(e){e.offset=(v(e)?-1:1)*(f.largeRadius.eval(e)+f.portPadding.eval(e))}).attr({"text-anchor":function(e){return v(e)?"end":"start"},transform:function(e){return"translate("+e.offset+",0)"}}).text(f.portLabel.eval).each(function(e){e.bbox=A(this)}),r.selectAll("rect.port-label-background").attr({x:function(e){return(e.offset<0?e.offset-e.bbox.width:e.offset)-f.portLabelPadding.eval(e).x},y:function(e){return-e.bbox.height/2-f.portLabelPadding.eval(e).y},width:function(e){return e.bbox.width+2*f.portLabelPadding.eval(e).x},height:function(e){return e.bbox.height+2*f.portLabelPadding.eval(e).y},fill:"white",opacity:0}),f},f.enableHover=function(e){if(!o&&f.parent()){var t=f.parent().child("draw-graphs");t&&(o=t.conduct())}var n="grow-ports-"+f.parent().portStyle.nameOf(this);return e?(d.on("mouseover."+n,function(e){var t=f.parent().nodeKey.eval(e),n=f.eventPort();s[t]&&s[t].forEach(function(e){e.state=e===n?"large":n?"small":"medium"});var r=o&&o.hoverPort(n)||[];r.push(t),f.animateNodes(r)}),d.on("mouseout."+n,function(e){var t=f.parent().nodeKey.eval(e);s[t]&&s[t].forEach(function(e){e.state="small"});var n=o&&o.hoverPort(null)||[];n.push(t),f.animateNodes(n)})):(d.on("mouseover."+n,null),d.on("mouseout."+n,null)),f},f.parent=ce(null),f},ie.symbol_port_style.outline={},ie.symbol_port_style.outline.circle=function(){return{tag:function(){return"circle"},draw:function(t){return function(e){e.attr("r",function(e){return t(e)})}}}},ie.symbol_port_style.outline.square=function(){return{tag:function(){return"rect"},init:function(e){},draw:function(t){return function(e){e.attr({x:function(e){return-t(e)},y:function(e){return-t(e)},width:function(e){return 2*t(e)},height:function(e){return 2*t(e)}})}}}},ie.symbol_port_style.outline.arrow=function(){var r=.75-Math.PI/8,o={tag:function(){return"path"},init:function(e){},draw:function(n){return function(e){e.attr("d",function(e){var t=n(e);return!o.outie()||o.outie()(e.orig)?"M"+-r*t+","+-t+" h"+t+" l"+t+","+t+" l"+-t+","+t+" h"+-t+" a"+t+","+t+" 0 1,1 0,"+-2*t:"M"+-(2-r)*t+","+-t+" h"+2*t+" a"+t+","+t+" 0 1,1 0,"+2*t+" h"+-2*t+" l"+t+","+-t+" l"+-t+","+-t})}},outie:ce(null)};return o},ie.symbol_port_style.content={},ie.symbol_port_style.content.d3symbol=function(){return{tag:function(){return"path"},enum:function(){return re.svg.symbolTypes},draw:function(r,o){return function(e){e.attr("d",function(e){var t=r(e),n=o(e);return t?re.svg.symbol().type(t).size(n*n)():""}),e.attr("transform",function(e){switch(r(e)){case"triangle-up":return"translate(0, -1)";case"triangle-down":return"translate(0, 1)";default:return null}})}}}},ie.symbol_port_style.content.letter=function(){return{tag:function(){return"text"},enum:function(){return re.range(65,91).map(String.fromCharCode)},draw:function(t,n){return function(e){e.text(t).attr({"dominant-baseline":"middle","text-anchor":"middle"}),e.each(function(e){e.symbol_size||(e.symbol_size=A(this))}),e.attr("transform",function(e){return"scale("+2*n(e)/e.symbol_size.height+") translate("+[0,2].join(",")+")"})}}}},ie.file_formats=[{exts:"json",mimes:"application/json",from_url:re.json,from_text:function(e,t){t(null,JSON.parse(e))}},{exts:["gv","dot"],mimes:"text/vnd.graphviz",from_url:function(e,t){re.text(e,X.bind(null,t))},from_text:function(e,t){X(t,null,e)}},{exts:"psv",mimes:"text/psv",from_url:function(e,t){re.dsv("|","text/plain")(e,Y.bind(null,t))},from_text:function(e,t){Y(t,null,re.dsv("|").parse(e))}},{exts:"csv",mimes:"text/csv",from_url:function(e,t){re.csv(e,Y.bind(null,t))},from_text:function(e,t){Y(t,null,re.csv.parse(e))}}],ie.match_file_format=function(n){return ie.file_formats.find(function(e){var t=e.exts;return Array.isArray(t)||(t=[t]),t.find(function(e){return new RegExp("."+e+"$").test(n)})})},ie.match_mime_type=function(n){return ie.file_formats.find(function(e){var t=e.mimes;return Array.isArray(t)||(t=[t]),t.includes(n)})},ie.load_graph=function(){var e,t,r,n,o,a;if(e=arguments[0],3===arguments.length)t=arguments[1],r=arguments[2];else{if(2!==arguments.length)throw new Error("need two or three arguments");r=arguments[1]}if(t)queue().defer(re.json,e).defer(re.json,t).await(function(e,t,n){e?r(e,null):r(null,{nodes:t.results,edges:n.results})});else if(/^data:/.test(e)){var i=e.slice(5).split(/,(.+)/);(n=ie.match_mime_type(i[0]))?n.from_text(i[1],r):r((a=i[0],new Error("do not know how to process mime type "+a)))}else{var u=(o=e)?o.replace(/\?.*/,""):null;(n=ie.match_file_format(u))?n.from_url(e,r):r(V(u))}},ie.load_graph_text=function(e,t,n){var r=ie.match_file_format(t);r?r.from_text(e,n):n(V(t))},ie.data_url=function(e){return"data:application/json,"+JSON.stringify(e)},ie.munge_graph=function(t,e,n,r){var o,a,i=e||"name",u=n||"sourcename",l=r||"targetname";if(!J(t)){var c=["database","response"],s=c.findIndex(function(e){return t[e]&&J(t[e])});if(s<0)throw new Error("couldn't find the data!");t=t[c[s]]}function d(t,e){return e.filter(function(e){return!!t[e]})}a=t.edges||t.links,o=t.nodes||t.vertices;var f=a[0];if(void 0===f[u]){var g=n?[n]:["source_ecomp_uid","node1","source","tail"],p=r?[r]:["target_ecomp_uid","node2","target","head"],h=["edge"];if(f.node0&&f.node1)u="node0",l="node1";else{var y=d(f,g);if(!y.length){if((s=h.findIndex(function(e){return f[e]&&d(f[e],g).length}))<0)throw n?new Error("sourceattr "+u+" didn't work"):new Error("didn't find any source attr");a=a.map(function(e){return e[h[s]]}),y=d(f=a[0],g)}if(1<y.length&&console.warn("found more than one possible source attr",y),u=y[0],!(y=d(f,p)).length)throw r&&!f[r]?new Error("targetattr "+l+" didn't work"):new Error("didn't find any target attr");1<y.length&&console.warn("found more than one possible target attr",y),l=y[0]}}var v=o[0];if(void 0===v[i]){var m=e?[e]:["ecomp_uid","id","_id","key"],x=["vertex"];if(!(y=d(v,m)).length){if((s=x.findIndex(function(e){return v[e]&&d(v[e],m).length}))<0)throw e?new Error("nodekeyattr "+i+" didn't work"):new Error("couldn't find the node data");o=o.map(function(e){return e[x[s]]}),y=d(v=o[0],m)}1<y.length&&console.warn("found more than one possible node key attr",y),i=y[0]}return{nodes:o,edges:a,nodekeyattr:i,sourceattr:u,targetattr:l}},ie.flat_group=(W=function(e,t){return t},H=function(){return null},G=function(){return null},{make:function(e,t){var n,r,o,a,i;return n=Array.isArray(e)?oe(e):e,o=t,i=(r=n).dimension(o),{crossfilter:r,dimension:i,group:(a=i.group().reduce(W,H,G),{all:function(){return a.all().filter(function(e){return null!==e.value})}})}},another:pe("use .make() instead",function(e,t){return this.make(e,t)})});var Z=function(e,i,u,l,c,s){if(c=c||0,i.length>(u.valuesByAttr?1:0)){var d=i.shift(),f=[],g=[],t=e.map(function(e){var t,n=e[u.nestKey],r=u.nestKeysUnique?n:K();if(r&&((t=u.ancestorKeys?(s=s||{},d&&(s[d]=n),Object.assign({},s)):{})[u.nodeKey]=r,u.label&&u.labelFun&&(t[u.label]=u.labelFun(n,d,e)),u.level&&(t[u.level]=c+1),f.push(t),l)){var o={};o[u.edgeSource]=l,o[u.edgeTarget]=r,g.push(o)}var a=u.valuesByAttr?e[i[0]]:e.values;return Z(a,i.slice(0),u,r,c+1,Object.assign({},s))});return{nodes:Array.prototype.concat.apply(f,t.map(ae.pluck("nodes"))),edges:Array.prototype.concat.apply(g,t.map(ae.pluck("edges")))}}return{nodes:e.map(function(e){return e=Object.assign({},e),u.level&&(e[u.level]=c+1),e}),edges:e.map(function(e){var t={};return t[u.edgeSource]=l,t[u.edgeTarget]=e[u.nodeKey],t})}};ie.convert_tree=function(e,t,n){return n=Object.assign({nodeKey:"key",edgeKey:"key",edgeSource:"sourcename",edgeTarget:"targetname",nestKey:"key"},n),Array.isArray(e)?Z(e,t,n,n.root,0,n.inherit):(t=[""].concat(t),Z([e],t,n,n.root,0,n.inherit))},ie.convert_nest=function(e,t,n,r,o,a,i){return ie.convert_tree(e,t,{nodeKey:n,edgeSource:r,edgeTarget:o,root:a,inherit:i,ancestorKeys:!0,label:"name",labelFun:function(e,t,n){return t+":"+e},level:"_level"})},ie.convert_adjacency_list=function(e,r,o){var t=Array.prototype.concat.apply([],e.map(function(n){return n[r.adjacencies].map(function(e){var t={};return o.edgeKey&&(t[o.edgeKey]=K()),t[o.edgeSource]=n[r.nodeKey],t[o.edgeTarget]=r.targetKey?e[r.targetKey]:e,o.adjacency&&(t[o.adjacency]=e),t})}));return{nodes:e,edges:t}},ie.deparallelize=function(e,l,c,t){var s=(t=t||{}).both||!1,d=t.reduce||null;return{all:function(){var u={};e.all().forEach(function(e){var t,n=e.value[l],r=e.value[c],o=!!s||n<r,a=o?n:r,i=o?r:n;u[a]=u[a]||{},u[a][i]?(t=u[a][i],d&&(t.original=d(t.original,e))):u[a][i]=t={in:0,out:0,original:Object.assign({},e)},o?++t.in:++t.out});var r=[];return Object.keys(u).forEach(function(n){Object.keys(u[n]).forEach(function(e){var t=u[n][e];t[l]=n,t[c]=e,r.push({key:t.original.key,value:t})})}),r}}},ie.path_reader=function(e){var a,i,u,l=ie.register_highlight_paths_group(e||"highlight-paths-group");function c(r,o,a){s.elementList.eval(r).forEach(function(e){var t,n;switch(s.elementType.eval(e)){case"node":t=s.nodeKey.eval(e),n=o[t]=o[t]||[];break;case"edge":t=s.edgeSource.eval(e)+"-"+s.edgeTarget.eval(e),n=a[t]=a[t]||[]}n.push(r)})}var s={pathList:ce(le,!1),timeRange:ce(null,!1),pathStrength:ce(null,!1),elementList:ce(le,!1),elementType:ce(null,!1),nodeKey:ce(null,!1),edgeSource:ce(null,!1),edgeTarget:ce(null,!1),clear:function(){l.paths_changed({},{},[])},data:function(e){var t,n={},r={},o=[];s.pathList.eval(e).forEach(function(e){if(e._range=s.timeRange.eval(e)){if(!1===t)throw new Error("can't have a mix of ranged and non-ranged paths");t=!0}else{if(!0===t)throw new Error("can't have a mix of ranged and non-ranged paths");t=!1,c(e,n,r)}o.push(e)}),t?(a=o.map(function(e){var t=[e._range[0].getTime(),e._range[1].getTime()];return t.path=e,t}),i=lysenkoIntervalTree(a),u&&this.setTime(u)):(i=a=null,l.paths_changed(n,r,o))},getIntervals:function(){return a},setTime:function(e){if(e&&i){var t=[],n={},r={};i.queryPoint(e.getTime(),function(e){t.push(e.path),c(e.path,n,r)}),l.paths_changed(n,r,t)}u=e}};return s},ie.path_selector=function(e,t,n,r){var o=ie.register_highlight_paths_group(n||"highlight-paths-group"),i=re.select(e).append("svg"),a=[],u=null,l=null;function c(t){return function(e){return!!t&&0<=t.indexOf(e)}}function s(e){var t=c(e);return function(e){return!t(e)}}function d(r,e){if(0!==e.length){i.attr("height",20*(e.length+1)).attr("width",30+46*(e.length/2+1)+20),i.selectAll(".path-selector").remove();var t=i.selectAll("g.path-selector").data(e);t.enter().append("g").attr("class","path-selector").attr("transform",function(e,t){return"translate(0, "+20*t+")"}).each(function(n,e){var t=n.element_list.filter(function(e){return"node"===e.element_type});re.select(this).append("line").attr("x1",60).attr("y1",9).attr("x2",30+30*t.length).attr("y2",9).attr("opacity",.4).attr("stroke-width",5).attr("stroke","#bdbdbd"),re.select(this).selectAll("circle").data(t).enter().append("circle").attr("cx",function(e,t){return 30+30*(t+1)}).attr("cy",9).attr("r",8).attr("opacity",.4).attr("fill",function(e){var t={key:e.property_map.ecomp_uid,value:e.property_map};return r.nodeStroke()(t)}),re.select(this).append("text").text("Path "+e).attr("class","path_label").attr("x",0).attr("y",13.6).on("mouseover.path-selector",function(){o.hover_changed([n])}).on("mouseout.path-selector",function(){o.hover_changed(null)}).on("click.path-selector",function(){var e,t;o.select_changed((t=[n],(e=l)?t?t.every(c(e))?e.filter(s(t)):e.concat(t.filter(s(e))):e:t))})}),t.exit().transition(1e3).attr("opacity",0).remove()}}function f(){var a=c(u);i.selectAll("g.path-selector").each(function(e,t){var n=a(e)?"#e41a1c":"black",r=a(e)?"black":"#bdbdbd",o=a(e)?"1":"0.4";re.select(this).select(".path_label").attr("fill",n),re.select(this).selectAll("line").attr("stroke",r).attr("opacity",o),re.select(this).selectAll("circle").attr("opacity",o)})}function g(){var a=c(l);i.selectAll("g.path-selector").each(function(e,t){var n=a(e)?"bold":"normal",r=a(e)?"black":"#bdbdbd",o=a(e)?"1":"0.4";re.select(this).select(".path_label").attr("font-weight",n),re.select(this).selectAll("line").attr("stroke",r).attr("opacity",o),re.select(this).selectAll("circle").attr("opacity",o)})}o.on("paths_changed.path-selector",function(e,t,n){u=l=null,a=n,p.redraw()}).on("hover_changed.path-selector",function(e){u=e,f()}).on("select_changed.path-selector",function(e){l=e,g()});var p={default_text:ce("Nothing here"),zero_text:ce("No paths"),error_text:ce(null),queried:ce(!1),redraw:function(){d(diagram,a),f(),g()},render:function(){return this.redraw(),this}};return ae.registerChart(p,r),p},ie.node_name=function(e){if(e<26)return String.fromCharCode(97+e);if(e<52)return String.fromCharCode(65+e-26);if(e<2704)return ie.node_name(Math.floor(e/52))+ie.node_name(e%52);throw new Error("no, that's too large")},ie.node_object=function(e,t){return t=t||{},_.extend({id:e,name:ie.node_name(e)},t)},ie.edge_object=function(e,t,n,r){return r=r||{},_.extend({source:t,target:n,sourcename:e(t),targetname:e(n)},r)},ie.generate=function(e,t,n,r){var o,a,i,u,l=n.nodePrefix||"",c=function(e){return o[e].name},s=t[0],d=n.linkLength||30;switch(e){case"clique":case"cliquestf":for(o=new Array(s),a=[],i=0;i<s;++i)for(o[i]=ie.node_object(i,{circle:"A",name:l+ie.node_name(i)}),u=0;u<i;++u)a.push(ie.edge_object(c,i,u,{notLayout:!0,undirected:!0}));if("cliquestf"===e)for(i=0;i<s;++i)o[i+s]=ie.node_object(i+s),o[i+2*s]=ie.node_object(i+2*s),a.push(ie.edge_object(c,i,i+s,{undirected:!0})),a.push(ie.edge_object(c,i,i+2*s,{undirected:!0}));break;case"wheel":for(o=new Array(s),i=0;i<s;++i)o[i]=ie.node_object(i,{name:l+ie.node_name(i)});var f=(a=ie.wheel_edges(c,_.range(s),s*d/2))[0].distance;for(i=0;i<t[1];++i)for(u=0;u<s;++u){var g,p=u,h=(u+1)%s;i%2==1&&(g=p,p=h,h=g),a.push(ie.edge_object(c,p,h,{distance:f,par:i+2}))}break;default:throw new Error("unknown generation type "+e)}r(null,{nodes:o,links:a})},ie.wheel_edges=function(e,t,n){for(var r=t.length,o=[],a=Math.floor(r/2),i=2*n*Math.sin(Math.PI/r),u=2*n*Math.sin(a*Math.PI/r),l=0;l<r;++l)o.push(ie.edge_object(e,t[l],t[(l+1)%r],{distance:i}));for(l=0;l<r/2;++l)o.push(ie.edge_object(e,t[l],t[(l+a)%r],{distance:u})),r%2&&l!=Math.floor(r/2)&&o.push(ie.edge_object(e,t[l],t[(l+r-a)%r],{distance:u}));return o},ie.random_graph=function(a){a=Object.assign({ncolors:5,ndashes:4,nodeKey:"key",edgeKey:"key",sourceKey:"sourcename",targetKey:"targetname",colorTag:"color",dashTag:"dash",nodeKeyGen:function(e){return"n"+e},edgeKeyGen:function(e){return"e"+e},newComponentProb:.1,newNodeProb:.9,removeEdgeProb:.75,log:!1},a),isNaN(a.newNodeProb)&&(a.newNodeProb=.9),a.newNodProb<=0&&(a.newNodeProb=.1);var i=[],u=[];function l(){var e={};return e[a.nodeKey]=a.nodeKeyGen(i.length),e[a.colorTag]=Math.floor(Math.random()*a.ncolors),i.push(e),e}function c(){return i[Math.floor(Math.random()*i.length)]}return{nodes:function(){return i},edges:function(){return u},generate:function(e){for(;0<e--;){var t,n,r=Math.random();if(t=!i.length||r<a.newComponentProb?l():c(),n=r<a.newNodeProb?l():c(),t&&n){var o={};o[a.edgeKey]=a.edgeKeyGen(u.length),o[a.sourceKey]=t[a.nodeKey],o[a.targetKey]=n[a.nodeKey],o[a.dashTag]=Math.floor(Math.random()*a.ndashes),a.log&&console.log(t[a.nodeKey]+" -> "+n[a.nodeKey]),u.push(o)}}},remove:function(e){for(;0<e--;){if(Math.random()<a.removeEdgeProb)u.splice(Math.floor(Math.random()*u.length),1);else{var n=i[Math.floor(Math.random()*i.length)],r=[];u.forEach(function(e,t){e[a.sourceKey]!==n[a.nodeKey]&&e[a.targetKey]!==n[a.nodeKey]||r.push(t)}),r.reverse().forEach(function(e){u.splice(e,1)})}}}}},ie.supergraph=function(e,t){if(!ie.supergraph.pattern){var n=metagraph,r={nodes:{graph:n.graph_pattern(t),sg:n.subgraph_pattern(t),subgraph:n.graph_pattern(t)},edges:{to_sg:{source:"graph",target:"sg",input:"parent"},from_sg:{source:"subgraph",target:"sg",input:"child"}}};ie.supergraph.pattern=n.compose(n.graph_detect(r))}return ie.supergraph.pattern.node("graph.Graph").value().create(e)};var $=fe("warn","dc_graph.line_breaks now takes a string - d.key behavior is deprecated and will be removed in a later version");return ie.line_breaks=function(e,i){var u=new RegExp(e,"g");return function(e){var t;"object"==typeof e&&($(),e=e.key);for(var n,r="",o=[],a=0;n=(t=u.exec(e))?e.slice(a,u.lastIndex):e.slice(a),r.length+n.length>i&&0<r.length&&(o.push(r),r=""),r+=n,a=u.lastIndex,null!==t;);return o.push(r),o}},ie.build_type_graph=function(e,t,n,i,u,l){var c={},r={},s={};return e.forEach(function(e){c[n(e)]=e;var t=i(e);r[t]||(r[t]={type:t})}),t.forEach(function(e){var t,n,r=u(e),o=l(e);if(!(t=c[r]))throw new Error("source key "+r+" not found!");if(!(n=c[o]))throw new Error("target key "+o+" not found!");var a=i(t)+"/"+i(n);s[a]||(s[a]={type:a,source:i(t),target:i(n)})}),{nodes:Object.keys(r).map(function(e){return r[e]}),edges:Object.keys(s).map(function(e){return s[e]})}},ie.d3=re,ie.crossfilter=oe,ie.dc=ae,ie}if("function"==typeof define&&define.amd)define(["d3","crossfilter","dc"],e);else if("object"==typeof module&&module.exports){var t=require("d3"),n=require("crossfilter");"function"!=typeof n&&(n=n.crossfilter);var r=require("dc");module.exports=e(t,n,r)}else this.dc_graph=e(d3,crossfilter,dc)}();
//# sourceMappingURL=dc.graph.min.js.map