cognitivebc 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +70 -0
  2. package/README.md +98 -4
  3. package/SECURITY.md +29 -0
  4. package/TERMS_OF_SERVICE.md +55 -0
  5. package/bin/cbc-cloud-bootstrap.js +108 -0
  6. package/bin/cbc-seed-projects.js +29 -0
  7. package/bin/cbc-server.js +45 -0
  8. package/bin/cognitivebc.js +251 -0
  9. package/docs/ACCESS_CONTROL.md +111 -0
  10. package/docs/ARTIFACT_AUDIT.md +36 -0
  11. package/docs/CONNECT_CLIENTS.md +116 -0
  12. package/docs/DEPLOY_AZURE.md +136 -0
  13. package/docs/INGESTION.md +29 -0
  14. package/docs/OPERATIONS.md +85 -0
  15. package/docs/PROJECT_IDENTITY.md +35 -0
  16. package/docs/RESOLVER.md +86 -0
  17. package/docs/SDK.md +96 -0
  18. package/docs/STORAGE.md +63 -0
  19. package/docs/TECHNICAL_SPECIFICATION.md +365 -0
  20. package/docs/TELEMETRY.md +119 -0
  21. package/index.js +27 -2
  22. package/package.json +45 -5
  23. package/packages/cbc-compiler/index.js +357 -0
  24. package/packages/cbc-compiler/sanitizer.js +43 -0
  25. package/packages/cbc-identity/index.js +92 -0
  26. package/packages/cbc-mcp/http-backend.js +138 -0
  27. package/packages/cbc-mcp/http-route.js +64 -0
  28. package/packages/cbc-mcp/index.js +50 -0
  29. package/packages/cbc-mcp/tools.js +122 -0
  30. package/packages/cbc-resolver/catalog-linker.js +215 -0
  31. package/packages/cbc-resolver/graph-builder.js +533 -0
  32. package/packages/cbc-resolver/index.js +548 -0
  33. package/packages/cbc-resolver/obsidian-bridge.js +564 -0
  34. package/packages/cbc-schema/index.js +194 -0
  35. package/packages/cbc-sdk-js/client.js +162 -0
  36. package/services/cbc-api/access-policy.js +130 -0
  37. package/services/cbc-api/artifact-audit.js +167 -0
  38. package/services/cbc-api/cloud.js +56 -0
  39. package/services/cbc-api/context-service.js +48 -0
  40. package/services/cbc-api/ingestion-service.js +234 -0
  41. package/services/cbc-api/pg-store.js +172 -0
  42. package/services/cbc-api/project-registry.js +322 -0
  43. package/services/cbc-api/public/app.html +123 -0
  44. package/services/cbc-api/public/graph.html +1168 -0
  45. package/services/cbc-api/public/graph2.html +455 -0
  46. package/services/cbc-api/public/graph3.html +503 -0
  47. package/services/cbc-api/public/index.html +78 -0
  48. package/services/cbc-api/public/vendor/cbc-app.js +209 -0
  49. package/services/cbc-api/public/vendor/cbc-auth.js +49 -0
  50. package/services/cbc-api/public/vendor/cbc-site.css +101 -0
  51. package/services/cbc-api/public/vendor/cose-base.js +3214 -0
  52. package/services/cbc-api/public/vendor/cytoscape-dagre.js +397 -0
  53. package/services/cbc-api/public/vendor/cytoscape-fcose.js +1549 -0
  54. package/services/cbc-api/public/vendor/cytoscape.min.js +32 -0
  55. package/services/cbc-api/public/vendor/dagre.min.js +3809 -0
  56. package/services/cbc-api/public/vendor/graphology-library.min.js +2 -0
  57. package/services/cbc-api/public/vendor/graphology.umd.min.js +2 -0
  58. package/services/cbc-api/public/vendor/layout-base.js +5230 -0
  59. package/services/cbc-api/public/vendor/pf-graph.css +86 -0
  60. package/services/cbc-api/public/vendor/pf-telemetry.js +176 -0
  61. package/services/cbc-api/public/vendor/sigma.min.js +1351 -0
  62. package/services/cbc-api/runtime-info.js +39 -0
  63. package/services/cbc-api/server.js +642 -0
  64. package/services/cbc-api/store-loader.js +269 -0
  65. package/services/cbc-api/telemetry.js +148 -0
  66. package/services/cbc-api/token-service.js +61 -0
@@ -0,0 +1,1351 @@
1
+ (function(Ce,de){typeof exports=="object"&&typeof module<"u"?module.exports=de():typeof define=="function"&&define.amd?define(de):(Ce=typeof globalThis<"u"?globalThis:Ce||self,Ce.Sigma=de())})(this,function(){"use strict";function Ce(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function de(r){var e=Ce(r,"string");return typeof e=="symbol"?e:e+""}function ne(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Rn(r,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,de(i.key),i)}}function oe(r,e,t){return e&&Rn(r.prototype,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function fe(r){return fe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},fe(r)}function dr(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dr=function(){return!!r})()}function fr(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Cn(r,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return fr(r)}function we(r,e,t){return e=fe(e),Cn(r,dr()?Reflect.construct(e,t||[],fe(r).constructor):e.apply(r,t))}function it(r,e){return it=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},it(r,e)}function Ae(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&it(r,e)}var nt={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"},gr=new Int8Array(4),Ie=new Int32Array(gr.buffer,0,1),mr=new Float32Array(gr.buffer,0,1),wn=/^\s*rgba?\s*\(/,An=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Sn(r){var e=0,t=0,i=0,n=1;if(r[0]==="#")r.length===4?(e=parseInt(r.charAt(1)+r.charAt(1),16),t=parseInt(r.charAt(2)+r.charAt(2),16),i=parseInt(r.charAt(3)+r.charAt(3),16)):(e=parseInt(r.charAt(1)+r.charAt(2),16),t=parseInt(r.charAt(3)+r.charAt(4),16),i=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(n=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(wn.test(r)){var o=r.match(An);o&&(e=+o[1],t=+o[2],i=+o[3],o[4]&&(n=+o[4]))}return{r:e,g:t,b:i,a:n}}var ge={};for(var ze in nt)ge[ze]=K(nt[ze]),ge[nt[ze]]=ge[ze];function vr(r,e,t,i,n){return Ie[0]=i<<24|t<<16|e<<8|r,Ie[0]=Ie[0]&4278190079,mr[0]}function K(r){if(r=r.toLowerCase(),typeof ge[r]<"u")return ge[r];var e=Sn(r),t=e.r,i=e.g,n=e.b,o=e.a;o=o*255|0;var a=vr(t,i,n,o);return ge[r]=a,a}function ot(r,e){mr[0]=K(r);var t=Ie[0],i=t&255,n=t>>8&255,o=t>>16&255,a=t>>24&255;return[i,n,o,a]}var at={};function pr(r){if(typeof at[r]<"u")return at[r];var e=(r&16711680)>>>16,t=(r&65280)>>>8,i=r&255,n=255,o=vr(e,t,i,n);return at[r]=o,o}function O(r,e,t){return(e=de(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function _r(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function me(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?_r(Object(t),!0).forEach(function(i){O(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):_r(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function xn(r,e){for(;!{}.hasOwnProperty.call(r,e)&&(r=fe(r))!==null;);return r}function st(){return st=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,e,t){var i=xn(r,e);if(i){var n=Object.getOwnPropertyDescriptor(i,e);return n.get?n.get.call(arguments.length<3?r:t):n.value}},st.apply(null,arguments)}function br(r,e,t,i){var n=st(fe(r.prototype),e,t);return typeof n=="function"?function(o){return n.apply(t,o)}:n}function Fn(r){return r.normalized?1:r.size}function ct(r){var e=0;return r.forEach(function(t){return e+=Fn(t)}),e}function yr(r,e,t){var i=r==="VERTEX"?e.VERTEX_SHADER:e.FRAGMENT_SHADER,n=e.createShader(i);if(n===null)throw new Error("loadShader: error while creating the shader");e.shaderSource(n,t),e.compileShader(n);var o=e.getShaderParameter(n,e.COMPILE_STATUS);if(!o){var a=e.getShaderInfoLog(n);throw e.deleteShader(n),new Error(`loadShader: error while compiling the shader:
2
+ `.concat(a,`
3
+ `).concat(t))}return n}function Ln(r,e){return yr("VERTEX",r,e)}function Nn(r,e){return yr("FRAGMENT",r,e)}function Pn(r,e){var t=r.createProgram();if(t===null)throw new Error("loadProgram: error while creating the program.");var i,n;for(i=0,n=e.length;i<n;i++)r.attachShader(t,e[i]);r.linkProgram(t);var o=r.getProgramParameter(t,r.LINK_STATUS);if(!o)throw r.deleteProgram(t),new Error("loadProgram: error while linking the program.");return t}function Er(r){var e=r.gl,t=r.buffer,i=r.program,n=r.vertexShader,o=r.fragmentShader;e.deleteShader(n),e.deleteShader(o),e.deleteProgram(i),e.deleteBuffer(t)}function lt(r){return r%1===0?r.toFixed(1):r.toString()}var Tr=`#define PICKING_MODE
4
+ `,Dn=O(O(O(O(O(O(O(O({},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),Rr=function(){function r(e,t,i){ne(this,r),O(this,"array",new Float32Array),O(this,"constantArray",new Float32Array),O(this,"capacity",0),O(this,"verticesCount",0);var n=this.getDefinition();if(this.VERTICES=n.VERTICES,this.VERTEX_SHADER_SOURCE=n.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=n.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=n.UNIFORMS,this.ATTRIBUTES=n.ATTRIBUTES,this.METHOD=n.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in n?n.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in n?n.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in n,this.ATTRIBUTES_ITEMS_COUNT=ct(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=i,this.normalProgram=this.getProgramInfo("normal",e,n.VERTEX_SHADER_SOURCE,n.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=t?this.getProgramInfo("pick",e,Tr+n.VERTEX_SHADER_SOURCE,Tr+n.FRAGMENT_SHADER_SOURCE,t):null,this.isInstanced){var o=ct(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*o);for(var a=0;a<this.CONSTANT_DATA.length;a++){var s=this.CONSTANT_DATA[a];if(s.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(o,")"));for(var c=0;c<s.length;c++)this.constantArray[a*o+c]=s[c]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return oe(r,[{key:"kill",value:function(){Er(this.normalProgram),this.pickProgram&&(Er(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(t,i,n,o,a){var s=this.getDefinition(),c=i.createBuffer();if(c===null)throw new Error("Program: error while creating the WebGL buffer.");var l=Ln(i,n),u=Nn(i,o),h=Pn(i,[l,u]),d={};s.UNIFORMS.forEach(function(p){var b=i.getUniformLocation(h,p);b&&(d[p]=b)});var m={};s.ATTRIBUTES.forEach(function(p){m[p.name]=i.getAttribLocation(h,p.name)});var f;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(p){m[p.name]=i.getAttribLocation(h,p.name)}),f=i.createBuffer(),f===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:t,program:h,gl:i,frameBuffer:a,buffer:c,constantBuffer:f||{},uniformLocations:d,attributeLocations:m,isPicking:t==="pick",vertexShader:l,fragmentShader:u}}},{key:"bindProgram",value:function(t){var i=this,n=0,o=t.gl,a=t.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,t.constantBuffer),n=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return n+=i.bindAttribute(s,t,n,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,t.buffer),n=0,this.ATTRIBUTES.forEach(function(s){return n+=i.bindAttribute(s,t,n,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),n=0,this.ATTRIBUTES.forEach(function(s){return n+=i.bindAttribute(s,t,n)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(t){var i=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(n){return i.unbindAttribute(n,t,!1)}),this.ATTRIBUTES.forEach(function(n){return i.unbindAttribute(n,t,!0)})):this.ATTRIBUTES.forEach(function(n){return i.unbindAttribute(n,t)})}},{key:"bindAttribute",value:function(t,i,n,o){var a=Dn[t.type];if(typeof a!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(t.type,'"'));var s=i.attributeLocations[t.name],c=i.gl;if(s!==-1){c.enableVertexAttribArray(s);var l=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:ct(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(c.vertexAttribPointer(s,t.size,t.type,t.normalized||!1,l,n),this.isInstanced&&o)if(c instanceof WebGL2RenderingContext)c.vertexAttribDivisor(s,1);else{var u=c.getExtension("ANGLE_instanced_arrays");u&&u.vertexAttribDivisorANGLE(s,1)}}return t.size*a}},{key:"unbindAttribute",value:function(t,i,n){var o=i.attributeLocations[t.name],a=i.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&n))if(a instanceof WebGL2RenderingContext)a.vertexAttribDivisor(o,0);else{var s=a.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(t){t!==this.capacity&&(this.capacity=t,this.verticesCount=this.VERTICES*t,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(t,i){var n=i.gl,o=i.program;n.enable(n.BLEND),n.useProgram(o),this.setUniforms(t,i),this.drawWebGL(this.METHOD,i)}},{key:"render",value:function(t){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,t.width*t.pixelRatio/t.downSizingRatio,t.height*t.pixelRatio/t.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(me(me({},t),{},{pixelRatio:t.pixelRatio/t.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,t.width*t.pixelRatio,t.height*t.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(t,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(t,i){var n=i.gl,o=i.frameBuffer;if(n.bindFramebuffer(n.FRAMEBUFFER,o),!this.isInstanced)n.drawArrays(t,0,this.verticesCount);else if(n instanceof WebGL2RenderingContext)n.drawArraysInstanced(t,0,this.VERTICES,this.capacity);else{var a=n.getExtension("ANGLE_instanced_arrays");a&&a.drawArraysInstancedANGLE(t,0,this.VERTICES,this.capacity)}}}]),r}(),Ge=function(r){Ae(e,r);function e(){return ne(this,e),we(this,e,arguments)}return oe(e,[{key:"kill",value:function(){br(e,"kill",this)([])}},{key:"process",value:function(i,n,o){var a=n*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(pr(i),a,o)}}]),e}(Rr),ut=function(r){Ae(e,r);function e(){var t;ne(this,e);for(var i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return t=we(this,e,[].concat(n)),O(fr(t),"drawLabel",void 0),t}return oe(e,[{key:"kill",value:function(){br(e,"kill",this)([])}},{key:"process",value:function(i,n,o,a,s){var c=n*this.STRIDE;if(s.hidden||o.hidden||a.hidden){for(var l=c+this.STRIDE;c<l;c++)this.array[c]=0;return}return this.processVisibleItem(pr(i),c,o,a,s)}}]),e}(Rr);function On(r,e){return function(){function t(i,n,o){ne(this,t),O(this,"drawLabel",e),this.programs=r.map(function(a){return new a(i,n,o)})}return oe(t,[{key:"reallocate",value:function(n){this.programs.forEach(function(o){return o.reallocate(n)})}},{key:"process",value:function(n,o,a,s,c){this.programs.forEach(function(l){return l.process(n,o,a,s,c)})}},{key:"render",value:function(n){this.programs.forEach(function(o){return o.render(n)})}},{key:"kill",value:function(){this.programs.forEach(function(n){return n.kill()})}}]),t}()}var kn=`
5
+ precision highp float;
6
+
7
+ varying vec4 v_color;
8
+ varying vec2 v_diffVector;
9
+ varying float v_radius;
10
+
11
+ uniform float u_correctionRatio;
12
+
13
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
14
+
15
+ void main(void) {
16
+ float border = u_correctionRatio * 2.0;
17
+ float dist = length(v_diffVector) - v_radius + border;
18
+
19
+ // No antialiasing for picking mode:
20
+ #ifdef PICKING_MODE
21
+ if (dist > border)
22
+ gl_FragColor = transparent;
23
+ else
24
+ gl_FragColor = v_color;
25
+
26
+ #else
27
+ float t = 0.0;
28
+ if (dist > border)
29
+ t = 1.0;
30
+ else if (dist > 0.0)
31
+ t = dist / border;
32
+
33
+ gl_FragColor = mix(v_color, transparent, t);
34
+ #endif
35
+ }
36
+ `,In=kn,zn=`
37
+ attribute vec4 a_id;
38
+ attribute vec4 a_color;
39
+ attribute vec2 a_position;
40
+ attribute float a_size;
41
+ attribute float a_angle;
42
+
43
+ uniform mat3 u_matrix;
44
+ uniform float u_sizeRatio;
45
+ uniform float u_correctionRatio;
46
+
47
+ varying vec4 v_color;
48
+ varying vec2 v_diffVector;
49
+ varying float v_radius;
50
+ varying float v_border;
51
+
52
+ const float bias = 255.0 / 254.0;
53
+
54
+ void main() {
55
+ float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
56
+ vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
57
+ vec2 position = a_position + diffVector;
58
+ gl_Position = vec4(
59
+ (u_matrix * vec3(position, 1)).xy,
60
+ 0,
61
+ 1
62
+ );
63
+
64
+ v_diffVector = diffVector;
65
+ v_radius = size / 2.0;
66
+
67
+ #ifdef PICKING_MODE
68
+ // For picking mode, we use the ID as the color:
69
+ v_color = a_id;
70
+ #else
71
+ // For normal mode, we use the color:
72
+ v_color = a_color;
73
+ #endif
74
+
75
+ v_color.a *= bias;
76
+ }
77
+ `,Gn=zn,Cr=WebGLRenderingContext,wr=Cr.UNSIGNED_BYTE,ht=Cr.FLOAT,Mn=["u_sizeRatio","u_correctionRatio","u_matrix"],dt=function(r){Ae(e,r);function e(){return ne(this,e),we(this,e,arguments)}return oe(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Gn,FRAGMENT_SHADER_SOURCE:In,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Mn,ATTRIBUTES:[{name:"a_position",size:2,type:ht},{name:"a_size",size:1,type:ht},{name:"a_color",size:4,type:wr,normalized:!0},{name:"a_id",size:4,type:wr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:ht}],CONSTANT_DATA:[[e.ANGLE_1],[e.ANGLE_2],[e.ANGLE_3]]}}},{key:"processVisibleItem",value:function(i,n,o){var a=this.array,s=K(o.color);a[n++]=o.x,a[n++]=o.y,a[n++]=o.size,a[n++]=s,a[n++]=i}},{key:"setUniforms",value:function(i,n){var o=n.gl,a=n.uniformLocations,s=a.u_sizeRatio,c=a.u_correctionRatio,l=a.u_matrix;o.uniform1f(c,i.correctionRatio),o.uniform1f(s,i.sizeRatio),o.uniformMatrix3fv(l,!1,i.matrix)}}]),e}(Ge);O(dt,"ANGLE_1",0),O(dt,"ANGLE_2",2*Math.PI/3),O(dt,"ANGLE_3",4*Math.PI/3);var Un=`
78
+ precision mediump float;
79
+
80
+ varying vec4 v_color;
81
+
82
+ void main(void) {
83
+ gl_FragColor = v_color;
84
+ }
85
+ `,Bn=Un,Hn=`
86
+ attribute vec2 a_position;
87
+ attribute vec2 a_normal;
88
+ attribute float a_radius;
89
+ attribute vec3 a_barycentric;
90
+
91
+ #ifdef PICKING_MODE
92
+ attribute vec4 a_id;
93
+ #else
94
+ attribute vec4 a_color;
95
+ #endif
96
+
97
+ uniform mat3 u_matrix;
98
+ uniform float u_sizeRatio;
99
+ uniform float u_correctionRatio;
100
+ uniform float u_minEdgeThickness;
101
+ uniform float u_lengthToThicknessRatio;
102
+ uniform float u_widenessToThicknessRatio;
103
+
104
+ varying vec4 v_color;
105
+
106
+ const float bias = 255.0 / 254.0;
107
+
108
+ void main() {
109
+ float minThickness = u_minEdgeThickness;
110
+
111
+ float normalLength = length(a_normal);
112
+ vec2 unitNormal = a_normal / normalLength;
113
+
114
+ // These first computations are taken from edge.vert.glsl and
115
+ // edge.clamped.vert.glsl. Please read it to get better comments on what's
116
+ // happening:
117
+ float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
118
+ float webGLThickness = pixelsThickness * u_correctionRatio;
119
+ float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
120
+ float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
121
+ float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
122
+
123
+ float da = a_barycentric.x;
124
+ float db = a_barycentric.y;
125
+ float dc = a_barycentric.z;
126
+
127
+ vec2 delta = vec2(
128
+ da * (webGLNodeRadius * unitNormal.y)
129
+ + db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
130
+ + dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
131
+
132
+ da * (-webGLNodeRadius * unitNormal.x)
133
+ + db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
134
+ + dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
135
+ );
136
+
137
+ vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
138
+
139
+ gl_Position = vec4(position, 0, 1);
140
+
141
+ #ifdef PICKING_MODE
142
+ // For picking mode, we use the ID as the color:
143
+ v_color = a_id;
144
+ #else
145
+ // For normal mode, we use the color:
146
+ v_color = a_color;
147
+ #endif
148
+
149
+ v_color.a *= bias;
150
+ }
151
+ `,$n=Hn,Ar=WebGLRenderingContext,Sr=Ar.UNSIGNED_BYTE,Me=Ar.FLOAT,jn=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],ft={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function xr(r){var e=me(me({},ft),{});return function(t){Ae(i,t);function i(){return ne(this,i),we(this,i,arguments)}return oe(i,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:$n,FRAGMENT_SHADER_SOURCE:Bn,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:jn,ATTRIBUTES:[{name:"a_position",size:2,type:Me},{name:"a_normal",size:2,type:Me},{name:"a_radius",size:1,type:Me},{name:"a_color",size:4,type:Sr,normalized:!0},{name:"a_id",size:4,type:Sr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Me}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,c,l){if(e.extremity==="source"){var u=[c,s];s=u[0],c=u[1]}var h=l.size||1,d=c.size||1,m=s.x,f=s.y,p=c.x,b=c.y,g=K(l.color),_=p-m,v=b-f,y=_*_+v*v,C=0,S=0;y&&(y=1/Math.sqrt(y),C=-v*y*h,S=_*y*h);var w=this.array;w[a++]=p,w[a++]=b,w[a++]=-C,w[a++]=-S,w[a++]=d,w[a++]=g,w[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,c=a.uniformLocations,l=c.u_matrix,u=c.u_sizeRatio,h=c.u_correctionRatio,d=c.u_minEdgeThickness,m=c.u_lengthToThicknessRatio,f=c.u_widenessToThicknessRatio;s.uniformMatrix3fv(l,!1,o.matrix),s.uniform1f(u,o.sizeRatio),s.uniform1f(h,o.correctionRatio),s.uniform1f(d,o.minEdgeThickness),s.uniform1f(m,e.lengthToThicknessRatio),s.uniform1f(f,e.widenessToThicknessRatio)}}]),i}(ut)}xr();var Vn=`
152
+ precision mediump float;
153
+
154
+ varying vec4 v_color;
155
+ varying vec2 v_normal;
156
+ varying float v_thickness;
157
+ varying float v_feather;
158
+
159
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
160
+
161
+ void main(void) {
162
+ // We only handle antialiasing for normal mode:
163
+ #ifdef PICKING_MODE
164
+ gl_FragColor = v_color;
165
+ #else
166
+ float dist = length(v_normal) * v_thickness;
167
+
168
+ float t = smoothstep(
169
+ v_thickness - v_feather,
170
+ v_thickness,
171
+ dist
172
+ );
173
+
174
+ gl_FragColor = mix(v_color, transparent, t);
175
+ #endif
176
+ }
177
+ `,Wn=Vn,Yn=`
178
+ attribute vec4 a_id;
179
+ attribute vec4 a_color;
180
+ attribute vec2 a_normal;
181
+ attribute float a_normalCoef;
182
+ attribute vec2 a_positionStart;
183
+ attribute vec2 a_positionEnd;
184
+ attribute float a_positionCoef;
185
+ attribute float a_radius;
186
+ attribute float a_radiusCoef;
187
+
188
+ uniform mat3 u_matrix;
189
+ uniform float u_zoomRatio;
190
+ uniform float u_sizeRatio;
191
+ uniform float u_pixelRatio;
192
+ uniform float u_correctionRatio;
193
+ uniform float u_minEdgeThickness;
194
+ uniform float u_lengthToThicknessRatio;
195
+ uniform float u_feather;
196
+
197
+ varying vec4 v_color;
198
+ varying vec2 v_normal;
199
+ varying float v_thickness;
200
+ varying float v_feather;
201
+
202
+ const float bias = 255.0 / 254.0;
203
+
204
+ void main() {
205
+ float minThickness = u_minEdgeThickness;
206
+
207
+ float radius = a_radius * a_radiusCoef;
208
+ vec2 normal = a_normal * a_normalCoef;
209
+ vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
210
+
211
+ float normalLength = length(normal);
212
+ vec2 unitNormal = normal / normalLength;
213
+
214
+ // These first computations are taken from edge.vert.glsl. Please read it to
215
+ // get better comments on what's happening:
216
+ float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
217
+ float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
218
+
219
+ // Here, we move the point to leave space for the arrow head:
220
+ float direction = sign(radius);
221
+ float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
222
+ float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
223
+
224
+ vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
225
+
226
+ // Here is the proper position of the vertex
227
+ gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
228
+
229
+ v_thickness = webGLThickness / u_zoomRatio;
230
+
231
+ v_normal = unitNormal;
232
+
233
+ v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
234
+
235
+ #ifdef PICKING_MODE
236
+ // For picking mode, we use the ID as the color:
237
+ v_color = a_id;
238
+ #else
239
+ // For normal mode, we use the color:
240
+ v_color = a_color;
241
+ #endif
242
+
243
+ v_color.a *= bias;
244
+ }
245
+ `,Xn=Yn,Fr=WebGLRenderingContext,Lr=Fr.UNSIGNED_BYTE,ae=Fr.FLOAT,qn=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Kn={lengthToThicknessRatio:ft.lengthToThicknessRatio};function Nr(r){var e=me(me({},Kn),{});return function(t){Ae(i,t);function i(){return ne(this,i),we(this,i,arguments)}return oe(i,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Xn,FRAGMENT_SHADER_SOURCE:Wn,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:qn,ATTRIBUTES:[{name:"a_positionStart",size:2,type:ae},{name:"a_positionEnd",size:2,type:ae},{name:"a_normal",size:2,type:ae},{name:"a_color",size:4,type:Lr,normalized:!0},{name:"a_id",size:4,type:Lr,normalized:!0},{name:"a_radius",size:1,type:ae}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:ae},{name:"a_normalCoef",size:1,type:ae},{name:"a_radiusCoef",size:1,type:ae}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,c,l){var u=l.size||1,h=s.x,d=s.y,m=c.x,f=c.y,p=K(l.color),b=m-h,g=f-d,_=c.size||1,v=b*b+g*g,y=0,C=0;v&&(v=1/Math.sqrt(v),y=-g*v*u,C=b*v*u);var S=this.array;S[a++]=h,S[a++]=d,S[a++]=m,S[a++]=f,S[a++]=y,S[a++]=C,S[a++]=p,S[a++]=o,S[a++]=_}},{key:"setUniforms",value:function(o,a){var s=a.gl,c=a.uniformLocations,l=c.u_matrix,u=c.u_zoomRatio,h=c.u_feather,d=c.u_pixelRatio,m=c.u_correctionRatio,f=c.u_sizeRatio,p=c.u_minEdgeThickness,b=c.u_lengthToThicknessRatio;s.uniformMatrix3fv(l,!1,o.matrix),s.uniform1f(u,o.zoomRatio),s.uniform1f(f,o.sizeRatio),s.uniform1f(m,o.correctionRatio),s.uniform1f(d,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(p,o.minEdgeThickness),s.uniform1f(b,e.lengthToThicknessRatio)}}]),i}(ut)}Nr();function Zn(r){return On([Nr(),xr()])}Zn();function Qn(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Jn=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"};const eo=Qn(Jn);function to(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function ro(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Pr(r){var e=ro(r,"string");return typeof e=="symbol"?e:e+""}function io(r,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,Pr(i.key),i)}}function no(r,e,t){return e&&io(r.prototype,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function Ue(r){return Ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ue(r)}function Dr(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Dr=function(){return!!r})()}function Or(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function oo(r,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Or(r)}function ao(r,e,t){return e=Ue(e),oo(r,Dr()?Reflect.construct(e,t||[],Ue(r).constructor):e.apply(r,t))}function gt(r,e){return gt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},gt(r,e)}function so(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&gt(r,e)}function kr(r,e,t){return(e=Pr(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function mt(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,i=Array(e);t<e;t++)i[t]=r[t];return i}function co(r){if(Array.isArray(r))return mt(r)}function lo(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function uo(r,e){if(r){if(typeof r=="string")return mt(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?mt(r,e):void 0}}function ho(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
246
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ir(r){return co(r)||lo(r)||uo(r)||ho()}function zr(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function Gr(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?zr(Object(t),!0).forEach(function(i){kr(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):zr(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function Mr(r,e,t,i){var n=Math.pow(1-r,2)*e.x+2*(1-r)*r*t.x+Math.pow(r,2)*i.x,o=Math.pow(1-r,2)*e.y+2*(1-r)*r*t.y+Math.pow(r,2)*i.y;return{x:n,y:o}}function fo(r,e,t){for(var i=20,n=0,o=r,a=0;a<i;a++){var s=Mr((a+1)/i,r,e,t);n+=Math.sqrt(Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2)),o=s}return n}function go(r){var e=r.curvatureAttribute,t=r.defaultCurvature,i=r.keepLabelUpright,n=i===void 0?!0:i;return function(o,a,s,c,l){var u=l.edgeLabelSize,h=a[e]||t,d=l.edgeLabelFont,m=l.edgeLabelWeight,f=l.edgeLabelColor.attribute?a[l.edgeLabelColor.attribute]||l.edgeLabelColor.color||"#000":l.edgeLabelColor.color,p=a.label;if(p){o.fillStyle=f,o.font="".concat(m," ").concat(u,"px ").concat(d);var b=!n||s.x<c.x,g=b?s.x:c.x,_=b?s.y:c.y,v=b?c.x:s.x,y=b?c.y:s.y,C=(g+v)/2,S=(_+y)/2,w=v-g,P=y-_,k=Math.sqrt(Math.pow(w,2)+Math.pow(P,2)),D=b?1:-1,U=C+P*h*D,z=S-w*h*D,B=a.size*.7+5,H={x:z-_,y:-(U-g)},$=Math.sqrt(Math.pow(H.x,2)+Math.pow(H.y,2)),T={x:y-z,y:-(v-U)},E=Math.sqrt(Math.pow(T.x,2)+Math.pow(T.y,2));g+=B*H.x/$,_+=B*H.y/$,v+=B*T.x/E,y+=B*T.y/E,U+=B*P/k,z-=B*w/k;var R={x:U,y:z},x={x:g,y:_},A={x:v,y},F=fo(x,R,A);if(!(F<s.size+c.size)){var N=o.measureText(p).width,G=F-s.size-c.size;if(N>G){var M="…";for(p=p+M,N=o.measureText(p).width;N>G&&p.length>1;)p=p.slice(0,-2)+M,N=o.measureText(p).width;if(p.length<4)return}for(var q={},te=0,re=p.length;te<re;te++){var ur=p[te];q[ur]||(q[ur]=o.measureText(ur).width*(1+h*.35))}for(var Re=.5-N/F/2,hr=0,xs=p.length;hr<xs;hr++){var En=p[hr],Tn=Mr(Re,x,R,A),Fs=2*(1-Re)*(U-g)+2*Re*(v-U),Ls=2*(1-Re)*(z-_)+2*Re*(y-z),Ns=Math.atan2(Ls,Fs);o.save(),o.translate(Tn.x,Tn.y),o.rotate(Ns),o.fillText(En,0,0),o.restore(),Re+=q[En]/F}}}}}function mo(r){var e=r.arrowHead,t=`
247
+ precision highp float;
248
+
249
+ varying vec4 v_color;
250
+ varying float v_thickness;
251
+ varying float v_feather;
252
+ varying vec2 v_cpA;
253
+ varying vec2 v_cpB;
254
+ varying vec2 v_cpC;
255
+ `.concat(e?`
256
+ varying float v_targetSize;
257
+ varying vec2 v_targetPoint;
258
+
259
+ uniform float u_lengthToThicknessRatio;
260
+ uniform float u_widenessToThicknessRatio;`:"",`
261
+
262
+ float det(vec2 a, vec2 b) {
263
+ return a.x * b.y - b.x * a.y;
264
+ }
265
+
266
+ vec2 getDistanceVector(vec2 b0, vec2 b1, vec2 b2) {
267
+ float a = det(b0, b2), b = 2.0 * det(b1, b0), d = 2.0 * det(b2, b1);
268
+ float f = b * d - a * a;
269
+ vec2 d21 = b2 - b1, d10 = b1 - b0, d20 = b2 - b0;
270
+ vec2 gf = 2.0 * (b * d21 + d * d10 + a * d20);
271
+ gf = vec2(gf.y, -gf.x);
272
+ vec2 pp = -f * gf / dot(gf, gf);
273
+ vec2 d0p = b0 - pp;
274
+ float ap = det(d0p, d20), bp = 2.0 * det(d10, d0p);
275
+ float t = clamp((ap + bp) / (2.0 * a + b + d), 0.0, 1.0);
276
+ return mix(mix(b0, b1, t), mix(b1, b2, t), t);
277
+ }
278
+
279
+ float distToQuadraticBezierCurve(vec2 p, vec2 b0, vec2 b1, vec2 b2) {
280
+ return length(getDistanceVector(b0 - p, b1 - p, b2 - p));
281
+ }
282
+
283
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
284
+
285
+ void main(void) {
286
+ float dist = distToQuadraticBezierCurve(gl_FragCoord.xy, v_cpA, v_cpB, v_cpC);
287
+ float thickness = v_thickness;
288
+ `).concat(e?`
289
+ float distToTarget = length(gl_FragCoord.xy - v_targetPoint);
290
+ float arrowLength = v_targetSize + thickness * u_lengthToThicknessRatio;
291
+ if (distToTarget < arrowLength) {
292
+ thickness = (distToTarget - v_targetSize) / (arrowLength - v_targetSize) * u_widenessToThicknessRatio * thickness;
293
+ }`:"",`
294
+
295
+ float halfThickness = thickness / 2.0;
296
+ if (dist < halfThickness) {
297
+ #ifdef PICKING_MODE
298
+ gl_FragColor = v_color;
299
+ #else
300
+ float t = smoothstep(
301
+ halfThickness - v_feather,
302
+ halfThickness,
303
+ dist
304
+ );
305
+
306
+ gl_FragColor = mix(v_color, transparent, t);
307
+ #endif
308
+ } else {
309
+ gl_FragColor = transparent;
310
+ }
311
+ }
312
+ `);return t}function vo(r){var e=r.arrowHead,t=`
313
+ attribute vec4 a_id;
314
+ attribute vec4 a_color;
315
+ attribute float a_direction;
316
+ attribute float a_thickness;
317
+ attribute vec2 a_source;
318
+ attribute vec2 a_target;
319
+ attribute float a_current;
320
+ attribute float a_curvature;
321
+ `.concat(e?`attribute float a_targetSize;
322
+ `:"",`
323
+
324
+ uniform mat3 u_matrix;
325
+ uniform float u_sizeRatio;
326
+ uniform float u_pixelRatio;
327
+ uniform vec2 u_dimensions;
328
+ uniform float u_minEdgeThickness;
329
+ uniform float u_feather;
330
+
331
+ varying vec4 v_color;
332
+ varying float v_thickness;
333
+ varying float v_feather;
334
+ varying vec2 v_cpA;
335
+ varying vec2 v_cpB;
336
+ varying vec2 v_cpC;
337
+ `).concat(e?`
338
+ varying float v_targetSize;
339
+ varying vec2 v_targetPoint;
340
+ uniform float u_widenessToThicknessRatio;
341
+ `:"",`
342
+
343
+ const float bias = 255.0 / 254.0;
344
+ const float epsilon = 0.7;
345
+
346
+ vec2 clipspaceToViewport(vec2 pos, vec2 dimensions) {
347
+ return vec2(
348
+ (pos.x + 1.0) * dimensions.x / 2.0,
349
+ (pos.y + 1.0) * dimensions.y / 2.0
350
+ );
351
+ }
352
+
353
+ vec2 viewportToClipspace(vec2 pos, vec2 dimensions) {
354
+ return vec2(
355
+ pos.x / dimensions.x * 2.0 - 1.0,
356
+ pos.y / dimensions.y * 2.0 - 1.0
357
+ );
358
+ }
359
+
360
+ void main() {
361
+ float minThickness = u_minEdgeThickness;
362
+
363
+ // Selecting the correct position
364
+ // Branchless "position = a_source if a_current == 1.0 else a_target"
365
+ vec2 position = a_source * max(0.0, a_current) + a_target * max(0.0, 1.0 - a_current);
366
+ position = (u_matrix * vec3(position, 1)).xy;
367
+
368
+ vec2 source = (u_matrix * vec3(a_source, 1)).xy;
369
+ vec2 target = (u_matrix * vec3(a_target, 1)).xy;
370
+
371
+ vec2 viewportPosition = clipspaceToViewport(position, u_dimensions);
372
+ vec2 viewportSource = clipspaceToViewport(source, u_dimensions);
373
+ vec2 viewportTarget = clipspaceToViewport(target, u_dimensions);
374
+
375
+ vec2 delta = viewportTarget.xy - viewportSource.xy;
376
+ float len = length(delta);
377
+ vec2 normal = vec2(-delta.y, delta.x) * a_direction;
378
+ vec2 unitNormal = normal / len;
379
+ float boundingBoxThickness = len * a_curvature;
380
+
381
+ float curveThickness = max(minThickness, a_thickness / u_sizeRatio);
382
+ v_thickness = curveThickness * u_pixelRatio;
383
+ v_feather = u_feather;
384
+
385
+ v_cpA = viewportSource;
386
+ v_cpB = 0.5 * (viewportSource + viewportTarget) + unitNormal * a_direction * boundingBoxThickness;
387
+ v_cpC = viewportTarget;
388
+
389
+ vec2 viewportOffsetPosition = (
390
+ viewportPosition +
391
+ unitNormal * (boundingBoxThickness / 2.0 + sign(boundingBoxThickness) * (`).concat(e?"curveThickness * u_widenessToThicknessRatio":"curveThickness",` + epsilon)) *
392
+ max(0.0, a_direction) // NOTE: cutting the bounding box in half to avoid overdraw
393
+ );
394
+
395
+ position = viewportToClipspace(viewportOffsetPosition, u_dimensions);
396
+ gl_Position = vec4(position, 0, 1);
397
+
398
+ `).concat(e?`
399
+ v_targetSize = a_targetSize * u_pixelRatio / u_sizeRatio;
400
+ v_targetPoint = viewportTarget;
401
+ `:"",`
402
+
403
+ #ifdef PICKING_MODE
404
+ // For picking mode, we use the ID as the color:
405
+ v_color = a_id;
406
+ #else
407
+ // For normal mode, we use the color:
408
+ v_color = a_color;
409
+ #endif
410
+
411
+ v_color.a *= bias;
412
+ }
413
+ `);return t}var Ur=.25,po={arrowHead:null,curvatureAttribute:"curvature",defaultCurvature:Ur},Br=WebGLRenderingContext,Hr=Br.UNSIGNED_BYTE,se=Br.FLOAT;function $r(r){var e=Gr(Gr({},po),r||{}),t=e,i=t.arrowHead,n=t.curvatureAttribute,o=t.drawLabel,a=["u_matrix","u_sizeRatio","u_dimensions","u_pixelRatio","u_feather","u_minEdgeThickness"].concat(Ir(i?["u_lengthToThicknessRatio","u_widenessToThicknessRatio"]:[]));return function(s){so(c,s);function c(){var l;to(this,c);for(var u=arguments.length,h=new Array(u),d=0;d<u;d++)h[d]=arguments[d];return l=ao(this,c,[].concat(h)),kr(Or(l),"drawLabel",o||go(e)),l}return no(c,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:vo(e),FRAGMENT_SHADER_SOURCE:mo(e),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:a,ATTRIBUTES:[{name:"a_source",size:2,type:se},{name:"a_target",size:2,type:se}].concat(Ir(i?[{name:"a_targetSize",size:1,type:se}]:[]),[{name:"a_thickness",size:1,type:se},{name:"a_curvature",size:1,type:se},{name:"a_color",size:4,type:Hr,normalized:!0},{name:"a_id",size:4,type:Hr,normalized:!0}]),CONSTANT_ATTRIBUTES:[{name:"a_current",size:1,type:se},{name:"a_direction",size:1,type:se}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[0,-1],[1,1],[1,-1]]}}},{key:"processVisibleItem",value:function(u,h,d,m,f){var p,b=f.size||1,g=d.x,_=d.y,v=m.x,y=m.y,C=K(f.color),S=(p=f[n])!==null&&p!==void 0?p:Ur,w=this.array;w[h++]=g,w[h++]=_,w[h++]=v,w[h++]=y,i&&(w[h++]=m.size),w[h++]=b,w[h++]=S,w[h++]=C,w[h++]=u}},{key:"setUniforms",value:function(u,h){var d=h.gl,m=h.uniformLocations,f=m.u_matrix,p=m.u_pixelRatio,b=m.u_feather,g=m.u_sizeRatio,_=m.u_dimensions,v=m.u_minEdgeThickness;if(d.uniformMatrix3fv(f,!1,u.matrix),d.uniform1f(p,u.pixelRatio),d.uniform1f(g,u.sizeRatio),d.uniform1f(b,u.antiAliasingFeather),d.uniform2f(_,u.width*u.pixelRatio,u.height*u.pixelRatio),d.uniform1f(v,u.minEdgeThickness),i){var y=m.u_lengthToThicknessRatio,C=m.u_widenessToThicknessRatio;d.uniform1f(y,i.lengthToThicknessRatio),d.uniform1f(C,i.widenessToThicknessRatio)}}}]),c}(ut)}var _o=$r();$r({arrowHead:ft});function bo(r){if(Array.isArray(r))return r}function yo(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var i,n,o,a,s=[],c=!0,l=!1;try{if(o=(t=t.call(r)).next,e!==0)for(;!(c=(i=o.call(t)).done)&&(s.push(i.value),s.length!==e);c=!0);}catch(u){l=!0,n=u}finally{try{if(!c&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw n}}return s}}function vt(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,i=Array(e);t<e;t++)i[t]=r[t];return i}function jr(r,e){if(r){if(typeof r=="string")return vt(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?vt(r,e):void 0}}function Eo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
414
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function To(r,e){return bo(r)||yo(r,e)||jr(r,e)||Eo()}function Ro(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Co(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Vr(r){var e=Co(r,"string");return typeof e=="symbol"?e:e+""}function wo(r,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,Vr(i.key),i)}}function Ao(r,e,t){return e&&wo(r.prototype,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function Be(r){return Be=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Be(r)}function Wr(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Wr=function(){return!!r})()}function pt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function So(r,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pt(r)}function xo(r,e,t){return e=Be(e),So(r,Wr()?Reflect.construct(e,t||[],Be(r).constructor):e.apply(r,t))}function _t(r,e){return _t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},_t(r,e)}function Fo(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&_t(r,e)}function ve(r,e,t){return(e=Vr(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Lo(r){if(Array.isArray(r))return vt(r)}function No(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function Po(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
415
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function bt(r){return Lo(r)||No(r)||jr(r)||Po()}function Yr(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function Xr(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Yr(Object(t),!0).forEach(function(i){ve(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Yr(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}var Do="relative",Oo={drawLabel:void 0,drawHover:void 0,borders:[{size:{value:.1},color:{attribute:"borderColor"}},{size:{fill:!0},color:{attribute:"color"}}]},ko="#000000";function Io(r){var e=r.borders,t=lt(e.filter(function(n){var o=n.size;return"fill"in o}).length),i=`
416
+ precision highp float;
417
+
418
+ varying vec2 v_diffVector;
419
+ varying float v_radius;
420
+
421
+ #ifdef PICKING_MODE
422
+ varying vec4 v_color;
423
+ #else
424
+ // For normal mode, we use the border colors defined in the program:
425
+ `.concat(e.flatMap(function(n,o){var a=n.size;return"attribute"in a?["varying float v_borderSize_".concat(o+1,";")]:[]}).join(`
426
+ `),`
427
+ `).concat(e.flatMap(function(n,o){var a=n.color;return"attribute"in a?["varying vec4 v_borderColor_".concat(o+1,";")]:"value"in a?["uniform vec4 u_borderColor_".concat(o+1,";")]:[]}).join(`
428
+ `),`
429
+ #endif
430
+
431
+ uniform float u_correctionRatio;
432
+
433
+ const float bias = 255.0 / 254.0;
434
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
435
+
436
+ void main(void) {
437
+ float dist = length(v_diffVector);
438
+ float aaBorder = 2.0 * u_correctionRatio;
439
+ float v_borderSize_0 = v_radius;
440
+ vec4 v_borderColor_0 = transparent;
441
+
442
+ // No antialiasing for picking mode:
443
+ #ifdef PICKING_MODE
444
+ if (dist > v_radius)
445
+ gl_FragColor = transparent;
446
+ else {
447
+ gl_FragColor = v_color;
448
+ gl_FragColor.a *= bias;
449
+ }
450
+ #else
451
+ // Sizes:
452
+ `).concat(e.flatMap(function(n,o){var a=n.size;if("fill"in a)return[];a=a;var s="attribute"in a?"v_borderSize_".concat(o+1):lt(a.value),c=(a.mode||Do)==="pixels"?"u_correctionRatio":"v_radius";return[" float borderSize_".concat(o+1," = ").concat(c," * ").concat(s,";")]}).join(`
453
+ `),`
454
+ // Now, let's split the remaining space between "fill" borders:
455
+ float fillBorderSize = (v_radius - (`).concat(e.flatMap(function(n,o){var a=n.size;return"fill"in a?[]:["borderSize_".concat(o+1)]}).join(" + "),") ) / ").concat(t,`;
456
+ `).concat(e.flatMap(function(n,o){var a=n.size;return"fill"in a?[" float borderSize_".concat(o+1," = fillBorderSize;")]:[]}).join(`
457
+ `),`
458
+
459
+ // Finally, normalize all border sizes, to start from the full size and to end with the smallest:
460
+ float adjustedBorderSize_0 = v_radius;
461
+ `).concat(e.map(function(n,o){return" float adjustedBorderSize_".concat(o+1," = adjustedBorderSize_").concat(o," - borderSize_").concat(o+1,";")}).join(`
462
+ `),`
463
+
464
+ // Colors:
465
+ vec4 borderColor_0 = transparent;
466
+ `).concat(e.map(function(n,o){var a=n.color,s=[];return"attribute"in a?s.push(" vec4 borderColor_".concat(o+1," = v_borderColor_").concat(o+1,";")):"transparent"in a?s.push(" vec4 borderColor_".concat(o+1," = vec4(0.0, 0.0, 0.0, 0.0);")):s.push(" vec4 borderColor_".concat(o+1," = u_borderColor_").concat(o+1,";")),s.push(" borderColor_".concat(o+1,".a *= bias;")),s.push(" if (borderSize_".concat(o+1," <= 1.0 * u_correctionRatio) { borderColor_").concat(o+1," = borderColor_").concat(o,"; }")),s.join(`
467
+ `)}).join(`
468
+ `),`
469
+ if (dist > adjustedBorderSize_0) {
470
+ gl_FragColor = borderColor_0;
471
+ } else `).concat(e.map(function(n,o){return"if (dist > adjustedBorderSize_".concat(o,` - aaBorder) {
472
+ gl_FragColor = mix(borderColor_`).concat(o+1,", borderColor_").concat(o,", (dist - adjustedBorderSize_").concat(o,` + aaBorder) / aaBorder);
473
+ } else if (dist > adjustedBorderSize_`).concat(o+1,`) {
474
+ gl_FragColor = borderColor_`).concat(o+1,`;
475
+ } else `)}).join(""),` { /* Nothing to add here */ }
476
+ #endif
477
+ }
478
+ `);return i}function zo(r){var e=r.borders,t=`
479
+ attribute vec2 a_position;
480
+ attribute float a_size;
481
+ attribute float a_angle;
482
+
483
+ uniform mat3 u_matrix;
484
+ uniform float u_sizeRatio;
485
+ uniform float u_correctionRatio;
486
+
487
+ varying vec2 v_diffVector;
488
+ varying float v_radius;
489
+
490
+ #ifdef PICKING_MODE
491
+ attribute vec4 a_id;
492
+ varying vec4 v_color;
493
+ #else
494
+ `.concat(e.flatMap(function(i,n){var o=i.size;return"attribute"in o?["attribute float a_borderSize_".concat(n+1,";"),"varying float v_borderSize_".concat(n+1,";")]:[]}).join(`
495
+ `),`
496
+ `).concat(e.flatMap(function(i,n){var o=i.color;return"attribute"in o?["attribute vec4 a_borderColor_".concat(n+1,";"),"varying vec4 v_borderColor_".concat(n+1,";")]:[]}).join(`
497
+ `),`
498
+ #endif
499
+
500
+ const float bias = 255.0 / 254.0;
501
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
502
+
503
+ void main() {
504
+ float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
505
+ vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
506
+ vec2 position = a_position + diffVector;
507
+ gl_Position = vec4(
508
+ (u_matrix * vec3(position, 1)).xy,
509
+ 0,
510
+ 1
511
+ );
512
+
513
+ v_radius = size / 2.0;
514
+ v_diffVector = diffVector;
515
+
516
+ #ifdef PICKING_MODE
517
+ v_color = a_id;
518
+ #else
519
+ `).concat(e.flatMap(function(i,n){var o=i.size;return"attribute"in o?[" v_borderSize_".concat(n+1," = a_borderSize_").concat(n+1,";")]:[]}).join(`
520
+ `),`
521
+ `).concat(e.flatMap(function(i,n){var o=i.color;return"attribute"in o?[" v_borderColor_".concat(n+1," = a_borderColor_").concat(n+1,";")]:[]}).join(`
522
+ `),`
523
+ #endif
524
+ }
525
+ `);return t}var qr=WebGLRenderingContext,Kr=qr.UNSIGNED_BYTE,He=qr.FLOAT;function Zr(r){var e,t=Xr(Xr({},Oo),r||{}),i=t.borders,n=t.drawLabel,o=t.drawHover,a=["u_sizeRatio","u_correctionRatio","u_matrix"].concat(bt(i.flatMap(function(s,c){var l=s.color;return"value"in l?["u_borderColor_".concat(c+1)]:[]})));return e=function(s){Fo(c,s);function c(){var l;Ro(this,c);for(var u=arguments.length,h=new Array(u),d=0;d<u;d++)h[d]=arguments[d];return l=xo(this,c,[].concat(h)),ve(pt(l),"drawLabel",n),ve(pt(l),"drawHover",o),l}return Ao(c,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:zo(t),FRAGMENT_SHADER_SOURCE:Io(t),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:a,ATTRIBUTES:[{name:"a_position",size:2,type:He},{name:"a_id",size:4,type:Kr,normalized:!0},{name:"a_size",size:1,type:He}].concat(bt(i.flatMap(function(u,h){var d=u.color;return"attribute"in d?[{name:"a_borderColor_".concat(h+1),size:4,type:Kr,normalized:!0}]:[]})),bt(i.flatMap(function(u,h){var d=u.size;return"attribute"in d?[{name:"a_borderSize_".concat(h+1),size:1,type:He}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:He}],CONSTANT_DATA:[[c.ANGLE_1],[c.ANGLE_2],[c.ANGLE_3]]}}},{key:"processVisibleItem",value:function(u,h,d){var m=this.array;m[h++]=d.x,m[h++]=d.y,m[h++]=u,m[h++]=d.size,i.forEach(function(f){var p=f.color;"attribute"in p&&(m[h++]=K(d[p.attribute]||p.defaultValue||ko))}),i.forEach(function(f){var p=f.size;"attribute"in p&&(m[h++]=d[p.attribute]||p.defaultValue)})}},{key:"setUniforms",value:function(u,h){var d=h.gl,m=h.uniformLocations,f=m.u_sizeRatio,p=m.u_correctionRatio,b=m.u_matrix;d.uniform1f(p,u.correctionRatio),d.uniform1f(f,u.sizeRatio),d.uniformMatrix3fv(b,!1,u.matrix),i.forEach(function(g,_){var v=g.color;if("value"in v){var y=m["u_borderColor_".concat(_+1)],C=ot(v.value),S=To(C,4),w=S[0],P=S[1],k=S[2],D=S[3];d.uniform4f(y,w/255,P/255,k/255,D/255)}})}}]),c}(Ge),ve(e,"ANGLE_1",0),ve(e,"ANGLE_2",2*Math.PI/3),ve(e,"ANGLE_3",4*Math.PI/3),e}Zr();var yt={exports:{}},pe=typeof Reflect=="object"?Reflect:null,Qr=pe&&typeof pe.apply=="function"?pe.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},$e;pe&&typeof pe.ownKeys=="function"?$e=pe.ownKeys:Object.getOwnPropertySymbols?$e=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:$e=function(e){return Object.getOwnPropertyNames(e)};function Go(r){console&&console.warn&&console.warn(r)}var Jr=Number.isNaN||function(e){return e!==e};function L(){L.init.call(this)}yt.exports=L,yt.exports.once=Ho,L.EventEmitter=L,L.prototype._events=void 0,L.prototype._eventsCount=0,L.prototype._maxListeners=void 0;var ei=10;function je(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(L,"defaultMaxListeners",{enumerable:!0,get:function(){return ei},set:function(r){if(typeof r!="number"||r<0||Jr(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");ei=r}}),L.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},L.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Jr(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ti(r){return r._maxListeners===void 0?L.defaultMaxListeners:r._maxListeners}L.prototype.getMaxListeners=function(){return ti(this)},L.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var n=e==="error",o=this._events;if(o!==void 0)n=n&&o.error===void 0;else if(!n)return!1;if(n){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=o[e];if(c===void 0)return!1;if(typeof c=="function")Qr(c,this,t);else for(var l=c.length,u=ai(c,l),i=0;i<l;++i)Qr(u[i],this,t);return!0};function ri(r,e,t,i){var n,o,a;if(je(t),o=r._events,o===void 0?(o=r._events=Object.create(null),r._eventsCount=0):(o.newListener!==void 0&&(r.emit("newListener",e,t.listener?t.listener:t),o=r._events),a=o[e]),a===void 0)a=o[e]=t,++r._eventsCount;else if(typeof a=="function"?a=o[e]=i?[t,a]:[a,t]:i?a.unshift(t):a.push(t),n=ti(r),n>0&&a.length>n&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=r,s.type=e,s.count=a.length,Go(s)}return r}L.prototype.addListener=function(e,t){return ri(this,e,t,!1)},L.prototype.on=L.prototype.addListener,L.prototype.prependListener=function(e,t){return ri(this,e,t,!0)};function Mo(){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 ii(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=Mo.bind(i);return n.listener=t,i.wrapFn=n,n}L.prototype.once=function(e,t){return je(t),this.on(e,ii(this,e,t)),this},L.prototype.prependOnceListener=function(e,t){return je(t),this.prependListener(e,ii(this,e,t)),this},L.prototype.removeListener=function(e,t){var i,n,o,a,s;if(je(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,a=i.length-1;a>=0;a--)if(i[a]===t||i[a].listener===t){s=i[a].listener,o=a;break}if(o<0)return this;o===0?i.shift():Uo(i,o),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,s||t)}return this},L.prototype.off=L.prototype.removeListener,L.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),a;for(n=0;n<o.length;++n)a=o[n],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this};function ni(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?Bo(n):ai(n,n.length)}L.prototype.listeners=function(e){return ni(this,e,!0)},L.prototype.rawListeners=function(e){return ni(this,e,!1)},L.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):oi.call(r,e)},L.prototype.listenerCount=oi;function oi(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}L.prototype.eventNames=function(){return this._eventsCount>0?$e(this._events):[]};function ai(r,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=r[i];return t}function Uo(r,e){for(;e+1<r.length;e++)r[e]=r[e+1];r.pop()}function Bo(r){for(var e=new Array(r.length),t=0;t<e.length;++t)e[t]=r[t].listener||r[t];return e}function Ho(r,e){return new Promise(function(t,i){function n(a){r.removeListener(e,o),i(a)}function o(){typeof r.removeListener=="function"&&r.removeListener("error",n),t([].slice.call(arguments))}si(r,e,o,{once:!0}),e!=="error"&&$o(r,n,{once:!0})})}function $o(r,e,t){typeof r.on=="function"&&si(r,"error",e,t)}function si(r,e,t,i){if(typeof r.on=="function")i.once?r.once(e,t):r.on(e,t);else if(typeof r.addEventListener=="function")r.addEventListener(e,function n(o){i.once&&r.removeEventListener(e,n),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r)}var ci=yt.exports;function Et(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,i=Array(e);t<e;t++)i[t]=r[t];return i}function jo(r){if(Array.isArray(r))return Et(r)}function Vo(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function Wo(r,e){if(r){if(typeof r=="string")return Et(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Et(r,e):void 0}}function Yo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
526
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tt(r){return jo(r)||Vo(r)||Wo(r)||Yo()}function Rt(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Xo(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function li(r){var e=Xo(r,"string");return typeof e=="symbol"?e:e+""}function qo(r,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,li(i.key),i)}}function Ct(r,e,t){return e&&qo(r.prototype,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function _e(r){return _e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_e(r)}function ui(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ui=function(){return!!r})()}function W(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Ko(r,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return W(r)}function hi(r,e,t){return e=_e(e),Ko(r,ui()?Reflect.construct(e,t||[],_e(r).constructor):e.apply(r,t))}function Zo(r,e){for(;!{}.hasOwnProperty.call(r,e)&&(r=_e(r))!==null;);return r}function wt(){return wt=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,e,t){var i=Zo(r,e);if(i){var n=Object.getOwnPropertyDescriptor(i,e);return n.get?n.get.call(arguments.length<3?r:t):n.value}},wt.apply(null,arguments)}function di(r,e,t,i){var n=wt(_e(r.prototype),e,t);return typeof n=="function"?function(o){return n.apply(t,o)}:n}function At(r,e){return At=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},At(r,e)}function fi(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&At(r,e)}function I(r,e,t){return(e=li(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Qo(r,e){if(r==null)return{};var t={};for(var i in r)if({}.hasOwnProperty.call(r,i)){if(e.includes(i))continue;t[i]=r[i]}return t}function Jo(r,e){if(r==null)return{};var t,i,n=Qo(r,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(i=0;i<o.length;i++)t=o[i],e.includes(t)||{}.propertyIsEnumerable.call(r,t)&&(n[t]=r[t])}return n}function gi(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function j(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?gi(Object(t),!0).forEach(function(i){I(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):gi(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function ea(r){var e=r.texturesCount,t=`
527
+ precision highp float;
528
+
529
+ varying vec4 v_color;
530
+ varying vec2 v_diffVector;
531
+ varying float v_radius;
532
+ varying vec4 v_texture;
533
+ varying float v_textureIndex;
534
+
535
+ uniform sampler2D u_atlas[`.concat(e,`];
536
+ uniform float u_correctionRatio;
537
+ uniform float u_cameraAngle;
538
+ uniform float u_percentagePadding;
539
+ uniform bool u_colorizeImages;
540
+ uniform bool u_keepWithinCircle;
541
+
542
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
543
+
544
+ const float radius = 0.5;
545
+
546
+ void main(void) {
547
+ float border = 2.0 * u_correctionRatio;
548
+ float dist = length(v_diffVector);
549
+ vec4 color = gl_FragColor;
550
+
551
+ float c = cos(-u_cameraAngle);
552
+ float s = sin(-u_cameraAngle);
553
+ vec2 diffVector = mat2(c, s, -s, c) * (v_diffVector);
554
+
555
+ // No antialiasing for picking mode:
556
+ #ifdef PICKING_MODE
557
+ border = 0.0;
558
+ color = v_color;
559
+
560
+ #else
561
+ // First case: No image to display
562
+ if (v_texture.w <= 0.0) {
563
+ if (!u_colorizeImages) {
564
+ color = v_color;
565
+ }
566
+ }
567
+
568
+ // Second case: Image loaded into the texture
569
+ else {
570
+ float paddingRatio = 1.0 + 2.0 * u_percentagePadding;
571
+ float coef = u_keepWithinCircle ? 1.0 : `).concat(Math.SQRT2,`;
572
+ vec2 coordinateInTexture = diffVector * vec2(paddingRatio, -paddingRatio) / v_radius / 2.0 * coef + vec2(0.5, 0.5);
573
+ int index = int(v_textureIndex + 0.5); // +0.5 avoid rounding errors
574
+
575
+ bool noTextureFound = false;
576
+ vec4 texel;
577
+
578
+ `).concat(Tt(new Array(e)).map(function(i,n){return"if (index == ".concat(n,") texel = texture2D(u_atlas[").concat(n,"], (v_texture.xy + coordinateInTexture * v_texture.zw), -1.0);")}).join(`
579
+ else `)+`else {
580
+ texel = texture2D(u_atlas[0], (v_texture.xy + coordinateInTexture * v_texture.zw), -1.0);
581
+ noTextureFound = true;
582
+ }`,`
583
+
584
+ if (noTextureFound) {
585
+ color = v_color;
586
+ } else {
587
+ // Colorize all visible image pixels:
588
+ if (u_colorizeImages) {
589
+ color = mix(gl_FragColor, v_color, texel.a);
590
+ }
591
+
592
+ // Colorize background pixels, keep image pixel colors:
593
+ else {
594
+ color = vec4(mix(v_color, texel, texel.a).rgb, max(texel.a, v_color.a));
595
+ }
596
+
597
+ // Erase pixels "in the padding":
598
+ if (abs(diffVector.x) > v_radius / paddingRatio || abs(diffVector.y) > v_radius / paddingRatio) {
599
+ color = u_colorizeImages ? gl_FragColor : v_color;
600
+ }
601
+ }
602
+ }
603
+ #endif
604
+
605
+ // Crop in a circle when u_keepWithinCircle is truthy:
606
+ if (u_keepWithinCircle) {
607
+ if (dist < v_radius - border) {
608
+ gl_FragColor = color;
609
+ } else if (dist < v_radius) {
610
+ gl_FragColor = mix(transparent, color, (v_radius - dist) / border);
611
+ }
612
+ }
613
+
614
+ // Crop in a square else:
615
+ else {
616
+ float squareHalfSize = v_radius * `).concat(Math.SQRT1_2*Math.cos(Math.PI/12),`;
617
+ if (abs(diffVector.x) > squareHalfSize || abs(diffVector.y) > squareHalfSize) {
618
+ gl_FragColor = transparent;
619
+ } else {
620
+ gl_FragColor = color;
621
+ }
622
+ }
623
+ }
624
+ `);return t}var ta=`
625
+ attribute vec4 a_id;
626
+ attribute vec4 a_color;
627
+ attribute vec2 a_position;
628
+ attribute float a_size;
629
+ attribute float a_angle;
630
+ attribute vec4 a_texture;
631
+ attribute float a_textureIndex;
632
+
633
+ uniform mat3 u_matrix;
634
+ uniform float u_sizeRatio;
635
+ uniform float u_correctionRatio;
636
+
637
+ varying vec4 v_color;
638
+ varying vec2 v_diffVector;
639
+ varying float v_radius;
640
+ varying vec4 v_texture;
641
+ varying float v_textureIndex;
642
+
643
+ const float bias = 255.0 / 254.0;
644
+ const float marginRatio = 1.05;
645
+
646
+ void main() {
647
+ float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
648
+ vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
649
+ vec2 position = a_position + diffVector * marginRatio;
650
+ gl_Position = vec4(
651
+ (u_matrix * vec3(position, 1)).xy,
652
+ 0,
653
+ 1
654
+ );
655
+
656
+ v_diffVector = diffVector;
657
+ v_radius = size / 2.0 / marginRatio;
658
+
659
+ #ifdef PICKING_MODE
660
+ // For picking mode, we use the ID as the color:
661
+ v_color = a_id;
662
+ #else
663
+ // For normal mode, we use the color:
664
+ v_color = a_color;
665
+
666
+ // Pass the texture coordinates:
667
+ v_textureIndex = a_textureIndex;
668
+ v_texture = a_texture;
669
+ #endif
670
+
671
+ v_color.a *= bias;
672
+ }
673
+ `,ra=ta;function ce(){ce=function(){return e};var r,e={},t=Object.prototype,i=t.hasOwnProperty,n=Object.defineProperty||function(T,E,R){T[E]=R.value},o=typeof Symbol=="function"?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function l(T,E,R){return Object.defineProperty(T,E,{value:R,enumerable:!0,configurable:!0,writable:!0}),T[E]}try{l({},"")}catch{l=function(E,R,x){return E[R]=x}}function u(T,E,R,x){var A=E&&E.prototype instanceof g?E:g,F=Object.create(A.prototype),N=new H(x||[]);return n(F,"_invoke",{value:D(T,R,N)}),F}function h(T,E,R){try{return{type:"normal",arg:T.call(E,R)}}catch(x){return{type:"throw",arg:x}}}e.wrap=u;var d="suspendedStart",m="suspendedYield",f="executing",p="completed",b={};function g(){}function _(){}function v(){}var y={};l(y,a,function(){return this});var C=Object.getPrototypeOf,S=C&&C(C($([])));S&&S!==t&&i.call(S,a)&&(y=S);var w=v.prototype=g.prototype=Object.create(y);function P(T){["next","throw","return"].forEach(function(E){l(T,E,function(R){return this._invoke(E,R)})})}function k(T,E){function R(A,F,N,G){var M=h(T[A],T,F);if(M.type!=="throw"){var q=M.arg,te=q.value;return te&&typeof te=="object"&&i.call(te,"__await")?E.resolve(te.__await).then(function(re){R("next",re,N,G)},function(re){R("throw",re,N,G)}):E.resolve(te).then(function(re){q.value=re,N(q)},function(re){return R("throw",re,N,G)})}G(M.arg)}var x;n(this,"_invoke",{value:function(A,F){function N(){return new E(function(G,M){R(A,F,G,M)})}return x=x?x.then(N,N):N()}})}function D(T,E,R){var x=d;return function(A,F){if(x===f)throw Error("Generator is already running");if(x===p){if(A==="throw")throw F;return{value:r,done:!0}}for(R.method=A,R.arg=F;;){var N=R.delegate;if(N){var G=U(N,R);if(G){if(G===b)continue;return G}}if(R.method==="next")R.sent=R._sent=R.arg;else if(R.method==="throw"){if(x===d)throw x=p,R.arg;R.dispatchException(R.arg)}else R.method==="return"&&R.abrupt("return",R.arg);x=f;var M=h(T,E,R);if(M.type==="normal"){if(x=R.done?p:m,M.arg===b)continue;return{value:M.arg,done:R.done}}M.type==="throw"&&(x=p,R.method="throw",R.arg=M.arg)}}}function U(T,E){var R=E.method,x=T.iterator[R];if(x===r)return E.delegate=null,R==="throw"&&T.iterator.return&&(E.method="return",E.arg=r,U(T,E),E.method==="throw")||R!=="return"&&(E.method="throw",E.arg=new TypeError("The iterator does not provide a '"+R+"' method")),b;var A=h(x,T.iterator,E.arg);if(A.type==="throw")return E.method="throw",E.arg=A.arg,E.delegate=null,b;var F=A.arg;return F?F.done?(E[T.resultName]=F.value,E.next=T.nextLoc,E.method!=="return"&&(E.method="next",E.arg=r),E.delegate=null,b):F:(E.method="throw",E.arg=new TypeError("iterator result is not an object"),E.delegate=null,b)}function z(T){var E={tryLoc:T[0]};1 in T&&(E.catchLoc=T[1]),2 in T&&(E.finallyLoc=T[2],E.afterLoc=T[3]),this.tryEntries.push(E)}function B(T){var E=T.completion||{};E.type="normal",delete E.arg,T.completion=E}function H(T){this.tryEntries=[{tryLoc:"root"}],T.forEach(z,this),this.reset(!0)}function $(T){if(T||T===""){var E=T[a];if(E)return E.call(T);if(typeof T.next=="function")return T;if(!isNaN(T.length)){var R=-1,x=function A(){for(;++R<T.length;)if(i.call(T,R))return A.value=T[R],A.done=!1,A;return A.value=r,A.done=!0,A};return x.next=x}}throw new TypeError(typeof T+" is not iterable")}return _.prototype=v,n(w,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:_,configurable:!0}),_.displayName=l(v,c,"GeneratorFunction"),e.isGeneratorFunction=function(T){var E=typeof T=="function"&&T.constructor;return!!E&&(E===_||(E.displayName||E.name)==="GeneratorFunction")},e.mark=function(T){return Object.setPrototypeOf?Object.setPrototypeOf(T,v):(T.__proto__=v,l(T,c,"GeneratorFunction")),T.prototype=Object.create(w),T},e.awrap=function(T){return{__await:T}},P(k.prototype),l(k.prototype,s,function(){return this}),e.AsyncIterator=k,e.async=function(T,E,R,x,A){A===void 0&&(A=Promise);var F=new k(u(T,E,R,x),A);return e.isGeneratorFunction(E)?F:F.next().then(function(N){return N.done?N.value:F.next()})},P(w),l(w,c,"Generator"),l(w,a,function(){return this}),l(w,"toString",function(){return"[object Generator]"}),e.keys=function(T){var E=Object(T),R=[];for(var x in E)R.push(x);return R.reverse(),function A(){for(;R.length;){var F=R.pop();if(F in E)return A.value=F,A.done=!1,A}return A.done=!0,A}},e.values=$,H.prototype={constructor:H,reset:function(T){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(B),!T)for(var E in this)E.charAt(0)==="t"&&i.call(this,E)&&!isNaN(+E.slice(1))&&(this[E]=r)},stop:function(){this.done=!0;var T=this.tryEntries[0].completion;if(T.type==="throw")throw T.arg;return this.rval},dispatchException:function(T){if(this.done)throw T;var E=this;function R(M,q){return F.type="throw",F.arg=T,E.next=M,q&&(E.method="next",E.arg=r),!!q}for(var x=this.tryEntries.length-1;x>=0;--x){var A=this.tryEntries[x],F=A.completion;if(A.tryLoc==="root")return R("end");if(A.tryLoc<=this.prev){var N=i.call(A,"catchLoc"),G=i.call(A,"finallyLoc");if(N&&G){if(this.prev<A.catchLoc)return R(A.catchLoc,!0);if(this.prev<A.finallyLoc)return R(A.finallyLoc)}else if(N){if(this.prev<A.catchLoc)return R(A.catchLoc,!0)}else{if(!G)throw Error("try statement without catch or finally");if(this.prev<A.finallyLoc)return R(A.finallyLoc)}}}},abrupt:function(T,E){for(var R=this.tryEntries.length-1;R>=0;--R){var x=this.tryEntries[R];if(x.tryLoc<=this.prev&&i.call(x,"finallyLoc")&&this.prev<x.finallyLoc){var A=x;break}}A&&(T==="break"||T==="continue")&&A.tryLoc<=E&&E<=A.finallyLoc&&(A=null);var F=A?A.completion:{};return F.type=T,F.arg=E,A?(this.method="next",this.next=A.finallyLoc,b):this.complete(F)},complete:function(T,E){if(T.type==="throw")throw T.arg;return T.type==="break"||T.type==="continue"?this.next=T.arg:T.type==="return"?(this.rval=this.arg=T.arg,this.method="return",this.next="end"):T.type==="normal"&&E&&(this.next=E),b},finish:function(T){for(var E=this.tryEntries.length-1;E>=0;--E){var R=this.tryEntries[E];if(R.finallyLoc===T)return this.complete(R.completion,R.afterLoc),B(R),b}},catch:function(T){for(var E=this.tryEntries.length-1;E>=0;--E){var R=this.tryEntries[E];if(R.tryLoc===T){var x=R.completion;if(x.type==="throw"){var A=x.arg;B(R)}return A}}throw Error("illegal catch attempt")},delegateYield:function(T,E,R){return this.delegate={iterator:$(T),resultName:E,nextLoc:R},this.method==="next"&&(this.arg=r),b}},e}function mi(r,e,t,i,n,o,a){try{var s=r[o](a),c=s.value}catch(l){return void t(l)}s.done?e(c):Promise.resolve(c).then(i,n)}function St(r){return function(){var e=this,t=arguments;return new Promise(function(i,n){var o=r.apply(e,t);function a(c){mi(o,i,n,a,s,"next",c)}function s(c){mi(o,i,n,a,s,"throw",c)}a(void 0)})}}var xt={size:{mode:"max",value:512},objectFit:"cover",correctCentering:!1,maxTextureSize:4096,debounceTimeout:500,crossOrigin:"anonymous"},ia=1;function Ft(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.crossOrigin;return new Promise(function(i,n){var o=new Image;o.addEventListener("load",function(){i(o)},{once:!0}),o.addEventListener("error",function(a){n(a.error)},{once:!0}),t&&o.setAttribute("crossOrigin",t),o.src=r})}function na(r){return Lt.apply(this,arguments)}function Lt(){return Lt=St(ce().mark(function r(e){var t,i,n,o,a,s,c,l,u,h,d,m,f,p=arguments;return ce().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(t=p.length>1&&p[1]!==void 0?p[1]:{},i=t.size,n=t.crossOrigin,n!=="use-credentials"){g.next=7;break}return g.next=4,fetch(e,{credentials:"include"});case 4:o=g.sent,g.next=10;break;case 7:return g.next=9,fetch(e);case 9:o=g.sent;case 10:return g.next=12,o.text();case 12:if(a=g.sent,s=new DOMParser().parseFromString(a,"image/svg+xml"),c=s.documentElement,l=c.getAttribute("width"),u=c.getAttribute("height"),!(!l||!u)){g.next=19;break}throw new Error("loadSVGImage: cannot use `size` if target SVG has no definite dimensions.");case 19:return typeof i=="number"&&(c.setAttribute("width",""+i),c.setAttribute("height",""+i)),h=new XMLSerializer().serializeToString(s),d=new Blob([h],{type:"image/svg+xml"}),m=URL.createObjectURL(d),f=Ft(m),f.finally(function(){return URL.revokeObjectURL(m)}),g.abrupt("return",f);case 26:case"end":return g.stop()}},r)})),Lt.apply(this,arguments)}function oa(r){return Nt.apply(this,arguments)}function Nt(){return Nt=St(ce().mark(function r(e){var t,i,n,o,a,s,c=arguments;return ce().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(i=c.length>1&&c[1]!==void 0?c[1]:{},n=i.size,o=i.crossOrigin,a=((t=e.split(/[#?]/)[0].split(".").pop())===null||t===void 0?void 0:t.trim().toLowerCase())==="svg",!(a&&n)){u.next=16;break}return u.prev=3,u.next=6,na(e,{size:n,crossOrigin:o});case 6:s=u.sent,u.next=14;break;case 9:return u.prev=9,u.t0=u.catch(3),u.next=13,Ft(e,{crossOrigin:o});case 13:s=u.sent;case 14:u.next=19;break;case 16:return u.next=18,Ft(e,{crossOrigin:o});case 18:s=u.sent;case 19:return u.abrupt("return",s);case 20:case"end":return u.stop()}},r,null,[[3,9]])})),Nt.apply(this,arguments)}function aa(r,e,t){var i=t.objectFit,n=t.size,o=t.correctCentering,a=i==="contain"?Math.max(r.width,r.height):Math.min(r.width,r.height),s=n.mode==="auto"?a:n.mode==="force"?n.value:Math.min(n.value,a),c=(r.width-a)/2,l=(r.height-a)/2;if(o){var u=e.getCorrectionOffset(r,a);c=u.x,l=u.y}return{sourceX:c,sourceY:l,sourceSize:a,destinationSize:s}}function sa(r,e,t){for(var i=e.canvas,n=i.width,o=i.height,a=[],s=t.x,c=t.y,l=t.rowHeight,u=t.maxRowWidth,h={},d=0,m=r.length;d<m;d++){var f=r[d],p=f.key,b=f.image,g=f.sourceSize,_=f.sourceX,v=f.sourceY,y=f.destinationSize,C=y+ia;c+C>o||s+C>n&&c+C+l>o||(s+C>n&&(u=Math.max(u,s),s=0,c+=l,l=C),a.push({key:p,image:b,sourceX:_,sourceY:v,sourceSize:g,destinationX:s,destinationY:c,destinationSize:y}),h[p]={x:s,y:c,size:y},s+=C,l=Math.max(l,C))}u=Math.max(u,s);for(var S=u,w=c+l,P=0,k=a.length;P<k;P++){var D=a[P],U=D.image,z=D.sourceSize,B=D.sourceX,H=D.sourceY,$=D.destinationSize,T=D.destinationX,E=D.destinationY;e.drawImage(U,B,H,z,z,T,E,$,$)}return{atlas:h,texture:e.getImageData(0,0,S,w),cursor:{x:s,y:c,rowHeight:l,maxRowWidth:u}}}function ca(r,e,t){var i=r.atlas,n=r.textures,o=r.cursor,a={atlas:j({},i),textures:Tt(n.slice(0,-1)),cursor:j({},o)},s=[];for(var c in e){var l,u=e[c];if(u.status==="ready"){var h=(l=i[c])===null||l===void 0?void 0:l.textureIndex;typeof h!="number"&&s.push(j({key:c},u))}}for(var d=function(){var f=sa(s,t,a.cursor),p=f.atlas,b=f.texture,g=f.cursor;a.cursor=g;var _=[];s.forEach(function(v){p[v.key]?a.atlas[v.key]=j(j({},p[v.key]),{},{textureIndex:a.textures.length}):_.push(v)}),a.textures.push(b),s=_,s.length&&(a.cursor={x:0,y:0,rowHeight:0,maxRowWidth:0},t.clearRect(0,0,t.canvas.width,t.canvas.height))};s.length;)d();return a}var la=function(){function r(){Rt(this,r),this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d",{willReadFrequently:!0})}return Ct(r,[{key:"getCorrectionOffset",value:function(t,i){this.canvas.width=i,this.canvas.height=i,this.context.clearRect(0,0,i,i),this.context.drawImage(t,0,0,i,i);for(var n=this.context.getImageData(0,0,i,i).data,o=new Uint8ClampedArray(n.length/4),a=0;a<n.length;a++)o[a]=n[a*4+3];for(var s=0,c=0,l=0,u=0;u<i;u++)for(var h=0;h<i;h++){var d=o[u*i+h];l+=d,s+=d*h,c+=d*u}var m=s/l,f=c/l;return{x:m-i/2,y:f-i/2}}}]),r}(),Ve=function(r){fi(e,r);function e(){var t,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Rt(this,e),t=hi(this,e),I(W(t),"canvas",document.createElement("canvas")),I(W(t),"ctx",t.canvas.getContext("2d",{willReadFrequently:!0})),I(W(t),"corrector",new la),I(W(t),"imageStates",{}),I(W(t),"textures",[t.ctx.getImageData(0,0,1,1)]),I(W(t),"lastTextureCursor",{x:0,y:0,rowHeight:0,maxRowWidth:0}),I(W(t),"atlas",{}),t.options=j(j({},xt),i),t.canvas.width=t.options.maxTextureSize,t.canvas.height=t.options.maxTextureSize,t}return Ct(e,[{key:"scheduleGenerateTexture",value:function(){var i=this;typeof this.frameId!="number"&&(typeof this.options.debounceTimeout=="number"?this.frameId=window.setTimeout(function(){i.generateTextures(),i.frameId=void 0},this.options.debounceTimeout):this.generateTextures())}},{key:"generateTextures",value:function(){var i=ca({atlas:this.atlas,textures:this.textures,cursor:this.lastTextureCursor},this.imageStates,this.ctx),n=i.atlas,o=i.textures,a=i.cursor;this.atlas=n,this.textures=o,this.lastTextureCursor=a,this.emit(e.NEW_TEXTURE_EVENT,{atlas:n,textures:o})}},{key:"registerImage",value:function(){var t=St(ce().mark(function n(o){var a,s;return ce().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(!this.imageStates[o]){l.next=2;break}return l.abrupt("return");case 2:return this.imageStates[o]={status:"loading"},l.prev=3,a=this.options.size,l.next=7,oa(o,{size:a.mode==="force"?a.value:void 0,crossOrigin:this.options.crossOrigin||void 0});case 7:s=l.sent,this.imageStates[o]=j({status:"ready",image:s},aa(s,this.corrector,this.options)),this.scheduleGenerateTexture(),l.next=15;break;case 12:l.prev=12,l.t0=l.catch(3),this.imageStates[o]={status:"error"};case 15:case"end":return l.stop()}},n,this,[[3,12]])}));function i(n){return t.apply(this,arguments)}return i}()},{key:"getAtlas",value:function(){return this.atlas}},{key:"getTextures",value:function(){return this.textures}}]),e}(ci.EventEmitter);I(Ve,"NEW_TEXTURE_EVENT","newTexture");var ua=["drawHover","drawLabel","drawingMode","keepWithinCircle","padding","colorAttribute","imageAttribute"],vi=WebGLRenderingContext,pi=vi.UNSIGNED_BYTE,Se=vi.FLOAT,ha=j(j({},xt),{},{drawingMode:"background",keepWithinCircle:!0,drawLabel:void 0,drawHover:void 0,padding:0,colorAttribute:"color",imageAttribute:"image"}),da=["u_sizeRatio","u_correctionRatio","u_cameraAngle","u_percentagePadding","u_matrix","u_colorizeImages","u_keepWithinCircle","u_atlas"];function Pt(r){var e,t=document.createElement("canvas").getContext("webgl"),i=Math.min(t.getParameter(t.MAX_TEXTURE_SIZE),xt.maxTextureSize);t.canvas.remove();var n=j(j(j({},ha),{maxTextureSize:i}),r||{}),o=n.drawHover,a=n.drawLabel,s=n.drawingMode,c=n.keepWithinCircle,l=n.padding,u=n.colorAttribute,h=n.imageAttribute,d=Jo(n,ua),m=new Ve(d);return e=function(f){fi(p,f);function p(b,g,_){var v;return Rt(this,p),v=hi(this,p,[b,g,_]),I(W(v),"drawLabel",a),I(W(v),"drawHover",o),I(W(v),"textureManagerCallback",null),v.textureManagerCallback=function(y){var C=y.atlas,S=y.textures,w=S.length!==v.textures.length;v.atlas=C,v.textureImages=S,w&&v.upgradeShaders(),v.bindTextures(),v.latestRenderParams&&v.render(v.latestRenderParams),v.renderer&&v.renderer.refresh&&v.renderer.refresh()},m.on(Ve.NEW_TEXTURE_EVENT,v.textureManagerCallback),v.atlas=m.getAtlas(),v.textureImages=m.getTextures(),v.textures=v.textureImages.map(function(){return b.createTexture()}),v.bindTextures(),v}return Ct(p,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:ra,FRAGMENT_SHADER_SOURCE:ea({texturesCount:m.getTextures().length}),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:da,ATTRIBUTES:[{name:"a_position",size:2,type:Se},{name:"a_size",size:1,type:Se},{name:"a_color",size:4,type:pi,normalized:!0},{name:"a_id",size:4,type:pi,normalized:!0},{name:"a_texture",size:4,type:Se},{name:"a_textureIndex",size:1,type:Se}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Se}],CONSTANT_DATA:[[p.ANGLE_1],[p.ANGLE_2],[p.ANGLE_3]]}}},{key:"upgradeShaders",value:function(){var g=this.getDefinition(),_=this.normalProgram,v=_.program,y=_.buffer,C=_.vertexShader,S=_.fragmentShader,w=_.gl;w.deleteProgram(v),w.deleteBuffer(y),w.deleteShader(C),w.deleteShader(S),this.normalProgram=this.getProgramInfo("normal",w,g.VERTEX_SHADER_SOURCE,g.FRAGMENT_SHADER_SOURCE,null)}},{key:"kill",value:function(){var g,_=(g=this.normalProgram)===null||g===void 0?void 0:g.gl;if(_)for(var v=0;v<this.textures.length;v++)_.deleteTexture(this.textures[v]);this.textureManagerCallback&&(m.off(Ve.NEW_TEXTURE_EVENT,this.textureManagerCallback),this.textureManagerCallback=null),di(p,"kill",this)([])}},{key:"bindTextures",value:function(){for(var g=this.normalProgram.gl,_=0;_<this.textureImages.length;_++){if(_>=this.textures.length){var v=g.createTexture();v&&this.textures.push(v)}g.activeTexture(g.TEXTURE0+_),g.bindTexture(g.TEXTURE_2D,this.textures[_]),g.texImage2D(g.TEXTURE_2D,0,g.RGBA,g.RGBA,g.UNSIGNED_BYTE,this.textureImages[_]),g.generateMipmap(g.TEXTURE_2D)}}},{key:"renderProgram",value:function(g,_){if(!_.isPicking)for(var v=_.gl,y=0;y<this.textureImages.length;y++)v.activeTexture(v.TEXTURE0+y),v.bindTexture(v.TEXTURE_2D,this.textures[y]);di(p,"renderProgram",this)([g,_])}},{key:"processVisibleItem",value:function(g,_,v){var y=this.array,C=K(v[u]),S=v[h],w=S?this.atlas[S]:void 0;if(typeof S=="string"&&!w&&m.registerImage(S),y[_++]=v.x,y[_++]=v.y,y[_++]=v.size,y[_++]=C,y[_++]=g,w&&typeof w.textureIndex=="number"){var P=this.textureImages[w.textureIndex],k=P.width,D=P.height;y[_++]=w.x/k,y[_++]=w.y/D,y[_++]=w.size/k,y[_++]=w.size/D,y[_++]=w.textureIndex}else y[_++]=0,y[_++]=0,y[_++]=0,y[_++]=0,y[_++]=0}},{key:"setUniforms",value:function(g,_){var v=_.gl,y=_.uniformLocations,C=y.u_sizeRatio,S=y.u_correctionRatio,w=y.u_matrix,P=y.u_atlas,k=y.u_colorizeImages,D=y.u_keepWithinCircle,U=y.u_cameraAngle,z=y.u_percentagePadding;this.latestRenderParams=g,v.uniform1f(S,g.correctionRatio),v.uniform1f(C,c?g.sizeRatio:g.sizeRatio/Math.SQRT2),v.uniform1f(U,g.cameraAngle),v.uniform1f(z,l),v.uniformMatrix3fv(w,!1,g.matrix),v.uniform1iv(P,Tt(new Array(this.textureImages.length)).map(function(B,H){return H})),v.uniform1i(k,s==="color"?1:0),v.uniform1i(D,c?1:0)}}]),p}(Ge),I(e,"ANGLE_1",0),I(e,"ANGLE_2",2*Math.PI/3),I(e,"ANGLE_3",4*Math.PI/3),I(e,"textureManager",m),e}Pt(),Pt({keepWithinCircle:!1,size:{mode:"force",value:256},drawingMode:"color",correctCentering:!0});function fa(r){if(Array.isArray(r))return r}function ga(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var i,n,o,a,s=[],c=!0,l=!1;try{if(o=(t=t.call(r)).next,e!==0)for(;!(c=(i=o.call(t)).done)&&(s.push(i.value),s.length!==e);c=!0);}catch(u){l=!0,n=u}finally{try{if(!c&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw n}}return s}}function Dt(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,i=Array(e);t<e;t++)i[t]=r[t];return i}function _i(r,e){if(r){if(typeof r=="string")return Dt(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Dt(r,e):void 0}}function ma(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
674
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function bi(r,e){return fa(r)||ga(r,e)||_i(r,e)||ma()}function va(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function pa(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function yi(r){var e=pa(r,"string");return typeof e=="symbol"?e:e+""}function _a(r,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,yi(i.key),i)}}function ba(r,e,t){return e&&_a(r.prototype,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function We(r){return We=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},We(r)}function Ei(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ei=function(){return!!r})()}function Ot(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function ya(r,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ot(r)}function Ea(r,e,t){return e=We(e),ya(r,Ei()?Reflect.construct(e,t||[],We(r).constructor):e.apply(r,t))}function kt(r,e){return kt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},kt(r,e)}function Ta(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&kt(r,e)}function be(r,e,t){return(e=yi(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Ra(r){if(Array.isArray(r))return Dt(r)}function Ca(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function wa(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
675
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xe(r){return Ra(r)||Ca(r)||_i(r)||wa()}function Ti(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function Ri(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ti(Object(t),!0).forEach(function(i){be(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Ti(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function Aa(r){var e=r.slices,t=r.offset,i=`
676
+ precision highp float;
677
+
678
+ varying vec2 v_diffVector;
679
+ varying float v_radius;
680
+
681
+ #ifdef PICKING_MODE
682
+ varying vec4 v_color;
683
+ #else
684
+ // For normal mode, we use the border colors defined in the program:
685
+ `.concat(e.flatMap(function(n,o){var a=n.value;return"attribute"in a?["varying float v_sliceValue_".concat(o+1,";")]:[]}).join(`
686
+ `),`
687
+ `).concat(e.map(function(n,o){var a=n.color;return"attribute"in a?"varying vec4 v_sliceColor_".concat(o+1,";"):"uniform vec4 u_sliceColor_".concat(o+1,";")}).join(`
688
+ `),`
689
+ #endif
690
+
691
+ uniform vec4 u_defaultColor;
692
+ uniform float u_cameraAngle;
693
+ uniform float u_correctionRatio;
694
+
695
+ `).concat("attribute"in t?`varying float v_offset;
696
+ `:"",`
697
+ `).concat("value"in t?`uniform float u_offset;
698
+ `:"",`
699
+
700
+ const float bias = 255.0 / 254.0;
701
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
702
+
703
+ void main(void) {
704
+ float aaBorder = u_correctionRatio * 2.0;;
705
+ float dist = length(v_diffVector);
706
+ float offset = `).concat("attribute"in t?"v_offset":"u_offset",`;
707
+ float angle = atan(v_diffVector.y / v_diffVector.x);
708
+ if (v_diffVector.x < 0.0 && v_diffVector.y < 0.0) angle += `).concat(Math.PI,`;
709
+ else if (v_diffVector.x < 0.0) angle += `).concat(Math.PI,`;
710
+ else if (v_diffVector.y < 0.0) angle += `).concat(2*Math.PI,`;
711
+ angle = angle - u_cameraAngle + offset;
712
+ angle = mod(angle, `).concat(2*Math.PI,`);
713
+
714
+ // No antialiasing for picking mode:
715
+ #ifdef PICKING_MODE
716
+ if (dist > v_radius)
717
+ gl_FragColor = transparent;
718
+ else {
719
+ gl_FragColor = v_color;
720
+ gl_FragColor.a *= bias;
721
+ }
722
+ #else
723
+ // Colors:
724
+ `).concat(e.map(function(n,o){var a=n.color,s=[];return"attribute"in a?s.push(" vec4 sliceColor_".concat(o+1," = v_sliceColor_").concat(o+1,";")):"transparent"in a?s.push(" vec4 sliceColor_".concat(o+1," = vec4(0.0, 0.0, 0.0, 0.0);")):s.push(" vec4 sliceColor_".concat(o+1," = u_sliceColor_").concat(o+1,";")),s.push(" sliceColor_".concat(o+1,".a *= bias;")),s.join(`
725
+ `)}).join(`
726
+ `),`
727
+ vec4 color = u_defaultColor;
728
+ color.a *= bias;
729
+
730
+ // Sizes:
731
+ `).concat(e.map(function(n,o){var a=n.value;return" float sliceValue_".concat(o+1," = ").concat("attribute"in a?"v_sliceValue_".concat(o+1):lt(a.value),";")}).join(`
732
+ `),`
733
+
734
+ // Angles and final color:
735
+ float total = `).concat(e.map(function(n,o){return"sliceValue_".concat(o+1)}).join(" + "),`;
736
+ float angle_0 = 0.0;
737
+ if (total > 0.0) {
738
+ `).concat(e.map(function(n,o){return" float angle_".concat(o+1," = angle_").concat(o," + sliceValue_").concat(o+1," * ").concat(2*Math.PI," / total;")}).join(`
739
+ `),`
740
+ `).concat(e.map(function(n,o){return"if (angle < angle_".concat(o+1,") color = sliceColor_").concat(o+1,";")}).join(`
741
+ else `),`
742
+ }
743
+
744
+ if (dist < v_radius - aaBorder) {
745
+ gl_FragColor = color;
746
+ } else if (dist < v_radius) {
747
+ gl_FragColor = mix(transparent, color, (v_radius - dist) / aaBorder);
748
+ }
749
+ #endif
750
+ }
751
+ `);return i}function Sa(r){var e=r.slices,t=r.offset,i=`
752
+ attribute vec4 a_id;
753
+ attribute vec2 a_position;
754
+ attribute float a_size;
755
+ attribute float a_angle;
756
+
757
+ uniform mat3 u_matrix;
758
+ uniform float u_sizeRatio;
759
+ uniform float u_correctionRatio;
760
+
761
+ varying vec2 v_diffVector;
762
+ varying float v_radius;
763
+
764
+ `.concat("attribute"in t?`attribute float a_offset;
765
+ `:"",`
766
+ `).concat("attribute"in t?`varying float v_offset;
767
+ `:"",`
768
+
769
+ #ifdef PICKING_MODE
770
+ varying vec4 v_color;
771
+ #else
772
+ `).concat(e.flatMap(function(n,o){var a=n.value;return"attribute"in a?["attribute float a_sliceValue_".concat(o+1,";"),"varying float v_sliceValue_".concat(o+1,";")]:[]}).join(`
773
+ `),`
774
+ `).concat(e.flatMap(function(n,o){var a=n.color;return"attribute"in a?["attribute vec4 a_sliceColor_".concat(o+1,";"),"varying vec4 v_sliceColor_".concat(o+1,";")]:[]}).join(`
775
+ `),`
776
+ #endif
777
+
778
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
779
+
780
+ void main() {
781
+ float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
782
+ vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
783
+ vec2 position = a_position + diffVector;
784
+ gl_Position = vec4(
785
+ (u_matrix * vec3(position, 1)).xy,
786
+ 0,
787
+ 1
788
+ );
789
+
790
+ v_radius = size / 2.0;
791
+ v_diffVector = diffVector;
792
+ `).concat("attribute"in t?`v_offset = a_offset;
793
+ `:"",`
794
+
795
+ #ifdef PICKING_MODE
796
+ v_color = a_id;
797
+ #else
798
+ `).concat(e.flatMap(function(n,o){var a=n.value;return"attribute"in a?[" v_sliceValue_".concat(o+1," = a_sliceValue_").concat(o+1,";")]:[]}).join(`
799
+ `),`
800
+ `).concat(e.flatMap(function(n,o){var a=n.color;return"attribute"in a?[" v_sliceColor_".concat(o+1," = a_sliceColor_").concat(o+1,";")]:[]}).join(`
801
+ `),`
802
+ #endif
803
+ }
804
+ `);return i}var It="#000000",xa={drawLabel:void 0,drawHover:void 0,defaultColor:It,offset:{value:0}},Ci=WebGLRenderingContext,wi=Ci.UNSIGNED_BYTE,Fe=Ci.FLOAT;function Fa(r){var e,t=Ri(Ri({},xa),r),i=t.slices,n=t.offset,o=t.drawHover,a=t.drawLabel,s=["u_sizeRatio","u_correctionRatio","u_cameraAngle","u_matrix","u_defaultColor"].concat(xe("value"in n?["u_offset"]:[]),xe(i.flatMap(function(c,l){var u=c.color;return"value"in u?["u_sliceColor_".concat(l+1)]:[]})));return e=function(c){Ta(l,c);function l(){var u;va(this,l);for(var h=arguments.length,d=new Array(h),m=0;m<h;m++)d[m]=arguments[m];return u=Ea(this,l,[].concat(d)),be(Ot(u),"drawLabel",a),be(Ot(u),"drawHover",o),u}return ba(l,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Sa(t),FRAGMENT_SHADER_SOURCE:Aa(t),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:s,ATTRIBUTES:[{name:"a_position",size:2,type:Fe},{name:"a_id",size:4,type:wi,normalized:!0},{name:"a_size",size:1,type:Fe}].concat(xe("attribute"in n?[{name:"a_offset",size:1,type:Fe}]:[]),xe(i.flatMap(function(h,d){var m=h.color;return"attribute"in m?[{name:"a_sliceColor_".concat(d+1),size:4,type:wi,normalized:!0}]:[]})),xe(i.flatMap(function(h,d){var m=h.value;return"attribute"in m?[{name:"a_sliceValue_".concat(d+1),size:1,type:Fe}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Fe}],CONSTANT_DATA:[[l.ANGLE_1],[l.ANGLE_2],[l.ANGLE_3]]}}},{key:"processVisibleItem",value:function(h,d,m){var f=this.array;f[d++]=m.x,f[d++]=m.y,f[d++]=h,f[d++]=m.size,"attribute"in n&&(f[d++]=m[n.attribute]||0),i.forEach(function(p){var b=p.color;"attribute"in b&&(f[d++]=K(m[b.attribute]||b.defaultValue||It))}),i.forEach(function(p){var b=p.value;"attribute"in b&&(f[d++]=m[b.attribute]||0)})}},{key:"setUniforms",value:function(h,d){var m=d.gl,f=d.uniformLocations,p=f.u_sizeRatio,b=f.u_correctionRatio,g=f.u_cameraAngle,_=f.u_matrix,v=f.u_defaultColor;m.uniform1f(b,h.correctionRatio),m.uniform1f(p,h.sizeRatio),m.uniform1f(g,h.cameraAngle),m.uniformMatrix3fv(_,!1,h.matrix),"value"in n&&m.uniform1f(f.u_offset,n.value);var y=ot(t.defaultColor||It),C=bi(y,4),S=C[0],w=C[1],P=C[2],k=C[3];m.uniform4f(v,S/255,w/255,P/255,k/255),i.forEach(function(D,U){var z=D.color;if("value"in z){var B=f["u_sliceColor_".concat(U+1)],H=ot(z.value),$=bi(H,4),T=$[0],E=$[1],R=$[2],x=$[3];m.uniform4f(B,T/255,E/255,R/255,x/255)}})}}]),l}(Ge),be(e,"ANGLE_1",0),be(e,"ANGLE_2",2*Math.PI/3),be(e,"ANGLE_3",4*Math.PI/3),e}const Ai=r=>r,Si=r=>r*r,xi=r=>r*(2-r),Fi=r=>(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1),Li=r=>r*r*r,Ni=r=>--r*r*r+1,Pi=r=>(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2),zt={linear:Ai,quadraticIn:Si,quadraticOut:xi,quadraticInOut:Fi,cubicIn:Li,cubicOut:Ni,cubicInOut:Pi},Gt={easing:"quadraticInOut",duration:150};function La(r,e,t,i){const n=Object.assign({},Gt,t),o=typeof n.easing=="function"?n.easing:zt[n.easing],a=Date.now(),s={};for(const u in e){const h=e[u];s[u]={};for(const d in h)s[u][d]=r.getNodeAttribute(u,d)}let c=null;const l=()=>{c=null;let u=(Date.now()-a)/n.duration;if(u>=1){for(const h in e){const d=e[h];for(const m in d)r.setNodeAttribute(h,m,d[m])}typeof i=="function"&&i();return}u=o(u);for(const h in e){const d=e[h],m=s[h];for(const f in d)r.setNodeAttribute(h,f,d[f]*u+m[f]*(1-u))}c=requestAnimationFrame(l)};return l(),()=>{c&&cancelAnimationFrame(c)}}const Ye={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"};function Na(r,e,t,i){const n=i||new Uint8Array(4);return r.readPixels(e,t,1,1,r.RGBA,r.UNSIGNED_BYTE,n),n}const Di=new Int8Array(4),Xe=new Int32Array(Di.buffer,0,1),Oi=new Float32Array(Di.buffer,0,1),Pa=/^\s*rgba?\s*\(/,Da=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function ki(r){let e=0,t=0,i=0,n=1;if(r[0]==="#")r.length===4?(e=parseInt(r.charAt(1)+r.charAt(1),16),t=parseInt(r.charAt(2)+r.charAt(2),16),i=parseInt(r.charAt(3)+r.charAt(3),16)):(e=parseInt(r.charAt(1)+r.charAt(2),16),t=parseInt(r.charAt(3)+r.charAt(4),16),i=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(n=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(Pa.test(r)){const o=r.match(Da);o&&(e=+o[1],t=+o[2],i=+o[3],o[4]&&(n=+o[4]))}return{r:e,g:t,b:i,a:n}}const ye={};for(const r in Ye)ye[r]=Y(Ye[r]),ye[Ye[r]]=ye[r];function Mt(r,e,t,i,n){return Xe[0]=i<<24|t<<16|e<<8|r,n&&(Xe[0]=Xe[0]&4278190079),Oi[0]}function Y(r){if(r=r.toLowerCase(),typeof ye[r]<"u")return ye[r];const e=ki(r),{r:t,g:i,b:n}=e;let{a:o}=e;o=o*255|0;const a=Mt(t,i,n,o,!0);return ye[r]=a,a}function Oa(r,e){Oi[0]=Y(r);let t=Xe[0];e&&(t=t|16777216);const i=t&255,n=t>>8&255,o=t>>16&255,a=t>>24&255;return[i,n,o,a]}const Ut={};function Bt(r){if(typeof Ut[r]<"u")return Ut[r];const e=(r&16711680)>>>16,t=(r&65280)>>>8,i=r&255,o=Mt(e,t,i,255,!0);return Ut[r]=o,o}function Ht(r,e,t,i){return t+(e<<8)+(r<<16)}function $t(r,e,t,i,n,o){const a=Math.floor(t/o*n),s=Math.floor(r.drawingBufferHeight/o-i/o*n),c=new Uint8Array(4);r.bindFramebuffer(r.FRAMEBUFFER,e),r.readPixels(a,s,1,1,r.RGBA,r.UNSIGNED_BYTE,c);const[l,u,h,d]=c;return[l,u,h,d]}function V(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Le(r,e,t){return r[0]=e,r[4]=typeof t=="number"?t:e,r}function jt(r,e){const t=Math.sin(e),i=Math.cos(e);return r[0]=i,r[1]=t,r[3]=-t,r[4]=i,r}function Vt(r,e,t){return r[6]=e,r[7]=t,r}function Z(r,e){const t=r[0],i=r[1],n=r[2],o=r[3],a=r[4],s=r[5],c=r[6],l=r[7],u=r[8],h=e[0],d=e[1],m=e[2],f=e[3],p=e[4],b=e[5],g=e[6],_=e[7],v=e[8];return r[0]=h*t+d*o+m*c,r[1]=h*i+d*a+m*l,r[2]=h*n+d*s+m*u,r[3]=f*t+p*o+b*c,r[4]=f*i+p*a+b*l,r[5]=f*n+p*s+b*u,r[6]=g*t+_*o+v*c,r[7]=g*i+_*a+v*l,r[8]=g*n+_*s+v*u,r}function qe(r,e,t=1){const i=r[0],n=r[1],o=r[3],a=r[4],s=r[6],c=r[7],l=e.x,u=e.y;return{x:l*i+u*o+s*t,y:l*n+u*a+c*t}}function Ii(r,e){const t=r.height/r.width,i=e.height/e.width;return t<1&&i>1||t>1&&i<1?1:Math.min(Math.max(i,1/i),Math.max(1/t,t))}function Ee(r,e,t,i,n){const{angle:o,ratio:a,x:s,y:c}=r,{width:l,height:u}=e,h=V(),d=Math.min(l,u)-2*i,m=Ii(e,t);return n?(Z(h,Vt(V(),s,c)),Z(h,Le(V(),a)),Z(h,jt(V(),o)),Z(h,Le(V(),l/d/2/m,u/d/2/m))):(Z(h,Le(V(),2*(d/l)*m,2*(d/u)*m)),Z(h,jt(V(),-o)),Z(h,Le(V(),1/a)),Z(h,Vt(V(),-s,-c))),h}function zi(r,e,t){const{x:i,y:n}=qe(r,{x:Math.cos(e.angle),y:Math.sin(e.angle)},0);return 1/Math.sqrt(Math.pow(i,2)+Math.pow(n,2))/t.width}function Wt(r,e){const t=e.size;if(t===0)return;const i=r.length;r.length+=t;let n=0;e.forEach(o=>{r[i+n]=o,n++})}function Gi(r){return typeof r=="object"&&r!==null&&r.constructor===Object}function Ke(r,...e){r=r||{};for(let t=0,i=e.length;t<i;t++){const n=e[t];n&&Object.assign(r,n)}return r}function Mi(r,...e){r=r||{};for(let t=0,i=e.length;t<i;t++){const n=e[t];if(n)for(const o in n)Gi(n[o])?r[o]=Mi(r[o],n[o]):r[o]=n[o]}return r}function Ui(r){if(!r.order)return{x:[0,1],y:[0,1]};let e=1/0,t=-1/0,i=1/0,n=-1/0;return r.forEachNode((o,a)=>{const{x:s,y:c}=a;s<e&&(e=s),s>t&&(t=s),c<i&&(i=c),c>n&&(n=c)}),{x:[e,t],y:[i,n]}}function Bi(r){if(!eo(r))throw new Error("Sigma: invalid graph instance.");r.forEachNode((e,t)=>{if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new Error(`Sigma: Coordinates of node ${e} are invalid. A node must have a numeric 'x' and 'y' attribute.`)})}function Hi(r,e,t){const i=document.createElement(r);if(e)for(const n in e)i.style[n]=e[n];if(t)for(const n in t)i.setAttribute(n,t[n]);return i}function Yt(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Xt(r,e,t){return t.sort(function(i,n){const o=e(i)||0,a=e(n)||0;return o<a?-1:o>a?1:0})}function qt(r){const{x:[e,t],y:[i,n]}=r;let o=Math.max(t-e,n-i),a=(t+e)/2,s=(n+i)/2;(o===0||Math.abs(o)===1/0||isNaN(o))&&(o=1),isNaN(a)&&(a=0),isNaN(s)&&(s=0);const c=l=>({x:.5+(l.x-a)/o,y:.5+(l.y-s)/o});return c.applyTo=l=>{l.x=.5+(l.x-a)/o,l.y=.5+(l.y-s)/o},c.inverse=l=>({x:a+o*(l.x-.5),y:s+o*(l.y-.5)}),c.ratio=o,c}const ka=Object.freeze(Object.defineProperty({__proto__:null,ANIMATE_DEFAULTS:Gt,HTML_COLORS:Ye,animateNodes:La,assign:Ke,assignDeep:Mi,colorToArray:Oa,colorToIndex:Ht,createElement:Hi,createNormalizationFunction:qt,cubicIn:Li,cubicInOut:Pi,cubicOut:Ni,easings:zt,extend:Wt,extractPixel:Na,floatColor:Y,getCorrectionRatio:Ii,getMatrixImpact:zi,getPixelColor:$t,getPixelRatio:Yt,graphExtent:Ui,identity:V,indexToColor:Bt,isPlainObject:Gi,linear:Ai,matrixFromCamera:Ee,multiply:Z,multiplyVec2:qe,parseColor:ki,quadraticIn:Si,quadraticInOut:Fi,quadraticOut:xi,rgbaToFloat:Mt,rotate:jt,scale:Le,translate:Vt,validateGraph:Bi,zIndexOrdering:Xt},Symbol.toStringTag,{value:"Module"}));function $i(r){return r.normalized?1:r.size}function Ze(r){let e=0;return r.forEach(t=>e+=$i(t)),e}function ji(r,e,t){const i=r==="VERTEX"?e.VERTEX_SHADER:e.FRAGMENT_SHADER,n=e.createShader(i);if(n===null)throw new Error("loadShader: error while creating the shader");if(e.shaderSource(n,t),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){const a=e.getShaderInfoLog(n);throw e.deleteShader(n),new Error(`loadShader: error while compiling the shader:
805
+ ${a}
806
+ ${t}`)}return n}function Vi(r,e){return ji("VERTEX",r,e)}function Wi(r,e){return ji("FRAGMENT",r,e)}function Yi(r,e){const t=r.createProgram();if(t===null)throw new Error("loadProgram: error while creating the program.");let i,n;for(i=0,n=e.length;i<n;i++)r.attachShader(t,e[i]);if(r.linkProgram(t),!r.getProgramParameter(t,r.LINK_STATUS))throw r.deleteProgram(t),new Error("loadProgram: error while linking the program.");return t}function Kt({gl:r,buffer:e,program:t,vertexShader:i,fragmentShader:n}){r.deleteShader(i),r.deleteShader(n),r.deleteProgram(t),r.deleteBuffer(e)}function Ia(r){return r%1===0?r.toFixed(1):r.toString()}const Xi=`#define PICKING_MODE
807
+ `,za={[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};class Zt{constructor(e,t,i){}}class Qt{constructor(e,t,i){this.array=new Float32Array,this.constantArray=new Float32Array,this.capacity=0,this.verticesCount=0;const n=this.getDefinition();if(this.VERTICES=n.VERTICES,this.VERTEX_SHADER_SOURCE=n.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=n.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=n.UNIFORMS,this.ATTRIBUTES=n.ATTRIBUTES,this.METHOD=n.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in n?n.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in n?n.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in n,this.ATTRIBUTES_ITEMS_COUNT=Ze(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=i,this.normalProgram=this.getProgramInfo("normal",e,n.VERTEX_SHADER_SOURCE,n.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=t?this.getProgramInfo("pick",e,Xi+n.VERTEX_SHADER_SOURCE,Xi+n.FRAGMENT_SHADER_SOURCE,t):null,this.isInstanced){const o=Ze(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error(`Program: error while getting constant data (expected ${this.VERTICES} items, received ${this.CONSTANT_DATA.length} instead)`);this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(let a=0;a<this.CONSTANT_DATA.length;a++){const s=this.CONSTANT_DATA[a];if(s.length!==o)throw new Error(`Program: error while getting constant data (one vector has ${s.length} items instead of ${o})`);for(let c=0;c<s.length;c++)this.constantArray[a*o+c]=s[c]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}kill(){Kt(this.normalProgram),this.pickProgram&&(Kt(this.pickProgram),this.pickProgram=null)}getProgramInfo(e,t,i,n,o){const a=this.getDefinition(),s=t.createBuffer();if(s===null)throw new Error("Program: error while creating the WebGL buffer.");const c=Vi(t,i),l=Wi(t,n),u=Yi(t,[c,l]),h={};a.UNIFORMS.forEach(f=>{const p=t.getUniformLocation(u,f);p&&(h[f]=p)});const d={};a.ATTRIBUTES.forEach(f=>{d[f.name]=t.getAttribLocation(u,f.name)});let m;if("CONSTANT_ATTRIBUTES"in a&&(a.CONSTANT_ATTRIBUTES.forEach(f=>{d[f.name]=t.getAttribLocation(u,f.name)}),m=t.createBuffer(),m===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:e,program:u,gl:t,frameBuffer:o,buffer:s,constantBuffer:m||{},uniformLocations:h,attributeLocations:d,isPicking:e==="pick",vertexShader:c,fragmentShader:l}}bindProgram(e){let t=0;const{gl:i,buffer:n}=e;this.isInstanced?(i.bindBuffer(i.ARRAY_BUFFER,e.constantBuffer),t=0,this.CONSTANT_ATTRIBUTES.forEach(o=>t+=this.bindAttribute(o,e,t,!1)),i.bufferData(i.ARRAY_BUFFER,this.constantArray,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,e.buffer),t=0,this.ATTRIBUTES.forEach(o=>t+=this.bindAttribute(o,e,t,!0)),i.bufferData(i.ARRAY_BUFFER,this.array,i.DYNAMIC_DRAW)):(i.bindBuffer(i.ARRAY_BUFFER,n),t=0,this.ATTRIBUTES.forEach(o=>t+=this.bindAttribute(o,e,t)),i.bufferData(i.ARRAY_BUFFER,this.array,i.DYNAMIC_DRAW)),i.bindBuffer(i.ARRAY_BUFFER,null)}unbindProgram(e){this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(t=>this.unbindAttribute(t,e,!1)),this.ATTRIBUTES.forEach(t=>this.unbindAttribute(t,e,!0))):this.ATTRIBUTES.forEach(t=>this.unbindAttribute(t,e))}bindAttribute(e,t,i,n){const o=za[e.type];if(typeof o!="number")throw new Error(`Program.bind: yet unsupported attribute type "${e.type}"`);const a=t.attributeLocations[e.name],s=t.gl;if(a!==-1){s.enableVertexAttribArray(a);const c=this.isInstanced?(n?this.ATTRIBUTES_ITEMS_COUNT:Ze(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(s.vertexAttribPointer(a,e.size,e.type,e.normalized||!1,c,i),this.isInstanced&&n)if(s instanceof WebGL2RenderingContext)s.vertexAttribDivisor(a,1);else{const l=s.getExtension("ANGLE_instanced_arrays");l&&l.vertexAttribDivisorANGLE(a,1)}}return e.size*o}unbindAttribute(e,t,i){const n=t.attributeLocations[e.name],o=t.gl;if(n!==-1&&(o.disableVertexAttribArray(n),this.isInstanced&&i))if(o instanceof WebGL2RenderingContext)o.vertexAttribDivisor(n,0);else{const a=o.getExtension("ANGLE_instanced_arrays");a&&a.vertexAttribDivisorANGLE(n,0)}}reallocate(e){e!==this.capacity&&(this.capacity=e,this.verticesCount=this.VERTICES*e,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}hasNothingToRender(){return this.verticesCount===0}renderProgram(e,t){const{gl:i,program:n}=t;i.enable(i.BLEND),i.useProgram(n),this.setUniforms(e,t),this.drawWebGL(this.METHOD,t)}render(e){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,e.width*e.pixelRatio/e.downSizingRatio,e.height*e.pixelRatio/e.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram({...e,pixelRatio:e.pixelRatio/e.downSizingRatio},this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,e.width*e.pixelRatio,e.height*e.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(e,this.normalProgram),this.unbindProgram(this.normalProgram))}drawWebGL(e,{gl:t,frameBuffer:i}){if(t.bindFramebuffer(t.FRAMEBUFFER,i),!this.isInstanced)t.drawArrays(e,0,this.verticesCount);else if(t instanceof WebGL2RenderingContext)t.drawArraysInstanced(e,0,this.VERTICES,this.capacity);else{const n=t.getExtension("ANGLE_instanced_arrays");n&&n.drawArraysInstancedANGLE(e,0,this.VERTICES,this.capacity)}}}class Ga extends Zt{}class Jt extends Qt{kill(){super.kill()}process(e,t,i){let n=t*this.STRIDE;if(i.hidden){for(let o=n+this.STRIDE;n<o;n++)this.array[n]=0;return}return this.processVisibleItem(Bt(e),n,i)}}function Ma(r,e,t){return class{constructor(n,o,a){this.drawLabel=e,this.drawHover=t,this.programs=r.map(s=>new s(n,o,a))}reallocate(n){this.programs.forEach(o=>o.reallocate(n))}process(n,o,a){this.programs.forEach(s=>s.process(n,o,a))}render(n){this.programs.forEach(o=>o.render(n))}kill(){this.programs.forEach(n=>n.kill())}}}class Ua extends Zt{}class le extends Qt{constructor(){super(...arguments),this.drawLabel=void 0}kill(){super.kill()}process(e,t,i,n,o){let a=t*this.STRIDE;if(o.hidden||i.hidden||n.hidden){for(let s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(Bt(e),a,i,n,o)}}function er(r,e){return class{constructor(i,n,o){this.drawLabel=e,this.programs=r.map(a=>new a(i,n,o))}reallocate(i){this.programs.forEach(n=>n.reallocate(i))}process(i,n,o,a,s){this.programs.forEach(c=>c.process(i,n,o,a,s))}render(i){this.programs.forEach(n=>n.render(i))}kill(){this.programs.forEach(i=>i.kill())}}}function qi(r,e,t,i,n){const o=n.edgeLabelSize,a=n.edgeLabelFont,s=n.edgeLabelWeight,c=n.edgeLabelColor.attribute?e[n.edgeLabelColor.attribute]||n.edgeLabelColor.color||"#000":n.edgeLabelColor.color;let l=e.label;if(!l)return;r.fillStyle=c,r.font=`${s} ${o}px ${a}`;const u=t.size,h=i.size;let d=t.x,m=t.y,f=i.x,p=i.y,b=(d+f)/2,g=(m+p)/2,_=f-d,v=p-m,y=Math.sqrt(_*_+v*v);if(y<u+h)return;d+=_*u/y,m+=v*u/y,f-=_*h/y,p-=v*h/y,b=(d+f)/2,g=(m+p)/2,_=f-d,v=p-m,y=Math.sqrt(_*_+v*v);let C=r.measureText(l).width;if(C>y){const w="…";for(l=l+w,C=r.measureText(l).width;C>y&&l.length>1;)l=l.slice(0,-2)+w,C=r.measureText(l).width;if(l.length<4)return}let S;_>0?v>0?S=Math.acos(_/y):S=Math.asin(v/y):v>0?S=Math.acos(_/y)+Math.PI:S=Math.asin(_/y)+Math.PI/2,r.save(),r.translate(b,g),r.rotate(S),r.fillText(l,-C/2,e.size/2+o),r.restore()}function tr(r,e,t){if(!e.label)return;const i=t.labelSize,n=t.labelFont,o=t.labelWeight,a=t.labelColor.attribute?e[t.labelColor.attribute]||t.labelColor.color||"#000":t.labelColor.color;r.fillStyle=a,r.font=`${o} ${i}px ${n}`,r.fillText(e.label,e.x+e.size+3,e.y+i/3)}function Ki(r,e,t){const i=t.labelSize,n=t.labelFont,o=t.labelWeight;r.font=`${o} ${i}px ${n}`,r.fillStyle="#FFF",r.shadowOffsetX=0,r.shadowOffsetY=0,r.shadowBlur=8,r.shadowColor="#000";const a=2;if(typeof e.label=="string"){const s=r.measureText(e.label).width,c=Math.round(s+5),l=Math.round(i+2*a),u=Math.max(e.size,i/2)+a,h=Math.asin(l/2/u),d=Math.sqrt(Math.abs(Math.pow(u,2)-Math.pow(l/2,2)));r.beginPath(),r.moveTo(e.x+d,e.y+l/2),r.lineTo(e.x+u+c,e.y+l/2),r.lineTo(e.x+u+c,e.y-l/2),r.lineTo(e.x+d,e.y-l/2),r.arc(e.x,e.y,u,h,-h),r.closePath(),r.fill()}else r.beginPath(),r.arc(e.x,e.y,e.size+a,0,Math.PI*2),r.closePath(),r.fill();r.shadowOffsetX=0,r.shadowOffsetY=0,r.shadowBlur=0,tr(r,e,t)}const Ba=`
808
+ precision highp float;
809
+
810
+ varying vec4 v_color;
811
+ varying vec2 v_diffVector;
812
+ varying float v_radius;
813
+
814
+ uniform float u_correctionRatio;
815
+
816
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
817
+
818
+ void main(void) {
819
+ float border = u_correctionRatio * 2.0;
820
+ float dist = length(v_diffVector) - v_radius + border;
821
+
822
+ // No antialiasing for picking mode:
823
+ #ifdef PICKING_MODE
824
+ if (dist > border)
825
+ gl_FragColor = transparent;
826
+ else
827
+ gl_FragColor = v_color;
828
+
829
+ #else
830
+ float t = 0.0;
831
+ if (dist > border)
832
+ t = 1.0;
833
+ else if (dist > 0.0)
834
+ t = dist / border;
835
+
836
+ gl_FragColor = mix(v_color, transparent, t);
837
+ #endif
838
+ }
839
+ `,Ha=`
840
+ attribute vec4 a_id;
841
+ attribute vec4 a_color;
842
+ attribute vec2 a_position;
843
+ attribute float a_size;
844
+ attribute float a_angle;
845
+
846
+ uniform mat3 u_matrix;
847
+ uniform float u_sizeRatio;
848
+ uniform float u_correctionRatio;
849
+
850
+ varying vec4 v_color;
851
+ varying vec2 v_diffVector;
852
+ varying float v_radius;
853
+ varying float v_border;
854
+
855
+ const float bias = 255.0 / 254.0;
856
+
857
+ void main() {
858
+ float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
859
+ vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
860
+ vec2 position = a_position + diffVector;
861
+ gl_Position = vec4(
862
+ (u_matrix * vec3(position, 1)).xy,
863
+ 0,
864
+ 1
865
+ );
866
+
867
+ v_diffVector = diffVector;
868
+ v_radius = size / 2.0;
869
+
870
+ #ifdef PICKING_MODE
871
+ // For picking mode, we use the ID as the color:
872
+ v_color = a_id;
873
+ #else
874
+ // For normal mode, we use the color:
875
+ v_color = a_color;
876
+ #endif
877
+
878
+ v_color.a *= bias;
879
+ }
880
+ `,{UNSIGNED_BYTE:Zi,FLOAT:rr}=WebGLRenderingContext,$a=["u_sizeRatio","u_correctionRatio","u_matrix"],ie=class ie extends Jt{getDefinition(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Ha,FRAGMENT_SHADER_SOURCE:Ba,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$a,ATTRIBUTES:[{name:"a_position",size:2,type:rr},{name:"a_size",size:1,type:rr},{name:"a_color",size:4,type:Zi,normalized:!0},{name:"a_id",size:4,type:Zi,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:rr}],CONSTANT_DATA:[[ie.ANGLE_1],[ie.ANGLE_2],[ie.ANGLE_3]]}}processVisibleItem(e,t,i){const n=this.array,o=Y(i.color);n[t++]=i.x,n[t++]=i.y,n[t++]=i.size,n[t++]=o,n[t++]=e}setUniforms(e,{gl:t,uniformLocations:i}){const{u_sizeRatio:n,u_correctionRatio:o,u_matrix:a}=i;t.uniform1f(o,e.correctionRatio),t.uniform1f(n,e.sizeRatio),t.uniformMatrix3fv(a,!1,e.matrix)}};ie.ANGLE_1=0,ie.ANGLE_2=2*Math.PI/3,ie.ANGLE_3=4*Math.PI/3;let Qe=ie;const ja=`
881
+ precision mediump float;
882
+
883
+ varying vec4 v_color;
884
+ varying float v_border;
885
+
886
+ const float radius = 0.5;
887
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
888
+
889
+ void main(void) {
890
+ vec2 m = gl_PointCoord - vec2(0.5, 0.5);
891
+ float dist = radius - length(m);
892
+
893
+ // No antialiasing for picking mode:
894
+ #ifdef PICKING_MODE
895
+ if (dist > v_border)
896
+ gl_FragColor = v_color;
897
+ else
898
+ gl_FragColor = transparent;
899
+
900
+ #else
901
+ float t = 0.0;
902
+ if (dist > v_border)
903
+ t = 1.0;
904
+ else if (dist > 0.0)
905
+ t = dist / v_border;
906
+
907
+ gl_FragColor = mix(transparent, v_color, t);
908
+ #endif
909
+ }
910
+ `,Va=`
911
+ attribute vec4 a_id;
912
+ attribute vec4 a_color;
913
+ attribute vec2 a_position;
914
+ attribute float a_size;
915
+
916
+ uniform float u_sizeRatio;
917
+ uniform float u_pixelRatio;
918
+ uniform mat3 u_matrix;
919
+
920
+ varying vec4 v_color;
921
+ varying float v_border;
922
+
923
+ const float bias = 255.0 / 254.0;
924
+
925
+ void main() {
926
+ gl_Position = vec4(
927
+ (u_matrix * vec3(a_position, 1)).xy,
928
+ 0,
929
+ 1
930
+ );
931
+
932
+ // Multiply the point size twice:
933
+ // - x SCALING_RATIO to correct the canvas scaling
934
+ // - x 2 to correct the formulae
935
+ gl_PointSize = a_size / u_sizeRatio * u_pixelRatio * 2.0;
936
+
937
+ v_border = (0.5 / a_size) * u_sizeRatio;
938
+
939
+ #ifdef PICKING_MODE
940
+ // For picking mode, we use the ID as the color:
941
+ v_color = a_id;
942
+ #else
943
+ // For normal mode, we use the color:
944
+ v_color = a_color;
945
+ #endif
946
+
947
+ v_color.a *= bias;
948
+ }
949
+ `,{UNSIGNED_BYTE:Qi,FLOAT:Ji}=WebGLRenderingContext,Wa=["u_sizeRatio","u_pixelRatio","u_matrix"];class Ya extends Jt{getDefinition(){return{VERTICES:1,VERTEX_SHADER_SOURCE:Va,FRAGMENT_SHADER_SOURCE:ja,METHOD:WebGLRenderingContext.POINTS,UNIFORMS:Wa,ATTRIBUTES:[{name:"a_position",size:2,type:Ji},{name:"a_size",size:1,type:Ji},{name:"a_color",size:4,type:Qi,normalized:!0},{name:"a_id",size:4,type:Qi,normalized:!0}]}}processVisibleItem(e,t,i){const n=this.array;n[t++]=i.x,n[t++]=i.y,n[t++]=i.size,n[t++]=Y(i.color),n[t++]=e}setUniforms({sizeRatio:e,pixelRatio:t,matrix:i},{gl:n,uniformLocations:o}){const{u_sizeRatio:a,u_pixelRatio:s,u_matrix:c}=o;n.uniform1f(s,t),n.uniform1f(a,e),n.uniformMatrix3fv(c,!1,i)}}const Xa=`
950
+ precision mediump float;
951
+
952
+ varying vec4 v_color;
953
+
954
+ void main(void) {
955
+ gl_FragColor = v_color;
956
+ }
957
+ `,qa=`
958
+ attribute vec2 a_position;
959
+ attribute vec2 a_normal;
960
+ attribute float a_radius;
961
+ attribute vec3 a_barycentric;
962
+
963
+ #ifdef PICKING_MODE
964
+ attribute vec4 a_id;
965
+ #else
966
+ attribute vec4 a_color;
967
+ #endif
968
+
969
+ uniform mat3 u_matrix;
970
+ uniform float u_sizeRatio;
971
+ uniform float u_correctionRatio;
972
+ uniform float u_minEdgeThickness;
973
+ uniform float u_lengthToThicknessRatio;
974
+ uniform float u_widenessToThicknessRatio;
975
+
976
+ varying vec4 v_color;
977
+
978
+ const float bias = 255.0 / 254.0;
979
+
980
+ void main() {
981
+ float minThickness = u_minEdgeThickness;
982
+
983
+ float normalLength = length(a_normal);
984
+ vec2 unitNormal = a_normal / normalLength;
985
+
986
+ // These first computations are taken from edge.vert.glsl and
987
+ // edge.clamped.vert.glsl. Please read it to get better comments on what's
988
+ // happening:
989
+ float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
990
+ float webGLThickness = pixelsThickness * u_correctionRatio;
991
+ float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
992
+ float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
993
+ float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
994
+
995
+ float da = a_barycentric.x;
996
+ float db = a_barycentric.y;
997
+ float dc = a_barycentric.z;
998
+
999
+ vec2 delta = vec2(
1000
+ da * (webGLNodeRadius * unitNormal.y)
1001
+ + db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
1002
+ + dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
1003
+
1004
+ da * (-webGLNodeRadius * unitNormal.x)
1005
+ + db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
1006
+ + dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
1007
+ );
1008
+
1009
+ vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
1010
+
1011
+ gl_Position = vec4(position, 0, 1);
1012
+
1013
+ #ifdef PICKING_MODE
1014
+ // For picking mode, we use the ID as the color:
1015
+ v_color = a_id;
1016
+ #else
1017
+ // For normal mode, we use the color:
1018
+ v_color = a_color;
1019
+ #endif
1020
+
1021
+ v_color.a *= bias;
1022
+ }
1023
+ `,{UNSIGNED_BYTE:en,FLOAT:Je}=WebGLRenderingContext,Ka=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],et={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function Ne(r){const e={...et,...r||{}};return class extends le{getDefinition(){return{VERTICES:3,VERTEX_SHADER_SOURCE:qa,FRAGMENT_SHADER_SOURCE:Xa,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ka,ATTRIBUTES:[{name:"a_position",size:2,type:Je},{name:"a_normal",size:2,type:Je},{name:"a_radius",size:1,type:Je},{name:"a_color",size:4,type:en,normalized:!0},{name:"a_id",size:4,type:en,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Je}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}processVisibleItem(i,n,o,a,s){e.extremity==="source"&&([o,a]=[a,o]);const c=s.size||1,l=a.size||1,u=o.x,h=o.y,d=a.x,m=a.y,f=Y(s.color),p=d-u,b=m-h;let g=p*p+b*b,_=0,v=0;g&&(g=1/Math.sqrt(g),_=-b*g*c,v=p*g*c);const y=this.array;y[n++]=d,y[n++]=m,y[n++]=-_,y[n++]=-v,y[n++]=l,y[n++]=f,y[n++]=i}setUniforms(i,{gl:n,uniformLocations:o}){const{u_matrix:a,u_sizeRatio:s,u_correctionRatio:c,u_minEdgeThickness:l,u_lengthToThicknessRatio:u,u_widenessToThicknessRatio:h}=o;n.uniformMatrix3fv(a,!1,i.matrix),n.uniform1f(s,i.sizeRatio),n.uniform1f(c,i.correctionRatio),n.uniform1f(l,i.minEdgeThickness),n.uniform1f(u,e.lengthToThicknessRatio),n.uniform1f(h,e.widenessToThicknessRatio)}}}const Za=Ne(),ir=`
1024
+ precision mediump float;
1025
+
1026
+ varying vec4 v_color;
1027
+ varying vec2 v_normal;
1028
+ varying float v_thickness;
1029
+ varying float v_feather;
1030
+
1031
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
1032
+
1033
+ void main(void) {
1034
+ // We only handle antialiasing for normal mode:
1035
+ #ifdef PICKING_MODE
1036
+ gl_FragColor = v_color;
1037
+ #else
1038
+ float dist = length(v_normal) * v_thickness;
1039
+
1040
+ float t = smoothstep(
1041
+ v_thickness - v_feather,
1042
+ v_thickness,
1043
+ dist
1044
+ );
1045
+
1046
+ gl_FragColor = mix(v_color, transparent, t);
1047
+ #endif
1048
+ }
1049
+ `,Qa=`
1050
+ attribute vec4 a_id;
1051
+ attribute vec4 a_color;
1052
+ attribute vec2 a_normal;
1053
+ attribute float a_normalCoef;
1054
+ attribute vec2 a_positionStart;
1055
+ attribute vec2 a_positionEnd;
1056
+ attribute float a_positionCoef;
1057
+ attribute float a_radius;
1058
+ attribute float a_radiusCoef;
1059
+
1060
+ uniform mat3 u_matrix;
1061
+ uniform float u_zoomRatio;
1062
+ uniform float u_sizeRatio;
1063
+ uniform float u_pixelRatio;
1064
+ uniform float u_correctionRatio;
1065
+ uniform float u_minEdgeThickness;
1066
+ uniform float u_lengthToThicknessRatio;
1067
+ uniform float u_feather;
1068
+
1069
+ varying vec4 v_color;
1070
+ varying vec2 v_normal;
1071
+ varying float v_thickness;
1072
+ varying float v_feather;
1073
+
1074
+ const float bias = 255.0 / 254.0;
1075
+
1076
+ void main() {
1077
+ float minThickness = u_minEdgeThickness;
1078
+
1079
+ float radius = a_radius * a_radiusCoef;
1080
+ vec2 normal = a_normal * a_normalCoef;
1081
+ vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
1082
+
1083
+ float normalLength = length(normal);
1084
+ vec2 unitNormal = normal / normalLength;
1085
+
1086
+ // These first computations are taken from edge.vert.glsl. Please read it to
1087
+ // get better comments on what's happening:
1088
+ float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
1089
+ float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
1090
+
1091
+ // Here, we move the point to leave space for the arrow head:
1092
+ float direction = sign(radius);
1093
+ float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
1094
+ float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
1095
+
1096
+ vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
1097
+
1098
+ // Here is the proper position of the vertex
1099
+ gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
1100
+
1101
+ v_thickness = webGLThickness / u_zoomRatio;
1102
+
1103
+ v_normal = unitNormal;
1104
+
1105
+ v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
1106
+
1107
+ #ifdef PICKING_MODE
1108
+ // For picking mode, we use the ID as the color:
1109
+ v_color = a_id;
1110
+ #else
1111
+ // For normal mode, we use the color:
1112
+ v_color = a_color;
1113
+ #endif
1114
+
1115
+ v_color.a *= bias;
1116
+ }
1117
+ `,{UNSIGNED_BYTE:tn,FLOAT:ue}=WebGLRenderingContext,Ja=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],rn={lengthToThicknessRatio:et.lengthToThicknessRatio};function nr(r){const e={...rn,...r||{}};return class extends le{getDefinition(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Qa,FRAGMENT_SHADER_SOURCE:ir,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ja,ATTRIBUTES:[{name:"a_positionStart",size:2,type:ue},{name:"a_positionEnd",size:2,type:ue},{name:"a_normal",size:2,type:ue},{name:"a_color",size:4,type:tn,normalized:!0},{name:"a_id",size:4,type:tn,normalized:!0},{name:"a_radius",size:1,type:ue}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:ue},{name:"a_normalCoef",size:1,type:ue},{name:"a_radiusCoef",size:1,type:ue}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}processVisibleItem(i,n,o,a,s){const c=s.size||1,l=o.x,u=o.y,h=a.x,d=a.y,m=Y(s.color),f=h-l,p=d-u,b=a.size||1;let g=f*f+p*p,_=0,v=0;g&&(g=1/Math.sqrt(g),_=-p*g*c,v=f*g*c);const y=this.array;y[n++]=l,y[n++]=u,y[n++]=h,y[n++]=d,y[n++]=_,y[n++]=v,y[n++]=m,y[n++]=i,y[n++]=b}setUniforms(i,{gl:n,uniformLocations:o}){const{u_matrix:a,u_zoomRatio:s,u_feather:c,u_pixelRatio:l,u_correctionRatio:u,u_sizeRatio:h,u_minEdgeThickness:d,u_lengthToThicknessRatio:m}=o;n.uniformMatrix3fv(a,!1,i.matrix),n.uniform1f(s,i.zoomRatio),n.uniform1f(h,i.sizeRatio),n.uniform1f(u,i.correctionRatio),n.uniform1f(l,i.pixelRatio),n.uniform1f(c,i.antiAliasingFeather),n.uniform1f(d,i.minEdgeThickness),n.uniform1f(m,e.lengthToThicknessRatio)}}}const es=nr(),ts=`
1118
+ attribute vec4 a_id;
1119
+ attribute vec4 a_color;
1120
+ attribute vec2 a_normal;
1121
+ attribute float a_normalCoef;
1122
+ attribute vec2 a_positionStart;
1123
+ attribute vec2 a_positionEnd;
1124
+ attribute float a_positionCoef;
1125
+ attribute float a_sourceRadius;
1126
+ attribute float a_targetRadius;
1127
+ attribute float a_sourceRadiusCoef;
1128
+ attribute float a_targetRadiusCoef;
1129
+
1130
+ uniform mat3 u_matrix;
1131
+ uniform float u_zoomRatio;
1132
+ uniform float u_sizeRatio;
1133
+ uniform float u_pixelRatio;
1134
+ uniform float u_correctionRatio;
1135
+ uniform float u_minEdgeThickness;
1136
+ uniform float u_lengthToThicknessRatio;
1137
+ uniform float u_feather;
1138
+
1139
+ varying vec4 v_color;
1140
+ varying vec2 v_normal;
1141
+ varying float v_thickness;
1142
+ varying float v_feather;
1143
+
1144
+ const float bias = 255.0 / 254.0;
1145
+
1146
+ void main() {
1147
+ float minThickness = u_minEdgeThickness;
1148
+
1149
+ vec2 normal = a_normal * a_normalCoef;
1150
+ vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
1151
+
1152
+ float normalLength = length(normal);
1153
+ vec2 unitNormal = normal / normalLength;
1154
+
1155
+ // These first computations are taken from edge.vert.glsl. Please read it to
1156
+ // get better comments on what's happening:
1157
+ float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
1158
+ float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
1159
+
1160
+ // Here, we move the point to leave space for the arrow heads:
1161
+ // Source arrow head
1162
+ float sourceRadius = a_sourceRadius * a_sourceRadiusCoef;
1163
+ float sourceDirection = sign(sourceRadius);
1164
+ float webGLSourceRadius = sourceDirection * sourceRadius * 2.0 * u_correctionRatio / u_sizeRatio;
1165
+ float webGLSourceArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
1166
+ vec2 sourceCompensationVector =
1167
+ vec2(-sourceDirection * unitNormal.y, sourceDirection * unitNormal.x)
1168
+ * (webGLSourceRadius + webGLSourceArrowHeadLength);
1169
+
1170
+ // Target arrow head
1171
+ float targetRadius = a_targetRadius * a_targetRadiusCoef;
1172
+ float targetDirection = sign(targetRadius);
1173
+ float webGLTargetRadius = targetDirection * targetRadius * 2.0 * u_correctionRatio / u_sizeRatio;
1174
+ float webGLTargetArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
1175
+ vec2 targetCompensationVector =
1176
+ vec2(-targetDirection * unitNormal.y, targetDirection * unitNormal.x)
1177
+ * (webGLTargetRadius + webGLTargetArrowHeadLength);
1178
+
1179
+ // Here is the proper position of the vertex
1180
+ gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + sourceCompensationVector + targetCompensationVector, 1)).xy, 0, 1);
1181
+
1182
+ v_thickness = webGLThickness / u_zoomRatio;
1183
+
1184
+ v_normal = unitNormal;
1185
+
1186
+ v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
1187
+
1188
+ #ifdef PICKING_MODE
1189
+ // For picking mode, we use the ID as the color:
1190
+ v_color = a_id;
1191
+ #else
1192
+ // For normal mode, we use the color:
1193
+ v_color = a_color;
1194
+ #endif
1195
+
1196
+ v_color.a *= bias;
1197
+ }
1198
+ `,{UNSIGNED_BYTE:nn,FLOAT:Q}=WebGLRenderingContext,rs=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],on={lengthToThicknessRatio:et.lengthToThicknessRatio};function or(r){const e={...on,...r||{}};return class extends le{getDefinition(){return{VERTICES:6,VERTEX_SHADER_SOURCE:ts,FRAGMENT_SHADER_SOURCE:ir,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:rs,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Q},{name:"a_positionEnd",size:2,type:Q},{name:"a_normal",size:2,type:Q},{name:"a_color",size:4,type:nn,normalized:!0},{name:"a_id",size:4,type:nn,normalized:!0},{name:"a_sourceRadius",size:1,type:Q},{name:"a_targetRadius",size:1,type:Q}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Q},{name:"a_normalCoef",size:1,type:Q},{name:"a_sourceRadiusCoef",size:1,type:Q},{name:"a_targetRadiusCoef",size:1,type:Q}],CONSTANT_DATA:[[0,1,-1,0],[0,-1,1,0],[1,1,0,1],[1,1,0,1],[0,-1,1,0],[1,-1,0,-1]]}}processVisibleItem(i,n,o,a,s){const c=s.size||1,l=o.x,u=o.y,h=a.x,d=a.y,m=Y(s.color),f=h-l,p=d-u,b=o.size||1,g=a.size||1;let _=f*f+p*p,v=0,y=0;_&&(_=1/Math.sqrt(_),v=-p*_*c,y=f*_*c);const C=this.array;C[n++]=l,C[n++]=u,C[n++]=h,C[n++]=d,C[n++]=v,C[n++]=y,C[n++]=m,C[n++]=i,C[n++]=b,C[n++]=g}setUniforms(i,{gl:n,uniformLocations:o}){const{u_matrix:a,u_zoomRatio:s,u_feather:c,u_pixelRatio:l,u_correctionRatio:u,u_sizeRatio:h,u_minEdgeThickness:d,u_lengthToThicknessRatio:m}=o;n.uniformMatrix3fv(a,!1,i.matrix),n.uniform1f(s,i.zoomRatio),n.uniform1f(h,i.sizeRatio),n.uniform1f(u,i.correctionRatio),n.uniform1f(l,i.pixelRatio),n.uniform1f(c,i.antiAliasingFeather),n.uniform1f(d,i.minEdgeThickness),n.uniform1f(m,e.lengthToThicknessRatio)}}}const is=or();function an(r){return er([nr(r),Ne(r)])}const sn=an();function cn(r){return er([or(r),Ne(r),Ne({...r,extremity:"source"})])}const ns=cn(),os=`
1199
+ precision mediump float;
1200
+
1201
+ varying vec4 v_color;
1202
+
1203
+ void main(void) {
1204
+ gl_FragColor = v_color;
1205
+ }
1206
+ `,as=`
1207
+ attribute vec4 a_id;
1208
+ attribute vec4 a_color;
1209
+ attribute vec2 a_position;
1210
+
1211
+ uniform mat3 u_matrix;
1212
+
1213
+ varying vec4 v_color;
1214
+
1215
+ const float bias = 255.0 / 254.0;
1216
+
1217
+ void main() {
1218
+ // Scale from [[-1 1] [-1 1]] to the container:
1219
+ gl_Position = vec4(
1220
+ (u_matrix * vec3(a_position, 1)).xy,
1221
+ 0,
1222
+ 1
1223
+ );
1224
+
1225
+ #ifdef PICKING_MODE
1226
+ // For picking mode, we use the ID as the color:
1227
+ v_color = a_id;
1228
+ #else
1229
+ // For normal mode, we use the color:
1230
+ v_color = a_color;
1231
+ #endif
1232
+
1233
+ v_color.a *= bias;
1234
+ }
1235
+ `,{UNSIGNED_BYTE:ln,FLOAT:ss}=WebGLRenderingContext,cs=["u_matrix"];class ls extends le{getDefinition(){return{VERTICES:2,VERTEX_SHADER_SOURCE:as,FRAGMENT_SHADER_SOURCE:os,METHOD:WebGLRenderingContext.LINES,UNIFORMS:cs,ATTRIBUTES:[{name:"a_position",size:2,type:ss},{name:"a_color",size:4,type:ln,normalized:!0},{name:"a_id",size:4,type:ln,normalized:!0}]}}processVisibleItem(e,t,i,n,o){const a=this.array,s=i.x,c=i.y,l=n.x,u=n.y,h=Y(o.color);a[t++]=s,a[t++]=c,a[t++]=h,a[t++]=e,a[t++]=l,a[t++]=u,a[t++]=h,a[t++]=e}setUniforms(e,{gl:t,uniformLocations:i}){const{u_matrix:n}=i;t.uniformMatrix3fv(n,!1,e.matrix)}}const us=`
1236
+ attribute vec4 a_id;
1237
+ attribute vec4 a_color;
1238
+ attribute vec2 a_normal;
1239
+ attribute float a_normalCoef;
1240
+ attribute vec2 a_positionStart;
1241
+ attribute vec2 a_positionEnd;
1242
+ attribute float a_positionCoef;
1243
+
1244
+ uniform mat3 u_matrix;
1245
+ uniform float u_sizeRatio;
1246
+ uniform float u_zoomRatio;
1247
+ uniform float u_pixelRatio;
1248
+ uniform float u_correctionRatio;
1249
+ uniform float u_minEdgeThickness;
1250
+ uniform float u_feather;
1251
+
1252
+ varying vec4 v_color;
1253
+ varying vec2 v_normal;
1254
+ varying float v_thickness;
1255
+ varying float v_feather;
1256
+
1257
+ const float bias = 255.0 / 254.0;
1258
+
1259
+ void main() {
1260
+ float minThickness = u_minEdgeThickness;
1261
+
1262
+ vec2 normal = a_normal * a_normalCoef;
1263
+ vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
1264
+
1265
+ float normalLength = length(normal);
1266
+ vec2 unitNormal = normal / normalLength;
1267
+
1268
+ // We require edges to be at least "minThickness" pixels thick *on screen*
1269
+ // (so we need to compensate the size ratio):
1270
+ float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
1271
+
1272
+ // Then, we need to retrieve the normalized thickness of the edge in the WebGL
1273
+ // referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
1274
+ // ratio:
1275
+ float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
1276
+
1277
+ // Here is the proper position of the vertex
1278
+ gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
1279
+
1280
+ // For the fragment shader though, we need a thickness that takes the "magic"
1281
+ // correction ratio into account (as in webGLThickness), but so that the
1282
+ // antialiasing effect does not depend on the zoom level. So here's yet
1283
+ // another thickness version:
1284
+ v_thickness = webGLThickness / u_zoomRatio;
1285
+
1286
+ v_normal = unitNormal;
1287
+
1288
+ v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
1289
+
1290
+ #ifdef PICKING_MODE
1291
+ // For picking mode, we use the ID as the color:
1292
+ v_color = a_id;
1293
+ #else
1294
+ // For normal mode, we use the color:
1295
+ v_color = a_color;
1296
+ #endif
1297
+
1298
+ v_color.a *= bias;
1299
+ }
1300
+ `,{UNSIGNED_BYTE:un,FLOAT:Pe}=WebGLRenderingContext,hs=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"];class hn extends le{getDefinition(){return{VERTICES:6,VERTEX_SHADER_SOURCE:us,FRAGMENT_SHADER_SOURCE:ir,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:hs,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Pe},{name:"a_positionEnd",size:2,type:Pe},{name:"a_normal",size:2,type:Pe},{name:"a_color",size:4,type:un,normalized:!0},{name:"a_id",size:4,type:un,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Pe},{name:"a_normalCoef",size:1,type:Pe}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}processVisibleItem(e,t,i,n,o){const a=o.size||1,s=i.x,c=i.y,l=n.x,u=n.y,h=Y(o.color),d=l-s,m=u-c;let f=d*d+m*m,p=0,b=0;f&&(f=1/Math.sqrt(f),p=-m*f*a,b=d*f*a);const g=this.array;g[t++]=s,g[t++]=c,g[t++]=l,g[t++]=u,g[t++]=p,g[t++]=b,g[t++]=h,g[t++]=e}setUniforms(e,{gl:t,uniformLocations:i}){const{u_matrix:n,u_zoomRatio:o,u_feather:a,u_pixelRatio:s,u_correctionRatio:c,u_sizeRatio:l,u_minEdgeThickness:u}=i;t.uniformMatrix3fv(n,!1,e.matrix),t.uniform1f(o,e.zoomRatio),t.uniform1f(l,e.sizeRatio),t.uniform1f(c,e.correctionRatio),t.uniform1f(s,e.pixelRatio),t.uniform1f(a,e.antiAliasingFeather),t.uniform1f(u,e.minEdgeThickness)}}const ds=`
1301
+ precision mediump float;
1302
+
1303
+ varying vec4 v_color;
1304
+
1305
+ void main(void) {
1306
+ gl_FragColor = v_color;
1307
+ }
1308
+ `,fs=`
1309
+ attribute vec4 a_id;
1310
+ attribute vec4 a_color;
1311
+ attribute vec2 a_normal;
1312
+ attribute float a_normalCoef;
1313
+ attribute vec2 a_positionStart;
1314
+ attribute vec2 a_positionEnd;
1315
+ attribute float a_positionCoef;
1316
+
1317
+ uniform mat3 u_matrix;
1318
+ uniform float u_sizeRatio;
1319
+ uniform float u_correctionRatio;
1320
+
1321
+ varying vec4 v_color;
1322
+
1323
+ const float minThickness = 1.7;
1324
+ const float bias = 255.0 / 254.0;
1325
+
1326
+ void main() {
1327
+ vec2 normal = a_normal * a_normalCoef;
1328
+ vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
1329
+
1330
+ // The only different here with edge.vert.glsl is that we need to handle null
1331
+ // input normal vector. Apart from that, you can read edge.vert.glsl more info
1332
+ // on how it works:
1333
+ float normalLength = length(normal);
1334
+ vec2 unitNormal = normal / normalLength;
1335
+ if (normalLength <= 0.0) unitNormal = normal;
1336
+ float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
1337
+ float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
1338
+
1339
+ gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
1340
+
1341
+ #ifdef PICKING_MODE
1342
+ // For picking mode, we use the ID as the color:
1343
+ v_color = a_id;
1344
+ #else
1345
+ // For normal mode, we use the color:
1346
+ v_color = a_color;
1347
+ #endif
1348
+
1349
+ v_color.a *= bias;
1350
+ }
1351
+ `,{UNSIGNED_BYTE:dn,FLOAT:De}=WebGLRenderingContext,gs=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness"];class ms extends le{getDefinition(){return{VERTICES:3,VERTEX_SHADER_SOURCE:fs,FRAGMENT_SHADER_SOURCE:ds,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:gs,ATTRIBUTES:[{name:"a_positionStart",size:2,type:De},{name:"a_positionEnd",size:2,type:De},{name:"a_normal",size:2,type:De},{name:"a_color",size:4,type:dn,normalized:!0},{name:"a_id",size:4,type:dn,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:De},{name:"a_normalCoef",size:1,type:De}],CONSTANT_DATA:[[0,1],[0,-1],[1,0]]}}processVisibleItem(e,t,i,n,o){const a=o.size||1,s=i.x,c=i.y,l=n.x,u=n.y,h=Y(o.color),d=l-s,m=u-c;let f=d*d+m*m,p=0,b=0;f&&(f=1/Math.sqrt(f),p=-m*f*a,b=d*f*a);const g=this.array;g[t++]=s,g[t++]=c,g[t++]=l,g[t++]=u,g[t++]=p,g[t++]=b,g[t++]=h,g[t++]=e}setUniforms(e,{gl:t,uniformLocations:i}){const{u_matrix:n,u_sizeRatio:o,u_correctionRatio:a,u_minEdgeThickness:s}=i;t.uniformMatrix3fv(n,!1,e.matrix),t.uniform1f(o,e.sizeRatio),t.uniform1f(a,e.correctionRatio),t.uniform1f(s,e.minEdgeThickness)}}const vs=Object.freeze(Object.defineProperty({__proto__:null,AbstractEdgeProgram:Ua,AbstractNodeProgram:Ga,AbstractProgram:Zt,DEFAULT_EDGE_ARROW_HEAD_PROGRAM_OPTIONS:et,DEFAULT_EDGE_CLAMPED_PROGRAM_OPTIONS:rn,DEFAULT_EDGE_DOUBLE_CLAMPED_PROGRAM_OPTIONS:on,EdgeArrowHeadProgram:Za,EdgeArrowProgram:sn,EdgeClampedProgram:es,EdgeDoubleArrowProgram:ns,EdgeDoubleClampedProgram:is,EdgeLineProgram:ls,EdgeProgram:le,EdgeRectangleProgram:hn,EdgeTriangleProgram:ms,NodeCircleProgram:Qe,NodePointProgram:Ya,NodeProgram:Jt,Program:Qt,createEdgeArrowHeadProgram:Ne,createEdgeArrowProgram:an,createEdgeClampedProgram:nr,createEdgeCompoundProgram:er,createEdgeDoubleArrowProgram:cn,createEdgeDoubleClampedProgram:or,createNodeCompoundProgram:Ma,drawDiscNodeHover:Ki,drawDiscNodeLabel:tr,drawStraightEdgeLabel:qi,getAttributeItemsCount:$i,getAttributesItemsCount:Ze,killProgram:Kt,loadFragmentShader:Wi,loadProgram:Yi,loadVertexShader:Vi,numberToGLSLFloat:Ia},Symbol.toStringTag,{value:"Module"}));class ar extends ci.EventEmitter{constructor(){super(),this.rawEmitter=this}}const tt=1.5;class Te extends ar{constructor(){super(),this.x=.5,this.y=.5,this.angle=0,this.ratio=1,this.minRatio=null,this.maxRatio=null,this.enabledZooming=!0,this.enabledPanning=!0,this.enabledRotation=!0,this.clean=null,this.nextFrame=null,this.previousState=null,this.enabled=!0,this.previousState=this.getState()}static from(e){return new Te().setState(e)}enable(){return this.enabled=!0,this}disable(){return this.enabled=!1,this}getState(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}hasState(e){return this.x===e.x&&this.y===e.y&&this.ratio===e.ratio&&this.angle===e.angle}getPreviousState(){const e=this.previousState;return e?{x:e.x,y:e.y,angle:e.angle,ratio:e.ratio}:null}getBoundedRatio(e){let t=e;return typeof this.minRatio=="number"&&(t=Math.max(t,this.minRatio)),typeof this.maxRatio=="number"&&(t=Math.min(t,this.maxRatio)),t}validateState(e){const t={};return this.enabledPanning&&typeof e.x=="number"&&(t.x=e.x),this.enabledPanning&&typeof e.y=="number"&&(t.y=e.y),this.enabledZooming&&typeof e.ratio=="number"&&(t.ratio=this.getBoundedRatio(e.ratio)),this.enabledRotation&&typeof e.angle=="number"&&(t.angle=e.angle),this.clean?this.clean({...this.getState(),...t}):t}isAnimated(){return!!this.nextFrame}setState(e){if(!this.enabled)return this;this.previousState=this.getState();const t=this.validateState(e);return typeof t.x=="number"&&(this.x=t.x),typeof t.y=="number"&&(this.y=t.y),typeof t.ratio=="number"&&(this.ratio=t.ratio),typeof t.angle=="number"&&(this.angle=t.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}updateState(e){return this.setState(e(this.getState())),this}animate(e,t={},i){if(!i)return new Promise(u=>this.animate(e,t,u));if(!this.enabled)return;const n={...Gt,...t},o=this.validateState(e),a=typeof n.easing=="function"?n.easing:zt[n.easing],s=Date.now(),c=this.getState(),l=()=>{const u=(Date.now()-s)/n.duration;if(u>=1){this.nextFrame=null,this.setState(o),this.animationCallback&&(this.animationCallback.call(null),this.animationCallback=void 0);return}const h=a(u),d={};typeof o.x=="number"&&(d.x=c.x+(o.x-c.x)*h),typeof o.y=="number"&&(d.y=c.y+(o.y-c.y)*h),this.enabledRotation&&typeof o.angle=="number"&&(d.angle=c.angle+(o.angle-c.angle)*h),typeof o.ratio=="number"&&(d.ratio=c.ratio+(o.ratio-c.ratio)*h),this.setState(d),this.nextFrame=requestAnimationFrame(l)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(l)):l(),this.animationCallback=i}animatedZoom(e){return e?typeof e=="number"?this.animate({ratio:this.ratio/e}):this.animate({ratio:this.ratio/(e.factor||tt)},e):this.animate({ratio:this.ratio/tt})}animatedUnzoom(e){return e?typeof e=="number"?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||tt)},e):this.animate({ratio:this.ratio*tt})}animatedReset(e){return this.animate({x:.5,y:.5,ratio:1,angle:0},e)}copy(){return Te.from(this.getState())}}const sr={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:qi,defaultDrawNodeLabel:tr,defaultDrawNodeHover:Ki,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},ps={circle:Qe},_s={arrow:sn,line:hn};function cr(r){if(typeof r.labelDensity!="number"||r.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");const{minCameraRatio:e,maxCameraRatio:t}=r;if(typeof e=="number"&&typeof t=="number"&&t<e)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function bs(r){const e=Ke({},sr,r);return e.nodeProgramClasses=Ke({},ps,e.nodeProgramClasses),e.edgeProgramClasses=Ke({},_s,e.edgeProgramClasses),e}function X(r,e){const t=e.getBoundingClientRect();return{x:r.clientX-t.left,y:r.clientY-t.top}}function J(r,e){const t={...X(r,e),sigmaDefaultPrevented:!1,preventSigmaDefault(){t.sigmaDefaultPrevented=!0},original:r};return t}function Oe(r){const e="x"in r?r:{...r.touches[0]||r.previousTouches[0],original:r.original,sigmaDefaultPrevented:r.sigmaDefaultPrevented,preventSigmaDefault:()=>{r.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}};return e}function ys(r,e){return{...J(r,e),delta:fn(r)}}const Es=2;function rt(r){const e=[];for(let t=0,i=Math.min(r.length,Es);t<i;t++)e.push(r[t]);return e}function ke(r,e,t){const i={touches:rt(r.touches).map(n=>X(n,t)),previousTouches:e.map(n=>X(n,t)),sigmaDefaultPrevented:!1,preventSigmaDefault(){i.sigmaDefaultPrevented=!0},original:r};return i}function fn(r){if(typeof r.deltaY<"u")return r.deltaY*-3/360;if(typeof r.detail<"u")return r.detail/-9;throw new Error("Captor: could not extract delta from event.")}class gn extends ar{constructor(e,t){super(),this.container=e,this.renderer=t}}const Ts=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"].reduce((r,e)=>({...r,[e]:sr[e]}),{});class mn extends gn{constructor(e,t){super(e,t),this.enabled=!0,this.draggedEvents=0,this.downStartTime=null,this.lastMouseX=null,this.lastMouseY=null,this.isMouseDown=!1,this.isMoving=!1,this.movingTimeout=null,this.startCameraState=null,this.clicks=0,this.doubleClickTimeout=null,this.currentWheelDirection=0,this.settings=Ts,this.handleClick=this.handleClick.bind(this),this.handleRightClick=this.handleRightClick.bind(this),this.handleDown=this.handleDown.bind(this),this.handleUp=this.handleUp.bind(this),this.handleMove=this.handleMove.bind(this),this.handleWheel=this.handleWheel.bind(this),this.handleLeave=this.handleLeave.bind(this),this.handleEnter=this.handleEnter.bind(this),e.addEventListener("click",this.handleClick,{capture:!1}),e.addEventListener("contextmenu",this.handleRightClick,{capture:!1}),e.addEventListener("mousedown",this.handleDown,{capture:!1}),e.addEventListener("wheel",this.handleWheel,{capture:!1}),e.addEventListener("mouseleave",this.handleLeave,{capture:!1}),e.addEventListener("mouseenter",this.handleEnter,{capture:!1}),document.addEventListener("mousemove",this.handleMove,{capture:!1}),document.addEventListener("mouseup",this.handleUp,{capture:!1})}kill(){const e=this.container;e.removeEventListener("click",this.handleClick),e.removeEventListener("contextmenu",this.handleRightClick),e.removeEventListener("mousedown",this.handleDown),e.removeEventListener("wheel",this.handleWheel),e.removeEventListener("mouseleave",this.handleLeave),e.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}handleClick(e){if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(e);setTimeout(()=>{this.clicks=0,this.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",J(e,this.container))}}handleRightClick(e){this.enabled&&this.emit("rightClick",J(e,this.container))}handleDoubleClick(e){if(!this.enabled)return;e.preventDefault(),e.stopPropagation();const t=J(e,this.container);if(this.emit("doubleClick",t),t.sigmaDefaultPrevented)return;const i=this.renderer.getCamera(),n=i.getBoundedRatio(i.getState().ratio/this.settings.doubleClickZoomingRatio);i.animate(this.renderer.getViewportZoomedState(X(e,this.container),n),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}handleDown(e){if(this.enabled){if(e.button===0){this.startCameraState=this.renderer.getCamera().getState();const{x:t,y:i}=X(e,this.container);this.lastMouseX=t,this.lastMouseY=i,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",J(e,this.container))}}handleUp(e){if(!this.enabled||!this.isMouseDown)return;const t=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);const{x:i,y:n}=X(e,this.container),o=t.getState(),a=t.getPreviousState()||{x:0,y:0};this.isMoving?t.animate({x:o.x+this.settings.inertiaRatio*(o.x-a.x),y:o.y+this.settings.inertiaRatio*(o.y-a.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==i||this.lastMouseY!==n)&&t.setState({x:o.x,y:o.y}),this.isMoving=!1,setTimeout(()=>{const s=this.draggedEvents>0;this.draggedEvents=0,s&&this.renderer.refresh()},0),this.emit("mouseup",J(e,this.container))}handleMove(e){if(!this.enabled)return;const t=J(e,this.container);if(this.emit("mousemovebody",t),(e.target===this.container||e.composedPath()[0]===this.container)&&this.emit("mousemove",t),!t.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(()=>{this.movingTimeout=null,this.isMoving=!1},this.settings.dragTimeout);const i=this.renderer.getCamera(),{x:n,y:o}=X(e,this.container),a=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),s=this.renderer.viewportToFramedGraph({x:n,y:o}),c=a.x-s.x,l=a.y-s.y,u=i.getState(),h=u.x+c,d=u.y+l;i.setState({x:h,y:d}),this.lastMouseX=n,this.lastMouseY=o,e.preventDefault(),e.stopPropagation()}}handleLeave(e){this.emit("mouseleave",J(e,this.container))}handleEnter(e){this.emit("mouseenter",J(e,this.container))}handleWheel(e){const t=this.renderer.getCamera();if(!this.enabled||!t.enabledZooming)return;const i=fn(e);if(!i)return;const n=ys(e,this.container);if(this.emit("wheel",n),n.sigmaDefaultPrevented){e.preventDefault(),e.stopPropagation();return}const o=t.getState().ratio,a=i>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,s=t.getBoundedRatio(o*a),c=i>0?1:-1,l=Date.now();o!==s&&(e.preventDefault(),e.stopPropagation(),!(this.currentWheelDirection===c&&this.lastWheelTriggerTime&&l-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(t.animate(this.renderer.getViewportZoomedState(X(e,this.container),s),{easing:"quadraticOut",duration:this.settings.zoomDuration},()=>{this.currentWheelDirection=0}),this.currentWheelDirection=c,this.lastWheelTriggerTime=l))}setSettings(e){this.settings=e}}const Rs=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"].reduce((r,e)=>({...r,[e]:sr[e]}),{});class Cs extends gn{constructor(e,t){super(e,t),this.enabled=!0,this.isMoving=!1,this.hasMoved=!1,this.touchMode=0,this.startTouchesPositions=[],this.lastTouches=[],this.lastTap=null,this.settings=Rs,this.handleStart=this.handleStart.bind(this),this.handleLeave=this.handleLeave.bind(this),this.handleMove=this.handleMove.bind(this),e.addEventListener("touchstart",this.handleStart,{capture:!1}),e.addEventListener("touchcancel",this.handleLeave,{capture:!1}),document.addEventListener("touchend",this.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",this.handleMove,{capture:!1,passive:!1})}kill(){const e=this.container;e.removeEventListener("touchstart",this.handleStart),e.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}getDimensions(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}handleStart(e){if(!this.enabled)return;e.preventDefault();const t=rt(e.touches);if(this.touchMode=t.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=t.map(i=>X(i,this.container)),this.touchMode===2){const[{x:i,y:n},{x:o,y:a}]=this.startTouchesPositions;this.startTouchesAngle=Math.atan2(a-n,o-i),this.startTouchesDistance=Math.sqrt(Math.pow(o-i,2)+Math.pow(a-n,2))}this.emit("touchdown",ke(e,this.lastTouches,this.container)),this.lastTouches=t,this.lastTouchesPositions=this.startTouchesPositions}handleLeave(e){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(e.cancelable&&e.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(e.touches.length===1){this.handleStart(e),e.preventDefault();break}case 1:if(this.isMoving){const t=this.renderer.getCamera(),i=t.getState(),n=t.getPreviousState()||{x:0,y:0};t.animate({x:i.x+this.settings.inertiaRatio*(i.x-n.x),y:i.y+this.settings.inertiaRatio*(i.y-n.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",ke(e,this.lastTouches,this.container)),!e.touches.length){const t=X(this.lastTouches[0],this.container),i=this.startTouchesPositions[0],n=(t.x-i.x)**2+(t.y-i.y)**2;if(!e.touches.length&&n<this.settings.tapMoveTolerance**2)if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){const o=ke(e,this.lastTouches,this.container);if(this.emit("doubletap",o),this.lastTap=null,!o.sigmaDefaultPrevented){const a=this.renderer.getCamera(),s=a.getBoundedRatio(a.getState().ratio/this.settings.doubleClickZoomingRatio);a.animate(this.renderer.getViewportZoomedState(t,s),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{const o=ke(e,this.lastTouches,this.container);this.emit("tap",o),this.lastTap={time:Date.now(),position:o.touches[0]||o.previousTouches[0]}}}this.lastTouches=rt(e.touches),this.startTouchesPositions=[]}}handleMove(e){if(!this.enabled||!this.startTouchesPositions.length)return;e.preventDefault();const t=rt(e.touches),i=t.map(l=>X(l,this.container)),n=this.lastTouches;this.lastTouches=t,this.lastTouchesPositions=i;const o=ke(e,n,this.container);if(this.emit("touchmove",o),o.sigmaDefaultPrevented||(this.hasMoved||(this.hasMoved=i.some((l,u)=>{const h=this.startTouchesPositions[u];return h&&(l.x!==h.x||l.y!==h.y)})),!this.hasMoved))return;this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(()=>{this.isMoving=!1},this.settings.dragTimeout);const a=this.renderer.getCamera(),s=this.startCameraState,c=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{const{x:l,y:u}=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),{x:h,y:d}=this.renderer.viewportToFramedGraph(i[0]);a.setState({x:s.x+l-h,y:s.y+u-d});break}case 2:{const l={x:.5,y:.5,angle:0,ratio:1},{x:u,y:h}=i[0],{x:d,y:m}=i[1],f=Math.atan2(m-h,d-u)-this.startTouchesAngle,p=Math.hypot(m-h,d-u)/this.startTouchesDistance,b=a.getBoundedRatio(s.ratio/p);l.ratio=b,l.angle=s.angle+f;const g=this.getDimensions(),_=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:s}),v=Math.min(g.width,g.height)-2*c,y=v/g.width,C=v/g.height,S=b/v;let w=u-v/2/y,P=h-v/2/C;[w,P]=[w*Math.cos(-l.angle)-P*Math.sin(-l.angle),P*Math.cos(-l.angle)+w*Math.sin(-l.angle)],l.x=_.x-w*S,l.y=_.y+P*S,a.setState(l);break}}}setSettings(e){this.settings=e}}class vn{constructor(e,t){this.key=e,this.size=t}static compare(e,t){return e.size>t.size?-1:e.size<t.size||e.key>t.key?1:-1}}class pn{constructor(){this.width=0,this.height=0,this.cellSize=0,this.columns=0,this.rows=0,this.cells={}}resizeAndClear(e,t){this.width=e.width,this.height=e.height,this.cellSize=t,this.columns=Math.ceil(e.width/t),this.rows=Math.ceil(e.height/t),this.cells={}}getIndex(e){const t=Math.floor(e.x/this.cellSize);return Math.floor(e.y/this.cellSize)*this.columns+t}add(e,t,i){const n=new vn(e,t),o=this.getIndex(i);let a=this.cells[o];a||(a=[],this.cells[o]=a),a.push(n)}organize(){for(const e in this.cells)this.cells[e].sort(vn.compare)}getLabelsToDisplay(e,t){const i=this.cellSize*this.cellSize,o=i/e/e*t/i,a=Math.ceil(o),s=[];for(const c in this.cells){const l=this.cells[c];for(let u=0;u<Math.min(a,l.length);u++)s.push(l[u].key)}return s}}function ws(r){const{graph:e,hoveredNode:t,highlightedNodes:i,displayedNodeLabels:n}=r,o=[];return e.forEachEdge((a,s,c,l)=>{(c===t||l===t||i.has(c)||i.has(l)||n.has(c)&&n.has(l))&&o.push(a)}),o}const _n=150,bn=50,ee=Object.prototype.hasOwnProperty;function As(r,e,t){if(!ee.call(t,"x")||!ee.call(t,"y"))throw new Error(`Sigma: could not find a valid position (x, y) for node "${e}". 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=r.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),ee.call(t,"hidden")||(t.hidden=!1),ee.call(t,"highlighted")||(t.highlighted=!1),ee.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=r.defaultNodeType),t.zIndex||(t.zIndex=0),t}function Ss(r,e,t){return t.color||(t.color=r.defaultEdgeColor),t.label||(t.label=""),t.size||(t.size=.5),ee.call(t,"hidden")||(t.hidden=!1),ee.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=r.defaultEdgeType),t.zIndex||(t.zIndex=0),t}let yn=class extends ar{constructor(e,t,i={}){if(super(),this.elements={},this.canvasContexts={},this.webGLContexts={},this.pickingLayers=new Set,this.textures={},this.frameBuffers={},this.activeListeners={},this.labelGrid=new pn,this.nodeDataCache={},this.edgeDataCache={},this.nodeProgramIndex={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.edgesWithForcedLabels=new Set,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeZExtent=[1/0,-1/0],this.edgeZExtent=[1/0,-1/0],this.matrix=V(),this.invMatrix=V(),this.correctionRatio=1,this.customBBox=null,this.normalizationFunction=qt({x:[0,1],y:[0,1]}),this.graphToViewportRatio=1,this.itemIDsIndex={},this.nodeIndices={},this.edgeIndices={},this.width=0,this.height=0,this.pixelRatio=Yt(),this.pickingDownSizingRatio=2*this.pixelRatio,this.displayedNodeLabels=new Set,this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null,this.hoveredEdge=null,this.renderFrame=null,this.renderHighlightedNodesFrame=null,this.needToProcess=!1,this.checkEdgesEventsFrame=null,this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={},this.settings=bs(i),cr(this.settings),Bi(e),!(t instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");this.graph=e,this.container=t,this.createWebGLContext("edges",{picking:i.enableEdgeEvents}),this.createCanvasContext("edgeLabels"),this.createWebGLContext("nodes",{picking:!0}),this.createCanvasContext("labels"),this.createCanvasContext("hovers"),this.createWebGLContext("hoverNodes"),this.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),this.resize();for(const n in this.settings.nodeProgramClasses)this.registerNodeProgram(n,this.settings.nodeProgramClasses[n],this.settings.nodeHoverProgramClasses[n]);for(const n in this.settings.edgeProgramClasses)this.registerEdgeProgram(n,this.settings.edgeProgramClasses[n]);this.camera=new Te,this.bindCameraHandlers(),this.mouseCaptor=new mn(this.elements.mouse,this),this.mouseCaptor.setSettings(this.settings),this.touchCaptor=new Cs(this.elements.mouse,this),this.touchCaptor.setSettings(this.settings),this.bindEventHandlers(),this.bindGraphHandlers(),this.handleSettingsUpdate(),this.refresh()}registerNodeProgram(e,t,i){return this.nodePrograms[e]&&this.nodePrograms[e].kill(),this.nodeHoverPrograms[e]&&this.nodeHoverPrograms[e].kill(),this.nodePrograms[e]=new t(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[e]=new(i||t)(this.webGLContexts.hoverNodes,null,this),this}registerEdgeProgram(e,t){return this.edgePrograms[e]&&this.edgePrograms[e].kill(),this.edgePrograms[e]=new t(this.webGLContexts.edges,this.frameBuffers.edges,this),this}unregisterNodeProgram(e){if(this.nodePrograms[e]){const{[e]:t,...i}=this.nodePrograms;t.kill(),this.nodePrograms=i}if(this.nodeHoverPrograms[e]){const{[e]:t,...i}=this.nodeHoverPrograms;t.kill(),this.nodePrograms=i}return this}unregisterEdgeProgram(e){if(this.edgePrograms[e]){const{[e]:t,...i}=this.edgePrograms;t.kill(),this.edgePrograms=i}return this}resetWebGLTexture(e){const t=this.webGLContexts[e],i=this.frameBuffers[e],n=this.textures[e];n&&t.deleteTexture(n);const o=t.createTexture();return t.bindFramebuffer(t.FRAMEBUFFER,i),t.bindTexture(t.TEXTURE_2D,o),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.width,this.height,0,t.RGBA,t.UNSIGNED_BYTE,null),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,o,0),this.textures[e]=o,this}bindCameraHandlers(){return this.activeListeners.camera=()=>{this.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}unbindCameraHandlers(){return this.camera.removeListener("updated",this.activeListeners.camera),this}getNodeAtPosition(e){const{x:t,y:i}=e,n=$t(this.webGLContexts.nodes,this.frameBuffers.nodes,t,i,this.pixelRatio,this.pickingDownSizingRatio),o=Ht(...n),a=this.itemIDsIndex[o];return a&&a.type==="node"?a.id:null}bindEventHandlers(){this.activeListeners.handleResize=()=>{this.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=t=>{const i=Oe(t),n={event:i,preventSigmaDefault(){i.preventSigmaDefault()}},o=this.getNodeAtPosition(i);if(o&&this.hoveredNode!==o&&!this.nodeDataCache[o].hidden){this.hoveredNode&&this.emit("leaveNode",{...n,node:this.hoveredNode}),this.hoveredNode=o,this.emit("enterNode",{...n,node:o}),this.scheduleHighlightedNodesRender();return}if(this.hoveredNode&&this.getNodeAtPosition(i)!==this.hoveredNode){const a=this.hoveredNode;this.hoveredNode=null,this.emit("leaveNode",{...n,node:a}),this.scheduleHighlightedNodesRender();return}if(this.settings.enableEdgeEvents){const a=this.hoveredNode?null:this.getEdgeAtPoint(n.event.x,n.event.y);a!==this.hoveredEdge&&(this.hoveredEdge&&this.emit("leaveEdge",{...n,edge:this.hoveredEdge}),a&&this.emit("enterEdge",{...n,edge:a}),this.hoveredEdge=a)}},this.activeListeners.handleMoveBody=t=>{const i=Oe(t);this.emit("moveBody",{event:i,preventSigmaDefault(){i.preventSigmaDefault()}})},this.activeListeners.handleLeave=t=>{const i=Oe(t),n={event:i,preventSigmaDefault(){i.preventSigmaDefault()}};this.hoveredNode&&(this.emit("leaveNode",{...n,node:this.hoveredNode}),this.scheduleHighlightedNodesRender()),this.settings.enableEdgeEvents&&this.hoveredEdge&&(this.emit("leaveEdge",{...n,edge:this.hoveredEdge}),this.scheduleHighlightedNodesRender()),this.emit("leaveStage",{...n})},this.activeListeners.handleEnter=t=>{const i=Oe(t),n={event:i,preventSigmaDefault(){i.preventSigmaDefault()}};this.emit("enterStage",{...n})};const e=t=>i=>{const n=Oe(i),o={event:n,preventSigmaDefault:()=>{n.preventSigmaDefault()}},a=this.getNodeAtPosition(n);if(a)return this.emit(`${t}Node`,{...o,node:a});if(this.settings.enableEdgeEvents){const s=this.getEdgeAtPoint(n.x,n.y);if(s)return this.emit(`${t}Edge`,{...o,edge:s})}return this.emit(`${t}Stage`,o)};return this.activeListeners.handleClick=e("click"),this.activeListeners.handleRightClick=e("rightClick"),this.activeListeners.handleDoubleClick=e("doubleClick"),this.activeListeners.handleWheel=e("wheel"),this.activeListeners.handleDown=e("down"),this.activeListeners.handleUp=e("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}bindGraphHandlers(){const e=this.graph,t=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=i=>{var a;const n=(a=i.hints)==null?void 0:a.attributes;this.graph.forEachNode(s=>this.updateNode(s));const o=!n||n.some(s=>t.has(s));this.refresh({partialGraph:{nodes:e.nodes()},skipIndexation:!o,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=i=>{var a;const n=(a=i.hints)==null?void 0:a.attributes;this.graph.forEachEdge(s=>this.updateEdge(s));const o=n&&["zIndex","type"].some(s=>n==null?void 0:n.includes(s));this.refresh({partialGraph:{edges:e.edges()},skipIndexation:!o,schedule:!0})},this.activeListeners.addNodeGraphUpdate=i=>{const n=i.key;this.addNode(n),this.refresh({partialGraph:{nodes:[n]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=i=>{const n=i.key;this.refresh({partialGraph:{nodes:[n]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=i=>{const n=i.key;this.removeNode(n),this.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=i=>{const n=i.key;this.addEdge(n),this.refresh({partialGraph:{edges:[n]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=i=>{const n=i.key;this.refresh({partialGraph:{edges:[n]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=i=>{const n=i.key;this.removeEdge(n),this.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=()=>{this.clearEdgeState(),this.clearEdgeIndices(),this.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=()=>{this.clearEdgeState(),this.clearNodeState(),this.clearEdgeIndices(),this.clearNodeIndices(),this.refresh({schedule:!0})},e.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),e.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),e.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),e.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),e.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),e.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),e.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),e.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),e.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),e.on("cleared",this.activeListeners.clearGraphUpdate),this}unbindGraphHandlers(){const e=this.graph;e.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),e.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),e.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),e.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),e.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),e.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),e.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),e.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),e.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),e.removeListener("cleared",this.activeListeners.clearGraphUpdate)}getEdgeAtPoint(e,t){const i=$t(this.webGLContexts.edges,this.frameBuffers.edges,e,t,this.pixelRatio,this.pickingDownSizingRatio),n=Ht(...i),o=this.itemIDsIndex[n];return o&&o.type==="edge"?o.id:null}process(){this.emit("beforeProcess");const e=this.graph,t=this.settings,i=this.getDimensions();if(this.nodeExtent=Ui(this.graph),!this.settings.autoRescale){const{width:f,height:p}=i,{x:b,y:g}=this.nodeExtent;this.nodeExtent={x:[(b[0]+b[1])/2-f/2,(b[0]+b[1])/2+f/2],y:[(g[0]+g[1])/2-p/2,(g[0]+g[1])/2+p/2]}}this.normalizationFunction=qt(this.customBBox||this.nodeExtent);const n=new Te,o=Ee(n.getState(),i,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(i,t.labelGridCellSize);const a={},s={},c={},l={};let u=1,h=e.nodes();for(let f=0,p=h.length;f<p;f++){const b=h[f],g=this.nodeDataCache[b],_=e.getNodeAttributes(b);g.x=_.x,g.y=_.y,this.normalizationFunction.applyTo(g),typeof g.label=="string"&&!g.hidden&&this.labelGrid.add(b,g.size,this.framedGraphToViewport(g,{matrix:o})),a[g.type]=(a[g.type]||0)+1}this.labelGrid.organize();for(const f in this.nodePrograms){if(!ee.call(this.nodePrograms,f))throw new Error(`Sigma: could not find a suitable program for node type "${f}"!`);this.nodePrograms[f].reallocate(a[f]||0),a[f]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(h=Xt(this.nodeZExtent,f=>this.nodeDataCache[f].zIndex,h));for(let f=0,p=h.length;f<p;f++){const b=h[f];s[b]=u,l[s[b]]={type:"node",id:b},u++;const g=this.nodeDataCache[b];this.addNodeToProgram(b,s[b],a[g.type]++)}const d={};let m=e.edges();for(let f=0,p=m.length;f<p;f++){const b=m[f],g=this.edgeDataCache[b];d[g.type]=(d[g.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(m=Xt(this.edgeZExtent,f=>this.edgeDataCache[f].zIndex,m));for(const f in this.edgePrograms){if(!ee.call(this.edgePrograms,f))throw new Error(`Sigma: could not find a suitable program for edge type "${f}"!`);this.edgePrograms[f].reallocate(d[f]||0),d[f]=0}for(let f=0,p=m.length;f<p;f++){const b=m[f];c[b]=u,l[c[b]]={type:"edge",id:b},u++;const g=this.edgeDataCache[b];this.addEdgeToProgram(b,c[b],d[g.type]++)}return this.itemIDsIndex=l,this.nodeIndices=s,this.edgeIndices=c,this.emit("afterProcess"),this}handleSettingsUpdate(e){const t=this.settings;if(this.camera.minRatio=t.minCameraRatio,this.camera.maxRatio=t.maxCameraRatio,this.camera.enabledZooming=t.enableCameraZooming,this.camera.enabledPanning=t.enableCameraPanning,this.camera.enabledRotation=t.enableCameraRotation,t.cameraPanBoundaries?this.camera.clean=i=>this.cleanCameraState(i,t.cameraPanBoundaries&&typeof t.cameraPanBoundaries=="object"?t.cameraPanBoundaries:{}):this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),e){if(e.edgeProgramClasses!==t.edgeProgramClasses){for(const i in t.edgeProgramClasses)t.edgeProgramClasses[i]!==e.edgeProgramClasses[i]&&this.registerEdgeProgram(i,t.edgeProgramClasses[i]);for(const i in e.edgeProgramClasses)t.edgeProgramClasses[i]||this.unregisterEdgeProgram(i)}if(e.nodeProgramClasses!==t.nodeProgramClasses||e.nodeHoverProgramClasses!==t.nodeHoverProgramClasses){for(const i in t.nodeProgramClasses)(t.nodeProgramClasses[i]!==e.nodeProgramClasses[i]||t.nodeHoverProgramClasses[i]!==e.nodeHoverProgramClasses[i])&&this.registerNodeProgram(i,t.nodeProgramClasses[i],t.nodeHoverProgramClasses[i]);for(const i in e.nodeProgramClasses)t.nodeProgramClasses[i]||this.unregisterNodeProgram(i)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}cleanCameraState(e,{tolerance:t=0,boundaries:i}={}){const n={...e},{x:[o,a],y:[s,c]}=i||this.nodeExtent,l=[this.graphToViewport({x:o,y:s},{cameraState:e}),this.graphToViewport({x:a,y:s},{cameraState:e}),this.graphToViewport({x:o,y:c},{cameraState:e}),this.graphToViewport({x:a,y:c},{cameraState:e})];let u=1/0,h=-1/0,d=1/0,m=-1/0;l.forEach(({x:y,y:C})=>{u=Math.min(u,y),h=Math.max(h,y),d=Math.min(d,C),m=Math.max(m,C)});const f=h-u,p=m-d,{width:b,height:g}=this.getDimensions();let _=0,v=0;if(f>=b?h<b-t?_=h-(b-t):u>t&&(_=u-t):h>b+t?_=h-(b+t):u<-t&&(_=u+t),p>=g?m<g-t?v=m-(g-t):d>t&&(v=d-t):m>g+t?v=m-(g+t):d<-t&&(v=d+t),_||v){const y=this.viewportToFramedGraph({x:0,y:0},{cameraState:e}),C=this.viewportToFramedGraph({x:_,y:v},{cameraState:e});_=C.x-y.x,v=C.y-y.y,n.x+=_,n.y+=v}return n}renderLabels(){if(!this.settings.renderLabels)return this;const e=this.camera.getState(),t=this.labelGrid.getLabelsToDisplay(e.ratio,this.settings.labelDensity);Wt(t,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;const i=this.canvasContexts.labels;for(let n=0,o=t.length;n<o;n++){const a=t[n],s=this.nodeDataCache[a];if(this.displayedNodeLabels.has(a)||s.hidden)continue;const{x:c,y:l}=this.framedGraphToViewport(s),u=this.scaleSize(s.size);if(!s.forceLabel&&u<this.settings.labelRenderedSizeThreshold||c<-_n||c>this.width+_n||l<-bn||l>this.height+bn)continue;this.displayedNodeLabels.add(a);const{defaultDrawNodeLabel:h}=this.settings,d=this.nodePrograms[s.type];((d==null?void 0:d.drawLabel)||h)(i,{key:a,...s,size:u,x:c,y:l},this.settings)}return this}renderEdgeLabels(){if(!this.settings.renderEdgeLabels)return this;const e=this.canvasContexts.edgeLabels;e.clearRect(0,0,this.width,this.height);const t=ws({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Wt(t,this.edgesWithForcedLabels);const i=new Set;for(let n=0,o=t.length;n<o;n++){const a=t[n],s=this.graph.extremities(a),c=this.nodeDataCache[s[0]],l=this.nodeDataCache[s[1]],u=this.edgeDataCache[a];if(i.has(a)||u.hidden||c.hidden||l.hidden)continue;const{defaultDrawEdgeLabel:h}=this.settings,d=this.edgePrograms[u.type];((d==null?void 0:d.drawLabel)||h)(e,{key:a,...u,size:this.scaleSize(u.size)},{key:s[0],...c,...this.framedGraphToViewport(c),size:this.scaleSize(c.size)},{key:s[1],...l,...this.framedGraphToViewport(l),size:this.scaleSize(l.size)},this.settings),i.add(a)}return this.displayedEdgeLabels=i,this}renderHighlightedNodes(){const e=this.canvasContexts.hovers;e.clearRect(0,0,this.width,this.height);const t=a=>{const s=this.nodeDataCache[a],{x:c,y:l}=this.framedGraphToViewport(s),u=this.scaleSize(s.size),{defaultDrawNodeHover:h}=this.settings,d=this.nodePrograms[s.type];((d==null?void 0:d.drawHover)||h)(e,{key:a,...s,size:u,x:c,y:l},this.settings)},i=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&i.push(this.hoveredNode),this.highlightedNodes.forEach(a=>{a!==this.hoveredNode&&i.push(a)}),i.forEach(a=>t(a));const n={};i.forEach(a=>{const s=this.nodeDataCache[a].type;n[s]=(n[s]||0)+1});for(const a in this.nodeHoverPrograms)this.nodeHoverPrograms[a].reallocate(n[a]||0),n[a]=0;i.forEach(a=>{const s=this.nodeDataCache[a];this.nodeHoverPrograms[s.type].process(0,n[s.type]++,s)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);const o=this.getRenderParams();for(const a in this.nodeHoverPrograms)this.nodeHoverPrograms[a].render(o)}scheduleHighlightedNodesRender(){this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(()=>{this.renderHighlightedNodesFrame=null,this.renderHighlightedNodes(),this.renderEdgeLabels()}))}render(){this.emit("beforeRender");const e=()=>(this.emit("afterRender"),this);if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(l=>this.resetWebGLTexture(l)),!this.graph.order)return e();const t=this.mouseCaptor,i=this.camera.isAnimated()||t.isMoving||t.draggedEvents||t.currentWheelDirection,n=this.camera.getState(),o=this.getDimensions(),a=this.getGraphDimensions(),s=this.getStagePadding();this.matrix=Ee(n,o,a,s),this.invMatrix=Ee(n,o,a,s,!0),this.correctionRatio=zi(this.matrix,n,o),this.graphToViewportRatio=this.getGraphToViewportRatio();const c=this.getRenderParams();for(const l in this.nodePrograms)this.nodePrograms[l].render(c);if(!this.settings.hideEdgesOnMove||!i)for(const l in this.edgePrograms)this.edgePrograms[l].render(c);return this.settings.hideLabelsOnMove&&i||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),e()}addNode(e){let t=Object.assign({},this.graph.getNodeAttributes(e));this.settings.nodeReducer&&(t=this.settings.nodeReducer(e,t));const i=As(this.settings,e,t);this.nodeDataCache[e]=i,this.nodesWithForcedLabels.delete(e),i.forceLabel&&!i.hidden&&this.nodesWithForcedLabels.add(e),this.highlightedNodes.delete(e),i.highlighted&&!i.hidden&&this.highlightedNodes.add(e),this.settings.zIndex&&(i.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=i.zIndex),i.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=i.zIndex))}updateNode(e){this.addNode(e);const t=this.nodeDataCache[e];this.normalizationFunction.applyTo(t)}removeNode(e){delete this.nodeDataCache[e],delete this.nodeProgramIndex[e],this.highlightedNodes.delete(e),this.hoveredNode===e&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(e)}addEdge(e){let t=Object.assign({},this.graph.getEdgeAttributes(e));this.settings.edgeReducer&&(t=this.settings.edgeReducer(e,t));const i=Ss(this.settings,e,t);this.edgeDataCache[e]=i,this.edgesWithForcedLabels.delete(e),i.forceLabel&&!i.hidden&&this.edgesWithForcedLabels.add(e),this.settings.zIndex&&(i.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=i.zIndex),i.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=i.zIndex))}updateEdge(e){this.addEdge(e)}removeEdge(e){delete this.edgeDataCache[e],delete this.edgeProgramIndex[e],this.hoveredEdge===e&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(e)}clearNodeIndices(){this.labelGrid=new pn,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0]}clearEdgeIndices(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}clearIndices(){this.clearEdgeIndices(),this.clearNodeIndices()}clearNodeState(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}clearEdgeState(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}clearState(){this.clearEdgeState(),this.clearNodeState()}addNodeToProgram(e,t,i){const n=this.nodeDataCache[e],o=this.nodePrograms[n.type];if(!o)throw new Error(`Sigma: could not find a suitable program for node type "${n.type}"!`);o.process(t,i,n),this.nodeProgramIndex[e]=i}addEdgeToProgram(e,t,i){const n=this.edgeDataCache[e],o=this.edgePrograms[n.type];if(!o)throw new Error(`Sigma: could not find a suitable program for edge type "${n.type}"!`);const a=this.graph.extremities(e),s=this.nodeDataCache[a[0]],c=this.nodeDataCache[a[1]];o.process(t,i,s,c,n),this.edgeProgramIndex[e]=i}getRenderParams(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}getStagePadding(){const{stagePadding:e,autoRescale:t}=this.settings;return t&&e||0}createLayer(e,t,i={}){if(this.elements[e])throw new Error(`Sigma: a layer named "${e}" already exists`);const n=Hi(t,{position:"absolute"},{class:`sigma-${e}`});return i.style&&Object.assign(n.style,i.style),this.elements[e]=n,"beforeLayer"in i&&i.beforeLayer?this.elements[i.beforeLayer].before(n):"afterLayer"in i&&i.afterLayer?this.elements[i.afterLayer].after(n):this.container.appendChild(n),n}createCanvas(e,t={}){return this.createLayer(e,"canvas",t)}createCanvasContext(e,t={}){const i=this.createCanvas(e,t),n={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[e]=i.getContext("2d",n),this}createWebGLContext(e,t={}){const i=(t==null?void 0:t.canvas)||this.createCanvas(e,t);t.hidden&&i.remove();const n={preserveDrawingBuffer:!1,antialias:!1,...t};let o;o=i.getContext("webgl2",n),o||(o=i.getContext("webgl",n)),o||(o=i.getContext("experimental-webgl",n));const a=o;if(this.webGLContexts[e]=a,a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA),t.picking){this.pickingLayers.add(e);const s=a.createFramebuffer();if(!s)throw new Error(`Sigma: cannot create a new frame buffer for layer ${e}`);this.frameBuffers[e]=s}return a}killLayer(e){var i;const t=this.elements[e];if(!t)throw new Error(`Sigma: cannot kill layer ${e}, which does not exist`);return this.webGLContexts[e]?((i=this.webGLContexts[e].getExtension("WEBGL_lose_context"))==null||i.loseContext(),delete this.webGLContexts[e]):this.canvasContexts[e]&&delete this.canvasContexts[e],t.remove(),delete this.elements[e],this}getCamera(){return this.camera}setCamera(e){this.unbindCameraHandlers(),this.camera=e,this.bindCameraHandlers()}getContainer(){return this.container}getGraph(){return this.graph}setGraph(e){e!==this.graph&&(this.hoveredNode&&!e.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!e.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=e,this.bindGraphHandlers(),this.refresh())}getMouseCaptor(){return this.mouseCaptor}getTouchCaptor(){return this.touchCaptor}getDimensions(){return{width:this.width,height:this.height}}getGraphDimensions(){const e=this.customBBox||this.nodeExtent;return{width:e.x[1]-e.x[0]||1,height:e.y[1]-e.y[0]||1}}getNodeDisplayData(e){const t=this.nodeDataCache[e];return t?Object.assign({},t):void 0}getEdgeDisplayData(e){const t=this.edgeDataCache[e];return t?Object.assign({},t):void 0}getNodeDisplayedLabels(){return new Set(this.displayedNodeLabels)}getEdgeDisplayedLabels(){return new Set(this.displayedEdgeLabels)}getSettings(){return{...this.settings}}getSetting(e){return this.settings[e]}setSetting(e,t){const i={...this.settings};return this.settings[e]=t,cr(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}updateSetting(e,t){return this.setSetting(e,t(this.settings[e])),this}setSettings(e){const t={...this.settings};return this.settings={...this.settings,...e},cr(this.settings),this.handleSettingsUpdate(t),this.scheduleRefresh(),this}resize(e){const t=this.width,i=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=Yt(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!e&&t===this.width&&i===this.height)return this;for(const n in this.elements){const o=this.elements[n];o.style.width=this.width+"px",o.style.height=this.height+"px"}for(const n in this.canvasContexts)this.elements[n].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[n].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[n].scale(this.pixelRatio,this.pixelRatio);for(const n in this.webGLContexts){this.elements[n].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[n].setAttribute("height",this.height*this.pixelRatio+"px");const o=this.webGLContexts[n];if(o.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(n)){const a=this.textures[n];a&&o.deleteTexture(a)}}return this.emit("resize"),this}clear(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}refresh(e){var o,a;const t=(e==null?void 0:e.skipIndexation)!==void 0?e==null?void 0:e.skipIndexation:!1,i=(e==null?void 0:e.schedule)!==void 0?e.schedule:!1,n=!e||!e.partialGraph;if(n)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(s=>this.addNode(s)),this.graph.forEachEdge(s=>this.addEdge(s));else{const s=((o=e.partialGraph)==null?void 0:o.nodes)||[];for(let l=0,u=(s==null?void 0:s.length)||0;l<u;l++){const h=s[l];if(this.updateNode(h),t){const d=this.nodeProgramIndex[h];if(d===void 0)throw new Error(`Sigma: node "${h}" can't be repaint`);this.addNodeToProgram(h,this.nodeIndices[h],d)}}const c=((a=e==null?void 0:e.partialGraph)==null?void 0:a.edges)||[];for(let l=0,u=c.length;l<u;l++){const h=c[l];if(this.updateEdge(h),t){const d=this.edgeProgramIndex[h];if(d===void 0)throw new Error(`Sigma: edge "${h}" can't be repaint`);this.addEdgeToProgram(h,this.edgeIndices[h],d)}}}return(n||!t)&&(this.needToProcess=!0),i?this.scheduleRender():this.render(),this}scheduleRender(){return this.renderFrame||(this.renderFrame=requestAnimationFrame(()=>{this.render()})),this}scheduleRefresh(e){return this.refresh({...e,schedule:!0})}getViewportZoomedState(e,t){const{ratio:i,angle:n,x:o,y:a}=this.camera.getState(),{minCameraRatio:s,maxCameraRatio:c}=this.settings;typeof c=="number"&&(t=Math.min(t,c)),typeof s=="number"&&(t=Math.max(t,s));const l=t/i,u={x:this.width/2,y:this.height/2},h=this.viewportToFramedGraph(e),d=this.viewportToFramedGraph(u);return{angle:n,x:(h.x-d.x)*(1-l)+o,y:(h.y-d.y)*(1-l)+a,ratio:t}}viewRectangle(){const e=this.viewportToFramedGraph({x:0,y:0}),t=this.viewportToFramedGraph({x:this.width,y:0}),i=this.viewportToFramedGraph({x:0,y:this.height});return{x1:e.x,y1:e.y,x2:t.x,y2:t.y,height:t.y-i.y}}framedGraphToViewport(e,t={}){const i=!!t.cameraState||!!t.viewportDimensions||!!t.graphDimensions,n=t.matrix?t.matrix:i?Ee(t.cameraState||this.camera.getState(),t.viewportDimensions||this.getDimensions(),t.graphDimensions||this.getGraphDimensions(),t.padding||this.getStagePadding()):this.matrix,o=qe(n,e);return{x:(1+o.x)*this.width/2,y:(1-o.y)*this.height/2}}viewportToFramedGraph(e,t={}){const i=!!t.cameraState||!!t.viewportDimensions||!t.graphDimensions,n=t.matrix?t.matrix:i?Ee(t.cameraState||this.camera.getState(),t.viewportDimensions||this.getDimensions(),t.graphDimensions||this.getGraphDimensions(),t.padding||this.getStagePadding(),!0):this.invMatrix,o=qe(n,{x:e.x/this.width*2-1,y:1-e.y/this.height*2});return isNaN(o.x)&&(o.x=0),isNaN(o.y)&&(o.y=0),o}viewportToGraph(e,t={}){return this.normalizationFunction.inverse(this.viewportToFramedGraph(e,t))}graphToViewport(e,t={}){return this.framedGraphToViewport(this.normalizationFunction(e),t)}getGraphToViewportRatio(){const e={x:0,y:0},t={x:1,y:1},i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),n=this.graphToViewport(e),o=this.graphToViewport(t);return Math.sqrt(Math.pow(n.x-o.x,2)+Math.pow(n.y-o.y,2))/i}getBBox(){return this.nodeExtent}getCustomBBox(){return this.customBBox}setCustomBBox(e){return this.customBBox=e,this.scheduleRender(),this}kill(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);const e=this.container;for(;e.firstChild;)e.removeChild(e.firstChild);this.canvasContexts={},this.webGLContexts={},this.elements={};for(const t in this.nodePrograms)this.nodePrograms[t].kill();for(const t in this.nodeHoverPrograms)this.nodeHoverPrograms[t].kill();for(const t in this.edgePrograms)this.edgePrograms[t].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(const t in this.elements)this.killLayer(t)}scaleSize(e=1,t=this.camera.ratio){return e/this.settings.zoomToSizeRatioFunction(t)*(this.getSetting("itemSizesReference")==="positions"?t*this.graphToViewportRatio:1)}getCanvases(){const e={};for(const t in this.elements)this.elements[t]instanceof HTMLCanvasElement&&(e[t]=this.elements[t]);return e}};const he=class he extends yn{};he.Camera=Te,he.MouseCaptor=mn,he.Sigma=yn,he.rendering={...vs,createNodeBorderProgram:Zr,createNodeImageProgram:Pt,createNodePiechartProgram:Fa,EdgeCurveProgram:_o},he.utils=ka;let lr=he;return lr});