PageSourceSearch

https://graphnavi.vercel.app/_next/static/chunks/5d49f49f-63c916b6feea1b6c.js

js graphnavi.vercel.app collected 2026-10-03 07:01:59 UTC 75,584 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[802],{26566:function(e,t,i){t.k=void 0;var n=i(60932).Z,o=i(79658).Z,r=i(7222).Z,a=i(97788).Z,s=i(92648).Z,l=i(50337).Z,c=i(94941).Z,u=i(53929).Z,d=i(37735).Z,f=s(i(34051)),h=i(85627);i(68750);var v=i(41996),p=s(i(81550)),m=i(29149),g=i(85312),y=i(25994),S=i(95908),x=i(49728),b=i(93799),z="#b3b3b3",k="#666666",I={spaceSize:4096,nodeSizeScale:1,linkWidthScale:1,arrowSizeScale:1,renderLinks:!0,arrowLinks:!0,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,useQuadtree:!1,simulation:{decay:1e3,gravity:0,center:0,repulsion:.1,repulsionTheta:1.7,repulsionQuadtreeLevels:12,linkSpring:1,linkDistance:2,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85},showFPSMonitor:!1,pixelRatio:2,scaleNodesOnZoom:!0},F=function(){function e(){o(this,e),this.backgroundColor="#222222",this.spaceSize=I.spaceSize,this.nodeColor=z,this.nodeGreyoutOpacity=.1,this.nodeSize=4,this.nodeSizeScale=I.nodeSizeScale,this.linkColor=k,this.linkGreyoutOpacity=.1,this.linkWidth=1,this.linkWidthScale=I.linkWidthScale,this.renderLinks=I.renderLinks,this.linkArrows=I.arrowLinks,this.linkArrowsSizeScale=I.arrowSizeScale,this.linkVisibilityDistanceRange=I.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=I.linkVisibilityMinTransparency,this.useQuadtree=I.useQuadtree,this.simulation={decay:I.simulation.decay,gravity:I.simulation.gravity,center:I.simulation.center,repulsion:I.simulation.repulsion,repulsionTheta:I.simulation.repulsionTheta,repulsionQuadtreeLevels:I.simulation.repulsionQuadtreeLevels,linkSpring:I.simulation.linkSpring,linkDistance:I.simulation.linkDistance,linkDistRandomVariationRange:I.simulation.linkDistRandomVariationRange,repulsionFromMouse:I.simulation.repulsionFromMouse,friction:I.simulation.friction,onStart:void 0,onTick:void 0,onEnd:void 0,onPause:void 0,onRestart:void 0},this.events={onClick:void 0,onZoomStart:void 0,onZoom:void 0,onZoomEnd:void 0},this.showFPSMonitor=I.showFPSMonitor,this.pixelRatio=I.pixelRatio,this.scaleNodesOnZoom=I.scaleNodesOnZoom,this.randomSeed=void 0}return r(e,[{key:"init",value:function(e){var t=this.getConfig();return Object.keys(e).map((function(e){return e})).forEach((function(i){"object"===typeof t[i]?t[i]=l({},t[i],e[i]):t[i]=e[i]})),t}},{key:"getConfig",value:function(){return this}}]),e}();function P(e,t,i){return"function"===typeof t?t(e,i):t}function T(e){var t,i;if(Array.isArray(e))i=e;else{var n=m.color(e),o=null===n||void 0===n?void 0:n.rgb();i=[(null===o||void 0===o?void 0:o.r)||0,(null===o||void 0===o?void 0:o.g)||0,(null===o||void 0===o?void 0:o.b)||0,null!==(t=null===n||void 0===n?void 0:n.opacity)&&void 0!==t?t:1]}return[i[0]/255,i[1]/255,i[2]/255,i[3]]}function w(e,t){var i=new Float32Array;return e({framebuffer:t})((function(){i=e.read()})),i}function A(e,t,i){return Math.min(Math.max(e,t),i)}var M=function e(t,i,n,r,a){o(this,e),this.reglInstance=t,this.config=i,this.store=n,this.data=r,a&&(this.points=a)};function L(e){return{buffer:e.buffer(new Float32Array([-1,-1,1,-1,-1,1,1,1])),size:2}}function D(e,t){for(var i=new Float32Array(t*t*2),n=0;n<t;n++)for(var o=0;o<t;o++){var r=n*t*2+2*o;i[r+0]=o,i[r+1]=n}return{buffer:e.buffer(i),size:2}}var C,_="#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nvarying vec2 index;void main(){gl_FragColor=vec4(0.0);}",E="#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nattribute vec2 quad;varying vec2 index;void main(){index=(quad+1.0)/2.0;gl_Position=vec4(quad,0,1);}",R=function(e){a(i,e);var t=d(i);function i(){return o(this,i),t.apply(this,arguments)}return r(i,[{key:"create",value:function(){var e=this.reglInstance;this.centermassFbo=e.framebuffer({color:e.texture({data:new Float32Array(4).fill(0),shape:[1,1,4],type:"float"}),depth:!1,stencil:!1})}},{key:"initPrograms",value:function(){var e=this,t=this,i=t.reglInstance,n=t.config,o=t.store,r=t.data,a=t.points;this.clearCentermassCommand=i({frag:_,vert:E,framebuffer:this.centermassFbo,primitive:"triangle strip",count:4,attributes:{quad:L(i)}}),this.calculateCentermassCommand=i({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nvarying vec4 rgba;void main(){gl_FragColor=rgba;}",vert:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D position;uniform float pointsTextureSize;attribute vec2 indexes;varying vec4 rgba;void main(){vec4 pointPosition=texture2D(position,indexes/pointsTextureSize);rgba=vec4(pointPosition.xy,1.0,0.0);gl_Position=vec4(0.0,0.0,0.0,1.0);gl_PointSize=1.0;}",framebuffer:function(){return e.centermassFbo},primitive:"points",count:function(){return r.nodes.length},attributes:{indexes:D(i,o.pointsTextureSize)},uniforms:{position:function(){return null===a||void 0===a?void 0:a.previousPositionFbo},pointsTextureSize:function(){return o.pointsTextureSize}},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}}),this.runCommand=i({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D position;uniform sampler2D centermass;uniform float center;uniform float alpha;varying vec2 index;void main(){vec4 pointPosition=texture2D(position,index);vec4 velocity=vec4(0.0);vec4 centermassValues=texture2D(centermass,vec2(0.0));vec2 centermassPosition=centermassValues.xy/centermassValues.b;vec2 distVector=centermassPosition-pointPosition.xy;float dist=sqrt(dot(distVector,distVector));if(dist>0.0){float angle=atan(distVector.y,distVector.x);float addV=alpha*center*dist*0.01;velocity.rg+=addV*vec2(cos(angle),sin(angle));}gl_FragColor=velocity;}",vert:E,framebuffer:function(){return null===a||void 0===a?void 0:a.velocityFbo}
1,primitive:"triangle strip",count:4,attributes:{quad:L(i)},uniforms:{position:function(){return null===a||void 0===a?void 0:a.previousPositionFbo},centermass:function(){return e.centermassFbo},center:function(){var e;return null===(e=n.simulation)||void 0===e?void 0:e.center},alpha:function(){return o.alpha}}})}},{key:"run",value:function(){var e,t,i;null===(e=this.clearCentermassCommand)||void 0===e||e.call(this),null===(t=this.calculateCentermassCommand)||void 0===t||t.call(this),null===(i=this.runCommand)||void 0===i||i.call(this)}},{key:"destroy",value:function(){var e;null===(e=this.centermassFbo)||void 0===e||e.destroy()}}]),i}(M),B=function(e){a(i,e);var t=d(i);function i(){return o(this,i),t.apply(this,arguments)}return r(i,[{key:"initPrograms",value:function(){var e=this,t=e.reglInstance,i=e.config,n=e.store,o=e.points;this.runCommand=t({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D position;uniform float gravity;uniform float spaceSize;uniform float alpha;varying vec2 index;void main(){vec4 pointPosition=texture2D(position,index);vec4 velocity=vec4(0.0);vec2 centerPosition=vec2(spaceSize/2.0);vec2 distVector=centerPosition-pointPosition.rg;float dist=sqrt(dot(distVector,distVector));if(dist>0.0){float angle=atan(distVector.y,distVector.x);float addV=alpha*gravity*dist*0.1;velocity.rg+=addV*vec2(cos(angle),sin(angle));}gl_FragColor=velocity;}",vert:E,framebuffer:function(){return null===o||void 0===o?void 0:o.velocityFbo},primitive:"triangle strip",count:4,attributes:{quad:L(t)},uniforms:{position:function(){return null===o||void 0===o?void 0:o.previousPositionFbo},gravity:function(){var e;return null===(e=i.simulation)||void 0===e?void 0:e.gravity},spaceSize:function(){return i.spaceSize},alpha:function(){return n.alpha}}})}},{key:"run",value:function(){var e;null===(e=this.runCommand)||void 0===e||e.call(this)}}]),i}(M);!function(e){e.OUTGOING="outgoing",e.INCOMING="incoming"}(C||(C={}));var N=function(e){a(i,e);var t=d(i);function i(){var e;return o(this,i),(e=t.call.apply(t,[this].concat(Array.prototype.slice.call(arguments)))).linkFirstIndicesAndAmount=new Float32Array,e.indices=new Float32Array,e.maxPointDegree=0,e}return r(i,[{key:"create",value:function(e){var t=this,i=this,n=i.reglInstance,o=i.store,r=o.pointsTextureSize,a=o.linksTextureSize,s=i.data;this.linkFirstIndicesAndAmount=new Float32Array(r*r*4),this.indices=new Float32Array(a*a*4);var l=new Float32Array(a*a*4),c=new Float32Array(a*a*4),u=e===C.INCOMING?s.groupedSourceToTargetLinks:s.groupedTargetToSourceLinks;this.maxPointDegree=0;var d=0;u.forEach((function(e,i){var n=t;t.linkFirstIndicesAndAmount[4*i+0]=d%a,t.linkFirstIndicesAndAmount[4*i+1]=Math.floor(d/a),t.linkFirstIndicesAndAmount[4*i+2]=e.size,e.forEach((function(e){var t,o;n.indices[4*d+0]=e%r,n.indices[4*d+1]=Math.floor(e/r);var a=null!==(t=s.degree[s.getInputIndexBySortedIndex(e)])&&void 0!==t?t:0,u=null!==(o=s.degree[s.getInputIndexBySortedIndex(i)])&&void 0!==o?o:0,f=a/(a+u),h=1/Math.min(a,u);h=Math.sqrt(h),l[4*d+0]=f,l[4*d+1]=h,c[4*d]=n.store.getRandomFloat(0,1),d+=1})),t.maxPointDegree=Math.max(t.maxPointDegree,e.size)})),this.linkFirstIndicesAndAmountFbo=n.framebuffer({color:n.texture({data:this.linkFirstIndicesAndAmount,shape:[r,r,4],type:"float"}),depth:!1,stencil:!1}),this.indicesFbo=n.framebuffer({color:n.texture({data:this.indices,shape:[a,a,4],type:"float"}),depth:!1,stencil:!1}),this.biasAndStrengthFbo=n.framebuffer({color:n.texture({data:l,shape:[a,a,4],type:"float"}),depth:!1,stencil:!1}),this.randomDistanceFbo=n.framebuffer({color:n.texture({data:c,shape:[a,a,4],type:"float"}),depth:!1,stencil:!1})}},{key:"initPrograms",value:function(){var e=this,t=this,i=t.reglInstance,n=t.config,o=t.store,r=t.points;this.runCommand=i({frag:function(){return t=e.maxPointDegree,"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D position;\nuniform float linkSpring;\nuniform float linkDistance;\nuniform vec2 linkDistRandomVariationRange;\n\nuniform sampler2D linkFirstIndicesAndAmount;\nuniform sampler2D linkIndices;\nuniform sampler2D linkBiasAndStrength;\nuniform sampler2D linkRandomDistanceFbo;\n\nuniform float pointsTextureSize;\nuniform float linksTextureSize;\nuniform float alpha;\n\nvarying vec2 index;\n\nconst float MAX_LINKS = ".concat(t,".0;\n\nvoid main() {\n  vec4 pointPosition = texture2D(position, index);\n  vec4 velocity = vec4(0.0);\n\n  vec4 linkFirstIJAndAmount = texture2D(linkFirstIndicesAndAmount, index);\n  float iCount = linkFirstIJAndAmount.r;\n  float jCount = linkFirstIJAndAmount.g;\n  float linkAmount = linkFirstIJAndAmount.b;\n  if (linkAmount > 0.0) {\n    for (float i = 0.0; i < MAX_LINKS; i += 1.0) {\n      if (i < linkAmount) {\n        if (iCount >= linksTextureSize) {\n          iCount = 0.0;\n          jCount += 1.0;\n        }\n        vec2 linkTextureIndex = (vec2(iCount, jCount) + 0.5) / linksTextureSize;\n        vec4 connectedPointIndex = texture2D(linkIndices, linkTextureIndex);\n        vec4 biasAndStrength = texture2D(linkBiasAndStrength, linkTextureIndex);\n        vec4 randomMinDistance = texture2D(linkRandomDistanceFbo, linkTextureIndex);\n        float bias = biasAndStrength.r;\n        float strength = biasAndStrength.g;\n        float randomMinLinkDist = randomMinDistance.r * (linkDistRandomVariationRange.g - linkDistRandomVariationRange.r) + linkDistRandomVariationRange.r;\n        randomMinLinkDist *= linkDistance;\n\n        iCount += 1.0;\n\n        vec4 connectedPointPosition = texture2D(position, (connectedPointIndex.rg + 0.5) / pointsTextureSize);\n        float x = connectedPointPosition.x - (pointPosition.x + velocity.x);\n        float y = connectedPointPosition.y - (pointPosition.y + velocity.y);\n        float l = sqrt(x * x + y * y);\n        l = max(l, randomMinLinkDist * 0.99);\n        l = (l - randomMinLinkDist) / l;
1\n        l *= linkSpring * alpha;\n        l *= strength;\n        l *= bias;\n        x *= l;\n        y *= l;\n        velocity.x += x;\n        velocity.y += y;\n      }\n    }\n  }\n\n  gl_FragColor = vec4(velocity.rg, 0.0, 0.0);\n}\n  ");var t},vert:E,framebuffer:function(){return null===r||void 0===r?void 0:r.velocityFbo},primitive:"triangle strip",count:4,attributes:{quad:L(i)},uniforms:{position:function(){return null===r||void 0===r?void 0:r.previousPositionFbo},linkSpring:function(){var e;return null===(e=n.simulation)||void 0===e?void 0:e.linkSpring},linkDistance:function(){var e;return null===(e=n.simulation)||void 0===e?void 0:e.linkDistance},linkDistRandomVariationRange:function(){var e;return null===(e=n.simulation)||void 0===e?void 0:e.linkDistRandomVariationRange},linkFirstIndicesAndAmount:function(){return e.linkFirstIndicesAndAmountFbo},linkIndices:function(){return e.indicesFbo},linkBiasAndStrength:function(){return e.biasAndStrengthFbo},linkRandomDistanceFbo:function(){return e.randomDistanceFbo},pointsTextureSize:function(){return o.pointsTextureSize},linksTextureSize:function(){return o.linksTextureSize},alpha:function(){return o.alpha}}})}},{key:"run",value:function(){var e;null===(e=this.runCommand)||void 0===e||e.call(this)}},{key:"destroy",value:function(){var e,t,i,n;null===(e=this.linkFirstIndicesAndAmountFbo)||void 0===e||e.destroy(),null===(t=this.indicesFbo)||void 0===t||t.destroy(),null===(i=this.biasAndStrengthFbo)||void 0===i||i.destroy(),null===(n=this.randomDistanceFbo)||void 0===n||n.destroy()}}]),i}(M),V="#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nvarying vec4 rgba;void main(){gl_FragColor=rgba;}",O="#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D position;uniform float pointsTextureSize;uniform float levelTextureSize;uniform float cellSize;attribute vec2 indexes;varying vec4 rgba;void main(){vec4 pointPosition=texture2D(position,indexes/pointsTextureSize);rgba=vec4(pointPosition.rg,1.0,0.0);float n=floor(pointPosition.x/cellSize);float m=floor(pointPosition.y/cellSize);vec2 levelPosition=2.0*(vec2(n,m)+0.5)/levelTextureSize-1.0;gl_Position=vec4(levelPosition,0.0,1.0);gl_PointSize=1.0;}",G=function(e){a(i,e);var t=d(i);function i(){var e;return o(this,i),(e=t.call.apply(t,[this].concat(Array.prototype.slice.call(arguments)))).levelsFbos=new Map,e.quadtreeLevels=0,e}return r(i,[{key:"create",value:function(){var e,t=this,i=t.reglInstance,n=t.config,o=t.store;this.quadtreeLevels=Math.log2(null!==(e=n.spaceSize)&&void 0!==e?e:I.spaceSize);for(var r=0;r<this.quadtreeLevels;r+=1){var a=Math.pow(2,r+1);this.levelsFbos.set("level[".concat(r,"]"),i.framebuffer({shape:[a,a],colorType:"float",depth:!1,stencil:!1}))}for(var s=new Float32Array(o.pointsTextureSize*o.pointsTextureSize*4),l=0;l<o.pointsTextureSize*o.pointsTextureSize;++l)s[4*l]=1e-5*o.getRandomFloat(-1,1),s[4*l+1]=1e-5*o.getRandomFloat(-1,1);this.randomValuesFbo=i.framebuffer({color:i.texture({data:s,shape:[o.pointsTextureSize,o.pointsTextureSize,4],type:"float"}),depth:!1,stencil:!1})}},{key:"initPrograms",value:function(){var e=this,t=this,i=t.reglInstance,n=t.config,o=t.store,r=t.data,a=t.points;this.clearLevelsCommand=i({frag:_,vert:E,framebuffer:function(e,t){return t.levelFbo},primitive:"triangle strip",count:4,attributes:{quad:L(i)}}),this.calculateLevelsCommand=i({frag:V,vert:O,framebuffer:function(e,t){return t.levelFbo},primitive:"points",count:function(){return r.nodes.length},attributes:{indexes:D(i,o.pointsTextureSize)},uniforms:{position:function(){return null===a||void 0===a?void 0:a.previousPositionFbo},pointsTextureSize:function(){return o.pointsTextureSize},levelTextureSize:function(e,t){return t.levelTextureSize},cellSize:function(e,t){return t.cellSize}},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}}),this.forceCommand=i({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D position;uniform sampler2D levelFbo;uniform float level;uniform float levels;uniform float levelTextureSize;uniform float repulsion;uniform float alpha;uniform float spaceSize;uniform float theta;varying vec2 index;const float MAX_LEVELS_NUM=14.0;vec2 calcAdd(vec2 ij,vec2 pp){vec2 add=vec2(0.0);vec4 centermass=texture2D(levelFbo,ij);
1if(centermass.r>0.0&&centermass.g>0.0&&centermass.b>0.0){vec2 centermassPosition=vec2(centermass.rg/centermass.b);vec2 distVector=pp-centermassPosition;float l=dot(distVector,distVector);float dist=sqrt(l);if(l>0.0){float angle=atan(distVector.y,distVector.x);float c=alpha*repulsion*centermass.b;float distanceMin2=1.0;if(l<distanceMin2)l=sqrt(distanceMin2*l);float addV=c/sqrt(l);add=addV*vec2(cos(angle),sin(angle));}}return add;}void main(){vec4 pointPosition=texture2D(position,index);float x=pointPosition.x;float y=pointPosition.y;float left=0.0;float top=0.0;float right=spaceSize;float bottom=spaceSize;float n_left=0.0;float n_top=0.0;float n_right=0.0;float n_bottom=0.0;float cellSize=0.0;for(float i=0.0;i<MAX_LEVELS_NUM;i+=1.0){if(i<=level){left+=cellSize*n_left;top+=cellSize*n_top;right-=cellSize*n_right;bottom-=cellSize*n_bottom;cellSize=pow(2.0,levels-i-1.0);float dist_left=x-left;n_left=max(0.0,floor(dist_left/cellSize-theta));float dist_top=y-top;n_top=max(0.0,floor(dist_top/cellSize-theta));float dist_right=right-x;n_right=max(0.0,floor(dist_right/cellSize-theta));float dist_bottom=bottom-y;n_bottom=max(0.0,floor(dist_bottom/cellSize-theta));}}vec4 velocity=vec4(vec2(0.0),1.0,0.0);for(float i=0.0;i<12.0;i+=1.0){for(float j=0.0;j<4.0;j+=1.0){float n=left+cellSize*j;float m=top+cellSize*n_top+cellSize*i;if(n<(left+n_left*cellSize)&&m<bottom){velocity.xy+=calcAdd(vec2(n/cellSize,m/cellSize)/levelTextureSize,pointPosition.xy);}n=left+cellSize*i;m=top+cellSize*j;if(n<(right-n_right*cellSize)&&m<(top+n_top*cellSize)){velocity.xy+=calcAdd(vec2(n/cellSize,m/cellSize)/levelTextureSize,pointPosition.xy);}n=right-n_right*cellSize+cellSize*j;m=top+cellSize*i;if(n<right&&m<(bottom-n_bottom*cellSize)){velocity.xy+=calcAdd(vec2(n/cellSize,m/cellSize)/levelTextureSize,pointPosition.xy);}n=left+n_left*cellSize+cellSize*i;m=bottom-n_bottom*cellSize+cellSize*j;if(n<right&&m<bottom){velocity.xy+=calcAdd(vec2(n/cellSize,m/cellSize)/levelTextureSize,pointPosition.xy);}}}gl_FragColor=velocity;}",vert:E,framebuffer:function(){return null===a||void 0===a?void 0:a.velocityFbo},primitive:"triangle strip",count:4,attributes:{quad:L(i)},uniforms:{position:function(){return null===a||void 0===a?void 0:a.previousPositionFbo},level:function(e,t){return t.level},levels:this.quadtreeLevels,levelFbo:function(e,t){return t.levelFbo},levelTextureSize:function(e,t){return t.levelTextureSize},alpha:function(){return o.alpha},repulsion:function(){var e;return null===(e=n.simulation)||void 0===e?void 0:e.repulsion},spaceSize:function(){return n.spaceSize},theta:function(){var e;return null===(e=n.simulation)||void 0===e?void 0:e.repulsionTheta}},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}}),this.forceFromItsOwnCentermassCommand=i({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D position;uniform sampler2D levelFbo;uniform sampler2D randomValues;uniform float levelTextureSize;uniform float repulsion;uniform float alpha;varying vec2 index;vec2 calcAdd(vec2 ij,vec2 pp){vec2 add=vec2(0.0);vec4 centermass=texture2D(levelFbo,ij);if(centermass.r>0.0&&centermass.g>0.0&&centermass.b>0.0){vec2 centermassPosition=vec2(centermass.rg/centermass.b);vec2 distVector=pp-centermassPosition;float l=dot(distVector,distVector);float dist=sqrt(l);if(l>0.0){float angle=atan(distVector.y,distVector.x);float c=alpha*repulsion*centermass.b;float distanceMin2=1.0;if(l<distanceMin2)l=sqrt(distanceMin2*l);float addV=c/sqrt(l);add=addV*vec2(cos(angle),sin(angle));}}return add;}void main(){vec4 pointPosition=texture2D(position,index);vec4 random=texture2D(randomValues,index);vec4 velocity=vec4(0.0);velocity.xy+=calcAdd(pointPosition.xy/levelTextureSize,pointPosition.xy);velocity.xy+=velocity.xy*random.rg;gl_FragColor=velocity;}",vert:E,framebuffer:function(){return null===a||void 0===a?void 0:a.velocityFbo},primitive:"triangle strip",count:4,attributes:{quad:L(i)},uniforms:{position:function(){return null===a||void 0===a?void 0:a.previousPositionFbo},randomValues:function(){return e.randomValuesFbo},levelFbo:function(e,t){return t.levelFbo},levelTextureSize:function(e,t){return t.levelTextureSize},alpha:function(){return o.alpha},repulsion:function(){var e;return null===(e=n.simulation)||void 0===e?void 0:e.repulsion},spaceSize:function(){return n.spaceSize}},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}}),this.clearVelocityCommand=i({frag:_,vert:E,framebuffer:function(){return null===a||void 0===a?void 0:a.velocityFbo}
1,primitive:"triangle strip",count:4,attributes:{quad:L(i)}})}},{key:"run",value:function(){for(var e,t,i,n,o,r,a=this.config,s=0;s<this.quadtreeLevels;s+=1){null===(e=this.clearLevelsCommand)||void 0===e||e.call(this,{levelFbo:this.levelsFbos.get("level[".concat(s,"]"))});var l=Math.pow(2,s+1),c=(null!==(t=a.spaceSize)&&void 0!==t?t:I.spaceSize)/l;null===(i=this.calculateLevelsCommand)||void 0===i||i.call(this,{levelFbo:this.levelsFbos.get("level[".concat(s,"]")),levelTextureSize:l,cellSize:c})}null===(n=this.clearVelocityCommand)||void 0===n||n.call(this);for(var u=0;u<this.quadtreeLevels;u+=1){var d=Math.pow(2,u+1);null===(o=this.forceCommand)||void 0===o||o.call(this,{levelFbo:this.levelsFbos.get("level[".concat(u,"]")),levelTextureSize:d,level:u}),u===this.quadtreeLevels-1&&(null===(r=this.forceFromItsOwnCentermassCommand)||void 0===r||r.call(this,{levelFbo:this.levelsFbos.get("level[".concat(u,"]")),levelTextureSize:d,level:u}))}}},{key:"destroy",value:function(){var e;null===(e=this.randomValuesFbo)||void 0===e||e.destroy(),this.levelsFbos.forEach((function(e){(null===e||void 0===e?void 0:e._framebuffer.framebuffer)&&e.destroy()})),this.levelsFbos.clear()}}]),i}(M);function q(e,t){e=Math.min(e,t);var i=t-e,n="\n    float dist = sqrt(l);\n    if (dist > 0.0) {\n      float c = alpha * repulsion * centermass.b;\n      addVelocity += calcAdd(vec2(x, y), l, c);\n      addVelocity += addVelocity * random.rg;\n    }\n  ";return"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D position;\nuniform sampler2D randomValues;\nuniform float spaceSize;\nuniform float repulsion;\nuniform float theta;\nuniform float alpha;\nuniform sampler2D level[".concat(t,"];\nvarying vec2 index;\n\nvec2 calcAdd(vec2 xy, float l, float c) {\n  float distanceMin2 = 1.0;\n  if (l < distanceMin2) l = sqrt(distanceMin2 * l);\n  float add = c / l;\n  return add * xy;\n}\n\nvoid main() {\n  vec4 pointPosition = texture2D(position, index);\n  vec4 random = texture2D(randomValues, index);\n\n  float width0 = spaceSize;\n\n  vec2 velocity = vec2(0.0);\n  vec2 addVelocity = vec2(0.0);\n\n  ").concat(new Array(t).fill(0).map((function(e,t){return"float width".concat(t+1," = width").concat(t," / 2.0;")})).join("\n"),"\n\n  for (float n = 0.0; n < pow(2.0, ").concat(i,".0); n += 1.0) {\n    for (float m = 0.0; m < pow(2.0, ").concat(i,".0); m += 1.0) {\n      ").concat(function o(r){if(r>=t)return n;var a=Math.pow(2,r+1),s=new Array(r+1-i).fill(0).map((function(e,t){return"pow(2.0, ".concat(r-(t+i),".0) * i").concat(t+i)})).join("+"),l=new Array(r+1-i).fill(0).map((function(e,t){return"pow(2.0, ".concat(r-(t+i),".0) * j").concat(t+i)})).join("+");return"\n      for (float ij".concat(r," = 0.0; ij").concat(r," < 4.0; ij").concat(r," += 1.0) {\n        float i").concat(r," = 0.0;\n        float j").concat(r," = 0.0;\n        if (ij").concat(r," == 1.0 || ij").concat(r," == 3.0) i").concat(r," = 1.0;\n        if (ij").concat(r," == 2.0 || ij").concat(r," == 3.0) j").concat(r," = 1.0;\n        float i = pow(2.0, ").concat(e,".0) * n / width").concat(r+1," + ").concat(s,";\n        float j = pow(2.0, ").concat(e,".0) * m / width").concat(r+1," + ").concat(l,";\n        float groupPosX = (i + 0.5) / ").concat(a,".0;\n        float groupPosY = (j + 0.5) / ").concat(a,".0;\n        \n        vec4 centermass = texture2D(level[").concat(r,"], vec2(groupPosX, groupPosY));\n        if (centermass.r > 0.0 && centermass.g > 0.0 && centermass.b > 0.0) {\n          float x = centermass.r / centermass.b - pointPosition.r;\n          float y = centermass.g / centermass.b - pointPosition.g;\n          float l = x * x + y * y;\n          if ((width").concat(r+1," * width").concat(r+1,") / theta < l) {\n            ").concat(n,"\n          } else {\n            ").concat(o(r+1),"\n          }\n        }\n      }\n      ")}(i),"\n    }\n  }\n\n  velocity -= addVelocity;\n\n  gl_FragColor = vec4(velocity, 0.0, 0.0);\n}\n")}var W=function(e){a(i,e);var t=d(i);function i(){var e;return o(this,i),(e=t.call.apply(t,[this].concat(Array.prototype.slice.call(arguments)))).levelsFbos=new Map,e.quadtreeLevels=0,e}return r(i,[{key:"create",value:function(){var e,t=this,i=t.reglInstance,n=t.config,o=t.store;this.quadtreeLevels=Math.log2(null!==(e=n.spaceSize)&&void 0!==e?e:I.spaceSize);for(var r=0;r<this.quadtreeLevels;r+=1){var a=Math.pow(2,r+1);this.levelsFbos.set("level[".concat(r,"]"),i.framebuffer({color:i.texture({data:new Float32Array(a*a*4),shape:[a,a,4],type:"float"}),depth:!1,stencil:!1}))}for(var s=new Float32Array(o.pointsTextureSize*o.pointsTextureSize*4),l=0;l<o.pointsTextureSize*o.pointsTextureSize;
1++l)s[4*l]=1e-5*o.getRandomFloat(-1,1),s[4*l+1]=1e-5*o.getRandomFloat(-1,1);this.randomValuesFbo=i.framebuffer({color:i.texture({data:s,shape:[o.pointsTextureSize,o.pointsTextureSize,4],type:"float"}),depth:!1,stencil:!1})}},{key:"initPrograms",value:function(){var e,t,i=this,n=this,o=n.reglInstance,r=n.config,a=n.store,s=n.data,c=n.points;this.clearLevelsCommand=o({frag:_,vert:E,framebuffer:function(e,t){return t.levelFbo},primitive:"triangle strip",count:4,attributes:{quad:L(o)}}),this.calculateLevelsCommand=o({frag:V,vert:O,framebuffer:function(e,t){return t.levelFbo},primitive:"points",count:function(){return s.nodes.length},attributes:{indexes:D(o,a.pointsTextureSize)},uniforms:{position:function(){return null===c||void 0===c?void 0:c.previousPositionFbo},pointsTextureSize:function(){return a.pointsTextureSize},levelTextureSize:function(e,t){return t.levelTextureSize},cellSize:function(e,t){return t.cellSize}},blend:{enable:!0,func:{src:"one",dst:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},stencil:{enable:!1}}),this.quadtreeCommand=o({frag:q(null!==(t=null===(e=r.simulation)||void 0===e?void 0:e.repulsionQuadtreeLevels)&&void 0!==t?t:this.quadtreeLevels,this.quadtreeLevels),vert:E,framebuffer:function(){return null===c||void 0===c?void 0:c.velocityFbo},primitive:"triangle strip",count:4,attributes:{quad:L(o)},uniforms:l({position:function(){return null===c||void 0===c?void 0:c.previousPositionFbo},randomValues:function(){return i.randomValuesFbo},spaceSize:function(){return r.spaceSize},repulsion:function(){var e;return null===(e=r.simulation)||void 0===e?void 0:e.repulsion},theta:function(){var e;return null===(e=r.simulation)||void 0===e?void 0:e.repulsionTheta},alpha:function(){return a.alpha}},Object.fromEntries(this.levelsFbos))})}},{key:"run",value:function(){for(var e,t,i,n,o=this.config,r=0;r<this.quadtreeLevels;r+=1){null===(e=this.clearLevelsCommand)||void 0===e||e.call(this,{levelFbo:this.levelsFbos.get("level[".concat(r,"]"))});var a=Math.pow(2,r+1),s=(null!==(t=o.spaceSize)&&void 0!==t?t:I.spaceSize)/a;null===(i=this.calculateLevelsCommand)||void 0===i||i.call(this,{levelFbo:this.levelsFbos.get("level[".concat(r,"]")),levelTextureSize:a,cellSize:s})}null===(n=this.quadtreeCommand)||void 0===n||n.call(this)}},{key:"destroy",value:function(){var e;null===(e=this.randomValuesFbo)||void 0===e||e.destroy(),this.levelsFbos.forEach((function(e){(null===e||void 0===e?void 0:e._framebuffer.framebuffer)&&e.destroy()})),this.levelsFbos.clear()}}]),i}(M),j=function(e){a(i,e);var t=d(i);function i(){return o(this,i),t.apply(this,arguments)}return r(i,[{key:"initPrograms",value:function(){var e=this,t=e.reglInstance,i=e.config,n=e.store,o=e.points;this.runCommand=t({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D position;uniform float repulsion;uniform vec2 mousePos;varying vec2 index;void main(){vec4 pointPosition=texture2D(position,index);vec4 velocity=vec4(0.0);vec2 mouse=mousePos;vec2 distVector=mouse-pointPosition.rg;float dist=sqrt(dot(distVector,distVector));dist=max(dist,10.0);float angle=atan(distVector.y,distVector.x);float addV=100.0*repulsion/(dist*dist);velocity.rg-=addV*vec2(cos(angle),sin(angle));gl_FragColor=velocity;}",vert:E,framebuffer:function(){return null===o||void 0===o?void 0:o.velocityFbo},primitive:"triangle strip",count:4,attributes:{quad:L(t)},uniforms:{position:function(){return null===o||void 0===o?void 0:o.previousPositionFbo},mousePos:function(){return n.mousePosition},repulsion:function(){var e;return null===(e=i.simulation)||void 0===e?void 0:e.repulsionFromMouse}}})}},{key:"run",value:function(){var e;null===(e=this.runCommand)||void 0===e||e.call(this)}}]),i}(M),Z=("undefined"!==typeof globalThis?globalThis:window,{exports:{}});Z.exports=function(){var e='<div class="gl-box">\n  <svg viewBox="0 0 55 60">\n    <text x="27" y="56" class="gl-fps">00 FPS</text>\n    <text x="28" y="8" class="gl-mem"></text>\n    <rect x="0" y="14" rx="4" ry="4" width="55" height="32"></rect>\n    <polyline class="gl-chart"></polyline>\n  </svg>\n  <svg viewBox="0 0 14 60" class="gl-cpu-svg">
1\n    <line x1="7" y1="38" x2="7" y2="11" class="opacity"/>\n    <line x1="7" y1="38" x2="7" y2="11" class="gl-cpu" stroke-dasharray="0 27"/>\n    <path d="M5.35 43c-.464 0-.812.377-.812.812v1.16c-.783.1972-1.421.812-1.595 1.624h-1.16c-.435 0-.812.348-.812.812s.348.812.812.812h1.102v1.653H1.812c-.464 0-.812.377-.812.812 0 .464.377.812.812.812h1.131c.1943.783.812 1.392 1.595 1.595v1.131c0 .464.377.812.812.812.464 0 .812-.377.812-.812V53.15h1.653v1.073c0 .464.377.812.812.812.464 0 .812-.377.812-.812v-1.131c.783-.1943 1.392-.812 1.595-1.595h1.131c.464 0 .812-.377.812-.812 0-.464-.377-.812-.812-.812h-1.073V48.22h1.102c.435 0 .812-.348.812-.812s-.348-.812-.812-.812h-1.16c-.1885-.783-.812-1.421-1.595-1.624v-1.131c0-.464-.377-.812-.812-.812-.464 0-.812.377-.812.812v1.073H6.162v-1.073c0-.464-.377-.812-.812-.812zm.58 3.48h2.088c.754 0 1.363.609 1.363 1.363v2.088c0 .754-.609 1.363-1.363 1.363H5.93c-.754 0-1.363-.609-1.363-1.363v-2.088c0-.754.609-1.363 1.363-1.363z"/>\n  </svg>\n  <svg viewBox="0 0 14 60" class="gl-gpu-svg">\n    <line x1="7" y1="38" x2="7" y2="11" class="opacity"/>\n    <line x1="7" y1="38" x2="7" y2="11" class="gl-gpu" stroke-dasharray="0 27"/>\n    <path d="M1.94775 43.3772a.736.736 0 10-.00416 1.472c.58535.00231.56465.1288.6348.3197.07015.18975.04933.43585.04933.43585l-.00653.05405v8.671a.736.736 0 101.472 0v-1.4145c.253.09522.52785.1495.81765.1495h5.267c1.2535 0 2.254-.9752 2.254-2.185v-3.105c0-1.2075-1.00625-2.185-2.254-2.185h-5.267c-.28865 0-.5635.05405-.8165.1495.01806-.16445.04209-.598-.1357-1.0787-.22425-.6072-.9499-1.2765-2.0125-1.2765zm2.9095 3.6455c.42435 0 .7659.36225.7659.8119v2.9785c0 .44965-.34155.8119-.7659.8119s-.7659-.36225-.7659-.8119v-2.9785c0-.44965.34155-.8119.7659-.8119zm4.117 0a2.3 2.3 0 012.3 2.3 2.3 2.3 0 01-2.3 2.3 2.3 2.3 0 01-2.3-2.3 2.3 2.3 0 012.3-2.3z"/>\n  </svg>\n</div>',t="#gl-bench {\n  position:absolute;\n  left:0;\n  top:0;\n  z-index:1000;\n  -webkit-user-select: none;\n  -moz-user-select: none;\n  user-select: none;\n}\n\n#gl-bench div {\n  position: relative;\n  display: block;\n  margin: 4px;\n  padding: 0 7px 0 10px;\n  background: #6c6;\n  border-radius: 15px;\n  cursor: pointer;\n  opacity: 0.9;\n}\n\n#gl-bench svg {\n  height: 60px;\n  margin: 0 -1px;\n}\n\n#gl-bench text {\n  font-size: 12px;\n  font-family: Helvetica,Arial,sans-serif;\n  font-weight: 700;\n  dominant-baseline: middle;\n  text-anchor: middle;\n}\n\n#gl-bench .gl-mem {\n  font-size: 9px;\n}\n\n#gl-bench line {\n  stroke-width: 5;\n  stroke: #112211;\n  stroke-linecap: round;\n}\n\n#gl-bench polyline {\n  fill: none;\n  stroke: #112211;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n  stroke-width: 3.5;\n}\n\n#gl-bench rect {\n  fill: #448844;\n}\n\n#gl-bench .opacity {\n  stroke: #448844;\n}\n",i=function(){function i(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=this;o(this,i),this.css=t,this.svg=e,this.paramLogger=function(){},this.chartLogger=function(){},this.chartLen=20,this.chartHz=20,this.names=[],this.cpuAccums=[],this.gpuAccums=[],this.activeAccums=[],this.chart=new Array(this.chartLen),this.now=function(){return performance&&performance.now?performance.now():Date.now()},this.updateUI=function(){var e=s;[].forEach.call(s.nodes["gl-gpu-svg"],(function(t){t.style.display=e.trackGPU?"inline":"none"}))},Object.assign(this,a),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;var l,c,u,d,h=0,v=function(e){++h<20?l=requestAnimationFrame(v):(s.detected=Math.ceil(1e3*h/(e-c)/70),cancelAnimationFrame(l)),c||(c=e)};if(requestAnimationFrame(v),r){var p=this,m=this,g=function(){var e=n(f.default.mark((function e(t,i){return f.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.resolve(setTimeout((function(){r.getError();var e=m.now()-t;i.forEach((function(t,i){t&&(m.gpuAccums[i]+=e)}))}),0)));case 1:case"end":return e.stop()}}),e)})));return function(t,i){return e.apply(this,arguments)}}(),y=function(e,t,i){return function(){var n=t.now();e.apply(i,arguments),t.trackGPU&&t.finished.push(g(n,t.activeAccums.slice(0)))}};["drawArrays","drawElements","drawArraysInstanced","drawBuffers","drawElementsInstanced","drawRangeElements"].forEach((function(e){r[e]&&(r[e]=y(r[e],p,r))}
1)),r.getExtension=(u=r.getExtension,d=this,function(){var e=u.apply(r,arguments);return e&&["drawElementsInstancedANGLE","drawBuffersWEBGL"].forEach((function(t){e[t]&&(e[t]=y(e[t],d,e))})),e})}if(!this.withoutUI){var S=this;this.dom||(this.dom=document.body);var x=document.createElement("div");x.id="gl-bench",this.dom.appendChild(x),this.dom.insertAdjacentHTML("afterbegin",'<style id="gl-bench-style">'+this.css+"</style>"),this.dom=x,this.dom.addEventListener("click",(function(){S.trackGPU=!S.trackGPU,S.updateUI()})),this.paramLogger=function(e,t,i){var n=["gl-cpu","gl-gpu","gl-mem","gl-fps","gl-gpu-svg","gl-chart"],o=Object.assign({},n);return n.forEach((function(e){return o[e]=t.getElementsByClassName(e)})),S.nodes=o,function(t,n,r,a,s,l,c){o["gl-cpu"][t].style.strokeDasharray=(.27*n).toFixed(0)+" 100",o["gl-gpu"][t].style.strokeDasharray=(.27*r).toFixed(0)+" 100",o["gl-mem"][t].innerHTML=i[t]?i[t]:a?"mem: "+a.toFixed(0)+"mb":"",o["gl-fps"][t].innerHTML=s.toFixed(0)+" FPS",e(i[t],n,r,a,s,l,c)}}(this.paramLogger,this.dom,this.names),this.chartLogger=function(e,t){var i=S,n={"gl-chart":t.getElementsByClassName("gl-chart")};return function(t,o,r){for(var a="",s=o.length,l=0;l<s;l++){var c=(r+l+1)%s;void 0!=o[c]&&(a=a+" "+(55*l/(s-1)).toFixed(1)+","+(45-22*o[c]/60/i.detected).toFixed(1))}n["gl-chart"][t].setAttribute("points",a),e(i.names[t],o,r)}}(this.chartLogger,this.dom)}}return r(i,[{key:"addUI",value:function(e){-1==this.names.indexOf(e)&&(this.names.push(e),this.dom&&(this.dom.insertAdjacentHTML("beforeend",this.svg),this.updateUI()),this.cpuAccums.push(0),this.gpuAccums.push(0),this.activeAccums.push(!1))}},{key:"nextFrame",value:function(e){this.frameId++;var t=e||this.now();if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=t;else{var i=t-this.paramTime;if(i>=1e3){for(var n=this,o=function(e){var t=n,o=n.cpuAccums[e]/i*100,s=n.gpuAccums[e]/i*100,l=performance&&performance.memory?performance.memory.usedJSHeapSize/(1<<20):0;n.paramLogger(e,o,s,l,a,i,r),n.cpuAccums[e]=0,Promise.all(n.finished).then((function(){t.gpuAccums[e]=0,t.finished=[]}))},r=this.frameId-this.paramFrame,a=r/i*1e3,s=0;s<this.names.length;s++)o(s);this.paramFrame=this.frameId,this.paramTime=t}}if(this.detected&&this.chartFrame)for(var l=t-this.chartTime,c=this.chartHz*l/1e3;--c>0&&this.detected;){var u=(this.frameId-this.chartFrame)/l*1e3;this.chart[this.circularId%this.chartLen]=u;for(var d=0;d<this.names.length;d++)this.chartLogger(d,this.chart,this.circularId);this.circularId++,this.chartFrame=this.frameId,this.chartTime=t}else this.chartFrame=this.frameId,this.chartTime=t,this.circularId=0}},{key:"begin",value:function(e){this.updateAccums(e)}},{key:"end",value:function(e){this.updateAccums(e)}},{key:"updateAccums",value:function(e){var t=this.names.indexOf(e);-1==t&&(t=this.names.length,this.addUI(e));for(var i=this.now(),n=i-this.t0,o=0;o<t+1;o++)this.activeAccums[o]&&(this.cpuAccums[o]+=n);this.activeAccums[t]=!this.activeAccums[t],this.t0=i}}]),i}();return i}();var Y=Z.exports,H=function(){function e(t){o(this,e),this.destroy();var i=t.getContext("webgl")||t.getContext("experimental-webgl");this.bench=new Y(i,{css:"\n  #gl-bench {\n    position:absolute;\n    right:0;\n    top:0;\n    z-index:1000;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    user-select: none;\n  }\n  #gl-bench div {\n    position: relative;\n    display: block;\n    margin: 4px;\n    padding: 0 7px 0 10px;\n    background: #5f69de;\n    border-radius: 15px;\n    cursor: pointer;\n    opacity: 0.9;\n  }\n  #gl-bench svg {\n    height: 60px;\n    margin: 0 -1px;\n  }\n  #gl-bench text {\n    font-size: 12px;\n    font-family: Helvetica,Arial,sans-serif;\n    font-weight: 700;\n    dominant-baseline: middle;\n    text-anchor: middle;\n  }\n  #gl-bench .gl-mem {\n    font-size: 9px;\n  }\n  #gl-bench line {\n    stroke-width: 5;\n    stroke: #112211;\n    stroke-linecap: round;\n  }\n  #gl-bench polyline {\n    fill: none;\n    stroke: #112211;\n    stroke-linecap: round;\n    stroke-linejoin: round;\n    stroke-width: 3.5;\n  }\n  #gl-bench rect {\n    fill: #8288e4;\n  }\n  #gl-bench .opacity {\n    stroke: #8288e4;\n  }\n"})}return r(e,[{key:"begin",value:function(){var e;null===(e=this.bench)||void 0===e||e.begin("frame")}},{key:"end",value:function(e){var t,i;null===(t=this.bench)||void 0===t||t.end("frame"),null===(i=this.bench)||void 0===i||i.nextFrame(e)}},{key:"destroy",value:function(){this.bench=void 0,h.select("#gl-bench").remove()}}]),e}(),U=function(){function e(){o(this,e),this.completeLinks=new Set,this.degree=[],this.groupedSourceToTargetLinks=new Map,this.groupedTargetToSourceLinks=new Map,this._nodes=[],this._links=[],this.idToNodeMap=new Map,this.sortedIndexToInputIndexMap=new Map,this.inputIndexToSortedIndexMap=new Map,this.idToSortedIndexMap=new Map,this.inputIndexToIdMap=new Map,this.idToIndegreeMap=new Map,this.idToOutdegreeMap=new Map}return r(e,[{key:"nodes",get:function(){return this._nodes}},{key:"links",get:function(){return this._links}},{key:"linksNumber",get:function(){return this.completeLinks.size}},{key:"setData",value:function(e,t){var i=this;this.idToNodeMap.clear(),this.idToSortedIndexMap.clear(),this.inputIndexToIdMap.clear(),this.idToIndegreeMap.clear(),this.idToOutdegreeMap.clear(),e.forEach((function(e,t){i.idToNodeMap.set(e.id,e),i.inputIndexToIdMap.set(t,e.id),i.idToIndegreeMap.set(e.id,0),i.idToOutdegreeMap.set(e.id,0)})),this.completeLinks.clear(),t.forEach((function(e){var t=i.idToNodeMap.get(e.source),n=i.idToNodeMap.get(e.target);
1if(void 0!==t&&void 0!==n){i.completeLinks.add(e);var o=i.idToOutdegreeMap.get(t.id);void 0!==o&&i.idToOutdegreeMap.set(t.id,o+1);var r=i.idToIndegreeMap.get(n.id);void 0!==r&&i.idToIndegreeMap.set(n.id,r+1)}})),this.degree=new Array(e.length),e.forEach((function(e,t){var n=i.idToOutdegreeMap.get(e.id),o=i.idToIndegreeMap.get(e.id);i.degree[t]=(null!==n&&void 0!==n?n:0)+(null!==o&&void 0!==o?o:0)})),this.sortedIndexToInputIndexMap.clear(),this.inputIndexToSortedIndexMap.clear(),Object.entries(this.degree).sort((function(e,t){return e[1]-t[1]})).forEach((function(e,t){var n=+c(e,1)[0];i.sortedIndexToInputIndexMap.set(t,n),i.inputIndexToSortedIndexMap.set(n,t),i.idToSortedIndexMap.set(i.inputIndexToIdMap.get(n),t)})),this.groupedSourceToTargetLinks.clear(),this.groupedTargetToSourceLinks.clear(),t.forEach((function(e){var t=i.idToSortedIndexMap.get(e.source),n=i.idToSortedIndexMap.get(e.target);if(void 0!==t&&void 0!==n){void 0===i.groupedSourceToTargetLinks.get(t)&&i.groupedSourceToTargetLinks.set(t,new Set);var o=i.groupedSourceToTargetLinks.get(t);null===o||void 0===o||o.add(n),void 0===i.groupedTargetToSourceLinks.get(n)&&i.groupedTargetToSourceLinks.set(n,new Set);var r=i.groupedTargetToSourceLinks.get(n);null===r||void 0===r||r.add(t)}})),this._nodes=e,this._links=t}},{key:"getNodeById",value:function(e){return this.idToNodeMap.get(e)}},{key:"getNodeByIndex",value:function(e){return this._nodes[e]}},{key:"getSortedIndexByInputIndex",value:function(e){return this.inputIndexToSortedIndexMap.get(e)}},{key:"getInputIndexBySortedIndex",value:function(e){return this.sortedIndexToInputIndexMap.get(e)}},{key:"getSortedIndexById",value:function(e){return void 0!==e?this.idToSortedIndexMap.get(e):void 0}},{key:"getAdjacentNodes",value:function(e){var t,i,n=this,o=this.getSortedIndexById(e);if(void 0!==o){var r=null!==(t=this.groupedSourceToTargetLinks.get(o))&&void 0!==t?t:[],a=null!==(i=this.groupedTargetToSourceLinks.get(o))&&void 0!==i?i:[];return u(new Set(u(r).concat(u(a)))).map((function(e){return n.getNodeByIndex(n.getInputIndexBySortedIndex(e))}))}}}]),e}(),X=function(e){a(i,e);var t=d(i);function i(){return o(this,i),t.apply(this,arguments)}return r(i,[{key:"create",value:function(){this.updateColor(),this.updateWidth()}},{key:"initPrograms",value:function(){var e=this,t=this,i=t.reglInstance,n=t.config,o=t.store,r=t.data,a=t.points,s=o.pointsTextureSize,l={buffer:i.buffer([[0,-.5],[1,-.5],[1,.5],[0,-.5],[1,.5],[0,.5]]),divisor:0},c=[];r.completeLinks.forEach((function(e){var t=r.getSortedIndexById(e.target),i=r.getSortedIndexById(e.source),n=i%s,o=Math.floor(i/s),a=t%s,l=Math.floor(t/s);c.push([n,o]),c.push([a,l])}));var u=i.buffer(c);this.drawStraightCommand=i({vert:"precision highp float;\n#define GLSLIFY 1\nattribute vec2 position,pointA,pointB;attribute vec4 color;attribute float width;uniform sampler2D positions;uniform sampler2D particleSize;uniform sampler2D particleGreyoutStatus;uniform mat3 transform;uniform float pointsTextureSize;uniform float widthScale;uniform float nodeSizeScale;uniform bool useArrow;uniform float arrowSizeScale;uniform float spaceSize;uniform vec2 screenSize;uniform float ratio;uniform vec2 linkVisibilityDistanceRange;uniform float linkVisibilityMinTransparency;uniform float greyoutOpacity;uniform bool scaleNodesOnZoom;varying vec4 rgbaColor;varying vec2 pos;varying float arrowLength;varying float linkWidthArrowWidthRatio;varying float smoothWidthRatio;varying float targetPointSize;float map(float value,float min1,float max1,float min2,float max2){return min2+(value-min1)*(max2-min2)/(max1-min1);}float pointSize(float size){float pSize;if(scaleNodesOnZoom){pSize=size*ratio*transform[0][0];}else{pSize=size*ratio*min(5.0,max(1.0,transform[0][0]*0.01));}return pSize;}void main(){pos=position;vec2 pointTexturePosA=(pointA+0.5)/pointsTextureSize;vec2 pointTexturePosB=(pointB+0.5)/pointsTextureSize;vec4 greyoutStatusA=texture2D(particleGreyoutStatus,pointTexturePosA);vec4 greyoutStatusB=texture2D(particleGreyoutStatus,pointTexturePosB);targetPointSize=pointSize(texture2D(particleSize,pointTexturePosB).r*nodeSizeScale);vec4 pointPositionA=texture2D(positions,pointTexturePosA);vec4 pointPositionB=texture2D(positions,pointTexturePosB);vec2 a=pointPositionA.xy;vec2 b=pointPositionB.xy;vec2 xBasis=b-a;vec2 yBasis=normalize(vec2(-xBasis.y,xBasis.x));vec2 distVector=a-b;float linkDist=sqrt(dot(distVector,distVector));float linkDistPx=linkDist*transform[0][0];targetPointSize=(targetPointSize/(2.0*ratio))/linkDistPx;float linkWidth=width*widthScale;float k=2.0;float arrowWidth=max(5.0,linkWidth*k);arrowWidth*=arrowSizeScale;float arrowWidthPx=arrowWidth/transform[0][0];arrowLength=min(0.3,(0.866*arrowWidthPx*2.0)/linkDist);float smoothWidth=2.0;float arrowExtraWidth=arrowWidth-linkWidth;linkWidth+=smoothWidth/2.0;if(useArrow){linkWidth+=arrowExtraWidth;}smoothWidthRatio=smoothWidth/linkWidth;linkWidthArrowWidthRatio=arrowExtraWidth/linkWidth;float linkWidthPx=linkWidth/transform[0][0];vec3 rgbColor=color.rgb;float opacity=color.a*max(linkVisibilityMinTransparency,map(linkDistPx,linkVisibilityDistanceRange.g,linkVisibilityDistanceRange.r,0.0,1.0));if(greyoutStatusA.r>0.0||greyoutStatusB.r>0.0){opacity*=greyoutOpacity;}rgbaColor=vec4(rgbColor,opacity);vec2 point=a+xBasis*position.x+yBasis*linkWidthPx*position.y;vec2 p=2.0*point/spaceSize-1.0;p*=spaceSize/screenSize;vec3 final=transform*vec3(p,1);gl_Position=vec4(final.rg,0,1);}",frag:"precision highp float;\n#define GLSLIFY 1\nuniform bool useArrow;varying vec4 rgbaColor;varying vec2 pos;varying float arrowLength;varying float linkWidthArrowWidthRatio;varying float smoothWidthRatio;varying float targetPointSize;float map(float value,float min1,float max1,float min2,float max2){return min2+(value-min1)*(max2-min2)/(max1-min1);}void main(){float opacity=1.0;vec3 color=rgbaColor.rgb;float smoothDelta=smoothWidthRatio/2.0;if(useArrow){float end_arrow=0.5+arrowLength/2.0;float start_arrow=end_arrow-arrowLength;float arrowWidthDelta=linkWidthArrowWidthRatio/2.0;float linkOpacity=rgbaColor.a*smoothstep(0.5-arrowWidthDelta,0.5-arrowWidthDelta-smoothDelta,abs(pos.y));float arrowOpacity=1.0;if(pos.x>start_arrow&&pos.x<start_arrow+arrowLength){float xmapped=map(pos.x,start_arrow,end_arrow,0.0,1.0);arrowOpacity=rgbaColor.a*smoothstep(xmapped-smoothDelta,xmapped,map(abs(pos.y),0.5,0.0,0.0,1.0));if(linkOpacity!=arrowOpacity){linkOpacity+=arrowOpacity;}}opacity=linkOpacity;}else opacity=rgbaColor.a*smoothstep(0.5,0.5-smoothDelta,abs(pos.y));gl_FragColor=vec4(color,opacity);}",attributes:{position:l,pointA:{buffer:function(){return u},divisor:1,offset:0*Float32Array.BYTES_PER_ELEMENT,stride:4*Float32Array.BYTES_PER_ELEMENT},pointB:{buffer:function(){return u},divisor:1,offset:2*Float32Array.BYTES_PER_ELEMENT,stride:4*Float32Array.BYTES_PER_ELEMENT},color:{buffer:function(){return e.colorBuffer},divisor:1,offset:0*Float32Array.BYTES_PER_ELEMENT,stride:4*Float32Array.BYTES_PER_ELEMENT},width:{buffer:function(){return e.widthBuffer},divisor:1,offset:0*Float32Array.BYTES_PER_ELEMENT,stride:1*Float32Array.BYTES_PER_ELEMENT}},uniforms:{positions:function(){return null===a||void 0===a?void 0:a.currentPositionFbo},particleSize:function(){return null===a||void 0===a?void 0:a.sizeFbo},particleGreyoutStatus:function(){return null===a||void 0===a?void 0:a.greyoutStatusFbo},transform:function(){return o.transform},pointsTextureSize:function(){return o.pointsTextureSize},nodeSizeScale:function(){return n.nodeSizeScale},widthScale:function(){return n.linkWidthScale},useArrow:function(){return n.linkArrows},arrowSizeScale:function(){return n.linkArrowsSizeScale},spaceSize:function(){return n.spaceSize},screenSize:function(){return o.screenSize},ratio:function(){return n.pixelRatio},linkVisibilityDistanceRange:function(){return n.linkVisibilityDistanceRange},linkVisibilityMinTransparency:function(){return n.linkVisibilityMinTransparency},greyoutOpacity:function(){return n.linkGreyoutOpacity},scaleNodesOnZoom:function(){return n.scaleNodesOnZoom}},cull:{enable:!0,face:"back"},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1},count:6,instances:function(){return r.linksNumber}})}},{key:"draw",value:function(){var e;this.colorBuffer&&this.widthBuffer&&(null===(e=this.drawStraightCommand)||void 0===e||e.call(this))}},{key:"updateColor",value:function(){var e=this,t=e.reglInstance,i=e.config,n=e.data,o=[];n.completeLinks.forEach((function(e){var t,n=T(null!==(t=P(e,i.linkColor))&&void 0!==t?t:k);o.push(n)}
1)),this.colorBuffer=t.buffer(o)}},{key:"updateWidth",value:function(){var e=this,t=e.reglInstance,i=e.config,n=e.data,o=[];n.completeLinks.forEach((function(e){var t=P(e,i.linkWidth);o.push([null!==t&&void 0!==t?t:1])})),this.widthBuffer=t.buffer(o)}},{key:"destroy",value:function(){var e,t;null===(e=this.colorBuffer)||void 0===e||e.destroy(),null===(t=this.widthBuffer)||void 0===t||t.destroy()}}]),i}(M);var Q=function(e){a(i,e);var t=d(i);function i(){return o(this,i),t.apply(this,arguments)}return r(i,[{key:"create",value:function(){for(var e,t,i=this,n=i.reglInstance,o=i.config,r=i.store,a=i.data,s=o.spaceSize,l=r.pointsTextureSize,c=a.nodes.length,u=new Float32Array(l*l*4),d=0;d<c;++d){var f=this.data.getSortedIndexByInputIndex(d),h=a.nodes[d];h&&void 0!==f&&(u[4*f+0]=null!==(e=h.x)&&void 0!==e?e:(null!==s&&void 0!==s?s:I.spaceSize)*(r.getRandomFloat(0,1)*(.505-.495)+.495),u[4*f+1]=null!==(t=h.y)&&void 0!==t?t:(null!==s&&void 0!==s?s:I.spaceSize)*(r.getRandomFloat(0,1)*(.505-.495)+.495))}this.currentPositionFbo=n.framebuffer({color:n.texture({data:u,shape:[l,l,4],type:"float"}),depth:!1,stencil:!1}),this.previousPositionFbo=n.framebuffer({color:n.texture({data:u,shape:[l,l,4],type:"float"}),depth:!1,stencil:!1}),this.velocityFbo=n.framebuffer({color:n.texture({data:new Float32Array(l*l*4).fill(0),shape:[l,l,4],type:"float"}),depth:!1,stencil:!1}),this.selectedFbo=n.framebuffer({color:n.texture({data:u,shape:[l,l,4],type:"float"}),depth:!1,stencil:!1}),this.updateSize(),this.updateColor(),this.updateGreyoutStatus()}},{key:"initPrograms",value:function(){var e=this,t=this,i=t.reglInstance,n=t.config,o=t.store,r=t.data;this.updatePositionCommand=i({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D position;uniform sampler2D velocity;uniform float friction;uniform float spaceSize;varying vec2 index;void main(){vec4 pointPosition=texture2D(position,index);vec4 pointVelocity=texture2D(velocity,index);pointVelocity.rg*=friction;pointPosition.rg+=pointVelocity.rg;pointPosition.r=clamp(pointPosition.r,0.0,spaceSize);pointPosition.g=clamp(pointPosition.g,0.0,spaceSize);gl_FragColor=pointPosition;}",vert:E,framebuffer:function(){return e.currentPositionFbo},primitive:"triangle strip",count:4,attributes:{quad:L(i)},uniforms:{position:function(){return e.previousPositionFbo},velocity:function(){return e.velocityFbo},friction:function(){var e;return null===(e=n.simulation)||void 0===e?void 0:e.friction},spaceSize:function(){return n.spaceSize}}}),this.drawCommand=i({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nvarying vec2 index;varying vec3 rgbColor;varying float alpha;const float smoothing=0.9;void main(){if(alpha==0.0){discard;}float r=0.0;float delta=0.0;vec2 cxy=2.0*gl_PointCoord-1.0;r=dot(cxy,cxy);float opacity=alpha*(1.0-smoothstep(smoothing,1.0,r));gl_FragColor=vec4(rgbColor,opacity);}",vert:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nattribute vec2 indexes;uniform sampler2D positions;uniform sampler2D particleColor;uniform sampler2D particleGreyoutStatus;uniform sampler2D particleSize;uniform float ratio;uniform mat3 transform;uniform float pointsTextureSize;uniform float sizeScale;uniform float spaceSize;uniform vec2 screenSize;uniform float greyoutOpacity;uniform bool scaleNodesOnZoom;varying vec2 index;varying vec3 rgbColor;varying float alpha;float pointSize(float size){float pSize;if(scaleNodesOnZoom){pSize=size*ratio*transform[0][0];}else{pSize=size*ratio*min(5.0,max(1.0,transform[0][0]*0.01));}return pSize;}void main(){index=indexes;vec4 pointPosition=texture2D(positions,(index+0.5)/pointsTextureSize);vec2 point=pointPosition.rg;vec2 p=2.0*point/spaceSize-1.0;p*=spaceSize/screenSize;vec3 final=transform*vec3(p,1);gl_Position=vec4(final.rg,0,1);vec4 pSize=texture2D(particleSize,(index+0.5)/pointsTextureSize);float size=pSize.r*sizeScale;vec4 pColor=texture2D(particleColor,(index+0.5)/pointsTextureSize);rgbColor=pColor.rgb;gl_PointSize=pointSize(size);alpha=pColor.a;vec4 greyoutStatus=texture2D(particleGreyoutStatus,(index+0.5)/pointsTextureSize);if(greyoutStatus.r>0.0){alpha*=greyoutOpacity;}}",primitive:"points",count:function(){return r.nodes.length},attributes:{indexes:D(i,o.pointsTextureSize)},uniforms:{positions:function(){return e.currentPositionFbo},particleColor:function(){return e.colorFbo},particleGreyoutStatus:function(){return e.greyoutStatusFbo},particleSize:function(){return e.sizeFbo},ratio:function(){return n.pixelRatio},sizeScale:function(){return n.nodeSizeScale},pointsTextureSize:function(){return o.pointsTextureSize},transform:function(){return o.transform},spaceSize:function(){return n.spaceSize},screenSize:function(){return o.screenSize},greyoutOpacity:function(){return n.nodeGreyoutOpacity},scaleNodesOnZoom:function(){return n.scaleNodesOnZoom}},blend:{enable:!0,func:{dstRGB:"one minus src alpha",srcRGB:"src alpha",dstAlpha:"one minus src alpha",srcAlpha:"one"},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1,mask:!1}}),this.findPointOnMouseClickCommand=i({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D position;uniform sampler2D particleSize;uniform float sizeScale;uniform float spaceSize;uniform vec2 screenSize;uniform float ratio;uniform mat3 transform;uniform vec2 mousePosition;uniform bool scaleNodesOnZoom;uniform float maxPointSize;varying vec2 index;float pointSize(float size){float pSize;if(scaleNodesOnZoom){pSize=size*ratio*transform[0][0];}
1else{pSize=size*ratio*min(5.0,max(1.0,transform[0][0]*0.01));}return min(pSize,maxPointSize);}float euclideanDistance(float x1,float x2,float y1,float y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}void main(){vec4 pointPosition=texture2D(position,index);vec2 p=2.0*pointPosition.rg/spaceSize-1.0;p*=spaceSize/screenSize;vec3 final=transform*vec3(p,1);vec4 pSize=texture2D(particleSize,index);float size=pSize.r*sizeScale;vec2 pointScreenPosition=(final.xy+1.0)*screenSize/2.0;gl_FragColor=vec4(0.0,0.0,pointPosition.rg);if(euclideanDistance(pointScreenPosition.x,mousePosition.x,pointScreenPosition.y,mousePosition.y)<0.5*pointSize(size)){gl_FragColor.r=1.0;}}",vert:E,framebuffer:function(){return e.selectedFbo},primitive:"triangle strip",count:4,attributes:{quad:L(i)},uniforms:{position:function(){return e.currentPositionFbo},particleSize:function(){return e.sizeFbo},spaceSize:function(){return n.spaceSize},screenSize:function(){return o.screenSize},sizeScale:function(){return n.nodeSizeScale},transform:function(){return o.transform},ratio:function(){return n.pixelRatio},mousePosition:function(){return o.screenMousePosition},scaleNodesOnZoom:function(){return n.scaleNodesOnZoom},maxPointSize:function(){return o.maxPointSize}}}),this.findPointsOnAreaSelectionCommand=i({frag:"#ifdef GL_ES\nprecision highp float;\n#define GLSLIFY 1\n#endif\nuniform sampler2D position;uniform sampler2D particleSize;uniform float sizeScale;uniform float spaceSize;uniform vec2 screenSize;uniform float ratio;uniform mat3 transform;uniform vec2 selection[2];uniform bool scaleNodesOnZoom;uniform float maxPointSize;varying vec2 index;float pointSize(float size){float pSize;if(scaleNodesOnZoom){pSize=size*ratio*transform[0][0];}else{pSize=size*ratio*min(5.0,max(1.0,transform[0][0]*0.01));}return min(pSize,maxPointSize);}void main(){vec4 pointPosition=texture2D(position,index);vec2 p=2.0*pointPosition.rg/spaceSize-1.0;p*=spaceSize/screenSize;vec3 final=transform*vec3(p,1);vec4 pSize=texture2D(particleSize,index);float size=pSize.r*sizeScale;float left=2.0*(selection[0].x-0.5*pointSize(size))/screenSize.x-1.0;float right=2.0*(selection[1].x+0.5*pointSize(size))/screenSize.x-1.0;float top=2.0*(selection[0].y-0.5*pointSize(size))/screenSize.y-1.0;float bottom=2.0*(selection[1].y+0.5*pointSize(size))/screenSize.y-1.0;gl_FragColor=vec4(0.0,0.0,pointPosition.rg);if(final.x>=left&&final.x<=right&&final.y>=top&&final.y<=bottom){gl_FragColor.r=1.0;}}",vert:E,framebuffer:function(){return e.selectedFbo},primitive:"triangle strip",count:4,attributes:{quad:L(i)},uniforms:{position:function(){return e.currentPositionFbo},particleSize:function(){return e.sizeFbo},spaceSize:function(){return n.spaceSize},screenSize:function(){return o.screenSize},sizeScale:function(){return n.nodeSizeScale},transform:function(){return o.transform},ratio:function(){return n.pixelRatio},"selection[0]":function(){return o.selectedArea[0]},"selection[1]":function(){return o.selectedArea[1]},scaleNodesOnZoom:function(){return n.scaleNodesOnZoom},maxPointSize:function(){return o.maxPointSize}}})}},{key:"updateColor",value:function(){var e=this,t=e.reglInstance,i=e.config,n=e.store,o=e.data;this.colorFbo=function(e,t,i,n){for(var o,r=new Float32Array(i*i*4),a=0;a<e.nodes.length;++a){var s=e.getSortedIndexByInputIndex(a),l=e.nodes[a];if(l&&void 0!==s){var c=T(null!==(o=P(l,n))&&void 0!==o?o:z);r[4*s+0]=c[0],r[4*s+1]=c[1],r[4*s+2]=c[2],r[4*s+3]=c[3]}}var u=t.texture({data:r,width:i,height:i,type:"float"});return t.framebuffer({color:u,depth:!1,stencil:!1})}(o,t,n.pointsTextureSize,i.nodeColor)}},{key:"updateGreyoutStatus",value:function(){var e=this.reglInstance,t=this.store;this.greyoutStatusFbo=function(e,t,i){var n=new Float32Array(i*i*4).fill(e?1:0);if(e){var o=!0,r=!1,a=void 0;try{for(var s,l=e[Symbol.iterator]();!(o=(s=l.next()).done);o=!0)n[4*s.value]=0}catch(u){r=!0,a=u}finally{try{o||null==l.return||l.return()}finally{if(r)throw a}}}var c=t.texture({data:n,width:i,height:i,type:"float"});return t.framebuffer({color:c,depth:!1,stencil:!1})}(t.selectedIndices,e,t.pointsTextureSize)}},{key:"updateSize",value:function(){var e=this,t=e.reglInstance,i=e.config,n=e.store,o=e.data;
1this.sizeFbo=function(e,t,i,n){for(var o=e.nodes.length,r=new Float32Array(i*i*4),a=0;a<o;++a){var s=e.getSortedIndexByInputIndex(a),l=e.nodes[a];if(l&&void 0!==s){var c=P(l,n);r[4*s]=null!==c&&void 0!==c?c:4}}var u=t.texture({data:r,width:i,height:i,type:"float"});return t.framebuffer({color:u,depth:!1,stencil:!1})}(o,t,n.pointsTextureSize,i.nodeSize)}},{key:"draw",value:function(){var e;null===(e=this.drawCommand)||void 0===e||e.call(this)}},{key:"updatePosition",value:function(){var e;null===(e=this.updatePositionCommand)||void 0===e||e.call(this),this.swapFbo()}},{key:"findPointsOnAreaSelection",value:function(){var e;null===(e=this.findPointsOnAreaSelectionCommand)||void 0===e||e.call(this)}},{key:"findPointsOnMouseClick",value:function(){var e;null===(e=this.findPointOnMouseClickCommand)||void 0===e||e.call(this)}},{key:"destroy",value:function(){var e,t,i,n,o,r,a;null===(e=this.currentPositionFbo)||void 0===e||e.destroy(),null===(t=this.previousPositionFbo)||void 0===t||t.destroy(),null===(i=this.velocityFbo)||void 0===i||i.destroy(),null===(n=this.selectedFbo)||void 0===n||n.destroy(),null===(o=this.colorFbo)||void 0===o||o.destroy(),null===(r=this.sizeFbo)||void 0===r||r.destroy(),null===(a=this.greyoutStatusFbo)||void 0===a||a.destroy()}},{key:"swapFbo",value:function(){var e=this.previousPositionFbo;this.previousPositionFbo=this.currentPositionFbo,this.currentPositionFbo=e}}]),i}(M),J=.001,K=function(){function e(){o(this,e),this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=y.mat3.create(),this.backgroundColor=[0,0,0,0],this.screenSize=[0,0],this.mousePosition=[0,0],this.screenMousePosition=[0,0],this.selectedArea=[[0,0],[0,0]],this.isSimulationRunning=!1,this.simulationProgress=0,this.selectedIndices=null,this.maxPointSize=64,this.alphaTarget=0,this.scaleNodeX=g.scaleLinear(),this.scaleNodeY=g.scaleLinear(),this.random=new S.Random,this.alphaDecay=function(e){return 1-Math.pow(J,1/e)}}return r(e,[{key:"addRandomSeed",value:function(e){this.random=this.random.clone(e)}},{key:"getRandomFloat",value:function(e,t){return this.random.float(e,t)}},{key:"updateScreenSize",value:function(e,t,i){this.screenSize=[e,t],this.scaleNodeX.domain([0,i]).range([(e-i)/2,(e+i)/2]),this.scaleNodeY.domain([i,0]).range([(t-i)/2,(t+i)/2])}},{key:"scaleX",value:function(e){return this.scaleNodeX(e)}},{key:"scaleY",value:function(e){return this.scaleNodeY(e)}},{key:"addAlpha",value:function(e){return(this.alphaTarget-this.alpha)*this.alphaDecay(e)}}]),e}(),$=function(){function e(t,i){var n=this;o(this,e),this.eventTransform=x.zoomIdentity,this.behavior=x.zoom().on("start",(function(e){var t,i,o;n.isRunning=!0;var r=!!e.sourceEvent;null===(o=null===(i=null===(t=n.config)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onZoomStart)||void 0===o||o.call(i,e,r)})).on("zoom",(function(e){var t,i,o;n.eventTransform=e.transform;var r=n.eventTransform,a=r.x,s=r.y,l=r.k,c=n.store,u=c.transform,d=c.screenSize,f=d[0],h=d[1];y.mat3.projection(u,f,h),y.mat3.translate(u,u,[a,s]),y.mat3.scale(u,u,[l,l]),y.mat3.translate(u,u,[f/2,h/2]),y.mat3.scale(u,u,[f/2,h/2]),y.mat3.scale(u,u,[1,-1]);var v=!!e.sourceEvent;null===(o=null===(i=null===(t=n.config)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onZoom)||void 0===o||o.call(i,e,v)})).on("end",(function(e){var t,i,o;n.isRunning=!1;var r=!!e.sourceEvent;null===(o=null===(i=null===(t=n.config)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onZoomEnd)||void 0===o||o.call(i,e,r)})),this.isRunning=!1,this.store=t,this.config=i}return r(e,[{key:"getTransform",value:function(e,t){if(0===e.length)return this.eventTransform;var i=this.store,n=i.screenSize,o=i.maxPointSize,r=n[0],a=n[1],s=b.extent(e.map((function(e){return e[0]}))),l=b.extent(e.map((function(e){return e[1]})));s[0]=this.store.scaleX(s[0]-o/2),s[1]=this.store.scaleX(s[1]+o/2),l[0]=this.store.scaleY(l[0]-o/2),l[1]=this.store.scaleY(l[1]+o/2);var c=r/(s[1]-s[0]),d=a/(l[0]-l[1]),f=A.apply(void 0,[null!==t&&void 0!==t?t:Math.min(c,d)].concat(u(this.behavior.scaleExtent()))),h=r/2-(s[1]+s[0])/2*f,v=a/2-(l[1]+l[0])/2*f;return x.zoomIdentity.translate(h,v).scale(f)}},{key:"getDistanceToPoint",value:function(e){var t=this.eventTransform,i=t.x,n=t.y,o=t.k,r=this.getTransform([e],o),a=i-r.x,s=n-r.y;return Math.sqrt(a*a+s*s)}},{key:"getMiddlePointTransform",value:function(e){var t=this.store.screenSize,i=this.eventTransform,n=i.x,o=i.y,r=i.k,a=t[0],s=t[1],l=(s/2-o)/r,c=a/2-1*(((a/2-n)/r+this.store.scaleX(e[0]))
1/2),u=s/2-1*((l+this.store.scaleY(e[1]))/2);return x.zoomIdentity.translate(c,u).scale(1)}}]),e}(),ee=function(){function e(t,i){var n;o(this,e),this.config=new F,this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.graph=new U,this.store=new K,this.zoomInstance=new $(this.store,this.config),this.hasBeenRecentlyDestroyed=!1,i&&this.config.init(i);var r=t.clientWidth,a=t.clientHeight;this.store.updateScreenSize(r,a,this.config.spaceSize),t.width=r*this.config.pixelRatio,t.height=a*this.config.pixelRatio,""===t.style.width&&""===t.style.height&&h.select(t).style("width","100%").style("height","100%"),this.canvas=t,this.canvasD3Selection=h.select(t),this.canvasD3Selection.call(this.zoomInstance.behavior).on("click",this.onClick.bind(this)).on("mousemove",this.onMouseMove.bind(this)).on("contextmenu",this.onRightClickMouse.bind(this)),this.reglInstance=p.default({canvas:this.canvas,attributes:{antialias:!1,preserveDrawingBuffer:!0,premultipliedAlpha:!1,alpha:!1},extensions:["OES_texture_float","ANGLE_instanced_arrays"]}),this.store.maxPointSize=(null!==(n=this.reglInstance.limits.pointSizeDims[1])&&void 0!==n?n:64)/this.config.pixelRatio,this.points=new Q(this.reglInstance,this.config,this.store,this.graph),this.lines=new X(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceGravity=new B(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceCenter=new R(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceManyBody=this.config.useQuadtree?new W(this.reglInstance,this.config,this.store,this.graph,this.points):new G(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new N(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new N(this.reglInstance,this.config,this.store,this.graph,this.points),this.forceMouse=new j(this.reglInstance,this.config,this.store,this.graph,this.points),this.store.backgroundColor=T(this.config.backgroundColor),this.config.showFPSMonitor&&(this.fpsMonitor=new H(this.canvas)),void 0!==this.config.randomSeed&&this.store.addRandomSeed(this.config.randomSeed)}return r(e,[{key:"progress",get:function(){return this.store.simulationProgress}},{key:"isSimulationRunning",get:function(){return this.store.isSimulationRunning}},{key:"maxPointSize",get:function(){return this.store.maxPointSize}},{key:"setConfig",value:function(e){var t,i,n=l({},this.config);this.config.init(e),n.linkColor!==this.config.linkColor&&this.lines.updateColor(),n.nodeColor!==this.config.nodeColor&&this.points.updateColor(),n.nodeSize!==this.config.nodeSize&&this.points.updateSize(),n.linkWidth!==this.config.linkWidth&&this.lines.updateWidth(),n.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=T(this.config.backgroundColor)),n.spaceSize===this.config.spaceSize&&n.simulation.repulsionQuadtreeLevels===this.config.simulation.repulsionQuadtreeLevels||this.update(this.store.isSimulationRunning),n.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new H(this.canvas):(null===(t=this.fpsMonitor)||void 0===t||t.destroy(),this.fpsMonitor=void 0)),n.pixelRatio!==this.config.pixelRatio&&(this.store.maxPointSize=(null!==(i=this.reglInstance.limits.pointSizeDims[1])&&void 0!==i?i:64)/this.config.pixelRatio)}},{key:"setData",value:function(e,t){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!e.length&&!t.length)return this.destroy(),void this.reglInstance.clear({color:this.store.backgroundColor,depth:1,stencil:0});this.graph.setData(e,t),this.update(i)}},{key:"zoomToNodeById",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:700,i=this.graph.getNodeById(e);i&&this.zoomToNode(i,t)}},{key:"zoomToNodeByIndex",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:700,i=this.graph.getNodeByIndex(e);i&&this.zoomToNode(i,t)}},{key:"zoom",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.setZoomLevel(e,t)}},{key:"setZoomLevel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.canvasD3Selection.transition().duration(t).call(this.zoomInstance.behavior.scaleTo,e)}},{key:"getZoomLevel",value:function(){return this.zoomInstance.eventTransform.k}},{key:"getNodePositions",value:function(){var e=this;if(this.hasBeenRecentlyDestroyed)return{};var t=w(this.reglInstance,this.points.currentPositionFbo);return this.graph.nodes.reduce((function(i,n){var o=e.graph.getSortedIndexById(n.id),r=t[4*o+0],a=t[4*o+1];return void 0!==r&&void 0!==a&&(i[n.id]={x:r,y:a}),i}),{})}},{key:"getNodePositionsMap",value:function(){var e=this,t=new Map;if(this.hasBeenRecentlyDestroyed)return t;var i=w(this.reglInstance,this.points.currentPositionFbo);return this.graph.nodes.reduce((function(t,n){var o=e.graph.getSortedIndexById(n.id),r=i[4*o+0],a=i[4*o+1];return void 0!==r&&void 0!==a&&t.set(n.id,[r,a]),t}),t)}},{key:"getNodePositionsArray",value:function(){var e=[];
1if(this.hasBeenRecentlyDestroyed)return[];var t=w(this.reglInstance,this.points.currentPositionFbo);e.length=this.graph.nodes.length;for(var i=0;i<this.graph.nodes.length;i+=1){var n=this.graph.getSortedIndexByInputIndex(i),o=t[4*n+0],r=t[4*n+1];void 0!==o&&void 0!==r&&(e[i]=[o,r])}return e}},{key:"fitView",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:250;this.setZoomTransformByNodePositions(this.getNodePositionsArray(),e)}},{key:"fitViewByNodeIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250,i=this.getNodePositionsMap(),n=e.map((function(e){return i.get(e)})).filter((function(e){return void 0!==e}));this.setZoomTransformByNodePositions(n,t)}},{key:"selectNodesInRange",value:function(e){if(e){var t=this.store.screenSize[1];this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection();var i=w(this.reglInstance,this.points.selectedFbo);this.store.selectedIndices=i.map((function(e,t){return t%4===0&&0!==e?t/4:-1})).filter((function(e){return-1!==e}))}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}},{key:"selectNodeById",value:function(e){var t,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(i){var n=null!==(t=this.graph.getAdjacentNodes(e))&&void 0!==t?t:[];this.selectNodesByIds([e].concat(u(n.map((function(e){return e.id})))))}else this.selectNodesByIds([e])}},{key:"selectNodeByIndex",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.graph.getNodeByIndex(e);i&&this.selectNodeById(i.id,t)}},{key:"selectNodesByIds",value:function(e){var t=this;this.selectNodesByIndices(null===e||void 0===e?void 0:e.map((function(e){return t.graph.getSortedIndexById(e)})))}},{key:"selectNodesByIndices",value:function(e){e?0===e.length?this.store.selectedIndices=new Float32Array:this.store.selectedIndices=new Float32Array(e.filter((function(e){return void 0!==e}))):this.store.selectedIndices=null,this.points.updateGreyoutStatus()}},{key:"unselectNodes",value:function(){this.store.selectedIndices=null,this.points.updateGreyoutStatus()}},{key:"getSelectedNodes",value:function(){var e=this.store.selectedIndices;if(!e)return null;var t=new Array(e.length),i=!0,n=!1,o=void 0;try{for(var r,a=e.entries()[Symbol.iterator]();!(i=(r=a.next()).done);i=!0){var s=c(r.value,2),l=s[0],u=s[1];if(void 0!==u){var d=this.graph.getInputIndexBySortedIndex(u);void 0!==d&&(t[l]=this.graph.nodes[d])}}}catch(f){n=!0,o=f}finally{try{i||null==a.return||a.return()}finally{if(n)throw o}}return t}},{key:"getAdjacentNodes",value:function(e){return this.graph.getAdjacentNodes(e)}},{key:"start",value:function(){var e,t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.graph.nodes.length&&(this.store.isSimulationRunning=!0,this.store.alpha=i,this.store.simulationProgress=0,null===(t=(e=this.config.simulation).onStart)||void 0===t||t.call(e),this.stopFrames(),this.frame())}},{key:"pause",value:function(){var e,t;this.store.isSimulationRunning=!1,null===(t=(e=this.config.simulation).onPause)||void 0===t||t.call(e)}},{key:"restart",value:function(){var e,t;this.store.isSimulationRunning=!0,null===(t=(e=this.config.simulation).onRestart)||void 0===t||t.call(e)}},{key:"step",value:function(){this.store.isSimulationRunning=!1,this.stopFrames(),this.frame()}},{key:"destroy",value:function(){var e;this.stopFrames(),this.hasBeenRecentlyDestroyed||(this.points.destroy(),this.lines.destroy(),this.forceCenter.destroy(),this.forceLinkIncoming.destroy(),this.forceLinkOutgoing.destroy(),null===(e=this.forceManyBody)||void 0===e||e.destroy(),this.reglInstance.destroy(),this.hasBeenRecentlyDestroyed=!0)}},{key:"create",value:function(){var e;this.points.create(),this.lines.create(),null===(e=this.forceManyBody)||void 0===e||e.create(),this.forceLinkIncoming.create(C.INCOMING),this.forceLinkOutgoing.create(C.OUTGOING),this.forceCenter.create(),this.hasBeenRecentlyDestroyed=!1}},{key:"update",value:function(e){var t=this.graph;this.store.pointsTextureSize=Math.ceil(Math.sqrt(t.nodes.length)),this.store.linksTextureSize=Math.ceil(Math.sqrt(2*t.linksNumber)),this.destroy(),this.create(),this.initPrograms(),e?this.start():this.step()}},{key:"initPrograms",value:function(){var e;this.points.initPrograms(),this.lines.initPrograms(),this.forceGravity.initPrograms(),this.forceLinkIncoming.initPrograms(),this.forceLinkOutgoing.initPrograms(),this.forceMouse.initPrograms(),null===(e=this.forceManyBody)||void 0===e||e.initPrograms(),this.forceCenter.initPrograms()}},{key:"frame",value:function(){var e=this,t=this.config,i=t.simulation,n=t.renderLinks,o=this.store,r=o.alpha,a=o.isSimulationRunning;r<J&&a&&this.end(),this.requestAnimationFrameId=window.requestAnimationFrame((function(t){var o,r,s,l,c,u;null===(o=e.fpsMonitor)||void 0===o||o.begin(),e.resizeCanvas(),e.isRightClickMouse&&(a||e.start(.1),e.forceMouse.run(),e.points.updatePosition()),a&&!e.zoomInstance.isRunning&&(i.gravity&&(e.forceGravity.run(),e.points.updatePosition()),i.center&&(e.forceCenter.run(),e.points.updatePosition()),null===(r=e.forceManyBody)||void 0===r||r.run(),e.points.updatePosition(),e.forceLinkIncoming.run(),e.points.updatePosition(),e.forceLinkOutgoing.run(),e.points.updatePosition(),e.store.alpha+=e.store.addAlpha(null!==(s=e.config.simulation.decay)&&void 0!==s?s:I.simulation.decay),e.isRightClickMouse&&(e.store.alpha=Math.max(e.store.alpha,.1)),e.store.simulationProgress=Math.sqrt(Math.min(1,J/e.store.alpha)),null===(c=(l=e.config.simulation).onTick)||void 0===c||c.call(l,e.store.alpha)),e.reglInstance.clear({color:e.store.backgroundColor,depth:1,stencil:0}),n&&e.lines.draw(),e.points.draw(),null===(u=e.fpsMonitor)||void 0===u||u.end(t),e.frame()}))}},{key:"stopFrames",value:function(){this.requestAnimationFrameId&&window.cancelAnimationFrame(this.requestAnimationFrameId)}},{key:"end",value:function(){var e,t;this.store.isSimulationRunning=!1,this.store.simulationProgress=1,null===(t=(e=this.config.simulation).onEnd)||void 0===t||t.call(e)}},{key:"onClick",value:function(e){var t,i,n=this;this.points.findPointsOnMouseClick();var o,r=w(this.reglInstance,this.points.selectedFbo),a=r.map((function(e,t){return t%4===0&&0!==e?(o=[r[t+2],n.config.spaceSize-r[t+3]],t/4):-1})).filter((function(e){return-1!==e})),s=this.graph.getInputIndexBySortedIndex(a[a.length-1]),l=a.length&&void 0!==s?this.graph.nodes[s]:void 0;null===(i=(t=this.config.events).onClick)||void 0===i||i.call(t,l,s,o,e)}},{key:"onMouseMove",value:function(e){var t=this.zoomInstance.eventTransform,i=t.x,n=t.y,o=t.k,r=this.canvas.clientHeight,a=e.offsetX,s=e.offsetY,l=(a-i)/o,c=(s-n)/o;this.store.mousePosition=[l,r-c],this.store.mousePosition[0]-=(this.store.screenSize[0]-this.config.spaceSize)/2,this.store.mousePosition[1]-=(this.store.screenSize[1]-this.config.spaceSize)/2,this.store.screenMousePosition=[a,this.store.screenSize[1]-s],this.isRightClickMouse=3===e.which}},{key:"onRightClickMouse",value:function(e){e.preventDefault()}},{key:"resizeCanvas",value:function(){var e=this.canvas.width,t=this.canvas.height,i=this.canvas.clientWidth,n=this.canvas.clientHeight;e===i*this.config.pixelRatio&&t===n*this.config.pixelRatio||(this.store.updateScreenSize(i,n,this.config.spaceSize),this.canvas.width=i*this.config.pixelRatio,this.canvas.height=n*this.config.pixelRatio,this.reglInstance.poll(),this.canvasD3Selection.call(this.zoomInstance.behavior.transform,this.zoomInstance.eventTransform))}},{key:"setZoomTransformByNodePositions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250,i=arguments.length>2?arguments[2]:void 0,n=this.zoomInstance.getTransform(e,i);this.canvasD3Selection.transition().ease(v.easeQuadInOut).duration(t).call(this.zoomInstance.behavior.transform,n)}},{key:"zoomToNode",value:function(e,t){var i=this.graph,n=this.store.screenSize,o=w(this.reglInstance,this.points.currentPositionFbo),r=i.getSortedIndexById(e.id);if(void 0!==r){var a=o[4*r+0],s=o[4*r+1];if(void 0!==a&&void 0!==s)if(this.zoomInstance.getDistanceToPoint([a,s])<Math.min(n[0],n[1]))this.setZoomTransformByNodePositions([[a,s]],t,3);else{var l=this.zoomInstance.getTransform([[a,s]],3),c=this.zoomInstance.getMiddlePointTransform([a,s]);this.canvasD3Selection.transition().ease(v.easeQuadIn).duration(t/2).call(this.zoomInstance.behavior.transform,c).transition().ease(v.easeQuadOut).duration(t/2).call(this.zoomInstance.behavior.transform,l)}}}}]),e}();t.k=ee}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.