LightRAG/lightrag/api/webui/assets/graph-vendor-B-X5JegA.js

313 lines
160 KiB
JavaScript
Raw Normal View History

2025-04-22 16:39:45 +08:00
import{g as xi,r as G,R as Me}from"./react-vendor-DEwriMA6.js";var Te={exports:{}},ut;function Ti(){if(ut)return Te.exports;ut=1;var n=typeof Reflect=="object"?Reflect:null,i=n&&typeof n.apply=="function"?n.apply:function(p,v,_){return Function.prototype.apply.call(p,v,_)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(p){return Object.getOwnPropertyNames(p).concat(Object.getOwnPropertySymbols(p))}:t=function(p){return Object.getOwnPropertyNames(p)};function e(g){console&&console.warn&&console.warn(g)}var r=Number.isNaN||function(p){return p!==p};function a(){a.init.call(this)}Te.exports=a,Te.exports.once=k,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function s(g){if(typeof g!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof g)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(g){if(typeof g!="number"||g<0||r(g))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+g+".");o=g}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(p){if(typeof p!="number"||p<0||r(p))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+p+".");return this._maxListeners=p,this};function u(g){return g._maxListeners===void 0?a.defaultMaxListeners:g._maxListeners}a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(p){for(var v=[],_=1;_<arguments.length;_++)v.push(arguments[_]);var A=p==="error",D=this._events;if(D!==void 0)A=A&&D.error===void 0;else if(!A)return!1;if(A){var L;if(v.length>0&&(L=v[0]),L instanceof Error)throw L;var F=new Error("Unhandled error."+(L?" ("+L.message+")":""));throw F.context=L,F}var P=D[p];if(P===void 0)return!1;if(typeof P=="function")i(P,this,v);else for(var q=P.length,O=y(P,q),_=0;_<q;++_)i(O[_],this,v);return!0};function h(g,p,v,_){var A,D,L;if(s(v),D=g._events,D===void 0?(D=g._events=Object.create(null),g._eventsCount=0):(D.newListener!==void 0&&(g.emit("newListener",p,v.listener?v.listener:v),D=g._events),L=D[p]),L===void 0)L=D[p]=v,++g._eventsCount;else if(typeof L=="function"?L=D[p]=_?[v,L]:[L,v]:_?L.unshift(v):L.push(v),A=u(g),A>0&&L.length>A&&!L.warned){L.warned=!0;var F=new Error("Possible EventEmitter memory leak detected. "+L.length+" "+String(p)+" listeners added. Use emitter.setMaxListeners() to increase limit");F.name="MaxListenersExceededWarning",F.emitter=g,F.type=p,F.count=L.length,e(F)}return g}a.prototype.addListener=function(p,v){return h(this,p,v,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(p,v){return h(this,p,v,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(g,p,v){var _={fired:!1,wrapFn:void 0,target:g,type:p,listener:v},A=d.bind(_);return A.listener=v,_.wrapFn=A,A}a.prototype.once=function(p,v){return s(v),this.on(p,l(this,p,v)),this},a.prototype.prependOnceListener=function(p,v){return s(v),this.prependListener(p,l(this,p,v)),this},a.prototype.removeListener=function(p,v){var _,A,D,L,F;if(s(v),A=this._events,A===void 0)return this;if(_=A[p],_===void 0)return this;if(_===v||_.listener===v)--this._eventsCount===0?this._events=Object.create(null):(delete A[p],A.removeListener&&this.emit("removeListener",p,_.listener||v));else if(typeof _!="function"){for(D=-1,L=_.length-1;L>=0;L--)if(_[L]===v||_[L].listener===v){F=_[L].listener,D=L;break}if(D<0)return this;D===0?_.shift():b(_,D),_.length===1&&(A[p]=_[0]),A.removeListener!==void 0&&this.emit("removeListener",p,F||v)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(p){var v,_
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function le(n,i){return Gr(n)||Fr(n,i)||Qt(n,i)||Pr()}var $e={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},ei=new Int8Array(4),Le=new Int32Array(ei.buffer,0,1),ti=new Float32Array(ei.buffer,0,1),Ir=/^\s*rgba?\s*\(/,Mr=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Or(n){var i=0,t=0,e=0,r=1;if(n[0]==="#")n.length===4?(i=parseInt(n.charAt(1)+n.charAt(1),16),t=parseInt(n.charAt(2)+n.charAt(2),16),e=parseInt(n.charAt(3)+n.charAt(3),16)):(i=parseInt(n.charAt(1)+n.charAt(2),16),t=parseInt(n.charAt(3)+n.charAt(4),16),e=parseInt(n.charAt(5)+n.charAt(6),16)),n.length===9&&(r=parseInt(n.charAt(7)+n.charAt(8),16)/255);else if(Ir.test(n)){var a=n.match(Mr);a&&(i=+a[1],t=+a[2],e=+a[3],a[4]&&(r=+a[4]))}return{r:i,g:t,b:e,a:r}}var he={};for(var Se in $e)he[Se]=pe($e[Se]),he[$e[Se]]=he[Se];function ii(n,i,t,e,r){return Le[0]=e<<24|t<<16|i<<8|n,Le[0]=Le[0]&4278190079,ti[0]}function pe(n){if(n=n.toLowerCase(),typeof he[n]<"u")return he[n];var i=Or(n),t=i.r,e=i.g,r=i.b,a=i.a;a=a*255|0;var o=ii(t,e,r,a);return he[n]=o,o}function ra(n,i){ti[0]=pe(n);var t=Le[0],e=t&
`.concat(o,`
`).concat(t))}return r}function zr(n,i){return ai("VERTEX",n,i)}function Br(n,i){return ai("FRAGMENT",n,i)}function Hr(n,i){var t=n.createProgram();if(t===null)throw new Error("loadProgram: error while creating the program.");var e,r;for(e=0,r=i.length;e<r;e++)n.attachShader(t,i[e]);n.linkProgram(t);var a=n.getProgramParameter(t,n.LINK_STATUS);if(!a)throw n.deleteProgram(t),new Error("loadProgram: error while linking the program.");return t}function mt(n){var i=n.gl,t=n.buffer,e=n.program,r=n.vertexShader,a=n.fragmentShader;i.deleteShader(r),i.deleteShader(a),i.deleteProgram(e),i.deleteBuffer(t)}function na(n){return n%1===0?n.toFixed(1):n.toString()}var vt=`#define PICKING_MODE
`,Wr=m(m(m(m(m(m(m(m({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),oi=function(){function n(i,t,e){U(this,n),m(this,"array",new Float32Array),m(this,"constantArray",new Float32Array),m(this,"capacity",0),m(this,"verticesCount",0);var r=this.getDefinition();if(this.VERTICES=r.VERTICES,this.VERTEX_SHADER_SOURCE=r.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=r.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=r.UNIFORMS,this.ATTRIBUTES=r.ATTRIBUTES,this.METHOD=r.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in r?r.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in r?r.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in r,this.ATTRIBUTES_ITEMS_COUNT=Be(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=e,this.normalProgram=this.getProgramInfo("normal",i,r.VERTEX_SHADER_SOURCE,r.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=t?this.getProgramInfo("pick",i,vt+r.VERTEX_SHADER_SOURCE,vt+r.FRAGMENT_SHADER_SOURCE,t):null,this.isInstanced){var a=Be(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*a);for(var o=0;o<this.CONSTANT_DATA.length;o++){var s=this.CONSTANT_DATA[o];if(s.length!==a)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(a,")"));for(var u=0;u<s.length;u++)this.constantArray[o*a+u]=s[u]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return $(n,[{key:"kill",value:function(){mt(this.normalProgram),this.pickProgram&&(mt(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(t,e,r,a,o){var s=this.getDefinition(),u=e.createBuffer();if(u===null)throw new Error("Program: error while creating the WebGL buffer.");var h=zr(e,r),d=Br(e,a),l=Hr(e,[h,d]),c={};s.UNIFORMS.forEach(function(b){var E=e.getUniformLocation(l,b);E&&(c[b]=E)});var f={};s.ATTRIBUTES.forEach(function(b){f[b.name]=e.getAttribLocation(l,b.name)});var y;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(b){f[b.name]=e.getAttribLocation(l,b.name)}),y=e.createBuffer(),y===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:t,program:l,gl:e,frameBuffer:o,buffer:u,constantBuffer:y||{},uniformLocations:c,attributeLocations:f,isPicking:t==="pick",vertexShader:h,fragmentShader:d}}},{key:"bindProgram",value:function(t){var e=this,r=0,a=t.gl,o=t.buffer;this.isInstanced?(a.bindBuffer(a.ARRAY_BUFFER,t.constantBuffer),r=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return r+=e.bindAttribute(s,t,r,!1)}),a.bufferData(a.ARRAY_BUFFER,this.constantArray,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,t.buffer),r=0,this.ATTRIBUTES.forEach(function(s){return r+=e.bindAttribute(s,t,r,!0)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)):(a.bindBuffer(a.ARRAY_BUFFER,o),r=0,this.ATTRIBUTES.forEach(function(s){return r+=e.bindAttribute(s,t,r)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)),a.bindBuffer(a.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(t){var e=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(r){return e.unbindAttribute(r,t,!1)}),this.ATTRIBUTES.forEach(function(r){return e.unbindAttribute(r,t,!0)})):this.ATTRIBUTES.forEach(function(r){return e.unbindAttribute(r,t)})}},{key:"bindAttribute",value:function(t,e,r,a){var o=Wr[t.type];if(typeof o!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(t.type,'"'));var s=e.attributeLocations[t.name],u=e.gl;if(s!==-1){u.enableVertexAttribArray(s);var h=this.isInstanced?(a?this.ATTRIBUTES_ITEMS_COUNT:Be(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Ar
precision highp float;
varying vec4 v_color;
varying vec2 v_diffVector;
varying float v_radius;
uniform float u_correctionRatio;
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
void main(void) {
float border = u_correctionRatio * 2.0;
float dist = length(v_diffVector) - v_radius + border;
// No antialiasing for picking mode:
#ifdef PICKING_MODE
if (dist > border)
gl_FragColor = transparent;
else
gl_FragColor = v_color;
#else
float t = 0.0;
if (dist > border)
t = 1.0;
else if (dist > 0.0)
t = dist / border;
gl_FragColor = mix(v_color, transparent, t);
#endif
}
`,Zr=qr,Xr=`
attribute vec4 a_id;
attribute vec4 a_color;
attribute vec2 a_position;
attribute float a_size;
attribute float a_angle;
uniform mat3 u_matrix;
uniform float u_sizeRatio;
uniform float u_correctionRatio;
varying vec4 v_color;
varying vec2 v_diffVector;
varying float v_radius;
varying float v_border;
const float bias = 255.0 / 254.0;
void main() {
float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
vec2 position = a_position + diffVector;
gl_Position = vec4(
(u_matrix * vec3(position, 1)).xy,
0,
1
);
v_diffVector = diffVector;
v_radius = size / 2.0;
#ifdef PICKING_MODE
// For picking mode, we use the ID as the color:
v_color = a_id;
#else
// For normal mode, we use the color:
v_color = a_color;
#endif
v_color.a *= bias;
}
`,Jr=Xr,ui=WebGLRenderingContext,yt=ui.UNSIGNED_BYTE,He=ui.FLOAT,Qr=["u_sizeRatio","u_correctionRatio","u_matrix"],Ge=function(n){function i(){return U(this,i),H(this,i,arguments)}return W(i,n),$(i,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Jr,FRAGMENT_SHADER_SOURCE:Zr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Qr,ATTRIBUTES:[{name:"a_position",size:2,type:He},{name:"a_size",size:1,type:He},{name:"a_color",size:4,type:yt,normalized:!0},{name:"a_id",size:4,type:yt,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:He}],CONSTANT_DATA:[[i.ANGLE_1],[i.ANGLE_2],[i.ANGLE_3]]}}},{key:"processVisibleItem",value:function(e,r,a){var o=this.array,s=pe(a.color);o[r++]=a.x,o[r++]=a.y,o[r++]=a.size,o[r++]=s,o[r++]=e}},{key:"setUniforms",value:function(e,r){var a=r.gl,o=r.uniformLocations,s=o.u_sizeRatio,u=o.u_correctionRatio,h=o.u_matrix;a.uniform1f(u,e.correctionRatio),a.uniform1f(s,e.sizeRatio),a.uniformMatrix3fv(h,!1,e.matrix)}}])}(jr);m(Ge,"ANGLE_1",0);m(Ge,"ANGLE_2",2*Math.PI/3);m(Ge,"ANGLE_3",4*Math.PI/3);var en=`
precision mediump float;
varying vec4 v_color;
void main(void) {
gl_FragColor = v_color;
}
`,tn=en,rn=`
attribute vec2 a_position;
attribute vec2 a_normal;
attribute float a_radius;
attribute vec3 a_barycentric;
#ifdef PICKING_MODE
attribute vec4 a_id;
#else
attribute vec4 a_color;
#endif
uniform mat3 u_matrix;
uniform float u_sizeRatio;
uniform float u_correctionRatio;
uniform float u_minEdgeThickness;
uniform float u_lengthToThicknessRatio;
uniform float u_widenessToThicknessRatio;
varying vec4 v_color;
const float bias = 255.0 / 254.0;
void main() {
float minThickness = u_minEdgeThickness;
float normalLength = length(a_normal);
vec2 unitNormal = a_normal / normalLength;
// These first computations are taken from edge.vert.glsl and
// edge.clamped.vert.glsl. Please read it to get better comments on what's
// happening:
float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
float webGLThickness = pixelsThickness * u_correctionRatio;
float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
float da = a_barycentric.x;
float db = a_barycentric.y;
float dc = a_barycentric.z;
vec2 delta = vec2(
da * (webGLNodeRadius * unitNormal.y)
+ db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
+ dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
da * (-webGLNodeRadius * unitNormal.x)
+ db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
+ dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
);
vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
gl_Position = vec4(position, 0, 1);
#ifdef PICKING_MODE
// For picking mode, we use the ID as the color:
v_color = a_id;
#else
// For normal mode, we use the color:
v_color = a_color;
#endif
v_color.a *= bias;
}
`,nn=rn,hi=WebGLRenderingContext,bt=hi.UNSIGNED_BYTE,ke=hi.FLOAT,an=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],di={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function li(n){var i=S(S({},di),n||{});return function(t){function e(){return U(this,e),H(this,e,arguments)}return W(e,t),$(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:nn,FRAGMENT_SHADER_SOURCE:tn,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:an,ATTRIBUTES:[{name:"a_position",size:2,type:ke},{name:"a_normal",size:2,type:ke},{name:"a_radius",size:1,type:ke},{name:"a_color",size:4,type:bt,normalized:!0},{name:"a_id",size:4,type:bt,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:ke}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(a,o,s,u,h){if(i.extremity==="source"){var d=[u,s];s=d[0],u=d[1]}var l=h.size||1,c=u.size||1,f=s.x,y=s.y,b=u.x,E=u.y,k=pe(h.color),x=b-f,T=E-y,g=x*x+T*T,p=0,v=0;g&&(g=1/Math.sqrt(g),p=-T*g*l,v=x*g*l);var _=this.array;_[o++]=b,_[o++]=E,_[o++]=-p,_[o++]=-v,_[o++]=c,_[o++]=k,_[o++]=a}},{key:"setUniforms",value:function(a,o){var s=o.gl,u=o.uniformLocations,h=u.u_matrix,d=u.u_sizeRatio,l=u.u_correctionRatio,c=u.u_minEdgeThickness,f=u.u_lengthToThicknessRatio,y=u.u_widenessToThicknessRatio;s.uniformMatrix3fv(h,!1,a.matrix),s.uniform1f(d,a.sizeRatio),s.uniform1f(l,a.correctionRatio),s.uniform1f(c,a.minEdgeThickness),s.uniform1f(f,i.lengthToThicknessRatio),s.uniform1f(y,i.widenessToThicknessRatio)}}])}(rt)}li();var on=`
precision mediump float;
varying vec4 v_color;
varying vec2 v_normal;
varying float v_thickness;
varying float v_feather;
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
void main(void) {
// We only handle antialiasing for normal mode:
#ifdef PICKING_MODE
gl_FragColor = v_color;
#else
float dist = length(v_normal) * v_thickness;
float t = smoothstep(
v_thickness - v_feather,
v_thickness,
dist
);
gl_FragColor = mix(v_color, transparent, t);
#endif
}
`,ci=on,sn=`
attribute vec4 a_id;
attribute vec4 a_color;
attribute vec2 a_normal;
attribute float a_normalCoef;
attribute vec2 a_positionStart;
attribute vec2 a_positionEnd;
attribute float a_positionCoef;
attribute float a_radius;
attribute float a_radiusCoef;
uniform mat3 u_matrix;
uniform float u_zoomRatio;
uniform float u_sizeRatio;
uniform float u_pixelRatio;
uniform float u_correctionRatio;
uniform float u_minEdgeThickness;
uniform float u_lengthToThicknessRatio;
uniform float u_feather;
varying vec4 v_color;
varying vec2 v_normal;
varying float v_thickness;
varying float v_feather;
const float bias = 255.0 / 254.0;
void main() {
float minThickness = u_minEdgeThickness;
float radius = a_radius * a_radiusCoef;
vec2 normal = a_normal * a_normalCoef;
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
float normalLength = length(normal);
vec2 unitNormal = normal / normalLength;
// These first computations are taken from edge.vert.glsl. Please read it to
// get better comments on what's happening:
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
// Here, we move the point to leave space for the arrow head:
float direction = sign(radius);
float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
// Here is the proper position of the vertex
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
v_thickness = webGLThickness / u_zoomRatio;
v_normal = unitNormal;
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
#ifdef PICKING_MODE
// For picking mode, we use the ID as the color:
v_color = a_id;
#else
// For normal mode, we use the color:
v_color = a_color;
#endif
v_color.a *= bias;
}
`,un=sn,fi=WebGLRenderingContext,wt=fi.UNSIGNED_BYTE,oe=fi.FLOAT,hn=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],dn={lengthToThicknessRatio:di.lengthToThicknessRatio};function gi(n){var i=S(S({},dn),{});return function(t){function e(){return U(this,e),H(this,e,arguments)}return W(e,t),$(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:un,FRAGMENT_SHADER_SOURCE:ci,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:hn,ATTRIBUTES:[{name:"a_positionStart",size:2,type:oe},{name:"a_positionEnd",size:2,type:oe},{name:"a_normal",size:2,type:oe},{name:"a_color",size:4,type:wt,normalized:!0},{name:"a_id",size:4,type:wt,normalized:!0},{name:"a_radius",size:1,type:oe}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:oe},{name:"a_normalCoef",size:1,type:oe},{name:"a_radiusCoef",size:1,type:oe}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(a,o,s,u,h){var d=h.size||1,l=s.x,c=s.y,f=u.x,y=u.y,b=pe(h.color),E=f-l,k=y-c,x=u.size||1,T=E*E+k*k,g=0,p=0;T&&(T=1/Math.sqrt(T),g=-k*T*d,p=E*T*d);var v=this.array;v[o++]=l,v[o++]=c,v[o++]=f,v[o++]=y,v[o++]=g,v[o++]=p,v[o++]=b,v[o++]=a,v[o++]=x}},{key:"setUniforms",value:function(a,o){var s=o.gl,u=o.uniformLocations,h=u.u_matrix,d=u.u_zoomRatio,l=u.u_feather,c=u.u_pixelRatio,f=u.u_correctionRatio,y=u.u_sizeRatio,b=u.u_minEdgeThickness,E=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(h,!1,a.matrix),s.uniform1f(d,a.zoomRatio),s.uniform1f(y,a.sizeRatio),s.uniform1f(f,a.correctionRatio),s.uniform1f(c,a.pixelRatio),s.uniform1f(l,a.antiAliasingFeather),s.uniform1f(b,a.minEdgeThickness),s.uniform1f(E,i.lengthToThicknessRatio)}}])}(rt)}gi();function ln(n){return Vr([gi(),li(n)])}var cn=ln(),fn=cn,gn=`
attribute vec4 a_id;
attribute vec4 a_color;
attribute vec2 a_normal;
attribute float a_normalCoef;
attribute vec2 a_positionStart;
attribute vec2 a_positionEnd;
attribute float a_positionCoef;
uniform mat3 u_matrix;
uniform float u_sizeRatio;
uniform float u_zoomRatio;
uniform float u_pixelRatio;
uniform float u_correctionRatio;
uniform float u_minEdgeThickness;
uniform float u_feather;
varying vec4 v_color;
varying vec2 v_normal;
varying float v_thickness;
varying float v_feather;
const float bias = 255.0 / 254.0;
void main() {
float minThickness = u_minEdgeThickness;
vec2 normal = a_normal * a_normalCoef;
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
float normalLength = length(normal);
vec2 unitNormal = normal / normalLength;
// We require edges to be at least "minThickness" pixels thick *on screen*
// (so we need to compensate the size ratio):
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
// Then, we need to retrieve the normalized thickness of the edge in the WebGL
// referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
// ratio:
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
// Here is the proper position of the vertex
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
// For the fragment shader though, we need a thickness that takes the "magic"
// correction ratio into account (as in webGLThickness), but so that the
// antialiasing effect does not depend on the zoom level. So here's yet
// another thickness version:
v_thickness = webGLThickness / u_zoomRatio;
v_normal = unitNormal;
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
#ifdef PICKING_MODE
// For picking mode, we use the ID as the color:
v_color = a_id;
#else
// For normal mode, we use the color:
v_color = a_color;
#endif
v_color.a *= bias;
}
`,pn=gn,pi=WebGLRenderingContext,Et=pi.UNSIGNED_BYTE,ye=pi.FLOAT,mn=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],vn=function(n){function i(){return U(this,i),H(this,i,arguments)}return W(i,n),$(i,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:pn,FRAGMENT_SHADER_SOURCE:ci,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:mn,ATTRIBUTES:[{name:"a_positionStart",size:2,type:ye},{name:"a_positionEnd",size:2,type:ye},{name:"a_normal",size:2,type:ye},{name:"a_color",size:4,type:Et,normalized:!0},{name:"a_id",size:4,type:Et,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:ye},{name:"a_normalCoef",size:1,type:ye}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(e,r,a,o,s){var u=s.size||1,h=a.x,d=a.y,l=o.x,c=o.y,f=pe(s.color),y=l-h,b=c-d,E=y*y+b*b,k=0,x=0;E&&(E=1/Math.sqrt(E),k=-b*E*u,x=y*E*u);var T=this.array;T[r++]=h,T[r++]=d,T[r++]=l,T[r++]=c,T[r++]=k,T[r++]=x,T[r++]=f,T[r++]=e}},{key:"setUniforms",value:function(e,r){var a=r.gl,o=r.uniformLocations,s=o.u_matrix,u=o.u_zoomRatio,h=o.u_feather,d=o.u_pixelRatio,l=o.u_correctionRatio,c=o.u_sizeRatio,f=o.u_minEdgeThickness;a.uniformMatrix3fv(s,!1,e.matrix),a.uniform1f(u,e.zoomRatio),a.uniform1f(c,e.sizeRatio),a.uniform1f(l,e.correctionRatio),a.uniform1f(d,e.pixelRatio),a.uniform1f(h,e.antiAliasingFeather),a.uniform1f(f,e.minEdgeThickness)}}])}(rt),nt=function(n){function i(){var t;return U(this,i),t=H(this,i),t.rawEmitter=t,t}return W(i,n),$(i)}(Mt.EventEmitter),We,_t;function yn(){return _t||(_t=1,We=function(i){return i!==null&&typeof i=="object"&&typeof i.addUndirectedEdgeWithKey=="function"&&typeof i.dropNode=="function"&&typeof i.multi=="boolean"}),We}var bn=yn();const wn=xi(bn);var En=function(i){return i},_n=function(i){return i*i},xn=function(i){return i*(2-i)},Tn=function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)},Cn=function(i){return i*i*i},Sn=function(i){return--i*i*i+1},kn=function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)},mi={linear:En,quadraticIn:_n,quadraticOut:xn,quadraticInOut:Tn,cubicIn:Cn,cubicOut:Sn,cubicInOut:kn},vi={easing:"quadraticInOut",duration:150};function aa(n,i,t,e){var r=Object.assign({},vi,t),a=typeof r.easing=="function"?r.easing:mi[r.easing],o=Date.now(),s={};for(var u in i){var h=i[u];s[u]={};for(var d in h)s[u][d]=n.getNodeAttribute(u,d)}var l=null,c=function(){l=null;var y=(Date.now()-o)/r.duration;if(y>=1){for(var b in i){var E=i[b];for(var k in E)n.setNodeAttribute(b,k,E[k])}return}y=a(y);for(var x in i){var T=i[x],g=s[x];for(var p in T)n.setNodeAttribute(x,p,T[p]*y+g[p]*(1-y))}l=requestAnimationFrame(c)};return c(),function(){l&&cancelAnimationFrame(l)}}function K(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ae(n,i,t){return n[0]=i,n[4]=typeof t=="number"?t:i,n}function xt(n,i){var t=Math.sin(i),e=Math.cos(i);return n[0]=e,n[1]=t,n[3]=-t,n[4]=e,n}function Tt(n,i,t){return n[6]=i,n[7]=t,n}function ne(n,i){var t=n[0],e=n[1],r=n[2],a=n[3],o=n[4],s=n[5],u=n[6],h=n[7],d=n[8],l=i[0],c=i[1],f=i[2],y=i[3],b=i[4],E=i[5],k=i[6],x=i[7],T=i[8];return n[0]=l*t+c*a+f*u,n[1]=l*e+c*o+f*h,n[2]=l*r+c*s+f*d,n[3]=y*t+b*a+E*u,n[4]=y*e+b*o+E*h,n[5]=y*r+b*s+E*d,n[6]=k*t+x*a+T*u,n[7]=k*e+x*o+T*h,n[8]=k*r+x*s+T*d,n}function Xe(n,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,e=n[0],r=n[1],a=n[3],o=n[4],s=n[6],u=n[7],h=i.x,d=i.y;return{x:h*e+d*a+s*t,y:h*r+d*o+u*t}}function An(n,i){var t=n.height/n.width,e=i.height/i.width;return t<1&&e>1||t>1&&e<1?1:Math.min(Math.max(e,1/e),Math.max(1/t,t))}function be(n,i,t,e,r){var a=n.angle,o=n.ratio,s=n.x,u=n.y,h=i.width,d=i.height,l=K(),c=Math.min(h,d)-2*e,f=An(i,t);return r?(ne(l,Tt(K(),s,u)),ne(l,Ae(K(),o)),ne(l,xt(K(),a)),ne(l,Ae(K(),h/c/2/f,d/c/2/f))):(ne(l,Ae(K(),2*(c/h)*f,2*(c/d)*f)),ne(l,xt(K(),-a)),ne(l,Ae(K(),1/o)),ne(l,Tt(K(),-s,-u))),l}function Rn(n,i,t){var e=Xe(n,{x:Math.cos(i.angle),y:Math.sin(i.angle)},0),r=e.x,a=e.y;return 1/Math.sqrt(Math.pow(r,2)+Math.pow(a,2))/t.width}function Ln(n){if(!n.order)return{x:[0,1],y:[0,
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lt(n){return Wn(n)||jn(n)||Qt(n)||Vn()}function Kn(n,i){if(n==null)return{};var t={};for(var e in n)if({}.hasOwnProperty.call(n,e)){if(i.includes(e))continue;t[e]=n[e]}return t}function Ke(n,i){if(n==null)return{};var t,e,r=Kn(n,i);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(e=0;e<a.length;e++)t=a[e],i.includes(t)||{}.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}var Dt=function(){function n(i,t){U(this,n),this.key=i,this.size=t}return $(n,null,[{key:"compare",value:function(t,e){return t.size>e.size?-1:t.size<e.size||t.key>e.key?1:-1}}])}(),Nt=function(){function n(){U(this,n),m(this,"width",0),m(this,"height",0),m(this,"cellSize",0),m(this,"columns",0),m(this,"rows",0),m(this,"cells",{})}return $(n,[{key:"resizeAndClear",value:function(t,e){this.width=t.width,this.height=t.height,this.cellSize=e,this.columns=Math.ceil(t.width/e),this.rows=Math.ceil(t.height/e),this.cells={}}},{key:"getIndex",value:function(t){var e=Math.floor(t.x/this.cellSize),r=Math.floor(t.y/this.cellSize);return r*this.columns+e}},{key:"add",value:function(t,e,r){var a=new Dt(t,e),o=this.getIndex(r),s=this.cells[o];s||(s=[],this.cells[o]=s),s.push(a)}},{key:"organize",value:function(){for(var t in this.cells){var e=this.cells[t];e.sort(Dt.compare)}}},{key:"getLabelsToDisplay",value:function(t,e){var r=this.cellSize*this.cellSize,a=r/t/t,o=a*e/r,s=Math.ceil(o),u=[];for(var h in this.cells)for(var d=this.cells[h],l=0;l<Math.min(s,d.length);l++)u.push(d[l].key);return u}}])}();function Yn(n){var i=n.graph,t=n.hoveredNode,e=n.highlightedNodes,r=n.displayedNodeLabels,a=[];return i.forEachEdge(function(o,s,u,h){(u===t||h===t||e.has(u)||e.has(h)||r.has(u)&&r.has(h))&&a.push(o)}),a}var qn=150,Zn=50,J=Object.prototype.hasOwnProperty;function Xn(n,i,t){if(!J.call(t,"x")||!J.call(t,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(i,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return t.color||(t.color=n.defaultNodeColor),!t.label&&t.label!==""&&(t.label=null),t.label!==void 0&&t.label!==null?t.label=""+t.label:t.label=null,t.size||(t.size=2),J.call(t,"hidden")||(t.hidden=!1),J.call(t,"highlighted")||(t.highlighted=!1),J.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=n.defaultNodeType),t.zIndex||(t.zIndex=0),t}function Jn(n,i,t){return t.color||(t.color=n.defaultEdgeColor),t.label||(t.label=""),t.size||(t.size=.5),J.call(t,"hidden")||(t.hidden=!1),J.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=n.defaultEdgeType),t.zIndex||(t.zIndex=0),t}var Qn=function(n){function i(t,e){var r,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(U(this,i),r=H(this,i),m(r,"elements",{}),m(r,"canvasContexts",{}),m(r,"webGLContexts",{}),m(r,"pickingLayers",new Set),m(r,"textures",{}),m(r,"frameBuffers",{}),m(r,"activeListeners",{}),m(r,"labelGrid",new Nt),m(r,"nodeDataCache",{}),m(r,"edgeDataCache",{}),m(r,"nodeProgramIndex",{}),m(r,"edgeProgramIndex",{}),m(r,"nodesWithForcedLabels",new Set),m(r,"edgesWithForcedLabels",new Set),m(r,"nodeExtent",{x:[0,1],y:[0,1]}),m(r,"nodeZExtent",[1/0,-1/0]),m(r,"edgeZExtent",[1/0,-1/0]),m(r,"matrix",K()),m(r,"invMatrix",K()),m(r,"correctionRatio",1),m(r,"customBBox",null),m(r,"normalizationFunction",kt({x:[0,1],y:[0,1]})),m(r,"graphToViewportRatio",1),m(r,"itemIDsIndex",{}),m(r,"nodeIndices",{}),m(r,"edgeIndices",{}),m(r,"width",0),m(r,"height",0),m(r,"pixelRatio",Ct()),m(r,"pickingDownSizingRatio",2*r.pixelRatio),m(r,"displayedNodeLabels",new Set),m(r,"displayedEdgeLabels",new Set),m(r,"highlightedNodes",new Set),m(r,"hoveredNode",null),m(r,"hoveredEdge",null),m(r,"renderFrame",null),m(r,"renderHighlightedNodesFrame",null),m(r,"needToProcess",!1),m(r,"checkEdgesEventsFrame",null),m(r,"nodePrograms",{}),m(r,"nodeHoverPrograms",{}),m(r,"edgePrograms",{}),r.settings=Pn(a),Ve(r.settings),Dn(t),!(e instanceof HTMLElement