All checks were successful
Deploy on webserver / Build site and deploy on success (push) Successful in 36s
312 lines
179 KiB
(Stored with Git Annex)
JavaScript
312 lines
179 KiB
(Stored with Git Annex)
JavaScript
(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))t(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&t(a)}).observe(document,{childList:!0,subtree:!0});function e(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function t(r){if(r.ep)return;r.ep=!0;const o=e(r);fetch(r.href,o)}})();function qe(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Nt={exports:{}},Pe=typeof Reflect=="object"?Reflect:null,Vt=Pe&&typeof Pe.apply=="function"?Pe.apply:function(i,e,t){return Function.prototype.apply.call(i,e,t)},rt;Pe&&typeof Pe.ownKeys=="function"?rt=Pe.ownKeys:Object.getOwnPropertySymbols?rt=function(i){return Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i))}:rt=function(i){return Object.getOwnPropertyNames(i)};function Sr(n){console&&console.warn&&console.warn(n)}var Li=Number.isNaN||function(i){return i!==i};function N(){N.init.call(this)}Nt.exports=N;Nt.exports.once=Lr;N.EventEmitter=N;N.prototype._events=void 0;N.prototype._eventsCount=0;N.prototype._maxListeners=void 0;var qt=10;function ot(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(N,"defaultMaxListeners",{enumerable:!0,get:function(){return qt},set:function(n){if(typeof n!="number"||n<0||Li(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");qt=n}});N.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};N.prototype.setMaxListeners=function(i){if(typeof i!="number"||i<0||Li(i))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+i+".");return this._maxListeners=i,this};function Di(n){return n._maxListeners===void 0?N.defaultMaxListeners:n._maxListeners}N.prototype.getMaxListeners=function(){return Di(this)};N.prototype.emit=function(i){for(var e=[],t=1;t<arguments.length;t++)e.push(arguments[t]);var r=i==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=o[i];if(u===void 0)return!1;if(typeof u=="function")Vt(u,this,e);else for(var h=u.length,d=Pi(u,h),t=0;t<h;++t)Vt(d[t],this,e);return!0};function xi(n,i,e,t){var r,o,a;if(ot(e),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",i,e.listener?e.listener:e),o=n._events),a=o[i]),a===void 0)a=o[i]=e,++n._eventsCount;else if(typeof a=="function"?a=o[i]=t?[e,a]:[a,e]:t?a.unshift(e):a.push(e),r=Di(n),r>0&&a.length>r&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(i)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=n,s.type=i,s.count=a.length,Sr(s)}return n}N.prototype.addListener=function(i,e){return xi(this,i,e,!1)};N.prototype.on=N.prototype.addListener;N.prototype.prependListener=function(i,e){return xi(this,i,e,!0)};function Rr(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Gi(n,i,e){var t={fired:!1,wrapFn:void 0,target:n,type:i,listener:e},r=Rr.bind(t);return r.listener=e,t.wrapFn=r,r}N.prototype.once=function(i,e){return ot(e),this.on(i,Gi(this,i,e)),this};N.prototype.prependOnceListener=function(i,e){return ot(e),this.prependListener(i,Gi(this,i,e)),this};N.prototype.removeListener=function(i,e){var t,r,o,a,s;if(ot(e),r=this._events,r===void 0)return this;if(t=r[i],t===void 0)return this;if(t===e||t.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete r[i],r.removeListener&&this.emit("removeListener",i,t.listener||e));else if(typeof t!="function"){for(o=-1,a=t.length-1;a>=0;a--)if(t[a]===e||t[a].listener===e){s=t[a].listener,o=a;break}if(o<0)return this;o===0?t.shift():Cr(t,o),t.length===1&&(r[i]=t[0]),r.removeListener!==void 0&&this.emit("removeListener",i,s||e)}return this};N.prototype.off=N.prototype.removeListener;N.prototype.removeAllListeners=function(i){var e,t,r;if(t=this._events,t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[i]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[i]),this;if(arguments.length===0){var o=Object.keys(t),a;for(r=0;r<o.length;++r)a=o[r],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=t[i],typeof e=="function")this.removeListener(i,e);else if(e!==void 0)for(r=e.length-1;r>=0;r--)this.removeListener(i,e[r]);return this};function Fi(n,i,e){var t=n._events;if(t===void 0)return[];var r=t[i];return r===void 0?[]:typeof r=="function"?e?[r.listener||r]:[r]:e?kr(r):Pi(r,r.length)}N.prototype.listeners=function(i){return Fi(this,i,!0)};N.prototype.rawListeners=function(i){return Fi(this,i,!1)};N.listenerCount=function(n,i){return typeof n.listenerCount=="function"?n.listenerCount(i):Ni.call(n,i)};N.prototype.listenerCount=Ni;function Ni(n){var i=this._events;if(i!==void 0){var e=i[n];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}N.prototype.eventNames=function(){return this._eventsCount>0?rt(this._events):[]};function Pi(n,i){for(var e=new Array(i),t=0;t<i;++t)e[t]=n[t];return e}function Cr(n,i){for(;i+1<n.length;i++)n[i]=n[i+1];n.pop()}function kr(n){for(var i=new Array(n.length),e=0;e<i.length;++e)i[e]=n[e].listener||n[e];return i}function Lr(n,i){return new Promise(function(e,t){function r(a){n.removeListener(i,o),t(a)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),e([].slice.call(arguments))}Ii(n,i,o,{once:!0}),i!=="error"&&Dr(n,r,{once:!0})})}function Dr(n,i,e){typeof n.on=="function"&&Ii(n,"error",i,e)}function Ii(n,i,e,t){if(typeof n.on=="function")t.once?n.once(i,e):n.on(i,e);else if(typeof n.addEventListener=="function")n.addEventListener(i,function r(o){t.once&&n.removeEventListener(i,r),e(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var zi=Nt.exports;function ye(n){if(typeof n!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=n}typeof Symbol<"u"&&(ye.prototype[Symbol.iterator]=function(){return this});ye.of=function(){var n=arguments,i=n.length,e=0;return new ye(function(){return e>=i?{done:!0}:{done:!1,value:n[e++]}})};ye.empty=function(){var n=new ye(function(){return{done:!0}});return n};ye.fromSequence=function(n){var i=0,e=n.length;return new ye(function(){return i>=e?{done:!0}:{done:!1,value:n[i++]}})};ye.is=function(n){return n instanceof ye?!0:typeof n=="object"&&n!==null&&typeof n.next=="function"};var at=ye;const oe=qe(at);var st={};st.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u";st.SYMBOL_SUPPORT=typeof Symbol<"u";var xr=at,Oi=st,Gr=Oi.ARRAY_BUFFER_SUPPORT,Fr=Oi.SYMBOL_SUPPORT;function Nr(n){return typeof n=="string"||Array.isArray(n)||Gr&&ArrayBuffer.isView(n)?xr.fromSequence(n):typeof n!="object"||n===null?null:Fr&&typeof n[Symbol.iterator]=="function"?n[Symbol.iterator]():typeof n.next=="function"?n:null}var Ui=function(i){var e=Nr(i);if(!e)throw new Error("obliterator: target is not iterable nor a valid iterator.");return e},Pr=Ui,Ir=function(i,e){for(var t=arguments.length>1?e:1/0,r=t!==1/0?new Array(t):[],o,a=0,s=Pr(i);;){if(a===t)return r;if(o=s.next(),o.done)return a!==e&&(r.length=a),r;r[a++]=o.value}};const Pt=qe(Ir);var zr=at,Or=Ui,Ur=function(){var i=arguments,e=null,t=-1;return new zr(function(){var o=null;do{if(e===null){if(t++,t>=i.length)return{done:!0};e=Or(i[t])}if(o=e.next(),o.done===!0){e=null;continue}break}while(!0);return o})};const Se=qe(Ur);function $r(){const n=arguments[0];for(let i=1,e=arguments.length;i<e;i++)if(arguments[i])for(const t in arguments[i])n[t]=arguments[i][t];return n}let W=$r;typeof Object.assign=="function"&&(W=Object.assign);function be(n,i,e,t){const r=n._nodes.get(i);let o=null;return r&&(t==="mixed"?o=r.out&&r.out[e]||r.undirected&&r.undirected[e]:t==="directed"?o=r.out&&r.out[e]:o=r.undirected&&r.undirected[e]),o}function Br(n){return n!==null&&typeof n=="object"&&typeof n.addUndirectedEdgeWithKey=="function"&&typeof n.dropNode=="function"}function q(n){return typeof n=="object"&&n!==null&&n.constructor===Object}function $i(n){let i;for(i in n)return!1;return!0}function re(n,i,e){Object.defineProperty(n,i,{enumerable:!1,configurable:!1,writable:!0,value:e})}function ne(n,i,e){const t={enumerable:!0,configurable:!0};typeof e=="function"?t.get=e:(t.value=e,t.writable=!1),Object.defineProperty(n,i,t)}function Yt(n){return!(!q(n)||n.attributes&&!Array.isArray(n.attributes))}function Mr(){let n=Math.floor(Math.random()*256)&255;return()=>n++}class It extends Error{constructor(i){super(),this.name="GraphError",this.message=i}}class R extends It{constructor(i){super(i),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,R.prototype.constructor)}}class E extends It{constructor(i){super(i),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,E.prototype.constructor)}}class D extends It{constructor(i){super(i),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}function kt(n,i){this.key=n,this.attributes=i,this.clear()}kt.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.directedSelfLoops=0,this.undirectedSelfLoops=0,this.in={},this.out={},this.undirected={}};function zt(n,i){this.key=n,this.attributes=i,this.clear()}zt.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedSelfLoops=0,this.in={},this.out={}};zt.prototype.upgradeToMixed=function(){this.undirectedDegree=0,this.undirectedSelfLoops=0,this.undirected={}};function Ot(n,i){this.key=n,this.attributes=i,this.clear()}Ot.prototype.clear=function(){this.undirectedDegree=0,this.undirectedSelfLoops=0,this.undirected={}};Ot.prototype.upgradeToMixed=function(){this.inDegree=0,this.outDegree=0,this.directedSelfLoops=0,this.in={},this.out={}};function Bi(n,i,e,t,r){this.key=i,this.attributes=r,this.undirected=n,this.source=e,this.target=t}function Mi(n,i,e,t,r,o,a){const s=n.multi;let u="out",h="in";i&&(u=h="undirected");let d,c;if(s){if(d=o[u],c=d[r],typeof c>"u"&&(c=new Set,d[r]=c),c.add(e),t===r&&i)return;d=a[h],typeof d[t]>"u"&&(d[t]=c)}else{if(o[u][r]=e,t===r&&i)return;a[h][t]=e}}function Hr(n,i,e){const t=n.multi,{source:r,target:o}=e,a=r.key,s=o.key,u=i?"undirected":"out",h=r[u],d=i?"undirected":"in";if(s in h)if(t){const l=h[s];l.size===1?(delete h[s],delete o[d][a]):l.delete(e)}else delete h[s];if(t)return;const c=o[d];delete c[a]}function Wr(n){const i=n._nodes.values();let e;for(;e=i.next(),e.done!==!0;)e.value.clear()}function jr(n){n._nodes.forEach((i,e)=>{if(i.out)for(const t in i.out){const r=new Set;r.add(i.out[t]),i.out[t]=r,n._nodes.get(t).in[e]=r}if(i.undirected)for(const t in i.undirected){if(t>e)continue;const r=new Set;r.add(i.undirected[t]),i.undirected[t]=r,n._nodes.get(t).undirected[e]=r}})}const Hi=0,Wi=1,Vr=2,ji=3;function Re(n,i,e,t,r,o,a){let s,u,h,d;if(t=""+t,e===Hi){if(s=n._nodes.get(t),!s)throw new E(`Graph.${i}: could not find the "${t}" node in the graph.`);h=r,d=o}else if(e===ji){if(r=""+r,u=n._edges.get(r),!u)throw new E(`Graph.${i}: could not find the "${r}" edge in the graph.`);const c=u.source.key,l=u.target.key;if(t===c)s=u.target;else if(t===l)s=u.source;else throw new E(`Graph.${i}: the "${t}" node is not attached to the "${r}" edge (${c}, ${l}).`);h=o,d=a}else{if(u=n._edges.get(t),!u)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);e===Wi?s=u.source:s=u.target,h=r,d=o}return[s,h,d]}function qr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);return a.attributes[s]}}function Yr(n,i,e){n.prototype[i]=function(t,r){const[o]=Re(this,i,e,t,r);return o.attributes}}function Kr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);return a.attributes.hasOwnProperty(s)}}function Zr(n,i,e){n.prototype[i]=function(t,r,o,a){const[s,u,h]=Re(this,i,e,t,r,o,a);return s.attributes[u]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Xr(n,i,e){n.prototype[i]=function(t,r,o,a){const[s,u,h]=Re(this,i,e,t,r,o,a);if(typeof h!="function")throw new R(`Graph.${i}: updater should be a function.`);const d=s.attributes,c=h(d[u]);return d[u]=c,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Qr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function Jr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);if(!q(s))throw new R(`Graph.${i}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function en(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);if(!q(s))throw new R(`Graph.${i}: provided attributes are not a plain object.`);return W(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function tn(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);if(typeof s!="function")throw new R(`Graph.${i}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const rn=[{name:n=>`get${n}Attribute`,attacher:qr},{name:n=>`get${n}Attributes`,attacher:Yr},{name:n=>`has${n}Attribute`,attacher:Kr},{name:n=>`set${n}Attribute`,attacher:Zr},{name:n=>`update${n}Attribute`,attacher:Xr},{name:n=>`remove${n}Attribute`,attacher:Qr},{name:n=>`replace${n}Attributes`,attacher:Jr},{name:n=>`merge${n}Attributes`,attacher:en},{name:n=>`update${n}Attributes`,attacher:tn}];function nn(n){rn.forEach(function({name:i,attacher:e}){e(n,i("Node"),Hi),e(n,i("Source"),Wi),e(n,i("Target"),Vr),e(n,i("Opposite"),ji)})}function on(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return o.attributes[r]}}function an(n,i,e){n.prototype[i]=function(t){let r;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+t,a=""+arguments[1];if(r=be(this,o,a,e),!r)throw new E(`Graph.${i}: could not find an edge for the given path ("${o}" - "${a}").`)}else if(t=""+t,r=this._edges.get(t),!r)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&r.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return r.attributes}}function sn(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return o.attributes.hasOwnProperty(r)}}function un(n,i,e){n.prototype[i]=function(t,r,o){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+t,u=""+r;if(r=arguments[2],o=arguments[3],a=be(this,s,u,e),!a)throw new E(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else if(t=""+t,a=this._edges.get(t),!a)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&a.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return a.attributes[r]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:r}),this}}function hn(n,i,e){n.prototype[i]=function(t,r,o){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+t,u=""+r;if(r=arguments[2],o=arguments[3],a=be(this,s,u,e),!a)throw new E(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else if(t=""+t,a=this._edges.get(t),!a)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(typeof o!="function")throw new R(`Graph.${i}: updater should be a function.`);if(e!=="mixed"&&a.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return a.attributes[r]=o(a.attributes[r]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:r}),this}}function dn(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return delete o.attributes[r],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:r}),this}}function cn(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(!q(r))throw new R(`Graph.${i}: provided attributes are not a plain object.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return o.attributes=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function ln(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(!q(r))throw new R(`Graph.${i}: provided attributes are not a plain object.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return W(o.attributes,r),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:r}),this}}function fn(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(typeof r!="function")throw new R(`Graph.${i}: provided updater is not a function.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return o.attributes=r(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const gn=[{name:n=>`get${n}Attribute`,attacher:on},{name:n=>`get${n}Attributes`,attacher:an},{name:n=>`has${n}Attribute`,attacher:sn},{name:n=>`set${n}Attribute`,attacher:un},{name:n=>`update${n}Attribute`,attacher:hn},{name:n=>`remove${n}Attribute`,attacher:dn},{name:n=>`replace${n}Attributes`,attacher:cn},{name:n=>`merge${n}Attributes`,attacher:ln},{name:n=>`update${n}Attributes`,attacher:fn}];function pn(n){gn.forEach(function({name:i,attacher:e}){e(n,i("Edge"),"mixed"),e(n,i("DirectedEdge"),"directed"),e(n,i("UndirectedEdge"),"undirected")})}const vn=[{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 mn(n,i){for(const e in i)n.push(i[e].key)}function yn(n,i){for(const e in i)i[e].forEach(t=>n.push(t.key))}function bn(n,i,e){for(const t in n){if(t===e)continue;const r=n[t];i(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected)}}function wn(n,i,e){for(const t in n)t!==e&&n[t].forEach(r=>i(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected))}function En(n,i,e){let t=!1;for(const r in n){if(r===e)continue;const o=n[r];if(t=i(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),t)return o.key}}function _n(n,i,e){let t,r,o,a,s,u=!1;for(const h in n)if(h!==e){for(t=n[h].values();r=t.next(),r.done!==!0;)if(o=r.value,a=o.source,s=o.target,u=i(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected),u)return o.key}}function ct(n,i){const e=Object.keys(n),t=e.length;let r=null,o=0;return new oe(function a(){let s;if(r){const u=r.next();if(u.done)return r=null,o++,a();s=u.value}else{if(o>=t)return{done:!0};const u=e[o];if(u===i)return o++,a();if(s=n[u],s instanceof Set)return r=s.values(),a();o++}return{done:!1,value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected}}})}function Tn(n,i,e){const t=i[e];t&&n.push(t.key)}function An(n,i,e){const t=i[e];t&&t.forEach(r=>n.push(r.key))}function Sn(n,i,e){const t=n[i];if(!t)return;const r=t.source,o=t.target;e(t.key,t.attributes,r.key,o.key,r.attributes,o.attributes,t.undirected)}function Rn(n,i,e){const t=n[i];t&&t.forEach(r=>e(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected))}function Cn(n,i,e){const t=n[i];if(!t)return;const r=t.source,o=t.target;if(e(t.key,t.attributes,r.key,o.key,r.attributes,o.attributes,t.undirected))return t.key}function kn(n,i,e){const t=n[i];if(!t)return;let r=!1;const o=t.values();let a,s;for(;a=o.next(),a.done!==!0;)if(s=a.value,r=e(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),r)return s.key}function lt(n,i){const e=n[i];if(e instanceof Set){const t=e.values();return new oe(function(){const r=t.next();if(r.done)return r;const o=r.value;return{done:!1,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}}})}return oe.of([e.key,e.attributes,e.source.key,e.target.key,e.source.attributes,e.target.attributes])}function Ln(n,i){if(n.size===0)return[];if(i==="mixed"||i===n.type)return typeof Array.from=="function"?Array.from(n._edges.keys()):Pt(n._edges.keys(),n._edges.size);const e=i==="undirected"?n.undirectedSize:n.directedSize,t=new Array(e),r=i==="undirected",o=n._edges.values();let a=0,s,u;for(;s=o.next(),s.done!==!0;)u=s.value,u.undirected===r&&(t[a++]=u.key);return t}function Dn(n,i,e){if(n.size===0)return;const t=i!=="mixed"&&i!==n.type,r=i==="undirected";let o,a;const s=n._edges.values();for(;o=s.next(),o.done!==!0;){if(a=o.value,t&&a.undirected!==r)continue;const{key:u,attributes:h,source:d,target:c}=a;e(u,h,d.key,c.key,d.attributes,c.attributes,a.undirected)}}function xn(n,i,e){if(n.size===0)return;const t=i!=="mixed"&&i!==n.type,r=i==="undirected";let o,a,s=!1;const u=n._edges.values();for(;o=u.next(),o.done!==!0;){if(a=o.value,t&&a.undirected!==r)continue;const{key:h,attributes:d,source:c,target:l}=a;if(s=e(h,d,c.key,l.key,c.attributes,l.attributes,a.undirected),s)return h}}function Gn(n,i){if(n.size===0)return oe.empty();const e=i!=="mixed"&&i!==n.type,t=i==="undirected",r=n._edges.values();return new oe(function(){let a,s;for(;;){if(a=r.next(),a.done)return a;if(s=a.value,!(e&&s.undirected!==t))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}})}function Fn(n,i,e,t){const r=[],o=n?yn:mn;return i!=="undirected"&&(e!=="out"&&o(r,t.in),e!=="in"&&o(r,t.out),!e&&t.directedSelfLoops>0&&r.splice(r.lastIndexOf(t.key),1)),i!=="directed"&&o(r,t.undirected),r}function Nn(n,i,e,t,r){const o=n?wn:bn;i!=="undirected"&&(e!=="out"&&o(t.in,r),e!=="in"&&o(t.out,r,e?null:t.key)),i!=="directed"&&o(t.undirected,r)}function Pn(n,i,e,t,r){const o=n?_n:En;let a;if(i!=="undirected"&&(e!=="out"&&(a=o(t.in,r),a)||e!=="in"&&(a=o(t.out,r,e?null:t.key),a))||i!=="directed"&&(a=o(t.undirected,r),a))return a}function In(n,i,e){let t=oe.empty();return n!=="undirected"&&(i!=="out"&&typeof e.in<"u"&&(t=Se(t,ct(e.in))),i!=="in"&&typeof e.out<"u"&&(t=Se(t,ct(e.out,i?null:e.key)))),n!=="directed"&&typeof e.undirected<"u"&&(t=Se(t,ct(e.undirected))),t}function zn(n,i,e,t,r){const o=i?An:Tn,a=[];return n!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&o(a,t.in,r),typeof t.out<"u"&&e!=="in"&&o(a,t.out,r),!e&&t.directedSelfLoops>0&&a.splice(a.lastIndexOf(t.key),1)),n!=="directed"&&typeof t.undirected<"u"&&o(a,t.undirected,r),a}function On(n,i,e,t,r,o){const a=i?Rn:Sn;n!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&a(t.in,r,o),t.key!==r&&typeof t.out<"u"&&e!=="in"&&a(t.out,r,o)),n!=="directed"&&typeof t.undirected<"u"&&a(t.undirected,r,o)}function Un(n,i,e,t,r,o){const a=i?kn:Cn;let s;if(n!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&(s=a(t.in,r,o),s)||t.key!==r&&typeof t.out<"u"&&e!=="in"&&(s=a(t.out,r,o,e?null:t.key),s))||n!=="directed"&&typeof t.undirected<"u"&&(s=a(t.undirected,r,o),s))return s}function $n(n,i,e,t){let r=oe.empty();return n!=="undirected"&&(typeof e.in<"u"&&i!=="out"&&t in e.in&&(r=Se(r,lt(e.in,t))),typeof e.out<"u"&&i!=="in"&&t in e.out&&(r=Se(r,lt(e.out,t)))),n!=="directed"&&typeof e.undirected<"u"&&t in e.undirected&&(r=Se(r,lt(e.undirected,t))),r}function Bn(n,i){const{name:e,type:t,direction:r}=i;n.prototype[e]=function(o,a){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return[];if(!arguments.length)return Ln(this,t);if(arguments.length===1){o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new E(`Graph.${e}: could not find the "${o}" node in the graph.`);return Fn(this.multi,t==="mixed"?this.type:t,r,s)}if(arguments.length===2){o=""+o,a=""+a;const s=this._nodes.get(o);if(!s)throw new E(`Graph.${e}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new E(`Graph.${e}: could not find the "${a}" target node in the graph.`);return zn(t,this.multi,r,s,a)}throw new R(`Graph.${e}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Mn(n,i){const{name:e,type:t,direction:r}=i,o="forEach"+e[0].toUpperCase()+e.slice(1,-1);n.prototype[o]=function(h,d,c){if(!(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)){if(arguments.length===1)return c=h,Dn(this,t,c);if(arguments.length===2){h=""+h,c=d;const l=this._nodes.get(h);if(typeof l>"u")throw new E(`Graph.${o}: could not find the "${h}" node in the graph.`);return Nn(this.multi,t==="mixed"?this.type:t,r,l,c)}if(arguments.length===3){h=""+h,d=""+d;const l=this._nodes.get(h);if(!l)throw new E(`Graph.${o}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(d))throw new E(`Graph.${o}: could not find the "${d}" target node in the graph.`);return On(t,this.multi,r,l,d,c)}throw new R(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const a="map"+e[0].toUpperCase()+e.slice(1);n.prototype[a]=function(){const h=Array.prototype.slice.call(arguments),d=h.pop();let c;if(h.length===0){let l=0;t!=="directed"&&(l+=this.undirectedSize),t!=="undirected"&&(l+=this.directedSize),c=new Array(l);let f=0;h.push((y,w,_,k,p,v,m)=>{c[f++]=d(y,w,_,k,p,v,m)})}else c=[],h.push((l,f,y,w,_,k,p)=>{c.push(d(l,f,y,w,_,k,p))});return this[o].apply(this,h),c};const s="filter"+e[0].toUpperCase()+e.slice(1);n.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),d=h.pop(),c=[];return h.push((l,f,y,w,_,k,p)=>{d(l,f,y,w,_,k,p)&&c.push(l)}),this[o].apply(this,h),c};const u="reduce"+e[0].toUpperCase()+e.slice(1);n.prototype[u]=function(){let h=Array.prototype.slice.call(arguments);if(h.length<2||h.length>4)throw new R(`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 R(`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,c;h.length===2?(d=h[0],c=h[1],h=[]):h.length===3?(d=h[1],c=h[2],h=[h[0]]):h.length===4&&(d=h[2],c=h[3],h=[h[0],h[1]]);let l=c;return h.push((f,y,w,_,k,p,v)=>{l=d(l,f,y,w,_,k,p,v)}),this[o].apply(this,h),l}}function Hn(n,i){const{name:e,type:t,direction:r}=i,o="find"+e[0].toUpperCase()+e.slice(1,-1);n.prototype[o]=function(u,h,d){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return!1;if(arguments.length===1)return d=u,xn(this,t,d);if(arguments.length===2){u=""+u,d=h;const c=this._nodes.get(u);if(typeof c>"u")throw new E(`Graph.${o}: could not find the "${u}" node in the graph.`);return Pn(this.multi,t==="mixed"?this.type:t,r,c,d)}if(arguments.length===3){u=""+u,h=""+h;const c=this._nodes.get(u);if(!c)throw new E(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(h))throw new E(`Graph.${o}: could not find the "${h}" target node in the graph.`);return Un(t,this.multi,r,c,h,d)}throw new R(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const a="some"+e[0].toUpperCase()+e.slice(1,-1);n.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((c,l,f,y,w,_,k)=>h(c,l,f,y,w,_,k)),!!this[o].apply(this,u)};const s="every"+e[0].toUpperCase()+e.slice(1,-1);n.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((c,l,f,y,w,_,k)=>!h(c,l,f,y,w,_,k)),!this[o].apply(this,u)}}function Wn(n,i){const{name:e,type:t,direction:r}=i,o=e.slice(0,-1)+"Entries";n.prototype[o]=function(a,s){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return oe.empty();if(!arguments.length)return Gn(this,t);if(arguments.length===1){a=""+a;const u=this._nodes.get(a);if(!u)throw new E(`Graph.${o}: could not find the "${a}" node in the graph.`);return In(t,r,u)}if(arguments.length===2){a=""+a,s=""+s;const u=this._nodes.get(a);if(!u)throw new E(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new E(`Graph.${o}: could not find the "${s}" target node in the graph.`);return $n(t,r,u,s)}throw new R(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function jn(n){vn.forEach(i=>{Bn(n,i),Mn(n,i),Hn(n,i),Wn(n,i)})}const Vn=[{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 ft(n,i){if(!(typeof i>"u"))for(const e in i)n.add(e)}function qn(n,i,e){if(n!=="mixed"){if(n==="undirected")return Object.keys(e.undirected);if(typeof i=="string")return Object.keys(e[i])}const t=new Set;return n!=="undirected"&&(i!=="out"&&ft(t,e.in),i!=="in"&&ft(t,e.out)),n!=="directed"&&ft(t,e.undirected),Pt(t.values(),t.size)}function Kt(n,i,e){for(const t in i){let r=i[t];r instanceof Set&&(r=r.values().next().value);const o=r.source,a=r.target,s=o===n?a:o;e(s.key,s.attributes)}}function gt(n,i,e,t){for(const r in e){let o=e[r];o instanceof Set&&(o=o.values().next().value);const a=o.source,s=o.target,u=a===i?s:a;n.has(u.key)||(n.add(u.key),t(u.key,u.attributes))}}function Zt(n,i,e){for(const t in i){let r=i[t];r instanceof Set&&(r=r.values().next().value);const o=r.source,a=r.target,s=o===n?a:o;if(e(s.key,s.attributes))return s.key}}function pt(n,i,e,t){for(const r in e){let o=e[r];o instanceof Set&&(o=o.values().next().value);const a=o.source,s=o.target,u=a===i?s:a;if(n.has(u.key))continue;if(n.add(u.key),t(u.key,u.attributes))return u.key}}function Yn(n,i,e,t){if(n!=="mixed"){if(n==="undirected")return Kt(e,e.undirected,t);if(typeof i=="string")return Kt(e,e[i],t)}const r=new Set;n!=="undirected"&&(i!=="out"&>(r,e,e.in,t),i!=="in"&>(r,e,e.out,t)),n!=="directed"&>(r,e,e.undirected,t)}function Kn(n,i,e,t){if(n!=="mixed"){if(n==="undirected")return Zt(e,e.undirected,t);if(typeof i=="string")return Zt(e,e[i],t)}const r=new Set;let o;if(n!=="undirected"&&(i!=="out"&&(o=pt(r,e,e.in,t),o)||i!=="in"&&(o=pt(r,e,e.out,t),o))||n!=="directed"&&(o=pt(r,e,e.undirected,t),o))return o}function Xt(n,i){const e=Object.keys(i),t=e.length;let r=0;return new oe(function(){if(r>=t)return{done:!0};let o=i[e[r++]];o instanceof Set&&(o=o.values().next().value);const a=o.source,s=o.target,u=a===n?s:a;return{done:!1,value:{neighbor:u.key,attributes:u.attributes}}})}function vt(n,i,e){const t=Object.keys(e),r=t.length;let o=0;return new oe(function a(){if(o>=r)return{done:!0};let s=e[t[o++]];s instanceof Set&&(s=s.values().next().value);const u=s.source,h=s.target,d=u===i?h:u;return n.has(d.key)?a():(n.add(d.key),{done:!1,value:{neighbor:d.key,attributes:d.attributes}})})}function Zn(n,i,e){if(n!=="mixed"){if(n==="undirected")return Xt(e,e.undirected);if(typeof i=="string")return Xt(e,e[i])}let t=oe.empty();const r=new Set;return n!=="undirected"&&(i!=="out"&&(t=Se(t,vt(r,e,e.in))),i!=="in"&&(t=Se(t,vt(r,e,e.out)))),n!=="directed"&&(t=Se(t,vt(r,e,e.undirected))),t}function Xn(n,i){const{name:e,type:t,direction:r}=i;n.prototype[e]=function(o){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return[];o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new E(`Graph.${e}: could not find the "${o}" node in the graph.`);return qn(t==="mixed"?this.type:t,r,a)}}function Qn(n,i){const{name:e,type:t,direction:r}=i,o="forEach"+e[0].toUpperCase()+e.slice(1,-1);n.prototype[o]=function(h,d){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return;h=""+h;const c=this._nodes.get(h);if(typeof c>"u")throw new E(`Graph.${o}: could not find the "${h}" node in the graph.`);Yn(t==="mixed"?this.type:t,r,c,d)};const a="map"+e[0].toUpperCase()+e.slice(1);n.prototype[a]=function(h,d){const c=[];return this[o](h,(l,f)=>{c.push(d(l,f))}),c};const s="filter"+e[0].toUpperCase()+e.slice(1);n.prototype[s]=function(h,d){const c=[];return this[o](h,(l,f)=>{d(l,f)&&c.push(l)}),c};const u="reduce"+e[0].toUpperCase()+e.slice(1);n.prototype[u]=function(h,d,c){if(arguments.length<3)throw new R(`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 l=c;return this[o](h,(f,y)=>{l=d(l,f,y)}),l}}function Jn(n,i){const{name:e,type:t,direction:r}=i,o=e[0].toUpperCase()+e.slice(1,-1),a="find"+o;n.prototype[a]=function(h,d){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return;h=""+h;const c=this._nodes.get(h);if(typeof c>"u")throw new E(`Graph.${a}: could not find the "${h}" node in the graph.`);return Kn(t==="mixed"?this.type:t,r,c,d)};const s="some"+o;n.prototype[s]=function(h,d){return!!this[a](h,d)};const u="every"+o;n.prototype[u]=function(h,d){return!this[a](h,(l,f)=>!d(l,f))}}function eo(n,i){const{name:e,type:t,direction:r}=i,o=e.slice(0,-1)+"Entries";n.prototype[o]=function(a){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return oe.empty();a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new E(`Graph.${o}: could not find the "${a}" node in the graph.`);return Zn(t==="mixed"?this.type:t,r,s)}}function to(n){Vn.forEach(i=>{Xn(n,i),Qn(n,i),Jn(n,i),eo(n,i)})}function Ze(n,i,e,t,r){const o=t._nodes.values(),a=t.type;let s,u,h,d,c,l;for(;s=o.next(),s.done!==!0;){let f=!1;if(u=s.value,a!=="undirected"){d=u.out;for(h in d)c=d[h],l=c.target,f=!0,r(u.key,l.key,u.attributes,l.attributes,c.key,c.attributes,c.undirected)}if(a!=="directed"){d=u.undirected;for(h in d)i&&u.key>h||(c=d[h],l=c.target,l.key!==h&&(l=c.source),f=!0,r(u.key,l.key,u.attributes,l.attributes,c.key,c.attributes,c.undirected))}e&&!f&&r(u.key,null,u.attributes,null,null,null,null)}}function Xe(n,i,e,t,r){const o=t._nodes.values(),a=t.type;let s,u,h,d,c,l,f,y;for(;s=o.next(),s.done!==!0;){let w=!1;if(u=s.value,a!=="undirected"){l=u.out;for(h in l)for(d=l[h].values();c=d.next(),c.done!==!0;)f=c.value,y=f.target,w=!0,r(u.key,y.key,u.attributes,y.attributes,f.key,f.attributes,f.undirected)}if(a!=="directed"){l=u.undirected;for(h in l)if(!(i&&u.key>h))for(d=l[h].values();c=d.next(),c.done!==!0;)f=c.value,y=f.target,y.key!==h&&(y=f.source),w=!0,r(u.key,y.key,u.attributes,y.attributes,f.key,f.attributes,f.undirected)}e&&!w&&r(u.key,null,u.attributes,null,null,null,null)}}function Qt(n,i){const e={key:n};return $i(i.attributes)||(e.attributes=W({},i.attributes)),e}function Jt(n,i){const e={key:n,source:i.source.key,target:i.target.key};return $i(i.attributes)||(e.attributes=W({},i.attributes)),i.undirected&&(e.undirected=!0),e}function io(n){return q(n)?"key"in n?"attributes"in n&&(!q(n.attributes)||n.attributes===null)?"invalid-attributes":null:"no-key":"not-object"}function ro(n){return q(n)?"source"in n?"target"in n?"attributes"in n&&(!q(n.attributes)||n.attributes===null)?"invalid-attributes":"undirected"in n&&typeof n.undirected!="boolean"?"invalid-undirected":null:"no-target":"no-source":"not-object"}const no=Mr(),oo=new Set(["directed","undirected","mixed"]),ei=new Set(["domain","_events","_eventsCount","_maxListeners"]),ao=[{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"}],so={allowSelfLoops:!0,multi:!1,type:"mixed"};function uo(n,i,e){if(e&&!q(e))throw new R(`Graph.addNode: invalid attributes. Expecting an object but got "${e}"`);if(i=""+i,e=e||{},n._nodes.has(i))throw new D(`Graph.addNode: the "${i}" node already exist in the graph.`);const t=new n.NodeDataClass(i,e);return n._nodes.set(i,t),n.emit("nodeAdded",{key:i,attributes:e}),t}function ti(n,i,e){const t=new n.NodeDataClass(i,e);return n._nodes.set(i,t),n.emit("nodeAdded",{key:i,attributes:e}),t}function Vi(n,i,e,t,r,o,a,s){if(!t&&n.type==="undirected")throw new D(`Graph.${i}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(t&&n.type==="directed")throw new D(`Graph.${i}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!q(s))throw new R(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!n.allowSelfLoops&&o===a)throw new D(`Graph.${i}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=n._nodes.get(o),h=n._nodes.get(a);if(!u)throw new E(`Graph.${i}: source node "${o}" not found.`);if(!h)throw new E(`Graph.${i}: target node "${a}" not found.`);const d={key:null,undirected:t,source:o,target:a,attributes:s};if(e)r=n._edgeKeyGenerator();else if(r=""+r,n._edges.has(r))throw new D(`Graph.${i}: the "${r}" edge already exists in the graph.`);if(!n.multi&&(t?typeof u.undirected[a]<"u":typeof u.out[a]<"u"))throw new D(`Graph.${i}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const c=new Bi(t,r,u,h,s);return n._edges.set(r,c),o===a?t?(u.undirectedSelfLoops++,n._undirectedSelfLoopCount++):(u.directedSelfLoops++,n._directedSelfLoopCount++):t?(u.undirectedDegree++,h.undirectedDegree++):(u.outDegree++,h.inDegree++),Mi(n,t,c,o,a,u,h),t?n._undirectedSize++:n._directedSize++,d.key=r,n.emit("edgeAdded",d),r}function ho(n,i,e,t,r,o,a,s,u){if(!t&&n.type==="undirected")throw new D(`Graph.${i}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(t&&n.type==="directed")throw new D(`Graph.${i}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(u){if(typeof s!="function")throw new R(`Graph.${i}: invalid updater function. Expecting a function but got "${s}"`)}else if(!q(s))throw new R(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let h;if(u&&(h=s,s=void 0),!n.allowSelfLoops&&o===a)throw new D(`Graph.${i}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=n._nodes.get(o),c=n._nodes.get(a),l,f;if(!e&&(l=n._edges.get(r),l)){if((l.source.key!==o||l.target.key!==a)&&(!t||l.source.key!==a||l.target.key!==o))throw new D(`Graph.${i}: inconsistency detected when attempting to merge the "${r}" edge with "${o}" source & "${a}" target vs. ("${l.source.key}", "${l.target.key}").`);f=l}if(!f&&!n.multi&&d&&(f=t?d.undirected[a]:d.out[a]),f){const k=[f.key,!1,!1,!1];if(u?!h:!s)return k;if(u){const p=f.attributes;f.attributes=h(p),n.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else W(f.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return k}s=s||{},u&&h&&(s=h(s));const y={key:null,undirected:t,source:o,target:a,attributes:s};if(e)r=n._edgeKeyGenerator();else if(r=""+r,n._edges.has(r))throw new D(`Graph.${i}: the "${r}" edge already exists in the graph.`);let w=!1,_=!1;return d||(d=ti(n,o,{}),w=!0,o===a&&(c=d,_=!0)),c||(c=ti(n,a,{}),_=!0),l=new Bi(t,r,d,c,s),n._edges.set(r,l),o===a?t?(d.undirectedSelfLoops++,n._undirectedSelfLoopCount++):(d.directedSelfLoops++,n._directedSelfLoopCount++):t?(d.undirectedDegree++,c.undirectedDegree++):(d.outDegree++,c.inDegree++),Mi(n,t,l,o,a,d,c),t?n._undirectedSize++:n._directedSize++,y.key=r,n.emit("edgeAdded",y),[r,!0,w,_]}class I extends zi.EventEmitter{constructor(i){if(super(),i=W({},so,i),typeof i.multi!="boolean")throw new R(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${i.multi}".`);if(!oo.has(i.type))throw new R(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${i.type}".`);if(typeof i.allowSelfLoops!="boolean")throw new R(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${i.allowSelfLoops}".`);const e=i.type==="mixed"?kt:i.type==="directed"?zt:Ot;re(this,"NodeDataClass",e);const t=no();let r=0;const o=()=>{let a;do a="geid_"+t+"_"+r++;while(this._edges.has(a));return a};re(this,"_attributes",{}),re(this,"_nodes",new Map),re(this,"_edges",new Map),re(this,"_directedSize",0),re(this,"_undirectedSize",0),re(this,"_directedSelfLoopCount",0),re(this,"_undirectedSelfLoopCount",0),re(this,"_edgeKeyGenerator",o),re(this,"_options",i),ei.forEach(a=>re(this,a,this[a])),ne(this,"order",()=>this._nodes.size),ne(this,"size",()=>this._edges.size),ne(this,"directedSize",()=>this._directedSize),ne(this,"undirectedSize",()=>this._undirectedSize),ne(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ne(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ne(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ne(this,"multi",this._options.multi),ne(this,"type",this._options.type),ne(this,"allowSelfLoops",this._options.allowSelfLoops),ne(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(i){return this._nodes.has(""+i)}hasDirectedEdge(i,e){if(this.type==="undirected")return!1;if(arguments.length===1){const t=""+i,r=this._edges.get(t);return!!r&&!r.undirected}else if(arguments.length===2){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)return!1;const r=t.out[e];return r?this.multi?!!r.size:!0:!1}throw new R(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(i,e){if(this.type==="directed")return!1;if(arguments.length===1){const t=""+i,r=this._edges.get(t);return!!r&&r.undirected}else if(arguments.length===2){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)return!1;const r=t.undirected[e];return r?this.multi?!!r.size:!0:!1}throw new R(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(i,e){if(arguments.length===1){const t=""+i;return this._edges.has(t)}else if(arguments.length===2){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)return!1;let r=typeof t.out<"u"&&t.out[e];return r||(r=typeof t.undirected<"u"&&t.undirected[e]),r?this.multi?!!r.size:!0:!1}throw new R(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(i,e){if(this.type==="undirected")return;if(i=""+i,e=""+e,this.multi)throw new D("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const t=this._nodes.get(i);if(!t)throw new E(`Graph.directedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(e))throw new E(`Graph.directedEdge: could not find the "${e}" target node in the graph.`);const r=t.out&&t.out[e]||void 0;if(r)return r.key}undirectedEdge(i,e){if(this.type==="directed")return;if(i=""+i,e=""+e,this.multi)throw new D("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const t=this._nodes.get(i);if(!t)throw new E(`Graph.undirectedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(e))throw new E(`Graph.undirectedEdge: could not find the "${e}" target node in the graph.`);const r=t.undirected&&t.undirected[e]||void 0;if(r)return r.key}edge(i,e){if(this.multi)throw new D("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.edge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(e))throw new E(`Graph.edge: could not find the "${e}" target node in the graph.`);const r=t.out&&t.out[e]||t.undirected&&t.undirected[e]||void 0;if(r)return r.key}areDirectedNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areDirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:e in t.in||e in t.out}areOutNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areOutNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:e in t.out}areInNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areInNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:e in t.in}areUndirectedNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areUndirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="directed"?!1:e in t.undirected}areNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&(e in t.in||e in t.out)||this.type!=="directed"&&e in t.undirected}areInboundNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areInboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&e in t.in||this.type!=="directed"&&e in t.undirected}areOutboundNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areOutboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&e in t.out||this.type!=="directed"&&e in t.undirected}inDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.inDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.inDegree+e.directedSelfLoops}outDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.outDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.outDegree+e.directedSelfLoops}directedDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.directedDegree: could not find the "${i}" node in the graph.`);if(this.type==="undirected")return 0;const t=e.directedSelfLoops,r=e.inDegree+t,o=e.outDegree+t;return r+o}undirectedDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.undirectedDegree: could not find the "${i}" node in the graph.`);if(this.type==="directed")return 0;const t=e.undirectedSelfLoops;return e.undirectedDegree+t*2}degree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.degree: could not find the "${i}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=e.undirectedDegree+e.undirectedSelfLoops*2),this.type!=="undirected"&&(t+=e.inDegree+e.outDegree+e.directedSelfLoops*2),t}inDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.inDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.inDegree}outDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.outDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.outDegree}directedDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.directedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.inDegree+e.outDegree}undirectedDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="directed"?0:e.undirectedDegree}degreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.degreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=e.undirectedDegree),this.type!=="undirected"&&(t+=e.inDegree+e.outDegree),t}source(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.source: could not find the "${i}" edge in the graph.`);return e.source.key}target(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.target: could not find the "${i}" edge in the graph.`);return e.target.key}extremities(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.extremities: could not find the "${i}" edge in the graph.`);return[e.source.key,e.target.key]}opposite(i,e){i=""+i,e=""+e;const t=this._edges.get(e);if(!t)throw new E(`Graph.opposite: could not find the "${e}" edge in the graph.`);const r=t.source.key,o=t.target.key;if(i===r)return o;if(i===o)return r;throw new E(`Graph.opposite: the "${i}" node is not attached to the "${e}" edge (${r}, ${o}).`)}hasExtremity(i,e){i=""+i,e=""+e;const t=this._edges.get(i);if(!t)throw new E(`Graph.hasExtremity: could not find the "${i}" edge in the graph.`);return t.source.key===e||t.target.key===e}isUndirected(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.isUndirected: could not find the "${i}" edge in the graph.`);return e.undirected}isDirected(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.isDirected: could not find the "${i}" edge in the graph.`);return!e.undirected}isSelfLoop(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.isSelfLoop: could not find the "${i}" edge in the graph.`);return e.source===e.target}addNode(i,e){return uo(this,i,e).key}mergeNode(i,e){if(e&&!q(e))throw new R(`Graph.mergeNode: invalid attributes. Expecting an object but got "${e}"`);i=""+i,e=e||{};let t=this._nodes.get(i);return t?(e&&(W(t.attributes,e),this.emit("nodeAttributesUpdated",{type:"merge",key:i,attributes:t.attributes,data:e})),[i,!1]):(t=new this.NodeDataClass(i,e),this._nodes.set(i,t),this.emit("nodeAdded",{key:i,attributes:e}),[i,!0])}updateNode(i,e){if(e&&typeof e!="function")throw new R(`Graph.updateNode: invalid updater function. Expecting a function but got "${e}"`);i=""+i;let t=this._nodes.get(i);if(t){if(e){const o=t.attributes;t.attributes=e(o),this.emit("nodeAttributesUpdated",{type:"replace",key:i,attributes:t.attributes})}return[i,!1]}const r=e?e({}):{};return t=new this.NodeDataClass(i,r),this._nodes.set(i,t),this.emit("nodeAdded",{key:i,attributes:r}),[i,!0]}dropNode(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.dropNode: could not find the "${i}" node in the graph.`);this.forEachEdge(i,t=>{this.dropEdge(t)}),this._nodes.delete(i),this.emit("nodeDropped",{key:i,attributes:e.attributes})}dropEdge(i){let e;if(arguments.length>1){const s=""+arguments[0],u=""+arguments[1];if(e=be(this,s,u,this.type),!e)throw new E(`Graph.dropEdge: could not find the "${s}" -> "${u}" edge in the graph.`)}else if(i=""+i,e=this._edges.get(i),!e)throw new E(`Graph.dropEdge: could not find the "${i}" edge in the graph.`);this._edges.delete(e.key);const{source:t,target:r,attributes:o}=e,a=e.undirected;return t===r?a?(t.undirectedSelfLoops--,this._undirectedSelfLoopCount--):(t.directedSelfLoops--,this._directedSelfLoopCount--):a?(t.undirectedDegree--,r.undirectedDegree--):(t.outDegree--,r.inDegree--),Hr(this,a,e),a?this._undirectedSize--:this._directedSize--,this.emit("edgeDropped",{key:i,attributes:o,source:t.key,target:r.key,undirected:a}),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){Wr(this),this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(i){return this._attributes[i]}getAttributes(){return this._attributes}hasAttribute(i){return this._attributes.hasOwnProperty(i)}setAttribute(i,e){return this._attributes[i]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}updateAttribute(i,e){if(typeof e!="function")throw new R("Graph.updateAttribute: updater should be a function.");const t=this._attributes[i];return this._attributes[i]=e(t),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}removeAttribute(i){return delete this._attributes[i],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:i}),this}replaceAttributes(i){if(!q(i))throw new R("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=i,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(i){if(!q(i))throw new R("Graph.mergeAttributes: provided attributes are not a plain object.");return W(this._attributes,i),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:i}),this}updateAttributes(i){if(typeof i!="function")throw new R("Graph.updateAttributes: provided updater is not a function.");return this._attributes=i(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(i,e){if(typeof i!="function")throw new R("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!Yt(e))throw new R("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const t=this._nodes.values();let r,o;for(;r=t.next(),r.done!==!0;)o=r.value,o.attributes=i(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})}updateEachEdgeAttributes(i,e){if(typeof i!="function")throw new R("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!Yt(e))throw new R("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const t=this._edges.values();let r,o,a,s;for(;r=t.next(),r.done!==!0;)o=r.value,a=o.source,s=o.target,o.attributes=i(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})}forEachAdjacencyEntry(i){if(typeof i!="function")throw new R("Graph.forEachAdjacencyEntry: expecting a callback.");this.multi?Xe(!1,!1,!1,this,i):Ze(!1,!1,!1,this,i)}forEachAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new R("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");this.multi?Xe(!1,!1,!0,this,i):Ze(!1,!1,!0,this,i)}forEachAssymetricAdjacencyEntry(i){if(typeof i!="function")throw new R("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");this.multi?Xe(!1,!0,!1,this,i):Ze(!1,!0,!1,this,i)}forEachAssymetricAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new R("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");this.multi?Xe(!1,!0,!0,this,i):Ze(!1,!0,!0,this,i)}nodes(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):Pt(this._nodes.keys(),this._nodes.size)}forEachNode(i){if(typeof i!="function")throw new R("Graph.forEachNode: expecting a callback.");const e=this._nodes.values();let t,r;for(;t=e.next(),t.done!==!0;)r=t.value,i(r.key,r.attributes)}findNode(i){if(typeof i!="function")throw new R("Graph.findNode: expecting a callback.");const e=this._nodes.values();let t,r;for(;t=e.next(),t.done!==!0;)if(r=t.value,i(r.key,r.attributes))return r.key}mapNodes(i){if(typeof i!="function")throw new R("Graph.mapNode: expecting a callback.");const e=this._nodes.values();let t,r;const o=new Array(this.order);let a=0;for(;t=e.next(),t.done!==!0;)r=t.value,o[a++]=i(r.key,r.attributes);return o}someNode(i){if(typeof i!="function")throw new R("Graph.someNode: expecting a callback.");const e=this._nodes.values();let t,r;for(;t=e.next(),t.done!==!0;)if(r=t.value,i(r.key,r.attributes))return!0;return!1}everyNode(i){if(typeof i!="function")throw new R("Graph.everyNode: expecting a callback.");const e=this._nodes.values();let t,r;for(;t=e.next(),t.done!==!0;)if(r=t.value,!i(r.key,r.attributes))return!1;return!0}filterNodes(i){if(typeof i!="function")throw new R("Graph.filterNodes: expecting a callback.");const e=this._nodes.values();let t,r;const o=[];for(;t=e.next(),t.done!==!0;)r=t.value,i(r.key,r.attributes)&&o.push(r.key);return o}reduceNodes(i,e){if(typeof i!="function")throw new R("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new R("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let t=e;const r=this._nodes.values();let o,a;for(;o=r.next(),o.done!==!0;)a=o.value,t=i(t,a.key,a.attributes);return t}nodeEntries(){const i=this._nodes.values();return new oe(()=>{const e=i.next();if(e.done)return e;const t=e.value;return{value:{node:t.key,attributes:t.attributes},done:!1}})}exportNode(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.exportNode: could not find the "${i}" node in the graph.`);return Qt(i,e)}exportEdge(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.exportEdge: could not find the "${i}" edge in the graph.`);return Jt(i,e)}export(){const i=new Array(this._nodes.size);let e=0;this._nodes.forEach((r,o)=>{i[e++]=Qt(o,r)});const t=new Array(this._edges.size);return e=0,this._edges.forEach((r,o)=>{t[e++]=Jt(o,r)}),{attributes:this.getAttributes(),nodes:i,edges:t,options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops}}}importNode(i,e=!1){const t=io(i);if(t){if(t==="not-object")throw new R('Graph.importNode: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(t==="no-key")throw new R("Graph.importNode: no key provided.");if(t==="invalid-attributes")throw new R("Graph.importNode: invalid attributes. Attributes should be a plain object, null or omitted.")}const{key:r,attributes:o={}}=i;return e?this.mergeNode(r,o):this.addNode(r,o),this}importEdge(i,e=!1){const t=ro(i);if(t){if(t==="not-object")throw new R('Graph.importEdge: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(t==="no-source")throw new R("Graph.importEdge: missing souce.");if(t==="no-target")throw new R("Graph.importEdge: missing target.");if(t==="invalid-attributes")throw new R("Graph.importEdge: invalid attributes. Attributes should be a plain object, null or omitted.");if(t==="invalid-undirected")throw new R("Graph.importEdge: invalid undirected. Undirected should be boolean or omitted.")}const{source:r,target:o,attributes:a={},undirected:s=!1}=i;let u;return"key"in i?(u=e?s?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:s?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,u.call(this,i.key,r,o,a)):(u=e?s?this.mergeUndirectedEdge:this.mergeDirectedEdge:s?this.addUndirectedEdge:this.addDirectedEdge,u.call(this,r,o,a)),this}import(i,e=!1){if(Br(i))return this.import(i.export(),e),this;if(!q(i))throw new R("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(i.attributes){if(!q(i.attributes))throw new R("Graph.import: invalid attributes. Expecting a plain object.");e?this.mergeAttributes(i.attributes):this.replaceAttributes(i.attributes)}let t,r,o;if(i.nodes){if(o=i.nodes,!Array.isArray(o))throw new R("Graph.import: invalid nodes. Expecting an array.");for(t=0,r=o.length;t<r;t++)this.importNode(o[t],e)}if(i.edges){if(o=i.edges,!Array.isArray(o))throw new R("Graph.import: invalid edges. Expecting an array.");for(t=0,r=o.length;t<r;t++)this.importEdge(o[t],e)}return this}nullCopy(i){const e=new I(W({},this._options,i));return e.replaceAttributes(W({},this.getAttributes())),e}emptyCopy(i){const e=this.nullCopy(i);return this._nodes.forEach((t,r)=>{const o=W({},t.attributes);t=new e.NodeDataClass(r,o),e._nodes.set(r,t)}),e}copy(){const i=this.emptyCopy(),e=this._edges.values();let t,r;for(;t=e.next(),t.done!==!0;)r=t.value,Vi(i,"copy",!1,r.undirected,r.key,r.source.key,r.target.key,W({},r.attributes));return i}upgradeToMixed(){return this.type==="mixed"?this:(this._nodes.forEach(i=>i.upgradeToMixed()),this._options.type="mixed",ne(this,"type",this._options.type),re(this,"NodeDataClass",kt),this)}upgradeToMulti(){return this.multi?this:(this._options.multi=!0,ne(this,"multi",!0),jr(this),this)}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const i={};this._nodes.forEach((o,a)=>{i[a]=o.attributes});const e={},t={};this._edges.forEach((o,a)=>{const s=o.undirected?"--":"->";let u="",h=o.source.key,d=o.target.key,c;o.undirected&&h>d&&(c=h,h=d,d=c);const l=`(${h})${s}(${d})`;a.startsWith("geid_")?this.multi&&(typeof t[l]>"u"?t[l]=0:t[l]++,u+=`${t[l]}. `):u+=`[${a}]: `,u+=l,e[u]=o.attributes});const r={};for(const o in this)this.hasOwnProperty(o)&&!ei.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(r[o]=this[o]);return r.attributes=this._attributes,r.nodes=i,r.edges=e,re(r,"constructor",this.constructor),r}}typeof Symbol<"u"&&(I.prototype[Symbol.for("nodejs.util.inspect.custom")]=I.prototype.inspect);ao.forEach(n=>{["add","merge","update"].forEach(i=>{const e=n.name(i),t=i==="add"?Vi:ho;n.generateKey?I.prototype[e]=function(r,o,a){return t(this,e,!0,(n.type||this.type)==="undirected",null,r,o,a,i==="update")}:I.prototype[e]=function(r,o,a,s){return t(this,e,!1,(n.type||this.type)==="undirected",r,o,a,s,i==="update")}})});nn(I);pn(I);jn(I);to(I);class qi extends I{constructor(i){const e=W({type:"directed"},i);if("multi"in e&&e.multi!==!1)throw new R("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(e.type!=="directed")throw new R('DirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Yi extends I{constructor(i){const e=W({type:"undirected"},i);if("multi"in e&&e.multi!==!1)throw new R("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(e.type!=="undirected")throw new R('UndirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Ki extends I{constructor(i){const e=W({multi:!0},i);if("multi"in e&&e.multi!==!0)throw new R("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(e)}}class Zi extends I{constructor(i){const e=W({type:"directed",multi:!0},i);if("multi"in e&&e.multi!==!0)throw new R("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(e.type!=="directed")throw new R('MultiDirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Xi extends I{constructor(i){const e=W({type:"undirected",multi:!0},i);if("multi"in e&&e.multi!==!0)throw new R("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(e.type!=="undirected")throw new R('MultiUndirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}function Ue(n){n.from=function(i,e){const t=W({},i.options,e),r=new n(t);return r.import(i),r}}Ue(I);Ue(qi);Ue(Yi);Ue(Ki);Ue(Zi);Ue(Xi);I.Graph=I;I.DirectedGraph=qi;I.UndirectedGraph=Yi;I.MultiGraph=Ki;I.MultiDirectedGraph=Zi;I.MultiUndirectedGraph=Xi;I.InvalidArgumentsGraphError=R;I.NotFoundGraphError=E;I.UsageGraphError=D;function co(n,i){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var t=e.call(n,i);if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function je(n){var i=co(n,"string");return typeof i=="symbol"?i:i+""}function K(n,i){if(!(n instanceof i))throw new TypeError("Cannot call a class as a function")}function ii(n,i){for(var e=0;e<i.length;e++){var t=i[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,je(t.key),t)}}function Z(n,i,e){return i&&ii(n.prototype,i),e&&ii(n,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function ze(n){return ze=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ze(n)}function Qi(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Qi=function(){return!!n})()}function lo(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function fo(n,i){if(i&&(typeof i=="object"||typeof i=="function"))return i;if(i!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return lo(n)}function he(n,i,e){return i=ze(i),fo(n,Qi()?Reflect.construct(i,e||[],ze(n).constructor):i.apply(n,e))}function Lt(n,i){return Lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Lt(n,i)}function de(n,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(i&&i.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),i&&Lt(n,i)}function go(n){if(Array.isArray(n))return n}function po(n,i){var e=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(e!=null){var t,r,o,a,s=[],u=!0,h=!1;try{if(o=(e=e.call(n)).next,i===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(t=o.call(e)).done)&&(s.push(t.value),s.length!==i);u=!0);}catch(d){h=!0,r=d}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(h)throw r}}return s}}function Dt(n,i){(i==null||i>n.length)&&(i=n.length);for(var e=0,t=Array(i);e<i;e++)t[e]=n[e];return t}function Ji(n,i){if(n){if(typeof n=="string")return Dt(n,i);var e={}.toString.call(n).slice(8,-1);return e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set"?Array.from(n):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Dt(n,i):void 0}}function vo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oe(n,i){return go(n)||po(n,i)||Ji(n,i)||vo()}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"},er=new Int8Array(4),yt=new Int32Array(er.buffer,0,1),mo=new Float32Array(er.buffer,0,1),yo=/^\s*rgba?\s*\(/,bo=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function wo(n){var i=0,e=0,t=0,r=1;if(n[0]==="#")n.length===4?(i=parseInt(n.charAt(1)+n.charAt(1),16),e=parseInt(n.charAt(2)+n.charAt(2),16),t=parseInt(n.charAt(3)+n.charAt(3),16)):(i=parseInt(n.charAt(1)+n.charAt(2),16),e=parseInt(n.charAt(3)+n.charAt(4),16),t=parseInt(n.charAt(5)+n.charAt(6),16)),n.length===9&&(r=parseInt(n.charAt(7)+n.charAt(8),16)/255);else if(yo.test(n)){var o=n.match(bo);o&&(i=+o[1],e=+o[2],t=+o[3],o[4]&&(r=+o[4]))}return{r:i,g:e,b:t,a:r}}var Ie={};for(var Qe in mt)Ie[Qe]=Ye(mt[Qe]),Ie[mt[Qe]]=Ie[Qe];function tr(n,i,e,t,r){return yt[0]=t<<24|e<<16|i<<8|n,yt[0]=yt[0]&4278190079,mo[0]}function Ye(n){if(n=n.toLowerCase(),typeof Ie[n]<"u")return Ie[n];var i=wo(n),e=i.r,t=i.g,r=i.b,o=i.a;o=o*255|0;var a=tr(e,t,r,o);return Ie[n]=a,a}var bt={};function ir(n){if(typeof bt[n]<"u")return bt[n];var i=(n&16711680)>>>16,e=(n&65280)>>>8,t=n&255,r=255,o=tr(i,e,t,r);return bt[n]=o,o}function ri(n,i,e,t){return e+(i<<8)+(n<<16)}function ni(n,i,e,t,r,o){var a=Math.floor(e/o*r),s=Math.floor(n.drawingBufferHeight/o-t/o*r),u=new Uint8Array(4);n.bindFramebuffer(n.FRAMEBUFFER,i),n.readPixels(a,s,1,1,n.RGBA,n.UNSIGNED_BYTE,u);var h=Oe(u,4),d=h[0],c=h[1],l=h[2],f=h[3];return[d,c,l,f]}function b(n,i,e){return(i=je(i))in n?Object.defineProperty(n,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[i]=e,n}function oi(n,i){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);i&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),e.push.apply(e,t)}return e}function C(n){for(var i=1;i<arguments.length;i++){var e=arguments[i]!=null?arguments[i]:{};i%2?oi(Object(e),!0).forEach(function(t){b(n,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):oi(Object(e)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})}return n}function Eo(n,i){for(;!{}.hasOwnProperty.call(n,i)&&(n=ze(n))!==null;);return n}function xt(){return xt=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,i,e){var t=Eo(n,i);if(t){var r=Object.getOwnPropertyDescriptor(t,i);return r.get?r.get.call(arguments.length<3?n:e):r.value}},xt.apply(null,arguments)}function rr(n,i,e,t){var r=xt(ze(n.prototype),i,e);return typeof r=="function"?function(o){return r.apply(e,o)}:r}function _o(n){return n.normalized?1:n.size}function wt(n){var i=0;return n.forEach(function(e){return i+=_o(e)}),i}function nr(n,i,e){var t=n==="VERTEX"?i.VERTEX_SHADER:i.FRAGMENT_SHADER,r=i.createShader(t);if(r===null)throw new Error("loadShader: error while creating the shader");i.shaderSource(r,e),i.compileShader(r);var o=i.getShaderParameter(r,i.COMPILE_STATUS);if(!o){var a=i.getShaderInfoLog(r);throw i.deleteShader(r),new Error(`loadShader: error while compiling the shader:
|
|
`.concat(a,`
|
|
`).concat(e))}return r}function To(n,i){return nr("VERTEX",n,i)}function Ao(n,i){return nr("FRAGMENT",n,i)}function So(n,i){var e=n.createProgram();if(e===null)throw new Error("loadProgram: error while creating the program.");var t,r;for(t=0,r=i.length;t<r;t++)n.attachShader(e,i[t]);n.linkProgram(e);var o=n.getProgramParameter(e,n.LINK_STATUS);if(!o)throw n.deleteProgram(e),new Error("loadProgram: error while linking the program.");return e}function ai(n){var i=n.gl,e=n.buffer,t=n.program,r=n.vertexShader,o=n.fragmentShader;i.deleteShader(r),i.deleteShader(o),i.deleteProgram(t),i.deleteBuffer(e)}var si=`#define PICKING_MODE
|
|
`,Ro=b(b(b(b(b(b(b(b({},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),or=function(){function n(i,e,t){K(this,n),b(this,"array",new Float32Array),b(this,"constantArray",new Float32Array),b(this,"capacity",0),b(this,"verticesCount",0);var r=this.getDefinition();if(this.VERTICES=r.VERTICES,this.VERTEX_SHADER_SOURCE=r.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=r.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=r.UNIFORMS,this.ATTRIBUTES=r.ATTRIBUTES,this.METHOD=r.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in r?r.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in r?r.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in r,this.ATTRIBUTES_ITEMS_COUNT=wt(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=t,this.normalProgram=this.getProgramInfo("normal",i,r.VERTEX_SHADER_SOURCE,r.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=e?this.getProgramInfo("pick",i,si+r.VERTEX_SHADER_SOURCE,si+r.FRAGMENT_SHADER_SOURCE,e):null,this.isInstanced){var o=wt(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(var a=0;a<this.CONSTANT_DATA.length;a++){var s=this.CONSTANT_DATA[a];if(s.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(o,")"));for(var u=0;u<s.length;u++)this.constantArray[a*o+u]=s[u]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return Z(n,[{key:"kill",value:function(){ai(this.normalProgram),this.pickProgram&&(ai(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(e,t,r,o,a){var s=this.getDefinition(),u=t.createBuffer();if(u===null)throw new Error("Program: error while creating the WebGL buffer.");var h=To(t,r),d=Ao(t,o),c=So(t,[h,d]),l={};s.UNIFORMS.forEach(function(w){var _=t.getUniformLocation(c,w);_&&(l[w]=_)});var f={};s.ATTRIBUTES.forEach(function(w){f[w.name]=t.getAttribLocation(c,w.name)});var y;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(w){f[w.name]=t.getAttribLocation(c,w.name)}),y=t.createBuffer(),y===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:e,program:c,gl:t,frameBuffer:a,buffer:u,constantBuffer:y||{},uniformLocations:l,attributeLocations:f,isPicking:e==="pick",vertexShader:h,fragmentShader:d}}},{key:"bindProgram",value:function(e){var t=this,r=0,o=e.gl,a=e.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,e.constantBuffer),r=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return r+=t.bindAttribute(s,e,r,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,e.buffer),r=0,this.ATTRIBUTES.forEach(function(s){return r+=t.bindAttribute(s,e,r,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),r=0,this.ATTRIBUTES.forEach(function(s){return r+=t.bindAttribute(s,e,r)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(e){var t=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(r){return t.unbindAttribute(r,e,!1)}),this.ATTRIBUTES.forEach(function(r){return t.unbindAttribute(r,e,!0)})):this.ATTRIBUTES.forEach(function(r){return t.unbindAttribute(r,e)})}},{key:"bindAttribute",value:function(e,t,r,o){var a=Ro[e.type];if(typeof a!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(e.type,'"'));var s=t.attributeLocations[e.name],u=t.gl;if(s!==-1){u.enableVertexAttribArray(s);var h=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:wt(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(u.vertexAttribPointer(s,e.size,e.type,e.normalized||!1,h,r),this.isInstanced&&o)if(u instanceof WebGL2RenderingContext)u.vertexAttribDivisor(s,1);else{var d=u.getExtension("ANGLE_instanced_arrays");d&&d.vertexAttribDivisorANGLE(s,1)}}return e.size*a}},{key:"unbindAttribute",value:function(e,t,r){var o=t.attributeLocations[e.name],a=t.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&r))if(a instanceof WebGL2RenderingContext)a.vertexAttribDivisor(o,0);else{var s=a.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(e){e!==this.capacity&&(this.capacity=e,this.verticesCount=this.VERTICES*e,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(e,t){var r=t.gl,o=t.program;r.enable(r.BLEND),r.useProgram(o),this.setUniforms(e,t),this.drawWebGL(this.METHOD,t)}},{key:"render",value:function(e){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,e.width*e.pixelRatio/e.downSizingRatio,e.height*e.pixelRatio/e.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(C(C({},e),{},{pixelRatio:e.pixelRatio/e.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,e.width*e.pixelRatio,e.height*e.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(e,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(e,t){var r=t.gl,o=t.frameBuffer;if(r.bindFramebuffer(r.FRAMEBUFFER,o),!this.isInstanced)r.drawArrays(e,0,this.verticesCount);else if(r instanceof WebGL2RenderingContext)r.drawArraysInstanced(e,0,this.VERTICES,this.capacity);else{var a=r.getExtension("ANGLE_instanced_arrays");a&&a.drawArraysInstancedANGLE(e,0,this.VERTICES,this.capacity)}}}])}(),Co=function(n){function i(){return K(this,i),he(this,i,arguments)}return de(i,n),Z(i,[{key:"kill",value:function(){rr(i,"kill",this)([])}},{key:"process",value:function(t,r,o){var a=r*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(ir(t),a,o)}}])}(or),Ut=function(n){function i(){var e;K(this,i);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return e=he(this,i,[].concat(r)),b(e,"drawLabel",void 0),e}return de(i,n),Z(i,[{key:"kill",value:function(){rr(i,"kill",this)([])}},{key:"process",value:function(t,r,o,a,s){var u=r*this.STRIDE;if(s.hidden||o.hidden||a.hidden){for(var h=u+this.STRIDE;u<h;u++)this.array[u]=0;return}return this.processVisibleItem(ir(t),u,o,a,s)}}])}(or);function ko(n,i){return function(){function e(t,r,o){K(this,e),b(this,"drawLabel",i),this.programs=n.map(function(a){return new a(t,r,o)})}return Z(e,[{key:"reallocate",value:function(r){this.programs.forEach(function(o){return o.reallocate(r)})}},{key:"process",value:function(r,o,a,s,u){this.programs.forEach(function(h){return h.process(r,o,a,s,u)})}},{key:"render",value:function(r){this.programs.forEach(function(o){return o.render(r)})}},{key:"kill",value:function(){this.programs.forEach(function(r){return r.kill()})}}])}()}function Lo(n,i,e,t,r){var o=r.edgeLabelSize,a=r.edgeLabelFont,s=r.edgeLabelWeight,u=r.edgeLabelColor.attribute?i[r.edgeLabelColor.attribute]||r.edgeLabelColor.color||"#000":r.edgeLabelColor.color,h=i.label;if(h){n.fillStyle=u,n.font="".concat(s," ").concat(o,"px ").concat(a);var d=e.size,c=t.size,l=e.x,f=e.y,y=t.x,w=t.y,_=(l+y)/2,k=(f+w)/2,p=y-l,v=w-f,m=Math.sqrt(p*p+v*v);if(!(m<d+c)){l+=p*d/m,f+=v*d/m,y-=p*c/m,w-=v*c/m,_=(l+y)/2,k=(f+w)/2,p=y-l,v=w-f,m=Math.sqrt(p*p+v*v);var A=n.measureText(h).width;if(A>m){var L="…";for(h=h+L,A=n.measureText(h).width;A>m&&h.length>1;)h=h.slice(0,-2)+L,A=n.measureText(h).width;if(h.length<4)return}var T;p>0?v>0?T=Math.acos(p/m):T=Math.asin(v/m):v>0?T=Math.acos(p/m)+Math.PI:T=Math.asin(p/m)+Math.PI/2,n.save(),n.translate(_,k),n.rotate(T),n.fillText(h,-A/2,i.size/2+o),n.restore()}}}function ar(n,i,e){if(i.label){var t=e.labelSize,r=e.labelFont,o=e.labelWeight,a=e.labelColor.attribute?i[e.labelColor.attribute]||e.labelColor.color||"#000":e.labelColor.color;n.fillStyle=a,n.font="".concat(o," ").concat(t,"px ").concat(r),n.fillText(i.label,i.x+i.size+3,i.y+t/3)}}function Do(n,i,e){var t=e.labelSize,r=e.labelFont,o=e.labelWeight;n.font="".concat(o," ").concat(t,"px ").concat(r),n.fillStyle="#FFF",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=8,n.shadowColor="#000";var a=2;if(typeof i.label=="string"){var s=n.measureText(i.label).width,u=Math.round(s+5),h=Math.round(t+2*a),d=Math.max(i.size,t/2)+a,c=Math.asin(h/2/d),l=Math.sqrt(Math.abs(Math.pow(d,2)-Math.pow(h/2,2)));n.beginPath(),n.moveTo(i.x+l,i.y+h/2),n.lineTo(i.x+d+u,i.y+h/2),n.lineTo(i.x+d+u,i.y-h/2),n.lineTo(i.x+l,i.y-h/2),n.arc(i.x,i.y,d,c,-c),n.closePath(),n.fill()}else n.beginPath(),n.arc(i.x,i.y,i.size+a,0,Math.PI*2),n.closePath(),n.fill();n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,ar(n,i,e)}var xo=`
|
|
precision highp float;
|
|
|
|
varying vec4 v_color;
|
|
varying vec2 v_diffVector;
|
|
varying float v_radius;
|
|
|
|
uniform float u_correctionRatio;
|
|
|
|
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
|
|
void main(void) {
|
|
float border = u_correctionRatio * 2.0;
|
|
float dist = length(v_diffVector) - v_radius + border;
|
|
|
|
// No antialiasing for picking mode:
|
|
#ifdef PICKING_MODE
|
|
if (dist > border)
|
|
gl_FragColor = transparent;
|
|
else
|
|
gl_FragColor = v_color;
|
|
|
|
#else
|
|
float t = 0.0;
|
|
if (dist > border)
|
|
t = 1.0;
|
|
else if (dist > 0.0)
|
|
t = dist / border;
|
|
|
|
gl_FragColor = mix(v_color, transparent, t);
|
|
#endif
|
|
}
|
|
`,Go=xo,Fo=`
|
|
attribute vec4 a_id;
|
|
attribute vec4 a_color;
|
|
attribute vec2 a_position;
|
|
attribute float a_size;
|
|
attribute float a_angle;
|
|
|
|
uniform mat3 u_matrix;
|
|
uniform float u_sizeRatio;
|
|
uniform float u_correctionRatio;
|
|
|
|
varying vec4 v_color;
|
|
varying vec2 v_diffVector;
|
|
varying float v_radius;
|
|
varying float v_border;
|
|
|
|
const float bias = 255.0 / 254.0;
|
|
|
|
void main() {
|
|
float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
|
|
vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
|
|
vec2 position = a_position + diffVector;
|
|
gl_Position = vec4(
|
|
(u_matrix * vec3(position, 1)).xy,
|
|
0,
|
|
1
|
|
);
|
|
|
|
v_diffVector = diffVector;
|
|
v_radius = size / 2.0;
|
|
|
|
#ifdef PICKING_MODE
|
|
// For picking mode, we use the ID as the color:
|
|
v_color = a_id;
|
|
#else
|
|
// For normal mode, we use the color:
|
|
v_color = a_color;
|
|
#endif
|
|
|
|
v_color.a *= bias;
|
|
}
|
|
`,No=Fo,sr=WebGLRenderingContext,ui=sr.UNSIGNED_BYTE,Et=sr.FLOAT,Po=["u_sizeRatio","u_correctionRatio","u_matrix"],ut=function(n){function i(){return K(this,i),he(this,i,arguments)}return de(i,n),Z(i,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:No,FRAGMENT_SHADER_SOURCE:Go,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Po,ATTRIBUTES:[{name:"a_position",size:2,type:Et},{name:"a_size",size:1,type:Et},{name:"a_color",size:4,type:ui,normalized:!0},{name:"a_id",size:4,type:ui,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Et}],CONSTANT_DATA:[[i.ANGLE_1],[i.ANGLE_2],[i.ANGLE_3]]}}},{key:"processVisibleItem",value:function(t,r,o){var a=this.array,s=Ye(o.color);a[r++]=o.x,a[r++]=o.y,a[r++]=o.size,a[r++]=s,a[r++]=t}},{key:"setUniforms",value:function(t,r){var o=r.gl,a=r.uniformLocations,s=a.u_sizeRatio,u=a.u_correctionRatio,h=a.u_matrix;o.uniform1f(u,t.correctionRatio),o.uniform1f(s,t.sizeRatio),o.uniformMatrix3fv(h,!1,t.matrix)}}])}(Co);b(ut,"ANGLE_1",0);b(ut,"ANGLE_2",2*Math.PI/3);b(ut,"ANGLE_3",4*Math.PI/3);var Io=`
|
|
precision mediump float;
|
|
|
|
varying vec4 v_color;
|
|
|
|
void main(void) {
|
|
gl_FragColor = v_color;
|
|
}
|
|
`,zo=Io,Oo=`
|
|
attribute vec2 a_position;
|
|
attribute vec2 a_normal;
|
|
attribute float a_radius;
|
|
attribute vec3 a_barycentric;
|
|
|
|
#ifdef PICKING_MODE
|
|
attribute vec4 a_id;
|
|
#else
|
|
attribute vec4 a_color;
|
|
#endif
|
|
|
|
uniform mat3 u_matrix;
|
|
uniform float u_sizeRatio;
|
|
uniform float u_correctionRatio;
|
|
uniform float u_minEdgeThickness;
|
|
uniform float u_lengthToThicknessRatio;
|
|
uniform float u_widenessToThicknessRatio;
|
|
|
|
varying vec4 v_color;
|
|
|
|
const float bias = 255.0 / 254.0;
|
|
|
|
void main() {
|
|
float minThickness = u_minEdgeThickness;
|
|
|
|
float normalLength = length(a_normal);
|
|
vec2 unitNormal = a_normal / normalLength;
|
|
|
|
// These first computations are taken from edge.vert.glsl and
|
|
// edge.clamped.vert.glsl. Please read it to get better comments on what's
|
|
// happening:
|
|
float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
|
|
float webGLThickness = pixelsThickness * u_correctionRatio;
|
|
float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
|
|
|
|
float da = a_barycentric.x;
|
|
float db = a_barycentric.y;
|
|
float dc = a_barycentric.z;
|
|
|
|
vec2 delta = vec2(
|
|
da * (webGLNodeRadius * unitNormal.y)
|
|
+ db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
|
|
+ dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
|
|
|
|
da * (-webGLNodeRadius * unitNormal.x)
|
|
+ db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
|
|
+ dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
|
|
);
|
|
|
|
vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
|
|
|
|
gl_Position = vec4(position, 0, 1);
|
|
|
|
#ifdef PICKING_MODE
|
|
// For picking mode, we use the ID as the color:
|
|
v_color = a_id;
|
|
#else
|
|
// For normal mode, we use the color:
|
|
v_color = a_color;
|
|
#endif
|
|
|
|
v_color.a *= bias;
|
|
}
|
|
`,Uo=Oo,ur=WebGLRenderingContext,hi=ur.UNSIGNED_BYTE,Je=ur.FLOAT,$o=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],hr={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function dr(n){var i=C(C({},hr),{});return function(e){function t(){return K(this,t),he(this,t,arguments)}return de(t,e),Z(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Uo,FRAGMENT_SHADER_SOURCE:zo,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$o,ATTRIBUTES:[{name:"a_position",size:2,type:Je},{name:"a_normal",size:2,type:Je},{name:"a_radius",size:1,type:Je},{name:"a_color",size:4,type:hi,normalized:!0},{name:"a_id",size:4,type:hi,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Je}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,u,h){if(i.extremity==="source"){var d=[u,s];s=d[0],u=d[1]}var c=h.size||1,l=u.size||1,f=s.x,y=s.y,w=u.x,_=u.y,k=Ye(h.color),p=w-f,v=_-y,m=p*p+v*v,A=0,L=0;m&&(m=1/Math.sqrt(m),A=-v*m*c,L=p*m*c);var T=this.array;T[a++]=w,T[a++]=_,T[a++]=-A,T[a++]=-L,T[a++]=l,T[a++]=k,T[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,h=u.u_matrix,d=u.u_sizeRatio,c=u.u_correctionRatio,l=u.u_minEdgeThickness,f=u.u_lengthToThicknessRatio,y=u.u_widenessToThicknessRatio;s.uniformMatrix3fv(h,!1,o.matrix),s.uniform1f(d,o.sizeRatio),s.uniform1f(c,o.correctionRatio),s.uniform1f(l,o.minEdgeThickness),s.uniform1f(f,i.lengthToThicknessRatio),s.uniform1f(y,i.widenessToThicknessRatio)}}])}(Ut)}dr();var Bo=`
|
|
precision mediump float;
|
|
|
|
varying vec4 v_color;
|
|
varying vec2 v_normal;
|
|
varying float v_thickness;
|
|
varying float v_feather;
|
|
|
|
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
|
|
void main(void) {
|
|
// We only handle antialiasing for normal mode:
|
|
#ifdef PICKING_MODE
|
|
gl_FragColor = v_color;
|
|
#else
|
|
float dist = length(v_normal) * v_thickness;
|
|
|
|
float t = smoothstep(
|
|
v_thickness - v_feather,
|
|
v_thickness,
|
|
dist
|
|
);
|
|
|
|
gl_FragColor = mix(v_color, transparent, t);
|
|
#endif
|
|
}
|
|
`,cr=Bo,Mo=`
|
|
attribute vec4 a_id;
|
|
attribute vec4 a_color;
|
|
attribute vec2 a_normal;
|
|
attribute float a_normalCoef;
|
|
attribute vec2 a_positionStart;
|
|
attribute vec2 a_positionEnd;
|
|
attribute float a_positionCoef;
|
|
attribute float a_radius;
|
|
attribute float a_radiusCoef;
|
|
|
|
uniform mat3 u_matrix;
|
|
uniform float u_zoomRatio;
|
|
uniform float u_sizeRatio;
|
|
uniform float u_pixelRatio;
|
|
uniform float u_correctionRatio;
|
|
uniform float u_minEdgeThickness;
|
|
uniform float u_lengthToThicknessRatio;
|
|
uniform float u_feather;
|
|
|
|
varying vec4 v_color;
|
|
varying vec2 v_normal;
|
|
varying float v_thickness;
|
|
varying float v_feather;
|
|
|
|
const float bias = 255.0 / 254.0;
|
|
|
|
void main() {
|
|
float minThickness = u_minEdgeThickness;
|
|
|
|
float radius = a_radius * a_radiusCoef;
|
|
vec2 normal = a_normal * a_normalCoef;
|
|
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
|
|
float normalLength = length(normal);
|
|
vec2 unitNormal = normal / normalLength;
|
|
|
|
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
// get better comments on what's happening:
|
|
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
|
|
// Here, we move the point to leave space for the arrow head:
|
|
float direction = sign(radius);
|
|
float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
|
|
vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
|
|
|
|
// Here is the proper position of the vertex
|
|
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
|
|
|
|
v_thickness = webGLThickness / u_zoomRatio;
|
|
|
|
v_normal = unitNormal;
|
|
|
|
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
|
|
#ifdef PICKING_MODE
|
|
// For picking mode, we use the ID as the color:
|
|
v_color = a_id;
|
|
#else
|
|
// For normal mode, we use the color:
|
|
v_color = a_color;
|
|
#endif
|
|
|
|
v_color.a *= bias;
|
|
}
|
|
`,Ho=Mo,lr=WebGLRenderingContext,di=lr.UNSIGNED_BYTE,Ge=lr.FLOAT,Wo=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],jo={lengthToThicknessRatio:hr.lengthToThicknessRatio};function fr(n){var i=C(C({},jo),{});return function(e){function t(){return K(this,t),he(this,t,arguments)}return de(t,e),Z(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Ho,FRAGMENT_SHADER_SOURCE:cr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Wo,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Ge},{name:"a_positionEnd",size:2,type:Ge},{name:"a_normal",size:2,type:Ge},{name:"a_color",size:4,type:di,normalized:!0},{name:"a_id",size:4,type:di,normalized:!0},{name:"a_radius",size:1,type:Ge}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Ge},{name:"a_normalCoef",size:1,type:Ge},{name:"a_radiusCoef",size:1,type:Ge}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,u,h){var d=h.size||1,c=s.x,l=s.y,f=u.x,y=u.y,w=Ye(h.color),_=f-c,k=y-l,p=u.size||1,v=_*_+k*k,m=0,A=0;v&&(v=1/Math.sqrt(v),m=-k*v*d,A=_*v*d);var L=this.array;L[a++]=c,L[a++]=l,L[a++]=f,L[a++]=y,L[a++]=m,L[a++]=A,L[a++]=w,L[a++]=o,L[a++]=p}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,h=u.u_matrix,d=u.u_zoomRatio,c=u.u_feather,l=u.u_pixelRatio,f=u.u_correctionRatio,y=u.u_sizeRatio,w=u.u_minEdgeThickness,_=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(h,!1,o.matrix),s.uniform1f(d,o.zoomRatio),s.uniform1f(y,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(l,o.pixelRatio),s.uniform1f(c,o.antiAliasingFeather),s.uniform1f(w,o.minEdgeThickness),s.uniform1f(_,i.lengthToThicknessRatio)}}])}(Ut)}fr();function Vo(n){return ko([fr(),dr()])}var qo=Vo(),Yo=qo,Ko=`
|
|
attribute vec4 a_id;
|
|
attribute vec4 a_color;
|
|
attribute vec2 a_normal;
|
|
attribute float a_normalCoef;
|
|
attribute vec2 a_positionStart;
|
|
attribute vec2 a_positionEnd;
|
|
attribute float a_positionCoef;
|
|
|
|
uniform mat3 u_matrix;
|
|
uniform float u_sizeRatio;
|
|
uniform float u_zoomRatio;
|
|
uniform float u_pixelRatio;
|
|
uniform float u_correctionRatio;
|
|
uniform float u_minEdgeThickness;
|
|
uniform float u_feather;
|
|
|
|
varying vec4 v_color;
|
|
varying vec2 v_normal;
|
|
varying float v_thickness;
|
|
varying float v_feather;
|
|
|
|
const float bias = 255.0 / 254.0;
|
|
|
|
void main() {
|
|
float minThickness = u_minEdgeThickness;
|
|
|
|
vec2 normal = a_normal * a_normalCoef;
|
|
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
|
|
float normalLength = length(normal);
|
|
vec2 unitNormal = normal / normalLength;
|
|
|
|
// We require edges to be at least "minThickness" pixels thick *on screen*
|
|
// (so we need to compensate the size ratio):
|
|
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
|
|
// Then, we need to retrieve the normalized thickness of the edge in the WebGL
|
|
// referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
|
|
// ratio:
|
|
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
|
|
// Here is the proper position of the vertex
|
|
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
|
|
|
|
// For the fragment shader though, we need a thickness that takes the "magic"
|
|
// correction ratio into account (as in webGLThickness), but so that the
|
|
// antialiasing effect does not depend on the zoom level. So here's yet
|
|
// another thickness version:
|
|
v_thickness = webGLThickness / u_zoomRatio;
|
|
|
|
v_normal = unitNormal;
|
|
|
|
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
|
|
#ifdef PICKING_MODE
|
|
// For picking mode, we use the ID as the color:
|
|
v_color = a_id;
|
|
#else
|
|
// For normal mode, we use the color:
|
|
v_color = a_color;
|
|
#endif
|
|
|
|
v_color.a *= bias;
|
|
}
|
|
`,Zo=Ko,gr=WebGLRenderingContext,ci=gr.UNSIGNED_BYTE,$e=gr.FLOAT,Xo=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Qo=function(n){function i(){return K(this,i),he(this,i,arguments)}return de(i,n),Z(i,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Zo,FRAGMENT_SHADER_SOURCE:cr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Xo,ATTRIBUTES:[{name:"a_positionStart",size:2,type:$e},{name:"a_positionEnd",size:2,type:$e},{name:"a_normal",size:2,type:$e},{name:"a_color",size:4,type:ci,normalized:!0},{name:"a_id",size:4,type:ci,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:$e},{name:"a_normalCoef",size:1,type:$e}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(t,r,o,a,s){var u=s.size||1,h=o.x,d=o.y,c=a.x,l=a.y,f=Ye(s.color),y=c-h,w=l-d,_=y*y+w*w,k=0,p=0;_&&(_=1/Math.sqrt(_),k=-w*_*u,p=y*_*u);var v=this.array;v[r++]=h,v[r++]=d,v[r++]=c,v[r++]=l,v[r++]=k,v[r++]=p,v[r++]=f,v[r++]=t}},{key:"setUniforms",value:function(t,r){var o=r.gl,a=r.uniformLocations,s=a.u_matrix,u=a.u_zoomRatio,h=a.u_feather,d=a.u_pixelRatio,c=a.u_correctionRatio,l=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,t.matrix),o.uniform1f(u,t.zoomRatio),o.uniform1f(l,t.sizeRatio),o.uniform1f(c,t.correctionRatio),o.uniform1f(d,t.pixelRatio),o.uniform1f(h,t.antiAliasingFeather),o.uniform1f(f,t.minEdgeThickness)}}])}(Ut),$t=function(n){function i(){var e;return K(this,i),e=he(this,i),e.rawEmitter=e,e}return de(i,n),Z(i)}(zi.EventEmitter),Bt=function(i){return i!==null&&typeof i=="object"&&typeof i.addUndirectedEdgeWithKey=="function"&&typeof i.dropNode=="function"&&typeof i.multi=="boolean"};const Jo=qe(Bt);var ea=function(i){return i},ta=function(i){return i*i},ia=function(i){return i*(2-i)},ra=function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)},na=function(i){return i*i*i},oa=function(i){return--i*i*i+1},aa=function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)},sa={linear:ea,quadraticIn:ta,quadraticOut:ia,quadraticInOut:ra,cubicIn:na,cubicOut:oa,cubicInOut:aa},ua={easing:"quadraticInOut",duration:150};function ge(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function et(n,i,e){return n[0]=i,n[4]=typeof e=="number"?e:i,n}function li(n,i){var e=Math.sin(i),t=Math.cos(i);return n[0]=t,n[1]=e,n[3]=-e,n[4]=t,n}function fi(n,i,e){return n[6]=i,n[7]=e,n}function Ce(n,i){var e=n[0],t=n[1],r=n[2],o=n[3],a=n[4],s=n[5],u=n[6],h=n[7],d=n[8],c=i[0],l=i[1],f=i[2],y=i[3],w=i[4],_=i[5],k=i[6],p=i[7],v=i[8];return n[0]=c*e+l*o+f*u,n[1]=c*t+l*a+f*h,n[2]=c*r+l*s+f*d,n[3]=y*e+w*o+_*u,n[4]=y*t+w*a+_*h,n[5]=y*r+w*s+_*d,n[6]=k*e+p*o+v*u,n[7]=k*t+p*a+v*h,n[8]=k*r+p*s+v*d,n}function Gt(n,i){var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,t=n[0],r=n[1],o=n[3],a=n[4],s=n[6],u=n[7],h=i.x,d=i.y;return{x:h*t+d*o+s*e,y:h*r+d*a+u*e}}function ha(n,i){var e=n.height/n.width,t=i.height/i.width;return e<1&&t>1||e>1&&t<1?1:Math.min(Math.max(t,1/t),Math.max(1/e,e))}function Be(n,i,e,t,r){var o=n.angle,a=n.ratio,s=n.x,u=n.y,h=i.width,d=i.height,c=ge(),l=Math.min(h,d)-2*t,f=ha(i,e);return r?(Ce(c,fi(ge(),s,u)),Ce(c,et(ge(),a)),Ce(c,li(ge(),o)),Ce(c,et(ge(),h/l/2/f,d/l/2/f))):(Ce(c,et(ge(),2*(l/h)*f,2*(l/d)*f)),Ce(c,li(ge(),-o)),Ce(c,et(ge(),1/a)),Ce(c,fi(ge(),-s,-u))),c}function da(n,i,e){var t=Gt(n,{x:Math.cos(i.angle),y:Math.sin(i.angle)},0),r=t.x,o=t.y;return 1/Math.sqrt(Math.pow(r,2)+Math.pow(o,2))/e.width}function ca(n){if(!n.order)return{x:[0,1],y:[0,1]};var i=1/0,e=-1/0,t=1/0,r=-1/0;return n.forEachNode(function(o,a){var s=a.x,u=a.y;s<i&&(i=s),s>e&&(e=s),u<t&&(t=u),u>r&&(r=u)}),{x:[i,e],y:[t,r]}}function la(n){if(!Jo(n))throw new Error("Sigma: invalid graph instance.");n.forEachNode(function(i,e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error("Sigma: Coordinates of node ".concat(i," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function fa(n,i,e){var t=document.createElement(n);if(i)for(var r in i)t.style[r]=i[r];if(e)for(var o in e)t.setAttribute(o,e[o]);return t}function gi(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function pi(n,i,e){return e.sort(function(t,r){var o=i(t)||0,a=i(r)||0;return o<a?-1:o>a?1:0})}function vi(n){var i=Oe(n.x,2),e=i[0],t=i[1],r=Oe(n.y,2),o=r[0],a=r[1],s=Math.max(t-e,a-o),u=(t+e)/2,h=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(u)&&(u=0),isNaN(h)&&(h=0);var d=function(l){return{x:.5+(l.x-u)/s,y:.5+(l.y-h)/s}};return d.applyTo=function(c){c.x=.5+(c.x-u)/s,c.y=.5+(c.y-h)/s},d.inverse=function(c){return{x:u+s*(c.x-.5),y:h+s*(c.y-.5)}},d.ratio=s,d}function Ft(n){"@babel/helpers - typeof";return Ft=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},Ft(n)}function mi(n,i){var e=i.size;if(e!==0){var t=n.length;n.length+=e;var r=0;i.forEach(function(o){n[t+r]=o,r++})}}function _t(n){n=n||{};for(var i=0,e=arguments.length<=1?0:arguments.length-1;i<e;i++){var t=i+1<1||arguments.length<=i+1?void 0:arguments[i+1];t&&Object.assign(n,t)}return n}var Mt={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:Lo,defaultDrawNodeLabel:ar,defaultDrawNodeHover:Do,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:{}},ga={circle:ut},pa={arrow:Yo,line:Qo};function Tt(n){if(typeof n.labelDensity!="number"||n.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var i=n.minCameraRatio,e=n.maxCameraRatio;if(typeof i=="number"&&typeof e=="number"&&e<i)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function va(n){var i=_t({},Mt,n);return i.nodeProgramClasses=_t({},ga,i.nodeProgramClasses),i.edgeProgramClasses=_t({},pa,i.edgeProgramClasses),i}var tt=1.5,yi=function(n){function i(){var e;return K(this,i),e=he(this,i),b(e,"x",.5),b(e,"y",.5),b(e,"angle",0),b(e,"ratio",1),b(e,"minRatio",null),b(e,"maxRatio",null),b(e,"enabledZooming",!0),b(e,"enabledPanning",!0),b(e,"enabledRotation",!0),b(e,"clean",null),b(e,"nextFrame",null),b(e,"previousState",null),b(e,"enabled",!0),e.previousState=e.getState(),e}return de(i,n),Z(i,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(t){return this.x===t.x&&this.y===t.y&&this.ratio===t.ratio&&this.angle===t.angle}},{key:"getPreviousState",value:function(){var t=this.previousState;return t?{x:t.x,y:t.y,angle:t.angle,ratio:t.ratio}:null}},{key:"getBoundedRatio",value:function(t){var r=t;return typeof this.minRatio=="number"&&(r=Math.max(r,this.minRatio)),typeof this.maxRatio=="number"&&(r=Math.min(r,this.maxRatio)),r}},{key:"validateState",value:function(t){var r={};return this.enabledPanning&&typeof t.x=="number"&&(r.x=t.x),this.enabledPanning&&typeof t.y=="number"&&(r.y=t.y),this.enabledZooming&&typeof t.ratio=="number"&&(r.ratio=this.getBoundedRatio(t.ratio)),this.enabledRotation&&typeof t.angle=="number"&&(r.angle=t.angle),this.clean?this.clean(C(C({},this.getState()),r)):r}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(t){if(!this.enabled)return this;this.previousState=this.getState();var r=this.validateState(t);return typeof r.x=="number"&&(this.x=r.x),typeof r.y=="number"&&(this.y=r.y),typeof r.ratio=="number"&&(this.ratio=r.ratio),typeof r.angle=="number"&&(this.angle=r.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(t){return this.setState(t(this.getState())),this}},{key:"animate",value:function(t){var r=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(f){return r.animate(t,o,f)});if(this.enabled){var s=C(C({},ua),o),u=this.validateState(t),h=typeof s.easing=="function"?s.easing:sa[s.easing],d=Date.now(),c=this.getState(),l=function(){var y=(Date.now()-d)/s.duration;if(y>=1){r.nextFrame=null,r.setState(u),r.animationCallback&&(r.animationCallback.call(null),r.animationCallback=void 0);return}var w=h(y),_={};typeof u.x=="number"&&(_.x=c.x+(u.x-c.x)*w),typeof u.y=="number"&&(_.y=c.y+(u.y-c.y)*w),r.enabledRotation&&typeof u.angle=="number"&&(_.angle=c.angle+(u.angle-c.angle)*w),typeof u.ratio=="number"&&(_.ratio=c.ratio+(u.ratio-c.ratio)*w),r.setState(_),r.nextFrame=requestAnimationFrame(l)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(l)):l(),this.animationCallback=a}}},{key:"animatedZoom",value:function(t){return t?typeof t=="number"?this.animate({ratio:this.ratio/t}):this.animate({ratio:this.ratio/(t.factor||tt)},t):this.animate({ratio:this.ratio/tt})}},{key:"animatedUnzoom",value:function(t){return t?typeof t=="number"?this.animate({ratio:this.ratio*t}):this.animate({ratio:this.ratio*(t.factor||tt)},t):this.animate({ratio:this.ratio*tt})}},{key:"animatedReset",value:function(t){return this.animate({x:.5,y:.5,ratio:1,angle:0},t)}},{key:"copy",value:function(){return i.from(this.getState())}}],[{key:"from",value:function(t){var r=new i;return r.setState(t)}}])}($t);function pe(n,i){var e=i.getBoundingClientRect();return{x:n.clientX-e.left,y:n.clientY-e.top}}function Te(n,i){var e=C(C({},pe(n,i)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:n});return e}function Me(n){var i="x"in n?n:C(C({},n.touches[0]||n.previousTouches[0]),{},{original:n.original,sigmaDefaultPrevented:n.sigmaDefaultPrevented,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0,i.sigmaDefaultPrevented=!0}});return i}function ma(n,i){return C(C({},Te(n,i)),{},{delta:pr(n)})}var ya=2;function nt(n){for(var i=[],e=0,t=Math.min(n.length,ya);e<t;e++)i.push(n[e]);return i}function He(n,i,e){var t={touches:nt(n.touches).map(function(r){return pe(r,e)}),previousTouches:i.map(function(r){return pe(r,e)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0},original:n};return t}function pr(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 vr=function(n){function i(e,t){var r;return K(this,i),r=he(this,i),r.container=e,r.renderer=t,r}return de(i,n),Z(i)}($t),ba=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],wa=ba.reduce(function(n,i){return C(C({},n),{},b({},i,Mt[i]))},{}),Ea=function(n){function i(e,t){var r;return K(this,i),r=he(this,i,[e,t]),b(r,"enabled",!0),b(r,"draggedEvents",0),b(r,"downStartTime",null),b(r,"lastMouseX",null),b(r,"lastMouseY",null),b(r,"isMouseDown",!1),b(r,"isMoving",!1),b(r,"movingTimeout",null),b(r,"startCameraState",null),b(r,"clicks",0),b(r,"doubleClickTimeout",null),b(r,"currentWheelDirection",0),b(r,"settings",wa),r.handleClick=r.handleClick.bind(r),r.handleRightClick=r.handleRightClick.bind(r),r.handleDown=r.handleDown.bind(r),r.handleUp=r.handleUp.bind(r),r.handleMove=r.handleMove.bind(r),r.handleWheel=r.handleWheel.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleEnter=r.handleEnter.bind(r),e.addEventListener("click",r.handleClick,{capture:!1}),e.addEventListener("contextmenu",r.handleRightClick,{capture:!1}),e.addEventListener("mousedown",r.handleDown,{capture:!1}),e.addEventListener("wheel",r.handleWheel,{capture:!1}),e.addEventListener("mouseleave",r.handleLeave,{capture:!1}),e.addEventListener("mouseenter",r.handleEnter,{capture:!1}),document.addEventListener("mousemove",r.handleMove,{capture:!1}),document.addEventListener("mouseup",r.handleUp,{capture:!1}),r}return de(i,n),Z(i,[{key:"kill",value:function(){var t=this.container;t.removeEventListener("click",this.handleClick),t.removeEventListener("contextmenu",this.handleRightClick),t.removeEventListener("mousedown",this.handleDown),t.removeEventListener("wheel",this.handleWheel),t.removeEventListener("mouseleave",this.handleLeave),t.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(t){var r=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(t);setTimeout(function(){r.clicks=0,r.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",Te(t,this.container))}}},{key:"handleRightClick",value:function(t){this.enabled&&this.emit("rightClick",Te(t,this.container))}},{key:"handleDoubleClick",value:function(t){if(this.enabled){t.preventDefault(),t.stopPropagation();var r=Te(t,this.container);if(this.emit("doubleClick",r),!r.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(pe(t,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(t){if(this.enabled){if(t.button===0){this.startCameraState=this.renderer.getCamera().getState();var r=pe(t,this.container),o=r.x,a=r.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Te(t,this.container))}}},{key:"handleUp",value:function(t){var r=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var a=pe(t,this.container),s=a.x,u=a.y,h=o.getState(),d=o.getPreviousState()||{x:0,y:0};this.isMoving?o.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)&&o.setState({x:h.x,y:h.y}),this.isMoving=!1,setTimeout(function(){var c=r.draggedEvents>0;r.draggedEvents=0,c&&r.renderer.getSetting("hideEdgesOnMove")&&r.renderer.refresh()},0),this.emit("mouseup",Te(t,this.container))}}},{key:"handleMove",value:function(t){var r=this;if(this.enabled){var o=Te(t,this.container);if(this.emit("mousemovebody",o),(t.target===this.container||t.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){r.movingTimeout=null,r.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=pe(t,this.container),u=s.x,h=s.y,d=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),c=this.renderer.viewportToFramedGraph({x:u,y:h}),l=d.x-c.x,f=d.y-c.y,y=a.getState(),w=y.x+l,_=y.y+f;a.setState({x:w,y:_}),this.lastMouseX=u,this.lastMouseY=h,t.preventDefault(),t.stopPropagation()}}}},{key:"handleLeave",value:function(t){this.emit("mouseleave",Te(t,this.container))}},{key:"handleEnter",value:function(t){this.emit("mouseenter",Te(t,this.container))}},{key:"handleWheel",value:function(t){var r=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=pr(t);if(a){var s=ma(t,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){t.preventDefault(),t.stopPropagation();return}var u=o.getState().ratio,h=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,d=o.getBoundedRatio(u*h),c=a>0?1:-1,l=Date.now();u!==d&&(t.preventDefault(),t.stopPropagation(),!(this.currentWheelDirection===c&&this.lastWheelTriggerTime&&l-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(pe(t,this.container),d),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){r.currentWheelDirection=0}),this.currentWheelDirection=c,this.lastWheelTriggerTime=l))}}}},{key:"setSettings",value:function(t){this.settings=t}}])}(vr),_a=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],Ta=_a.reduce(function(n,i){return C(C({},n),{},b({},i,Mt[i]))},{}),Aa=function(n){function i(e,t){var r;return K(this,i),r=he(this,i,[e,t]),b(r,"enabled",!0),b(r,"isMoving",!1),b(r,"hasMoved",!1),b(r,"touchMode",0),b(r,"startTouchesPositions",[]),b(r,"lastTouches",[]),b(r,"lastTap",null),b(r,"settings",Ta),r.handleStart=r.handleStart.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleMove=r.handleMove.bind(r),e.addEventListener("touchstart",r.handleStart,{capture:!1}),e.addEventListener("touchcancel",r.handleLeave,{capture:!1}),document.addEventListener("touchend",r.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",r.handleMove,{capture:!1,passive:!1}),r}return de(i,n),Z(i,[{key:"kill",value:function(){var t=this.container;t.removeEventListener("touchstart",this.handleStart),t.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(t){var r=this;if(this.enabled){t.preventDefault();var o=nt(t.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return pe(f,r.container)}),this.touchMode===2){var a=Oe(this.startTouchesPositions,2),s=a[0],u=s.x,h=s.y,d=a[1],c=d.x,l=d.y;this.startTouchesAngle=Math.atan2(l-h,c-u),this.startTouchesDistance=Math.sqrt(Math.pow(c-u,2)+Math.pow(l-h,2))}this.emit("touchdown",He(t,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(t){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(t.cancelable&&t.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(t.touches.length===1){this.handleStart(t),t.preventDefault();break}case 1:if(this.isMoving){var r=this.renderer.getCamera(),o=r.getState(),a=r.getPreviousState()||{x:0,y:0};r.animate({x:o.x+this.settings.inertiaRatio*(o.x-a.x),y:o.y+this.settings.inertiaRatio*(o.y-a.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",He(t,this.lastTouches,this.container)),!t.touches.length){var s=pe(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],h=Math.pow(s.x-u.x,2)+Math.pow(s.y-u.y,2);if(!t.touches.length&&h<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var d=He(t,this.lastTouches,this.container);if(this.emit("doubletap",d),this.lastTap=null,!d.sigmaDefaultPrevented){var c=this.renderer.getCamera(),l=c.getBoundedRatio(c.getState().ratio/this.settings.doubleClickZoomingRatio);c.animate(this.renderer.getViewportZoomedState(s,l),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=He(t,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=nt(t.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(t){var r=this;if(!(!this.enabled||!this.startTouchesPositions.length)){t.preventDefault();var o=nt(t.touches),a=o.map(function(ie){return pe(ie,r.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var u=He(t,s,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(ie,le){var X=r.startTouchesPositions[le];return X&&(ie.x!==X.x||ie.y!==X.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){r.isMoving=!1},this.settings.dragTimeout);var h=this.renderer.getCamera(),d=this.startCameraState,c=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var l=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=l.x,y=l.y,w=this.renderer.viewportToFramedGraph(a[0]),_=w.x,k=w.y;h.setState({x:d.x+f-_,y:d.y+y-k});break}case 2:{var p={x:.5,y:.5,angle:0,ratio:1},v=a[0],m=v.x,A=v.y,L=a[1],T=L.x,S=L.y,g=Math.atan2(S-A,T-m)-this.startTouchesAngle,z=Math.hypot(S-A,T-m)/this.startTouchesDistance,$=h.getBoundedRatio(d.ratio/z);p.ratio=$,p.angle=d.angle+g;var O=this.getDimensions(),J=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:d}),P=Math.min(O.width,O.height)-2*c,j=P/O.width,ae=P/O.height,we=$/P,ce=m-P/2/j,se=A-P/2/ae,ee=[ce*Math.cos(-p.angle)-se*Math.sin(-p.angle),se*Math.cos(-p.angle)+ce*Math.sin(-p.angle)];ce=ee[0],se=ee[1],p.x=J.x-ce*we,p.y=J.y+se*we,h.setState(p);break}}}}}},{key:"setSettings",value:function(t){this.settings=t}}])}(vr);function Sa(n){if(Array.isArray(n))return Dt(n)}function Ra(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Ca(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function bi(n){return Sa(n)||Ra(n)||Ji(n)||Ca()}function ka(n,i){if(n==null)return{};var e={};for(var t in n)if({}.hasOwnProperty.call(n,t)){if(i.indexOf(t)!==-1)continue;e[t]=n[t]}return e}function At(n,i){if(n==null)return{};var e,t,r=ka(n,i);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(t=0;t<o.length;t++)e=o[t],i.indexOf(e)===-1&&{}.propertyIsEnumerable.call(n,e)&&(r[e]=n[e])}return r}var wi=function(){function n(i,e){K(this,n),this.key=i,this.size=e}return Z(n,null,[{key:"compare",value:function(e,t){return e.size>t.size?-1:e.size<t.size||e.key>t.key?1:-1}}])}(),Ei=function(){function n(){K(this,n),b(this,"width",0),b(this,"height",0),b(this,"cellSize",0),b(this,"columns",0),b(this,"rows",0),b(this,"cells",{})}return Z(n,[{key:"resizeAndClear",value:function(e,t){this.width=e.width,this.height=e.height,this.cellSize=t,this.columns=Math.ceil(e.width/t),this.rows=Math.ceil(e.height/t),this.cells={}}},{key:"getIndex",value:function(e){var t=Math.floor(e.x/this.cellSize),r=Math.floor(e.y/this.cellSize);return r*this.columns+t}},{key:"add",value:function(e,t,r){var o=new wi(e,t),a=this.getIndex(r),s=this.cells[a];s||(s=[],this.cells[a]=s),s.push(o)}},{key:"organize",value:function(){for(var e in this.cells){var t=this.cells[e];t.sort(wi.compare)}}},{key:"getLabelsToDisplay",value:function(e,t){var r=this.cellSize*this.cellSize,o=r/e/e,a=o*t/r,s=Math.ceil(a),u=[];for(var h in this.cells)for(var d=this.cells[h],c=0;c<Math.min(s,d.length);c++)u.push(d[c].key);return u}}])}();function La(n){var i=n.graph,e=n.hoveredNode,t=n.highlightedNodes,r=n.displayedNodeLabels,o=[];return i.forEachEdge(function(a,s,u,h){(u===e||h===e||t.has(u)||t.has(h)||r.has(u)&&r.has(h))&&o.push(a)}),o}var _i=150,Ti=50,Ae=Object.prototype.hasOwnProperty;function Da(n,i,e){if(!Ae.call(e,"x")||!Ae.call(e,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(i,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return e.color||(e.color=n.defaultNodeColor),!e.label&&e.label!==""&&(e.label=null),e.label!==void 0&&e.label!==null?e.label=""+e.label:e.label=null,e.size||(e.size=2),Ae.call(e,"hidden")||(e.hidden=!1),Ae.call(e,"highlighted")||(e.highlighted=!1),Ae.call(e,"forceLabel")||(e.forceLabel=!1),(!e.type||e.type==="")&&(e.type=n.defaultNodeType),e.zIndex||(e.zIndex=0),e}function xa(n,i,e){return e.color||(e.color=n.defaultEdgeColor),e.label||(e.label=""),e.size||(e.size=.5),Ae.call(e,"hidden")||(e.hidden=!1),Ae.call(e,"forceLabel")||(e.forceLabel=!1),(!e.type||e.type==="")&&(e.type=n.defaultEdgeType),e.zIndex||(e.zIndex=0),e}var Ga=function(n){function i(e,t){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(K(this,i),r=he(this,i),b(r,"elements",{}),b(r,"canvasContexts",{}),b(r,"webGLContexts",{}),b(r,"pickingLayers",new Set),b(r,"textures",{}),b(r,"frameBuffers",{}),b(r,"activeListeners",{}),b(r,"labelGrid",new Ei),b(r,"nodeDataCache",{}),b(r,"edgeDataCache",{}),b(r,"nodeProgramIndex",{}),b(r,"edgeProgramIndex",{}),b(r,"nodesWithForcedLabels",new Set),b(r,"edgesWithForcedLabels",new Set),b(r,"nodeExtent",{x:[0,1],y:[0,1]}),b(r,"nodeZExtent",[1/0,-1/0]),b(r,"edgeZExtent",[1/0,-1/0]),b(r,"matrix",ge()),b(r,"invMatrix",ge()),b(r,"correctionRatio",1),b(r,"customBBox",null),b(r,"normalizationFunction",vi({x:[0,1],y:[0,1]})),b(r,"graphToViewportRatio",1),b(r,"itemIDsIndex",{}),b(r,"nodeIndices",{}),b(r,"edgeIndices",{}),b(r,"width",0),b(r,"height",0),b(r,"pixelRatio",gi()),b(r,"pickingDownSizingRatio",2*r.pixelRatio),b(r,"displayedNodeLabels",new Set),b(r,"displayedEdgeLabels",new Set),b(r,"highlightedNodes",new Set),b(r,"hoveredNode",null),b(r,"hoveredEdge",null),b(r,"renderFrame",null),b(r,"renderHighlightedNodesFrame",null),b(r,"needToProcess",!1),b(r,"checkEdgesEventsFrame",null),b(r,"nodePrograms",{}),b(r,"nodeHoverPrograms",{}),b(r,"edgePrograms",{}),r.settings=va(o),Tt(r.settings),la(e),!(t instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");r.graph=e,r.container=t,r.createWebGLContext("edges",{picking:o.enableEdgeEvents}),r.createCanvasContext("edgeLabels"),r.createWebGLContext("nodes",{picking:!0}),r.createCanvasContext("labels"),r.createCanvasContext("hovers"),r.createWebGLContext("hoverNodes"),r.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),r.resize();for(var a in r.settings.nodeProgramClasses)r.registerNodeProgram(a,r.settings.nodeProgramClasses[a],r.settings.nodeHoverProgramClasses[a]);for(var s in r.settings.edgeProgramClasses)r.registerEdgeProgram(s,r.settings.edgeProgramClasses[s]);return r.camera=new yi,r.bindCameraHandlers(),r.mouseCaptor=new Ea(r.elements.mouse,r),r.mouseCaptor.setSettings(r.settings),r.touchCaptor=new Aa(r.elements.mouse,r),r.touchCaptor.setSettings(r.settings),r.bindEventHandlers(),r.bindGraphHandlers(),r.handleSettingsUpdate(),r.refresh(),r}return de(i,n),Z(i,[{key:"registerNodeProgram",value:function(t,r,o){return this.nodePrograms[t]&&this.nodePrograms[t].kill(),this.nodeHoverPrograms[t]&&this.nodeHoverPrograms[t].kill(),this.nodePrograms[t]=new r(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[t]=new(o||r)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(t,r){return this.edgePrograms[t]&&this.edgePrograms[t].kill(),this.edgePrograms[t]=new r(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(t){if(this.nodePrograms[t]){var r=this.nodePrograms,o=r[t],a=At(r,[t].map(je));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[t]){var s=this.nodeHoverPrograms,u=s[t],h=At(s,[t].map(je));u.kill(),this.nodePrograms=h}return this}},{key:"unregisterEdgeProgram",value:function(t){if(this.edgePrograms[t]){var r=this.edgePrograms,o=r[t],a=At(r,[t].map(je));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(t){var r=this.webGLContexts[t],o=this.frameBuffers[t],a=this.textures[t];a&&r.deleteTexture(a);var s=r.createTexture();return r.bindFramebuffer(r.FRAMEBUFFER,o),r.bindTexture(r.TEXTURE_2D,s),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.width,this.height,0,r.RGBA,r.UNSIGNED_BYTE,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,s,0),this.textures[t]=s,this}},{key:"bindCameraHandlers",value:function(){var t=this;return this.activeListeners.camera=function(){t.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(t){var r=t.x,o=t.y,a=ni(this.webGLContexts.nodes,this.frameBuffers.nodes,r,o,this.pixelRatio,this.pickingDownSizingRatio),s=ri.apply(void 0,bi(a)),u=this.itemIDsIndex[s];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var t=this;this.activeListeners.handleResize=function(){t.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var a=Me(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},u=t.getNodeAtPosition(a);if(u&&t.hoveredNode!==u&&!t.nodeDataCache[u].hidden){t.hoveredNode&&t.emit("leaveNode",C(C({},s),{},{node:t.hoveredNode})),t.hoveredNode=u,t.emit("enterNode",C(C({},s),{},{node:u})),t.scheduleHighlightedNodesRender();return}if(t.hoveredNode&&t.getNodeAtPosition(a)!==t.hoveredNode){var h=t.hoveredNode;t.hoveredNode=null,t.emit("leaveNode",C(C({},s),{},{node:h})),t.scheduleHighlightedNodesRender();return}if(t.settings.enableEdgeEvents){var d=t.hoveredNode?null:t.getEdgeAtPoint(s.event.x,s.event.y);d!==t.hoveredEdge&&(t.hoveredEdge&&t.emit("leaveEdge",C(C({},s),{},{edge:t.hoveredEdge})),d&&t.emit("enterEdge",C(C({},s),{},{edge:d})),t.hoveredEdge=d)}},this.activeListeners.handleMoveBody=function(o){var a=Me(o);t.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=Me(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};t.hoveredNode&&(t.emit("leaveNode",C(C({},s),{},{node:t.hoveredNode})),t.scheduleHighlightedNodesRender()),t.settings.enableEdgeEvents&&t.hoveredEdge&&(t.emit("leaveEdge",C(C({},s),{},{edge:t.hoveredEdge})),t.scheduleHighlightedNodesRender()),t.emit("leaveStage",C({},s))},this.activeListeners.handleEnter=function(o){var a=Me(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};t.emit("enterStage",C({},s))};var r=function(a){return function(s){var u=Me(s),h={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},d=t.getNodeAtPosition(u);if(d)return t.emit("".concat(a,"Node"),C(C({},h),{},{node:d}));if(t.settings.enableEdgeEvents){var c=t.getEdgeAtPoint(u.x,u.y);if(c)return t.emit("".concat(a,"Edge"),C(C({},h),{},{edge:c}))}return t.emit("".concat(a,"Stage"),h)}};return this.activeListeners.handleClick=r("click"),this.activeListeners.handleRightClick=r("rightClick"),this.activeListeners.handleDoubleClick=r("doubleClick"),this.activeListeners.handleWheel=r("wheel"),this.activeListeners.handleDown=r("down"),this.activeListeners.handleUp=r("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var t=this,r=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,u=(s=a.hints)===null||s===void 0?void 0:s.attributes;t.graph.forEachNode(function(d){return t.updateNode(d)});var h=!u||u.some(function(d){return o.has(d)});t.refresh({partialGraph:{nodes:r.nodes()},skipIndexation:!h,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,u=(s=a.hints)===null||s===void 0?void 0:s.attributes;t.graph.forEachEdge(function(d){return t.updateEdge(d)});var h=u&&["zIndex","type"].some(function(d){return u==null?void 0:u.includes(d)});t.refresh({partialGraph:{edges:r.edges()},skipIndexation:!h,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;t.addNode(s),t.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;t.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;t.removeNode(s),t.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;t.addEdge(s),t.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;t.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;t.removeEdge(s),t.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){t.clearEdgeState(),t.clearEdgeIndices(),t.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){t.clearEdgeState(),t.clearNodeState(),t.clearEdgeIndices(),t.clearNodeIndices(),t.refresh({schedule:!0})},r.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var t=this.graph;t.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),t.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),t.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),t.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),t.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),t.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),t.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),t.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),t.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),t.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(t,r){var o=ni(this.webGLContexts.edges,this.frameBuffers.edges,t,r,this.pixelRatio,this.pickingDownSizingRatio),a=ri.apply(void 0,bi(o)),s=this.itemIDsIndex[a];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var t=this;this.emit("beforeProcess");var r=this.graph,o=this.settings,a=this.getDimensions();if(this.nodeExtent=ca(this.graph),!this.settings.autoRescale){var s=a.width,u=a.height,h=this.nodeExtent,d=h.x,c=h.y;this.nodeExtent={x:[(d[0]+d[1])/2-s/2,(d[0]+d[1])/2+s/2],y:[(c[0]+c[1])/2-u/2,(c[0]+c[1])/2+u/2]}}this.normalizationFunction=vi(this.customBBox||this.nodeExtent);var l=new yi,f=Be(l.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var y={},w={},_={},k={},p=1,v=r.nodes(),m=0,A=v.length;m<A;m++){var L=v[m],T=this.nodeDataCache[L],S=r.getNodeAttributes(L);T.x=S.x,T.y=S.y,this.normalizationFunction.applyTo(T),typeof T.label=="string"&&!T.hidden&&this.labelGrid.add(L,T.size,this.framedGraphToViewport(T,{matrix:f})),y[T.type]=(y[T.type]||0)+1}this.labelGrid.organize();for(var g in this.nodePrograms){if(!Ae.call(this.nodePrograms,g))throw new Error('Sigma: could not find a suitable program for node type "'.concat(g,'"!'));this.nodePrograms[g].reallocate(y[g]||0),y[g]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(v=pi(this.nodeZExtent,function(dt){return t.nodeDataCache[dt].zIndex},v));for(var z=0,$=v.length;z<$;z++){var O=v[z];w[O]=p,k[w[O]]={type:"node",id:O},p++;var J=this.nodeDataCache[O];this.addNodeToProgram(O,w[O],y[J.type]++)}for(var P={},j=r.edges(),ae=0,we=j.length;ae<we;ae++){var ce=j[ae],se=this.edgeDataCache[ce];P[se.type]=(P[se.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(j=pi(this.edgeZExtent,function(dt){return t.edgeDataCache[dt].zIndex},j));for(var ee in this.edgePrograms){if(!Ae.call(this.edgePrograms,ee))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ee,'"!'));this.edgePrograms[ee].reallocate(P[ee]||0),P[ee]=0}for(var ie=0,le=j.length;ie<le;ie++){var X=j[ie];_[X]=p,k[_[X]]={type:"edge",id:X},p++;var Ne=this.edgeDataCache[X];this.addEdgeToProgram(X,_[X],P[Ne.type]++)}return this.itemIDsIndex=k,this.nodeIndices=w,this.edgeIndices=_,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(t){var r=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(d){return r.cleanCameraState(d,o.cameraPanBoundaries&&Ft(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),t){if(t.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==t.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in t.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(t.nodeProgramClasses!==o.nodeProgramClasses||t.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var u in o.nodeProgramClasses)(o.nodeProgramClasses[u]!==t.nodeProgramClasses[u]||o.nodeHoverProgramClasses[u]!==t.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,o.nodeProgramClasses[u],o.nodeHoverProgramClasses[u]);for(var h in t.nodeProgramClasses)o.nodeProgramClasses[h]||this.unregisterNodeProgram(h)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=r.tolerance,a=o===void 0?0:o,s=r.boundaries,u=C({},t),h=s||this.nodeExtent,d=Oe(h.x,2),c=d[0],l=d[1],f=Oe(h.y,2),y=f[0],w=f[1],_=[this.graphToViewport({x:c,y},{cameraState:t}),this.graphToViewport({x:l,y},{cameraState:t}),this.graphToViewport({x:c,y:w},{cameraState:t}),this.graphToViewport({x:l,y:w},{cameraState:t})],k=1/0,p=-1/0,v=1/0,m=-1/0;_.forEach(function(P){var j=P.x,ae=P.y;k=Math.min(k,j),p=Math.max(p,j),v=Math.min(v,ae),m=Math.max(m,ae)});var A=p-k,L=m-v,T=this.getDimensions(),S=T.width,g=T.height,z=0,$=0;if(A>=S?p<S-a?z=p-(S-a):k>a&&(z=k-a):p>S+a?z=p-(S+a):k<-a&&(z=k+a),L>=g?m<g-a?$=m-(g-a):v>a&&($=v-a):m>g+a?$=m-(g+a):v<-a&&($=v+a),z||$){var O=this.viewportToFramedGraph({x:0,y:0},{cameraState:t}),J=this.viewportToFramedGraph({x:z,y:$},{cameraState:t});z=J.x-O.x,$=J.y-O.y,u.x+=z,u.y+=$}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var t=this.camera.getState(),r=this.labelGrid.getLabelsToDisplay(t.ratio,this.settings.labelDensity);mi(r,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=r.length;a<s;a++){var u=r[a],h=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!h.hidden){var d=this.framedGraphToViewport(h),c=d.x,l=d.y,f=this.scaleSize(h.size);if(!(!h.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(c<-_i||c>this.width+_i||l<-Ti||l>this.height+Ti)){this.displayedNodeLabels.add(u);var y=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[h.type],_=(w==null?void 0:w.drawLabel)||y;_(o,C(C({key:u},h),{},{size:f,x:c,y:l}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var t=this.canvasContexts.edgeLabels;t.clearRect(0,0,this.width,this.height);var r=La({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});mi(r,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=r.length;a<s;a++){var u=r[a],h=this.graph.extremities(u),d=this.nodeDataCache[h[0]],c=this.nodeDataCache[h[1]],l=this.edgeDataCache[u];if(!o.has(u)&&!(l.hidden||d.hidden||c.hidden)){var f=this.settings.defaultDrawEdgeLabel,y=this.edgePrograms[l.type],w=(y==null?void 0:y.drawLabel)||f;w(t,C(C({key:u},l),{},{size:this.scaleSize(l.size)}),C(C(C({key:h[0]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),C(C(C({key:h[1]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),this.settings),o.add(u)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var t=this,r=this.canvasContexts.hovers;r.clearRect(0,0,this.width,this.height);var o=function(f){var y=t.nodeDataCache[f],w=t.framedGraphToViewport(y),_=w.x,k=w.y,p=t.scaleSize(y.size),v=t.settings.defaultDrawNodeHover,m=t.nodePrograms[y.type],A=(m==null?void 0:m.drawHover)||v;A(r,C(C({key:f},y),{},{size:p,x:_,y:k}),t.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(l){l!==t.hoveredNode&&a.push(l)}),a.forEach(function(l){return o(l)});var s={};a.forEach(function(l){var f=t.nodeDataCache[l].type;s[f]=(s[f]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(s[u]||0),s[u]=0;a.forEach(function(l){var f=t.nodeDataCache[l];t.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var h=this.getRenderParams();for(var d in this.nodeHoverPrograms){var c=this.nodeHoverPrograms[d];c.render(h)}}},{key:"scheduleHighlightedNodesRender",value:function(){var t=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){t.renderHighlightedNodesFrame=null,t.renderHighlightedNodes(),t.renderEdgeLabels()}))}},{key:"render",value:function(){var t=this;this.emit("beforeRender");var r=function(){return t.emit("afterRender"),t};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(_){return t.resetWebGLTexture(_)}),!this.graph.order)return r();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),u=this.getDimensions(),h=this.getGraphDimensions(),d=this.getStagePadding();this.matrix=Be(s,u,h,d),this.invMatrix=Be(s,u,h,d,!0),this.correctionRatio=da(this.matrix,s,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var c=this.getRenderParams();for(var l in this.nodePrograms){var f=this.nodePrograms[l];f.render(c)}if(!this.settings.hideEdgesOnMove||!a)for(var y in this.edgePrograms){var w=this.edgePrograms[y];w.render(c)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),r()}},{key:"addNode",value:function(t){var r=Object.assign({},this.graph.getNodeAttributes(t));this.settings.nodeReducer&&(r=this.settings.nodeReducer(t,r));var o=Da(this.settings,t,r);this.nodeDataCache[t]=o,this.nodesWithForcedLabels.delete(t),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(t),this.highlightedNodes.delete(t),o.highlighted&&!o.hidden&&this.highlightedNodes.add(t),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(t){this.addNode(t);var r=this.nodeDataCache[t];this.normalizationFunction.applyTo(r)}},{key:"removeNode",value:function(t){delete this.nodeDataCache[t],delete this.nodeProgramIndex[t],this.highlightedNodes.delete(t),this.hoveredNode===t&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(t)}},{key:"addEdge",value:function(t){var r=Object.assign({},this.graph.getEdgeAttributes(t));this.settings.edgeReducer&&(r=this.settings.edgeReducer(t,r));var o=xa(this.settings,t,r);this.edgeDataCache[t]=o,this.edgesWithForcedLabels.delete(t),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(t),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(t){this.addEdge(t)}},{key:"removeEdge",value:function(t){delete this.edgeDataCache[t],delete this.edgeProgramIndex[t],this.hoveredEdge===t&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(t)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Ei,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(t,r,o){var a=this.nodeDataCache[t],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(r,o,a),this.nodeProgramIndex[t]=o}},{key:"addEdgeToProgram",value:function(t,r,o){var a=this.edgeDataCache[t],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var u=this.graph.extremities(t),h=this.nodeDataCache[u[0]],d=this.nodeDataCache[u[1]];s.process(r,o,h,d,a),this.edgeProgramIndex[t]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var t=this.settings,r=t.stagePadding,o=t.autoRescale;return o&&r||0}},{key:"createLayer",value:function(t,r){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[t])throw new Error('Sigma: a layer named "'.concat(t,'" already exists'));var a=fa(r,{position:"absolute"},{class:"sigma-".concat(t)});return o.style&&Object.assign(a.style,o.style),this.elements[t]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(t,"canvas",r)}},{key:"createCanvasContext",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(t,r),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[t]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=(r==null?void 0:r.canvas)||this.createCanvas(t,r);r.hidden&&o.remove();var a=C({preserveDrawingBuffer:!1,antialias:!1},r),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var u=s;if(this.webGLContexts[t]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),r.picking){this.pickingLayers.add(t);var h=u.createFramebuffer();if(!h)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(t));this.frameBuffers[t]=h}return u}},{key:"killLayer",value:function(t){var r=this.elements[t];if(!r)throw new Error("Sigma: cannot kill layer ".concat(t,", which does not exist"));if(this.webGLContexts[t]){var o,a=this.webGLContexts[t];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[t]}else this.canvasContexts[t]&&delete this.canvasContexts[t];return r.remove(),delete this.elements[t],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(t){this.unbindCameraHandlers(),this.camera=t,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(t){t!==this.graph&&(this.hoveredNode&&!t.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!t.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=t,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var t=this.customBBox||this.nodeExtent;return{width:t.x[1]-t.x[0]||1,height:t.y[1]-t.y[0]||1}}},{key:"getNodeDisplayData",value:function(t){var r=this.nodeDataCache[t];return r?Object.assign({},r):void 0}},{key:"getEdgeDisplayData",value:function(t){var r=this.edgeDataCache[t];return r?Object.assign({},r):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 C({},this.settings)}},{key:"getSetting",value:function(t){return this.settings[t]}},{key:"setSetting",value:function(t,r){var o=C({},this.settings);return this.settings[t]=r,Tt(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(t,r){return this.setSetting(t,r(this.settings[t])),this}},{key:"setSettings",value:function(t){var r=C({},this.settings);return this.settings=C(C({},this.settings),t),Tt(this.settings),this.handleSettingsUpdate(r),this.scheduleRefresh(),this}},{key:"resize",value:function(t){var r=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=gi(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!t&&r===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var u in this.canvasContexts)this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[u].scale(this.pixelRatio,this.pixelRatio);for(var 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 c=this.textures[h];c&&d.deleteTexture(c)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(t){var r=this,o=(t==null?void 0:t.skipIndexation)!==void 0?t==null?void 0:t.skipIndexation:!1,a=(t==null?void 0:t.schedule)!==void 0?t.schedule:!1,s=!t||!t.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(m){return r.addNode(m)}),this.graph.forEachEdge(function(m){return r.addEdge(m)});else{for(var u,h,d=((u=t.partialGraph)===null||u===void 0?void 0:u.nodes)||[],c=0,l=(d==null?void 0:d.length)||0;c<l;c++){var f=d[c];if(this.updateNode(f),o){var y=this.nodeProgramIndex[f];if(y===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],y)}}for(var w=(t==null||(h=t.partialGraph)===null||h===void 0?void 0:h.edges)||[],_=0,k=w.length;_<k;_++){var p=w[_];if(this.updateEdge(p),o){var v=this.edgeProgramIndex[p];if(v===void 0)throw new Error('Sigma: edge "'.concat(p,`" can't be repaint`));this.addEdgeToProgram(p,this.edgeIndices[p],v)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var t=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){t.render()})),this}},{key:"scheduleRefresh",value:function(t){return this.refresh(C(C({},t),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(t,r){var o=this.camera.getState(),a=o.ratio,s=o.angle,u=o.x,h=o.y,d=this.settings,c=d.minCameraRatio,l=d.maxCameraRatio;typeof l=="number"&&(r=Math.min(r,l)),typeof c=="number"&&(r=Math.max(r,c));var f=r/a,y={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(t),_=this.viewportToFramedGraph(y);return{angle:s,x:(w.x-_.x)*(1-f)+u,y:(w.y-_.y)*(1-f)+h,ratio:r}}},{key:"viewRectangle",value:function(){var t=this.viewportToFramedGraph({x:0,y:0}),r=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:t.x,y1:t.y,x2:r.x,y2:r.y,height:r.y-o.y}}},{key:"framedGraphToViewport",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!r.cameraState||!!r.viewportDimensions||!!r.graphDimensions,a=r.matrix?r.matrix:o?Be(r.cameraState||this.camera.getState(),r.viewportDimensions||this.getDimensions(),r.graphDimensions||this.getGraphDimensions(),r.padding||this.getStagePadding()):this.matrix,s=Gt(a,t);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!r.cameraState||!!r.viewportDimensions||!r.graphDimensions,a=r.matrix?r.matrix:o?Be(r.cameraState||this.camera.getState(),r.viewportDimensions||this.getDimensions(),r.graphDimensions||this.getGraphDimensions(),r.padding||this.getStagePadding(),!0):this.invMatrix,s=Gt(a,{x:t.x/this.width*2-1,y:1-t.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(t,r))}},{key:"graphToViewport",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(t),r)}},{key:"getGraphToViewportRatio",value:function(){var t={x:0,y:0},r={x:1,y:1},o=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),a=this.graphToViewport(t),s=this.graphToViewport(r),u=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return u/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(t){return this.customBBox=t,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var t=this.container;t.firstChild;)t.removeChild(t.firstChild);for(var r in this.nodePrograms)this.nodePrograms[r].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return t/this.settings.zoomToSizeRatioFunction(r)*(this.getSetting("itemSizesReference")==="positions"?r*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var t={};for(var r in this.elements)this.elements[r]instanceof HTMLCanvasElement&&(t[r]=this.elements[r]);return t}}])}($t),Fa=Ga,ht={};function Na(n){return typeof n!="number"||isNaN(n)?1:n}function Pa(n,i){var e={},t=function(a){return typeof a>"u"?i:a};typeof i=="function"&&(t=i);var r=function(a){return t(a[n])},o=function(){return t(void 0)};return typeof n=="string"?(e.fromAttributes=r,e.fromGraph=function(a,s){return r(a.getNodeAttributes(s))},e.fromEntry=function(a,s){return r(s)}):typeof n=="function"?(e.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},e.fromGraph=function(a,s){return t(n(s,a.getNodeAttributes(s)))},e.fromEntry=function(a,s){return t(n(a,s))}):(e.fromAttributes=o,e.fromGraph=o,e.fromEntry=o),e}function mr(n,i){var e={},t=function(a){return typeof a>"u"?i:a};typeof i=="function"&&(t=i);var r=function(a){return t(a[n])},o=function(){return t(void 0)};return typeof n=="string"?(e.fromAttributes=r,e.fromGraph=function(a,s){return r(a.getEdgeAttributes(s))},e.fromEntry=function(a,s){return r(s)},e.fromPartialEntry=e.fromEntry,e.fromMinimalEntry=e.fromEntry):typeof n=="function"?(e.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},e.fromGraph=function(a,s){var u=a.extremities(s);return t(n(s,a.getEdgeAttributes(s),u[0],u[1],a.getNodeAttributes(u[0]),a.getNodeAttributes(u[1]),a.isUndirected(s)))},e.fromEntry=function(a,s,u,h,d,c,l){return t(n(a,s,u,h,d,c,l))},e.fromPartialEntry=function(a,s,u,h){return t(n(a,s,u,h))},e.fromMinimalEntry=function(a,s){return t(n(a,s))}):(e.fromAttributes=o,e.fromGraph=o,e.fromEntry=o,e.fromMinimalEntry=o),e}ht.createNodeValueGetter=Pa;ht.createEdgeValueGetter=mr;ht.createEdgeWeightGetter=function(n){return mr(n,Na)};var H=0,U=1,x=2,G=3,Ee=4,_e=5,F=6,Ai=7,it=8,Si=9,Ia=0,za=1,Oa=2,V=0,ue=1,Q=2,Fe=3,ke=4,B=5,te=6,ve=7,me=8,Ri=3,fe=10,Ua=3,Y=9,St=10,$a=function(i,e,t){var r,o,a,s,u,h,d,c,l,f,y=e.length,w=t.length,_=i.adjustSizes,k=i.barnesHutTheta*i.barnesHutTheta,p,v,m,A,L,T,S,g=[];for(a=0;a<y;a+=fe)e[a+Ee]=e[a+x],e[a+_e]=e[a+G],e[a+x]=0,e[a+G]=0;if(i.outboundAttractionDistribution){for(p=0,a=0;a<y;a+=fe)p+=e[a+F];p/=y/fe}if(i.barnesHutOptimize){var z=1/0,$=-1/0,O=1/0,J=-1/0,P,j,ae;for(a=0;a<y;a+=fe)z=Math.min(z,e[a+H]),$=Math.max($,e[a+H]),O=Math.min(O,e[a+U]),J=Math.max(J,e[a+U]);var we=$-z,ce=J-O;for(we>ce?(O-=(we-ce)/2,J=O+we):(z-=(ce-we)/2,$=z+ce),g[0+V]=-1,g[0+ue]=(z+$)/2,g[0+Q]=(O+J)/2,g[0+Fe]=Math.max($-z,J-O),g[0+ke]=-1,g[0+B]=-1,g[0+te]=0,g[0+ve]=0,g[0+me]=0,r=1,a=0;a<y;a+=fe)for(o=0,ae=Ri;;)if(g[o+B]>=0){e[a+H]<g[o+ue]?e[a+U]<g[o+Q]?P=g[o+B]:P=g[o+B]+Y:e[a+U]<g[o+Q]?P=g[o+B]+Y*2:P=g[o+B]+Y*3,g[o+ve]=(g[o+ve]*g[o+te]+e[a+H]*e[a+F])/(g[o+te]+e[a+F]),g[o+me]=(g[o+me]*g[o+te]+e[a+U]*e[a+F])/(g[o+te]+e[a+F]),g[o+te]+=e[a+F],o=P;continue}else if(g[o+V]<0){g[o+V]=a;break}else{if(g[o+B]=r*Y,c=g[o+Fe]/2,l=g[o+B],g[l+V]=-1,g[l+ue]=g[o+ue]-c,g[l+Q]=g[o+Q]-c,g[l+Fe]=c,g[l+ke]=l+Y,g[l+B]=-1,g[l+te]=0,g[l+ve]=0,g[l+me]=0,l+=Y,g[l+V]=-1,g[l+ue]=g[o+ue]-c,g[l+Q]=g[o+Q]+c,g[l+Fe]=c,g[l+ke]=l+Y,g[l+B]=-1,g[l+te]=0,g[l+ve]=0,g[l+me]=0,l+=Y,g[l+V]=-1,g[l+ue]=g[o+ue]+c,g[l+Q]=g[o+Q]-c,g[l+Fe]=c,g[l+ke]=l+Y,g[l+B]=-1,g[l+te]=0,g[l+ve]=0,g[l+me]=0,l+=Y,g[l+V]=-1,g[l+ue]=g[o+ue]+c,g[l+Q]=g[o+Q]+c,g[l+Fe]=c,g[l+ke]=g[o+ke],g[l+B]=-1,g[l+te]=0,g[l+ve]=0,g[l+me]=0,r+=4,e[g[o+V]+H]<g[o+ue]?e[g[o+V]+U]<g[o+Q]?P=g[o+B]:P=g[o+B]+Y:e[g[o+V]+U]<g[o+Q]?P=g[o+B]+Y*2:P=g[o+B]+Y*3,g[o+te]=e[g[o+V]+F],g[o+ve]=e[g[o+V]+H],g[o+me]=e[g[o+V]+U],g[P+V]=g[o+V],g[o+V]=-1,e[a+H]<g[o+ue]?e[a+U]<g[o+Q]?j=g[o+B]:j=g[o+B]+Y:e[a+U]<g[o+Q]?j=g[o+B]+Y*2:j=g[o+B]+Y*3,P===j)if(ae--){o=P;continue}else{ae=Ri;break}g[j+V]=a;break}}if(i.barnesHutOptimize)for(v=i.scalingRatio,a=0;a<y;a+=fe)for(o=0;;)if(g[o+B]>=0)if(T=Math.pow(e[a+H]-g[o+ve],2)+Math.pow(e[a+U]-g[o+me],2),f=g[o+Fe],4*f*f/T<k){if(m=e[a+H]-g[o+ve],A=e[a+U]-g[o+me],_===!0?T>0?(S=v*e[a+F]*g[o+te]/T,e[a+x]+=m*S,e[a+G]+=A*S):T<0&&(S=-v*e[a+F]*g[o+te]/Math.sqrt(T),e[a+x]+=m*S,e[a+G]+=A*S):T>0&&(S=v*e[a+F]*g[o+te]/T,e[a+x]+=m*S,e[a+G]+=A*S),o=g[o+ke],o<0)break;continue}else{o=g[o+B];continue}else{if(h=g[o+V],h>=0&&h!==a&&(m=e[a+H]-e[h+H],A=e[a+U]-e[h+U],T=m*m+A*A,_===!0?T>0?(S=v*e[a+F]*e[h+F]/T,e[a+x]+=m*S,e[a+G]+=A*S):T<0&&(S=-v*e[a+F]*e[h+F]/Math.sqrt(T),e[a+x]+=m*S,e[a+G]+=A*S):T>0&&(S=v*e[a+F]*e[h+F]/T,e[a+x]+=m*S,e[a+G]+=A*S)),o=g[o+ke],o<0)break;continue}else for(v=i.scalingRatio,s=0;s<y;s+=fe)for(u=0;u<s;u+=fe)m=e[s+H]-e[u+H],A=e[s+U]-e[u+U],_===!0?(T=Math.sqrt(m*m+A*A)-e[s+it]-e[u+it],T>0?(S=v*e[s+F]*e[u+F]/T/T,e[s+x]+=m*S,e[s+G]+=A*S,e[u+x]-=m*S,e[u+G]-=A*S):T<0&&(S=100*v*e[s+F]*e[u+F],e[s+x]+=m*S,e[s+G]+=A*S,e[u+x]-=m*S,e[u+G]-=A*S)):(T=Math.sqrt(m*m+A*A),T>0&&(S=v*e[s+F]*e[u+F]/T/T,e[s+x]+=m*S,e[s+G]+=A*S,e[u+x]-=m*S,e[u+G]-=A*S));for(l=i.gravity/i.scalingRatio,v=i.scalingRatio,a=0;a<y;a+=fe)S=0,m=e[a+H],A=e[a+U],T=Math.sqrt(Math.pow(m,2)+Math.pow(A,2)),i.strongGravityMode?T>0&&(S=v*e[a+F]*l):T>0&&(S=v*e[a+F]*l/T),e[a+x]-=m*S,e[a+G]-=A*S;for(v=1*(i.outboundAttractionDistribution?p:1),d=0;d<w;d+=Ua)s=t[d+Ia],u=t[d+za],c=t[d+Oa],L=Math.pow(c,i.edgeWeightInfluence),m=e[s+H]-e[u+H],A=e[s+U]-e[u+U],_===!0?(T=Math.sqrt(m*m+A*A)-e[s+it]-e[u+it],i.linLogMode?i.outboundAttractionDistribution?T>0&&(S=-v*L*Math.log(1+T)/T/e[s+F]):T>0&&(S=-v*L*Math.log(1+T)/T):i.outboundAttractionDistribution?T>0&&(S=-v*L/e[s+F]):T>0&&(S=-v*L)):(T=Math.sqrt(Math.pow(m,2)+Math.pow(A,2)),i.linLogMode?i.outboundAttractionDistribution?T>0&&(S=-v*L*Math.log(1+T)/T/e[s+F]):T>0&&(S=-v*L*Math.log(1+T)/T):i.outboundAttractionDistribution?(T=1,S=-v*L/e[s+F]):(T=1,S=-v*L)),T>0&&(e[s+x]+=m*S,e[s+G]+=A*S,e[u+x]-=m*S,e[u+G]-=A*S);var se,ee,ie,le,X,Ne;if(_===!0)for(a=0;a<y;a+=fe)e[a+Si]!==1&&(se=Math.sqrt(Math.pow(e[a+x],2)+Math.pow(e[a+G],2)),se>St&&(e[a+x]=e[a+x]*St/se,e[a+G]=e[a+G]*St/se),ee=e[a+F]*Math.sqrt((e[a+Ee]-e[a+x])*(e[a+Ee]-e[a+x])+(e[a+_e]-e[a+G])*(e[a+_e]-e[a+G])),ie=Math.sqrt((e[a+Ee]+e[a+x])*(e[a+Ee]+e[a+x])+(e[a+_e]+e[a+G])*(e[a+_e]+e[a+G]))/2,le=.1*Math.log(1+ie)/(1+Math.sqrt(ee)),X=e[a+H]+e[a+x]*(le/i.slowDown),e[a+H]=X,Ne=e[a+U]+e[a+G]*(le/i.slowDown),e[a+U]=Ne);else for(a=0;a<y;a+=fe)e[a+Si]!==1&&(ee=e[a+F]*Math.sqrt((e[a+Ee]-e[a+x])*(e[a+Ee]-e[a+x])+(e[a+_e]-e[a+G])*(e[a+_e]-e[a+G])),ie=Math.sqrt((e[a+Ee]+e[a+x])*(e[a+Ee]+e[a+x])+(e[a+_e]+e[a+G])*(e[a+_e]+e[a+G]))/2,le=e[a+Ai]*Math.log(1+ie)/(1+Math.sqrt(ee)),e[a+Ai]=Math.min(1,Math.sqrt(le*(Math.pow(e[a+x],2)+Math.pow(e[a+G],2))/(1+Math.sqrt(ee)))),X=e[a+H]+e[a+x]*(le/i.slowDown),e[a+H]=X,Ne=e[a+U]+e[a+G]*(le/i.slowDown),e[a+U]=Ne);return{}},De={},Ve=10,Ci=3;De.assign=function(n){n=n||{};var i=Array.prototype.slice.call(arguments).slice(1),e,t,r;for(e=0,r=i.length;e<r;e++)if(i[e])for(t in i[e])n[t]=i[e][t];return n};De.validateSettings=function(n){return"linLogMode"in n&&typeof n.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in n&&typeof n.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in n&&typeof n.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in n&&typeof n.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in n&&!(typeof n.scalingRatio=="number"&&n.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in n&&typeof n.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in n&&!(typeof n.gravity=="number"&&n.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in n&&!(typeof n.slowDown=="number"||n.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in n&&typeof n.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in n&&!(typeof n.barnesHutTheta=="number"&&n.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null};De.graphToByteArrays=function(n,i){var e=n.order,t=n.size,r={},o,a=new Float32Array(e*Ve),s=new Float32Array(t*Ci);return o=0,n.forEachNode(function(u,h){r[u]=o,a[o]=h.x,a[o+1]=h.y,a[o+2]=0,a[o+3]=0,a[o+4]=0,a[o+5]=0,a[o+6]=1,a[o+7]=1,a[o+8]=h.size||1,a[o+9]=h.fixed?1:0,o+=Ve}),o=0,n.forEachEdge(function(u,h,d,c,l,f,y){var w=r[d],_=r[c],k=i(u,h,d,c,l,f,y);a[w+6]+=k,a[_+6]+=k,s[o]=w,s[o+1]=_,s[o+2]=k,o+=Ci}),{nodes:a,edges:s}};De.assignLayoutChanges=function(n,i,e){var t=0;n.updateEachNodeAttributes(function(r,o){return o.x=i[t],o.y=i[t+1],t+=Ve,e?e(r,o):o})};De.readGraphPositions=function(n,i){var e=0;n.forEachNode(function(t,r){i[e]=r.x,i[e+1]=r.y,e+=Ve})};De.collectLayoutChanges=function(n,i,e){for(var t=n.nodes(),r={},o=0,a=0,s=i.length;o<s;o+=Ve){if(e){var u=Object.assign({},n.getNodeAttributes(t[a]));u.x=i[o],u.y=i[o+1],u=e(t[a],u),r[t[a]]={x:u.x,y:u.y}}else r[t[a]]={x:i[o],y:i[o+1]};a++}return r};De.createWorker=function(i){var e=window.URL||window.webkitURL,t=i.toString(),r=e.createObjectURL(new Blob(["("+t+").call(this);"],{type:"text/javascript"})),o=new Worker(r);return e.revokeObjectURL(r),o};var Ba={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5},Ma=Bt,Ha=ht.createEdgeWeightGetter,Wa=$a,We=De,ja=Ba;function yr(n,i,e){if(!Ma(i))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof e=="number"&&(e={iterations:e});var t=e.iterations;if(typeof t!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(t<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var r=Ha("getEdgeWeight"in e?e.getEdgeWeight:"weight").fromEntry,o=typeof e.outputReducer=="function"?e.outputReducer:null,a=We.assign({},ja,e.settings),s=We.validateSettings(a);if(s)throw new Error("graphology-layout-forceatlas2: "+s.message);var u=We.graphToByteArrays(i,r),h;for(h=0;h<t;h++)Wa(a,u.nodes,u.edges);if(n){We.assignLayoutChanges(i,u.nodes,o);return}return We.collectLayoutChanges(i,u.nodes)}function Va(n){var i=typeof n=="number"?n:n.order;return{barnesHutOptimize:i>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(i)}}var Ht=yr.bind(null,!1);Ht.assign=yr.bind(null,!0);Ht.inferSettings=Va;var qa=Ht;const Ya=qe(qa);var Ke={},br=st,Ka=br.ARRAY_BUFFER_SUPPORT,Za=br.SYMBOL_SUPPORT,Xa=function(i,e){var t,r,o,a,s;if(!i)throw new Error("obliterator/forEach: invalid iterable.");if(typeof e!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(i)||Ka&&ArrayBuffer.isView(i)||typeof i=="string"||i.toString()==="[object Arguments]"){for(o=0,a=i.length;o<a;o++)e(i[o],o);return}if(typeof i.forEach=="function"){i.forEach(e);return}if(Za&&Symbol.iterator in i&&typeof i.next!="function"&&(i=i[Symbol.iterator]()),typeof i.next=="function"){for(t=i,o=0;s=t.next(),s.done!==!0;)e(s.value,o),o++;return}for(r in i)i.hasOwnProperty(r)&&e(i[r],r)},wr={};(function(n){var i=Math.pow(2,8)-1,e=Math.pow(2,16)-1,t=Math.pow(2,32)-1,r=Math.pow(2,7)-1,o=Math.pow(2,15)-1,a=Math.pow(2,31)-1;n.getPointerArray=function(u){var h=u-1;if(h<=i)return Uint8Array;if(h<=e)return Uint16Array;if(h<=t)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},n.getSignedPointerArray=function(u){var h=u-1;return h<=r?Int8Array:h<=o?Int16Array:h<=a?Int32Array:Float64Array},n.getNumberType=function(u){return u===(u|0)?Math.sign(u)===-1?u<=127&&u>=-128?Int8Array:u<=32767&&u>=-32768?Int16Array:Int32Array:u<=255?Uint8Array:u<=65535?Uint16Array:Uint32Array:Float64Array};var s={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};n.getMinimalRepresentation=function(u,h){var d=null,c=0,l,f,y,w,_;for(w=0,_=u.length;w<_;w++)y=h?h(u[w]):u[w],f=n.getNumberType(y),l=s[f.name],l>c&&(c=l,d=f);return d},n.isTypedArray=function(u){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(u)},n.concat=function(){var u=0,h,d,c;for(h=0,c=arguments.length;h<c;h++)u+=arguments[h].length;var l=new arguments[0].constructor(u);for(h=0,d=0;h<c;h++)l.set(arguments[h],d),d+=arguments[h].length;return l},n.indices=function(u){for(var h=n.getPointerArray(u),d=new h(u),c=0;c<u;c++)d[c]=c;return d}})(wr);var Er=Xa,_r=wr;function Qa(n){return Array.isArray(n)||_r.isTypedArray(n)}function Wt(n){if(typeof n.length=="number")return n.length;if(typeof n.size=="number")return n.size}function Ja(n){var i=Wt(n),e=typeof i=="number"?new Array(i):[],t=0;return Er(n,function(r){e[t++]=r}),e}function es(n){var i=Wt(n),e=typeof i=="number"?_r.getPointerArray(i):Array,t=typeof i=="number"?new Array(i):[],r=typeof i=="number"?new e(i):[],o=0;return Er(n,function(a){t[o]=a,r[o]=o++}),[t,r]}Ke.isArrayLike=Qa;Ke.guessLength=Wt;Ke.toArray=Ja;Ke.toArrayWithIndices=es;var Rt=Ke,Tr=at;function M(n,i){if(arguments.length<2)throw new Error("mnemonist/fixed-deque: expecting an Array class and a capacity.");if(typeof i!="number"||i<=0)throw new Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=n,this.capacity=i,this.items=new n(this.capacity),this.clear()}M.prototype.clear=function(){this.start=0,this.size=0};M.prototype.push=function(n){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.push: deque capacity ("+this.capacity+") exceeded!");var i=this.start+this.size;return i>=this.capacity&&(i-=this.capacity),this.items[i]=n,++this.size};M.prototype.unshift=function(n){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.unshift: deque capacity ("+this.capacity+") exceeded!");var i=this.start-1;return this.start===0&&(i=this.capacity-1),this.items[i]=n,this.start=i,++this.size};M.prototype.pop=function(){if(this.size!==0){this.size--;var n=this.start+this.size;return n>=this.capacity&&(n-=this.capacity),this.items[n]}};M.prototype.shift=function(){if(this.size!==0){var n=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[n]}};M.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]};M.prototype.peekLast=function(){if(this.size!==0){var n=this.start+this.size-1;return n>=this.capacity&&(n-=this.capacity),this.items[n]}};M.prototype.get=function(n){if(!(this.size===0||n>=this.capacity))return n=this.start+n,n>=this.capacity&&(n-=this.capacity),this.items[n]};M.prototype.forEach=function(n,i){i=arguments.length>1?i:this;for(var e=this.capacity,t=this.size,r=this.start,o=0;o<t;)n.call(i,this.items[r],o,this),r++,o++,r===e&&(r=0)};M.prototype.toArray=function(){var n=this.start+this.size;if(n<this.capacity)return this.items.slice(this.start,n);for(var i=new this.ArrayClass(this.size),e=this.capacity,t=this.size,r=this.start,o=0;o<t;)i[o]=this.items[r],r++,o++,r===e&&(r=0);return i};M.prototype.values=function(){var n=this.items,i=this.capacity,e=this.size,t=this.start,r=0;return new Tr(function(){if(r>=e)return{done:!0};var o=n[t];return t++,r++,t===i&&(t=0),{value:o,done:!1}})};M.prototype.entries=function(){var n=this.items,i=this.capacity,e=this.size,t=this.start,r=0;return new Tr(function(){if(r>=e)return{done:!0};var o=n[t];return t++,t===i&&(t=0),{value:[r++,o],done:!1}})};typeof Symbol<"u"&&(M.prototype[Symbol.iterator]=M.prototype.values);M.prototype.inspect=function(){var n=this.toArray();return n.type=this.ArrayClass.name,n.capacity=this.capacity,Object.defineProperty(n,"constructor",{value:M,enumerable:!1}),n};typeof Symbol<"u"&&(M.prototype[Symbol.for("nodejs.util.inspect.custom")]=M.prototype.inspect);M.from=function(n,i,e){if(arguments.length<3&&(e=Rt.guessLength(n),typeof e!="number"))throw new Error("mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.");var t=new M(i,e);if(Rt.isArrayLike(n)){var r,o;for(r=0,o=n.length;r<o;r++)t.items[r]=n[r];return t.size=o,t}return Rt.forEach(n,function(a){t.push(a)}),t};var ts=M,is=ts;function xe(n){this.graph=n,this.queue=new is(Array,n.order),this.seen=new Set,this.size=0}xe.prototype.hasAlreadySeenEverything=function(){return this.seen.size===this.graph.order};xe.prototype.countUnseenNodes=function(){return this.graph.order-this.seen.size};xe.prototype.forEachNodeYetUnseen=function(n){var i=this.seen,e=this.graph;e.someNode(function(t,r){if(i.size===e.order)return!0;if(i.has(t))return!1;var o=n(t,r);return!!o})};xe.prototype.has=function(n){return this.seen.has(n)};xe.prototype.push=function(n){var i=this.seen.size;return this.seen.add(n),i===this.seen.size?!1:(this.queue.push(n),this.size++,!0)};xe.prototype.pushWith=function(n,i){var e=this.seen.size;return this.seen.add(n),e===this.seen.size?!1:(this.queue.push(i),this.size++,!0)};xe.prototype.shift=function(){var n=this.queue.shift();return this.size=this.queue.size,n};var rs=xe,jt={};function ns(n,i,e){this.node=n,this.attributes=i,this.depth=e}function os(n){return n[0].toUpperCase()+n.slice(1)}jt.TraversalRecord=ns;jt.capitalize=os;var as=Bt,ss=rs,Ar=jt,ki=Ar.TraversalRecord,us=Ar.capitalize;function hs(n,i,e,t){if(t=t||{},!as(n))throw new Error("graphology-traversal/bfs: expecting a graphology instance.");if(typeof e!="function")throw new Error("graphology-traversal/bfs: given callback is not a function.");if(n.order===0)return;var r=new ss(n),o=n["forEach"+us(t.mode||"outbound")+"Neighbor"].bind(n),a;i===null?a=r.forEachNodeYetUnseen.bind(r):a=function(d){i=""+i,d(i,n.getNodeAttributes(i))};var s,u;function h(d,c){r.pushWith(d,new ki(d,c,s.depth+1))}a(function(d,c){for(r.pushWith(d,new ki(d,c,0));r.size!==0;)s=r.shift(),u=e(s.node,s.attributes,s.depth),u!==!0&&o(s.node,h)})}var ds=hs;const Le=typeof limitGraphRootNodeId<"u"&&limitGraphRootNodeId!==""?limitGraphRootNodeId:null,Ct={instrument:{color:"#f08324"},organization:{color:"#2491f0"},person:{color:"#24f083"},project:{color:"#8324f0"},publication:{color:"#432205"},topic:{color:"#e924f0"},objective:{color:"#f7b983"}},cs={http:{color:"#999",size:1},sql:{color:"#e31a1c",size:2},rpc:{color:"#b15928",size:1.5}},ls="#ffcc00",fs=1.6,gs=2;async function ps(){const n=await fetch("/graph.json");if(!n.ok)throw new Error("Failed to load graph.json");return n.json()}function vs(n,i){if(!n.hasNode(i))throw new Error(`Root node "${i}" not found in graph.`);const e=new Set;ds(n,i,r=>e.add(r)),n.forEachNeighbor(i,r=>e.add(r)),e.add(i);const t=[];n.forEachNode(r=>{e.has(r)||t.push(r)}),t.forEach(r=>{n.hasNode(r)&&n.dropNode(r)})}(async function(){const i=await ps(),e=new I;i.nodes.forEach(p=>{const v=Ct[p.type]||{color:"#666"},m=p.id===Le;e.addNode(p.id,{label:p.label||p.id,size:Math.log(p.size*10)+1,color:v.color,domainType:p.type,url:p.url||null,x:Math.random()-.5,y:Math.random()-.5,root:m,type:"circle"})}),i.edges.forEach(p=>{const v=cs[p.type]||{color:"#71716f88",size:1};e.addEdgeWithKey(p.id||`${p.source}->${p.target}`,p.source,p.target,{label:p.type,color:v.color,size:v.size,domainType:p.type})}),typeof Le<"u"&&Le!==null&&Le!==""&&vs(e,Le),Ya.assign(e,{iterations:1e3,settings:{barnesHutOptimize:!0,outboundAttractionDistribution:!0,strongGravityMode:!0,adjustSizes:!0}});const r=document.getElementById("sigma-container"),o=new Fa(e,r,{renderLabels:!0,nodeReducer:(p,v)=>{const m=!!v.highlight;return v.root,{...v,size:(v.size||1)*(m?fs:1)}},edgeReducer:(p,v)=>{const m=!!v.highlight;return{...v,color:m?ls:v.color,size:(v.size||1)*(m?gs:1),hidden:v.hidden}}});o.getCamera();function a(p,v){p.forEachEdge((m,A)=>{const L=p.getNodeAttribute(p.source(m),"hidden"),T=p.getNodeAttribute(p.target(m),"hidden");p.setEdgeAttribute(m,"hidden",L||T)}),v.refresh()}const s=document.getElementById("sigma-controls-list")||(()=>{const p=document.createElement("div");return p.id="sigma-controls-list",document.getElementById("sigma-node-type-controls").appendChild(p),p})(),u=new Map;e.forEachNode((p,v)=>{const m=v.domainType||"unknown";u.has(m)||u.set(m,{key:m,color:Ct[m]&&Ct[m].color||"#666"})});const h=Array.from(u.values()).sort((p,v)=>{const m=p.key.toString().toLowerCase(),A=v.key.toString().toLowerCase();return m<A?-1:m>A?1:0}),d=p=>p.charAt(0).toUpperCase()+p.slice(1);h.forEach(p=>{const v=p.key,m=`toggle-${v}`,A=document.createElement("div");A.style.marginBottom="2px";const L=document.createElement("input");L.type="checkbox",L.id=m,L.checked=!0,L.style.marginRight="6px";const T=p.color,S=document.createElement("span");S.style.display="inline-block",S.style.width="12px",S.style.height="12px",S.style.borderRadius="50%",S.style.backgroundColor=T,S.style.marginRight="8px",S.style.verticalAlign="middle";const g=document.createElement("label");g.htmlFor=m,g.textContent=d(v),g.style.verticalAlign="middle",A.appendChild(L),A.appendChild(S),A.appendChild(g),s.appendChild(A),L.addEventListener("change",()=>{const z=!L.checked;e.forEachNode(($,O)=>{(O.domainType||"unknown")===v&&e.setNodeAttribute($,"hidden",z)}),a(e,o)})});let c=null,l=0;const f=400,y=4e3;let w=null;function _(){c&&(e.forEachNode(p=>e.removeNodeAttribute(p,"selected")),e.forEachEdge(p=>e.removeEdgeAttribute(p,"selected")),c=null,o.refresh(),w&&(clearTimeout(w),w=null))}function k(p){c=p,e.forEachNode(v=>e.setNodeAttribute(v,"selected",v===p)),e.forEachEdge(v=>{const m=e.source(v),A=e.target(v),L=m===p||A===p;e.setEdgeAttribute(v,"selected",L),L&&(e.setNodeAttribute(m,"selected",!0),e.setNodeAttribute(A,"selected",!0))}),o.refresh(),w&&clearTimeout(w),w=setTimeout(_,y)}a(e,o),o.on("downNode",({node:p,event:v})=>{const m=Date.now(),A=e.getNodeAttribute(p,"url");if(c===p){A?window.location.href=A:k(p),l=0;return}if(m-l<f&&c){const L=e.getNodeAttribute(c,"url");L&&(window.location.href=L),l=0;return}l=m,k(p)}),o.on("enterNode",({node:p})=>{e.forEachNode(v=>e.setNodeAttribute(v,"highlight",v===p)),e.forEachEdge((v,m)=>{const A=e.source(v),L=e.target(v),T=A===p||L===p;e.setEdgeAttribute(v,"highlight",T),T&&(e.setNodeAttribute(A,"highlight",!0),e.setNodeAttribute(L,"highlight",!0))}),o.refresh()}),o.on("leaveNode",()=>{e.forEachNode(p=>e.removeNodeAttribute(p,"highlight")),e.forEachEdge(p=>e.removeEdgeAttribute(p,"highlight")),o.refresh()}),o.getContainer().addEventListener("pointerdown",p=>{p.target===o.getContainer()&&_()}),Le&&e.hasNode(Le)&&o.emit("enterNode",{node:Le})})();
|