@hpcc-js/graph 2.78.0 → 2.79.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,7 +31,14 @@ export interface Options {
31
31
 
32
32
  export function forceDirected(data: Data, options: Options) {
33
33
  // eslint-disable-next-line quotes
34
- const workerCode = `var forceDirected=function(t){"use strict";function n(t){return function(){return t}}function e(){return 1e-6*(Math.random()-.5)}function r(t,n,e,r){if(isNaN(n)||isNaN(e))return t;var i,o,s,u,a,c,l,f,h,v=t._root,y={data:r},p=t._x0,_=t._y0,d=t._x1,g=t._y1;if(!v)return t._root=y,t;for(;v.length;)if((c=n>=(o=(p+d)/2))?p=o:d=o,(l=e>=(s=(_+g)/2))?_=s:g=s,i=v,!(v=v[f=l<<1|c]))return i[f]=y,t;if(u=+t._x.call(null,v.data),a=+t._y.call(null,v.data),n===u&&e===a)return y.next=v,i?i[f]=y:t._root=y,t;do{i=i?i[f]=new Array(4):t._root=new Array(4),(c=n>=(o=(p+d)/2))?p=o:d=o,(l=e>=(s=(_+g)/2))?_=s:g=s}while((f=l<<1|c)==(h=(a>=s)<<1|u>=o));return i[h]=v,i[f]=y,t}function i(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function o(t){return t[0]}function s(t){return t[1]}function u(t,n,e){var r=new a(null==n?o:n,null==e?s:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function a(t,n,e,r,i,o){this._x=t,this._y=n,this._x0=e,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function c(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var l=u.prototype=a.prototype;l.copy=function(){var t,n,e=new a(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=c(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=c(n));return e},l.add=function(t){var n=+this._x.call(null,t),e=+this._y.call(null,t);return r(this.cover(n,e),n,e,t)},l.addAll=function(t){var n,e,i,o,s=t.length,u=new Array(s),a=new Array(s),c=1/0,l=1/0,f=-1/0,h=-1/0;for(e=0;e<s;++e)isNaN(i=+this._x.call(null,n=t[e]))||isNaN(o=+this._y.call(null,n))||(u[e]=i,a[e]=o,i<c&&(c=i),i>f&&(f=i),o<l&&(l=o),o>h&&(h=o));if(c>f||l>h)return this;for(this.cover(c,l).cover(f,h),e=0;e<s;++e)r(this,u[e],a[e],t[e]);return this},l.cover=function(t,n){if(isNaN(t=+t)||isNaN(n=+n))return this;var e=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(e))i=(e=Math.floor(t))+1,o=(r=Math.floor(n))+1;else{for(var s,u,a=i-e,c=this._root;e>t||t>=i||r>n||n>=o;)switch(u=(n<r)<<1|t<e,(s=new Array(4))[u]=c,c=s,a*=2,u){case 0:i=e+a,o=r+a;break;case 1:e=i-a,o=r+a;break;case 2:i=e+a,r=o-a;break;case 3:e=i-a,r=o-a}this._root&&this._root.length&&(this._root=c)}return this._x0=e,this._y0=r,this._x1=i,this._y1=o,this},l.data=function(){var t=[];return this.visit(function(n){if(!n.length)do{t.push(n.data)}while(n=n.next)}),t},l.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},l.find=function(t,n,e){var r,o,s,u,a,c,l,f=this._x0,h=this._y0,v=this._x1,y=this._y1,p=[],_=this._root;for(_&&p.push(new i(_,f,h,v,y)),null==e?e=1/0:(f=t-e,h=n-e,v=t+e,y=n+e,e*=e);c=p.pop();)if(!(!(_=c.node)||(o=c.x0)>v||(s=c.y0)>y||(u=c.x1)<f||(a=c.y1)<h))if(_.length){var d=(o+u)/2,g=(s+a)/2;p.push(new i(_[3],d,g,u,a),new i(_[2],o,g,d,a),new i(_[1],d,s,u,g),new i(_[0],o,s,d,g)),(l=(n>=g)<<1|t>=d)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-l],p[p.length-1-l]=c)}else{var x=t-+this._x.call(null,_.data),w=n-+this._y.call(null,_.data),m=x*x+w*w;if(m<e){var b=Math.sqrt(e=m);f=t-b,h=n-b,v=t+b,y=n+b,r=_.data}}return r},l.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t)))return this;var n,e,r,i,o,s,u,a,c,l,f,h,v=this._root,y=this._x0,p=this._y0,_=this._x1,d=this._y1;if(!v)return this;if(v.length)for(;;){if((c=o>=(u=(y+_)/2))?y=u:_=u,(l=s>=(a=(p+d)/2))?p=a:d=a,n=v,!(v=v[f=l<<1|c]))return this;if(!v.length)break;(n[f+1&3]||n[f+2&3]||n[f+3&3])&&(e=n,h=f)}for(;v.data!==t;)if(r=v,!(v=v.next))return this;return(i=v.next)&&delete v.next,r?(i?r.next=i:delete r.next,this):n?(i?n[f]=i:delete n[f],(v=n[0]||n[1]||n[2]||n[3])&&v===(n[3]||n[2]||n[1]||n[0])&&!v.length&&(e?e[h]=v:this._root=v),this):(this._root=i,this)},l.removeAll=function(t){for(var n=0,e=t.length;n<e;++n)this.remove(t[n]);return this},l.root=function(){return this._root},l.size=function(){var t=0;return this.visit(function(n){if(!n.length)do{++t}while(n=n.next)}),t},l.visit=function(t){var n,e,r,o,s,u,a=[],c=this._root;for(c&&a.push(new i(c,this._x0,this._y0,this._x1,this._y1));n=a.pop();)if(!t(c=n.node,r=n.x0,o=n.y0,s=n.x1,u=n.y1)&&c.length){var l=(r+s)/2,f=(o+u)/2;(e=c[3])&&a.push(new i(e,l,f,s,u)),(e=c[2])&&a.push(new i(e,r,f,l,u)),(e=c[1])&&a.push(new i(e,l,o,s,f)),(e=c[0])&&a.push(new i(e,r,o,l,f))}return this},l.visitAfter=function(t){var n,e=[],r=[];for(this._root&&e.push(new i(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var o=n.node;if(o.length){var s,u=n.x0,a=n.y0,c=n.x1,l=n.y1,f=(u+c)/2,h=(a+l)/2;(s=o[0])&&e.push(new i(s,u,a,f,h)),(s=o[1])&&e.push(new i(s,f,a,c,h)),(s=o[2])&&e.push(new i(s,u,h,f,l)),(s=o[3])&&e.push(new i(s,f,h,c,l))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.y0,n.x1,n.y1);return this},l.x=function(t){return arguments.length?(this._x=t,this):this._x},l.y=function(t){return arguments.length?(this._y=t,this):this._y};function f(){}function h(t,n){var e=new f;if(t instanceof f)t.each(function(t,n){e.set(n,t)});else if(Array.isArray(t)){var r,i=-1,o=t.length;if(null==n)for(;++i<o;)e.set(i,t[i]);else for(;++i<o;)e.set(n(r=t[i],i,t),r)}else if(t)for(var s in t)e.set(s,t[s]);return e}function v(){}f.prototype=h.prototype={constructor:f,has:function(t){return"$"+t in this},get:function(t){return this["$"+t]},set:function(t,n){return this["$"+t]=n,this},remove:function(t){var n="$"+t;return n in this&&delete this[n]},clear:function(){for(var t in this)"$"===t[0]&&delete this[t]},keys:function(){var t=[];for(var n in this)"$"===n[0]&&t.push(n.slice(1));return t},values:function(){var t=[];for(var n in this)"$"===n[0]&&t.push(this[n]);return t},entries:function(){var t=[];for(var n in this)"$"===n[0]&&t.push({key:n.slice(1),value:this[n]});return t},size:function(){var t=0;for(var n in this)"$"===n[0]&&++t;return t},empty:function(){for(var t in this)if("$"===t[0])return!1;return!0},each:function(t){for(var n in this)"$"===n[0]&&t(this[n],n.slice(1),this)}};var y=h.prototype;function p(t){return t.index}function _(t,n){var e=t.get(n);if(!e)throw new Error("missing: "+n);return e}v.prototype=function(t,n){var e=new v;if(t instanceof v)t.each(function(t){e.add(t)});else if(t){var r=-1,i=t.length;if(null==n)for(;++r<i;)e.add(t[r]);else for(;++r<i;)e.add(n(t[r],r,t))}return e}.prototype={constructor:v,has:y.has,add:function(t){return this["$"+(t+="")]=t,this},remove:y.remove,clear:y.clear,values:y.keys,size:y.size,empty:y.empty,each:y.each};var d={value:function(){}};function g(){for(var t,n=0,e=arguments.length,r={};n<e;++n){if(!(t=arguments[n]+"")||t in r||/[\\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new x(r)}function x(t){this._=t}function w(t,n){for(var e,r=0,i=t.length;r<i;++r)if((e=t[r]).name===n)return e.value}function m(t,n,e){for(var r=0,i=t.length;r<i;++r)if(t[r].name===n){t[r]=d,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=e&&t.push({name:n,value:e}),t}x.prototype=g.prototype={constructor:x,on:function(t,n){var e,r,i=this._,o=(r=i,(t+"").trim().split(/^|\\s+/).map(function(t){var n="",e=t.indexOf(".");if(e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})),s=-1,u=o.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++s<u;)if(e=(t=o[s]).type)i[e]=m(i[e],t.name,n);else if(null==n)for(e in i)i[e]=m(i[e],t.name,null);return this}for(;++s<u;)if((e=(t=o[s]).type)&&(e=w(i[e],t.name)))return e},copy:function(){var t={},n=this._;for(var e in n)t[e]=n[e].slice();return new x(t)},call:function(t,n){if((e=arguments.length-2)>0)for(var e,r,i=new Array(e),o=0;o<e;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,e=(r=this._[t]).length;o<e;++o)r[o].value.apply(n,i)},apply:function(t,n,e){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(n,e)}};var b,A,N=0,M=0,k=0,E=1e3,j=0,T=0,q=0,D="object"==typeof performance&&performance.now?performance:Date,S="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function $(){return T||(S(O),T=D.now()+q)}function O(){T=0}function P(){this._call=this._time=this._next=null}function z(t,n,e){var r=new P;return r.restart(t,n,e),r}function C(){T=(j=D.now())+q,N=M=0;try{!function(){$(),++N;for(var t,n=b;n;)(t=T-n._time)>=0&&n._call.call(null,t),n=n._next;--N}()}finally{N=0,function(){var t,n,e=b,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:b=n);A=t,I(r)}(),T=0}}function F(){var t=D.now(),n=t-j;n>E&&(q-=n,j=t)}function I(t){N||(M&&(M=clearTimeout(M)),t-T>24?(t<1/0&&(M=setTimeout(C,t-D.now()-q)),k&&(k=clearInterval(k))):(k||(j=D.now(),k=setInterval(F,E)),N=1,S(C)))}function Y(t){return t.x}function K(t){return t.y}P.prototype=z.prototype={constructor:P,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?$():+e)+(null==n?0:+n),this._next||A===this||(A?A._next=this:b=this,A=this),this._call=t,this._time=e,I()},stop:function(){this._call&&(this._call=null,this._time=1/0,I())}};var L=10,U=Math.PI*(3-Math.sqrt(5));var W="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function B(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var G,H;(function(t,n){t.exports=function(){function t(t){return"function"==typeof t}var n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},e=0,r=void 0,i=void 0,o=function(t,n){h[e]=t,h[e+1]=n,2===(e+=2)&&(i?i(v):g())},s="undefined"!=typeof window?window:void 0,u=s||{},a=u.MutationObserver||u.WebKitMutationObserver,c="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),l="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function f(){var t=setTimeout;return function(){return t(v,1)}}var h=new Array(1e3);function v(){for(var t=0;t<e;t+=2){var n=h[t],r=h[t+1];n(r),h[t]=void 0,h[t+1]=void 0}e=0}var y,p,_,d,g=void 0;function x(t,n){var e=this,r=new this.constructor(b);void 0===r[m]&&P(r);var i=e._state;if(i){var s=arguments[i-1];o(function(){return $(i,r,s,e._result)})}else D(e,r,t,n);return r}function w(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var n=new this(b);return E(n,t),n}c?g=function(){return process.nextTick(v)}:a?(p=0,_=new a(v),d=document.createTextNode(""),_.observe(d,{characterData:!0}),g=function(){d.data=p=++p%2}):l?((y=new MessageChannel).port1.onmessage=v,g=function(){return y.port2.postMessage(0)}):g=void 0===s?function(){try{var t=Function("return this")().require("vertx");return void 0!==(r=t.runOnLoop||t.runOnContext)?function(){r(v)}:f()}catch(t){return f()}}():f();var m=Math.random().toString(36).substring(2);function b(){}var A=void 0,N=1,M=2;function k(n,e,r){e.constructor===n.constructor&&r===x&&e.constructor.resolve===w?function(t,n){n._state===N?T(t,n._result):n._state===M?q(t,n._result):D(n,void 0,function(n){return E(t,n)},function(n){return q(t,n)})}(n,e):void 0===r?T(n,e):t(r)?function(t,n,e){o(function(t){var r=!1,i=function(t,n,e,r){try{t.call(n,e,r)}catch(t){return t}}(e,n,function(e){r||(r=!0,n!==e?E(t,e):T(t,e))},function(n){r||(r=!0,q(t,n))},t._label);!r&&i&&(r=!0,q(t,i))},t)}(n,e,r):T(n,e)}function E(t,n){if(t===n)q(t,new TypeError("You cannot resolve a promise with itself"));else if(function(t){var n=typeof t;return null!==t&&("object"===n||"function"===n)}(n)){var e=void 0;try{e=n.then}catch(n){return void q(t,n)}k(t,n,e)}else T(t,n)}function j(t){t._onerror&&t._onerror(t._result),S(t)}function T(t,n){t._state===A&&(t._result=n,t._state=N,0!==t._subscribers.length&&o(S,t))}function q(t,n){t._state===A&&(t._state=M,t._result=n,o(j,t))}function D(t,n,e,r){var i=t._subscribers,s=i.length;t._onerror=null,i[s]=n,i[s+N]=e,i[s+M]=r,0===s&&t._state&&o(S,t)}function S(t){var n=t._subscribers,e=t._state;if(0!==n.length){for(var r=void 0,i=void 0,o=t._result,s=0;s<n.length;s+=3)r=n[s],i=n[s+e],r?$(e,r,i,o):i(o);t._subscribers.length=0}}function $(n,e,r,i){var o=t(r),s=void 0,u=void 0,a=!0;if(o){try{s=r(i)}catch(t){a=!1,u=t}if(e===s)return void q(e,new TypeError("A promises callback cannot return that same promise."))}else s=i;e._state!==A||(o&&a?E(e,s):!1===a?q(e,u):n===N?T(e,s):n===M&&q(e,s))}var O=0;function P(t){t[m]=O++,t._state=void 0,t._result=void 0,t._subscribers=[]}var z=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(b),this.promise[m]||P(this.promise),n(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?T(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&T(this.promise,this._result))):q(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var n=0;this._state===A&&n<t.length;n++)this._eachEntry(t[n],n)},t.prototype._eachEntry=function(t,n){var e=this._instanceConstructor,r=e.resolve;if(r===w){var i=void 0,o=void 0,s=!1;try{i=t.then}catch(t){s=!0,o=t}if(i===x&&t._state!==A)this._settledAt(t._state,n,t._result);else if("function"!=typeof i)this._remaining--,this._result[n]=t;else if(e===C){var u=new e(b);s?q(u,o):k(u,t,i),this._willSettleAt(u,n)}else this._willSettleAt(new e(function(n){return n(t)}),n)}else this._willSettleAt(r(t),n)},t.prototype._settledAt=function(t,n,e){var r=this.promise;r._state===A&&(this._remaining--,t===M?q(r,e):this._result[n]=e),0===this._remaining&&T(r,this._result)},t.prototype._willSettleAt=function(t,n){var e=this;D(t,void 0,function(t){return e._settledAt(N,n,t)},function(t){return e._settledAt(M,n,t)})},t}(),C=function(){function n(t){this[m]=O++,this._result=this._state=void 0,this._subscribers=[],b!==t&&("function"!=typeof t&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof n?function(t,n){try{n(function(n){E(t,n)},function(n){q(t,n)})}catch(n){q(t,n)}}(this,t):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return n.prototype.catch=function(t){return this.then(null,t)},n.prototype.finally=function(n){var e=this.constructor;return t(n)?this.then(function(t){return e.resolve(n()).then(function(){return t})},function(t){return e.resolve(n()).then(function(){throw t})}):this.then(n,n)},n}();return C.prototype.then=x,C.all=function(t){return new z(this,t).promise},C.race=function(t){var e=this;return n(t)?new e(function(n,r){for(var i=t.length,o=0;o<i;o++)e.resolve(t[o]).then(n,r)}):new e(function(t,n){return n(new TypeError("You must pass an array to race."))})},C.resolve=w,C.reject=function(t){var n=new this(b);return q(n,t),n},C._setScheduler=function(t){i=t},C._setAsap=function(t){o=t},C._asap=o,C.polyfill=function(){var t=void 0;if(void 0!==W)t=W;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;if(n){var e=null;try{e=Object.prototype.toString.call(n.resolve())}catch(t){}if("[object Promise]"===e&&!n.cast)return}t.Promise=C},C.Promise=C,C}()}(H={path:G,exports:{},require:function(t,n){return B(null==n&&H.path)}},H.exports),H.exports).polyfill();function J(t,r){var i=t.nodes,o=t.links,s=function(t){var r,i,o,s,u,a=p,c=function(t){return 1/Math.min(s[t.source.index],s[t.target.index])},l=n(30),f=1;function v(n){for(var o=0,s=t.length;o<f;++o)for(var a,c,l,h,v,y,p,_=0;_<s;++_)c=(a=t[_]).source,h=(l=a.target).x+l.vx-c.x-c.vx||e(),v=l.y+l.vy-c.y-c.vy||e(),h*=y=((y=Math.sqrt(h*h+v*v))-i[_])/y*n*r[_],v*=y,l.vx-=h*(p=u[_]),l.vy-=v*p,c.vx+=h*(p=1-p),c.vy+=v*p}function y(){if(o){var n,e,c=o.length,l=t.length,f=h(o,a);for(n=0,s=new Array(c);n<l;++n)(e=t[n]).index=n,"object"!=typeof e.source&&(e.source=_(f,e.source)),"object"!=typeof e.target&&(e.target=_(f,e.target)),s[e.source.index]=(s[e.source.index]||0)+1,s[e.target.index]=(s[e.target.index]||0)+1;for(n=0,u=new Array(l);n<l;++n)e=t[n],u[n]=s[e.source.index]/(s[e.source.index]+s[e.target.index]);r=new Array(l),d(),i=new Array(l),g()}}function d(){if(o)for(var n=0,e=t.length;n<e;++n)r[n]=+c(t[n],n,t)}function g(){if(o)for(var n=0,e=t.length;n<e;++n)i[n]=+l(t[n],n,t)}return null==t&&(t=[]),v.initialize=function(t){o=t,y()},v.links=function(n){return arguments.length?(t=n,y(),v):t},v.id=function(t){return arguments.length?(a=t,v):a},v.iterations=function(t){return arguments.length?(f=+t,v):f},v.strength=function(t){return arguments.length?(c="function"==typeof t?t:n(+t),d(),v):c},v.distance=function(t){return arguments.length?(l="function"==typeof t?t:n(+t),g(),v):l},v}(o).id(function(t){return t.id}).distance(r.linkDistance).strength(r.linkStrength),a=function(){var t,r,i,o,s=n(-30),a=1,c=1/0,l=.81;function f(n){var e,o=t.length,s=u(t,Y,K).visitAfter(v);for(i=n,e=0;e<o;++e)r=t[e],s.visit(y)}function h(){if(t){var n,e,r=t.length;for(o=new Array(r),n=0;n<r;++n)e=t[n],o[e.index]=+s(e,n,t)}}function v(t){var n,e,r,i,s,u=0,a=0;if(t.length){for(r=i=s=0;s<4;++s)(n=t[s])&&(e=Math.abs(n.value))&&(u+=n.value,a+=e,r+=e*n.x,i+=e*n.y);t.x=r/a,t.y=i/a}else{(n=t).x=n.data.x,n.y=n.data.y;do{u+=o[n.data.index]}while(n=n.next)}t.value=u}function y(t,n,s,u){if(!t.value)return!0;var f=t.x-r.x,h=t.y-r.y,v=u-n,y=f*f+h*h;if(v*v/l<y)return y<c&&(0===f&&(y+=(f=e())*f),0===h&&(y+=(h=e())*h),y<a&&(y=Math.sqrt(a*y)),r.vx+=f*t.value*i/y,r.vy+=h*t.value*i/y),!0;if(!(t.length||y>=c)){(t.data!==r||t.next)&&(0===f&&(y+=(f=e())*f),0===h&&(y+=(h=e())*h),y<a&&(y=Math.sqrt(a*y)));do{t.data!==r&&(v=o[t.data.index]*i/y,r.vx+=f*v,r.vy+=h*v)}while(t=t.next)}}return f.initialize=function(n){t=n,h()},f.strength=function(t){return arguments.length?(s="function"==typeof t?t:n(+t),h(),f):s},f.distanceMin=function(t){return arguments.length?(a=t*t,f):Math.sqrt(a)},f.distanceMax=function(t){return arguments.length?(c=t*t,f):Math.sqrt(c)},f.theta=function(t){return arguments.length?(l=t*t,f):Math.sqrt(l)},f}().strength(r.repulsionStrength);return function(t){var n,e=1,r=.001,i=1-Math.pow(r,1/300),o=0,s=.6,u=h(),a=z(l),c=g("tick","end");function l(){f(),c.call("tick",n),e<r&&(a.stop(),c.call("end",n))}function f(r){var a,c,l=t.length;void 0===r&&(r=1);for(var f=0;f<r;++f)for(e+=(o-e)*i,u.each(function(t){t(e)}),a=0;a<l;++a)null==(c=t[a]).fx?c.x+=c.vx*=s:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=s:(c.y=c.fy,c.vy=0);return n}function v(){for(var n,e=0,r=t.length;e<r;++e){if((n=t[e]).index=e,null!=n.fx&&(n.x=n.fx),null!=n.fy&&(n.y=n.fy),isNaN(n.x)||isNaN(n.y)){var i=L*Math.sqrt(e),o=e*U;n.x=i*Math.cos(o),n.y=i*Math.sin(o)}(isNaN(n.vx)||isNaN(n.vy))&&(n.vx=n.vy=0)}}function y(n){return n.initialize&&n.initialize(t),n}return null==t&&(t=[]),v(),n={tick:f,restart:function(){return a.restart(l),n},stop:function(){return a.stop(),n},nodes:function(e){return arguments.length?(t=e,v(),u.each(y),n):t},alpha:function(t){return arguments.length?(e=+t,n):e},alphaMin:function(t){return arguments.length?(r=+t,n):r},alphaDecay:function(t){return arguments.length?(i=+t,n):+i},alphaTarget:function(t){return arguments.length?(o=+t,n):o},velocityDecay:function(t){return arguments.length?(s=1-t,n):1-s},force:function(t,e){return arguments.length>1?(null==e?u.remove(t):u.set(t,y(e)),n):u.get(t)},find:function(n,e,r){var i,o,s,u,a,c=0,l=t.length;for(null==r?r=1/0:r*=r,c=0;c<l;++c)(s=(i=n-(u=t[c]).x)*i+(o=e-u.y)*o)<r&&(a=u,r=s);return a},on:function(t,e){return arguments.length>1?(c.on(t,e),n):c.on(t)}}}(i).force("link",s).force("charge",a).force("center",function(t,n){var e;function r(){var r,i,o=e.length,s=0,u=0;for(r=0;r<o;++r)s+=(i=e[r]).x,u+=i.y;for(s=s/o-t,u=u/o-n,r=0;r<o;++r)(i=e[r]).x-=s,i.y-=u}return null==t&&(t=0),null==n&&(n=0),r.initialize=function(t){e=t},r.x=function(n){return arguments.length?(t=+n,r):t},r.y=function(t){return arguments.length?(n=+t,r):n},r}()).alpha(r.alpha).alphaMin(r.alphaMin).alphaDecay(r.alphaDecay).velocityDecay(r.velocityDecay).stop().tick(r.iterations),{nodes:i,links:o}}return self.onmessage=function(t){var n=J.apply(void 0,t.data);self.postMessage(n)},t.forceDirected=J,t}({});`;
34
+ const workerCode = `var forceDirected=function(t){"use strict";function n(t){return function(){return t}}function e(){return 1e-6*(Math.random()-.5)}function r(t,n,e,r){if(isNaN(n)||isNaN(e))return t;var i,o,s,u,a,c,f,l,h,v=t._root,y={data:r},p=t._x0,_=t._y0,d=t._x1,g=t._y1;if(!v)return t._root=y,t;for(;v.length;)if((c=n>=(o=(p+d)/2))?p=o:d=o,(f=e>=(s=(_+g)/2))?_=s:g=s,i=v,!(v=v[l=f<<1|c]))return i[l]=y,t;if(u=+t._x.call(null,v.data),a=+t._y.call(null,v.data),n===u&&e===a)return y.next=v,i?i[l]=y:t._root=y,t;do{i=i?i[l]=new Array(4):t._root=new Array(4),(c=n>=(o=(p+d)/2))?p=o:d=o,(f=e>=(s=(_+g)/2))?_=s:g=s}while((l=f<<1|c)==(h=(a>=s)<<1|u>=o));return i[h]=v,i[l]=y,t}function i(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function o(t){return t[0]}function s(t){return t[1]}function u(t,n,e){var r=new a(null==n?o:n,null==e?s:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function a(t,n,e,r,i,o){this._x=t,this._y=n,this._x0=e,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function c(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var f=u.prototype=a.prototype;f.copy=function(){var t,n,e=new a(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=c(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=c(n));return e},f.add=function(t){var n=+this._x.call(null,t),e=+this._y.call(null,t);return r(this.cover(n,e),n,e,t)},f.addAll=function(t){var n,e,i,o,s=t.length,u=new Array(s),a=new Array(s),c=1/0,f=1/0,l=-1/0,h=-1/0;for(e=0;e<s;++e)isNaN(i=+this._x.call(null,n=t[e]))||isNaN(o=+this._y.call(null,n))||(u[e]=i,a[e]=o,i<c&&(c=i),i>l&&(l=i),o<f&&(f=o),o>h&&(h=o));if(c>l||f>h)return this;for(this.cover(c,f).cover(l,h),e=0;e<s;++e)r(this,u[e],a[e],t[e]);return this},f.cover=function(t,n){if(isNaN(t=+t)||isNaN(n=+n))return this;var e=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(e))i=(e=Math.floor(t))+1,o=(r=Math.floor(n))+1;else{for(var s,u,a=i-e,c=this._root;e>t||t>=i||r>n||n>=o;)switch(u=(n<r)<<1|t<e,(s=new Array(4))[u]=c,c=s,a*=2,u){case 0:i=e+a,o=r+a;break;case 1:e=i-a,o=r+a;break;case 2:i=e+a,r=o-a;break;case 3:e=i-a,r=o-a}this._root&&this._root.length&&(this._root=c)}return this._x0=e,this._y0=r,this._x1=i,this._y1=o,this},f.data=function(){var t=[];return this.visit((function(n){if(!n.length)do{t.push(n.data)}while(n=n.next)})),t},f.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},f.find=function(t,n,e){var r,o,s,u,a,c,f,l=this._x0,h=this._y0,v=this._x1,y=this._y1,p=[],_=this._root;for(_&&p.push(new i(_,l,h,v,y)),null==e?e=1/0:(l=t-e,h=n-e,v=t+e,y=n+e,e*=e);c=p.pop();)if(!(!(_=c.node)||(o=c.x0)>v||(s=c.y0)>y||(u=c.x1)<l||(a=c.y1)<h))if(_.length){var d=(o+u)/2,g=(s+a)/2;p.push(new i(_[3],d,g,u,a),new i(_[2],o,g,d,a),new i(_[1],d,s,u,g),new i(_[0],o,s,d,g)),(f=(n>=g)<<1|t>=d)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-f],p[p.length-1-f]=c)}else{var x=t-+this._x.call(null,_.data),w=n-+this._y.call(null,_.data),m=x*x+w*w;if(m<e){var b=Math.sqrt(e=m);l=t-b,h=n-b,v=t+b,y=n+b,r=_.data}}return r},f.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t)))return this;var n,e,r,i,o,s,u,a,c,f,l,h,v=this._root,y=this._x0,p=this._y0,_=this._x1,d=this._y1;if(!v)return this;if(v.length)for(;;){if((c=o>=(u=(y+_)/2))?y=u:_=u,(f=s>=(a=(p+d)/2))?p=a:d=a,n=v,!(v=v[l=f<<1|c]))return this;if(!v.length)break;(n[l+1&3]||n[l+2&3]||n[l+3&3])&&(e=n,h=l)}for(;v.data!==t;)if(r=v,!(v=v.next))return this;return(i=v.next)&&delete v.next,r?(i?r.next=i:delete r.next,this):n?(i?n[l]=i:delete n[l],(v=n[0]||n[1]||n[2]||n[3])&&v===(n[3]||n[2]||n[1]||n[0])&&!v.length&&(e?e[h]=v:this._root=v),this):(this._root=i,this)},f.removeAll=function(t){for(var n=0,e=t.length;n<e;++n)this.remove(t[n]);return this},f.root=function(){return this._root},f.size=function(){var t=0;return this.visit((function(n){if(!n.length)do{++t}while(n=n.next)})),t},f.visit=function(t){var n,e,r,o,s,u,a=[],c=this._root;for(c&&a.push(new i(c,this._x0,this._y0,this._x1,this._y1));n=a.pop();)if(!t(c=n.node,r=n.x0,o=n.y0,s=n.x1,u=n.y1)&&c.length){var f=(r+s)/2,l=(o+u)/2;(e=c[3])&&a.push(new i(e,f,l,s,u)),(e=c[2])&&a.push(new i(e,r,l,f,u)),(e=c[1])&&a.push(new i(e,f,o,s,l)),(e=c[0])&&a.push(new i(e,r,o,f,l))}return this},f.visitAfter=function(t){var n,e=[],r=[];for(this._root&&e.push(new i(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var o=n.node;if(o.length){var s,u=n.x0,a=n.y0,c=n.x1,f=n.y1,l=(u+c)/2,h=(a+f)/2;(s=o[0])&&e.push(new i(s,u,a,l,h)),(s=o[1])&&e.push(new i(s,l,a,c,h)),(s=o[2])&&e.push(new i(s,u,h,l,f)),(s=o[3])&&e.push(new i(s,l,h,c,f))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.y0,n.x1,n.y1);return this},f.x=function(t){return arguments.length?(this._x=t,this):this._x},f.y=function(t){return arguments.length?(this._y=t,this):this._y};var l="$";function h(){}function v(t,n){var e=new h;if(t instanceof h)t.each((function(t,n){e.set(n,t)}));else if(Array.isArray(t)){var r,i=-1,o=t.length;if(null==n)for(;++i<o;)e.set(i,t[i]);else for(;++i<o;)e.set(n(r=t[i],i,t),r)}else if(t)for(var s in t)e.set(s,t[s]);return e}function y(){}h.prototype=v.prototype={constructor:h,has:function(t){return l+t in this},get:function(t){return this[l+t]},set:function(t,n){return this[l+t]=n,this},remove:function(t){var n=l+t;return n in this&&delete this[n]},clear:function(){for(var t in this)t[0]===l&&delete this[t]},keys:function(){var t=[];for(var n in this)n[0]===l&&t.push(n.slice(1));return t},values:function(){var t=[];for(var n in this)n[0]===l&&t.push(this[n]);return t},entries:function(){var t=[];for(var n in this)n[0]===l&&t.push({key:n.slice(1),value:this[n]});return t},size:function(){var t=0;for(var n in this)n[0]===l&&++t;return t},empty:function(){for(var t in this)if(t[0]===l)return!1;return!0},each:function(t){for(var n in this)n[0]===l&&t(this[n],n.slice(1),this)}};var p=v.prototype;function _(t){return t.index}function d(t,n){var e=t.get(n);if(!e)throw new Error("missing: "+n);return e}y.prototype={constructor:y,has:p.has,add:function(t){return this[l+(t+="")]=t,this},remove:p.remove,clear:p.clear,values:p.keys,size:p.size,empty:p.empty,each:p.each};var g={value:function(){}};function x(){for(var t,n=0,e=arguments.length,r={};n<e;++n){if(!(t=arguments[n]+"")||t in r||/[\\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new w(r)}function w(t){this._=t}function m(t,n){return t.trim().split(/^|\\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))}function b(t,n){for(var e,r=0,i=t.length;r<i;++r)if((e=t[r]).name===n)return e.value}function A(t,n,e){for(var r=0,i=t.length;r<i;++r)if(t[r].name===n){t[r]=g,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=e&&t.push({name:n,value:e}),t}w.prototype=x.prototype={constructor:w,on:function(t,n){var e,r=this._,i=m(t+"",r),o=-1,s=i.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++o<s;)if(e=(t=i[o]).type)r[e]=A(r[e],t.name,n);else if(null==n)for(e in r)r[e]=A(r[e],t.name,null);return this}for(;++o<s;)if((e=(t=i[o]).type)&&(e=b(r[e],t.name)))return e},copy:function(){var t={},n=this._;for(var e in n)t[e]=n[e].slice();return new w(t)},call:function(t,n){if((e=arguments.length-2)>0)for(var e,r,i=new Array(e),o=0;o<e;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,e=(r=this._[t]).length;o<e;++o)r[o].value.apply(n,i)},apply:function(t,n,e){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(n,e)}};var N,M,k=0,E=0,j=0,T=0,S=0,q=0,D="object"==typeof performance&&performance.now?performance:Date,O="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function P(){return S||(O(z),S=D.now()+q)}function z(){S=0}function C(){this._call=this._time=this._next=null}function F(t,n,e){var r=new C;return r.restart(t,n,e),r}function I(){S=(T=D.now())+q,k=E=0;try{!function(){P(),++k;for(var t,n=N;n;)(t=S-n._time)>=0&&n._call.call(null,t),n=n._next;--k}()}finally{k=0,function(){var t,n,e=N,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:N=n);M=t,K(r)}(),S=0}}function Y(){var t=D.now(),n=t-T;n>1e3&&(q-=n,T=t)}function K(t){k||(E&&(E=clearTimeout(E)),t-S>24?(t<1/0&&(E=setTimeout(I,t-D.now()-q)),j&&(j=clearInterval(j))):(j||(T=D.now(),j=setInterval(Y,1e3)),k=1,O(I)))}function L(t){return t.x}function U(t){return t.y}C.prototype=F.prototype={constructor:C,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?P():+e)+(null==n?0:+n),this._next||M===this||(M?M._next=this:N=this,M=this),this._call=t,this._time=e,K()},stop:function(){this._call&&(this._call=null,this._time=1/0,K())}};var W=Math.PI*(3-Math.sqrt(5));var $="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var B={exports:{}};
35
+ /*!
36
+ * @overview es6-promise - a tiny implementation of Promises/A+.
37
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
38
+ * @license Licensed under MIT license
39
+ * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
40
+ * @version v4.2.8+1e68dce6
41
+ */function G(t,r){var i=t.nodes,o=t.links,s=function(t){var r,i,o,s,u,a=_,c=function(t){return 1/Math.min(s[t.source.index],s[t.target.index])},f=n(30),l=1;function h(n){for(var o=0,s=t.length;o<l;++o)for(var a,c,f,h,v,y,p,_=0;_<s;++_)c=(a=t[_]).source,h=(f=a.target).x+f.vx-c.x-c.vx||e(),v=f.y+f.vy-c.y-c.vy||e(),h*=y=((y=Math.sqrt(h*h+v*v))-i[_])/y*n*r[_],v*=y,f.vx-=h*(p=u[_]),f.vy-=v*p,c.vx+=h*(p=1-p),c.vy+=v*p}function y(){if(o){var n,e,c=o.length,f=t.length,l=v(o,a);for(n=0,s=new Array(c);n<f;++n)(e=t[n]).index=n,"object"!=typeof e.source&&(e.source=d(l,e.source)),"object"!=typeof e.target&&(e.target=d(l,e.target)),s[e.source.index]=(s[e.source.index]||0)+1,s[e.target.index]=(s[e.target.index]||0)+1;for(n=0,u=new Array(f);n<f;++n)e=t[n],u[n]=s[e.source.index]/(s[e.source.index]+s[e.target.index]);r=new Array(f),p(),i=new Array(f),g()}}function p(){if(o)for(var n=0,e=t.length;n<e;++n)r[n]=+c(t[n],n,t)}function g(){if(o)for(var n=0,e=t.length;n<e;++n)i[n]=+f(t[n],n,t)}return null==t&&(t=[]),h.initialize=function(t){o=t,y()},h.links=function(n){return arguments.length?(t=n,y(),h):t},h.id=function(t){return arguments.length?(a=t,h):a},h.iterations=function(t){return arguments.length?(l=+t,h):l},h.strength=function(t){return arguments.length?(c="function"==typeof t?t:n(+t),p(),h):c},h.distance=function(t){return arguments.length?(f="function"==typeof t?t:n(+t),g(),h):f},h}(o).id((function(t){return t.id})).distance(r.linkDistance).strength(r.linkStrength),a=function(){var t,r,i,o,s=n(-30),a=1,c=1/0,f=.81;function l(n){var e,o=t.length,s=u(t,L,U).visitAfter(v);for(i=n,e=0;e<o;++e)r=t[e],s.visit(y)}function h(){if(t){var n,e,r=t.length;for(o=new Array(r),n=0;n<r;++n)e=t[n],o[e.index]=+s(e,n,t)}}function v(t){var n,e,r,i,s,u=0,a=0;if(t.length){for(r=i=s=0;s<4;++s)(n=t[s])&&(e=Math.abs(n.value))&&(u+=n.value,a+=e,r+=e*n.x,i+=e*n.y);t.x=r/a,t.y=i/a}else{(n=t).x=n.data.x,n.y=n.data.y;do{u+=o[n.data.index]}while(n=n.next)}t.value=u}function y(t,n,s,u){if(!t.value)return!0;var l=t.x-r.x,h=t.y-r.y,v=u-n,y=l*l+h*h;if(v*v/f<y)return y<c&&(0===l&&(y+=(l=e())*l),0===h&&(y+=(h=e())*h),y<a&&(y=Math.sqrt(a*y)),r.vx+=l*t.value*i/y,r.vy+=h*t.value*i/y),!0;if(!(t.length||y>=c)){(t.data!==r||t.next)&&(0===l&&(y+=(l=e())*l),0===h&&(y+=(h=e())*h),y<a&&(y=Math.sqrt(a*y)));do{t.data!==r&&(v=o[t.data.index]*i/y,r.vx+=l*v,r.vy+=h*v)}while(t=t.next)}}return l.initialize=function(n){t=n,h()},l.strength=function(t){return arguments.length?(s="function"==typeof t?t:n(+t),h(),l):s},l.distanceMin=function(t){return arguments.length?(a=t*t,l):Math.sqrt(a)},l.distanceMax=function(t){return arguments.length?(c=t*t,l):Math.sqrt(c)},l.theta=function(t){return arguments.length?(f=t*t,l):Math.sqrt(f)},l}().strength(r.repulsionStrength);return function(t){var n,e=1,r=.001,i=1-Math.pow(r,1/300),o=0,s=.6,u=v(),a=F(f),c=x("tick","end");function f(){l(),c.call("tick",n),e<r&&(a.stop(),c.call("end",n))}function l(r){var a,c,f=t.length;void 0===r&&(r=1);for(var l=0;l<r;++l)for(e+=(o-e)*i,u.each((function(t){t(e)})),a=0;a<f;++a)null==(c=t[a]).fx?c.x+=c.vx*=s:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=s:(c.y=c.fy,c.vy=0);return n}function h(){for(var n,e=0,r=t.length;e<r;++e){if((n=t[e]).index=e,null!=n.fx&&(n.x=n.fx),null!=n.fy&&(n.y=n.fy),isNaN(n.x)||isNaN(n.y)){var i=10*Math.sqrt(e),o=e*W;n.x=i*Math.cos(o),n.y=i*Math.sin(o)}(isNaN(n.vx)||isNaN(n.vy))&&(n.vx=n.vy=0)}}function y(n){return n.initialize&&n.initialize(t),n}return null==t&&(t=[]),h(),n={tick:l,restart:function(){return a.restart(f),n},stop:function(){return a.stop(),n},nodes:function(e){return arguments.length?(t=e,h(),u.each(y),n):t},alpha:function(t){return arguments.length?(e=+t,n):e},alphaMin:function(t){return arguments.length?(r=+t,n):r},alphaDecay:function(t){return arguments.length?(i=+t,n):+i},alphaTarget:function(t){return arguments.length?(o=+t,n):o},velocityDecay:function(t){return arguments.length?(s=1-t,n):1-s},force:function(t,e){return arguments.length>1?(null==e?u.remove(t):u.set(t,y(e)),n):u.get(t)},find:function(n,e,r){var i,o,s,u,a,c=0,f=t.length;for(null==r?r=1/0:r*=r,c=0;c<f;++c)(s=(i=n-(u=t[c]).x)*i+(o=e-u.y)*o)<r&&(a=u,r=s);return a},on:function(t,e){return arguments.length>1?(c.on(t,e),n):c.on(t)}}}(i).force("link",s).force("charge",a).force("center",function(t,n){var e;function r(){var r,i,o=e.length,s=0,u=0;for(r=0;r<o;++r)s+=(i=e[r]).x,u+=i.y;for(s=s/o-t,u=u/o-n,r=0;r<o;++r)(i=e[r]).x-=s,i.y-=u}return null==t&&(t=0),null==n&&(n=0),r.initialize=function(t){e=t},r.x=function(n){return arguments.length?(t=+n,r):t},r.y=function(t){return arguments.length?(n=+t,r):n},r}()).alpha(r.alpha).alphaMin(r.alphaMin).alphaDecay(r.alphaDecay).velocityDecay(r.velocityDecay).stop().tick(r.iterations),{nodes:i,links:o}}return B.exports=function(){function t(t){var n=typeof t;return null!==t&&("object"===n||"function"===n)}function n(t){return"function"==typeof t}var e=void 0;e=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var r=e,i=0,o=void 0,s=void 0,u=function(t,n){w[i]=t,w[i+1]=n,2===(i+=2)&&(s?s(m):A())};function a(t){s=t}function c(t){u=t}var f="undefined"!=typeof window?window:void 0,l=f||{},h=l.MutationObserver||l.WebKitMutationObserver,v="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),y="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function p(){return function(){return process.nextTick(m)}}function _(){return void 0!==o?function(){o(m)}:x()}function d(){var t=0,n=new h(m),e=document.createTextNode("");return n.observe(e,{characterData:!0}),function(){e.data=t=++t%2}}function g(){var t=new MessageChannel;return t.port1.onmessage=m,function(){return t.port2.postMessage(0)}}function x(){var t=setTimeout;return function(){return t(m,1)}}var w=new Array(1e3);function m(){for(var t=0;t<i;t+=2)(0,w[t])(w[t+1]),w[t]=void 0,w[t+1]=void 0;i=0}function b(){try{var t=Function("return this")().require("vertx");return o=t.runOnLoop||t.runOnContext,_()}catch(t){return x()}}var A=void 0;function N(t,n){var e=this,r=new this.constructor(E);void 0===r[k]&&J(r);var i=e._state;if(i){var o=arguments[i-1];u((function(){return W(i,r,o,e._result)}))}else L(e,r,t,n);return r}function M(t){var n=this;if(t&&"object"==typeof t&&t.constructor===n)return t;var e=new n(E);return F(e,t),e}A=v?p():h?d():y?g():void 0===f?b():x();var k=Math.random().toString(36).substring(2);function E(){}var j=void 0,T=1,S=2;function q(){return new TypeError("You cannot resolve a promise with itself")}function D(){return new TypeError("A promises callback cannot return that same promise.")}function O(t,n,e,r){try{t.call(n,e,r)}catch(t){return t}}function P(t,n,e){u((function(t){var r=!1,i=O(e,n,(function(e){r||(r=!0,n!==e?F(t,e):Y(t,e))}),(function(n){r||(r=!0,K(t,n))}),"Settle: "+(t._label||" unknown promise"));!r&&i&&(r=!0,K(t,i))}),t)}function z(t,n){n._state===T?Y(t,n._result):n._state===S?K(t,n._result):L(n,void 0,(function(n){return F(t,n)}),(function(n){return K(t,n)}))}function C(t,e,r){e.constructor===t.constructor&&r===N&&e.constructor.resolve===M?z(t,e):void 0===r?Y(t,e):n(r)?P(t,e,r):Y(t,e)}function F(n,e){if(n===e)K(n,q());else if(t(e)){var r=void 0;try{r=e.then}catch(t){return void K(n,t)}C(n,e,r)}else Y(n,e)}function I(t){t._onerror&&t._onerror(t._result),U(t)}function Y(t,n){t._state===j&&(t._result=n,t._state=T,0!==t._subscribers.length&&u(U,t))}function K(t,n){t._state===j&&(t._state=S,t._result=n,u(I,t))}function L(t,n,e,r){var i=t._subscribers,o=i.length;t._onerror=null,i[o]=n,i[o+T]=e,i[o+S]=r,0===o&&t._state&&u(U,t)}function U(t){var n=t._subscribers,e=t._state;if(0!==n.length){for(var r=void 0,i=void 0,o=t._result,s=0;s<n.length;s+=3)r=n[s],i=n[s+e],r?W(e,r,i,o):i(o);t._subscribers.length=0}}function W(t,e,r,i){var o=n(r),s=void 0,u=void 0,a=!0;if(o){try{s=r(i)}catch(t){a=!1,u=t}if(e===s)return void K(e,D())}else s=i;e._state!==j||(o&&a?F(e,s):!1===a?K(e,u):t===T?Y(e,s):t===S&&K(e,s))}function B(t,n){try{n((function(n){F(t,n)}),(function(n){K(t,n)}))}catch(n){K(t,n)}}var G=0;function H(){return G++}function J(t){t[k]=G++,t._state=void 0,t._result=void 0,t._subscribers=[]}function Q(){return new Error("Array Methods must be provided an Array")}var R=function(){function t(t,n){this._instanceConstructor=t,this.promise=new t(E),this.promise[k]||J(this.promise),r(n)?(this.length=n.length,this._remaining=n.length,this._result=new Array(this.length),0===this.length?Y(this.promise,this._result):(this.length=this.length||0,this._enumerate(n),0===this._remaining&&Y(this.promise,this._result))):K(this.promise,Q())}return t.prototype._enumerate=function(t){for(var n=0;this._state===j&&n<t.length;n++)this._eachEntry(t[n],n)},t.prototype._eachEntry=function(t,n){var e=this._instanceConstructor,r=e.resolve;if(r===M){var i=void 0,o=void 0,s=!1;try{i=t.then}catch(t){s=!0,o=t}if(i===N&&t._state!==j)this._settledAt(t._state,n,t._result);else if("function"!=typeof i)this._remaining--,this._result[n]=t;else if(e===et){var u=new e(E);s?K(u,o):C(u,t,i),this._willSettleAt(u,n)}else this._willSettleAt(new e((function(n){return n(t)})),n)}else this._willSettleAt(r(t),n)},t.prototype._settledAt=function(t,n,e){var r=this.promise;r._state===j&&(this._remaining--,t===S?K(r,e):this._result[n]=e),0===this._remaining&&Y(r,this._result)},t.prototype._willSettleAt=function(t,n){var e=this;L(t,void 0,(function(t){return e._settledAt(T,n,t)}),(function(t){return e._settledAt(S,n,t)}))},t}();function V(t){return new R(this,t).promise}function X(t){var n=this;return r(t)?new n((function(e,r){for(var i=t.length,o=0;o<i;o++)n.resolve(t[o]).then(e,r)})):new n((function(t,n){return n(new TypeError("You must pass an array to race."))}))}function Z(t){var n=new this(E);return K(n,t),n}function tt(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function nt(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var et=function(){function t(n){this[k]=H(),this._result=this._state=void 0,this._subscribers=[],E!==n&&("function"!=typeof n&&tt(),this instanceof t?B(this,n):nt())}return t.prototype.catch=function(t){return this.then(null,t)},t.prototype.finally=function(t){var e=this,r=e.constructor;return n(t)?e.then((function(n){return r.resolve(t()).then((function(){return n}))}),(function(n){return r.resolve(t()).then((function(){throw n}))})):e.then(t,t)},t}();function rt(){var t=void 0;if(void 0!==$)t=$;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;if(n){var e=null;try{e=Object.prototype.toString.call(n.resolve())}catch(t){}if("[object Promise]"===e&&!n.cast)return}t.Promise=et}return et.prototype.then=N,et.all=V,et.race=X,et.resolve=M,et.reject=Z,et._setScheduler=a,et._setAsap=c,et._asap=u,et.polyfill=rt,et.Promise=et,et}(),B.exports.polyfill(),self.onmessage=function(t){var n=G.apply(void 0,t.data);self.postMessage(n)},t.forceDirected=G,Object.defineProperty(t,"__esModule",{value:!0}),t}({});`;
35
42
 
36
43
  const workerBlob = new Blob([workerCode], { type: "application/javascript" });
37
44
  const workerUrl = URL.createObjectURL(workerBlob);
@@ -3,8 +3,6 @@ import { Cluster, graphviz as gvWorker, Node } from "./graphvizWorker";
3
3
  import { Layout, Point } from "./layout";
4
4
  import { EdgePlaceholder } from "./placeholders";
5
5
 
6
- declare const window: any;
7
-
8
6
  type Engine = "circo" | "dot" | "fdp" | "neato" | "osage" | "patchwork" | "twopi";
9
7
 
10
8
  const lineBasis = d3Line<Point>()