@rigour-labs/cli 6.0.0 → 6.1.0-beta.2
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.
- package/dist/cli.js +2 -0
- package/dist/commands/hooks.js +22 -1
- package/dist/commands/index.js +1 -1
- package/dist/commands/studio-contracts.d.ts +20 -0
- package/dist/commands/studio-contracts.js +78 -0
- package/dist/commands/studio-contracts.test.d.ts +1 -0
- package/dist/commands/studio-contracts.test.js +33 -0
- package/dist/commands/studio.js +194 -24
- package/dist/commands/team.d.ts +2 -0
- package/dist/commands/team.js +78 -0
- package/package.json +4 -3
- package/studio-dist/assets/KnowledgeGraph-CWGbolsD.js +430 -0
- package/studio-dist/assets/KnowledgeGraph-DEqMBSbC.css +1 -0
- package/studio-dist/assets/index-DR7ehi_i.js +398 -0
- package/studio-dist/assets/index-PA_eqVds.css +1 -0
- package/studio-dist/index.html +2 -2
- package/studio-dist/assets/index-DzNTOo-7.js +0 -372
- package/studio-dist/assets/index-jC3k12bf.css +0 -1
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import{g as Tn,r as N,R as H,j as v,S as Ci,a as Ai,D as Di,b as Li,c as Gi,B as Er,G as _r,T as xi,N as Tr}from"./index-DR7ehi_i.js";var mi={exports:{}},it=typeof Reflect=="object"?Reflect:null,Fi=it&&typeof it.apply=="function"?it.apply:function(i,e,t){return Function.prototype.apply.call(i,e,t)},Ut;it&&typeof it.ownKeys=="function"?Ut=it.ownKeys:Object.getOwnPropertySymbols?Ut=function(i){return Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i))}:Ut=function(i){return Object.getOwnPropertyNames(i)};function Sr(r){console&&console.warn&&console.warn(r)}var Sn=Number.isNaN||function(i){return i!==i};function ee(){ee.init.call(this)}mi.exports=ee;mi.exports.once=Ar;ee.EventEmitter=ee;ee.prototype._events=void 0;ee.prototype._eventsCount=0;ee.prototype._maxListeners=void 0;var Pi=10;function jt(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(ee,"defaultMaxListeners",{enumerable:!0,get:function(){return Pi},set:function(r){if(typeof r!="number"||r<0||Sn(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");Pi=r}});ee.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};ee.prototype.setMaxListeners=function(i){if(typeof i!="number"||i<0||Sn(i))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+i+".");return this._maxListeners=i,this};function Rn(r){return r._maxListeners===void 0?ee.defaultMaxListeners:r._maxListeners}ee.prototype.getMaxListeners=function(){return Rn(this)};ee.prototype.emit=function(i){for(var e=[],t=1;t<arguments.length;t++)e.push(arguments[t]);var n=i==="error",a=this._events;if(a!==void 0)n=n&&a.error===void 0;else if(!n)return!1;if(n){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var u=a[i];if(u===void 0)return!1;if(typeof u=="function")Fi(u,this,e);else for(var h=u.length,c=Ln(u,h),t=0;t<h;++t)Fi(c[t],this,e);return!0};function kn(r,i,e,t){var n,a,o;if(jt(e),a=r._events,a===void 0?(a=r._events=Object.create(null),r._eventsCount=0):(a.newListener!==void 0&&(r.emit("newListener",i,e.listener?e.listener:e),a=r._events),o=a[i]),o===void 0)o=a[i]=e,++r._eventsCount;else if(typeof o=="function"?o=a[i]=t?[e,o]:[o,e]:t?o.unshift(e):o.push(e),n=Rn(r),n>0&&o.length>n&&!o.warned){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(i)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=r,s.type=i,s.count=o.length,Sr(s)}return r}ee.prototype.addListener=function(i,e){return kn(this,i,e,!1)};ee.prototype.on=ee.prototype.addListener;ee.prototype.prependListener=function(i,e){return kn(this,i,e,!0)};function Rr(){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 Cn(r,i,e){var t={fired:!1,wrapFn:void 0,target:r,type:i,listener:e},n=Rr.bind(t);return n.listener=e,t.wrapFn=n,n}ee.prototype.once=function(i,e){return jt(e),this.on(i,Cn(this,i,e)),this};ee.prototype.prependOnceListener=function(i,e){return jt(e),this.prependListener(i,Cn(this,i,e)),this};ee.prototype.removeListener=function(i,e){var t,n,a,o,s;if(jt(e),n=this._events,n===void 0)return this;if(t=n[i],t===void 0)return this;if(t===e||t.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete n[i],n.removeListener&&this.emit("removeListener",i,t.listener||e));else if(typeof t!="function"){for(a=-1,o=t.length-1;o>=0;o--)if(t[o]===e||t[o].listener===e){s=t[o].listener,a=o;break}if(a<0)return this;a===0?t.shift():kr(t,a),t.length===1&&(n[i]=t[0]),n.removeListener!==void 0&&this.emit("removeListener",i,s||e)}return this};ee.prototype.off=ee.prototype.removeListener;ee.prototype.removeAllListeners=function(i){var e,t,n;if(t=this._events,t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[i]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[i]),this;if(arguments.length===0){var a=Object.keys(t),o;for(n=0;n<a.length;++n)o=a[n],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=t[i],typeof e=="function")this.removeListener(i,e);else if(e!==void 0)for(n=e.length-1;n>=0;n--)this.removeListener(i,e[n]);return this};function An(r,i,e){var t=r._events;if(t===void 0)return[];var n=t[i];return n===void 0?[]:typeof n=="function"?e?[n.listener||n]:[n]:e?Cr(n):Ln(n,n.length)}ee.prototype.listeners=function(i){return An(this,i,!0)};ee.prototype.rawListeners=function(i){return An(this,i,!1)};ee.listenerCount=function(r,i){return typeof r.listenerCount=="function"?r.listenerCount(i):Dn.call(r,i)};ee.prototype.listenerCount=Dn;function Dn(r){var i=this._events;if(i!==void 0){var e=i[r];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}ee.prototype.eventNames=function(){return this._eventsCount>0?Ut(this._events):[]};function Ln(r,i){for(var e=new Array(i),t=0;t<i;++t)e[t]=r[t];return e}function kr(r,i){for(;i+1<r.length;i++)r[i]=r[i+1];r.pop()}function Cr(r){for(var i=new Array(r.length),e=0;e<i.length;++e)i[e]=r[e].listener||r[e];return i}function Ar(r,i){return new Promise(function(e,t){function n(o){r.removeListener(i,a),t(o)}function a(){typeof r.removeListener=="function"&&r.removeListener("error",n),e([].slice.call(arguments))}Gn(r,i,a,{once:!0}),i!=="error"&&Dr(r,n,{once:!0})})}function Dr(r,i,e){typeof r.on=="function"&&Gn(r,"error",i,e)}function Gn(r,i,e,t){if(typeof r.on=="function")t.once?r.once(i,e):r.on(i,e);else if(typeof r.addEventListener=="function")r.addEventListener(i,function n(a){t.once&&r.removeEventListener(i,n),e(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r)}var xn=mi.exports;function Lr(){const r=arguments[0];for(let i=1,e=arguments.length;i<e;i++)if(arguments[i])for(const t in arguments[i])r[t]=arguments[i][t];return r}let se=Lr;typeof Object.assign=="function"&&(se=Object.assign);function Re(r,i,e,t){const n=r._nodes.get(i);let a=null;return n&&(t==="mixed"?a=n.out&&n.out[e]||n.undirected&&n.undirected[e]:t==="directed"?a=n.out&&n.out[e]:a=n.undirected&&n.undirected[e]),a}function fe(r){return typeof r=="object"&&r!==null}function Fn(r){let i;for(i in r)return!1;return!0}function Te(r,i,e){Object.defineProperty(r,i,{enumerable:!1,configurable:!1,writable:!0,value:e})}function ke(r,i,e){const t={enumerable:!0,configurable:!0};typeof e=="function"?t.get=e:(t.value=e,t.writable=!1),Object.defineProperty(r,i,t)}function Oi(r){return!(!fe(r)||r.attributes&&!Array.isArray(r.attributes))}function Gr(){let r=Math.floor(Math.random()*256)&255;return()=>r++}function $e(){const r=arguments;let i=null,e=-1;return{[Symbol.iterator](){return this},next(){let t=null;do{if(i===null){if(e++,e>=r.length)return{done:!0};i=r[e][Symbol.iterator]()}if(t=i.next(),t.done){i=null;continue}break}while(!0);return t}}}function ut(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class vi extends Error{constructor(i){super(),this.name="GraphError",this.message=i}}class L extends vi{constructor(i){super(i),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,L.prototype.constructor)}}class A extends vi{constructor(i){super(i),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,A.prototype.constructor)}}class P extends vi{constructor(i){super(i),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,P.prototype.constructor)}}function Pn(r,i){this.key=r,this.attributes=i,this.clear()}Pn.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function On(r,i){this.key=r,this.attributes=i,this.clear()}On.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function In(r,i){this.key=r,this.attributes=i,this.clear()}In.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function ht(r,i,e,t,n){this.key=i,this.attributes=n,this.undirected=r,this.source=e,this.target=t}ht.prototype.attach=function(){let r="out",i="in";this.undirected&&(r=i="undirected");const e=this.source.key,t=this.target.key;this.source[r][t]=this,!(this.undirected&&e===t)&&(this.target[i][e]=this)};ht.prototype.attachMulti=function(){let r="out",i="in";const e=this.source.key,t=this.target.key;this.undirected&&(r=i="undirected");const n=this.source[r],a=n[t];if(typeof a>"u"){n[t]=this,this.undirected&&e===t||(this.target[i][e]=this);return}a.previous=this,this.next=a,n[t]=this,this.target[i][e]=this};ht.prototype.detach=function(){const r=this.source.key,i=this.target.key;let e="out",t="in";this.undirected&&(e=t="undirected"),delete this.source[e][i],delete this.target[t][r]};ht.prototype.detachMulti=function(){const r=this.source.key,i=this.target.key;let e="out",t="in";this.undirected&&(e=t="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[e][i],delete this.target[t][r]):(this.next.previous=void 0,this.source[e][i]=this.next,this.target[t][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const zn=0,Un=1,xr=2,$n=3;function Ne(r,i,e,t,n,a,o){let s,u,h,c;if(t=""+t,e===zn){if(s=r._nodes.get(t),!s)throw new A(`Graph.${i}: could not find the "${t}" node in the graph.`);h=n,c=a}else if(e===$n){if(n=""+n,u=r._edges.get(n),!u)throw new A(`Graph.${i}: could not find the "${n}" edge in the graph.`);const l=u.source.key,d=u.target.key;if(t===l)s=u.target;else if(t===d)s=u.source;else throw new A(`Graph.${i}: the "${t}" node is not attached to the "${n}" edge (${l}, ${d}).`);h=a,c=o}else{if(u=r._edges.get(t),!u)throw new A(`Graph.${i}: could not find the "${t}" edge in the graph.`);e===Un?s=u.source:s=u.target,h=n,c=a}return[s,h,c]}function Fr(r,i,e){r.prototype[i]=function(t,n,a){const[o,s]=Ne(this,i,e,t,n,a);return o.attributes[s]}}function Pr(r,i,e){r.prototype[i]=function(t,n){const[a]=Ne(this,i,e,t,n);return a.attributes}}function Or(r,i,e){r.prototype[i]=function(t,n,a){const[o,s]=Ne(this,i,e,t,n,a);return o.attributes.hasOwnProperty(s)}}function Ir(r,i,e){r.prototype[i]=function(t,n,a,o){const[s,u,h]=Ne(this,i,e,t,n,a,o);return s.attributes[u]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function zr(r,i,e){r.prototype[i]=function(t,n,a,o){const[s,u,h]=Ne(this,i,e,t,n,a,o);if(typeof h!="function")throw new L(`Graph.${i}: updater should be a function.`);const c=s.attributes,l=h(c[u]);return c[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Ur(r,i,e){r.prototype[i]=function(t,n,a){const[o,s]=Ne(this,i,e,t,n,a);return delete o.attributes[s],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:s}),this}}function $r(r,i,e){r.prototype[i]=function(t,n,a){const[o,s]=Ne(this,i,e,t,n,a);if(!fe(s))throw new L(`Graph.${i}: provided attributes are not a plain object.`);return o.attributes=s,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Nr(r,i,e){r.prototype[i]=function(t,n,a){const[o,s]=Ne(this,i,e,t,n,a);if(!fe(s))throw new L(`Graph.${i}: provided attributes are not a plain object.`);return se(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function jr(r,i,e){r.prototype[i]=function(t,n,a){const[o,s]=Ne(this,i,e,t,n,a);if(typeof s!="function")throw new L(`Graph.${i}: provided updater is not a function.`);return o.attributes=s(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const Br=[{name:r=>`get${r}Attribute`,attacher:Fr},{name:r=>`get${r}Attributes`,attacher:Pr},{name:r=>`has${r}Attribute`,attacher:Or},{name:r=>`set${r}Attribute`,attacher:Ir},{name:r=>`update${r}Attribute`,attacher:zr},{name:r=>`remove${r}Attribute`,attacher:Ur},{name:r=>`replace${r}Attributes`,attacher:$r},{name:r=>`merge${r}Attributes`,attacher:Nr},{name:r=>`update${r}Attributes`,attacher:jr}];function Hr(r){Br.forEach(function({name:i,attacher:e}){e(r,i("Node"),zn),e(r,i("Source"),Un),e(r,i("Target"),xr),e(r,i("Opposite"),$n)})}function Wr(r,i,e){r.prototype[i]=function(t,n){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new P(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new P(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+t,s=""+n;if(n=arguments[2],a=Re(this,o,s,e),!a)throw new A(`Graph.${i}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(e!=="mixed")throw new P(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(t=""+t,a=this._edges.get(t),!a)throw new A(`Graph.${i}: could not find the "${t}" edge in the graph.`)}return a.attributes[n]}}function Mr(r,i,e){r.prototype[i]=function(t){let n;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new P(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new P(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+t,o=""+arguments[1];if(n=Re(this,a,o,e),!n)throw new A(`Graph.${i}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(e!=="mixed")throw new P(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(t=""+t,n=this._edges.get(t),!n)throw new A(`Graph.${i}: could not find the "${t}" edge in the graph.`)}return n.attributes}}function Vr(r,i,e){r.prototype[i]=function(t,n){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new P(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new P(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+t,s=""+n;if(n=arguments[2],a=Re(this,o,s,e),!a)throw new A(`Graph.${i}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(e!=="mixed")throw new P(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(t=""+t,a=this._edges.get(t),!a)throw new A(`Graph.${i}: could not find the "${t}" edge in the graph.`)}return a.attributes.hasOwnProperty(n)}}function Kr(r,i,e){r.prototype[i]=function(t,n,a){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new P(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new P(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+t,u=""+n;if(n=arguments[2],a=arguments[3],o=Re(this,s,u,e),!o)throw new A(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(e!=="mixed")throw new P(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(t=""+t,o=this._edges.get(t),!o)throw new A(`Graph.${i}: could not find the "${t}" edge in the graph.`)}return o.attributes[n]=a,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:n}),this}}function Zr(r,i,e){r.prototype[i]=function(t,n,a){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new P(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new P(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+t,u=""+n;if(n=arguments[2],a=arguments[3],o=Re(this,s,u,e),!o)throw new A(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(e!=="mixed")throw new P(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(t=""+t,o=this._edges.get(t),!o)throw new A(`Graph.${i}: could not find the "${t}" edge in the graph.`)}if(typeof a!="function")throw new L(`Graph.${i}: updater should be a function.`);return o.attributes[n]=a(o.attributes[n]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:n}),this}}function qr(r,i,e){r.prototype[i]=function(t,n){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new P(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new P(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+t,s=""+n;if(n=arguments[2],a=Re(this,o,s,e),!a)throw new A(`Graph.${i}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(e!=="mixed")throw new P(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(t=""+t,a=this._edges.get(t),!a)throw new A(`Graph.${i}: could not find the "${t}" edge in the graph.`)}return delete a.attributes[n],this.emit("edgeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:n}),this}}function Yr(r,i,e){r.prototype[i]=function(t,n){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new P(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new P(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+t,s=""+n;if(n=arguments[2],a=Re(this,o,s,e),!a)throw new A(`Graph.${i}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(e!=="mixed")throw new P(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(t=""+t,a=this._edges.get(t),!a)throw new A(`Graph.${i}: could not find the "${t}" edge in the graph.`)}if(!fe(n))throw new L(`Graph.${i}: provided attributes are not a plain object.`);return a.attributes=n,this.emit("edgeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function Xr(r,i,e){r.prototype[i]=function(t,n){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new P(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new P(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+t,s=""+n;if(n=arguments[2],a=Re(this,o,s,e),!a)throw new A(`Graph.${i}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(e!=="mixed")throw new P(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(t=""+t,a=this._edges.get(t),!a)throw new A(`Graph.${i}: could not find the "${t}" edge in the graph.`)}if(!fe(n))throw new L(`Graph.${i}: provided attributes are not a plain object.`);return se(a.attributes,n),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:n}),this}}function Qr(r,i,e){r.prototype[i]=function(t,n){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new P(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new P(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+t,s=""+n;if(n=arguments[2],a=Re(this,o,s,e),!a)throw new A(`Graph.${i}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(e!=="mixed")throw new P(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(t=""+t,a=this._edges.get(t),!a)throw new A(`Graph.${i}: could not find the "${t}" edge in the graph.`)}if(typeof n!="function")throw new L(`Graph.${i}: provided updater is not a function.`);return a.attributes=n(a.attributes),this.emit("edgeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const Jr=[{name:r=>`get${r}Attribute`,attacher:Wr},{name:r=>`get${r}Attributes`,attacher:Mr},{name:r=>`has${r}Attribute`,attacher:Vr},{name:r=>`set${r}Attribute`,attacher:Kr},{name:r=>`update${r}Attribute`,attacher:Zr},{name:r=>`remove${r}Attribute`,attacher:qr},{name:r=>`replace${r}Attributes`,attacher:Yr},{name:r=>`merge${r}Attributes`,attacher:Xr},{name:r=>`update${r}Attributes`,attacher:Qr}];function ea(r){Jr.forEach(function({name:i,attacher:e}){e(r,i("Edge"),"mixed"),e(r,i("DirectedEdge"),"directed"),e(r,i("UndirectedEdge"),"undirected")})}const ta=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function ia(r,i,e,t){let n=!1;for(const a in i){if(a===t)continue;const o=i[a];if(n=e(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),r&&n)return o.key}}function na(r,i,e,t){let n,a,o,s=!1;for(const u in i)if(u!==t){n=i[u];do{if(a=n.source,o=n.target,s=e(n.key,n.attributes,a.key,o.key,a.attributes,o.attributes,n.undirected),r&&s)return n.key;n=n.next}while(n!==void 0)}}function Zt(r,i){const e=Object.keys(r),t=e.length;let n,a=0;return{[Symbol.iterator](){return this},next(){do if(n)n=n.next;else{if(a>=t)return{done:!0};const o=e[a++];if(o===i){n=void 0;continue}n=r[o]}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}}}}function ra(r,i,e,t){const n=i[e];if(!n)return;const a=n.source,o=n.target;if(t(n.key,n.attributes,a.key,o.key,a.attributes,o.attributes,n.undirected)&&r)return n.key}function aa(r,i,e,t){let n=i[e];if(!n)return;let a=!1;do{if(a=t(n.key,n.attributes,n.source.key,n.target.key,n.source.attributes,n.target.attributes,n.undirected),r&&a)return n.key;n=n.next}while(n!==void 0)}function qt(r,i){let e=r[i];if(e.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!e)return{done:!0};const n={edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected};return e=e.next,{done:!1,value:n}}};let t=!1;return{[Symbol.iterator](){return this},next(){return t===!0?{done:!0}:(t=!0,{done:!1,value:{edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected}})}}}function oa(r,i){if(r.size===0)return[];if(i==="mixed"||i===r.type)return Array.from(r._edges.keys());const e=i==="undirected"?r.undirectedSize:r.directedSize,t=new Array(e),n=i==="undirected",a=r._edges.values();let o=0,s,u;for(;s=a.next(),s.done!==!0;)u=s.value,u.undirected===n&&(t[o++]=u.key);return t}function Nn(r,i,e,t){if(i.size===0)return;const n=e!=="mixed"&&e!==i.type,a=e==="undirected";let o,s,u=!1;const h=i._edges.values();for(;o=h.next(),o.done!==!0;){if(s=o.value,n&&s.undirected!==a)continue;const{key:c,attributes:l,source:d,target:m}=s;if(u=t(c,l,d.key,m.key,d.attributes,m.attributes,s.undirected),r&&u)return c}}function sa(r,i){if(r.size===0)return ut();const e=i!=="mixed"&&i!==r.type,t=i==="undirected",n=r._edges.values();return{[Symbol.iterator](){return this},next(){let a,o;for(;;){if(a=n.next(),a.done)return a;if(o=a.value,!(e&&o.undirected!==t))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function yi(r,i,e,t,n,a){const o=i?na:ia;let s;if(e!=="undirected"&&(t!=="out"&&(s=o(r,n.in,a),r&&s)||t!=="in"&&(s=o(r,n.out,a,t?void 0:n.key),r&&s))||e!=="directed"&&(s=o(r,n.undirected,a),r&&s))return s}function ua(r,i,e,t){const n=[];return yi(!1,r,i,e,t,function(a){n.push(a)}),n}function ha(r,i,e){let t=ut();return r!=="undirected"&&(i!=="out"&&typeof e.in<"u"&&(t=$e(t,Zt(e.in))),i!=="in"&&typeof e.out<"u"&&(t=$e(t,Zt(e.out,i?void 0:e.key)))),r!=="directed"&&typeof e.undirected<"u"&&(t=$e(t,Zt(e.undirected))),t}function bi(r,i,e,t,n,a,o){const s=e?aa:ra;let u;if(i!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&(u=s(r,n.in,a,o),r&&u)||typeof n.out<"u"&&t!=="in"&&(t||n.key!==a)&&(u=s(r,n.out,a,o),r&&u))||i!=="directed"&&typeof n.undirected<"u"&&(u=s(r,n.undirected,a,o),r&&u))return u}function la(r,i,e,t,n){const a=[];return bi(!1,r,i,e,t,n,function(o){a.push(o)}),a}function ca(r,i,e,t){let n=ut();return r!=="undirected"&&(typeof e.in<"u"&&i!=="out"&&t in e.in&&(n=$e(n,qt(e.in,t))),typeof e.out<"u"&&i!=="in"&&t in e.out&&(i||e.key!==t)&&(n=$e(n,qt(e.out,t)))),r!=="directed"&&typeof e.undirected<"u"&&t in e.undirected&&(n=$e(n,qt(e.undirected,t))),n}function da(r,i){const{name:e,type:t,direction:n}=i;r.prototype[e]=function(a,o){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return[];if(!arguments.length)return oa(this,t);if(arguments.length===1){a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${e}: could not find the "${a}" node in the graph.`);return ua(this.multi,t==="mixed"?this.type:t,n,s)}if(arguments.length===2){a=""+a,o=""+o;const s=this._nodes.get(a);if(!s)throw new A(`Graph.${e}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new A(`Graph.${e}: could not find the "${o}" target node in the graph.`);return la(t,this.multi,n,s,o)}throw new L(`Graph.${e}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function fa(r,i){const{name:e,type:t,direction:n}=i,a="forEach"+e[0].toUpperCase()+e.slice(1,-1);r.prototype[a]=function(h,c,l){if(!(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)){if(arguments.length===1)return l=h,Nn(!1,this,t,l);if(arguments.length===2){h=""+h,l=c;const d=this._nodes.get(h);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${h}" node in the graph.`);return yi(!1,this.multi,t==="mixed"?this.type:t,n,d,l)}if(arguments.length===3){h=""+h,c=""+c;const d=this._nodes.get(h);if(!d)throw new A(`Graph.${a}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(c))throw new A(`Graph.${a}: could not find the "${c}" target node in the graph.`);return bi(!1,t,this.multi,n,d,c,l)}throw new L(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+e[0].toUpperCase()+e.slice(1);r.prototype[o]=function(){const h=Array.prototype.slice.call(arguments),c=h.pop();let l;if(h.length===0){let d=0;t!=="directed"&&(d+=this.undirectedSize),t!=="undirected"&&(d+=this.directedSize),l=new Array(d);let m=0;h.push((E,k,S,x,R,b,_)=>{l[m++]=c(E,k,S,x,R,b,_)})}else l=[],h.push((d,m,E,k,S,x,R)=>{l.push(c(d,m,E,k,S,x,R))});return this[a].apply(this,h),l};const s="filter"+e[0].toUpperCase()+e.slice(1);r.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),c=h.pop(),l=[];return h.push((d,m,E,k,S,x,R)=>{c(d,m,E,k,S,x,R)&&l.push(d)}),this[a].apply(this,h),l};const u="reduce"+e[0].toUpperCase()+e.slice(1);r.prototype[u]=function(){let h=Array.prototype.slice.call(arguments);if(h.length<2||h.length>4)throw new L(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${h.length}).`);if(typeof h[h.length-1]=="function"&&typeof h[h.length-2]!="function")throw new L(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c,l;h.length===2?(c=h[0],l=h[1],h=[]):h.length===3?(c=h[1],l=h[2],h=[h[0]]):h.length===4&&(c=h[2],l=h[3],h=[h[0],h[1]]);let d=l;return h.push((m,E,k,S,x,R,b)=>{d=c(d,m,E,k,S,x,R,b)}),this[a].apply(this,h),d}}function ga(r,i){const{name:e,type:t,direction:n}=i,a="find"+e[0].toUpperCase()+e.slice(1,-1);r.prototype[a]=function(u,h,c){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return!1;if(arguments.length===1)return c=u,Nn(!0,this,t,c);if(arguments.length===2){u=""+u,c=h;const l=this._nodes.get(u);if(typeof l>"u")throw new A(`Graph.${a}: could not find the "${u}" node in the graph.`);return yi(!0,this.multi,t==="mixed"?this.type:t,n,l,c)}if(arguments.length===3){u=""+u,h=""+h;const l=this._nodes.get(u);if(!l)throw new A(`Graph.${a}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(h))throw new A(`Graph.${a}: could not find the "${h}" target node in the graph.`);return bi(!0,t,this.multi,n,l,h,c)}throw new L(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+e[0].toUpperCase()+e.slice(1,-1);r.prototype[o]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((l,d,m,E,k,S,x)=>h(l,d,m,E,k,S,x)),!!this[a].apply(this,u)};const s="every"+e[0].toUpperCase()+e.slice(1,-1);r.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((l,d,m,E,k,S,x)=>!h(l,d,m,E,k,S,x)),!this[a].apply(this,u)}}function pa(r,i){const{name:e,type:t,direction:n}=i,a=e.slice(0,-1)+"Entries";r.prototype[a]=function(o,s){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return ut();if(!arguments.length)return sa(this,t);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(!u)throw new A(`Graph.${a}: could not find the "${o}" node in the graph.`);return ha(t,n,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new A(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new A(`Graph.${a}: could not find the "${s}" target node in the graph.`);return ca(t,n,u,s)}throw new L(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function ma(r){ta.forEach(i=>{da(r,i),fa(r,i),ga(r,i),pa(r,i)})}const va=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Bt(){this.A=null,this.B=null}Bt.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};Bt.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function ft(r,i,e,t,n){for(const a in t){const o=t[a],s=o.source,u=o.target,h=s===e?u:s;if(i&&i.has(h.key))continue;const c=n(h.key,h.attributes);if(r&&c)return h.key}}function wi(r,i,e,t,n){if(i!=="mixed"){if(i==="undirected")return ft(r,null,t,t.undirected,n);if(typeof e=="string")return ft(r,null,t,t[e],n)}const a=new Bt;let o;if(i!=="undirected"){if(e!=="out"){if(o=ft(r,null,t,t.in,n),r&&o)return o;a.wrap(t.in)}if(e!=="in"){if(o=ft(r,a,t,t.out,n),r&&o)return o;a.wrap(t.out)}}if(i!=="directed"&&(o=ft(r,a,t,t.undirected,n),r&&o))return o}function ya(r,i,e){if(r!=="mixed"){if(r==="undirected")return Object.keys(e.undirected);if(typeof i=="string")return Object.keys(e[i])}const t=[];return wi(!1,r,i,e,function(n){t.push(n)}),t}function gt(r,i,e){const t=Object.keys(e),n=t.length;let a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=n)return r&&r.wrap(e),{done:!0};const s=e[t[a++]],u=s.source,h=s.target;if(o=u===i?h:u,r&&r.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function ba(r,i,e){if(r!=="mixed"){if(r==="undirected")return gt(null,e,e.undirected);if(typeof i=="string")return gt(null,e,e[i])}let t=ut();const n=new Bt;return r!=="undirected"&&(i!=="out"&&(t=$e(t,gt(n,e,e.in))),i!=="in"&&(t=$e(t,gt(n,e,e.out)))),r!=="directed"&&(t=$e(t,gt(n,e,e.undirected))),t}function wa(r,i){const{name:e,type:t,direction:n}=i;r.prototype[e]=function(a){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return[];a=""+a;const o=this._nodes.get(a);if(typeof o>"u")throw new A(`Graph.${e}: could not find the "${a}" node in the graph.`);return ya(t==="mixed"?this.type:t,n,o)}}function Ea(r,i){const{name:e,type:t,direction:n}=i,a="forEach"+e[0].toUpperCase()+e.slice(1,-1);r.prototype[a]=function(h,c){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return;h=""+h;const l=this._nodes.get(h);if(typeof l>"u")throw new A(`Graph.${a}: could not find the "${h}" node in the graph.`);wi(!1,t==="mixed"?this.type:t,n,l,c)};const o="map"+e[0].toUpperCase()+e.slice(1);r.prototype[o]=function(h,c){const l=[];return this[a](h,(d,m)=>{l.push(c(d,m))}),l};const s="filter"+e[0].toUpperCase()+e.slice(1);r.prototype[s]=function(h,c){const l=[];return this[a](h,(d,m)=>{c(d,m)&&l.push(d)}),l};const u="reduce"+e[0].toUpperCase()+e.slice(1);r.prototype[u]=function(h,c,l){if(arguments.length<3)throw new L(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let d=l;return this[a](h,(m,E)=>{d=c(d,m,E)}),d}}function _a(r,i){const{name:e,type:t,direction:n}=i,a=e[0].toUpperCase()+e.slice(1,-1),o="find"+a;r.prototype[o]=function(h,c){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return;h=""+h;const l=this._nodes.get(h);if(typeof l>"u")throw new A(`Graph.${o}: could not find the "${h}" node in the graph.`);return wi(!0,t==="mixed"?this.type:t,n,l,c)};const s="some"+a;r.prototype[s]=function(h,c){return!!this[o](h,c)};const u="every"+a;r.prototype[u]=function(h,c){return!this[o](h,(d,m)=>!c(d,m))}}function Ta(r,i){const{name:e,type:t,direction:n}=i,a=e.slice(0,-1)+"Entries";r.prototype[a]=function(o){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return ut();o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new A(`Graph.${a}: could not find the "${o}" node in the graph.`);return ba(t==="mixed"?this.type:t,n,s)}}function Sa(r){va.forEach(i=>{wa(r,i),Ea(r,i),_a(r,i),Ta(r,i)})}function xt(r,i,e,t,n){const a=t._nodes.values(),o=t.type;let s,u,h,c,l,d;for(;s=a.next(),s.done!==!0;){let m=!1;if(u=s.value,o!=="undirected"){c=u.out;for(h in c){l=c[h];do d=l.target,m=!0,n(u.key,d.key,u.attributes,d.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}if(o!=="directed"){c=u.undirected;for(h in c)if(!(i&&u.key>h)){l=c[h];do d=l.target,d.key!==h&&(d=l.source),m=!0,n(u.key,d.key,u.attributes,d.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}e&&!m&&n(u.key,null,u.attributes,null,null,null,null)}}function Ra(r,i){const e={key:r};return Fn(i.attributes)||(e.attributes=se({},i.attributes)),e}function ka(r,i,e){const t={key:i,source:e.source.key,target:e.target.key};return Fn(e.attributes)||(t.attributes=se({},e.attributes)),r==="mixed"&&e.undirected&&(t.undirected=!0),t}function Ca(r){if(!fe(r))throw new L('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new L("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!fe(r.attributes)||r.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Aa(r){if(!fe(r))throw new L('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new L("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new L("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!fe(r.attributes)||r.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new L("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Da=Gr(),La=new Set(["directed","undirected","mixed"]),Ii=new Set(["domain","_events","_eventsCount","_maxListeners"]),Ga=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],xa={allowSelfLoops:!0,multi:!1,type:"mixed"};function Fa(r,i,e){if(e&&!fe(e))throw new L(`Graph.addNode: invalid attributes. Expecting an object but got "${e}"`);if(i=""+i,e=e||{},r._nodes.has(i))throw new P(`Graph.addNode: the "${i}" node already exist in the graph.`);const t=new r.NodeDataClass(i,e);return r._nodes.set(i,t),r.emit("nodeAdded",{key:i,attributes:e}),t}function zi(r,i,e){const t=new r.NodeDataClass(i,e);return r._nodes.set(i,t),r.emit("nodeAdded",{key:i,attributes:e}),t}function jn(r,i,e,t,n,a,o,s){if(!t&&r.type==="undirected")throw new P(`Graph.${i}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(t&&r.type==="directed")throw new P(`Graph.${i}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!fe(s))throw new L(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`);if(a=""+a,o=""+o,s=s||{},!r.allowSelfLoops&&a===o)throw new P(`Graph.${i}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=r._nodes.get(a),h=r._nodes.get(o);if(!u)throw new A(`Graph.${i}: source node "${a}" not found.`);if(!h)throw new A(`Graph.${i}: target node "${o}" not found.`);const c={key:null,undirected:t,source:a,target:o,attributes:s};if(e)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new P(`Graph.${i}: the "${n}" edge already exists in the graph.`);if(!r.multi&&(t?typeof u.undirected[o]<"u":typeof u.out[o]<"u"))throw new P(`Graph.${i}: an edge linking "${a}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const l=new ht(t,n,u,h,s);r._edges.set(n,l);const d=a===o;return t?(u.undirectedDegree++,h.undirectedDegree++,d&&(u.undirectedLoops++,r._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,d&&(u.directedLoops++,r._directedSelfLoopCount++)),r.multi?l.attachMulti():l.attach(),t?r._undirectedSize++:r._directedSize++,c.key=n,r.emit("edgeAdded",c),n}function Pa(r,i,e,t,n,a,o,s,u){if(!t&&r.type==="undirected")throw new P(`Graph.${i}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(t&&r.type==="directed")throw new P(`Graph.${i}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(u){if(typeof s!="function")throw new L(`Graph.${i}: invalid updater function. Expecting a function but got "${s}"`)}else if(!fe(s))throw new L(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let h;if(u&&(h=s,s=void 0),!r.allowSelfLoops&&a===o)throw new P(`Graph.${i}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=r._nodes.get(a),l=r._nodes.get(o),d,m;if(!e&&(d=r._edges.get(n),d)){if((d.source.key!==a||d.target.key!==o)&&(!t||d.source.key!==o||d.target.key!==a))throw new P(`Graph.${i}: inconsistency detected when attempting to merge the "${n}" edge with "${a}" source & "${o}" target vs. ("${d.source.key}", "${d.target.key}").`);m=d}if(!m&&!r.multi&&c&&(m=t?c.undirected[o]:c.out[o]),m){const R=[m.key,!1,!1,!1];if(u?!h:!s)return R;if(u){const b=m.attributes;m.attributes=h(b),r.emit("edgeAttributesUpdated",{type:"replace",key:m.key,attributes:m.attributes})}else se(m.attributes,s),r.emit("edgeAttributesUpdated",{type:"merge",key:m.key,attributes:m.attributes,data:s});return R}s=s||{},u&&h&&(s=h(s));const E={key:null,undirected:t,source:a,target:o,attributes:s};if(e)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new P(`Graph.${i}: the "${n}" edge already exists in the graph.`);let k=!1,S=!1;c||(c=zi(r,a,{}),k=!0,a===o&&(l=c,S=!0)),l||(l=zi(r,o,{}),S=!0),d=new ht(t,n,c,l,s),r._edges.set(n,d);const x=a===o;return t?(c.undirectedDegree++,l.undirectedDegree++,x&&(c.undirectedLoops++,r._undirectedSelfLoopCount++)):(c.outDegree++,l.inDegree++,x&&(c.directedLoops++,r._directedSelfLoopCount++)),r.multi?d.attachMulti():d.attach(),t?r._undirectedSize++:r._directedSize++,E.key=n,r.emit("edgeAdded",E),[n,!0,k,S]}function tt(r,i){r._edges.delete(i.key);const{source:e,target:t,attributes:n}=i,a=i.undirected,o=e===t;a?(e.undirectedDegree--,t.undirectedDegree--,o&&(e.undirectedLoops--,r._undirectedSelfLoopCount--)):(e.outDegree--,t.inDegree--,o&&(e.directedLoops--,r._directedSelfLoopCount--)),r.multi?i.detachMulti():i.detach(),a?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:i.key,attributes:n,source:e.key,target:t.key,undirected:a})}class X extends xn.EventEmitter{constructor(i){if(super(),i=se({},xa,i),typeof i.multi!="boolean")throw new L(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${i.multi}".`);if(!La.has(i.type))throw new L(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${i.type}".`);if(typeof i.allowSelfLoops!="boolean")throw new L(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${i.allowSelfLoops}".`);const e=i.type==="mixed"?Pn:i.type==="directed"?On:In;Te(this,"NodeDataClass",e);const t="geid_"+Da()+"_";let n=0;const a=()=>{let o;do o=t+n++;while(this._edges.has(o));return o};Te(this,"_attributes",{}),Te(this,"_nodes",new Map),Te(this,"_edges",new Map),Te(this,"_directedSize",0),Te(this,"_undirectedSize",0),Te(this,"_directedSelfLoopCount",0),Te(this,"_undirectedSelfLoopCount",0),Te(this,"_edgeKeyGenerator",a),Te(this,"_options",i),Ii.forEach(o=>Te(this,o,this[o])),ke(this,"order",()=>this._nodes.size),ke(this,"size",()=>this._edges.size),ke(this,"directedSize",()=>this._directedSize),ke(this,"undirectedSize",()=>this._undirectedSize),ke(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ke(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ke(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ke(this,"multi",this._options.multi),ke(this,"type",this._options.type),ke(this,"allowSelfLoops",this._options.allowSelfLoops),ke(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(i){return this._nodes.has(""+i)}hasDirectedEdge(i,e){if(this.type==="undirected")return!1;if(arguments.length===1){const t=""+i,n=this._edges.get(t);return!!n&&!n.undirected}else if(arguments.length===2){i=""+i,e=""+e;const t=this._nodes.get(i);return t?t.out.hasOwnProperty(e):!1}throw new L(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(i,e){if(this.type==="directed")return!1;if(arguments.length===1){const t=""+i,n=this._edges.get(t);return!!n&&n.undirected}else if(arguments.length===2){i=""+i,e=""+e;const t=this._nodes.get(i);return t?t.undirected.hasOwnProperty(e):!1}throw new L(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(i,e){if(arguments.length===1){const t=""+i;return this._edges.has(t)}else if(arguments.length===2){i=""+i,e=""+e;const t=this._nodes.get(i);return t?typeof t.out<"u"&&t.out.hasOwnProperty(e)||typeof t.undirected<"u"&&t.undirected.hasOwnProperty(e):!1}throw new L(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(i,e){if(this.type==="undirected")return;if(i=""+i,e=""+e,this.multi)throw new P("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const t=this._nodes.get(i);if(!t)throw new A(`Graph.directedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(e))throw new A(`Graph.directedEdge: could not find the "${e}" target node in the graph.`);const n=t.out&&t.out[e]||void 0;if(n)return n.key}undirectedEdge(i,e){if(this.type==="directed")return;if(i=""+i,e=""+e,this.multi)throw new P("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const t=this._nodes.get(i);if(!t)throw new A(`Graph.undirectedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(e))throw new A(`Graph.undirectedEdge: could not find the "${e}" target node in the graph.`);const n=t.undirected&&t.undirected[e]||void 0;if(n)return n.key}edge(i,e){if(this.multi)throw new P("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new A(`Graph.edge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(e))throw new A(`Graph.edge: could not find the "${e}" target node in the graph.`);const n=t.out&&t.out[e]||t.undirected&&t.undirected[e]||void 0;if(n)return n.key}areDirectedNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new A(`Graph.areDirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:e in t.in||e in t.out}areOutNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new A(`Graph.areOutNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:e in t.out}areInNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new A(`Graph.areInNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:e in t.in}areUndirectedNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new A(`Graph.areUndirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="directed"?!1:e in t.undirected}areNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new A(`Graph.areNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&(e in t.in||e in t.out)||this.type!=="directed"&&e in t.undirected}areInboundNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new A(`Graph.areInboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&e in t.in||this.type!=="directed"&&e in t.undirected}areOutboundNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new A(`Graph.areOutboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&e in t.out||this.type!=="directed"&&e in t.undirected}inDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.inDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.inDegree}outDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.outDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.outDegree}directedDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.directedDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.inDegree+e.outDegree}undirectedDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.undirectedDegree: could not find the "${i}" node in the graph.`);return this.type==="directed"?0:e.undirectedDegree}inboundDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.inboundDegree: could not find the "${i}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=e.undirectedDegree),this.type!=="undirected"&&(t+=e.inDegree),t}outboundDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.outboundDegree: could not find the "${i}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=e.undirectedDegree),this.type!=="undirected"&&(t+=e.outDegree),t}degree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.degree: could not find the "${i}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=e.undirectedDegree),this.type!=="undirected"&&(t+=e.inDegree+e.outDegree),t}inDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.inDegree-e.directedLoops}outDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.outDegree-e.directedLoops}directedDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.inDegree+e.outDegree-e.directedLoops*2}undirectedDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="directed"?0:e.undirectedDegree-e.undirectedLoops*2}inboundDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let t=0,n=0;return this.type!=="directed"&&(t+=e.undirectedDegree,n+=e.undirectedLoops*2),this.type!=="undirected"&&(t+=e.inDegree,n+=e.directedLoops),t-n}outboundDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let t=0,n=0;return this.type!=="directed"&&(t+=e.undirectedDegree,n+=e.undirectedLoops*2),this.type!=="undirected"&&(t+=e.outDegree,n+=e.directedLoops),t-n}degreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let t=0,n=0;return this.type!=="directed"&&(t+=e.undirectedDegree,n+=e.undirectedLoops*2),this.type!=="undirected"&&(t+=e.inDegree+e.outDegree,n+=e.directedLoops*2),t-n}source(i){i=""+i;const e=this._edges.get(i);if(!e)throw new A(`Graph.source: could not find the "${i}" edge in the graph.`);return e.source.key}target(i){i=""+i;const e=this._edges.get(i);if(!e)throw new A(`Graph.target: could not find the "${i}" edge in the graph.`);return e.target.key}extremities(i){i=""+i;const e=this._edges.get(i);if(!e)throw new A(`Graph.extremities: could not find the "${i}" edge in the graph.`);return[e.source.key,e.target.key]}opposite(i,e){i=""+i,e=""+e;const t=this._edges.get(e);if(!t)throw new A(`Graph.opposite: could not find the "${e}" edge in the graph.`);const n=t.source.key,a=t.target.key;if(i===n)return a;if(i===a)return n;throw new A(`Graph.opposite: the "${i}" node is not attached to the "${e}" edge (${n}, ${a}).`)}hasExtremity(i,e){i=""+i,e=""+e;const t=this._edges.get(i);if(!t)throw new A(`Graph.hasExtremity: could not find the "${i}" edge in the graph.`);return t.source.key===e||t.target.key===e}isUndirected(i){i=""+i;const e=this._edges.get(i);if(!e)throw new A(`Graph.isUndirected: could not find the "${i}" edge in the graph.`);return e.undirected}isDirected(i){i=""+i;const e=this._edges.get(i);if(!e)throw new A(`Graph.isDirected: could not find the "${i}" edge in the graph.`);return!e.undirected}isSelfLoop(i){i=""+i;const e=this._edges.get(i);if(!e)throw new A(`Graph.isSelfLoop: could not find the "${i}" edge in the graph.`);return e.source===e.target}addNode(i,e){return Fa(this,i,e).key}mergeNode(i,e){if(e&&!fe(e))throw new L(`Graph.mergeNode: invalid attributes. Expecting an object but got "${e}"`);i=""+i,e=e||{};let t=this._nodes.get(i);return t?(e&&(se(t.attributes,e),this.emit("nodeAttributesUpdated",{type:"merge",key:i,attributes:t.attributes,data:e})),[i,!1]):(t=new this.NodeDataClass(i,e),this._nodes.set(i,t),this.emit("nodeAdded",{key:i,attributes:e}),[i,!0])}updateNode(i,e){if(e&&typeof e!="function")throw new L(`Graph.updateNode: invalid updater function. Expecting a function but got "${e}"`);i=""+i;let t=this._nodes.get(i);if(t){if(e){const a=t.attributes;t.attributes=e(a),this.emit("nodeAttributesUpdated",{type:"replace",key:i,attributes:t.attributes})}return[i,!1]}const n=e?e({}):{};return t=new this.NodeDataClass(i,n),this._nodes.set(i,t),this.emit("nodeAdded",{key:i,attributes:n}),[i,!0]}dropNode(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new A(`Graph.dropNode: could not find the "${i}" node in the graph.`);let t;if(this.type!=="undirected"){for(const n in e.out){t=e.out[n];do tt(this,t),t=t.next;while(t)}for(const n in e.in){t=e.in[n];do tt(this,t),t=t.next;while(t)}}if(this.type!=="directed")for(const n in e.undirected){t=e.undirected[n];do tt(this,t),t=t.next;while(t)}this._nodes.delete(i),this.emit("nodeDropped",{key:i,attributes:e.attributes})}dropEdge(i){let e;if(arguments.length>1){const t=""+arguments[0],n=""+arguments[1];if(e=Re(this,t,n,this.type),!e)throw new A(`Graph.dropEdge: could not find the "${t}" -> "${n}" edge in the graph.`)}else if(i=""+i,e=this._edges.get(i),!e)throw new A(`Graph.dropEdge: could not find the "${i}" edge in the graph.`);return tt(this,e),this}dropDirectedEdge(i,e){if(arguments.length<2)throw new P("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new P("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");i=""+i,e=""+e;const t=Re(this,i,e,"directed");if(!t)throw new A(`Graph.dropDirectedEdge: could not find a "${i}" -> "${e}" edge in the graph.`);return tt(this,t),this}dropUndirectedEdge(i,e){if(arguments.length<2)throw new P("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new P("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const t=Re(this,i,e,"undirected");if(!t)throw new A(`Graph.dropUndirectedEdge: could not find a "${i}" -> "${e}" edge in the graph.`);return tt(this,t),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const i=this._nodes.values();let e;for(;e=i.next(),e.done!==!0;)e.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(i){return this._attributes[i]}getAttributes(){return this._attributes}hasAttribute(i){return this._attributes.hasOwnProperty(i)}setAttribute(i,e){return this._attributes[i]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}updateAttribute(i,e){if(typeof e!="function")throw new L("Graph.updateAttribute: updater should be a function.");const t=this._attributes[i];return this._attributes[i]=e(t),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}removeAttribute(i){return delete this._attributes[i],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:i}),this}replaceAttributes(i){if(!fe(i))throw new L("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=i,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(i){if(!fe(i))throw new L("Graph.mergeAttributes: provided attributes are not a plain object.");return se(this._attributes,i),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:i}),this}updateAttributes(i){if(typeof i!="function")throw new L("Graph.updateAttributes: provided updater is not a function.");return this._attributes=i(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(i,e){if(typeof i!="function")throw new L("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!Oi(e))throw new L("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const t=this._nodes.values();let n,a;for(;n=t.next(),n.done!==!0;)a=n.value,a.attributes=i(a.key,a.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})}updateEachEdgeAttributes(i,e){if(typeof i!="function")throw new L("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!Oi(e))throw new L("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const t=this._edges.values();let n,a,o,s;for(;n=t.next(),n.done!==!0;)a=n.value,o=a.source,s=a.target,a.attributes=i(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})}forEachAdjacencyEntry(i){if(typeof i!="function")throw new L("Graph.forEachAdjacencyEntry: expecting a callback.");xt(!1,!1,!1,this,i)}forEachAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new L("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");xt(!1,!1,!0,this,i)}forEachAssymetricAdjacencyEntry(i){if(typeof i!="function")throw new L("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");xt(!1,!0,!1,this,i)}forEachAssymetricAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new L("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");xt(!1,!0,!0,this,i)}nodes(){return Array.from(this._nodes.keys())}forEachNode(i){if(typeof i!="function")throw new L("Graph.forEachNode: expecting a callback.");const e=this._nodes.values();let t,n;for(;t=e.next(),t.done!==!0;)n=t.value,i(n.key,n.attributes)}findNode(i){if(typeof i!="function")throw new L("Graph.findNode: expecting a callback.");const e=this._nodes.values();let t,n;for(;t=e.next(),t.done!==!0;)if(n=t.value,i(n.key,n.attributes))return n.key}mapNodes(i){if(typeof i!="function")throw new L("Graph.mapNode: expecting a callback.");const e=this._nodes.values();let t,n;const a=new Array(this.order);let o=0;for(;t=e.next(),t.done!==!0;)n=t.value,a[o++]=i(n.key,n.attributes);return a}someNode(i){if(typeof i!="function")throw new L("Graph.someNode: expecting a callback.");const e=this._nodes.values();let t,n;for(;t=e.next(),t.done!==!0;)if(n=t.value,i(n.key,n.attributes))return!0;return!1}everyNode(i){if(typeof i!="function")throw new L("Graph.everyNode: expecting a callback.");const e=this._nodes.values();let t,n;for(;t=e.next(),t.done!==!0;)if(n=t.value,!i(n.key,n.attributes))return!1;return!0}filterNodes(i){if(typeof i!="function")throw new L("Graph.filterNodes: expecting a callback.");const e=this._nodes.values();let t,n;const a=[];for(;t=e.next(),t.done!==!0;)n=t.value,i(n.key,n.attributes)&&a.push(n.key);return a}reduceNodes(i,e){if(typeof i!="function")throw new L("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new L("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let t=e;const n=this._nodes.values();let a,o;for(;a=n.next(),a.done!==!0;)o=a.value,t=i(t,o.key,o.attributes);return t}nodeEntries(){const i=this._nodes.values();return{[Symbol.iterator](){return this},next(){const e=i.next();if(e.done)return e;const t=e.value;return{value:{node:t.key,attributes:t.attributes},done:!1}}}}export(){const i=new Array(this._nodes.size);let e=0;this._nodes.forEach((n,a)=>{i[e++]=Ra(a,n)});const t=new Array(this._edges.size);return e=0,this._edges.forEach((n,a)=>{t[e++]=ka(this.type,a,n)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:i,edges:t}}import(i,e=!1){if(i instanceof X)return i.forEachNode((u,h)=>{e?this.mergeNode(u,h):this.addNode(u,h)}),i.forEachEdge((u,h,c,l,d,m,E)=>{e?E?this.mergeUndirectedEdgeWithKey(u,c,l,h):this.mergeDirectedEdgeWithKey(u,c,l,h):E?this.addUndirectedEdgeWithKey(u,c,l,h):this.addDirectedEdgeWithKey(u,c,l,h)}),this;if(!fe(i))throw new L("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(i.attributes){if(!fe(i.attributes))throw new L("Graph.import: invalid attributes. Expecting a plain object.");e?this.mergeAttributes(i.attributes):this.replaceAttributes(i.attributes)}let t,n,a,o,s;if(i.nodes){if(a=i.nodes,!Array.isArray(a))throw new L("Graph.import: invalid nodes. Expecting an array.");for(t=0,n=a.length;t<n;t++){o=a[t],Ca(o);const{key:u,attributes:h}=o;e?this.mergeNode(u,h):this.addNode(u,h)}}if(i.edges){let u=!1;if(this.type==="undirected"&&(u=!0),a=i.edges,!Array.isArray(a))throw new L("Graph.import: invalid edges. Expecting an array.");for(t=0,n=a.length;t<n;t++){s=a[t],Aa(s);const{source:h,target:c,attributes:l,undirected:d=u}=s;let m;"key"in s?(m=e?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,m.call(this,s.key,h,c,l)):(m=e?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,m.call(this,h,c,l))}}return this}nullCopy(i){const e=new X(se({},this._options,i));return e.replaceAttributes(se({},this.getAttributes())),e}emptyCopy(i){const e=this.nullCopy(i);return this._nodes.forEach((t,n)=>{const a=se({},t.attributes);t=new e.NodeDataClass(n,a),e._nodes.set(n,t)}),e}copy(i){if(i=i||{},typeof i.type=="string"&&i.type!==this.type&&i.type!=="mixed")throw new P(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${i.type}" because this would mean losing information about the current graph.`);if(typeof i.multi=="boolean"&&i.multi!==this.multi&&i.multi!==!0)throw new P("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof i.allowSelfLoops=="boolean"&&i.allowSelfLoops!==this.allowSelfLoops&&i.allowSelfLoops!==!0)throw new P("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const e=this.emptyCopy(i),t=this._edges.values();let n,a;for(;n=t.next(),n.done!==!0;)a=n.value,jn(e,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,se({},a.attributes));return e}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const i={};this._nodes.forEach((a,o)=>{i[o]=a.attributes});const e={},t={};this._edges.forEach((a,o)=>{const s=a.undirected?"--":"->";let u="",h=a.source.key,c=a.target.key,l;a.undirected&&h>c&&(l=h,h=c,c=l);const d=`(${h})${s}(${c})`;o.startsWith("geid_")?this.multi&&(typeof t[d]>"u"?t[d]=0:t[d]++,u+=`${t[d]}. `):u+=`[${o}]: `,u+=d,e[u]=a.attributes});const n={};for(const a in this)this.hasOwnProperty(a)&&!Ii.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(n[a]=this[a]);return n.attributes=this._attributes,n.nodes=i,n.edges=e,Te(n,"constructor",this.constructor),n}}typeof Symbol<"u"&&(X.prototype[Symbol.for("nodejs.util.inspect.custom")]=X.prototype.inspect);Ga.forEach(r=>{["add","merge","update"].forEach(i=>{const e=r.name(i),t=i==="add"?jn:Pa;r.generateKey?X.prototype[e]=function(n,a,o){return t(this,e,!0,(r.type||this.type)==="undirected",null,n,a,o,i==="update")}:X.prototype[e]=function(n,a,o,s){return t(this,e,!1,(r.type||this.type)==="undirected",n,a,o,s,i==="update")}})});Hr(X);ea(X);ma(X);Sa(X);class Bn extends X{constructor(i){const e=se({type:"directed"},i);if("multi"in e&&e.multi!==!1)throw new L("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(e.type!=="directed")throw new L('DirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Hn extends X{constructor(i){const e=se({type:"undirected"},i);if("multi"in e&&e.multi!==!1)throw new L("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(e.type!=="undirected")throw new L('UndirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Wn extends X{constructor(i){const e=se({multi:!0},i);if("multi"in e&&e.multi!==!0)throw new L("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(e)}}class Mn extends X{constructor(i){const e=se({type:"directed",multi:!0},i);if("multi"in e&&e.multi!==!0)throw new L("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(e.type!=="directed")throw new L('MultiDirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Vn extends X{constructor(i){const e=se({type:"undirected",multi:!0},i);if("multi"in e&&e.multi!==!0)throw new L("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(e.type!=="undirected")throw new L('MultiUndirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}function lt(r){r.from=function(i,e){const t=se({},i.options,e),n=new r(t);return n.import(i),n}}lt(X);lt(Bn);lt(Hn);lt(Wn);lt(Mn);lt(Vn);X.Graph=X;X.DirectedGraph=Bn;X.UndirectedGraph=Hn;X.MultiGraph=Wn;X.MultiDirectedGraph=Mn;X.MultiUndirectedGraph=Vn;X.InvalidArgumentsGraphError=L;X.NotFoundGraphError=A;X.UsageGraphError=P;function Oa(r,i){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var t=e.call(r,i);if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function wt(r){var i=Oa(r,"string");return typeof i=="symbol"?i:i+""}function le(r,i){if(!(r instanceof i))throw new TypeError("Cannot call a class as a function")}function Ui(r,i){for(var e=0;e<i.length;e++){var t=i[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,wt(t.key),t)}}function ce(r,i,e){return i&&Ui(r.prototype,i),e&&Ui(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function rt(r){return rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},rt(r)}function Kn(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Kn=function(){return!!r})()}function Ia(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function za(r,i){if(i&&(typeof i=="object"||typeof i=="function"))return i;if(i!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ia(r)}function ye(r,i,e){return i=rt(i),za(r,Kn()?Reflect.construct(i,e||[],rt(r).constructor):i.apply(r,e))}function oi(r,i){return oi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},oi(r,i)}function be(r,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(i&&i.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),i&&oi(r,i)}function Ua(r){if(Array.isArray(r))return r}function $a(r,i){var e=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(e!=null){var t,n,a,o,s=[],u=!0,h=!1;try{if(a=(e=e.call(r)).next,i===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(t=a.call(e)).done)&&(s.push(t.value),s.length!==i);u=!0);}catch(c){h=!0,n=c}finally{try{if(!u&&e.return!=null&&(o=e.return(),Object(o)!==o))return}finally{if(h)throw n}}return s}}function si(r,i){(i==null||i>r.length)&&(i=r.length);for(var e=0,t=Array(i);e<i;e++)t[e]=r[e];return t}function Zn(r,i){if(r){if(typeof r=="string")return si(r,i);var e={}.toString.call(r).slice(8,-1);return e==="Object"&&r.constructor&&(e=r.constructor.name),e==="Map"||e==="Set"?Array.from(r):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?si(r,i):void 0}}function Na(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function at(r,i){return Ua(r)||$a(r,i)||Zn(r,i)||Na()}var Yt={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"},qn=new Int8Array(4),Xt=new Int32Array(qn.buffer,0,1),ja=new Float32Array(qn.buffer,0,1),Ba=/^\s*rgba?\s*\(/,Ha=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Wa(r){var i=0,e=0,t=0,n=1;if(r[0]==="#")r.length===4?(i=parseInt(r.charAt(1)+r.charAt(1),16),e=parseInt(r.charAt(2)+r.charAt(2),16),t=parseInt(r.charAt(3)+r.charAt(3),16)):(i=parseInt(r.charAt(1)+r.charAt(2),16),e=parseInt(r.charAt(3)+r.charAt(4),16),t=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(n=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(Ba.test(r)){var a=r.match(Ha);a&&(i=+a[1],e=+a[2],t=+a[3],a[4]&&(n=+a[4]))}return{r:i,g:e,b:t,a:n}}var nt={};for(var Ft in Yt)nt[Ft]=Ye(Yt[Ft]),nt[Yt[Ft]]=nt[Ft];function Yn(r,i,e,t,n){return Xt[0]=t<<24|e<<16|i<<8|r,Xt[0]=Xt[0]&4278190079,ja[0]}function Ye(r){if(r=r.toLowerCase(),typeof nt[r]<"u")return nt[r];var i=Wa(r),e=i.r,t=i.g,n=i.b,a=i.a;a=a*255|0;var o=Yn(e,t,n,a);return nt[r]=o,o}var Qt={};function Xn(r){if(typeof Qt[r]<"u")return Qt[r];var i=(r&16711680)>>>16,e=(r&65280)>>>8,t=r&255,n=255,a=Yn(i,e,t,n);return Qt[r]=a,a}function $i(r,i,e,t){return e+(i<<8)+(r<<16)}function Ni(r,i,e,t,n,a){var o=Math.floor(e/a*n),s=Math.floor(r.drawingBufferHeight/a-t/a*n),u=new Uint8Array(4);r.bindFramebuffer(r.FRAMEBUFFER,i),r.readPixels(o,s,1,1,r.RGBA,r.UNSIGNED_BYTE,u);var h=at(u,4),c=h[0],l=h[1],d=h[2],m=h[3];return[c,l,d,m]}function T(r,i,e){return(i=wt(i))in r?Object.defineProperty(r,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[i]=e,r}function ji(r,i){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);i&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),e.push.apply(e,t)}return e}function F(r){for(var i=1;i<arguments.length;i++){var e=arguments[i]!=null?arguments[i]:{};i%2?ji(Object(e),!0).forEach(function(t){T(r,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):ji(Object(e)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))})}return r}function Ma(r,i){for(;!{}.hasOwnProperty.call(r,i)&&(r=rt(r))!==null;);return r}function ui(){return ui=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,i,e){var t=Ma(r,i);if(t){var n=Object.getOwnPropertyDescriptor(t,i);return n.get?n.get.call(arguments.length<3?r:e):n.value}},ui.apply(null,arguments)}function Qn(r,i,e,t){var n=ui(rt(r.prototype),i,e);return typeof n=="function"?function(a){return n.apply(e,a)}:n}function Va(r){return r.normalized?1:r.size}function Jt(r){var i=0;return r.forEach(function(e){return i+=Va(e)}),i}function Jn(r,i,e){var t=r==="VERTEX"?i.VERTEX_SHADER:i.FRAGMENT_SHADER,n=i.createShader(t);if(n===null)throw new Error("loadShader: error while creating the shader");i.shaderSource(n,e),i.compileShader(n);var a=i.getShaderParameter(n,i.COMPILE_STATUS);if(!a){var o=i.getShaderInfoLog(n);throw i.deleteShader(n),new Error(`loadShader: error while compiling the shader:
|
|
3
|
+
`.concat(o,`
|
|
4
|
+
`).concat(e))}return n}function Ka(r,i){return Jn("VERTEX",r,i)}function Za(r,i){return Jn("FRAGMENT",r,i)}function qa(r,i){var e=r.createProgram();if(e===null)throw new Error("loadProgram: error while creating the program.");var t,n;for(t=0,n=i.length;t<n;t++)r.attachShader(e,i[t]);r.linkProgram(e);var a=r.getProgramParameter(e,r.LINK_STATUS);if(!a){var o=r.getProgramInfoLog(e);throw r.deleteProgram(e),new Error("loadProgram: error while linking the program: ".concat(o))}return e}function Bi(r){var i=r.gl,e=r.buffer,t=r.program,n=r.vertexShader,a=r.fragmentShader;i.deleteShader(n),i.deleteShader(a),i.deleteProgram(t),i.deleteBuffer(e)}var Hi=`#define PICKING_MODE
|
|
5
|
+
`,Ya=T(T(T(T(T(T(T(T({},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),er=function(){function r(i,e,t){le(this,r),T(this,"array",new Float32Array),T(this,"constantArray",new Float32Array),T(this,"capacity",0),T(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=Jt(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=t,this.normalProgram=this.getProgramInfo("normal",i,n.VERTEX_SHADER_SOURCE,n.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=e?this.getProgramInfo("pick",i,Hi+n.VERTEX_SHADER_SOURCE,Hi+n.FRAGMENT_SHADER_SOURCE,e):null,this.isInstanced){var a=Jt(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*a);for(var o=0;o<this.CONSTANT_DATA.length;o++){var s=this.CONSTANT_DATA[o];if(s.length!==a)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(a,")"));for(var u=0;u<s.length;u++)this.constantArray[o*a+u]=s[u]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return ce(r,[{key:"kill",value:function(){Bi(this.normalProgram),this.pickProgram&&(Bi(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(e,t,n,a,o){var s=this.getDefinition(),u=t.createBuffer();if(u===null)throw new Error("Program: error while creating the WebGL buffer.");var h=Ka(t,n),c=Za(t,a),l=qa(t,[h,c]),d={};s.UNIFORMS.forEach(function(k){var S=t.getUniformLocation(l,k);S&&(d[k]=S)});var m={};s.ATTRIBUTES.forEach(function(k){m[k.name]=t.getAttribLocation(l,k.name)});var E;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(k){m[k.name]=t.getAttribLocation(l,k.name)}),E=t.createBuffer(),E===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:e,program:l,gl:t,frameBuffer:o,buffer:u,constantBuffer:E||{},uniformLocations:d,attributeLocations:m,isPicking:e==="pick",vertexShader:h,fragmentShader:c}}},{key:"bindProgram",value:function(e){var t=this,n=0,a=e.gl,o=e.buffer;this.isInstanced?(a.bindBuffer(a.ARRAY_BUFFER,e.constantBuffer),n=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return n+=t.bindAttribute(s,e,n,!1)}),a.bufferData(a.ARRAY_BUFFER,this.constantArray,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,e.buffer),n=0,this.ATTRIBUTES.forEach(function(s){return n+=t.bindAttribute(s,e,n,!0)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)):(a.bindBuffer(a.ARRAY_BUFFER,o),n=0,this.ATTRIBUTES.forEach(function(s){return n+=t.bindAttribute(s,e,n)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)),a.bindBuffer(a.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(e){var t=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e,!1)}),this.ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e,!0)})):this.ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e)})}},{key:"bindAttribute",value:function(e,t,n,a){var o=Ya[e.type];if(typeof o!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(e.type,'"'));var s=t.attributeLocations[e.name],u=t.gl;if(s!==-1){u.enableVertexAttribArray(s);var h=this.isInstanced?(a?this.ATTRIBUTES_ITEMS_COUNT:Jt(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(u.vertexAttribPointer(s,e.size,e.type,e.normalized||!1,h,n),this.isInstanced&&a)if(u instanceof WebGL2RenderingContext)u.vertexAttribDivisor(s,1);else{var c=u.getExtension("ANGLE_instanced_arrays");c&&c.vertexAttribDivisorANGLE(s,1)}}return e.size*o}},{key:"unbindAttribute",value:function(e,t,n){var a=t.attributeLocations[e.name],o=t.gl;if(a!==-1&&(o.disableVertexAttribArray(a),this.isInstanced&&n))if(o instanceof WebGL2RenderingContext)o.vertexAttribDivisor(a,0);else{var s=o.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(a,0)}}},{key:"reallocate",value:function(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))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(e,t){var n=t.gl,a=t.program;n.enable(n.BLEND),n.useProgram(a),this.setUniforms(e,t),this.drawWebGL(this.METHOD,t)}},{key:"render",value:function(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(F(F({},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))}},{key:"drawWebGL",value:function(e,t){var n=t.gl,a=t.frameBuffer;if(n.bindFramebuffer(n.FRAMEBUFFER,a),!this.isInstanced)n.drawArrays(e,0,this.verticesCount);else if(n instanceof WebGL2RenderingContext)n.drawArraysInstanced(e,0,this.VERTICES,this.capacity);else{var o=n.getExtension("ANGLE_instanced_arrays");o&&o.drawArraysInstancedANGLE(e,0,this.VERTICES,this.capacity)}}}])}(),Xa=function(r){function i(){return le(this,i),ye(this,i,arguments)}return be(i,r),ce(i,[{key:"kill",value:function(){Qn(i,"kill",this)([])}},{key:"process",value:function(t,n,a){var o=n*this.STRIDE;if(a.hidden){for(var s=o+this.STRIDE;o<s;o++)this.array[o]=0;return}return this.processVisibleItem(Xn(t),o,a)}}])}(er),_t=function(r){function i(){var e;le(this,i);for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return e=ye(this,i,[].concat(n)),T(e,"drawLabel",void 0),e}return be(i,r),ce(i,[{key:"kill",value:function(){Qn(i,"kill",this)([])}},{key:"process",value:function(t,n,a,o,s){var u=n*this.STRIDE;if(s.hidden||a.hidden||o.hidden){for(var h=u+this.STRIDE;u<h;u++)this.array[u]=0;return}return this.processVisibleItem(Xn(t),u,a,o,s)}}])}(er);function tr(r,i){return function(){function e(t,n,a){le(this,e),T(this,"drawLabel",i),this.programs=r.map(function(o){return new o(t,n,a)})}return ce(e,[{key:"reallocate",value:function(n){this.programs.forEach(function(a){return a.reallocate(n)})}},{key:"process",value:function(n,a,o,s,u){this.programs.forEach(function(h){return h.process(n,a,o,s,u)})}},{key:"render",value:function(n){this.programs.forEach(function(a){return a.render(n)})}},{key:"kill",value:function(){this.programs.forEach(function(n){return n.kill()})}}])}()}function Qa(r,i,e,t,n){var a=n.edgeLabelSize,o=n.edgeLabelFont,s=n.edgeLabelWeight,u=n.edgeLabelColor.attribute?i[n.edgeLabelColor.attribute]||n.edgeLabelColor.color||"#000":n.edgeLabelColor.color,h=i.label;if(h){r.fillStyle=u,r.font="".concat(s," ").concat(a,"px ").concat(o);var c=e.size,l=t.size,d=e.x,m=e.y,E=t.x,k=t.y,S=(d+E)/2,x=(m+k)/2,R=E-d,b=k-m,_=Math.sqrt(R*R+b*b);if(!(_<c+l)){d+=R*c/_,m+=b*c/_,E-=R*l/_,k-=b*l/_,S=(d+E)/2,x=(m+k)/2,R=E-d,b=k-m,_=Math.sqrt(R*R+b*b);var G=r.measureText(h).width;if(G>_){var z="…";for(h=h+z,G=r.measureText(h).width;G>_&&h.length>1;)h=h.slice(0,-2)+z,G=r.measureText(h).width;if(h.length<4)return}var w;R>0?b>0?w=Math.acos(R/_):w=Math.asin(b/_):b>0?w=Math.acos(R/_)+Math.PI:w=Math.asin(R/_)+Math.PI/2,r.save(),r.translate(S,x),r.rotate(w),r.fillText(h,-G/2,i.size/2+a),r.restore()}}}function ir(r,i,e){if(i.label){var t=e.labelSize,n=e.labelFont,a=e.labelWeight,o=e.labelColor.attribute?i[e.labelColor.attribute]||e.labelColor.color||"#000":e.labelColor.color;r.fillStyle=o,r.font="".concat(a," ").concat(t,"px ").concat(n),r.fillText(i.label,i.x+i.size+3,i.y+t/3)}}function Ja(r,i,e){var t=e.labelSize,n=e.labelFont,a=e.labelWeight;r.font="".concat(a," ").concat(t,"px ").concat(n),r.fillStyle="#FFF",r.shadowOffsetX=0,r.shadowOffsetY=0,r.shadowBlur=8,r.shadowColor="#000";var o=2;if(typeof i.label=="string"){var s=r.measureText(i.label).width,u=Math.round(s+5),h=Math.round(t+2*o),c=Math.max(i.size,t/2)+o,l=Math.asin(h/2/c),d=Math.sqrt(Math.abs(Math.pow(c,2)-Math.pow(h/2,2)));r.beginPath(),r.moveTo(i.x+d,i.y+h/2),r.lineTo(i.x+c+u,i.y+h/2),r.lineTo(i.x+c+u,i.y-h/2),r.lineTo(i.x+d,i.y-h/2),r.arc(i.x,i.y,c,l,-l),r.closePath(),r.fill()}else r.beginPath(),r.arc(i.x,i.y,i.size+o,0,Math.PI*2),r.closePath(),r.fill();r.shadowOffsetX=0,r.shadowOffsetY=0,r.shadowBlur=0,ir(r,i,e)}var eo=`
|
|
6
|
+
precision highp float;
|
|
7
|
+
|
|
8
|
+
varying vec4 v_color;
|
|
9
|
+
varying vec2 v_diffVector;
|
|
10
|
+
varying float v_radius;
|
|
11
|
+
|
|
12
|
+
uniform float u_correctionRatio;
|
|
13
|
+
|
|
14
|
+
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
15
|
+
|
|
16
|
+
void main(void) {
|
|
17
|
+
float border = u_correctionRatio * 2.0;
|
|
18
|
+
float dist = length(v_diffVector) - v_radius + border;
|
|
19
|
+
|
|
20
|
+
// No antialiasing for picking mode:
|
|
21
|
+
#ifdef PICKING_MODE
|
|
22
|
+
if (dist > border)
|
|
23
|
+
gl_FragColor = transparent;
|
|
24
|
+
else
|
|
25
|
+
gl_FragColor = v_color;
|
|
26
|
+
|
|
27
|
+
#else
|
|
28
|
+
float t = 0.0;
|
|
29
|
+
if (dist > border)
|
|
30
|
+
t = 1.0;
|
|
31
|
+
else if (dist > 0.0)
|
|
32
|
+
t = dist / border;
|
|
33
|
+
|
|
34
|
+
gl_FragColor = mix(v_color, transparent, t);
|
|
35
|
+
#endif
|
|
36
|
+
}
|
|
37
|
+
`,to=eo,io=`
|
|
38
|
+
attribute vec4 a_id;
|
|
39
|
+
attribute vec4 a_color;
|
|
40
|
+
attribute vec2 a_position;
|
|
41
|
+
attribute float a_size;
|
|
42
|
+
attribute float a_angle;
|
|
43
|
+
|
|
44
|
+
uniform mat3 u_matrix;
|
|
45
|
+
uniform float u_sizeRatio;
|
|
46
|
+
uniform float u_correctionRatio;
|
|
47
|
+
|
|
48
|
+
varying vec4 v_color;
|
|
49
|
+
varying vec2 v_diffVector;
|
|
50
|
+
varying float v_radius;
|
|
51
|
+
varying float v_border;
|
|
52
|
+
|
|
53
|
+
const float bias = 255.0 / 254.0;
|
|
54
|
+
|
|
55
|
+
void main() {
|
|
56
|
+
float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
|
|
57
|
+
vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
|
|
58
|
+
vec2 position = a_position + diffVector;
|
|
59
|
+
gl_Position = vec4(
|
|
60
|
+
(u_matrix * vec3(position, 1)).xy,
|
|
61
|
+
0,
|
|
62
|
+
1
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
v_diffVector = diffVector;
|
|
66
|
+
v_radius = size / 2.0;
|
|
67
|
+
|
|
68
|
+
#ifdef PICKING_MODE
|
|
69
|
+
// For picking mode, we use the ID as the color:
|
|
70
|
+
v_color = a_id;
|
|
71
|
+
#else
|
|
72
|
+
// For normal mode, we use the color:
|
|
73
|
+
v_color = a_color;
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
v_color.a *= bias;
|
|
77
|
+
}
|
|
78
|
+
`,no=io,nr=WebGLRenderingContext,Wi=nr.UNSIGNED_BYTE,ei=nr.FLOAT,ro=["u_sizeRatio","u_correctionRatio","u_matrix"],Tt=function(r){function i(){return le(this,i),ye(this,i,arguments)}return be(i,r),ce(i,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:no,FRAGMENT_SHADER_SOURCE:to,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:ro,ATTRIBUTES:[{name:"a_position",size:2,type:ei},{name:"a_size",size:1,type:ei},{name:"a_color",size:4,type:Wi,normalized:!0},{name:"a_id",size:4,type:Wi,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:ei}],CONSTANT_DATA:[[i.ANGLE_1],[i.ANGLE_2],[i.ANGLE_3]]}}},{key:"processVisibleItem",value:function(t,n,a){var o=this.array,s=Ye(a.color);o[n++]=a.x,o[n++]=a.y,o[n++]=a.size,o[n++]=s,o[n++]=t}},{key:"setUniforms",value:function(t,n){var a=n.gl,o=n.uniformLocations,s=o.u_sizeRatio,u=o.u_correctionRatio,h=o.u_matrix;a.uniform1f(u,t.correctionRatio),a.uniform1f(s,t.sizeRatio),a.uniformMatrix3fv(h,!1,t.matrix)}}])}(Xa);T(Tt,"ANGLE_1",0);T(Tt,"ANGLE_2",2*Math.PI/3);T(Tt,"ANGLE_3",4*Math.PI/3);var ao=`
|
|
79
|
+
precision mediump float;
|
|
80
|
+
|
|
81
|
+
varying vec4 v_color;
|
|
82
|
+
|
|
83
|
+
void main(void) {
|
|
84
|
+
gl_FragColor = v_color;
|
|
85
|
+
}
|
|
86
|
+
`,oo=ao,so=`
|
|
87
|
+
attribute vec2 a_position;
|
|
88
|
+
attribute vec2 a_normal;
|
|
89
|
+
attribute float a_radius;
|
|
90
|
+
attribute vec3 a_barycentric;
|
|
91
|
+
|
|
92
|
+
#ifdef PICKING_MODE
|
|
93
|
+
attribute vec4 a_id;
|
|
94
|
+
#else
|
|
95
|
+
attribute vec4 a_color;
|
|
96
|
+
#endif
|
|
97
|
+
|
|
98
|
+
uniform mat3 u_matrix;
|
|
99
|
+
uniform float u_sizeRatio;
|
|
100
|
+
uniform float u_correctionRatio;
|
|
101
|
+
uniform float u_minEdgeThickness;
|
|
102
|
+
uniform float u_lengthToThicknessRatio;
|
|
103
|
+
uniform float u_widenessToThicknessRatio;
|
|
104
|
+
|
|
105
|
+
varying vec4 v_color;
|
|
106
|
+
|
|
107
|
+
const float bias = 255.0 / 254.0;
|
|
108
|
+
|
|
109
|
+
void main() {
|
|
110
|
+
float minThickness = u_minEdgeThickness;
|
|
111
|
+
|
|
112
|
+
float normalLength = length(a_normal);
|
|
113
|
+
vec2 unitNormal = a_normal / normalLength;
|
|
114
|
+
|
|
115
|
+
// These first computations are taken from edge.vert.glsl and
|
|
116
|
+
// edge.clamped.vert.glsl. Please read it to get better comments on what's
|
|
117
|
+
// happening:
|
|
118
|
+
float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
|
|
119
|
+
float webGLThickness = pixelsThickness * u_correctionRatio;
|
|
120
|
+
float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
121
|
+
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
122
|
+
float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
|
|
123
|
+
|
|
124
|
+
float da = a_barycentric.x;
|
|
125
|
+
float db = a_barycentric.y;
|
|
126
|
+
float dc = a_barycentric.z;
|
|
127
|
+
|
|
128
|
+
vec2 delta = vec2(
|
|
129
|
+
da * (webGLNodeRadius * unitNormal.y)
|
|
130
|
+
+ db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
|
|
131
|
+
+ dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
|
|
132
|
+
|
|
133
|
+
da * (-webGLNodeRadius * unitNormal.x)
|
|
134
|
+
+ db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
|
|
135
|
+
+ dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
|
|
139
|
+
|
|
140
|
+
gl_Position = vec4(position, 0, 1);
|
|
141
|
+
|
|
142
|
+
#ifdef PICKING_MODE
|
|
143
|
+
// For picking mode, we use the ID as the color:
|
|
144
|
+
v_color = a_id;
|
|
145
|
+
#else
|
|
146
|
+
// For normal mode, we use the color:
|
|
147
|
+
v_color = a_color;
|
|
148
|
+
#endif
|
|
149
|
+
|
|
150
|
+
v_color.a *= bias;
|
|
151
|
+
}
|
|
152
|
+
`,uo=so,rr=WebGLRenderingContext,Mi=rr.UNSIGNED_BYTE,Pt=rr.FLOAT,ho=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Ei={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function Nt(r){var i=F(F({},Ei),r||{});return function(e){function t(){return le(this,t),ye(this,t,arguments)}return be(t,e),ce(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:uo,FRAGMENT_SHADER_SOURCE:oo,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:ho,ATTRIBUTES:[{name:"a_position",size:2,type:Pt},{name:"a_normal",size:2,type:Pt},{name:"a_radius",size:1,type:Pt},{name:"a_color",size:4,type:Mi,normalized:!0},{name:"a_id",size:4,type:Mi,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Pt}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(a,o,s,u,h){if(i.extremity==="source"){var c=[u,s];s=c[0],u=c[1]}var l=h.size||1,d=u.size||1,m=s.x,E=s.y,k=u.x,S=u.y,x=Ye(h.color),R=k-m,b=S-E,_=R*R+b*b,G=0,z=0;_&&(_=1/Math.sqrt(_),G=-b*_*l,z=R*_*l);var w=this.array;w[o++]=k,w[o++]=S,w[o++]=-G,w[o++]=-z,w[o++]=d,w[o++]=x,w[o++]=a}},{key:"setUniforms",value:function(a,o){var s=o.gl,u=o.uniformLocations,h=u.u_matrix,c=u.u_sizeRatio,l=u.u_correctionRatio,d=u.u_minEdgeThickness,m=u.u_lengthToThicknessRatio,E=u.u_widenessToThicknessRatio;s.uniformMatrix3fv(h,!1,a.matrix),s.uniform1f(c,a.sizeRatio),s.uniform1f(l,a.correctionRatio),s.uniform1f(d,a.minEdgeThickness),s.uniform1f(m,i.lengthToThicknessRatio),s.uniform1f(E,i.widenessToThicknessRatio)}}])}(_t)}Nt();var lo=`
|
|
153
|
+
precision mediump float;
|
|
154
|
+
|
|
155
|
+
varying vec4 v_color;
|
|
156
|
+
varying vec2 v_normal;
|
|
157
|
+
varying float v_thickness;
|
|
158
|
+
varying float v_feather;
|
|
159
|
+
|
|
160
|
+
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
161
|
+
|
|
162
|
+
void main(void) {
|
|
163
|
+
// We only handle antialiasing for normal mode:
|
|
164
|
+
#ifdef PICKING_MODE
|
|
165
|
+
gl_FragColor = v_color;
|
|
166
|
+
#else
|
|
167
|
+
float dist = length(v_normal) * v_thickness;
|
|
168
|
+
|
|
169
|
+
float t = smoothstep(
|
|
170
|
+
v_thickness - v_feather,
|
|
171
|
+
v_thickness,
|
|
172
|
+
dist
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
gl_FragColor = mix(v_color, transparent, t);
|
|
176
|
+
#endif
|
|
177
|
+
}
|
|
178
|
+
`,_i=lo,co=`
|
|
179
|
+
attribute vec4 a_id;
|
|
180
|
+
attribute vec4 a_color;
|
|
181
|
+
attribute vec2 a_normal;
|
|
182
|
+
attribute float a_normalCoef;
|
|
183
|
+
attribute vec2 a_positionStart;
|
|
184
|
+
attribute vec2 a_positionEnd;
|
|
185
|
+
attribute float a_positionCoef;
|
|
186
|
+
attribute float a_radius;
|
|
187
|
+
attribute float a_radiusCoef;
|
|
188
|
+
|
|
189
|
+
uniform mat3 u_matrix;
|
|
190
|
+
uniform float u_zoomRatio;
|
|
191
|
+
uniform float u_sizeRatio;
|
|
192
|
+
uniform float u_pixelRatio;
|
|
193
|
+
uniform float u_correctionRatio;
|
|
194
|
+
uniform float u_minEdgeThickness;
|
|
195
|
+
uniform float u_lengthToThicknessRatio;
|
|
196
|
+
uniform float u_feather;
|
|
197
|
+
|
|
198
|
+
varying vec4 v_color;
|
|
199
|
+
varying vec2 v_normal;
|
|
200
|
+
varying float v_thickness;
|
|
201
|
+
varying float v_feather;
|
|
202
|
+
|
|
203
|
+
const float bias = 255.0 / 254.0;
|
|
204
|
+
|
|
205
|
+
void main() {
|
|
206
|
+
float minThickness = u_minEdgeThickness;
|
|
207
|
+
|
|
208
|
+
float radius = a_radius * a_radiusCoef;
|
|
209
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
210
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
211
|
+
|
|
212
|
+
float normalLength = length(normal);
|
|
213
|
+
vec2 unitNormal = normal / normalLength;
|
|
214
|
+
|
|
215
|
+
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
216
|
+
// get better comments on what's happening:
|
|
217
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
218
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
219
|
+
|
|
220
|
+
// Here, we move the point to leave space for the arrow head:
|
|
221
|
+
float direction = sign(radius);
|
|
222
|
+
float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
223
|
+
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
224
|
+
|
|
225
|
+
vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
|
|
226
|
+
|
|
227
|
+
// Here is the proper position of the vertex
|
|
228
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
|
|
229
|
+
|
|
230
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
231
|
+
|
|
232
|
+
v_normal = unitNormal;
|
|
233
|
+
|
|
234
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
235
|
+
|
|
236
|
+
#ifdef PICKING_MODE
|
|
237
|
+
// For picking mode, we use the ID as the color:
|
|
238
|
+
v_color = a_id;
|
|
239
|
+
#else
|
|
240
|
+
// For normal mode, we use the color:
|
|
241
|
+
v_color = a_color;
|
|
242
|
+
#endif
|
|
243
|
+
|
|
244
|
+
v_color.a *= bias;
|
|
245
|
+
}
|
|
246
|
+
`,fo=co,ar=WebGLRenderingContext,Vi=ar.UNSIGNED_BYTE,Ze=ar.FLOAT,go=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],po={lengthToThicknessRatio:Ei.lengthToThicknessRatio};function or(r){var i=F(F({},po),{});return function(e){function t(){return le(this,t),ye(this,t,arguments)}return be(t,e),ce(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:fo,FRAGMENT_SHADER_SOURCE:_i,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:go,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Ze},{name:"a_positionEnd",size:2,type:Ze},{name:"a_normal",size:2,type:Ze},{name:"a_color",size:4,type:Vi,normalized:!0},{name:"a_id",size:4,type:Vi,normalized:!0},{name:"a_radius",size:1,type:Ze}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Ze},{name:"a_normalCoef",size:1,type:Ze},{name:"a_radiusCoef",size:1,type:Ze}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(a,o,s,u,h){var c=h.size||1,l=s.x,d=s.y,m=u.x,E=u.y,k=Ye(h.color),S=m-l,x=E-d,R=u.size||1,b=S*S+x*x,_=0,G=0;b&&(b=1/Math.sqrt(b),_=-x*b*c,G=S*b*c);var z=this.array;z[o++]=l,z[o++]=d,z[o++]=m,z[o++]=E,z[o++]=_,z[o++]=G,z[o++]=k,z[o++]=a,z[o++]=R}},{key:"setUniforms",value:function(a,o){var s=o.gl,u=o.uniformLocations,h=u.u_matrix,c=u.u_zoomRatio,l=u.u_feather,d=u.u_pixelRatio,m=u.u_correctionRatio,E=u.u_sizeRatio,k=u.u_minEdgeThickness,S=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(h,!1,a.matrix),s.uniform1f(c,a.zoomRatio),s.uniform1f(E,a.sizeRatio),s.uniform1f(m,a.correctionRatio),s.uniform1f(d,a.pixelRatio),s.uniform1f(l,a.antiAliasingFeather),s.uniform1f(k,a.minEdgeThickness),s.uniform1f(S,i.lengthToThicknessRatio)}}])}(_t)}or();function mo(r){return tr([or(),Nt(r)])}var vo=mo(),yo=vo,bo=`
|
|
247
|
+
attribute vec4 a_id;
|
|
248
|
+
attribute vec4 a_color;
|
|
249
|
+
attribute vec2 a_normal;
|
|
250
|
+
attribute float a_normalCoef;
|
|
251
|
+
attribute vec2 a_positionStart;
|
|
252
|
+
attribute vec2 a_positionEnd;
|
|
253
|
+
attribute float a_positionCoef;
|
|
254
|
+
|
|
255
|
+
uniform mat3 u_matrix;
|
|
256
|
+
uniform float u_sizeRatio;
|
|
257
|
+
uniform float u_zoomRatio;
|
|
258
|
+
uniform float u_pixelRatio;
|
|
259
|
+
uniform float u_correctionRatio;
|
|
260
|
+
uniform float u_minEdgeThickness;
|
|
261
|
+
uniform float u_feather;
|
|
262
|
+
|
|
263
|
+
varying vec4 v_color;
|
|
264
|
+
varying vec2 v_normal;
|
|
265
|
+
varying float v_thickness;
|
|
266
|
+
varying float v_feather;
|
|
267
|
+
|
|
268
|
+
const float bias = 255.0 / 254.0;
|
|
269
|
+
|
|
270
|
+
void main() {
|
|
271
|
+
float minThickness = u_minEdgeThickness;
|
|
272
|
+
|
|
273
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
274
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
275
|
+
|
|
276
|
+
float normalLength = length(normal);
|
|
277
|
+
vec2 unitNormal = normal / normalLength;
|
|
278
|
+
|
|
279
|
+
// We require edges to be at least "minThickness" pixels thick *on screen*
|
|
280
|
+
// (so we need to compensate the size ratio):
|
|
281
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
282
|
+
|
|
283
|
+
// Then, we need to retrieve the normalized thickness of the edge in the WebGL
|
|
284
|
+
// referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
|
|
285
|
+
// ratio:
|
|
286
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
287
|
+
|
|
288
|
+
// Here is the proper position of the vertex
|
|
289
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
|
|
290
|
+
|
|
291
|
+
// For the fragment shader though, we need a thickness that takes the "magic"
|
|
292
|
+
// correction ratio into account (as in webGLThickness), but so that the
|
|
293
|
+
// antialiasing effect does not depend on the zoom level. So here's yet
|
|
294
|
+
// another thickness version:
|
|
295
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
296
|
+
|
|
297
|
+
v_normal = unitNormal;
|
|
298
|
+
|
|
299
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
300
|
+
|
|
301
|
+
#ifdef PICKING_MODE
|
|
302
|
+
// For picking mode, we use the ID as the color:
|
|
303
|
+
v_color = a_id;
|
|
304
|
+
#else
|
|
305
|
+
// For normal mode, we use the color:
|
|
306
|
+
v_color = a_color;
|
|
307
|
+
#endif
|
|
308
|
+
|
|
309
|
+
v_color.a *= bias;
|
|
310
|
+
}
|
|
311
|
+
`,wo=bo,sr=WebGLRenderingContext,Ki=sr.UNSIGNED_BYTE,pt=sr.FLOAT,Eo=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],_o=function(r){function i(){return le(this,i),ye(this,i,arguments)}return be(i,r),ce(i,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:wo,FRAGMENT_SHADER_SOURCE:_i,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Eo,ATTRIBUTES:[{name:"a_positionStart",size:2,type:pt},{name:"a_positionEnd",size:2,type:pt},{name:"a_normal",size:2,type:pt},{name:"a_color",size:4,type:Ki,normalized:!0},{name:"a_id",size:4,type:Ki,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:pt},{name:"a_normalCoef",size:1,type:pt}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(t,n,a,o,s){var u=s.size||1,h=a.x,c=a.y,l=o.x,d=o.y,m=Ye(s.color),E=l-h,k=d-c,S=E*E+k*k,x=0,R=0;S&&(S=1/Math.sqrt(S),x=-k*S*u,R=E*S*u);var b=this.array;b[n++]=h,b[n++]=c,b[n++]=l,b[n++]=d,b[n++]=x,b[n++]=R,b[n++]=m,b[n++]=t}},{key:"setUniforms",value:function(t,n){var a=n.gl,o=n.uniformLocations,s=o.u_matrix,u=o.u_zoomRatio,h=o.u_feather,c=o.u_pixelRatio,l=o.u_correctionRatio,d=o.u_sizeRatio,m=o.u_minEdgeThickness;a.uniformMatrix3fv(s,!1,t.matrix),a.uniform1f(u,t.zoomRatio),a.uniform1f(d,t.sizeRatio),a.uniform1f(l,t.correctionRatio),a.uniform1f(c,t.pixelRatio),a.uniform1f(h,t.antiAliasingFeather),a.uniform1f(m,t.minEdgeThickness)}}])}(_t),Ti=function(r){function i(){var e;return le(this,i),e=ye(this,i),e.rawEmitter=e,e}return be(i,r),ce(i)}(xn.EventEmitter),Si=function(i){return i!==null&&typeof i=="object"&&typeof i.addUndirectedEdgeWithKey=="function"&&typeof i.dropNode=="function"&&typeof i.multi=="boolean"};const To=Tn(Si);var So=function(i){return i},Ro=function(i){return i*i},ko=function(i){return i*(2-i)},Co=function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)},Ao=function(i){return i*i*i},Do=function(i){return--i*i*i+1},Lo=function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)},Go={linear:So,quadraticIn:Ro,quadraticOut:ko,quadraticInOut:Co,cubicIn:Ao,cubicOut:Do,cubicInOut:Lo},xo={easing:"quadraticInOut",duration:150};function Ae(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ot(r,i,e){return r[0]=i,r[4]=typeof e=="number"?e:i,r}function Zi(r,i){var e=Math.sin(i),t=Math.cos(i);return r[0]=t,r[1]=e,r[3]=-e,r[4]=t,r}function qi(r,i,e){return r[6]=i,r[7]=e,r}function Be(r,i){var e=r[0],t=r[1],n=r[2],a=r[3],o=r[4],s=r[5],u=r[6],h=r[7],c=r[8],l=i[0],d=i[1],m=i[2],E=i[3],k=i[4],S=i[5],x=i[6],R=i[7],b=i[8];return r[0]=l*e+d*a+m*u,r[1]=l*t+d*o+m*h,r[2]=l*n+d*s+m*c,r[3]=E*e+k*a+S*u,r[4]=E*t+k*o+S*h,r[5]=E*n+k*s+S*c,r[6]=x*e+R*a+b*u,r[7]=x*t+R*o+b*h,r[8]=x*n+R*s+b*c,r}function hi(r,i){var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,t=r[0],n=r[1],a=r[3],o=r[4],s=r[6],u=r[7],h=i.x,c=i.y;return{x:h*t+c*a+s*e,y:h*n+c*o+u*e}}function Fo(r,i){var e=r.height/r.width,t=i.height/i.width;return e<1&&t>1||e>1&&t<1?1:Math.min(Math.max(t,1/t),Math.max(1/e,e))}function mt(r,i,e,t,n){var a=r.angle,o=r.ratio,s=r.x,u=r.y,h=i.width,c=i.height,l=Ae(),d=Math.min(h,c)-2*t,m=Fo(i,e);return n?(Be(l,qi(Ae(),s,u)),Be(l,Ot(Ae(),o)),Be(l,Zi(Ae(),a)),Be(l,Ot(Ae(),h/d/2/m,c/d/2/m))):(Be(l,Ot(Ae(),2*(d/h)*m,2*(d/c)*m)),Be(l,Zi(Ae(),-a)),Be(l,Ot(Ae(),1/o)),Be(l,qi(Ae(),-s,-u))),l}function Po(r,i,e){var t=hi(r,{x:Math.cos(i.angle),y:Math.sin(i.angle)},0),n=t.x,a=t.y;return 1/Math.sqrt(Math.pow(n,2)+Math.pow(a,2))/e.width}function Oo(r){if(!r.order)return{x:[0,1],y:[0,1]};var i=1/0,e=-1/0,t=1/0,n=-1/0;return r.forEachNode(function(a,o){var s=o.x,u=o.y;s<i&&(i=s),s>e&&(e=s),u<t&&(t=u),u>n&&(n=u)}),{x:[i,e],y:[t,n]}}function Io(r){if(!To(r))throw new Error("Sigma: invalid graph instance.");r.forEachNode(function(i,e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error("Sigma: Coordinates of node ".concat(i," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function zo(r,i,e){var t=document.createElement(r);if(i)for(var n in i)t.style[n]=i[n];if(e)for(var a in e)t.setAttribute(a,e[a]);return t}function Yi(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Xi(r,i,e){return e.sort(function(t,n){var a=i(t)||0,o=i(n)||0;return a<o?-1:a>o?1:0})}function Qi(r){var i=at(r.x,2),e=i[0],t=i[1],n=at(r.y,2),a=n[0],o=n[1],s=Math.max(t-e,o-a),u=(t+e)/2,h=(o+a)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(u)&&(u=0),isNaN(h)&&(h=0);var c=function(d){return{x:.5+(d.x-u)/s,y:.5+(d.y-h)/s}};return c.applyTo=function(l){l.x=.5+(l.x-u)/s,l.y=.5+(l.y-h)/s},c.inverse=function(l){return{x:u+s*(l.x-.5),y:h+s*(l.y-.5)}},c.ratio=s,c}function li(r){"@babel/helpers - typeof";return li=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},li(r)}function Ji(r,i){var e=i.size;if(e!==0){var t=r.length;r.length+=e;var n=0;i.forEach(function(a){r[t+n]=a,n++})}}function ti(r){r=r||{};for(var i=0,e=arguments.length<=1?0:arguments.length-1;i<e;i++){var t=i+1<1||arguments.length<=i+1?void 0:arguments[i+1];t&&Object.assign(r,t)}return r}var Ri={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:Qa,defaultDrawNodeLabel:ir,defaultDrawNodeHover:Ja,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:{}},Uo={circle:Tt},$o={arrow:yo,line:_o};function ii(r){if(typeof r.labelDensity!="number"||r.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var i=r.minCameraRatio,e=r.maxCameraRatio;if(typeof i=="number"&&typeof e=="number"&&e<i)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function No(r){var i=ti({},Ri,r);return i.nodeProgramClasses=ti({},Uo,i.nodeProgramClasses),i.edgeProgramClasses=ti({},$o,i.edgeProgramClasses),i}var It=1.5,en=function(r){function i(){var e;return le(this,i),e=ye(this,i),T(e,"x",.5),T(e,"y",.5),T(e,"angle",0),T(e,"ratio",1),T(e,"minRatio",null),T(e,"maxRatio",null),T(e,"enabledZooming",!0),T(e,"enabledPanning",!0),T(e,"enabledRotation",!0),T(e,"clean",null),T(e,"nextFrame",null),T(e,"previousState",null),T(e,"enabled",!0),e.previousState=e.getState(),e}return be(i,r),ce(i,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(t){return this.x===t.x&&this.y===t.y&&this.ratio===t.ratio&&this.angle===t.angle}},{key:"getPreviousState",value:function(){var t=this.previousState;return t?{x:t.x,y:t.y,angle:t.angle,ratio:t.ratio}:null}},{key:"getBoundedRatio",value:function(t){var n=t;return typeof this.minRatio=="number"&&(n=Math.max(n,this.minRatio)),typeof this.maxRatio=="number"&&(n=Math.min(n,this.maxRatio)),n}},{key:"validateState",value:function(t){var n={};return this.enabledPanning&&typeof t.x=="number"&&(n.x=t.x),this.enabledPanning&&typeof t.y=="number"&&(n.y=t.y),this.enabledZooming&&typeof t.ratio=="number"&&(n.ratio=this.getBoundedRatio(t.ratio)),this.enabledRotation&&typeof t.angle=="number"&&(n.angle=t.angle),this.clean?this.clean(F(F({},this.getState()),n)):n}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(t){if(!this.enabled)return this;this.previousState=this.getState();var n=this.validateState(t);return typeof n.x=="number"&&(this.x=n.x),typeof n.y=="number"&&(this.y=n.y),typeof n.ratio=="number"&&(this.ratio=n.ratio),typeof n.angle=="number"&&(this.angle=n.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(t){return this.setState(t(this.getState())),this}},{key:"animate",value:function(t){var n=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(!o)return new Promise(function(m){return n.animate(t,a,m)});if(this.enabled){var s=F(F({},xo),a),u=this.validateState(t),h=typeof s.easing=="function"?s.easing:Go[s.easing],c=Date.now(),l=this.getState(),d=function(){var E=(Date.now()-c)/s.duration;if(E>=1){n.nextFrame=null,n.setState(u),n.animationCallback&&(n.animationCallback.call(null),n.animationCallback=void 0);return}var k=h(E),S={};typeof u.x=="number"&&(S.x=l.x+(u.x-l.x)*k),typeof u.y=="number"&&(S.y=l.y+(u.y-l.y)*k),n.enabledRotation&&typeof u.angle=="number"&&(S.angle=l.angle+(u.angle-l.angle)*k),typeof u.ratio=="number"&&(S.ratio=l.ratio+(u.ratio-l.ratio)*k),n.setState(S),n.nextFrame=requestAnimationFrame(d)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(d)):d(),this.animationCallback=o}}},{key:"animatedZoom",value:function(t){return t?typeof t=="number"?this.animate({ratio:this.ratio/t}):this.animate({ratio:this.ratio/(t.factor||It)},t):this.animate({ratio:this.ratio/It})}},{key:"animatedUnzoom",value:function(t){return t?typeof t=="number"?this.animate({ratio:this.ratio*t}):this.animate({ratio:this.ratio*(t.factor||It)},t):this.animate({ratio:this.ratio*It})}},{key:"animatedReset",value:function(t){return this.animate({x:.5,y:.5,ratio:1,angle:0},t)}},{key:"copy",value:function(){return i.from(this.getState())}}],[{key:"from",value:function(t){var n=new i;return n.setState(t)}}])}(Ti);function De(r,i){var e=i.getBoundingClientRect();return{x:r.clientX-e.left,y:r.clientY-e.top}}function ze(r,i){var e=F(F({},De(r,i)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:r});return e}function vt(r){var i="x"in r?r:F(F({},r.touches[0]||r.previousTouches[0]),{},{original:r.original,sigmaDefaultPrevented:r.sigmaDefaultPrevented,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0,i.sigmaDefaultPrevented=!0}});return i}function jo(r,i){return F(F({},ze(r,i)),{},{delta:ur(r)})}var Bo=2;function $t(r){for(var i=[],e=0,t=Math.min(r.length,Bo);e<t;e++)i.push(r[e]);return i}function yt(r,i,e){var t={touches:$t(r.touches).map(function(n){return De(n,e)}),previousTouches:i.map(function(n){return De(n,e)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0},original:r};return t}function ur(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.")}var hr=function(r){function i(e,t){var n;return le(this,i),n=ye(this,i),n.container=e,n.renderer=t,n}return be(i,r),ce(i)}(Ti),Ho=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],Wo=Ho.reduce(function(r,i){return F(F({},r),{},T({},i,Ri[i]))},{}),Mo=function(r){function i(e,t){var n;return le(this,i),n=ye(this,i,[e,t]),T(n,"enabled",!0),T(n,"draggedEvents",0),T(n,"downStartTime",null),T(n,"lastMouseX",null),T(n,"lastMouseY",null),T(n,"isMouseDown",!1),T(n,"isMoving",!1),T(n,"movingTimeout",null),T(n,"startCameraState",null),T(n,"clicks",0),T(n,"doubleClickTimeout",null),T(n,"currentWheelDirection",0),T(n,"settings",Wo),n.handleClick=n.handleClick.bind(n),n.handleRightClick=n.handleRightClick.bind(n),n.handleDown=n.handleDown.bind(n),n.handleUp=n.handleUp.bind(n),n.handleMove=n.handleMove.bind(n),n.handleWheel=n.handleWheel.bind(n),n.handleLeave=n.handleLeave.bind(n),n.handleEnter=n.handleEnter.bind(n),e.addEventListener("click",n.handleClick,{capture:!1}),e.addEventListener("contextmenu",n.handleRightClick,{capture:!1}),e.addEventListener("mousedown",n.handleDown,{capture:!1}),e.addEventListener("wheel",n.handleWheel,{capture:!1}),e.addEventListener("mouseleave",n.handleLeave,{capture:!1}),e.addEventListener("mouseenter",n.handleEnter,{capture:!1}),document.addEventListener("mousemove",n.handleMove,{capture:!1}),document.addEventListener("mouseup",n.handleUp,{capture:!1}),n}return be(i,r),ce(i,[{key:"kill",value:function(){var t=this.container;t.removeEventListener("click",this.handleClick),t.removeEventListener("contextmenu",this.handleRightClick),t.removeEventListener("mousedown",this.handleDown),t.removeEventListener("wheel",this.handleWheel),t.removeEventListener("mouseleave",this.handleLeave),t.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(t){var n=this;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(t);setTimeout(function(){n.clicks=0,n.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",ze(t,this.container))}}},{key:"handleRightClick",value:function(t){this.enabled&&this.emit("rightClick",ze(t,this.container))}},{key:"handleDoubleClick",value:function(t){if(this.enabled){t.preventDefault(),t.stopPropagation();var n=ze(t,this.container);if(this.emit("doubleClick",n),!n.sigmaDefaultPrevented){var a=this.renderer.getCamera(),o=a.getBoundedRatio(a.getState().ratio/this.settings.doubleClickZoomingRatio);a.animate(this.renderer.getViewportZoomedState(De(t,this.container),o),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(t){if(this.enabled){if(t.button===0){this.startCameraState=this.renderer.getCamera().getState();var n=De(t,this.container),a=n.x,o=n.y;this.lastMouseX=a,this.lastMouseY=o,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",ze(t,this.container))}}},{key:"handleUp",value:function(t){var n=this;if(!(!this.enabled||!this.isMouseDown)){var a=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var o=De(t,this.container),s=o.x,u=o.y,h=a.getState(),c=a.getPreviousState()||{x:0,y:0};this.isMoving?a.animate({x:h.x+this.settings.inertiaRatio*(h.x-c.x),y:h.y+this.settings.inertiaRatio*(h.y-c.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==u)&&a.setState({x:h.x,y:h.y}),this.isMoving=!1,setTimeout(function(){var l=n.draggedEvents>0;n.draggedEvents=0,l&&n.renderer.getSetting("hideEdgesOnMove")&&n.renderer.refresh()},0),this.emit("mouseup",ze(t,this.container))}}},{key:"handleMove",value:function(t){var n=this;if(this.enabled){var a=ze(t,this.container);if(this.emit("mousemovebody",a),(t.target===this.container||t.composedPath()[0]===this.container)&&this.emit("mousemove",a),!a.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){n.movingTimeout=null,n.isMoving=!1},this.settings.dragTimeout);var o=this.renderer.getCamera(),s=De(t,this.container),u=s.x,h=s.y,c=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),l=this.renderer.viewportToFramedGraph({x:u,y:h}),d=c.x-l.x,m=c.y-l.y,E=o.getState(),k=E.x+d,S=E.y+m;o.setState({x:k,y:S}),this.lastMouseX=u,this.lastMouseY=h,t.preventDefault(),t.stopPropagation()}}}},{key:"handleLeave",value:function(t){this.emit("mouseleave",ze(t,this.container))}},{key:"handleEnter",value:function(t){this.emit("mouseenter",ze(t,this.container))}},{key:"handleWheel",value:function(t){var n=this,a=this.renderer.getCamera();if(!(!this.enabled||!a.enabledZooming)){var o=ur(t);if(o){var s=jo(t,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){t.preventDefault(),t.stopPropagation();return}var u=a.getState().ratio,h=o>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,c=a.getBoundedRatio(u*h),l=o>0?1:-1,d=Date.now();u!==c&&(t.preventDefault(),t.stopPropagation(),!(this.currentWheelDirection===l&&this.lastWheelTriggerTime&&d-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(a.animate(this.renderer.getViewportZoomedState(De(t,this.container),c),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){n.currentWheelDirection=0}),this.currentWheelDirection=l,this.lastWheelTriggerTime=d))}}}},{key:"setSettings",value:function(t){this.settings=t}}])}(hr),Vo=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],Ko=Vo.reduce(function(r,i){return F(F({},r),{},T({},i,Ri[i]))},{}),Zo=function(r){function i(e,t){var n;return le(this,i),n=ye(this,i,[e,t]),T(n,"enabled",!0),T(n,"isMoving",!1),T(n,"hasMoved",!1),T(n,"touchMode",0),T(n,"startTouchesPositions",[]),T(n,"lastTouches",[]),T(n,"lastTap",null),T(n,"settings",Ko),n.handleStart=n.handleStart.bind(n),n.handleLeave=n.handleLeave.bind(n),n.handleMove=n.handleMove.bind(n),e.addEventListener("touchstart",n.handleStart,{capture:!1}),e.addEventListener("touchcancel",n.handleLeave,{capture:!1}),document.addEventListener("touchend",n.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",n.handleMove,{capture:!1,passive:!1}),n}return be(i,r),ce(i,[{key:"kill",value:function(){var t=this.container;t.removeEventListener("touchstart",this.handleStart),t.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(t){var n=this;if(this.enabled){t.preventDefault();var a=$t(t.touches);if(this.touchMode=a.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=a.map(function(m){return De(m,n.container)}),this.touchMode===2){var o=at(this.startTouchesPositions,2),s=o[0],u=s.x,h=s.y,c=o[1],l=c.x,d=c.y;this.startTouchesAngle=Math.atan2(d-h,l-u),this.startTouchesDistance=Math.sqrt(Math.pow(l-u,2)+Math.pow(d-h,2))}this.emit("touchdown",yt(t,this.lastTouches,this.container)),this.lastTouches=a,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(t){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(t.cancelable&&t.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(t.touches.length===1){this.handleStart(t),t.preventDefault();break}case 1:if(this.isMoving){var n=this.renderer.getCamera(),a=n.getState(),o=n.getPreviousState()||{x:0,y:0};n.animate({x:a.x+this.settings.inertiaRatio*(a.x-o.x),y:a.y+this.settings.inertiaRatio*(a.y-o.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",yt(t,this.lastTouches,this.container)),!t.touches.length){var s=De(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],h=Math.pow(s.x-u.x,2)+Math.pow(s.y-u.y,2);if(!t.touches.length&&h<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var c=yt(t,this.lastTouches,this.container);if(this.emit("doubletap",c),this.lastTap=null,!c.sigmaDefaultPrevented){var l=this.renderer.getCamera(),d=l.getBoundedRatio(l.getState().ratio/this.settings.doubleClickZoomingRatio);l.animate(this.renderer.getViewportZoomedState(s,d),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var m=yt(t,this.lastTouches,this.container);this.emit("tap",m),this.lastTap={time:Date.now(),position:m.touches[0]||m.previousTouches[0]}}}this.lastTouches=$t(t.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(t){var n=this;if(!(!this.enabled||!this.startTouchesPositions.length)){t.preventDefault();var a=$t(t.touches),o=a.map(function(C){return De(C,n.container)}),s=this.lastTouches;this.lastTouches=a,this.lastTouchesPositions=o;var u=yt(t,s,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=o.some(function(C,p){var j=n.startTouchesPositions[p];return j&&(C.x!==j.x||C.y!==j.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){n.isMoving=!1},this.settings.dragTimeout);var h=this.renderer.getCamera(),c=this.startCameraState,l=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var d=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),m=d.x,E=d.y,k=this.renderer.viewportToFramedGraph(o[0]),S=k.x,x=k.y;h.setState({x:c.x+m-S,y:c.y+E-x});break}case 2:{var R={x:.5,y:.5,angle:0,ratio:1},b=o[0],_=b.x,G=b.y,z=o[1],w=z.x,D=z.y,f=Math.atan2(D-G,w-_)-this.startTouchesAngle,W=Math.hypot(D-G,w-_)/this.startTouchesDistance,Q=h.getBoundedRatio(c.ratio/W);R.ratio=Q,R.angle=c.angle+f;var B=this.getDimensions(),ie=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),O=Math.min(B.width,B.height)-2*l,te=O/B.width,we=O/B.height,M=Q/O,g=_-O/2/te,de=G-O/2/we,ue=[g*Math.cos(-R.angle)-de*Math.sin(-R.angle),de*Math.cos(-R.angle)+g*Math.sin(-R.angle)];g=ue[0],de=ue[1],R.x=ie.x-g*M,R.y=ie.y+de*M,h.setState(R);break}}}}}},{key:"setSettings",value:function(t){this.settings=t}}])}(hr);function qo(r){if(Array.isArray(r))return si(r)}function Yo(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function Xo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
312
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tn(r){return qo(r)||Yo(r)||Zn(r)||Xo()}function Qo(r,i){if(r==null)return{};var e={};for(var t in r)if({}.hasOwnProperty.call(r,t)){if(i.indexOf(t)!==-1)continue;e[t]=r[t]}return e}function ni(r,i){if(r==null)return{};var e,t,n=Qo(r,i);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(t=0;t<a.length;t++)e=a[t],i.indexOf(e)===-1&&{}.propertyIsEnumerable.call(r,e)&&(n[e]=r[e])}return n}var nn=function(){function r(i,e){le(this,r),this.key=i,this.size=e}return ce(r,null,[{key:"compare",value:function(e,t){return e.size>t.size?-1:e.size<t.size||e.key>t.key?1:-1}}])}(),rn=function(){function r(){le(this,r),T(this,"width",0),T(this,"height",0),T(this,"cellSize",0),T(this,"columns",0),T(this,"rows",0),T(this,"cells",{})}return ce(r,[{key:"resizeAndClear",value:function(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={}}},{key:"getIndex",value:function(e){var t=Math.floor(e.x/this.cellSize),n=Math.floor(e.y/this.cellSize);return n*this.columns+t}},{key:"add",value:function(e,t,n){var a=new nn(e,t),o=this.getIndex(n),s=this.cells[o];s||(s=[],this.cells[o]=s),s.push(a)}},{key:"organize",value:function(){for(var e in this.cells){var t=this.cells[e];t.sort(nn.compare)}}},{key:"getLabelsToDisplay",value:function(e,t){var n=this.cellSize*this.cellSize,a=n/e/e,o=a*t/n,s=Math.ceil(o),u=[];for(var h in this.cells)for(var c=this.cells[h],l=0;l<Math.min(s,c.length);l++)u.push(c[l].key);return u}}])}();function Jo(r){var i=r.graph,e=r.hoveredNode,t=r.highlightedNodes,n=r.displayedNodeLabels,a=[];return i.forEachEdge(function(o,s,u,h){(u===e||h===e||t.has(u)||t.has(h)||n.has(u)&&n.has(h))&&a.push(o)}),a}var an=150,on=50,Ue=Object.prototype.hasOwnProperty;function es(r,i,e){if(!Ue.call(e,"x")||!Ue.call(e,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(i,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return e.color||(e.color=r.defaultNodeColor),!e.label&&e.label!==""&&(e.label=null),e.label!==void 0&&e.label!==null?e.label=""+e.label:e.label=null,e.size||(e.size=2),Ue.call(e,"hidden")||(e.hidden=!1),Ue.call(e,"highlighted")||(e.highlighted=!1),Ue.call(e,"forceLabel")||(e.forceLabel=!1),(!e.type||e.type==="")&&(e.type=r.defaultNodeType),e.zIndex||(e.zIndex=0),e}function ts(r,i,e){return e.color||(e.color=r.defaultEdgeColor),e.label||(e.label=""),e.size||(e.size=.5),Ue.call(e,"hidden")||(e.hidden=!1),Ue.call(e,"forceLabel")||(e.forceLabel=!1),(!e.type||e.type==="")&&(e.type=r.defaultEdgeType),e.zIndex||(e.zIndex=0),e}var is=function(r){function i(e,t){var n,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(le(this,i),n=ye(this,i),T(n,"elements",{}),T(n,"canvasContexts",{}),T(n,"webGLContexts",{}),T(n,"pickingLayers",new Set),T(n,"textures",{}),T(n,"frameBuffers",{}),T(n,"activeListeners",{}),T(n,"labelGrid",new rn),T(n,"nodeDataCache",{}),T(n,"edgeDataCache",{}),T(n,"nodeProgramIndex",{}),T(n,"edgeProgramIndex",{}),T(n,"nodesWithForcedLabels",new Set),T(n,"edgesWithForcedLabels",new Set),T(n,"nodeExtent",{x:[0,1],y:[0,1]}),T(n,"nodeZExtent",[1/0,-1/0]),T(n,"edgeZExtent",[1/0,-1/0]),T(n,"matrix",Ae()),T(n,"invMatrix",Ae()),T(n,"correctionRatio",1),T(n,"customBBox",null),T(n,"normalizationFunction",Qi({x:[0,1],y:[0,1]})),T(n,"graphToViewportRatio",1),T(n,"itemIDsIndex",{}),T(n,"nodeIndices",{}),T(n,"edgeIndices",{}),T(n,"width",0),T(n,"height",0),T(n,"pixelRatio",Yi()),T(n,"pickingDownSizingRatio",2*n.pixelRatio),T(n,"displayedNodeLabels",new Set),T(n,"displayedEdgeLabels",new Set),T(n,"highlightedNodes",new Set),T(n,"hoveredNode",null),T(n,"hoveredEdge",null),T(n,"renderFrame",null),T(n,"renderHighlightedNodesFrame",null),T(n,"needToProcess",!1),T(n,"checkEdgesEventsFrame",null),T(n,"nodePrograms",{}),T(n,"nodeHoverPrograms",{}),T(n,"edgePrograms",{}),n.settings=No(a),ii(n.settings),Io(e),!(t instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");n.graph=e,n.container=t,n.createWebGLContext("edges",{picking:a.enableEdgeEvents}),n.createCanvasContext("edgeLabels"),n.createWebGLContext("nodes",{picking:!0}),n.createCanvasContext("labels"),n.createCanvasContext("hovers"),n.createWebGLContext("hoverNodes"),n.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),n.resize();for(var o in n.settings.nodeProgramClasses)n.registerNodeProgram(o,n.settings.nodeProgramClasses[o],n.settings.nodeHoverProgramClasses[o]);for(var s in n.settings.edgeProgramClasses)n.registerEdgeProgram(s,n.settings.edgeProgramClasses[s]);return n.camera=new en,n.bindCameraHandlers(),n.mouseCaptor=new Mo(n.elements.mouse,n),n.mouseCaptor.setSettings(n.settings),n.touchCaptor=new Zo(n.elements.mouse,n),n.touchCaptor.setSettings(n.settings),n.bindEventHandlers(),n.bindGraphHandlers(),n.handleSettingsUpdate(),n.refresh(),n}return be(i,r),ce(i,[{key:"registerNodeProgram",value:function(t,n,a){return this.nodePrograms[t]&&this.nodePrograms[t].kill(),this.nodeHoverPrograms[t]&&this.nodeHoverPrograms[t].kill(),this.nodePrograms[t]=new n(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[t]=new(a||n)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(t,n){return this.edgePrograms[t]&&this.edgePrograms[t].kill(),this.edgePrograms[t]=new n(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(t){if(this.nodePrograms[t]){var n=this.nodePrograms,a=n[t],o=ni(n,[t].map(wt));a.kill(),this.nodePrograms=o}if(this.nodeHoverPrograms[t]){var s=this.nodeHoverPrograms,u=s[t],h=ni(s,[t].map(wt));u.kill(),this.nodePrograms=h}return this}},{key:"unregisterEdgeProgram",value:function(t){if(this.edgePrograms[t]){var n=this.edgePrograms,a=n[t],o=ni(n,[t].map(wt));a.kill(),this.edgePrograms=o}return this}},{key:"resetWebGLTexture",value:function(t){var n=this.webGLContexts[t],a=this.frameBuffers[t],o=this.textures[t];o&&n.deleteTexture(o);var s=n.createTexture();return n.bindFramebuffer(n.FRAMEBUFFER,a),n.bindTexture(n.TEXTURE_2D,s),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,this.width,this.height,0,n.RGBA,n.UNSIGNED_BYTE,null),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,s,0),this.textures[t]=s,this}},{key:"bindCameraHandlers",value:function(){var t=this;return this.activeListeners.camera=function(){t.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(t){var n=t.x,a=t.y,o=Ni(this.webGLContexts.nodes,this.frameBuffers.nodes,n,a,this.pixelRatio,this.pickingDownSizingRatio),s=$i.apply(void 0,tn(o)),u=this.itemIDsIndex[s];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var t=this;this.activeListeners.handleResize=function(){t.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(a){var o=vt(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}},u=t.getNodeAtPosition(o);if(u&&t.hoveredNode!==u&&!t.nodeDataCache[u].hidden){t.hoveredNode&&t.emit("leaveNode",F(F({},s),{},{node:t.hoveredNode})),t.hoveredNode=u,t.emit("enterNode",F(F({},s),{},{node:u})),t.scheduleHighlightedNodesRender();return}if(t.hoveredNode&&t.getNodeAtPosition(o)!==t.hoveredNode){var h=t.hoveredNode;t.hoveredNode=null,t.emit("leaveNode",F(F({},s),{},{node:h})),t.scheduleHighlightedNodesRender();return}if(t.settings.enableEdgeEvents){var c=t.hoveredNode?null:t.getEdgeAtPoint(s.event.x,s.event.y);c!==t.hoveredEdge&&(t.hoveredEdge&&t.emit("leaveEdge",F(F({},s),{},{edge:t.hoveredEdge})),c&&t.emit("enterEdge",F(F({},s),{},{edge:c})),t.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(a){var o=vt(a);t.emit("moveBody",{event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(a){var o=vt(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};t.hoveredNode&&(t.emit("leaveNode",F(F({},s),{},{node:t.hoveredNode})),t.scheduleHighlightedNodesRender()),t.settings.enableEdgeEvents&&t.hoveredEdge&&(t.emit("leaveEdge",F(F({},s),{},{edge:t.hoveredEdge})),t.scheduleHighlightedNodesRender()),t.emit("leaveStage",F({},s))},this.activeListeners.handleEnter=function(a){var o=vt(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};t.emit("enterStage",F({},s))};var n=function(o){return function(s){var u=vt(s),h={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},c=t.getNodeAtPosition(u);if(c)return t.emit("".concat(o,"Node"),F(F({},h),{},{node:c}));if(t.settings.enableEdgeEvents){var l=t.getEdgeAtPoint(u.x,u.y);if(l)return t.emit("".concat(o,"Edge"),F(F({},h),{},{edge:l}))}return t.emit("".concat(o,"Stage"),h)}};return this.activeListeners.handleClick=n("click"),this.activeListeners.handleRightClick=n("rightClick"),this.activeListeners.handleDoubleClick=n("doubleClick"),this.activeListeners.handleWheel=n("wheel"),this.activeListeners.handleDown=n("down"),this.activeListeners.handleUp=n("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}},{key:"bindGraphHandlers",value:function(){var t=this,n=this.graph,a=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(o){var s,u=(s=o.hints)===null||s===void 0?void 0:s.attributes;t.graph.forEachNode(function(c){return t.updateNode(c)});var h=!u||u.some(function(c){return a.has(c)});t.refresh({partialGraph:{nodes:n.nodes()},skipIndexation:!h,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(o){var s,u=(s=o.hints)===null||s===void 0?void 0:s.attributes;t.graph.forEachEdge(function(c){return t.updateEdge(c)});var h=u&&["zIndex","type"].some(function(c){return u==null?void 0:u.includes(c)});t.refresh({partialGraph:{edges:n.edges()},skipIndexation:!h,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(o){var s=o.key;t.addNode(s),t.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(o){var s=o.key;t.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(o){var s=o.key;t.removeNode(s),t.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(o){var s=o.key;t.addEdge(s),t.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(o){var s=o.key;t.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(o){var s=o.key;t.removeEdge(s),t.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){t.clearEdgeState(),t.clearEdgeIndices(),t.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){t.clearEdgeState(),t.clearNodeState(),t.clearEdgeIndices(),t.clearNodeIndices(),t.refresh({schedule:!0})},n.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),n.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),n.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),n.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),n.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),n.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),n.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),n.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),n.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),n.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var t=this.graph;t.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),t.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),t.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),t.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),t.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),t.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),t.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),t.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),t.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),t.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(t,n){var a=Ni(this.webGLContexts.edges,this.frameBuffers.edges,t,n,this.pixelRatio,this.pickingDownSizingRatio),o=$i.apply(void 0,tn(a)),s=this.itemIDsIndex[o];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var t=this;this.emit("beforeProcess");var n=this.graph,a=this.settings,o=this.getDimensions();if(this.nodeExtent=Oo(this.graph),!this.settings.autoRescale){var s=o.width,u=o.height,h=this.nodeExtent,c=h.x,l=h.y;this.nodeExtent={x:[(c[0]+c[1])/2-s/2,(c[0]+c[1])/2+s/2],y:[(l[0]+l[1])/2-u/2,(l[0]+l[1])/2+u/2]}}this.normalizationFunction=Qi(this.customBBox||this.nodeExtent);var d=new en,m=mt(d.getState(),o,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(o,a.labelGridCellSize);for(var E={},k={},S={},x={},R=1,b=n.nodes(),_=0,G=b.length;_<G;_++){var z=b[_],w=this.nodeDataCache[z],D=n.getNodeAttributes(z);w.x=D.x,w.y=D.y,this.normalizationFunction.applyTo(w),typeof w.label=="string"&&!w.hidden&&this.labelGrid.add(z,w.size,this.framedGraphToViewport(w,{matrix:m})),E[w.type]=(E[w.type]||0)+1}this.labelGrid.organize();for(var f in this.nodePrograms){if(!Ue.call(this.nodePrograms,f))throw new Error('Sigma: could not find a suitable program for node type "'.concat(f,'"!'));this.nodePrograms[f].reallocate(E[f]||0),E[f]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(b=Xi(this.nodeZExtent,function(Ee){return t.nodeDataCache[Ee].zIndex},b));for(var W=0,Q=b.length;W<Q;W++){var B=b[W];k[B]=R,x[k[B]]={type:"node",id:B},R++;var ie=this.nodeDataCache[B];this.addNodeToProgram(B,k[B],E[ie.type]++)}for(var O={},te=n.edges(),we=0,M=te.length;we<M;we++){var g=te[we],de=this.edgeDataCache[g];O[de.type]=(O[de.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(te=Xi(this.edgeZExtent,function(Ee){return t.edgeDataCache[Ee].zIndex},te));for(var ue in this.edgePrograms){if(!Ue.call(this.edgePrograms,ue))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ue,'"!'));this.edgePrograms[ue].reallocate(O[ue]||0),O[ue]=0}for(var C=0,p=te.length;C<p;C++){var j=te[C];S[j]=R,x[S[j]]={type:"edge",id:j},R++;var J=this.edgeDataCache[j];this.addEdgeToProgram(j,S[j],O[J.type]++)}return this.itemIDsIndex=x,this.nodeIndices=k,this.edgeIndices=S,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(t){var n=this,a=this.settings;if(this.camera.minRatio=a.minCameraRatio,this.camera.maxRatio=a.maxCameraRatio,this.camera.enabledZooming=a.enableCameraZooming,this.camera.enabledPanning=a.enableCameraPanning,this.camera.enabledRotation=a.enableCameraRotation,a.cameraPanBoundaries?this.camera.clean=function(c){return n.cleanCameraState(c,a.cameraPanBoundaries&&li(a.cameraPanBoundaries)==="object"?a.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),t){if(t.edgeProgramClasses!==a.edgeProgramClasses){for(var o in a.edgeProgramClasses)a.edgeProgramClasses[o]!==t.edgeProgramClasses[o]&&this.registerEdgeProgram(o,a.edgeProgramClasses[o]);for(var s in t.edgeProgramClasses)a.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(t.nodeProgramClasses!==a.nodeProgramClasses||t.nodeHoverProgramClasses!==a.nodeHoverProgramClasses){for(var u in a.nodeProgramClasses)(a.nodeProgramClasses[u]!==t.nodeProgramClasses[u]||a.nodeHoverProgramClasses[u]!==t.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,a.nodeProgramClasses[u],a.nodeHoverProgramClasses[u]);for(var h in t.nodeProgramClasses)a.nodeProgramClasses[h]||this.unregisterNodeProgram(h)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.tolerance,o=a===void 0?0:a,s=n.boundaries,u=F({},t),h=s||this.nodeExtent,c=at(h.x,2),l=c[0],d=c[1],m=at(h.y,2),E=m[0],k=m[1],S=[this.graphToViewport({x:l,y:E},{cameraState:t}),this.graphToViewport({x:d,y:E},{cameraState:t}),this.graphToViewport({x:l,y:k},{cameraState:t}),this.graphToViewport({x:d,y:k},{cameraState:t})],x=1/0,R=-1/0,b=1/0,_=-1/0;S.forEach(function(O){var te=O.x,we=O.y;x=Math.min(x,te),R=Math.max(R,te),b=Math.min(b,we),_=Math.max(_,we)});var G=R-x,z=_-b,w=this.getDimensions(),D=w.width,f=w.height,W=0,Q=0;if(G>=D?R<D-o?W=R-(D-o):x>o&&(W=x-o):R>D+o?W=R-(D+o):x<-o&&(W=x+o),z>=f?_<f-o?Q=_-(f-o):b>o&&(Q=b-o):_>f+o?Q=_-(f+o):b<-o&&(Q=b+o),W||Q){var B=this.viewportToFramedGraph({x:0,y:0},{cameraState:t}),ie=this.viewportToFramedGraph({x:W,y:Q},{cameraState:t});W=ie.x-B.x,Q=ie.y-B.y,u.x+=W,u.y+=Q}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var t=this.camera.getState(),n=this.labelGrid.getLabelsToDisplay(t.ratio,this.settings.labelDensity);Ji(n,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var a=this.canvasContexts.labels,o=0,s=n.length;o<s;o++){var u=n[o],h=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!h.hidden){var c=this.framedGraphToViewport(h),l=c.x,d=c.y,m=this.scaleSize(h.size);if(!(!h.forceLabel&&m<this.settings.labelRenderedSizeThreshold)&&!(l<-an||l>this.width+an||d<-on||d>this.height+on)){this.displayedNodeLabels.add(u);var E=this.settings.defaultDrawNodeLabel,k=this.nodePrograms[h.type],S=(k==null?void 0:k.drawLabel)||E;S(a,F(F({key:u},h),{},{size:m,x:l,y:d}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var t=this.canvasContexts.edgeLabels;t.clearRect(0,0,this.width,this.height);var n=Jo({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Ji(n,this.edgesWithForcedLabels);for(var a=new Set,o=0,s=n.length;o<s;o++){var u=n[o],h=this.graph.extremities(u),c=this.nodeDataCache[h[0]],l=this.nodeDataCache[h[1]],d=this.edgeDataCache[u];if(!a.has(u)&&!(d.hidden||c.hidden||l.hidden)){var m=this.settings.defaultDrawEdgeLabel,E=this.edgePrograms[d.type],k=(E==null?void 0:E.drawLabel)||m;k(t,F(F({key:u},d),{},{size:this.scaleSize(d.size)}),F(F(F({key:h[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),F(F(F({key:h[1]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),this.settings),a.add(u)}}return this.displayedEdgeLabels=a,this}},{key:"renderHighlightedNodes",value:function(){var t=this,n=this.canvasContexts.hovers;n.clearRect(0,0,this.width,this.height);var a=function(m){var E=t.nodeDataCache[m],k=t.framedGraphToViewport(E),S=k.x,x=k.y,R=t.scaleSize(E.size),b=t.settings.defaultDrawNodeHover,_=t.nodePrograms[E.type],G=(_==null?void 0:_.drawHover)||b;G(n,F(F({key:m},E),{},{size:R,x:S,y:x}),t.settings)},o=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&o.push(this.hoveredNode),this.highlightedNodes.forEach(function(d){d!==t.hoveredNode&&o.push(d)}),o.forEach(function(d){return a(d)});var s={};o.forEach(function(d){var m=t.nodeDataCache[d].type;s[m]=(s[m]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(s[u]||0),s[u]=0;o.forEach(function(d){var m=t.nodeDataCache[d];t.nodeHoverPrograms[m.type].process(0,s[m.type]++,m)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var h=this.getRenderParams();for(var c in this.nodeHoverPrograms){var l=this.nodeHoverPrograms[c];l.render(h)}}},{key:"scheduleHighlightedNodesRender",value:function(){var t=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){t.renderHighlightedNodesFrame=null,t.renderHighlightedNodes(),t.renderEdgeLabels()}))}},{key:"render",value:function(){var t=this;this.emit("beforeRender");var n=function(){return t.emit("afterRender"),t};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(S){return t.resetWebGLTexture(S)}),!this.graph.order)return n();var a=this.mouseCaptor,o=this.camera.isAnimated()||a.isMoving||a.draggedEvents||a.currentWheelDirection,s=this.camera.getState(),u=this.getDimensions(),h=this.getGraphDimensions(),c=this.getStagePadding();this.matrix=mt(s,u,h,c),this.invMatrix=mt(s,u,h,c,!0),this.correctionRatio=Po(this.matrix,s,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var l=this.getRenderParams();for(var d in this.nodePrograms){var m=this.nodePrograms[d];m.render(l)}if(!this.settings.hideEdgesOnMove||!o)for(var E in this.edgePrograms){var k=this.edgePrograms[E];k.render(l)}return this.settings.hideLabelsOnMove&&o||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),n()}},{key:"addNode",value:function(t){var n=Object.assign({},this.graph.getNodeAttributes(t));this.settings.nodeReducer&&(n=this.settings.nodeReducer(t,n));var a=es(this.settings,t,n);this.nodeDataCache[t]=a,this.nodesWithForcedLabels.delete(t),a.forceLabel&&!a.hidden&&this.nodesWithForcedLabels.add(t),this.highlightedNodes.delete(t),a.highlighted&&!a.hidden&&this.highlightedNodes.add(t),this.settings.zIndex&&(a.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=a.zIndex),a.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=a.zIndex))}},{key:"updateNode",value:function(t){this.addNode(t);var n=this.nodeDataCache[t];this.normalizationFunction.applyTo(n)}},{key:"removeNode",value:function(t){delete this.nodeDataCache[t],delete this.nodeProgramIndex[t],this.highlightedNodes.delete(t),this.hoveredNode===t&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(t)}},{key:"addEdge",value:function(t){var n=Object.assign({},this.graph.getEdgeAttributes(t));this.settings.edgeReducer&&(n=this.settings.edgeReducer(t,n));var a=ts(this.settings,t,n);this.edgeDataCache[t]=a,this.edgesWithForcedLabels.delete(t),a.forceLabel&&!a.hidden&&this.edgesWithForcedLabels.add(t),this.settings.zIndex&&(a.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=a.zIndex),a.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=a.zIndex))}},{key:"updateEdge",value:function(t){this.addEdge(t)}},{key:"removeEdge",value:function(t){delete this.edgeDataCache[t],delete this.edgeProgramIndex[t],this.hoveredEdge===t&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(t)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new rn,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(t,n,a){var o=this.nodeDataCache[t],s=this.nodePrograms[o.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(o.type,'"!'));s.process(n,a,o),this.nodeProgramIndex[t]=a}},{key:"addEdgeToProgram",value:function(t,n,a){var o=this.edgeDataCache[t],s=this.edgePrograms[o.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(o.type,'"!'));var u=this.graph.extremities(t),h=this.nodeDataCache[u[0]],c=this.nodeDataCache[u[1]];s.process(n,a,h,c,o),this.edgeProgramIndex[t]=a}},{key:"getRenderParams",value:function(){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}}},{key:"getStagePadding",value:function(){var t=this.settings,n=t.stagePadding,a=t.autoRescale;return a&&n||0}},{key:"createLayer",value:function(t,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[t])throw new Error('Sigma: a layer named "'.concat(t,'" already exists'));var o=zo(n,{position:"absolute"},{class:"sigma-".concat(t)});return a.style&&Object.assign(o.style,a.style),this.elements[t]=o,"beforeLayer"in a&&a.beforeLayer?this.elements[a.beforeLayer].before(o):"afterLayer"in a&&a.afterLayer?this.elements[a.afterLayer].after(o):this.container.appendChild(o),o}},{key:"createCanvas",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(t,"canvas",n)}},{key:"createCanvasContext",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=this.createCanvas(t,n),o={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[t]=a.getContext("2d",o),this}},{key:"createWebGLContext",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=(n==null?void 0:n.canvas)||this.createCanvas(t,n);n.hidden&&a.remove();var o=F({preserveDrawingBuffer:!1,antialias:!1},n),s;s=a.getContext("webgl2",o),s||(s=a.getContext("webgl",o)),s||(s=a.getContext("experimental-webgl",o));var u=s;if(this.webGLContexts[t]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),n.picking){this.pickingLayers.add(t);var h=u.createFramebuffer();if(!h)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(t));this.frameBuffers[t]=h}return u}},{key:"killLayer",value:function(t){var n=this.elements[t];if(!n)throw new Error("Sigma: cannot kill layer ".concat(t,", which does not exist"));if(this.webGLContexts[t]){var a,o=this.webGLContexts[t];(a=o.getExtension("WEBGL_lose_context"))===null||a===void 0||a.loseContext(),delete this.webGLContexts[t]}else this.canvasContexts[t]&&delete this.canvasContexts[t];return n.remove(),delete this.elements[t],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(t){this.unbindCameraHandlers(),this.camera=t,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(t){t!==this.graph&&(this.hoveredNode&&!t.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!t.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=t,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var t=this.customBBox||this.nodeExtent;return{width:t.x[1]-t.x[0]||1,height:t.y[1]-t.y[0]||1}}},{key:"getNodeDisplayData",value:function(t){var n=this.nodeDataCache[t];return n?Object.assign({},n):void 0}},{key:"getEdgeDisplayData",value:function(t){var n=this.edgeDataCache[t];return n?Object.assign({},n):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return F({},this.settings)}},{key:"getSetting",value:function(t){return this.settings[t]}},{key:"setSetting",value:function(t,n){var a=F({},this.settings);return this.settings[t]=n,ii(this.settings),this.handleSettingsUpdate(a),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(t,n){return this.setSetting(t,n(this.settings[t])),this}},{key:"setSettings",value:function(t){var n=F({},this.settings);return this.settings=F(F({},this.settings),t),ii(this.settings),this.handleSettingsUpdate(n),this.scheduleRefresh(),this}},{key:"resize",value:function(t){var n=this.width,a=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=Yi(),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(!t&&n===this.width&&a===this.height)return this;for(var o in this.elements){var s=this.elements[o];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var u in this.canvasContexts)this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[u].scale(this.pixelRatio,this.pixelRatio);for(var h in this.webGLContexts){this.elements[h].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[h].setAttribute("height",this.height*this.pixelRatio+"px");var c=this.webGLContexts[h];if(c.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(h)){var l=this.textures[h];l&&c.deleteTexture(l)}}return this.emit("resize"),this}},{key:"clear",value:function(){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}},{key:"refresh",value:function(t){var n=this,a=(t==null?void 0:t.skipIndexation)!==void 0?t==null?void 0:t.skipIndexation:!1,o=(t==null?void 0:t.schedule)!==void 0?t.schedule:!1,s=!t||!t.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(_){return n.addNode(_)}),this.graph.forEachEdge(function(_){return n.addEdge(_)});else{for(var u,h,c=((u=t.partialGraph)===null||u===void 0?void 0:u.nodes)||[],l=0,d=(c==null?void 0:c.length)||0;l<d;l++){var m=c[l];if(this.updateNode(m),a){var E=this.nodeProgramIndex[m];if(E===void 0)throw new Error('Sigma: node "'.concat(m,`" can't be repaint`));this.addNodeToProgram(m,this.nodeIndices[m],E)}}for(var k=(t==null||(h=t.partialGraph)===null||h===void 0?void 0:h.edges)||[],S=0,x=k.length;S<x;S++){var R=k[S];if(this.updateEdge(R),a){var b=this.edgeProgramIndex[R];if(b===void 0)throw new Error('Sigma: edge "'.concat(R,`" can't be repaint`));this.addEdgeToProgram(R,this.edgeIndices[R],b)}}}return(s||!a)&&(this.needToProcess=!0),o?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var t=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){t.render()})),this}},{key:"scheduleRefresh",value:function(t){return this.refresh(F(F({},t),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(t,n){var a=this.camera.getState(),o=a.ratio,s=a.angle,u=a.x,h=a.y,c=this.settings,l=c.minCameraRatio,d=c.maxCameraRatio;typeof d=="number"&&(n=Math.min(n,d)),typeof l=="number"&&(n=Math.max(n,l));var m=n/o,E={x:this.width/2,y:this.height/2},k=this.viewportToFramedGraph(t),S=this.viewportToFramedGraph(E);return{angle:s,x:(k.x-S.x)*(1-m)+u,y:(k.y-S.y)*(1-m)+h,ratio:n}}},{key:"viewRectangle",value:function(){var t=this.viewportToFramedGraph({x:0,y:0}),n=this.viewportToFramedGraph({x:this.width,y:0}),a=this.viewportToFramedGraph({x:0,y:this.height});return{x1:t.x,y1:t.y,x2:n.x,y2:n.y,height:n.y-a.y}}},{key:"framedGraphToViewport",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!n.cameraState||!!n.viewportDimensions||!!n.graphDimensions,o=n.matrix?n.matrix:a?mt(n.cameraState||this.camera.getState(),n.viewportDimensions||this.getDimensions(),n.graphDimensions||this.getGraphDimensions(),n.padding||this.getStagePadding()):this.matrix,s=hi(o,t);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!n.cameraState||!!n.viewportDimensions||!n.graphDimensions,o=n.matrix?n.matrix:a?mt(n.cameraState||this.camera.getState(),n.viewportDimensions||this.getDimensions(),n.graphDimensions||this.getGraphDimensions(),n.padding||this.getStagePadding(),!0):this.invMatrix,s=hi(o,{x:t.x/this.width*2-1,y:1-t.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(t,n))}},{key:"graphToViewport",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(t),n)}},{key:"getGraphToViewportRatio",value:function(){var t={x:0,y:0},n={x:1,y:1},a=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),o=this.graphToViewport(t),s=this.graphToViewport(n),u=Math.sqrt(Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2));return u/a}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(t){return this.customBBox=t,this.scheduleRender(),this}},{key:"kill",value:function(){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);for(var t=this.container;t.firstChild;)t.removeChild(t.firstChild);for(var n in this.nodePrograms)this.nodePrograms[n].kill();for(var a in this.nodeHoverPrograms)this.nodeHoverPrograms[a].kill();for(var o in this.edgePrograms)this.edgePrograms[o].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return t/this.settings.zoomToSizeRatioFunction(n)*(this.getSetting("itemSizesReference")==="positions"?n*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var t={};for(var n in this.elements)this.elements[n]instanceof HTMLCanvasElement&&(t[n]=this.elements[n]);return t}}])}(Ti);const lr=N.createContext(null),ns=lr.Provider;function ki(){const r=N.useContext(lr);if(r==null)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return r}function Ht(){return ki().sigma}function cr(){const{sigma:r}=ki();return N.useCallback(i=>{r&&Object.keys(i).forEach(e=>{r.setSetting(e,i[e])})},[r])}function Wt(r){return new Set(Object.keys(r))}const sn=Wt({clickNode:!0,rightClickNode:!0,downNode:!0,enterNode:!0,leaveNode:!0,doubleClickNode:!0,wheelNode:!0,clickEdge:!0,rightClickEdge:!0,downEdge:!0,enterEdge:!0,leaveEdge:!0,doubleClickEdge:!0,wheelEdge:!0,clickStage:!0,rightClickStage:!0,downStage:!0,doubleClickStage:!0,wheelStage:!0,beforeRender:!0,afterRender:!0,kill:!0,upStage:!0,upEdge:!0,upNode:!0,enterStage:!0,leaveStage:!0,resize:!0,afterClear:!0,afterProcess:!0,beforeClear:!0,beforeProcess:!0,moveBody:!0}),un=Wt({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),hn=Wt({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),ln=Wt({updated:!0});function rs(){const r=Ht(),i=cr(),[e,t]=N.useState({});return N.useEffect(()=>{if(!r||!e)return;const n=e,a=Object.keys(n);return a.forEach(o=>{const s=n[o];sn.has(o)&&r.on(o,s),un.has(o)&&r.getMouseCaptor().on(o,s),hn.has(o)&&r.getTouchCaptor().on(o,s),ln.has(o)&&r.getCamera().on(o,s)}),()=>{r&&a.forEach(o=>{const s=n[o];sn.has(o)&&r.off(o,s),un.has(o)&&r.getMouseCaptor().off(o,s),hn.has(o)&&r.getTouchCaptor().off(o,s),ln.has(o)&&r.getCamera().off(o,s)})}},[r,e,i]),t}function Mt(r,i){if(r===i)return!0;if(typeof r=="object"&&r!=null&&typeof i=="object"&&i!=null){if(Object.keys(r).length!=Object.keys(i).length)return!1;for(const e in r)if(!Object.hasOwn(i,e)||!Mt(r[e],i[e]))return!1;return!0}return!1}function as(r){const i=Ht(),[e,t]=N.useState(r||{});N.useEffect(()=>{t(h=>Mt(h,r||{})?h:r||{})},[r]);const n=N.useCallback(h=>{i.getCamera().animatedZoom(Object.assign(Object.assign({},e),h))},[i,e]),a=N.useCallback(h=>{i.getCamera().animatedUnzoom(Object.assign(Object.assign({},e),h))},[i,e]),o=N.useCallback(h=>{i.getCamera().animatedReset(Object.assign(Object.assign({},e),h))},[i,e]),s=N.useCallback((h,c)=>{i.getCamera().animate(h,Object.assign(Object.assign({},e),c))},[i,e]),u=N.useCallback((h,c)=>{const l=i.getNodeDisplayData(h);l?i.getCamera().animate(l,Object.assign(Object.assign({},e),c)):console.warn(`Node ${h} not found`)},[i,e]);return{zoomIn:n,zoomOut:a,reset:o,goto:s,gotoNode:u}}function os(r){const i=ki(),[e,t]=N.useState(!1),[n,a]=N.useState(r||i.container),o=N.useCallback(()=>t(s=>!s),[]);return N.useEffect(()=>(document.addEventListener("fullscreenchange",o),()=>document.removeEventListener("fullscreenchange",o)),[o]),N.useEffect(()=>{a(r||i.container)},[r,i.container]),{toggle:N.useCallback(()=>{var s;s=n,document.fullscreenElement!==s?s.requestFullscreen():document.exitFullscreen&&document.exitFullscreen()},[n]),isFullScreen:e}}const ss=N.forwardRef(({graph:r,id:i,className:e,style:t,settings:n={},children:a},o)=>{const s=N.useRef(null),u=N.useRef(null),h={className:`react-sigma ${e||""}`,id:i,style:t},[c,l]=N.useState(null),[d,m]=N.useState(n);N.useEffect(()=>{m(S=>Mt(S,n)?S:n)},[n]),N.useEffect(()=>{let S=null;if(u.current!==null){let x=new X;r&&(x=typeof r=="function"?new r:r),S=new is(x,u.current,d),l(R=>{let b=null;return R&&(b=R.getCamera().getState()),b&&S.getCamera().setState(b),S})}return()=>{S&&S.kill()}},[u,r,d]),N.useImperativeHandle(o,()=>c,[c]);const E=N.useMemo(()=>c&&s.current?{sigma:c,container:s.current}:null,[c,s]),k=E!==null?H.createElement(ns,{value:E},a):null;return H.createElement("div",Object.assign({},h,{ref:s}),H.createElement("div",{className:"sigma-container",ref:u}),k)}),us=({id:r,className:i,style:e,children:t,position:n="bottom-left"})=>{const a={className:`react-sigma-controls ${i||""} ${n}`,id:r,style:e};return H.createElement("div",Object.assign({},a),t)};var cn;function ci(){return ci=Object.assign?Object.assign.bind():function(r){for(var i=1;i<arguments.length;i++){var e=arguments[i];for(var t in e)({}).hasOwnProperty.call(e,t)&&(r[t]=e[t])}return r},ci.apply(null,arguments)}var dn,hs=function(r){return N.createElement("svg",ci({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"dot-circle-regular_svg__svg-inline--fa dot-circle-regular_svg__fa-dot-circle dot-circle-regular_svg__fa-w-16","data-icon":"dot-circle","data-prefix":"far",viewBox:"0 0 512 512",width:"1em",height:"1em"},r),cn||(cn=N.createElement("path",{fill:"currentColor",d:"M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8m0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80"})))};function di(){return di=Object.assign?Object.assign.bind():function(r){for(var i=1;i<arguments.length;i++){var e=arguments[i];for(var t in e)({}).hasOwnProperty.call(e,t)&&(r[t]=e[t])}return r},di.apply(null,arguments)}var fn,ls=function(r){return N.createElement("svg",di({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"minus-solid_svg__svg-inline--fa minus-solid_svg__fa-minus minus-solid_svg__fa-w-14","data-icon":"minus","data-prefix":"fas",viewBox:"0 0 448 512",width:"1em",height:"1em"},r),dn||(dn=N.createElement("path",{fill:"currentColor",d:"M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32"})))};function fi(){return fi=Object.assign?Object.assign.bind():function(r){for(var i=1;i<arguments.length;i++){var e=arguments[i];for(var t in e)({}).hasOwnProperty.call(e,t)&&(r[t]=e[t])}return r},fi.apply(null,arguments)}var cs=function(r){return N.createElement("svg",fi({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"plus-solid_svg__svg-inline--fa plus-solid_svg__fa-plus plus-solid_svg__fa-w-14","data-icon":"plus","data-prefix":"fas",viewBox:"0 0 448 512",width:"1em",height:"1em"},r),fn||(fn=N.createElement("path",{fill:"currentColor",d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32"})))};const ds=({className:r,style:i,animationDuration:e=200,children:t,labels:n={}})=>{const{zoomIn:a,zoomOut:o,reset:s}=as({duration:e,factor:1.5}),u={style:i,className:`react-sigma-control ${r||""}`};return H.createElement(H.Fragment,null,H.createElement("div",Object.assign({},u),H.createElement("button",{onClick:()=>a(),title:n.zoomIn||"Zoom In"},t?t[0]:H.createElement(cs,{style:{width:"1em"}}))),H.createElement("div",Object.assign({},u),H.createElement("button",{onClick:()=>o(),title:n.zoomOut||"Zoom Out"},t?t[1]:H.createElement(ls,{style:{width:"1em"}}))),H.createElement("div",Object.assign({},u),H.createElement("button",{onClick:()=>s(),title:n.reset||"See whole graph"},t?t[2]:H.createElement(hs,{style:{width:"1em"}}))))};var gn;function gi(){return gi=Object.assign?Object.assign.bind():function(r){for(var i=1;i<arguments.length;i++){var e=arguments[i];for(var t in e)({}).hasOwnProperty.call(e,t)&&(r[t]=e[t])}return r},gi.apply(null,arguments)}var pn,fs=function(r){return N.createElement("svg",gi({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"compress-solid_svg__svg-inline--fa compress-solid_svg__fa-compress compress-solid_svg__fa-w-14","data-icon":"compress","data-prefix":"fas",viewBox:"0 0 448 512",width:"1em",height:"1em"},r),gn||(gn=N.createElement("path",{fill:"currentColor",d:"M436 192H312c-13.3 0-24-10.7-24-24V44c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v84h84c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12m-276-24V44c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v84H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24m0 300V344c0-13.3-10.7-24-24-24H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12m192 0v-84h84c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12H312c-13.3 0-24 10.7-24 24v124c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12"})))};function pi(){return pi=Object.assign?Object.assign.bind():function(r){for(var i=1;i<arguments.length;i++){var e=arguments[i];for(var t in e)({}).hasOwnProperty.call(e,t)&&(r[t]=e[t])}return r},pi.apply(null,arguments)}var gs=function(r){return N.createElement("svg",pi({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"expand-solid_svg__svg-inline--fa expand-solid_svg__fa-expand expand-solid_svg__fa-w-14","data-icon":"expand","data-prefix":"fas",viewBox:"0 0 448 512",width:"1em",height:"1em"},r),pn||(pn=N.createElement("path",{fill:"currentColor",d:"M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12M288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12m148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12M160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12"})))};const ps=({id:r,className:i,style:e,container:t,children:n,labels:a={}})=>{const{isFullScreen:o,toggle:s}=os(t==null?void 0:t.current),u={className:`react-sigma-control ${i||""}`,id:r,style:e};return document.fullscreenEnabled?H.createElement("div",Object.assign({},u),H.createElement("button",{onClick:s,title:o?a.exit||"Exit fullscreen":a.enter||"Enter fullscreen"},n&&!o&&n[0],n&&o&&n[1],!n&&!o&&H.createElement(gs,{style:{width:"1em"}}),!n&&o&&H.createElement(fs,{style:{width:"1em"}}))):null};function ms(r,i){const e=Ht(),[t,n]=N.useState(!1),[a,o]=N.useState(null),s=N.useRef(i);return Mt(s.current,i)||(s.current=i),N.useEffect(()=>{n(!1);let u=null;return s.current&&(u=new r(e.getGraph(),s.current)),o(u),()=>{u!==null&&u.kill()}},[e,s,o,n,r]),{stop:N.useCallback(()=>{a&&(a.stop(),n(!1))},[a,n]),start:N.useCallback(()=>{a&&(a.start(),n(!0))},[a,n]),kill:N.useCallback(()=>{a&&a.kill(),n(!1)},[a,n]),isRunning:t}}var St={};function vs(r){return typeof r!="number"||isNaN(r)?1:r}function ys(r,i){var e={},t=function(o){return typeof o>"u"?i:o};typeof i=="function"&&(t=i);var n=function(o){return t(o[r])},a=function(){return t(void 0)};return typeof r=="string"?(e.fromAttributes=n,e.fromGraph=function(o,s){return n(o.getNodeAttributes(s))},e.fromEntry=function(o,s){return n(s)}):typeof r=="function"?(e.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},e.fromGraph=function(o,s){return t(r(s,o.getNodeAttributes(s)))},e.fromEntry=function(o,s){return t(r(o,s))}):(e.fromAttributes=a,e.fromGraph=a,e.fromEntry=a),e}function dr(r,i){var e={},t=function(o){return typeof o>"u"?i:o};typeof i=="function"&&(t=i);var n=function(o){return t(o[r])},a=function(){return t(void 0)};return typeof r=="string"?(e.fromAttributes=n,e.fromGraph=function(o,s){return n(o.getEdgeAttributes(s))},e.fromEntry=function(o,s){return n(s)},e.fromPartialEntry=e.fromEntry,e.fromMinimalEntry=e.fromEntry):typeof r=="function"?(e.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},e.fromGraph=function(o,s){var u=o.extremities(s);return t(r(s,o.getEdgeAttributes(s),u[0],u[1],o.getNodeAttributes(u[0]),o.getNodeAttributes(u[1]),o.isUndirected(s)))},e.fromEntry=function(o,s,u,h,c,l,d){return t(r(o,s,u,h,c,l,d))},e.fromPartialEntry=function(o,s,u,h){return t(r(o,s,u,h))},e.fromMinimalEntry=function(o,s){return t(r(o,s))}):(e.fromAttributes=a,e.fromGraph=a,e.fromEntry=a,e.fromMinimalEntry=a),e}St.createNodeValueGetter=ys;St.createEdgeValueGetter=dr;St.createEdgeWeightGetter=function(r){return dr(r,vs)};var oe=0,re=1,V=2,K=3,Pe=4,Oe=5,Y=6,mn=7,zt=8,vn=9,bs=0,ws=1,Es=2,he=0,Se=1,me=2,qe=3,He=4,ae=5,ve=6,Ge=7,xe=8,yn=3,Ce=10,_s=3,ge=9,ri=10,Ts=function(i,e,t){var n,a,o,s,u,h,c,l,d,m,E=e.length,k=t.length,S=i.adjustSizes,x=i.barnesHutTheta*i.barnesHutTheta,R,b,_,G,z,w,D,f=[];for(o=0;o<E;o+=Ce)e[o+Pe]=e[o+V],e[o+Oe]=e[o+K],e[o+V]=0,e[o+K]=0;if(i.outboundAttractionDistribution){for(R=0,o=0;o<E;o+=Ce)R+=e[o+Y];R/=E/Ce}if(i.barnesHutOptimize){var W=1/0,Q=-1/0,B=1/0,ie=-1/0,O,te,we;for(o=0;o<E;o+=Ce)W=Math.min(W,e[o+oe]),Q=Math.max(Q,e[o+oe]),B=Math.min(B,e[o+re]),ie=Math.max(ie,e[o+re]);var M=Q-W,g=ie-B;for(M>g?(B-=(M-g)/2,ie=B+M):(W-=(g-M)/2,Q=W+g),f[0+he]=-1,f[0+Se]=(W+Q)/2,f[0+me]=(B+ie)/2,f[0+qe]=Math.max(Q-W,ie-B),f[0+He]=-1,f[0+ae]=-1,f[0+ve]=0,f[0+Ge]=0,f[0+xe]=0,n=1,o=0;o<E;o+=Ce)for(a=0,we=yn;;)if(f[a+ae]>=0){e[o+oe]<f[a+Se]?e[o+re]<f[a+me]?O=f[a+ae]:O=f[a+ae]+ge:e[o+re]<f[a+me]?O=f[a+ae]+ge*2:O=f[a+ae]+ge*3,f[a+Ge]=(f[a+Ge]*f[a+ve]+e[o+oe]*e[o+Y])/(f[a+ve]+e[o+Y]),f[a+xe]=(f[a+xe]*f[a+ve]+e[o+re]*e[o+Y])/(f[a+ve]+e[o+Y]),f[a+ve]+=e[o+Y],a=O;continue}else if(f[a+he]<0){f[a+he]=o;break}else{if(f[a+ae]=n*ge,l=f[a+qe]/2,d=f[a+ae],f[d+he]=-1,f[d+Se]=f[a+Se]-l,f[d+me]=f[a+me]-l,f[d+qe]=l,f[d+He]=d+ge,f[d+ae]=-1,f[d+ve]=0,f[d+Ge]=0,f[d+xe]=0,d+=ge,f[d+he]=-1,f[d+Se]=f[a+Se]-l,f[d+me]=f[a+me]+l,f[d+qe]=l,f[d+He]=d+ge,f[d+ae]=-1,f[d+ve]=0,f[d+Ge]=0,f[d+xe]=0,d+=ge,f[d+he]=-1,f[d+Se]=f[a+Se]+l,f[d+me]=f[a+me]-l,f[d+qe]=l,f[d+He]=d+ge,f[d+ae]=-1,f[d+ve]=0,f[d+Ge]=0,f[d+xe]=0,d+=ge,f[d+he]=-1,f[d+Se]=f[a+Se]+l,f[d+me]=f[a+me]+l,f[d+qe]=l,f[d+He]=f[a+He],f[d+ae]=-1,f[d+ve]=0,f[d+Ge]=0,f[d+xe]=0,n+=4,e[f[a+he]+oe]<f[a+Se]?e[f[a+he]+re]<f[a+me]?O=f[a+ae]:O=f[a+ae]+ge:e[f[a+he]+re]<f[a+me]?O=f[a+ae]+ge*2:O=f[a+ae]+ge*3,f[a+ve]=e[f[a+he]+Y],f[a+Ge]=e[f[a+he]+oe],f[a+xe]=e[f[a+he]+re],f[O+he]=f[a+he],f[a+he]=-1,e[o+oe]<f[a+Se]?e[o+re]<f[a+me]?te=f[a+ae]:te=f[a+ae]+ge:e[o+re]<f[a+me]?te=f[a+ae]+ge*2:te=f[a+ae]+ge*3,O===te)if(we--){a=O;continue}else{we=yn;break}f[te+he]=o;break}}if(i.barnesHutOptimize)for(b=i.scalingRatio,o=0;o<E;o+=Ce)for(a=0;;)if(f[a+ae]>=0)if(w=Math.pow(e[o+oe]-f[a+Ge],2)+Math.pow(e[o+re]-f[a+xe],2),m=f[a+qe],4*m*m/w<x){if(_=e[o+oe]-f[a+Ge],G=e[o+re]-f[a+xe],S===!0?w>0?(D=b*e[o+Y]*f[a+ve]/w,e[o+V]+=_*D,e[o+K]+=G*D):w<0&&(D=-b*e[o+Y]*f[a+ve]/Math.sqrt(w),e[o+V]+=_*D,e[o+K]+=G*D):w>0&&(D=b*e[o+Y]*f[a+ve]/w,e[o+V]+=_*D,e[o+K]+=G*D),a=f[a+He],a<0)break;continue}else{a=f[a+ae];continue}else{if(h=f[a+he],h>=0&&h!==o&&(_=e[o+oe]-e[h+oe],G=e[o+re]-e[h+re],w=_*_+G*G,S===!0?w>0?(D=b*e[o+Y]*e[h+Y]/w,e[o+V]+=_*D,e[o+K]+=G*D):w<0&&(D=-b*e[o+Y]*e[h+Y]/Math.sqrt(w),e[o+V]+=_*D,e[o+K]+=G*D):w>0&&(D=b*e[o+Y]*e[h+Y]/w,e[o+V]+=_*D,e[o+K]+=G*D)),a=f[a+He],a<0)break;continue}else for(b=i.scalingRatio,s=0;s<E;s+=Ce)for(u=0;u<s;u+=Ce)_=e[s+oe]-e[u+oe],G=e[s+re]-e[u+re],S===!0?(w=Math.sqrt(_*_+G*G)-e[s+zt]-e[u+zt],w>0?(D=b*e[s+Y]*e[u+Y]/w/w,e[s+V]+=_*D,e[s+K]+=G*D,e[u+V]-=_*D,e[u+K]-=G*D):w<0&&(D=100*b*e[s+Y]*e[u+Y],e[s+V]+=_*D,e[s+K]+=G*D,e[u+V]-=_*D,e[u+K]-=G*D)):(w=Math.sqrt(_*_+G*G),w>0&&(D=b*e[s+Y]*e[u+Y]/w/w,e[s+V]+=_*D,e[s+K]+=G*D,e[u+V]-=_*D,e[u+K]-=G*D));for(d=i.gravity/i.scalingRatio,b=i.scalingRatio,o=0;o<E;o+=Ce)D=0,_=e[o+oe],G=e[o+re],w=Math.sqrt(Math.pow(_,2)+Math.pow(G,2)),i.strongGravityMode?w>0&&(D=b*e[o+Y]*d):w>0&&(D=b*e[o+Y]*d/w),e[o+V]-=_*D,e[o+K]-=G*D;for(b=1*(i.outboundAttractionDistribution?R:1),c=0;c<k;c+=_s)s=t[c+bs],u=t[c+ws],l=t[c+Es],z=Math.pow(l,i.edgeWeightInfluence),_=e[s+oe]-e[u+oe],G=e[s+re]-e[u+re],S===!0?(w=Math.sqrt(_*_+G*G)-e[s+zt]-e[u+zt],i.linLogMode?i.outboundAttractionDistribution?w>0&&(D=-b*z*Math.log(1+w)/w/e[s+Y]):w>0&&(D=-b*z*Math.log(1+w)/w):i.outboundAttractionDistribution?w>0&&(D=-b*z/e[s+Y]):w>0&&(D=-b*z)):(w=Math.sqrt(Math.pow(_,2)+Math.pow(G,2)),i.linLogMode?i.outboundAttractionDistribution?w>0&&(D=-b*z*Math.log(1+w)/w/e[s+Y]):w>0&&(D=-b*z*Math.log(1+w)/w):i.outboundAttractionDistribution?(w=1,D=-b*z/e[s+Y]):(w=1,D=-b*z)),w>0&&(e[s+V]+=_*D,e[s+K]+=G*D,e[u+V]-=_*D,e[u+K]-=G*D);var de,ue,C,p,j,J;if(S===!0)for(o=0;o<E;o+=Ce)e[o+vn]!==1&&(de=Math.sqrt(Math.pow(e[o+V],2)+Math.pow(e[o+K],2)),de>ri&&(e[o+V]=e[o+V]*ri/de,e[o+K]=e[o+K]*ri/de),ue=e[o+Y]*Math.sqrt((e[o+Pe]-e[o+V])*(e[o+Pe]-e[o+V])+(e[o+Oe]-e[o+K])*(e[o+Oe]-e[o+K])),C=Math.sqrt((e[o+Pe]+e[o+V])*(e[o+Pe]+e[o+V])+(e[o+Oe]+e[o+K])*(e[o+Oe]+e[o+K]))/2,p=.1*Math.log(1+C)/(1+Math.sqrt(ue)),j=e[o+oe]+e[o+V]*(p/i.slowDown),e[o+oe]=j,J=e[o+re]+e[o+K]*(p/i.slowDown),e[o+re]=J);else for(o=0;o<E;o+=Ce)e[o+vn]!==1&&(ue=e[o+Y]*Math.sqrt((e[o+Pe]-e[o+V])*(e[o+Pe]-e[o+V])+(e[o+Oe]-e[o+K])*(e[o+Oe]-e[o+K])),C=Math.sqrt((e[o+Pe]+e[o+V])*(e[o+Pe]+e[o+V])+(e[o+Oe]+e[o+K])*(e[o+Oe]+e[o+K]))/2,p=e[o+mn]*Math.log(1+C)/(1+Math.sqrt(ue)),e[o+mn]=Math.min(1,Math.sqrt(p*(Math.pow(e[o+V],2)+Math.pow(e[o+K],2))/(1+Math.sqrt(ue)))),j=e[o+oe]+e[o+V]*(p/i.slowDown),e[o+oe]=j,J=e[o+re]+e[o+K]*(p/i.slowDown),e[o+re]=J);return{}},je={},Et=10,bn=3;je.assign=function(r){r=r||{};var i=Array.prototype.slice.call(arguments).slice(1),e,t,n;for(e=0,n=i.length;e<n;e++)if(i[e])for(t in i[e])r[t]=i[e][t];return r};je.validateSettings=function(r){return"linLogMode"in r&&typeof r.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in r&&typeof r.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in r&&typeof r.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in r&&typeof r.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in r&&!(typeof r.scalingRatio=="number"&&r.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in r&&typeof r.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in r&&!(typeof r.gravity=="number"&&r.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in r&&!(typeof r.slowDown=="number"||r.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in r&&typeof r.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in r&&!(typeof r.barnesHutTheta=="number"&&r.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null};je.graphToByteArrays=function(r,i){var e=r.order,t=r.size,n={},a,o=new Float32Array(e*Et),s=new Float32Array(t*bn);return a=0,r.forEachNode(function(u,h){n[u]=a,o[a]=h.x,o[a+1]=h.y,o[a+2]=0,o[a+3]=0,o[a+4]=0,o[a+5]=0,o[a+6]=1,o[a+7]=1,o[a+8]=h.size||1,o[a+9]=h.fixed?1:0,a+=Et}),a=0,r.forEachEdge(function(u,h,c,l,d,m,E){var k=n[c],S=n[l],x=i(u,h,c,l,d,m,E);o[k+6]+=x,o[S+6]+=x,s[a]=k,s[a+1]=S,s[a+2]=x,a+=bn}),{nodes:o,edges:s}};je.assignLayoutChanges=function(r,i,e){var t=0;r.updateEachNodeAttributes(function(n,a){return a.x=i[t],a.y=i[t+1],t+=Et,e?e(n,a):a})};je.readGraphPositions=function(r,i){var e=0;r.forEachNode(function(t,n){i[e]=n.x,i[e+1]=n.y,e+=Et})};je.collectLayoutChanges=function(r,i,e){for(var t=r.nodes(),n={},a=0,o=0,s=i.length;a<s;a+=Et){if(e){var u=Object.assign({},r.getNodeAttributes(t[o]));u.x=i[a],u.y=i[a+1],u=e(t[o],u),n[t[o]]={x:u.x,y:u.y}}else n[t[o]]={x:i[a],y:i[a+1]};o++}return n};je.createWorker=function(i){var e=window.URL||window.webkitURL,t=i.toString(),n=e.createObjectURL(new Blob(["("+t+").call(this);"],{type:"text/javascript"})),a=new Worker(n);return e.revokeObjectURL(n),a};var fr={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5},Ss=Si,Rs=St.createEdgeWeightGetter,ks=Ts,bt=je,Cs=fr;function gr(r,i,e){if(!Ss(i))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof e=="number"&&(e={iterations:e});var t=e.iterations;if(typeof t!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(t<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var n=Rs("getEdgeWeight"in e?e.getEdgeWeight:"weight").fromEntry,a=typeof e.outputReducer=="function"?e.outputReducer:null,o=bt.assign({},Cs,e.settings),s=bt.validateSettings(o);if(s)throw new Error("graphology-layout-forceatlas2: "+s.message);var u=bt.graphToByteArrays(i,n),h;for(h=0;h<t;h++)ks(o,u.nodes,u.edges);if(r){bt.assignLayoutChanges(i,u.nodes,a);return}return bt.collectLayoutChanges(i,u.nodes)}function As(r){var i=typeof r=="number"?r:r.order;return{barnesHutOptimize:i>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(i)}}var pr=gr.bind(null,!1);pr.assign=gr.bind(null,!0);pr.inferSettings=As;var Ds=function(){var i,e,t={};(function(){var a=0,o=1,s=2,u=3,h=4,c=5,l=6,d=7,m=8,E=9,k=0,S=1,x=2,R=0,b=1,_=2,G=3,z=4,w=5,D=6,f=7,W=8,Q=3,B=10,ie=3,O=9,te=10;t.exports=function(M,g,de){var ue,C,p,j,J,Ee,Xe,pe,$,Vt,Le=g.length,br=de.length,ct=M.adjustSizes,wr=M.barnesHutTheta*M.barnesHutTheta,Rt,ne,Z,q,Fe,U,I,y=[];for(p=0;p<Le;p+=B)g[p+h]=g[p+s],g[p+c]=g[p+u],g[p+s]=0,g[p+u]=0;if(M.outboundAttractionDistribution){for(Rt=0,p=0;p<Le;p+=B)Rt+=g[p+l];Rt/=Le/B}if(M.barnesHutOptimize){var Me=1/0,Qe=-1/0,Ve=1/0,Je=-1/0,_e,et,Kt;for(p=0;p<Le;p+=B)Me=Math.min(Me,g[p+a]),Qe=Math.max(Qe,g[p+a]),Ve=Math.min(Ve,g[p+o]),Je=Math.max(Je,g[p+o]);var kt=Qe-Me,Ct=Je-Ve;for(kt>Ct?(Ve-=(kt-Ct)/2,Je=Ve+kt):(Me-=(Ct-kt)/2,Qe=Me+Ct),y[0+R]=-1,y[0+b]=(Me+Qe)/2,y[0+_]=(Ve+Je)/2,y[0+G]=Math.max(Qe-Me,Je-Ve),y[0+z]=-1,y[0+w]=-1,y[0+D]=0,y[0+f]=0,y[0+W]=0,ue=1,p=0;p<Le;p+=B)for(C=0,Kt=Q;;)if(y[C+w]>=0){g[p+a]<y[C+b]?g[p+o]<y[C+_]?_e=y[C+w]:_e=y[C+w]+O:g[p+o]<y[C+_]?_e=y[C+w]+O*2:_e=y[C+w]+O*3,y[C+f]=(y[C+f]*y[C+D]+g[p+a]*g[p+l])/(y[C+D]+g[p+l]),y[C+W]=(y[C+W]*y[C+D]+g[p+o]*g[p+l])/(y[C+D]+g[p+l]),y[C+D]+=g[p+l],C=_e;continue}else if(y[C+R]<0){y[C+R]=p;break}else{if(y[C+w]=ue*O,pe=y[C+G]/2,$=y[C+w],y[$+R]=-1,y[$+b]=y[C+b]-pe,y[$+_]=y[C+_]-pe,y[$+G]=pe,y[$+z]=$+O,y[$+w]=-1,y[$+D]=0,y[$+f]=0,y[$+W]=0,$+=O,y[$+R]=-1,y[$+b]=y[C+b]-pe,y[$+_]=y[C+_]+pe,y[$+G]=pe,y[$+z]=$+O,y[$+w]=-1,y[$+D]=0,y[$+f]=0,y[$+W]=0,$+=O,y[$+R]=-1,y[$+b]=y[C+b]+pe,y[$+_]=y[C+_]-pe,y[$+G]=pe,y[$+z]=$+O,y[$+w]=-1,y[$+D]=0,y[$+f]=0,y[$+W]=0,$+=O,y[$+R]=-1,y[$+b]=y[C+b]+pe,y[$+_]=y[C+_]+pe,y[$+G]=pe,y[$+z]=y[C+z],y[$+w]=-1,y[$+D]=0,y[$+f]=0,y[$+W]=0,ue+=4,g[y[C+R]+a]<y[C+b]?g[y[C+R]+o]<y[C+_]?_e=y[C+w]:_e=y[C+w]+O:g[y[C+R]+o]<y[C+_]?_e=y[C+w]+O*2:_e=y[C+w]+O*3,y[C+D]=g[y[C+R]+l],y[C+f]=g[y[C+R]+a],y[C+W]=g[y[C+R]+o],y[_e+R]=y[C+R],y[C+R]=-1,g[p+a]<y[C+b]?g[p+o]<y[C+_]?et=y[C+w]:et=y[C+w]+O:g[p+o]<y[C+_]?et=y[C+w]+O*2:et=y[C+w]+O*3,_e===et)if(Kt--){C=_e;continue}else{Kt=Q;break}y[et+R]=p;break}}if(M.barnesHutOptimize)for(ne=M.scalingRatio,p=0;p<Le;p+=B)for(C=0;;)if(y[C+w]>=0)if(U=Math.pow(g[p+a]-y[C+f],2)+Math.pow(g[p+o]-y[C+W],2),Vt=y[C+G],4*Vt*Vt/U<wr){if(Z=g[p+a]-y[C+f],q=g[p+o]-y[C+W],ct===!0?U>0?(I=ne*g[p+l]*y[C+D]/U,g[p+s]+=Z*I,g[p+u]+=q*I):U<0&&(I=-ne*g[p+l]*y[C+D]/Math.sqrt(U),g[p+s]+=Z*I,g[p+u]+=q*I):U>0&&(I=ne*g[p+l]*y[C+D]/U,g[p+s]+=Z*I,g[p+u]+=q*I),C=y[C+z],C<0)break;continue}else{C=y[C+w];continue}else{if(Ee=y[C+R],Ee>=0&&Ee!==p&&(Z=g[p+a]-g[Ee+a],q=g[p+o]-g[Ee+o],U=Z*Z+q*q,ct===!0?U>0?(I=ne*g[p+l]*g[Ee+l]/U,g[p+s]+=Z*I,g[p+u]+=q*I):U<0&&(I=-ne*g[p+l]*g[Ee+l]/Math.sqrt(U),g[p+s]+=Z*I,g[p+u]+=q*I):U>0&&(I=ne*g[p+l]*g[Ee+l]/U,g[p+s]+=Z*I,g[p+u]+=q*I)),C=y[C+z],C<0)break;continue}else for(ne=M.scalingRatio,j=0;j<Le;j+=B)for(J=0;J<j;J+=B)Z=g[j+a]-g[J+a],q=g[j+o]-g[J+o],ct===!0?(U=Math.sqrt(Z*Z+q*q)-g[j+m]-g[J+m],U>0?(I=ne*g[j+l]*g[J+l]/U/U,g[j+s]+=Z*I,g[j+u]+=q*I,g[J+s]-=Z*I,g[J+u]-=q*I):U<0&&(I=100*ne*g[j+l]*g[J+l],g[j+s]+=Z*I,g[j+u]+=q*I,g[J+s]-=Z*I,g[J+u]-=q*I)):(U=Math.sqrt(Z*Z+q*q),U>0&&(I=ne*g[j+l]*g[J+l]/U/U,g[j+s]+=Z*I,g[j+u]+=q*I,g[J+s]-=Z*I,g[J+u]-=q*I));for($=M.gravity/M.scalingRatio,ne=M.scalingRatio,p=0;p<Le;p+=B)I=0,Z=g[p+a],q=g[p+o],U=Math.sqrt(Math.pow(Z,2)+Math.pow(q,2)),M.strongGravityMode?U>0&&(I=ne*g[p+l]*$):U>0&&(I=ne*g[p+l]*$/U),g[p+s]-=Z*I,g[p+u]-=q*I;for(ne=1*(M.outboundAttractionDistribution?Rt:1),Xe=0;Xe<br;Xe+=ie)j=de[Xe+k],J=de[Xe+S],pe=de[Xe+x],Fe=Math.pow(pe,M.edgeWeightInfluence),Z=g[j+a]-g[J+a],q=g[j+o]-g[J+o],ct===!0?(U=Math.sqrt(Z*Z+q*q)-g[j+m]-g[J+m],M.linLogMode?M.outboundAttractionDistribution?U>0&&(I=-ne*Fe*Math.log(1+U)/U/g[j+l]):U>0&&(I=-ne*Fe*Math.log(1+U)/U):M.outboundAttractionDistribution?U>0&&(I=-ne*Fe/g[j+l]):U>0&&(I=-ne*Fe)):(U=Math.sqrt(Math.pow(Z,2)+Math.pow(q,2)),M.linLogMode?M.outboundAttractionDistribution?U>0&&(I=-ne*Fe*Math.log(1+U)/U/g[j+l]):U>0&&(I=-ne*Fe*Math.log(1+U)/U):M.outboundAttractionDistribution?(U=1,I=-ne*Fe/g[j+l]):(U=1,I=-ne*Fe)),U>0&&(g[j+s]+=Z*I,g[j+u]+=q*I,g[J+s]-=Z*I,g[J+u]-=q*I);var At,dt,Dt,Ke,Lt,Gt;if(ct===!0)for(p=0;p<Le;p+=B)g[p+E]!==1&&(At=Math.sqrt(Math.pow(g[p+s],2)+Math.pow(g[p+u],2)),At>te&&(g[p+s]=g[p+s]*te/At,g[p+u]=g[p+u]*te/At),dt=g[p+l]*Math.sqrt((g[p+h]-g[p+s])*(g[p+h]-g[p+s])+(g[p+c]-g[p+u])*(g[p+c]-g[p+u])),Dt=Math.sqrt((g[p+h]+g[p+s])*(g[p+h]+g[p+s])+(g[p+c]+g[p+u])*(g[p+c]+g[p+u]))/2,Ke=.1*Math.log(1+Dt)/(1+Math.sqrt(dt)),Lt=g[p+a]+g[p+s]*(Ke/M.slowDown),g[p+a]=Lt,Gt=g[p+o]+g[p+u]*(Ke/M.slowDown),g[p+o]=Gt);else for(p=0;p<Le;p+=B)g[p+E]!==1&&(dt=g[p+l]*Math.sqrt((g[p+h]-g[p+s])*(g[p+h]-g[p+s])+(g[p+c]-g[p+u])*(g[p+c]-g[p+u])),Dt=Math.sqrt((g[p+h]+g[p+s])*(g[p+h]+g[p+s])+(g[p+c]+g[p+u])*(g[p+c]+g[p+u]))/2,Ke=g[p+d]*Math.log(1+Dt)/(1+Math.sqrt(dt)),g[p+d]=Math.min(1,Math.sqrt(Ke*(Math.pow(g[p+s],2)+Math.pow(g[p+u],2))/(1+Math.sqrt(dt)))),Lt=g[p+a]+g[p+s]*(Ke/M.slowDown),g[p+a]=Lt,Gt=g[p+o]+g[p+u]*(Ke/M.slowDown),g[p+o]=Gt);return{}}})();var n=t.exports;self.addEventListener("message",function(a){var o=a.data;i=new Float32Array(o.nodes),o.edges&&(e=new Float32Array(o.edges)),n(o.settings,i,e),self.postMessage({nodes:i.buffer},[i.buffer])})},Ls=Ds,Gs=Si,xs=St.createEdgeWeightGetter,ot=je,Fs=fr;function We(r,i){if(i=i||{},!Gs(r))throw new Error("graphology-layout-forceatlas2/worker: the given graph is not a valid graphology instance.");var e=xs("getEdgeWeight"in i?i.getEdgeWeight:"weight").fromEntry,t=ot.assign({},Fs,i.settings),n=ot.validateSettings(t);if(n)throw new Error("graphology-layout-forceatlas2/worker: "+n.message);this.worker=null,this.graph=r,this.settings=t,this.getEdgeWeight=e,this.matrices=null,this.running=!1,this.killed=!1,this.outputReducer=typeof i.outputReducer=="function"?i.outputReducer:null,this.handleMessage=this.handleMessage.bind(this);var a=void 0,o=this;this.handleGraphUpdate=function(){o.worker&&o.worker.terminate(),a&&clearTimeout(a),a=setTimeout(function(){a=void 0,o.spawnWorker()},0)},r.on("nodeAdded",this.handleGraphUpdate),r.on("edgeAdded",this.handleGraphUpdate),r.on("nodeDropped",this.handleGraphUpdate),r.on("edgeDropped",this.handleGraphUpdate),this.spawnWorker()}We.prototype.isRunning=function(){return this.running};We.prototype.spawnWorker=function(){this.worker&&this.worker.terminate(),this.worker=ot.createWorker(Ls),this.worker.addEventListener("message",this.handleMessage),this.running&&(this.running=!1,this.start())};We.prototype.handleMessage=function(r){if(this.running){var i=new Float32Array(r.data.nodes);ot.assignLayoutChanges(this.graph,i,this.outputReducer),this.outputReducer&&ot.readGraphPositions(this.graph,i),this.matrices.nodes=i,this.askForIterations()}};We.prototype.askForIterations=function(r){var i=this.matrices,e={settings:this.settings,nodes:i.nodes.buffer},t=[i.nodes.buffer];return r&&(e.edges=i.edges.buffer,t.push(i.edges.buffer)),this.worker.postMessage(e,t),this};We.prototype.start=function(){if(this.killed)throw new Error("graphology-layout-forceatlas2/worker.start: layout was killed.");return this.running?this:(this.matrices=ot.graphToByteArrays(this.graph,this.getEdgeWeight),this.running=!0,this.askForIterations(!0),this)};We.prototype.stop=function(){return this.running=!1,this};We.prototype.kill=function(){if(this.killed)return this;this.running=!1,this.killed=!0,this.matrices=null,this.worker.terminate(),this.graph.removeListener("nodeAdded",this.handleGraphUpdate),this.graph.removeListener("edgeAdded",this.handleGraphUpdate),this.graph.removeListener("nodeDropped",this.handleGraphUpdate),this.graph.removeListener("edgeDropped",this.handleGraphUpdate)};var Ps=We;const Os=Tn(Ps);function Is(r={}){return ms(Os,r)}var zs=`
|
|
313
|
+
attribute vec4 a_id;
|
|
314
|
+
attribute vec4 a_color;
|
|
315
|
+
attribute vec2 a_normal;
|
|
316
|
+
attribute float a_normalCoef;
|
|
317
|
+
attribute vec2 a_positionStart;
|
|
318
|
+
attribute vec2 a_positionEnd;
|
|
319
|
+
attribute float a_positionCoef;
|
|
320
|
+
attribute float a_sourceRadius;
|
|
321
|
+
attribute float a_targetRadius;
|
|
322
|
+
attribute float a_sourceRadiusCoef;
|
|
323
|
+
attribute float a_targetRadiusCoef;
|
|
324
|
+
|
|
325
|
+
uniform mat3 u_matrix;
|
|
326
|
+
uniform float u_zoomRatio;
|
|
327
|
+
uniform float u_sizeRatio;
|
|
328
|
+
uniform float u_pixelRatio;
|
|
329
|
+
uniform float u_correctionRatio;
|
|
330
|
+
uniform float u_minEdgeThickness;
|
|
331
|
+
uniform float u_lengthToThicknessRatio;
|
|
332
|
+
uniform float u_feather;
|
|
333
|
+
|
|
334
|
+
varying vec4 v_color;
|
|
335
|
+
varying vec2 v_normal;
|
|
336
|
+
varying float v_thickness;
|
|
337
|
+
varying float v_feather;
|
|
338
|
+
|
|
339
|
+
const float bias = 255.0 / 254.0;
|
|
340
|
+
|
|
341
|
+
void main() {
|
|
342
|
+
float minThickness = u_minEdgeThickness;
|
|
343
|
+
|
|
344
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
345
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
346
|
+
|
|
347
|
+
float normalLength = length(normal);
|
|
348
|
+
vec2 unitNormal = normal / normalLength;
|
|
349
|
+
|
|
350
|
+
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
351
|
+
// get better comments on what's happening:
|
|
352
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
353
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
354
|
+
|
|
355
|
+
// Here, we move the point to leave space for the arrow heads:
|
|
356
|
+
// Source arrow head
|
|
357
|
+
float sourceRadius = a_sourceRadius * a_sourceRadiusCoef;
|
|
358
|
+
float sourceDirection = sign(sourceRadius);
|
|
359
|
+
float webGLSourceRadius = sourceDirection * sourceRadius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
360
|
+
float webGLSourceArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
361
|
+
vec2 sourceCompensationVector =
|
|
362
|
+
vec2(-sourceDirection * unitNormal.y, sourceDirection * unitNormal.x)
|
|
363
|
+
* (webGLSourceRadius + webGLSourceArrowHeadLength);
|
|
364
|
+
|
|
365
|
+
// Target arrow head
|
|
366
|
+
float targetRadius = a_targetRadius * a_targetRadiusCoef;
|
|
367
|
+
float targetDirection = sign(targetRadius);
|
|
368
|
+
float webGLTargetRadius = targetDirection * targetRadius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
369
|
+
float webGLTargetArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
370
|
+
vec2 targetCompensationVector =
|
|
371
|
+
vec2(-targetDirection * unitNormal.y, targetDirection * unitNormal.x)
|
|
372
|
+
* (webGLTargetRadius + webGLTargetArrowHeadLength);
|
|
373
|
+
|
|
374
|
+
// Here is the proper position of the vertex
|
|
375
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + sourceCompensationVector + targetCompensationVector, 1)).xy, 0, 1);
|
|
376
|
+
|
|
377
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
378
|
+
|
|
379
|
+
v_normal = unitNormal;
|
|
380
|
+
|
|
381
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
382
|
+
|
|
383
|
+
#ifdef PICKING_MODE
|
|
384
|
+
// For picking mode, we use the ID as the color:
|
|
385
|
+
v_color = a_id;
|
|
386
|
+
#else
|
|
387
|
+
// For normal mode, we use the color:
|
|
388
|
+
v_color = a_color;
|
|
389
|
+
#endif
|
|
390
|
+
|
|
391
|
+
v_color.a *= bias;
|
|
392
|
+
}
|
|
393
|
+
`,Us=zs,mr=WebGLRenderingContext,wn=mr.UNSIGNED_BYTE,Ie=mr.FLOAT,$s=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Ns={lengthToThicknessRatio:Ei.lengthToThicknessRatio};function vr(r){var i=F(F({},Ns),{});return function(e){function t(){return le(this,t),ye(this,t,arguments)}return be(t,e),ce(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Us,FRAGMENT_SHADER_SOURCE:_i,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$s,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Ie},{name:"a_positionEnd",size:2,type:Ie},{name:"a_normal",size:2,type:Ie},{name:"a_color",size:4,type:wn,normalized:!0},{name:"a_id",size:4,type:wn,normalized:!0},{name:"a_sourceRadius",size:1,type:Ie},{name:"a_targetRadius",size:1,type:Ie}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Ie},{name:"a_normalCoef",size:1,type:Ie},{name:"a_sourceRadiusCoef",size:1,type:Ie},{name:"a_targetRadiusCoef",size:1,type:Ie}],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]]}}},{key:"processVisibleItem",value:function(a,o,s,u,h){var c=h.size||1,l=s.x,d=s.y,m=u.x,E=u.y,k=Ye(h.color),S=m-l,x=E-d,R=s.size||1,b=u.size||1,_=S*S+x*x,G=0,z=0;_&&(_=1/Math.sqrt(_),G=-x*_*c,z=S*_*c);var w=this.array;w[o++]=l,w[o++]=d,w[o++]=m,w[o++]=E,w[o++]=G,w[o++]=z,w[o++]=k,w[o++]=a,w[o++]=R,w[o++]=b}},{key:"setUniforms",value:function(a,o){var s=o.gl,u=o.uniformLocations,h=u.u_matrix,c=u.u_zoomRatio,l=u.u_feather,d=u.u_pixelRatio,m=u.u_correctionRatio,E=u.u_sizeRatio,k=u.u_minEdgeThickness,S=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(h,!1,a.matrix),s.uniform1f(c,a.zoomRatio),s.uniform1f(E,a.sizeRatio),s.uniform1f(m,a.correctionRatio),s.uniform1f(d,a.pixelRatio),s.uniform1f(l,a.antiAliasingFeather),s.uniform1f(k,a.minEdgeThickness),s.uniform1f(S,i.lengthToThicknessRatio)}}])}(_t)}vr();function js(r){return tr([vr(),Nt(r),Nt(F(F({},r),{},{extremity:"source"}))])}js();var Bs=`
|
|
394
|
+
precision mediump float;
|
|
395
|
+
|
|
396
|
+
varying vec4 v_color;
|
|
397
|
+
|
|
398
|
+
void main(void) {
|
|
399
|
+
gl_FragColor = v_color;
|
|
400
|
+
}
|
|
401
|
+
`,Hs=Bs,Ws=`
|
|
402
|
+
attribute vec4 a_id;
|
|
403
|
+
attribute vec4 a_color;
|
|
404
|
+
attribute vec2 a_position;
|
|
405
|
+
|
|
406
|
+
uniform mat3 u_matrix;
|
|
407
|
+
|
|
408
|
+
varying vec4 v_color;
|
|
409
|
+
|
|
410
|
+
const float bias = 255.0 / 254.0;
|
|
411
|
+
|
|
412
|
+
void main() {
|
|
413
|
+
// Scale from [[-1 1] [-1 1]] to the container:
|
|
414
|
+
gl_Position = vec4(
|
|
415
|
+
(u_matrix * vec3(a_position, 1)).xy,
|
|
416
|
+
0,
|
|
417
|
+
1
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
#ifdef PICKING_MODE
|
|
421
|
+
// For picking mode, we use the ID as the color:
|
|
422
|
+
v_color = a_id;
|
|
423
|
+
#else
|
|
424
|
+
// For normal mode, we use the color:
|
|
425
|
+
v_color = a_color;
|
|
426
|
+
#endif
|
|
427
|
+
|
|
428
|
+
v_color.a *= bias;
|
|
429
|
+
}
|
|
430
|
+
`,Ms=Ws,yr=WebGLRenderingContext,En=yr.UNSIGNED_BYTE,Vs=yr.FLOAT,Ks=["u_matrix"],Zs=function(r){function i(){return le(this,i),ye(this,i,arguments)}return be(i,r),ce(i,[{key:"getDefinition",value:function(){return{VERTICES:2,VERTEX_SHADER_SOURCE:Ms,FRAGMENT_SHADER_SOURCE:Hs,METHOD:WebGLRenderingContext.LINES,UNIFORMS:Ks,ATTRIBUTES:[{name:"a_position",size:2,type:Vs},{name:"a_color",size:4,type:En,normalized:!0},{name:"a_id",size:4,type:En,normalized:!0}]}}},{key:"processVisibleItem",value:function(t,n,a,o,s){var u=this.array,h=a.x,c=a.y,l=o.x,d=o.y,m=Ye(s.color);u[n++]=h,u[n++]=c,u[n++]=m,u[n++]=t,u[n++]=l,u[n++]=d,u[n++]=m,u[n++]=t}},{key:"setUniforms",value:function(t,n){var a=n.gl,o=n.uniformLocations,s=o.u_matrix;a.uniformMatrix3fv(s,!1,t.matrix)}}])}(_t);const st={repository:"#22d3ee",file:"#64748b",agent:"#a78bfa",task:"#60a5fa",run:"#f59e0b",advice:"#2dd4bf",pattern:"#f472b6",memory:"#38bdf8",lesson:"#34d399",policy:"#fbbf24",outcome:"#fb7185"},qs={impact:new Set(["repository","agent","task","run","advice","lesson","policy","outcome"]),code:new Set(["repository","file","pattern"]),knowledge:new Set(["repository","advice","pattern","memory","lesson","policy","outcome"]),all:new Set(Object.keys(st))};function Ys(r,i,e){const t=Object.keys(st),o=t.indexOf(e)/t.length*Math.PI*2+(r%17/17-.5)*.7,s=6+r/Math.max(1,i)*4;return{x:Math.cos(o)*s,y:Math.sin(o)*s}}function Xs(r,i){return`${r.label} ${r.detail??""} ${r.state??""}`.toLowerCase().includes(i)}function Qs(r,i,e){const t=qs[i],n=r.nodes.filter(u=>t.has(u.type)),a=e.trim().toLowerCase();if(!a)return{...r,nodes:n};const o=new Set(n.filter(u=>Xs(u,a)).map(u=>u.id)),s=new Set(o);for(const u of r.edges)o.has(u.from)&&s.add(u.to),o.has(u.to)&&s.add(u.from);return{...r,nodes:n.filter(u=>s.has(u.id))}}function Js(r){const i=new X({type:"directed",multi:!0,allowSelfLoops:!1}),e=new Set(r.nodes.map(t=>t.id));return r.nodes.forEach((t,n)=>{const a=Ys(n,r.nodes.length,t.type),{type:o,...s}=t;i.addNode(t.id,{...s,entityType:o,...a,size:Math.max(2.5,Math.min(13,2+Math.sqrt(Math.max(1,t.weight))*1.8)),color:st[t.type],label:t.label})}),r.edges.forEach(t=>{!e.has(t.from)||!e.has(t.to)||t.from===t.to||i.addDirectedEdgeWithKey(t.id,t.from,t.to,{kind:t.type,color:t.type==="imports"?"rgba(34, 211, 238, 0.18)":"rgba(148, 163, 184, 0.34)",size:t.type==="imports"?.4:.8})}),i}function _n(r,i){const e=new Set;return r.edges.forEach(t=>{t.from===i&&e.add(t.to),t.to===i&&e.add(t.from)}),r.nodes.filter(t=>e.has(t.id))}function eu({data:r,selectedId:i,onSelect:e}){const t=Ht(),n=rs(),a=cr(),{start:o,stop:s,kill:u}=Is({settings:{barnesHutOptimize:!0,gravity:.08,scalingRatio:8,slowDown:5}});return H.useEffect(()=>{n({clickNode:({node:h})=>{const c=r.nodes.find(d=>d.id===h);if(!c)return;const l=_n(r,h);e({node:c,neighbours:l,relationshipCount:l.length})},clickStage:()=>e(null)})},[r,e,n]),H.useEffect(()=>{const h=new Set(i?[i,..._n(r,i).map(c=>c.id)]:[]);a({nodeReducer:(c,l)=>({...l,label:i&&!h.has(c)?"":l.label,color:i&&!h.has(c)?"rgba(100, 116, 139, 0.16)":l.color,zIndex:h.has(c)?2:1}),edgeReducer:(c,l)=>{if(!i)return l;const m=t.getGraph().extremities(c).includes(i);return{...l,hidden:!m,size:m?1.8:l.size}}}),t.refresh()},[r,i,a,t]),H.useEffect(()=>{if(t.getGraph().order<2)return;o();const h=window.setTimeout(s,1800);return()=>{window.clearTimeout(h),s(),u()}},[u,t,o,s]),null}function tu(r){const i=H.useMemo(()=>Js(r.data),[r.data]),e=H.useMemo(()=>`${r.data.generatedAt}:${r.data.nodes.map(n=>n.id).join("|")}`,[r.data]),t=H.useMemo(()=>({allowInvalidContainer:!0,defaultNodeType:"circle",nodeProgramClasses:{circle:Tt},defaultEdgeType:"line",edgeProgramClasses:{line:Zs},labelDensity:.08,labelGridCellSize:120,labelRenderedSizeThreshold:7,minCameraRatio:.04,maxCameraRatio:8,renderEdgeLabels:!1,zIndex:!0}),[]);return v.jsxs(ss,{graph:i,settings:t,className:"impact-sigma",style:{height:"100%",width:"100%"},children:[v.jsx(eu,{...r}),v.jsxs(us,{position:"bottom-right",children:[v.jsx(ds,{}),v.jsx(ps,{})]})]},e)}const iu=[{id:"impact",label:"Improvement"},{id:"code",label:"Code structure"},{id:"knowledge",label:"Learning"},{id:"all",label:"Everything"}],nu=[{id:"knowledge",label:"Knowledge network"},{id:"code",label:"Patterns & code"},{id:"impact",label:"Reuse & outcomes"},{id:"all",label:"All evidence"}],ru=["repository","file","agent","run","advice","pattern","memory","lesson","policy","outcome"];function ai(r){return typeof r=="number"&&Number.isFinite(r)?r.toLocaleString():null}function au({selection:r}){var s,u,h;if(!r)return v.jsxs("aside",{className:"graph-inspector graph-inspector-empty",children:[v.jsx(Tr,{size:28}),v.jsx("h3",{children:"Select anything"}),v.jsx("p",{children:"Click a node to isolate its evidence trail and understand why it matters."})]});const{node:i,neighbours:e,relationshipCount:t}=r,n=ai((s=i.evidence)==null?void 0:s.avoidedTokens),a=ai((u=i.evidence)==null?void 0:u.returnedTokens),o=ai((h=i.evidence)==null?void 0:h.excludedFiles);return v.jsxs("aside",{className:"graph-inspector","aria-live":"polite",children:[v.jsx("span",{className:"node-type-badge",style:{color:st[i.type]},children:i.type}),v.jsx("h3",{children:i.label}),v.jsx("p",{children:i.detail||"No additional detail recorded."}),v.jsxs("dl",{className:"graph-facts",children:[i.state&&v.jsxs("div",{children:[v.jsx("dt",{children:"Evidence state"}),v.jsx("dd",{children:i.state})]}),v.jsxs("div",{children:[v.jsx("dt",{children:"Relationships"}),v.jsx("dd",{children:t})]}),v.jsxs("div",{children:[v.jsx("dt",{children:"Why shown"}),v.jsx("dd",{children:i.type==="file"?"Structural or touched dependency":i.type==="advice"?"Guidance issued by Rigour during agent work":"Recorded engineering evidence"})]}),n&&v.jsxs("div",{children:[v.jsx("dt",{children:"Context avoided"}),v.jsxs("dd",{children:[n," tokens · measured estimate"]})]}),a&&v.jsxs("div",{children:[v.jsx("dt",{children:"Context returned"}),v.jsxs("dd",{children:[a," tokens"]})]}),o&&v.jsxs("div",{children:[v.jsx("dt",{children:"Repository files excluded"}),v.jsx("dd",{children:o})]})]}),v.jsxs("div",{className:"graph-neighbours",children:[v.jsx("strong",{children:"Connected evidence"}),e.slice(0,8).map(c=>v.jsxs("span",{children:[v.jsx("i",{style:{background:st[c.type]}}),c.label]},c.id)),e.length===0&&v.jsx("span",{children:"No direct relationships recorded."})]})]})}function su({mode:r="impact",onNavigate:i}){const[e,t]=H.useState(null),[n,a]=H.useState(""),[o,s]=H.useState(!0),[u,h]=H.useState(""),[c,l]=H.useState(r==="expertise"?"knowledge":"impact"),[d,m]=H.useState(null),[E,k]=H.useState([]),[S,x]=H.useState({deepFindings:0,driftScans:0,driftDirection:"not measured"}),R=H.useCallback(async()=>{s(!0),a("");try{const[f,W,Q,B]=await Promise.all([fetch("/api/knowledge-graph"),fetch("/api/agent-history?limit=12"),r==="expertise"?fetch("/api/deep-findings"):Promise.resolve(null),r==="expertise"?fetch("/api/drift"):Promise.resolve(null)]),ie=await f.json();if(!f.ok||ie.error)throw new Error(ie.error||`HTTP ${f.status}`);if(!Array.isArray(ie.nodes)||!Array.isArray(ie.edges)||typeof ie.counts!="object")throw new Error("Studio received an invalid graph response.");if(t(ie),W.ok){const O=await W.json();k(Array.isArray(O.events)?O.events.slice(0,6):[])}if(r==="expertise"){const O=Q!=null&&Q.ok?await Q.json():[],te=B!=null&&B.ok?await B.json():{};x({deepFindings:Array.isArray(O)?O.length:0,driftScans:Number(te.totalScans)||0,driftDirection:typeof te.overallDirection=="string"?te.overallDirection:"not measured"})}}catch(f){a(f instanceof Error?f.message:String(f))}finally{s(!1)}},[r]);H.useEffect(()=>{R()},[R]),H.useEffect(()=>m(null),[c,u]);const b=H.useMemo(()=>e?Qs(e,c,u):null,[e,c,u]),_=H.useMemo(()=>new Set((b==null?void 0:b.nodes.map(f=>f.id))??[]),[b]),G=H.useMemo(()=>b?{...b,edges:b.edges.filter(f=>_.has(f.from)&&_.has(f.to))}:null,[b,_]),z=r==="expertise"?nu:iu,D=((e==null?void 0:e.nodes.filter(f=>f.type==="lesson"))??[]).filter(f=>f.state==="validated"||f.state==="promoted").length;return v.jsxs("section",{className:"knowledge-graph","aria-labelledby":"knowledge-graph-title",children:[v.jsxs("div",{className:"knowledge-hero",children:[v.jsxs("div",{children:[v.jsx("span",{className:"knowledge-eyebrow",children:r==="expertise"?"Rigour SME growth graph":"Rigour impact graph"}),v.jsx("h1",{id:"knowledge-graph-title",children:r==="expertise"?"See Rigour become your team’s SME":"See how agents improve your codebase"}),v.jsx("p",{children:r==="expertise"?"Every governed interaction becomes evidence. Patterns, memory and verified outcomes mature into reusable personal and team judgment.":"Code structure, agent actions, prevented risks, proof and reusable team judgment—connected in one evidence map."})]}),v.jsxs("div",{className:"knowledge-impact",children:[v.jsxs("span",{children:[v.jsx(Ci,{size:15}),v.jsx("b",{children:r==="expertise"?D:(e==null?void 0:e.counts.outcome)??0})," ",r==="expertise"?"validated":"outcomes"]}),v.jsxs("span",{children:[v.jsx(Ai,{size:15}),v.jsx("b",{children:(e==null?void 0:e.counts.advice)??0})," advice issued"]}),v.jsxs("span",{children:[v.jsx(Di,{size:15}),v.jsx("b",{children:"Local"})," offline-ready"]})]})]}),v.jsxs("div",{className:"knowledge-toolbar",children:[v.jsx("div",{className:"segmented-control",role:"tablist","aria-label":"Graph perspective",children:z.map(f=>v.jsx("button",{type:"button",role:"tab","aria-selected":c===f.id,className:c===f.id?"active":"",onClick:()=>l(f.id),children:f.label},f.id))}),v.jsxs("label",{className:"graph-search",children:[v.jsx(Li,{size:15}),v.jsx("span",{className:"sr-only",children:"Search graph"}),v.jsx("input",{value:u,onChange:f=>h(f.target.value),placeholder:"Find agent, file, risk, pattern or lesson"})]}),v.jsxs("button",{type:"button",className:"refresh-btn",onClick:R,disabled:o,children:[v.jsx(Gi,{size:14,className:o?"spinning":""}),"Refresh"]})]}),r==="expertise"&&v.jsxs("div",{className:"expertise-journey","aria-label":"Knowledge lifecycle",children:[v.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i("lessons"),children:[v.jsx(Er,{size:16}),v.jsxs("span",{children:[v.jsx("strong",{children:(e==null?void 0:e.counts.lesson)??0})," lessons",v.jsx("small",{children:"Review evidence and promotion"})]})]}),v.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i("patterns"),children:[v.jsx(Ai,{size:16}),v.jsxs("span",{children:[v.jsx("strong",{children:(e==null?void 0:e.counts.pattern)??0})," patterns",v.jsx("small",{children:"Conventions learned from code"})]})]}),v.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i("memory"),children:[v.jsx(Di,{size:16}),v.jsxs("span",{children:[v.jsx("strong",{children:(e==null?void 0:e.counts.memory)??0})," memories",v.jsx("small",{children:"Stable facts agents can recall"})]})]}),v.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i("deep"),children:[v.jsx(Ci,{size:16}),v.jsxs("span",{children:[v.jsx("strong",{children:S.deepFindings})," deep findings",v.jsx("small",{children:"Probabilistic insight with proof"})]})]}),v.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i("drift"),children:[v.jsx(_r,{size:16}),v.jsxs("span",{children:[v.jsx("strong",{children:S.driftScans})," scans",v.jsxs("small",{children:["Drift: ",S.driftDirection]})]})]})]}),o&&v.jsxs("div",{className:"graph-state",children:[v.jsx(Gi,{className:"spinning",size:22})," Building the evidence map from local data…"]}),n&&v.jsxs("div",{className:"graph-state error",role:"alert",children:[v.jsx(xi,{size:22}),v.jsxs("span",{children:["Graph unavailable: ",n]}),v.jsx("button",{type:"button",onClick:R,children:"Retry"})]}),!o&&!n&&G&&v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"graph-summary","aria-label":"Graph legend",children:[ru.filter(f=>e==null?void 0:e.counts[f]).map(f=>v.jsxs("span",{children:[v.jsx("i",{className:"node-swatch",style:{background:st[f]}}),e==null?void 0:e.counts[f]," ",f]},f)),(e==null?void 0:e.truncated)&&v.jsxs("span",{className:"graph-limited",children:[v.jsx(xi,{size:13})," Focused for performance"]})]}),v.jsxs("div",{className:"graph-workspace",children:[v.jsxs("div",{className:"graph-canvas-wrap",children:[G.nodes.length>0?v.jsx(tu,{data:G,selectedId:(d==null?void 0:d.node.id)??null,onSelect:m}):v.jsxs("div",{className:"graph-state",children:[v.jsx(Li,{size:20}),"No connected evidence matches this view."]}),v.jsx("div",{className:"graph-instruction",children:"Scroll to zoom · drag to explore · click to explain"})]}),v.jsx(au,{selection:d})]}),v.jsxs("div",{className:"graph-evidence-strip","aria-label":"Recent governed work",children:[v.jsxs("div",{children:[v.jsx("strong",{children:"Recent governed work"}),v.jsx("span",{children:"What Rigour observed—not inferred"})]}),v.jsxs("ol",{children:[E.map(f=>{const W=f.tool||f.type||"agent event";return v.jsxs("li",{className:f.outcome,children:[v.jsx("i",{}),v.jsx("strong",{children:W.replace(/^rigour_/,"").replaceAll("_"," ")}),v.jsx("span",{children:f.summary||f.outcome})]},f.id)}),E.length===0&&v.jsxs("li",{className:"empty",children:[v.jsx("i",{}),v.jsx("strong",{children:"No evidence yet"}),v.jsx("span",{children:"Agent interactions will appear here."})]})]})]})]})]})}export{su as KnowledgeGraph};
|