=d||t.judgingDistancea){var l=a/c;s*=l,u*=l}e[2*o]=s,e[2*o+1]=u}))},e.prototype.updatePosition=function(t,e){var n=this,r=n.nodes,o=n.distanceThresholdMode,i=n.nodeMap;if(null===r||void 0===r?void 0:r.length){var s=0;"max"===o?n.judgingDistance=-1/0:"min"===o&&(n.judgingDistance=1/0);var u=1/0,c=-1/0;r.forEach((function(r,l){var d=i[r.id];if((0,a.isNumber)(r.fx)&&(0,a.isNumber)(r.fy))return r.x=r.fx,r.y=r.fy,d.x=r.x,void(d.y=r.y);var f=t[2*l]*e,h=t[2*l+1]*e;r.x+=f,r.y+=h,d.x=r.x,d.y=r.y,r.yc&&(c=r.y);var p=Math.sqrt(f*f+h*h);switch(o){case"max":n.judgingDistancep&&(n.judgingDistance=p);break;default:s+=p}})),this.currentMinY=u,this.currentMaxY=c,o&&"mean"!==o||(n.judgingDistance=s/r.length)}else this.judgingDistance=0},e.prototype.stop=function(){this.timeInterval&&"undefined"!==typeof window&&window.clearInterval(this.timeInterval)},e.prototype.destroy=function(){var t=this;t.stop(),t.tick=null,t.nodes=null,t.edges=null,t.destroyed=!0},e.prototype.getType=function(){return"force2"},e.prototype.getSameTypeLeafMap=function(){var t=this,e=t.nodeClusterBy,n=t.nodes,r=t.edges,o=t.nodeMap,i=t.degreesMap;if(null===n||void 0===n?void 0:n.length){var s={};return n.forEach((function(t,n){1===i[t.id].all&&(s[t.id]=(0,a.getCoreNodeAndRelativeLeafNodes)("leaf",t,r,e,i,o))})),s}},e}(i.Base);e.Force2Layout=c},3744:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,n=t.ry-this.ry,r=Math.hypot(e,n);r=r<1e-4?1e-4:r;var o=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=o*e/r,this.fy+=o*n/r},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var n=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/n,ry:(this.ry*this.mass+e.ry*e.mass)/n,mass:n,degree:this.degree+e.degree})},t}();e.default=n},3218:function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!==typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ForceAtlas2Layout=void 0;var i=n(5716),a=n(5027),s=o(n(3744)),u=o(n(2395)),c=o(n(787)),l=function(t){function e(e){var n=t.call(this)||this;return n.center=[0,0],n.width=300,n.height=300,n.nodes=[],n.edges=[],n.kr=5,n.kg=1,n.mode="normal",n.preventOverlap=!1,n.dissuadeHubs=!1,n.barnesHut=void 0,n.maxIteration=0,n.ks=.1,n.ksmax=10,n.tao=.1,n.onLayoutEnd=function(){},n.prune=void 0,n.updateCfg(e),n}return r(e,t),e.prototype.getDefaultCfg=function(){return{}},e.prototype.execute=function(){var t=this,e=t.nodes,n=t.onLayoutEnd,r=t.prune,o=t.maxIteration;t.width||"undefined"===typeof window||(t.width=window.innerWidth),t.height||"undefined"===typeof window||(t.height=window.innerHeight);for(var i=[],s=e.length,u=0;u250&&(t.barnesHut=!0),void 0===t.prune&&s>100&&(t.prune=!0),0!==this.maxIteration||t.prune?0===this.maxIteration&&r&&(o=100,s<=200&&s>100?o=500:s>200&&(o=950),this.maxIteration=o):(o=250,s<=200&&s>100?o=1e3:s>200&&(o=1200),this.maxIteration=o),t.kr||(t.kr=50,s>100&&s<=500?t.kr=20:s>500&&(t.kr=1)),t.kg||(t.kg=20,s>100&&s<=500?t.kg=10:s>500&&(t.kg=1)),this.nodes=t.updateNodesByForces(i),n()},e.prototype.updateNodesByForces=function(t){for(var e=this,n=e.edges,r=e.maxIteration,o=e.nodes,i=n.filter((function(t){return(0,a.getEdgeTerminal)(t,"source")!==(0,a.getEdgeTerminal)(t,"target")})),s=o.length,u=i.length,c=[],l={},d={},f=[],h=0;h0;){for(y=0;y50||!l)?this.getOptRepGraForces(g,m,o):this.getRepGraForces(p,50,g,100,i,o);var x=this.updatePos(g,v,h,o);u=x.nodes,h=x.sg,p--,a.tick&&a.tick()}return u},e.prototype.getAttrForces=function(t,e,n,r,o,i,a,s){for(var u=this,c=u.nodes,l=u.preventOverlap,d=u.dissuadeHubs,f=u.mode,h=u.prune,p=0;p0&&(w=x,E=x),s[2*r[g.id]]+=w*b[0],s[2*r[m.id]]-=E*b[0],s[2*r[g.id]+1]+=w*b[1],s[2*r[m.id]+1]-=E*b[1]}}return s},e.prototype.getRepGraForces=function(t,e,n,r,o,i){for(var a=this,s=a.nodes,u=a.preventOverlap,c=a.kr,l=a.kg,d=a.center,f=a.prune,h=s.length,p=0;p0&&(y=c*(i[p]+1)*(i[g]+1)/m),n[2*p]-=y*v[0],n[2*g]+=y*v[0],n[2*p+1]-=y*v[1],n[2*g+1]+=y*v[1]}var b=[s[p].x-d[0],s[p].y-d[1]],x=Math.hypot(b[0],b[1]);b[0]=b[0]/x,b[1]=b[1]/x;var w=l*(i[p]+1);n[2*p]-=w*b[0],n[2*p+1]-=w*b[1]}return n},e.prototype.getOptRepGraForces=function(t,e,n){for(var r=this,o=r.nodes,i=r.kg,a=r.center,s=r.prune,l=o.length,d=9e10,f=-9e10,h=9e10,p=-9e10,g=0;g=f&&(f=o[g].x),o[g].x<=d&&(d=o[g].x),o[g].y>=p&&(p=o[g].y),o[g].y<=h&&(h=o[g].y));var v={xmid:(f+d)/2,ymid:(p+h)/2,length:Math.max(f-d,p-h),massCenter:a,mass:l},m=new u.default(v),y=new c.default(m);for(g=0;g1.5*w?1.5*w:n);for(v=0;vM?M:E)*t[2*v],_=E*t[2*v+1];i[v].x+=k,i[v].y+=_}return{nodes:i,sg:n}},e}(i.Base);e.ForceAtlas2Layout=l},2395:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}();e.default=n},787:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)=o&&(null===(t=e.onLayoutEnd)||void 0===t||t.call(e),window.clearInterval(e.timeInterval))}),0)}return{nodes:n,edges:r}}},e.prototype.runOneStep=function(t){var e,n=this,r=n.nodes;if(r){var o=n.edges,a=n.center,s=n.gravity,u=n.speed,c=n.clustering,l=n.height*n.width,d=Math.sqrt(l)/10,f=l/(r.length+1),h=Math.sqrt(f),p=[];if(r.forEach((function(t,e){p[e]={x:0,y:0}})),n.applyCalculate(r,o,p,h,f),c){for(var g in t)t[g].cx=0,t[g].cy=0,t[g].count=0;for(var g in r.forEach((function(e){var n=t[e.cluster];(0,i.isNumber)(e.x)&&(n.cx+=e.x),(0,i.isNumber)(e.y)&&(n.cy+=e.y),n.count++})),t)t[g].cx/=t[g].count,t[g].cy/=t[g].count;var v=n.clusterGravity||s;r.forEach((function(e,n){if((0,i.isNumber)(e.x)&&(0,i.isNumber)(e.y)){var r=t[e.cluster],o=Math.sqrt((e.x-r.cx)*(e.x-r.cx)+(e.y-r.cy)*(e.y-r.cy)),a=h*v;p[n].x-=a*(e.x-r.cx)/o,p[n].y-=a*(e.y-r.cy)/o}}))}r.forEach((function(t,e){if((0,i.isNumber)(t.x)&&(0,i.isNumber)(t.y)){var n=.01*h*s;p[e].x-=n*(t.x-a[0]),p[e].y-=n*(t.y-a[1])}})),r.forEach((function(t,e){if((0,i.isNumber)(t.fx)&&(0,i.isNumber)(t.fy))return t.x=t.fx,void(t.y=t.fy);if((0,i.isNumber)(t.x)&&(0,i.isNumber)(t.y)){var n=Math.sqrt(p[e].x*p[e].x+p[e].y*p[e].y);if(n>0){var r=Math.min(d*(u/800),n);t.x+=p[e].x/n*r,t.y+=p[e].y/n*r}}})),null===(e=n.tick)||void 0===e||e.call(n)}},e.prototype.applyCalculate=function(t,e,n,r,o){this.calRepulsive(t,n,o),e&&this.calAttractive(e,n,r)},e.prototype.calRepulsive=function(t,e,n){t.forEach((function(r,o){e[o]={x:0,y:0},t.forEach((function(t,a){if(o!==a&&(0,i.isNumber)(r.x)&&(0,i.isNumber)(t.x)&&(0,i.isNumber)(r.y)&&(0,i.isNumber)(t.y)){var s=r.x-t.x,u=r.y-t.y,c=s*s+u*u;if(0===c){c=1;var l=o>a?1:-1;s=.01*l,u=.01*l}var d=n/c;e[o].x+=s*d,e[o].y+=u*d}}))}))},e.prototype.calAttractive=function(t,e,n){var r=this;t.forEach((function(t){var o=(0,i.getEdgeTerminal)(t,"source"),a=(0,i.getEdgeTerminal)(t,"target");if(o&&a){var s=r.nodeIdxMap[o],u=r.nodeIdxMap[a];if(s!==u){var c=r.nodeMap[o],l=r.nodeMap[a];if((0,i.isNumber)(l.x)&&(0,i.isNumber)(c.x)&&(0,i.isNumber)(l.y)&&(0,i.isNumber)(c.y)){var d=l.x-c.x,f=l.y-c.y,h=Math.sqrt(d*d+f*f),p=h*h/n;e[u].x-=d/h*p,e[u].y-=f/h*p,e[s].x+=d/h*p,e[s].y+=f/h*p}}}}))},e.prototype.stop=function(){this.timeInterval&&"undefined"!==typeof window&&window.clearInterval(this.timeInterval)},e.prototype.destroy=function(){var t=this;t.stop(),t.tick=null,t.nodes=null,t.edges=null,t.destroyed=!0},e.prototype.getType=function(){return"fruchterman"},e}(o.Base);e.FruchtermanLayout=a},8765:function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!==typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0}),e.GForceLayout=void 0;var o=n(5716),i=n(5027),a=function(t,e){return t?(0,i.isNumber)(t)?function(e){return t}:t:function(t){return e||1}},s=function(t){function e(e){var n=t.call(this)||this;return n.maxIteration=500,n.workerEnabled=!1,n.edgeStrength=200,n.nodeStrength=1e3,n.coulombDisScale=.005,n.damping=.9,n.maxSpeed=1e3,n.minMovement=.5,n.interval=.02,n.factor=1,n.linkDistance=1,n.gravity=10,n.preventOverlap=!0,n.collideStrength=1,n.tick=function(){},n.nodes=[],n.edges=[],n.width=300,n.height=300,n.nodeMap={},n.nodeIdxMap={},n.animate=!0,n.updateCfg(e),n}return r(e,t),e.prototype.getDefaultCfg=function(){return{maxIteration:500,gravity:10,enableTick:!0,animate:!0}},e.prototype.execute=function(){var t,e,n=this,r=n.nodes;if(void 0!==n.timeInterval&&"undefined"!==typeof window&&window.clearInterval(n.timeInterval),r&&0!==r.length){n.width||"undefined"===typeof window||(n.width=window.innerWidth),n.height||"undefined"===typeof window||(n.height=window.innerHeight),n.center||(n.center=[n.width/2,n.height/2]);var o=n.center;if(1===r.length)return r[0].x=o[0],r[0].y=o[1],void(null===(e=n.onLayoutEnd)||void 0===e||e.call(n));var s={},u={};r.forEach((function(t,e){(0,i.isNumber)(t.x)||(t.x=Math.random()*n.width),(0,i.isNumber)(t.y)||(t.y=Math.random()*n.height),s[t.id]=t,u[t.id]=e})),n.nodeMap=s,n.nodeIdxMap=u,n.linkDistance=a(n.linkDistance,1),n.nodeStrength=a(n.nodeStrength,1),n.edgeStrength=a(n.edgeStrength,1);var c,l=n.nodeSize;if(n.preventOverlap){var d,f=n.nodeSpacing;d=(0,i.isNumber)(f)?function(){return f}:(0,i.isFunction)(f)?f:function(){return 0},c=l?(0,i.isArray)(l)?function(t){return Math.max(l[0],l[1])+d(t)}:function(t){return l+d(t)}:function(t){return t.size?(0,i.isArray)(t.size)?Math.max(t.size[0],t.size[1])+d(t):(0,i.isObject)(t.size)?Math.max(t.size.width,t.size.height)+d(t):t.size+d(t):10+d(t)}}n.nodeSize=c;var h=n.edges;n.degrees=(0,i.getDegree)(r.length,n.nodeIdxMap,h),n.getMass||(n.getMass=function(t){return t.mass||n.degrees[n.nodeIdxMap[t.id]].all||1}),n.run()}else null===(t=n.onLayoutEnd)||void 0===t||t.call(n)},e.prototype.run=function(){var t,e=this,n=e.maxIteration,r=e.nodes,o=e.workerEnabled,i=e.minMovement,a=e.animate;if(r)if(o||!a){for(var s=0;s=n&&(null===(o=e.onLayoutEnd)||void 0===o||o.call(e),window.clearInterval(e.timeInterval))}}),0)}},e.prototype.reachMoveThreshold=function(t,e,n){var r=0;return t.forEach((function(t,n){var o=t.x-e[n].x,i=t.y-e[n].y;r+=Math.sqrt(o*o+i*i)})),(r/=t.length)=f)){var h=n.x-e.x,p=n.y-e.y;0===h&&0===p&&(h=.01*Math.random(),p=.01*Math.random());var g=h*h+p*p,v=Math.sqrt(g),m=(v+.1)*i,y=h/v,b=p/v,x=.5*(c(n)+c(e))*o/(m*m),w=r?r(e):1;if(t[2*s]+=y*x,t[2*s+1]+=b*x,t[2*f]-=y*x,t[2*f+1]-=b*x,a&&(l(n)+l(e))/2>v){var E=u*(c(n)+c(e))*.5/g;t[2*s]+=y*E/d,t[2*s+1]+=b*E/d,t[2*f]-=y*E/w,t[2*f+1]-=b*E/w}}}))}))},e.prototype.calAttractive=function(t,e){var n=this,r=n.nodeMap,o=n.nodeIdxMap,a=n.linkDistance,s=n.edgeStrength,u=n.nodeSize,c=n.getMass;e.forEach((function(e,n){var l=(0,i.getEdgeTerminal)(e,"source"),d=(0,i.getEdgeTerminal)(e,"target"),f=r[l],h=r[d],p=h.x-f.x,g=h.y-f.y;0===p&&0===g&&(p=.01*Math.random(),g=.01*Math.random());var v=Math.sqrt(p*p+g*g),m=p/v,y=g/v,b=((a(e,f,h)||1+(u(f)+u(h)||0)/2)-v)*s(e),x=o[l],w=o[d],E=c?c(f):1,S=c?c(h):1;t[2*x]-=m*b/E,t[2*x+1]-=y*b/E,t[2*w]+=m*b/S,t[2*w+1]+=y*b/S}))},e.prototype.calGravity=function(t,e){for(var n=this,r=n.center,o=n.gravity,a=n.degrees,s=e.length,u=0;uo.maxSpeed){var c=o.maxSpeed/u;a*=c,s*=c}e[2*r]=a,e[2*r+1]=s}))},e.prototype.updatePosition=function(t,e,n){n.forEach((function(n,r){if((0,i.isNumber)(n.fx)&&(0,i.isNumber)(n.fy))return n.x=n.fx,void(n.y=n.fy);var o=t[2*r]*e,a=t[2*r+1]*e;n.x+=o,n.y+=a}))},e.prototype.stop=function(){this.timeInterval&&"undefined"!==typeof window&&window.clearInterval(this.timeInterval)},e.prototype.destroy=function(){var t=this;t.stop(),t.tick=null,t.nodes=null,t.edges=null,t.destroyed=!0},e.prototype.getType=function(){return"gForce"},e}(o.Base);e.GForceLayout=s},7649:function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!==typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(e){i(e)}}function s(t){try{u(r.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"===typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.clusterBundle=e.clusterCode=e.fruchtermanBundle=e.fruchtermanCode=void 0,e.fruchtermanCode="\nimport { globalInvocationID } from 'g-webgpu';\nconst MAX_EDGE_PER_VERTEX;\nconst VERTEX_COUNT;\n@numthreads(1, 1, 1)\nclass Fruchterman {\n @in @out\n u_Data: vec4[];\n @in\n u_K: float;\n @in\n u_K2: float;\n \n @in\n u_Center: vec2;\n @in\n u_Gravity: float;\n @in\n u_ClusterGravity: float;\n @in\n u_Speed: float;\n @in\n u_MaxDisplace: float;\n @in\n u_Clustering: float;\n @in\n u_AttributeArray: vec4[];\n @in\n u_ClusterCenters: vec4[];\n calcRepulsive(i: int, currentNode: vec4): vec2 {\n let dx = 0, dy = 0;\n for (let j = 0; j < VERTEX_COUNT; j++) {\n if (i != j) {\n const nextNode = this.u_Data[j];\n const xDist = currentNode[0] - nextNode[0];\n const yDist = currentNode[1] - nextNode[1];\n const dist = (xDist * xDist + yDist * yDist) + 0.01;\n let param = this.u_K2 / dist;\n \n if (dist > 0.0) {\n dx += param * xDist;\n dy += param * yDist;\n if (xDist == 0 && yDist == 0) {\n const sign = i < j ? 1 : -1;\n dx += param * sign;\n dy += param * sign;\n }\n }\n }\n }\n return [dx, dy];\n }\n calcGravity(currentNode: vec4, nodeAttributes: vec4): vec2 { // \n let dx = 0, dy = 0;\n const vx = currentNode[0] - this.u_Center[0];\n const vy = currentNode[1] - this.u_Center[1];\n const gf = 0.01 * this.u_K * this.u_Gravity;\n dx = gf * vx;\n dy = gf * vy;\n if (this.u_Clustering == 1) {\n const clusterIdx = int(nodeAttributes[0]);\n const center = this.u_ClusterCenters[clusterIdx];\n const cvx = currentNode[0] - center[0];\n const cvy = currentNode[1] - center[1];\n const dist = sqrt(cvx * cvx + cvy * cvy) + 0.01;\n const parma = this.u_K * this.u_ClusterGravity / dist;\n dx += parma * cvx;\n dy += parma * cvy;\n }\n return [dx, dy];\n }\n calcAttractive(i: int, currentNode: vec4): vec2 {\n let dx = 0, dy = 0;\n const arr_offset = int(floor(currentNode[2] + 0.5));\n const length = int(floor(currentNode[3] + 0.5));\n const node_buffer: vec4;\n for (let p = 0; p < MAX_EDGE_PER_VERTEX; p++) {\n if (p >= length) break;\n const arr_idx = arr_offset + p;\n // when arr_idx % 4 == 0 update currentNodedx_buffer\n const buf_offset = arr_idx - arr_idx / 4 * 4;\n if (p == 0 || buf_offset == 0) {\n node_buffer = this.u_Data[int(arr_idx / 4)];\n }\n const float_j = buf_offset == 0 ? node_buffer[0] :\n buf_offset == 1 ? node_buffer[1] :\n buf_offset == 2 ? node_buffer[2] :\n node_buffer[3];\n const nextNode = this.u_Data[int(float_j)];\n const xDist = currentNode[0] - nextNode[0];\n const yDist = currentNode[1] - nextNode[1];\n const dist = sqrt(xDist * xDist + yDist * yDist) + 0.01;\n let attractiveF = dist / this.u_K;\n \n if (dist > 0.0) {\n dx -= xDist * attractiveF;\n dy -= yDist * attractiveF;\n if (xDist == 0 && yDist == 0) {\n const sign = i < int(float_j) ? 1 : -1;\n dx -= sign * attractiveF;\n dy -= sign * attractiveF;\n }\n }\n }\n return [dx, dy];\n }\n @main\n compute() {\n const i = globalInvocationID.x;\n const currentNode = this.u_Data[i];\n let dx = 0, dy = 0;\n if (i >= VERTEX_COUNT) {\n this.u_Data[i] = currentNode;\n return;\n }\n\n // [gravity, fx, fy, 0]\n const nodeAttributes = this.u_AttributeArray[i];\n\n if (nodeAttributes[1] != 0 && nodeAttributes[2] != 0) {\n // the node is fixed\n this.u_Data[i] = [\n nodeAttributes[1],\n nodeAttributes[2],\n currentNode[2],\n currentNode[3]\n ];\n return;\n }\n\n // repulsive\n const repulsive = this.calcRepulsive(i, currentNode);\n dx += repulsive[0];\n dy += repulsive[1];\n // attractive\n const attractive = this.calcAttractive(i, currentNode);\n dx += attractive[0];\n dy += attractive[1];\n // gravity\n const gravity = this.calcGravity(currentNode, nodeAttributes);\n dx -= gravity[0];\n dy -= gravity[1];\n // speed\n dx *= this.u_Speed;\n dy *= this.u_Speed;\n\n // move\n const distLength = sqrt(dx * dx + dy * dy);\n if (distLength > 0.0) {\n const limitedDist = min(this.u_MaxDisplace * this.u_Speed, distLength);\n this.u_Data[i] = [\n currentNode[0] + dx / distLength * limitedDist,\n currentNode[1] + dy / distLength * limitedDist,\n currentNode[2],\n currentNode[3]\n ];\n }\n }\n}\n",e.fruchtermanBundle='{"shaders":{"WGSL":"","GLSL450":"","GLSL100":"\\n\\nfloat epsilon = 0.00001;\\nvec2 addrTranslation_1Dto2D(float address1D, vec2 texSize) {\\n vec2 conv_const = vec2(1.0 / texSize.x, 1.0 / (texSize.x * texSize.y));\\n vec2 normAddr2D = float(address1D) * conv_const;\\n return vec2(fract(normAddr2D.x + epsilon), normAddr2D.y);\\n}\\n\\nvoid barrier() {}\\n \\n\\nuniform vec2 u_OutputTextureSize;\\nuniform int u_OutputTexelCount;\\nvarying vec2 v_TexCoord;\\n\\nbool gWebGPUDebug = false;\\nvec4 gWebGPUDebugOutput = vec4(0.0);\\n\\n#define MAX_EDGE_PER_VERTEX __DefineValuePlaceholder__MAX_EDGE_PER_VERTEX\\n#define VERTEX_COUNT __DefineValuePlaceholder__VERTEX_COUNT\\n\\nuniform sampler2D u_Data;\\nuniform vec2 u_DataSize;\\nvec4 getDatau_Data(vec2 address2D) {\\n return vec4(texture2D(u_Data, address2D).rgba);\\n}\\nvec4 getDatau_Data(float address1D) {\\n return getDatau_Data(addrTranslation_1Dto2D(address1D, u_DataSize));\\n}\\nvec4 getDatau_Data(int address1D) {\\n return getDatau_Data(float(address1D));\\n}\\nuniform float u_K;\\nuniform float u_K2;\\nuniform vec2 u_Center;\\nuniform float u_Gravity;\\nuniform float u_ClusterGravity;\\nuniform float u_Speed;\\nuniform float u_MaxDisplace;\\nuniform float u_Clustering;\\nuniform sampler2D u_AttributeArray;\\nuniform vec2 u_AttributeArraySize;\\nvec4 getDatau_AttributeArray(vec2 address2D) {\\n return vec4(texture2D(u_AttributeArray, address2D).rgba);\\n}\\nvec4 getDatau_AttributeArray(float address1D) {\\n return getDatau_AttributeArray(addrTranslation_1Dto2D(address1D, u_AttributeArraySize));\\n}\\nvec4 getDatau_AttributeArray(int address1D) {\\n return getDatau_AttributeArray(float(address1D));\\n}\\nuniform sampler2D u_ClusterCenters;\\nuniform vec2 u_ClusterCentersSize;\\nvec4 getDatau_ClusterCenters(vec2 address2D) {\\n return vec4(texture2D(u_ClusterCenters, address2D).rgba);\\n}\\nvec4 getDatau_ClusterCenters(float address1D) {\\n return getDatau_ClusterCenters(addrTranslation_1Dto2D(address1D, u_ClusterCentersSize));\\n}\\nvec4 getDatau_ClusterCenters(int address1D) {\\n return getDatau_ClusterCenters(float(address1D));\\n}\\nvec2 calcRepulsive(int i, vec4 currentNode) {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nfloat dx = 0.0;\\nfloat dy = 0.0;\\nfor (int j = 0; j < VERTEX_COUNT; j++) {if (i != j) {vec4 nextNode = getDatau_Data(j);\\nfloat xDist = currentNode.x - nextNode.x;\\nfloat yDist = currentNode.y - nextNode.y;\\nfloat dist = ((xDist * xDist) + (yDist * yDist)) + 0.01;\\nfloat param = u_K2 / dist;\\nif (dist > 0.0) {dx += param * xDist;\\ndy += param * yDist;\\nif ((xDist == 0.0) && (yDist == 0.0)) {float sign = (i < j) ? (1.0) : (-1.0);\\ndx += param * sign;\\ndy += param * sign;}}}}\\nreturn vec2(dx, dy);}\\nvec2 calcGravity(vec4 currentNode, vec4 nodeAttributes) {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nfloat dx = 0.0;\\nfloat dy = 0.0;\\nfloat vx = currentNode.x - u_Center.x;\\nfloat vy = currentNode.y - u_Center.y;\\nfloat gf = (0.01 * u_K) * u_Gravity;\\ndx = gf * vx;\\ndy = gf * vy;\\nif (u_Clustering == 1.0) {int clusterIdx = int(nodeAttributes.x);\\nvec4 center = getDatau_ClusterCenters(clusterIdx);\\nfloat cvx = currentNode.x - center.x;\\nfloat cvy = currentNode.y - center.y;\\nfloat dist = sqrt((cvx * cvx) + (cvy * cvy)) + 0.01;\\nfloat parma = (u_K * u_ClusterGravity) / dist;\\ndx += parma * cvx;\\ndy += parma * cvy;}\\nreturn vec2(dx, dy);}\\nvec2 calcAttractive(int i, vec4 currentNode) {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nfloat dx = 0.0;\\nfloat dy = 0.0;\\nint arr_offset = int(floor(currentNode.z + 0.5));\\nint length = int(floor(currentNode.w + 0.5));\\nvec4 node_buffer;\\nfor (int p = 0; p < MAX_EDGE_PER_VERTEX; p++) {if (p >= length) {break;}\\nint arr_idx = arr_offset + int(p);\\nint buf_offset = arr_idx - ((arr_idx / 4) * 4);\\nif ((p == 0) || (buf_offset == 0)) {node_buffer = getDatau_Data(int(arr_idx / 4));}\\nfloat float_j = (buf_offset == 0) ? (node_buffer.x) : ((buf_offset == 1) ? (node_buffer.y) : ((buf_offset == 2) ? (node_buffer.z) : (node_buffer.w)));\\nvec4 nextNode = getDatau_Data(int(float_j));\\nfloat xDist = currentNode.x - nextNode.x;\\nfloat yDist = currentNode.y - nextNode.y;\\nfloat dist = sqrt((xDist * xDist) + (yDist * yDist)) + 0.01;\\nfloat attractiveF = dist / u_K;\\nif (dist > 0.0) {dx -= xDist * attractiveF;\\ndy -= yDist * attractiveF;\\nif ((xDist == 0.0) && (yDist == 0.0)) {float sign = (i < int(float_j)) ? (1.0) : (-1.0);\\ndx -= sign * attractiveF;\\ndy -= sign * attractiveF;}}}\\nreturn vec2(dx, dy);}\\nvoid main() {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nint i = globalInvocationID.x;\\nvec4 currentNode = getDatau_Data(i);\\nfloat dx = 0.0;\\nfloat dy = 0.0;\\nif (i >= VERTEX_COUNT) {gl_FragColor = vec4(currentNode);\\nreturn ;}\\nvec4 nodeAttributes = getDatau_AttributeArray(i);\\nif ((nodeAttributes.y != 0.0) && (nodeAttributes.z != 0.0)) {gl_FragColor = vec4(vec4(nodeAttributes.y, nodeAttributes.z, currentNode.z, currentNode.w));\\nreturn ;}\\nvec2 repulsive = calcRepulsive(i, currentNode);\\ndx += repulsive.x;\\ndy += repulsive.y;\\nvec2 attractive = calcAttractive(i, currentNode);\\ndx += attractive.x;\\ndy += attractive.y;\\nvec2 gravity = calcGravity(currentNode, nodeAttributes);\\ndx -= gravity.x;\\ndy -= gravity.y;\\ndx *= u_Speed;\\ndy *= u_Speed;\\nfloat distLength = sqrt((dx * dx) + (dy * dy));\\nif (distLength > 0.0) {float limitedDist = min(u_MaxDisplace * u_Speed, distLength);\\ngl_FragColor = vec4(vec4(currentNode.x + ((dx / distLength) * limitedDist), currentNode.y + ((dy / distLength) * limitedDist), currentNode.z, currentNode.w));}if (gWebGPUDebug) {\\n gl_FragColor = gWebGPUDebugOutput;\\n}}\\n"},"context":{"name":"","dispatch":[1,1,1],"threadGroupSize":[1,1,1],"maxIteration":1,"defines":[{"name":"MAX_EDGE_PER_VERTEX","type":"Float","runtime":true},{"name":"VERTEX_COUNT","type":"Float","runtime":true}],"uniforms":[{"name":"u_Data","type":"vec4[]","storageClass":"StorageBuffer","readonly":false,"writeonly":false,"size":[1,1]},{"name":"u_K","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_K2","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_Center","type":"vec2","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_Gravity","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_ClusterGravity","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_Speed","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_MaxDisplace","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_Clustering","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_AttributeArray","type":"vec4[]","storageClass":"StorageBuffer","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_ClusterCenters","type":"vec4[]","storageClass":"StorageBuffer","readonly":true,"writeonly":false,"size":[1,1]}],"globalDeclarations":[],"output":{"name":"u_Data","size":[1,1],"length":1},"needPingpong":true}}',e.clusterCode="\nimport { globalInvocationID } from 'g-webgpu';\nconst VERTEX_COUNT;\nconst CLUSTER_COUNT;\n@numthreads(1, 1, 1)\nclass CalcCenter {\n @in\n u_Data: vec4[];\n @in\n u_NodeAttributes: vec4[]; // [[clusterIdx, 0, 0, 0], ...]\n @in @out\n u_ClusterCenters: vec4[]; // [[cx, cy, nodeCount, clusterIdx], ...]\n @main\n compute() {\n const i = globalInvocationID.x;\n const center = this.u_ClusterCenters[i];\n let sumx = 0;\n let sumy = 0;\n let count = 0;\n for (let j = 0; j < VERTEX_COUNT; j++) {\n const attributes = this.u_NodeAttributes[j];\n const clusterIdx = int(attributes[0]);\n const vertex = this.u_Data[j];\n if (clusterIdx == i) {\n sumx += vertex.x;\n sumy += vertex.y;\n count += 1;\n }\n }\n this.u_ClusterCenters[i] = [\n sumx / count,\n sumy / count,\n count,\n i\n ];\n }\n}\n",e.clusterBundle='{"shaders":{"WGSL":"","GLSL450":"","GLSL100":"\\n\\nfloat epsilon = 0.00001;\\nvec2 addrTranslation_1Dto2D(float address1D, vec2 texSize) {\\n vec2 conv_const = vec2(1.0 / texSize.x, 1.0 / (texSize.x * texSize.y));\\n vec2 normAddr2D = float(address1D) * conv_const;\\n return vec2(fract(normAddr2D.x + epsilon), normAddr2D.y);\\n}\\n\\nvoid barrier() {}\\n \\n\\nuniform vec2 u_OutputTextureSize;\\nuniform int u_OutputTexelCount;\\nvarying vec2 v_TexCoord;\\n\\nbool gWebGPUDebug = false;\\nvec4 gWebGPUDebugOutput = vec4(0.0);\\n\\n#define VERTEX_COUNT __DefineValuePlaceholder__VERTEX_COUNT\\n#define CLUSTER_COUNT __DefineValuePlaceholder__CLUSTER_COUNT\\n\\nuniform sampler2D u_Data;\\nuniform vec2 u_DataSize;\\nvec4 getDatau_Data(vec2 address2D) {\\n return vec4(texture2D(u_Data, address2D).rgba);\\n}\\nvec4 getDatau_Data(float address1D) {\\n return getDatau_Data(addrTranslation_1Dto2D(address1D, u_DataSize));\\n}\\nvec4 getDatau_Data(int address1D) {\\n return getDatau_Data(float(address1D));\\n}\\nuniform sampler2D u_NodeAttributes;\\nuniform vec2 u_NodeAttributesSize;\\nvec4 getDatau_NodeAttributes(vec2 address2D) {\\n return vec4(texture2D(u_NodeAttributes, address2D).rgba);\\n}\\nvec4 getDatau_NodeAttributes(float address1D) {\\n return getDatau_NodeAttributes(addrTranslation_1Dto2D(address1D, u_NodeAttributesSize));\\n}\\nvec4 getDatau_NodeAttributes(int address1D) {\\n return getDatau_NodeAttributes(float(address1D));\\n}\\nuniform sampler2D u_ClusterCenters;\\nuniform vec2 u_ClusterCentersSize;\\nvec4 getDatau_ClusterCenters(vec2 address2D) {\\n return vec4(texture2D(u_ClusterCenters, address2D).rgba);\\n}\\nvec4 getDatau_ClusterCenters(float address1D) {\\n return getDatau_ClusterCenters(addrTranslation_1Dto2D(address1D, u_ClusterCentersSize));\\n}\\nvec4 getDatau_ClusterCenters(int address1D) {\\n return getDatau_ClusterCenters(float(address1D));\\n}\\nvoid main() {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nint i = globalInvocationID.x;\\nvec4 center = getDatau_ClusterCenters(i);\\nfloat sumx = 0.0;\\nfloat sumy = 0.0;\\nfloat count = 0.0;\\nfor (int j = 0; j < VERTEX_COUNT; j++) {vec4 attributes = getDatau_NodeAttributes(j);\\nint clusterIdx = int(attributes.x);\\nvec4 vertex = getDatau_Data(j);\\nif (clusterIdx == i) {sumx += vertex.x;\\nsumy += vertex.y;\\ncount += 1.0;}}\\ngl_FragColor = vec4(vec4(sumx / count, sumy / count, count, i));if (gWebGPUDebug) {\\n gl_FragColor = gWebGPUDebugOutput;\\n}}\\n"},"context":{"name":"","dispatch":[1,1,1],"threadGroupSize":[1,1,1],"maxIteration":1,"defines":[{"name":"VERTEX_COUNT","type":"Float","runtime":true},{"name":"CLUSTER_COUNT","type":"Float","runtime":true}],"uniforms":[{"name":"u_Data","type":"vec4[]","storageClass":"StorageBuffer","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_NodeAttributes","type":"vec4[]","storageClass":"StorageBuffer","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_ClusterCenters","type":"vec4[]","storageClass":"StorageBuffer","readonly":false,"writeonly":false,"size":[1,1]}],"globalDeclarations":[],"output":{"name":"u_ClusterCenters","size":[1,1],"length":1},"needPingpong":true}}'},4518:function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!==typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(e){i(e)}}function s(t){try{u(r.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"===typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.aveMovementBundle=e.aveMovementCode=e.gForceBundle=e.gForceCode=void 0,e.gForceCode="\nimport { globalInvocationID } from 'g-webgpu';\n\nconst MAX_EDGE_PER_VERTEX;\nconst VERTEX_COUNT;\nconst SHIFT_20 = 1048576;\n\n@numthreads(1, 1, 1)\nclass GGForce {\n @in @out\n u_Data: vec4[];\n\n @in\n u_damping: float;\n \n @in\n u_maxSpeed: float;\n\n @in\n u_minMovement: float;\n\n @in\n u_AveMovement: vec4[];\n\n @in\n u_coulombDisScale: float;\n\n @in\n u_factor: float;\n\n @in\n u_NodeAttributeArray1: vec4[];\n\n @in\n u_NodeAttributeArray2: vec4[];\n\n @in\n u_interval: float;\n\n unpack_float(packedValue: float): ivec2 {\n const packedIntValue = int(packedValue);\n const v0 = packedIntValue / SHIFT_20;\n return [v0, packedIntValue - v0 * SHIFT_20];\n }\n\n calcRepulsive(i: int, currentNode: vec4): vec2 {\n let ax = 0, ay = 0;\n for (let j: int = 0; j < VERTEX_COUNT; j++) {\n if (i != j) {\n const nextNode = this.u_Data[j];\n const vx = currentNode[0] - nextNode[0];\n const vy = currentNode[1] - nextNode[1];\n const dist = sqrt(vx * vx + vy * vy) + 0.01;\n const n_dist = (dist + 0.1) * this.u_coulombDisScale;\n const direx = vx / dist;\n const direy = vy / dist;\n const attributesi = this.u_NodeAttributeArray1[i];\n const attributesj = this.u_NodeAttributeArray1[j];\n const massi = attributesi[0];\n const nodeStrengthi = attributesi[2];\n const nodeStrengthj = attributesj[2];\n const nodeStrength = (nodeStrengthi + nodeStrengthj) / 2;\n // const param = nodeStrength * this.u_factor / (n_dist * n_dist * massi);\n const param = nodeStrength * this.u_factor / (n_dist * n_dist);\n ax += direx * param;\n ay += direy * param;\n }\n }\n return [ax, ay];\n }\n\n calcGravity(i: int, currentNode: vec4, attributes2: vec4): vec2 {\n // note: attributes2 = [centerX, centerY, gravity, 0]\n\n const vx = currentNode[0] - attributes2[0];\n const vy = currentNode[1] - attributes2[1];\n \n const ax = vx * attributes2[2];\n const ay = vy * attributes2[2];\n \n return [ax, ay];\n }\n\n calcAttractive(i: int, currentNode: vec4, attributes1: vec4): vec2 {\n // note: attributes1 = [mass, degree, nodeSterngth, 0]\n\n const mass = attributes1[0];\n let ax = 0, ay = 0;\n // const arr_offset = int(floor(currentNode[2] + 0.5));\n // const length = int(floor(currentNode[3] + 0.5));\n\n const compressed = this.unpack_float(currentNode[2]);\n const length = compressed[0];\n const arr_offset = compressed[1];\n\n const node_buffer: vec4;\n for (let p: int = 0; p < MAX_EDGE_PER_VERTEX; p++) {\n if (p >= length) break;\n const arr_idx = arr_offset + 4 * p; // i \u8282\u70b9\u7684\u7b2c p \u6761\u8fb9\u5f00\u59cb\u7684\u5c0f\u683c\u5b50\u4f4d\u7f6e\n const buf_offset = arr_idx - arr_idx / 4 * 4;\n if (p == 0 || buf_offset == 0) {\n node_buffer = this.u_Data[int(arr_idx / 4)]; // \u5927\u683c\u5b50\uff0c\u5927\u683c\u5b50\u4f4d\u7f6e=\u5c0f\u4e2a\u5b50\u4f4d\u7f6e / 4\uff0c\n }\n\n let float_j: float = node_buffer[0];\n\n const nextNode = this.u_Data[int(float_j)];\n const vx = nextNode[0] - currentNode[0];\n const vy = nextNode[1] - currentNode[1];\n const dist = sqrt(vx * vx + vy * vy) + 0.01;\n const direx = vx / dist;\n const direy = vy / dist;\n const edgeLength = node_buffer[1];\n const edgeStrength = node_buffer[2];\n const diff: float = edgeLength - dist;//edgeLength\n // const param = diff * this.u_stiffness / mass; //\n const param = diff * edgeStrength / mass; // \n ax -= direx * param;\n ay -= direy * param;\n }\n return [ax, ay];\n }\n\n @main\n compute() {\n const i = globalInvocationID.x;\n const currentNode = this.u_Data[i];\n const movement = u_AveMovement[0];\n let ax = 0, ay = 0;\n\n if (i >= VERTEX_COUNT || movement.x < u_minMovement) {\n this.u_Data[i] = currentNode;\n return;\n }\n\n // \u6bcf\u4e2a\u8282\u70b9\u5c5e\u6027\u5360\u4e24\u4e2a\u6570\u7ec4\u4e2d\u5404\u4e00\u683c\n // [mass, degree, nodeStrength, fx]\n const nodeAttributes1 = this.u_NodeAttributeArray1[i];\n // [centerX, centerY, centerGravity, fy]\n const nodeAttributes2 = this.u_NodeAttributeArray2[i];\n\n // repulsive\n const repulsive = this.calcRepulsive(i, currentNode);\n ax += repulsive[0];\n ay += repulsive[1];\n\n // attractive\n const attractive = this.calcAttractive(i, currentNode, nodeAttributes1);\n ax += attractive[0];\n ay += attractive[1];\n\n // gravity\n const gravity = this.calcGravity(i, currentNode, nodeAttributes2);\n ax -= gravity[0];\n ay -= gravity[1];\n\n // speed\n const param = this.u_interval * this.u_damping;\n let vx = ax * param;\n let vy = ay * param;\n const vlength = sqrt(vx * vx + vy * vy) + 0.0001;\n if (vlength > this.u_maxSpeed) {\n const param2 = this.u_maxSpeed / vlength;\n vx = param2 * vx;\n vy = param2 * vy;\n }\n\n // move\n if (nodeAttributes1[3] != 0 && nodeAttributes2[3] != 0) {\n this.u_Data[i] = [\n nodeAttributes1[3],\n nodeAttributes2[3],\n currentNode[2],\n 0\n ];\n } else {\n const distx = vx * this.u_interval;\n const disty = vy * this.u_interval;\n const distLength = sqrt(distx * distx + disty * disty);\n this.u_Data[i] = [\n currentNode[0] + distx,\n currentNode[1] + disty,\n currentNode[2],\n distLength\n ];\n }\n \n // the avarage move distance\n // need to share memory\n \n }\n}\n",e.gForceBundle='{"shaders":{"WGSL":"","GLSL450":"","GLSL100":"\\n\\nfloat epsilon = 0.00001;\\nvec2 addrTranslation_1Dto2D(float address1D, vec2 texSize) {\\n vec2 conv_const = vec2(1.0 / texSize.x, 1.0 / (texSize.x * texSize.y));\\n vec2 normAddr2D = float(address1D) * conv_const;\\n return vec2(fract(normAddr2D.x + epsilon), normAddr2D.y);\\n}\\n\\nvoid barrier() {}\\n \\n\\nuniform vec2 u_OutputTextureSize;\\nuniform int u_OutputTexelCount;\\nvarying vec2 v_TexCoord;\\n\\nbool gWebGPUDebug = false;\\nvec4 gWebGPUDebugOutput = vec4(0.0);\\n\\n#define MAX_EDGE_PER_VERTEX __DefineValuePlaceholder__MAX_EDGE_PER_VERTEX\\n#define VERTEX_COUNT __DefineValuePlaceholder__VERTEX_COUNT\\n#define SHIFT_20 1048576.0\\n\\nuniform sampler2D u_Data;\\nuniform vec2 u_DataSize;\\nvec4 getDatau_Data(vec2 address2D) {\\n return vec4(texture2D(u_Data, address2D).rgba);\\n}\\nvec4 getDatau_Data(float address1D) {\\n return getDatau_Data(addrTranslation_1Dto2D(address1D, u_DataSize));\\n}\\nvec4 getDatau_Data(int address1D) {\\n return getDatau_Data(float(address1D));\\n}\\nuniform float u_damping;\\nuniform float u_maxSpeed;\\nuniform float u_minMovement;\\nuniform sampler2D u_AveMovement;\\nuniform vec2 u_AveMovementSize;\\nvec4 getDatau_AveMovement(vec2 address2D) {\\n return vec4(texture2D(u_AveMovement, address2D).rgba);\\n}\\nvec4 getDatau_AveMovement(float address1D) {\\n return getDatau_AveMovement(addrTranslation_1Dto2D(address1D, u_AveMovementSize));\\n}\\nvec4 getDatau_AveMovement(int address1D) {\\n return getDatau_AveMovement(float(address1D));\\n}\\nuniform float u_coulombDisScale;\\nuniform float u_factor;\\nuniform sampler2D u_NodeAttributeArray1;\\nuniform vec2 u_NodeAttributeArray1Size;\\nvec4 getDatau_NodeAttributeArray1(vec2 address2D) {\\n return vec4(texture2D(u_NodeAttributeArray1, address2D).rgba);\\n}\\nvec4 getDatau_NodeAttributeArray1(float address1D) {\\n return getDatau_NodeAttributeArray1(addrTranslation_1Dto2D(address1D, u_NodeAttributeArray1Size));\\n}\\nvec4 getDatau_NodeAttributeArray1(int address1D) {\\n return getDatau_NodeAttributeArray1(float(address1D));\\n}\\nuniform sampler2D u_NodeAttributeArray2;\\nuniform vec2 u_NodeAttributeArray2Size;\\nvec4 getDatau_NodeAttributeArray2(vec2 address2D) {\\n return vec4(texture2D(u_NodeAttributeArray2, address2D).rgba);\\n}\\nvec4 getDatau_NodeAttributeArray2(float address1D) {\\n return getDatau_NodeAttributeArray2(addrTranslation_1Dto2D(address1D, u_NodeAttributeArray2Size));\\n}\\nvec4 getDatau_NodeAttributeArray2(int address1D) {\\n return getDatau_NodeAttributeArray2(float(address1D));\\n}\\nuniform float u_interval;\\nivec2 unpack_float(float packedValue) {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nint packedIntValue = int(packedValue);\\nint v0 = packedIntValue / int(SHIFT_20);\\nreturn ivec2(v0, packedIntValue - (v0 * int(SHIFT_20)));}\\nvec2 calcRepulsive(int i, vec4 currentNode) {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nfloat ax = 0.0;\\nfloat ay = 0.0;\\nfor (int j = 0; j < VERTEX_COUNT; j++) {if (i != j) {vec4 nextNode = getDatau_Data(j);\\nfloat vx = currentNode.x - nextNode.x;\\nfloat vy = currentNode.y - nextNode.y;\\nfloat dist = sqrt((vx * vx) + (vy * vy)) + 0.01;\\nfloat n_dist = (dist + 0.1) * u_coulombDisScale;\\nfloat direx = vx / dist;\\nfloat direy = vy / dist;\\nvec4 attributesi = getDatau_NodeAttributeArray1(i);\\nvec4 attributesj = getDatau_NodeAttributeArray1(j);\\nfloat massi = attributesi.x;\\nfloat nodeStrengthi = attributesi.z;\\nfloat nodeStrengthj = attributesj.z;\\nfloat nodeStrength = (nodeStrengthi + nodeStrengthj) / 2.0;\\nfloat param = (nodeStrength * u_factor) / (n_dist * n_dist);\\nax += direx * param;\\nay += direy * param;}}\\nreturn vec2(ax, ay);}\\nvec2 calcGravity(int i, vec4 currentNode, vec4 attributes2) {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nfloat vx = currentNode.x - attributes2.x;\\nfloat vy = currentNode.y - attributes2.y;\\nfloat ax = vx * attributes2.z;\\nfloat ay = vy * attributes2.z;\\nreturn vec2(ax, ay);}\\nvec2 calcAttractive(int i, vec4 currentNode, vec4 attributes1) {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nfloat mass = attributes1.x;\\nfloat ax = 0.0;\\nfloat ay = 0.0;\\nivec2 compressed = unpack_float(currentNode.z);\\nint length = compressed.x;\\nint arr_offset = compressed.y;\\nvec4 node_buffer;\\nfor (int p = 0; p < MAX_EDGE_PER_VERTEX; p++) {if (p >= length) {break;}\\nint arr_idx = arr_offset + (4 * p);\\nint buf_offset = arr_idx - ((arr_idx / 4) * 4);\\nif ((p == 0) || (buf_offset == 0)) {node_buffer = getDatau_Data(int(arr_idx / 4));}\\nfloat float_j = node_buffer.x;\\nvec4 nextNode = getDatau_Data(int(float_j));\\nfloat vx = nextNode.x - currentNode.x;\\nfloat vy = nextNode.y - currentNode.y;\\nfloat dist = sqrt((vx * vx) + (vy * vy)) + 0.01;\\nfloat direx = vx / dist;\\nfloat direy = vy / dist;\\nfloat edgeLength = node_buffer.y;\\nfloat edgeStrength = node_buffer.z;\\nfloat diff = edgeLength - dist;\\nfloat param = (diff * edgeStrength) / mass;\\nax -= direx * param;\\nay -= direy * param;}\\nreturn vec2(ax, ay);}\\nvoid main() {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nint i = globalInvocationID.x;\\nvec4 currentNode = getDatau_Data(i);\\nvec4 movement = getDatau_AveMovement(0.0);\\nfloat ax = 0.0;\\nfloat ay = 0.0;\\nif ((i >= VERTEX_COUNT) || (movement.x < u_minMovement)) {gl_FragColor = vec4(currentNode);\\nreturn ;}\\nvec4 nodeAttributes1 = getDatau_NodeAttributeArray1(i);\\nvec4 nodeAttributes2 = getDatau_NodeAttributeArray2(i);\\nvec2 repulsive = calcRepulsive(i, currentNode);\\nax += repulsive.x;\\nay += repulsive.y;\\nvec2 attractive = calcAttractive(i, currentNode, nodeAttributes1);\\nax += attractive.x;\\nay += attractive.y;\\nvec2 gravity = calcGravity(i, currentNode, nodeAttributes2);\\nax -= gravity.x;\\nay -= gravity.y;\\nfloat param = u_interval * u_damping;\\nfloat vx = ax * param;\\nfloat vy = ay * param;\\nfloat vlength = sqrt((vx * vx) + (vy * vy)) + 0.0001;\\nif (vlength > u_maxSpeed) {float param2 = u_maxSpeed / vlength;\\nvx = param2 * vx;\\nvy = param2 * vy;}\\nif ((nodeAttributes1.w != 0.0) && (nodeAttributes2.w != 0.0)) {gl_FragColor = vec4(vec4(nodeAttributes1.w, nodeAttributes2.w, currentNode.z, 0.0));}else {float distx = vx * u_interval;\\nfloat disty = vy * u_interval;\\nfloat distLength = sqrt((distx * distx) + (disty * disty));\\ngl_FragColor = vec4(vec4(currentNode.x + distx, currentNode.y + disty, currentNode.z, distLength));}if (gWebGPUDebug) {\\n gl_FragColor = gWebGPUDebugOutput;\\n}}\\n"},"context":{"name":"","dispatch":[1,1,1],"threadGroupSize":[1,1,1],"maxIteration":1,"defines":[{"name":"MAX_EDGE_PER_VERTEX","type":"Float","runtime":true},{"name":"VERTEX_COUNT","type":"Float","runtime":true},{"name":"SHIFT_20","type":"Float","value":1048576,"runtime":false}],"uniforms":[{"name":"u_Data","type":"vec4[]","storageClass":"StorageBuffer","readonly":false,"writeonly":false,"size":[1,1]},{"name":"u_damping","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_maxSpeed","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_minMovement","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_AveMovement","type":"vec4[]","storageClass":"StorageBuffer","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_coulombDisScale","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_factor","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_NodeAttributeArray1","type":"vec4[]","storageClass":"StorageBuffer","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_NodeAttributeArray2","type":"vec4[]","storageClass":"StorageBuffer","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_interval","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]}],"globalDeclarations":[],"output":{"name":"u_Data","size":[1,1],"length":1},"needPingpong":true}}',e.aveMovementCode="\nconst VERTEX_COUNT;\n@numthreads(1, 1, 1)\nclass CalcAveMovement {\n @in\n u_Data: vec4[];\n @in\n u_iter: float;\n @in @out\n u_AveMovement: vec4[];\n @main\n compute() {\n let movement = 0;\n for (let j: int = 0; j < VERTEX_COUNT; j++) {\n const vertex = this.u_Data[j];\n movement += vertex[3];\n }\n movement = movement / float(VERTEX_COUNT);\n this.u_AveMovement[0] = [movement, 0, 0, 0];\n }\n}\n",e.aveMovementBundle='{"shaders":{"WGSL":"","GLSL450":"","GLSL100":"\\n\\nfloat epsilon = 0.00001;\\nvec2 addrTranslation_1Dto2D(float address1D, vec2 texSize) {\\n vec2 conv_const = vec2(1.0 / texSize.x, 1.0 / (texSize.x * texSize.y));\\n vec2 normAddr2D = float(address1D) * conv_const;\\n return vec2(fract(normAddr2D.x + epsilon), normAddr2D.y);\\n}\\n\\nvoid barrier() {}\\n \\n\\nuniform vec2 u_OutputTextureSize;\\nuniform int u_OutputTexelCount;\\nvarying vec2 v_TexCoord;\\n\\nbool gWebGPUDebug = false;\\nvec4 gWebGPUDebugOutput = vec4(0.0);\\n\\n#define VERTEX_COUNT __DefineValuePlaceholder__VERTEX_COUNT\\n\\nuniform sampler2D u_Data;\\nuniform vec2 u_DataSize;\\nvec4 getDatau_Data(vec2 address2D) {\\n return vec4(texture2D(u_Data, address2D).rgba);\\n}\\nvec4 getDatau_Data(float address1D) {\\n return getDatau_Data(addrTranslation_1Dto2D(address1D, u_DataSize));\\n}\\nvec4 getDatau_Data(int address1D) {\\n return getDatau_Data(float(address1D));\\n}\\nuniform float u_iter;\\nuniform sampler2D u_AveMovement;\\nuniform vec2 u_AveMovementSize;\\nvec4 getDatau_AveMovement(vec2 address2D) {\\n return vec4(texture2D(u_AveMovement, address2D).rgba);\\n}\\nvec4 getDatau_AveMovement(float address1D) {\\n return getDatau_AveMovement(addrTranslation_1Dto2D(address1D, u_AveMovementSize));\\n}\\nvec4 getDatau_AveMovement(int address1D) {\\n return getDatau_AveMovement(float(address1D));\\n}\\nvoid main() {\\nivec3 workGroupSize = ivec3(1, 1, 1);\\nivec3 numWorkGroups = ivec3(1, 1, 1); \\nint globalInvocationIndex = int(floor(v_TexCoord.x * u_OutputTextureSize.x))\\n + int(floor(v_TexCoord.y * u_OutputTextureSize.y)) * int(u_OutputTextureSize.x);\\nint workGroupIDLength = globalInvocationIndex / (workGroupSize.x * workGroupSize.y * workGroupSize.z);\\nivec3 workGroupID = ivec3(workGroupIDLength / numWorkGroups.y / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.z, workGroupIDLength / numWorkGroups.x / numWorkGroups.y);\\nint localInvocationIDZ = globalInvocationIndex / (workGroupSize.x * workGroupSize.y);\\nint localInvocationIDY = (globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y) / workGroupSize.x;\\nint localInvocationIDX = globalInvocationIndex - localInvocationIDZ * workGroupSize.x * workGroupSize.y - localInvocationIDY * workGroupSize.x;\\nivec3 localInvocationID = ivec3(localInvocationIDX, localInvocationIDY, localInvocationIDZ);\\nivec3 globalInvocationID = workGroupID * workGroupSize + localInvocationID;\\nint localInvocationIndex = localInvocationID.z * workGroupSize.x * workGroupSize.y\\n + localInvocationID.y * workGroupSize.x + localInvocationID.x;\\nfloat movement = 0.0;\\nfor (int j = 0; j < VERTEX_COUNT; j++) {vec4 vertex = getDatau_Data(j);\\nmovement += vertex.w;}\\nmovement = movement / float(VERTEX_COUNT);\\ngl_FragColor = vec4(vec4(movement, 0.0, 0.0, 0.0));if (gWebGPUDebug) {\\n gl_FragColor = gWebGPUDebugOutput;\\n}}\\n"},"context":{"name":"","dispatch":[1,1,1],"threadGroupSize":[1,1,1],"maxIteration":1,"defines":[{"name":"VERTEX_COUNT","type":"Float","runtime":true}],"uniforms":[{"name":"u_Data","type":"vec4[]","storageClass":"StorageBuffer","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_iter","type":"Float","storageClass":"Uniform","readonly":true,"writeonly":false,"size":[1,1]},{"name":"u_AveMovement","type":"vec4[]","storageClass":"StorageBuffer","readonly":false,"writeonly":false,"size":[1,1]}],"globalDeclarations":[],"output":{"name":"u_AveMovement","size":[1,1],"length":1},"needPingpong":true}}'},989:function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!==typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0}),e.GridLayout=void 0;var o=n(5027),i=function(t){function e(e){var n=t.call(this)||this;return n.begin=[0,0],n.preventOverlap=!0,n.preventOverlapPadding=10,n.condense=!1,n.sortBy="degree",n.nodes=[],n.edges=[],n.width=300,n.height=300,n.row=0,n.col=0,n.cellWidth=0,n.cellHeight=0,n.cellUsed={},n.id2manPos={},n.onLayoutEnd=function(){},n.updateCfg(e),n}return r(e,t),e.prototype.getDefaultCfg=function(){return{begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30}},e.prototype.execute=function(){var t=this,e=t.nodes,n=t.edges,r=t.begin,i=e.length;if(0===i)return t.onLayoutEnd&&t.onLayoutEnd(),{nodes:e,edges:n};if(1===i)return e[0].x=r[0],e[0].y=r[1],t.onLayoutEnd&&t.onLayoutEnd(),{nodes:e,edges:n};var a=t.sortBy,s=t.width,u=t.height,c=t.condense,l=t.preventOverlapPadding,d=t.preventOverlap,f=t.nodeSpacing,h=t.nodeSize,p=[];e.forEach((function(t){p.push(t)}));var g={};if(p.forEach((function(t,e){g[t.id]=e})),("degree"===a||!(0,o.isString)(a)||void 0===p[0][a])&&(a="degree",(0,o.isNaN)(e[0].degree))){var v=(0,o.getDegree)(p.length,g,n);p.forEach((function(t,e){t.degree=v[e].all}))}p.sort((function(t,e){return e[a]-t[a]})),s||"undefined"===typeof window||(s=window.innerWidth),u||"undefined"===typeof window||(u=window.innerHeight);var m=t.rows,y=null!=t.cols?t.cols:t.columns;if(t.cells=i,null!=m&&null!=y?(t.rows=m,t.cols=y):null!=m&&null==y?(t.rows=m,t.cols=Math.ceil(t.cells/t.rows)):null==m&&null!=y?(t.cols=y,t.rows=Math.ceil(t.cells/t.cols)):(t.splits=Math.sqrt(t.cells*t.height/t.width),t.rows=Math.round(t.splits),t.cols=Math.round(t.width/t.height*t.splits)),t.rows=Math.max(t.rows,1),t.cols=Math.max(t.cols,1),t.cols*t.rows>t.cells)((x=t.small())-1)*(b=t.large())>=t.cells?t.small(x-1):(b-1)*x>=t.cells&&t.large(b-1);else for(;t.cols*t.rows=t.cells?t.large(b+1):t.small(x+1)}if(t.cellWidth=s/t.cols,t.cellHeight=u/t.rows,c&&(t.cellWidth=0,t.cellHeight=0),d||f){var w=(0,o.getFuncByUnknownType)(10,f),E=(0,o.getFuncByUnknownType)(30,h,!1);p.forEach((function(e){e.x&&e.y||(e.x=0,e.y=0);var n,r,i=E(e)||30;(0,o.isArray)(i)?(n=i[0],r=i[1]):(n=i,r=i);var a=void 0!==w?w(e):l,s=n+a,u=r+a;t.cellWidth=Math.max(t.cellWidth,s),t.cellHeight=Math.max(t.cellHeight,u)}))}t.cellUsed={},t.row=0,t.col=0,t.id2manPos={};for(var S=0;S=e&&(t.col=0,t.row++)},e.prototype.getPos=function(t){var e,n,r=this,o=r.begin,i=r.cellWidth,a=r.cellHeight,s=r.id2manPos[t.id];if(s)e=s.col*i+i/2+o[0],n=s.row*a+a/2+o[1];else{for(;r.used(r.row,r.col);)r.moveToNextCell();e=r.col*i+i/2+o[0],n=r.row*a+a/2+o[1],r.use(r.row,r.col),r.moveToNextCell()}t.x=e,t.y=n},e.prototype.getType=function(){return"grid"},e}(n(5716).Base);e.GridLayout=i},1569:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.ERLayout=e.ForceAtlas2Layout=e.ComboCombinedLayout=e.ComboForceLayout=e.GForceGPULayout=e.FruchtermanGPULayout=e.FruchtermanLayout=e.MDSLayout=e.ConcentricLayout=e.RadialLayout=e.DagreCompoundLayout=e.DagreLayout=e.CircularLayout=e.ForceLayout=e.Force2Layout=e.GForceLayout=e.RandomLayout=e.GridLayout=e.Layouts=e.Layout=void 0;var i=n(989);Object.defineProperty(e,"GridLayout",{enumerable:!0,get:function(){return i.GridLayout}});var a=n(6254);Object.defineProperty(e,"RandomLayout",{enumerable:!0,get:function(){return a.RandomLayout}});var s=n(8765);Object.defineProperty(e,"GForceLayout",{enumerable:!0,get:function(){return s.GForceLayout}});var u=n(6593);Object.defineProperty(e,"Force2Layout",{enumerable:!0,get:function(){return u.Force2Layout}});var c=n(497);Object.defineProperty(e,"ForceLayout",{enumerable:!0,get:function(){return c.ForceLayout}});var l=n(2852);Object.defineProperty(e,"CircularLayout",{enumerable:!0,get:function(){return l.CircularLayout}});var d=n(6452);Object.defineProperty(e,"DagreLayout",{enumerable:!0,get:function(){return d.DagreLayout}});var f=n(6833);Object.defineProperty(e,"DagreCompoundLayout",{enumerable:!0,get:function(){return f.DagreCompoundLayout}});var h=n(2689);Object.defineProperty(e,"RadialLayout",{enumerable:!0,get:function(){return h.RadialLayout}});var p=n(1881);Object.defineProperty(e,"ConcentricLayout",{enumerable:!0,get:function(){return p.ConcentricLayout}});var g=n(1887);Object.defineProperty(e,"MDSLayout",{enumerable:!0,get:function(){return g.MDSLayout}});var v=n(9136);Object.defineProperty(e,"FruchtermanLayout",{enumerable:!0,get:function(){return v.FruchtermanLayout}});var m=n(7649);Object.defineProperty(e,"FruchtermanGPULayout",{enumerable:!0,get:function(){return m.FruchtermanGPULayout}});var y=n(4518);Object.defineProperty(e,"GForceGPULayout",{enumerable:!0,get:function(){return y.GForceGPULayout}});var b=n(1420);Object.defineProperty(e,"ComboForceLayout",{enumerable:!0,get:function(){return b.ComboForceLayout}});var x=n(1928);Object.defineProperty(e,"ComboCombinedLayout",{enumerable:!0,get:function(){return x.ComboCombinedLayout}});var w=n(3218);Object.defineProperty(e,"ForceAtlas2Layout",{enumerable:!0,get:function(){return w.ForceAtlas2Layout}});var E=n(1213);Object.defineProperty(e,"ERLayout",{enumerable:!0,get:function(){return E.ERLayout}});var S=n(5571);Object.defineProperty(e,"Layout",{enumerable:!0,get:function(){return S.Layout}}),Object.defineProperty(e,"Layouts",{enumerable:!0,get:function(){return S.Layouts}}),o(n(9696),e)},5571:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Layouts=e.Layout=void 0;var r=n(6036),o=n(989),i=n(6254),a=n(6593),s=n(8765),u=n(497),c=n(2852),l=n(6452),d=n(2689),f=n(1881),h=n(1887),p=n(9136),g=n(7649),v=n(4518),m=n(1420),y=n(1928),b=n(3218),x=n(1213),w=n(6833),E=n(5027),S=function(){function t(t){var e=(0,r.getLayoutByName)(t.type);this.layoutInstance=new e(t)}return t.prototype.layout=function(t){return this.layoutInstance.layout(t)},t.prototype.updateCfg=function(t){this.layoutInstance.updateCfg(t)},t.prototype.init=function(t){this.correctLayers(t.nodes),this.layoutInstance.init(t)},t.prototype.correctLayers=function(t){if(null===t||void 0===t?void 0:t.length){var e=1/0,n=[];if(t.forEach((function(t){(0,E.isString)(t.layer)&&(t.layer=parseInt(t.layer,10)),void 0===t.layer||isNaN(t.layer)||(n.push(t),t.layer{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(8041),o=function(){function t(t){this.distances=t.distances,this.dimension=t.dimension||2,this.linkDistance=t.linkDistance}return t.prototype.layout=function(){var t=this,e=t.dimension,n=t.distances,o=t.linkDistance;try{var i=r.Matrix.mul(r.Matrix.pow(n,2),-.5),a=i.mean("row"),s=i.mean("column"),u=i.mean();i.add(u).subRowVector(a).subColumnVector(s);var c=new r.SingularValueDecomposition(i),l=r.Matrix.sqrt(c.diagonalMatrix).diagonal();return c.leftSingularVectors.toJSON().map((function(t){return r.Matrix.mul([t],[l]).toJSON()[0].splice(0,e)}))}catch(g){for(var d=[],f=0;fr[0]?r[0]:v-r[0],b=m-r[1]>r[1]?r[1]:m-r[1];0===y&&(y=v/2),0===b&&(b=m/2);var x=b>y?y:b,w=Math.max.apply(Math,g),E=[];g.forEach((function(e,n){t.unitRadius||(t.unitRadius=x/w),E[n]=e*t.unitRadius})),t.radii=E;var S=t.eIdealDisMatrix();t.eIdealDistances=S;var M=function(t){for(var e=t.length,n=t[0].length,r=[],o=0;oC[1]?C[0]:C[1])+I(t)}:function(t){return C+I(t)}:function(t){return t.size?(0,i.isArray)(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])+I(t):(0,i.isObject)(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)+I(t):t.size+I(t):10+I(t)};var N={nodes:e,nodeSizeFunc:_,adjMatrix:f,positions:k,radii:E,height:m,width:v,strictRadial:O,focusID:d,iterations:t.maxPreventOverlapIteration||200,k:k.length/4.5},P=new u.default(N);k=P.layout()}return k.forEach((function(t,n){e[n].x=t[0]+r[0],e[n].y=t[1]+r[1]})),t.onLayoutEnd&&t.onLayoutEnd(),{nodes:e,edges:n}}t.onLayoutEnd&&t.onLayoutEnd()},e.prototype.run=function(){for(var t=this,e=t.maxIteration,n=t.positions||[],r=t.weights||[],o=t.eIdealDistances||[],i=t.radii||[],a=0;a<=e;a++){var s=a/e;t.oneIteration(s,n,i,o,r)}},e.prototype.oneIteration=function(t,e,n,r,o){var i=1-t,a=this.focusIndex;e.forEach((function(s,u){var l=c(s,[0,0]),d=0===l?0:1/l;if(u!==a){var f=0,h=0,p=0;e.forEach((function(t,e){if(u!==e){var n=c(s,t),i=0===n?0:1/n,a=r[e][u];p+=o[u][e],f+=o[u][e]*(t[0]+a*(s[0]-t[0])*i),h+=o[u][e]*(t[1]+a*(s[1]-t[1])*i)}}));var g=0===n[u]?0:1/n[u];p*=i,p+=t*g*g,f*=i,f+=t*g*s[0]*d,s[0]=f/p,h*=i,h+=t*g*s[1]*d,s[1]=h/p}}))},e.prototype.eIdealDisMatrix=function(){var t=this,e=t.nodes;if(!e)return[];var n=t.distances,r=t.linkDistance,o=t.radii||[],a=t.unitRadius||50,s=[];return n&&n.forEach((function(n,u){var c=[];n.forEach((function(n,s){if(u===s)c.push(0);else if(o[u]===o[s])if("data"===t.sortBy)c.push(n*(Math.abs(u-s)*t.sortStrength)/(o[u]/a));else if(t.sortBy){var l=e[u][t.sortBy]||0,d=e[s][t.sortBy]||0;(0,i.isString)(l)&&(l=l.charCodeAt(0)),(0,i.isString)(d)&&(d=d.charCodeAt(0)),c.push(n*(Math.abs(l-d)*t.sortStrength)/(o[u]/a))}else c.push(n*r/(o[u]/a));else{var f=(r+a)/2;c.push(n*f)}})),s.push(c)})),s},e.prototype.handleInfinity=function(t,e,n){for(var r=t.length,o=0;on?t[e][r]:n);return n},e.prototype.getType=function(){return"radial"},e}(a.Base);e.RadialLayout=l},1625:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.disp=[],this.positions=t.positions,this.adjMatrix=t.adjMatrix,this.focusID=t.focusID,this.radii=t.radii,this.iterations=t.iterations||10,this.height=t.height||10,this.width=t.width||10,this.speed=t.speed||100,this.gravity=t.gravity||10,this.nodeSizeFunc=t.nodeSizeFunc,this.k=t.k||5,this.strictRadial=t.strictRadial,this.nodes=t.nodes}return t.prototype.layout=function(){var t=this,e=t.positions,n=[],r=t.iterations,o=t.width/10;t.maxDisplace=o,t.disp=n;for(var i=0;iu?1:-1;c=.01*f,l=.01*f}if(dMath.PI/2&&(l-=Math.PI/2,s*=-1,u*=-1);var d=Math.cos(l)*c;t.x=s*d,t.y=u*d}));var s=t.radii;e.forEach((function(t,u){if(u!==i){var c=Math.sqrt(n[u].x*n[u].x+n[u].y*n[u].y);if(c>0&&u!==i){var l=Math.min(a*(r/800),c);if(t[0]+=n[u].x/c*l,t[1]+=n[u].y/c*l,o){var d=t[0]-e[i][0],f=t[1]-e[i][1],h=Math.sqrt(d*d+f*f);d=d/h*s[u],f=f/h*s[u],t[0]=e[i][0]+d,t[1]=e[i][1]+f}}}}))},t}();e.default=n},6254:function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!==typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0}),e.RandomLayout=void 0;var o=function(t){function e(e){var n=t.call(this)||this;return n.center=[0,0],n.width=300,n.height=300,n.nodes=[],n.edges=[],n.onLayoutEnd=function(){},n.updateCfg(e),n}return r(e,t),e.prototype.getDefaultCfg=function(){return{center:[0,0],width:300,height:300}},e.prototype.execute=function(){var t=this,e=t.nodes,n=t.center;return t.width||"undefined"===typeof window||(t.width=window.innerWidth),t.height||"undefined"===typeof window||(t.height=window.innerHeight),e&&e.forEach((function(e){e.x=.9*(Math.random()-.5)*t.width+n[0],e.y=.9*(Math.random()-.5)*t.height+n[1]})),t.onLayoutEnd&&t.onLayoutEnd(),{nodes:e,edges:this.edges}},e.prototype.getType=function(){return"random"},e}(n(5716).Base);e.RandomLayout=o},9696:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},6036:function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!==typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0}),e.getLayoutByName=e.unRegisterLayout=e.registerLayout=void 0;var o=n(5716),i=n(5027),a=new Map;e.registerLayout=function(t,e){if(a.get(t)&&console.warn("The layout with the name ".concat(t," exists already, it will be overridden")),(0,i.isObject)(e)){var n=function(t){function n(n){var r,o,i=r=t.call(this)||this,a={},s=Object.assign({},i.getDefaultCfg(),(null===(o=e.getDefaultCfg)||void 0===o?void 0:o.call(e))||{});return Object.assign(a,s,e,n),Object.keys(a).forEach((function(t){var e=a[t];i[t]=e})),r}return r(n,t),n}(o.Base);a.set(t,n)}else a.set(t,e);return a.get(t)};e.unRegisterLayout=function(t){a.has(t)&&a.delete(t)};e.getLayoutByName=function(t){return a.has(t)?a.get(t):null}},1510:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isArray=void 0,e.isArray=Array.isArray},2375:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getFuncByUnknownType=e.getFunc=e.isFunction=void 0;var r=n(5027),o=n(6442);e.isFunction=function(t){return"function"===typeof t};e.getFunc=function(t,e,n){return n||((0,o.isNumber)(t)?function(){return t}:function(){return e})};e.getFuncByUnknownType=function(t,n,i){return void 0===i&&(i=!0),n||0===n?(0,e.isFunction)(n)?n:(0,o.isNumber)(n)?function(){return n}:(0,r.isArray)(n)?function(){if(i){var e=Math.max.apply(Math,n);return isNaN(e)?t:e}return n}:(0,r.isObject)(n)?function(){if(i){var e=Math.max(n.width,n.height);return isNaN(e)?t:e}return[n.width,n.height]}:function(){return t}:function(e){return e.size?(0,r.isArray)(e.size)?e.size[0]>e.size[1]?e.size[0]:e.size[1]:(0,r.isObject)(e.size)?e.size.width>e.size.height?e.size.width:e.size.height:e.size:t}}},7313:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.arrayToTextureData=e.attributesToTextureData=e.buildTextureDataWithTwoEdgeAttr=e.buildTextureData=e.proccessToFunc=void 0;var r=n(5027),o=n(2137);e.proccessToFunc=function(t,e){return t?(0,r.isNumber)(t)?function(){return t}:t:function(){return e||1}};e.buildTextureData=function(t,e){var n=[],r=[],i={},a=0;for(a=0;a{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getCoreNodeAndRelativeLeafNodes=e.getAvgNodePosition=e.getLayoutBBox=e.traverseTreeUp=e.scaleMatrix=e.getAdjMatrix=e.floydWarshall=e.getDegreeMap=e.getDegree=e.getEdgeTerminal=void 0;var r=n(1510),o=n(6442),i=n(7852);e.getEdgeTerminal=function(t,e){var n=t[e];return(0,i.isObject)(n)?n.cell:n};e.getDegree=function(t,n,r){for(var o=[],i=0;ie[r][i]+e[i][o]&&(e[r][o]=e[r][i]+e[i][o]);return e};e.getAdjMatrix=function(t,n){var r=t.nodes,o=t.edges,i=[],a={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){a[t.id]=e;i.push([])})),null===o||void 0===o||o.forEach((function(t){var r=(0,e.getEdgeTerminal)(t,"source"),o=(0,e.getEdgeTerminal)(t,"target"),s=a[r],u=a[o];void 0!==s&&void 0!==u&&(i[s][u]=1,n||(i[u][s]=1))})),i};e.scaleMatrix=function(t,e){var n=[];return t.forEach((function(t){var r=[];t.forEach((function(t){r.push(t*e)})),n.push(r)})),n};var a=function(t,e){if(t&&t.children)for(var n=t.children.length-1;n>=0;n--)if(!a(t.children[n],e))return;return!!e(t)};e.traverseTreeUp=function(t,e){"function"===typeof e&&a(t,e)};e.getLayoutBBox=function(t){var e=1/0,n=1/0,i=-1/0,a=-1/0;return t.forEach((function(t){var s=t.size;(0,r.isArray)(s)?1===s.length&&(s=[s[0],s[0]]):(0,o.isNumber)(s)?s=[s,s]:(void 0===s||isNaN(s))&&(s=[30,30]);var u=[s[0]/2,s[1]/2],c=t.x-u[0],l=t.x+u[0],d=t.y-u[1],f=t.y+u[1];e>c&&(e=c),n>d&&(n=d),i{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toNumber=e.isNaN=e.isNumber=void 0;e.isNumber=function(t){return"number"===typeof t};e.isNaN=function(t){return Number.isNaN(Number(t))};e.toNumber=function(t){var n=parseFloat(t);return(0,e.isNaN)(n)?t:n}},7852:function(t,e){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.camelize=e.isString=void 0;e.isString=function(t){return"string"===typeof t};var n=/-(\w)/g;e.camelize=function(t){var e=Object.create(null);return function(n){return e[n]||(e[n]=t(n))}}((function(t){return t.replace(n,(function(t,e){return e?e.toUpperCase():""}))}))},3905:(t,e,n)=>{"use strict";function r(t){return[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16)]}function o(t){var e=Math.round(t).toString(16);return 1===e.length?"0".concat(e):e}function i(t){return"#".concat(o(t[0])).concat(o(t[1])).concat(o(t[2]))}n.r(e),n.d(e,{Cache:()=>Wn,angleTo:()=>S,arcToCubic:()=>H,assign:()=>hn,augment:()=>pn,clamp:()=>xe,clearAnimationFrame:()=>dn,clone:()=>vn,clonePath:()=>J,contains:()=>St,createDOM:()=>Jn,debounce:()=>mn,deepMix:()=>xn,difference:()=>kt,direction:()=>E,distanceSquareRoot:()=>et,each:()=>It,endsWith:()=>ue,equalizeSegments:()=>wt,every:()=>ce,extend:()=>wn,filter:()=>Mt,find:()=>Rt,findIndex:()=>Ft,firstValue:()=>Bt,fixedBase:()=>we,flatten:()=>zt,flattenDeep:()=>Ut,forIn:()=>Be,get:()=>Tn,getDrawDirection:()=>vt,getPathArea:()=>gt,getPathBBox:()=>dt,getPathBBoxTotalLength:()=>ht,getPointAtLength:()=>mt,getRange:()=>Vt,getRotatedCurve:()=>pt,getTotalLength:()=>ft,getType:()=>$e,getWrapBehavior:()=>ge,gradient:()=>d,group:()=>pe,groupBy:()=>fe,groupToMap:()=>he,has:()=>ze,hasKey:()=>Ge,hasValue:()=>We,head:()=>ie,identity:()=>Gn,includes:()=>St,indexOf:()=>En,isArguments:()=>Qe,isArray:()=>Ct,isArrayLike:()=>Et,isBoolean:()=>Je,isDate:()=>tn,isDecimal:()=>Se,isElement:()=>cn,isEmpty:()=>Mn,isEqual:()=>_n,isEqualWith:()=>An,isError:()=>en,isEven:()=>Me,isFinite:()=>nn,isFunction:()=>_t,isInteger:()=>ke,isMatch:()=>Nt,isNegative:()=>_e,isNil:()=>At,isNull:()=>rn,isNumber:()=>Ee,isNumberEqual:()=>Ce,isObject:()=>Ot,isObjectLike:()=>Pt,isOdd:()=>Oe,isPlainObject:()=>jt,isPointInPolygon:()=>Hn,isPointInStroke:()=>bt,isPolygonsIntersect:()=>Qn,isPositive:()=>Ie,isPrototype:()=>an,isRegExp:()=>sn,isString:()=>te,isType:()=>Dt,isUndefined:()=>un,keys:()=>Tt,last:()=>ae,lowerCase:()=>Ve,lowerFirst:()=>Xe,map:()=>Cn,mapValues:()=>In,max:()=>Wt,maxBy:()=>Te,memoize:()=>s,min:()=>Yt,minBy:()=>Ne,mix:()=>hn,mod:()=>Pe,modifyCSS:()=>tr,noop:()=>zn,normalizePath:()=>V,number2color:()=>ye,omit:()=>Dn,parseRadius:()=>be,path2Absolute:()=>W,path2Array:()=>Q,path2Curve:()=>$,path2String:()=>k,pick:()=>Ln,pull:()=>Zt,pullAt:()=>$t,reduce:()=>Qt,remove:()=>Jt,requestAnimationFrame:()=>ln,reverseCurve:()=>tt,rgb2arr:()=>r,set:()=>Nn,size:()=>Un,some:()=>le,sortBy:()=>ee,startsWith:()=>se,substitute:()=>He,throttle:()=>jn,toArray:()=>Rn,toCSSGradient:()=>g,toDegree:()=>De,toInteger:()=>je,toRGB:()=>c,toRadian:()=>Fe,toString:()=>Ye,transform:()=>x,union:()=>re,uniq:()=>ne,uniqueId:()=>Bn,upperCase:()=>qe,upperFirst:()=>Ze,values:()=>Ue,valuesOfKey:()=>oe,vertical:()=>M,wrapBehavior:()=>ve});var a=new Map;function s(t,e,n){void 0===n&&(n=128);return function(){for(var r=[],o=0;oo&&(r=n,a(1),++e),n[t]=i}function a(t){e=0,n=Object.create(null),t||(r=Object.create(null))}return a(),{clear:a,has:function(t){return void 0!==n[t]||void 0!==r[t]},get:function(t){var e=n[t];return void 0!==e?e:void 0!==(e=r[t])?(i(t,e),e):void 0},set:function(t,e){void 0!==n[t]?n[t]=e:i(t,e)}}}(n));var s=a.get(t);if(s.has(i))return s.get(i);var u=t.apply(this,r);return s.set(i,u),u}}var u=/rgba?\(([\s.,0-9]+)\)/;var c=s((function(t){if("#"===t[0]&&7===t.length)return t;var e=function(){var t=document.getElementById("antv-web-colour-picker");return t||((t=document.createElement("i")).id="antv-web-colour-picker",t.title="Web Colour Picker",t.style.display="none",document.body.appendChild(t),t)}();e.style.color=t;var n=document.defaultView.getComputedStyle(e,"").getPropertyValue("color");return n=i(u.exec(n)[1].split(/\s*,\s*/).map((function(t){return Number(t)})))}),(function(t){return t}),256);function l(t,e,n,r){return t[r]+(e[r]-t[r])*n}function d(t){var e=("string"===typeof t?t.split("-"):t).map((function(t){return r(-1===t.indexOf("#")?c(t):t)}));return function(t){return function(t,e){var n=isNaN(Number(e))||e<0?0:e>1?1:Number(e),r=t.length-1,o=Math.floor(r*n),a=r*n-o,s=t[o],u=o===r?s:t[o+1];return i([l(s,u,a,0),l(s,u,a,1),l(s,u,a,2)])}(e,t)}}var f=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,h=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,p=/[\d.]+:(#[^\s]+|[^)]+\))/gi;function g(t){if(/^[r,R,L,l]{1}[\s]*\(/.test(t)){var e,n=void 0;if("l"===t[0]){var r=+(o=f.exec(t))[1]+90;n=o[2],e="linear-gradient(".concat(r,"deg, ")}else if("r"===t[0]){var o;e="radial-gradient(",n=(o=h.exec(t))[4]}var i=n.match(p);return i.forEach((function(t,n){var r=t.split(":");e+="".concat(r[1]," ").concat(100*Number(r[0]),"%"),n!==i.length-1&&(e+=", ")})),e+=")"}return t}var v=n(5367);function m(t,e,n){var r=[0,0,0,0,0,0,0,0,0];return v.fromTranslation(r,n),v.multiply(t,r,e)}function y(t,e,n){var r=[0,0,0,0,0,0,0,0,0];return v.fromRotation(r,n),v.multiply(t,r,e)}function b(t,e,n){var r=[0,0,0,0,0,0,0,0,0];return v.fromScaling(r,n),v.multiply(t,r,e)}function x(t,e){for(var n,r,o,i=t?[].concat(t):[1,0,0,0,1,0,0,0,1],a=0,s=e.length;a=0;return n?o?2*Math.PI-r:r:o?r:2*Math.PI-r}function M(t,e,n){return n?(t[0]=e[1],t[1]=-1*e[0]):(t[0]=-1*e[1],t[1]=e[0]),t}function k(t,e){return void 0===e&&(e="off"),function(t,e){if("off"===e)return[].concat(t);var n="number"===typeof e&&e>=1?Math.pow(10,e):1;return t.map((function(t){var r=t.slice(1).map(Number).map((function(t){return e?Math.round(t*n)/n:Math.round(t)}));return[t[0]].concat(r)}))}(t,e).map((function(t){return t[0]+t.slice(1).join(" ")})).join("")}var _=function(){return _=Object.assign||function(t){for(var e,n=1,r=arguments.length;n7){t[n].shift();for(var r=t[n],o=n;r.length;)e[n]="A",t.splice(o+=1,0,["C"].concat(r.splice(0,6)));t.splice(n,1)}}var I={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function T(t){return Array.isArray(t)&&t.every((function(t){var e=t[0].toLowerCase();return I[e]===t.length-1&&"achlmqstvz".includes(e)}))}function N(t){return T(t)&&t.every((function(t){var e=t[0];return e===e.toUpperCase()}))}function P(t){return N(t)&&t.every((function(t){var e=t[0];return"ACLMQZ".includes(e)}))}function L(t){for(var e=t.pathValue[t.segmentStart],n=e.toLowerCase(),r=t.data;r.length>=I[n]&&("m"===n&&r.length>2?(t.segments.push([e].concat(r.splice(0,2))),n="l",e="m"===e?"l":"L"):t.segments.push([e].concat(r.splice(0,I[n]))),I[n]););}function D(t){var e=t.index,n=t.pathValue,r=n.charCodeAt(e);return 48===r?(t.param=0,void(t.index+=1)):49===r?(t.param=1,void(t.index+=1)):void(t.err='[path-util]: invalid Arc flag "'.concat(n[e],'", expecting 0 or 1 at index ').concat(e))}function j(t){return t>=48&&t<=57||43===t||45===t||46===t}function R(t){return t>=48&&t<=57}function F(t){var e,n=t.max,r=t.pathValue,o=t.index,i=o,a=!1,s=!1,u=!1,c=!1;if(i>=n)t.err="[path-util]: Invalid path value at index ".concat(i,', "pathValue" is missing param');else if(43!==(e=r.charCodeAt(i))&&45!==e||(i+=1,e=r.charCodeAt(i)),R(e)||46===e){if(46!==e){if(a=48===e,i+=1,e=r.charCodeAt(i),a&&i=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e));)t.index+=1}function z(t){var e=t.max,n=t.pathValue,r=t.index,o=n.charCodeAt(r),i=I[n[r].toLowerCase()];if(t.segmentStart=r,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(o))if(t.index+=1,B(t),t.data=[],i){for(;;){for(var a=i;a>0;a-=1){if(97!==(32|o)||3!==a&&4!==a?F(t):D(t),t.err.length)return;t.data.push(t.param),B(t),t.index=t.max)break;if(!j(n.charCodeAt(t.index)))break}L(t)}else L(t);else t.err='[path-util]: Invalid path value "'.concat(n[r],'" is not a path command')}var G=function(t){this.pathValue=t,this.segments=[],this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""};function U(t){if(T(t))return[].concat(t);var e=new G(t);for(B(e);e.index1&&(m*=_=Math.sqrt(_),y*=_);var A=m*m,C=y*y,O=(i===a?-1:1)*Math.sqrt(Math.abs((A*C-A*k*k-C*M*M)/(A*k*k+C*M*M)));h=O*m*k/y+(g+b)/2,p=O*-y*M/m+(v+x)/2,d=Math.asin(((v-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),f=Math.asin(((x-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),d=gf&&(d-=2*Math.PI),!a&&f>d&&(f-=2*Math.PI)}var I=f-d;if(Math.abs(I)>w){var T=f,N=b,P=x;f=d+w*(a&&f>d?1:-1),S=H(b=h+m*Math.cos(f),x=p+y*Math.sin(f),m,y,o,0,a,N,P,[f,T,h,p])}I=f-d;var L=Math.cos(d),D=Math.sin(d),j=Math.cos(f),R=Math.sin(f),F=Math.tan(I/4),B=4/3*m*F,z=4/3*y*F,G=[g,v],U=[g+B*D,v-z*L],W=[b+B*R,x-z*j],Y=[b,x];if(U[0]=2*G[0]-U[0],U[1]=2*G[1]-U[1],c)return U.concat(W,Y,S);for(var V=[],q=0,Z=(S=U.concat(W,Y,S)).length;q=i)a={x:n,y:r};else{var s=q([t,e],[n,r],o/i);a={x:s[0],y:s[1]}}return{length:i,point:a,min:{x:Math.min(t,n),y:Math.min(e,r)},max:{x:Math.max(t,n),y:Math.max(e,r)}}}function rt(t,e){var n=t.x,r=t.y,o=e.x,i=e.y,a=n*o+r*i,s=Math.sqrt((Math.pow(n,2)+Math.pow(r,2))*(Math.pow(o,2)+Math.pow(i,2)));return(n*i-r*o<0?-1:1)*Math.acos(a/s)}function ot(t,e,n,r,o,i,a,s,u,c){var l=Math.abs,d=Math.sin,f=Math.cos,h=Math.sqrt,p=Math.PI,g=l(n),v=l(r),m=(o%360+360)%360*(p/180);if(t===s&&e===u)return{x:t,y:e};if(0===g||0===v)return nt(t,e,s,u,c).point;var y=(t-s)/2,b=(e-u)/2,x={x:f(m)*y+d(m)*b,y:-d(m)*y+f(m)*b},w=Math.pow(x.x,2)/Math.pow(g,2)+Math.pow(x.y,2)/Math.pow(v,2);w>1&&(g*=h(w),v*=h(w));var E=(Math.pow(g,2)*Math.pow(v,2)-Math.pow(g,2)*Math.pow(x.y,2)-Math.pow(v,2)*Math.pow(x.x,2))/(Math.pow(g,2)*Math.pow(x.y,2)+Math.pow(v,2)*Math.pow(x.x,2)),S=(i!==a?1:-1)*h(E=E<0?0:E),M=S*(g*x.y/v),k=S*(-v*x.x/g),_=f(m)*M-d(m)*k+(t+s)/2,A=d(m)*M+f(m)*k+(e+u)/2,C={x:(x.x-M)/g,y:(x.y-k)/v},O=rt({x:1,y:0},C),I=rt(C,{x:(-x.x-M)/g,y:(-x.y-k)/v});!a&&I>0?I-=2*p:a&&I<0&&(I+=2*p);var T=O+(I%=2*p)*c,N=g*f(T),P=v*d(T);return{x:f(m)*N-d(m)*P+_,y:d(m)*N+f(m)*P+A}}function it(t,e,n,r,o,i,a,s,u,c,l){var d,f=l.bbox,h=void 0===f||f,p=l.length,g=void 0===p||p,v=l.sampleSize,m=void 0===v?30:v,y="number"===typeof c,b=t,x=e,w=0,E=[b,x,w],S=[b,x],M={x:0,y:0},k=[{x:b,y:x}];y&&c<=0&&(M={x:b,y:x});for(var _=0;_<=m;_+=1){if(b=(d=ot(t,e,n,r,o,i,a,s,u,_/m)).x,x=d.y,h&&k.push({x:b,y:x}),g&&(w+=et(S,[b,x])),S=[b,x],y&&w>=c&&c>E[2]){var A=(w-c)/(w-E[2]);M={x:S[0]*(1-A)+E[0]*A,y:S[1]*(1-A)+E[1]*A}}E=[b,x,w]}return y&&c>=w&&(M={x:s,y:u}),{length:w,point:M,min:{x:Math.min.apply(null,k.map((function(t){return t.x}))),y:Math.min.apply(null,k.map((function(t){return t.y})))},max:{x:Math.max.apply(null,k.map((function(t){return t.x}))),y:Math.max.apply(null,k.map((function(t){return t.y})))}}}function at(t,e,n,r,o,i,a,s,u){var c=1-u;return{x:Math.pow(c,3)*t+3*Math.pow(c,2)*u*n+3*c*Math.pow(u,2)*o+Math.pow(u,3)*a,y:Math.pow(c,3)*e+3*Math.pow(c,2)*u*r+3*c*Math.pow(u,2)*i+Math.pow(u,3)*s}}function st(t,e,n,r,o,i,a,s,u,c){var l,d=c.bbox,f=void 0===d||d,h=c.length,p=void 0===h||h,g=c.sampleSize,v=void 0===g?10:g,m="number"===typeof u,y=t,b=e,x=0,w=[y,b,x],E=[y,b],S={x:0,y:0},M=[{x:y,y:b}];m&&u<=0&&(S={x:y,y:b});for(var k=0;k<=v;k+=1){if(y=(l=at(t,e,n,r,o,i,a,s,k/v)).x,b=l.y,f&&M.push({x:y,y:b}),p&&(x+=et(E,[y,b])),E=[y,b],m&&x>=u&&u>w[2]){var _=(x-u)/(x-w[2]);S={x:E[0]*(1-_)+w[0]*_,y:E[1]*(1-_)+w[1]*_}}w=[y,b,x]}return m&&u>=x&&(S={x:a,y:s}),{length:x,point:S,min:{x:Math.min.apply(null,M.map((function(t){return t.x}))),y:Math.min.apply(null,M.map((function(t){return t.y})))},max:{x:Math.max.apply(null,M.map((function(t){return t.x}))),y:Math.max.apply(null,M.map((function(t){return t.y})))}}}function ut(t,e,n,r,o,i,a){var s=1-a;return{x:Math.pow(s,2)*t+2*s*a*n+Math.pow(a,2)*o,y:Math.pow(s,2)*e+2*s*a*r+Math.pow(a,2)*i}}function ct(t,e,n,r,o,i,a,s){var u,c=s.bbox,l=void 0===c||c,d=s.length,f=void 0===d||d,h=s.sampleSize,p=void 0===h?10:h,g="number"===typeof a,v=t,m=e,y=0,b=[v,m,y],x=[v,m],w={x:0,y:0},E=[{x:v,y:m}];g&&a<=0&&(w={x:v,y:m});for(var S=0;S<=p;S+=1){if(v=(u=ut(t,e,n,r,o,i,S/p)).x,m=u.y,l&&E.push({x:v,y:m}),f&&(y+=et(x,[v,m])),x=[v,m],g&&y>=a&&a>b[2]){var M=(y-a)/(y-b[2]);w={x:x[0]*(1-M)+b[0]*M,y:x[1]*(1-M)+b[1]*M}}b=[v,m,y]}return g&&a>=y&&(w={x:o,y:i}),{length:y,point:w,min:{x:Math.min.apply(null,E.map((function(t){return t.x}))),y:Math.min.apply(null,E.map((function(t){return t.y})))},max:{x:Math.max.apply(null,E.map((function(t){return t.x}))),y:Math.max.apply(null,E.map((function(t){return t.y})))}}}function lt(t,e,n){for(var r,o,i,a,s,u,c,l,d,f=V(t),h="number"===typeof e,p=[],g=0,v=0,m=0,y=0,b=[],x=[],w=0,E={x:0,y:0},S=E,M=E,k=E,_=0,A=0,C=f.length;A=e&&(k=M),x.push(S),b.push(E),_+=w,g=(u="Z"!==l?d.slice(-2):[m,y])[0],v=u[1];return h&&e>=_&&(k={x:g,y:v}),{length:_,point:k,min:{x:Math.min.apply(null,b.map((function(t){return t.x}))),y:Math.min.apply(null,b.map((function(t){return t.y})))},max:{x:Math.max.apply(null,x.map((function(t){return t.x}))),y:Math.max.apply(null,x.map((function(t){return t.y})))}}}function dt(t,e){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};var n=lt(t,void 0,_(_({},e),{length:!1})),r=n.min,o=r.x,i=r.y,a=n.max,s=a.x,u=a.y,c=s-o,l=u-i;return{width:c,height:l,x:o,y:i,x2:s,y2:u,cx:o+c/2,cy:i+l/2,cz:Math.max(c,l)+Math.min(c,l)/2}}function ft(t,e){return lt(t,void 0,_(_({},e),{bbox:!1,length:!0})).length}function ht(t,e){if(!t)return{length:0,x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};var n=lt(t,void 0,_(_({},e),{bbox:!0,length:!0})),r=n.length,o=n.min,i=o.x,a=o.y,s=n.max,u=s.x,c=s.y,l=u-i,d=c-a;return{length:r,width:l,height:d,x:i,y:a,x2:u,y2:c,cx:i+l/2,cy:a+d/2,cz:Math.max(l,d)+Math.min(l,d)/2}}function pt(t,e){var n=t.length-1,r=[],o=0,i=function(t){var e=t.length,n=e-1;return t.map((function(r,o){return t.map((function(r,i){var a,s=o+i;return 0===i||t[s]&&"M"===t[s][0]?(a=t[s],["M"].concat(a.slice(-2))):(s>=e&&(s-=n),t[s])}))}))}(t);return i.forEach((function(i,a){t.slice(1).forEach((function(r,i){o+=et(t[(a+i)%n].slice(-2),e[i%n].slice(-2))})),r[a]=o,o=0})),i[r.indexOf(Math.min.apply(null,r))]}function gt(t){var e=0,n=0,r=0;return $(t).map((function(t){var o;if("M"===t[0])return e=t[1],n=t[2],0;var i=t.slice(1),a=i[0],s=i[1],u=i[2],c=i[3],l=i[4],d=i[5];return r=function(t,e,n,r,o,i,a,s){return 3*((s-e)*(n+o)-(a-t)*(r+i)+r*(t-o)-n*(e-i)+s*(o+t/3)-a*(i+e/3))/20}(e,n,a,s,u,c,l,d),o=t.slice(-2),e=o[0],n=o[1],r})).reduce((function(t,e){return t+e}),0)}function vt(t){return gt(t)>=0}function mt(t,e,n){return lt(t,e,_(_({},n),{bbox:!1,length:!0})).point}function yt(t,e){for(var n,r,o,i,a=U(t),s=V(a),u=ft(a),c=function(t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},l=8,d=0,f=0,h=1/0,p=0;p<=u;p+=l)(d=c(n=mt(s,p))).5;)m=c(o=mt(s,g=f-l)),y=c(i=mt(s,v=f+l)),g>=0&&m=o)return s=o-(a=ft(r=n.slice(0,-1))),{segment:n[i],index:i,length:s,lengthAtSegment:a};for(var d=[];i>0;)u=r[i],s=o-(a=ft(r=r.slice(0,-1))),o=a,d.push({segment:u,index:i,length:s,lengthAtSegment:a}),i-=1;return d.find((function(t){return t.lengthAtSegment<=e}))}(a,f);return{closest:r,distance:Math.sqrt(h),segment:b}}function bt(t,e){var n=yt(t,e).distance;return Math.abs(n)<.001}function xt(t){return t.map((function(t,e,n){var r=e&&n[e-1].slice(-2).concat(t.slice(1)),o=e?st(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],{bbox:!1}).length:0;return{s:t,ss:e?o?function(t,e){void 0===e&&(e=.5);var n=t.slice(0,2),r=t.slice(2,4),o=t.slice(4,6),i=t.slice(6,8),a=q(n,r,e),s=q(r,o,e),u=q(o,i,e),c=q(a,s,e),l=q(s,u,e),d=q(c,l,e);return[["C"].concat(a,c,d),["C"].concat(l,u,i)]}(r):[t,t]:[t],l:o}}))}function wt(t,e,n){var r=xt(t),o=xt(e),i=r.length,a=o.length,s=r.filter((function(t){return t.l})).length,u=o.filter((function(t){return t.l})).length,c=r.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/s||0,l=o.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/u||0,d=n||Math.max(i,a),f=[c,l],h=[d-i,d-a],p=0,g=[r,o].map((function(t,e){return t.l===d?t.map((function(t){return t.s})):t.map((function(t,n){return p=n&&h[e]&&t.l>=f[e],h[e]-=p?1:0,p?t.ss:[t.s]})).flat()}));return g[0].length===g[1].length?g:wt(g[0],g[1],d)}const Et=function(t){return null!==t&&"function"!==typeof t&&isFinite(t.length)};const St=function(t,e){return!!Et(t)&&t.indexOf(e)>-1};const Mt=function(t,e){if(!Et(t))return t;for(var n=[],r=0;r-1;)Ht.call(t,i,1);return t};var Kt=Array.prototype.splice;const $t=function(t,e){if(!Et(t))return[];for(var n=t?e.length:0,r=n-1;n--;){var o=void 0,i=e[n];n!==r&&i===o||(o=i,Kt.call(t,i,1))}return t};const Qt=function(t,e,n){if(!Ct(t)&&!jt(t))return t;var r=n;return It(t,(function(t,n){r=e(r,t,n)})),r};const Jt=function(t,e){var n=[];if(!Et(t))return n;for(var r=-1,o=[],i=t.length;++re[o])return 1;if(t[o]n?n:t};const we=function(t,e){var n=e.toString(),r=n.indexOf(".");if(-1===r)return Math.round(t);var o=n.substr(r+1).length;return o>20&&(o=20),parseFloat(t.toFixed(o))};function Ee(t){return"number"===typeof t}function Se(t){return Ee(t)&&t%1!==0}function Me(t){return Ee(t)&&t%2===0}function ke(t){return Ee(t)&&t%1===0}function _e(t){return Ee(t)&&t<0}var Ae=1e-5;function Ce(t,e,n){return void 0===n&&(n=Ae),t===e||Math.abs(t-e)0},Te=function(t,e){if(Ct(t)){for(var n,r=-1/0,o=0;or&&(n=i,r=a)}return n}},Ne=function(t,e){if(Ct(t)){for(var n,r=1/0,o=0;oe?(r&&(clearTimeout(r),r=null),s=c,a=t.apply(o,i),r||(o=i=null)):r||!1===n.trailing||(r=setTimeout(u,l)),a};return c.cancel=function(){clearTimeout(r),s=0,r=o=i=null},c},Rn=function(t){return Et(t)?Array.prototype.slice.call(t):[]};var Fn={};const Bn=function(t){return Fn[t=t||"g"]?Fn[t]+=1:Fn[t]=1,t+Fn[t]},zn=function(){},Gn=function(t){return t};function Un(t){return At(t)?0:Et(t)?t.length:Object.keys(t).length}const Wn=function(){function t(){this.map={}}return t.prototype.has=function(t){return void 0!==this.map[t]},t.prototype.get=function(t,e){var n=this.map[t];return void 0===n?e:n},t.prototype.set=function(t,e){this.map[t]=e},t.prototype.clear=function(){this.map={}},t.prototype.delete=function(t){delete this.map[t]},t.prototype.size=function(){return Object.keys(this.map).length},t}();var Yn=1e-6;function Vn(t){return Math.abs(t)0!==Vn(s[1]-n)>0&&Vn(e-(n-a[1])*(a[0]-s[0])/(a[1]-s[1])-a[0])<0&&(r=!r)}return r}var qn=function(t,e,n){return t>=e&&t<=n};function Zn(t){for(var e=[],n=t.length,r=0;r1){var a=t[0],s=t[n-1];e.push({from:{x:s[0],y:s[1]},to:{x:a[0],y:a[1]}})}return e}function Kn(t,e){var n=!1;return t.forEach((function(t){if(function(t,e,n,r){var o=n.x-t.x,i=n.y-t.y,a=e.x-t.x,s=e.y-t.y,u=r.x-n.x,c=r.y-n.y,l=a*c-s*u,d=null;if(l*l>.001*(a*a+s*s)*(u*u+c*c)){var f=(o*c-i*u)/l,h=(o*s-i*a)/l;qn(f,0,1)&&qn(h,0,1)&&(d={x:t.x+f*a,y:t.y+f*s})}return d}(t.from,t.to,e.from,e.to))return n=!0,!1})),n}function $n(t){var e=t.map((function(t){return t[0]})),n=t.map((function(t){return t[1]}));return{minX:Math.min.apply(null,e),maxX:Math.max.apply(null,e),minY:Math.min.apply(null,n),maxY:Math.max.apply(null,n)}}function Qn(t,e){if(t.length<2||e.length<2)return!1;var n,r,o=$n(t),i=$n(e);if(n=o,(r=i).minX>n.maxX||r.maxXn.maxY||r.maxY{"use strict";n.r(e),n.d(e,{AbstractMatrix:()=>x,CHO:()=>$,CholeskyDecomposition:()=>$,EVD:()=>Z,EigenvalueDecomposition:()=>Z,LU:()=>j,LuDecomposition:()=>j,Matrix:()=>E,MatrixColumnSelectionView:()=>k,MatrixColumnView:()=>M,MatrixFlipColumnView:()=>_,MatrixFlipRowView:()=>A,MatrixRowSelectionView:()=>O,MatrixRowView:()=>C,MatrixSelectionView:()=>I,MatrixSubView:()=>T,MatrixTransposeView:()=>N,NIPALS:()=>Q,Nipals:()=>Q,QR:()=>F,QrDecomposition:()=>F,SVD:()=>B,SingularValueDecomposition:()=>B,WrapperMatrix1D:()=>P,WrapperMatrix2D:()=>L,correlation:()=>q,covariance:()=>H,default:()=>E,determinant:()=>U,inverse:()=>z,linearDependencies:()=>V,pseudoInverse:()=>X,solve:()=>G,wrap:()=>D});const r=Object.prototype.toString;function o(t){const e=r.call(t);return e.endsWith("Array]")&&!e.includes("Big")}function i(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!o(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!o(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!o(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,a=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(a<=r||a>t.length||!Number.isInteger(a))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[r],u=r+1;u1&&void 0!==arguments[1]?arguments[1]:{};if(!o(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,a=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(a<=r||a>t.length||!Number.isInteger(a))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[r],u=r+1;us&&(s=t[u]);return s}(t);if(r===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var a=n.min,s=void 0===a?n.autoMinMax?r:0:a,u=n.max,c=void 0===u?n.autoMinMax?i:1:u;if(s>=c)throw new RangeError("min option must be smaller than max option");for(var l=(c-s)/(i-r),d=0;d1&&void 0!==arguments[1]?arguments[1]:{};const{maxRows:n=15,maxColumns:r=10,maxNumSize:o=8}=e;return"".concat(t.constructor.name," {\n").concat(a,"[\n").concat(s).concat(function(t,e,n,r){const{rows:o,columns:i}=t,a=Math.min(o,e),u=Math.min(i,n),l=[];for(let s=0;sr)throw new RangeError("Row index out of range")}function d(t,e,n){let r=n?t.columns:t.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function f(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function h(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function p(t,e,n){return{row:g(t,e),column:v(t,n)}}function g(t,e){if("object"!==typeof e)throw new TypeError("unexpected type for row indices");if(e.some((e=>e<0||e>=t.rows)))throw new RangeError("row indices are out of range");return Array.isArray(e)||(e=Array.from(e)),e}function v(t,e){if("object"!==typeof e)throw new TypeError("unexpected type for column indices");if(e.some((e=>e<0||e>=t.columns)))throw new RangeError("column indices are out of range");return Array.isArray(e)||(e=Array.from(e)),e}function m(t,e,n,r,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(b("startRow",e),b("endRow",n),b("startColumn",r),b("endColumn",o),e>n||r>o||e<0||e>=t.rows||n<0||n>=t.rows||r<0||r>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function y(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=[];for(let r=0;r2&&void 0!==arguments[2]?arguments[2]:{};if("object"!==typeof n)throw new TypeError("options must be an object");const{random:r=Math.random}=n;let o=new E(t,e);for(let i=0;i2&&void 0!==arguments[2]?arguments[2]:{};if("object"!==typeof n)throw new TypeError("options must be an object");const{min:r=0,max:o=1e3,random:i=Math.random}=n;if(!Number.isInteger(r))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(r>=o)throw new RangeError("min must be smaller than max");let a=o-r,s=new E(t,e);for(let u=0;un?(o=!0,n=e):(r=!1,o=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,o=!1;for(;tn?(o=!0,n=e):(r=!1,o=!0);for(let n=e+1;nt.get(r,n)&&(r=o);if(0===t.get(r,n))n++;else{t.swapRows(e,r);let o=t.get(e,n);for(let r=n;r=0;)if(0===t.maxRow(r))r--;else{let o=0,i=!1;for(;o0&&void 0!==arguments[0]?arguments[0]:{};if("object"!==typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new E(this.rows*e,this.columns*n);for(let o=0;ot&&(t=this.get(e,n));return t}maxIndex(){let t=this.get(0,0),e=[0,0];for(let n=0;nt&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}min(){let t=this.get(0,0);for(let e=0;ee&&(e=this.get(t,n));return e}maxRowIndex(t){l(this,t);let e=this.get(t,0),n=[t,0];for(let r=1;re&&(e=this.get(t,r),n[1]=r);return n}minRow(t){l(this,t);let e=this.get(t,0);for(let n=1;ne&&(e=this.get(n,t));return e}maxColumnIndex(t){d(this,t);let e=this.get(0,t),n=[0,t];for(let r=1;re&&(e=this.get(r,t),n[0]=r);return n}minColumn(t){d(this,t);let e=this.get(0,t);for(let n=1;n0&&void 0!==arguments[0]?arguments[0]:"frobenius",e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:{};if("object"!==typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new E(this.rows,this.columns);for(let o=0;o0&&void 0!==arguments[0]?arguments[0]:{};if("object"!==typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new E(this.rows,this.columns);for(let o=0;o0&&void 0!==arguments[0]?arguments[0]:w;for(let e=0;e0&&void 0!==arguments[0]?arguments[0]:w;for(let e=0;en||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new E(t.length,n-e+1);for(let o=0;o=this.rows)throw new RangeError("Row index out of range: ".concat(t[o]));r.set(o,i-e,this.get(t[o],i))}return r}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let r=new E(n-e+1,t.length);for(let o=0;o=this.columns)throw new RangeError("Column index out of range: ".concat(t[o]));r.set(i-e,o,this.get(i,t[o]))}return r}setSubMatrix(t,e,n){m(this,e,e+(t=E.checkMatrix(t)).rows-1,n,n+t.columns-1);for(let r=0;r1&&void 0!==arguments[1]?arguments[1]:{};if("object"===typeof t&&(e=t,t=void 0),"object"!==typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:r=this.mean(t)}=e;if("boolean"!==typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!Array.isArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,o=t.columns,i=[];for(let a=0;a1&&void 0!==arguments[1]?arguments[1]:{};if("object"===typeof t&&(e=t,t=void 0),"object"!==typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!Array.isArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if("object"===typeof t&&(e=t,t=void 0),"object"!==typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n0){if(this.data=[],!(Number.isInteger(e)&&e>0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"===typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t1&&void 0!==arguments[1]?arguments[1]:{};const{rows:n=1}=e;if(t.length%n!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,n){let r=this._calculateIndex(t,e);return this.data[r]=n,this}get(t,e){let n=this._calculateIndex(t,e);return this.data[n]}_calculateIndex(t,e){return t*this.columns+e}}class L extends x{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}function D(t,e){if(Array.isArray(t))return t[0]&&Array.isArray(t[0])?new L(t):new P(t,e);throw new Error("the argument is not an array")}class j{constructor(t){let e,n,r,o,i,a,s,u,c,l=(t=L.checkMatrix(t)).clone(),d=l.rows,f=l.columns,h=new Float64Array(d),p=1;for(e=0;eMath.abs(u[o])&&(o=e);if(o!==n){for(r=0;r=0;o--){for(r=0;re?r.set(o,e,t.get(o,e)):o===e?r.set(o,e,1):r.set(o,e,0);return r}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new E(e,n);for(let o=0;oMath.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class F{constructor(t){let e,n,r,o,i=(t=L.checkMatrix(t)).clone(),a=t.rows,s=t.columns,u=new Float64Array(s);for(r=0;r=0;i--){for(o=0;o=0;n--){for(t=0;t1&&void 0!==arguments[1]?arguments[1]:{},n=(t=L.checkMatrix(t)).rows,r=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:a=!1}=e;let s,u=Boolean(o),c=Boolean(i),l=!1;if(n=0;t--)if(0!==h[t]){for(let e=t+1;e=0;E--){if(E0;){let t,e;for(t=S-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+_*Math.abs(h[t]+Math.abs(h[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===S-2)e=4;else{let n;for(n=S-1;n>=t&&n!==t;n--){let e=(n!==S?Math.abs(v[n]):0)+(n!==t+1?Math.abs(v[n-1]):0);if(Math.abs(h[n])<=_*e){h[n]=0;break}}n===t?e=3:n===S-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=v[S-2];v[S-2]=0;for(let n=S-2;n>=t;n--){let o=R(h[n],e),i=h[n]/o,a=e/o;if(h[n]=o,n!==t&&(e=-a*v[n-1],v[n-1]=i*v[n-1]),c)for(let t=0;t=h[t+1]);){let e=h[t];if(h[t]=h[t+1],h[t+1]=e,c&&te&&o.set(c,n,t.get(c,n)/this.s[n]);let i=this.U,a=i.rows,s=i.columns,u=new E(n,a);for(let c=0;ct&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return E.diag(this.s)}}function z(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t=L.checkMatrix(t),e?new B(t).inverse():G(t,E.eye(t.rows))}function G(t,e){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t=L.checkMatrix(t),e=L.checkMatrix(e),n?new B(t).solve(e):t.isSquare()?new j(t).solve(e):new F(t).solve(e)}function U(t){if((t=E.checkMatrix(t)).isSquare()){let e,n,r,o;if(2===t.columns)return e=t.get(0,0),n=t.get(0,1),r=t.get(1,0),o=t.get(1,1),e*o-n*r;if(3===t.columns){let o,i,a;return o=new I(t,[1,2],[1,2]),i=new I(t,[1,2],[0,2]),a=new I(t,[1,2],[0,1]),e=t.get(0,0),n=t.get(0,1),r=t.get(0,2),e*U(o)-n*U(i)+r*U(a)}return new j(t).determinant}throw Error("determinant can only be calculated for a square matrix")}function W(t,e){let n=[];for(let r=0;r3&&void 0!==arguments[3]?arguments[3]:1e-9;if(t>(arguments.length>4&&void 0!==arguments[4]?arguments[4]:1e-9))return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:{};const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let o=(t=E.checkMatrix(t)).rows,i=new E(o,o);for(let a=0;a1&&void 0!==arguments[1]?arguments[1]:Number.EPSILON;t=E.checkMatrix(t);let n=new B(t,{autoTranspose:!0}),r=n.leftSingularVectors,o=n.rightSingularVectors,i=n.diagonal;for(let a=0;ae?i[a]=1/i[a]:i[a]=0;return o.mmul(E.diag(i).mmul(r.transpose()))}function H(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=new E(t);let r=!1;if("object"!==typeof e||E.isMatrix(e)||Array.isArray(e)?e=new E(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:o=!0}=n;o&&(t=t.center("column"),r||(e=e.center("column")));const i=t.transpose().mmul(e);for(let a=0;a1&&void 0!==arguments[1]?arguments[1]:t,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=new E(t);let r=!1;if("object"!==typeof e||E.isMatrix(e)||Array.isArray(e)?e=new E(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:o=!0,scale:i=!0}=n;o&&(t.center("column"),r||e.center("column")),i&&(t.scale("column"),r||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),s=r?a:e.standardDeviation("column",{unbiased:!0}),u=t.transpose().mmul(e);for(let c=0;c1&&void 0!==arguments[1]?arguments[1]:{};const{assumeSymmetric:n=!1}=e;if(!(t=L.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");let r,o,i=t.columns,a=new E(i,i),s=new Float64Array(i),u=new Float64Array(i),c=t,l=!1;if(l=!!n||t.isSymmetric(),l){for(r=0;r0;s--){for(d=0,a=0,c=0;c0&&(i=-i),e[s]=d*i,a-=o*i,n[s-1]=o-i,u=0;uc){x=0;do{for(x+=1,o=n[c],d=(n[c+1]-o)/(2*e[c]),f=R(d,1),d<0&&(f=-f),n[c]=e[c]/(d+f),n[c+1]=e[c]*(d+f),h=n[c+1],i=o-n[c],a=c+2;a=c;a--)for(v=g,g=p,b=y,o=p*e[a],i=p*d,f=R(d,e[a]),e[a+1]=y*f,y=e[a]/f,p=d/f,d=p*n[a]-y*o,n[a+1]=i+y*(p*o+y*n[a]),u=0;uS*E)}n[c]=n[c]+w,e[c]=0}for(a=0;a=c;s--)n[s]=e.get(s,c-1)/l,a+=n[s]*n[s];for(i=Math.sqrt(a),n[c]>0&&(i=-i),a-=n[c]*i,n[c]=n[c]-i,u=c;u=c;s--)o+=n[s]*e.get(s,u);for(o/=a,s=c;s<=f;s++)e.set(s,u,e.get(s,u)-o*n[s])}for(s=0;s<=f;s++){for(o=0,u=f;u>=c;u--)o+=n[u]*e.get(s,u);for(o/=a,u=c;u<=f;u++)e.set(s,u,e.get(s,u)-o*n[u])}n[c]=l*n[c],e.set(c,c-1,l*i)}}for(s=0;s=d+1;c--)if(0!==e.get(c,c-1)){for(s=c+1;s<=f;s++)n[s]=e.get(s,c-1);for(u=c;u<=f;u++){for(i=0,s=c;s<=f;s++)i+=n[s]*r.get(s,u);for(i=i/n[c]/e.get(c,c-1),s=c;s<=f;s++)r.set(s,u,r.get(s,u)+i*n[s])}}}(i,t,e,a),function(t,e,n,r,o){let i,a,s,u,c,l,d,f,h,p,g,v,m,y,b,x=t-1,w=0,E=t-1,S=Number.EPSILON,M=0,k=0,_=0,A=0,C=0,O=0,I=0,T=0;for(i=0;iE)&&(n[i]=o.get(i,i),e[i]=0),a=Math.max(i-1,0);a=w;){for(u=x;u>w&&(O=Math.abs(o.get(u-1,u-1))+Math.abs(o.get(u,u)),0===O&&(O=k),!(Math.abs(o.get(u,u-1))=0){for(I=_>=0?_+I:_-I,n[x-1]=f+I,n[x]=n[x-1],0!==I&&(n[x]=f-d/I),e[x-1]=0,e[x]=0,f=o.get(x,x-1),O=Math.abs(f)+Math.abs(I),_=f/O,A=I/O,C=Math.sqrt(_*_+A*A),_/=C,A/=C,a=x-1;a0)){for(O=Math.sqrt(O),h=u&&(I=o.get(c,c),C=f-I,O=h-I,_=(C*O-d)/o.get(c+1,c)+o.get(c,c+1),A=o.get(c+1,c+1)-I-C-O,C=o.get(c+2,c+1),O=Math.abs(_)+Math.abs(A)+Math.abs(C),_/=O,A/=O,C/=O,c!==u)&&!(Math.abs(o.get(c,c-1))*(Math.abs(A)+Math.abs(C))c+2&&o.set(i,i-3,0);for(s=c;s<=x-1&&(y=s!==x-1,s!==c&&(_=o.get(s,s-1),A=o.get(s+1,s-1),C=y?o.get(s+2,s-1):0,f=Math.abs(_)+Math.abs(A)+Math.abs(C),0!==f&&(_/=f,A/=f,C/=f)),0!==f);s++)if(O=Math.sqrt(_*_+A*A+C*C),_<0&&(O=-O),0!==O){for(s!==c?o.set(s,s-1,-O*f):u!==c&&o.set(s,s-1,-o.get(s,s-1)),_+=O,f=_/O,h=A/O,I=C/O,A/=_,C/=_,a=s;a=0;x--)if(_=n[x],A=e[x],0===A)for(u=x,o.set(x,x,1),i=x-1;i>=0;i--){for(d=o.get(i,i)-_,C=0,a=u;a<=x;a++)C+=o.get(i,a)*o.get(a,x);if(e[i]<0)I=d,O=C;else if(u=i,0===e[i]?o.set(i,x,0!==d?-C/d:-C/(S*k)):(f=o.get(i,i+1),h=o.get(i+1,i),A=(n[i]-_)*(n[i]-_)+e[i]*e[i],l=(f*O-I*C)/A,o.set(i,x,l),o.set(i+1,x,Math.abs(f)>Math.abs(I)?(-C-d*l)/f:(-O-h*l)/I)),l=Math.abs(o.get(i,x)),S*l*l>1)for(a=i;a<=x;a++)o.set(a,x,o.get(a,x)/l)}else if(A<0)for(u=x-1,Math.abs(o.get(x,x-1))>Math.abs(o.get(x-1,x))?(o.set(x-1,x-1,A/o.get(x,x-1)),o.set(x-1,x,-(o.get(x,x)-_)/o.get(x,x-1))):(b=K(0,-o.get(x-1,x),o.get(x-1,x-1)-_,A),o.set(x-1,x-1,b[0]),o.set(x-1,x,b[1])),o.set(x,x-1,0),o.set(x,x,1),i=x-2;i>=0;i--){for(p=0,g=0,a=u;a<=x;a++)p+=o.get(i,a)*o.get(a,x-1),g+=o.get(i,a)*o.get(a,x);if(d=o.get(i,i)-_,e[i]<0)I=d,C=p,O=g;else if(u=i,0===e[i]?(b=K(-p,-g,d,A),o.set(i,x-1,b[0]),o.set(i,x,b[1])):(f=o.get(i,i+1),h=o.get(i+1,i),v=(n[i]-_)*(n[i]-_)+e[i]*e[i]-A*A,m=2*(n[i]-_)*A,0===v&&0===m&&(v=S*k*(Math.abs(d)+Math.abs(A)+Math.abs(f)+Math.abs(h)+Math.abs(I))),b=K(f*C-I*p+A*g,f*O-I*g-A*p,v,m),o.set(i,x-1,b[0]),o.set(i,x,b[1]),Math.abs(f)>Math.abs(I)+Math.abs(A)?(o.set(i+1,x-1,(-p-d*o.get(i,x-1)+A*o.get(i,x))/f),o.set(i+1,x,(-g-d*o.get(i,x)-A*o.get(i,x-1))/f)):(b=K(-C-h*o.get(i,x-1),-O-h*o.get(i,x),I,A),o.set(i+1,x-1,b[0]),o.set(i+1,x,b[1]))),l=Math.max(Math.abs(o.get(i,x-1)),Math.abs(o.get(i,x))),S*l*l>1)for(a=i;a<=x;a++)o.set(a,x-1,o.get(a,x-1)/l),o.set(a,x,o.get(a,x)/l)}for(i=0;iE)for(a=i;a=w;a--)for(i=w;i<=E;i++){for(I=0,s=w;s<=Math.min(a,E);s++)I+=r.get(i,s)*o.get(s,a);r.set(i,a,I)}}(i,u,s,a,t)}this.n=i,this.e=u,this.d=s,this.V=a}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,n=this.n,r=this.e,o=this.d,i=new E(n,n);for(t=0;t0?i.set(t,t+1,r[t]):r[t]<0&&i.set(t,t-1,r[t])}return i}}function K(t,e,n,r){let o,i;return Math.abs(n)>Math.abs(r)?(o=r/n,i=n+o*r,[(t+o*e)/i,(e-o*t)/i]):(o=n/r,i=r+o*n,[(o*t+e)/i,(o*e-t)/i])}class ${constructor(t){if(!(t=L.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,o=t,i=o.rows,a=new E(i,i),s=!0;for(n=0;n0,a.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r=0;i--)for(o=0;o1&&void 0!==arguments[1]?arguments[1]:{};t=L.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:o=1e3,terminationCriteria:i=1e-10}=e;let a;if(n){if(n=Array.isArray(n)&&"number"===typeof n[0]?E.columnVector(n):L.checkMatrix(n),!n.isColumnVector()||n.rows!==t.rows)throw new Error("Y must be a column vector of length X.rows");a=n}else a=t.getColumnVector(0);let s,u,c,l,d=1;for(let f=0;fi;f++)c=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),c=c.div(c.norm()),s=t.mmul(c).div(c.transpose().mmul(c).get(0,0)),f>0&&(d=s.clone().sub(l).pow(2).sum()),l=s.clone(),n?(u=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),u=u.div(u.norm()),a=n.mmul(u).div(u.transpose().mmul(u).get(0,0))):a=s;if(n){let e=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0));e=e.div(e.norm());let r=t.clone().sub(s.clone().mmul(e.transpose())),o=a.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),i=n.clone().sub(s.clone().mulS(o.get(0,0)).mmul(u.transpose()));this.t=s,this.p=e.transpose(),this.w=c.transpose(),this.q=u,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=i,this.betas=o}else this.w=c.transpose(),this.s=s.transpose().mmul(s).sqrt(),this.t=r?s.clone().div(this.s.get(0,0)):s,this.xResidual=t.sub(s.mmul(c.transpose()))}}},5285:(t,e,n)=>{"use strict";n.r(e),n.d(e,{Graph:()=>w,GraphWithEvent:()=>C,algorithm:()=>r,comparision:()=>i,essence:()=>o,generate:()=>s});var r={};n.r(r),n.d(r,{components:()=>P,dfs:()=>D,dijkstra:()=>z,dijkstraAll:()=>G,findCycles:()=>W,floydWarshall:()=>ot,isAcyclic:()=>tt,postorder:()=>et,preorder:()=>nt,prim:()=>N,tarjan:()=>U,topsort:()=>J});var o={};n.r(o),n.d(o,{hasSelfLoop:()=>bt,isGraph:()=>vt,isNullGraph:()=>yt,isSimpleGraph:()=>mt});var i={};n.r(i),n.d(i,{containAllSameEdges:()=>dt,containAllSameNodes:()=>lt,containSameEdges:()=>at,containSameNodes:()=>it,getSameEdges:()=>ut,getSameNodes:()=>st,isGraphComplement:()=>xt,isGraphContainsAnother:()=>ht,isGraphOptionSame:()=>ct,isGraphSame:()=>ft});var a,s={};function u(t,e){var n=t.get(e)||0;t.set(e,n+1)}function c(t,e){var n=t.get(e);void 0!==n&&((n-=1)>0?t.set(e,n):t.delete(e))}function l(t,e,n,r){var o=String(e),i=String(n);if(!t&&o>i){var s=o;o=i,i=s}return o+a.EDGE_KEY_DELIM+i+a.EDGE_KEY_DELIM+(void 0===r?a.DEFAULT_EDGE_NAME:r)}function d(t,e,n,r){var o=String(e),i=String(n),a={v:e,w:n};if(!t&&o>i){var s=a.v;a.v=a.w,a.w=s}return void 0!==r&&(a.name=r),a}function f(t,e){return l(t,e.v,e.w,e.name)}function h(t){return"function"===typeof t}n.r(s),n.d(s,{getGraphComplement:()=>wt}),function(t){t.DEFAULT_EDGE_NAME="\0",t.GRAPH_NODE="\0",t.EDGE_KEY_DELIM="\x01"}(a||(a={}));var p=function(t){return t.nodes().map((function(e){var n={id:e,value:t.node(e),parent:t.parent(e)};return void 0===n.value&&delete n.value,void 0===n.parent&&delete n.parent,n}))},g=function(t){return t.edges().map((function(e){var n=t.edge(e),r={v:e.v,w:e.w,value:n,name:e.name};return void 0===r.name&&delete r.name,void 0===r.value&&delete r.value,r}))};function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function m(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.directed=!0,this.multigraph=!1,this.compound=!1,this.GRAPH_NODE=a.GRAPH_NODE,this.label=void 0,this.nodeCountNum=0,this.edgeCountNum=0,this.defaultNodeLabelFn=function(){},this.defaultEdgeLabelFn=function(){},this.parentMap=void 0,this.childrenMap=void 0,this.nodesLabelMap=new Map,this.inEdgesMap=new Map,this.outEdgesMap=new Map,this.predecessorsMap=new Map,this.successorsMap=new Map,this.edgesMap=new Map,this.edgesLabelsMap=new Map,this.isDirected=function(){return e.directed},this.isMultigraph=function(){return e.multigraph},this.isCompound=function(){return e.compound},this.setGraph=function(t){return e.label=t,e},this.graph=function(){return e.label},this.setDefaultNodeLabel=function(t){return h(t)?e.defaultNodeLabelFn=t:e.defaultNodeLabelFn=function(){return t},e},this.nodeCount=function(){return e.nodeCountNum},this.node=function(t){return e.nodesLabelMap.get(t)},this.nodes=function(){return Array.from(e.nodesLabelMap.keys())},this.sources=function(){return e.nodes().filter((function(t){var n;return!(null===(n=e.inEdgesMap.get(t))||void 0===n?void 0:n.size)}))},this.sinks=function(){return e.nodes().filter((function(t){var n;return!(null===(n=e.outEdgesMap.get(t))||void 0===n?void 0:n.size)}))},this.setNodes=function(t,n){return t.map((function(t){return e.setNode(t,n)})),e},this.hasNode=function(t){return e.nodesLabelMap.has(t)},this.checkCompound=function(){if(!e.isCompound())throw new Error("Cannot construct parent-children relations in a non-compound graph")},this.parent=function(t){if(e.isCompound()){var n,r=null===(n=e.parentMap)||void 0===n?void 0:n.get(t);if(r!==e.GRAPH_NODE)return r}},this.removeFromParentsChildList=function(t){var n=e.parentMap.get(t);e.childrenMap.get(n).delete(t)},this.setParent=function(t,n){var r,o;e.checkCompound();for(var i=void 0===n?e.GRAPH_NODE:n,a=e.parent(i);a;){if(t===a)throw new Error("Setting "+n+" as parent of "+t+" would create a cycle");a=e.parent(a)}n&&e.setNode(n),e.setNode(t),e.removeFromParentsChildList(t),null===(r=e.parentMap)||void 0===r||r.set(t,i);var s=e.childrenMap.get(i);return s.set(t,!0),null===(o=e.childrenMap)||void 0===o||o.set(i,s),e},this.children=function(t){var n=void 0===t?e.GRAPH_NODE:t;if(e.isCompound()){var r,o=null===(r=e.childrenMap)||void 0===r?void 0:r.get(n);return o?Array.from(o.keys()):void 0}return n===e.GRAPH_NODE?e.nodes():t&&e.hasNode(t)?[]:void 0},this.predecessors=function(t){var n=e.predecessorsMap.get(t);return n?Array.from(n.keys()):void 0},this.successors=function(t){var n=e.successorsMap.get(t);return n?Array.from(n.keys()):void 0},this.neighbors=function(t){var n;if(e.hasNode(t))return Array.from(new Set(null===(n=e.predecessors(t))||void 0===n?void 0:n.concat(e.successors(t))))},this.isLeaf=function(t){var n,r;return e.isDirected()?!(null===(r=e.successors(t))||void 0===r?void 0:r.length):!(null===(n=e.neighbors(t))||void 0===n?void 0:n.length)},this.filterNodes=function(n){var r=e.directed,o=e.multigraph,i=e.compound,a=new t({directed:r,multigraph:o,compound:i});if(a.setGraph(e.graph()),e.nodes().forEach((function(t){n(t)&&a.setNode(t,e.node(t))})),e.edges().forEach((function(t){a.hasNode(t.v)&&a.hasNode(t.w)&&a.setEdgeObj(t,e.edge(t))})),i){a.nodes().forEach((function(t){a.setParent(t,function(t){for(var n=e.parent(t);void 0!==n&&!a.hasNode(n);)n=e.parent(n);return n}(t))}))}return a},this.setDefaultEdgeLabel=function(t){return h(t)?e.defaultEdgeLabelFn=t:e.defaultEdgeLabelFn=function(){return t},e},this.edgeCount=function(){return e.edgeCountNum},this.setEdgeObj=function(t,n){return e.setEdge(t.v,t.w,n,t.name)},this.setPath=function(t,n){return t.reduce((function(t,r){return e.setEdge(t,r,n),r})),e},this.edgeFromArgs=function(t,n,r){return e.edge({v:t,w:n,name:r})},this.edge=function(t){return e.edgesLabelsMap.get(f(e.isDirected(),t))},this.hasEdge=function(t,n,r){return e.edgesLabelsMap.has(f(e.isDirected(),{v:t,w:n,name:r}))},this.removeEdgeObj=function(t){var n=t.v,r=t.w,o=t.name;return e.removeEdge(n,r,o)},this.edges=function(){return Array.from(e.edgesMap.values())},this.inEdges=function(t,n){var r=e.inEdgesMap.get(t);if(r)return Array.from(r.values()).filter((function(t){return!n||t.v===n}))},this.outEdges=function(t,n){var r=e.outEdgesMap.get(t);if(r)return Array.from(r.values()).filter((function(t){return!n||t.w===n}))},this.nodeEdges=function(t,n){var r;if(e.hasNode(t))return null===(r=e.inEdges(t,n))||void 0===r?void 0:r.concat(e.outEdges(t,n))},this.toJSON=function(){return function(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:p(t),edges:g(t),value:t.graph()};return void 0===e.value&&delete e.value,e}(e)},this.nodeInDegree=function(t){var n=e.inEdgesMap.get(t);return n?n.size:0},this.nodeOutDegree=function(t){var n=e.outEdgesMap.get(t);return n?n.size:0},this.nodeDegree=function(t){return e.nodeInDegree(t)+e.nodeOutDegree(t)},this.source=function(t){return t.v},this.target=function(t){return t.w};var r=m(m({},x),n);this.compound=r.compound,this.directed=r.directed,this.multigraph=r.multigraph,this.compound&&(this.parentMap=new Map,this.childrenMap=new Map)}var e,n,r;return e=t,(n=[{key:"setNode",value:function(t,e){var n,r=this.nodesLabelMap,o=this.defaultNodeLabelFn,i=this.isCompound,a=this.parentMap,s=this.childrenMap,u=this.inEdgesMap,c=this.outEdgesMap,l=this.predecessorsMap,d=this.successorsMap;return r.has(t)?(void 0!==e&&r.set(t,e),this):(r.set(t,e||o(t)),i()&&(null===a||void 0===a||a.set(t,this.GRAPH_NODE),null===s||void 0===s||s.set(t,new Map),(null===s||void 0===s?void 0:s.has(this.GRAPH_NODE))||null===s||void 0===s||s.set(this.GRAPH_NODE,new Map),null===s||void 0===s||null===(n=s.get(this.GRAPH_NODE))||void 0===n||n.set(t,!0)),[u,c,l,d].forEach((function(e){return e.set(t,new Map)})),this.nodeCountNum+=1,this)}},{key:"removeNode",value:function(t){var e=this;if(this.hasNode(t)){var n,r,o,i=function(t){e.removeEdge(t.v,t.w,t.name)},a=this.inEdgesMap,s=this.outEdgesMap,u=this.predecessorsMap,c=this.successorsMap,l=this.nodesLabelMap;this.isCompound()&&(this.removeFromParentsChildList(t),null===(n=this.parentMap)||void 0===n||n.delete(t),null===(r=this.children(t))||void 0===r||r.forEach((function(t){return e.setParent(t)})),null===(o=this.childrenMap)||void 0===o||o.delete(t));var d=a.get(t),f=s.get(t);Array.from(d.values()).forEach((function(t){return i(t)})),Array.from(f.values()).forEach((function(t){return i(t)})),l.delete(t),a.delete(t),s.delete(t),u.delete(t),c.delete(t),this.nodeCountNum-=1}return this}},{key:"setEdge",value:function(t,e,n,r){var o,i,a=d(this.isDirected(),t,e,r),s=f(this.isDirected(),a),c=a.v,l=a.w;if(this.edgesLabelsMap.has(s))return this.edgesLabelsMap.set(s,n),this;if(void 0!==r&&!this.isMultigraph())throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(c),this.setNode(l),this.edgesLabelsMap.set(s,n||this.defaultEdgeLabelFn(c,l,r)),Object.freeze(a),this.edgesMap.set(s,a);var h=this.predecessorsMap.get(l),p=this.successorsMap.get(c);return u(h,c),u(p,l),null===(o=this.inEdgesMap.get(l))||void 0===o||o.set(s,a),null===(i=this.outEdgesMap.get(c))||void 0===i||i.set(s,a),this.edgeCountNum+=1,this}},{key:"removeEdge",value:function(t,e,n){var r=l(this.isDirected(),t,e,n);if(this.edgesMap.get(r)){var o=d(this.isDirected(),t,e,n),i=o.v,a=o.w;this.edgesLabelsMap.delete(r),this.edgesMap.delete(r);var s=this.predecessorsMap.get(a),u=this.successorsMap.get(i);c(s,i),c(u,a),this.inEdgesMap.get(a).delete(r),this.outEdgesMap.get(i).delete(r),this.edgeCountNum-=1}return this}}])&&b(e.prototype,n),r&&b(e,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function E(t){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E(t)}function S(t,e){for(var n=0;n-1&&this.eventPool[t].splice(n,1)}}},{key:"emitEvent",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r>1])||void 0===a?void 0:a.priority)e.arr[r].priority)throw new Error("New priority is greater than current priority.Key: ".concat(t," Old: + ").concat(e.arr[r].priority," New: ").concat(n));e.arr[r].priority=n,e.innerDecrease(r)}}));const N=function(t,e){var n,r=new w,o=new Map,i=new T;function a(t){var r=t.v===n?t.w:t.v,a=i.priority(r);if(void 0!==a){var s=e(t);s0;){var u;if(n=i.removeMin(),o.has(n))r.setEdge(n,o.get(n));else{if(s)throw new Error("Input graph is not connected: "+t.graph());s=!0}null===(u=t.nodeEdges(n))||void 0===u||u.forEach(a)}return r};const P=function(t){var e=new Set,n=[];return t.nodes().forEach((function(r){for(var o=[],i=[r];i.length>0;){var a,s,u=i.pop();if(!e.has(u))e.add(u),o.push(u),null===(a=t.successors(u))||void 0===a||a.forEach((function(t){return i.push(t)})),null===(s=t.predecessors(u))||void 0===s||s.forEach((function(t){return i.push(t)}))}o.length&&n.push(o)})),n};var L=function t(e,n,r,o,i,a){o.includes(n)||(o.push(n),r||a.push(n),i(n).forEach((function(n){return t(e,n,r,o,i,a)})),r&&a.push(n))};const D=function(t,e,n){var r=Array.isArray(e)?e:[e],o=function(e){return t.isDirected()?t.successors(e):t.neighbors(e)},i=[],a=[];return r.forEach((function(e){if(!t.hasNode(e))throw new Error("Graph does not have node: "+e);L(t,e,"post"===n,a,o,i)})),i};function j(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!==typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var r,o,i=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);a=!0);}catch(u){s=!0,o=u}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}(t,e)||function(t,e){if(!t)return;if("string"===typeof t)return R(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return R(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&(o=s.removeMin(),!(i=a.get(o))||i.distance!==Number.POSITIVE_INFINITY);)r(o).forEach(u);var c={};return Array.from(a.entries()).forEach((function(t){var e=j(t,2),n=e[0],r=e[1];return c[String(n)]=r,c})),c};const z=function(t,e,n,r){return B(t,e,n||F,r||function(e){return t.outEdges(e)})};const G=function(t,e,n){var r={};return t.nodes().forEach((function(o){return r[String(o)]=z(t,o,e,n),r})),r};const U=function(t){var e=0,n=[],r=new Map,o=[];function i(a){var s,u={onStack:!0,lowlink:e,index:e};if(r.set(a,u),e+=1,n.push(a),null===(s=t.successors(a))||void 0===s||s.forEach((function(t){var e;if(r.has(t)){if(null===(e=r.get(t))||void 0===e?void 0:e.onStack){var n=r.get(t);u.lowlink=Math.min(u.lowlink,n.index)}}else{i(t);var o=r.get(t);u.lowlink=Math.min(u.lowlink,o.lowlink)}})),u.lowlink===u.index){var c,l=[];do{c=n.pop(),r.get(c).onStack=!1,l.push(c)}while(a!==c);o.push(l)}}return t.nodes().forEach((function(t){r.has(t)||i(t)})),o};const W=function(t){return U(t).filter((function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])}))};function Y(t){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Y(t)}function V(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n-1}(s),s&&-1===o.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===o[0])n(t,e);else if(s===o[1])n(t,e),t.right2left();else if(s===o[2])n(t,e);else if(s===o[3])n(t,e),t.bottom2top();else if(s===o[4]||s===o[5]){var u=r(t,e),c=u.left,l=u.right;n(c,e),n(l,e),e.isHorizontal?c.right2left():c.bottom2top(),l.translate(c.x-l.x,c.y-l.y),t.x=c.x,t.y=l.y;var d=t.getBoundingBox();e.isHorizontal?d.top<0&&t.translate(0,-d.top):d.left<0&&t.translate(-d.left,0)}var f=e.fixedRoot;return void 0===f&&(f=!0),f&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){var n=e.isHorizontal?["x","y"]:["y","x"],r=n[0],o=n[1],i={x:1/0,y:1/0},a={x:-1/0,y:-1/0},s=0;t.DFTraverse((function(t){s++;var e=t.x,n=t.y;i.x=Math.min(i.x,e),i.y=Math.min(i.y,n),a.x=Math.max(a.x,e),a.y=Math.max(a.y,n)}));var u=a[o]-i[o];if(0===u)return;var c=2*Math.PI/s;t.DFTraverse((function(e){var n=(e[o]-i[o])/u*(2*Math.PI-c)+c,a=e[r]-t[r];e.x=Math.cos(n)*a,e.y=Math.sin(n)*a}))}}(t,e),t}},function(t,e,n){var r=n(0),o={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.label||" ";return t.width||18*e.split("").length}};function i(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof i)return t;n.data=t;var r=e.getHGap(t),o=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(r,o),n}r.assign(i.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){var n=this;n.hgap+=t,n.vgap+=e,n.width+=2*t,n.height+=2*e},eachNode:function(t){for(var e,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode((function(e){t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)})),t},translate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode((function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV}))},right2left:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.x=t.x-2*(t.x-e.left)-t.width})),t.translate(e.width,0)},bottom2top:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.y=t.y-2*(t.y-e.top)-t.height})),t.translate(0,e.height)}}),t.exports=function(t,e,n){void 0===e&&(e={});var a,s=new i(t,e=r.assign({},o,e)),u=[s];if(!n&&!t.collapsed)for(;a=u.shift();)if(!a.data.collapsed){var c=e.getChildren(a.data),l=c?c.length:0;if(a.children=new Array(l),c&&l)for(var d=0;dn.low&&(n=n.nxt);var s=o+r.prelim+r.w-(a+i.prelim);s>0&&(a+=s,c(t,e,n.index,s));var u=f(r),h=f(i);u<=h&&null!==(r=d(r))&&(o+=r.mod),u>=h&&null!==(i=l(i))&&(a+=i.mod)}!r&&i?function(t,e,n,r){var o=t.c[0].el;o.tl=n;var i=r-n.mod-t.c[0].msel;o.mod+=i,o.prelim-=i,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,i,a):r&&!i&&function(t,e,n,r){var o=t.c[e].er;o.tr=n;var i=r-n.mod-t.c[e].mser;o.mod+=i,o.prelim-=i,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,o)}function c(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){var o=e-n;t.c[n+1].shift+=r/o,t.c[e].shift-=r/o,t.c[e].change-=r-r/o}}(t,e,n,r)}function l(t){return 0===t.cs?t.tl:t.c[0]}function d(t){return 0===t.cs?t.tr:t.c[t.cs-1]}function f(t){return t.y+t.h}function h(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}s(t,r);var p=n.fromNode(t,r);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=h(f(e.c[0].el),0,null),r=1;rs&&(s=e.depth);var n=e.children,r=n.length,i=new o(e.height,[]);return n.forEach((function(e,n){var o=t(e);i.children.push(o),0===n&&(i.leftChild=o),n===r-1&&(i.rightChild=o)})),i.originNode=e,i.isLeaf=e.isLeaf(),i}(t);return function t(e){if(e.isLeaf||0===e.children.length)e.drawingDepth=s;else{var n=e.children.map((function(e){return t(e)})),r=Math.min.apply(null,n);e.drawingDepth=r-1}return e.drawingDepth}(u),function t(r){r.x=r.drawingDepth*e.rankSep,r.isLeaf?(r.y=0,n&&(r.y=n.y+n.height+e.nodeSep,r.originNode.parent!==n.originNode.parent&&(r.y+=e.subTreeSep)),n=r):(r.children.forEach((function(e){t(e)})),r.y=(r.leftChild.y+r.rightChild.y)/2)}(u),a(u,t,e.isHorizontal),t}},function(t,e,n){function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}var o=n(1),i=n(11),a=n(4),s=n(0),u=["LR","RL","H"],c=u[0],l=function(t){function e(){return t.apply(this,arguments)||this}var n,o;return o=t,(n=e).prototype=Object.create(o.prototype),n.prototype.constructor=n,r(n,o),e.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,o=t.dropCap,s=void 0===o||o,l=t.direction,d=void 0===l?c:l,f=t.align;if(d&&-1===u.indexOf(d))throw new TypeError("Invalid direction: "+d);if(d===u[0])i(e,r,s,f);else if(d===u[1])i(e,r,s,f),e.right2left();else if(d===u[2]){var h=a(e,t),p=h.left,g=h.right;i(p,r,s,f),p.right2left(),i(g,r,s,f);var v=p.getBoundingBox();g.translate(v.width,0),e.x=g.x-e.width/2}return e},e}(o),d={};t.exports=function(t,e){return e=s.assign({},d,e),new l(t,e).execute()}},function(t,e,n){var r=n(0);t.exports=function(t,e,n,o){var i=null;t.eachNode((function(t){!function(t,e,n,o,i){var a=("function"===typeof n?n(t):n)*t.depth;if(!o)try{if(t.id===t.parent.children[0].id)return t.x+=a,void(t.y=e?e.y:0)}catch(c){}if(t.x+=a,e){if(t.y=e.y+r.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var s=e.parent,u=s.y+r.getHeight(s,t,i);t.y=u>t.y?u:t.y}}else t.y=0}(t,i,e,n,o),i=t}))}},function(t,e,n){function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}var o=n(1),i=n(13),a=n(2),s=n(0),u=function(t){function e(){return t.apply(this,arguments)||this}var n,o;return o=t,(n=e).prototype=Object.create(o.prototype),n.prototype.constructor=n,r(n,o),e.prototype.execute=function(){return a(this.rootNode,this.options,i)},e}(o),c={};t.exports=function(t,e){return e=s.assign({},c,e),new u(t,e).execute()}},function(t,e,n){var r=n(0);function o(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=o(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function i(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){i(t)}));var r=e[0],o=e[n-1],a=o.y-r.y+o.height,s=0;if(e.forEach((function(t){s+=t.totalHeight})),a>t.height)t.y=r.y+a/2-t.height/2;else if(1!==e.length||t.height>s){var u=t.y+(t.height-a)/2-r.y;e.forEach((function(t){t.translate(0,u)}))}else t.y=(r.y+r.height/2+o.y+o.height/2)/2-t.height/2}}var a={getSubTreeSep:function(){return 0}};t.exports=function(t,e){void 0===e&&(e={}),e=r.assign({},a,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse((function(t){t.x=t.parent.x+t.parent.width})),t.parent=null,o(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode((function(t){var e=t.children,n=e.length;if(n){var r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(var o=1;o{"use strict";var r=n(96);function o(t,e,n){var o=[0,0,0,0,0,0,0,0,0];return r.mat3.fromTranslation(o,n),r.mat3.multiply(t,o,e)}function i(t,e,n){var o=[0,0,0,0,0,0,0,0,0];return r.mat3.fromRotation(o,n),r.mat3.multiply(t,o,e)}function a(t,e,n){var o=[0,0,0,0,0,0,0,0,0];return r.mat3.fromScaling(o,n),r.mat3.multiply(t,o,e)}function s(t,e){return t[0]*e[1]-e[0]*t[1]}e.pd=function(t,e){for(var n,s,u,c=t?[].concat(t):[1,0,0,0,1,0,0,0,1],l=0,d=e.length;l{"use strict";n.r(e),n.d(e,{Cache:()=>Ae,assign:()=>Ht,augment:()=>qt,clamp:()=>et,clearAnimationFrame:()=>Vt,clone:()=>Kt,contains:()=>o,debounce:()=>$t,deepMix:()=>te,difference:()=>a,each:()=>h,endsWith:()=>W,every:()=>Y,extend:()=>ee,filter:()=>i,find:()=>y,findIndex:()=>b,firstValue:()=>x,fixedBase:()=>nt,flatten:()=>w,flattenDeep:()=>S,forIn:()=>xt,get:()=>de,getEllipsisText:()=>_e,getRange:()=>_,getType:()=>Nt,getWrapBehavior:()=>K,group:()=>Z,groupBy:()=>H,groupToMap:()=>q,has:()=>wt,hasKey:()=>Et,hasValue:()=>Mt,head:()=>z,identity:()=>we,includes:()=>o,indexOf:()=>ne,isArguments:()=>Pt,isArray:()=>d,isArrayLike:()=>r,isBoolean:()=>Lt,isDate:()=>Dt,isDecimal:()=>ot,isElement:()=>Wt,isEmpty:()=>oe,isEqual:()=>ae,isEqualWith:()=>se,isError:()=>jt,isEven:()=>it,isFinite:()=>Rt,isFunction:()=>c,isInteger:()=>at,isMatch:()=>g,isNegative:()=>st,isNil:()=>l,isNull:()=>Ft,isNumber:()=>rt,isNumberEqual:()=>ct,isObject:()=>f,isObjectLike:()=>v,isOdd:()=>lt,isPlainObject:()=>m,isPositive:()=>dt,isPrototype:()=>zt,isRegExp:()=>Gt,isString:()=>D,isType:()=>u,isUndefined:()=>Ut,keys:()=>p,last:()=>G,lowerCase:()=>_t,lowerFirst:()=>At,map:()=>ue,mapValues:()=>le,max:()=>M,maxBy:()=>ft,measureTextWidth:()=>ke,memoize:()=>Qt,min:()=>k,minBy:()=>ht,mix:()=>Ht,mod:()=>pt,noop:()=>xe,number2color:()=>J,omit:()=>ge,parseRadius:()=>tt,pick:()=>pe,pull:()=>I,pullAt:()=>N,reduce:()=>P,remove:()=>L,requestAnimationFrame:()=>Yt,set:()=>fe,size:()=>Ee,some:()=>V,sortBy:()=>j,startsWith:()=>U,substitute:()=>Ct,throttle:()=>ve,toArray:()=>me,toDegree:()=>vt,toInteger:()=>mt,toRadian:()=>bt,toString:()=>kt,union:()=>F,uniq:()=>R,uniqueId:()=>be,upperCase:()=>Ot,upperFirst:()=>It,values:()=>St,valuesOfKey:()=>B,wrapBehavior:()=>$});const r=function(t){return null!==t&&"function"!==typeof t&&isFinite(t.length)};const o=function(t,e){return!!r(t)&&t.indexOf(e)>-1};const i=function(t,e){if(!r(t))return t;for(var n=[],o=0;o-1;)C.call(t,i,1);return t};var T=Array.prototype.splice;const N=function(t,e){if(!r(t))return[];for(var n=t?e.length:0,o=n-1;n--;){var i=void 0,a=e[n];n!==o&&a===i||(i=a,T.call(t,a,1))}return t};const P=function(t,e,n){if(!d(t)&&!m(t))return t;var r=n;return h(t,(function(t,n){r=e(r,t,n)})),r};const L=function(t,e){var n=[];if(!r(t))return n;for(var o=-1,i=[],a=t.length;++oe[o])return 1;if(t[o]