@mcp-graph-workflow/mcp-graph 5.9.1 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/routes/siebel.d.ts.map +1 -1
- package/dist/api/routes/siebel.js +36 -0
- package/dist/api/routes/siebel.js.map +1 -1
- package/dist/schemas/knowledge.schema.d.ts +2 -0
- package/dist/schemas/knowledge.schema.d.ts.map +1 -1
- package/dist/schemas/knowledge.schema.js +1 -1
- package/dist/schemas/knowledge.schema.js.map +1 -1
- package/dist/web/dashboard/dist/assets/benchmark-tab-DE9sF83l.js +1 -0
- package/dist/web/dashboard/dist/assets/{constants-z0QkAiYv.js → constants-lq4BIQN3.js} +1 -1
- package/dist/web/dashboard/dist/assets/context-tab-BDBUYfAA.js +1 -0
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-DDw7DUED.js → gitnexus-tab-Yn1v6B3B.js} +16 -16
- package/dist/web/dashboard/dist/assets/graph-section-C6dzE7Vr.js +1 -0
- package/dist/web/dashboard/dist/assets/graph-tab-eIpG9sGq.js +1 -0
- package/dist/web/dashboard/dist/assets/graph-utils-Cq350VUG.js +1 -0
- package/dist/web/dashboard/dist/assets/{index-F9dY4AG_.js → index-BjE9IIVd.js} +2 -2
- package/dist/web/dashboard/dist/assets/index-CsH_Hv51.js +208 -0
- package/dist/web/dashboard/dist/assets/index-p238Jynp.css +1 -0
- package/dist/web/dashboard/dist/assets/index-ruquw1ns.js +1 -0
- package/dist/web/dashboard/dist/assets/{insights-tab-YN7G6mjm.js → insights-tab-iSZItsRP.js} +15 -15
- package/dist/web/dashboard/dist/assets/journey-tab-GXibD334.js +1 -0
- package/dist/web/dashboard/dist/assets/logs-tab-DROI_l7-.js +2 -0
- package/dist/web/dashboard/dist/assets/memories-tab-DUMqEP5R.js +1 -0
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-DIQ0Fmr_.js +1 -0
- package/dist/web/dashboard/dist/assets/siebel-tab-Ci5KiOA6.js +4 -0
- package/dist/web/dashboard/dist/assets/sif-parse.worker-DZrybOHz.js +4 -0
- package/dist/web/dashboard/dist/assets/skills-tab-EfuAQFRT.js +1 -0
- package/dist/web/dashboard/dist/assets/{style-Da3qWU01.js → style-DF9Y1aXX.js} +1 -1
- package/dist/web/dashboard/dist/index.html +5 -2
- package/package.json +2 -2
- package/dist/web/dashboard/dist/assets/benchmark-tab-BoMsoQjO.js +0 -1
- package/dist/web/dashboard/dist/assets/context-tab-BLT4qQ77.js +0 -1
- package/dist/web/dashboard/dist/assets/graph-tab-DG9Q6nko.js +0 -1
- package/dist/web/dashboard/dist/assets/graph-utils-BpYHKE87.js +0 -1
- package/dist/web/dashboard/dist/assets/index-Cu23WCcu.css +0 -1
- package/dist/web/dashboard/dist/assets/index-DtkPX5ZZ.js +0 -55
- package/dist/web/dashboard/dist/assets/journey-tab-BcweuR82.js +0 -1
- package/dist/web/dashboard/dist/assets/logs-tab-BjdAURdy.js +0 -2
- package/dist/web/dashboard/dist/assets/memories-tab-CQ2xM2aw.js +0 -1
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-CIeCpE1a.js +0 -1
- package/dist/web/dashboard/dist/assets/siebel-tab-bj5CT4-Z.js +0 -3
- package/dist/web/dashboard/dist/assets/skills-tab-Bgk72mKO.js +0 -1
package/dist/web/dashboard/dist/assets/{gitnexus-tab-DDw7DUED.js → gitnexus-tab-Yn1v6B3B.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{g as $r,r as G,t as Et,j as g,a as Oe,O as Ii}from"./index-DtkPX5ZZ.js";import{C as we,b as pt,c as Ur}from"./constants-z0QkAiYv.js";var st={exports:{}},Xt;function Oi(){if(Xt)return st.exports;Xt=1;var n=typeof Reflect=="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(y,S,C){return Function.prototype.apply.call(y,S,C)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(y){return Object.getOwnPropertyNames(y).concat(Object.getOwnPropertySymbols(y))}:t=function(y){return Object.getOwnPropertyNames(y)};function e(m){console&&console.warn&&console.warn(m)}var i=Number.isNaN||function(y){return y!==y};function o(){o.init.call(this)}st.exports=o,st.exports.once=L,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(m){if(typeof m!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof m)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(m){if(typeof m!="number"||m<0||i(m))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+m+".");a=m}}),o.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},o.prototype.setMaxListeners=function(y){if(typeof y!="number"||y<0||i(y))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+y+".");return this._maxListeners=y,this};function u(m){return m._maxListeners===void 0?o.defaultMaxListeners:m._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(y){for(var S=[],C=1;C<arguments.length;C++)S.push(arguments[C]);var P=y==="error",O=this._events;if(O!==void 0)P=P&&O.error===void 0;else if(!P)return!1;if(P){var z;if(S.length>0&&(z=S[0]),z instanceof Error)throw z;var Y=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw Y.context=z,Y}var j=O[y];if(j===void 0)return!1;if(typeof j=="function")r(j,this,S);else for(var p=j.length,Q=b(j,p),C=0;C<p;++C)r(Q[C],this,S);return!0};function l(m,y,S,C){var P,O,z;if(s(S),O=m._events,O===void 0?(O=m._events=Object.create(null),m._eventsCount=0):(O.newListener!==void 0&&(m.emit("newListener",y,S.listener?S.listener:S),O=m._events),z=O[y]),z===void 0)z=O[y]=S,++m._eventsCount;else if(typeof z=="function"?z=O[y]=C?[S,z]:[z,S]:C?z.unshift(S):z.push(S),P=u(m),P>0&&z.length>P&&!z.warned){z.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(y)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=m,Y.type=y,Y.count=z.length,e(Y)}return m}o.prototype.addListener=function(y,S){return l(this,y,S,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(y,S){return l(this,y,S,!0)};function h(){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 d(m,y,S){var C={fired:!1,wrapFn:void 0,target:m,type:y,listener:S},P=h.bind(C);return P.listener=S,C.wrapFn=P,P}o.prototype.once=function(y,S){return s(S),this.on(y,d(this,y,S)),this},o.prototype.prependOnceListener=function(y,S){return s(S),this.prependListener(y,d(this,y,S)),this},o.prototype.removeListener=function(y,S){var C,P,O,z,Y;if(s(S),P=this._events,P===void 0)return this;if(C=P[y],C===void 0)return this;if(C===S||C.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete P[y],P.removeListener&&this.emit("removeListener",y,C.listener||S));else if(typeof C!="function"){for(O=-1,z=C.length-1;z>=0;z--)if(C[z]===S||C[z].listener===S){Y=C[z].listener,O=z;break}if(O<0)return this;O===0?C.shift():w(C,O),C.length===1&&(P[y]=C[0]),P.removeListener!==void 0&&this.emit("removeListener",y,Y||S)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(y){var S,C,P;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[y]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[y]),this;if(arguments.length===0){var O=Object.keys(C),z;for(P=0;P<O.length;++P)z=O[P],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=C[y],typeof S=="function")this.removeListener(y,S);else if(S!==void 0)for(P=S.length-1;P>=0;P--)this.removeListener(y,S[P]);return this};function c(m,y,S){var C=m._events;if(C===void 0)return[];var P=C[y];return P===void 0?[]:typeof P=="function"?S?[P.listener||P]:[P]:S?E(P):b(P,P.length)}o.prototype.listeners=function(y){return c(this,y,!0)},o.prototype.rawListeners=function(y){return c(this,y,!1)},o.listenerCount=function(m,y){return typeof m.listenerCount=="function"?m.listenerCount(y):f.call(m,y)},o.prototype.listenerCount=f;function f(m){var y=this._events;if(y!==void 0){var S=y[m];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function b(m,y){for(var S=new Array(y),C=0;C<y;++C)S[C]=m[C];return S}function w(m,y){for(;y+1<m.length;y++)m[y]=m[y+1];m.pop()}function E(m){for(var y=new Array(m.length),S=0;S<y.length;++S)y[S]=m[S].listener||m[S];return y}function L(m,y){return new Promise(function(S,C){function P(z){m.removeListener(y,O),C(z)}function O(){typeof m.removeListener=="function"&&m.removeListener("error",P),S([].slice.call(arguments))}R(m,y,O,{once:!0}),y!=="error"&&_(m,P,{once:!0})})}function _(m,y,S){typeof m.on=="function"&&R(m,"error",y,S)}function R(m,y,S,C){if(typeof m.on=="function")C.once?m.once(y,S):m.on(y,S);else if(typeof m.addEventListener=="function")m.addEventListener(y,function P(O){C.once&&m.removeEventListener(y,P),S(O)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof m)}return st.exports}var jr=Oi();function zi(){const n=arguments[0];for(let r=1,t=arguments.length;r<t;r++)if(arguments[r])for(const e in arguments[r])n[e]=arguments[r][e];return n}let te=zi;typeof Object.assign=="function"&&(te=Object.assign);function fe(n,r,t,e){const i=n._nodes.get(r);let o=null;return i&&(e==="mixed"?o=i.out&&i.out[t]||i.undirected&&i.undirected[t]:e==="directed"?o=i.out&&i.out[t]:o=i.undirected&&i.undirected[t]),o}function ae(n){return typeof n=="object"&&n!==null}function Mr(n){let r;for(r in n)return!1;return!0}function de(n,r,t){Object.defineProperty(n,r,{enumerable:!1,configurable:!1,writable:!0,value:t})}function ve(n,r,t){const e={enumerable:!0,configurable:!0};typeof t=="function"?e.get=t:(e.value=t,e.writable=!1),Object.defineProperty(n,r,e)}function Qt(n){return!(!ae(n)||n.attributes&&!Array.isArray(n.attributes))}function $i(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function ke(){const n=arguments;let r=null,t=-1;return{[Symbol.iterator](){return this},next(){let e=null;do{if(r===null){if(t++,t>=n.length)return{done:!0};r=n[t][Symbol.iterator]()}if(e=r.next(),e.done){r=null;continue}break}while(!0);return e}}}function Ve(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Bt extends Error{constructor(r){super(),this.name="GraphError",this.message=r}}class D extends Bt{constructor(r){super(r),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}class A extends Bt{constructor(r){super(r),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,A.prototype.constructor)}}class U extends Bt{constructor(r){super(r),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,U.prototype.constructor)}}function Br(n,r){this.key=n,this.attributes=r,this.clear()}Br.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 Hr(n,r){this.key=n,this.attributes=r,this.clear()}Hr.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Wr(n,r){this.key=n,this.attributes=r,this.clear()}Wr.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function qe(n,r,t,e,i){this.key=r,this.attributes=i,this.undirected=n,this.source=t,this.target=e}qe.prototype.attach=function(){let n="out",r="in";this.undirected&&(n=r="undirected");const t=this.source.key,e=this.target.key;this.source[n][e]=this,!(this.undirected&&t===e)&&(this.target[r][t]=this)};qe.prototype.attachMulti=function(){let n="out",r="in";const t=this.source.key,e=this.target.key;this.undirected&&(n=r="undirected");const i=this.source[n],o=i[e];if(typeof o>"u"){i[e]=this,this.undirected&&t===e||(this.target[r][t]=this);return}o.previous=this,this.next=o,i[e]=this,this.target[r][t]=this};qe.prototype.detach=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),delete this.source[t][r],delete this.target[e][n]};qe.prototype.detachMulti=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][r],delete this.target[e][n]):(this.next.previous=void 0,this.source[t][r]=this.next,this.target[e][n]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Vr=0,qr=1,Ui=2,Kr=3;function Ae(n,r,t,e,i,o,a){let s,u,l,h;if(e=""+e,t===Vr){if(s=n._nodes.get(e),!s)throw new A(`Graph.${r}: could not find the "${e}" node in the graph.`);l=i,h=o}else if(t===Kr){if(i=""+i,u=n._edges.get(i),!u)throw new A(`Graph.${r}: could not find the "${i}" edge in the graph.`);const d=u.source.key,c=u.target.key;if(e===d)s=u.target;else if(e===c)s=u.source;else throw new A(`Graph.${r}: the "${e}" node is not attached to the "${i}" edge (${d}, ${c}).`);l=o,h=a}else{if(u=n._edges.get(e),!u)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`);t===qr?s=u.source:s=u.target,l=i,h=o}return[s,l,h]}function ji(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);return a.attributes[s]}}function Mi(n,r,t){n.prototype[r]=function(e,i){const[o]=Ae(this,r,t,e,i);return o.attributes}}function Bi(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);return a.attributes.hasOwnProperty(s)}}function Hi(n,r,t){n.prototype[r]=function(e,i,o,a){const[s,u,l]=Ae(this,r,t,e,i,o,a);return s.attributes[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Wi(n,r,t){n.prototype[r]=function(e,i,o,a){const[s,u,l]=Ae(this,r,t,e,i,o,a);if(typeof l!="function")throw new D(`Graph.${r}: updater should be a function.`);const h=s.attributes,d=l(h[u]);return h[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Vi(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function qi(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);if(!ae(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function Ki(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);if(!ae(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return te(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function Yi(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);if(typeof s!="function")throw new D(`Graph.${r}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const Zi=[{name:n=>`get${n}Attribute`,attacher:ji},{name:n=>`get${n}Attributes`,attacher:Mi},{name:n=>`has${n}Attribute`,attacher:Bi},{name:n=>`set${n}Attribute`,attacher:Hi},{name:n=>`update${n}Attribute`,attacher:Wi},{name:n=>`remove${n}Attribute`,attacher:Vi},{name:n=>`replace${n}Attributes`,attacher:qi},{name:n=>`merge${n}Attributes`,attacher:Ki},{name:n=>`update${n}Attributes`,attacher:Yi}];function Xi(n){Zi.forEach(function({name:r,attacher:t}){t(n,r("Node"),Vr),t(n,r("Source"),qr),t(n,r("Target"),Ui),t(n,r("Opposite"),Kr)})}function Qi(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return o.attributes[i]}}function Ji(n,r,t){n.prototype[r]=function(e){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new U(`Graph.${r}: 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=""+e,a=""+arguments[1];if(i=fe(this,o,a,t),!i)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,i=this._edges.get(e),!i)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return i.attributes}}function en(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function tn(n,r,t){n.prototype[r]=function(e,i,o){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new U(`Graph.${r}: 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=""+e,u=""+i;if(i=arguments[2],o=arguments[3],a=fe(this,s,u,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function rn(n,r,t){n.prototype[r]=function(e,i,o){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new U(`Graph.${r}: 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=""+e,u=""+i;if(i=arguments[2],o=arguments[3],a=fe(this,s,u,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof o!="function")throw new D(`Graph.${r}: updater should be a function.`);return a.attributes[i]=o(a.attributes[i]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function nn(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function on(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!ae(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function an(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!ae(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return te(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function sn(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof i!="function")throw new D(`Graph.${r}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const un=[{name:n=>`get${n}Attribute`,attacher:Qi},{name:n=>`get${n}Attributes`,attacher:Ji},{name:n=>`has${n}Attribute`,attacher:en},{name:n=>`set${n}Attribute`,attacher:tn},{name:n=>`update${n}Attribute`,attacher:rn},{name:n=>`remove${n}Attribute`,attacher:nn},{name:n=>`replace${n}Attributes`,attacher:on},{name:n=>`merge${n}Attributes`,attacher:an},{name:n=>`update${n}Attributes`,attacher:sn}];function ln(n){un.forEach(function({name:r,attacher:t}){t(n,r("Edge"),"mixed"),t(n,r("DirectedEdge"),"directed"),t(n,r("UndirectedEdge"),"undirected")})}const hn=[{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 dn(n,r,t,e){let i=!1;for(const o in r){if(o===e)continue;const a=r[o];if(i=t(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),n&&i)return a.key}}function cn(n,r,t,e){let i,o,a,s=!1;for(const u in r)if(u!==e){i=r[u];do{if(o=i.source,a=i.target,s=t(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),n&&s)return i.key;i=i.next}while(i!==void 0)}}function xt(n,r){const t=Object.keys(n),e=t.length;let i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=e)return{done:!0};const a=t[o++];if(a===r){i=void 0;continue}i=n[a]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function fn(n,r,t,e){const i=r[t];if(!i)return;const o=i.source,a=i.target;if(e(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&n)return i.key}function gn(n,r,t,e){let i=r[t];if(!i)return;let o=!1;do{if(o=e(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),n&&o)return i.key;i=i.next}while(i!==void 0)}function _t(n,r){let t=n[r];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const i={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:i}}};let e=!1;return{[Symbol.iterator](){return this},next(){return e===!0?{done:!0}:(e=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function pn(n,r){if(n.size===0)return[];if(r==="mixed"||r===n.type)return Array.from(n._edges.keys());const t=r==="undirected"?n.undirectedSize:n.directedSize,e=new Array(t),i=r==="undirected",o=n._edges.values();let a=0,s,u;for(;s=o.next(),s.done!==!0;)u=s.value,u.undirected===i&&(e[a++]=u.key);return e}function Yr(n,r,t,e){if(r.size===0)return;const i=t!=="mixed"&&t!==r.type,o=t==="undirected";let a,s,u=!1;const l=r._edges.values();for(;a=l.next(),a.done!==!0;){if(s=a.value,i&&s.undirected!==o)continue;const{key:h,attributes:d,source:c,target:f}=s;if(u=e(h,d,c.key,f.key,c.attributes,f.attributes,s.undirected),n&&u)return h}}function mn(n,r){if(n.size===0)return Ve();const t=r!=="mixed"&&r!==n.type,e=r==="undirected",i=n._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(t&&a.undirected!==e))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function Ht(n,r,t,e,i,o){const a=r?cn:dn;let s;if(t!=="undirected"&&(e!=="out"&&(s=a(n,i.in,o),n&&s)||e!=="in"&&(s=a(n,i.out,o,e?void 0:i.key),n&&s))||t!=="directed"&&(s=a(n,i.undirected,o),n&&s))return s}function vn(n,r,t,e){const i=[];return Ht(!1,n,r,t,e,function(o){i.push(o)}),i}function yn(n,r,t){let e=Ve();return n!=="undirected"&&(r!=="out"&&typeof t.in<"u"&&(e=ke(e,xt(t.in))),r!=="in"&&typeof t.out<"u"&&(e=ke(e,xt(t.out,r?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(e=ke(e,xt(t.undirected))),e}function Wt(n,r,t,e,i,o,a){const s=t?gn:fn;let u;if(r!=="undirected"&&(typeof i.in<"u"&&e!=="out"&&(u=s(n,i.in,o,a),n&&u)||typeof i.out<"u"&&e!=="in"&&(e||i.key!==o)&&(u=s(n,i.out,o,a),n&&u))||r!=="directed"&&typeof i.undirected<"u"&&(u=s(n,i.undirected,o,a),n&&u))return u}function bn(n,r,t,e,i){const o=[];return Wt(!1,n,r,t,e,i,function(a){o.push(a)}),o}function wn(n,r,t,e){let i=Ve();return n!=="undirected"&&(typeof t.in<"u"&&r!=="out"&&e in t.in&&(i=ke(i,_t(t.in,e))),typeof t.out<"u"&&r!=="in"&&e in t.out&&(r||t.key!==e)&&(i=ke(i,_t(t.out,e)))),n!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(i=ke(i,_t(t.undirected,e))),i}function En(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(o,a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];if(!arguments.length)return pn(this,e);if(arguments.length===1){o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new A(`Graph.${t}: could not find the "${o}" node in the graph.`);return vn(this.multi,e==="mixed"?this.type:e,i,s)}if(arguments.length===2){o=""+o,a=""+a;const s=this._nodes.get(o);if(!s)throw new A(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new A(`Graph.${t}: could not find the "${a}" target node in the graph.`);return bn(e,this.multi,i,s,a)}throw new D(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function xn(n,r){const{name:t,type:e,direction:i}=r,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(l,h,d){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return d=l,Yr(!1,this,e,d);if(arguments.length===2){l=""+l,d=h;const c=this._nodes.get(l);if(typeof c>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);return Ht(!1,this.multi,e==="mixed"?this.type:e,i,c,d)}if(arguments.length===3){l=""+l,h=""+h;const c=this._nodes.get(l);if(!c)throw new A(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(h))throw new A(`Graph.${o}: could not find the "${h}" target node in the graph.`);return Wt(!1,e,this.multi,i,c,h,d)}throw new D(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const a="map"+t[0].toUpperCase()+t.slice(1);n.prototype[a]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop();let d;if(l.length===0){let c=0;e!=="directed"&&(c+=this.undirectedSize),e!=="undirected"&&(c+=this.directedSize),d=new Array(c);let f=0;l.push((b,w,E,L,_,R,m)=>{d[f++]=h(b,w,E,L,_,R,m)})}else d=[],l.push((c,f,b,w,E,L,_)=>{d.push(h(c,f,b,w,E,L,_))});return this[o].apply(this,l),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop(),d=[];return l.push((c,f,b,w,E,L,_)=>{h(c,f,b,w,E,L,_)&&d.push(c)}),this[o].apply(this,l),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(){let l=Array.prototype.slice.call(arguments);if(l.length<2||l.length>4)throw new D(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${l.length}).`);if(typeof l[l.length-1]=="function"&&typeof l[l.length-2]!="function")throw new D(`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 h,d;l.length===2?(h=l[0],d=l[1],l=[]):l.length===3?(h=l[1],d=l[2],l=[l[0]]):l.length===4&&(h=l[2],d=l[3],l=[l[0],l[1]]);let c=d;return l.push((f,b,w,E,L,_,R)=>{c=h(c,f,b,w,E,L,_,R)}),this[o].apply(this,l),c}}function _n(n,r){const{name:t,type:e,direction:i}=r,o="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(u,l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return h=u,Yr(!0,this,e,h);if(arguments.length===2){u=""+u,h=l;const d=this._nodes.get(u);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${u}" node in the graph.`);return Ht(!0,this.multi,e==="mixed"?this.type:e,i,d,h)}if(arguments.length===3){u=""+u,l=""+l;const d=this._nodes.get(u);if(!d)throw new A(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new A(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Wt(!0,e,this.multi,i,d,l,h)}throw new D(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const a="some"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,f,b,w,E,L)=>l(d,c,f,b,w,E,L)),!!this[o].apply(this,u)};const s="every"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,f,b,w,E,L)=>!l(d,c,f,b,w,E,L)),!this[o].apply(this,u)}}function Cn(n,r){const{name:t,type:e,direction:i}=r,o=t.slice(0,-1)+"Entries";n.prototype[o]=function(a,s){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();if(!arguments.length)return mn(this,e);if(arguments.length===1){a=""+a;const u=this._nodes.get(a);if(!u)throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return yn(e,i,u)}if(arguments.length===2){a=""+a,s=""+s;const u=this._nodes.get(a);if(!u)throw new A(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new A(`Graph.${o}: could not find the "${s}" target node in the graph.`);return wn(e,i,u,s)}throw new D(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Sn(n){hn.forEach(r=>{En(n,r),xn(n,r),_n(n,r),Cn(n,r)})}const Tn=[{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 mt(){this.A=null,this.B=null}mt.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};mt.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function Ze(n,r,t,e,i){for(const o in e){const a=e[o],s=a.source,u=a.target,l=s===t?u:s;if(r&&r.has(l.key))continue;const h=i(l.key,l.attributes);if(n&&h)return l.key}}function Vt(n,r,t,e,i){if(r!=="mixed"){if(r==="undirected")return Ze(n,null,e,e.undirected,i);if(typeof t=="string")return Ze(n,null,e,e[t],i)}const o=new mt;let a;if(r!=="undirected"){if(t!=="out"){if(a=Ze(n,null,e,e.in,i),n&&a)return a;o.wrap(e.in)}if(t!=="in"){if(a=Ze(n,o,e,e.out,i),n&&a)return a;o.wrap(e.out)}}if(r!=="directed"&&(a=Ze(n,o,e,e.undirected,i),n&&a))return a}function Rn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Object.keys(t.undirected);if(typeof r=="string")return Object.keys(t[r])}const e=[];return Vt(!1,n,r,t,function(i){e.push(i)}),e}function Xe(n,r,t){const e=Object.keys(t),i=e.length;let o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=i)return n&&n.wrap(t),{done:!0};const s=t[e[o++]],u=s.source,l=s.target;if(a=u===r?l:u,n&&n.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function kn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Xe(null,t,t.undirected);if(typeof r=="string")return Xe(null,t,t[r])}let e=Ve();const i=new mt;return n!=="undirected"&&(r!=="out"&&(e=ke(e,Xe(i,t,t.in))),r!=="in"&&(e=ke(e,Xe(i,t,t.out)))),n!=="directed"&&(e=ke(e,Xe(i,t,t.undirected))),e}function An(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new A(`Graph.${t}: could not find the "${o}" node in the graph.`);return Rn(e==="mixed"?this.type:e,i,a)}}function Ln(n,r){const{name:t,type:e,direction:i}=r,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);Vt(!1,e==="mixed"?this.type:e,i,d,h)};const a="map"+t[0].toUpperCase()+t.slice(1);n.prototype[a]=function(l,h){const d=[];return this[o](l,(c,f)=>{d.push(h(c,f))}),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(l,h){const d=[];return this[o](l,(c,f)=>{h(c,f)&&d.push(c)}),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(l,h,d){if(arguments.length<3)throw new D(`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=d;return this[o](l,(f,b)=>{c=h(c,f,b)}),c}}function Dn(n,r){const{name:t,type:e,direction:i}=r,o=t[0].toUpperCase()+t.slice(1,-1),a="find"+o;n.prototype[a]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);return Vt(!0,e==="mixed"?this.type:e,i,d,h)};const s="some"+o;n.prototype[s]=function(l,h){return!!this[a](l,h)};const u="every"+o;n.prototype[u]=function(l,h){return!this[a](l,(c,f)=>!h(c,f))}}function Gn(n,r){const{name:t,type:e,direction:i}=r,o=t.slice(0,-1)+"Entries";n.prototype[o]=function(a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return kn(e==="mixed"?this.type:e,i,s)}}function Nn(n){Tn.forEach(r=>{An(n,r),Ln(n,r),Dn(n,r),Gn(n,r)})}function ut(n,r,t,e,i){const o=e._nodes.values(),a=e.type;let s,u,l,h,d,c;for(;s=o.next(),s.done!==!0;){let f=!1;if(u=s.value,a!=="undirected"){h=u.out;for(l in h){d=h[l];do c=d.target,f=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(a!=="directed"){h=u.undirected;for(l in h)if(!(r&&u.key>l)){d=h[l];do c=d.target,c.key!==l&&(c=d.source),f=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}t&&!f&&i(u.key,null,u.attributes,null,null,null,null)}}function Fn(n,r){const t={key:n};return Mr(r.attributes)||(t.attributes=te({},r.attributes)),t}function Pn(n,r,t){const e={key:r,source:t.source.key,target:t.target.key};return Mr(t.attributes)||(e.attributes=te({},t.attributes)),n==="mixed"&&t.undirected&&(e.undirected=!0),e}function In(n){if(!ae(n))throw new D('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in n))throw new D("Graph.import: serialized node is missing its key.");if("attributes"in n&&(!ae(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function On(n){if(!ae(n))throw new D('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in n))throw new D("Graph.import: serialized edge is missing its source.");if(!("target"in n))throw new D("Graph.import: serialized edge is missing its target.");if("attributes"in n&&(!ae(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in n&&typeof n.undirected!="boolean")throw new D("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const zn=$i(),$n=new Set(["directed","undirected","mixed"]),Jt=new Set(["domain","_events","_eventsCount","_maxListeners"]),Un=[{name:n=>`${n}Edge`,generateKey:!0},{name:n=>`${n}DirectedEdge`,generateKey:!0,type:"directed"},{name:n=>`${n}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:n=>`${n}EdgeWithKey`},{name:n=>`${n}DirectedEdgeWithKey`,type:"directed"},{name:n=>`${n}UndirectedEdgeWithKey`,type:"undirected"}],jn={allowSelfLoops:!0,multi:!1,type:"mixed"};function Mn(n,r,t){if(t&&!ae(t))throw new D(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(r=""+r,t=t||{},n._nodes.has(r))throw new U(`Graph.addNode: the "${r}" node already exist in the graph.`);const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function er(n,r,t){const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function Zr(n,r,t,e,i,o,a,s){if(!e&&n.type==="undirected")throw new U(`Graph.${r}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(e&&n.type==="directed")throw new U(`Graph.${r}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!ae(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!n.allowSelfLoops&&o===a)throw new U(`Graph.${r}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=n._nodes.get(o),l=n._nodes.get(a);if(!u)throw new A(`Graph.${r}: source node "${o}" not found.`);if(!l)throw new A(`Graph.${r}: target node "${a}" not found.`);const h={key:null,undirected:e,source:o,target:a,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new U(`Graph.${r}: the "${i}" edge already exists in the graph.`);if(!n.multi&&(e?typeof u.undirected[a]<"u":typeof u.out[a]<"u"))throw new U(`Graph.${r}: an edge linking "${o}" to "${a}" 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 d=new qe(e,i,u,l,s);n._edges.set(i,d);const c=o===a;return e?(u.undirectedDegree++,l.undirectedDegree++,c&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,c&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?d.attachMulti():d.attach(),e?n._undirectedSize++:n._directedSize++,h.key=i,n.emit("edgeAdded",h),i}function Bn(n,r,t,e,i,o,a,s,u){if(!e&&n.type==="undirected")throw new U(`Graph.${r}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(e&&n.type==="directed")throw new U(`Graph.${r}: 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 D(`Graph.${r}: invalid updater function. Expecting a function but got "${s}"`)}else if(!ae(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let l;if(u&&(l=s,s=void 0),!n.allowSelfLoops&&o===a)throw new U(`Graph.${r}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let h=n._nodes.get(o),d=n._nodes.get(a),c,f;if(!t&&(c=n._edges.get(i),c)){if((c.source.key!==o||c.target.key!==a)&&(!e||c.source.key!==a||c.target.key!==o))throw new U(`Graph.${r}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${c.source.key}", "${c.target.key}").`);f=c}if(!f&&!n.multi&&h&&(f=e?h.undirected[a]:h.out[a]),f){const _=[f.key,!1,!1,!1];if(u?!l:!s)return _;if(u){const R=f.attributes;f.attributes=l(R),n.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else te(f.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return _}s=s||{},u&&l&&(s=l(s));const b={key:null,undirected:e,source:o,target:a,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new U(`Graph.${r}: the "${i}" edge already exists in the graph.`);let w=!1,E=!1;h||(h=er(n,o,{}),w=!0,o===a&&(d=h,E=!0)),d||(d=er(n,a,{}),E=!0),c=new qe(e,i,h,d,s),n._edges.set(i,c);const L=o===a;return e?(h.undirectedDegree++,d.undirectedDegree++,L&&(h.undirectedLoops++,n._undirectedSelfLoopCount++)):(h.outDegree++,d.inDegree++,L&&(h.directedLoops++,n._directedSelfLoopCount++)),n.multi?c.attachMulti():c.attach(),e?n._undirectedSize++:n._directedSize++,b.key=i,n.emit("edgeAdded",b),[i,!0,w,E]}function Me(n,r){n._edges.delete(r.key);const{source:t,target:e,attributes:i}=r,o=r.undirected,a=t===e;o?(t.undirectedDegree--,e.undirectedDegree--,a&&(t.undirectedLoops--,n._undirectedSelfLoopCount--)):(t.outDegree--,e.inDegree--,a&&(t.directedLoops--,n._directedSelfLoopCount--)),n.multi?r.detachMulti():r.detach(),o?n._undirectedSize--:n._directedSize--,n.emit("edgeDropped",{key:r.key,attributes:i,source:t.key,target:e.key,undirected:o})}class X extends jr.EventEmitter{constructor(r){if(super(),r=te({},jn,r),typeof r.multi!="boolean")throw new D(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${r.multi}".`);if(!$n.has(r.type))throw new D(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${r.type}".`);if(typeof r.allowSelfLoops!="boolean")throw new D(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${r.allowSelfLoops}".`);const t=r.type==="mixed"?Br:r.type==="directed"?Hr:Wr;de(this,"NodeDataClass",t);const e="geid_"+zn()+"_";let i=0;const o=()=>{let a;do a=e+i++;while(this._edges.has(a));return a};de(this,"_attributes",{}),de(this,"_nodes",new Map),de(this,"_edges",new Map),de(this,"_directedSize",0),de(this,"_undirectedSize",0),de(this,"_directedSelfLoopCount",0),de(this,"_undirectedSelfLoopCount",0),de(this,"_edgeKeyGenerator",o),de(this,"_options",r),Jt.forEach(a=>de(this,a,this[a])),ve(this,"order",()=>this._nodes.size),ve(this,"size",()=>this._edges.size),ve(this,"directedSize",()=>this._directedSize),ve(this,"undirectedSize",()=>this._undirectedSize),ve(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ve(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ve(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ve(this,"multi",this._options.multi),ve(this,"type",this._options.type),ve(this,"allowSelfLoops",this._options.allowSelfLoops),ve(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(r){return this._nodes.has(""+r)}hasDirectedEdge(r,t){if(this.type==="undirected")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&!i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.out.hasOwnProperty(t):!1}throw new D(`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(r,t){if(this.type==="directed")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.undirected.hasOwnProperty(t):!1}throw new D(`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(r,t){if(arguments.length===1){const e=""+r;return this._edges.has(e)}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?typeof e.out<"u"&&e.out.hasOwnProperty(t)||typeof e.undirected<"u"&&e.undirected.hasOwnProperty(t):!1}throw new D(`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(r,t){if(this.type==="undirected")return;if(r=""+r,t=""+t,this.multi)throw new U("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const e=this._nodes.get(r);if(!e)throw new A(`Graph.directedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||void 0;if(i)return i.key}undirectedEdge(r,t){if(this.type==="directed")return;if(r=""+r,t=""+t,this.multi)throw new U("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const e=this._nodes.get(r);if(!e)throw new A(`Graph.undirectedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=e.undirected&&e.undirected[t]||void 0;if(i)return i.key}edge(r,t){if(this.multi)throw new U("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.edge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||e.undirected&&e.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areDirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in||t in e.out}areOutNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.out}areInNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in}areUndirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areUndirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="directed"?!1:t in e.undirected}areNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&(t in e.in||t in e.out)||this.type!=="directed"&&t in e.undirected}areInboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.in||this.type!=="directed"&&t in e.undirected}areOutboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.out||this.type!=="directed"&&t in e.undirected}inDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegree: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree),e}outboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.outDegree),e}degree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree),e}inDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree,i+=t.directedLoops),e-i}outboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.outDegree,i+=t.directedLoops),e-i}degreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree,i+=t.directedLoops*2),e-i}source(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.source: could not find the "${r}" edge in the graph.`);return t.source.key}target(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.target: could not find the "${r}" edge in the graph.`);return t.target.key}extremities(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.extremities: could not find the "${r}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(r,t){r=""+r,t=""+t;const e=this._edges.get(t);if(!e)throw new A(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=e.source.key,o=e.target.key;if(r===i)return o;if(r===o)return i;throw new A(`Graph.opposite: the "${r}" node is not attached to the "${t}" edge (${i}, ${o}).`)}hasExtremity(r,t){r=""+r,t=""+t;const e=this._edges.get(r);if(!e)throw new A(`Graph.hasExtremity: could not find the "${r}" edge in the graph.`);return e.source.key===t||e.target.key===t}isUndirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isUndirected: could not find the "${r}" edge in the graph.`);return t.undirected}isDirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isDirected: could not find the "${r}" edge in the graph.`);return!t.undirected}isSelfLoop(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isSelfLoop: could not find the "${r}" edge in the graph.`);return t.source===t.target}addNode(r,t){return Mn(this,r,t).key}mergeNode(r,t){if(t&&!ae(t))throw new D(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);r=""+r,t=t||{};let e=this._nodes.get(r);return e?(t&&(te(e.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:r,attributes:e.attributes,data:t})),[r,!1]):(e=new this.NodeDataClass(r,t),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:t}),[r,!0])}updateNode(r,t){if(t&&typeof t!="function")throw new D(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);r=""+r;let e=this._nodes.get(r);if(e){if(t){const o=e.attributes;e.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:r,attributes:e.attributes})}return[r,!1]}const i=t?t({}):{};return e=new this.NodeDataClass(r,i),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:i}),[r,!0]}dropNode(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.dropNode: could not find the "${r}" node in the graph.`);let e;if(this.type!=="undirected"){for(const i in t.out){e=t.out[i];do Me(this,e),e=e.next;while(e)}for(const i in t.in){e=t.in[i];do Me(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const i in t.undirected){e=t.undirected[i];do Me(this,e),e=e.next;while(e)}this._nodes.delete(r),this.emit("nodeDropped",{key:r,attributes:t.attributes})}dropEdge(r){let t;if(arguments.length>1){const e=""+arguments[0],i=""+arguments[1];if(t=fe(this,e,i,this.type),!t)throw new A(`Graph.dropEdge: could not find the "${e}" -> "${i}" edge in the graph.`)}else if(r=""+r,t=this._edges.get(r),!t)throw new A(`Graph.dropEdge: could not find the "${r}" edge in the graph.`);return Me(this,t),this}dropDirectedEdge(r,t){if(arguments.length<2)throw new U("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 U("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.");r=""+r,t=""+t;const e=fe(this,r,t,"directed");if(!e)throw new A(`Graph.dropDirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Me(this,e),this}dropUndirectedEdge(r,t){if(arguments.length<2)throw new U("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 U("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 e=fe(this,r,t,"undirected");if(!e)throw new A(`Graph.dropUndirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Me(this,e),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const r=this._nodes.values();let t;for(;t=r.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(r){return this._attributes[r]}getAttributes(){return this._attributes}hasAttribute(r){return this._attributes.hasOwnProperty(r)}setAttribute(r,t){return this._attributes[r]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}updateAttribute(r,t){if(typeof t!="function")throw new D("Graph.updateAttribute: updater should be a function.");const e=this._attributes[r];return this._attributes[r]=t(e),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}removeAttribute(r){return delete this._attributes[r],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:r}),this}replaceAttributes(r){if(!ae(r))throw new D("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=r,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(r){if(!ae(r))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return te(this._attributes,r),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:r}),this}updateAttributes(r){if(typeof r!="function")throw new D("Graph.updateAttributes: provided updater is not a function.");return this._attributes=r(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(r,t){if(typeof r!="function")throw new D("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new D("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._nodes.values();let i,o;for(;i=e.next(),i.done!==!0;)o=i.value,o.attributes=r(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(r,t){if(typeof r!="function")throw new D("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new D("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._edges.values();let i,o,a,s;for(;i=e.next(),i.done!==!0;)o=i.value,a=o.source,s=o.target,o.attributes=r(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntry: expecting a callback.");ut(!1,!1,!1,this,r)}forEachAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!1,!0,this,r)}forEachAssymetricAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ut(!1,!0,!1,this,r)}forEachAssymetricAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!0,!0,this,r)}nodes(){return Array.from(this._nodes.keys())}forEachNode(r){if(typeof r!="function")throw new D("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)}findNode(r){if(typeof r!="function")throw new D("Graph.findNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,r(i.key,i.attributes))return i.key}mapNodes(r){if(typeof r!="function")throw new D("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let e,i;const o=new Array(this.order);let a=0;for(;e=t.next(),e.done!==!0;)i=e.value,o[a++]=r(i.key,i.attributes);return o}someNode(r){if(typeof r!="function")throw new D("Graph.someNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,r(i.key,i.attributes))return!0;return!1}everyNode(r){if(typeof r!="function")throw new D("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,!r(i.key,i.attributes))return!1;return!0}filterNodes(r){if(typeof r!="function")throw new D("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let e,i;const o=[];for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(r,t){if(typeof r!="function")throw new D("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new D("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 e=t;const i=this._nodes.values();let o,a;for(;o=i.next(),o.done!==!0;)a=o.value,e=r(e,a.key,a.attributes);return e}nodeEntries(){const r=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=r.next();if(t.done)return t;const e=t.value;return{value:{node:e.key,attributes:e.attributes},done:!1}}}}export(){const r=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,o)=>{r[t++]=Fn(o,i)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((i,o)=>{e[t++]=Pn(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:r,edges:e}}import(r,t=!1){if(r instanceof X)return r.forEachNode((u,l)=>{t?this.mergeNode(u,l):this.addNode(u,l)}),r.forEachEdge((u,l,h,d,c,f,b)=>{t?b?this.mergeUndirectedEdgeWithKey(u,h,d,l):this.mergeDirectedEdgeWithKey(u,h,d,l):b?this.addUndirectedEdgeWithKey(u,h,d,l):this.addDirectedEdgeWithKey(u,h,d,l)}),this;if(!ae(r))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!ae(r.attributes))throw new D("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(r.attributes):this.replaceAttributes(r.attributes)}let e,i,o,a,s;if(r.nodes){if(o=r.nodes,!Array.isArray(o))throw new D("Graph.import: invalid nodes. Expecting an array.");for(e=0,i=o.length;e<i;e++){a=o[e],In(a);const{key:u,attributes:l}=a;t?this.mergeNode(u,l):this.addNode(u,l)}}if(r.edges){let u=!1;if(this.type==="undirected"&&(u=!0),o=r.edges,!Array.isArray(o))throw new D("Graph.import: invalid edges. Expecting an array.");for(e=0,i=o.length;e<i;e++){s=o[e],On(s);const{source:l,target:h,attributes:d,undirected:c=u}=s;let f;"key"in s?(f=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,l,h,d)):(f=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,l,h,d))}}return this}nullCopy(r){const t=new X(te({},this._options,r));return t.replaceAttributes(te({},this.getAttributes())),t}emptyCopy(r){const t=this.nullCopy(r);return this._nodes.forEach((e,i)=>{const o=te({},e.attributes);e=new t.NodeDataClass(i,o),t._nodes.set(i,e)}),t}copy(r){if(r=r||{},typeof r.type=="string"&&r.type!==this.type&&r.type!=="mixed")throw new U(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${r.type}" because this would mean losing information about the current graph.`);if(typeof r.multi=="boolean"&&r.multi!==this.multi&&r.multi!==!0)throw new U("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 r.allowSelfLoops=="boolean"&&r.allowSelfLoops!==this.allowSelfLoops&&r.allowSelfLoops!==!0)throw new U("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 t=this.emptyCopy(r),e=this._edges.values();let i,o;for(;i=e.next(),i.done!==!0;)o=i.value,Zr(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,te({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const r={};this._nodes.forEach((o,a)=>{r[a]=o.attributes});const t={},e={};this._edges.forEach((o,a)=>{const s=o.undirected?"--":"->";let u="",l=o.source.key,h=o.target.key,d;o.undirected&&l>h&&(d=l,l=h,h=d);const c=`(${l})${s}(${h})`;a.startsWith("geid_")?this.multi&&(typeof e[c]>"u"?e[c]=0:e[c]++,u+=`${e[c]}. `):u+=`[${a}]: `,u+=c,t[u]=o.attributes});const i={};for(const o in this)this.hasOwnProperty(o)&&!Jt.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=r,i.edges=t,de(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(X.prototype[Symbol.for("nodejs.util.inspect.custom")]=X.prototype.inspect);Un.forEach(n=>{["add","merge","update"].forEach(r=>{const t=n.name(r),e=r==="add"?Zr:Bn;n.generateKey?X.prototype[t]=function(i,o,a){return e(this,t,!0,(n.type||this.type)==="undirected",null,i,o,a,r==="update")}:X.prototype[t]=function(i,o,a,s){return e(this,t,!1,(n.type||this.type)==="undirected",i,o,a,s,r==="update")}})});Xi(X);ln(X);Sn(X);Nn(X);class Xr extends X{constructor(r){const t=te({type:"directed"},r);if("multi"in t&&t.multi!==!1)throw new D("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new D('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Qr extends X{constructor(r){const t=te({type:"undirected"},r);if("multi"in t&&t.multi!==!1)throw new D("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new D('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Jr extends X{constructor(r){const t=te({multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class ei extends X{constructor(r){const t=te({type:"directed",multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new D('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class ti extends X{constructor(r){const t=te({type:"undirected",multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new D('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Ke(n){n.from=function(r,t){const e=te({},r.options,t),i=new n(e);return i.import(r),i}}Ke(X);Ke(Xr);Ke(Qr);Ke(Jr);Ke(ei);Ke(ti);X.Graph=X;X.DirectedGraph=Xr;X.UndirectedGraph=Qr;X.MultiGraph=Jr;X.MultiDirectedGraph=ei;X.MultiUndirectedGraph=ti;X.InvalidArgumentsGraphError=D;X.NotFoundGraphError=A;X.UsageGraphError=U;function Hn(n,r){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var e=t.call(n,r);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function it(n){var r=Hn(n,"string");return typeof r=="symbol"?r:r+""}function re(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}function tr(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,it(e.key),e)}}function ie(n,r,t){return r&&tr(n.prototype,r),t&&tr(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function He(n){return He=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},He(n)}function ri(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ri=function(){return!!n})()}function Wn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Vn(n,r){if(r&&(typeof r=="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wn(n)}function le(n,r,t){return r=He(r),Vn(n,ri()?Reflect.construct(r,t||[],He(n).constructor):r.apply(n,t))}function It(n,r){return It=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},It(n,r)}function he(n,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(r&&r.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),r&&It(n,r)}function qn(n){if(Array.isArray(n))return n}function Kn(n,r){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var e,i,o,a,s=[],u=!0,l=!1;try{if(o=(t=t.call(n)).next,r===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(e=o.call(t)).done)&&(s.push(e.value),s.length!==r);u=!0);}catch(h){l=!0,i=h}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw i}}return s}}function Ot(n,r){(r==null||r>n.length)&&(r=n.length);for(var t=0,e=Array(r);t<r;t++)e[t]=n[t];return e}function ii(n,r){if(n){if(typeof n=="string")return Ot(n,r);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ot(n,r):void 0}}function Yn(){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 We(n,r){return qn(n)||Kn(n,r)||ii(n,r)||Yn()}var Ct={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"},ni=new Int8Array(4),St=new Int32Array(ni.buffer,0,1),Zn=new Float32Array(ni.buffer,0,1),Xn=/^\s*rgba?\s*\(/,Qn=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Jn(n){var r=0,t=0,e=0,i=1;if(n[0]==="#")n.length===4?(r=parseInt(n.charAt(1)+n.charAt(1),16),t=parseInt(n.charAt(2)+n.charAt(2),16),e=parseInt(n.charAt(3)+n.charAt(3),16)):(r=parseInt(n.charAt(1)+n.charAt(2),16),t=parseInt(n.charAt(3)+n.charAt(4),16),e=parseInt(n.charAt(5)+n.charAt(6),16)),n.length===9&&(i=parseInt(n.charAt(7)+n.charAt(8),16)/255);else if(Xn.test(n)){var
|
|
3
|
-
`.concat(
|
|
4
|
-
`).concat(t))}return i}function
|
|
5
|
-
`,
|
|
1
|
+
import{g as $r,r as G,t as Et,j as g,a as Oe,O as Ii}from"./index-CsH_Hv51.js";import{C as we,b as pt,c as Ur}from"./constants-lq4BIQN3.js";var st={exports:{}},Xt;function Oi(){if(Xt)return st.exports;Xt=1;var n=typeof Reflect=="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(y,S,C){return Function.prototype.apply.call(y,S,C)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(y){return Object.getOwnPropertyNames(y).concat(Object.getOwnPropertySymbols(y))}:t=function(y){return Object.getOwnPropertyNames(y)};function e(m){console&&console.warn&&console.warn(m)}var i=Number.isNaN||function(y){return y!==y};function a(){a.init.call(this)}st.exports=a,st.exports.once=L,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function s(m){if(typeof m!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof m)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(m){if(typeof m!="number"||m<0||i(m))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+m+".");o=m}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(y){if(typeof y!="number"||y<0||i(y))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+y+".");return this._maxListeners=y,this};function u(m){return m._maxListeners===void 0?a.defaultMaxListeners:m._maxListeners}a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(y){for(var S=[],C=1;C<arguments.length;C++)S.push(arguments[C]);var P=y==="error",O=this._events;if(O!==void 0)P=P&&O.error===void 0;else if(!P)return!1;if(P){var z;if(S.length>0&&(z=S[0]),z instanceof Error)throw z;var Y=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw Y.context=z,Y}var j=O[y];if(j===void 0)return!1;if(typeof j=="function")r(j,this,S);else for(var p=j.length,Q=b(j,p),C=0;C<p;++C)r(Q[C],this,S);return!0};function l(m,y,S,C){var P,O,z;if(s(S),O=m._events,O===void 0?(O=m._events=Object.create(null),m._eventsCount=0):(O.newListener!==void 0&&(m.emit("newListener",y,S.listener?S.listener:S),O=m._events),z=O[y]),z===void 0)z=O[y]=S,++m._eventsCount;else if(typeof z=="function"?z=O[y]=C?[S,z]:[z,S]:C?z.unshift(S):z.push(S),P=u(m),P>0&&z.length>P&&!z.warned){z.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(y)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=m,Y.type=y,Y.count=z.length,e(Y)}return m}a.prototype.addListener=function(y,S){return l(this,y,S,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(y,S){return l(this,y,S,!0)};function h(){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 d(m,y,S){var C={fired:!1,wrapFn:void 0,target:m,type:y,listener:S},P=h.bind(C);return P.listener=S,C.wrapFn=P,P}a.prototype.once=function(y,S){return s(S),this.on(y,d(this,y,S)),this},a.prototype.prependOnceListener=function(y,S){return s(S),this.prependListener(y,d(this,y,S)),this},a.prototype.removeListener=function(y,S){var C,P,O,z,Y;if(s(S),P=this._events,P===void 0)return this;if(C=P[y],C===void 0)return this;if(C===S||C.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete P[y],P.removeListener&&this.emit("removeListener",y,C.listener||S));else if(typeof C!="function"){for(O=-1,z=C.length-1;z>=0;z--)if(C[z]===S||C[z].listener===S){Y=C[z].listener,O=z;break}if(O<0)return this;O===0?C.shift():w(C,O),C.length===1&&(P[y]=C[0]),P.removeListener!==void 0&&this.emit("removeListener",y,Y||S)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(y){var S,C,P;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[y]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[y]),this;if(arguments.length===0){var O=Object.keys(C),z;for(P=0;P<O.length;++P)z=O[P],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=C[y],typeof S=="function")this.removeListener(y,S);else if(S!==void 0)for(P=S.length-1;P>=0;P--)this.removeListener(y,S[P]);return this};function c(m,y,S){var C=m._events;if(C===void 0)return[];var P=C[y];return P===void 0?[]:typeof P=="function"?S?[P.listener||P]:[P]:S?E(P):b(P,P.length)}a.prototype.listeners=function(y){return c(this,y,!0)},a.prototype.rawListeners=function(y){return c(this,y,!1)},a.listenerCount=function(m,y){return typeof m.listenerCount=="function"?m.listenerCount(y):f.call(m,y)},a.prototype.listenerCount=f;function f(m){var y=this._events;if(y!==void 0){var S=y[m];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function b(m,y){for(var S=new Array(y),C=0;C<y;++C)S[C]=m[C];return S}function w(m,y){for(;y+1<m.length;y++)m[y]=m[y+1];m.pop()}function E(m){for(var y=new Array(m.length),S=0;S<y.length;++S)y[S]=m[S].listener||m[S];return y}function L(m,y){return new Promise(function(S,C){function P(z){m.removeListener(y,O),C(z)}function O(){typeof m.removeListener=="function"&&m.removeListener("error",P),S([].slice.call(arguments))}R(m,y,O,{once:!0}),y!=="error"&&_(m,P,{once:!0})})}function _(m,y,S){typeof m.on=="function"&&R(m,"error",y,S)}function R(m,y,S,C){if(typeof m.on=="function")C.once?m.once(y,S):m.on(y,S);else if(typeof m.addEventListener=="function")m.addEventListener(y,function P(O){C.once&&m.removeEventListener(y,P),S(O)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof m)}return st.exports}var jr=Oi();function zi(){const n=arguments[0];for(let r=1,t=arguments.length;r<t;r++)if(arguments[r])for(const e in arguments[r])n[e]=arguments[r][e];return n}let te=zi;typeof Object.assign=="function"&&(te=Object.assign);function fe(n,r,t,e){const i=n._nodes.get(r);let a=null;return i&&(e==="mixed"?a=i.out&&i.out[t]||i.undirected&&i.undirected[t]:e==="directed"?a=i.out&&i.out[t]:a=i.undirected&&i.undirected[t]),a}function oe(n){return typeof n=="object"&&n!==null}function Mr(n){let r;for(r in n)return!1;return!0}function de(n,r,t){Object.defineProperty(n,r,{enumerable:!1,configurable:!1,writable:!0,value:t})}function ve(n,r,t){const e={enumerable:!0,configurable:!0};typeof t=="function"?e.get=t:(e.value=t,e.writable=!1),Object.defineProperty(n,r,e)}function Qt(n){return!(!oe(n)||n.attributes&&!Array.isArray(n.attributes))}function $i(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function ke(){const n=arguments;let r=null,t=-1;return{[Symbol.iterator](){return this},next(){let e=null;do{if(r===null){if(t++,t>=n.length)return{done:!0};r=n[t][Symbol.iterator]()}if(e=r.next(),e.done){r=null;continue}break}while(!0);return e}}}function Ve(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Bt extends Error{constructor(r){super(),this.name="GraphError",this.message=r}}class D extends Bt{constructor(r){super(r),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}class A extends Bt{constructor(r){super(r),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,A.prototype.constructor)}}class U extends Bt{constructor(r){super(r),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,U.prototype.constructor)}}function Br(n,r){this.key=n,this.attributes=r,this.clear()}Br.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 Hr(n,r){this.key=n,this.attributes=r,this.clear()}Hr.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Wr(n,r){this.key=n,this.attributes=r,this.clear()}Wr.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function qe(n,r,t,e,i){this.key=r,this.attributes=i,this.undirected=n,this.source=t,this.target=e}qe.prototype.attach=function(){let n="out",r="in";this.undirected&&(n=r="undirected");const t=this.source.key,e=this.target.key;this.source[n][e]=this,!(this.undirected&&t===e)&&(this.target[r][t]=this)};qe.prototype.attachMulti=function(){let n="out",r="in";const t=this.source.key,e=this.target.key;this.undirected&&(n=r="undirected");const i=this.source[n],a=i[e];if(typeof a>"u"){i[e]=this,this.undirected&&t===e||(this.target[r][t]=this);return}a.previous=this,this.next=a,i[e]=this,this.target[r][t]=this};qe.prototype.detach=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),delete this.source[t][r],delete this.target[e][n]};qe.prototype.detachMulti=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][r],delete this.target[e][n]):(this.next.previous=void 0,this.source[t][r]=this.next,this.target[e][n]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Vr=0,qr=1,Ui=2,Kr=3;function Ae(n,r,t,e,i,a,o){let s,u,l,h;if(e=""+e,t===Vr){if(s=n._nodes.get(e),!s)throw new A(`Graph.${r}: could not find the "${e}" node in the graph.`);l=i,h=a}else if(t===Kr){if(i=""+i,u=n._edges.get(i),!u)throw new A(`Graph.${r}: could not find the "${i}" edge in the graph.`);const d=u.source.key,c=u.target.key;if(e===d)s=u.target;else if(e===c)s=u.source;else throw new A(`Graph.${r}: the "${e}" node is not attached to the "${i}" edge (${d}, ${c}).`);l=a,h=o}else{if(u=n._edges.get(e),!u)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`);t===qr?s=u.source:s=u.target,l=i,h=a}return[s,l,h]}function ji(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return o.attributes[s]}}function Mi(n,r,t){n.prototype[r]=function(e,i){const[a]=Ae(this,r,t,e,i);return a.attributes}}function Bi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return o.attributes.hasOwnProperty(s)}}function Hi(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,l]=Ae(this,r,t,e,i,a,o);return s.attributes[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Wi(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,l]=Ae(this,r,t,e,i,a,o);if(typeof l!="function")throw new D(`Graph.${r}: updater should be a function.`);const h=s.attributes,d=l(h[u]);return h[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Vi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return delete o.attributes[s],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:s}),this}}function qi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(!oe(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return o.attributes=s,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Ki(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(!oe(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return te(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Yi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(typeof s!="function")throw new D(`Graph.${r}: 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 Zi=[{name:n=>`get${n}Attribute`,attacher:ji},{name:n=>`get${n}Attributes`,attacher:Mi},{name:n=>`has${n}Attribute`,attacher:Bi},{name:n=>`set${n}Attribute`,attacher:Hi},{name:n=>`update${n}Attribute`,attacher:Wi},{name:n=>`remove${n}Attribute`,attacher:Vi},{name:n=>`replace${n}Attributes`,attacher:qi},{name:n=>`merge${n}Attributes`,attacher:Ki},{name:n=>`update${n}Attributes`,attacher:Yi}];function Xi(n){Zi.forEach(function({name:r,attacher:t}){t(n,r("Node"),Vr),t(n,r("Source"),qr),t(n,r("Target"),Ui),t(n,r("Opposite"),Kr)})}function Qi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes[i]}}function Ji(n,r,t){n.prototype[r]=function(e){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new U(`Graph.${r}: 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=""+e,o=""+arguments[1];if(i=fe(this,a,o,t),!i)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,i=this._edges.get(e),!i)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return i.attributes}}function en(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function tn(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new U(`Graph.${r}: 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=""+e,u=""+i;if(i=arguments[2],a=arguments[3],o=fe(this,s,u,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return o.attributes[i]=a,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function rn(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new U(`Graph.${r}: 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=""+e,u=""+i;if(i=arguments[2],a=arguments[3],o=fe(this,s,u,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof a!="function")throw new D(`Graph.${r}: updater should be a function.`);return o.attributes[i]=a(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function nn(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return delete a.attributes[i],this.emit("edgeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:i}),this}}function an(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!oe(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return a.attributes=i,this.emit("edgeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function on(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!oe(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return te(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function sn(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: 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=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: 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(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof i!="function")throw new D(`Graph.${r}: provided updater is not a function.`);return a.attributes=i(a.attributes),this.emit("edgeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const un=[{name:n=>`get${n}Attribute`,attacher:Qi},{name:n=>`get${n}Attributes`,attacher:Ji},{name:n=>`has${n}Attribute`,attacher:en},{name:n=>`set${n}Attribute`,attacher:tn},{name:n=>`update${n}Attribute`,attacher:rn},{name:n=>`remove${n}Attribute`,attacher:nn},{name:n=>`replace${n}Attributes`,attacher:an},{name:n=>`merge${n}Attributes`,attacher:on},{name:n=>`update${n}Attributes`,attacher:sn}];function ln(n){un.forEach(function({name:r,attacher:t}){t(n,r("Edge"),"mixed"),t(n,r("DirectedEdge"),"directed"),t(n,r("UndirectedEdge"),"undirected")})}const hn=[{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 dn(n,r,t,e){let i=!1;for(const a in r){if(a===e)continue;const o=r[a];if(i=t(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),n&&i)return o.key}}function cn(n,r,t,e){let i,a,o,s=!1;for(const u in r)if(u!==e){i=r[u];do{if(a=i.source,o=i.target,s=t(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),n&&s)return i.key;i=i.next}while(i!==void 0)}}function xt(n,r){const t=Object.keys(n),e=t.length;let i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=e)return{done:!0};const o=t[a++];if(o===r){i=void 0;continue}i=n[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function fn(n,r,t,e){const i=r[t];if(!i)return;const a=i.source,o=i.target;if(e(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&n)return i.key}function gn(n,r,t,e){let i=r[t];if(!i)return;let a=!1;do{if(a=e(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),n&&a)return i.key;i=i.next}while(i!==void 0)}function _t(n,r){let t=n[r];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const i={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:i}}};let e=!1;return{[Symbol.iterator](){return this},next(){return e===!0?{done:!0}:(e=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function pn(n,r){if(n.size===0)return[];if(r==="mixed"||r===n.type)return Array.from(n._edges.keys());const t=r==="undirected"?n.undirectedSize:n.directedSize,e=new Array(t),i=r==="undirected",a=n._edges.values();let o=0,s,u;for(;s=a.next(),s.done!==!0;)u=s.value,u.undirected===i&&(e[o++]=u.key);return e}function Yr(n,r,t,e){if(r.size===0)return;const i=t!=="mixed"&&t!==r.type,a=t==="undirected";let o,s,u=!1;const l=r._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;const{key:h,attributes:d,source:c,target:f}=s;if(u=e(h,d,c.key,f.key,c.attributes,f.attributes,s.undirected),n&&u)return h}}function mn(n,r){if(n.size===0)return Ve();const t=r!=="mixed"&&r!==n.type,e=r==="undirected",i=n._edges.values();return{[Symbol.iterator](){return this},next(){let a,o;for(;;){if(a=i.next(),a.done)return a;if(o=a.value,!(t&&o.undirected!==e))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 Ht(n,r,t,e,i,a){const o=r?cn:dn;let s;if(t!=="undirected"&&(e!=="out"&&(s=o(n,i.in,a),n&&s)||e!=="in"&&(s=o(n,i.out,a,e?void 0:i.key),n&&s))||t!=="directed"&&(s=o(n,i.undirected,a),n&&s))return s}function vn(n,r,t,e){const i=[];return Ht(!1,n,r,t,e,function(a){i.push(a)}),i}function yn(n,r,t){let e=Ve();return n!=="undirected"&&(r!=="out"&&typeof t.in<"u"&&(e=ke(e,xt(t.in))),r!=="in"&&typeof t.out<"u"&&(e=ke(e,xt(t.out,r?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(e=ke(e,xt(t.undirected))),e}function Wt(n,r,t,e,i,a,o){const s=t?gn:fn;let u;if(r!=="undirected"&&(typeof i.in<"u"&&e!=="out"&&(u=s(n,i.in,a,o),n&&u)||typeof i.out<"u"&&e!=="in"&&(e||i.key!==a)&&(u=s(n,i.out,a,o),n&&u))||r!=="directed"&&typeof i.undirected<"u"&&(u=s(n,i.undirected,a,o),n&&u))return u}function bn(n,r,t,e,i){const a=[];return Wt(!1,n,r,t,e,i,function(o){a.push(o)}),a}function wn(n,r,t,e){let i=Ve();return n!=="undirected"&&(typeof t.in<"u"&&r!=="out"&&e in t.in&&(i=ke(i,_t(t.in,e))),typeof t.out<"u"&&r!=="in"&&e in t.out&&(r||t.key!==e)&&(i=ke(i,_t(t.out,e)))),n!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(i=ke(i,_t(t.undirected,e))),i}function En(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(a,o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];if(!arguments.length)return pn(this,e);if(arguments.length===1){a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${t}: could not find the "${a}" node in the graph.`);return vn(this.multi,e==="mixed"?this.type:e,i,s)}if(arguments.length===2){a=""+a,o=""+o;const s=this._nodes.get(a);if(!s)throw new A(`Graph.${t}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new A(`Graph.${t}: could not find the "${o}" target node in the graph.`);return bn(e,this.multi,i,s,o)}throw new D(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function xn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(l,h,d){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return d=l,Yr(!1,this,e,d);if(arguments.length===2){l=""+l,d=h;const c=this._nodes.get(l);if(typeof c>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);return Ht(!1,this.multi,e==="mixed"?this.type:e,i,c,d)}if(arguments.length===3){l=""+l,h=""+h;const c=this._nodes.get(l);if(!c)throw new A(`Graph.${a}: could not find the "${l}" 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 Wt(!1,e,this.multi,i,c,h,d)}throw new D(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop();let d;if(l.length===0){let c=0;e!=="directed"&&(c+=this.undirectedSize),e!=="undirected"&&(c+=this.directedSize),d=new Array(c);let f=0;l.push((b,w,E,L,_,R,m)=>{d[f++]=h(b,w,E,L,_,R,m)})}else d=[],l.push((c,f,b,w,E,L,_)=>{d.push(h(c,f,b,w,E,L,_))});return this[a].apply(this,l),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop(),d=[];return l.push((c,f,b,w,E,L,_)=>{h(c,f,b,w,E,L,_)&&d.push(c)}),this[a].apply(this,l),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(){let l=Array.prototype.slice.call(arguments);if(l.length<2||l.length>4)throw new D(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${l.length}).`);if(typeof l[l.length-1]=="function"&&typeof l[l.length-2]!="function")throw new D(`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 h,d;l.length===2?(h=l[0],d=l[1],l=[]):l.length===3?(h=l[1],d=l[2],l=[l[0]]):l.length===4&&(h=l[2],d=l[3],l=[l[0],l[1]]);let c=d;return l.push((f,b,w,E,L,_,R)=>{c=h(c,f,b,w,E,L,_,R)}),this[a].apply(this,l),c}}function _n(n,r){const{name:t,type:e,direction:i}=r,a="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(u,l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return h=u,Yr(!0,this,e,h);if(arguments.length===2){u=""+u,h=l;const d=this._nodes.get(u);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${u}" node in the graph.`);return Ht(!0,this.multi,e==="mixed"?this.type:e,i,d,h)}if(arguments.length===3){u=""+u,l=""+l;const d=this._nodes.get(u);if(!d)throw new A(`Graph.${a}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new A(`Graph.${a}: could not find the "${l}" target node in the graph.`);return Wt(!0,e,this.multi,i,d,l,h)}throw new D(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,f,b,w,E,L)=>l(d,c,f,b,w,E,L)),!!this[a].apply(this,u)};const s="every"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,f,b,w,E,L)=>!l(d,c,f,b,w,E,L)),!this[a].apply(this,u)}}function Cn(n,r){const{name:t,type:e,direction:i}=r,a=t.slice(0,-1)+"Entries";n.prototype[a]=function(o,s){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();if(!arguments.length)return mn(this,e);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 yn(e,i,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 wn(e,i,u,s)}throw new D(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Sn(n){hn.forEach(r=>{En(n,r),xn(n,r),_n(n,r),Cn(n,r)})}const Tn=[{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 mt(){this.A=null,this.B=null}mt.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};mt.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function Ze(n,r,t,e,i){for(const a in e){const o=e[a],s=o.source,u=o.target,l=s===t?u:s;if(r&&r.has(l.key))continue;const h=i(l.key,l.attributes);if(n&&h)return l.key}}function Vt(n,r,t,e,i){if(r!=="mixed"){if(r==="undirected")return Ze(n,null,e,e.undirected,i);if(typeof t=="string")return Ze(n,null,e,e[t],i)}const a=new mt;let o;if(r!=="undirected"){if(t!=="out"){if(o=Ze(n,null,e,e.in,i),n&&o)return o;a.wrap(e.in)}if(t!=="in"){if(o=Ze(n,a,e,e.out,i),n&&o)return o;a.wrap(e.out)}}if(r!=="directed"&&(o=Ze(n,a,e,e.undirected,i),n&&o))return o}function Rn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Object.keys(t.undirected);if(typeof r=="string")return Object.keys(t[r])}const e=[];return Vt(!1,n,r,t,function(i){e.push(i)}),e}function Xe(n,r,t){const e=Object.keys(t),i=e.length;let a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return n&&n.wrap(t),{done:!0};const s=t[e[a++]],u=s.source,l=s.target;if(o=u===r?l:u,n&&n.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function kn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Xe(null,t,t.undirected);if(typeof r=="string")return Xe(null,t,t[r])}let e=Ve();const i=new mt;return n!=="undirected"&&(r!=="out"&&(e=ke(e,Xe(i,t,t.in))),r!=="in"&&(e=ke(e,Xe(i,t,t.out)))),n!=="directed"&&(e=ke(e,Xe(i,t,t.undirected))),e}function An(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];a=""+a;const o=this._nodes.get(a);if(typeof o>"u")throw new A(`Graph.${t}: could not find the "${a}" node in the graph.`);return Rn(e==="mixed"?this.type:e,i,o)}}function Ln(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);Vt(!1,e==="mixed"?this.type:e,i,d,h)};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(l,h){const d=[];return this[a](l,(c,f)=>{d.push(h(c,f))}),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(l,h){const d=[];return this[a](l,(c,f)=>{h(c,f)&&d.push(c)}),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(l,h,d){if(arguments.length<3)throw new D(`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=d;return this[a](l,(f,b)=>{c=h(c,f,b)}),c}}function Dn(n,r){const{name:t,type:e,direction:i}=r,a=t[0].toUpperCase()+t.slice(1,-1),o="find"+a;n.prototype[o]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);return Vt(!0,e==="mixed"?this.type:e,i,d,h)};const s="some"+a;n.prototype[s]=function(l,h){return!!this[o](l,h)};const u="every"+a;n.prototype[u]=function(l,h){return!this[o](l,(c,f)=>!h(c,f))}}function Gn(n,r){const{name:t,type:e,direction:i}=r,a=t.slice(0,-1)+"Entries";n.prototype[a]=function(o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();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 kn(e==="mixed"?this.type:e,i,s)}}function Nn(n){Tn.forEach(r=>{An(n,r),Ln(n,r),Dn(n,r),Gn(n,r)})}function ut(n,r,t,e,i){const a=e._nodes.values(),o=e.type;let s,u,l,h,d,c;for(;s=a.next(),s.done!==!0;){let f=!1;if(u=s.value,o!=="undirected"){h=u.out;for(l in h){d=h[l];do c=d.target,f=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(o!=="directed"){h=u.undirected;for(l in h)if(!(r&&u.key>l)){d=h[l];do c=d.target,c.key!==l&&(c=d.source),f=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}t&&!f&&i(u.key,null,u.attributes,null,null,null,null)}}function Fn(n,r){const t={key:n};return Mr(r.attributes)||(t.attributes=te({},r.attributes)),t}function Pn(n,r,t){const e={key:r,source:t.source.key,target:t.target.key};return Mr(t.attributes)||(e.attributes=te({},t.attributes)),n==="mixed"&&t.undirected&&(e.undirected=!0),e}function In(n){if(!oe(n))throw new D('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in n))throw new D("Graph.import: serialized node is missing its key.");if("attributes"in n&&(!oe(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function On(n){if(!oe(n))throw new D('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in n))throw new D("Graph.import: serialized edge is missing its source.");if(!("target"in n))throw new D("Graph.import: serialized edge is missing its target.");if("attributes"in n&&(!oe(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in n&&typeof n.undirected!="boolean")throw new D("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const zn=$i(),$n=new Set(["directed","undirected","mixed"]),Jt=new Set(["domain","_events","_eventsCount","_maxListeners"]),Un=[{name:n=>`${n}Edge`,generateKey:!0},{name:n=>`${n}DirectedEdge`,generateKey:!0,type:"directed"},{name:n=>`${n}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:n=>`${n}EdgeWithKey`},{name:n=>`${n}DirectedEdgeWithKey`,type:"directed"},{name:n=>`${n}UndirectedEdgeWithKey`,type:"undirected"}],jn={allowSelfLoops:!0,multi:!1,type:"mixed"};function Mn(n,r,t){if(t&&!oe(t))throw new D(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(r=""+r,t=t||{},n._nodes.has(r))throw new U(`Graph.addNode: the "${r}" node already exist in the graph.`);const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function er(n,r,t){const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function Zr(n,r,t,e,i,a,o,s){if(!e&&n.type==="undirected")throw new U(`Graph.${r}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(e&&n.type==="directed")throw new U(`Graph.${r}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!oe(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`);if(a=""+a,o=""+o,s=s||{},!n.allowSelfLoops&&a===o)throw new U(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=n._nodes.get(a),l=n._nodes.get(o);if(!u)throw new A(`Graph.${r}: source node "${a}" not found.`);if(!l)throw new A(`Graph.${r}: target node "${o}" not found.`);const h={key:null,undirected:e,source:a,target:o,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new U(`Graph.${r}: the "${i}" edge already exists in the graph.`);if(!n.multi&&(e?typeof u.undirected[o]<"u":typeof u.out[o]<"u"))throw new U(`Graph.${r}: 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 d=new qe(e,i,u,l,s);n._edges.set(i,d);const c=a===o;return e?(u.undirectedDegree++,l.undirectedDegree++,c&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,c&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?d.attachMulti():d.attach(),e?n._undirectedSize++:n._directedSize++,h.key=i,n.emit("edgeAdded",h),i}function Bn(n,r,t,e,i,a,o,s,u){if(!e&&n.type==="undirected")throw new U(`Graph.${r}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(e&&n.type==="directed")throw new U(`Graph.${r}: 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 D(`Graph.${r}: invalid updater function. Expecting a function but got "${s}"`)}else if(!oe(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let l;if(u&&(l=s,s=void 0),!n.allowSelfLoops&&a===o)throw new U(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let h=n._nodes.get(a),d=n._nodes.get(o),c,f;if(!t&&(c=n._edges.get(i),c)){if((c.source.key!==a||c.target.key!==o)&&(!e||c.source.key!==o||c.target.key!==a))throw new U(`Graph.${r}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${c.source.key}", "${c.target.key}").`);f=c}if(!f&&!n.multi&&h&&(f=e?h.undirected[o]:h.out[o]),f){const _=[f.key,!1,!1,!1];if(u?!l:!s)return _;if(u){const R=f.attributes;f.attributes=l(R),n.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else te(f.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return _}s=s||{},u&&l&&(s=l(s));const b={key:null,undirected:e,source:a,target:o,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new U(`Graph.${r}: the "${i}" edge already exists in the graph.`);let w=!1,E=!1;h||(h=er(n,a,{}),w=!0,a===o&&(d=h,E=!0)),d||(d=er(n,o,{}),E=!0),c=new qe(e,i,h,d,s),n._edges.set(i,c);const L=a===o;return e?(h.undirectedDegree++,d.undirectedDegree++,L&&(h.undirectedLoops++,n._undirectedSelfLoopCount++)):(h.outDegree++,d.inDegree++,L&&(h.directedLoops++,n._directedSelfLoopCount++)),n.multi?c.attachMulti():c.attach(),e?n._undirectedSize++:n._directedSize++,b.key=i,n.emit("edgeAdded",b),[i,!0,w,E]}function Me(n,r){n._edges.delete(r.key);const{source:t,target:e,attributes:i}=r,a=r.undirected,o=t===e;a?(t.undirectedDegree--,e.undirectedDegree--,o&&(t.undirectedLoops--,n._undirectedSelfLoopCount--)):(t.outDegree--,e.inDegree--,o&&(t.directedLoops--,n._directedSelfLoopCount--)),n.multi?r.detachMulti():r.detach(),a?n._undirectedSize--:n._directedSize--,n.emit("edgeDropped",{key:r.key,attributes:i,source:t.key,target:e.key,undirected:a})}class X extends jr.EventEmitter{constructor(r){if(super(),r=te({},jn,r),typeof r.multi!="boolean")throw new D(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${r.multi}".`);if(!$n.has(r.type))throw new D(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${r.type}".`);if(typeof r.allowSelfLoops!="boolean")throw new D(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${r.allowSelfLoops}".`);const t=r.type==="mixed"?Br:r.type==="directed"?Hr:Wr;de(this,"NodeDataClass",t);const e="geid_"+zn()+"_";let i=0;const a=()=>{let o;do o=e+i++;while(this._edges.has(o));return o};de(this,"_attributes",{}),de(this,"_nodes",new Map),de(this,"_edges",new Map),de(this,"_directedSize",0),de(this,"_undirectedSize",0),de(this,"_directedSelfLoopCount",0),de(this,"_undirectedSelfLoopCount",0),de(this,"_edgeKeyGenerator",a),de(this,"_options",r),Jt.forEach(o=>de(this,o,this[o])),ve(this,"order",()=>this._nodes.size),ve(this,"size",()=>this._edges.size),ve(this,"directedSize",()=>this._directedSize),ve(this,"undirectedSize",()=>this._undirectedSize),ve(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ve(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ve(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ve(this,"multi",this._options.multi),ve(this,"type",this._options.type),ve(this,"allowSelfLoops",this._options.allowSelfLoops),ve(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(r){return this._nodes.has(""+r)}hasDirectedEdge(r,t){if(this.type==="undirected")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&!i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.out.hasOwnProperty(t):!1}throw new D(`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(r,t){if(this.type==="directed")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.undirected.hasOwnProperty(t):!1}throw new D(`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(r,t){if(arguments.length===1){const e=""+r;return this._edges.has(e)}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?typeof e.out<"u"&&e.out.hasOwnProperty(t)||typeof e.undirected<"u"&&e.undirected.hasOwnProperty(t):!1}throw new D(`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(r,t){if(this.type==="undirected")return;if(r=""+r,t=""+t,this.multi)throw new U("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const e=this._nodes.get(r);if(!e)throw new A(`Graph.directedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||void 0;if(i)return i.key}undirectedEdge(r,t){if(this.type==="directed")return;if(r=""+r,t=""+t,this.multi)throw new U("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const e=this._nodes.get(r);if(!e)throw new A(`Graph.undirectedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=e.undirected&&e.undirected[t]||void 0;if(i)return i.key}edge(r,t){if(this.multi)throw new U("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.edge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||e.undirected&&e.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areDirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in||t in e.out}areOutNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.out}areInNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in}areUndirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areUndirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="directed"?!1:t in e.undirected}areNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&(t in e.in||t in e.out)||this.type!=="directed"&&t in e.undirected}areInboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.in||this.type!=="directed"&&t in e.undirected}areOutboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.out||this.type!=="directed"&&t in e.undirected}inDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegree: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree),e}outboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.outDegree),e}degree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree),e}inDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree,i+=t.directedLoops),e-i}outboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.outDegree,i+=t.directedLoops),e-i}degreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree,i+=t.directedLoops*2),e-i}source(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.source: could not find the "${r}" edge in the graph.`);return t.source.key}target(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.target: could not find the "${r}" edge in the graph.`);return t.target.key}extremities(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.extremities: could not find the "${r}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(r,t){r=""+r,t=""+t;const e=this._edges.get(t);if(!e)throw new A(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=e.source.key,a=e.target.key;if(r===i)return a;if(r===a)return i;throw new A(`Graph.opposite: the "${r}" node is not attached to the "${t}" edge (${i}, ${a}).`)}hasExtremity(r,t){r=""+r,t=""+t;const e=this._edges.get(r);if(!e)throw new A(`Graph.hasExtremity: could not find the "${r}" edge in the graph.`);return e.source.key===t||e.target.key===t}isUndirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isUndirected: could not find the "${r}" edge in the graph.`);return t.undirected}isDirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isDirected: could not find the "${r}" edge in the graph.`);return!t.undirected}isSelfLoop(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isSelfLoop: could not find the "${r}" edge in the graph.`);return t.source===t.target}addNode(r,t){return Mn(this,r,t).key}mergeNode(r,t){if(t&&!oe(t))throw new D(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);r=""+r,t=t||{};let e=this._nodes.get(r);return e?(t&&(te(e.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:r,attributes:e.attributes,data:t})),[r,!1]):(e=new this.NodeDataClass(r,t),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:t}),[r,!0])}updateNode(r,t){if(t&&typeof t!="function")throw new D(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);r=""+r;let e=this._nodes.get(r);if(e){if(t){const a=e.attributes;e.attributes=t(a),this.emit("nodeAttributesUpdated",{type:"replace",key:r,attributes:e.attributes})}return[r,!1]}const i=t?t({}):{};return e=new this.NodeDataClass(r,i),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:i}),[r,!0]}dropNode(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.dropNode: could not find the "${r}" node in the graph.`);let e;if(this.type!=="undirected"){for(const i in t.out){e=t.out[i];do Me(this,e),e=e.next;while(e)}for(const i in t.in){e=t.in[i];do Me(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const i in t.undirected){e=t.undirected[i];do Me(this,e),e=e.next;while(e)}this._nodes.delete(r),this.emit("nodeDropped",{key:r,attributes:t.attributes})}dropEdge(r){let t;if(arguments.length>1){const e=""+arguments[0],i=""+arguments[1];if(t=fe(this,e,i,this.type),!t)throw new A(`Graph.dropEdge: could not find the "${e}" -> "${i}" edge in the graph.`)}else if(r=""+r,t=this._edges.get(r),!t)throw new A(`Graph.dropEdge: could not find the "${r}" edge in the graph.`);return Me(this,t),this}dropDirectedEdge(r,t){if(arguments.length<2)throw new U("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 U("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.");r=""+r,t=""+t;const e=fe(this,r,t,"directed");if(!e)throw new A(`Graph.dropDirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Me(this,e),this}dropUndirectedEdge(r,t){if(arguments.length<2)throw new U("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 U("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 e=fe(this,r,t,"undirected");if(!e)throw new A(`Graph.dropUndirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Me(this,e),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const r=this._nodes.values();let t;for(;t=r.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(r){return this._attributes[r]}getAttributes(){return this._attributes}hasAttribute(r){return this._attributes.hasOwnProperty(r)}setAttribute(r,t){return this._attributes[r]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}updateAttribute(r,t){if(typeof t!="function")throw new D("Graph.updateAttribute: updater should be a function.");const e=this._attributes[r];return this._attributes[r]=t(e),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}removeAttribute(r){return delete this._attributes[r],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:r}),this}replaceAttributes(r){if(!oe(r))throw new D("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=r,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(r){if(!oe(r))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return te(this._attributes,r),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:r}),this}updateAttributes(r){if(typeof r!="function")throw new D("Graph.updateAttributes: provided updater is not a function.");return this._attributes=r(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(r,t){if(typeof r!="function")throw new D("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new D("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._nodes.values();let i,a;for(;i=e.next(),i.done!==!0;)a=i.value,a.attributes=r(a.key,a.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(r,t){if(typeof r!="function")throw new D("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new D("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._edges.values();let i,a,o,s;for(;i=e.next(),i.done!==!0;)a=i.value,o=a.source,s=a.target,a.attributes=r(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntry: expecting a callback.");ut(!1,!1,!1,this,r)}forEachAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!1,!0,this,r)}forEachAssymetricAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ut(!1,!0,!1,this,r)}forEachAssymetricAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!0,!0,this,r)}nodes(){return Array.from(this._nodes.keys())}forEachNode(r){if(typeof r!="function")throw new D("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)}findNode(r){if(typeof r!="function")throw new D("Graph.findNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,r(i.key,i.attributes))return i.key}mapNodes(r){if(typeof r!="function")throw new D("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let e,i;const a=new Array(this.order);let o=0;for(;e=t.next(),e.done!==!0;)i=e.value,a[o++]=r(i.key,i.attributes);return a}someNode(r){if(typeof r!="function")throw new D("Graph.someNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,r(i.key,i.attributes))return!0;return!1}everyNode(r){if(typeof r!="function")throw new D("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,!r(i.key,i.attributes))return!1;return!0}filterNodes(r){if(typeof r!="function")throw new D("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let e,i;const a=[];for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)&&a.push(i.key);return a}reduceNodes(r,t){if(typeof r!="function")throw new D("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new D("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 e=t;const i=this._nodes.values();let a,o;for(;a=i.next(),a.done!==!0;)o=a.value,e=r(e,o.key,o.attributes);return e}nodeEntries(){const r=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=r.next();if(t.done)return t;const e=t.value;return{value:{node:e.key,attributes:e.attributes},done:!1}}}}export(){const r=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,a)=>{r[t++]=Fn(a,i)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((i,a)=>{e[t++]=Pn(this.type,a,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:r,edges:e}}import(r,t=!1){if(r instanceof X)return r.forEachNode((u,l)=>{t?this.mergeNode(u,l):this.addNode(u,l)}),r.forEachEdge((u,l,h,d,c,f,b)=>{t?b?this.mergeUndirectedEdgeWithKey(u,h,d,l):this.mergeDirectedEdgeWithKey(u,h,d,l):b?this.addUndirectedEdgeWithKey(u,h,d,l):this.addDirectedEdgeWithKey(u,h,d,l)}),this;if(!oe(r))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!oe(r.attributes))throw new D("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(r.attributes):this.replaceAttributes(r.attributes)}let e,i,a,o,s;if(r.nodes){if(a=r.nodes,!Array.isArray(a))throw new D("Graph.import: invalid nodes. Expecting an array.");for(e=0,i=a.length;e<i;e++){o=a[e],In(o);const{key:u,attributes:l}=o;t?this.mergeNode(u,l):this.addNode(u,l)}}if(r.edges){let u=!1;if(this.type==="undirected"&&(u=!0),a=r.edges,!Array.isArray(a))throw new D("Graph.import: invalid edges. Expecting an array.");for(e=0,i=a.length;e<i;e++){s=a[e],On(s);const{source:l,target:h,attributes:d,undirected:c=u}=s;let f;"key"in s?(f=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,l,h,d)):(f=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,l,h,d))}}return this}nullCopy(r){const t=new X(te({},this._options,r));return t.replaceAttributes(te({},this.getAttributes())),t}emptyCopy(r){const t=this.nullCopy(r);return this._nodes.forEach((e,i)=>{const a=te({},e.attributes);e=new t.NodeDataClass(i,a),t._nodes.set(i,e)}),t}copy(r){if(r=r||{},typeof r.type=="string"&&r.type!==this.type&&r.type!=="mixed")throw new U(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${r.type}" because this would mean losing information about the current graph.`);if(typeof r.multi=="boolean"&&r.multi!==this.multi&&r.multi!==!0)throw new U("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 r.allowSelfLoops=="boolean"&&r.allowSelfLoops!==this.allowSelfLoops&&r.allowSelfLoops!==!0)throw new U("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 t=this.emptyCopy(r),e=this._edges.values();let i,a;for(;i=e.next(),i.done!==!0;)a=i.value,Zr(t,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,te({},a.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const r={};this._nodes.forEach((a,o)=>{r[o]=a.attributes});const t={},e={};this._edges.forEach((a,o)=>{const s=a.undirected?"--":"->";let u="",l=a.source.key,h=a.target.key,d;a.undirected&&l>h&&(d=l,l=h,h=d);const c=`(${l})${s}(${h})`;o.startsWith("geid_")?this.multi&&(typeof e[c]>"u"?e[c]=0:e[c]++,u+=`${e[c]}. `):u+=`[${o}]: `,u+=c,t[u]=a.attributes});const i={};for(const a in this)this.hasOwnProperty(a)&&!Jt.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=r,i.edges=t,de(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(X.prototype[Symbol.for("nodejs.util.inspect.custom")]=X.prototype.inspect);Un.forEach(n=>{["add","merge","update"].forEach(r=>{const t=n.name(r),e=r==="add"?Zr:Bn;n.generateKey?X.prototype[t]=function(i,a,o){return e(this,t,!0,(n.type||this.type)==="undirected",null,i,a,o,r==="update")}:X.prototype[t]=function(i,a,o,s){return e(this,t,!1,(n.type||this.type)==="undirected",i,a,o,s,r==="update")}})});Xi(X);ln(X);Sn(X);Nn(X);class Xr extends X{constructor(r){const t=te({type:"directed"},r);if("multi"in t&&t.multi!==!1)throw new D("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new D('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Qr extends X{constructor(r){const t=te({type:"undirected"},r);if("multi"in t&&t.multi!==!1)throw new D("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new D('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Jr extends X{constructor(r){const t=te({multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class ei extends X{constructor(r){const t=te({type:"directed",multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new D('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class ti extends X{constructor(r){const t=te({type:"undirected",multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new D('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Ke(n){n.from=function(r,t){const e=te({},r.options,t),i=new n(e);return i.import(r),i}}Ke(X);Ke(Xr);Ke(Qr);Ke(Jr);Ke(ei);Ke(ti);X.Graph=X;X.DirectedGraph=Xr;X.UndirectedGraph=Qr;X.MultiGraph=Jr;X.MultiDirectedGraph=ei;X.MultiUndirectedGraph=ti;X.InvalidArgumentsGraphError=D;X.NotFoundGraphError=A;X.UsageGraphError=U;function Hn(n,r){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var e=t.call(n,r);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function it(n){var r=Hn(n,"string");return typeof r=="symbol"?r:r+""}function re(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}function tr(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,it(e.key),e)}}function ie(n,r,t){return r&&tr(n.prototype,r),t&&tr(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function He(n){return He=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},He(n)}function ri(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ri=function(){return!!n})()}function Wn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Vn(n,r){if(r&&(typeof r=="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wn(n)}function le(n,r,t){return r=He(r),Vn(n,ri()?Reflect.construct(r,t||[],He(n).constructor):r.apply(n,t))}function It(n,r){return It=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},It(n,r)}function he(n,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(r&&r.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),r&&It(n,r)}function qn(n){if(Array.isArray(n))return n}function Kn(n,r){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var e,i,a,o,s=[],u=!0,l=!1;try{if(a=(t=t.call(n)).next,r===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(e=a.call(t)).done)&&(s.push(e.value),s.length!==r);u=!0);}catch(h){l=!0,i=h}finally{try{if(!u&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Ot(n,r){(r==null||r>n.length)&&(r=n.length);for(var t=0,e=Array(r);t<r;t++)e[t]=n[t];return e}function ii(n,r){if(n){if(typeof n=="string")return Ot(n,r);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ot(n,r):void 0}}function Yn(){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 We(n,r){return qn(n)||Kn(n,r)||ii(n,r)||Yn()}var Ct={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"},ni=new Int8Array(4),St=new Int32Array(ni.buffer,0,1),Zn=new Float32Array(ni.buffer,0,1),Xn=/^\s*rgba?\s*\(/,Qn=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Jn(n){var r=0,t=0,e=0,i=1;if(n[0]==="#")n.length===4?(r=parseInt(n.charAt(1)+n.charAt(1),16),t=parseInt(n.charAt(2)+n.charAt(2),16),e=parseInt(n.charAt(3)+n.charAt(3),16)):(r=parseInt(n.charAt(1)+n.charAt(2),16),t=parseInt(n.charAt(3)+n.charAt(4),16),e=parseInt(n.charAt(5)+n.charAt(6),16)),n.length===9&&(i=parseInt(n.charAt(7)+n.charAt(8),16)/255);else if(Xn.test(n)){var a=n.match(Qn);a&&(r=+a[1],t=+a[2],e=+a[3],a[4]&&(i=+a[4]))}return{r,g:t,b:e,a:i}}var Be={};for(var lt in Ct)Be[lt]=$e(Ct[lt]),Be[Ct[lt]]=Be[lt];function ai(n,r,t,e,i){return St[0]=e<<24|t<<16|r<<8|n,St[0]=St[0]&4278190079,Zn[0]}function $e(n){if(n=n.toLowerCase(),typeof Be[n]<"u")return Be[n];var r=Jn(n),t=r.r,e=r.g,i=r.b,a=r.a;a=a*255|0;var o=ai(t,e,i,a);return Be[n]=o,o}var Tt={};function oi(n){if(typeof Tt[n]<"u")return Tt[n];var r=(n&16711680)>>>16,t=(n&65280)>>>8,e=n&255,i=255,a=ai(r,t,e,i);return Tt[n]=a,a}function rr(n,r,t,e){return t+(r<<8)+(n<<16)}function ir(n,r,t,e,i,a){var o=Math.floor(t/a*i),s=Math.floor(n.drawingBufferHeight/a-e/a*i),u=new Uint8Array(4);n.bindFramebuffer(n.FRAMEBUFFER,r),n.readPixels(o,s,1,1,n.RGBA,n.UNSIGNED_BYTE,u);var l=We(u,4),h=l[0],d=l[1],c=l[2],f=l[3];return[h,d,c,f]}function T(n,r,t){return(r=it(r))in n?Object.defineProperty(n,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[r]=t,n}function nr(n,r){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(n);r&&(e=e.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,e)}return t}function F(n){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?nr(Object(t),!0).forEach(function(e){T(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):nr(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function ea(n,r){for(;!{}.hasOwnProperty.call(n,r)&&(n=He(n))!==null;);return n}function zt(){return zt=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,r,t){var e=ea(n,r);if(e){var i=Object.getOwnPropertyDescriptor(e,r);return i.get?i.get.call(arguments.length<3?n:t):i.value}},zt.apply(null,arguments)}function si(n,r,t,e){var i=zt(He(n.prototype),r,t);return typeof i=="function"?function(a){return i.apply(t,a)}:i}function ta(n){return n.normalized?1:n.size}function Rt(n){var r=0;return n.forEach(function(t){return r+=ta(t)}),r}function ui(n,r,t){var e=n==="VERTEX"?r.VERTEX_SHADER:r.FRAGMENT_SHADER,i=r.createShader(e);if(i===null)throw new Error("loadShader: error while creating the shader");r.shaderSource(i,t),r.compileShader(i);var a=r.getShaderParameter(i,r.COMPILE_STATUS);if(!a){var o=r.getShaderInfoLog(i);throw r.deleteShader(i),new Error(`loadShader: error while compiling the shader:
|
|
3
|
+
`.concat(o,`
|
|
4
|
+
`).concat(t))}return i}function ra(n,r){return ui("VERTEX",n,r)}function ia(n,r){return ui("FRAGMENT",n,r)}function na(n,r){var t=n.createProgram();if(t===null)throw new Error("loadProgram: error while creating the program.");var e,i;for(e=0,i=r.length;e<i;e++)n.attachShader(t,r[e]);n.linkProgram(t);var a=n.getProgramParameter(t,n.LINK_STATUS);if(!a)throw n.deleteProgram(t),new Error("loadProgram: error while linking the program.");return t}function ar(n){var r=n.gl,t=n.buffer,e=n.program,i=n.vertexShader,a=n.fragmentShader;r.deleteShader(i),r.deleteShader(a),r.deleteProgram(e),r.deleteBuffer(t)}var or=`#define PICKING_MODE
|
|
5
|
+
`,aa=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),li=(function(){function n(r,t,e){re(this,n),T(this,"array",new Float32Array),T(this,"constantArray",new Float32Array),T(this,"capacity",0),T(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=Rt(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=e,this.normalProgram=this.getProgramInfo("normal",r,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=t?this.getProgramInfo("pick",r,or+i.VERTEX_SHADER_SOURCE,or+i.FRAGMENT_SHADER_SOURCE,t):null,this.isInstanced){var a=Rt(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 ie(n,[{key:"kill",value:function(){ar(this.normalProgram),this.pickProgram&&(ar(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(t,e,i,a,o){var s=this.getDefinition(),u=e.createBuffer();if(u===null)throw new Error("Program: error while creating the WebGL buffer.");var l=ra(e,i),h=ia(e,a),d=na(e,[l,h]),c={};s.UNIFORMS.forEach(function(w){var E=e.getUniformLocation(d,w);E&&(c[w]=E)});var f={};s.ATTRIBUTES.forEach(function(w){f[w.name]=e.getAttribLocation(d,w.name)});var b;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(w){f[w.name]=e.getAttribLocation(d,w.name)}),b=e.createBuffer(),b===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:t,program:d,gl:e,frameBuffer:o,buffer:u,constantBuffer:b||{},uniformLocations:c,attributeLocations:f,isPicking:t==="pick",vertexShader:l,fragmentShader:h}}},{key:"bindProgram",value:function(t){var e=this,i=0,a=t.gl,o=t.buffer;this.isInstanced?(a.bindBuffer(a.ARRAY_BUFFER,t.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return i+=e.bindAttribute(s,t,i,!1)}),a.bufferData(a.ARRAY_BUFFER,this.constantArray,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,t.buffer),i=0,this.ATTRIBUTES.forEach(function(s){return i+=e.bindAttribute(s,t,i,!0)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)):(a.bindBuffer(a.ARRAY_BUFFER,o),i=0,this.ATTRIBUTES.forEach(function(s){return i+=e.bindAttribute(s,t,i)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)),a.bindBuffer(a.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(t){var e=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(i){return e.unbindAttribute(i,t,!1)}),this.ATTRIBUTES.forEach(function(i){return e.unbindAttribute(i,t,!0)})):this.ATTRIBUTES.forEach(function(i){return e.unbindAttribute(i,t)})}},{key:"bindAttribute",value:function(t,e,i,a){var o=aa[t.type];if(typeof o!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(t.type,'"'));var s=e.attributeLocations[t.name],u=e.gl;if(s!==-1){u.enableVertexAttribArray(s);var l=this.isInstanced?(a?this.ATTRIBUTES_ITEMS_COUNT:Rt(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(u.vertexAttribPointer(s,t.size,t.type,t.normalized||!1,l,i),this.isInstanced&&a)if(u instanceof WebGL2RenderingContext)u.vertexAttribDivisor(s,1);else{var h=u.getExtension("ANGLE_instanced_arrays");h&&h.vertexAttribDivisorANGLE(s,1)}}return t.size*o}},{key:"unbindAttribute",value:function(t,e,i){var a=e.attributeLocations[t.name],o=e.gl;if(a!==-1&&(o.disableVertexAttribArray(a),this.isInstanced&&i))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(t){t!==this.capacity&&(this.capacity=t,this.verticesCount=this.VERTICES*t,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(t,e){var i=e.gl,a=e.program;i.enable(i.BLEND),i.useProgram(a),this.setUniforms(t,e),this.drawWebGL(this.METHOD,e)}},{key:"render",value:function(t){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,t.width*t.pixelRatio/t.downSizingRatio,t.height*t.pixelRatio/t.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(F(F({},t),{},{pixelRatio:t.pixelRatio/t.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,t.width*t.pixelRatio,t.height*t.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(t,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(t,e){var i=e.gl,a=e.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,a),!this.isInstanced)i.drawArrays(t,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(t,0,this.VERTICES,this.capacity);else{var o=i.getExtension("ANGLE_instanced_arrays");o&&o.drawArraysInstancedANGLE(t,0,this.VERTICES,this.capacity)}}}])})(),oa=(function(n){function r(){return re(this,r),le(this,r,arguments)}return he(r,n),ie(r,[{key:"kill",value:function(){si(r,"kill",this)([])}},{key:"process",value:function(e,i,a){var o=i*this.STRIDE;if(a.hidden){for(var s=o+this.STRIDE;o<s;o++)this.array[o]=0;return}return this.processVisibleItem(oi(e),o,a)}}])})(li),nt=(function(n){function r(){var t;re(this,r);for(var e=arguments.length,i=new Array(e),a=0;a<e;a++)i[a]=arguments[a];return t=le(this,r,[].concat(i)),T(t,"drawLabel",void 0),t}return he(r,n),ie(r,[{key:"kill",value:function(){si(r,"kill",this)([])}},{key:"process",value:function(e,i,a,o,s){var u=i*this.STRIDE;if(s.hidden||a.hidden||o.hidden){for(var l=u+this.STRIDE;u<l;u++)this.array[u]=0;return}return this.processVisibleItem(oi(e),u,a,o,s)}}])})(li);function hi(n,r){return(function(){function t(e,i,a){re(this,t),T(this,"drawLabel",r),this.programs=n.map(function(o){return new o(e,i,a)})}return ie(t,[{key:"reallocate",value:function(i){this.programs.forEach(function(a){return a.reallocate(i)})}},{key:"process",value:function(i,a,o,s,u){this.programs.forEach(function(l){return l.process(i,a,o,s,u)})}},{key:"render",value:function(i){this.programs.forEach(function(a){return a.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function sa(n,r,t,e,i){var a=i.edgeLabelSize,o=i.edgeLabelFont,s=i.edgeLabelWeight,u=i.edgeLabelColor.attribute?r[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,l=r.label;if(l){n.fillStyle=u,n.font="".concat(s," ").concat(a,"px ").concat(o);var h=t.size,d=e.size,c=t.x,f=t.y,b=e.x,w=e.y,E=(c+b)/2,L=(f+w)/2,_=b-c,R=w-f,m=Math.sqrt(_*_+R*R);if(!(m<h+d)){c+=_*h/m,f+=R*h/m,b-=_*d/m,w-=R*d/m,E=(c+b)/2,L=(f+w)/2,_=b-c,R=w-f,m=Math.sqrt(_*_+R*R);var y=n.measureText(l).width;if(y>m){var S="…";for(l=l+S,y=n.measureText(l).width;y>m&&l.length>1;)l=l.slice(0,-2)+S,y=n.measureText(l).width;if(l.length<4)return}var C;_>0?R>0?C=Math.acos(_/m):C=Math.asin(R/m):R>0?C=Math.acos(_/m)+Math.PI:C=Math.asin(_/m)+Math.PI/2,n.save(),n.translate(E,L),n.rotate(C),n.fillText(l,-y/2,r.size/2+a),n.restore()}}}function di(n,r,t){if(r.label){var e=t.labelSize,i=t.labelFont,a=t.labelWeight,o=t.labelColor.attribute?r[t.labelColor.attribute]||t.labelColor.color||"#000":t.labelColor.color;n.fillStyle=o,n.font="".concat(a," ").concat(e,"px ").concat(i),n.fillText(r.label,r.x+r.size+3,r.y+e/3)}}function ua(n,r,t){var e=t.labelSize,i=t.labelFont,a=t.labelWeight;n.font="".concat(a," ").concat(e,"px ").concat(i),n.fillStyle="#FFF",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=8,n.shadowColor="#000";var o=2;if(typeof r.label=="string"){var s=n.measureText(r.label).width,u=Math.round(s+5),l=Math.round(e+2*o),h=Math.max(r.size,e/2)+o,d=Math.asin(l/2/h),c=Math.sqrt(Math.abs(Math.pow(h,2)-Math.pow(l/2,2)));n.beginPath(),n.moveTo(r.x+c,r.y+l/2),n.lineTo(r.x+h+u,r.y+l/2),n.lineTo(r.x+h+u,r.y-l/2),n.lineTo(r.x+c,r.y-l/2),n.arc(r.x,r.y,h,d,-d),n.closePath(),n.fill()}else n.beginPath(),n.arc(r.x,r.y,r.size+o,0,Math.PI*2),n.closePath(),n.fill();n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,di(n,r,t)}var la=`
|
|
6
6
|
precision highp float;
|
|
7
7
|
|
|
8
8
|
varying vec4 v_color;
|
|
@@ -34,7 +34,7 @@ void main(void) {
|
|
|
34
34
|
gl_FragColor = mix(v_color, transparent, t);
|
|
35
35
|
#endif
|
|
36
36
|
}
|
|
37
|
-
`,
|
|
37
|
+
`,ha=la,da=`
|
|
38
38
|
attribute vec4 a_id;
|
|
39
39
|
attribute vec4 a_color;
|
|
40
40
|
attribute vec2 a_position;
|
|
@@ -75,7 +75,7 @@ void main() {
|
|
|
75
75
|
|
|
76
76
|
v_color.a *= bias;
|
|
77
77
|
}
|
|
78
|
-
`,
|
|
78
|
+
`,ca=da,ci=WebGLRenderingContext,sr=ci.UNSIGNED_BYTE,kt=ci.FLOAT,fa=["u_sizeRatio","u_correctionRatio","u_matrix"],vt=(function(n){function r(){return re(this,r),le(this,r,arguments)}return he(r,n),ie(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:ca,FRAGMENT_SHADER_SOURCE:ha,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:fa,ATTRIBUTES:[{name:"a_position",size:2,type:kt},{name:"a_size",size:1,type:kt},{name:"a_color",size:4,type:sr,normalized:!0},{name:"a_id",size:4,type:sr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:kt}],CONSTANT_DATA:[[r.ANGLE_1],[r.ANGLE_2],[r.ANGLE_3]]}}},{key:"processVisibleItem",value:function(e,i,a){var o=this.array,s=$e(a.color);o[i++]=a.x,o[i++]=a.y,o[i++]=a.size,o[i++]=s,o[i++]=e}},{key:"setUniforms",value:function(e,i){var a=i.gl,o=i.uniformLocations,s=o.u_sizeRatio,u=o.u_correctionRatio,l=o.u_matrix;a.uniform1f(u,e.correctionRatio),a.uniform1f(s,e.sizeRatio),a.uniformMatrix3fv(l,!1,e.matrix)}}])})(oa);T(vt,"ANGLE_1",0);T(vt,"ANGLE_2",2*Math.PI/3);T(vt,"ANGLE_3",4*Math.PI/3);var ga=`
|
|
79
79
|
precision mediump float;
|
|
80
80
|
|
|
81
81
|
varying vec4 v_color;
|
|
@@ -83,7 +83,7 @@ varying vec4 v_color;
|
|
|
83
83
|
void main(void) {
|
|
84
84
|
gl_FragColor = v_color;
|
|
85
85
|
}
|
|
86
|
-
`,
|
|
86
|
+
`,pa=ga,ma=`
|
|
87
87
|
attribute vec2 a_position;
|
|
88
88
|
attribute vec2 a_normal;
|
|
89
89
|
attribute float a_radius;
|
|
@@ -149,7 +149,7 @@ void main() {
|
|
|
149
149
|
|
|
150
150
|
v_color.a *= bias;
|
|
151
151
|
}
|
|
152
|
-
`,
|
|
152
|
+
`,va=ma,fi=WebGLRenderingContext,ur=fi.UNSIGNED_BYTE,ht=fi.FLOAT,ya=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],qt={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function gt(n){var r=F(F({},qt),n||{});return(function(t){function e(){return re(this,e),le(this,e,arguments)}return he(e,t),ie(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:va,FRAGMENT_SHADER_SOURCE:pa,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:ya,ATTRIBUTES:[{name:"a_position",size:2,type:ht},{name:"a_normal",size:2,type:ht},{name:"a_radius",size:1,type:ht},{name:"a_color",size:4,type:ur,normalized:!0},{name:"a_id",size:4,type:ur,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:ht}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(a,o,s,u,l){if(r.extremity==="source"){var h=[u,s];s=h[0],u=h[1]}var d=l.size||1,c=u.size||1,f=s.x,b=s.y,w=u.x,E=u.y,L=$e(l.color),_=w-f,R=E-b,m=_*_+R*R,y=0,S=0;m&&(m=1/Math.sqrt(m),y=-R*m*d,S=_*m*d);var C=this.array;C[o++]=w,C[o++]=E,C[o++]=-y,C[o++]=-S,C[o++]=c,C[o++]=L,C[o++]=a}},{key:"setUniforms",value:function(a,o){var s=o.gl,u=o.uniformLocations,l=u.u_matrix,h=u.u_sizeRatio,d=u.u_correctionRatio,c=u.u_minEdgeThickness,f=u.u_lengthToThicknessRatio,b=u.u_widenessToThicknessRatio;s.uniformMatrix3fv(l,!1,a.matrix),s.uniform1f(h,a.sizeRatio),s.uniform1f(d,a.correctionRatio),s.uniform1f(c,a.minEdgeThickness),s.uniform1f(f,r.lengthToThicknessRatio),s.uniform1f(b,r.widenessToThicknessRatio)}}])})(nt)}gt();var ba=`
|
|
153
153
|
precision mediump float;
|
|
154
154
|
|
|
155
155
|
varying vec4 v_color;
|
|
@@ -175,7 +175,7 @@ void main(void) {
|
|
|
175
175
|
gl_FragColor = mix(v_color, transparent, t);
|
|
176
176
|
#endif
|
|
177
177
|
}
|
|
178
|
-
`,Kt=
|
|
178
|
+
`,Kt=ba,wa=`
|
|
179
179
|
attribute vec4 a_id;
|
|
180
180
|
attribute vec4 a_color;
|
|
181
181
|
attribute vec2 a_normal;
|
|
@@ -243,7 +243,7 @@ void main() {
|
|
|
243
243
|
|
|
244
244
|
v_color.a *= bias;
|
|
245
245
|
}
|
|
246
|
-
`,
|
|
246
|
+
`,Ea=wa,gi=WebGLRenderingContext,lr=gi.UNSIGNED_BYTE,ze=gi.FLOAT,xa=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],_a={lengthToThicknessRatio:qt.lengthToThicknessRatio};function pi(n){var r=F(F({},_a),{});return(function(t){function e(){return re(this,e),le(this,e,arguments)}return he(e,t),ie(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Ea,FRAGMENT_SHADER_SOURCE:Kt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:xa,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:lr,normalized:!0},{name:"a_id",size:4,type:lr,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,l){var h=l.size||1,d=s.x,c=s.y,f=u.x,b=u.y,w=$e(l.color),E=f-d,L=b-c,_=u.size||1,R=E*E+L*L,m=0,y=0;R&&(R=1/Math.sqrt(R),m=-L*R*h,y=E*R*h);var S=this.array;S[o++]=d,S[o++]=c,S[o++]=f,S[o++]=b,S[o++]=m,S[o++]=y,S[o++]=w,S[o++]=a,S[o++]=_}},{key:"setUniforms",value:function(a,o){var s=o.gl,u=o.uniformLocations,l=u.u_matrix,h=u.u_zoomRatio,d=u.u_feather,c=u.u_pixelRatio,f=u.u_correctionRatio,b=u.u_sizeRatio,w=u.u_minEdgeThickness,E=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(l,!1,a.matrix),s.uniform1f(h,a.zoomRatio),s.uniform1f(b,a.sizeRatio),s.uniform1f(f,a.correctionRatio),s.uniform1f(c,a.pixelRatio),s.uniform1f(d,a.antiAliasingFeather),s.uniform1f(w,a.minEdgeThickness),s.uniform1f(E,r.lengthToThicknessRatio)}}])})(nt)}pi();function Ca(n){return hi([pi(),gt(n)])}var Sa=Ca(),mi=Sa,Ta=`
|
|
247
247
|
attribute vec4 a_id;
|
|
248
248
|
attribute vec4 a_color;
|
|
249
249
|
attribute vec2 a_normal;
|
|
@@ -308,8 +308,8 @@ void main() {
|
|
|
308
308
|
|
|
309
309
|
v_color.a *= bias;
|
|
310
310
|
}
|
|
311
|
-
`,ko=Ro,vi=WebGLRenderingContext,hr=vi.UNSIGNED_BYTE,Qe=vi.FLOAT,Ao=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Lo=(function(n){function r(){return re(this,r),le(this,r,arguments)}return he(r,n),ie(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:ko,FRAGMENT_SHADER_SOURCE:Kt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ao,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Qe},{name:"a_positionEnd",size:2,type:Qe},{name:"a_normal",size:2,type:Qe},{name:"a_color",size:4,type:hr,normalized:!0},{name:"a_id",size:4,type:hr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Qe},{name:"a_normalCoef",size:1,type:Qe}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(e,i,o,a,s){var u=s.size||1,l=o.x,h=o.y,d=a.x,c=a.y,f=$e(s.color),b=d-l,w=c-h,E=b*b+w*w,L=0,_=0;E&&(E=1/Math.sqrt(E),L=-w*E*u,_=b*E*u);var R=this.array;R[i++]=l,R[i++]=h,R[i++]=d,R[i++]=c,R[i++]=L,R[i++]=_,R[i++]=f,R[i++]=e}},{key:"setUniforms",value:function(e,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,u=a.u_zoomRatio,l=a.u_feather,h=a.u_pixelRatio,d=a.u_correctionRatio,c=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,e.matrix),o.uniform1f(u,e.zoomRatio),o.uniform1f(c,e.sizeRatio),o.uniform1f(d,e.correctionRatio),o.uniform1f(h,e.pixelRatio),o.uniform1f(l,e.antiAliasingFeather),o.uniform1f(f,e.minEdgeThickness)}}])})(nt),Yt=(function(n){function r(){var t;return re(this,r),t=le(this,r),t.rawEmitter=t,t}return he(r,n),ie(r)})(jr.EventEmitter),At,dr;function yi(){return dr||(dr=1,At=function(r){return r!==null&&typeof r=="object"&&typeof r.addUndirectedEdgeWithKey=="function"&&typeof r.dropNode=="function"&&typeof r.multi=="boolean"}),At}var Do=yi();const Go=$r(Do);var No=function(r){return r},Fo=function(r){return r*r},Po=function(r){return r*(2-r)},Io=function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)},Oo=function(r){return r*r*r},zo=function(r){return--r*r*r+1},$o=function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)},Uo={linear:No,quadraticIn:Fo,quadraticOut:Po,quadraticInOut:Io,cubicIn:Oo,cubicOut:zo,cubicInOut:$o},jo={easing:"quadraticInOut",duration:150};function ye(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function dt(n,r,t){return n[0]=r,n[4]=typeof t=="number"?t:r,n}function cr(n,r){var t=Math.sin(r),e=Math.cos(r);return n[0]=e,n[1]=t,n[3]=-t,n[4]=e,n}function fr(n,r,t){return n[6]=r,n[7]=t,n}function Pe(n,r){var t=n[0],e=n[1],i=n[2],o=n[3],a=n[4],s=n[5],u=n[6],l=n[7],h=n[8],d=r[0],c=r[1],f=r[2],b=r[3],w=r[4],E=r[5],L=r[6],_=r[7],R=r[8];return n[0]=d*t+c*o+f*u,n[1]=d*e+c*a+f*l,n[2]=d*i+c*s+f*h,n[3]=b*t+w*o+E*u,n[4]=b*e+w*a+E*l,n[5]=b*i+w*s+E*h,n[6]=L*t+_*o+R*u,n[7]=L*e+_*a+R*l,n[8]=L*i+_*s+R*h,n}function $t(n,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,e=n[0],i=n[1],o=n[3],a=n[4],s=n[6],u=n[7],l=r.x,h=r.y;return{x:l*e+h*o+s*t,y:l*i+h*a+u*t}}function Mo(n,r){var t=n.height/n.width,e=r.height/r.width;return t<1&&e>1||t>1&&e<1?1:Math.min(Math.max(e,1/e),Math.max(1/t,t))}function Je(n,r,t,e,i){var o=n.angle,a=n.ratio,s=n.x,u=n.y,l=r.width,h=r.height,d=ye(),c=Math.min(l,h)-2*e,f=Mo(r,t);return i?(Pe(d,fr(ye(),s,u)),Pe(d,dt(ye(),a)),Pe(d,cr(ye(),o)),Pe(d,dt(ye(),l/c/2/f,h/c/2/f))):(Pe(d,dt(ye(),2*(c/l)*f,2*(c/h)*f)),Pe(d,cr(ye(),-o)),Pe(d,dt(ye(),1/a)),Pe(d,fr(ye(),-s,-u))),d}function Bo(n,r,t){var e=$t(n,{x:Math.cos(r.angle),y:Math.sin(r.angle)},0),i=e.x,o=e.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/t.width}function Ho(n){if(!n.order)return{x:[0,1],y:[0,1]};var r=1/0,t=-1/0,e=1/0,i=-1/0;return n.forEachNode(function(o,a){var s=a.x,u=a.y;s<r&&(r=s),s>t&&(t=s),u<e&&(e=u),u>i&&(i=u)}),{x:[r,t],y:[e,i]}}function Wo(n){if(!Go(n))throw new Error("Sigma: invalid graph instance.");n.forEachNode(function(r,t){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new Error("Sigma: Coordinates of node ".concat(r," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Vo(n,r,t){var e=document.createElement(n);if(r)for(var i in r)e.style[i]=r[i];if(t)for(var o in t)e.setAttribute(o,t[o]);return e}function gr(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function pr(n,r,t){return t.sort(function(e,i){var o=r(e)||0,a=r(i)||0;return o<a?-1:o>a?1:0})}function mr(n){var r=We(n.x,2),t=r[0],e=r[1],i=We(n.y,2),o=i[0],a=i[1],s=Math.max(e-t,a-o),u=(e+t)/2,l=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(u)&&(u=0),isNaN(l)&&(l=0);var h=function(c){return{x:.5+(c.x-u)/s,y:.5+(c.y-l)/s}};return h.applyTo=function(d){d.x=.5+(d.x-u)/s,d.y=.5+(d.y-l)/s},h.inverse=function(d){return{x:u+s*(d.x-.5),y:l+s*(d.y-.5)}},h.ratio=s,h}function Ut(n){"@babel/helpers - typeof";return Ut=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ut(n)}function vr(n,r){var t=r.size;if(t!==0){var e=n.length;n.length+=t;var i=0;r.forEach(function(o){n[e+i]=o,i++})}}function Lt(n){n=n||{};for(var r=0,t=arguments.length<=1?0:arguments.length-1;r<t;r++){var e=r+1<1||arguments.length<=r+1?void 0:arguments[r+1];e&&Object.assign(n,e)}return n}var Zt={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:so,defaultDrawNodeLabel:di,defaultDrawNodeHover:uo,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:{}},qo={circle:vt},Ko={arrow:mi,line:Lo};function Dt(n){if(typeof n.labelDensity!="number"||n.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var r=n.minCameraRatio,t=n.maxCameraRatio;if(typeof r=="number"&&typeof t=="number"&&t<r)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Yo(n){var r=Lt({},Zt,n);return r.nodeProgramClasses=Lt({},qo,r.nodeProgramClasses),r.edgeProgramClasses=Lt({},Ko,r.edgeProgramClasses),r}var ct=1.5,yr=(function(n){function r(){var t;return re(this,r),t=le(this,r),T(t,"x",.5),T(t,"y",.5),T(t,"angle",0),T(t,"ratio",1),T(t,"minRatio",null),T(t,"maxRatio",null),T(t,"enabledZooming",!0),T(t,"enabledPanning",!0),T(t,"enabledRotation",!0),T(t,"clean",null),T(t,"nextFrame",null),T(t,"previousState",null),T(t,"enabled",!0),t.previousState=t.getState(),t}return he(r,n),ie(r,[{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(e){return this.x===e.x&&this.y===e.y&&this.ratio===e.ratio&&this.angle===e.angle}},{key:"getPreviousState",value:function(){var e=this.previousState;return e?{x:e.x,y:e.y,angle:e.angle,ratio:e.ratio}:null}},{key:"getBoundedRatio",value:function(e){var i=e;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(e){var i={};return this.enabledPanning&&typeof e.x=="number"&&(i.x=e.x),this.enabledPanning&&typeof e.y=="number"&&(i.y=e.y),this.enabledZooming&&typeof e.ratio=="number"&&(i.ratio=this.getBoundedRatio(e.ratio)),this.enabledRotation&&typeof e.angle=="number"&&(i.angle=e.angle),this.clean?this.clean(F(F({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(e){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(e);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(e){return this.setState(e(this.getState())),this}},{key:"animate",value:function(e){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(f){return i.animate(e,o,f)});if(this.enabled){var s=F(F({},jo),o),u=this.validateState(e),l=typeof s.easing=="function"?s.easing:Uo[s.easing],h=Date.now(),d=this.getState(),c=function(){var b=(Date.now()-h)/s.duration;if(b>=1){i.nextFrame=null,i.setState(u),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var w=l(b),E={};typeof u.x=="number"&&(E.x=d.x+(u.x-d.x)*w),typeof u.y=="number"&&(E.y=d.y+(u.y-d.y)*w),i.enabledRotation&&typeof u.angle=="number"&&(E.angle=d.angle+(u.angle-d.angle)*w),typeof u.ratio=="number"&&(E.ratio=d.ratio+(u.ratio-d.ratio)*w),i.setState(E),i.nextFrame=requestAnimationFrame(c)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(c)):c(),this.animationCallback=a}}},{key:"animatedZoom",value:function(e){return e?typeof e=="number"?this.animate({ratio:this.ratio/e}):this.animate({ratio:this.ratio/(e.factor||ct)},e):this.animate({ratio:this.ratio/ct})}},{key:"animatedUnzoom",value:function(e){return e?typeof e=="number"?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||ct)},e):this.animate({ratio:this.ratio*ct})}},{key:"animatedReset",value:function(e){return this.animate({x:.5,y:.5,ratio:1,angle:0},e)}},{key:"copy",value:function(){return r.from(this.getState())}}],[{key:"from",value:function(e){var i=new r;return i.setState(e)}}])})(Yt);function be(n,r){var t=r.getBoundingClientRect();return{x:n.clientX-t.left,y:n.clientY-t.top}}function Te(n,r){var t=F(F({},be(n,r)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0},original:n});return t}function et(n){var r="x"in n?n:F(F({},n.touches[0]||n.previousTouches[0]),{},{original:n.original,sigmaDefaultPrevented:n.sigmaDefaultPrevented,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0,r.sigmaDefaultPrevented=!0}});return r}function Zo(n,r){return F(F({},Te(n,r)),{},{delta:bi(n)})}var Xo=2;function ft(n){for(var r=[],t=0,e=Math.min(n.length,Xo);t<e;t++)r.push(n[t]);return r}function tt(n,r,t){var e={touches:ft(n.touches).map(function(i){return be(i,t)}),previousTouches:r.map(function(i){return be(i,t)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:n};return e}function bi(n){if(typeof n.deltaY<"u")return n.deltaY*-3/360;if(typeof n.detail<"u")return n.detail/-9;throw new Error("Captor: could not extract delta from event.")}var wi=(function(n){function r(t,e){var i;return re(this,r),i=le(this,r),i.container=t,i.renderer=e,i}return he(r,n),ie(r)})(Yt),Qo=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],Jo=Qo.reduce(function(n,r){return F(F({},n),{},T({},r,Zt[r]))},{}),ea=(function(n){function r(t,e){var i;return re(this,r),i=le(this,r,[t,e]),T(i,"enabled",!0),T(i,"draggedEvents",0),T(i,"downStartTime",null),T(i,"lastMouseX",null),T(i,"lastMouseY",null),T(i,"isMouseDown",!1),T(i,"isMoving",!1),T(i,"movingTimeout",null),T(i,"startCameraState",null),T(i,"clicks",0),T(i,"doubleClickTimeout",null),T(i,"currentWheelDirection",0),T(i,"settings",Jo),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),t.addEventListener("click",i.handleClick,{capture:!1}),t.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),t.addEventListener("mousedown",i.handleDown,{capture:!1}),t.addEventListener("wheel",i.handleWheel,{capture:!1}),t.addEventListener("mouseleave",i.handleLeave,{capture:!1}),t.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return he(r,n),ie(r,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("click",this.handleClick),e.removeEventListener("contextmenu",this.handleRightClick),e.removeEventListener("mousedown",this.handleDown),e.removeEventListener("wheel",this.handleWheel),e.removeEventListener("mouseleave",this.handleLeave),e.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(e){var i=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(e);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",Te(e,this.container))}}},{key:"handleRightClick",value:function(e){this.enabled&&this.emit("rightClick",Te(e,this.container))}},{key:"handleDoubleClick",value:function(e){if(this.enabled){e.preventDefault(),e.stopPropagation();var i=Te(e,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(be(e,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(e){if(this.enabled){if(e.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=be(e,this.container),o=i.x,a=i.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Te(e,this.container))}}},{key:"handleUp",value:function(e){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var a=be(e,this.container),s=a.x,u=a.y,l=o.getState(),h=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:l.x+this.settings.inertiaRatio*(l.x-h.x),y:l.y+this.settings.inertiaRatio*(l.y-h.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==u)&&o.setState({x:l.x,y:l.y}),this.isMoving=!1,setTimeout(function(){var d=i.draggedEvents>0;i.draggedEvents=0,d&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",Te(e,this.container))}}},{key:"handleMove",value:function(e){var i=this;if(this.enabled){var o=Te(e,this.container);if(this.emit("mousemovebody",o),(e.target===this.container||e.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=be(e,this.container),u=s.x,l=s.y,h=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:u,y:l}),c=h.x-d.x,f=h.y-d.y,b=a.getState(),w=b.x+c,E=b.y+f;a.setState({x:w,y:E}),this.lastMouseX=u,this.lastMouseY=l,e.preventDefault(),e.stopPropagation()}}}},{key:"handleLeave",value:function(e){this.emit("mouseleave",Te(e,this.container))}},{key:"handleEnter",value:function(e){this.emit("mouseenter",Te(e,this.container))}},{key:"handleWheel",value:function(e){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=bi(e);if(a){var s=Zo(e,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){e.preventDefault(),e.stopPropagation();return}var u=o.getState().ratio,l=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,h=o.getBoundedRatio(u*l),d=a>0?1:-1,c=Date.now();u!==h&&(e.preventDefault(),e.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&c-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(be(e,this.container),h),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=c))}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(wi),ta=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],ra=ta.reduce(function(n,r){return F(F({},n),{},T({},r,Zt[r]))},{}),ia=(function(n){function r(t,e){var i;return re(this,r),i=le(this,r,[t,e]),T(i,"enabled",!0),T(i,"isMoving",!1),T(i,"hasMoved",!1),T(i,"touchMode",0),T(i,"startTouchesPositions",[]),T(i,"lastTouches",[]),T(i,"lastTap",null),T(i,"settings",ra),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),t.addEventListener("touchstart",i.handleStart,{capture:!1}),t.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return he(r,n),ie(r,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("touchstart",this.handleStart),e.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(e){var i=this;if(this.enabled){e.preventDefault();var o=ft(e.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return be(f,i.container)}),this.touchMode===2){var a=We(this.startTouchesPositions,2),s=a[0],u=s.x,l=s.y,h=a[1],d=h.x,c=h.y;this.startTouchesAngle=Math.atan2(c-l,d-u),this.startTouchesDistance=Math.sqrt(Math.pow(d-u,2)+Math.pow(c-l,2))}this.emit("touchdown",tt(e,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(e){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(e.cancelable&&e.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(e.touches.length===1){this.handleStart(e),e.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),a=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-a.x),y:o.y+this.settings.inertiaRatio*(o.y-a.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",tt(e,this.lastTouches,this.container)),!e.touches.length){var s=be(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],l=Math.pow(s.x-u.x,2)+Math.pow(s.y-u.y,2);if(!e.touches.length&&l<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var h=tt(e,this.lastTouches,this.container);if(this.emit("doubletap",h),this.lastTap=null,!h.sigmaDefaultPrevented){var d=this.renderer.getCamera(),c=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(s,c),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=tt(e,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=ft(e.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(e){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){e.preventDefault();var o=ft(e.touches),a=o.map(function(oe){return be(oe,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var u=tt(e,s,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(oe,J){var I=i.startTouchesPositions[J];return I&&(oe.x!==I.x||oe.y!==I.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var l=this.renderer.getCamera(),h=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var c=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=c.x,b=c.y,w=this.renderer.viewportToFramedGraph(a[0]),E=w.x,L=w.y;l.setState({x:h.x+f-E,y:h.y+b-L});break}case 2:{var _={x:.5,y:.5,angle:0,ratio:1},R=a[0],m=R.x,y=R.y,S=a[1],C=S.x,P=S.y,O=Math.atan2(P-y,C-m)-this.startTouchesAngle,z=Math.hypot(P-y,C-m)/this.startTouchesDistance,Y=l.getBoundedRatio(h.ratio/z);_.ratio=Y,_.angle=h.angle+O;var j=this.getDimensions(),p=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:h}),Q=Math.min(j.width,j.height)-2*d,ne=Q/j.width,k=Q/j.height,v=Y/Q,B=m-Q/2/ne,q=y-Q/2/k,ee=[B*Math.cos(-_.angle)-q*Math.sin(-_.angle),q*Math.cos(-_.angle)+B*Math.sin(-_.angle)];B=ee[0],q=ee[1],_.x=p.x-B*v,_.y=p.y+q*v,l.setState(_);break}}}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(wi);function na(n){if(Array.isArray(n))return Ot(n)}function oa(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function aa(){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 br(n){return na(n)||oa(n)||ii(n)||aa()}function sa(n,r){if(n==null)return{};var t={};for(var e in n)if({}.hasOwnProperty.call(n,e)){if(r.indexOf(e)!==-1)continue;t[e]=n[e]}return t}function Gt(n,r){if(n==null)return{};var t,e,i=sa(n,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(e=0;e<o.length;e++)t=o[e],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(i[t]=n[t])}return i}var wr=(function(){function n(r,t){re(this,n),this.key=r,this.size=t}return ie(n,null,[{key:"compare",value:function(t,e){return t.size>e.size?-1:t.size<e.size||t.key>e.key?1:-1}}])})(),Er=(function(){function n(){re(this,n),T(this,"width",0),T(this,"height",0),T(this,"cellSize",0),T(this,"columns",0),T(this,"rows",0),T(this,"cells",{})}return ie(n,[{key:"resizeAndClear",value:function(t,e){this.width=t.width,this.height=t.height,this.cellSize=e,this.columns=Math.ceil(t.width/e),this.rows=Math.ceil(t.height/e),this.cells={}}},{key:"getIndex",value:function(t){var e=Math.floor(t.x/this.cellSize),i=Math.floor(t.y/this.cellSize);return i*this.columns+e}},{key:"add",value:function(t,e,i){var o=new wr(t,e),a=this.getIndex(i),s=this.cells[a];s||(s=[],this.cells[a]=s),s.push(o)}},{key:"organize",value:function(){for(var t in this.cells){var e=this.cells[t];e.sort(wr.compare)}}},{key:"getLabelsToDisplay",value:function(t,e){var i=this.cellSize*this.cellSize,o=i/t/t,a=o*e/i,s=Math.ceil(a),u=[];for(var l in this.cells)for(var h=this.cells[l],d=0;d<Math.min(s,h.length);d++)u.push(h[d].key);return u}}])})();function ua(n){var r=n.graph,t=n.hoveredNode,e=n.highlightedNodes,i=n.displayedNodeLabels,o=[];return r.forEachEdge(function(a,s,u,l){(u===t||l===t||e.has(u)||e.has(l)||i.has(u)&&i.has(l))&&o.push(a)}),o}var xr=150,_r=50,Re=Object.prototype.hasOwnProperty;function la(n,r,t){if(!Re.call(t,"x")||!Re.call(t,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(r,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return t.color||(t.color=n.defaultNodeColor),!t.label&&t.label!==""&&(t.label=null),t.label!==void 0&&t.label!==null?t.label=""+t.label:t.label=null,t.size||(t.size=2),Re.call(t,"hidden")||(t.hidden=!1),Re.call(t,"highlighted")||(t.highlighted=!1),Re.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=n.defaultNodeType),t.zIndex||(t.zIndex=0),t}function ha(n,r,t){return t.color||(t.color=n.defaultEdgeColor),t.label||(t.label=""),t.size||(t.size=.5),Re.call(t,"hidden")||(t.hidden=!1),Re.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=n.defaultEdgeType),t.zIndex||(t.zIndex=0),t}var da=(function(n){function r(t,e){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(re(this,r),i=le(this,r),T(i,"elements",{}),T(i,"canvasContexts",{}),T(i,"webGLContexts",{}),T(i,"pickingLayers",new Set),T(i,"textures",{}),T(i,"frameBuffers",{}),T(i,"activeListeners",{}),T(i,"labelGrid",new Er),T(i,"nodeDataCache",{}),T(i,"edgeDataCache",{}),T(i,"nodeProgramIndex",{}),T(i,"edgeProgramIndex",{}),T(i,"nodesWithForcedLabels",new Set),T(i,"edgesWithForcedLabels",new Set),T(i,"nodeExtent",{x:[0,1],y:[0,1]}),T(i,"nodeZExtent",[1/0,-1/0]),T(i,"edgeZExtent",[1/0,-1/0]),T(i,"matrix",ye()),T(i,"invMatrix",ye()),T(i,"correctionRatio",1),T(i,"customBBox",null),T(i,"normalizationFunction",mr({x:[0,1],y:[0,1]})),T(i,"graphToViewportRatio",1),T(i,"itemIDsIndex",{}),T(i,"nodeIndices",{}),T(i,"edgeIndices",{}),T(i,"width",0),T(i,"height",0),T(i,"pixelRatio",gr()),T(i,"pickingDownSizingRatio",2*i.pixelRatio),T(i,"displayedNodeLabels",new Set),T(i,"displayedEdgeLabels",new Set),T(i,"highlightedNodes",new Set),T(i,"hoveredNode",null),T(i,"hoveredEdge",null),T(i,"renderFrame",null),T(i,"renderHighlightedNodesFrame",null),T(i,"needToProcess",!1),T(i,"checkEdgesEventsFrame",null),T(i,"nodePrograms",{}),T(i,"nodeHoverPrograms",{}),T(i,"edgePrograms",{}),i.settings=Yo(o),Dt(i.settings),Wo(t),!(e instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=t,i.container=e,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var a in i.settings.nodeProgramClasses)i.registerNodeProgram(a,i.settings.nodeProgramClasses[a],i.settings.nodeHoverProgramClasses[a]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new yr,i.bindCameraHandlers(),i.mouseCaptor=new ea(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new ia(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return he(r,n),ie(r,[{key:"registerNodeProgram",value:function(e,i,o){return this.nodePrograms[e]&&this.nodePrograms[e].kill(),this.nodeHoverPrograms[e]&&this.nodeHoverPrograms[e].kill(),this.nodePrograms[e]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[e]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(e,i){return this.edgePrograms[e]&&this.edgePrograms[e].kill(),this.edgePrograms[e]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(e){if(this.nodePrograms[e]){var i=this.nodePrograms,o=i[e],a=Gt(i,[e].map(it));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[e]){var s=this.nodeHoverPrograms,u=s[e],l=Gt(s,[e].map(it));u.kill(),this.nodePrograms=l}return this}},{key:"unregisterEdgeProgram",value:function(e){if(this.edgePrograms[e]){var i=this.edgePrograms,o=i[e],a=Gt(i,[e].map(it));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(e){var i=this.webGLContexts[e],o=this.frameBuffers[e],a=this.textures[e];a&&i.deleteTexture(a);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,s,0),this.textures[e]=s,this}},{key:"bindCameraHandlers",value:function(){var e=this;return this.activeListeners.camera=function(){e.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(e){var i=e.x,o=e.y,a=ir(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=rr.apply(void 0,br(a)),u=this.itemIDsIndex[s];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var e=this;this.activeListeners.handleResize=function(){e.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var a=et(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},u=e.getNodeAtPosition(a);if(u&&e.hoveredNode!==u&&!e.nodeDataCache[u].hidden){e.hoveredNode&&e.emit("leaveNode",F(F({},s),{},{node:e.hoveredNode})),e.hoveredNode=u,e.emit("enterNode",F(F({},s),{},{node:u})),e.scheduleHighlightedNodesRender();return}if(e.hoveredNode&&e.getNodeAtPosition(a)!==e.hoveredNode){var l=e.hoveredNode;e.hoveredNode=null,e.emit("leaveNode",F(F({},s),{},{node:l})),e.scheduleHighlightedNodesRender();return}if(e.settings.enableEdgeEvents){var h=e.hoveredNode?null:e.getEdgeAtPoint(s.event.x,s.event.y);h!==e.hoveredEdge&&(e.hoveredEdge&&e.emit("leaveEdge",F(F({},s),{},{edge:e.hoveredEdge})),h&&e.emit("enterEdge",F(F({},s),{},{edge:h})),e.hoveredEdge=h)}},this.activeListeners.handleMoveBody=function(o){var a=et(o);e.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=et(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};e.hoveredNode&&(e.emit("leaveNode",F(F({},s),{},{node:e.hoveredNode})),e.scheduleHighlightedNodesRender()),e.settings.enableEdgeEvents&&e.hoveredEdge&&(e.emit("leaveEdge",F(F({},s),{},{edge:e.hoveredEdge})),e.scheduleHighlightedNodesRender()),e.emit("leaveStage",F({},s))},this.activeListeners.handleEnter=function(o){var a=et(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};e.emit("enterStage",F({},s))};var i=function(a){return function(s){var u=et(s),l={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},h=e.getNodeAtPosition(u);if(h)return e.emit("".concat(a,"Node"),F(F({},l),{},{node:h}));if(e.settings.enableEdgeEvents){var d=e.getEdgeAtPoint(u.x,u.y);if(d)return e.emit("".concat(a,"Edge"),F(F({},l),{},{edge:d}))}return e.emit("".concat(a,"Stage"),l)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("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 e=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,u=(s=a.hints)===null||s===void 0?void 0:s.attributes;e.graph.forEachNode(function(h){return e.updateNode(h)});var l=!u||u.some(function(h){return o.has(h)});e.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!l,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,u=(s=a.hints)===null||s===void 0?void 0:s.attributes;e.graph.forEachEdge(function(h){return e.updateEdge(h)});var l=u&&["zIndex","type"].some(function(h){return u==null?void 0:u.includes(h)});e.refresh({partialGraph:{edges:i.edges()},skipIndexation:!l,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;e.addNode(s),e.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;e.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;e.removeNode(s),e.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;e.addEdge(s),e.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;e.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;e.removeEdge(s),e.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){e.clearEdgeState(),e.clearEdgeIndices(),e.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){e.clearEdgeState(),e.clearNodeState(),e.clearEdgeIndices(),e.clearNodeIndices(),e.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var e=this.graph;e.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),e.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),e.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),e.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),e.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),e.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),e.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),e.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),e.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),e.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(e,i){var o=ir(this.webGLContexts.edges,this.frameBuffers.edges,e,i,this.pixelRatio,this.pickingDownSizingRatio),a=rr.apply(void 0,br(o)),s=this.itemIDsIndex[a];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var e=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,a=this.getDimensions();if(this.nodeExtent=Ho(this.graph),!this.settings.autoRescale){var s=a.width,u=a.height,l=this.nodeExtent,h=l.x,d=l.y;this.nodeExtent={x:[(h[0]+h[1])/2-s/2,(h[0]+h[1])/2+s/2],y:[(d[0]+d[1])/2-u/2,(d[0]+d[1])/2+u/2]}}this.normalizationFunction=mr(this.customBBox||this.nodeExtent);var c=new yr,f=Je(c.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var b={},w={},E={},L={},_=1,R=i.nodes(),m=0,y=R.length;m<y;m++){var S=R[m],C=this.nodeDataCache[S],P=i.getNodeAttributes(S);C.x=P.x,C.y=P.y,this.normalizationFunction.applyTo(C),typeof C.label=="string"&&!C.hidden&&this.labelGrid.add(S,C.size,this.framedGraphToViewport(C,{matrix:f})),b[C.type]=(b[C.type]||0)+1}this.labelGrid.organize();for(var O in this.nodePrograms){if(!Re.call(this.nodePrograms,O))throw new Error('Sigma: could not find a suitable program for node type "'.concat(O,'"!'));this.nodePrograms[O].reallocate(b[O]||0),b[O]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(R=pr(this.nodeZExtent,function(se){return e.nodeDataCache[se].zIndex},R));for(var z=0,Y=R.length;z<Y;z++){var j=R[z];w[j]=_,L[w[j]]={type:"node",id:j},_++;var p=this.nodeDataCache[j];this.addNodeToProgram(j,w[j],b[p.type]++)}for(var Q={},ne=i.edges(),k=0,v=ne.length;k<v;k++){var B=ne[k],q=this.edgeDataCache[B];Q[q.type]=(Q[q.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(ne=pr(this.edgeZExtent,function(se){return e.edgeDataCache[se].zIndex},ne));for(var ee in this.edgePrograms){if(!Re.call(this.edgePrograms,ee))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ee,'"!'));this.edgePrograms[ee].reallocate(Q[ee]||0),Q[ee]=0}for(var oe=0,J=ne.length;oe<J;oe++){var I=ne[oe];E[I]=_,L[E[I]]={type:"edge",id:I},_++;var Le=this.edgeDataCache[I];this.addEdgeToProgram(I,E[I],Q[Le.type]++)}return this.itemIDsIndex=L,this.nodeIndices=w,this.edgeIndices=E,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(e){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(h){return i.cleanCameraState(h,o.cameraPanBoundaries&&Ut(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),e){if(e.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==e.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in e.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(e.nodeProgramClasses!==o.nodeProgramClasses||e.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var u in o.nodeProgramClasses)(o.nodeProgramClasses[u]!==e.nodeProgramClasses[u]||o.nodeHoverProgramClasses[u]!==e.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,o.nodeProgramClasses[u],o.nodeHoverProgramClasses[u]);for(var l in e.nodeProgramClasses)o.nodeProgramClasses[l]||this.unregisterNodeProgram(l)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,a=o===void 0?0:o,s=i.boundaries,u=F({},e),l=s||this.nodeExtent,h=We(l.x,2),d=h[0],c=h[1],f=We(l.y,2),b=f[0],w=f[1],E=[this.graphToViewport({x:d,y:b},{cameraState:e}),this.graphToViewport({x:c,y:b},{cameraState:e}),this.graphToViewport({x:d,y:w},{cameraState:e}),this.graphToViewport({x:c,y:w},{cameraState:e})],L=1/0,_=-1/0,R=1/0,m=-1/0;E.forEach(function(Q){var ne=Q.x,k=Q.y;L=Math.min(L,ne),_=Math.max(_,ne),R=Math.min(R,k),m=Math.max(m,k)});var y=_-L,S=m-R,C=this.getDimensions(),P=C.width,O=C.height,z=0,Y=0;if(y>=P?_<P-a?z=_-(P-a):L>a&&(z=L-a):_>P+a?z=_-(P+a):L<-a&&(z=L+a),S>=O?m<O-a?Y=m-(O-a):R>a&&(Y=R-a):m>O+a?Y=m-(O+a):R<-a&&(Y=R+a),z||Y){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:e}),p=this.viewportToFramedGraph({x:z,y:Y},{cameraState:e});z=p.x-j.x,Y=p.y-j.y,u.x+=z,u.y+=Y}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var e=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(e.ratio,this.settings.labelDensity);vr(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=i.length;a<s;a++){var u=i[a],l=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!l.hidden){var h=this.framedGraphToViewport(l),d=h.x,c=h.y,f=this.scaleSize(l.size);if(!(!l.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(d<-xr||d>this.width+xr||c<-_r||c>this.height+_r)){this.displayedNodeLabels.add(u);var b=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[l.type],E=(w==null?void 0:w.drawLabel)||b;E(o,F(F({key:u},l),{},{size:f,x:d,y:c}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var e=this.canvasContexts.edgeLabels;e.clearRect(0,0,this.width,this.height);var i=ua({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});vr(i,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=i.length;a<s;a++){var u=i[a],l=this.graph.extremities(u),h=this.nodeDataCache[l[0]],d=this.nodeDataCache[l[1]],c=this.edgeDataCache[u];if(!o.has(u)&&!(c.hidden||h.hidden||d.hidden)){var f=this.settings.defaultDrawEdgeLabel,b=this.edgePrograms[c.type],w=(b==null?void 0:b.drawLabel)||f;w(e,F(F({key:u},c),{},{size:this.scaleSize(c.size)}),F(F(F({key:l[0]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),F(F(F({key:l[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),o.add(u)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var e=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(f){var b=e.nodeDataCache[f],w=e.framedGraphToViewport(b),E=w.x,L=w.y,_=e.scaleSize(b.size),R=e.settings.defaultDrawNodeHover,m=e.nodePrograms[b.type],y=(m==null?void 0:m.drawHover)||R;y(i,F(F({key:f},b),{},{size:_,x:E,y:L}),e.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(c){c!==e.hoveredNode&&a.push(c)}),a.forEach(function(c){return o(c)});var s={};a.forEach(function(c){var f=e.nodeDataCache[c].type;s[f]=(s[f]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(s[u]||0),s[u]=0;a.forEach(function(c){var f=e.nodeDataCache[c];e.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var l=this.getRenderParams();for(var h in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[h];d.render(l)}}},{key:"scheduleHighlightedNodesRender",value:function(){var e=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){e.renderHighlightedNodesFrame=null,e.renderHighlightedNodes(),e.renderEdgeLabels()}))}},{key:"render",value:function(){var e=this;this.emit("beforeRender");var i=function(){return e.emit("afterRender"),e};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(E){return e.resetWebGLTexture(E)}),!this.graph.order)return i();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),u=this.getDimensions(),l=this.getGraphDimensions(),h=this.getStagePadding();this.matrix=Je(s,u,l,h),this.invMatrix=Je(s,u,l,h,!0),this.correctionRatio=Bo(this.matrix,s,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var c in this.nodePrograms){var f=this.nodePrograms[c];f.render(d)}if(!this.settings.hideEdgesOnMove||!a)for(var b in this.edgePrograms){var w=this.edgePrograms[b];w.render(d)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(e){var i=Object.assign({},this.graph.getNodeAttributes(e));this.settings.nodeReducer&&(i=this.settings.nodeReducer(e,i));var o=la(this.settings,e,i);this.nodeDataCache[e]=o,this.nodesWithForcedLabels.delete(e),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(e),this.highlightedNodes.delete(e),o.highlighted&&!o.hidden&&this.highlightedNodes.add(e),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(e){this.addNode(e);var i=this.nodeDataCache[e];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(e){delete this.nodeDataCache[e],delete this.nodeProgramIndex[e],this.highlightedNodes.delete(e),this.hoveredNode===e&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(e)}},{key:"addEdge",value:function(e){var i=Object.assign({},this.graph.getEdgeAttributes(e));this.settings.edgeReducer&&(i=this.settings.edgeReducer(e,i));var o=ha(this.settings,e,i);this.edgeDataCache[e]=o,this.edgesWithForcedLabels.delete(e),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(e),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(e){this.addEdge(e)}},{key:"removeEdge",value:function(e){delete this.edgeDataCache[e],delete this.edgeProgramIndex[e],this.hoveredEdge===e&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(e)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Er,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(e,i,o){var a=this.nodeDataCache[e],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(i,o,a),this.nodeProgramIndex[e]=o}},{key:"addEdgeToProgram",value:function(e,i,o){var a=this.edgeDataCache[e],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var u=this.graph.extremities(e),l=this.nodeDataCache[u[0]],h=this.nodeDataCache[u[1]];s.process(i,o,l,h,a),this.edgeProgramIndex[e]=o}},{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 e=this.settings,i=e.stagePadding,o=e.autoRescale;return o&&i||0}},{key:"createLayer",value:function(e,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[e])throw new Error('Sigma: a layer named "'.concat(e,'" already exists'));var a=Vo(i,{position:"absolute"},{class:"sigma-".concat(e)});return o.style&&Object.assign(a.style,o.style),this.elements[e]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(e,"canvas",i)}},{key:"createCanvasContext",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(e,i),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[e]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=(i==null?void 0:i.canvas)||this.createCanvas(e,i);i.hidden&&o.remove();var a=F({preserveDrawingBuffer:!1,antialias:!1},i),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var u=s;if(this.webGLContexts[e]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(e);var l=u.createFramebuffer();if(!l)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(e));this.frameBuffers[e]=l}return u}},{key:"killLayer",value:function(e){var i=this.elements[e];if(!i)throw new Error("Sigma: cannot kill layer ".concat(e,", which does not exist"));if(this.webGLContexts[e]){var o,a=this.webGLContexts[e];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[e]}else this.canvasContexts[e]&&delete this.canvasContexts[e];return i.remove(),delete this.elements[e],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(e){this.unbindCameraHandlers(),this.camera=e,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(e){e!==this.graph&&(this.hoveredNode&&!e.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!e.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=e,this.bindGraphHandlers(),this.refresh())}},{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 e=this.customBBox||this.nodeExtent;return{width:e.x[1]-e.x[0]||1,height:e.y[1]-e.y[0]||1}}},{key:"getNodeDisplayData",value:function(e){var i=this.nodeDataCache[e];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(e){var i=this.edgeDataCache[e];return i?Object.assign({},i):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(e){return this.settings[e]}},{key:"setSetting",value:function(e,i){var o=F({},this.settings);return this.settings[e]=i,Dt(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(e,i){return this.setSetting(e,i(this.settings[e])),this}},{key:"setSettings",value:function(e){var i=F({},this.settings);return this.settings=F(F({},this.settings),e),Dt(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(e){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=gr(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!e&&i===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];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 l in this.webGLContexts){this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px");var h=this.webGLContexts[l];if(h.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(l)){var d=this.textures[l];d&&h.deleteTexture(d)}}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(e){var i=this,o=(e==null?void 0:e.skipIndexation)!==void 0?e==null?void 0:e.skipIndexation:!1,a=(e==null?void 0:e.schedule)!==void 0?e.schedule:!1,s=!e||!e.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(m){return i.addNode(m)}),this.graph.forEachEdge(function(m){return i.addEdge(m)});else{for(var u,l,h=((u=e.partialGraph)===null||u===void 0?void 0:u.nodes)||[],d=0,c=(h==null?void 0:h.length)||0;d<c;d++){var f=h[d];if(this.updateNode(f),o){var b=this.nodeProgramIndex[f];if(b===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],b)}}for(var w=(e==null||(l=e.partialGraph)===null||l===void 0?void 0:l.edges)||[],E=0,L=w.length;E<L;E++){var _=w[E];if(this.updateEdge(_),o){var R=this.edgeProgramIndex[_];if(R===void 0)throw new Error('Sigma: edge "'.concat(_,`" can't be repaint`));this.addEdgeToProgram(_,this.edgeIndices[_],R)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var e=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){e.render()})),this}},{key:"scheduleRefresh",value:function(e){return this.refresh(F(F({},e),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(e,i){var o=this.camera.getState(),a=o.ratio,s=o.angle,u=o.x,l=o.y,h=this.settings,d=h.minCameraRatio,c=h.maxCameraRatio;typeof c=="number"&&(i=Math.min(i,c)),typeof d=="number"&&(i=Math.max(i,d));var f=i/a,b={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(e),E=this.viewportToFramedGraph(b);return{angle:s,x:(w.x-E.x)*(1-f)+u,y:(w.y-E.y)*(1-f)+l,ratio:i}}},{key:"viewRectangle",value:function(){var e=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:e.x,y1:e.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,a=i.matrix?i.matrix:o?Je(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=$t(a,e);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,a=i.matrix?i.matrix:o?Je(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=$t(a,{x:e.x/this.width*2-1,y:1-e.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(e,i))}},{key:"graphToViewport",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(e),i)}},{key:"getGraphToViewportRatio",value:function(){var e={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=this.graphToViewport(e),s=this.graphToViewport(i),u=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return u/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(e){return this.customBBox=e,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 e=this.container;e.firstChild;)e.removeChild(e.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].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 e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return e/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var e={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(e[i]=this.elements[i]);return e}}])})(Yt);const Ei=G.createContext(null),ca=Ei.Provider;function xi(){const n=G.useContext(Ei);if(n==null)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return n}function yt(){return xi().sigma}function fa(){const{sigma:n}=xi();return G.useCallback((r=>{n&&Object.keys(r).forEach((t=>{n.setSetting(t,r[t])}))}),[n])}function bt(n){return new Set(Object.keys(n))}const Cr=bt({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}),Sr=bt({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),Tr=bt({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),Rr=bt({updated:!0});function ga(){const n=yt(),r=fa(),[t,e]=G.useState({});return G.useEffect((()=>{if(!n||!t)return;const i=t,o=Object.keys(i);return o.forEach((a=>{const s=i[a];Cr.has(a)&&n.on(a,s),Sr.has(a)&&n.getMouseCaptor().on(a,s),Tr.has(a)&&n.getTouchCaptor().on(a,s),Rr.has(a)&&n.getCamera().on(a,s)})),()=>{n&&o.forEach((a=>{const s=i[a];Cr.has(a)&&n.off(a,s),Sr.has(a)&&n.getMouseCaptor().off(a,s),Tr.has(a)&&n.getTouchCaptor().off(a,s),Rr.has(a)&&n.getCamera().off(a,s)}))}}),[n,t,r]),e}function pa(){const n=yt();return G.useCallback(((r,t=!0)=>{n&&r&&(t&&n.getGraph().order>0&&n.getGraph().clear(),n.getGraph().import(r),n.refresh())}),[n])}function _i(n,r){if(n===r)return!0;if(typeof n=="object"&&n!=null&&typeof r=="object"&&r!=null){if(Object.keys(n).length!=Object.keys(r).length)return!1;for(const t in n)if(!Object.hasOwn(r,t)||!_i(n[t],r[t]))return!1;return!0}return!1}const ma=G.forwardRef((({graph:n,id:r,className:t,style:e,settings:i={},children:o},a)=>{const s=G.useRef(null),u=G.useRef(null),l={className:`react-sigma ${t||""}`,id:r,style:e},[h,d]=G.useState(null),[c,f]=G.useState(i);G.useEffect((()=>{f((E=>_i(E,i)?E:i))}),[i]),G.useEffect((()=>{let E=null;if(u.current!==null){let L=new X;n&&(L=typeof n=="function"?new n:n),E=new da(L,u.current,c),d((_=>{let R=null;return _&&(R=_.getCamera().getState()),R&&E.getCamera().setState(R),E}))}return()=>{E&&E.kill()}}),[u,n,c]),G.useImperativeHandle(a,(()=>h),[h]);const b=G.useMemo((()=>h&&s.current?{sigma:h,container:s.current}:null),[h,s]),w=b!==null?Et.createElement(ca,{value:b},o):null;return Et.createElement("div",Object.assign({},l,{ref:s}),Et.createElement("div",{className:"sigma-container",ref:u}),w)}));var rt={},kr;function va(){if(kr)return rt;kr=1;function n(e){return typeof e!="number"||isNaN(e)?1:e}function r(e,i){var o={},a=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(a=i);var s=function(l){return a(l[e])},u=function(){return a(void 0)};return typeof e=="string"?(o.fromAttributes=s,o.fromGraph=function(l,h){return s(l.getNodeAttributes(h))},o.fromEntry=function(l,h){return s(h)}):typeof e=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},o.fromGraph=function(l,h){return a(e(h,l.getNodeAttributes(h)))},o.fromEntry=function(l,h){return a(e(l,h))}):(o.fromAttributes=u,o.fromGraph=u,o.fromEntry=u),o}function t(e,i){var o={},a=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(a=i);var s=function(l){return a(l[e])},u=function(){return a(void 0)};return typeof e=="string"?(o.fromAttributes=s,o.fromGraph=function(l,h){return s(l.getEdgeAttributes(h))},o.fromEntry=function(l,h){return s(h)},o.fromPartialEntry=o.fromEntry,o.fromMinimalEntry=o.fromEntry):typeof e=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},o.fromGraph=function(l,h){var d=l.extremities(h);return a(e(h,l.getEdgeAttributes(h),d[0],d[1],l.getNodeAttributes(d[0]),l.getNodeAttributes(d[1]),l.isUndirected(h)))},o.fromEntry=function(l,h,d,c,f,b,w){return a(e(l,h,d,c,f,b,w))},o.fromPartialEntry=function(l,h,d,c){return a(e(l,h,d,c))},o.fromMinimalEntry=function(l,h){return a(e(l,h))}):(o.fromAttributes=u,o.fromGraph=u,o.fromEntry=u,o.fromMinimalEntry=u),o}return rt.createNodeValueGetter=r,rt.createEdgeValueGetter=t,rt.createEdgeWeightGetter=function(e){return t(e,n)},rt}var Nt,Ar;function ya(){if(Ar)return Nt;Ar=1;var n=0,r=1,t=2,e=3,i=4,o=5,a=6,s=7,u=8,l=9,h=0,d=1,c=2,f=0,b=1,w=2,E=3,L=4,_=5,R=6,m=7,y=8,S=3,C=10,P=3,O=9,z=10;return Nt=function(j,p,Q){var ne,k,v,B,q,ee,oe,J,I,Le,se=p.length,ot=Q.length,Ie=j.adjustSizes,at=j.barnesHutTheta*j.barnesHutTheta,Ue,K,W,H,ge,M,$,x=[];for(v=0;v<se;v+=C)p[v+i]=p[v+t],p[v+o]=p[v+e],p[v+t]=0,p[v+e]=0;if(j.outboundAttractionDistribution){for(Ue=0,v=0;v<se;v+=C)Ue+=p[v+a];Ue/=se/C}if(j.barnesHutOptimize){var pe=1/0,De=-1/0,Ee=1/0,Ge=-1/0,ue,Ne,Ye;for(v=0;v<se;v+=C)pe=Math.min(pe,p[v+n]),De=Math.max(De,p[v+n]),Ee=Math.min(Ee,p[v+r]),Ge=Math.max(Ge,p[v+r]);var je=De-pe,Fe=Ge-Ee;for(je>Fe?(Ee-=(je-Fe)/2,Ge=Ee+je):(pe-=(Fe-je)/2,De=pe+Fe),x[0+f]=-1,x[0+b]=(pe+De)/2,x[0+w]=(Ee+Ge)/2,x[0+E]=Math.max(De-pe,Ge-Ee),x[0+L]=-1,x[0+_]=-1,x[0+R]=0,x[0+m]=0,x[0+y]=0,ne=1,v=0;v<se;v+=C)for(k=0,Ye=S;;)if(x[k+_]>=0){p[v+n]<x[k+b]?p[v+r]<x[k+w]?ue=x[k+_]:ue=x[k+_]+O:p[v+r]<x[k+w]?ue=x[k+_]+O*2:ue=x[k+_]+O*3,x[k+m]=(x[k+m]*x[k+R]+p[v+n]*p[v+a])/(x[k+R]+p[v+a]),x[k+y]=(x[k+y]*x[k+R]+p[v+r]*p[v+a])/(x[k+R]+p[v+a]),x[k+R]+=p[v+a],k=ue;continue}else if(x[k+f]<0){x[k+f]=v;break}else{if(x[k+_]=ne*O,J=x[k+E]/2,I=x[k+_],x[I+f]=-1,x[I+b]=x[k+b]-J,x[I+w]=x[k+w]-J,x[I+E]=J,x[I+L]=I+O,x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,I+=O,x[I+f]=-1,x[I+b]=x[k+b]-J,x[I+w]=x[k+w]+J,x[I+E]=J,x[I+L]=I+O,x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,I+=O,x[I+f]=-1,x[I+b]=x[k+b]+J,x[I+w]=x[k+w]-J,x[I+E]=J,x[I+L]=I+O,x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,I+=O,x[I+f]=-1,x[I+b]=x[k+b]+J,x[I+w]=x[k+w]+J,x[I+E]=J,x[I+L]=x[k+L],x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,ne+=4,p[x[k+f]+n]<x[k+b]?p[x[k+f]+r]<x[k+w]?ue=x[k+_]:ue=x[k+_]+O:p[x[k+f]+r]<x[k+w]?ue=x[k+_]+O*2:ue=x[k+_]+O*3,x[k+R]=p[x[k+f]+a],x[k+m]=p[x[k+f]+n],x[k+y]=p[x[k+f]+r],x[ue+f]=x[k+f],x[k+f]=-1,p[v+n]<x[k+b]?p[v+r]<x[k+w]?Ne=x[k+_]:Ne=x[k+_]+O:p[v+r]<x[k+w]?Ne=x[k+_]+O*2:Ne=x[k+_]+O*3,ue===Ne)if(Ye--){k=ue;continue}else{Ye=S;break}x[Ne+f]=v;break}}if(j.barnesHutOptimize)for(K=j.scalingRatio,v=0;v<se;v+=C)for(k=0;;)if(x[k+_]>=0)if(M=Math.pow(p[v+n]-x[k+m],2)+Math.pow(p[v+r]-x[k+y],2),Le=x[k+E],4*Le*Le/M<at){if(W=p[v+n]-x[k+m],H=p[v+r]-x[k+y],Ie===!0?M>0?($=K*p[v+a]*x[k+R]/M,p[v+t]+=W*$,p[v+e]+=H*$):M<0&&($=-K*p[v+a]*x[k+R]/Math.sqrt(M),p[v+t]+=W*$,p[v+e]+=H*$):M>0&&($=K*p[v+a]*x[k+R]/M,p[v+t]+=W*$,p[v+e]+=H*$),k=x[k+L],k<0)break;continue}else{k=x[k+_];continue}else{if(ee=x[k+f],ee>=0&&ee!==v&&(W=p[v+n]-p[ee+n],H=p[v+r]-p[ee+r],M=W*W+H*H,Ie===!0?M>0?($=K*p[v+a]*p[ee+a]/M,p[v+t]+=W*$,p[v+e]+=H*$):M<0&&($=-K*p[v+a]*p[ee+a]/Math.sqrt(M),p[v+t]+=W*$,p[v+e]+=H*$):M>0&&($=K*p[v+a]*p[ee+a]/M,p[v+t]+=W*$,p[v+e]+=H*$)),k=x[k+L],k<0)break;continue}else for(K=j.scalingRatio,B=0;B<se;B+=C)for(q=0;q<B;q+=C)W=p[B+n]-p[q+n],H=p[B+r]-p[q+r],Ie===!0?(M=Math.sqrt(W*W+H*H)-p[B+u]-p[q+u],M>0?($=K*p[B+a]*p[q+a]/M/M,p[B+t]+=W*$,p[B+e]+=H*$,p[q+t]-=W*$,p[q+e]-=H*$):M<0&&($=100*K*p[B+a]*p[q+a],p[B+t]+=W*$,p[B+e]+=H*$,p[q+t]-=W*$,p[q+e]-=H*$)):(M=Math.sqrt(W*W+H*H),M>0&&($=K*p[B+a]*p[q+a]/M/M,p[B+t]+=W*$,p[B+e]+=H*$,p[q+t]-=W*$,p[q+e]-=H*$));for(I=j.gravity/j.scalingRatio,K=j.scalingRatio,v=0;v<se;v+=C)$=0,W=p[v+n],H=p[v+r],M=Math.sqrt(Math.pow(W,2)+Math.pow(H,2)),j.strongGravityMode?M>0&&($=K*p[v+a]*I):M>0&&($=K*p[v+a]*I/M),p[v+t]-=W*$,p[v+e]-=H*$;for(K=1*(j.outboundAttractionDistribution?Ue:1),oe=0;oe<ot;oe+=P)B=Q[oe+h],q=Q[oe+d],J=Q[oe+c],ge=Math.pow(J,j.edgeWeightInfluence),W=p[B+n]-p[q+n],H=p[B+r]-p[q+r],Ie===!0?(M=Math.sqrt(W*W+H*H)-p[B+u]-p[q+u],j.linLogMode?j.outboundAttractionDistribution?M>0&&($=-K*ge*Math.log(1+M)/M/p[B+a]):M>0&&($=-K*ge*Math.log(1+M)/M):j.outboundAttractionDistribution?M>0&&($=-K*ge/p[B+a]):M>0&&($=-K*ge)):(M=Math.sqrt(Math.pow(W,2)+Math.pow(H,2)),j.linLogMode?j.outboundAttractionDistribution?M>0&&($=-K*ge*Math.log(1+M)/M/p[B+a]):M>0&&($=-K*ge*Math.log(1+M)/M):j.outboundAttractionDistribution?(M=1,$=-K*ge/p[B+a]):(M=1,$=-K*ge)),M>0&&(p[B+t]+=W*$,p[B+e]+=H*$,p[q+t]-=W*$,p[q+e]-=H*$);var xe,N,Z,V,me,_e;if(Ie===!0)for(v=0;v<se;v+=C)p[v+l]!==1&&(xe=Math.sqrt(Math.pow(p[v+t],2)+Math.pow(p[v+e],2)),xe>z&&(p[v+t]=p[v+t]*z/xe,p[v+e]=p[v+e]*z/xe),N=p[v+a]*Math.sqrt((p[v+i]-p[v+t])*(p[v+i]-p[v+t])+(p[v+o]-p[v+e])*(p[v+o]-p[v+e])),Z=Math.sqrt((p[v+i]+p[v+t])*(p[v+i]+p[v+t])+(p[v+o]+p[v+e])*(p[v+o]+p[v+e]))/2,V=.1*Math.log(1+Z)/(1+Math.sqrt(N)),me=p[v+n]+p[v+t]*(V/j.slowDown),p[v+n]=me,_e=p[v+r]+p[v+e]*(V/j.slowDown),p[v+r]=_e);else for(v=0;v<se;v+=C)p[v+l]!==1&&(N=p[v+a]*Math.sqrt((p[v+i]-p[v+t])*(p[v+i]-p[v+t])+(p[v+o]-p[v+e])*(p[v+o]-p[v+e])),Z=Math.sqrt((p[v+i]+p[v+t])*(p[v+i]+p[v+t])+(p[v+o]+p[v+e])*(p[v+o]+p[v+e]))/2,V=p[v+s]*Math.log(1+Z)/(1+Math.sqrt(N)),p[v+s]=Math.min(1,Math.sqrt(V*(Math.pow(p[v+t],2)+Math.pow(p[v+e],2))/(1+Math.sqrt(N)))),me=p[v+n]+p[v+t]*(V/j.slowDown),p[v+n]=me,_e=p[v+r]+p[v+e]*(V/j.slowDown),p[v+r]=_e);return{}},Nt}var Ce={},Lr;function ba(){if(Lr)return Ce;Lr=1;var n=10,r=3;return Ce.assign=function(t){t=t||{};var e=Array.prototype.slice.call(arguments).slice(1),i,o,a;for(i=0,a=e.length;i<a;i++)if(e[i])for(o in e[i])t[o]=e[i][o];return t},Ce.validateSettings=function(t){return"linLogMode"in t&&typeof t.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&typeof t.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&typeof t.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&typeof t.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in t&&!(typeof t.scalingRatio=="number"&&t.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&typeof t.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&!(typeof t.gravity=="number"&&t.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&!(typeof t.slowDown=="number"||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&typeof t.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&!(typeof t.barnesHutTheta=="number"&&t.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Ce.graphToByteArrays=function(t,e){var i=t.order,o=t.size,a={},s,u=new Float32Array(i*n),l=new Float32Array(o*r);return s=0,t.forEachNode(function(h,d){a[h]=s,u[s]=d.x,u[s+1]=d.y,u[s+2]=0,u[s+3]=0,u[s+4]=0,u[s+5]=0,u[s+6]=1,u[s+7]=1,u[s+8]=d.size||1,u[s+9]=d.fixed?1:0,s+=n}),s=0,t.forEachEdge(function(h,d,c,f,b,w,E){var L=a[c],_=a[f],R=e(h,d,c,f,b,w,E);u[L+6]+=R,u[_+6]+=R,l[s]=L,l[s+1]=_,l[s+2]=R,s+=r}),{nodes:u,edges:l}},Ce.assignLayoutChanges=function(t,e,i){var o=0;t.updateEachNodeAttributes(function(a,s){return s.x=e[o],s.y=e[o+1],o+=n,i?i(a,s):s})},Ce.readGraphPositions=function(t,e){var i=0;t.forEachNode(function(o,a){e[i]=a.x,e[i+1]=a.y,i+=n})},Ce.collectLayoutChanges=function(t,e,i){for(var o=t.nodes(),a={},s=0,u=0,l=e.length;s<l;s+=n){if(i){var h=Object.assign({},t.getNodeAttributes(o[u]));h.x=e[s],h.y=e[s+1],h=i(o[u],h),a[o[u]]={x:h.x,y:h.y}}else a[o[u]]={x:e[s],y:e[s+1]};u++}return a},Ce.createWorker=function(e){var i=window.URL||window.webkitURL,o=e.toString(),a=i.createObjectURL(new Blob(["("+o+").call(this);"],{type:"text/javascript"})),s=new Worker(a);return i.revokeObjectURL(a),s},Ce}var Ft,Dr;function wa(){return Dr||(Dr=1,Ft={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),Ft}var Pt,Gr;function Ea(){if(Gr)return Pt;Gr=1;var n=yi(),r=va().createEdgeWeightGetter,t=ya(),e=ba(),i=wa();function o(u,l,h){if(!n(l))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof h=="number"&&(h={iterations:h});var d=h.iterations;if(typeof d!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(d<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=r("getEdgeWeight"in h?h.getEdgeWeight:"weight").fromEntry,f=typeof h.outputReducer=="function"?h.outputReducer:null,b=e.assign({},i,h.settings),w=e.validateSettings(b);if(w)throw new Error("graphology-layout-forceatlas2: "+w.message);var E=e.graphToByteArrays(l,c),L;for(L=0;L<d;L++)t(b,E.nodes,E.edges);if(u){e.assignLayoutChanges(l,E.nodes,f);return}return e.collectLayoutChanges(l,E.nodes)}function a(u){var l=typeof u=="number"?u:u.order;return{barnesHutOptimize:l>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(l)}}var s=o.bind(null,!1);return s.assign=o.bind(null,!0),s.inferSettings=a,Pt=s,Pt}var xa=Ea();const _a=$r(xa);function jt(n){return n!=null&&typeof n=="object"&&"symbols"in n&&Array.isArray(n.symbols)}function Ci(n){return n!=null&&typeof n=="object"&&"riskLevel"in n&&"affectedSymbols"in n}function Ca(n){return n!=null&&typeof n=="object"&&"result"in n&&Array.isArray(n.result)&&n.result.length>0&&typeof n.result[0]=="object"}function Sa(n){if(!Array.isArray(n)||n.length===0)return!1;const r=n[0];return r!=null&&typeof r=="object"&&!Array.isArray(r)}function Nr({data:n,pageSize:r=50}){const[t,e]=G.useState(0),i=G.useMemo(()=>{if(n.length===0)return[];const s=new Set;for(const u of n)for(const l of Object.keys(u))s.add(l);return Array.from(s)},[n]),o=Math.ceil(n.length/r),a=n.slice(t*r,(t+1)*r);return n.length===0?g.jsx("div",{className:"p-4 text-sm text-[var(--color-text-muted)]",children:"No results"}):g.jsxs("div",{children:[g.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] mb-2",children:[n.length," rows"]}),g.jsx("div",{className:"overflow-x-auto rounded-lg border border-[var(--color-border)]",children:g.jsxs("table",{className:"w-full text-xs",children:[g.jsx("thead",{children:g.jsx("tr",{className:"border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)] text-left text-[var(--color-text-muted)]",children:i.map(s=>g.jsx("th",{className:"py-1.5 px-2 font-medium whitespace-nowrap",children:s},s))})}),g.jsx("tbody",{children:a.map((s,u)=>g.jsx("tr",{className:"border-b border-[var(--color-border)] hover:bg-[var(--color-bg-tertiary)] transition-colors",children:i.map(l=>g.jsx("td",{className:"py-1 px-2 max-w-[300px] truncate",children:Ta(s[l])},l))},u))})]})}),o>1&&g.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2 text-xs",children:[g.jsx("button",{onClick:()=>e(s=>Math.max(0,s-1)),disabled:t===0,className:"px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] disabled:opacity-30",children:"Prev"}),g.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[t+1," / ",o]}),g.jsx("button",{onClick:()=>e(s=>Math.min(o-1,s+1)),disabled:t>=o-1,className:"px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] disabled:opacity-30",children:"Next"})]})]})}function Ta(n){return n==null?"—":typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):typeof n=="object"?JSON.stringify(n):String(n)}function Ra({data:n}){const[r,t]=G.useState(!1),[e,i]=G.useState(!1),o=JSON.stringify(n,null,2),a=G.useCallback(async()=>{try{await navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),2e3)}catch{}},[o]);return g.jsxs("div",{className:"rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]",children:[g.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-[var(--color-border)]",children:[g.jsx("button",{onClick:()=>t(s=>!s),className:"text-[10px] text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition-colors",children:r?"▸ Show JSON":"▾ JSON"}),g.jsx("button",{onClick:()=>void a(),className:"text-[10px] px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition-colors",children:e?"Copied!":"Copy"})]}),!r&&g.jsx("pre",{className:"p-3 text-xs whitespace-pre-wrap overflow-x-auto max-h-[400px] overflow-y-auto",children:o})]})}function ka(n){const r=[],t=new Map;for(const e of n){if(!e.file)continue;const i=t.get(e.file);i?i.push(e):t.set(e.file,[e])}for(const[e,i]of t){const o=e.split("/");let a=r;for(let s=0;s<o.length;s++){const u=o[s],l=o.slice(0,s+1).join("/"),h=s===o.length-1;let d=a.find(c=>c.name===u);d||(d={name:u,path:l,isDirectory:!h,children:[],symbolCount:0,symbols:[]},a.push(d)),h&&(d.symbols=i),a=d.children}}return Mt(r),r}function Mt(n){let r=0;for(const t of n)if(t.isDirectory){const e=Mt(t.children);t.symbolCount=e,r+=e}else t.symbolCount=t.symbols.length,r+=t.symbols.length,Mt(t.children);return n.sort((t,e)=>t.isDirectory!==e.isDirectory?t.isDirectory?-1:1:t.name.localeCompare(e.name)),r}function Aa(n,r){if(!r.trim())return n;const t=r.toLowerCase();return Si(n,t)}function Si(n,r){const t=[];for(const e of n){const i=e.path.toLowerCase().includes(r);if(i&&!e.isDirectory)t.push(e);else if(e.isDirectory)if(i)t.push(e);else{const o=Si(e.children,r);o.length>0&&t.push({...e,children:o})}}return t}const La=G.memo(function({tree:r,searchQuery:t,onSearchChange:e,expandedPaths:i,onToggleExpand:o,selectedPath:a,onSelectPath:s}){return g.jsxs("div",{className:"flex flex-col min-h-0",children:[g.jsx("div",{className:"px-3 py-2 border-b border-[var(--color-border)]",children:g.jsx("input",{type:"text",value:t,onChange:u=>e(u.target.value),placeholder:"Search files...",className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]"})}),g.jsx("div",{className:"overflow-y-auto flex-1 py-1",children:r.length===0?g.jsx("div",{className:"px-3 py-4 text-xs text-[var(--color-text-muted)] text-center",children:t?"No files match":"No files indexed"}):r.map(u=>g.jsx(Ti,{item:u,depth:0,expandedPaths:i,selectedPath:a,onToggleExpand:o,onSelectPath:s},u.path))})]})});function Ti({item:n,depth:r,expandedPaths:t,selectedPath:e,onToggleExpand:i,onSelectPath:o}){const a=t.has(n.path),s=e===n.path,u=n.children.length>0,l=n.isDirectory?we.folder:we.file,h=G.useCallback(c=>{c.stopPropagation(),i(n.path)},[n.path,i]),d=G.useCallback(()=>{n.isDirectory&&i(n.path),o(n.path,n.isDirectory)},[n.path,n.isDirectory,i,o]);return g.jsxs(g.Fragment,{children:[g.jsxs("button",{onClick:d,className:`w-full text-left flex items-center gap-1.5 px-2 py-0.5 text-xs hover:bg-[var(--color-bg-tertiary)] transition-colors ${s?"bg-[var(--color-bg-tertiary)] font-semibold":""}`,style:{paddingLeft:`${r*14+8}px`},children:[u||n.isDirectory?g.jsx("span",{onClick:h,className:"w-3 text-center text-[var(--color-text-muted)] hover:text-[var(--color-text)] cursor-pointer shrink-0 text-[10px]",children:a?"▾":"▸"}):g.jsx("span",{className:"w-3 shrink-0"}),g.jsx("span",{style:{color:l},className:"shrink-0 text-[10px]",children:n.isDirectory?"📁":"📄"}),g.jsx("span",{className:"truncate",style:{color:l},children:n.name}),n.symbolCount>0&&g.jsx("span",{className:"text-[9px] text-[var(--color-text-muted)] ml-auto shrink-0",children:n.symbolCount})]}),a&&n.children.map(c=>g.jsx(Ti,{item:c,depth:r+1,expandedPaths:t,selectedPath:e,onToggleExpand:i,onSelectPath:o},c.path))]})}const Fr=Object.keys(we),Da=Object.keys(pt),Ga=[{label:"All",value:null},{label:"1 hop",value:1},{label:"2 hops",value:2},{label:"3 hops",value:3}],Na=G.memo(function({visibleNodeKinds:r,visibleEdgeTypes:t,focusDepth:e,onToggleNodeKind:i,onToggleEdgeType:o,onSetFocusDepth:a,symbolCounts:s,relationCounts:u}){return g.jsxs("div",{className:"p-4 overflow-y-auto flex-1 space-y-6",children:[g.jsxs("section",{children:[g.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--color-text-muted)] mb-1",children:"Node Types"}),g.jsx("p",{className:"text-[9px] text-[var(--color-text-muted)] mb-2",children:"Toggle visibility of node types in the graph"}),g.jsx("div",{className:"space-y-1",children:Fr.map(l=>{const h=we[l],d=r.has(l),c=s[l]??0;return g.jsxs("button",{onClick:()=>i(l),className:"w-full flex items-center gap-2 px-2 py-1 rounded text-xs hover:bg-[var(--color-bg-tertiary)] transition-colors",children:[g.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:d?h:"#333"}}),g.jsx("span",{className:d?"":"text-[var(--color-text-muted)] line-through",children:l.charAt(0).toUpperCase()+l.slice(1)}),g.jsx("span",{className:"text-[9px] text-[var(--color-text-muted)] ml-auto",children:c}),g.jsx(Pr,{open:d})]},l)})})]}),g.jsxs("section",{children:[g.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--color-text-muted)] mb-1",children:"Edge Types"}),g.jsx("p",{className:"text-[9px] text-[var(--color-text-muted)] mb-2",children:"Toggle visibility of relationship types"}),g.jsx("div",{className:"space-y-1",children:Da.map(l=>{const h=pt[l],d=Ur[l]??l,c=t.has(l),f=u[l]??0;return g.jsxs("button",{onClick:()=>o(l),className:"w-full flex items-center gap-2 px-2 py-1 rounded text-xs hover:bg-[var(--color-bg-tertiary)] transition-colors",children:[g.jsx("span",{className:"w-4 shrink-0 flex items-center",children:g.jsx("span",{className:"w-full h-0.5 rounded",style:{background:c?h:"#333"}})}),g.jsx("span",{className:c?"":"text-[var(--color-text-muted)] line-through",children:d}),g.jsx("span",{className:"text-[9px] text-[var(--color-text-muted)] ml-auto",children:f}),g.jsx(Pr,{open:c})]},l)})})]}),g.jsxs("section",{children:[g.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--color-text-muted)] mb-1",children:"Focus Depth"}),g.jsx("p",{className:"text-[9px] text-[var(--color-text-muted)] mb-2",children:"Show nodes within N hops of selected node"}),g.jsx("div",{className:"flex gap-1",children:Ga.map(l=>g.jsx("button",{onClick:()=>a(l.value),className:`text-[10px] px-2.5 py-1 rounded transition-colors ${e===l.value?"bg-[var(--color-accent)] text-white":"bg-[var(--color-bg-tertiary)] text-[var(--color-text-muted)] hover:bg-[var(--color-bg)]"}`,children:l.label},l.label))})]}),g.jsxs("section",{children:[g.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--color-text-muted)] mb-2",children:"Color Legend"}),g.jsx("div",{className:"grid grid-cols-2 gap-1",children:Fr.map(l=>g.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[g.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:we[l]}}),g.jsx("span",{children:l.charAt(0).toUpperCase()+l.slice(1)})]},l))})]})]})});function Pr({open:n}){return n?g.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-[var(--color-text-muted)]",children:[g.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),g.jsx("circle",{cx:"12",cy:"12",r:"3"})]}):g.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-[var(--color-text-muted)] opacity-40",children:[g.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),g.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),g.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Fa(n,r,t){if(!n.hasNode(r))return new Set;const e=new Set([r]),i=[[r,0]];for(;i.length>0;){const[o,a]=i.shift();if(!(a>=t))for(const s of n.neighbors(o))e.has(s)||(e.add(s),i.push([s,a+1]))}return e}var Pa=`
|
|
311
|
+
`,Ra=Ta,vi=WebGLRenderingContext,hr=vi.UNSIGNED_BYTE,Qe=vi.FLOAT,ka=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Aa=(function(n){function r(){return re(this,r),le(this,r,arguments)}return he(r,n),ie(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Ra,FRAGMENT_SHADER_SOURCE:Kt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:ka,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Qe},{name:"a_positionEnd",size:2,type:Qe},{name:"a_normal",size:2,type:Qe},{name:"a_color",size:4,type:hr,normalized:!0},{name:"a_id",size:4,type:hr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Qe},{name:"a_normalCoef",size:1,type:Qe}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(e,i,a,o,s){var u=s.size||1,l=a.x,h=a.y,d=o.x,c=o.y,f=$e(s.color),b=d-l,w=c-h,E=b*b+w*w,L=0,_=0;E&&(E=1/Math.sqrt(E),L=-w*E*u,_=b*E*u);var R=this.array;R[i++]=l,R[i++]=h,R[i++]=d,R[i++]=c,R[i++]=L,R[i++]=_,R[i++]=f,R[i++]=e}},{key:"setUniforms",value:function(e,i){var a=i.gl,o=i.uniformLocations,s=o.u_matrix,u=o.u_zoomRatio,l=o.u_feather,h=o.u_pixelRatio,d=o.u_correctionRatio,c=o.u_sizeRatio,f=o.u_minEdgeThickness;a.uniformMatrix3fv(s,!1,e.matrix),a.uniform1f(u,e.zoomRatio),a.uniform1f(c,e.sizeRatio),a.uniform1f(d,e.correctionRatio),a.uniform1f(h,e.pixelRatio),a.uniform1f(l,e.antiAliasingFeather),a.uniform1f(f,e.minEdgeThickness)}}])})(nt),Yt=(function(n){function r(){var t;return re(this,r),t=le(this,r),t.rawEmitter=t,t}return he(r,n),ie(r)})(jr.EventEmitter),At,dr;function yi(){return dr||(dr=1,At=function(r){return r!==null&&typeof r=="object"&&typeof r.addUndirectedEdgeWithKey=="function"&&typeof r.dropNode=="function"&&typeof r.multi=="boolean"}),At}var La=yi();const Da=$r(La);var Ga=function(r){return r},Na=function(r){return r*r},Fa=function(r){return r*(2-r)},Pa=function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)},Ia=function(r){return r*r*r},Oa=function(r){return--r*r*r+1},za=function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)},$a={linear:Ga,quadraticIn:Na,quadraticOut:Fa,quadraticInOut:Pa,cubicIn:Ia,cubicOut:Oa,cubicInOut:za},Ua={easing:"quadraticInOut",duration:150};function ye(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function dt(n,r,t){return n[0]=r,n[4]=typeof t=="number"?t:r,n}function cr(n,r){var t=Math.sin(r),e=Math.cos(r);return n[0]=e,n[1]=t,n[3]=-t,n[4]=e,n}function fr(n,r,t){return n[6]=r,n[7]=t,n}function Pe(n,r){var t=n[0],e=n[1],i=n[2],a=n[3],o=n[4],s=n[5],u=n[6],l=n[7],h=n[8],d=r[0],c=r[1],f=r[2],b=r[3],w=r[4],E=r[5],L=r[6],_=r[7],R=r[8];return n[0]=d*t+c*a+f*u,n[1]=d*e+c*o+f*l,n[2]=d*i+c*s+f*h,n[3]=b*t+w*a+E*u,n[4]=b*e+w*o+E*l,n[5]=b*i+w*s+E*h,n[6]=L*t+_*a+R*u,n[7]=L*e+_*o+R*l,n[8]=L*i+_*s+R*h,n}function $t(n,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,e=n[0],i=n[1],a=n[3],o=n[4],s=n[6],u=n[7],l=r.x,h=r.y;return{x:l*e+h*a+s*t,y:l*i+h*o+u*t}}function ja(n,r){var t=n.height/n.width,e=r.height/r.width;return t<1&&e>1||t>1&&e<1?1:Math.min(Math.max(e,1/e),Math.max(1/t,t))}function Je(n,r,t,e,i){var a=n.angle,o=n.ratio,s=n.x,u=n.y,l=r.width,h=r.height,d=ye(),c=Math.min(l,h)-2*e,f=ja(r,t);return i?(Pe(d,fr(ye(),s,u)),Pe(d,dt(ye(),o)),Pe(d,cr(ye(),a)),Pe(d,dt(ye(),l/c/2/f,h/c/2/f))):(Pe(d,dt(ye(),2*(c/l)*f,2*(c/h)*f)),Pe(d,cr(ye(),-a)),Pe(d,dt(ye(),1/o)),Pe(d,fr(ye(),-s,-u))),d}function Ma(n,r,t){var e=$t(n,{x:Math.cos(r.angle),y:Math.sin(r.angle)},0),i=e.x,a=e.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(a,2))/t.width}function Ba(n){if(!n.order)return{x:[0,1],y:[0,1]};var r=1/0,t=-1/0,e=1/0,i=-1/0;return n.forEachNode(function(a,o){var s=o.x,u=o.y;s<r&&(r=s),s>t&&(t=s),u<e&&(e=u),u>i&&(i=u)}),{x:[r,t],y:[e,i]}}function Ha(n){if(!Da(n))throw new Error("Sigma: invalid graph instance.");n.forEachNode(function(r,t){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new Error("Sigma: Coordinates of node ".concat(r," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Wa(n,r,t){var e=document.createElement(n);if(r)for(var i in r)e.style[i]=r[i];if(t)for(var a in t)e.setAttribute(a,t[a]);return e}function gr(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function pr(n,r,t){return t.sort(function(e,i){var a=r(e)||0,o=r(i)||0;return a<o?-1:a>o?1:0})}function mr(n){var r=We(n.x,2),t=r[0],e=r[1],i=We(n.y,2),a=i[0],o=i[1],s=Math.max(e-t,o-a),u=(e+t)/2,l=(o+a)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(u)&&(u=0),isNaN(l)&&(l=0);var h=function(c){return{x:.5+(c.x-u)/s,y:.5+(c.y-l)/s}};return h.applyTo=function(d){d.x=.5+(d.x-u)/s,d.y=.5+(d.y-l)/s},h.inverse=function(d){return{x:u+s*(d.x-.5),y:l+s*(d.y-.5)}},h.ratio=s,h}function Ut(n){"@babel/helpers - typeof";return Ut=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ut(n)}function vr(n,r){var t=r.size;if(t!==0){var e=n.length;n.length+=t;var i=0;r.forEach(function(a){n[e+i]=a,i++})}}function Lt(n){n=n||{};for(var r=0,t=arguments.length<=1?0:arguments.length-1;r<t;r++){var e=r+1<1||arguments.length<=r+1?void 0:arguments[r+1];e&&Object.assign(n,e)}return n}var Zt={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:sa,defaultDrawNodeLabel:di,defaultDrawNodeHover:ua,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:{}},Va={circle:vt},qa={arrow:mi,line:Aa};function Dt(n){if(typeof n.labelDensity!="number"||n.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var r=n.minCameraRatio,t=n.maxCameraRatio;if(typeof r=="number"&&typeof t=="number"&&t<r)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Ka(n){var r=Lt({},Zt,n);return r.nodeProgramClasses=Lt({},Va,r.nodeProgramClasses),r.edgeProgramClasses=Lt({},qa,r.edgeProgramClasses),r}var ct=1.5,yr=(function(n){function r(){var t;return re(this,r),t=le(this,r),T(t,"x",.5),T(t,"y",.5),T(t,"angle",0),T(t,"ratio",1),T(t,"minRatio",null),T(t,"maxRatio",null),T(t,"enabledZooming",!0),T(t,"enabledPanning",!0),T(t,"enabledRotation",!0),T(t,"clean",null),T(t,"nextFrame",null),T(t,"previousState",null),T(t,"enabled",!0),t.previousState=t.getState(),t}return he(r,n),ie(r,[{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(e){return this.x===e.x&&this.y===e.y&&this.ratio===e.ratio&&this.angle===e.angle}},{key:"getPreviousState",value:function(){var e=this.previousState;return e?{x:e.x,y:e.y,angle:e.angle,ratio:e.ratio}:null}},{key:"getBoundedRatio",value:function(e){var i=e;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(e){var i={};return this.enabledPanning&&typeof e.x=="number"&&(i.x=e.x),this.enabledPanning&&typeof e.y=="number"&&(i.y=e.y),this.enabledZooming&&typeof e.ratio=="number"&&(i.ratio=this.getBoundedRatio(e.ratio)),this.enabledRotation&&typeof e.angle=="number"&&(i.angle=e.angle),this.clean?this.clean(F(F({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(e){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(e);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(e){return this.setState(e(this.getState())),this}},{key:"animate",value:function(e){var i=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(f){return i.animate(e,a,f)});if(this.enabled){var s=F(F({},Ua),a),u=this.validateState(e),l=typeof s.easing=="function"?s.easing:$a[s.easing],h=Date.now(),d=this.getState(),c=function(){var b=(Date.now()-h)/s.duration;if(b>=1){i.nextFrame=null,i.setState(u),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var w=l(b),E={};typeof u.x=="number"&&(E.x=d.x+(u.x-d.x)*w),typeof u.y=="number"&&(E.y=d.y+(u.y-d.y)*w),i.enabledRotation&&typeof u.angle=="number"&&(E.angle=d.angle+(u.angle-d.angle)*w),typeof u.ratio=="number"&&(E.ratio=d.ratio+(u.ratio-d.ratio)*w),i.setState(E),i.nextFrame=requestAnimationFrame(c)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(c)):c(),this.animationCallback=o}}},{key:"animatedZoom",value:function(e){return e?typeof e=="number"?this.animate({ratio:this.ratio/e}):this.animate({ratio:this.ratio/(e.factor||ct)},e):this.animate({ratio:this.ratio/ct})}},{key:"animatedUnzoom",value:function(e){return e?typeof e=="number"?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||ct)},e):this.animate({ratio:this.ratio*ct})}},{key:"animatedReset",value:function(e){return this.animate({x:.5,y:.5,ratio:1,angle:0},e)}},{key:"copy",value:function(){return r.from(this.getState())}}],[{key:"from",value:function(e){var i=new r;return i.setState(e)}}])})(Yt);function be(n,r){var t=r.getBoundingClientRect();return{x:n.clientX-t.left,y:n.clientY-t.top}}function Te(n,r){var t=F(F({},be(n,r)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0},original:n});return t}function et(n){var r="x"in n?n:F(F({},n.touches[0]||n.previousTouches[0]),{},{original:n.original,sigmaDefaultPrevented:n.sigmaDefaultPrevented,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0,r.sigmaDefaultPrevented=!0}});return r}function Ya(n,r){return F(F({},Te(n,r)),{},{delta:bi(n)})}var Za=2;function ft(n){for(var r=[],t=0,e=Math.min(n.length,Za);t<e;t++)r.push(n[t]);return r}function tt(n,r,t){var e={touches:ft(n.touches).map(function(i){return be(i,t)}),previousTouches:r.map(function(i){return be(i,t)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:n};return e}function bi(n){if(typeof n.deltaY<"u")return n.deltaY*-3/360;if(typeof n.detail<"u")return n.detail/-9;throw new Error("Captor: could not extract delta from event.")}var wi=(function(n){function r(t,e){var i;return re(this,r),i=le(this,r),i.container=t,i.renderer=e,i}return he(r,n),ie(r)})(Yt),Xa=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],Qa=Xa.reduce(function(n,r){return F(F({},n),{},T({},r,Zt[r]))},{}),Ja=(function(n){function r(t,e){var i;return re(this,r),i=le(this,r,[t,e]),T(i,"enabled",!0),T(i,"draggedEvents",0),T(i,"downStartTime",null),T(i,"lastMouseX",null),T(i,"lastMouseY",null),T(i,"isMouseDown",!1),T(i,"isMoving",!1),T(i,"movingTimeout",null),T(i,"startCameraState",null),T(i,"clicks",0),T(i,"doubleClickTimeout",null),T(i,"currentWheelDirection",0),T(i,"settings",Qa),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),t.addEventListener("click",i.handleClick,{capture:!1}),t.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),t.addEventListener("mousedown",i.handleDown,{capture:!1}),t.addEventListener("wheel",i.handleWheel,{capture:!1}),t.addEventListener("mouseleave",i.handleLeave,{capture:!1}),t.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return he(r,n),ie(r,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("click",this.handleClick),e.removeEventListener("contextmenu",this.handleRightClick),e.removeEventListener("mousedown",this.handleDown),e.removeEventListener("wheel",this.handleWheel),e.removeEventListener("mouseleave",this.handleLeave),e.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(e){var i=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(e);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",Te(e,this.container))}}},{key:"handleRightClick",value:function(e){this.enabled&&this.emit("rightClick",Te(e,this.container))}},{key:"handleDoubleClick",value:function(e){if(this.enabled){e.preventDefault(),e.stopPropagation();var i=Te(e,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var a=this.renderer.getCamera(),o=a.getBoundedRatio(a.getState().ratio/this.settings.doubleClickZoomingRatio);a.animate(this.renderer.getViewportZoomedState(be(e,this.container),o),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(e){if(this.enabled){if(e.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=be(e,this.container),a=i.x,o=i.y;this.lastMouseX=a,this.lastMouseY=o,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Te(e,this.container))}}},{key:"handleUp",value:function(e){var i=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=be(e,this.container),s=o.x,u=o.y,l=a.getState(),h=a.getPreviousState()||{x:0,y:0};this.isMoving?a.animate({x:l.x+this.settings.inertiaRatio*(l.x-h.x),y:l.y+this.settings.inertiaRatio*(l.y-h.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==u)&&a.setState({x:l.x,y:l.y}),this.isMoving=!1,setTimeout(function(){var d=i.draggedEvents>0;i.draggedEvents=0,d&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",Te(e,this.container))}}},{key:"handleMove",value:function(e){var i=this;if(this.enabled){var a=Te(e,this.container);if(this.emit("mousemovebody",a),(e.target===this.container||e.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(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var o=this.renderer.getCamera(),s=be(e,this.container),u=s.x,l=s.y,h=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:u,y:l}),c=h.x-d.x,f=h.y-d.y,b=o.getState(),w=b.x+c,E=b.y+f;o.setState({x:w,y:E}),this.lastMouseX=u,this.lastMouseY=l,e.preventDefault(),e.stopPropagation()}}}},{key:"handleLeave",value:function(e){this.emit("mouseleave",Te(e,this.container))}},{key:"handleEnter",value:function(e){this.emit("mouseenter",Te(e,this.container))}},{key:"handleWheel",value:function(e){var i=this,a=this.renderer.getCamera();if(!(!this.enabled||!a.enabledZooming)){var o=bi(e);if(o){var s=Ya(e,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){e.preventDefault(),e.stopPropagation();return}var u=a.getState().ratio,l=o>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,h=a.getBoundedRatio(u*l),d=o>0?1:-1,c=Date.now();u!==h&&(e.preventDefault(),e.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&c-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(a.animate(this.renderer.getViewportZoomedState(be(e,this.container),h),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=c))}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(wi),eo=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],to=eo.reduce(function(n,r){return F(F({},n),{},T({},r,Zt[r]))},{}),ro=(function(n){function r(t,e){var i;return re(this,r),i=le(this,r,[t,e]),T(i,"enabled",!0),T(i,"isMoving",!1),T(i,"hasMoved",!1),T(i,"touchMode",0),T(i,"startTouchesPositions",[]),T(i,"lastTouches",[]),T(i,"lastTap",null),T(i,"settings",to),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),t.addEventListener("touchstart",i.handleStart,{capture:!1}),t.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return he(r,n),ie(r,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("touchstart",this.handleStart),e.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(e){var i=this;if(this.enabled){e.preventDefault();var a=ft(e.touches);if(this.touchMode=a.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=a.map(function(f){return be(f,i.container)}),this.touchMode===2){var o=We(this.startTouchesPositions,2),s=o[0],u=s.x,l=s.y,h=o[1],d=h.x,c=h.y;this.startTouchesAngle=Math.atan2(c-l,d-u),this.startTouchesDistance=Math.sqrt(Math.pow(d-u,2)+Math.pow(c-l,2))}this.emit("touchdown",tt(e,this.lastTouches,this.container)),this.lastTouches=a,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(e){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(e.cancelable&&e.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(e.touches.length===1){this.handleStart(e),e.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),a=i.getState(),o=i.getPreviousState()||{x:0,y:0};i.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",tt(e,this.lastTouches,this.container)),!e.touches.length){var s=be(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],l=Math.pow(s.x-u.x,2)+Math.pow(s.y-u.y,2);if(!e.touches.length&&l<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var h=tt(e,this.lastTouches,this.container);if(this.emit("doubletap",h),this.lastTap=null,!h.sigmaDefaultPrevented){var d=this.renderer.getCamera(),c=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(s,c),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=tt(e,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=ft(e.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(e){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){e.preventDefault();var a=ft(e.touches),o=a.map(function(ae){return be(ae,i.container)}),s=this.lastTouches;this.lastTouches=a,this.lastTouchesPositions=o;var u=tt(e,s,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=o.some(function(ae,J){var I=i.startTouchesPositions[J];return I&&(ae.x!==I.x||ae.y!==I.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var l=this.renderer.getCamera(),h=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var c=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=c.x,b=c.y,w=this.renderer.viewportToFramedGraph(o[0]),E=w.x,L=w.y;l.setState({x:h.x+f-E,y:h.y+b-L});break}case 2:{var _={x:.5,y:.5,angle:0,ratio:1},R=o[0],m=R.x,y=R.y,S=o[1],C=S.x,P=S.y,O=Math.atan2(P-y,C-m)-this.startTouchesAngle,z=Math.hypot(P-y,C-m)/this.startTouchesDistance,Y=l.getBoundedRatio(h.ratio/z);_.ratio=Y,_.angle=h.angle+O;var j=this.getDimensions(),p=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:h}),Q=Math.min(j.width,j.height)-2*d,ne=Q/j.width,k=Q/j.height,v=Y/Q,B=m-Q/2/ne,q=y-Q/2/k,ee=[B*Math.cos(-_.angle)-q*Math.sin(-_.angle),q*Math.cos(-_.angle)+B*Math.sin(-_.angle)];B=ee[0],q=ee[1],_.x=p.x-B*v,_.y=p.y+q*v,l.setState(_);break}}}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(wi);function io(n){if(Array.isArray(n))return Ot(n)}function no(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function ao(){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 br(n){return io(n)||no(n)||ii(n)||ao()}function oo(n,r){if(n==null)return{};var t={};for(var e in n)if({}.hasOwnProperty.call(n,e)){if(r.indexOf(e)!==-1)continue;t[e]=n[e]}return t}function Gt(n,r){if(n==null)return{};var t,e,i=oo(n,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(e=0;e<a.length;e++)t=a[e],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(i[t]=n[t])}return i}var wr=(function(){function n(r,t){re(this,n),this.key=r,this.size=t}return ie(n,null,[{key:"compare",value:function(t,e){return t.size>e.size?-1:t.size<e.size||t.key>e.key?1:-1}}])})(),Er=(function(){function n(){re(this,n),T(this,"width",0),T(this,"height",0),T(this,"cellSize",0),T(this,"columns",0),T(this,"rows",0),T(this,"cells",{})}return ie(n,[{key:"resizeAndClear",value:function(t,e){this.width=t.width,this.height=t.height,this.cellSize=e,this.columns=Math.ceil(t.width/e),this.rows=Math.ceil(t.height/e),this.cells={}}},{key:"getIndex",value:function(t){var e=Math.floor(t.x/this.cellSize),i=Math.floor(t.y/this.cellSize);return i*this.columns+e}},{key:"add",value:function(t,e,i){var a=new wr(t,e),o=this.getIndex(i),s=this.cells[o];s||(s=[],this.cells[o]=s),s.push(a)}},{key:"organize",value:function(){for(var t in this.cells){var e=this.cells[t];e.sort(wr.compare)}}},{key:"getLabelsToDisplay",value:function(t,e){var i=this.cellSize*this.cellSize,a=i/t/t,o=a*e/i,s=Math.ceil(o),u=[];for(var l in this.cells)for(var h=this.cells[l],d=0;d<Math.min(s,h.length);d++)u.push(h[d].key);return u}}])})();function so(n){var r=n.graph,t=n.hoveredNode,e=n.highlightedNodes,i=n.displayedNodeLabels,a=[];return r.forEachEdge(function(o,s,u,l){(u===t||l===t||e.has(u)||e.has(l)||i.has(u)&&i.has(l))&&a.push(o)}),a}var xr=150,_r=50,Re=Object.prototype.hasOwnProperty;function uo(n,r,t){if(!Re.call(t,"x")||!Re.call(t,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(r,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return t.color||(t.color=n.defaultNodeColor),!t.label&&t.label!==""&&(t.label=null),t.label!==void 0&&t.label!==null?t.label=""+t.label:t.label=null,t.size||(t.size=2),Re.call(t,"hidden")||(t.hidden=!1),Re.call(t,"highlighted")||(t.highlighted=!1),Re.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=n.defaultNodeType),t.zIndex||(t.zIndex=0),t}function lo(n,r,t){return t.color||(t.color=n.defaultEdgeColor),t.label||(t.label=""),t.size||(t.size=.5),Re.call(t,"hidden")||(t.hidden=!1),Re.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=n.defaultEdgeType),t.zIndex||(t.zIndex=0),t}var ho=(function(n){function r(t,e){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(re(this,r),i=le(this,r),T(i,"elements",{}),T(i,"canvasContexts",{}),T(i,"webGLContexts",{}),T(i,"pickingLayers",new Set),T(i,"textures",{}),T(i,"frameBuffers",{}),T(i,"activeListeners",{}),T(i,"labelGrid",new Er),T(i,"nodeDataCache",{}),T(i,"edgeDataCache",{}),T(i,"nodeProgramIndex",{}),T(i,"edgeProgramIndex",{}),T(i,"nodesWithForcedLabels",new Set),T(i,"edgesWithForcedLabels",new Set),T(i,"nodeExtent",{x:[0,1],y:[0,1]}),T(i,"nodeZExtent",[1/0,-1/0]),T(i,"edgeZExtent",[1/0,-1/0]),T(i,"matrix",ye()),T(i,"invMatrix",ye()),T(i,"correctionRatio",1),T(i,"customBBox",null),T(i,"normalizationFunction",mr({x:[0,1],y:[0,1]})),T(i,"graphToViewportRatio",1),T(i,"itemIDsIndex",{}),T(i,"nodeIndices",{}),T(i,"edgeIndices",{}),T(i,"width",0),T(i,"height",0),T(i,"pixelRatio",gr()),T(i,"pickingDownSizingRatio",2*i.pixelRatio),T(i,"displayedNodeLabels",new Set),T(i,"displayedEdgeLabels",new Set),T(i,"highlightedNodes",new Set),T(i,"hoveredNode",null),T(i,"hoveredEdge",null),T(i,"renderFrame",null),T(i,"renderHighlightedNodesFrame",null),T(i,"needToProcess",!1),T(i,"checkEdgesEventsFrame",null),T(i,"nodePrograms",{}),T(i,"nodeHoverPrograms",{}),T(i,"edgePrograms",{}),i.settings=Ka(a),Dt(i.settings),Ha(t),!(e instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=t,i.container=e,i.createWebGLContext("edges",{picking:a.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var o in i.settings.nodeProgramClasses)i.registerNodeProgram(o,i.settings.nodeProgramClasses[o],i.settings.nodeHoverProgramClasses[o]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new yr,i.bindCameraHandlers(),i.mouseCaptor=new Ja(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new ro(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return he(r,n),ie(r,[{key:"registerNodeProgram",value:function(e,i,a){return this.nodePrograms[e]&&this.nodePrograms[e].kill(),this.nodeHoverPrograms[e]&&this.nodeHoverPrograms[e].kill(),this.nodePrograms[e]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[e]=new(a||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(e,i){return this.edgePrograms[e]&&this.edgePrograms[e].kill(),this.edgePrograms[e]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(e){if(this.nodePrograms[e]){var i=this.nodePrograms,a=i[e],o=Gt(i,[e].map(it));a.kill(),this.nodePrograms=o}if(this.nodeHoverPrograms[e]){var s=this.nodeHoverPrograms,u=s[e],l=Gt(s,[e].map(it));u.kill(),this.nodePrograms=l}return this}},{key:"unregisterEdgeProgram",value:function(e){if(this.edgePrograms[e]){var i=this.edgePrograms,a=i[e],o=Gt(i,[e].map(it));a.kill(),this.edgePrograms=o}return this}},{key:"resetWebGLTexture",value:function(e){var i=this.webGLContexts[e],a=this.frameBuffers[e],o=this.textures[e];o&&i.deleteTexture(o);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,a),i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,s,0),this.textures[e]=s,this}},{key:"bindCameraHandlers",value:function(){var e=this;return this.activeListeners.camera=function(){e.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(e){var i=e.x,a=e.y,o=ir(this.webGLContexts.nodes,this.frameBuffers.nodes,i,a,this.pixelRatio,this.pickingDownSizingRatio),s=rr.apply(void 0,br(o)),u=this.itemIDsIndex[s];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var e=this;this.activeListeners.handleResize=function(){e.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(a){var o=et(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}},u=e.getNodeAtPosition(o);if(u&&e.hoveredNode!==u&&!e.nodeDataCache[u].hidden){e.hoveredNode&&e.emit("leaveNode",F(F({},s),{},{node:e.hoveredNode})),e.hoveredNode=u,e.emit("enterNode",F(F({},s),{},{node:u})),e.scheduleHighlightedNodesRender();return}if(e.hoveredNode&&e.getNodeAtPosition(o)!==e.hoveredNode){var l=e.hoveredNode;e.hoveredNode=null,e.emit("leaveNode",F(F({},s),{},{node:l})),e.scheduleHighlightedNodesRender();return}if(e.settings.enableEdgeEvents){var h=e.hoveredNode?null:e.getEdgeAtPoint(s.event.x,s.event.y);h!==e.hoveredEdge&&(e.hoveredEdge&&e.emit("leaveEdge",F(F({},s),{},{edge:e.hoveredEdge})),h&&e.emit("enterEdge",F(F({},s),{},{edge:h})),e.hoveredEdge=h)}},this.activeListeners.handleMoveBody=function(a){var o=et(a);e.emit("moveBody",{event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(a){var o=et(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};e.hoveredNode&&(e.emit("leaveNode",F(F({},s),{},{node:e.hoveredNode})),e.scheduleHighlightedNodesRender()),e.settings.enableEdgeEvents&&e.hoveredEdge&&(e.emit("leaveEdge",F(F({},s),{},{edge:e.hoveredEdge})),e.scheduleHighlightedNodesRender()),e.emit("leaveStage",F({},s))},this.activeListeners.handleEnter=function(a){var o=et(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};e.emit("enterStage",F({},s))};var i=function(o){return function(s){var u=et(s),l={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},h=e.getNodeAtPosition(u);if(h)return e.emit("".concat(o,"Node"),F(F({},l),{},{node:h}));if(e.settings.enableEdgeEvents){var d=e.getEdgeAtPoint(u.x,u.y);if(d)return e.emit("".concat(o,"Edge"),F(F({},l),{},{edge:d}))}return e.emit("".concat(o,"Stage"),l)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("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 e=this,i=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;e.graph.forEachNode(function(h){return e.updateNode(h)});var l=!u||u.some(function(h){return a.has(h)});e.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!l,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(o){var s,u=(s=o.hints)===null||s===void 0?void 0:s.attributes;e.graph.forEachEdge(function(h){return e.updateEdge(h)});var l=u&&["zIndex","type"].some(function(h){return u==null?void 0:u.includes(h)});e.refresh({partialGraph:{edges:i.edges()},skipIndexation:!l,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(o){var s=o.key;e.addNode(s),e.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(o){var s=o.key;e.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(o){var s=o.key;e.removeNode(s),e.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(o){var s=o.key;e.addEdge(s),e.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(o){var s=o.key;e.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(o){var s=o.key;e.removeEdge(s),e.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){e.clearEdgeState(),e.clearEdgeIndices(),e.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){e.clearEdgeState(),e.clearNodeState(),e.clearEdgeIndices(),e.clearNodeIndices(),e.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var e=this.graph;e.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),e.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),e.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),e.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),e.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),e.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),e.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),e.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),e.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),e.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(e,i){var a=ir(this.webGLContexts.edges,this.frameBuffers.edges,e,i,this.pixelRatio,this.pickingDownSizingRatio),o=rr.apply(void 0,br(a)),s=this.itemIDsIndex[o];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var e=this;this.emit("beforeProcess");var i=this.graph,a=this.settings,o=this.getDimensions();if(this.nodeExtent=Ba(this.graph),!this.settings.autoRescale){var s=o.width,u=o.height,l=this.nodeExtent,h=l.x,d=l.y;this.nodeExtent={x:[(h[0]+h[1])/2-s/2,(h[0]+h[1])/2+s/2],y:[(d[0]+d[1])/2-u/2,(d[0]+d[1])/2+u/2]}}this.normalizationFunction=mr(this.customBBox||this.nodeExtent);var c=new yr,f=Je(c.getState(),o,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(o,a.labelGridCellSize);for(var b={},w={},E={},L={},_=1,R=i.nodes(),m=0,y=R.length;m<y;m++){var S=R[m],C=this.nodeDataCache[S],P=i.getNodeAttributes(S);C.x=P.x,C.y=P.y,this.normalizationFunction.applyTo(C),typeof C.label=="string"&&!C.hidden&&this.labelGrid.add(S,C.size,this.framedGraphToViewport(C,{matrix:f})),b[C.type]=(b[C.type]||0)+1}this.labelGrid.organize();for(var O in this.nodePrograms){if(!Re.call(this.nodePrograms,O))throw new Error('Sigma: could not find a suitable program for node type "'.concat(O,'"!'));this.nodePrograms[O].reallocate(b[O]||0),b[O]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(R=pr(this.nodeZExtent,function(se){return e.nodeDataCache[se].zIndex},R));for(var z=0,Y=R.length;z<Y;z++){var j=R[z];w[j]=_,L[w[j]]={type:"node",id:j},_++;var p=this.nodeDataCache[j];this.addNodeToProgram(j,w[j],b[p.type]++)}for(var Q={},ne=i.edges(),k=0,v=ne.length;k<v;k++){var B=ne[k],q=this.edgeDataCache[B];Q[q.type]=(Q[q.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(ne=pr(this.edgeZExtent,function(se){return e.edgeDataCache[se].zIndex},ne));for(var ee in this.edgePrograms){if(!Re.call(this.edgePrograms,ee))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ee,'"!'));this.edgePrograms[ee].reallocate(Q[ee]||0),Q[ee]=0}for(var ae=0,J=ne.length;ae<J;ae++){var I=ne[ae];E[I]=_,L[E[I]]={type:"edge",id:I},_++;var Le=this.edgeDataCache[I];this.addEdgeToProgram(I,E[I],Q[Le.type]++)}return this.itemIDsIndex=L,this.nodeIndices=w,this.edgeIndices=E,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(e){var i=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(h){return i.cleanCameraState(h,a.cameraPanBoundaries&&Ut(a.cameraPanBoundaries)==="object"?a.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),e){if(e.edgeProgramClasses!==a.edgeProgramClasses){for(var o in a.edgeProgramClasses)a.edgeProgramClasses[o]!==e.edgeProgramClasses[o]&&this.registerEdgeProgram(o,a.edgeProgramClasses[o]);for(var s in e.edgeProgramClasses)a.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(e.nodeProgramClasses!==a.nodeProgramClasses||e.nodeHoverProgramClasses!==a.nodeHoverProgramClasses){for(var u in a.nodeProgramClasses)(a.nodeProgramClasses[u]!==e.nodeProgramClasses[u]||a.nodeHoverProgramClasses[u]!==e.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,a.nodeProgramClasses[u],a.nodeHoverProgramClasses[u]);for(var l in e.nodeProgramClasses)a.nodeProgramClasses[l]||this.unregisterNodeProgram(l)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=i.tolerance,o=a===void 0?0:a,s=i.boundaries,u=F({},e),l=s||this.nodeExtent,h=We(l.x,2),d=h[0],c=h[1],f=We(l.y,2),b=f[0],w=f[1],E=[this.graphToViewport({x:d,y:b},{cameraState:e}),this.graphToViewport({x:c,y:b},{cameraState:e}),this.graphToViewport({x:d,y:w},{cameraState:e}),this.graphToViewport({x:c,y:w},{cameraState:e})],L=1/0,_=-1/0,R=1/0,m=-1/0;E.forEach(function(Q){var ne=Q.x,k=Q.y;L=Math.min(L,ne),_=Math.max(_,ne),R=Math.min(R,k),m=Math.max(m,k)});var y=_-L,S=m-R,C=this.getDimensions(),P=C.width,O=C.height,z=0,Y=0;if(y>=P?_<P-o?z=_-(P-o):L>o&&(z=L-o):_>P+o?z=_-(P+o):L<-o&&(z=L+o),S>=O?m<O-o?Y=m-(O-o):R>o&&(Y=R-o):m>O+o?Y=m-(O+o):R<-o&&(Y=R+o),z||Y){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:e}),p=this.viewportToFramedGraph({x:z,y:Y},{cameraState:e});z=p.x-j.x,Y=p.y-j.y,u.x+=z,u.y+=Y}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var e=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(e.ratio,this.settings.labelDensity);vr(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var a=this.canvasContexts.labels,o=0,s=i.length;o<s;o++){var u=i[o],l=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!l.hidden){var h=this.framedGraphToViewport(l),d=h.x,c=h.y,f=this.scaleSize(l.size);if(!(!l.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(d<-xr||d>this.width+xr||c<-_r||c>this.height+_r)){this.displayedNodeLabels.add(u);var b=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[l.type],E=(w==null?void 0:w.drawLabel)||b;E(a,F(F({key:u},l),{},{size:f,x:d,y:c}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var e=this.canvasContexts.edgeLabels;e.clearRect(0,0,this.width,this.height);var i=so({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});vr(i,this.edgesWithForcedLabels);for(var a=new Set,o=0,s=i.length;o<s;o++){var u=i[o],l=this.graph.extremities(u),h=this.nodeDataCache[l[0]],d=this.nodeDataCache[l[1]],c=this.edgeDataCache[u];if(!a.has(u)&&!(c.hidden||h.hidden||d.hidden)){var f=this.settings.defaultDrawEdgeLabel,b=this.edgePrograms[c.type],w=(b==null?void 0:b.drawLabel)||f;w(e,F(F({key:u},c),{},{size:this.scaleSize(c.size)}),F(F(F({key:l[0]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),F(F(F({key:l[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),a.add(u)}}return this.displayedEdgeLabels=a,this}},{key:"renderHighlightedNodes",value:function(){var e=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var a=function(f){var b=e.nodeDataCache[f],w=e.framedGraphToViewport(b),E=w.x,L=w.y,_=e.scaleSize(b.size),R=e.settings.defaultDrawNodeHover,m=e.nodePrograms[b.type],y=(m==null?void 0:m.drawHover)||R;y(i,F(F({key:f},b),{},{size:_,x:E,y:L}),e.settings)},o=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&o.push(this.hoveredNode),this.highlightedNodes.forEach(function(c){c!==e.hoveredNode&&o.push(c)}),o.forEach(function(c){return a(c)});var s={};o.forEach(function(c){var f=e.nodeDataCache[c].type;s[f]=(s[f]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(s[u]||0),s[u]=0;o.forEach(function(c){var f=e.nodeDataCache[c];e.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var l=this.getRenderParams();for(var h in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[h];d.render(l)}}},{key:"scheduleHighlightedNodesRender",value:function(){var e=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){e.renderHighlightedNodesFrame=null,e.renderHighlightedNodes(),e.renderEdgeLabels()}))}},{key:"render",value:function(){var e=this;this.emit("beforeRender");var i=function(){return e.emit("afterRender"),e};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(E){return e.resetWebGLTexture(E)}),!this.graph.order)return i();var a=this.mouseCaptor,o=this.camera.isAnimated()||a.isMoving||a.draggedEvents||a.currentWheelDirection,s=this.camera.getState(),u=this.getDimensions(),l=this.getGraphDimensions(),h=this.getStagePadding();this.matrix=Je(s,u,l,h),this.invMatrix=Je(s,u,l,h,!0),this.correctionRatio=Ma(this.matrix,s,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var c in this.nodePrograms){var f=this.nodePrograms[c];f.render(d)}if(!this.settings.hideEdgesOnMove||!o)for(var b in this.edgePrograms){var w=this.edgePrograms[b];w.render(d)}return this.settings.hideLabelsOnMove&&o||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(e){var i=Object.assign({},this.graph.getNodeAttributes(e));this.settings.nodeReducer&&(i=this.settings.nodeReducer(e,i));var a=uo(this.settings,e,i);this.nodeDataCache[e]=a,this.nodesWithForcedLabels.delete(e),a.forceLabel&&!a.hidden&&this.nodesWithForcedLabels.add(e),this.highlightedNodes.delete(e),a.highlighted&&!a.hidden&&this.highlightedNodes.add(e),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(e){this.addNode(e);var i=this.nodeDataCache[e];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(e){delete this.nodeDataCache[e],delete this.nodeProgramIndex[e],this.highlightedNodes.delete(e),this.hoveredNode===e&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(e)}},{key:"addEdge",value:function(e){var i=Object.assign({},this.graph.getEdgeAttributes(e));this.settings.edgeReducer&&(i=this.settings.edgeReducer(e,i));var a=lo(this.settings,e,i);this.edgeDataCache[e]=a,this.edgesWithForcedLabels.delete(e),a.forceLabel&&!a.hidden&&this.edgesWithForcedLabels.add(e),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(e){this.addEdge(e)}},{key:"removeEdge",value:function(e){delete this.edgeDataCache[e],delete this.edgeProgramIndex[e],this.hoveredEdge===e&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(e)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Er,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(e,i,a){var o=this.nodeDataCache[e],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(i,a,o),this.nodeProgramIndex[e]=a}},{key:"addEdgeToProgram",value:function(e,i,a){var o=this.edgeDataCache[e],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(e),l=this.nodeDataCache[u[0]],h=this.nodeDataCache[u[1]];s.process(i,a,l,h,o),this.edgeProgramIndex[e]=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 e=this.settings,i=e.stagePadding,a=e.autoRescale;return a&&i||0}},{key:"createLayer",value:function(e,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[e])throw new Error('Sigma: a layer named "'.concat(e,'" already exists'));var o=Wa(i,{position:"absolute"},{class:"sigma-".concat(e)});return a.style&&Object.assign(o.style,a.style),this.elements[e]=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(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(e,"canvas",i)}},{key:"createCanvasContext",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=this.createCanvas(e,i),o={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[e]=a.getContext("2d",o),this}},{key:"createWebGLContext",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=(i==null?void 0:i.canvas)||this.createCanvas(e,i);i.hidden&&a.remove();var o=F({preserveDrawingBuffer:!1,antialias:!1},i),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[e]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(e);var l=u.createFramebuffer();if(!l)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(e));this.frameBuffers[e]=l}return u}},{key:"killLayer",value:function(e){var i=this.elements[e];if(!i)throw new Error("Sigma: cannot kill layer ".concat(e,", which does not exist"));if(this.webGLContexts[e]){var a,o=this.webGLContexts[e];(a=o.getExtension("WEBGL_lose_context"))===null||a===void 0||a.loseContext(),delete this.webGLContexts[e]}else this.canvasContexts[e]&&delete this.canvasContexts[e];return i.remove(),delete this.elements[e],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(e){this.unbindCameraHandlers(),this.camera=e,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(e){e!==this.graph&&(this.hoveredNode&&!e.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!e.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=e,this.bindGraphHandlers(),this.refresh())}},{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 e=this.customBBox||this.nodeExtent;return{width:e.x[1]-e.x[0]||1,height:e.y[1]-e.y[0]||1}}},{key:"getNodeDisplayData",value:function(e){var i=this.nodeDataCache[e];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(e){var i=this.edgeDataCache[e];return i?Object.assign({},i):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(e){return this.settings[e]}},{key:"setSetting",value:function(e,i){var a=F({},this.settings);return this.settings[e]=i,Dt(this.settings),this.handleSettingsUpdate(a),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(e,i){return this.setSetting(e,i(this.settings[e])),this}},{key:"setSettings",value:function(e){var i=F({},this.settings);return this.settings=F(F({},this.settings),e),Dt(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(e){var i=this.width,a=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=gr(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!e&&i===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 l in this.webGLContexts){this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px");var h=this.webGLContexts[l];if(h.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(l)){var d=this.textures[l];d&&h.deleteTexture(d)}}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(e){var i=this,a=(e==null?void 0:e.skipIndexation)!==void 0?e==null?void 0:e.skipIndexation:!1,o=(e==null?void 0:e.schedule)!==void 0?e.schedule:!1,s=!e||!e.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(m){return i.addNode(m)}),this.graph.forEachEdge(function(m){return i.addEdge(m)});else{for(var u,l,h=((u=e.partialGraph)===null||u===void 0?void 0:u.nodes)||[],d=0,c=(h==null?void 0:h.length)||0;d<c;d++){var f=h[d];if(this.updateNode(f),a){var b=this.nodeProgramIndex[f];if(b===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],b)}}for(var w=(e==null||(l=e.partialGraph)===null||l===void 0?void 0:l.edges)||[],E=0,L=w.length;E<L;E++){var _=w[E];if(this.updateEdge(_),a){var R=this.edgeProgramIndex[_];if(R===void 0)throw new Error('Sigma: edge "'.concat(_,`" can't be repaint`));this.addEdgeToProgram(_,this.edgeIndices[_],R)}}}return(s||!a)&&(this.needToProcess=!0),o?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var e=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){e.render()})),this}},{key:"scheduleRefresh",value:function(e){return this.refresh(F(F({},e),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(e,i){var a=this.camera.getState(),o=a.ratio,s=a.angle,u=a.x,l=a.y,h=this.settings,d=h.minCameraRatio,c=h.maxCameraRatio;typeof c=="number"&&(i=Math.min(i,c)),typeof d=="number"&&(i=Math.max(i,d));var f=i/o,b={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(e),E=this.viewportToFramedGraph(b);return{angle:s,x:(w.x-E.x)*(1-f)+u,y:(w.y-E.y)*(1-f)+l,ratio:i}}},{key:"viewRectangle",value:function(){var e=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),a=this.viewportToFramedGraph({x:0,y:this.height});return{x1:e.x,y1:e.y,x2:i.x,y2:i.y,height:i.y-a.y}}},{key:"framedGraphToViewport",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,o=i.matrix?i.matrix:a?Je(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=$t(o,e);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,o=i.matrix?i.matrix:a?Je(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=$t(o,{x:e.x/this.width*2-1,y:1-e.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(e,i))}},{key:"graphToViewport",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(e),i)}},{key:"getGraphToViewportRatio",value:function(){var e={x:0,y:0},i={x:1,y:1},a=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),o=this.graphToViewport(e),s=this.graphToViewport(i),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(e){return this.customBBox=e,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 e=this.container;e.firstChild;)e.removeChild(e.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].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 e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return e/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var e={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(e[i]=this.elements[i]);return e}}])})(Yt);const Ei=G.createContext(null),co=Ei.Provider;function xi(){const n=G.useContext(Ei);if(n==null)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return n}function yt(){return xi().sigma}function fo(){const{sigma:n}=xi();return G.useCallback((r=>{n&&Object.keys(r).forEach((t=>{n.setSetting(t,r[t])}))}),[n])}function bt(n){return new Set(Object.keys(n))}const Cr=bt({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}),Sr=bt({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),Tr=bt({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),Rr=bt({updated:!0});function go(){const n=yt(),r=fo(),[t,e]=G.useState({});return G.useEffect((()=>{if(!n||!t)return;const i=t,a=Object.keys(i);return a.forEach((o=>{const s=i[o];Cr.has(o)&&n.on(o,s),Sr.has(o)&&n.getMouseCaptor().on(o,s),Tr.has(o)&&n.getTouchCaptor().on(o,s),Rr.has(o)&&n.getCamera().on(o,s)})),()=>{n&&a.forEach((o=>{const s=i[o];Cr.has(o)&&n.off(o,s),Sr.has(o)&&n.getMouseCaptor().off(o,s),Tr.has(o)&&n.getTouchCaptor().off(o,s),Rr.has(o)&&n.getCamera().off(o,s)}))}}),[n,t,r]),e}function po(){const n=yt();return G.useCallback(((r,t=!0)=>{n&&r&&(t&&n.getGraph().order>0&&n.getGraph().clear(),n.getGraph().import(r),n.refresh())}),[n])}function _i(n,r){if(n===r)return!0;if(typeof n=="object"&&n!=null&&typeof r=="object"&&r!=null){if(Object.keys(n).length!=Object.keys(r).length)return!1;for(const t in n)if(!Object.hasOwn(r,t)||!_i(n[t],r[t]))return!1;return!0}return!1}const mo=G.forwardRef((({graph:n,id:r,className:t,style:e,settings:i={},children:a},o)=>{const s=G.useRef(null),u=G.useRef(null),l={className:`react-sigma ${t||""}`,id:r,style:e},[h,d]=G.useState(null),[c,f]=G.useState(i);G.useEffect((()=>{f((E=>_i(E,i)?E:i))}),[i]),G.useEffect((()=>{let E=null;if(u.current!==null){let L=new X;n&&(L=typeof n=="function"?new n:n),E=new ho(L,u.current,c),d((_=>{let R=null;return _&&(R=_.getCamera().getState()),R&&E.getCamera().setState(R),E}))}return()=>{E&&E.kill()}}),[u,n,c]),G.useImperativeHandle(o,(()=>h),[h]);const b=G.useMemo((()=>h&&s.current?{sigma:h,container:s.current}:null),[h,s]),w=b!==null?Et.createElement(co,{value:b},a):null;return Et.createElement("div",Object.assign({},l,{ref:s}),Et.createElement("div",{className:"sigma-container",ref:u}),w)}));var rt={},kr;function vo(){if(kr)return rt;kr=1;function n(e){return typeof e!="number"||isNaN(e)?1:e}function r(e,i){var a={},o=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(o=i);var s=function(l){return o(l[e])},u=function(){return o(void 0)};return typeof e=="string"?(a.fromAttributes=s,a.fromGraph=function(l,h){return s(l.getNodeAttributes(h))},a.fromEntry=function(l,h){return s(h)}):typeof e=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},a.fromGraph=function(l,h){return o(e(h,l.getNodeAttributes(h)))},a.fromEntry=function(l,h){return o(e(l,h))}):(a.fromAttributes=u,a.fromGraph=u,a.fromEntry=u),a}function t(e,i){var a={},o=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(o=i);var s=function(l){return o(l[e])},u=function(){return o(void 0)};return typeof e=="string"?(a.fromAttributes=s,a.fromGraph=function(l,h){return s(l.getEdgeAttributes(h))},a.fromEntry=function(l,h){return s(h)},a.fromPartialEntry=a.fromEntry,a.fromMinimalEntry=a.fromEntry):typeof e=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},a.fromGraph=function(l,h){var d=l.extremities(h);return o(e(h,l.getEdgeAttributes(h),d[0],d[1],l.getNodeAttributes(d[0]),l.getNodeAttributes(d[1]),l.isUndirected(h)))},a.fromEntry=function(l,h,d,c,f,b,w){return o(e(l,h,d,c,f,b,w))},a.fromPartialEntry=function(l,h,d,c){return o(e(l,h,d,c))},a.fromMinimalEntry=function(l,h){return o(e(l,h))}):(a.fromAttributes=u,a.fromGraph=u,a.fromEntry=u,a.fromMinimalEntry=u),a}return rt.createNodeValueGetter=r,rt.createEdgeValueGetter=t,rt.createEdgeWeightGetter=function(e){return t(e,n)},rt}var Nt,Ar;function yo(){if(Ar)return Nt;Ar=1;var n=0,r=1,t=2,e=3,i=4,a=5,o=6,s=7,u=8,l=9,h=0,d=1,c=2,f=0,b=1,w=2,E=3,L=4,_=5,R=6,m=7,y=8,S=3,C=10,P=3,O=9,z=10;return Nt=function(j,p,Q){var ne,k,v,B,q,ee,ae,J,I,Le,se=p.length,at=Q.length,Ie=j.adjustSizes,ot=j.barnesHutTheta*j.barnesHutTheta,Ue,K,W,H,ge,M,$,x=[];for(v=0;v<se;v+=C)p[v+i]=p[v+t],p[v+a]=p[v+e],p[v+t]=0,p[v+e]=0;if(j.outboundAttractionDistribution){for(Ue=0,v=0;v<se;v+=C)Ue+=p[v+o];Ue/=se/C}if(j.barnesHutOptimize){var pe=1/0,De=-1/0,Ee=1/0,Ge=-1/0,ue,Ne,Ye;for(v=0;v<se;v+=C)pe=Math.min(pe,p[v+n]),De=Math.max(De,p[v+n]),Ee=Math.min(Ee,p[v+r]),Ge=Math.max(Ge,p[v+r]);var je=De-pe,Fe=Ge-Ee;for(je>Fe?(Ee-=(je-Fe)/2,Ge=Ee+je):(pe-=(Fe-je)/2,De=pe+Fe),x[0+f]=-1,x[0+b]=(pe+De)/2,x[0+w]=(Ee+Ge)/2,x[0+E]=Math.max(De-pe,Ge-Ee),x[0+L]=-1,x[0+_]=-1,x[0+R]=0,x[0+m]=0,x[0+y]=0,ne=1,v=0;v<se;v+=C)for(k=0,Ye=S;;)if(x[k+_]>=0){p[v+n]<x[k+b]?p[v+r]<x[k+w]?ue=x[k+_]:ue=x[k+_]+O:p[v+r]<x[k+w]?ue=x[k+_]+O*2:ue=x[k+_]+O*3,x[k+m]=(x[k+m]*x[k+R]+p[v+n]*p[v+o])/(x[k+R]+p[v+o]),x[k+y]=(x[k+y]*x[k+R]+p[v+r]*p[v+o])/(x[k+R]+p[v+o]),x[k+R]+=p[v+o],k=ue;continue}else if(x[k+f]<0){x[k+f]=v;break}else{if(x[k+_]=ne*O,J=x[k+E]/2,I=x[k+_],x[I+f]=-1,x[I+b]=x[k+b]-J,x[I+w]=x[k+w]-J,x[I+E]=J,x[I+L]=I+O,x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,I+=O,x[I+f]=-1,x[I+b]=x[k+b]-J,x[I+w]=x[k+w]+J,x[I+E]=J,x[I+L]=I+O,x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,I+=O,x[I+f]=-1,x[I+b]=x[k+b]+J,x[I+w]=x[k+w]-J,x[I+E]=J,x[I+L]=I+O,x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,I+=O,x[I+f]=-1,x[I+b]=x[k+b]+J,x[I+w]=x[k+w]+J,x[I+E]=J,x[I+L]=x[k+L],x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,ne+=4,p[x[k+f]+n]<x[k+b]?p[x[k+f]+r]<x[k+w]?ue=x[k+_]:ue=x[k+_]+O:p[x[k+f]+r]<x[k+w]?ue=x[k+_]+O*2:ue=x[k+_]+O*3,x[k+R]=p[x[k+f]+o],x[k+m]=p[x[k+f]+n],x[k+y]=p[x[k+f]+r],x[ue+f]=x[k+f],x[k+f]=-1,p[v+n]<x[k+b]?p[v+r]<x[k+w]?Ne=x[k+_]:Ne=x[k+_]+O:p[v+r]<x[k+w]?Ne=x[k+_]+O*2:Ne=x[k+_]+O*3,ue===Ne)if(Ye--){k=ue;continue}else{Ye=S;break}x[Ne+f]=v;break}}if(j.barnesHutOptimize)for(K=j.scalingRatio,v=0;v<se;v+=C)for(k=0;;)if(x[k+_]>=0)if(M=Math.pow(p[v+n]-x[k+m],2)+Math.pow(p[v+r]-x[k+y],2),Le=x[k+E],4*Le*Le/M<ot){if(W=p[v+n]-x[k+m],H=p[v+r]-x[k+y],Ie===!0?M>0?($=K*p[v+o]*x[k+R]/M,p[v+t]+=W*$,p[v+e]+=H*$):M<0&&($=-K*p[v+o]*x[k+R]/Math.sqrt(M),p[v+t]+=W*$,p[v+e]+=H*$):M>0&&($=K*p[v+o]*x[k+R]/M,p[v+t]+=W*$,p[v+e]+=H*$),k=x[k+L],k<0)break;continue}else{k=x[k+_];continue}else{if(ee=x[k+f],ee>=0&&ee!==v&&(W=p[v+n]-p[ee+n],H=p[v+r]-p[ee+r],M=W*W+H*H,Ie===!0?M>0?($=K*p[v+o]*p[ee+o]/M,p[v+t]+=W*$,p[v+e]+=H*$):M<0&&($=-K*p[v+o]*p[ee+o]/Math.sqrt(M),p[v+t]+=W*$,p[v+e]+=H*$):M>0&&($=K*p[v+o]*p[ee+o]/M,p[v+t]+=W*$,p[v+e]+=H*$)),k=x[k+L],k<0)break;continue}else for(K=j.scalingRatio,B=0;B<se;B+=C)for(q=0;q<B;q+=C)W=p[B+n]-p[q+n],H=p[B+r]-p[q+r],Ie===!0?(M=Math.sqrt(W*W+H*H)-p[B+u]-p[q+u],M>0?($=K*p[B+o]*p[q+o]/M/M,p[B+t]+=W*$,p[B+e]+=H*$,p[q+t]-=W*$,p[q+e]-=H*$):M<0&&($=100*K*p[B+o]*p[q+o],p[B+t]+=W*$,p[B+e]+=H*$,p[q+t]-=W*$,p[q+e]-=H*$)):(M=Math.sqrt(W*W+H*H),M>0&&($=K*p[B+o]*p[q+o]/M/M,p[B+t]+=W*$,p[B+e]+=H*$,p[q+t]-=W*$,p[q+e]-=H*$));for(I=j.gravity/j.scalingRatio,K=j.scalingRatio,v=0;v<se;v+=C)$=0,W=p[v+n],H=p[v+r],M=Math.sqrt(Math.pow(W,2)+Math.pow(H,2)),j.strongGravityMode?M>0&&($=K*p[v+o]*I):M>0&&($=K*p[v+o]*I/M),p[v+t]-=W*$,p[v+e]-=H*$;for(K=1*(j.outboundAttractionDistribution?Ue:1),ae=0;ae<at;ae+=P)B=Q[ae+h],q=Q[ae+d],J=Q[ae+c],ge=Math.pow(J,j.edgeWeightInfluence),W=p[B+n]-p[q+n],H=p[B+r]-p[q+r],Ie===!0?(M=Math.sqrt(W*W+H*H)-p[B+u]-p[q+u],j.linLogMode?j.outboundAttractionDistribution?M>0&&($=-K*ge*Math.log(1+M)/M/p[B+o]):M>0&&($=-K*ge*Math.log(1+M)/M):j.outboundAttractionDistribution?M>0&&($=-K*ge/p[B+o]):M>0&&($=-K*ge)):(M=Math.sqrt(Math.pow(W,2)+Math.pow(H,2)),j.linLogMode?j.outboundAttractionDistribution?M>0&&($=-K*ge*Math.log(1+M)/M/p[B+o]):M>0&&($=-K*ge*Math.log(1+M)/M):j.outboundAttractionDistribution?(M=1,$=-K*ge/p[B+o]):(M=1,$=-K*ge)),M>0&&(p[B+t]+=W*$,p[B+e]+=H*$,p[q+t]-=W*$,p[q+e]-=H*$);var xe,N,Z,V,me,_e;if(Ie===!0)for(v=0;v<se;v+=C)p[v+l]!==1&&(xe=Math.sqrt(Math.pow(p[v+t],2)+Math.pow(p[v+e],2)),xe>z&&(p[v+t]=p[v+t]*z/xe,p[v+e]=p[v+e]*z/xe),N=p[v+o]*Math.sqrt((p[v+i]-p[v+t])*(p[v+i]-p[v+t])+(p[v+a]-p[v+e])*(p[v+a]-p[v+e])),Z=Math.sqrt((p[v+i]+p[v+t])*(p[v+i]+p[v+t])+(p[v+a]+p[v+e])*(p[v+a]+p[v+e]))/2,V=.1*Math.log(1+Z)/(1+Math.sqrt(N)),me=p[v+n]+p[v+t]*(V/j.slowDown),p[v+n]=me,_e=p[v+r]+p[v+e]*(V/j.slowDown),p[v+r]=_e);else for(v=0;v<se;v+=C)p[v+l]!==1&&(N=p[v+o]*Math.sqrt((p[v+i]-p[v+t])*(p[v+i]-p[v+t])+(p[v+a]-p[v+e])*(p[v+a]-p[v+e])),Z=Math.sqrt((p[v+i]+p[v+t])*(p[v+i]+p[v+t])+(p[v+a]+p[v+e])*(p[v+a]+p[v+e]))/2,V=p[v+s]*Math.log(1+Z)/(1+Math.sqrt(N)),p[v+s]=Math.min(1,Math.sqrt(V*(Math.pow(p[v+t],2)+Math.pow(p[v+e],2))/(1+Math.sqrt(N)))),me=p[v+n]+p[v+t]*(V/j.slowDown),p[v+n]=me,_e=p[v+r]+p[v+e]*(V/j.slowDown),p[v+r]=_e);return{}},Nt}var Ce={},Lr;function bo(){if(Lr)return Ce;Lr=1;var n=10,r=3;return Ce.assign=function(t){t=t||{};var e=Array.prototype.slice.call(arguments).slice(1),i,a,o;for(i=0,o=e.length;i<o;i++)if(e[i])for(a in e[i])t[a]=e[i][a];return t},Ce.validateSettings=function(t){return"linLogMode"in t&&typeof t.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&typeof t.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&typeof t.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&typeof t.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in t&&!(typeof t.scalingRatio=="number"&&t.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&typeof t.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&!(typeof t.gravity=="number"&&t.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&!(typeof t.slowDown=="number"||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&typeof t.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&!(typeof t.barnesHutTheta=="number"&&t.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Ce.graphToByteArrays=function(t,e){var i=t.order,a=t.size,o={},s,u=new Float32Array(i*n),l=new Float32Array(a*r);return s=0,t.forEachNode(function(h,d){o[h]=s,u[s]=d.x,u[s+1]=d.y,u[s+2]=0,u[s+3]=0,u[s+4]=0,u[s+5]=0,u[s+6]=1,u[s+7]=1,u[s+8]=d.size||1,u[s+9]=d.fixed?1:0,s+=n}),s=0,t.forEachEdge(function(h,d,c,f,b,w,E){var L=o[c],_=o[f],R=e(h,d,c,f,b,w,E);u[L+6]+=R,u[_+6]+=R,l[s]=L,l[s+1]=_,l[s+2]=R,s+=r}),{nodes:u,edges:l}},Ce.assignLayoutChanges=function(t,e,i){var a=0;t.updateEachNodeAttributes(function(o,s){return s.x=e[a],s.y=e[a+1],a+=n,i?i(o,s):s})},Ce.readGraphPositions=function(t,e){var i=0;t.forEachNode(function(a,o){e[i]=o.x,e[i+1]=o.y,i+=n})},Ce.collectLayoutChanges=function(t,e,i){for(var a=t.nodes(),o={},s=0,u=0,l=e.length;s<l;s+=n){if(i){var h=Object.assign({},t.getNodeAttributes(a[u]));h.x=e[s],h.y=e[s+1],h=i(a[u],h),o[a[u]]={x:h.x,y:h.y}}else o[a[u]]={x:e[s],y:e[s+1]};u++}return o},Ce.createWorker=function(e){var i=window.URL||window.webkitURL,a=e.toString(),o=i.createObjectURL(new Blob(["("+a+").call(this);"],{type:"text/javascript"})),s=new Worker(o);return i.revokeObjectURL(o),s},Ce}var Ft,Dr;function wo(){return Dr||(Dr=1,Ft={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),Ft}var Pt,Gr;function Eo(){if(Gr)return Pt;Gr=1;var n=yi(),r=vo().createEdgeWeightGetter,t=yo(),e=bo(),i=wo();function a(u,l,h){if(!n(l))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof h=="number"&&(h={iterations:h});var d=h.iterations;if(typeof d!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(d<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=r("getEdgeWeight"in h?h.getEdgeWeight:"weight").fromEntry,f=typeof h.outputReducer=="function"?h.outputReducer:null,b=e.assign({},i,h.settings),w=e.validateSettings(b);if(w)throw new Error("graphology-layout-forceatlas2: "+w.message);var E=e.graphToByteArrays(l,c),L;for(L=0;L<d;L++)t(b,E.nodes,E.edges);if(u){e.assignLayoutChanges(l,E.nodes,f);return}return e.collectLayoutChanges(l,E.nodes)}function o(u){var l=typeof u=="number"?u:u.order;return{barnesHutOptimize:l>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(l)}}var s=a.bind(null,!1);return s.assign=a.bind(null,!0),s.inferSettings=o,Pt=s,Pt}var xo=Eo();const _o=$r(xo);function jt(n){return n!=null&&typeof n=="object"&&"symbols"in n&&Array.isArray(n.symbols)}function Ci(n){return n!=null&&typeof n=="object"&&"riskLevel"in n&&"affectedSymbols"in n}function Co(n){return n!=null&&typeof n=="object"&&"result"in n&&Array.isArray(n.result)&&n.result.length>0&&typeof n.result[0]=="object"}function So(n){if(!Array.isArray(n)||n.length===0)return!1;const r=n[0];return r!=null&&typeof r=="object"&&!Array.isArray(r)}function Nr({data:n,pageSize:r=50}){const[t,e]=G.useState(0),i=G.useMemo(()=>{if(n.length===0)return[];const s=new Set;for(const u of n)for(const l of Object.keys(u))s.add(l);return Array.from(s)},[n]),a=Math.ceil(n.length/r),o=n.slice(t*r,(t+1)*r);return n.length===0?g.jsx("div",{className:"p-4 text-sm text-muted",children:"No results"}):g.jsxs("div",{children:[g.jsxs("div",{className:"text-xs text-muted mb-2",children:[n.length," rows"]}),g.jsx("div",{className:"overflow-x-auto rounded-lg border border-edge",children:g.jsxs("table",{className:"w-full text-xs",children:[g.jsx("thead",{children:g.jsx("tr",{className:"border-b border-edge bg-surface-alt text-left text-muted",children:i.map(s=>g.jsx("th",{className:"py-1.5 px-2 font-medium whitespace-nowrap",children:s},s))})}),g.jsx("tbody",{children:o.map((s,u)=>g.jsx("tr",{className:"border-b border-edge hover:bg-surface-elevated transition-colors",children:i.map(l=>g.jsx("td",{className:"py-1 px-2 max-w-[300px] truncate",children:To(s[l])},l))},u))})]})}),a>1&&g.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2 text-xs",children:[g.jsx("button",{onClick:()=>e(s=>Math.max(0,s-1)),disabled:t===0,className:"px-2 py-0.5 rounded bg-surface-elevated disabled:opacity-30",children:"Prev"}),g.jsxs("span",{className:"text-muted",children:[t+1," / ",a]}),g.jsx("button",{onClick:()=>e(s=>Math.min(a-1,s+1)),disabled:t>=a-1,className:"px-2 py-0.5 rounded bg-surface-elevated disabled:opacity-30",children:"Next"})]})]})}function To(n){return n==null?"—":typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):typeof n=="object"?JSON.stringify(n):String(n)}function Ro({data:n}){const[r,t]=G.useState(!1),[e,i]=G.useState(!1),a=JSON.stringify(n,null,2),o=G.useCallback(async()=>{try{await navigator.clipboard.writeText(a),i(!0),setTimeout(()=>i(!1),2e3)}catch{}},[a]);return g.jsxs("div",{className:"rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[g.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-edge",children:[g.jsx("button",{onClick:()=>t(s=>!s),className:"text-[10px] text-muted hover:text-foreground transition-colors",children:r?"▸ Show JSON":"▾ JSON"}),g.jsx("button",{onClick:()=>void o(),className:"text-[10px] px-2 py-0.5 rounded bg-surface-elevated text-muted hover:text-foreground transition-colors",children:e?"Copied!":"Copy"})]}),!r&&g.jsx("pre",{className:"p-3 text-xs whitespace-pre-wrap overflow-x-auto max-h-[400px] overflow-y-auto",children:a})]})}function ko(n){const r=[],t=new Map;for(const e of n){if(!e.file)continue;const i=t.get(e.file);i?i.push(e):t.set(e.file,[e])}for(const[e,i]of t){const a=e.split("/");let o=r;for(let s=0;s<a.length;s++){const u=a[s],l=a.slice(0,s+1).join("/"),h=s===a.length-1;let d=o.find(c=>c.name===u);d||(d={name:u,path:l,isDirectory:!h,children:[],symbolCount:0,symbols:[]},o.push(d)),h&&(d.symbols=i),o=d.children}}return Mt(r),r}function Mt(n){let r=0;for(const t of n)if(t.isDirectory){const e=Mt(t.children);t.symbolCount=e,r+=e}else t.symbolCount=t.symbols.length,r+=t.symbols.length,Mt(t.children);return n.sort((t,e)=>t.isDirectory!==e.isDirectory?t.isDirectory?-1:1:t.name.localeCompare(e.name)),r}function Ao(n,r){if(!r.trim())return n;const t=r.toLowerCase();return Si(n,t)}function Si(n,r){const t=[];for(const e of n){const i=e.path.toLowerCase().includes(r);if(i&&!e.isDirectory)t.push(e);else if(e.isDirectory)if(i)t.push(e);else{const a=Si(e.children,r);a.length>0&&t.push({...e,children:a})}}return t}const Lo=G.memo(function({tree:r,searchQuery:t,onSearchChange:e,expandedPaths:i,onToggleExpand:a,selectedPath:o,onSelectPath:s}){return g.jsxs("div",{className:"flex flex-col min-h-0",children:[g.jsx("div",{className:"px-3 py-2 border-b border-edge",children:g.jsx("input",{type:"text",value:t,onChange:u=>e(u.target.value),placeholder:"Search files...",className:"w-full text-xs px-2 py-1.5 rounded bg-surface border border-edge focus:outline-none focus:border-accent"})}),g.jsx("div",{className:"overflow-y-auto flex-1 py-1",children:r.length===0?g.jsx("div",{className:"px-3 py-4 text-xs text-muted text-center",children:t?"No files match":"No files indexed"}):r.map(u=>g.jsx(Ti,{item:u,depth:0,expandedPaths:i,selectedPath:o,onToggleExpand:a,onSelectPath:s},u.path))})]})});function Ti({item:n,depth:r,expandedPaths:t,selectedPath:e,onToggleExpand:i,onSelectPath:a}){const o=t.has(n.path),s=e===n.path,u=n.children.length>0,l=n.isDirectory?we.folder:we.file,h=G.useCallback(c=>{c.stopPropagation(),i(n.path)},[n.path,i]),d=G.useCallback(()=>{n.isDirectory&&i(n.path),a(n.path,n.isDirectory)},[n.path,n.isDirectory,i,a]);return g.jsxs(g.Fragment,{children:[g.jsxs("button",{onClick:d,className:`w-full text-left flex items-center gap-1.5 px-2 py-0.5 text-xs hover:bg-surface-elevated transition-colors ${s?"bg-surface-elevated font-semibold":""}`,style:{paddingLeft:`${r*14+8}px`},children:[u||n.isDirectory?g.jsx("span",{onClick:h,className:"w-3 text-center text-muted hover:text-foreground cursor-pointer shrink-0 text-[10px]",children:o?"▾":"▸"}):g.jsx("span",{className:"w-3 shrink-0"}),g.jsx("span",{style:{color:l},className:"shrink-0 text-[10px]",children:n.isDirectory?"📁":"📄"}),g.jsx("span",{className:"truncate",style:{color:l},children:n.name}),n.symbolCount>0&&g.jsx("span",{className:"text-[9px] text-muted ml-auto shrink-0",children:n.symbolCount})]}),o&&n.children.map(c=>g.jsx(Ti,{item:c,depth:r+1,expandedPaths:t,selectedPath:e,onToggleExpand:i,onSelectPath:a},c.path))]})}const Fr=Object.keys(we),Do=Object.keys(pt),Go=[{label:"All",value:null},{label:"1 hop",value:1},{label:"2 hops",value:2},{label:"3 hops",value:3}],No=G.memo(function({visibleNodeKinds:r,visibleEdgeTypes:t,focusDepth:e,onToggleNodeKind:i,onToggleEdgeType:a,onSetFocusDepth:o,symbolCounts:s,relationCounts:u}){return g.jsxs("div",{className:"p-4 overflow-y-auto flex-1 space-y-6",children:[g.jsxs("section",{children:[g.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted mb-1",children:"Node Types"}),g.jsx("p",{className:"text-[9px] text-muted mb-2",children:"Toggle visibility of node types in the graph"}),g.jsx("div",{className:"space-y-1",children:Fr.map(l=>{const h=we[l],d=r.has(l),c=s[l]??0;return g.jsxs("button",{onClick:()=>i(l),className:"w-full flex items-center gap-2 px-2 py-1 rounded text-xs hover:bg-surface-elevated transition-colors",children:[g.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:d?h:"#333"}}),g.jsx("span",{className:d?"":"text-muted line-through",children:l.charAt(0).toUpperCase()+l.slice(1)}),g.jsx("span",{className:"text-[9px] text-muted ml-auto",children:c}),g.jsx(Pr,{open:d})]},l)})})]}),g.jsxs("section",{children:[g.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted mb-1",children:"Edge Types"}),g.jsx("p",{className:"text-[9px] text-muted mb-2",children:"Toggle visibility of relationship types"}),g.jsx("div",{className:"space-y-1",children:Do.map(l=>{const h=pt[l],d=Ur[l]??l,c=t.has(l),f=u[l]??0;return g.jsxs("button",{onClick:()=>a(l),className:"w-full flex items-center gap-2 px-2 py-1 rounded text-xs hover:bg-surface-elevated transition-colors",children:[g.jsx("span",{className:"w-4 shrink-0 flex items-center",children:g.jsx("span",{className:"w-full h-0.5 rounded",style:{background:c?h:"#333"}})}),g.jsx("span",{className:c?"":"text-muted line-through",children:d}),g.jsx("span",{className:"text-[9px] text-muted ml-auto",children:f}),g.jsx(Pr,{open:c})]},l)})})]}),g.jsxs("section",{children:[g.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted mb-1",children:"Focus Depth"}),g.jsx("p",{className:"text-[9px] text-muted mb-2",children:"Show nodes within N hops of selected node"}),g.jsx("div",{className:"flex gap-1",children:Go.map(l=>g.jsx("button",{onClick:()=>o(l.value),className:`text-[10px] px-2.5 py-1 rounded transition-colors ${e===l.value?"bg-accent text-white":"bg-surface-elevated text-muted hover:bg-surface"}`,children:l.label},l.label))})]}),g.jsxs("section",{children:[g.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted mb-2",children:"Color Legend"}),g.jsx("div",{className:"grid grid-cols-2 gap-1",children:Fr.map(l=>g.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[g.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:we[l]}}),g.jsx("span",{children:l.charAt(0).toUpperCase()+l.slice(1)})]},l))})]})]})});function Pr({open:n}){return n?g.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-muted",children:[g.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),g.jsx("circle",{cx:"12",cy:"12",r:"3"})]}):g.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-muted opacity-40",children:[g.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),g.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),g.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Fo(n,r,t){if(!n.hasNode(r))return new Set;const e=new Set([r]),i=[[r,0]];for(;i.length>0;){const[a,o]=i.shift();if(!(o>=t))for(const s of n.neighbors(a))e.has(s)||(e.add(s),i.push([s,o+1]))}return e}var Po=`
|
|
313
313
|
attribute vec4 a_id;
|
|
314
314
|
attribute vec4 a_color;
|
|
315
315
|
attribute vec2 a_normal;
|
|
@@ -390,7 +390,7 @@ void main() {
|
|
|
390
390
|
|
|
391
391
|
v_color.a *= bias;
|
|
392
392
|
}
|
|
393
|
-
`,
|
|
393
|
+
`,Io=Po,Ri=WebGLRenderingContext,Ir=Ri.UNSIGNED_BYTE,Se=Ri.FLOAT,Oo=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],zo={lengthToThicknessRatio:qt.lengthToThicknessRatio};function ki(n){var r=F(F({},zo),{});return(function(t){function e(){return re(this,e),le(this,e,arguments)}return he(e,t),ie(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Io,FRAGMENT_SHADER_SOURCE:Kt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Oo,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Se},{name:"a_positionEnd",size:2,type:Se},{name:"a_normal",size:2,type:Se},{name:"a_color",size:4,type:Ir,normalized:!0},{name:"a_id",size:4,type:Ir,normalized:!0},{name:"a_sourceRadius",size:1,type:Se},{name:"a_targetRadius",size:1,type:Se}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Se},{name:"a_normalCoef",size:1,type:Se},{name:"a_sourceRadiusCoef",size:1,type:Se},{name:"a_targetRadiusCoef",size:1,type:Se}],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,l){var h=l.size||1,d=s.x,c=s.y,f=u.x,b=u.y,w=$e(l.color),E=f-d,L=b-c,_=s.size||1,R=u.size||1,m=E*E+L*L,y=0,S=0;m&&(m=1/Math.sqrt(m),y=-L*m*h,S=E*m*h);var C=this.array;C[o++]=d,C[o++]=c,C[o++]=f,C[o++]=b,C[o++]=y,C[o++]=S,C[o++]=w,C[o++]=a,C[o++]=_,C[o++]=R}},{key:"setUniforms",value:function(a,o){var s=o.gl,u=o.uniformLocations,l=u.u_matrix,h=u.u_zoomRatio,d=u.u_feather,c=u.u_pixelRatio,f=u.u_correctionRatio,b=u.u_sizeRatio,w=u.u_minEdgeThickness,E=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(l,!1,a.matrix),s.uniform1f(h,a.zoomRatio),s.uniform1f(b,a.sizeRatio),s.uniform1f(f,a.correctionRatio),s.uniform1f(c,a.pixelRatio),s.uniform1f(d,a.antiAliasingFeather),s.uniform1f(w,a.minEdgeThickness),s.uniform1f(E,r.lengthToThicknessRatio)}}])})(nt)}ki();function $o(n){return hi([ki(),gt(n),gt(F(F({},n),{},{extremity:"source"}))])}$o();var Uo=`
|
|
394
394
|
precision mediump float;
|
|
395
395
|
|
|
396
396
|
varying vec4 v_color;
|
|
@@ -398,7 +398,7 @@ varying vec4 v_color;
|
|
|
398
398
|
void main(void) {
|
|
399
399
|
gl_FragColor = v_color;
|
|
400
400
|
}
|
|
401
|
-
`,
|
|
401
|
+
`,jo=Uo,Mo=`
|
|
402
402
|
attribute vec4 a_id;
|
|
403
403
|
attribute vec4 a_color;
|
|
404
404
|
attribute vec2 a_position;
|
|
@@ -427,4 +427,4 @@ void main() {
|
|
|
427
427
|
|
|
428
428
|
v_color.a *= bias;
|
|
429
429
|
}
|
|
430
|
-
`,Ba=Ma,Ai=WebGLRenderingContext,Or=Ai.UNSIGNED_BYTE,Ha=Ai.FLOAT,Wa=["u_matrix"],Va=(function(n){function r(){return re(this,r),le(this,r,arguments)}return he(r,n),ie(r,[{key:"getDefinition",value:function(){return{VERTICES:2,VERTEX_SHADER_SOURCE:Ba,FRAGMENT_SHADER_SOURCE:ja,METHOD:WebGLRenderingContext.LINES,UNIFORMS:Wa,ATTRIBUTES:[{name:"a_position",size:2,type:Ha},{name:"a_color",size:4,type:Or,normalized:!0},{name:"a_id",size:4,type:Or,normalized:!0}]}}},{key:"processVisibleItem",value:function(e,i,o,a,s){var u=this.array,l=o.x,h=o.y,d=a.x,c=a.y,f=$e(s.color);u[i++]=l,u[i++]=h,u[i++]=f,u[i++]=e,u[i++]=d,u[i++]=c,u[i++]=f,u[i++]=e}},{key:"setUniforms",value:function(e,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix;o.uniformMatrix3fv(s,!1,e.matrix)}}])})(nt);function ce(n,r){return(n.startsWith("#")&&n.length>7?n.slice(0,7):n)+r}function os(){const[n,r]=G.useState(null),[t,e]=G.useState(null),[i,o]=G.useState(!0),[a,s]=G.useState(null),[u,l]=G.useState(""),[h,d]=G.useState({data:null,loading:!1,error:null}),[c,f]=G.useState(""),[b,w]=G.useState(null),[E,L]=G.useState(null),[_,R]=G.useState(null),[m,y]=G.useState(null),[S,C]=G.useState(!1),[P,O]=G.useState(null),[z,Y]=G.useState(!1),[j,p]=G.useState("explorer"),[Q,ne]=G.useState(""),[k,v]=G.useState(new Set),[B,q]=G.useState(null),[ee,oe]=G.useState(!1),[J,I]=G.useState(!1),[Le,se]=G.useState(new Set(Object.keys(we))),[ot,Ie]=G.useState(new Set(Object.keys(pt))),[at,Ue]=G.useState(null),K=G.useCallback(async()=>{try{o(!0);const[N,Z]=await Promise.all([Oe.getCodeGraphStatus().catch(()=>null),Oe.getFolder().catch(()=>null)]);if(r(N),O((Z==null?void 0:Z.currentPath)??(N==null?void 0:N.basePath)??null),N!=null&&N.indexed)try{const V=await Oe.getFullCodeGraph();V!=null&&V.symbols&&R(V)}catch{}}catch(N){e(N instanceof Error?N.message:"Failed to load")}finally{o(!1)}},[]);G.useEffect(()=>{K()},[K]);const W=G.useCallback(async()=>{if(u.trim()){d({data:null,loading:!0,error:null});try{const N=await Oe.searchCodeGraph(u);d({data:N,loading:!1,error:null}),jt(N)&&y(N)}catch(N){d({data:null,loading:!1,error:N instanceof Error?N.message:"Query failed"})}}},[u]),H=G.useCallback(async N=>{if(N.trim())try{const Z=await Oe.getSymbolContext(N);jt(Z)&&(w(Z),y(Z))}catch{}},[]),ge=G.useCallback(async N=>{if(N.trim())try{const Z=await Oe.getSymbolImpact(N);Ci(Z)&&L(Z)}catch{}},[]),M=G.useCallback(async()=>{Y(!0);try{await Oe.triggerReindex(),await K()}catch{}finally{Y(!1)}},[K]),$=G.useCallback(()=>{K()},[K]),x=G.useCallback(N=>{s(N),f(N),I(!0),H(N)},[H]),pe=G.useMemo(()=>_?ka(_.symbols):[],[_]),De=G.useMemo(()=>Q.trim()?Aa(pe,Q):pe,[pe,Q]),Ee=G.useMemo(()=>{const N={};if(_)for(const Z of _.symbols)N[Z.kind]=(N[Z.kind]??0)+1;return N},[_]),Ge=G.useMemo(()=>{const N={};if(_)for(const Z of _.relations)N[Z.type]=(N[Z.type]??0)+1;return N},[_]),ue=G.useCallback(N=>{v(Z=>{const V=new Set(Z);return V.has(N)?V.delete(N):V.add(N),V})},[]),Ne=G.useCallback((N,Z)=>{if(q(N),!_)return;const V=_.symbols.filter(me=>me.file?Z?me.file.startsWith(N+"/")||me.file.startsWith(N):me.file===N:!1);if(V.length>0){const me={symbols:V,relations:_.relations.filter(_e=>{const Gi=_e.from??_e.fromSymbol??"",Ni=_e.to??_e.toSymbol??"",Fi=V.some(wt=>wt.name===Gi),Pi=V.some(wt=>wt.name===Ni);return Fi||Pi})};y(me)}},[_]),Ye=G.useCallback(N=>{se(Z=>{const V=new Set(Z);return V.has(N)?V.delete(N):V.add(N),V})},[]),je=G.useCallback(N=>{Ie(Z=>{const V=new Set(Z);return V.has(N)?V.delete(N):V.add(N),V})},[]);if(i)return g.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:"Loading Code Graph..."});if(t)return g.jsxs("div",{className:"flex items-center justify-center h-full text-[var(--color-danger)]",children:["Failed to load: ",t]});const Fe=(n==null?void 0:n.indexed)??!1,xe=_??m;return g.jsxs("div",{className:"h-full flex flex-col",children:[g.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[g.jsx("h2",{className:"text-sm font-semibold",children:"Code Graph — Code Intelligence"}),g.jsx(qa,{label:"Code Graph",indexed:(n==null?void 0:n.indexed)??!1,running:Fe,onAction:M,actionLoading:z}),xe&&g.jsxs("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:[xe.symbols.length," symbols · ",xe.relations.length," relations"]})]}),g.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[g.jsx("span",{className:"text-[10px] text-[var(--color-text-muted)] whitespace-nowrap font-mono",children:P?`Current: ${P}`:"No project path"}),g.jsx("button",{onClick:()=>C(!0),className:"text-[10px] font-medium px-3 py-1 rounded bg-[var(--color-accent)] text-white hover:opacity-90 transition-opacity whitespace-nowrap",children:"Open Folder..."})]}),g.jsx(Ii,{open:S,onClose:()=>C(!1),onFolderChanged:$}),(n==null?void 0:n.typescriptAvailable)===!1&&g.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-[var(--color-border)] bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",children:[g.jsx("span",{className:"text-sm font-medium",children:"TypeScript compiler not found."}),g.jsxs("span",{className:"text-xs",children:["Code Graph requires the ",g.jsx("code",{className:"font-mono bg-yellow-500/10 px-1 rounded",children:"typescript"})," package to analyze source files. Install it: ",g.jsx("code",{className:"font-mono bg-yellow-500/10 px-1 rounded",children:"npm install -D typescript"})]})]}),g.jsxs("div",{className:"flex flex-1 min-h-0",children:[g.jsxs("div",{className:"w-[30%] min-w-[320px] border-r border-[var(--color-border)] flex flex-col min-h-0",children:[g.jsx("div",{className:"flex border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:["explorer","filters"].map(N=>g.jsx("button",{onClick:()=>p(N),className:`flex-1 text-xs px-3 py-2 font-medium transition-colors ${j===N?"border-b-2 border-[var(--color-accent)] text-[var(--color-accent)]":"text-[var(--color-text-muted)] hover:text-[var(--color-text)]"}`,children:N==="explorer"?"Explorer":"Filters"},N))}),j==="explorer"&&g.jsxs("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden",children:[g.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:g.jsx(La,{tree:De,searchQuery:Q,onSearchChange:ne,expandedPaths:k,onToggleExpand:ue,selectedPath:B,onSelectPath:Ne})}),g.jsx(zr,{title:"Query",open:ee,onToggle:()=>oe(N=>!N),children:g.jsx(Ka,{queryInput:u,onQueryChange:l,onSubmit:W,result:h,gitNexusRunning:Fe,onSymbolSelect:x})}),g.jsx(zr,{title:"Symbol Explorer",open:J,onToggle:()=>I(N=>!N),children:g.jsx(Xa,{symbolInput:c,onSymbolInputChange:f,onContext:H,onImpact:ge,contextData:b,impactData:E,gitNexusRunning:Fe,onSymbolSelect:x})})]}),j==="filters"&&g.jsx(Na,{visibleNodeKinds:Le,visibleEdgeTypes:ot,focusDepth:at,onToggleNodeKind:Ye,onToggleEdgeType:je,onSetFocusDepth:Ue,symbolCounts:Ee,relationCounts:Ge})]}),g.jsx(Qa,{fullGraph:xe,contextGraph:m,selectedSymbol:a,onNodeClick:x,visibleNodeKinds:Le,visibleEdgeTypes:ot,focusDepth:at})]})]})}function zr({title:n,open:r,onToggle:t,children:e}){return g.jsxs("div",{className:"border-t border-[var(--color-border)]",children:[g.jsxs("button",{onClick:t,className:"w-full flex items-center gap-2 px-3 py-2 text-xs font-medium text-[var(--color-text-muted)] hover:text-[var(--color-text)] hover:bg-[var(--color-bg-tertiary)] transition-colors",children:[g.jsx("span",{className:"text-[10px]",children:r?"▾":"▸"}),n]}),r&&g.jsx("div",{className:"max-h-[300px] overflow-auto",children:e})]})}function qa({label:n,indexed:r,running:t,onAction:e,actionLoading:i}){const o=r?"var(--color-success)":"var(--color-text-muted)",a=r?`Indexed (${t?"active":"ready"})`:"Not indexed";return g.jsxs("span",{className:"inline-flex items-center gap-1",children:[g.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${o}20`,color:o},children:[n,": ",a]}),e&&g.jsx("button",{onClick:e,disabled:i,className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-[var(--color-accent)] text-white disabled:opacity-50 hover:opacity-90 transition-opacity",children:i?"Indexing...":"Reindex"})]})}function Ka({queryInput:n,onQueryChange:r,onSubmit:t,result:e,gitNexusRunning:i,onSymbolSelect:o}){return g.jsxs("div",{className:"p-4",children:[g.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Query Code Graph"}),!i&&g.jsx("div",{className:"mb-4 p-3 rounded-lg bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] text-sm text-[var(--color-text-muted)]",children:"Code index not available. Click Reindex to enable code graph queries."}),g.jsxs("div",{className:"flex gap-2 mb-4",children:[g.jsx("input",{type:"text",value:n,onChange:a=>r(a.target.value),onKeyDown:a=>a.key==="Enter"&&t(),placeholder:"e.g., MATCH (n) RETURN n.name LIMIT 20",className:"flex-1 text-sm px-3 py-2 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",disabled:!i}),g.jsx("button",{onClick:t,disabled:!i||e.loading,className:"text-sm px-4 py-2 rounded-lg bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:e.loading?"...":"Query"})]}),e.error&&g.jsx("div",{className:"p-3 rounded-lg bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] text-sm text-[var(--color-danger)]",children:e.error}),e.data!=null&&g.jsx(Ya,{data:e.data,onSymbolSelect:o})]})}function Ya({data:n,onSymbolSelect:r}){return jt(n)?g.jsx(Li,{symbols:n.symbols,onSymbolSelect:r}):Ci(n)?g.jsx(Di,{impact:n,onSymbolSelect:r}):Ca(n)?g.jsx(Nr,{data:n.result}):Sa(n)?g.jsx(Nr,{data:n}):g.jsx(Ra,{data:n})}function Li({symbols:n,onSymbolSelect:r}){const[t,e]=G.useState(0),i=50,o=Math.ceil(n.length/i),a=n.slice(t*i,(t+1)*i);return g.jsxs("div",{children:[g.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] mb-2",children:[n.length," symbols found"]}),g.jsxs("table",{className:"w-full text-xs",children:[g.jsx("thead",{children:g.jsxs("tr",{className:"border-b border-[var(--color-border)] text-left text-[var(--color-text-muted)]",children:[g.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Name"}),g.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Kind"}),g.jsx("th",{className:"py-1.5 px-2 font-medium",children:"File"}),g.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Lines"})]})}),g.jsx("tbody",{children:a.map(s=>g.jsxs("tr",{onClick:()=>r(s.name),className:"border-b border-[var(--color-border)] hover:bg-[var(--color-bg-tertiary)] cursor-pointer transition-colors",children:[g.jsx("td",{className:"py-1 px-2 font-medium",children:s.name}),g.jsx("td",{className:"py-1 px-2",children:g.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:`${we[s.kind]??"#9e9e9e"}20`,color:we[s.kind]??"#9e9e9e"},children:s.kind})}),g.jsx("td",{className:"py-1 px-2 text-[var(--color-text-muted)] truncate max-w-[200px]",children:s.file??"—"}),g.jsx("td",{className:"py-1 px-2 text-[var(--color-text-muted)]",children:s.startLine!=null?`${s.startLine}–${s.endLine??s.startLine}`:"—"})]},`${s.name}-${s.file??""}-${s.startLine??""}`))})]}),o>1&&g.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2 text-xs",children:[g.jsx("button",{onClick:()=>e(s=>Math.max(0,s-1)),disabled:t===0,className:"px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] disabled:opacity-30",children:"Prev"}),g.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[t+1," / ",o]}),g.jsx("button",{onClick:()=>e(s=>Math.min(o-1,s+1)),disabled:t>=o-1,className:"px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] disabled:opacity-30",children:"Next"})]})]})}const Za={low:"#4caf50",medium:"#ff9800",high:"#f44336"};function Di({impact:n,onSymbolSelect:r}){const t=Za[n.riskLevel]??"#9e9e9e";return g.jsxs("div",{className:"rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] p-4",children:[g.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[g.jsxs("span",{className:"text-sm font-semibold",children:["Impact: ",n.symbol]}),g.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${t}20`,color:t},children:[n.riskLevel," risk"]})]}),g.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] mb-2",children:[n.affectedSymbols.length," affected symbols"]}),g.jsx("div",{className:"space-y-1",children:n.affectedSymbols.map(e=>g.jsxs("button",{onClick:()=>r(e.name),className:"w-full text-left flex items-center justify-between px-2 py-1 rounded hover:bg-[var(--color-bg-tertiary)] transition-colors text-xs",children:[g.jsx("span",{className:"font-medium",children:e.name}),g.jsxs("span",{className:"text-[var(--color-text-muted)] flex items-center gap-2",children:[g.jsx("span",{className:"truncate max-w-[150px]",children:e.file}),g.jsxs("span",{children:[Math.round(e.confidence*100),"%"]})]})]},`${e.name}-${e.file}`))})]})}function Xa({symbolInput:n,onSymbolInputChange:r,onContext:t,onImpact:e,contextData:i,impactData:o,gitNexusRunning:a,onSymbolSelect:s}){return g.jsxs("div",{className:"p-4",children:[g.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Symbol Explorer"}),!a&&g.jsx("div",{className:"mb-4 p-3 rounded-lg bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] text-sm text-[var(--color-text-muted)]",children:"Code index not available. Click Reindex to explore symbols."}),g.jsxs("div",{className:"flex gap-2 mb-4",children:[g.jsx("input",{type:"text",value:n,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&t(n),placeholder:"e.g., SqliteStore, buildTaskContext",className:"flex-1 text-sm px-3 py-2 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",disabled:!a}),g.jsx("button",{onClick:()=>t(n),disabled:!a||!n.trim(),className:"text-sm px-3 py-2 rounded-lg bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:"Context"}),g.jsx("button",{onClick:()=>e(n),disabled:!a||!n.trim(),className:"text-sm px-3 py-2 rounded-lg bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:"Impact"})]}),i&&g.jsxs("div",{className:"mb-4",children:[g.jsxs("h4",{className:"text-xs font-semibold mb-2 text-[var(--color-text-muted)]",children:["Context — ",i.symbols.length," symbols"]}),g.jsx(Li,{symbols:i.symbols,onSymbolSelect:s})]}),o&&g.jsx(Di,{impact:o,onSymbolSelect:s}),!i&&!o&&g.jsx("div",{className:"text-center text-[var(--color-text-muted)] text-sm py-8",children:"Enter a symbol name and click Context or Impact to explore"})]})}function Qa({fullGraph:n,contextGraph:r,selectedSymbol:t,onNodeClick:e,visibleNodeKinds:i,visibleEdgeTypes:o,focusDepth:a}){const[s,u]=G.useState(null);if(!n||n.symbols.length===0)return g.jsx("div",{className:"flex-1 min-w-[300px] flex items-center justify-center",style:{background:"#06060f"},children:g.jsxs("div",{className:"text-center text-[#3a3a5a]",children:[g.jsx("p",{className:"text-sm mb-1",children:"No symbol graph"}),g.jsx("p",{className:"text-xs",children:"Query or select a symbol to see its graph"})]})});const l=G.useMemo(()=>{const d=new Set;if(r)for(const c of r.symbols)d.add(c.name);return d},[r]),h=s??t;return g.jsxs("div",{className:"flex-1 min-w-[300px] relative",style:{background:"#06060f"},children:[g.jsx("div",{className:"absolute top-2 left-2 z-10 flex flex-wrap gap-1 rounded-lg px-2 py-1.5",style:{background:"#06060fdd"},children:Object.entries(we).map(([d,c])=>g.jsx("span",{className:"text-[8px] font-medium px-1.5 py-0.5 rounded-full",style:{background:`${c}20`,color:c,textShadow:`0 0 8px ${c}`},children:d},d))}),g.jsxs("div",{className:"absolute bottom-2 right-2 z-10 text-[9px]",style:{color:"#3a3a5a"},children:[n.symbols.length," nodes · ",n.relations.length," edges"]}),g.jsxs(ma,{style:{width:"100%",height:"100%",background:"#06060f"},settings:{defaultNodeColor:"#3a3a5a",defaultEdgeColor:"#151525",stagePadding:40,labelColor:{color:"#c0c0e0"},labelSize:11,labelFont:"monospace",labelWeight:"bold",labelRenderedSizeThreshold:10,labelDensity:.5,renderLabels:!0,renderEdgeLabels:!0,enableEdgeEvents:!1,defaultEdgeType:"arrow",edgeProgramClasses:{arrow:mi,line:Va},defaultDrawNodeHover:es,defaultDrawNodeLabel:Ja,minEdgeThickness:.5,minCameraRatio:.05,maxCameraRatio:10,zIndex:!0},children:[g.jsx(ts,{fullGraph:n,highlightedNodes:l,selectedSymbol:t}),g.jsx(rs,{onNodeClick:e,onNodeHover:u,activeNode:h,highlightedNodes:l,visibleNodeKinds:i,visibleEdgeTypes:o,focusDepth:a,selectedSymbol:t})]})]})}function Ja(n,r,t){const{x:e,y:i,size:o,color:a,label:s}=r;if(!s)return;const u=t.labelSize;n.font=`${t.labelWeight} ${u}px ${t.labelFont}`,n.shadowColor=a,n.shadowBlur=6,n.fillStyle="#d0d0f0",n.fillText(s,e+o*1.5,i+u/3),n.shadowBlur=0}function es(n,r){const{x:t,y:e,size:i,color:o,label:a}=r,s=n.createRadialGradient(t,e,i*.5,t,e,i*6);s.addColorStop(0,ce(o,"80")),s.addColorStop(.3,ce(o,"30")),s.addColorStop(.6,ce(o,"10")),s.addColorStop(1,ce(o,"00")),n.beginPath(),n.arc(t,e,i*6,0,Math.PI*2),n.fillStyle=s,n.fill(),n.beginPath(),n.arc(t,e,i*1.5,0,Math.PI*2),n.fillStyle=o,n.fill(),n.beginPath(),n.arc(t,e,i*.5,0,Math.PI*2),n.fillStyle="#ffffff",n.fill(),a&&(n.font="bold 13px monospace",n.shadowColor=o,n.shadowBlur=12,n.fillStyle="#ffffff",n.fillText(a,t+i*2,e+4),n.shadowBlur=0)}function ts({fullGraph:n,highlightedNodes:r,selectedSymbol:t}){const e=pa(),i=yt();return G.useEffect(()=>{const o=new X({type:"directed",multi:!1,allowSelfLoops:!1});for(const u of n.symbols)if(!o.hasNode(u.name)){const l=we[u.kind]??"#6a6a8a";o.addNode(u.name,{label:u.name,size:3,color:l,baseColor:l,kind:u.kind,x:Math.random()*200-100,y:Math.random()*200-100})}const a=new Set;for(const u of n.relations){const l=u.from??u.fromSymbol??"",h=u.to??u.toSymbol??"",d=`${l}\0${h}`;if(!l||!h||!o.hasNode(l)||!o.hasNode(h)||l===h||a.has(d))continue;a.add(d);const c=pt[u.type]??"#2a2a50";try{o.addEdge(l,h,{color:ce(c,"a0"),size:.5,baseColor:c,relType:u.type,label:Ur[u.type]??u.type,type:u.type==="belongs_to"?"line":"arrow"})}catch{}}o.order>0&&_a.assign(o,{iterations:o.order>500?250:180,settings:{gravity:.3,scalingRatio:o.order>200?8:4,barnesHutOptimize:o.order>50,barnesHutTheta:.5,strongGravityMode:!1,slowDown:3,adjustSizes:!0,linLogMode:!0,outboundAttractionDistribution:!0}}),e(o);const s=i.getGraph();s.forEachNode(u=>{const l=s.degree(u),h=Math.min(10,Math.max(1.5,1.5+Math.pow(l,.6)*.8));s.setNodeAttribute(u,"size",h)})},[n,e,i]),G.useEffect(()=>{const o=i.getGraph(),a=r.size>0;o.forEachNode(s=>{const u=o.getNodeAttribute(s,"baseColor")??"#6a6a8a",l=o.degree(s),h=r.has(s),d=s===t,c=a&&!h;if(d)o.setNodeAttribute(s,"size",14),o.setNodeAttribute(s,"zIndex",2);else if(h){const f=Math.min(10,Math.max(5,5+Math.sqrt(l)*1.2));o.setNodeAttribute(s,"size",f),o.setNodeAttribute(s,"zIndex",1)}else{const f=Math.min(10,Math.max(1.5,1.5+Math.pow(l,.6)*.8));o.setNodeAttribute(s,"size",f),o.setNodeAttribute(s,"zIndex",0)}d?o.setNodeAttribute(s,"color","#ffffff"):c?o.setNodeAttribute(s,"color",ce(u,"30")):o.setNodeAttribute(s,"color",u)}),o.forEachEdge((s,u,l,h)=>{const d=o.getEdgeAttribute(s,"baseColor")??"#2a2a50",c=r.has(l),f=r.has(h),b=t!=null&&(l===t||h===t),w=c&&f;b?(o.setEdgeAttribute(s,"color",ce(d,"f0")),o.setEdgeAttribute(s,"size",3),o.setEdgeAttribute(s,"zIndex",2)):w?(o.setEdgeAttribute(s,"color",ce(d,"90")),o.setEdgeAttribute(s,"size",1.5),o.setEdgeAttribute(s,"zIndex",1)):a&&!w&&!b?(o.setEdgeAttribute(s,"color",ce("#080815","20")),o.setEdgeAttribute(s,"size",.15),o.setEdgeAttribute(s,"zIndex",0)):(o.setEdgeAttribute(s,"color",ce(d,"50")),o.setEdgeAttribute(s,"size",.4),o.setEdgeAttribute(s,"zIndex",0))}),i.refresh()},[r,t,i]),null}function rs({onNodeClick:n,onNodeHover:r,activeNode:t,highlightedNodes:e,visibleNodeKinds:i,visibleEdgeTypes:o,focusDepth:a,selectedSymbol:s}){const u=ga(),l=yt();return G.useEffect(()=>{u({clickNode:h=>{n(h.node)},enterNode:h=>{r(h.node)},leaveNode:()=>{r(null)}})},[u,n,r]),G.useEffect(()=>{const h=l.getGraph();let d=null;a!=null&&s&&h.hasNode(s)&&(d=Fa(h,s,a)),l.setSetting("nodeReducer",(c,f)=>{const b=h.getNodeAttribute(c,"kind");if(!i.has(b))return{...f,hidden:!0};if(d&&!d.has(c))return{...f,hidden:!0};if(t&&h.hasNode(t)){const w=new Set(h.neighbors(t));if(w.add(t),c===t)return{...f,color:"#ffffff",size:(f.size??3)*1.3,zIndex:3};if(w.has(c)){const E=h.getNodeAttribute(c,"baseColor")??"#6a6a8a";return{...f,color:E.startsWith("#")&&E.length>7?E.slice(0,7):E,zIndex:2}}if(e.size===0){const E=h.getNodeAttribute(c,"baseColor")??"#6a6a8a";return{...f,color:ce(E,"25"),zIndex:0}}{const E=f.color??"#6a6a8a";return{...f,color:E.startsWith("#")&&E.length>7?E.slice(0,7):E}}}return f}),l.setSetting("edgeReducer",(c,f)=>{const b=h.source(c),w=h.target(c),E=h.getEdgeAttribute(c,"relType");if(!o.has(E))return{...f,hidden:!0};const L=h.getNodeAttribute(b,"kind"),_=h.getNodeAttribute(w,"kind");if(!i.has(L)||!i.has(_))return{...f,hidden:!0};if(d&&(!d.has(b)||!d.has(w)))return{...f,hidden:!0};if(t&&h.hasNode(t)){if(b===t||w===t){const m=h.getEdgeAttribute(c,"baseColor")??"#4a4a7a";return{...f,color:ce(m,"f0"),size:3,zIndex:2,forceLabel:!0}}if(e.size===0)return{...f,color:"#1e1e3a",size:.2,zIndex:0}}return f})},[t,e,i,o,a,s,l]),null}export{os as GitNexusTab};
|
|
430
|
+
`,Bo=Mo,Ai=WebGLRenderingContext,Or=Ai.UNSIGNED_BYTE,Ho=Ai.FLOAT,Wo=["u_matrix"],Vo=(function(n){function r(){return re(this,r),le(this,r,arguments)}return he(r,n),ie(r,[{key:"getDefinition",value:function(){return{VERTICES:2,VERTEX_SHADER_SOURCE:Bo,FRAGMENT_SHADER_SOURCE:jo,METHOD:WebGLRenderingContext.LINES,UNIFORMS:Wo,ATTRIBUTES:[{name:"a_position",size:2,type:Ho},{name:"a_color",size:4,type:Or,normalized:!0},{name:"a_id",size:4,type:Or,normalized:!0}]}}},{key:"processVisibleItem",value:function(e,i,a,o,s){var u=this.array,l=a.x,h=a.y,d=o.x,c=o.y,f=$e(s.color);u[i++]=l,u[i++]=h,u[i++]=f,u[i++]=e,u[i++]=d,u[i++]=c,u[i++]=f,u[i++]=e}},{key:"setUniforms",value:function(e,i){var a=i.gl,o=i.uniformLocations,s=o.u_matrix;a.uniformMatrix3fv(s,!1,e.matrix)}}])})(nt);function ce(n,r){return(n.startsWith("#")&&n.length>7?n.slice(0,7):n)+r}function as(){const[n,r]=G.useState(null),[t,e]=G.useState(null),[i,a]=G.useState(!0),[o,s]=G.useState(null),[u,l]=G.useState(""),[h,d]=G.useState({data:null,loading:!1,error:null}),[c,f]=G.useState(""),[b,w]=G.useState(null),[E,L]=G.useState(null),[_,R]=G.useState(null),[m,y]=G.useState(null),[S,C]=G.useState(!1),[P,O]=G.useState(null),[z,Y]=G.useState(!1),[j,p]=G.useState("explorer"),[Q,ne]=G.useState(""),[k,v]=G.useState(new Set),[B,q]=G.useState(null),[ee,ae]=G.useState(!1),[J,I]=G.useState(!1),[Le,se]=G.useState(new Set(Object.keys(we))),[at,Ie]=G.useState(new Set(Object.keys(pt))),[ot,Ue]=G.useState(null),K=G.useCallback(async()=>{try{a(!0);const[N,Z]=await Promise.all([Oe.getCodeGraphStatus().catch(()=>null),Oe.getFolder().catch(()=>null)]);if(r(N),O((Z==null?void 0:Z.currentPath)??(N==null?void 0:N.basePath)??null),N!=null&&N.indexed)try{const V=await Oe.getFullCodeGraph();V!=null&&V.symbols&&R(V)}catch{}}catch(N){e(N instanceof Error?N.message:"Failed to load")}finally{a(!1)}},[]);G.useEffect(()=>{K()},[K]);const W=G.useCallback(async()=>{if(u.trim()){d({data:null,loading:!0,error:null});try{const N=await Oe.searchCodeGraph(u);d({data:N,loading:!1,error:null}),jt(N)&&y(N)}catch(N){d({data:null,loading:!1,error:N instanceof Error?N.message:"Query failed"})}}},[u]),H=G.useCallback(async N=>{if(N.trim())try{const Z=await Oe.getSymbolContext(N);jt(Z)&&(w(Z),y(Z))}catch{}},[]),ge=G.useCallback(async N=>{if(N.trim())try{const Z=await Oe.getSymbolImpact(N);Ci(Z)&&L(Z)}catch{}},[]),M=G.useCallback(async()=>{Y(!0);try{await Oe.triggerReindex(),await K()}catch{}finally{Y(!1)}},[K]),$=G.useCallback(()=>{K()},[K]),x=G.useCallback(N=>{s(N),f(N),I(!0),H(N)},[H]),pe=G.useMemo(()=>_?ko(_.symbols):[],[_]),De=G.useMemo(()=>Q.trim()?Ao(pe,Q):pe,[pe,Q]),Ee=G.useMemo(()=>{const N={};if(_)for(const Z of _.symbols)N[Z.kind]=(N[Z.kind]??0)+1;return N},[_]),Ge=G.useMemo(()=>{const N={};if(_)for(const Z of _.relations)N[Z.type]=(N[Z.type]??0)+1;return N},[_]),ue=G.useCallback(N=>{v(Z=>{const V=new Set(Z);return V.has(N)?V.delete(N):V.add(N),V})},[]),Ne=G.useCallback((N,Z)=>{if(q(N),!_)return;const V=_.symbols.filter(me=>me.file?Z?me.file.startsWith(N+"/")||me.file.startsWith(N):me.file===N:!1);if(V.length>0){const me={symbols:V,relations:_.relations.filter(_e=>{const Gi=_e.from??_e.fromSymbol??"",Ni=_e.to??_e.toSymbol??"",Fi=V.some(wt=>wt.name===Gi),Pi=V.some(wt=>wt.name===Ni);return Fi||Pi})};y(me)}},[_]),Ye=G.useCallback(N=>{se(Z=>{const V=new Set(Z);return V.has(N)?V.delete(N):V.add(N),V})},[]),je=G.useCallback(N=>{Ie(Z=>{const V=new Set(Z);return V.has(N)?V.delete(N):V.add(N),V})},[]);if(i)return g.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading Code Graph..."});if(t)return g.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load: ",t]});const Fe=(n==null?void 0:n.indexed)??!1,xe=_??m;return g.jsxs("div",{className:"h-full flex flex-col",children:[g.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-edge bg-surface-alt",children:[g.jsx("h2",{className:"text-sm font-semibold",children:"Code Graph — Code Intelligence"}),g.jsx(qo,{label:"Code Graph",indexed:(n==null?void 0:n.indexed)??!1,running:Fe,onAction:M,actionLoading:z}),xe&&g.jsxs("span",{className:"text-[10px] text-muted",children:[xe.symbols.length," symbols · ",xe.relations.length," relations"]})]}),g.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5 border-b border-edge bg-surface-alt",children:[g.jsx("span",{className:"text-[10px] text-muted whitespace-nowrap font-mono",children:P?`Current: ${P}`:"No project path"}),g.jsx("button",{onClick:()=>C(!0),className:"text-[10px] font-medium px-3 py-1 rounded bg-accent text-white hover:opacity-90 transition-opacity whitespace-nowrap",children:"Open Folder..."})]}),g.jsx(Ii,{open:S,onClose:()=>C(!1),onFolderChanged:$}),(n==null?void 0:n.typescriptAvailable)===!1&&g.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-edge bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",children:[g.jsx("span",{className:"text-sm font-medium",children:"TypeScript compiler not found."}),g.jsxs("span",{className:"text-xs",children:["Code Graph requires the ",g.jsx("code",{className:"font-mono bg-yellow-500/10 px-1 rounded",children:"typescript"})," package to analyze source files. Install it: ",g.jsx("code",{className:"font-mono bg-yellow-500/10 px-1 rounded",children:"npm install -D typescript"})]})]}),g.jsxs("div",{className:"flex flex-1 min-h-0",children:[g.jsxs("div",{className:"w-full md:w-[30%] md:min-w-[280px] border-r border-edge flex flex-col min-h-0",children:[g.jsx("div",{className:"flex border-b border-edge bg-surface-alt",children:["explorer","filters"].map(N=>g.jsx("button",{onClick:()=>p(N),className:`flex-1 text-xs px-3 py-2 font-medium transition-colors ${j===N?"border-b-2 border-accent text-accent":"text-muted hover:text-foreground"}`,children:N==="explorer"?"Explorer":"Filters"},N))}),j==="explorer"&&g.jsxs("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden",children:[g.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:g.jsx(Lo,{tree:De,searchQuery:Q,onSearchChange:ne,expandedPaths:k,onToggleExpand:ue,selectedPath:B,onSelectPath:Ne})}),g.jsx(zr,{title:"Query",open:ee,onToggle:()=>ae(N=>!N),children:g.jsx(Ko,{queryInput:u,onQueryChange:l,onSubmit:W,result:h,gitNexusRunning:Fe,onSymbolSelect:x})}),g.jsx(zr,{title:"Symbol Explorer",open:J,onToggle:()=>I(N=>!N),children:g.jsx(Xo,{symbolInput:c,onSymbolInputChange:f,onContext:H,onImpact:ge,contextData:b,impactData:E,gitNexusRunning:Fe,onSymbolSelect:x})})]}),j==="filters"&&g.jsx(No,{visibleNodeKinds:Le,visibleEdgeTypes:at,focusDepth:ot,onToggleNodeKind:Ye,onToggleEdgeType:je,onSetFocusDepth:Ue,symbolCounts:Ee,relationCounts:Ge})]}),g.jsx(Qo,{fullGraph:xe,contextGraph:m,selectedSymbol:o,onNodeClick:x,visibleNodeKinds:Le,visibleEdgeTypes:at,focusDepth:ot})]})]})}function zr({title:n,open:r,onToggle:t,children:e}){return g.jsxs("div",{className:"border-t border-edge",children:[g.jsxs("button",{onClick:t,className:"w-full flex items-center gap-2 px-3 py-2 text-xs font-medium text-muted hover:text-foreground hover:bg-surface-elevated transition-colors",children:[g.jsx("span",{className:"text-[10px]",children:r?"▾":"▸"}),n]}),r&&g.jsx("div",{className:"max-h-[300px] overflow-auto",children:e})]})}function qo({label:n,indexed:r,running:t,onAction:e,actionLoading:i}){const a=r?"var(--color-success)":"var(--color-text-muted)",o=r?`Indexed (${t?"active":"ready"})`:"Not indexed";return g.jsxs("span",{className:"inline-flex items-center gap-1",children:[g.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${a}20`,color:a},children:[n,": ",o]}),e&&g.jsx("button",{onClick:e,disabled:i,className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-accent text-white disabled:opacity-50 hover:opacity-90 transition-opacity",children:i?"Indexing...":"Reindex"})]})}function Ko({queryInput:n,onQueryChange:r,onSubmit:t,result:e,gitNexusRunning:i,onSymbolSelect:a}){return g.jsxs("div",{className:"p-4",children:[g.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Query Code Graph"}),!i&&g.jsx("div",{className:"mb-4 p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-elevated text-sm text-muted",children:"Code index not available. Click Reindex to enable code graph queries."}),g.jsxs("div",{className:"flex gap-2 mb-4",children:[g.jsx("input",{type:"text",value:n,onChange:o=>r(o.target.value),onKeyDown:o=>o.key==="Enter"&&t(),placeholder:"e.g., MATCH (n) RETURN n.name LIMIT 20",className:"flex-1 text-sm px-3 py-2 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt focus:outline-none focus:border-accent",disabled:!i}),g.jsx("button",{onClick:t,disabled:!i||e.loading,className:"text-sm px-4 py-2 rounded-lg bg-accent text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:e.loading?"...":"Query"})]}),e.error&&g.jsx("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-elevated text-sm text-danger",children:e.error}),e.data!=null&&g.jsx(Yo,{data:e.data,onSymbolSelect:a})]})}function Yo({data:n,onSymbolSelect:r}){return jt(n)?g.jsx(Li,{symbols:n.symbols,onSymbolSelect:r}):Ci(n)?g.jsx(Di,{impact:n,onSymbolSelect:r}):Co(n)?g.jsx(Nr,{data:n.result}):So(n)?g.jsx(Nr,{data:n}):g.jsx(Ro,{data:n})}function Li({symbols:n,onSymbolSelect:r}){const[t,e]=G.useState(0),i=50,a=Math.ceil(n.length/i),o=n.slice(t*i,(t+1)*i);return g.jsxs("div",{children:[g.jsxs("div",{className:"text-xs text-muted mb-2",children:[n.length," symbols found"]}),g.jsxs("table",{className:"w-full text-xs",children:[g.jsx("thead",{children:g.jsxs("tr",{className:"border-b border-edge text-left text-muted",children:[g.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Name"}),g.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Kind"}),g.jsx("th",{className:"py-1.5 px-2 font-medium",children:"File"}),g.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Lines"})]})}),g.jsx("tbody",{children:o.map(s=>g.jsxs("tr",{onClick:()=>r(s.name),className:"border-b border-edge hover:bg-surface-elevated cursor-pointer transition-colors",children:[g.jsx("td",{className:"py-1 px-2 font-medium",children:s.name}),g.jsx("td",{className:"py-1 px-2",children:g.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:`${we[s.kind]??"#9e9e9e"}20`,color:we[s.kind]??"#9e9e9e"},children:s.kind})}),g.jsx("td",{className:"py-1 px-2 text-muted truncate max-w-[200px]",children:s.file??"—"}),g.jsx("td",{className:"py-1 px-2 text-muted",children:s.startLine!=null?`${s.startLine}–${s.endLine??s.startLine}`:"—"})]},`${s.name}-${s.file??""}-${s.startLine??""}`))})]}),a>1&&g.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2 text-xs",children:[g.jsx("button",{onClick:()=>e(s=>Math.max(0,s-1)),disabled:t===0,className:"px-2 py-0.5 rounded bg-surface-elevated disabled:opacity-30",children:"Prev"}),g.jsxs("span",{className:"text-muted",children:[t+1," / ",a]}),g.jsx("button",{onClick:()=>e(s=>Math.min(a-1,s+1)),disabled:t>=a-1,className:"px-2 py-0.5 rounded bg-surface-elevated disabled:opacity-30",children:"Next"})]})]})}const Zo={low:"#4caf50",medium:"#ff9800",high:"#f44336"};function Di({impact:n,onSymbolSelect:r}){const t=Zo[n.riskLevel]??"#9e9e9e";return g.jsxs("div",{className:"rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt p-4",children:[g.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[g.jsxs("span",{className:"text-sm font-semibold",children:["Impact: ",n.symbol]}),g.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${t}20`,color:t},children:[n.riskLevel," risk"]})]}),g.jsxs("div",{className:"text-xs text-muted mb-2",children:[n.affectedSymbols.length," affected symbols"]}),g.jsx("div",{className:"space-y-1",children:n.affectedSymbols.map(e=>g.jsxs("button",{onClick:()=>r(e.name),className:"w-full text-left flex items-center justify-between px-2 py-1 rounded hover:bg-surface-elevated transition-colors text-xs",children:[g.jsx("span",{className:"font-medium",children:e.name}),g.jsxs("span",{className:"text-muted flex items-center gap-2",children:[g.jsx("span",{className:"truncate max-w-[150px]",children:e.file}),g.jsxs("span",{children:[Math.round(e.confidence*100),"%"]})]})]},`${e.name}-${e.file}`))})]})}function Xo({symbolInput:n,onSymbolInputChange:r,onContext:t,onImpact:e,contextData:i,impactData:a,gitNexusRunning:o,onSymbolSelect:s}){return g.jsxs("div",{className:"p-4",children:[g.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Symbol Explorer"}),!o&&g.jsx("div",{className:"mb-4 p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-elevated text-sm text-muted",children:"Code index not available. Click Reindex to explore symbols."}),g.jsxs("div",{className:"flex gap-2 mb-4",children:[g.jsx("input",{type:"text",value:n,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&t(n),placeholder:"e.g., SqliteStore, buildTaskContext",className:"flex-1 text-sm px-3 py-2 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt focus:outline-none focus:border-accent",disabled:!o}),g.jsx("button",{onClick:()=>t(n),disabled:!o||!n.trim(),className:"text-sm px-3 py-2 rounded-lg bg-accent text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:"Context"}),g.jsx("button",{onClick:()=>e(n),disabled:!o||!n.trim(),className:"text-sm px-3 py-2 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-elevated font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:"Impact"})]}),i&&g.jsxs("div",{className:"mb-4",children:[g.jsxs("h4",{className:"text-xs font-semibold mb-2 text-muted",children:["Context — ",i.symbols.length," symbols"]}),g.jsx(Li,{symbols:i.symbols,onSymbolSelect:s})]}),a&&g.jsx(Di,{impact:a,onSymbolSelect:s}),!i&&!a&&g.jsx("div",{className:"text-center text-muted text-sm py-8",children:"Enter a symbol name and click Context or Impact to explore"})]})}function Qo({fullGraph:n,contextGraph:r,selectedSymbol:t,onNodeClick:e,visibleNodeKinds:i,visibleEdgeTypes:a,focusDepth:o}){const[s,u]=G.useState(null);if(!n||n.symbols.length===0)return g.jsx("div",{className:"flex-1 min-w-0 flex items-center justify-center",style:{background:"#06060f"},children:g.jsxs("div",{className:"text-center text-[#3a3a5a]",children:[g.jsx("p",{className:"text-sm mb-1",children:"No symbol graph"}),g.jsx("p",{className:"text-xs",children:"Query or select a symbol to see its graph"})]})});const l=G.useMemo(()=>{const d=new Set;if(r)for(const c of r.symbols)d.add(c.name);return d},[r]),h=s??t;return g.jsxs("div",{className:"flex-1 min-w-0 relative",style:{background:"#06060f"},children:[g.jsx("div",{className:"absolute top-2 left-2 z-10 flex flex-wrap gap-1 rounded-lg px-2 py-1.5",style:{background:"#06060fdd"},children:Object.entries(we).map(([d,c])=>g.jsx("span",{className:"text-[8px] font-medium px-1.5 py-0.5 rounded-full",style:{background:`${c}20`,color:c,textShadow:`0 0 8px ${c}`},children:d},d))}),g.jsxs("div",{className:"absolute bottom-2 right-2 z-10 text-[9px]",style:{color:"#3a3a5a"},children:[n.symbols.length," nodes · ",n.relations.length," edges"]}),g.jsxs(mo,{style:{width:"100%",height:"100%",background:"#06060f"},settings:{defaultNodeColor:"#3a3a5a",defaultEdgeColor:"#151525",stagePadding:40,labelColor:{color:"#c0c0e0"},labelSize:11,labelFont:"monospace",labelWeight:"bold",labelRenderedSizeThreshold:10,labelDensity:.5,renderLabels:!0,renderEdgeLabels:!0,enableEdgeEvents:!1,defaultEdgeType:"arrow",edgeProgramClasses:{arrow:mi,line:Vo},defaultDrawNodeHover:es,defaultDrawNodeLabel:Jo,minEdgeThickness:.5,minCameraRatio:.05,maxCameraRatio:10,zIndex:!0},children:[g.jsx(ts,{fullGraph:n,highlightedNodes:l,selectedSymbol:t}),g.jsx(rs,{onNodeClick:e,onNodeHover:u,activeNode:h,highlightedNodes:l,visibleNodeKinds:i,visibleEdgeTypes:a,focusDepth:o,selectedSymbol:t})]})]})}function Jo(n,r,t){const{x:e,y:i,size:a,color:o,label:s}=r;if(!s)return;const u=t.labelSize;n.font=`${t.labelWeight} ${u}px ${t.labelFont}`,n.shadowColor=o,n.shadowBlur=6,n.fillStyle="#d0d0f0",n.fillText(s,e+a*1.5,i+u/3),n.shadowBlur=0}function es(n,r){const{x:t,y:e,size:i,color:a,label:o}=r,s=n.createRadialGradient(t,e,i*.5,t,e,i*6);s.addColorStop(0,ce(a,"80")),s.addColorStop(.3,ce(a,"30")),s.addColorStop(.6,ce(a,"10")),s.addColorStop(1,ce(a,"00")),n.beginPath(),n.arc(t,e,i*6,0,Math.PI*2),n.fillStyle=s,n.fill(),n.beginPath(),n.arc(t,e,i*1.5,0,Math.PI*2),n.fillStyle=a,n.fill(),n.beginPath(),n.arc(t,e,i*.5,0,Math.PI*2),n.fillStyle="#ffffff",n.fill(),o&&(n.font="bold 13px monospace",n.shadowColor=a,n.shadowBlur=12,n.fillStyle="#ffffff",n.fillText(o,t+i*2,e+4),n.shadowBlur=0)}function ts({fullGraph:n,highlightedNodes:r,selectedSymbol:t}){const e=po(),i=yt();return G.useEffect(()=>{const a=new X({type:"directed",multi:!1,allowSelfLoops:!1});for(const u of n.symbols)if(!a.hasNode(u.name)){const l=we[u.kind]??"#6a6a8a";a.addNode(u.name,{label:u.name,size:3,color:l,baseColor:l,kind:u.kind,x:Math.random()*200-100,y:Math.random()*200-100})}const o=new Set;for(const u of n.relations){const l=u.from??u.fromSymbol??"",h=u.to??u.toSymbol??"",d=`${l}\0${h}`;if(!l||!h||!a.hasNode(l)||!a.hasNode(h)||l===h||o.has(d))continue;o.add(d);const c=pt[u.type]??"#2a2a50";try{a.addEdge(l,h,{color:ce(c,"a0"),size:.5,baseColor:c,relType:u.type,label:Ur[u.type]??u.type,type:u.type==="belongs_to"?"line":"arrow"})}catch{}}a.order>0&&_o.assign(a,{iterations:a.order>500?250:180,settings:{gravity:.3,scalingRatio:a.order>200?8:4,barnesHutOptimize:a.order>50,barnesHutTheta:.5,strongGravityMode:!1,slowDown:3,adjustSizes:!0,linLogMode:!0,outboundAttractionDistribution:!0}}),e(a);const s=i.getGraph();s.forEachNode(u=>{const l=s.degree(u),h=Math.min(10,Math.max(1.5,1.5+Math.pow(l,.6)*.8));s.setNodeAttribute(u,"size",h)})},[n,e,i]),G.useEffect(()=>{const a=i.getGraph(),o=r.size>0;a.forEachNode(s=>{const u=a.getNodeAttribute(s,"baseColor")??"#6a6a8a",l=a.degree(s),h=r.has(s),d=s===t,c=o&&!h;if(d)a.setNodeAttribute(s,"size",14),a.setNodeAttribute(s,"zIndex",2);else if(h){const f=Math.min(10,Math.max(5,5+Math.sqrt(l)*1.2));a.setNodeAttribute(s,"size",f),a.setNodeAttribute(s,"zIndex",1)}else{const f=Math.min(10,Math.max(1.5,1.5+Math.pow(l,.6)*.8));a.setNodeAttribute(s,"size",f),a.setNodeAttribute(s,"zIndex",0)}d?a.setNodeAttribute(s,"color","#ffffff"):c?a.setNodeAttribute(s,"color",ce(u,"30")):a.setNodeAttribute(s,"color",u)}),a.forEachEdge((s,u,l,h)=>{const d=a.getEdgeAttribute(s,"baseColor")??"#2a2a50",c=r.has(l),f=r.has(h),b=t!=null&&(l===t||h===t),w=c&&f;b?(a.setEdgeAttribute(s,"color",ce(d,"f0")),a.setEdgeAttribute(s,"size",3),a.setEdgeAttribute(s,"zIndex",2)):w?(a.setEdgeAttribute(s,"color",ce(d,"90")),a.setEdgeAttribute(s,"size",1.5),a.setEdgeAttribute(s,"zIndex",1)):o&&!w&&!b?(a.setEdgeAttribute(s,"color",ce("#080815","20")),a.setEdgeAttribute(s,"size",.15),a.setEdgeAttribute(s,"zIndex",0)):(a.setEdgeAttribute(s,"color",ce(d,"50")),a.setEdgeAttribute(s,"size",.4),a.setEdgeAttribute(s,"zIndex",0))}),i.refresh()},[r,t,i]),null}function rs({onNodeClick:n,onNodeHover:r,activeNode:t,highlightedNodes:e,visibleNodeKinds:i,visibleEdgeTypes:a,focusDepth:o,selectedSymbol:s}){const u=go(),l=yt();return G.useEffect(()=>{u({clickNode:h=>{n(h.node)},enterNode:h=>{r(h.node)},leaveNode:()=>{r(null)}})},[u,n,r]),G.useEffect(()=>{const h=l.getGraph();let d=null;o!=null&&s&&h.hasNode(s)&&(d=Fo(h,s,o)),l.setSetting("nodeReducer",(c,f)=>{const b=h.getNodeAttribute(c,"kind");if(!i.has(b))return{...f,hidden:!0};if(d&&!d.has(c))return{...f,hidden:!0};if(t&&h.hasNode(t)){const w=new Set(h.neighbors(t));if(w.add(t),c===t)return{...f,color:"#ffffff",size:(f.size??3)*1.3,zIndex:3};if(w.has(c)){const E=h.getNodeAttribute(c,"baseColor")??"#6a6a8a";return{...f,color:E.startsWith("#")&&E.length>7?E.slice(0,7):E,zIndex:2}}if(e.size===0){const E=h.getNodeAttribute(c,"baseColor")??"#6a6a8a";return{...f,color:ce(E,"25"),zIndex:0}}{const E=f.color??"#6a6a8a";return{...f,color:E.startsWith("#")&&E.length>7?E.slice(0,7):E}}}return f}),l.setSetting("edgeReducer",(c,f)=>{const b=h.source(c),w=h.target(c),E=h.getEdgeAttribute(c,"relType");if(!a.has(E))return{...f,hidden:!0};const L=h.getNodeAttribute(b,"kind"),_=h.getNodeAttribute(w,"kind");if(!i.has(L)||!i.has(_))return{...f,hidden:!0};if(d&&(!d.has(b)||!d.has(w)))return{...f,hidden:!0};if(t&&h.hasNode(t)){if(b===t||w===t){const m=h.getEdgeAttribute(c,"baseColor")??"#4a4a7a";return{...f,color:ce(m,"f0"),size:3,zIndex:2,forceLabel:!0}}if(e.size===0)return{...f,color:"#1e1e3a",size:.2,zIndex:0}}return f})},[t,e,i,a,o,s,l]),null}export{as as GitNexusTab};
|