@mcp-graph-workflow/mcp-graph 3.0.0 → 4.1.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/README.md +14 -4
- package/dist/api/middleware/validate.d.ts.map +1 -1
- package/dist/api/middleware/validate.js.map +1 -1
- package/dist/api/router.d.ts +1 -2
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js.map +1 -1
- package/dist/api/routes/edges.js.map +1 -1
- package/dist/api/routes/import.d.ts.map +1 -1
- package/dist/api/routes/import.js +4 -1
- package/dist/api/routes/import.js.map +1 -1
- package/dist/api/routes/integrations.js.map +1 -1
- package/dist/api/routes/rag.js.map +1 -1
- package/dist/cli/commands/import-cmd.d.ts.map +1 -1
- package/dist/cli/commands/import-cmd.js +6 -3
- package/dist/cli/commands/import-cmd.js.map +1 -1
- package/dist/cli/commands/index-cmd.d.ts.map +1 -1
- package/dist/cli/commands/index-cmd.js +11 -7
- package/dist/cli/commands/index-cmd.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +6 -3
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/serve.js +2 -1
- package/dist/cli/commands/serve.js.map +1 -1
- package/dist/cli/commands/stats.d.ts.map +1 -1
- package/dist/cli/commands/stats.js +13 -9
- package/dist/cli/commands/stats.js.map +1 -1
- package/dist/cli/index.js +7 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/core/capture/web-capture.d.ts.map +1 -1
- package/dist/core/capture/web-capture.js +5 -4
- package/dist/core/capture/web-capture.js.map +1 -1
- package/dist/core/context/context-assembler.d.ts.map +1 -1
- package/dist/core/context/context-assembler.js.map +1 -1
- package/dist/core/context/rag-context.d.ts.map +1 -1
- package/dist/core/context/rag-context.js.map +1 -1
- package/dist/core/importer/prd-to-graph.d.ts.map +1 -1
- package/dist/core/importer/prd-to-graph.js +1 -2
- package/dist/core/importer/prd-to-graph.js.map +1 -1
- package/dist/core/insights/bottleneck-detector.d.ts.map +1 -1
- package/dist/core/parser/file-reader.d.ts.map +1 -1
- package/dist/core/parser/file-reader.js +2 -1
- package/dist/core/parser/file-reader.js.map +1 -1
- package/dist/core/planner/lifecycle-phase.js +1 -1
- package/dist/core/planner/lifecycle-phase.js.map +1 -1
- package/dist/core/rag/embedding-store.d.ts.map +1 -1
- package/dist/core/rag/embedding-store.js.map +1 -1
- package/dist/core/rag/serena-indexer.js +1 -1
- package/dist/core/rag/serena-indexer.js.map +1 -1
- package/dist/core/search/fts-search.js +1 -1
- package/dist/core/search/fts-search.js.map +1 -1
- package/dist/core/store/sqlite-store.d.ts.map +1 -1
- package/dist/core/store/sqlite-store.js.map +1 -1
- package/dist/mcp/init-project.js +2 -2
- package/dist/mcp/init-project.js.map +1 -1
- package/dist/mcp/tools/update-node.js.map +1 -1
- package/package.json +10 -3
- package/dist/web/dashboard/dist/assets/benchmark-tab-BTKW3REK.js +0 -1
- package/dist/web/dashboard/dist/assets/benchmark-tab-BhbUvjLM.js +0 -1
- package/dist/web/dashboard/dist/assets/benchmark-tab-D64Ala80.js +0 -1
- package/dist/web/dashboard/dist/assets/benchmark-tab-DJ7HyF-u.js +0 -1
- package/dist/web/dashboard/dist/assets/benchmark-tab-DVyzQZ2d.js +0 -1
- package/dist/web/dashboard/dist/assets/benchmark-tab-XUH7yQNv.js +0 -1
- package/dist/web/dashboard/dist/assets/benchmark-tab-ZfJu1pxc.js +0 -1
- package/dist/web/dashboard/dist/assets/gitnexus-tab-BFHEXsJm.js +0 -312
- package/dist/web/dashboard/dist/assets/gitnexus-tab-Bbp91fom.js +0 -312
- package/dist/web/dashboard/dist/assets/gitnexus-tab-C3fPSzYi.js +0 -312
- package/dist/web/dashboard/dist/assets/gitnexus-tab-Cd0k8qk3.js +0 -312
- package/dist/web/dashboard/dist/assets/gitnexus-tab-Cuc-KSII.js +0 -312
- package/dist/web/dashboard/dist/assets/gitnexus-tab-DEwJXSnD.js +0 -312
- package/dist/web/dashboard/dist/assets/gitnexus-tab-DOD7xwmm.js +0 -312
- package/dist/web/dashboard/dist/assets/graph-tab-AD7csRcc.js +0 -1
- package/dist/web/dashboard/dist/assets/graph-tab-BKyDCyHH.js +0 -1
- package/dist/web/dashboard/dist/assets/graph-tab-D0F0WJES.js +0 -1
- package/dist/web/dashboard/dist/assets/graph-tab-DA16nThT.js +0 -1
- package/dist/web/dashboard/dist/assets/graph-tab-DJknUhrl.js +0 -1
- package/dist/web/dashboard/dist/assets/graph-tab-DRPfelKw.js +0 -1
- package/dist/web/dashboard/dist/assets/graph-tab-lJ2rPS4Z.js +0 -1
- package/dist/web/dashboard/dist/assets/graph-utils-BN7tt0ZS.js +0 -23
- package/dist/web/dashboard/dist/assets/graph-utils-BTV1KGUM.js +0 -23
- package/dist/web/dashboard/dist/assets/graph-utils-BkfAOVJ9.js +0 -23
- package/dist/web/dashboard/dist/assets/graph-utils-Bo7cD1sx.js +0 -23
- package/dist/web/dashboard/dist/assets/graph-utils-CI4znRl5.js +0 -23
- package/dist/web/dashboard/dist/assets/graph-utils-DrCx5m7q.js +0 -23
- package/dist/web/dashboard/dist/assets/graph-utils-KQmzMFXM.js +0 -23
- package/dist/web/dashboard/dist/assets/index-BGMP3W6f.css +0 -1
- package/dist/web/dashboard/dist/assets/index-BVXu3x9W.js +0 -53
- package/dist/web/dashboard/dist/assets/index-B_T9j86O.js +0 -53
- package/dist/web/dashboard/dist/assets/index-Bga9WW2A.css +0 -1
- package/dist/web/dashboard/dist/assets/index-BonF71I0.js +0 -53
- package/dist/web/dashboard/dist/assets/index-CSyjxREL.js +0 -53
- package/dist/web/dashboard/dist/assets/index-CbUKe2Fv.js +0 -53
- package/dist/web/dashboard/dist/assets/index-DzM6oBA3.js +0 -53
- package/dist/web/dashboard/dist/assets/index-IK005MzD.js +0 -53
- package/dist/web/dashboard/dist/assets/insights-tab-B9R3HsMU.js +0 -1
- package/dist/web/dashboard/dist/assets/insights-tab-BO_cxLyV.js +0 -1
- package/dist/web/dashboard/dist/assets/insights-tab-Brn6IMfQ.js +0 -1
- package/dist/web/dashboard/dist/assets/insights-tab-C6x-aJ8p.js +0 -1
- package/dist/web/dashboard/dist/assets/insights-tab-CapL1jP-.js +0 -1
- package/dist/web/dashboard/dist/assets/insights-tab-CeWM6zgV.js +0 -1
- package/dist/web/dashboard/dist/assets/insights-tab-xQj5e61M.js +0 -1
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-0oOO63rA.js +0 -1
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-BcWoplsM.js +0 -1
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-Bjj5KccG.js +0 -1
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-C7cKQyup.js +0 -1
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-CT4ja7Ay.js +0 -1
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-CmPHHBDQ.js +0 -1
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-_jmBe3MU.js +0 -1
- package/dist/web/dashboard/dist/assets/serena-tab-BVyBTaHC.js +0 -1
- package/dist/web/dashboard/dist/assets/serena-tab-CVI1GGRk.js +0 -1
- package/dist/web/dashboard/dist/assets/serena-tab-D1ki2NjT.js +0 -1
- package/dist/web/dashboard/dist/assets/serena-tab-DRrRfjpO.js +0 -1
- package/dist/web/dashboard/dist/assets/serena-tab-DvYbwR4Z.js +0 -1
- package/dist/web/dashboard/dist/assets/serena-tab-L6isY0iT.js +0 -1
- package/dist/web/dashboard/dist/assets/serena-tab-ba2n0AOh.js +0 -1
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
import{g as Tr,r as M,t as ft,j as E,a as _e}from"./index-DzM6oBA3.js";import{C as st,b as mi}from"./constants-BIEJOBya.js";var et={exports:{}},jt;function vi(){if(jt)return et.exports;jt=1;var n=typeof Reflect=="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(v,S,T){return Function.prototype.apply.call(v,S,T)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:t=function(v){return Object.getOwnPropertyNames(v)};function e(m){console&&console.warn&&console.warn(m)}var i=Number.isNaN||function(v){return v!==v};function a(){a.init.call(this)}et.exports=a,et.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(v){if(typeof v!="number"||v<0||i(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function u(m){return m._maxListeners===void 0?a.defaultMaxListeners:m._maxListeners}a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(v){for(var S=[],T=1;T<arguments.length;T++)S.push(arguments[T]);var I=v==="error",P=this._events;if(P!==void 0)I=I&&P.error===void 0;else if(!I)return!1;if(I){var N;if(S.length>0&&(N=S[0]),N instanceof Error)throw N;var q=new Error("Unhandled error."+(N?" ("+N.message+")":""));throw q.context=N,q}var U=P[v];if(U===void 0)return!1;if(typeof U=="function")r(U,this,S);else for(var f=U.length,K=b(U,f),T=0;T<f;++T)r(K[T],this,S);return!0};function h(m,v,S,T){var I,P,N;if(s(S),P=m._events,P===void 0?(P=m._events=Object.create(null),m._eventsCount=0):(P.newListener!==void 0&&(m.emit("newListener",v,S.listener?S.listener:S),P=m._events),N=P[v]),N===void 0)N=P[v]=S,++m._eventsCount;else if(typeof N=="function"?N=P[v]=T?[S,N]:[N,S]:T?N.unshift(S):N.push(S),I=u(m),I>0&&N.length>I&&!N.warned){N.warned=!0;var q=new Error("Possible EventEmitter memory leak detected. "+N.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");q.name="MaxListenersExceededWarning",q.emitter=m,q.type=v,q.count=N.length,e(q)}return m}a.prototype.addListener=function(v,S){return h(this,v,S,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(v,S){return h(this,v,S,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(m,v,S){var T={fired:!1,wrapFn:void 0,target:m,type:v,listener:S},I=d.bind(T);return I.listener=S,T.wrapFn=I,I}a.prototype.once=function(v,S){return s(S),this.on(v,l(this,v,S)),this},a.prototype.prependOnceListener=function(v,S){return s(S),this.prependListener(v,l(this,v,S)),this},a.prototype.removeListener=function(v,S){var T,I,P,N,q;if(s(S),I=this._events,I===void 0)return this;if(T=I[v],T===void 0)return this;if(T===S||T.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete I[v],I.removeListener&&this.emit("removeListener",v,T.listener||S));else if(typeof T!="function"){for(P=-1,N=T.length-1;N>=0;N--)if(T[N]===S||T[N].listener===S){q=T[N].listener,P=N;break}if(P<0)return this;P===0?T.shift():w(T,P),T.length===1&&(I[v]=T[0]),I.removeListener!==void 0&&this.emit("removeListener",v,q||S)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(v){var S,T,I;if(T=this._events,T===void 0)return this;if(T.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):T[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete T[v]),this;if(arguments.length===0){var P=Object.keys(T),N;for(I=0;I<P.length;++I)N=P[I],N!=="removeListener"&&this.removeAllListeners(N);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=T[v],typeof S=="function")this.removeListener(v,S);else if(S!==void 0)for(I=S.length-1;I>=0;I--)this.removeListener(v,S[I]);return this};function c(m,v,S){var T=m._events;if(T===void 0)return[];var I=T[v];return I===void 0?[]:typeof I=="function"?S?[I.listener||I]:[I]:S?_(I):b(I,I.length)}a.prototype.listeners=function(v){return c(this,v,!0)},a.prototype.rawListeners=function(v){return c(this,v,!1)},a.listenerCount=function(m,v){return typeof m.listenerCount=="function"?m.listenerCount(v):g.call(m,v)},a.prototype.listenerCount=g;function g(m){var v=this._events;if(v!==void 0){var S=v[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,v){for(var S=new Array(v),T=0;T<v;++T)S[T]=m[T];return S}function w(m,v){for(;v+1<m.length;v++)m[v]=m[v+1];m.pop()}function _(m){for(var v=new Array(m.length),S=0;S<v.length;++S)v[S]=m[S].listener||m[S];return v}function L(m,v){return new Promise(function(S,T){function I(N){m.removeListener(v,P),T(N)}function P(){typeof m.removeListener=="function"&&m.removeListener("error",I),S([].slice.call(arguments))}k(m,v,P,{once:!0}),v!=="error"&&C(m,I,{once:!0})})}function C(m,v,S){typeof m.on=="function"&&k(m,"error",v,S)}function k(m,v,S,T){if(typeof m.on=="function")T.once?m.once(v,S):m.on(v,S);else if(typeof m.addEventListener=="function")m.addEventListener(v,function I(P){T.once&&m.removeEventListener(v,I),S(P)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof m)}return et.exports}var Ar=vi();function yi(){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 J=yi;typeof Object.assign=="function"&&(J=Object.assign);function se(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 te(n){return typeof n=="object"&&n!==null}function kr(n){let r;for(r in n)return!1;return!0}function oe(n,r,t){Object.defineProperty(n,r,{enumerable:!1,configurable:!1,writable:!0,value:t})}function de(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 Mt(n){return!(!te(n)||n.attributes&&!Array.isArray(n.attributes))}function bi(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function ve(){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 Ge(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Ft extends Error{constructor(r){super(),this.name="GraphError",this.message=r}}class D extends Ft{constructor(r){super(r),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}class R extends Ft{constructor(r){super(r),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,R.prototype.constructor)}}class O extends Ft{constructor(r){super(r),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,O.prototype.constructor)}}function Rr(n,r){this.key=n,this.attributes=r,this.clear()}Rr.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 Lr(n,r){this.key=n,this.attributes=r,this.clear()}Lr.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Dr(n,r){this.key=n,this.attributes=r,this.clear()}Dr.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Ne(n,r,t,e,i){this.key=r,this.attributes=i,this.undirected=n,this.source=t,this.target=e}Ne.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)};Ne.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};Ne.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]};Ne.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 Gr=0,Nr=1,wi=2,Fr=3;function ye(n,r,t,e,i,a,o){let s,u,h,d;if(e=""+e,t===Gr){if(s=n._nodes.get(e),!s)throw new R(`Graph.${r}: could not find the "${e}" node in the graph.`);h=i,d=a}else if(t===Fr){if(i=""+i,u=n._edges.get(i),!u)throw new R(`Graph.${r}: could not find the "${i}" edge in the graph.`);const l=u.source.key,c=u.target.key;if(e===l)s=u.target;else if(e===c)s=u.source;else throw new R(`Graph.${r}: the "${e}" node is not attached to the "${i}" edge (${l}, ${c}).`);h=a,d=o}else{if(u=n._edges.get(e),!u)throw new R(`Graph.${r}: could not find the "${e}" edge in the graph.`);t===Nr?s=u.source:s=u.target,h=i,d=a}return[s,h,d]}function Ei(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=ye(this,r,t,e,i,a);return o.attributes[s]}}function xi(n,r,t){n.prototype[r]=function(e,i){const[a]=ye(this,r,t,e,i);return a.attributes}}function _i(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=ye(this,r,t,e,i,a);return o.attributes.hasOwnProperty(s)}}function Si(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,h]=ye(this,r,t,e,i,a,o);return s.attributes[u]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Ci(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,h]=ye(this,r,t,e,i,a,o);if(typeof h!="function")throw new D(`Graph.${r}: updater should be a function.`);const d=s.attributes,l=h(d[u]);return d[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Ti(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=ye(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 Ai(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=ye(this,r,t,e,i,a);if(!te(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]=ye(this,r,t,e,i,a);if(!te(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return J(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Ri(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=ye(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 Li=[{name:n=>`get${n}Attribute`,attacher:Ei},{name:n=>`get${n}Attributes`,attacher:xi},{name:n=>`has${n}Attribute`,attacher:_i},{name:n=>`set${n}Attribute`,attacher:Si},{name:n=>`update${n}Attribute`,attacher:Ci},{name:n=>`remove${n}Attribute`,attacher:Ti},{name:n=>`replace${n}Attributes`,attacher:Ai},{name:n=>`merge${n}Attributes`,attacher:ki},{name:n=>`update${n}Attributes`,attacher:Ri}];function Di(n){Li.forEach(function({name:r,attacher:t}){t(n,r("Node"),Gr),t(n,r("Source"),Nr),t(n,r("Target"),wi),t(n,r("Opposite"),Fr)})}function Gi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=se(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes[i]}}function Ni(n,r,t){n.prototype[r]=function(e){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new O(`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=se(this,a,o,t),!i)throw new R(`Graph.${r}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return i.attributes}}function Fi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=se(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function Pi(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new O(`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=se(this,s,u,t),!o)throw new R(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 Ii(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new O(`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=se(this,s,u,t),!o)throw new R(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 zi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=se(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 Oi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=se(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!te(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 $i(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=se(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!te(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return J(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function Ui(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=se(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 ji=[{name:n=>`get${n}Attribute`,attacher:Gi},{name:n=>`get${n}Attributes`,attacher:Ni},{name:n=>`has${n}Attribute`,attacher:Fi},{name:n=>`set${n}Attribute`,attacher:Pi},{name:n=>`update${n}Attribute`,attacher:Ii},{name:n=>`remove${n}Attribute`,attacher:zi},{name:n=>`replace${n}Attributes`,attacher:Oi},{name:n=>`merge${n}Attributes`,attacher:$i},{name:n=>`update${n}Attributes`,attacher:Ui}];function Mi(n){ji.forEach(function({name:r,attacher:t}){t(n,r("Edge"),"mixed"),t(n,r("DirectedEdge"),"directed"),t(n,r("UndirectedEdge"),"undirected")})}const Bi=[{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 Hi(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 Wi(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 gt(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 Vi(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 qi(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 pt(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 Ki(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 Pr(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 h=r._edges.values();for(;o=h.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;const{key:d,attributes:l,source:c,target:g}=s;if(u=e(d,l,c.key,g.key,c.attributes,g.attributes,s.undirected),n&&u)return d}}function Yi(n,r){if(n.size===0)return Ge();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 Pt(n,r,t,e,i,a){const o=r?Wi:Hi;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 Zi(n,r,t,e){const i=[];return Pt(!1,n,r,t,e,function(a){i.push(a)}),i}function Xi(n,r,t){let e=Ge();return n!=="undirected"&&(r!=="out"&&typeof t.in<"u"&&(e=ve(e,gt(t.in))),r!=="in"&&typeof t.out<"u"&&(e=ve(e,gt(t.out,r?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(e=ve(e,gt(t.undirected))),e}function It(n,r,t,e,i,a,o){const s=t?qi:Vi;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 Qi(n,r,t,e,i){const a=[];return It(!1,n,r,t,e,i,function(o){a.push(o)}),a}function Ji(n,r,t,e){let i=Ge();return n!=="undirected"&&(typeof t.in<"u"&&r!=="out"&&e in t.in&&(i=ve(i,pt(t.in,e))),typeof t.out<"u"&&r!=="in"&&e in t.out&&(r||t.key!==e)&&(i=ve(i,pt(t.out,e)))),n!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(i=ve(i,pt(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 Ki(this,e);if(arguments.length===1){a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new R(`Graph.${t}: could not find the "${a}" node in the graph.`);return Zi(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 R(`Graph.${t}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new R(`Graph.${t}: could not find the "${o}" target node in the graph.`);return Qi(e,this.multi,i,s,o)}throw new D(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function tn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(h,d,l){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return l=h,Pr(!1,this,e,l);if(arguments.length===2){h=""+h,l=d;const c=this._nodes.get(h);if(typeof c>"u")throw new R(`Graph.${a}: could not find the "${h}" node in the graph.`);return Pt(!1,this.multi,e==="mixed"?this.type:e,i,c,l)}if(arguments.length===3){h=""+h,d=""+d;const c=this._nodes.get(h);if(!c)throw new R(`Graph.${a}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(d))throw new R(`Graph.${a}: could not find the "${d}" target node in the graph.`);return It(!1,e,this.multi,i,c,d,l)}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 h=Array.prototype.slice.call(arguments),d=h.pop();let l;if(h.length===0){let c=0;e!=="directed"&&(c+=this.undirectedSize),e!=="undirected"&&(c+=this.directedSize),l=new Array(c);let g=0;h.push((b,w,_,L,C,k,m)=>{l[g++]=d(b,w,_,L,C,k,m)})}else l=[],h.push((c,g,b,w,_,L,C)=>{l.push(d(c,g,b,w,_,L,C))});return this[a].apply(this,h),l};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),d=h.pop(),l=[];return h.push((c,g,b,w,_,L,C)=>{d(c,g,b,w,_,L,C)&&l.push(c)}),this[a].apply(this,h),l};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(){let h=Array.prototype.slice.call(arguments);if(h.length<2||h.length>4)throw new D(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${h.length}).`);if(typeof h[h.length-1]=="function"&&typeof h[h.length-2]!="function")throw new 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 d,l;h.length===2?(d=h[0],l=h[1],h=[]):h.length===3?(d=h[1],l=h[2],h=[h[0]]):h.length===4&&(d=h[2],l=h[3],h=[h[0],h[1]]);let c=l;return h.push((g,b,w,_,L,C,k)=>{c=d(c,g,b,w,_,L,C,k)}),this[a].apply(this,h),c}}function rn(n,r){const{name:t,type:e,direction:i}=r,a="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(u,h,d){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return d=u,Pr(!0,this,e,d);if(arguments.length===2){u=""+u,d=h;const l=this._nodes.get(u);if(typeof l>"u")throw new R(`Graph.${a}: could not find the "${u}" node in the graph.`);return Pt(!0,this.multi,e==="mixed"?this.type:e,i,l,d)}if(arguments.length===3){u=""+u,h=""+h;const l=this._nodes.get(u);if(!l)throw new R(`Graph.${a}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(h))throw new R(`Graph.${a}: could not find the "${h}" target node in the graph.`);return It(!0,e,this.multi,i,l,h,d)}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),h=u.pop();return u.push((l,c,g,b,w,_,L)=>h(l,c,g,b,w,_,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),h=u.pop();return u.push((l,c,g,b,w,_,L)=>!h(l,c,g,b,w,_,L)),!this[a].apply(this,u)}}function nn(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 Ge();if(!arguments.length)return Yi(this,e);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(!u)throw new R(`Graph.${a}: could not find the "${o}" node in the graph.`);return Xi(e,i,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new R(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new R(`Graph.${a}: could not find the "${s}" target node in the graph.`);return Ji(e,i,u,s)}throw new D(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function an(n){Bi.forEach(r=>{en(n,r),tn(n,r),rn(n,r),nn(n,r)})}const on=[{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 ut(){this.A=null,this.B=null}ut.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};ut.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function Oe(n,r,t,e,i){for(const a in e){const o=e[a],s=o.source,u=o.target,h=s===t?u:s;if(r&&r.has(h.key))continue;const d=i(h.key,h.attributes);if(n&&d)return h.key}}function zt(n,r,t,e,i){if(r!=="mixed"){if(r==="undirected")return Oe(n,null,e,e.undirected,i);if(typeof t=="string")return Oe(n,null,e,e[t],i)}const a=new ut;let o;if(r!=="undirected"){if(t!=="out"){if(o=Oe(n,null,e,e.in,i),n&&o)return o;a.wrap(e.in)}if(t!=="in"){if(o=Oe(n,a,e,e.out,i),n&&o)return o;a.wrap(e.out)}}if(r!=="directed"&&(o=Oe(n,a,e,e.undirected,i),n&&o))return o}function sn(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 zt(!1,n,r,t,function(i){e.push(i)}),e}function $e(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,h=s.target;if(o=u===r?h:u,n&&n.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function un(n,r,t){if(n!=="mixed"){if(n==="undirected")return $e(null,t,t.undirected);if(typeof r=="string")return $e(null,t,t[r])}let e=Ge();const i=new ut;return n!=="undirected"&&(r!=="out"&&(e=ve(e,$e(i,t,t.in))),r!=="in"&&(e=ve(e,$e(i,t,t.out)))),n!=="directed"&&(e=ve(e,$e(i,t,t.undirected))),e}function hn(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 R(`Graph.${t}: could not find the "${a}" node in the graph.`);return sn(e==="mixed"?this.type:e,i,o)}}function dn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(h,d){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const l=this._nodes.get(h);if(typeof l>"u")throw new R(`Graph.${a}: could not find the "${h}" node in the graph.`);zt(!1,e==="mixed"?this.type:e,i,l,d)};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(h,d){const l=[];return this[a](h,(c,g)=>{l.push(d(c,g))}),l};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(h,d){const l=[];return this[a](h,(c,g)=>{d(c,g)&&l.push(c)}),l};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(h,d,l){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=l;return this[a](h,(g,b)=>{c=d(c,g,b)}),c}}function ln(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(h,d){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const l=this._nodes.get(h);if(typeof l>"u")throw new R(`Graph.${o}: could not find the "${h}" node in the graph.`);return zt(!0,e==="mixed"?this.type:e,i,l,d)};const s="some"+a;n.prototype[s]=function(h,d){return!!this[o](h,d)};const u="every"+a;n.prototype[u]=function(h,d){return!this[o](h,(c,g)=>!d(c,g))}}function cn(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 Ge();o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new R(`Graph.${a}: could not find the "${o}" node in the graph.`);return un(e==="mixed"?this.type:e,i,s)}}function fn(n){on.forEach(r=>{hn(n,r),dn(n,r),ln(n,r),cn(n,r)})}function tt(n,r,t,e,i){const a=e._nodes.values(),o=e.type;let s,u,h,d,l,c;for(;s=a.next(),s.done!==!0;){let g=!1;if(u=s.value,o!=="undirected"){d=u.out;for(h in d){l=d[h];do c=l.target,g=!0,i(u.key,c.key,u.attributes,c.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}if(o!=="directed"){d=u.undirected;for(h in d)if(!(r&&u.key>h)){l=d[h];do c=l.target,c.key!==h&&(c=l.source),g=!0,i(u.key,c.key,u.attributes,c.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}t&&!g&&i(u.key,null,u.attributes,null,null,null,null)}}function gn(n,r){const t={key:n};return kr(r.attributes)||(t.attributes=J({},r.attributes)),t}function pn(n,r,t){const e={key:r,source:t.source.key,target:t.target.key};return kr(t.attributes)||(e.attributes=J({},t.attributes)),n==="mixed"&&t.undirected&&(e.undirected=!0),e}function mn(n){if(!te(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&&(!te(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function vn(n){if(!te(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&&(!te(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 yn=bi(),bn=new Set(["directed","undirected","mixed"]),Bt=new Set(["domain","_events","_eventsCount","_maxListeners"]),wn=[{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"}],En={allowSelfLoops:!0,multi:!1,type:"mixed"};function xn(n,r,t){if(t&&!te(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 O(`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 Ht(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 Ir(n,r,t,e,i,a,o,s){if(!e&&n.type==="undirected")throw new O(`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 O(`Graph.${r}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!te(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 O(`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),h=n._nodes.get(o);if(!u)throw new R(`Graph.${r}: source node "${a}" not found.`);if(!h)throw new R(`Graph.${r}: target node "${o}" not found.`);const d={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 O(`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 O(`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 l=new Ne(e,i,u,h,s);n._edges.set(i,l);const c=a===o;return e?(u.undirectedDegree++,h.undirectedDegree++,c&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,c&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?l.attachMulti():l.attach(),e?n._undirectedSize++:n._directedSize++,d.key=i,n.emit("edgeAdded",d),i}function _n(n,r,t,e,i,a,o,s,u){if(!e&&n.type==="undirected")throw new O(`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 O(`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(!te(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let h;if(u&&(h=s,s=void 0),!n.allowSelfLoops&&a===o)throw new O(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=n._nodes.get(a),l=n._nodes.get(o),c,g;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 O(`Graph.${r}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${c.source.key}", "${c.target.key}").`);g=c}if(!g&&!n.multi&&d&&(g=e?d.undirected[o]:d.out[o]),g){const C=[g.key,!1,!1,!1];if(u?!h:!s)return C;if(u){const k=g.attributes;g.attributes=h(k),n.emit("edgeAttributesUpdated",{type:"replace",key:g.key,attributes:g.attributes})}else J(g.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:g.key,attributes:g.attributes,data:s});return C}s=s||{},u&&h&&(s=h(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 O(`Graph.${r}: the "${i}" edge already exists in the graph.`);let w=!1,_=!1;d||(d=Ht(n,a,{}),w=!0,a===o&&(l=d,_=!0)),l||(l=Ht(n,o,{}),_=!0),c=new Ne(e,i,d,l,s),n._edges.set(i,c);const L=a===o;return e?(d.undirectedDegree++,l.undirectedDegree++,L&&(d.undirectedLoops++,n._undirectedSelfLoopCount++)):(d.outDegree++,l.inDegree++,L&&(d.directedLoops++,n._directedSelfLoopCount++)),n.multi?c.attachMulti():c.attach(),e?n._undirectedSize++:n._directedSize++,b.key=i,n.emit("edgeAdded",b),[i,!0,w,_]}function ke(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 V extends Ar.EventEmitter{constructor(r){if(super(),r=J({},En,r),typeof r.multi!="boolean")throw new D(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${r.multi}".`);if(!bn.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"?Rr:r.type==="directed"?Lr:Dr;oe(this,"NodeDataClass",t);const e="geid_"+yn()+"_";let i=0;const a=()=>{let o;do o=e+i++;while(this._edges.has(o));return o};oe(this,"_attributes",{}),oe(this,"_nodes",new Map),oe(this,"_edges",new Map),oe(this,"_directedSize",0),oe(this,"_undirectedSize",0),oe(this,"_directedSelfLoopCount",0),oe(this,"_undirectedSelfLoopCount",0),oe(this,"_edgeKeyGenerator",a),oe(this,"_options",r),Bt.forEach(o=>oe(this,o,this[o])),de(this,"order",()=>this._nodes.size),de(this,"size",()=>this._edges.size),de(this,"directedSize",()=>this._directedSize),de(this,"undirectedSize",()=>this._undirectedSize),de(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),de(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),de(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),de(this,"multi",this._options.multi),de(this,"type",this._options.type),de(this,"allowSelfLoops",this._options.allowSelfLoops),de(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 O("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 R(`Graph.directedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new R(`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 O("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 R(`Graph.undirectedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new R(`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 O("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 R(`Graph.edge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`Graph.isSelfLoop: could not find the "${r}" edge in the graph.`);return t.source===t.target}addNode(r,t){return xn(this,r,t).key}mergeNode(r,t){if(t&&!te(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&&(J(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 R(`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 ke(this,e),e=e.next;while(e)}for(const i in t.in){e=t.in[i];do ke(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const i in t.undirected){e=t.undirected[i];do ke(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=se(this,e,i,this.type),!t)throw new R(`Graph.dropEdge: could not find the "${e}" -> "${i}" edge in the graph.`)}else if(r=""+r,t=this._edges.get(r),!t)throw new R(`Graph.dropEdge: could not find the "${r}" edge in the graph.`);return ke(this,t),this}dropDirectedEdge(r,t){if(arguments.length<2)throw new O("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 O("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=se(this,r,t,"directed");if(!e)throw new R(`Graph.dropDirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return ke(this,e),this}dropUndirectedEdge(r,t){if(arguments.length<2)throw new O("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 O("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=se(this,r,t,"undirected");if(!e)throw new R(`Graph.dropUndirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return ke(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(!te(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(!te(r))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return J(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&&!Mt(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&&!Mt(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.");tt(!1,!1,!1,this,r)}forEachAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");tt(!1,!1,!0,this,r)}forEachAssymetricAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");tt(!1,!0,!1,this,r)}forEachAssymetricAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");tt(!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++]=gn(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 V)return r.forEachNode((u,h)=>{t?this.mergeNode(u,h):this.addNode(u,h)}),r.forEachEdge((u,h,d,l,c,g,b)=>{t?b?this.mergeUndirectedEdgeWithKey(u,d,l,h):this.mergeDirectedEdgeWithKey(u,d,l,h):b?this.addUndirectedEdgeWithKey(u,d,l,h):this.addDirectedEdgeWithKey(u,d,l,h)}),this;if(!te(r))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!te(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],mn(o);const{key:u,attributes:h}=o;t?this.mergeNode(u,h):this.addNode(u,h)}}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],vn(s);const{source:h,target:d,attributes:l,undirected:c=u}=s;let g;"key"in s?(g=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,g.call(this,s.key,h,d,l)):(g=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,g.call(this,h,d,l))}}return this}nullCopy(r){const t=new V(J({},this._options,r));return t.replaceAttributes(J({},this.getAttributes())),t}emptyCopy(r){const t=this.nullCopy(r);return this._nodes.forEach((e,i)=>{const a=J({},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 O(`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 O("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 O("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,Ir(t,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,J({},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="",h=a.source.key,d=a.target.key,l;a.undirected&&h>d&&(l=h,h=d,d=l);const c=`(${h})${s}(${d})`;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)&&!Bt.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=r,i.edges=t,oe(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(V.prototype[Symbol.for("nodejs.util.inspect.custom")]=V.prototype.inspect);wn.forEach(n=>{["add","merge","update"].forEach(r=>{const t=n.name(r),e=r==="add"?Ir:_n;n.generateKey?V.prototype[t]=function(i,a,o){return e(this,t,!0,(n.type||this.type)==="undirected",null,i,a,o,r==="update")}:V.prototype[t]=function(i,a,o,s){return e(this,t,!1,(n.type||this.type)==="undirected",i,a,o,s,r==="update")}})});Di(V);Mi(V);an(V);fn(V);class zr extends V{constructor(r){const t=J({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 Or extends V{constructor(r){const t=J({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 $r extends V{constructor(r){const t=J({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 Ur extends V{constructor(r){const t=J({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 jr extends V{constructor(r){const t=J({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 Fe(n){n.from=function(r,t){const e=J({},r.options,t),i=new n(e);return i.import(r),i}}Fe(V);Fe(zr);Fe(Or);Fe($r);Fe(Ur);Fe(jr);V.Graph=V;V.DirectedGraph=zr;V.UndirectedGraph=Or;V.MultiGraph=$r;V.MultiDirectedGraph=Ur;V.MultiUndirectedGraph=jr;V.InvalidArgumentsGraphError=D;V.NotFoundGraphError=R;V.UsageGraphError=O;function Sn(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 We(n){var r=Sn(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 Wt(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,We(e.key),e)}}function ie(n,r,t){return r&&Wt(n.prototype,r),t&&Wt(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function Le(n){return Le=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Le(n)}function Mr(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Mr=function(){return!!n})()}function Cn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Tn(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 Cn(n)}function ue(n,r,t){return r=Le(r),Tn(n,Mr()?Reflect.construct(r,t||[],Le(n).constructor):r.apply(n,t))}function kt(n,r){return kt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},kt(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&&kt(n,r)}function An(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,h=!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(d){h=!0,i=d}finally{try{if(!u&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(h)throw i}}return s}}function Rt(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 Br(n,r){if(n){if(typeof n=="string")return Rt(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)?Rt(n,r):void 0}}function Rn(){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 De(n,r){return An(n)||kn(n,r)||Br(n,r)||Rn()}var mt={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"},Hr=new Int8Array(4),vt=new Int32Array(Hr.buffer,0,1),Ln=new Float32Array(Hr.buffer,0,1),Dn=/^\s*rgba?\s*\(/,Gn=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Nn(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(Dn.test(n)){var a=n.match(Gn);a&&(r=+a[1],t=+a[2],e=+a[3],a[4]&&(i=+a[4]))}return{r,g:t,b:e,a:i}}var Re={};for(var rt in mt)Re[rt]=Ve(mt[rt]),Re[mt[rt]]=Re[rt];function Wr(n,r,t,e,i){return vt[0]=e<<24|t<<16|r<<8|n,vt[0]=vt[0]&4278190079,Ln[0]}function Ve(n){if(n=n.toLowerCase(),typeof Re[n]<"u")return Re[n];var r=Nn(n),t=r.r,e=r.g,i=r.b,a=r.a;a=a*255|0;var o=Wr(t,e,i,a);return Re[n]=o,o}var yt={};function Vr(n){if(typeof yt[n]<"u")return yt[n];var r=(n&16711680)>>>16,t=(n&65280)>>>8,e=n&255,i=255,a=Wr(r,t,e,i);return yt[n]=a,a}function Vt(n,r,t,e){return t+(r<<8)+(n<<16)}function qt(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 h=De(u,4),d=h[0],l=h[1],c=h[2],g=h[3];return[d,l,c,g]}function x(n,r,t){return(r=We(r))in n?Object.defineProperty(n,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[r]=t,n}function Kt(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?Kt(Object(t),!0).forEach(function(e){x(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Kt(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function Fn(n,r){for(;!{}.hasOwnProperty.call(n,r)&&(n=Le(n))!==null;);return n}function Lt(){return Lt=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,r,t){var e=Fn(n,r);if(e){var i=Object.getOwnPropertyDescriptor(e,r);return i.get?i.get.call(arguments.length<3?n:t):i.value}},Lt.apply(null,arguments)}function qr(n,r,t,e){var i=Lt(Le(n.prototype),r,t);return typeof i=="function"?function(a){return i.apply(t,a)}:i}function Pn(n){return n.normalized?1:n.size}function bt(n){var r=0;return n.forEach(function(t){return r+=Pn(t)}),r}function Kr(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 In(n,r){return Kr("VERTEX",n,r)}function zn(n,r){return Kr("FRAGMENT",n,r)}function On(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 Yt(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 Zt=`#define PICKING_MODE
|
|
5
|
-
`,$n=x(x(x(x(x(x(x(x({},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),Yr=(function(){function n(r,t,e){re(this,n),x(this,"array",new Float32Array),x(this,"constantArray",new Float32Array),x(this,"capacity",0),x(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=bt(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,Zt+i.VERTEX_SHADER_SOURCE,Zt+i.FRAGMENT_SHADER_SOURCE,t):null,this.isInstanced){var a=bt(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(){Yt(this.normalProgram),this.pickProgram&&(Yt(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 h=In(e,i),d=zn(e,a),l=On(e,[h,d]),c={};s.UNIFORMS.forEach(function(w){var _=e.getUniformLocation(l,w);_&&(c[w]=_)});var g={};s.ATTRIBUTES.forEach(function(w){g[w.name]=e.getAttribLocation(l,w.name)});var b;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(w){g[w.name]=e.getAttribLocation(l,w.name)}),b=e.createBuffer(),b===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:t,program:l,gl:e,frameBuffer:o,buffer:u,constantBuffer:b||{},uniformLocations:c,attributeLocations:g,isPicking:t==="pick",vertexShader:h,fragmentShader:d}}},{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=$n[t.type];if(typeof o!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(t.type,'"'));var s=e.attributeLocations[t.name],u=e.gl;if(s!==-1){u.enableVertexAttribArray(s);var h=this.isInstanced?(a?this.ATTRIBUTES_ITEMS_COUNT:bt(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,h,i),this.isInstanced&&a)if(u instanceof WebGL2RenderingContext)u.vertexAttribDivisor(s,1);else{var d=u.getExtension("ANGLE_instanced_arrays");d&&d.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)}}}])})(),Un=(function(n){function r(){return re(this,r),ue(this,r,arguments)}return he(r,n),ie(r,[{key:"kill",value:function(){qr(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(Vr(e),o,a)}}])})(Yr),Ot=(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=ue(this,r,[].concat(i)),x(t,"drawLabel",void 0),t}return he(r,n),ie(r,[{key:"kill",value:function(){qr(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 h=u+this.STRIDE;u<h;u++)this.array[u]=0;return}return this.processVisibleItem(Vr(e),u,a,o,s)}}])})(Yr);function jn(n,r){return(function(){function t(e,i,a){re(this,t),x(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(h){return h.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 Mn(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,h=r.label;if(h){n.fillStyle=u,n.font="".concat(s," ").concat(a,"px ").concat(o);var d=t.size,l=e.size,c=t.x,g=t.y,b=e.x,w=e.y,_=(c+b)/2,L=(g+w)/2,C=b-c,k=w-g,m=Math.sqrt(C*C+k*k);if(!(m<d+l)){c+=C*d/m,g+=k*d/m,b-=C*l/m,w-=k*l/m,_=(c+b)/2,L=(g+w)/2,C=b-c,k=w-g,m=Math.sqrt(C*C+k*k);var v=n.measureText(h).width;if(v>m){var S="…";for(h=h+S,v=n.measureText(h).width;v>m&&h.length>1;)h=h.slice(0,-2)+S,v=n.measureText(h).width;if(h.length<4)return}var T;C>0?k>0?T=Math.acos(C/m):T=Math.asin(k/m):k>0?T=Math.acos(C/m)+Math.PI:T=Math.asin(C/m)+Math.PI/2,n.save(),n.translate(_,L),n.rotate(T),n.fillText(h,-v/2,r.size/2+a),n.restore()}}}function Zr(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 Bn(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),h=Math.round(e+2*o),d=Math.max(r.size,e/2)+o,l=Math.asin(h/2/d),c=Math.sqrt(Math.abs(Math.pow(d,2)-Math.pow(h/2,2)));n.beginPath(),n.moveTo(r.x+c,r.y+h/2),n.lineTo(r.x+d+u,r.y+h/2),n.lineTo(r.x+d+u,r.y-h/2),n.lineTo(r.x+c,r.y-h/2),n.arc(r.x,r.y,d,l,-l),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,Zr(n,r,t)}var Hn=`
|
|
6
|
-
precision highp float;
|
|
7
|
-
|
|
8
|
-
varying vec4 v_color;
|
|
9
|
-
varying vec2 v_diffVector;
|
|
10
|
-
varying float v_radius;
|
|
11
|
-
|
|
12
|
-
uniform float u_correctionRatio;
|
|
13
|
-
|
|
14
|
-
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
15
|
-
|
|
16
|
-
void main(void) {
|
|
17
|
-
float border = u_correctionRatio * 2.0;
|
|
18
|
-
float dist = length(v_diffVector) - v_radius + border;
|
|
19
|
-
|
|
20
|
-
// No antialiasing for picking mode:
|
|
21
|
-
#ifdef PICKING_MODE
|
|
22
|
-
if (dist > border)
|
|
23
|
-
gl_FragColor = transparent;
|
|
24
|
-
else
|
|
25
|
-
gl_FragColor = v_color;
|
|
26
|
-
|
|
27
|
-
#else
|
|
28
|
-
float t = 0.0;
|
|
29
|
-
if (dist > border)
|
|
30
|
-
t = 1.0;
|
|
31
|
-
else if (dist > 0.0)
|
|
32
|
-
t = dist / border;
|
|
33
|
-
|
|
34
|
-
gl_FragColor = mix(v_color, transparent, t);
|
|
35
|
-
#endif
|
|
36
|
-
}
|
|
37
|
-
`,Wn=Hn,Vn=`
|
|
38
|
-
attribute vec4 a_id;
|
|
39
|
-
attribute vec4 a_color;
|
|
40
|
-
attribute vec2 a_position;
|
|
41
|
-
attribute float a_size;
|
|
42
|
-
attribute float a_angle;
|
|
43
|
-
|
|
44
|
-
uniform mat3 u_matrix;
|
|
45
|
-
uniform float u_sizeRatio;
|
|
46
|
-
uniform float u_correctionRatio;
|
|
47
|
-
|
|
48
|
-
varying vec4 v_color;
|
|
49
|
-
varying vec2 v_diffVector;
|
|
50
|
-
varying float v_radius;
|
|
51
|
-
varying float v_border;
|
|
52
|
-
|
|
53
|
-
const float bias = 255.0 / 254.0;
|
|
54
|
-
|
|
55
|
-
void main() {
|
|
56
|
-
float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
|
|
57
|
-
vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
|
|
58
|
-
vec2 position = a_position + diffVector;
|
|
59
|
-
gl_Position = vec4(
|
|
60
|
-
(u_matrix * vec3(position, 1)).xy,
|
|
61
|
-
0,
|
|
62
|
-
1
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
v_diffVector = diffVector;
|
|
66
|
-
v_radius = size / 2.0;
|
|
67
|
-
|
|
68
|
-
#ifdef PICKING_MODE
|
|
69
|
-
// For picking mode, we use the ID as the color:
|
|
70
|
-
v_color = a_id;
|
|
71
|
-
#else
|
|
72
|
-
// For normal mode, we use the color:
|
|
73
|
-
v_color = a_color;
|
|
74
|
-
#endif
|
|
75
|
-
|
|
76
|
-
v_color.a *= bias;
|
|
77
|
-
}
|
|
78
|
-
`,qn=Vn,Xr=WebGLRenderingContext,Xt=Xr.UNSIGNED_BYTE,wt=Xr.FLOAT,Kn=["u_sizeRatio","u_correctionRatio","u_matrix"],ht=(function(n){function r(){return re(this,r),ue(this,r,arguments)}return he(r,n),ie(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:qn,FRAGMENT_SHADER_SOURCE:Wn,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Kn,ATTRIBUTES:[{name:"a_position",size:2,type:wt},{name:"a_size",size:1,type:wt},{name:"a_color",size:4,type:Xt,normalized:!0},{name:"a_id",size:4,type:Xt,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:wt}],CONSTANT_DATA:[[r.ANGLE_1],[r.ANGLE_2],[r.ANGLE_3]]}}},{key:"processVisibleItem",value:function(e,i,a){var o=this.array,s=Ve(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,h=o.u_matrix;a.uniform1f(u,e.correctionRatio),a.uniform1f(s,e.sizeRatio),a.uniformMatrix3fv(h,!1,e.matrix)}}])})(Un);x(ht,"ANGLE_1",0);x(ht,"ANGLE_2",2*Math.PI/3);x(ht,"ANGLE_3",4*Math.PI/3);var Yn=`
|
|
79
|
-
precision mediump float;
|
|
80
|
-
|
|
81
|
-
varying vec4 v_color;
|
|
82
|
-
|
|
83
|
-
void main(void) {
|
|
84
|
-
gl_FragColor = v_color;
|
|
85
|
-
}
|
|
86
|
-
`,Zn=Yn,Xn=`
|
|
87
|
-
attribute vec2 a_position;
|
|
88
|
-
attribute vec2 a_normal;
|
|
89
|
-
attribute float a_radius;
|
|
90
|
-
attribute vec3 a_barycentric;
|
|
91
|
-
|
|
92
|
-
#ifdef PICKING_MODE
|
|
93
|
-
attribute vec4 a_id;
|
|
94
|
-
#else
|
|
95
|
-
attribute vec4 a_color;
|
|
96
|
-
#endif
|
|
97
|
-
|
|
98
|
-
uniform mat3 u_matrix;
|
|
99
|
-
uniform float u_sizeRatio;
|
|
100
|
-
uniform float u_correctionRatio;
|
|
101
|
-
uniform float u_minEdgeThickness;
|
|
102
|
-
uniform float u_lengthToThicknessRatio;
|
|
103
|
-
uniform float u_widenessToThicknessRatio;
|
|
104
|
-
|
|
105
|
-
varying vec4 v_color;
|
|
106
|
-
|
|
107
|
-
const float bias = 255.0 / 254.0;
|
|
108
|
-
|
|
109
|
-
void main() {
|
|
110
|
-
float minThickness = u_minEdgeThickness;
|
|
111
|
-
|
|
112
|
-
float normalLength = length(a_normal);
|
|
113
|
-
vec2 unitNormal = a_normal / normalLength;
|
|
114
|
-
|
|
115
|
-
// These first computations are taken from edge.vert.glsl and
|
|
116
|
-
// edge.clamped.vert.glsl. Please read it to get better comments on what's
|
|
117
|
-
// happening:
|
|
118
|
-
float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
|
|
119
|
-
float webGLThickness = pixelsThickness * u_correctionRatio;
|
|
120
|
-
float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
121
|
-
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
122
|
-
float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
|
|
123
|
-
|
|
124
|
-
float da = a_barycentric.x;
|
|
125
|
-
float db = a_barycentric.y;
|
|
126
|
-
float dc = a_barycentric.z;
|
|
127
|
-
|
|
128
|
-
vec2 delta = vec2(
|
|
129
|
-
da * (webGLNodeRadius * unitNormal.y)
|
|
130
|
-
+ db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
|
|
131
|
-
+ dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
|
|
132
|
-
|
|
133
|
-
da * (-webGLNodeRadius * unitNormal.x)
|
|
134
|
-
+ db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
|
|
135
|
-
+ dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
|
|
139
|
-
|
|
140
|
-
gl_Position = vec4(position, 0, 1);
|
|
141
|
-
|
|
142
|
-
#ifdef PICKING_MODE
|
|
143
|
-
// For picking mode, we use the ID as the color:
|
|
144
|
-
v_color = a_id;
|
|
145
|
-
#else
|
|
146
|
-
// For normal mode, we use the color:
|
|
147
|
-
v_color = a_color;
|
|
148
|
-
#endif
|
|
149
|
-
|
|
150
|
-
v_color.a *= bias;
|
|
151
|
-
}
|
|
152
|
-
`,Qn=Xn,Qr=WebGLRenderingContext,Qt=Qr.UNSIGNED_BYTE,it=Qr.FLOAT,Jn=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Jr={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function ei(n){var r=F(F({},Jr),{});return(function(t){function e(){return re(this,e),ue(this,e,arguments)}return he(e,t),ie(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Qn,FRAGMENT_SHADER_SOURCE:Zn,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Jn,ATTRIBUTES:[{name:"a_position",size:2,type:it},{name:"a_normal",size:2,type:it},{name:"a_radius",size:1,type:it},{name:"a_color",size:4,type:Qt,normalized:!0},{name:"a_id",size:4,type:Qt,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:it}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(a,o,s,u,h){if(r.extremity==="source"){var d=[u,s];s=d[0],u=d[1]}var l=h.size||1,c=u.size||1,g=s.x,b=s.y,w=u.x,_=u.y,L=Ve(h.color),C=w-g,k=_-b,m=C*C+k*k,v=0,S=0;m&&(m=1/Math.sqrt(m),v=-k*m*l,S=C*m*l);var T=this.array;T[o++]=w,T[o++]=_,T[o++]=-v,T[o++]=-S,T[o++]=c,T[o++]=L,T[o++]=a}},{key:"setUniforms",value:function(a,o){var s=o.gl,u=o.uniformLocations,h=u.u_matrix,d=u.u_sizeRatio,l=u.u_correctionRatio,c=u.u_minEdgeThickness,g=u.u_lengthToThicknessRatio,b=u.u_widenessToThicknessRatio;s.uniformMatrix3fv(h,!1,a.matrix),s.uniform1f(d,a.sizeRatio),s.uniform1f(l,a.correctionRatio),s.uniform1f(c,a.minEdgeThickness),s.uniform1f(g,r.lengthToThicknessRatio),s.uniform1f(b,r.widenessToThicknessRatio)}}])})(Ot)}ei();var ea=`
|
|
153
|
-
precision mediump float;
|
|
154
|
-
|
|
155
|
-
varying vec4 v_color;
|
|
156
|
-
varying vec2 v_normal;
|
|
157
|
-
varying float v_thickness;
|
|
158
|
-
varying float v_feather;
|
|
159
|
-
|
|
160
|
-
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
161
|
-
|
|
162
|
-
void main(void) {
|
|
163
|
-
// We only handle antialiasing for normal mode:
|
|
164
|
-
#ifdef PICKING_MODE
|
|
165
|
-
gl_FragColor = v_color;
|
|
166
|
-
#else
|
|
167
|
-
float dist = length(v_normal) * v_thickness;
|
|
168
|
-
|
|
169
|
-
float t = smoothstep(
|
|
170
|
-
v_thickness - v_feather,
|
|
171
|
-
v_thickness,
|
|
172
|
-
dist
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
gl_FragColor = mix(v_color, transparent, t);
|
|
176
|
-
#endif
|
|
177
|
-
}
|
|
178
|
-
`,ti=ea,ta=`
|
|
179
|
-
attribute vec4 a_id;
|
|
180
|
-
attribute vec4 a_color;
|
|
181
|
-
attribute vec2 a_normal;
|
|
182
|
-
attribute float a_normalCoef;
|
|
183
|
-
attribute vec2 a_positionStart;
|
|
184
|
-
attribute vec2 a_positionEnd;
|
|
185
|
-
attribute float a_positionCoef;
|
|
186
|
-
attribute float a_radius;
|
|
187
|
-
attribute float a_radiusCoef;
|
|
188
|
-
|
|
189
|
-
uniform mat3 u_matrix;
|
|
190
|
-
uniform float u_zoomRatio;
|
|
191
|
-
uniform float u_sizeRatio;
|
|
192
|
-
uniform float u_pixelRatio;
|
|
193
|
-
uniform float u_correctionRatio;
|
|
194
|
-
uniform float u_minEdgeThickness;
|
|
195
|
-
uniform float u_lengthToThicknessRatio;
|
|
196
|
-
uniform float u_feather;
|
|
197
|
-
|
|
198
|
-
varying vec4 v_color;
|
|
199
|
-
varying vec2 v_normal;
|
|
200
|
-
varying float v_thickness;
|
|
201
|
-
varying float v_feather;
|
|
202
|
-
|
|
203
|
-
const float bias = 255.0 / 254.0;
|
|
204
|
-
|
|
205
|
-
void main() {
|
|
206
|
-
float minThickness = u_minEdgeThickness;
|
|
207
|
-
|
|
208
|
-
float radius = a_radius * a_radiusCoef;
|
|
209
|
-
vec2 normal = a_normal * a_normalCoef;
|
|
210
|
-
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
211
|
-
|
|
212
|
-
float normalLength = length(normal);
|
|
213
|
-
vec2 unitNormal = normal / normalLength;
|
|
214
|
-
|
|
215
|
-
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
216
|
-
// get better comments on what's happening:
|
|
217
|
-
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
218
|
-
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
219
|
-
|
|
220
|
-
// Here, we move the point to leave space for the arrow head:
|
|
221
|
-
float direction = sign(radius);
|
|
222
|
-
float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
223
|
-
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
224
|
-
|
|
225
|
-
vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
|
|
226
|
-
|
|
227
|
-
// Here is the proper position of the vertex
|
|
228
|
-
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
|
|
229
|
-
|
|
230
|
-
v_thickness = webGLThickness / u_zoomRatio;
|
|
231
|
-
|
|
232
|
-
v_normal = unitNormal;
|
|
233
|
-
|
|
234
|
-
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
235
|
-
|
|
236
|
-
#ifdef PICKING_MODE
|
|
237
|
-
// For picking mode, we use the ID as the color:
|
|
238
|
-
v_color = a_id;
|
|
239
|
-
#else
|
|
240
|
-
// For normal mode, we use the color:
|
|
241
|
-
v_color = a_color;
|
|
242
|
-
#endif
|
|
243
|
-
|
|
244
|
-
v_color.a *= bias;
|
|
245
|
-
}
|
|
246
|
-
`,ra=ta,ri=WebGLRenderingContext,Jt=ri.UNSIGNED_BYTE,Se=ri.FLOAT,ia=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],na={lengthToThicknessRatio:Jr.lengthToThicknessRatio};function ii(n){var r=F(F({},na),{});return(function(t){function e(){return re(this,e),ue(this,e,arguments)}return he(e,t),ie(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:ra,FRAGMENT_SHADER_SOURCE:ti,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:ia,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:Jt,normalized:!0},{name:"a_id",size:4,type:Jt,normalized:!0},{name:"a_radius",size:1,type:Se}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Se},{name:"a_normalCoef",size:1,type:Se},{name:"a_radiusCoef",size:1,type:Se}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(a,o,s,u,h){var d=h.size||1,l=s.x,c=s.y,g=u.x,b=u.y,w=Ve(h.color),_=g-l,L=b-c,C=u.size||1,k=_*_+L*L,m=0,v=0;k&&(k=1/Math.sqrt(k),m=-L*k*d,v=_*k*d);var S=this.array;S[o++]=l,S[o++]=c,S[o++]=g,S[o++]=b,S[o++]=m,S[o++]=v,S[o++]=w,S[o++]=a,S[o++]=C}},{key:"setUniforms",value:function(a,o){var s=o.gl,u=o.uniformLocations,h=u.u_matrix,d=u.u_zoomRatio,l=u.u_feather,c=u.u_pixelRatio,g=u.u_correctionRatio,b=u.u_sizeRatio,w=u.u_minEdgeThickness,_=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(h,!1,a.matrix),s.uniform1f(d,a.zoomRatio),s.uniform1f(b,a.sizeRatio),s.uniform1f(g,a.correctionRatio),s.uniform1f(c,a.pixelRatio),s.uniform1f(l,a.antiAliasingFeather),s.uniform1f(w,a.minEdgeThickness),s.uniform1f(_,r.lengthToThicknessRatio)}}])})(Ot)}ii();function aa(n){return jn([ii(),ei()])}var oa=aa(),sa=oa,ua=`
|
|
247
|
-
attribute vec4 a_id;
|
|
248
|
-
attribute vec4 a_color;
|
|
249
|
-
attribute vec2 a_normal;
|
|
250
|
-
attribute float a_normalCoef;
|
|
251
|
-
attribute vec2 a_positionStart;
|
|
252
|
-
attribute vec2 a_positionEnd;
|
|
253
|
-
attribute float a_positionCoef;
|
|
254
|
-
|
|
255
|
-
uniform mat3 u_matrix;
|
|
256
|
-
uniform float u_sizeRatio;
|
|
257
|
-
uniform float u_zoomRatio;
|
|
258
|
-
uniform float u_pixelRatio;
|
|
259
|
-
uniform float u_correctionRatio;
|
|
260
|
-
uniform float u_minEdgeThickness;
|
|
261
|
-
uniform float u_feather;
|
|
262
|
-
|
|
263
|
-
varying vec4 v_color;
|
|
264
|
-
varying vec2 v_normal;
|
|
265
|
-
varying float v_thickness;
|
|
266
|
-
varying float v_feather;
|
|
267
|
-
|
|
268
|
-
const float bias = 255.0 / 254.0;
|
|
269
|
-
|
|
270
|
-
void main() {
|
|
271
|
-
float minThickness = u_minEdgeThickness;
|
|
272
|
-
|
|
273
|
-
vec2 normal = a_normal * a_normalCoef;
|
|
274
|
-
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
275
|
-
|
|
276
|
-
float normalLength = length(normal);
|
|
277
|
-
vec2 unitNormal = normal / normalLength;
|
|
278
|
-
|
|
279
|
-
// We require edges to be at least "minThickness" pixels thick *on screen*
|
|
280
|
-
// (so we need to compensate the size ratio):
|
|
281
|
-
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
282
|
-
|
|
283
|
-
// Then, we need to retrieve the normalized thickness of the edge in the WebGL
|
|
284
|
-
// referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
|
|
285
|
-
// ratio:
|
|
286
|
-
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
287
|
-
|
|
288
|
-
// Here is the proper position of the vertex
|
|
289
|
-
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
|
|
290
|
-
|
|
291
|
-
// For the fragment shader though, we need a thickness that takes the "magic"
|
|
292
|
-
// correction ratio into account (as in webGLThickness), but so that the
|
|
293
|
-
// antialiasing effect does not depend on the zoom level. So here's yet
|
|
294
|
-
// another thickness version:
|
|
295
|
-
v_thickness = webGLThickness / u_zoomRatio;
|
|
296
|
-
|
|
297
|
-
v_normal = unitNormal;
|
|
298
|
-
|
|
299
|
-
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
300
|
-
|
|
301
|
-
#ifdef PICKING_MODE
|
|
302
|
-
// For picking mode, we use the ID as the color:
|
|
303
|
-
v_color = a_id;
|
|
304
|
-
#else
|
|
305
|
-
// For normal mode, we use the color:
|
|
306
|
-
v_color = a_color;
|
|
307
|
-
#endif
|
|
308
|
-
|
|
309
|
-
v_color.a *= bias;
|
|
310
|
-
}
|
|
311
|
-
`,ha=ua,ni=WebGLRenderingContext,er=ni.UNSIGNED_BYTE,Ue=ni.FLOAT,da=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],la=(function(n){function r(){return re(this,r),ue(this,r,arguments)}return he(r,n),ie(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:ha,FRAGMENT_SHADER_SOURCE:ti,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:da,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Ue},{name:"a_positionEnd",size:2,type:Ue},{name:"a_normal",size:2,type:Ue},{name:"a_color",size:4,type:er,normalized:!0},{name:"a_id",size:4,type:er,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Ue},{name:"a_normalCoef",size:1,type:Ue}],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,h=a.x,d=a.y,l=o.x,c=o.y,g=Ve(s.color),b=l-h,w=c-d,_=b*b+w*w,L=0,C=0;_&&(_=1/Math.sqrt(_),L=-w*_*u,C=b*_*u);var k=this.array;k[i++]=h,k[i++]=d,k[i++]=l,k[i++]=c,k[i++]=L,k[i++]=C,k[i++]=g,k[i++]=e}},{key:"setUniforms",value:function(e,i){var a=i.gl,o=i.uniformLocations,s=o.u_matrix,u=o.u_zoomRatio,h=o.u_feather,d=o.u_pixelRatio,l=o.u_correctionRatio,c=o.u_sizeRatio,g=o.u_minEdgeThickness;a.uniformMatrix3fv(s,!1,e.matrix),a.uniform1f(u,e.zoomRatio),a.uniform1f(c,e.sizeRatio),a.uniform1f(l,e.correctionRatio),a.uniform1f(d,e.pixelRatio),a.uniform1f(h,e.antiAliasingFeather),a.uniform1f(g,e.minEdgeThickness)}}])})(Ot),$t=(function(n){function r(){var t;return re(this,r),t=ue(this,r),t.rawEmitter=t,t}return he(r,n),ie(r)})(Ar.EventEmitter),Et,tr;function ai(){return tr||(tr=1,Et=function(r){return r!==null&&typeof r=="object"&&typeof r.addUndirectedEdgeWithKey=="function"&&typeof r.dropNode=="function"&&typeof r.multi=="boolean"}),Et}var ca=ai();const fa=Tr(ca);var ga=function(r){return r},pa=function(r){return r*r},ma=function(r){return r*(2-r)},va=function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)},ya=function(r){return r*r*r},ba=function(r){return--r*r*r+1},wa=function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)},Ea={linear:ga,quadraticIn:pa,quadraticOut:ma,quadraticInOut:va,cubicIn:ya,cubicOut:ba,cubicInOut:wa},xa={easing:"quadraticInOut",duration:150};function le(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function nt(n,r,t){return n[0]=r,n[4]=typeof t=="number"?t:r,n}function rr(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 ir(n,r,t){return n[6]=r,n[7]=t,n}function be(n,r){var t=n[0],e=n[1],i=n[2],a=n[3],o=n[4],s=n[5],u=n[6],h=n[7],d=n[8],l=r[0],c=r[1],g=r[2],b=r[3],w=r[4],_=r[5],L=r[6],C=r[7],k=r[8];return n[0]=l*t+c*a+g*u,n[1]=l*e+c*o+g*h,n[2]=l*i+c*s+g*d,n[3]=b*t+w*a+_*u,n[4]=b*e+w*o+_*h,n[5]=b*i+w*s+_*d,n[6]=L*t+C*a+k*u,n[7]=L*e+C*o+k*h,n[8]=L*i+C*s+k*d,n}function Dt(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],h=r.x,d=r.y;return{x:h*e+d*a+s*t,y:h*i+d*o+u*t}}function _a(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,h=r.width,d=r.height,l=le(),c=Math.min(h,d)-2*e,g=_a(r,t);return i?(be(l,ir(le(),s,u)),be(l,nt(le(),o)),be(l,rr(le(),a)),be(l,nt(le(),h/c/2/g,d/c/2/g))):(be(l,nt(le(),2*(c/h)*g,2*(c/d)*g)),be(l,rr(le(),-a)),be(l,nt(le(),1/o)),be(l,ir(le(),-s,-u))),l}function Sa(n,r,t){var e=Dt(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 Ca(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 Ta(n){if(!fa(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 Aa(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 nr(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function ar(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 or(n){var r=De(n.x,2),t=r[0],e=r[1],i=De(n.y,2),a=i[0],o=i[1],s=Math.max(e-t,o-a),u=(e+t)/2,h=(o+a)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(u)&&(u=0),isNaN(h)&&(h=0);var d=function(c){return{x:.5+(c.x-u)/s,y:.5+(c.y-h)/s}};return d.applyTo=function(l){l.x=.5+(l.x-u)/s,l.y=.5+(l.y-h)/s},d.inverse=function(l){return{x:u+s*(l.x-.5),y:h+s*(l.y-.5)}},d.ratio=s,d}function Gt(n){"@babel/helpers - typeof";return Gt=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},Gt(n)}function sr(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 xt(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 Ut={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:Mn,defaultDrawNodeLabel:Zr,defaultDrawNodeHover:Bn,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:{}},ka={circle:ht},Ra={arrow:sa,line:la};function _t(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 La(n){var r=xt({},Ut,n);return r.nodeProgramClasses=xt({},ka,r.nodeProgramClasses),r.edgeProgramClasses=xt({},Ra,r.edgeProgramClasses),r}var at=1.5,ur=(function(n){function r(){var t;return re(this,r),t=ue(this,r),x(t,"x",.5),x(t,"y",.5),x(t,"angle",0),x(t,"ratio",1),x(t,"minRatio",null),x(t,"maxRatio",null),x(t,"enabledZooming",!0),x(t,"enabledPanning",!0),x(t,"enabledRotation",!0),x(t,"clean",null),x(t,"nextFrame",null),x(t,"previousState",null),x(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(g){return i.animate(e,a,g)});if(this.enabled){var s=F(F({},xa),a),u=this.validateState(e),h=typeof s.easing=="function"?s.easing:Ea[s.easing],d=Date.now(),l=this.getState(),c=function(){var b=(Date.now()-d)/s.duration;if(b>=1){i.nextFrame=null,i.setState(u),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var w=h(b),_={};typeof u.x=="number"&&(_.x=l.x+(u.x-l.x)*w),typeof u.y=="number"&&(_.y=l.y+(u.y-l.y)*w),i.enabledRotation&&typeof u.angle=="number"&&(_.angle=l.angle+(u.angle-l.angle)*w),typeof u.ratio=="number"&&(_.ratio=l.ratio+(u.ratio-l.ratio)*w),i.setState(_),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||at)},e):this.animate({ratio:this.ratio/at})}},{key:"animatedUnzoom",value:function(e){return e?typeof e=="number"?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||at)},e):this.animate({ratio:this.ratio*at})}},{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)}}])})($t);function ce(n,r){var t=r.getBoundingClientRect();return{x:n.clientX-t.left,y:n.clientY-t.top}}function pe(n,r){var t=F(F({},ce(n,r)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0},original:n});return t}function Me(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 Da(n,r){return F(F({},pe(n,r)),{},{delta:oi(n)})}var Ga=2;function ot(n){for(var r=[],t=0,e=Math.min(n.length,Ga);t<e;t++)r.push(n[t]);return r}function Be(n,r,t){var e={touches:ot(n.touches).map(function(i){return ce(i,t)}),previousTouches:r.map(function(i){return ce(i,t)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:n};return e}function oi(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 si=(function(n){function r(t,e){var i;return re(this,r),i=ue(this,r),i.container=t,i.renderer=e,i}return he(r,n),ie(r)})($t),Na=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],Fa=Na.reduce(function(n,r){return F(F({},n),{},x({},r,Ut[r]))},{}),Pa=(function(n){function r(t,e){var i;return re(this,r),i=ue(this,r,[t,e]),x(i,"enabled",!0),x(i,"draggedEvents",0),x(i,"downStartTime",null),x(i,"lastMouseX",null),x(i,"lastMouseY",null),x(i,"isMouseDown",!1),x(i,"isMoving",!1),x(i,"movingTimeout",null),x(i,"startCameraState",null),x(i,"clicks",0),x(i,"doubleClickTimeout",null),x(i,"currentWheelDirection",0),x(i,"settings",Fa),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",pe(e,this.container))}}},{key:"handleRightClick",value:function(e){this.enabled&&this.emit("rightClick",pe(e,this.container))}},{key:"handleDoubleClick",value:function(e){if(this.enabled){e.preventDefault(),e.stopPropagation();var i=pe(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(ce(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=ce(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",pe(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=ce(e,this.container),s=o.x,u=o.y,h=a.getState(),d=a.getPreviousState()||{x:0,y:0};this.isMoving?a.animate({x:h.x+this.settings.inertiaRatio*(h.x-d.x),y:h.y+this.settings.inertiaRatio*(h.y-d.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==u)&&a.setState({x:h.x,y:h.y}),this.isMoving=!1,setTimeout(function(){var l=i.draggedEvents>0;i.draggedEvents=0,l&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",pe(e,this.container))}}},{key:"handleMove",value:function(e){var i=this;if(this.enabled){var a=pe(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=ce(e,this.container),u=s.x,h=s.y,d=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),l=this.renderer.viewportToFramedGraph({x:u,y:h}),c=d.x-l.x,g=d.y-l.y,b=o.getState(),w=b.x+c,_=b.y+g;o.setState({x:w,y:_}),this.lastMouseX=u,this.lastMouseY=h,e.preventDefault(),e.stopPropagation()}}}},{key:"handleLeave",value:function(e){this.emit("mouseleave",pe(e,this.container))}},{key:"handleEnter",value:function(e){this.emit("mouseenter",pe(e,this.container))}},{key:"handleWheel",value:function(e){var i=this,a=this.renderer.getCamera();if(!(!this.enabled||!a.enabledZooming)){var o=oi(e);if(o){var s=Da(e,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){e.preventDefault(),e.stopPropagation();return}var u=a.getState().ratio,h=o>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,d=a.getBoundedRatio(u*h),l=o>0?1:-1,c=Date.now();u!==d&&(e.preventDefault(),e.stopPropagation(),!(this.currentWheelDirection===l&&this.lastWheelTriggerTime&&c-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(a.animate(this.renderer.getViewportZoomedState(ce(e,this.container),d),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=l,this.lastWheelTriggerTime=c))}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(si),Ia=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],za=Ia.reduce(function(n,r){return F(F({},n),{},x({},r,Ut[r]))},{}),Oa=(function(n){function r(t,e){var i;return re(this,r),i=ue(this,r,[t,e]),x(i,"enabled",!0),x(i,"isMoving",!1),x(i,"hasMoved",!1),x(i,"touchMode",0),x(i,"startTouchesPositions",[]),x(i,"lastTouches",[]),x(i,"lastTap",null),x(i,"settings",za),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=ot(e.touches);if(this.touchMode=a.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=a.map(function(g){return ce(g,i.container)}),this.touchMode===2){var o=De(this.startTouchesPositions,2),s=o[0],u=s.x,h=s.y,d=o[1],l=d.x,c=d.y;this.startTouchesAngle=Math.atan2(c-h,l-u),this.startTouchesDistance=Math.sqrt(Math.pow(l-u,2)+Math.pow(c-h,2))}this.emit("touchdown",Be(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",Be(e,this.lastTouches,this.container)),!e.touches.length){var s=ce(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],h=Math.pow(s.x-u.x,2)+Math.pow(s.y-u.y,2);if(!e.touches.length&&h<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var d=Be(e,this.lastTouches,this.container);if(this.emit("doubletap",d),this.lastTap=null,!d.sigmaDefaultPrevented){var l=this.renderer.getCamera(),c=l.getBoundedRatio(l.getState().ratio/this.settings.doubleClickZoomingRatio);l.animate(this.renderer.getViewportZoomedState(s,c),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var g=Be(e,this.lastTouches,this.container);this.emit("tap",g),this.lastTap={time:Date.now(),position:g.touches[0]||g.previousTouches[0]}}}this.lastTouches=ot(e.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(e){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){e.preventDefault();var a=ot(e.touches),o=a.map(function(ee){return ce(ee,i.container)}),s=this.lastTouches;this.lastTouches=a,this.lastTouchesPositions=o;var u=Be(e,s,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=o.some(function(ee,Q){var z=i.startTouchesPositions[Q];return z&&(ee.x!==z.x||ee.y!==z.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var h=this.renderer.getCamera(),d=this.startCameraState,l=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var c=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),g=c.x,b=c.y,w=this.renderer.viewportToFramedGraph(o[0]),_=w.x,L=w.y;h.setState({x:d.x+g-_,y:d.y+b-L});break}case 2:{var C={x:.5,y:.5,angle:0,ratio:1},k=o[0],m=k.x,v=k.y,S=o[1],T=S.x,I=S.y,P=Math.atan2(I-v,T-m)-this.startTouchesAngle,N=Math.hypot(I-v,T-m)/this.startTouchesDistance,q=h.getBoundedRatio(d.ratio/N);C.ratio=q,C.angle=d.angle+P;var U=this.getDimensions(),f=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:d}),K=Math.min(U.width,U.height)-2*l,X=K/U.width,A=K/U.height,p=q/K,G=m-K/2/X,B=v-K/2/A,Z=[G*Math.cos(-C.angle)-B*Math.sin(-C.angle),B*Math.cos(-C.angle)+G*Math.sin(-C.angle)];G=Z[0],B=Z[1],C.x=f.x-G*p,C.y=f.y+B*p,h.setState(C);break}}}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(si);function $a(n){if(Array.isArray(n))return Rt(n)}function Ua(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function ja(){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 hr(n){return $a(n)||Ua(n)||Br(n)||ja()}function Ma(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 St(n,r){if(n==null)return{};var t,e,i=Ma(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 dr=(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}}])})(),lr=(function(){function n(){re(this,n),x(this,"width",0),x(this,"height",0),x(this,"cellSize",0),x(this,"columns",0),x(this,"rows",0),x(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 dr(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(dr.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 h in this.cells)for(var d=this.cells[h],l=0;l<Math.min(s,d.length);l++)u.push(d[l].key);return u}}])})();function Ba(n){var r=n.graph,t=n.hoveredNode,e=n.highlightedNodes,i=n.displayedNodeLabels,a=[];return r.forEachEdge(function(o,s,u,h){(u===t||h===t||e.has(u)||e.has(h)||i.has(u)&&i.has(h))&&a.push(o)}),a}var cr=150,fr=50,me=Object.prototype.hasOwnProperty;function Ha(n,r,t){if(!me.call(t,"x")||!me.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),me.call(t,"hidden")||(t.hidden=!1),me.call(t,"highlighted")||(t.highlighted=!1),me.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=n.defaultNodeType),t.zIndex||(t.zIndex=0),t}function Wa(n,r,t){return t.color||(t.color=n.defaultEdgeColor),t.label||(t.label=""),t.size||(t.size=.5),me.call(t,"hidden")||(t.hidden=!1),me.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=n.defaultEdgeType),t.zIndex||(t.zIndex=0),t}var Va=(function(n){function r(t,e){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(re(this,r),i=ue(this,r),x(i,"elements",{}),x(i,"canvasContexts",{}),x(i,"webGLContexts",{}),x(i,"pickingLayers",new Set),x(i,"textures",{}),x(i,"frameBuffers",{}),x(i,"activeListeners",{}),x(i,"labelGrid",new lr),x(i,"nodeDataCache",{}),x(i,"edgeDataCache",{}),x(i,"nodeProgramIndex",{}),x(i,"edgeProgramIndex",{}),x(i,"nodesWithForcedLabels",new Set),x(i,"edgesWithForcedLabels",new Set),x(i,"nodeExtent",{x:[0,1],y:[0,1]}),x(i,"nodeZExtent",[1/0,-1/0]),x(i,"edgeZExtent",[1/0,-1/0]),x(i,"matrix",le()),x(i,"invMatrix",le()),x(i,"correctionRatio",1),x(i,"customBBox",null),x(i,"normalizationFunction",or({x:[0,1],y:[0,1]})),x(i,"graphToViewportRatio",1),x(i,"itemIDsIndex",{}),x(i,"nodeIndices",{}),x(i,"edgeIndices",{}),x(i,"width",0),x(i,"height",0),x(i,"pixelRatio",nr()),x(i,"pickingDownSizingRatio",2*i.pixelRatio),x(i,"displayedNodeLabels",new Set),x(i,"displayedEdgeLabels",new Set),x(i,"highlightedNodes",new Set),x(i,"hoveredNode",null),x(i,"hoveredEdge",null),x(i,"renderFrame",null),x(i,"renderHighlightedNodesFrame",null),x(i,"needToProcess",!1),x(i,"checkEdgesEventsFrame",null),x(i,"nodePrograms",{}),x(i,"nodeHoverPrograms",{}),x(i,"edgePrograms",{}),i.settings=La(a),_t(i.settings),Ta(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 ur,i.bindCameraHandlers(),i.mouseCaptor=new Pa(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new Oa(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=St(i,[e].map(We));a.kill(),this.nodePrograms=o}if(this.nodeHoverPrograms[e]){var s=this.nodeHoverPrograms,u=s[e],h=St(s,[e].map(We));u.kill(),this.nodePrograms=h}return this}},{key:"unregisterEdgeProgram",value:function(e){if(this.edgePrograms[e]){var i=this.edgePrograms,a=i[e],o=St(i,[e].map(We));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=qt(this.webGLContexts.nodes,this.frameBuffers.nodes,i,a,this.pixelRatio,this.pickingDownSizingRatio),s=Vt.apply(void 0,hr(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=Me(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 h=e.hoveredNode;e.hoveredNode=null,e.emit("leaveNode",F(F({},s),{},{node:h})),e.scheduleHighlightedNodesRender();return}if(e.settings.enableEdgeEvents){var d=e.hoveredNode?null:e.getEdgeAtPoint(s.event.x,s.event.y);d!==e.hoveredEdge&&(e.hoveredEdge&&e.emit("leaveEdge",F(F({},s),{},{edge:e.hoveredEdge})),d&&e.emit("enterEdge",F(F({},s),{},{edge:d})),e.hoveredEdge=d)}},this.activeListeners.handleMoveBody=function(a){var o=Me(a);e.emit("moveBody",{event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(a){var o=Me(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=Me(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};e.emit("enterStage",F({},s))};var i=function(o){return function(s){var u=Me(s),h={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},d=e.getNodeAtPosition(u);if(d)return e.emit("".concat(o,"Node"),F(F({},h),{},{node:d}));if(e.settings.enableEdgeEvents){var l=e.getEdgeAtPoint(u.x,u.y);if(l)return e.emit("".concat(o,"Edge"),F(F({},h),{},{edge:l}))}return e.emit("".concat(o,"Stage"),h)}};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(d){return e.updateNode(d)});var h=!u||u.some(function(d){return a.has(d)});e.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!h,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(d){return e.updateEdge(d)});var h=u&&["zIndex","type"].some(function(d){return u==null?void 0:u.includes(d)});e.refresh({partialGraph:{edges:i.edges()},skipIndexation:!h,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=qt(this.webGLContexts.edges,this.frameBuffers.edges,e,i,this.pixelRatio,this.pickingDownSizingRatio),o=Vt.apply(void 0,hr(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=Ca(this.graph),!this.settings.autoRescale){var s=o.width,u=o.height,h=this.nodeExtent,d=h.x,l=h.y;this.nodeExtent={x:[(d[0]+d[1])/2-s/2,(d[0]+d[1])/2+s/2],y:[(l[0]+l[1])/2-u/2,(l[0]+l[1])/2+u/2]}}this.normalizationFunction=or(this.customBBox||this.nodeExtent);var c=new ur,g=je(c.getState(),o,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(o,a.labelGridCellSize);for(var b={},w={},_={},L={},C=1,k=i.nodes(),m=0,v=k.length;m<v;m++){var S=k[m],T=this.nodeDataCache[S],I=i.getNodeAttributes(S);T.x=I.x,T.y=I.y,this.normalizationFunction.applyTo(T),typeof T.label=="string"&&!T.hidden&&this.labelGrid.add(S,T.size,this.framedGraphToViewport(T,{matrix:g})),b[T.type]=(b[T.type]||0)+1}this.labelGrid.organize();for(var P in this.nodePrograms){if(!me.call(this.nodePrograms,P))throw new Error('Sigma: could not find a suitable program for node type "'.concat(P,'"!'));this.nodePrograms[P].reallocate(b[P]||0),b[P]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(k=ar(this.nodeZExtent,function(ne){return e.nodeDataCache[ne].zIndex},k));for(var N=0,q=k.length;N<q;N++){var U=k[N];w[U]=C,L[w[U]]={type:"node",id:U},C++;var f=this.nodeDataCache[U];this.addNodeToProgram(U,w[U],b[f.type]++)}for(var K={},X=i.edges(),A=0,p=X.length;A<p;A++){var G=X[A],B=this.edgeDataCache[G];K[B.type]=(K[B.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(X=ar(this.edgeZExtent,function(ne){return e.edgeDataCache[ne].zIndex},X));for(var Z in this.edgePrograms){if(!me.call(this.edgePrograms,Z))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Z,'"!'));this.edgePrograms[Z].reallocate(K[Z]||0),K[Z]=0}for(var ee=0,Q=X.length;ee<Q;ee++){var z=X[ee];_[z]=C,L[_[z]]={type:"edge",id:z},C++;var Pe=this.edgeDataCache[z];this.addEdgeToProgram(z,_[z],K[Pe.type]++)}return this.itemIDsIndex=L,this.nodeIndices=w,this.edgeIndices=_,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(d){return i.cleanCameraState(d,a.cameraPanBoundaries&&Gt(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 h in e.nodeProgramClasses)a.nodeProgramClasses[h]||this.unregisterNodeProgram(h)}}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),h=s||this.nodeExtent,d=De(h.x,2),l=d[0],c=d[1],g=De(h.y,2),b=g[0],w=g[1],_=[this.graphToViewport({x:l,y:b},{cameraState:e}),this.graphToViewport({x:c,y:b},{cameraState:e}),this.graphToViewport({x:l,y:w},{cameraState:e}),this.graphToViewport({x:c,y:w},{cameraState:e})],L=1/0,C=-1/0,k=1/0,m=-1/0;_.forEach(function(K){var X=K.x,A=K.y;L=Math.min(L,X),C=Math.max(C,X),k=Math.min(k,A),m=Math.max(m,A)});var v=C-L,S=m-k,T=this.getDimensions(),I=T.width,P=T.height,N=0,q=0;if(v>=I?C<I-o?N=C-(I-o):L>o&&(N=L-o):C>I+o?N=C-(I+o):L<-o&&(N=L+o),S>=P?m<P-o?q=m-(P-o):k>o&&(q=k-o):m>P+o?q=m-(P+o):k<-o&&(q=k+o),N||q){var U=this.viewportToFramedGraph({x:0,y:0},{cameraState:e}),f=this.viewportToFramedGraph({x:N,y:q},{cameraState:e});N=f.x-U.x,q=f.y-U.y,u.x+=N,u.y+=q}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);sr(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],h=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!h.hidden){var d=this.framedGraphToViewport(h),l=d.x,c=d.y,g=this.scaleSize(h.size);if(!(!h.forceLabel&&g<this.settings.labelRenderedSizeThreshold)&&!(l<-cr||l>this.width+cr||c<-fr||c>this.height+fr)){this.displayedNodeLabels.add(u);var b=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[h.type],_=(w==null?void 0:w.drawLabel)||b;_(a,F(F({key:u},h),{},{size:g,x:l,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=Ba({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});sr(i,this.edgesWithForcedLabels);for(var a=new Set,o=0,s=i.length;o<s;o++){var u=i[o],h=this.graph.extremities(u),d=this.nodeDataCache[h[0]],l=this.nodeDataCache[h[1]],c=this.edgeDataCache[u];if(!a.has(u)&&!(c.hidden||d.hidden||l.hidden)){var g=this.settings.defaultDrawEdgeLabel,b=this.edgePrograms[c.type],w=(b==null?void 0:b.drawLabel)||g;w(e,F(F({key:u},c),{},{size:this.scaleSize(c.size)}),F(F(F({key:h[0]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),F(F(F({key:h[1]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),this.settings),a.add(u)}}return this.displayedEdgeLabels=a,this}},{key:"renderHighlightedNodes",value:function(){var e=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var a=function(g){var b=e.nodeDataCache[g],w=e.framedGraphToViewport(b),_=w.x,L=w.y,C=e.scaleSize(b.size),k=e.settings.defaultDrawNodeHover,m=e.nodePrograms[b.type],v=(m==null?void 0:m.drawHover)||k;v(i,F(F({key:g},b),{},{size:C,x:_,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 g=e.nodeDataCache[c].type;s[g]=(s[g]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(s[u]||0),s[u]=0;o.forEach(function(c){var g=e.nodeDataCache[c];e.nodeHoverPrograms[g.type].process(0,s[g.type]++,g)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var h=this.getRenderParams();for(var d in this.nodeHoverPrograms){var l=this.nodeHoverPrograms[d];l.render(h)}}},{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(_){return e.resetWebGLTexture(_)}),!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(),h=this.getGraphDimensions(),d=this.getStagePadding();this.matrix=je(s,u,h,d),this.invMatrix=je(s,u,h,d,!0),this.correctionRatio=Sa(this.matrix,s,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var l=this.getRenderParams();for(var c in this.nodePrograms){var g=this.nodePrograms[c];g.render(l)}if(!this.settings.hideEdgesOnMove||!o)for(var b in this.edgePrograms){var w=this.edgePrograms[b];w.render(l)}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=Ha(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=Wa(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 lr,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),h=this.nodeDataCache[u[0]],d=this.nodeDataCache[u[1]];s.process(i,a,h,d,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=Aa(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 h=u.createFramebuffer();if(!h)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(e));this.frameBuffers[e]=h}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,_t(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),_t(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=nr(),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 h in this.webGLContexts){this.elements[h].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[h].setAttribute("height",this.height*this.pixelRatio+"px");var d=this.webGLContexts[h];if(d.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(h)){var l=this.textures[h];l&&d.deleteTexture(l)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(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,h,d=((u=e.partialGraph)===null||u===void 0?void 0:u.nodes)||[],l=0,c=(d==null?void 0:d.length)||0;l<c;l++){var g=d[l];if(this.updateNode(g),a){var b=this.nodeProgramIndex[g];if(b===void 0)throw new Error('Sigma: node "'.concat(g,`" can't be repaint`));this.addNodeToProgram(g,this.nodeIndices[g],b)}}for(var w=(e==null||(h=e.partialGraph)===null||h===void 0?void 0:h.edges)||[],_=0,L=w.length;_<L;_++){var C=w[_];if(this.updateEdge(C),a){var k=this.edgeProgramIndex[C];if(k===void 0)throw new Error('Sigma: edge "'.concat(C,`" can't be repaint`));this.addEdgeToProgram(C,this.edgeIndices[C],k)}}}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,h=a.y,d=this.settings,l=d.minCameraRatio,c=d.maxCameraRatio;typeof c=="number"&&(i=Math.min(i,c)),typeof l=="number"&&(i=Math.max(i,l));var g=i/o,b={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(e),_=this.viewportToFramedGraph(b);return{angle:s,x:(w.x-_.x)*(1-g)+u,y:(w.y-_.y)*(1-g)+h,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=Dt(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=Dt(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}}])})($t);const ui=M.createContext(null),qa=ui.Provider;function hi(){const n=M.useContext(ui);if(n==null)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return n}function dt(){return hi().sigma}function Ka(){const{sigma:n}=hi();return M.useCallback((r=>{n&&Object.keys(r).forEach((t=>{n.setSetting(t,r[t])}))}),[n])}function lt(n){return new Set(Object.keys(n))}const gr=lt({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}),pr=lt({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),mr=lt({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),vr=lt({updated:!0});function Ya(){const n=dt(),r=Ka(),[t,e]=M.useState({});return M.useEffect((()=>{if(!n||!t)return;const i=t,a=Object.keys(i);return a.forEach((o=>{const s=i[o];gr.has(o)&&n.on(o,s),pr.has(o)&&n.getMouseCaptor().on(o,s),mr.has(o)&&n.getTouchCaptor().on(o,s),vr.has(o)&&n.getCamera().on(o,s)})),()=>{n&&a.forEach((o=>{const s=i[o];gr.has(o)&&n.off(o,s),pr.has(o)&&n.getMouseCaptor().off(o,s),mr.has(o)&&n.getTouchCaptor().off(o,s),vr.has(o)&&n.getCamera().off(o,s)}))}}),[n,t,r]),e}function Za(){const n=dt();return M.useCallback(((r,t=!0)=>{n&&r&&(t&&n.getGraph().order>0&&n.getGraph().clear(),n.getGraph().import(r),n.refresh())}),[n])}function di(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)||!di(n[t],r[t]))return!1;return!0}return!1}const Xa=M.forwardRef((({graph:n,id:r,className:t,style:e,settings:i={},children:a},o)=>{const s=M.useRef(null),u=M.useRef(null),h={className:`react-sigma ${t||""}`,id:r,style:e},[d,l]=M.useState(null),[c,g]=M.useState(i);M.useEffect((()=>{g((_=>di(_,i)?_:i))}),[i]),M.useEffect((()=>{let _=null;if(u.current!==null){let L=new V;n&&(L=typeof n=="function"?new n:n),_=new Va(L,u.current,c),l((C=>{let k=null;return C&&(k=C.getCamera().getState()),k&&_.getCamera().setState(k),_}))}return()=>{_&&_.kill()}}),[u,n,c]),M.useImperativeHandle(o,(()=>d),[d]);const b=M.useMemo((()=>d&&s.current?{sigma:d,container:s.current}:null),[d,s]),w=b!==null?ft.createElement(qa,{value:b},a):null;return ft.createElement("div",Object.assign({},h,{ref:s}),ft.createElement("div",{className:"sigma-container",ref:u}),w)}));var He={},yr;function Qa(){if(yr)return He;yr=1;function n(e){return typeof e!="number"||isNaN(e)?1:e}function r(e,i){var a={},o=function(h){return typeof h>"u"?i:h};typeof i=="function"&&(o=i);var s=function(h){return o(h[e])},u=function(){return o(void 0)};return typeof e=="string"?(a.fromAttributes=s,a.fromGraph=function(h,d){return s(h.getNodeAttributes(d))},a.fromEntry=function(h,d){return s(d)}):typeof e=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},a.fromGraph=function(h,d){return o(e(d,h.getNodeAttributes(d)))},a.fromEntry=function(h,d){return o(e(h,d))}):(a.fromAttributes=u,a.fromGraph=u,a.fromEntry=u),a}function t(e,i){var a={},o=function(h){return typeof h>"u"?i:h};typeof i=="function"&&(o=i);var s=function(h){return o(h[e])},u=function(){return o(void 0)};return typeof e=="string"?(a.fromAttributes=s,a.fromGraph=function(h,d){return s(h.getEdgeAttributes(d))},a.fromEntry=function(h,d){return s(d)},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(h,d){var l=h.extremities(d);return o(e(d,h.getEdgeAttributes(d),l[0],l[1],h.getNodeAttributes(l[0]),h.getNodeAttributes(l[1]),h.isUndirected(d)))},a.fromEntry=function(h,d,l,c,g,b,w){return o(e(h,d,l,c,g,b,w))},a.fromPartialEntry=function(h,d,l,c){return o(e(h,d,l,c))},a.fromMinimalEntry=function(h,d){return o(e(h,d))}):(a.fromAttributes=u,a.fromGraph=u,a.fromEntry=u,a.fromMinimalEntry=u),a}return He.createNodeValueGetter=r,He.createEdgeValueGetter=t,He.createEdgeWeightGetter=function(e){return t(e,n)},He}var Ct,br;function Ja(){if(br)return Ct;br=1;var n=0,r=1,t=2,e=3,i=4,a=5,o=6,s=7,u=8,h=9,d=0,l=1,c=2,g=0,b=1,w=2,_=3,L=4,C=5,k=6,m=7,v=8,S=3,T=10,I=3,P=9,N=10;return Ct=function(U,f,K){var X,A,p,G,B,Z,ee,Q,z,Pe,ne=f.length,gi=K.length,Ie=U.adjustSizes,pi=U.barnesHutTheta*U.barnesHutTheta,qe,Y,H,W,fe,j,$,y=[];for(p=0;p<ne;p+=T)f[p+i]=f[p+t],f[p+a]=f[p+e],f[p+t]=0,f[p+e]=0;if(U.outboundAttractionDistribution){for(qe=0,p=0;p<ne;p+=T)qe+=f[p+o];qe/=ne/T}if(U.barnesHutOptimize){var we=1/0,Ce=-1/0,Ee=1/0,Te=-1/0,ae,Ae,ct;for(p=0;p<ne;p+=T)we=Math.min(we,f[p+n]),Ce=Math.max(Ce,f[p+n]),Ee=Math.min(Ee,f[p+r]),Te=Math.max(Te,f[p+r]);var Ke=Ce-we,Ye=Te-Ee;for(Ke>Ye?(Ee-=(Ke-Ye)/2,Te=Ee+Ke):(we-=(Ye-Ke)/2,Ce=we+Ye),y[0+g]=-1,y[0+b]=(we+Ce)/2,y[0+w]=(Ee+Te)/2,y[0+_]=Math.max(Ce-we,Te-Ee),y[0+L]=-1,y[0+C]=-1,y[0+k]=0,y[0+m]=0,y[0+v]=0,X=1,p=0;p<ne;p+=T)for(A=0,ct=S;;)if(y[A+C]>=0){f[p+n]<y[A+b]?f[p+r]<y[A+w]?ae=y[A+C]:ae=y[A+C]+P:f[p+r]<y[A+w]?ae=y[A+C]+P*2:ae=y[A+C]+P*3,y[A+m]=(y[A+m]*y[A+k]+f[p+n]*f[p+o])/(y[A+k]+f[p+o]),y[A+v]=(y[A+v]*y[A+k]+f[p+r]*f[p+o])/(y[A+k]+f[p+o]),y[A+k]+=f[p+o],A=ae;continue}else if(y[A+g]<0){y[A+g]=p;break}else{if(y[A+C]=X*P,Q=y[A+_]/2,z=y[A+C],y[z+g]=-1,y[z+b]=y[A+b]-Q,y[z+w]=y[A+w]-Q,y[z+_]=Q,y[z+L]=z+P,y[z+C]=-1,y[z+k]=0,y[z+m]=0,y[z+v]=0,z+=P,y[z+g]=-1,y[z+b]=y[A+b]-Q,y[z+w]=y[A+w]+Q,y[z+_]=Q,y[z+L]=z+P,y[z+C]=-1,y[z+k]=0,y[z+m]=0,y[z+v]=0,z+=P,y[z+g]=-1,y[z+b]=y[A+b]+Q,y[z+w]=y[A+w]-Q,y[z+_]=Q,y[z+L]=z+P,y[z+C]=-1,y[z+k]=0,y[z+m]=0,y[z+v]=0,z+=P,y[z+g]=-1,y[z+b]=y[A+b]+Q,y[z+w]=y[A+w]+Q,y[z+_]=Q,y[z+L]=y[A+L],y[z+C]=-1,y[z+k]=0,y[z+m]=0,y[z+v]=0,X+=4,f[y[A+g]+n]<y[A+b]?f[y[A+g]+r]<y[A+w]?ae=y[A+C]:ae=y[A+C]+P:f[y[A+g]+r]<y[A+w]?ae=y[A+C]+P*2:ae=y[A+C]+P*3,y[A+k]=f[y[A+g]+o],y[A+m]=f[y[A+g]+n],y[A+v]=f[y[A+g]+r],y[ae+g]=y[A+g],y[A+g]=-1,f[p+n]<y[A+b]?f[p+r]<y[A+w]?Ae=y[A+C]:Ae=y[A+C]+P:f[p+r]<y[A+w]?Ae=y[A+C]+P*2:Ae=y[A+C]+P*3,ae===Ae)if(ct--){A=ae;continue}else{ct=S;break}y[Ae+g]=p;break}}if(U.barnesHutOptimize)for(Y=U.scalingRatio,p=0;p<ne;p+=T)for(A=0;;)if(y[A+C]>=0)if(j=Math.pow(f[p+n]-y[A+m],2)+Math.pow(f[p+r]-y[A+v],2),Pe=y[A+_],4*Pe*Pe/j<pi){if(H=f[p+n]-y[A+m],W=f[p+r]-y[A+v],Ie===!0?j>0?($=Y*f[p+o]*y[A+k]/j,f[p+t]+=H*$,f[p+e]+=W*$):j<0&&($=-Y*f[p+o]*y[A+k]/Math.sqrt(j),f[p+t]+=H*$,f[p+e]+=W*$):j>0&&($=Y*f[p+o]*y[A+k]/j,f[p+t]+=H*$,f[p+e]+=W*$),A=y[A+L],A<0)break;continue}else{A=y[A+C];continue}else{if(Z=y[A+g],Z>=0&&Z!==p&&(H=f[p+n]-f[Z+n],W=f[p+r]-f[Z+r],j=H*H+W*W,Ie===!0?j>0?($=Y*f[p+o]*f[Z+o]/j,f[p+t]+=H*$,f[p+e]+=W*$):j<0&&($=-Y*f[p+o]*f[Z+o]/Math.sqrt(j),f[p+t]+=H*$,f[p+e]+=W*$):j>0&&($=Y*f[p+o]*f[Z+o]/j,f[p+t]+=H*$,f[p+e]+=W*$)),A=y[A+L],A<0)break;continue}else for(Y=U.scalingRatio,G=0;G<ne;G+=T)for(B=0;B<G;B+=T)H=f[G+n]-f[B+n],W=f[G+r]-f[B+r],Ie===!0?(j=Math.sqrt(H*H+W*W)-f[G+u]-f[B+u],j>0?($=Y*f[G+o]*f[B+o]/j/j,f[G+t]+=H*$,f[G+e]+=W*$,f[B+t]-=H*$,f[B+e]-=W*$):j<0&&($=100*Y*f[G+o]*f[B+o],f[G+t]+=H*$,f[G+e]+=W*$,f[B+t]-=H*$,f[B+e]-=W*$)):(j=Math.sqrt(H*H+W*W),j>0&&($=Y*f[G+o]*f[B+o]/j/j,f[G+t]+=H*$,f[G+e]+=W*$,f[B+t]-=H*$,f[B+e]-=W*$));for(z=U.gravity/U.scalingRatio,Y=U.scalingRatio,p=0;p<ne;p+=T)$=0,H=f[p+n],W=f[p+r],j=Math.sqrt(Math.pow(H,2)+Math.pow(W,2)),U.strongGravityMode?j>0&&($=Y*f[p+o]*z):j>0&&($=Y*f[p+o]*z/j),f[p+t]-=H*$,f[p+e]-=W*$;for(Y=1*(U.outboundAttractionDistribution?qe:1),ee=0;ee<gi;ee+=I)G=K[ee+d],B=K[ee+l],Q=K[ee+c],fe=Math.pow(Q,U.edgeWeightInfluence),H=f[G+n]-f[B+n],W=f[G+r]-f[B+r],Ie===!0?(j=Math.sqrt(H*H+W*W)-f[G+u]-f[B+u],U.linLogMode?U.outboundAttractionDistribution?j>0&&($=-Y*fe*Math.log(1+j)/j/f[G+o]):j>0&&($=-Y*fe*Math.log(1+j)/j):U.outboundAttractionDistribution?j>0&&($=-Y*fe/f[G+o]):j>0&&($=-Y*fe)):(j=Math.sqrt(Math.pow(H,2)+Math.pow(W,2)),U.linLogMode?U.outboundAttractionDistribution?j>0&&($=-Y*fe*Math.log(1+j)/j/f[G+o]):j>0&&($=-Y*fe*Math.log(1+j)/j):U.outboundAttractionDistribution?(j=1,$=-Y*fe/f[G+o]):(j=1,$=-Y*fe)),j>0&&(f[G+t]+=H*$,f[G+e]+=W*$,f[B+t]-=H*$,f[B+e]-=W*$);var Ze,ze,Xe,xe,Qe,Je;if(Ie===!0)for(p=0;p<ne;p+=T)f[p+h]!==1&&(Ze=Math.sqrt(Math.pow(f[p+t],2)+Math.pow(f[p+e],2)),Ze>N&&(f[p+t]=f[p+t]*N/Ze,f[p+e]=f[p+e]*N/Ze),ze=f[p+o]*Math.sqrt((f[p+i]-f[p+t])*(f[p+i]-f[p+t])+(f[p+a]-f[p+e])*(f[p+a]-f[p+e])),Xe=Math.sqrt((f[p+i]+f[p+t])*(f[p+i]+f[p+t])+(f[p+a]+f[p+e])*(f[p+a]+f[p+e]))/2,xe=.1*Math.log(1+Xe)/(1+Math.sqrt(ze)),Qe=f[p+n]+f[p+t]*(xe/U.slowDown),f[p+n]=Qe,Je=f[p+r]+f[p+e]*(xe/U.slowDown),f[p+r]=Je);else for(p=0;p<ne;p+=T)f[p+h]!==1&&(ze=f[p+o]*Math.sqrt((f[p+i]-f[p+t])*(f[p+i]-f[p+t])+(f[p+a]-f[p+e])*(f[p+a]-f[p+e])),Xe=Math.sqrt((f[p+i]+f[p+t])*(f[p+i]+f[p+t])+(f[p+a]+f[p+e])*(f[p+a]+f[p+e]))/2,xe=f[p+s]*Math.log(1+Xe)/(1+Math.sqrt(ze)),f[p+s]=Math.min(1,Math.sqrt(xe*(Math.pow(f[p+t],2)+Math.pow(f[p+e],2))/(1+Math.sqrt(ze)))),Qe=f[p+n]+f[p+t]*(xe/U.slowDown),f[p+n]=Qe,Je=f[p+r]+f[p+e]*(xe/U.slowDown),f[p+r]=Je);return{}},Ct}var ge={},wr;function eo(){if(wr)return ge;wr=1;var n=10,r=3;return ge.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},ge.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},ge.graphToByteArrays=function(t,e){var i=t.order,a=t.size,o={},s,u=new Float32Array(i*n),h=new Float32Array(a*r);return s=0,t.forEachNode(function(d,l){o[d]=s,u[s]=l.x,u[s+1]=l.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]=l.size||1,u[s+9]=l.fixed?1:0,s+=n}),s=0,t.forEachEdge(function(d,l,c,g,b,w,_){var L=o[c],C=o[g],k=e(d,l,c,g,b,w,_);u[L+6]+=k,u[C+6]+=k,h[s]=L,h[s+1]=C,h[s+2]=k,s+=r}),{nodes:u,edges:h}},ge.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})},ge.readGraphPositions=function(t,e){var i=0;t.forEachNode(function(a,o){e[i]=o.x,e[i+1]=o.y,i+=n})},ge.collectLayoutChanges=function(t,e,i){for(var a=t.nodes(),o={},s=0,u=0,h=e.length;s<h;s+=n){if(i){var d=Object.assign({},t.getNodeAttributes(a[u]));d.x=e[s],d.y=e[s+1],d=i(a[u],d),o[a[u]]={x:d.x,y:d.y}}else o[a[u]]={x:e[s],y:e[s+1]};u++}return o},ge.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},ge}var Tt,Er;function to(){return Er||(Er=1,Tt={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),Tt}var At,xr;function ro(){if(xr)return At;xr=1;var n=ai(),r=Qa().createEdgeWeightGetter,t=Ja(),e=eo(),i=to();function a(u,h,d){if(!n(h))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof d=="number"&&(d={iterations:d});var l=d.iterations;if(typeof l!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(l<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=r("getEdgeWeight"in d?d.getEdgeWeight:"weight").fromEntry,g=typeof d.outputReducer=="function"?d.outputReducer:null,b=e.assign({},i,d.settings),w=e.validateSettings(b);if(w)throw new Error("graphology-layout-forceatlas2: "+w.message);var _=e.graphToByteArrays(h,c),L;for(L=0;L<l;L++)t(b,_.nodes,_.edges);if(u){e.assignLayoutChanges(h,_.nodes,g);return}return e.collectLayoutChanges(h,_.nodes)}function o(u){var h=typeof u=="number"?u:u.order;return{barnesHutOptimize:h>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(h)}}var s=a.bind(null,!1);return s.assign=a.bind(null,!0),s.inferSettings=o,At=s,At}var io=ro();const no=Tr(io);function Nt(n){return n!=null&&typeof n=="object"&&"symbols"in n&&Array.isArray(n.symbols)}function li(n){return n!=null&&typeof n=="object"&&"riskLevel"in n&&"affectedSymbols"in n}function ao(n){return n!=null&&typeof n=="object"&&"result"in n&&Array.isArray(n.result)&&n.result.length>0&&typeof n.result[0]=="object"}function oo(n){if(!Array.isArray(n)||n.length===0)return!1;const r=n[0];return r!=null&&typeof r=="object"&&!Array.isArray(r)}function _r({data:n,pageSize:r=50}){const[t,e]=M.useState(0),i=M.useMemo(()=>{if(n.length===0)return[];const s=new Set;for(const u of n)for(const h of Object.keys(u))s.add(h);return Array.from(s)},[n]),a=Math.ceil(n.length/r),o=n.slice(t*r,(t+1)*r);return n.length===0?E.jsx("div",{className:"p-4 text-sm text-[var(--color-text-muted)]",children:"No results"}):E.jsxs("div",{children:[E.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] mb-2",children:[n.length," rows"]}),E.jsx("div",{className:"overflow-x-auto rounded-lg border border-[var(--color-border)]",children:E.jsxs("table",{className:"w-full text-xs",children:[E.jsx("thead",{children:E.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=>E.jsx("th",{className:"py-1.5 px-2 font-medium whitespace-nowrap",children:s},s))})}),E.jsx("tbody",{children:o.map((s,u)=>E.jsx("tr",{className:"border-b border-[var(--color-border)] hover:bg-[var(--color-bg-tertiary)] transition-colors",children:i.map(h=>E.jsx("td",{className:"py-1 px-2 max-w-[300px] truncate",children:so(s[h])},h))},u))})]})}),a>1&&E.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2 text-xs",children:[E.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"}),E.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[t+1," / ",a]}),E.jsx("button",{onClick:()=>e(s=>Math.min(a-1,s+1)),disabled:t>=a-1,className:"px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] disabled:opacity-30",children:"Next"})]})]})}function so(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 uo({data:n}){const[r,t]=M.useState(!1),[e,i]=M.useState(!1),a=JSON.stringify(n,null,2),o=M.useCallback(async()=>{try{await navigator.clipboard.writeText(a),i(!0),setTimeout(()=>i(!1),2e3)}catch{}},[a]);return E.jsxs("div",{className:"rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]",children:[E.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-[var(--color-border)]",children:[E.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"}),E.jsx("button",{onClick:()=>void o(),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&&E.jsx("pre",{className:"p-3 text-xs whitespace-pre-wrap overflow-x-auto max-h-[400px] overflow-y-auto",children:a})]})}const ho=new Set(["function","class","method","interface","variable","module","file","folder"]),lo=new Set(["imports","calls","belongs_to","extends","implements"]);function Sr(n){return ho.has(n)?n:"module"}function co(n){return lo.has(n)?n:"imports"}function fo(n){const r=new Map,t=[];for(const e of n)e.src&&!r.has(e.src)&&r.set(e.src,{name:e.src,kind:Sr(Cr(e.src)),file:e.srcFile??void 0}),e.dst&&!r.has(e.dst)&&r.set(e.dst,{name:e.dst,kind:Sr(Cr(e.dst)),file:e.dstFile??void 0}),e.src&&e.dst&&e.relType&&t.push({from:e.src,to:e.dst,type:co(e.relType.toLowerCase())});return{symbols:Array.from(r.values()),relations:t}}function Cr(n){return n.endsWith(".ts")||n.endsWith(".js")||n.endsWith(".tsx")?"file":/^[A-Z][a-z]/.test(n)&&!n.includes(".")?"class":/^[a-z]/.test(n)&&!n.includes(".")?"function":"module"}function To(){const[n,r]=M.useState(null),[t,e]=M.useState("query"),[i,a]=M.useState(null),[o,s]=M.useState(!0),[u,h]=M.useState(null),[d,l]=M.useState(""),[c,g]=M.useState({data:null,loading:!1,error:null}),[b,w]=M.useState(""),[_,L]=M.useState(null),[C,k]=M.useState(null),[m,v]=M.useState(null),[S,T]=M.useState(null),[I,P]=M.useState(!1),N=M.useCallback(async()=>{try{s(!0);const G=await _e.getGitNexusStatus().catch(()=>null);if(r(G),G!=null&&G.running)try{const Z=await _e.getFullCodeGraph();if(Z.result&&Array.isArray(Z.result)){const ee=fo(Z.result);v(ee)}}catch{}}catch(G){a(G instanceof Error?G.message:"Failed to load")}finally{s(!1)}},[]);M.useEffect(()=>{N()},[N]),M.useEffect(()=>{if((n==null?void 0:n.analyzePhase)!=="analyzing")return;const G=setInterval(()=>{N()},5e3);return()=>clearInterval(G)},[n==null?void 0:n.analyzePhase,N]);const q=M.useCallback(async()=>{if(d.trim()){g({data:null,loading:!0,error:null});try{const G=await _e.queryCodeGraph(d);g({data:G,loading:!1,error:null}),Nt(G)&&T(G)}catch(G){g({data:null,loading:!1,error:G instanceof Error?G.message:"Query failed"})}}},[d]),U=M.useCallback(async G=>{if(G.trim())try{const B=await _e.getSymbolContext(G);Nt(B)&&(L(B),T(B))}catch{}},[]),f=M.useCallback(async G=>{if(G.trim())try{const B=await _e.getSymbolImpact(G);li(B)&&k(B)}catch{}},[]),K=M.useCallback(async()=>{P(!0);try{await _e.triggerAnalyze(),await _e.triggerServe(),await N()}catch{}finally{P(!1)}},[N]),X=M.useCallback(G=>{h(G),w(G),e("symbol"),U(G)},[U]);if(o)return E.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:"Loading GitNexus..."});if(i)return E.jsxs("div",{className:"flex items-center justify-center h-full text-[var(--color-danger)]",children:["Failed to load: ",i]});const A=(n==null?void 0:n.running)??!1,p=m??S;return E.jsxs("div",{className:"h-full flex flex-col",children:[E.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[E.jsx("h2",{className:"text-sm font-semibold",children:"GitNexus — Code Intelligence"}),E.jsx(go,{label:"GitNexus",indexed:(n==null?void 0:n.indexed)??!1,running:A,onAction:K,actionLoading:I}),p&&E.jsxs("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:[p.symbols.length," symbols · ",p.relations.length," relations"]}),E.jsx("div",{className:"flex gap-1 ml-auto",children:["query","symbol"].map(G=>E.jsx("button",{onClick:()=>e(G),className:`text-xs px-2 py-1 rounded transition-colors ${t===G?"bg-[var(--color-accent)] text-white":"text-[var(--color-text-muted)] hover:bg-[var(--color-bg-tertiary)]"}`,children:G==="query"?"Query":"Symbol"},G))})]}),E.jsxs("div",{className:"flex flex-1 min-h-0",children:[E.jsxs("div",{className:"w-[30%] min-w-[320px] border-r border-[var(--color-border)] overflow-auto",children:[t==="query"&&E.jsx(po,{queryInput:d,onQueryChange:l,onSubmit:q,result:c,gitNexusRunning:A,onSymbolSelect:X}),t==="symbol"&&E.jsx(yo,{symbolInput:b,onSymbolInputChange:w,onContext:U,onImpact:f,contextData:_,impactData:C,gitNexusRunning:A,onSymbolSelect:X})]}),E.jsx(bo,{fullGraph:p,contextGraph:S,selectedSymbol:u,onNodeClick:X})]})]})}function go({label:n,indexed:r,running:t,onAction:e,actionLoading:i}){const a=t?"var(--color-success)":r?"var(--color-warning)":"var(--color-text-muted)",o=t?"Active":r?"Indexed":"Inactive",s=!t&&e;return E.jsxs("span",{className:"inline-flex items-center gap-1",children:[E.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${a}20`,color:a},children:[n,": ",o]}),s&&E.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?"Starting...":"Analyze & Start"})]})}function po({queryInput:n,onQueryChange:r,onSubmit:t,result:e,gitNexusRunning:i,onSymbolSelect:a}){return E.jsxs("div",{className:"p-4",children:[E.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Query Code Graph"}),!i&&E.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:"GitNexus is not running. Start it to enable code graph queries."}),E.jsxs("div",{className:"flex gap-2 mb-4",children:[E.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-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",disabled:!i}),E.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&&E.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&&E.jsx(mo,{data:e.data,onSymbolSelect:a})]})}function mo({data:n,onSymbolSelect:r}){return Nt(n)?E.jsx(ci,{symbols:n.symbols,onSymbolSelect:r}):li(n)?E.jsx(fi,{impact:n,onSymbolSelect:r}):ao(n)?E.jsx(_r,{data:n.result}):oo(n)?E.jsx(_r,{data:n}):E.jsx(uo,{data:n})}function ci({symbols:n,onSymbolSelect:r}){const[t,e]=M.useState(0),i=50,a=Math.ceil(n.length/i),o=n.slice(t*i,(t+1)*i);return E.jsxs("div",{children:[E.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] mb-2",children:[n.length," symbols found"]}),E.jsxs("table",{className:"w-full text-xs",children:[E.jsx("thead",{children:E.jsxs("tr",{className:"border-b border-[var(--color-border)] text-left text-[var(--color-text-muted)]",children:[E.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Name"}),E.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Kind"}),E.jsx("th",{className:"py-1.5 px-2 font-medium",children:"File"}),E.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Lines"})]})}),E.jsx("tbody",{children:o.map(s=>E.jsxs("tr",{onClick:()=>r(s.name),className:"border-b border-[var(--color-border)] hover:bg-[var(--color-bg-tertiary)] cursor-pointer transition-colors",children:[E.jsx("td",{className:"py-1 px-2 font-medium",children:s.name}),E.jsx("td",{className:"py-1 px-2",children:E.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:`${st[s.kind]??"#9e9e9e"}20`,color:st[s.kind]??"#9e9e9e"},children:s.kind})}),E.jsx("td",{className:"py-1 px-2 text-[var(--color-text-muted)] truncate max-w-[200px]",children:s.file??"—"}),E.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??""}`))})]}),a>1&&E.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2 text-xs",children:[E.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"}),E.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[t+1," / ",a]}),E.jsx("button",{onClick:()=>e(s=>Math.min(a-1,s+1)),disabled:t>=a-1,className:"px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] disabled:opacity-30",children:"Next"})]})]})}const vo={low:"#4caf50",medium:"#ff9800",high:"#f44336"};function fi({impact:n,onSymbolSelect:r}){const t=vo[n.riskLevel]??"#9e9e9e";return E.jsxs("div",{className:"rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] p-4",children:[E.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[E.jsxs("span",{className:"text-sm font-semibold",children:["Impact: ",n.symbol]}),E.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${t}20`,color:t},children:[n.riskLevel," risk"]})]}),E.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] mb-2",children:[n.affectedSymbols.length," affected symbols"]}),E.jsx("div",{className:"space-y-1",children:n.affectedSymbols.map(e=>E.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:[E.jsx("span",{className:"font-medium",children:e.name}),E.jsxs("span",{className:"text-[var(--color-text-muted)] flex items-center gap-2",children:[E.jsx("span",{className:"truncate max-w-[150px]",children:e.file}),E.jsxs("span",{children:[Math.round(e.confidence*100),"%"]})]})]},`${e.name}-${e.file}`))})]})}function yo({symbolInput:n,onSymbolInputChange:r,onContext:t,onImpact:e,contextData:i,impactData:a,gitNexusRunning:o,onSymbolSelect:s}){return E.jsxs("div",{className:"p-4",children:[E.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Symbol Explorer"}),!o&&E.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:"GitNexus is not running. Start it to explore symbols."}),E.jsxs("div",{className:"flex gap-2 mb-4",children:[E.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:!o}),E.jsx("button",{onClick:()=>t(n),disabled:!o||!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"}),E.jsx("button",{onClick:()=>e(n),disabled:!o||!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&&E.jsxs("div",{className:"mb-4",children:[E.jsxs("h4",{className:"text-xs font-semibold mb-2 text-[var(--color-text-muted)]",children:["Context — ",i.symbols.length," symbols"]}),E.jsx(ci,{symbols:i.symbols,onSymbolSelect:s})]}),a&&E.jsx(fi,{impact:a,onSymbolSelect:s}),!i&&!a&&E.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 bo({fullGraph:n,contextGraph:r,selectedSymbol:t,onNodeClick:e}){const[i,a]=M.useState(null);if(!n||n.symbols.length===0)return E.jsx("div",{className:"flex-1 min-w-[300px] flex items-center justify-center",style:{background:"#06060f"},children:E.jsxs("div",{className:"text-center text-[#3a3a5a]",children:[E.jsx("p",{className:"text-sm mb-1",children:"No symbol graph"}),E.jsx("p",{className:"text-xs",children:"Query or select a symbol to see its graph"})]})});const o=new Set;if(r)for(const u of r.symbols)o.add(u.name);const s=i??t;return E.jsxs("div",{className:"flex-1 min-w-[300px] relative",style:{background:"#06060f"},children:[E.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(st).map(([u,h])=>E.jsx("span",{className:"text-[8px] font-medium px-1.5 py-0.5 rounded-full",style:{background:`${h}20`,color:h,textShadow:`0 0 8px ${h}`},children:u},u))}),E.jsxs("div",{className:"absolute bottom-2 right-2 z-10 text-[9px]",style:{color:"#3a3a5a"},children:[n.symbols.length," nodes · ",n.relations.length," edges"]}),E.jsxs(Xa,{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:!1,enableEdgeEvents:!1,defaultEdgeType:"line",defaultDrawNodeHover:Eo,defaultDrawNodeLabel:wo,minEdgeThickness:.3,minCameraRatio:.05,maxCameraRatio:10,zIndex:!0},children:[E.jsx(xo,{fullGraph:n,highlightedNodes:o,selectedSymbol:t}),E.jsx(_o,{onNodeClick:e,onNodeHover:a,activeNode:s,highlightedNodes:o})]})]})}function wo(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 Eo(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,a+"80"),s.addColorStop(.3,a+"30"),s.addColorStop(.6,a+"10"),s.addColorStop(1,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 xo({fullGraph:n,highlightedNodes:r,selectedSymbol:t}){const e=Za(),i=dt();return M.useEffect(()=>{const a=new V({type:"directed",multi:!1,allowSelfLoops:!1});for(const u of n.symbols)if(!a.hasNode(u.name)){const h=st[u.kind]??"#6a6a8a";a.addNode(u.name,{label:u.name,size:3,color:h,baseColor:h,kind:u.kind,x:Math.random()*200-100,y:Math.random()*200-100})}const o=new Set;for(const u of n.relations){const h=`${u.from}→${u.to}`;if(a.hasNode(u.from)&&a.hasNode(u.to)&&u.from!==u.to&&!o.has(h)){o.add(h);const d=mi[u.type]??"#2a2a50";a.addEdge(u.from,u.to,{color:d+"35",size:.4,baseColor:d,relType:u.type})}}a.order>0&&no.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 h=s.degree(u),d=Math.min(10,Math.max(1.5,1.5+Math.pow(h,.6)*.8));s.setNodeAttribute(u,"size",d)})},[n,e,i]),M.useEffect(()=>{const a=i.getGraph(),o=r.size>0;a.forEachNode(s=>{const u=a.getNodeAttribute(s,"baseColor")??"#6a6a8a",h=a.degree(s),d=r.has(s),l=s===t,c=o&&!d;if(l)a.setNodeAttribute(s,"size",14),a.setNodeAttribute(s,"zIndex",2);else if(d){const g=Math.min(10,Math.max(5,5+Math.sqrt(h)*1.2));a.setNodeAttribute(s,"size",g),a.setNodeAttribute(s,"zIndex",1)}else{const g=Math.min(10,Math.max(1.5,1.5+Math.pow(h,.6)*.8));a.setNodeAttribute(s,"size",g),a.setNodeAttribute(s,"zIndex",0)}l?a.setNodeAttribute(s,"color","#ffffff"):c?a.setNodeAttribute(s,"color",u+"30"):a.setNodeAttribute(s,"color",u)}),a.forEachEdge((s,u,h,d)=>{const l=a.getEdgeAttribute(s,"baseColor")??"#2a2a50",c=r.has(h),g=r.has(d),b=t!=null&&(h===t||d===t),w=c&&g;b?(a.setEdgeAttribute(s,"color",l+"f0"),a.setEdgeAttribute(s,"size",3),a.setEdgeAttribute(s,"zIndex",2)):w?(a.setEdgeAttribute(s,"color",l+"90"),a.setEdgeAttribute(s,"size",1.5),a.setEdgeAttribute(s,"zIndex",1)):o&&!w&&!b?(a.setEdgeAttribute(s,"color","#08081520"),a.setEdgeAttribute(s,"size",.15),a.setEdgeAttribute(s,"zIndex",0)):(a.setEdgeAttribute(s,"color",l+"35"),a.setEdgeAttribute(s,"size",.4),a.setEdgeAttribute(s,"zIndex",0))}),i.refresh()},[r,t,i]),null}function _o({onNodeClick:n,onNodeHover:r,activeNode:t,highlightedNodes:e}){const i=Ya(),a=dt();return M.useEffect(()=>{i({clickNode:o=>{n(o.node)},enterNode:o=>{r(o.node)},leaveNode:()=>{r(null)}})},[i,n,r]),M.useEffect(()=>{const o=a.getGraph();if(t&&o.hasNode(t)){const s=new Set(o.neighbors(t));s.add(t),a.setSetting("nodeReducer",(u,h)=>{if(u===t)return{...h,color:"#ffffff",size:(h.size??3)*1.3,zIndex:3};if(s.has(u))return{...h,zIndex:2};if(e.size===0){const d=o.getNodeAttribute(u,"baseColor")??"#6a6a8a";return{...h,color:d+"25",zIndex:0}}return h}),a.setSetting("edgeReducer",(u,h)=>{const d=o.source(u),l=o.target(u);if(d===t||l===t){const g=o.getEdgeAttribute(u,"baseColor")??"#4a4a7a";return{...h,color:g+"f0",size:3,zIndex:2}}return e.size===0?{...h,color:"#0a0a15",size:.15,zIndex:0}:h})}else a.setSetting("nodeReducer",null),a.setSetting("edgeReducer",null)},[t,e,a]),null}export{To as GitNexusTab};
|