@plebeiantech/lat.md 0.12.3-fork.14 → 0.12.3-fork.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cli/checklist-menu.d.ts +2 -1
- package/dist/src/cli/checklist-menu.js +3 -2
- package/dist/src/cli/index.js +47 -10
- package/dist/src/cli/init-preferences.d.ts +4 -0
- package/dist/src/cli/init-preferences.js +35 -0
- package/dist/src/cli/init.js +7 -1
- package/dist/src/cli/search.js +2 -7
- package/dist/src/cli/ui-build-server.d.ts +12 -0
- package/dist/src/cli/ui-build-server.js +26 -0
- package/dist/src/cli/ui-build.js +1 -1
- package/dist/src/cli/ui.js +1 -1
- package/dist/src/search/query.d.ts +5 -2
- package/dist/src/search/query.js +25 -21
- package/dist/src/source-formats.d.ts +1 -1
- package/dist/src/source-formats.js +2 -0
- package/dist/src/source-parser.js +200 -0
- package/dist/src/view/client/assets/GraphView-BuZg_wrj.js +456 -0
- package/dist/src/view/client/assets/{MarkdownEditor-B7quqPb8.js → MarkdownEditor-BKqJtZYv.js} +8 -8
- package/dist/src/view/client/assets/_commonjsHelpers-CqkleIqs.js +1 -0
- package/dist/src/view/client/assets/abnfDiagram-VCTEODGH-CAu3KwfO.js +1 -0
- package/dist/src/view/client/assets/{arc-BnwR8Bu7.js → arc-CFnPZhKM.js} +1 -1
- package/dist/src/view/client/assets/architectureDiagram-5GKGNRK7-Cf9Kd0OA.js +36 -0
- package/dist/src/view/client/assets/{blockDiagram-I7D4REHJ-DETl8e_H.js → blockDiagram-I7D4REHJ-dPn7g_vm.js} +2 -2
- package/dist/src/view/client/assets/{c4Diagram-7LVT6UL2-DJRAT1Ve.js → c4Diagram-7LVT6UL2-DdZrwaPd.js} +2 -2
- package/dist/src/view/client/assets/channel-C-byJRR7.js +1 -0
- package/dist/src/view/client/assets/{chunk-2Q5K7J3B-C0TmOC1Q.js → chunk-2Q5K7J3B-C42JuteH.js} +1 -1
- package/dist/src/view/client/assets/{chunk-5VM5RSS4-dfBOrYE6.js → chunk-5VM5RSS4-BKK3z8Zy.js} +1 -1
- package/dist/src/view/client/assets/{chunk-F27PBJKO-DAnks99K.js → chunk-F27PBJKO-qZl_uKcW.js} +1 -1
- package/dist/src/view/client/assets/{chunk-IMKFNOWR-CPjB07if.js → chunk-IMKFNOWR-Bs4Rnoj_.js} +1 -1
- package/dist/src/view/client/assets/{chunk-JWPE2WC7-VvU_gZI6.js → chunk-JWPE2WC7-BpxgV2rA.js} +1 -1
- package/dist/src/view/client/assets/{chunk-POPQ4Y6H-DDUbVF55.js → chunk-POPQ4Y6H-hIynofdE.js} +1 -1
- package/dist/src/view/client/assets/{chunk-SVP7TREG-BHROkr6D.js → chunk-SVP7TREG-t3gKMqeu.js} +1 -1
- package/dist/src/view/client/assets/{chunk-TICWLB2K-95PzGIOg.js → chunk-TICWLB2K-B2x394mh.js} +1 -1
- package/dist/src/view/client/assets/{chunk-XXDRQBXY-MdmuLhIs.js → chunk-XXDRQBXY-CHaVKDsH.js} +1 -1
- package/dist/src/view/client/assets/classDiagram-ZZMXUADV-FlqGrEwv.js +1 -0
- package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-FlqGrEwv.js +1 -0
- package/dist/src/view/client/assets/cose-bilkent-JH36ORCC-DE2-Jgqu.js +1 -0
- package/dist/src/view/client/assets/{cynefin-OW5HDTMX-CeA8IKWo.js → cynefin-OW5HDTMX-BsEtOvRy.js} +1 -1
- package/dist/src/view/client/assets/cynefinDiagram-5FMLGOSQ-BKYG1Xs8.js +62 -0
- package/dist/src/view/client/assets/{dagre-GXQ25YYZ-DLQwTa3H.js → dagre-GXQ25YYZ-hgrdNjl7.js} +2 -2
- package/dist/src/view/client/assets/{diagram-S7CK7UJ4-kbKdIyXG.js → diagram-S7CK7UJ4-VIx8zAxf.js} +2 -2
- package/dist/src/view/client/assets/diagram-UQ7AKVKN-yfloehRm.js +41 -0
- package/dist/src/view/client/assets/{diagram-VSXAHHWV-EXJTU8qq.js → diagram-VSXAHHWV-BT_dA4Q9.js} +2 -2
- package/dist/src/view/client/assets/diagram-VX7I27RA-Gfmwxx6u.js +24 -0
- package/dist/src/view/client/assets/diagram-Z3DM3KII-C2yM7EOo.js +24 -0
- package/dist/src/view/client/assets/ebnfDiagram-PWID7BFC-Bkb_Lj59.js +1 -0
- package/dist/src/view/client/assets/{erDiagram-RLTQ6QDP-C925J5A3.js → erDiagram-RLTQ6QDP-C7wQHPye.js} +2 -2
- package/dist/src/view/client/assets/{flowDiagram-HODETNUW-DzoCa-Nq.js → flowDiagram-HODETNUW-CXoKr3oI.js} +1 -1
- package/dist/src/view/client/assets/ganttDiagram-EL5Y4UJY-DqqXKgLa.js +292 -0
- package/dist/src/view/client/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/src/view/client/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/src/view/client/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/src/view/client/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/dist/src/view/client/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/src/view/client/assets/gitGraphDiagram-WWUBYQGX-D_DAhSgZ.js +106 -0
- package/dist/src/view/client/assets/index-DAxFk0q-.css +1 -0
- package/dist/src/view/client/assets/index-DPuOWFj2.js +10 -0
- package/dist/src/view/client/assets/infoDiagram-27XIBGKW-B50EOats.js +2 -0
- package/dist/src/view/client/assets/{ishikawaDiagram-5VMMS53U-CW4mto2d.js → ishikawaDiagram-5VMMS53U-D1rny9gj.js} +2 -2
- package/dist/src/view/client/assets/{journeyDiagram-3NMN7TZE-8R4eacFW.js → journeyDiagram-3NMN7TZE-B5UD2Xo4.js} +2 -2
- package/dist/src/view/client/assets/{kanban-definition-UXKFOSKX-Cy9ioXEJ.js → kanban-definition-UXKFOSKX-CTgey9zw.js} +6 -6
- package/dist/src/view/client/assets/{layout-C0MFuhth.js → layout-4X2n4os-.js} +1 -1
- package/dist/src/view/client/assets/{linear-Dv3N4dQR.js → linear-D0RIBXsp.js} +1 -1
- package/dist/src/view/client/assets/{maplibre-gl-DnqZgfUS.js → maplibre-gl-CDX6Zuow.js} +1 -1
- package/dist/src/view/client/assets/{mermaid.core-bds9A7e2.js → mermaid.core-BAnH8y-D.js} +11 -11
- package/dist/src/view/client/assets/{mindmap-definition-YA3MSWOX-DjmGW355.js → mindmap-definition-YA3MSWOX-WiFsh3Jg.js} +2 -2
- package/dist/src/view/client/assets/pegDiagram-XKGWAZYB-DCJOrckP.js +1 -0
- package/dist/src/view/client/assets/{pieDiagram-E7YTZNPT-CCH2gGR-.js → pieDiagram-E7YTZNPT-C78IkUE2.js} +2 -2
- package/dist/src/view/client/assets/{quadrantDiagram-AXDQQJYC-CjocPJFz.js → quadrantDiagram-AXDQQJYC-xZ6guleB.js} +4 -4
- package/dist/src/view/client/assets/railroadDiagram-O6MQD6OU-D3PwmgX0.js +1 -0
- package/dist/src/view/client/assets/{requirementDiagram-BXWQKSXE-Ct6AoXRr.js → requirementDiagram-BXWQKSXE-v-I8wLGH.js} +2 -2
- package/dist/src/view/client/assets/{sankeyDiagram-P5KCCOFB-CIpgGN_w.js → sankeyDiagram-P5KCCOFB-DBY-sdO7.js} +2 -2
- package/dist/src/view/client/assets/{sequenceDiagram-WJ2MYXX4-DrmLFj6w.js → sequenceDiagram-WJ2MYXX4-D9HApBFi.js} +2 -2
- package/dist/src/view/client/assets/sizeCapture-INFHLROL-ERAytLnQ.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-D77RDMKH-BKef_Qwv.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-BePfayWI.js +1 -0
- package/dist/src/view/client/assets/swimlanes-42K2YHIH-D7dS_tnF.js +1 -0
- package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-DaqCEguT.js +8 -0
- package/dist/src/view/client/assets/{timeline-definition-24CTP7MA-BExPu6X5.js → timeline-definition-24CTP7MA-Di1UCseG.js} +2 -2
- package/dist/src/view/client/assets/{vennDiagram-4TSXK5OY-PC1MU3si.js → vennDiagram-4TSXK5OY-g7Je3H2H.js} +2 -2
- package/dist/src/view/client/assets/{wardleyDiagram-VM6X3IG4-DNWqU3fa.js → wardleyDiagram-VM6X3IG4-C_diPEka.js} +2 -2
- package/dist/src/view/client/assets/{xychartDiagram-S5SC5T6Z-E1uA28_D.js → xychartDiagram-S5SC5T6Z-C8uIQy_I.js} +2 -2
- package/dist/src/view/client/index.html +2 -2
- package/dist/src/view/document-route.d.ts +2 -0
- package/dist/src/view/document-route.js +40 -7
- package/dist/src/view/graph.d.ts +2 -2
- package/dist/src/view/graph.js +7 -3
- package/dist/src/view/highlight.js +205 -203
- package/dist/src/view/markdown.js +4 -0
- package/dist/src/view/preindexed-search.d.ts +15 -0
- package/dist/src/view/preindexed-search.js +25 -0
- package/dist/src/view/protocol.d.ts +3 -0
- package/dist/src/view/references.js +3 -4
- package/dist/src/view/search-result.d.ts +4 -0
- package/dist/src/view/search-result.js +20 -0
- package/dist/src/view/search.d.ts +7 -2
- package/dist/src/view/search.js +23 -30
- package/dist/src/view/server-build.d.ts +21 -0
- package/dist/src/view/server-build.js +145 -0
- package/dist/src/view/server-deployment.d.ts +32 -0
- package/dist/src/view/server-deployment.js +133 -0
- package/dist/src/view/server-index-worker.d.ts +6 -0
- package/dist/src/view/server-index-worker.js +14 -0
- package/dist/src/view/server.d.ts +1 -1
- package/dist/src/view/server.js +26 -8
- package/dist/src/view/static-build.d.ts +16 -1
- package/dist/src/view/static-build.js +187 -89
- package/dist/src/view/static-protocol.d.ts +7 -0
- package/dist/src/view/static-protocol.js +5 -0
- package/dist/src/view/store.js +14 -4
- package/dist/src/view/vercel-build.d.ts +24 -0
- package/dist/src/view/vercel-build.js +133 -0
- package/dist/src/view/vercel-server-build.d.ts +10 -0
- package/dist/src/view/vercel-server-build.js +61 -0
- package/dist/vendor/lat.md-server/cli.d.ts +2 -0
- package/dist/vendor/lat.md-server/cli.js +12 -0
- package/dist/vendor/lat.md-server/index.d.ts +38 -0
- package/dist/vendor/lat.md-server/index.js +128 -0
- package/package.json +19 -5
- package/dist/src/view/client/assets/abnfDiagram-VCTEODGH-V7-T6qsl.js +0 -1
- package/dist/src/view/client/assets/architectureDiagram-5GKGNRK7-u97vDna9.js +0 -36
- package/dist/src/view/client/assets/channel-BwQbnWCN.js +0 -1
- package/dist/src/view/client/assets/classDiagram-ZZMXUADV-HvQKkIS-.js +0 -1
- package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-HvQKkIS-.js +0 -1
- package/dist/src/view/client/assets/cose-bilkent-JH36ORCC-CauUf_rN.js +0 -1
- package/dist/src/view/client/assets/cynefinDiagram-5FMLGOSQ-L1rtcT8l.js +0 -62
- package/dist/src/view/client/assets/diagram-UQ7AKVKN-kmzp92RC.js +0 -41
- package/dist/src/view/client/assets/diagram-VX7I27RA-DAiIyMCG.js +0 -24
- package/dist/src/view/client/assets/diagram-Z3DM3KII-G9wz50ZV.js +0 -24
- package/dist/src/view/client/assets/ebnfDiagram-PWID7BFC-D2tVRCNA.js +0 -1
- package/dist/src/view/client/assets/ganttDiagram-EL5Y4UJY-D2ebbg4p.js +0 -292
- package/dist/src/view/client/assets/gitGraphDiagram-WWUBYQGX-B4QratYy.js +0 -106
- package/dist/src/view/client/assets/index-D0ajr_Ja.css +0 -1
- package/dist/src/view/client/assets/index-KZcnpXJH.js +0 -321
- package/dist/src/view/client/assets/infoDiagram-27XIBGKW-DL4mtHkt.js +0 -2
- package/dist/src/view/client/assets/pegDiagram-XKGWAZYB-BWsZp0ab.js +0 -1
- package/dist/src/view/client/assets/railroadDiagram-O6MQD6OU-BjLeb2KF.js +0 -1
- package/dist/src/view/client/assets/sizeCapture-INFHLROL-BdFMe2Lr.js +0 -1
- package/dist/src/view/client/assets/stateDiagram-D77RDMKH-Zd9F1goW.js +0 -1
- package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-ByIKCftl.js +0 -1
- package/dist/src/view/client/assets/swimlanes-42K2YHIH-a7VFwi00.js +0 -1
- package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-CzxaUHB-.js +0 -8
- /package/dist/src/view/client/assets/{logo-small-RR_KBOAT.svg → logo-RR_KBOAT.svg} +0 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import{r as z,f as ke,g as at,j as F,s as xt,a as Oi,M as Bi,n as Hi,S as Wi,b as ji,d as Vi,e as qi,c as Tt}from"./index-DPuOWFj2.js";import{g as Ki}from"./_commonjsHelpers-CqkleIqs.js";var De={exports:{}},Rt;function Yi(){if(Rt)return De.exports;Rt=1;var r=typeof Reflect=="object"?Reflect:null,i=r&&typeof r.apply=="function"?r.apply:function(p,v,E){return Function.prototype.apply.call(p,v,E)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(p){return Object.getOwnPropertyNames(p).concat(Object.getOwnPropertySymbols(p))}:t=function(p){return Object.getOwnPropertyNames(p)};function e(g){console&&console.warn&&console.warn(g)}var n=Number.isNaN||function(p){return p!==p};function o(){o.init.call(this)}De.exports=o,De.exports.once=R,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(g){if(typeof g!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof g)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(g){if(typeof g!="number"||g<0||n(g))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+g+".");a=g}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(p){if(typeof p!="number"||p<0||n(p))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+p+".");return this._maxListeners=p,this};function u(g){return g._maxListeners===void 0?o.defaultMaxListeners:g._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(p){for(var v=[],E=1;E<arguments.length;E++)v.push(arguments[E]);var k=p==="error",N=this._events;if(N!==void 0)k=k&&N.error===void 0;else if(!k)return!1;if(k){var S;if(v.length>0&&(S=v[0]),S instanceof Error)throw S;var M=new Error("Unhandled error."+(S?" ("+S.message+")":""));throw M.context=S,M}var I=N[p];if(I===void 0)return!1;if(typeof I=="function")i(I,this,v);else for(var L=I.length,P=y(I,L),E=0;E<L;++E)i(P[E],this,v);return!0};function h(g,p,v,E){var k,N,S;if(s(v),N=g._events,N===void 0?(N=g._events=Object.create(null),g._eventsCount=0):(N.newListener!==void 0&&(g.emit("newListener",p,v.listener?v.listener:v),N=g._events),S=N[p]),S===void 0)S=N[p]=v,++g._eventsCount;else if(typeof S=="function"?S=N[p]=E?[v,S]:[S,v]:E?S.unshift(v):S.push(v),k=u(g),k>0&&S.length>k&&!S.warned){S.warned=!0;var M=new Error("Possible EventEmitter memory leak detected. "+S.length+" "+String(p)+" listeners added. Use emitter.setMaxListeners() to increase limit");M.name="MaxListenersExceededWarning",M.emitter=g,M.type=p,M.count=S.length,e(M)}return g}o.prototype.addListener=function(p,v){return h(this,p,v,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(p,v){return h(this,p,v,!0)};function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(g,p,v){var E={fired:!1,wrapFn:void 0,target:g,type:p,listener:v},k=c.bind(E);return k.listener=v,E.wrapFn=k,k}o.prototype.once=function(p,v){return s(v),this.on(p,d(this,p,v)),this},o.prototype.prependOnceListener=function(p,v){return s(v),this.prependListener(p,d(this,p,v)),this},o.prototype.removeListener=function(p,v){var E,k,N,S,M;if(s(v),k=this._events,k===void 0)return this;if(E=k[p],E===void 0)return this;if(E===v||E.listener===v)--this._eventsCount===0?this._events=Object.create(null):(delete k[p],k.removeListener&&this.emit("removeListener",p,E.listener||v));else if(typeof E!="function"){for(N=-1,S=E.length-1;S>=0;S--)if(E[S]===v||E[S].listener===v){M=E[S].listener,N=S;break}if(N<0)return this;N===0?E.shift():m(E,N),E.length===1&&(k[p]=E[0]),k.removeListener!==void 0&&this.emit("removeListener",p,M||v)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(p){var v,E,k;if(E=this._events,E===void 0)return this;if(E.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):E[p]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete E[p]),this;if(arguments.length===0){var N=Object.keys(E),S;for(k=0;k<N.length;++k)S=N[k],S!=="removeListener"&&this.removeAllListeners(S);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(v=E[p],typeof v=="function")this.removeListener(p,v);else if(v!==void 0)for(k=v.length-1;k>=0;k--)this.removeListener(p,v[k]);return this};function l(g,p,v){var E=g._events;if(E===void 0)return[];var k=E[p];return k===void 0?[]:typeof k=="function"?v?[k.listener||k]:[k]:v?b(k):y(k,k.length)}o.prototype.listeners=function(p){return l(this,p,!0)},o.prototype.rawListeners=function(p){return l(this,p,!1)},o.listenerCount=function(g,p){return typeof g.listenerCount=="function"?g.listenerCount(p):f.call(g,p)},o.prototype.listenerCount=f;function f(g){var p=this._events;if(p!==void 0){var v=p[g];if(typeof v=="function")return 1;if(v!==void 0)return v.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function y(g,p){for(var v=new Array(p),E=0;E<p;++E)v[E]=g[E];return v}function m(g,p){for(;p+1<g.length;p++)g[p]=g[p+1];g.pop()}function b(g){for(var p=new Array(g.length),v=0;v<p.length;++v)p[v]=g[v].listener||g[v];return p}function R(g,p){return new Promise(function(v,E){function k(S){g.removeListener(p,N),E(S)}function N(){typeof g.removeListener=="function"&&g.removeListener("error",k),v([].slice.call(arguments))}_(g,p,N,{once:!0}),p!=="error"&&x(g,k,{once:!0})})}function x(g,p,v){typeof g.on=="function"&&_(g,"error",p,v)}function _(g,p,v,E){if(typeof g.on=="function")E.once?g.once(p,v):g.on(p,v);else if(typeof g.addEventListener=="function")g.addEventListener(p,function k(N){E.once&&g.removeEventListener(p,k),v(N)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof g)}return De.exports}var ii=Yi();function Zi(){const r=arguments[0];for(let i=1,t=arguments.length;i<t;i++)if(arguments[i])for(const e in arguments[i])r[e]=arguments[i][e];return r}let B=Zi;typeof Object.assign=="function"&&(B=Object.assign);function X(r,i,t,e){const n=r._nodes.get(i);let o=null;return n&&(e==="mixed"?o=n.out&&n.out[t]||n.undirected&&n.undirected[t]:e==="directed"?o=n.out&&n.out[t]:o=n.undirected&&n.undirected[t]),o}function V(r){return typeof r=="object"&&r!==null}function ni(r){let i;for(i in r)return!1;return!0}function Z(r,i,t){Object.defineProperty(r,i,{enumerable:!1,configurable:!1,writable:!0,value:t})}function J(r,i,t){const e={enumerable:!0,configurable:!0};typeof t=="function"?e.get=t:(e.value=t,e.writable=!1),Object.defineProperty(r,i,e)}function St(r){return!(!V(r)||r.attributes&&!Array.isArray(r.attributes))}function Xi(){let r=Math.floor(Math.random()*256)&255;return()=>r++}function ae(){const r=arguments;let i=null,t=-1;return{[Symbol.iterator](){return this},next(){let e=null;do{if(i===null){if(t++,t>=r.length)return{done:!0};i=r[t][Symbol.iterator]()}if(e=i.next(),e.done){i=null;continue}break}while(!0);return e}}}function be(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class gt extends Error{constructor(i){super(),this.name="GraphError",this.message=i}}class C extends gt{constructor(i){super(i),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,C.prototype.constructor)}}class T extends gt{constructor(i){super(i),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,T.prototype.constructor)}}class D extends gt{constructor(i){super(i),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}function ri(r,i){this.key=r,this.attributes=i,this.clear()}ri.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function oi(r,i){this.key=r,this.attributes=i,this.clear()}oi.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function ai(r,i){this.key=r,this.attributes=i,this.clear()}ai.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function we(r,i,t,e,n){this.key=i,this.attributes=n,this.undirected=r,this.source=t,this.target=e}we.prototype.attach=function(){let r="out",i="in";this.undirected&&(r=i="undirected");const t=this.source.key,e=this.target.key;this.source[r][e]=this,!(this.undirected&&t===e)&&(this.target[i][t]=this)};we.prototype.attachMulti=function(){let r="out",i="in";const t=this.source.key,e=this.target.key;this.undirected&&(r=i="undirected");const n=this.source[r],o=n[e];if(typeof o>"u"){n[e]=this,this.undirected&&t===e||(this.target[i][t]=this);return}o.previous=this,this.next=o,n[e]=this,this.target[i][t]=this};we.prototype.detach=function(){const r=this.source.key,i=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),delete this.source[t][i],delete this.target[e][r]};we.prototype.detachMulti=function(){const r=this.source.key,i=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][i],delete this.target[e][r]):(this.next.previous=void 0,this.source[t][i]=this.next,this.target[e][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const si=0,ui=1,Ji=2,hi=3;function se(r,i,t,e,n,o,a){let s,u,h,c;if(e=""+e,t===si){if(s=r._nodes.get(e),!s)throw new T(`Graph.${i}: could not find the "${e}" node in the graph.`);h=n,c=o}else if(t===hi){if(n=""+n,u=r._edges.get(n),!u)throw new T(`Graph.${i}: could not find the "${n}" edge in the graph.`);const d=u.source.key,l=u.target.key;if(e===d)s=u.target;else if(e===l)s=u.source;else throw new T(`Graph.${i}: the "${e}" node is not attached to the "${n}" edge (${d}, ${l}).`);h=o,c=a}else{if(u=r._edges.get(e),!u)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`);t===ui?s=u.source:s=u.target,h=n,c=o}return[s,h,c]}function Qi(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);return a.attributes[s]}}function en(r,i,t){r.prototype[i]=function(e,n){const[o]=se(this,i,t,e,n);return o.attributes}}function tn(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);return a.attributes.hasOwnProperty(s)}}function nn(r,i,t){r.prototype[i]=function(e,n,o,a){const[s,u,h]=se(this,i,t,e,n,o,a);return s.attributes[u]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function rn(r,i,t){r.prototype[i]=function(e,n,o,a){const[s,u,h]=se(this,i,t,e,n,o,a);if(typeof h!="function")throw new C(`Graph.${i}: updater should be a function.`);const c=s.attributes,d=h(c[u]);return c[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function on(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function an(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);if(!V(s))throw new C(`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 sn(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);if(!V(s))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return B(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function un(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);if(typeof s!="function")throw new C(`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 hn=[{name:r=>`get${r}Attribute`,attacher:Qi},{name:r=>`get${r}Attributes`,attacher:en},{name:r=>`has${r}Attribute`,attacher:tn},{name:r=>`set${r}Attribute`,attacher:nn},{name:r=>`update${r}Attribute`,attacher:rn},{name:r=>`remove${r}Attribute`,attacher:on},{name:r=>`replace${r}Attributes`,attacher:an},{name:r=>`merge${r}Attributes`,attacher:sn},{name:r=>`update${r}Attributes`,attacher:un}];function dn(r){hn.forEach(function({name:i,attacher:t}){t(r,i("Node"),si),t(r,i("Source"),ui),t(r,i("Target"),Ji),t(r,i("Opposite"),hi)})}function cn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==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=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return o.attributes[n]}}function ln(r,i,t){r.prototype[i]=function(e){let n;if(this.type!=="mixed"&&t!=="mixed"&&t!==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=""+e,a=""+arguments[1];if(n=X(this,o,a,t),!n)throw new T(`Graph.${i}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,n=this._edges.get(e),!n)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return n.attributes}}function fn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==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=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return o.attributes.hasOwnProperty(n)}}function gn(r,i,t){r.prototype[i]=function(e,n,o){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==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=""+e,u=""+n;if(n=arguments[2],o=arguments[3],a=X(this,s,u,t),!a)throw new T(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return a.attributes[n]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:n}),this}}function pn(r,i,t){r.prototype[i]=function(e,n,o){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==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=""+e,u=""+n;if(n=arguments[2],o=arguments[3],a=X(this,s,u,t),!a)throw new T(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(typeof o!="function")throw new C(`Graph.${i}: updater should be a function.`);return a.attributes[n]=o(a.attributes[n]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:n}),this}}function mn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==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=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return delete o.attributes[n],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:n}),this}}function vn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==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=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(!V(n))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return o.attributes=n,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function yn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==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=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(!V(n))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return B(o.attributes,n),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:n}),this}}function bn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==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=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(typeof n!="function")throw new C(`Graph.${i}: provided updater is not a function.`);return o.attributes=n(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const wn=[{name:r=>`get${r}Attribute`,attacher:cn},{name:r=>`get${r}Attributes`,attacher:ln},{name:r=>`has${r}Attribute`,attacher:fn},{name:r=>`set${r}Attribute`,attacher:gn},{name:r=>`update${r}Attribute`,attacher:pn},{name:r=>`remove${r}Attribute`,attacher:mn},{name:r=>`replace${r}Attributes`,attacher:vn},{name:r=>`merge${r}Attributes`,attacher:yn},{name:r=>`update${r}Attributes`,attacher:bn}];function En(r){wn.forEach(function({name:i,attacher:t}){t(r,i("Edge"),"mixed"),t(r,i("DirectedEdge"),"directed"),t(r,i("UndirectedEdge"),"undirected")})}const _n=[{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 xn(r,i,t,e){let n=!1;for(const o in i){if(o===e)continue;const a=i[o];if(n=t(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),r&&n)return a.key}}function Tn(r,i,t,e){let n,o,a,s=!1;for(const u in i)if(u!==e){n=i[u];do{if(o=n.source,a=n.target,s=t(n.key,n.attributes,o.key,a.key,o.attributes,a.attributes,n.undirected),r&&s)return n.key;n=n.next}while(n!==void 0)}}function He(r,i){const t=Object.keys(r),e=t.length;let n,o=0;return{[Symbol.iterator](){return this},next(){do if(n)n=n.next;else{if(o>=e)return{done:!0};const a=t[o++];if(a===i){n=void 0;continue}n=r[a]}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}}}}function Rn(r,i,t,e){const n=i[t];if(!n)return;const o=n.source,a=n.target;if(e(n.key,n.attributes,o.key,a.key,o.attributes,a.attributes,n.undirected)&&r)return n.key}function Sn(r,i,t,e){let n=i[t];if(!n)return;let o=!1;do{if(o=e(n.key,n.attributes,n.source.key,n.target.key,n.source.attributes,n.target.attributes,n.undirected),r&&o)return n.key;n=n.next}while(n!==void 0)}function We(r,i){let t=r[i];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const n={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:n}}};let e=!1;return{[Symbol.iterator](){return this},next(){return e===!0?{done:!0}:(e=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function Cn(r,i){if(r.size===0)return[];if(i==="mixed"||i===r.type)return Array.from(r._edges.keys());const t=i==="undirected"?r.undirectedSize:r.directedSize,e=new Array(t),n=i==="undirected",o=r._edges.values();let a=0,s,u;for(;s=o.next(),s.done!==!0;)u=s.value,u.undirected===n&&(e[a++]=u.key);return e}function di(r,i,t,e){if(i.size===0)return;const n=t!=="mixed"&&t!==i.type,o=t==="undirected";let a,s,u=!1;const h=i._edges.values();for(;a=h.next(),a.done!==!0;){if(s=a.value,n&&s.undirected!==o)continue;const{key:c,attributes:d,source:l,target:f}=s;if(u=e(c,d,l.key,f.key,l.attributes,f.attributes,s.undirected),r&&u)return c}}function kn(r,i){if(r.size===0)return be();const t=i!=="mixed"&&i!==r.type,e=i==="undirected",n=r._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=n.next(),o.done)return o;if(a=o.value,!(t&&a.undirected!==e))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function pt(r,i,t,e,n,o){const a=i?Tn:xn;let s;if(t!=="undirected"&&(e!=="out"&&(s=a(r,n.in,o),r&&s)||e!=="in"&&(s=a(r,n.out,o,e?void 0:n.key),r&&s))||t!=="directed"&&(s=a(r,n.undirected,o),r&&s))return s}function An(r,i,t,e){const n=[];return pt(!1,r,i,t,e,function(o){n.push(o)}),n}function Ln(r,i,t){let e=be();return r!=="undirected"&&(i!=="out"&&typeof t.in<"u"&&(e=ae(e,He(t.in))),i!=="in"&&typeof t.out<"u"&&(e=ae(e,He(t.out,i?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(e=ae(e,He(t.undirected))),e}function mt(r,i,t,e,n,o,a){const s=t?Sn:Rn;let u;if(i!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&(u=s(r,n.in,o,a),r&&u)||typeof n.out<"u"&&e!=="in"&&(e||n.key!==o)&&(u=s(r,n.out,o,a),r&&u))||i!=="directed"&&typeof n.undirected<"u"&&(u=s(r,n.undirected,o,a),r&&u))return u}function Nn(r,i,t,e,n){const o=[];return mt(!1,r,i,t,e,n,function(a){o.push(a)}),o}function Dn(r,i,t,e){let n=be();return r!=="undirected"&&(typeof t.in<"u"&&i!=="out"&&e in t.in&&(n=ae(n,We(t.in,e))),typeof t.out<"u"&&i!=="in"&&e in t.out&&(i||t.key!==e)&&(n=ae(n,We(t.out,e)))),r!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(n=ae(n,We(t.undirected,e))),n}function Gn(r,i){const{name:t,type:e,direction:n}=i;r.prototype[t]=function(o,a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];if(!arguments.length)return Cn(this,e);if(arguments.length===1){o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new T(`Graph.${t}: could not find the "${o}" node in the graph.`);return An(this.multi,e==="mixed"?this.type:e,n,s)}if(arguments.length===2){o=""+o,a=""+a;const s=this._nodes.get(o);if(!s)throw new T(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new T(`Graph.${t}: could not find the "${a}" target node in the graph.`);return Nn(e,this.multi,n,s,a)}throw new C(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Fn(r,i){const{name:t,type:e,direction:n}=i,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(h,c,d){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return d=h,di(!1,this,e,d);if(arguments.length===2){h=""+h,d=c;const l=this._nodes.get(h);if(typeof l>"u")throw new T(`Graph.${o}: could not find the "${h}" node in the graph.`);return pt(!1,this.multi,e==="mixed"?this.type:e,n,l,d)}if(arguments.length===3){h=""+h,c=""+c;const l=this._nodes.get(h);if(!l)throw new T(`Graph.${o}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(c))throw new T(`Graph.${o}: could not find the "${c}" target node in the graph.`);return mt(!1,e,this.multi,n,l,c,d)}throw new C(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const a="map"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(){const h=Array.prototype.slice.call(arguments),c=h.pop();let d;if(h.length===0){let l=0;e!=="directed"&&(l+=this.undirectedSize),e!=="undirected"&&(l+=this.directedSize),d=new Array(l);let f=0;h.push((y,m,b,R,x,_,g)=>{d[f++]=c(y,m,b,R,x,_,g)})}else d=[],h.push((l,f,y,m,b,R,x)=>{d.push(c(l,f,y,m,b,R,x))});return this[o].apply(this,h),d};const s="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),c=h.pop(),d=[];return h.push((l,f,y,m,b,R,x)=>{c(l,f,y,m,b,R,x)&&d.push(l)}),this[o].apply(this,h),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[u]=function(){let h=Array.prototype.slice.call(arguments);if(h.length<2||h.length>4)throw new C(`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 C(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c,d;h.length===2?(c=h[0],d=h[1],h=[]):h.length===3?(c=h[1],d=h[2],h=[h[0]]):h.length===4&&(c=h[2],d=h[3],h=[h[0],h[1]]);let l=d;return h.push((f,y,m,b,R,x,_)=>{l=c(l,f,y,m,b,R,x,_)}),this[o].apply(this,h),l}}function Pn(r,i){const{name:t,type:e,direction:n}=i,o="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(u,h,c){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return c=u,di(!0,this,e,c);if(arguments.length===2){u=""+u,c=h;const d=this._nodes.get(u);if(typeof d>"u")throw new T(`Graph.${o}: could not find the "${u}" node in the graph.`);return pt(!0,this.multi,e==="mixed"?this.type:e,n,d,c)}if(arguments.length===3){u=""+u,h=""+h;const d=this._nodes.get(u);if(!d)throw new T(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(h))throw new T(`Graph.${o}: could not find the "${h}" target node in the graph.`);return mt(!0,e,this.multi,n,d,h,c)}throw new C(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const a="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((d,l,f,y,m,b,R)=>h(d,l,f,y,m,b,R)),!!this[o].apply(this,u)};const s="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((d,l,f,y,m,b,R)=>!h(d,l,f,y,m,b,R)),!this[o].apply(this,u)}}function Mn(r,i){const{name:t,type:e,direction:n}=i,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(a,s){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return be();if(!arguments.length)return kn(this,e);if(arguments.length===1){a=""+a;const u=this._nodes.get(a);if(!u)throw new T(`Graph.${o}: could not find the "${a}" node in the graph.`);return Ln(e,n,u)}if(arguments.length===2){a=""+a,s=""+s;const u=this._nodes.get(a);if(!u)throw new T(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new T(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Dn(e,n,u,s)}throw new C(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function In(r){_n.forEach(i=>{Gn(r,i),Fn(r,i),Pn(r,i),Mn(r,i)})}const zn=[{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 Ue(){this.A=null,this.B=null}Ue.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};Ue.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function _e(r,i,t,e,n){for(const o in e){const a=e[o],s=a.source,u=a.target,h=s===t?u:s;if(i&&i.has(h.key))continue;const c=n(h.key,h.attributes);if(r&&c)return h.key}}function vt(r,i,t,e,n){if(i!=="mixed"){if(i==="undirected")return _e(r,null,e,e.undirected,n);if(typeof t=="string")return _e(r,null,e,e[t],n)}const o=new Ue;let a;if(i!=="undirected"){if(t!=="out"){if(a=_e(r,null,e,e.in,n),r&&a)return a;o.wrap(e.in)}if(t!=="in"){if(a=_e(r,o,e,e.out,n),r&&a)return a;o.wrap(e.out)}}if(i!=="directed"&&(a=_e(r,o,e,e.undirected,n),r&&a))return a}function $n(r,i,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof i=="string")return Object.keys(t[i])}const e=[];return vt(!1,r,i,t,function(n){e.push(n)}),e}function xe(r,i,t){const e=Object.keys(t),n=e.length;let o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=n)return r&&r.wrap(t),{done:!0};const s=t[e[o++]],u=s.source,h=s.target;if(a=u===i?h:u,r&&r.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function Un(r,i,t){if(r!=="mixed"){if(r==="undirected")return xe(null,t,t.undirected);if(typeof i=="string")return xe(null,t,t[i])}let e=be();const n=new Ue;return r!=="undirected"&&(i!=="out"&&(e=ae(e,xe(n,t,t.in))),i!=="in"&&(e=ae(e,xe(n,t,t.out)))),r!=="directed"&&(e=ae(e,xe(n,t,t.undirected))),e}function On(r,i){const{name:t,type:e,direction:n}=i;r.prototype[t]=function(o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new T(`Graph.${t}: could not find the "${o}" node in the graph.`);return $n(e==="mixed"?this.type:e,n,a)}}function Bn(r,i){const{name:t,type:e,direction:n}=i,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(h,c){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const d=this._nodes.get(h);if(typeof d>"u")throw new T(`Graph.${o}: could not find the "${h}" node in the graph.`);vt(!1,e==="mixed"?this.type:e,n,d,c)};const a="map"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(h,c){const d=[];return this[o](h,(l,f)=>{d.push(c(l,f))}),d};const s="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(h,c){const d=[];return this[o](h,(l,f)=>{c(l,f)&&d.push(l)}),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[u]=function(h,c,d){if(arguments.length<3)throw new C(`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=d;return this[o](h,(f,y)=>{l=c(l,f,y)}),l}}function Hn(r,i){const{name:t,type:e,direction:n}=i,o=t[0].toUpperCase()+t.slice(1,-1),a="find"+o;r.prototype[a]=function(h,c){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const d=this._nodes.get(h);if(typeof d>"u")throw new T(`Graph.${a}: could not find the "${h}" node in the graph.`);return vt(!0,e==="mixed"?this.type:e,n,d,c)};const s="some"+o;r.prototype[s]=function(h,c){return!!this[a](h,c)};const u="every"+o;r.prototype[u]=function(h,c){return!this[a](h,(l,f)=>!c(l,f))}}function Wn(r,i){const{name:t,type:e,direction:n}=i,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return be();a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new T(`Graph.${o}: could not find the "${a}" node in the graph.`);return Un(e==="mixed"?this.type:e,n,s)}}function jn(r){zn.forEach(i=>{On(r,i),Bn(r,i),Hn(r,i),Wn(r,i)})}function Ge(r,i,t,e,n){const o=e._nodes.values(),a=e.type;let s,u,h,c,d,l;for(;s=o.next(),s.done!==!0;){let f=!1;if(u=s.value,a!=="undirected"){c=u.out;for(h in c){d=c[h];do l=d.target,f=!0,n(u.key,l.key,u.attributes,l.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(a!=="directed"){c=u.undirected;for(h in c)if(!(i&&u.key>h)){d=c[h];do l=d.target,l.key!==h&&(l=d.source),f=!0,n(u.key,l.key,u.attributes,l.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}t&&!f&&n(u.key,null,u.attributes,null,null,null,null)}}function Vn(r,i){const t={key:r};return ni(i.attributes)||(t.attributes=B({},i.attributes)),t}function qn(r,i,t){const e={key:i,source:t.source.key,target:t.target.key};return ni(t.attributes)||(e.attributes=B({},t.attributes)),r==="mixed"&&t.undirected&&(e.undirected=!0),e}function Kn(r){if(!V(r))throw new C('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new C("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!V(r.attributes)||r.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Yn(r){if(!V(r))throw new C('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new C("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new C("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!V(r.attributes)||r.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new C("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Zn=Xi(),Xn=new Set(["directed","undirected","mixed"]),Ct=new Set(["domain","_events","_eventsCount","_maxListeners"]),Jn=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],Qn={allowSelfLoops:!0,multi:!1,type:"mixed"};function er(r,i,t){if(t&&!V(t))throw new C(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(i=""+i,t=t||{},r._nodes.has(i))throw new D(`Graph.addNode: the "${i}" node already exist in the graph.`);const e=new r.NodeDataClass(i,t);return r._nodes.set(i,e),r.emit("nodeAdded",{key:i,attributes:t}),e}function kt(r,i,t){const e=new r.NodeDataClass(i,t);return r._nodes.set(i,e),r.emit("nodeAdded",{key:i,attributes:t}),e}function ci(r,i,t,e,n,o,a,s){if(!e&&r.type==="undirected")throw new D(`Graph.${i}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(e&&r.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&&!V(s))throw new C(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!r.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=r._nodes.get(o),h=r._nodes.get(a);if(!u)throw new T(`Graph.${i}: source node "${o}" not found.`);if(!h)throw new T(`Graph.${i}: target node "${a}" not found.`);const c={key:null,undirected:e,source:o,target:a,attributes:s};if(t)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new D(`Graph.${i}: the "${n}" edge already exists in the graph.`);if(!r.multi&&(e?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 d=new we(e,n,u,h,s);r._edges.set(n,d);const l=o===a;return e?(u.undirectedDegree++,h.undirectedDegree++,l&&(u.undirectedLoops++,r._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,l&&(u.directedLoops++,r._directedSelfLoopCount++)),r.multi?d.attachMulti():d.attach(),e?r._undirectedSize++:r._directedSize++,c.key=n,r.emit("edgeAdded",c),n}function tr(r,i,t,e,n,o,a,s,u){if(!e&&r.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(e&&r.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 C(`Graph.${i}: invalid updater function. Expecting a function but got "${s}"`)}else if(!V(s))throw new C(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let h;if(u&&(h=s,s=void 0),!r.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 c=r._nodes.get(o),d=r._nodes.get(a),l,f;if(!t&&(l=r._edges.get(n),l)){if((l.source.key!==o||l.target.key!==a)&&(!e||l.source.key!==a||l.target.key!==o))throw new D(`Graph.${i}: inconsistency detected when attempting to merge the "${n}" edge with "${o}" source & "${a}" target vs. ("${l.source.key}", "${l.target.key}").`);f=l}if(!f&&!r.multi&&c&&(f=e?c.undirected[a]:c.out[a]),f){const x=[f.key,!1,!1,!1];if(u?!h:!s)return x;if(u){const _=f.attributes;f.attributes=h(_),r.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else B(f.attributes,s),r.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return x}s=s||{},u&&h&&(s=h(s));const y={key:null,undirected:e,source:o,target:a,attributes:s};if(t)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new D(`Graph.${i}: the "${n}" edge already exists in the graph.`);let m=!1,b=!1;c||(c=kt(r,o,{}),m=!0,o===a&&(d=c,b=!0)),d||(d=kt(r,a,{}),b=!0),l=new we(e,n,c,d,s),r._edges.set(n,l);const R=o===a;return e?(c.undirectedDegree++,d.undirectedDegree++,R&&(c.undirectedLoops++,r._undirectedSelfLoopCount++)):(c.outDegree++,d.inDegree++,R&&(c.directedLoops++,r._directedSelfLoopCount++)),r.multi?l.attachMulti():l.attach(),e?r._undirectedSize++:r._directedSize++,y.key=n,r.emit("edgeAdded",y),[n,!0,m,b]}function ge(r,i){r._edges.delete(i.key);const{source:t,target:e,attributes:n}=i,o=i.undirected,a=t===e;o?(t.undirectedDegree--,e.undirectedDegree--,a&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,e.inDegree--,a&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?i.detachMulti():i.detach(),o?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:i.key,attributes:n,source:t.key,target:e.key,undirected:o})}class U extends ii.EventEmitter{constructor(i){if(super(),i=B({},Qn,i),typeof i.multi!="boolean")throw new C(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${i.multi}".`);if(!Xn.has(i.type))throw new C(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${i.type}".`);if(typeof i.allowSelfLoops!="boolean")throw new C(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${i.allowSelfLoops}".`);const t=i.type==="mixed"?ri:i.type==="directed"?oi:ai;Z(this,"NodeDataClass",t);const e="geid_"+Zn()+"_";let n=0;const o=()=>{let a;do a=e+n++;while(this._edges.has(a));return a};Z(this,"_attributes",{}),Z(this,"_nodes",new Map),Z(this,"_edges",new Map),Z(this,"_directedSize",0),Z(this,"_undirectedSize",0),Z(this,"_directedSelfLoopCount",0),Z(this,"_undirectedSelfLoopCount",0),Z(this,"_edgeKeyGenerator",o),Z(this,"_options",i),Ct.forEach(a=>Z(this,a,this[a])),J(this,"order",()=>this._nodes.size),J(this,"size",()=>this._edges.size),J(this,"directedSize",()=>this._directedSize),J(this,"undirectedSize",()=>this._undirectedSize),J(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),J(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),J(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),J(this,"multi",this._options.multi),J(this,"type",this._options.type),J(this,"allowSelfLoops",this._options.allowSelfLoops),J(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,t){if(this.type==="undirected")return!1;if(arguments.length===1){const e=""+i,n=this._edges.get(e);return!!n&&!n.undirected}else if(arguments.length===2){i=""+i,t=""+t;const e=this._nodes.get(i);return e?e.out.hasOwnProperty(t):!1}throw new C(`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,t){if(this.type==="directed")return!1;if(arguments.length===1){const e=""+i,n=this._edges.get(e);return!!n&&n.undirected}else if(arguments.length===2){i=""+i,t=""+t;const e=this._nodes.get(i);return e?e.undirected.hasOwnProperty(t):!1}throw new C(`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,t){if(arguments.length===1){const e=""+i;return this._edges.has(e)}else if(arguments.length===2){i=""+i,t=""+t;const e=this._nodes.get(i);return e?typeof e.out<"u"&&e.out.hasOwnProperty(t)||typeof e.undirected<"u"&&e.undirected.hasOwnProperty(t):!1}throw new C(`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,t){if(this.type==="undirected")return;if(i=""+i,t=""+t,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 e=this._nodes.get(i);if(!e)throw new T(`Graph.directedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(t))throw new T(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const n=e.out&&e.out[t]||void 0;if(n)return n.key}undirectedEdge(i,t){if(this.type==="directed")return;if(i=""+i,t=""+t,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 e=this._nodes.get(i);if(!e)throw new T(`Graph.undirectedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(t))throw new T(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const n=e.undirected&&e.undirected[t]||void 0;if(n)return n.key}edge(i,t){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,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.edge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(t))throw new T(`Graph.edge: could not find the "${t}" target node in the graph.`);const n=e.out&&e.out[t]||e.undirected&&e.undirected[t]||void 0;if(n)return n.key}areDirectedNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areDirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:t in e.in||t in e.out}areOutNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areOutNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:t in e.out}areInNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areInNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:t in e.in}areUndirectedNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areUndirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="directed"?!1:t in e.undirected}areNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&(t in e.in||t in e.out)||this.type!=="directed"&&t in e.undirected}areInboundNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areInboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&t in e.in||this.type!=="directed"&&t in e.undirected}areOutboundNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areOutboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&t in e.out||this.type!=="directed"&&t in e.undirected}inDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.directedDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.undirectedDegree: could not find the "${i}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inboundDegree: could not find the "${i}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree),e}outboundDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outboundDegree: could not find the "${i}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.outDegree),e}degree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.degree: could not find the "${i}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree),e}inDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.directedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let e=0,n=0;return this.type!=="directed"&&(e+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree,n+=t.directedLoops),e-n}outboundDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let e=0,n=0;return this.type!=="directed"&&(e+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.outDegree,n+=t.directedLoops),e-n}degreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.degreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let e=0,n=0;return this.type!=="directed"&&(e+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree,n+=t.directedLoops*2),e-n}source(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.source: could not find the "${i}" edge in the graph.`);return t.source.key}target(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.target: could not find the "${i}" edge in the graph.`);return t.target.key}extremities(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.extremities: could not find the "${i}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(i,t){i=""+i,t=""+t;const e=this._edges.get(t);if(!e)throw new T(`Graph.opposite: could not find the "${t}" edge in the graph.`);const n=e.source.key,o=e.target.key;if(i===n)return o;if(i===o)return n;throw new T(`Graph.opposite: the "${i}" node is not attached to the "${t}" edge (${n}, ${o}).`)}hasExtremity(i,t){i=""+i,t=""+t;const e=this._edges.get(i);if(!e)throw new T(`Graph.hasExtremity: could not find the "${i}" edge in the graph.`);return e.source.key===t||e.target.key===t}isUndirected(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.isUndirected: could not find the "${i}" edge in the graph.`);return t.undirected}isDirected(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.isDirected: could not find the "${i}" edge in the graph.`);return!t.undirected}isSelfLoop(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.isSelfLoop: could not find the "${i}" edge in the graph.`);return t.source===t.target}addNode(i,t){return er(this,i,t).key}mergeNode(i,t){if(t&&!V(t))throw new C(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);i=""+i,t=t||{};let e=this._nodes.get(i);return e?(t&&(B(e.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:i,attributes:e.attributes,data:t})),[i,!1]):(e=new this.NodeDataClass(i,t),this._nodes.set(i,e),this.emit("nodeAdded",{key:i,attributes:t}),[i,!0])}updateNode(i,t){if(t&&typeof t!="function")throw new C(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);i=""+i;let e=this._nodes.get(i);if(e){if(t){const o=e.attributes;e.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:i,attributes:e.attributes})}return[i,!1]}const n=t?t({}):{};return e=new this.NodeDataClass(i,n),this._nodes.set(i,e),this.emit("nodeAdded",{key:i,attributes:n}),[i,!0]}dropNode(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.dropNode: could not find the "${i}" node in the graph.`);let e;if(this.type!=="undirected"){for(const n in t.out){e=t.out[n];do ge(this,e),e=e.next;while(e)}for(const n in t.in){e=t.in[n];do ge(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const n in t.undirected){e=t.undirected[n];do ge(this,e),e=e.next;while(e)}this._nodes.delete(i),this.emit("nodeDropped",{key:i,attributes:t.attributes})}dropEdge(i){let t;if(arguments.length>1){const e=""+arguments[0],n=""+arguments[1];if(t=X(this,e,n,this.type),!t)throw new T(`Graph.dropEdge: could not find the "${e}" -> "${n}" edge in the graph.`)}else if(i=""+i,t=this._edges.get(i),!t)throw new T(`Graph.dropEdge: could not find the "${i}" edge in the graph.`);return ge(this,t),this}dropDirectedEdge(i,t){if(arguments.length<2)throw new D("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new D("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");i=""+i,t=""+t;const e=X(this,i,t,"directed");if(!e)throw new T(`Graph.dropDirectedEdge: could not find a "${i}" -> "${t}" edge in the graph.`);return ge(this,e),this}dropUndirectedEdge(i,t){if(arguments.length<2)throw new D("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new D("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const e=X(this,i,t,"undirected");if(!e)throw new T(`Graph.dropUndirectedEdge: could not find a "${i}" -> "${t}" edge in the graph.`);return ge(this,e),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const i=this._nodes.values();let t;for(;t=i.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(i){return this._attributes[i]}getAttributes(){return this._attributes}hasAttribute(i){return this._attributes.hasOwnProperty(i)}setAttribute(i,t){return this._attributes[i]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}updateAttribute(i,t){if(typeof t!="function")throw new C("Graph.updateAttribute: updater should be a function.");const e=this._attributes[i];return this._attributes[i]=t(e),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(!V(i))throw new C("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(!V(i))throw new C("Graph.mergeAttributes: provided attributes are not a plain object.");return B(this._attributes,i),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:i}),this}updateAttributes(i){if(typeof i!="function")throw new C("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,t){if(typeof i!="function")throw new C("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!St(t))throw new C("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._nodes.values();let n,o;for(;n=e.next(),n.done!==!0;)o=n.value,o.attributes=i(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(i,t){if(typeof i!="function")throw new C("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!St(t))throw new C("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._edges.values();let n,o,a,s;for(;n=e.next(),n.done!==!0;)o=n.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:t||null})}forEachAdjacencyEntry(i){if(typeof i!="function")throw new C("Graph.forEachAdjacencyEntry: expecting a callback.");Ge(!1,!1,!1,this,i)}forEachAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new C("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Ge(!1,!1,!0,this,i)}forEachAssymetricAdjacencyEntry(i){if(typeof i!="function")throw new C("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Ge(!1,!0,!1,this,i)}forEachAssymetricAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new C("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Ge(!1,!0,!0,this,i)}nodes(){return Array.from(this._nodes.keys())}forEachNode(i){if(typeof i!="function")throw new C("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)n=e.value,i(n.key,n.attributes)}findNode(i){if(typeof i!="function")throw new C("Graph.findNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)if(n=e.value,i(n.key,n.attributes))return n.key}mapNodes(i){if(typeof i!="function")throw new C("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let e,n;const o=new Array(this.order);let a=0;for(;e=t.next(),e.done!==!0;)n=e.value,o[a++]=i(n.key,n.attributes);return o}someNode(i){if(typeof i!="function")throw new C("Graph.someNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)if(n=e.value,i(n.key,n.attributes))return!0;return!1}everyNode(i){if(typeof i!="function")throw new C("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)if(n=e.value,!i(n.key,n.attributes))return!1;return!0}filterNodes(i){if(typeof i!="function")throw new C("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let e,n;const o=[];for(;e=t.next(),e.done!==!0;)n=e.value,i(n.key,n.attributes)&&o.push(n.key);return o}reduceNodes(i,t){if(typeof i!="function")throw new C("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new C("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let e=t;const n=this._nodes.values();let o,a;for(;o=n.next(),o.done!==!0;)a=o.value,e=i(e,a.key,a.attributes);return e}nodeEntries(){const i=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=i.next();if(t.done)return t;const e=t.value;return{value:{node:e.key,attributes:e.attributes},done:!1}}}}export(){const i=new Array(this._nodes.size);let t=0;this._nodes.forEach((n,o)=>{i[t++]=Vn(o,n)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((n,o)=>{e[t++]=qn(this.type,o,n)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:i,edges:e}}import(i,t=!1){if(i instanceof U)return i.forEachNode((u,h)=>{t?this.mergeNode(u,h):this.addNode(u,h)}),i.forEachEdge((u,h,c,d,l,f,y)=>{t?y?this.mergeUndirectedEdgeWithKey(u,c,d,h):this.mergeDirectedEdgeWithKey(u,c,d,h):y?this.addUndirectedEdgeWithKey(u,c,d,h):this.addDirectedEdgeWithKey(u,c,d,h)}),this;if(!V(i))throw new C("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(i.attributes){if(!V(i.attributes))throw new C("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(i.attributes):this.replaceAttributes(i.attributes)}let e,n,o,a,s;if(i.nodes){if(o=i.nodes,!Array.isArray(o))throw new C("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=o.length;e<n;e++){a=o[e],Kn(a);const{key:u,attributes:h}=a;t?this.mergeNode(u,h):this.addNode(u,h)}}if(i.edges){let u=!1;if(this.type==="undirected"&&(u=!0),o=i.edges,!Array.isArray(o))throw new C("Graph.import: invalid edges. Expecting an array.");for(e=0,n=o.length;e<n;e++){s=o[e],Yn(s);const{source:h,target:c,attributes:d,undirected:l=u}=s;let f;"key"in s?(f=t?l?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:l?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,h,c,d)):(f=t?l?this.mergeUndirectedEdge:this.mergeDirectedEdge:l?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,h,c,d))}}return this}nullCopy(i){const t=new U(B({},this._options,i));return t.replaceAttributes(B({},this.getAttributes())),t}emptyCopy(i){const t=this.nullCopy(i);return this._nodes.forEach((e,n)=>{const o=B({},e.attributes);e=new t.NodeDataClass(n,o),t._nodes.set(n,e)}),t}copy(i){if(i=i||{},typeof i.type=="string"&&i.type!==this.type&&i.type!=="mixed")throw new D(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${i.type}" because this would mean losing information about the current graph.`);if(typeof i.multi=="boolean"&&i.multi!==this.multi&&i.multi!==!0)throw new D("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof i.allowSelfLoops=="boolean"&&i.allowSelfLoops!==this.allowSelfLoops&&i.allowSelfLoops!==!0)throw new D("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(i),e=this._edges.values();let n,o;for(;n=e.next(),n.done!==!0;)o=n.value,ci(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,B({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const i={};this._nodes.forEach((o,a)=>{i[a]=o.attributes});const t={},e={};this._edges.forEach((o,a)=>{const s=o.undirected?"--":"->";let u="",h=o.source.key,c=o.target.key,d;o.undirected&&h>c&&(d=h,h=c,c=d);const l=`(${h})${s}(${c})`;a.startsWith("geid_")?this.multi&&(typeof e[l]>"u"?e[l]=0:e[l]++,u+=`${e[l]}. `):u+=`[${a}]: `,u+=l,t[u]=o.attributes});const n={};for(const o in this)this.hasOwnProperty(o)&&!Ct.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(n[o]=this[o]);return n.attributes=this._attributes,n.nodes=i,n.edges=t,Z(n,"constructor",this.constructor),n}}typeof Symbol<"u"&&(U.prototype[Symbol.for("nodejs.util.inspect.custom")]=U.prototype.inspect);Jn.forEach(r=>{["add","merge","update"].forEach(i=>{const t=r.name(i),e=i==="add"?ci:tr;r.generateKey?U.prototype[t]=function(n,o,a){return e(this,t,!0,(r.type||this.type)==="undirected",null,n,o,a,i==="update")}:U.prototype[t]=function(n,o,a,s){return e(this,t,!1,(r.type||this.type)==="undirected",n,o,a,s,i==="update")}})});dn(U);En(U);In(U);jn(U);class li extends U{constructor(i){const t=B({type:"directed"},i);if("multi"in t&&t.multi!==!1)throw new C("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new C('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class fi extends U{constructor(i){const t=B({type:"undirected"},i);if("multi"in t&&t.multi!==!1)throw new C("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new C('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class gi extends U{constructor(i){const t=B({multi:!0},i);if("multi"in t&&t.multi!==!0)throw new C("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class yt extends U{constructor(i){const t=B({type:"directed",multi:!0},i);if("multi"in t&&t.multi!==!0)throw new C("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new C('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class pi extends U{constructor(i){const t=B({type:"undirected",multi:!0},i);if("multi"in t&&t.multi!==!0)throw new C("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new C('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Ee(r){r.from=function(i,t){const e=B({},i.options,t),n=new r(e);return n.import(i),n}}Ee(U);Ee(li);Ee(fi);Ee(gi);Ee(yt);Ee(pi);U.Graph=U;U.DirectedGraph=li;U.UndirectedGraph=fi;U.MultiGraph=gi;U.MultiDirectedGraph=yt;U.MultiUndirectedGraph=pi;U.InvalidArgumentsGraphError=C;U.NotFoundGraphError=T;U.UsageGraphError=D;function ir(r,i){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var e=t.call(r,i);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(r)}function Ae(r){var i=ir(r,"string");return typeof i=="symbol"?i:i+""}function W(r,i){if(!(r instanceof i))throw new TypeError("Cannot call a class as a function")}function At(r,i){for(var t=0;t<i.length;t++){var e=i[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,Ae(e.key),e)}}function j(r,i,t){return i&&At(r.prototype,i),t&&At(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function ve(r){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ve(r)}function mi(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(mi=function(){return!!r})()}function nr(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function rr(r,i){if(i&&(typeof i=="object"||typeof i=="function"))return i;if(i!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return nr(r)}function q(r,i,t){return i=ve(i),rr(r,mi()?Reflect.construct(i,t||[],ve(r).constructor):i.apply(r,t))}function st(r,i){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},st(r,i)}function K(r,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(i&&i.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),i&&st(r,i)}function or(r){if(Array.isArray(r))return r}function ar(r,i){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var e,n,o,a,s=[],u=!0,h=!1;try{if(o=(t=t.call(r)).next,i===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(e=o.call(t)).done)&&(s.push(e.value),s.length!==i);u=!0);}catch(c){h=!0,n=c}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw n}}return s}}function ut(r,i){(i==null||i>r.length)&&(i=r.length);for(var t=0,e=Array(i);t<i;t++)e[t]=r[t];return e}function vi(r,i){if(r){if(typeof r=="string")return ut(r,i);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ut(r,i):void 0}}function sr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ye(r,i){return or(r)||ar(r,i)||vi(r,i)||sr()}var je={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"},yi=new Int8Array(4),Ve=new Int32Array(yi.buffer,0,1),ur=new Float32Array(yi.buffer,0,1),hr=/^\s*rgba?\s*\(/,dr=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function cr(r){var i=0,t=0,e=0,n=1;if(r[0]==="#")r.length===4?(i=parseInt(r.charAt(1)+r.charAt(1),16),t=parseInt(r.charAt(2)+r.charAt(2),16),e=parseInt(r.charAt(3)+r.charAt(3),16)):(i=parseInt(r.charAt(1)+r.charAt(2),16),t=parseInt(r.charAt(3)+r.charAt(4),16),e=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(n=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(hr.test(r)){var o=r.match(dr);o&&(i=+o[1],t=+o[2],e=+o[3],o[4]&&(n=+o[4]))}return{r:i,g:t,b:e,a:n}}var me={};for(var Fe in je)me[Fe]=fe(je[Fe]),me[je[Fe]]=me[Fe];function bi(r,i,t,e,n){return Ve[0]=e<<24|t<<16|i<<8|r,Ve[0]=Ve[0]&4278190079,ur[0]}function fe(r){if(r=r.toLowerCase(),typeof me[r]<"u")return me[r];var i=cr(r),t=i.r,e=i.g,n=i.b,o=i.a;o=o*255|0;var a=bi(t,e,n,o);return me[r]=a,a}var qe={};function wi(r){if(typeof qe[r]<"u")return qe[r];var i=(r&16711680)>>>16,t=(r&65280)>>>8,e=r&255,n=255,o=bi(i,t,e,n);return qe[r]=o,o}function Lt(r,i,t,e){return t+(i<<8)+(r<<16)}function Nt(r,i,t,e,n,o){var a=Math.floor(t/o*n),s=Math.floor(r.drawingBufferHeight/o-e/o*n),u=new Uint8Array(4);r.bindFramebuffer(r.FRAMEBUFFER,i),r.readPixels(a,s,1,1,r.RGBA,r.UNSIGNED_BYTE,u);var h=ye(u,4),c=h[0],d=h[1],l=h[2],f=h[3];return[c,d,l,f]}function w(r,i,t){return(i=Ae(i))in r?Object.defineProperty(r,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[i]=t,r}function Dt(r,i){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);i&&(e=e.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,e)}return t}function A(r){for(var i=1;i<arguments.length;i++){var t=arguments[i]!=null?arguments[i]:{};i%2?Dt(Object(t),!0).forEach(function(e){w(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Dt(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function lr(r,i){for(;!{}.hasOwnProperty.call(r,i)&&(r=ve(r))!==null;);return r}function ht(){return ht=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,i,t){var e=lr(r,i);if(e){var n=Object.getOwnPropertyDescriptor(e,i);return n.get?n.get.call(arguments.length<3?r:t):n.value}},ht.apply(null,arguments)}function Ei(r,i,t,e){var n=ht(ve(r.prototype),i,t);return typeof n=="function"?function(o){return n.apply(t,o)}:n}function fr(r){return r.normalized?1:r.size}function Ke(r){var i=0;return r.forEach(function(t){return i+=fr(t)}),i}function _i(r,i,t){var e=r==="VERTEX"?i.VERTEX_SHADER:i.FRAGMENT_SHADER,n=i.createShader(e);if(n===null)throw new Error("loadShader: error while creating the shader");i.shaderSource(n,t),i.compileShader(n);var o=i.getShaderParameter(n,i.COMPILE_STATUS);if(!o){var a=i.getShaderInfoLog(n);throw i.deleteShader(n),new Error(`loadShader: error while compiling the shader:
|
|
3
|
+
`.concat(a,`
|
|
4
|
+
`).concat(t))}return n}function gr(r,i){return _i("VERTEX",r,i)}function pr(r,i){return _i("FRAGMENT",r,i)}function mr(r,i){var t=r.createProgram();if(t===null)throw new Error("loadProgram: error while creating the program.");var e,n;for(e=0,n=i.length;e<n;e++)r.attachShader(t,i[e]);r.linkProgram(t);var o=r.getProgramParameter(t,r.LINK_STATUS);if(!o){var a=r.getProgramInfoLog(t);throw r.deleteProgram(t),new Error("loadProgram: error while linking the program: ".concat(a))}return t}function Gt(r){var i=r.gl,t=r.buffer,e=r.program,n=r.vertexShader,o=r.fragmentShader;i.deleteShader(n),i.deleteShader(o),i.deleteProgram(e),i.deleteBuffer(t)}var Ft=`#define PICKING_MODE
|
|
5
|
+
`,vr=w(w(w(w(w(w(w(w({},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),xi=(function(){function r(i,t,e){W(this,r),w(this,"array",new Float32Array),w(this,"constantArray",new Float32Array),w(this,"capacity",0),w(this,"verticesCount",0);var n=this.getDefinition();if(this.VERTICES=n.VERTICES,this.VERTEX_SHADER_SOURCE=n.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=n.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=n.UNIFORMS,this.ATTRIBUTES=n.ATTRIBUTES,this.METHOD=n.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in n?n.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in n?n.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in n,this.ATTRIBUTES_ITEMS_COUNT=Ke(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=e,this.normalProgram=this.getProgramInfo("normal",i,n.VERTEX_SHADER_SOURCE,n.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=t?this.getProgramInfo("pick",i,Ft+n.VERTEX_SHADER_SOURCE,Ft+n.FRAGMENT_SHADER_SOURCE,t):null,this.isInstanced){var o=Ke(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 j(r,[{key:"kill",value:function(){Gt(this.normalProgram),this.pickProgram&&(Gt(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(t,e,n,o,a){var s=this.getDefinition(),u=e.createBuffer();if(u===null)throw new Error("Program: error while creating the WebGL buffer.");var h=gr(e,n),c=pr(e,o),d=mr(e,[h,c]),l={};s.UNIFORMS.forEach(function(m){var b=e.getUniformLocation(d,m);b&&(l[m]=b)});var f={};s.ATTRIBUTES.forEach(function(m){f[m.name]=e.getAttribLocation(d,m.name)});var y;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(m){f[m.name]=e.getAttribLocation(d,m.name)}),y=e.createBuffer(),y===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:t,program:d,gl:e,frameBuffer:a,buffer:u,constantBuffer:y||{},uniformLocations:l,attributeLocations:f,isPicking:t==="pick",vertexShader:h,fragmentShader:c}}},{key:"bindProgram",value:function(t){var e=this,n=0,o=t.gl,a=t.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,t.constantBuffer),n=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return n+=e.bindAttribute(s,t,n,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,t.buffer),n=0,this.ATTRIBUTES.forEach(function(s){return n+=e.bindAttribute(s,t,n,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),n=0,this.ATTRIBUTES.forEach(function(s){return n+=e.bindAttribute(s,t,n)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(t){var e=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(n){return e.unbindAttribute(n,t,!1)}),this.ATTRIBUTES.forEach(function(n){return e.unbindAttribute(n,t,!0)})):this.ATTRIBUTES.forEach(function(n){return e.unbindAttribute(n,t)})}},{key:"bindAttribute",value:function(t,e,n,o){var a=vr[t.type];if(typeof a!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(t.type,'"'));var s=e.attributeLocations[t.name],u=e.gl;if(s!==-1){u.enableVertexAttribArray(s);var h=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:Ke(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(u.vertexAttribPointer(s,t.size,t.type,t.normalized||!1,h,n),this.isInstanced&&o)if(u instanceof WebGL2RenderingContext)u.vertexAttribDivisor(s,1);else{var c=u.getExtension("ANGLE_instanced_arrays");c&&c.vertexAttribDivisorANGLE(s,1)}}return t.size*a}},{key:"unbindAttribute",value:function(t,e,n){var o=e.attributeLocations[t.name],a=e.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&n))if(a instanceof WebGL2RenderingContext)a.vertexAttribDivisor(o,0);else{var s=a.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(t){t!==this.capacity&&(this.capacity=t,this.verticesCount=this.VERTICES*t,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(t,e){var n=e.gl,o=e.program;n.enable(n.BLEND),n.useProgram(o),this.setUniforms(t,e),this.drawWebGL(this.METHOD,e)}},{key:"render",value:function(t){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,t.width*t.pixelRatio/t.downSizingRatio,t.height*t.pixelRatio/t.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(A(A({},t),{},{pixelRatio:t.pixelRatio/t.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,t.width*t.pixelRatio,t.height*t.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(t,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(t,e){var n=e.gl,o=e.frameBuffer;if(n.bindFramebuffer(n.FRAMEBUFFER,o),!this.isInstanced)n.drawArrays(t,0,this.verticesCount);else if(n instanceof WebGL2RenderingContext)n.drawArraysInstanced(t,0,this.VERTICES,this.capacity);else{var a=n.getExtension("ANGLE_instanced_arrays");a&&a.drawArraysInstancedANGLE(t,0,this.VERTICES,this.capacity)}}}])})(),yr=(function(r){function i(){return W(this,i),q(this,i,arguments)}return K(i,r),j(i,[{key:"kill",value:function(){Ei(i,"kill",this)([])}},{key:"process",value:function(e,n,o){var a=n*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(wi(e),a,o)}}])})(xi),Le=(function(r){function i(){var t;W(this,i);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];return t=q(this,i,[].concat(n)),w(t,"drawLabel",void 0),t}return K(i,r),j(i,[{key:"kill",value:function(){Ei(i,"kill",this)([])}},{key:"process",value:function(e,n,o,a,s){var u=n*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(wi(e),u,o,a,s)}}])})(xi);function Ti(r,i){return(function(){function t(e,n,o){W(this,t),w(this,"drawLabel",i),this.programs=r.map(function(a){return new a(e,n,o)})}return j(t,[{key:"reallocate",value:function(n){this.programs.forEach(function(o){return o.reallocate(n)})}},{key:"process",value:function(n,o,a,s,u){this.programs.forEach(function(h){return h.process(n,o,a,s,u)})}},{key:"render",value:function(n){this.programs.forEach(function(o){return o.render(n)})}},{key:"kill",value:function(){this.programs.forEach(function(n){return n.kill()})}}])})()}function br(r,i,t,e,n){var o=n.edgeLabelSize,a=n.edgeLabelFont,s=n.edgeLabelWeight,u=n.edgeLabelColor.attribute?i[n.edgeLabelColor.attribute]||n.edgeLabelColor.color||"#000":n.edgeLabelColor.color,h=i.label;if(h){r.fillStyle=u,r.font="".concat(s," ").concat(o,"px ").concat(a);var c=t.size,d=e.size,l=t.x,f=t.y,y=e.x,m=e.y,b=(l+y)/2,R=(f+m)/2,x=y-l,_=m-f,g=Math.sqrt(x*x+_*_);if(!(g<c+d)){l+=x*c/g,f+=_*c/g,y-=x*d/g,m-=_*d/g,b=(l+y)/2,R=(f+m)/2,x=y-l,_=m-f,g=Math.sqrt(x*x+_*_);var p=r.measureText(h).width;if(p>g){var v="…";for(h=h+v,p=r.measureText(h).width;p>g&&h.length>1;)h=h.slice(0,-2)+v,p=r.measureText(h).width;if(h.length<4)return}var E;x>0?_>0?E=Math.acos(x/g):E=Math.asin(_/g):_>0?E=Math.acos(x/g)+Math.PI:E=Math.asin(x/g)+Math.PI/2,r.save(),r.translate(b,R),r.rotate(E),r.fillText(h,-p/2,i.size/2+o),r.restore()}}}function Ri(r,i,t){if(i.label){var e=t.labelSize,n=t.labelFont,o=t.labelWeight,a=t.labelColor.attribute?i[t.labelColor.attribute]||t.labelColor.color||"#000":t.labelColor.color;r.fillStyle=a,r.font="".concat(o," ").concat(e,"px ").concat(n),r.fillText(i.label,i.x+i.size+3,i.y+e/3)}}function wr(r,i,t){var e=t.labelSize,n=t.labelFont,o=t.labelWeight;r.font="".concat(o," ").concat(e,"px ").concat(n),r.fillStyle="#FFF",r.shadowOffsetX=0,r.shadowOffsetY=0,r.shadowBlur=8,r.shadowColor="#000";var a=2;if(typeof i.label=="string"){var s=r.measureText(i.label).width,u=Math.round(s+5),h=Math.round(e+2*a),c=Math.max(i.size,e/2)+a,d=Math.asin(h/2/c),l=Math.sqrt(Math.abs(Math.pow(c,2)-Math.pow(h/2,2)));r.beginPath(),r.moveTo(i.x+l,i.y+h/2),r.lineTo(i.x+c+u,i.y+h/2),r.lineTo(i.x+c+u,i.y-h/2),r.lineTo(i.x+l,i.y-h/2),r.arc(i.x,i.y,c,d,-d),r.closePath(),r.fill()}else r.beginPath(),r.arc(i.x,i.y,i.size+a,0,Math.PI*2),r.closePath(),r.fill();r.shadowOffsetX=0,r.shadowOffsetY=0,r.shadowBlur=0,Ri(r,i,t)}var Er=`
|
|
6
|
+
precision highp float;
|
|
7
|
+
|
|
8
|
+
varying vec4 v_color;
|
|
9
|
+
varying vec2 v_diffVector;
|
|
10
|
+
varying float v_radius;
|
|
11
|
+
|
|
12
|
+
uniform float u_correctionRatio;
|
|
13
|
+
|
|
14
|
+
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
15
|
+
|
|
16
|
+
void main(void) {
|
|
17
|
+
float border = u_correctionRatio * 2.0;
|
|
18
|
+
float dist = length(v_diffVector) - v_radius + border;
|
|
19
|
+
|
|
20
|
+
// No antialiasing for picking mode:
|
|
21
|
+
#ifdef PICKING_MODE
|
|
22
|
+
if (dist > border)
|
|
23
|
+
gl_FragColor = transparent;
|
|
24
|
+
else
|
|
25
|
+
gl_FragColor = v_color;
|
|
26
|
+
|
|
27
|
+
#else
|
|
28
|
+
float t = 0.0;
|
|
29
|
+
if (dist > border)
|
|
30
|
+
t = 1.0;
|
|
31
|
+
else if (dist > 0.0)
|
|
32
|
+
t = dist / border;
|
|
33
|
+
|
|
34
|
+
gl_FragColor = mix(v_color, transparent, t);
|
|
35
|
+
#endif
|
|
36
|
+
}
|
|
37
|
+
`,_r=Er,xr=`
|
|
38
|
+
attribute vec4 a_id;
|
|
39
|
+
attribute vec4 a_color;
|
|
40
|
+
attribute vec2 a_position;
|
|
41
|
+
attribute float a_size;
|
|
42
|
+
attribute float a_angle;
|
|
43
|
+
|
|
44
|
+
uniform mat3 u_matrix;
|
|
45
|
+
uniform float u_sizeRatio;
|
|
46
|
+
uniform float u_correctionRatio;
|
|
47
|
+
|
|
48
|
+
varying vec4 v_color;
|
|
49
|
+
varying vec2 v_diffVector;
|
|
50
|
+
varying float v_radius;
|
|
51
|
+
varying float v_border;
|
|
52
|
+
|
|
53
|
+
const float bias = 255.0 / 254.0;
|
|
54
|
+
|
|
55
|
+
void main() {
|
|
56
|
+
float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
|
|
57
|
+
vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
|
|
58
|
+
vec2 position = a_position + diffVector;
|
|
59
|
+
gl_Position = vec4(
|
|
60
|
+
(u_matrix * vec3(position, 1)).xy,
|
|
61
|
+
0,
|
|
62
|
+
1
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
v_diffVector = diffVector;
|
|
66
|
+
v_radius = size / 2.0;
|
|
67
|
+
|
|
68
|
+
#ifdef PICKING_MODE
|
|
69
|
+
// For picking mode, we use the ID as the color:
|
|
70
|
+
v_color = a_id;
|
|
71
|
+
#else
|
|
72
|
+
// For normal mode, we use the color:
|
|
73
|
+
v_color = a_color;
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
v_color.a *= bias;
|
|
77
|
+
}
|
|
78
|
+
`,Tr=xr,Si=WebGLRenderingContext,Pt=Si.UNSIGNED_BYTE,Ye=Si.FLOAT,Rr=["u_sizeRatio","u_correctionRatio","u_matrix"],Ne=(function(r){function i(){return W(this,i),q(this,i,arguments)}return K(i,r),j(i,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Tr,FRAGMENT_SHADER_SOURCE:_r,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Rr,ATTRIBUTES:[{name:"a_position",size:2,type:Ye},{name:"a_size",size:1,type:Ye},{name:"a_color",size:4,type:Pt,normalized:!0},{name:"a_id",size:4,type:Pt,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Ye}],CONSTANT_DATA:[[i.ANGLE_1],[i.ANGLE_2],[i.ANGLE_3]]}}},{key:"processVisibleItem",value:function(e,n,o){var a=this.array,s=fe(o.color);a[n++]=o.x,a[n++]=o.y,a[n++]=o.size,a[n++]=s,a[n++]=e}},{key:"setUniforms",value:function(e,n){var o=n.gl,a=n.uniformLocations,s=a.u_sizeRatio,u=a.u_correctionRatio,h=a.u_matrix;o.uniform1f(u,e.correctionRatio),o.uniform1f(s,e.sizeRatio),o.uniformMatrix3fv(h,!1,e.matrix)}}])})(yr);w(Ne,"ANGLE_1",0);w(Ne,"ANGLE_2",2*Math.PI/3);w(Ne,"ANGLE_3",4*Math.PI/3);var Sr=`
|
|
79
|
+
precision mediump float;
|
|
80
|
+
|
|
81
|
+
varying vec4 v_color;
|
|
82
|
+
|
|
83
|
+
void main(void) {
|
|
84
|
+
gl_FragColor = v_color;
|
|
85
|
+
}
|
|
86
|
+
`,Cr=Sr,kr=`
|
|
87
|
+
attribute vec2 a_position;
|
|
88
|
+
attribute vec2 a_normal;
|
|
89
|
+
attribute float a_radius;
|
|
90
|
+
attribute vec3 a_barycentric;
|
|
91
|
+
|
|
92
|
+
#ifdef PICKING_MODE
|
|
93
|
+
attribute vec4 a_id;
|
|
94
|
+
#else
|
|
95
|
+
attribute vec4 a_color;
|
|
96
|
+
#endif
|
|
97
|
+
|
|
98
|
+
uniform mat3 u_matrix;
|
|
99
|
+
uniform float u_sizeRatio;
|
|
100
|
+
uniform float u_correctionRatio;
|
|
101
|
+
uniform float u_minEdgeThickness;
|
|
102
|
+
uniform float u_lengthToThicknessRatio;
|
|
103
|
+
uniform float u_widenessToThicknessRatio;
|
|
104
|
+
|
|
105
|
+
varying vec4 v_color;
|
|
106
|
+
|
|
107
|
+
const float bias = 255.0 / 254.0;
|
|
108
|
+
|
|
109
|
+
void main() {
|
|
110
|
+
float minThickness = u_minEdgeThickness;
|
|
111
|
+
|
|
112
|
+
float normalLength = length(a_normal);
|
|
113
|
+
vec2 unitNormal = a_normal / normalLength;
|
|
114
|
+
|
|
115
|
+
// These first computations are taken from edge.vert.glsl and
|
|
116
|
+
// edge.clamped.vert.glsl. Please read it to get better comments on what's
|
|
117
|
+
// happening:
|
|
118
|
+
float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
|
|
119
|
+
float webGLThickness = pixelsThickness * u_correctionRatio;
|
|
120
|
+
float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
121
|
+
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
122
|
+
float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
|
|
123
|
+
|
|
124
|
+
float da = a_barycentric.x;
|
|
125
|
+
float db = a_barycentric.y;
|
|
126
|
+
float dc = a_barycentric.z;
|
|
127
|
+
|
|
128
|
+
vec2 delta = vec2(
|
|
129
|
+
da * (webGLNodeRadius * unitNormal.y)
|
|
130
|
+
+ db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
|
|
131
|
+
+ dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
|
|
132
|
+
|
|
133
|
+
da * (-webGLNodeRadius * unitNormal.x)
|
|
134
|
+
+ db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
|
|
135
|
+
+ dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
|
|
139
|
+
|
|
140
|
+
gl_Position = vec4(position, 0, 1);
|
|
141
|
+
|
|
142
|
+
#ifdef PICKING_MODE
|
|
143
|
+
// For picking mode, we use the ID as the color:
|
|
144
|
+
v_color = a_id;
|
|
145
|
+
#else
|
|
146
|
+
// For normal mode, we use the color:
|
|
147
|
+
v_color = a_color;
|
|
148
|
+
#endif
|
|
149
|
+
|
|
150
|
+
v_color.a *= bias;
|
|
151
|
+
}
|
|
152
|
+
`,Ar=kr,Ci=WebGLRenderingContext,Mt=Ci.UNSIGNED_BYTE,Pe=Ci.FLOAT,Lr=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],bt={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function $e(r){var i=A(A({},bt),r||{});return(function(t){function e(){return W(this,e),q(this,e,arguments)}return K(e,t),j(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Ar,FRAGMENT_SHADER_SOURCE:Cr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Lr,ATTRIBUTES:[{name:"a_position",size:2,type:Pe},{name:"a_normal",size:2,type:Pe},{name:"a_radius",size:1,type:Pe},{name:"a_color",size:4,type:Mt,normalized:!0},{name:"a_id",size:4,type:Mt,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Pe}],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 c=[u,s];s=c[0],u=c[1]}var d=h.size||1,l=u.size||1,f=s.x,y=s.y,m=u.x,b=u.y,R=fe(h.color),x=m-f,_=b-y,g=x*x+_*_,p=0,v=0;g&&(g=1/Math.sqrt(g),p=-_*g*d,v=x*g*d);var E=this.array;E[a++]=m,E[a++]=b,E[a++]=-p,E[a++]=-v,E[a++]=l,E[a++]=R,E[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,h=u.u_matrix,c=u.u_sizeRatio,d=u.u_correctionRatio,l=u.u_minEdgeThickness,f=u.u_lengthToThicknessRatio,y=u.u_widenessToThicknessRatio;s.uniformMatrix3fv(h,!1,o.matrix),s.uniform1f(c,o.sizeRatio),s.uniform1f(d,o.correctionRatio),s.uniform1f(l,o.minEdgeThickness),s.uniform1f(f,i.lengthToThicknessRatio),s.uniform1f(y,i.widenessToThicknessRatio)}}])})(Le)}$e();var Nr=`
|
|
153
|
+
precision mediump float;
|
|
154
|
+
|
|
155
|
+
varying vec4 v_color;
|
|
156
|
+
varying vec2 v_normal;
|
|
157
|
+
varying float v_thickness;
|
|
158
|
+
varying float v_feather;
|
|
159
|
+
|
|
160
|
+
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
161
|
+
|
|
162
|
+
void main(void) {
|
|
163
|
+
// We only handle antialiasing for normal mode:
|
|
164
|
+
#ifdef PICKING_MODE
|
|
165
|
+
gl_FragColor = v_color;
|
|
166
|
+
#else
|
|
167
|
+
float dist = length(v_normal) * v_thickness;
|
|
168
|
+
|
|
169
|
+
float t = smoothstep(
|
|
170
|
+
v_thickness - v_feather,
|
|
171
|
+
v_thickness,
|
|
172
|
+
dist
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
gl_FragColor = mix(v_color, transparent, t);
|
|
176
|
+
#endif
|
|
177
|
+
}
|
|
178
|
+
`,wt=Nr,Dr=`
|
|
179
|
+
attribute vec4 a_id;
|
|
180
|
+
attribute vec4 a_color;
|
|
181
|
+
attribute vec2 a_normal;
|
|
182
|
+
attribute float a_normalCoef;
|
|
183
|
+
attribute vec2 a_positionStart;
|
|
184
|
+
attribute vec2 a_positionEnd;
|
|
185
|
+
attribute float a_positionCoef;
|
|
186
|
+
attribute float a_radius;
|
|
187
|
+
attribute float a_radiusCoef;
|
|
188
|
+
|
|
189
|
+
uniform mat3 u_matrix;
|
|
190
|
+
uniform float u_zoomRatio;
|
|
191
|
+
uniform float u_sizeRatio;
|
|
192
|
+
uniform float u_pixelRatio;
|
|
193
|
+
uniform float u_correctionRatio;
|
|
194
|
+
uniform float u_minEdgeThickness;
|
|
195
|
+
uniform float u_lengthToThicknessRatio;
|
|
196
|
+
uniform float u_feather;
|
|
197
|
+
|
|
198
|
+
varying vec4 v_color;
|
|
199
|
+
varying vec2 v_normal;
|
|
200
|
+
varying float v_thickness;
|
|
201
|
+
varying float v_feather;
|
|
202
|
+
|
|
203
|
+
const float bias = 255.0 / 254.0;
|
|
204
|
+
|
|
205
|
+
void main() {
|
|
206
|
+
float minThickness = u_minEdgeThickness;
|
|
207
|
+
|
|
208
|
+
float radius = a_radius * a_radiusCoef;
|
|
209
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
210
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
211
|
+
|
|
212
|
+
float normalLength = length(normal);
|
|
213
|
+
vec2 unitNormal = normal / normalLength;
|
|
214
|
+
|
|
215
|
+
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
216
|
+
// get better comments on what's happening:
|
|
217
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
218
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
219
|
+
|
|
220
|
+
// Here, we move the point to leave space for the arrow head:
|
|
221
|
+
float direction = sign(radius);
|
|
222
|
+
float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
223
|
+
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
224
|
+
|
|
225
|
+
vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
|
|
226
|
+
|
|
227
|
+
// Here is the proper position of the vertex
|
|
228
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
|
|
229
|
+
|
|
230
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
231
|
+
|
|
232
|
+
v_normal = unitNormal;
|
|
233
|
+
|
|
234
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
235
|
+
|
|
236
|
+
#ifdef PICKING_MODE
|
|
237
|
+
// For picking mode, we use the ID as the color:
|
|
238
|
+
v_color = a_id;
|
|
239
|
+
#else
|
|
240
|
+
// For normal mode, we use the color:
|
|
241
|
+
v_color = a_color;
|
|
242
|
+
#endif
|
|
243
|
+
|
|
244
|
+
v_color.a *= bias;
|
|
245
|
+
}
|
|
246
|
+
`,Gr=Dr,ki=WebGLRenderingContext,It=ki.UNSIGNED_BYTE,le=ki.FLOAT,Fr=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Pr={lengthToThicknessRatio:bt.lengthToThicknessRatio};function Ai(r){var i=A(A({},Pr),{});return(function(t){function e(){return W(this,e),q(this,e,arguments)}return K(e,t),j(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Gr,FRAGMENT_SHADER_SOURCE:wt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Fr,ATTRIBUTES:[{name:"a_positionStart",size:2,type:le},{name:"a_positionEnd",size:2,type:le},{name:"a_normal",size:2,type:le},{name:"a_color",size:4,type:It,normalized:!0},{name:"a_id",size:4,type:It,normalized:!0},{name:"a_radius",size:1,type:le}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:le},{name:"a_normalCoef",size:1,type:le},{name:"a_radiusCoef",size:1,type:le}],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 c=h.size||1,d=s.x,l=s.y,f=u.x,y=u.y,m=fe(h.color),b=f-d,R=y-l,x=u.size||1,_=b*b+R*R,g=0,p=0;_&&(_=1/Math.sqrt(_),g=-R*_*c,p=b*_*c);var v=this.array;v[a++]=d,v[a++]=l,v[a++]=f,v[a++]=y,v[a++]=g,v[a++]=p,v[a++]=m,v[a++]=o,v[a++]=x}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,h=u.u_matrix,c=u.u_zoomRatio,d=u.u_feather,l=u.u_pixelRatio,f=u.u_correctionRatio,y=u.u_sizeRatio,m=u.u_minEdgeThickness,b=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(h,!1,o.matrix),s.uniform1f(c,o.zoomRatio),s.uniform1f(y,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(l,o.pixelRatio),s.uniform1f(d,o.antiAliasingFeather),s.uniform1f(m,o.minEdgeThickness),s.uniform1f(b,i.lengthToThicknessRatio)}}])})(Le)}Ai();function Li(r){return Ti([Ai(),$e(r)])}var Mr=Li(),Ir=Mr,zr=`
|
|
247
|
+
attribute vec4 a_id;
|
|
248
|
+
attribute vec4 a_color;
|
|
249
|
+
attribute vec2 a_normal;
|
|
250
|
+
attribute float a_normalCoef;
|
|
251
|
+
attribute vec2 a_positionStart;
|
|
252
|
+
attribute vec2 a_positionEnd;
|
|
253
|
+
attribute float a_positionCoef;
|
|
254
|
+
|
|
255
|
+
uniform mat3 u_matrix;
|
|
256
|
+
uniform float u_sizeRatio;
|
|
257
|
+
uniform float u_zoomRatio;
|
|
258
|
+
uniform float u_pixelRatio;
|
|
259
|
+
uniform float u_correctionRatio;
|
|
260
|
+
uniform float u_minEdgeThickness;
|
|
261
|
+
uniform float u_feather;
|
|
262
|
+
|
|
263
|
+
varying vec4 v_color;
|
|
264
|
+
varying vec2 v_normal;
|
|
265
|
+
varying float v_thickness;
|
|
266
|
+
varying float v_feather;
|
|
267
|
+
|
|
268
|
+
const float bias = 255.0 / 254.0;
|
|
269
|
+
|
|
270
|
+
void main() {
|
|
271
|
+
float minThickness = u_minEdgeThickness;
|
|
272
|
+
|
|
273
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
274
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
275
|
+
|
|
276
|
+
float normalLength = length(normal);
|
|
277
|
+
vec2 unitNormal = normal / normalLength;
|
|
278
|
+
|
|
279
|
+
// We require edges to be at least "minThickness" pixels thick *on screen*
|
|
280
|
+
// (so we need to compensate the size ratio):
|
|
281
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
282
|
+
|
|
283
|
+
// Then, we need to retrieve the normalized thickness of the edge in the WebGL
|
|
284
|
+
// referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
|
|
285
|
+
// ratio:
|
|
286
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
287
|
+
|
|
288
|
+
// Here is the proper position of the vertex
|
|
289
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
|
|
290
|
+
|
|
291
|
+
// For the fragment shader though, we need a thickness that takes the "magic"
|
|
292
|
+
// correction ratio into account (as in webGLThickness), but so that the
|
|
293
|
+
// antialiasing effect does not depend on the zoom level. So here's yet
|
|
294
|
+
// another thickness version:
|
|
295
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
296
|
+
|
|
297
|
+
v_normal = unitNormal;
|
|
298
|
+
|
|
299
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
300
|
+
|
|
301
|
+
#ifdef PICKING_MODE
|
|
302
|
+
// For picking mode, we use the ID as the color:
|
|
303
|
+
v_color = a_id;
|
|
304
|
+
#else
|
|
305
|
+
// For normal mode, we use the color:
|
|
306
|
+
v_color = a_color;
|
|
307
|
+
#endif
|
|
308
|
+
|
|
309
|
+
v_color.a *= bias;
|
|
310
|
+
}
|
|
311
|
+
`,$r=zr,Ni=WebGLRenderingContext,zt=Ni.UNSIGNED_BYTE,Te=Ni.FLOAT,Ur=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Or=(function(r){function i(){return W(this,i),q(this,i,arguments)}return K(i,r),j(i,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:$r,FRAGMENT_SHADER_SOURCE:wt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ur,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Te},{name:"a_positionEnd",size:2,type:Te},{name:"a_normal",size:2,type:Te},{name:"a_color",size:4,type:zt,normalized:!0},{name:"a_id",size:4,type:zt,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Te},{name:"a_normalCoef",size:1,type:Te}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(e,n,o,a,s){var u=s.size||1,h=o.x,c=o.y,d=a.x,l=a.y,f=fe(s.color),y=d-h,m=l-c,b=y*y+m*m,R=0,x=0;b&&(b=1/Math.sqrt(b),R=-m*b*u,x=y*b*u);var _=this.array;_[n++]=h,_[n++]=c,_[n++]=d,_[n++]=l,_[n++]=R,_[n++]=x,_[n++]=f,_[n++]=e}},{key:"setUniforms",value:function(e,n){var o=n.gl,a=n.uniformLocations,s=a.u_matrix,u=a.u_zoomRatio,h=a.u_feather,c=a.u_pixelRatio,d=a.u_correctionRatio,l=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,e.matrix),o.uniform1f(u,e.zoomRatio),o.uniform1f(l,e.sizeRatio),o.uniform1f(d,e.correctionRatio),o.uniform1f(c,e.pixelRatio),o.uniform1f(h,e.antiAliasingFeather),o.uniform1f(f,e.minEdgeThickness)}}])})(Le),Et=(function(r){function i(){var t;return W(this,i),t=q(this,i),t.rawEmitter=t,t}return K(i,r),j(i)})(ii.EventEmitter),Ze,$t;function Br(){return $t||($t=1,Ze=function(i){return i!==null&&typeof i=="object"&&typeof i.addUndirectedEdgeWithKey=="function"&&typeof i.dropNode=="function"&&typeof i.multi=="boolean"}),Ze}var Hr=Br();const Wr=Ki(Hr);var jr=function(i){return i},Vr=function(i){return i*i},qr=function(i){return i*(2-i)},Kr=function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)},Yr=function(i){return i*i*i},Zr=function(i){return--i*i*i+1},Xr=function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)},Jr={linear:jr,quadraticIn:Vr,quadraticOut:qr,quadraticInOut:Kr,cubicIn:Yr,cubicOut:Zr,cubicInOut:Xr},Qr={easing:"quadraticInOut",duration:150};function Q(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Me(r,i,t){return r[0]=i,r[4]=typeof t=="number"?t:i,r}function Ut(r,i){var t=Math.sin(i),e=Math.cos(i);return r[0]=e,r[1]=t,r[3]=-t,r[4]=e,r}function Ot(r,i,t){return r[6]=i,r[7]=t,r}function de(r,i){var t=r[0],e=r[1],n=r[2],o=r[3],a=r[4],s=r[5],u=r[6],h=r[7],c=r[8],d=i[0],l=i[1],f=i[2],y=i[3],m=i[4],b=i[5],R=i[6],x=i[7],_=i[8];return r[0]=d*t+l*o+f*u,r[1]=d*e+l*a+f*h,r[2]=d*n+l*s+f*c,r[3]=y*t+m*o+b*u,r[4]=y*e+m*a+b*h,r[5]=y*n+m*s+b*c,r[6]=R*t+x*o+_*u,r[7]=R*e+x*a+_*h,r[8]=R*n+x*s+_*c,r}function dt(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,e=r[0],n=r[1],o=r[3],a=r[4],s=r[6],u=r[7],h=i.x,c=i.y;return{x:h*e+c*o+s*t,y:h*n+c*a+u*t}}function Di(r,i){var t=r.height/r.width,e=i.height/i.width;return t<1&&e>1||t>1&&e<1?1:Math.min(Math.max(e,1/e),Math.max(1/t,t))}function Re(r,i,t,e,n){var o=r.angle,a=r.ratio,s=r.x,u=r.y,h=i.width,c=i.height,d=Q(),l=Math.min(h,c)-2*e,f=Di(i,t);return n?(de(d,Ot(Q(),s,u)),de(d,Me(Q(),a)),de(d,Ut(Q(),o)),de(d,Me(Q(),h/l/2/f,c/l/2/f))):(de(d,Me(Q(),2*(l/h)*f,2*(l/c)*f)),de(d,Ut(Q(),-o)),de(d,Me(Q(),1/a)),de(d,Ot(Q(),-s,-u))),d}function eo(r,i,t){var e=dt(r,{x:Math.cos(i.angle),y:Math.sin(i.angle)},0),n=e.x,o=e.y;return 1/Math.sqrt(Math.pow(n,2)+Math.pow(o,2))/t.width}function to(r){if(!r.order)return{x:[0,1],y:[0,1]};var i=1/0,t=-1/0,e=1/0,n=-1/0;return r.forEachNode(function(o,a){var s=a.x,u=a.y;s<i&&(i=s),s>t&&(t=s),u<e&&(e=u),u>n&&(n=u)}),{x:[i,t],y:[e,n]}}function io(r){if(!Wr(r))throw new Error("Sigma: invalid graph instance.");r.forEachNode(function(i,t){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new Error("Sigma: Coordinates of node ".concat(i," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function no(r,i,t){var e=document.createElement(r);if(i)for(var n in i)e.style[n]=i[n];if(t)for(var o in t)e.setAttribute(o,t[o]);return e}function Bt(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Ht(r,i,t){return t.sort(function(e,n){var o=i(e)||0,a=i(n)||0;return o<a?-1:o>a?1:0})}function Wt(r){var i=ye(r.x,2),t=i[0],e=i[1],n=ye(r.y,2),o=n[0],a=n[1],s=Math.max(e-t,a-o),u=(e+t)/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 c=function(l){return{x:.5+(l.x-u)/s,y:.5+(l.y-h)/s}};return c.applyTo=function(d){d.x=.5+(d.x-u)/s,d.y=.5+(d.y-h)/s},c.inverse=function(d){return{x:u+s*(d.x-.5),y:h+s*(d.y-.5)}},c.ratio=s,c}function ct(r){"@babel/helpers - typeof";return ct=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},ct(r)}function jt(r,i){var t=i.size;if(t!==0){var e=r.length;r.length+=t;var n=0;i.forEach(function(o){r[e+n]=o,n++})}}function Xe(r){r=r||{};for(var i=0,t=arguments.length<=1?0:arguments.length-1;i<t;i++){var e=i+1<1||arguments.length<=i+1?void 0:arguments[i+1];e&&Object.assign(r,e)}return r}var _t={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:br,defaultDrawNodeLabel:Ri,defaultDrawNodeHover:wr,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:{}},ro={circle:Ne},oo={arrow:Ir,line:Or};function Je(r){if(typeof r.labelDensity!="number"||r.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var i=r.minCameraRatio,t=r.maxCameraRatio;if(typeof i=="number"&&typeof t=="number"&&t<i)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function ao(r){var i=Xe({},_t,r);return i.nodeProgramClasses=Xe({},ro,i.nodeProgramClasses),i.edgeProgramClasses=Xe({},oo,i.edgeProgramClasses),i}var Ie=1.5,Vt=(function(r){function i(){var t;return W(this,i),t=q(this,i),w(t,"x",.5),w(t,"y",.5),w(t,"angle",0),w(t,"ratio",1),w(t,"minRatio",null),w(t,"maxRatio",null),w(t,"enabledZooming",!0),w(t,"enabledPanning",!0),w(t,"enabledRotation",!0),w(t,"clean",null),w(t,"nextFrame",null),w(t,"previousState",null),w(t,"enabled",!0),t.previousState=t.getState(),t}return K(i,r),j(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(e){return this.x===e.x&&this.y===e.y&&this.ratio===e.ratio&&this.angle===e.angle}},{key:"getPreviousState",value:function(){var e=this.previousState;return e?{x:e.x,y:e.y,angle:e.angle,ratio:e.ratio}:null}},{key:"getBoundedRatio",value:function(e){var n=e;return typeof this.minRatio=="number"&&(n=Math.max(n,this.minRatio)),typeof this.maxRatio=="number"&&(n=Math.min(n,this.maxRatio)),n}},{key:"validateState",value:function(e){var n={};return this.enabledPanning&&typeof e.x=="number"&&(n.x=e.x),this.enabledPanning&&typeof e.y=="number"&&(n.y=e.y),this.enabledZooming&&typeof e.ratio=="number"&&(n.ratio=this.getBoundedRatio(e.ratio)),this.enabledRotation&&typeof e.angle=="number"&&(n.angle=e.angle),this.clean?this.clean(A(A({},this.getState()),n)):n}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(e){if(!this.enabled)return this;this.previousState=this.getState();var n=this.validateState(e);return typeof n.x=="number"&&(this.x=n.x),typeof n.y=="number"&&(this.y=n.y),typeof n.ratio=="number"&&(this.ratio=n.ratio),typeof n.angle=="number"&&(this.angle=n.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(e){return this.setState(e(this.getState())),this}},{key:"animate",value:function(e){var n=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 n.animate(e,o,f)});if(this.enabled){var s=A(A({},Qr),o),u=this.validateState(e),h=typeof s.easing=="function"?s.easing:Jr[s.easing],c=Date.now(),d=this.getState(),l=function(){var y=(Date.now()-c)/s.duration;if(y>=1){n.nextFrame=null,n.setState(u),n.animationCallback&&(n.animationCallback.call(null),n.animationCallback=void 0);return}var m=h(y),b={};typeof u.x=="number"&&(b.x=d.x+(u.x-d.x)*m),typeof u.y=="number"&&(b.y=d.y+(u.y-d.y)*m),n.enabledRotation&&typeof u.angle=="number"&&(b.angle=d.angle+(u.angle-d.angle)*m),typeof u.ratio=="number"&&(b.ratio=d.ratio+(u.ratio-d.ratio)*m),n.setState(b),n.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(e){return e?typeof e=="number"?this.animate({ratio:this.ratio/e}):this.animate({ratio:this.ratio/(e.factor||Ie)},e):this.animate({ratio:this.ratio/Ie})}},{key:"animatedUnzoom",value:function(e){return e?typeof e=="number"?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||Ie)},e):this.animate({ratio:this.ratio*Ie})}},{key:"animatedReset",value:function(e){return this.animate({x:.5,y:.5,ratio:1,angle:0},e)}},{key:"copy",value:function(){return i.from(this.getState())}}],[{key:"from",value:function(e){var n=new i;return n.setState(e)}}])})(Et);function te(r,i){var t=i.getBoundingClientRect();return{x:r.clientX-t.left,y:r.clientY-t.top}}function re(r,i){var t=A(A({},te(r,i)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0},original:r});return t}function Se(r){var i="x"in r?r:A(A({},r.touches[0]||r.previousTouches[0]),{},{original:r.original,sigmaDefaultPrevented:r.sigmaDefaultPrevented,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0,i.sigmaDefaultPrevented=!0}});return i}function so(r,i){return A(A({},re(r,i)),{},{delta:Gi(r)})}var uo=2;function ze(r){for(var i=[],t=0,e=Math.min(r.length,uo);t<e;t++)i.push(r[t]);return i}function Ce(r,i,t){var e={touches:ze(r.touches).map(function(n){return te(n,t)}),previousTouches:i.map(function(n){return te(n,t)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:r};return e}function Gi(r){if(typeof r.deltaY<"u")return r.deltaY*-3/360;if(typeof r.detail<"u")return r.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Fi=(function(r){function i(t,e){var n;return W(this,i),n=q(this,i),n.container=t,n.renderer=e,n}return K(i,r),j(i)})(Et),ho=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],co=ho.reduce(function(r,i){return A(A({},r),{},w({},i,_t[i]))},{}),lo=(function(r){function i(t,e){var n;return W(this,i),n=q(this,i,[t,e]),w(n,"enabled",!0),w(n,"draggedEvents",0),w(n,"downStartTime",null),w(n,"lastMouseX",null),w(n,"lastMouseY",null),w(n,"isMouseDown",!1),w(n,"isMoving",!1),w(n,"movingTimeout",null),w(n,"startCameraState",null),w(n,"clicks",0),w(n,"doubleClickTimeout",null),w(n,"currentWheelDirection",0),w(n,"settings",co),n.handleClick=n.handleClick.bind(n),n.handleRightClick=n.handleRightClick.bind(n),n.handleDown=n.handleDown.bind(n),n.handleUp=n.handleUp.bind(n),n.handleMove=n.handleMove.bind(n),n.handleWheel=n.handleWheel.bind(n),n.handleLeave=n.handleLeave.bind(n),n.handleEnter=n.handleEnter.bind(n),t.addEventListener("click",n.handleClick,{capture:!1}),t.addEventListener("contextmenu",n.handleRightClick,{capture:!1}),t.addEventListener("mousedown",n.handleDown,{capture:!1}),t.addEventListener("wheel",n.handleWheel,{capture:!1}),t.addEventListener("mouseleave",n.handleLeave,{capture:!1}),t.addEventListener("mouseenter",n.handleEnter,{capture:!1}),document.addEventListener("mousemove",n.handleMove,{capture:!1}),document.addEventListener("mouseup",n.handleUp,{capture:!1}),n}return K(i,r),j(i,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("click",this.handleClick),e.removeEventListener("contextmenu",this.handleRightClick),e.removeEventListener("mousedown",this.handleDown),e.removeEventListener("wheel",this.handleWheel),e.removeEventListener("mouseleave",this.handleLeave),e.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(e){var n=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(e);setTimeout(function(){n.clicks=0,n.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",re(e,this.container))}}},{key:"handleRightClick",value:function(e){this.enabled&&this.emit("rightClick",re(e,this.container))}},{key:"handleDoubleClick",value:function(e){if(this.enabled){e.preventDefault(),e.stopPropagation();var n=re(e,this.container);if(this.emit("doubleClick",n),!n.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(te(e,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(e){if(this.enabled){if(e.button===0){this.startCameraState=this.renderer.getCamera().getState();var n=te(e,this.container),o=n.x,a=n.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",re(e,this.container))}}},{key:"handleUp",value:function(e){var n=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=te(e,this.container),s=a.x,u=a.y,h=o.getState(),c=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:h.x+this.settings.inertiaRatio*(h.x-c.x),y:h.y+this.settings.inertiaRatio*(h.y-c.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==u)&&o.setState({x:h.x,y:h.y}),this.isMoving=!1,setTimeout(function(){var d=n.draggedEvents>0;n.draggedEvents=0,d&&n.renderer.getSetting("hideEdgesOnMove")&&n.renderer.refresh()},0),this.emit("mouseup",re(e,this.container))}}},{key:"handleMove",value:function(e){var n=this;if(this.enabled){var o=re(e,this.container);if(this.emit("mousemovebody",o),(e.target===this.container||e.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){n.movingTimeout=null,n.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=te(e,this.container),u=s.x,h=s.y,c=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:u,y:h}),l=c.x-d.x,f=c.y-d.y,y=a.getState(),m=y.x+l,b=y.y+f;a.setState({x:m,y:b}),this.lastMouseX=u,this.lastMouseY=h,e.preventDefault(),e.stopPropagation()}}}},{key:"handleLeave",value:function(e){this.emit("mouseleave",re(e,this.container))}},{key:"handleEnter",value:function(e){this.emit("mouseenter",re(e,this.container))}},{key:"handleWheel",value:function(e){var n=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Gi(e);if(a){var s=so(e,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){e.preventDefault(),e.stopPropagation();return}var u=o.getState().ratio,h=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,c=o.getBoundedRatio(u*h),d=a>0?1:-1,l=Date.now();u!==c&&(e.preventDefault(),e.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&l-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(te(e,this.container),c),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){n.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=l))}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(Fi),fo=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],go=fo.reduce(function(r,i){return A(A({},r),{},w({},i,_t[i]))},{}),po=(function(r){function i(t,e){var n;return W(this,i),n=q(this,i,[t,e]),w(n,"enabled",!0),w(n,"isMoving",!1),w(n,"hasMoved",!1),w(n,"touchMode",0),w(n,"startTouchesPositions",[]),w(n,"lastTouches",[]),w(n,"lastTap",null),w(n,"settings",go),n.handleStart=n.handleStart.bind(n),n.handleLeave=n.handleLeave.bind(n),n.handleMove=n.handleMove.bind(n),t.addEventListener("touchstart",n.handleStart,{capture:!1}),t.addEventListener("touchcancel",n.handleLeave,{capture:!1}),document.addEventListener("touchend",n.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",n.handleMove,{capture:!1,passive:!1}),n}return K(i,r),j(i,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("touchstart",this.handleStart),e.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(e){var n=this;if(this.enabled){e.preventDefault();var o=ze(e.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return te(f,n.container)}),this.touchMode===2){var a=ye(this.startTouchesPositions,2),s=a[0],u=s.x,h=s.y,c=a[1],d=c.x,l=c.y;this.startTouchesAngle=Math.atan2(l-h,d-u),this.startTouchesDistance=Math.sqrt(Math.pow(d-u,2)+Math.pow(l-h,2))}this.emit("touchdown",Ce(e,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(e){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(e.cancelable&&e.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(e.touches.length===1){this.handleStart(e),e.preventDefault();break}case 1:if(this.isMoving){var n=this.renderer.getCamera(),o=n.getState(),a=n.getPreviousState()||{x:0,y:0};n.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",Ce(e,this.lastTouches,this.container)),!e.touches.length){var s=te(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],h=Math.pow(s.x-u.x,2)+Math.pow(s.y-u.y,2);if(!e.touches.length&&h<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var c=Ce(e,this.lastTouches,this.container);if(this.emit("doubletap",c),this.lastTap=null,!c.sigmaDefaultPrevented){var d=this.renderer.getCamera(),l=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(s,l),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=Ce(e,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=ze(e.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(e){var n=this;if(!(!this.enabled||!this.startTouchesPositions.length)){e.preventDefault();var o=ze(e.touches),a=o.map(function(he){return te(he,n.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var u=Ce(e,s,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(he,Oe){var ie=n.startTouchesPositions[Oe];return ie&&(he.x!==ie.x||he.y!==ie.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){n.isMoving=!1},this.settings.dragTimeout);var h=this.renderer.getCamera(),c=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var l=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=l.x,y=l.y,m=this.renderer.viewportToFramedGraph(a[0]),b=m.x,R=m.y;h.setState({x:c.x+f-b,y:c.y+y-R});break}case 2:{var x={x:.5,y:.5,angle:0,ratio:1},_=a[0],g=_.x,p=_.y,v=a[1],E=v.x,k=v.y,N=Math.atan2(k-p,E-g)-this.startTouchesAngle,S=Math.hypot(k-p,E-g)/this.startTouchesDistance,M=h.getBoundedRatio(c.ratio/S);x.ratio=M,x.angle=c.angle+N;var I=this.getDimensions(),L=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),P=Math.min(I.width,I.height)-2*d,G=P/I.width,$=P/I.height,O=M/P,H=g-P/2/G,Y=p-P/2/$,ue=[H*Math.cos(-x.angle)-Y*Math.sin(-x.angle),Y*Math.cos(-x.angle)+H*Math.sin(-x.angle)];H=ue[0],Y=ue[1],x.x=L.x-H*O,x.y=L.y+Y*O,h.setState(x);break}}}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(Fi);function mo(r){if(Array.isArray(r))return ut(r)}function vo(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function yo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
312
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qt(r){return mo(r)||vo(r)||vi(r)||yo()}function bo(r,i){if(r==null)return{};var t={};for(var e in r)if({}.hasOwnProperty.call(r,e)){if(i.indexOf(e)!==-1)continue;t[e]=r[e]}return t}function Qe(r,i){if(r==null)return{};var t,e,n=bo(r,i);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(e=0;e<o.length;e++)t=o[e],i.indexOf(t)===-1&&{}.propertyIsEnumerable.call(r,t)&&(n[t]=r[t])}return n}var Kt=(function(){function r(i,t){W(this,r),this.key=i,this.size=t}return j(r,null,[{key:"compare",value:function(t,e){return t.size>e.size?-1:t.size<e.size||t.key>e.key?1:-1}}])})(),Yt=(function(){function r(){W(this,r),w(this,"width",0),w(this,"height",0),w(this,"cellSize",0),w(this,"columns",0),w(this,"rows",0),w(this,"cells",{})}return j(r,[{key:"resizeAndClear",value:function(t,e){this.width=t.width,this.height=t.height,this.cellSize=e,this.columns=Math.ceil(t.width/e),this.rows=Math.ceil(t.height/e),this.cells={}}},{key:"getIndex",value:function(t){var e=Math.floor(t.x/this.cellSize),n=Math.floor(t.y/this.cellSize);return n*this.columns+e}},{key:"add",value:function(t,e,n){var o=new Kt(t,e),a=this.getIndex(n),s=this.cells[a];s||(s=[],this.cells[a]=s),s.push(o)}},{key:"organize",value:function(){for(var t in this.cells){var e=this.cells[t];e.sort(Kt.compare)}}},{key:"getLabelsToDisplay",value:function(t,e){var n=this.cellSize*this.cellSize,o=n/t/t,a=o*e/n,s=Math.ceil(a),u=[];for(var h in this.cells)for(var c=this.cells[h],d=0;d<Math.min(s,c.length);d++)u.push(c[d].key);return u}}])})();function wo(r){var i=r.graph,t=r.hoveredNode,e=r.highlightedNodes,n=r.displayedNodeLabels,o=[];return i.forEachEdge(function(a,s,u,h){(u===t||h===t||e.has(u)||e.has(h)||n.has(u)&&n.has(h))&&o.push(a)}),o}var Zt=150,Xt=50,oe=Object.prototype.hasOwnProperty;function Eo(r,i,t){if(!oe.call(t,"x")||!oe.call(t,"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 t.color||(t.color=r.defaultNodeColor),!t.label&&t.label!==""&&(t.label=null),t.label!==void 0&&t.label!==null?t.label=""+t.label:t.label=null,t.size||(t.size=2),oe.call(t,"hidden")||(t.hidden=!1),oe.call(t,"highlighted")||(t.highlighted=!1),oe.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=r.defaultNodeType),t.zIndex||(t.zIndex=0),t}function _o(r,i,t){return t.color||(t.color=r.defaultEdgeColor),t.label||(t.label=""),t.size||(t.size=.5),oe.call(t,"hidden")||(t.hidden=!1),oe.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=r.defaultEdgeType),t.zIndex||(t.zIndex=0),t}var xo=(function(r){function i(t,e){var n,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(W(this,i),n=q(this,i),w(n,"elements",{}),w(n,"canvasContexts",{}),w(n,"webGLContexts",{}),w(n,"pickingLayers",new Set),w(n,"textures",{}),w(n,"frameBuffers",{}),w(n,"activeListeners",{}),w(n,"labelGrid",new Yt),w(n,"nodeDataCache",{}),w(n,"edgeDataCache",{}),w(n,"nodeProgramIndex",{}),w(n,"edgeProgramIndex",{}),w(n,"nodesWithForcedLabels",new Set),w(n,"edgesWithForcedLabels",new Set),w(n,"nodeExtent",{x:[0,1],y:[0,1]}),w(n,"nodeZExtent",[1/0,-1/0]),w(n,"edgeZExtent",[1/0,-1/0]),w(n,"matrix",Q()),w(n,"invMatrix",Q()),w(n,"correctionRatio",1),w(n,"customBBox",null),w(n,"normalizationFunction",Wt({x:[0,1],y:[0,1]})),w(n,"graphToViewportRatio",1),w(n,"itemIDsIndex",{}),w(n,"nodeIndices",{}),w(n,"edgeIndices",{}),w(n,"width",0),w(n,"height",0),w(n,"pixelRatio",Bt()),w(n,"pickingDownSizingRatio",2*n.pixelRatio),w(n,"displayedNodeLabels",new Set),w(n,"displayedEdgeLabels",new Set),w(n,"highlightedNodes",new Set),w(n,"hoveredNode",null),w(n,"hoveredEdge",null),w(n,"renderFrame",null),w(n,"renderHighlightedNodesFrame",null),w(n,"needToProcess",!1),w(n,"checkEdgesEventsFrame",null),w(n,"nodePrograms",{}),w(n,"nodeHoverPrograms",{}),w(n,"edgePrograms",{}),n.settings=ao(o),Je(n.settings),io(t),!(e instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");n.graph=t,n.container=e,n.createWebGLContext("edges",{picking:o.enableEdgeEvents}),n.createCanvasContext("edgeLabels"),n.createWebGLContext("nodes",{picking:!0}),n.createCanvasContext("labels"),n.createCanvasContext("hovers"),n.createWebGLContext("hoverNodes"),n.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),n.resize();for(var a in n.settings.nodeProgramClasses)n.registerNodeProgram(a,n.settings.nodeProgramClasses[a],n.settings.nodeHoverProgramClasses[a]);for(var s in n.settings.edgeProgramClasses)n.registerEdgeProgram(s,n.settings.edgeProgramClasses[s]);return n.camera=new Vt,n.bindCameraHandlers(),n.mouseCaptor=new lo(n.elements.mouse,n),n.mouseCaptor.setSettings(n.settings),n.touchCaptor=new po(n.elements.mouse,n),n.touchCaptor.setSettings(n.settings),n.bindEventHandlers(),n.bindGraphHandlers(),n.handleSettingsUpdate(),n.refresh(),n}return K(i,r),j(i,[{key:"registerNodeProgram",value:function(e,n,o){return this.nodePrograms[e]&&this.nodePrograms[e].kill(),this.nodeHoverPrograms[e]&&this.nodeHoverPrograms[e].kill(),this.nodePrograms[e]=new n(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[e]=new(o||n)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(e,n){return this.edgePrograms[e]&&this.edgePrograms[e].kill(),this.edgePrograms[e]=new n(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(e){if(this.nodePrograms[e]){var n=this.nodePrograms,o=n[e],a=Qe(n,[e].map(Ae));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[e]){var s=this.nodeHoverPrograms,u=s[e],h=Qe(s,[e].map(Ae));u.kill(),this.nodePrograms=h}return this}},{key:"unregisterEdgeProgram",value:function(e){if(this.edgePrograms[e]){var n=this.edgePrograms,o=n[e],a=Qe(n,[e].map(Ae));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(e){var n=this.webGLContexts[e],o=this.frameBuffers[e],a=this.textures[e];a&&n.deleteTexture(a);var s=n.createTexture();return n.bindFramebuffer(n.FRAMEBUFFER,o),n.bindTexture(n.TEXTURE_2D,s),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,this.width,this.height,0,n.RGBA,n.UNSIGNED_BYTE,null),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,s,0),this.textures[e]=s,this}},{key:"bindCameraHandlers",value:function(){var e=this;return this.activeListeners.camera=function(){e.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(e){var n=e.x,o=e.y,a=Nt(this.webGLContexts.nodes,this.frameBuffers.nodes,n,o,this.pixelRatio,this.pickingDownSizingRatio),s=Lt.apply(void 0,qt(a)),u=this.itemIDsIndex[s];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var e=this;this.activeListeners.handleResize=function(){e.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var a=Se(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},u=e.getNodeAtPosition(a);if(u&&e.hoveredNode!==u&&!e.nodeDataCache[u].hidden){e.hoveredNode&&e.emit("leaveNode",A(A({},s),{},{node:e.hoveredNode})),e.hoveredNode=u,e.emit("enterNode",A(A({},s),{},{node:u})),e.scheduleHighlightedNodesRender();return}if(e.hoveredNode&&e.getNodeAtPosition(a)!==e.hoveredNode){var h=e.hoveredNode;e.hoveredNode=null,e.emit("leaveNode",A(A({},s),{},{node:h})),e.scheduleHighlightedNodesRender();return}if(e.settings.enableEdgeEvents){var c=e.hoveredNode?null:e.getEdgeAtPoint(s.event.x,s.event.y);c!==e.hoveredEdge&&(e.hoveredEdge&&e.emit("leaveEdge",A(A({},s),{},{edge:e.hoveredEdge})),c&&e.emit("enterEdge",A(A({},s),{},{edge:c})),e.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=Se(o);e.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=Se(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};e.hoveredNode&&(e.emit("leaveNode",A(A({},s),{},{node:e.hoveredNode})),e.scheduleHighlightedNodesRender()),e.settings.enableEdgeEvents&&e.hoveredEdge&&(e.emit("leaveEdge",A(A({},s),{},{edge:e.hoveredEdge})),e.scheduleHighlightedNodesRender()),e.emit("leaveStage",A({},s))},this.activeListeners.handleEnter=function(o){var a=Se(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};e.emit("enterStage",A({},s))};var n=function(a){return function(s){var u=Se(s),h={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},c=e.getNodeAtPosition(u);if(c)return e.emit("".concat(a,"Node"),A(A({},h),{},{node:c}));if(e.settings.enableEdgeEvents){var d=e.getEdgeAtPoint(u.x,u.y);if(d)return e.emit("".concat(a,"Edge"),A(A({},h),{},{edge:d}))}return e.emit("".concat(a,"Stage"),h)}};return this.activeListeners.handleClick=n("click"),this.activeListeners.handleRightClick=n("rightClick"),this.activeListeners.handleDoubleClick=n("doubleClick"),this.activeListeners.handleWheel=n("wheel"),this.activeListeners.handleDown=n("down"),this.activeListeners.handleUp=n("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var e=this,n=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,u=(s=a.hints)===null||s===void 0?void 0:s.attributes;e.graph.forEachNode(function(c){return e.updateNode(c)});var h=!u||u.some(function(c){return o.has(c)});e.refresh({partialGraph:{nodes:n.nodes()},skipIndexation:!h,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,u=(s=a.hints)===null||s===void 0?void 0:s.attributes;e.graph.forEachEdge(function(c){return e.updateEdge(c)});var h=u&&["zIndex","type"].some(function(c){return u?.includes(c)});e.refresh({partialGraph:{edges:n.edges()},skipIndexation:!h,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;e.addNode(s),e.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;e.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;e.removeNode(s),e.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;e.addEdge(s),e.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;e.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;e.removeEdge(s),e.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){e.clearEdgeState(),e.clearEdgeIndices(),e.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){e.clearEdgeState(),e.clearNodeState(),e.clearEdgeIndices(),e.clearNodeIndices(),e.refresh({schedule:!0})},n.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),n.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),n.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),n.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),n.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),n.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),n.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),n.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),n.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),n.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var e=this.graph;e.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),e.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),e.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),e.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),e.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),e.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),e.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),e.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),e.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),e.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(e,n){var o=Nt(this.webGLContexts.edges,this.frameBuffers.edges,e,n,this.pixelRatio,this.pickingDownSizingRatio),a=Lt.apply(void 0,qt(o)),s=this.itemIDsIndex[a];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var e=this;this.emit("beforeProcess");var n=this.graph,o=this.settings,a=this.getDimensions();if(this.nodeExtent=to(this.graph),!this.settings.autoRescale){var s=a.width,u=a.height,h=this.nodeExtent,c=h.x,d=h.y;this.nodeExtent={x:[(c[0]+c[1])/2-s/2,(c[0]+c[1])/2+s/2],y:[(d[0]+d[1])/2-u/2,(d[0]+d[1])/2+u/2]}}this.normalizationFunction=Wt(this.customBBox||this.nodeExtent);var l=new Vt,f=Re(l.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var y={},m={},b={},R={},x=1,_=n.nodes(),g=0,p=_.length;g<p;g++){var v=_[g],E=this.nodeDataCache[v],k=n.getNodeAttributes(v);E.x=k.x,E.y=k.y,this.normalizationFunction.applyTo(E),typeof E.label=="string"&&!E.hidden&&this.labelGrid.add(v,E.size,this.framedGraphToViewport(E,{matrix:f})),y[E.type]=(y[E.type]||0)+1}this.labelGrid.organize();for(var N in this.nodePrograms){if(!oe.call(this.nodePrograms,N))throw new Error('Sigma: could not find a suitable program for node type "'.concat(N,'"!'));this.nodePrograms[N].reallocate(y[N]||0),y[N]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(_=Ht(this.nodeZExtent,function(Be){return e.nodeDataCache[Be].zIndex},_));for(var S=0,M=_.length;S<M;S++){var I=_[S];m[I]=x,R[m[I]]={type:"node",id:I},x++;var L=this.nodeDataCache[I];this.addNodeToProgram(I,m[I],y[L.type]++)}for(var P={},G=n.edges(),$=0,O=G.length;$<O;$++){var H=G[$],Y=this.edgeDataCache[H];P[Y.type]=(P[Y.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(G=Ht(this.edgeZExtent,function(Be){return e.edgeDataCache[Be].zIndex},G));for(var ue in this.edgePrograms){if(!oe.call(this.edgePrograms,ue))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ue,'"!'));this.edgePrograms[ue].reallocate(P[ue]||0),P[ue]=0}for(var he=0,Oe=G.length;he<Oe;he++){var ie=G[he];b[ie]=x,R[b[ie]]={type:"edge",id:ie},x++;var Ui=this.edgeDataCache[ie];this.addEdgeToProgram(ie,b[ie],P[Ui.type]++)}return this.itemIDsIndex=R,this.nodeIndices=m,this.edgeIndices=b,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(e){var n=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(c){return n.cleanCameraState(c,o.cameraPanBoundaries&&ct(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),e){if(e.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==e.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in e.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(e.nodeProgramClasses!==o.nodeProgramClasses||e.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var u in o.nodeProgramClasses)(o.nodeProgramClasses[u]!==e.nodeProgramClasses[u]||o.nodeHoverProgramClasses[u]!==e.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,o.nodeProgramClasses[u],o.nodeHoverProgramClasses[u]);for(var h in e.nodeProgramClasses)o.nodeProgramClasses[h]||this.unregisterNodeProgram(h)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n.tolerance,a=o===void 0?0:o,s=n.boundaries,u=A({},e),h=s||this.nodeExtent,c=ye(h.x,2),d=c[0],l=c[1],f=ye(h.y,2),y=f[0],m=f[1],b=[this.graphToViewport({x:d,y},{cameraState:e}),this.graphToViewport({x:l,y},{cameraState:e}),this.graphToViewport({x:d,y:m},{cameraState:e}),this.graphToViewport({x:l,y:m},{cameraState:e})],R=1/0,x=-1/0,_=1/0,g=-1/0;b.forEach(function(P){var G=P.x,$=P.y;R=Math.min(R,G),x=Math.max(x,G),_=Math.min(_,$),g=Math.max(g,$)});var p=x-R,v=g-_,E=this.getDimensions(),k=E.width,N=E.height,S=0,M=0;if(p>=k?x<k-a?S=x-(k-a):R>a&&(S=R-a):x>k+a?S=x-(k+a):R<-a&&(S=R+a),v>=N?g<N-a?M=g-(N-a):_>a&&(M=_-a):g>N+a?M=g-(N+a):_<-a&&(M=_+a),S||M){var I=this.viewportToFramedGraph({x:0,y:0},{cameraState:e}),L=this.viewportToFramedGraph({x:S,y:M},{cameraState:e});S=L.x-I.x,M=L.y-I.y,u.x+=S,u.y+=M}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var e=this.camera.getState(),n=this.labelGrid.getLabelsToDisplay(e.ratio,this.settings.labelDensity);jt(n,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=n.length;a<s;a++){var u=n[a],h=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!h.hidden){var c=this.framedGraphToViewport(h),d=c.x,l=c.y,f=this.scaleSize(h.size);if(!(!h.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(d<-Zt||d>this.width+Zt||l<-Xt||l>this.height+Xt)){this.displayedNodeLabels.add(u);var y=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[h.type],b=m?.drawLabel||y;b(o,A(A({key:u},h),{},{size:f,x:d,y:l}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var e=this.canvasContexts.edgeLabels;e.clearRect(0,0,this.width,this.height);var n=wo({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});jt(n,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=n.length;a<s;a++){var u=n[a],h=this.graph.extremities(u),c=this.nodeDataCache[h[0]],d=this.nodeDataCache[h[1]],l=this.edgeDataCache[u];if(!o.has(u)&&!(l.hidden||c.hidden||d.hidden)){var f=this.settings.defaultDrawEdgeLabel,y=this.edgePrograms[l.type],m=y?.drawLabel||f;m(e,A(A({key:u},l),{},{size:this.scaleSize(l.size)}),A(A(A({key:h[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),A(A(A({key:h[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),o.add(u)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var e=this,n=this.canvasContexts.hovers;n.clearRect(0,0,this.width,this.height);var o=function(f){var y=e.nodeDataCache[f],m=e.framedGraphToViewport(y),b=m.x,R=m.y,x=e.scaleSize(y.size),_=e.settings.defaultDrawNodeHover,g=e.nodePrograms[y.type],p=g?.drawHover||_;p(n,A(A({key:f},y),{},{size:x,x:b,y:R}),e.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(l){l!==e.hoveredNode&&a.push(l)}),a.forEach(function(l){return o(l)});var s={};a.forEach(function(l){var f=e.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=e.nodeDataCache[l];e.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 c in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[c];d.render(h)}}},{key:"scheduleHighlightedNodesRender",value:function(){var e=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){e.renderHighlightedNodesFrame=null,e.renderHighlightedNodes(),e.renderEdgeLabels()}))}},{key:"render",value:function(){var e=this;this.emit("beforeRender");var n=function(){return e.emit("afterRender"),e};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(b){return e.resetWebGLTexture(b)}),!this.graph.order)return n();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),u=this.getDimensions(),h=this.getGraphDimensions(),c=this.getStagePadding();this.matrix=Re(s,u,h,c),this.invMatrix=Re(s,u,h,c,!0),this.correctionRatio=eo(this.matrix,s,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var l in this.nodePrograms){var f=this.nodePrograms[l];f.render(d)}if(!this.settings.hideEdgesOnMove||!a)for(var y in this.edgePrograms){var m=this.edgePrograms[y];m.render(d)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),n()}},{key:"addNode",value:function(e){var n=Object.assign({},this.graph.getNodeAttributes(e));this.settings.nodeReducer&&(n=this.settings.nodeReducer(e,n));var o=Eo(this.settings,e,n);this.nodeDataCache[e]=o,this.nodesWithForcedLabels.delete(e),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(e),this.highlightedNodes.delete(e),o.highlighted&&!o.hidden&&this.highlightedNodes.add(e),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(e){this.addNode(e);var n=this.nodeDataCache[e];this.normalizationFunction.applyTo(n)}},{key:"removeNode",value:function(e){delete this.nodeDataCache[e],delete this.nodeProgramIndex[e],this.highlightedNodes.delete(e),this.hoveredNode===e&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(e)}},{key:"addEdge",value:function(e){var n=Object.assign({},this.graph.getEdgeAttributes(e));this.settings.edgeReducer&&(n=this.settings.edgeReducer(e,n));var o=_o(this.settings,e,n);this.edgeDataCache[e]=o,this.edgesWithForcedLabels.delete(e),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(e),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(e){this.addEdge(e)}},{key:"removeEdge",value:function(e){delete this.edgeDataCache[e],delete this.edgeProgramIndex[e],this.hoveredEdge===e&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(e)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Yt,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(e,n,o){var a=this.nodeDataCache[e],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(n,o,a),this.nodeProgramIndex[e]=o}},{key:"addEdgeToProgram",value:function(e,n,o){var a=this.edgeDataCache[e],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var u=this.graph.extremities(e),h=this.nodeDataCache[u[0]],c=this.nodeDataCache[u[1]];s.process(n,o,h,c,a),this.edgeProgramIndex[e]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var e=this.settings,n=e.stagePadding,o=e.autoRescale;return o&&n||0}},{key:"createLayer",value:function(e,n){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[e])throw new Error('Sigma: a layer named "'.concat(e,'" already exists'));var a=no(n,{position:"absolute"},{class:"sigma-".concat(e)});return o.style&&Object.assign(a.style,o.style),this.elements[e]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(e,"canvas",n)}},{key:"createCanvasContext",value:function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(e,n),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[e]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n?.canvas||this.createCanvas(e,n);n.hidden&&o.remove();var a=A({preserveDrawingBuffer:!1,antialias:!1},n),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var u=s;if(this.webGLContexts[e]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),n.picking){this.pickingLayers.add(e);var h=u.createFramebuffer();if(!h)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(e));this.frameBuffers[e]=h}return u}},{key:"killLayer",value:function(e){var n=this.elements[e];if(!n)throw new Error("Sigma: cannot kill layer ".concat(e,", which does not exist"));if(this.webGLContexts[e]){var o,a=this.webGLContexts[e];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[e]}else this.canvasContexts[e]&&delete this.canvasContexts[e];return n.remove(),delete this.elements[e],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(e){this.unbindCameraHandlers(),this.camera=e,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(e){e!==this.graph&&(this.hoveredNode&&!e.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!e.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=e,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var e=this.customBBox||this.nodeExtent;return{width:e.x[1]-e.x[0]||1,height:e.y[1]-e.y[0]||1}}},{key:"getNodeDisplayData",value:function(e){var n=this.nodeDataCache[e];return n?Object.assign({},n):void 0}},{key:"getEdgeDisplayData",value:function(e){var n=this.edgeDataCache[e];return n?Object.assign({},n):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return A({},this.settings)}},{key:"getSetting",value:function(e){return this.settings[e]}},{key:"setSetting",value:function(e,n){var o=A({},this.settings);return this.settings[e]=n,Je(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(e,n){return this.setSetting(e,n(this.settings[e])),this}},{key:"setSettings",value:function(e){var n=A({},this.settings);return this.settings=A(A({},this.settings),e),Je(this.settings),this.handleSettingsUpdate(n),this.scheduleRefresh(),this}},{key:"resize",value:function(e){var n=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=Bt(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!e&&n===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 c=this.webGLContexts[h];if(c.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(h)){var d=this.textures[h];d&&c.deleteTexture(d)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(e){var n=this,o=e?.skipIndexation!==void 0?e?.skipIndexation:!1,a=e?.schedule!==void 0?e.schedule:!1,s=!e||!e.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(g){return n.addNode(g)}),this.graph.forEachEdge(function(g){return n.addEdge(g)});else{for(var u,h,c=((u=e.partialGraph)===null||u===void 0?void 0:u.nodes)||[],d=0,l=c?.length||0;d<l;d++){var f=c[d];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 m=(e==null||(h=e.partialGraph)===null||h===void 0?void 0:h.edges)||[],b=0,R=m.length;b<R;b++){var x=m[b];if(this.updateEdge(x),o){var _=this.edgeProgramIndex[x];if(_===void 0)throw new Error('Sigma: edge "'.concat(x,`" can't be repaint`));this.addEdgeToProgram(x,this.edgeIndices[x],_)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var e=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){e.render()})),this}},{key:"scheduleRefresh",value:function(e){return this.refresh(A(A({},e),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(e,n){var o=this.camera.getState(),a=o.ratio,s=o.angle,u=o.x,h=o.y,c=this.settings,d=c.minCameraRatio,l=c.maxCameraRatio;typeof l=="number"&&(n=Math.min(n,l)),typeof d=="number"&&(n=Math.max(n,d));var f=n/a,y={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(e),b=this.viewportToFramedGraph(y);return{angle:s,x:(m.x-b.x)*(1-f)+u,y:(m.y-b.y)*(1-f)+h,ratio:n}}},{key:"viewRectangle",value:function(){var e=this.viewportToFramedGraph({x:0,y:0}),n=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:e.x,y1:e.y,x2:n.x,y2:n.y,height:n.y-o.y}}},{key:"framedGraphToViewport",value:function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!n.cameraState||!!n.viewportDimensions||!!n.graphDimensions,a=n.matrix?n.matrix:o?Re(n.cameraState||this.camera.getState(),n.viewportDimensions||this.getDimensions(),n.graphDimensions||this.getGraphDimensions(),n.padding||this.getStagePadding()):this.matrix,s=dt(a,e);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!n.cameraState||!!n.viewportDimensions||!n.graphDimensions,a=n.matrix?n.matrix:o?Re(n.cameraState||this.camera.getState(),n.viewportDimensions||this.getDimensions(),n.graphDimensions||this.getGraphDimensions(),n.padding||this.getStagePadding(),!0):this.invMatrix,s=dt(a,{x:e.x/this.width*2-1,y:1-e.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(e,n))}},{key:"graphToViewport",value:function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(e),n)}},{key:"getGraphToViewportRatio",value:function(){var e={x:0,y:0},n={x:1,y:1},o=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2)),a=this.graphToViewport(e),s=this.graphToViewport(n),u=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return u/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(e){return this.customBBox=e,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var e=this.container;e.firstChild;)e.removeChild(e.firstChild);for(var n in this.nodePrograms)this.nodePrograms[n].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return e/this.settings.zoomToSizeRatioFunction(n)*(this.getSetting("itemSizesReference")==="positions"?n*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var e={};for(var n in this.elements)this.elements[n]instanceof HTMLCanvasElement&&(e[n]=this.elements[n]);return e}}])})(Et),To=xo;function lt(r,i,t,e){const n=(c,d)=>Math.max(1,Math.min(c,d)-80)*Di({width:c,height:d},e),o=c=>{const d=n(c.width,c.height),l=n(c.activeWidth,c.height);return{ratio:d/l,offset:(c.width-c.activeWidth)/(2*l)}},a=o(i),s=o(t),u=r.ratio/a.ratio,h=(s.offset-a.offset)*u;return{...r,x:r.x+h*Math.cos(r.angle),y:r.y+h*Math.sin(r.angle),ratio:s.ratio*u}}function et(r,i){return lt({x:.5,y:.5,angle:0,ratio:1},{...r,width:r.activeWidth},r,i)}var Ro=`
|
|
313
|
+
attribute vec4 a_id;
|
|
314
|
+
attribute vec4 a_color;
|
|
315
|
+
attribute vec2 a_normal;
|
|
316
|
+
attribute float a_normalCoef;
|
|
317
|
+
attribute vec2 a_positionStart;
|
|
318
|
+
attribute vec2 a_positionEnd;
|
|
319
|
+
attribute float a_positionCoef;
|
|
320
|
+
attribute float a_sourceRadius;
|
|
321
|
+
attribute float a_targetRadius;
|
|
322
|
+
attribute float a_sourceRadiusCoef;
|
|
323
|
+
attribute float a_targetRadiusCoef;
|
|
324
|
+
|
|
325
|
+
uniform mat3 u_matrix;
|
|
326
|
+
uniform float u_zoomRatio;
|
|
327
|
+
uniform float u_sizeRatio;
|
|
328
|
+
uniform float u_pixelRatio;
|
|
329
|
+
uniform float u_correctionRatio;
|
|
330
|
+
uniform float u_minEdgeThickness;
|
|
331
|
+
uniform float u_lengthToThicknessRatio;
|
|
332
|
+
uniform float u_feather;
|
|
333
|
+
|
|
334
|
+
varying vec4 v_color;
|
|
335
|
+
varying vec2 v_normal;
|
|
336
|
+
varying float v_thickness;
|
|
337
|
+
varying float v_feather;
|
|
338
|
+
|
|
339
|
+
const float bias = 255.0 / 254.0;
|
|
340
|
+
|
|
341
|
+
void main() {
|
|
342
|
+
float minThickness = u_minEdgeThickness;
|
|
343
|
+
|
|
344
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
345
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
346
|
+
|
|
347
|
+
float normalLength = length(normal);
|
|
348
|
+
vec2 unitNormal = normal / normalLength;
|
|
349
|
+
|
|
350
|
+
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
351
|
+
// get better comments on what's happening:
|
|
352
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
353
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
354
|
+
|
|
355
|
+
// Here, we move the point to leave space for the arrow heads:
|
|
356
|
+
// Source arrow head
|
|
357
|
+
float sourceRadius = a_sourceRadius * a_sourceRadiusCoef;
|
|
358
|
+
float sourceDirection = sign(sourceRadius);
|
|
359
|
+
float webGLSourceRadius = sourceDirection * sourceRadius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
360
|
+
float webGLSourceArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
361
|
+
vec2 sourceCompensationVector =
|
|
362
|
+
vec2(-sourceDirection * unitNormal.y, sourceDirection * unitNormal.x)
|
|
363
|
+
* (webGLSourceRadius + webGLSourceArrowHeadLength);
|
|
364
|
+
|
|
365
|
+
// Target arrow head
|
|
366
|
+
float targetRadius = a_targetRadius * a_targetRadiusCoef;
|
|
367
|
+
float targetDirection = sign(targetRadius);
|
|
368
|
+
float webGLTargetRadius = targetDirection * targetRadius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
369
|
+
float webGLTargetArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
370
|
+
vec2 targetCompensationVector =
|
|
371
|
+
vec2(-targetDirection * unitNormal.y, targetDirection * unitNormal.x)
|
|
372
|
+
* (webGLTargetRadius + webGLTargetArrowHeadLength);
|
|
373
|
+
|
|
374
|
+
// Here is the proper position of the vertex
|
|
375
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + sourceCompensationVector + targetCompensationVector, 1)).xy, 0, 1);
|
|
376
|
+
|
|
377
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
378
|
+
|
|
379
|
+
v_normal = unitNormal;
|
|
380
|
+
|
|
381
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
382
|
+
|
|
383
|
+
#ifdef PICKING_MODE
|
|
384
|
+
// For picking mode, we use the ID as the color:
|
|
385
|
+
v_color = a_id;
|
|
386
|
+
#else
|
|
387
|
+
// For normal mode, we use the color:
|
|
388
|
+
v_color = a_color;
|
|
389
|
+
#endif
|
|
390
|
+
|
|
391
|
+
v_color.a *= bias;
|
|
392
|
+
}
|
|
393
|
+
`,So=Ro,Pi=WebGLRenderingContext,Jt=Pi.UNSIGNED_BYTE,ne=Pi.FLOAT,Co=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],ko={lengthToThicknessRatio:bt.lengthToThicknessRatio};function Mi(r){var i=A(A({},ko),{});return(function(t){function e(){return W(this,e),q(this,e,arguments)}return K(e,t),j(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:So,FRAGMENT_SHADER_SOURCE:wt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Co,ATTRIBUTES:[{name:"a_positionStart",size:2,type:ne},{name:"a_positionEnd",size:2,type:ne},{name:"a_normal",size:2,type:ne},{name:"a_color",size:4,type:Jt,normalized:!0},{name:"a_id",size:4,type:Jt,normalized:!0},{name:"a_sourceRadius",size:1,type:ne},{name:"a_targetRadius",size:1,type:ne}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:ne},{name:"a_normalCoef",size:1,type:ne},{name:"a_sourceRadiusCoef",size:1,type:ne},{name:"a_targetRadiusCoef",size:1,type:ne}],CONSTANT_DATA:[[0,1,-1,0],[0,-1,1,0],[1,1,0,1],[1,1,0,1],[0,-1,1,0],[1,-1,0,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,u,h){var c=h.size||1,d=s.x,l=s.y,f=u.x,y=u.y,m=fe(h.color),b=f-d,R=y-l,x=s.size||1,_=u.size||1,g=b*b+R*R,p=0,v=0;g&&(g=1/Math.sqrt(g),p=-R*g*c,v=b*g*c);var E=this.array;E[a++]=d,E[a++]=l,E[a++]=f,E[a++]=y,E[a++]=p,E[a++]=v,E[a++]=m,E[a++]=o,E[a++]=x,E[a++]=_}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,h=u.u_matrix,c=u.u_zoomRatio,d=u.u_feather,l=u.u_pixelRatio,f=u.u_correctionRatio,y=u.u_sizeRatio,m=u.u_minEdgeThickness,b=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(h,!1,o.matrix),s.uniform1f(c,o.zoomRatio),s.uniform1f(y,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(l,o.pixelRatio),s.uniform1f(d,o.antiAliasingFeather),s.uniform1f(m,o.minEdgeThickness),s.uniform1f(b,i.lengthToThicknessRatio)}}])})(Le)}Mi();function Ao(r){return Ti([Mi(),$e(r),$e(A(A({},r),{},{extremity:"source"}))])}Ao();var Lo=`
|
|
394
|
+
precision mediump float;
|
|
395
|
+
|
|
396
|
+
varying vec4 v_color;
|
|
397
|
+
|
|
398
|
+
void main(void) {
|
|
399
|
+
gl_FragColor = v_color;
|
|
400
|
+
}
|
|
401
|
+
`,No=Lo,Do=`
|
|
402
|
+
attribute vec4 a_id;
|
|
403
|
+
attribute vec4 a_color;
|
|
404
|
+
attribute vec2 a_position;
|
|
405
|
+
|
|
406
|
+
uniform mat3 u_matrix;
|
|
407
|
+
|
|
408
|
+
varying vec4 v_color;
|
|
409
|
+
|
|
410
|
+
const float bias = 255.0 / 254.0;
|
|
411
|
+
|
|
412
|
+
void main() {
|
|
413
|
+
// Scale from [[-1 1] [-1 1]] to the container:
|
|
414
|
+
gl_Position = vec4(
|
|
415
|
+
(u_matrix * vec3(a_position, 1)).xy,
|
|
416
|
+
0,
|
|
417
|
+
1
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
#ifdef PICKING_MODE
|
|
421
|
+
// For picking mode, we use the ID as the color:
|
|
422
|
+
v_color = a_id;
|
|
423
|
+
#else
|
|
424
|
+
// For normal mode, we use the color:
|
|
425
|
+
v_color = a_color;
|
|
426
|
+
#endif
|
|
427
|
+
|
|
428
|
+
v_color.a *= bias;
|
|
429
|
+
}
|
|
430
|
+
`,Go=Do,Ii=WebGLRenderingContext,Qt=Ii.UNSIGNED_BYTE,Fo=Ii.FLOAT,Po=["u_matrix"],Mo=(function(r){function i(){return W(this,i),q(this,i,arguments)}return K(i,r),j(i,[{key:"getDefinition",value:function(){return{VERTICES:2,VERTEX_SHADER_SOURCE:Go,FRAGMENT_SHADER_SOURCE:No,METHOD:WebGLRenderingContext.LINES,UNIFORMS:Po,ATTRIBUTES:[{name:"a_position",size:2,type:Fo},{name:"a_color",size:4,type:Qt,normalized:!0},{name:"a_id",size:4,type:Qt,normalized:!0}]}}},{key:"processVisibleItem",value:function(e,n,o,a,s){var u=this.array,h=o.x,c=o.y,d=a.x,l=a.y,f=fe(s.color);u[n++]=h,u[n++]=c,u[n++]=f,u[n++]=e,u[n++]=d,u[n++]=l,u[n++]=f,u[n++]=e}},{key:"setUniforms",value:function(e,n){var o=n.gl,a=n.uniformLocations,s=a.u_matrix;o.uniformMatrix3fv(s,!1,e.matrix)}}])})(Le);class zi extends Ne{fillOpacity(){return .8}getDefinition(){return{...super.getDefinition(),FRAGMENT_SHADER_SOURCE:`
|
|
431
|
+
precision highp float;
|
|
432
|
+
|
|
433
|
+
varying vec4 v_color;
|
|
434
|
+
varying vec2 v_diffVector;
|
|
435
|
+
varying float v_radius;
|
|
436
|
+
uniform float u_correctionRatio;
|
|
437
|
+
|
|
438
|
+
void main(void) {
|
|
439
|
+
float inset = v_radius - length(v_diffVector);
|
|
440
|
+
if (inset < 0.0) discard;
|
|
441
|
+
|
|
442
|
+
#ifdef PICKING_MODE
|
|
443
|
+
// Picking IDs must remain opaque and unmodified, including at the border.
|
|
444
|
+
gl_FragColor = v_color;
|
|
445
|
+
#else
|
|
446
|
+
// Sigma's circle geometry uses two correction units per CSS pixel.
|
|
447
|
+
float pixels = inset / (2.0 * u_correctionRatio);
|
|
448
|
+
float coverage = smoothstep(0.0, 0.5, pixels);
|
|
449
|
+
float fill = smoothstep(1.0, 1.5, pixels);
|
|
450
|
+
vec3 color = mix(v_color.rgb * 0.45, v_color.rgb, fill);
|
|
451
|
+
float alpha = mix(0.95, ${this.fillOpacity()}, fill) * v_color.a * coverage;
|
|
452
|
+
// Sigma blends with ONE / ONE_MINUS_SRC_ALPHA: premultiply RGB as well.
|
|
453
|
+
gl_FragColor = vec4(color * alpha, alpha);
|
|
454
|
+
#endif
|
|
455
|
+
}
|
|
456
|
+
`}}}class Io extends zi{fillOpacity(){return .96}}function zo(r){if(r.kind==="code-reference"){const s=(r.sourcePath?.split("/")??[]).at(-2);return s?`${s} › ${r.label}`:r.label}const i=r.breadcrumbs.filter(Boolean),t=r.label.trim(),e=i.at(-1)?.trim();if(!e)return t;const o=e.localeCompare(t,void 0,{sensitivity:"accent"})===0?i.at(-2)?.trim():e;return o&&o!==t?`${o} › ${t}`:t}function $o(r){const i=Number.isFinite(r)?Math.max(0,r):0;return 1.2*Math.sqrt(9+i*3.75)}function tt(r,i){return{x:Math.cos(r)*i,y:Math.sin(r)*i}}function Uo(r){const i=r.nodes.filter(d=>d.kind==="document").sort((d,l)=>d.id.localeCompare(l.id)),t=r.nodes.filter(d=>d.kind!=="document").sort((d,l)=>d.id.localeCompare(l.id)),e=new Set(i.map(d=>d.id)),n=new Set(t.map(d=>d.id)),o=new Map,a=i.length>1?Math.max(14,i.length*2.5):0;i.forEach((d,l)=>{const f=-Math.PI/2+l/Math.max(1,i.length)*Math.PI*2;o.set(d.id,tt(f,a))});const s=new Map;for(const d of r.edges){const l=e.has(d.from)?d.from:e.has(d.to)?d.to:"",f=n.has(d.from)?d.from:n.has(d.to)?d.to:"";if(!l||!f)continue;const y=s.get(f)??new Map;y.set(l,(y.get(l)??0)+d.weight),s.set(f,y)}const u=new Map,h=[];for(const d of t){const l=[...s.get(d.id)??[]].sort((y,m)=>m[1]-y[1]||y[0].localeCompare(m[0]))[0]?.[0];if(!l){h.push(d.id);continue}const f=u.get(l)??[];f.push(d.id),u.set(l,f)}for(const[d,l]of u){const f=o.get(d)??{x:0,y:0},y=Math.atan2(f.y,f.x);let m=0,b=0;for(;m<l.length;){const R=Math.min(12+b*4,l.length-m),x=6.4+b*5.6;for(let _=0;_<R;_++){const g=y+b*.31+_/R*Math.PI*2,p=tt(g,x);o.set(l[m+_],{x:f.x+p.x,y:f.y+p.y})}m+=R,b++}}const c=a+16;return h.forEach((d,l)=>{const f=l/Math.max(1,h.length)*Math.PI*2;o.set(d,tt(f,c))}),o}function Oo(r,i){const t=new Map(r.nodes.flatMap(o=>{if(o.kind!=="document"||!o.documentPath)return[];const a=i.get(o.documentPath);return a===void 0||!Number.isFinite(a)?[]:[[o.id,a]]})),e=new Map(t),n=new Map(r.nodes.map(o=>[o.id,o.kind]));for(const o of r.edges){const a=t.get(o.from);a!==void 0&&n.get(o.to)!=="document"&&e.set(o.to,Math.max(e.get(o.to)??-1/0,a));const s=t.get(o.to);s!==void 0&&n.get(o.from)!=="document"&&e.set(o.from,Math.max(e.get(o.from)??-1/0,s))}return e}function Bo(r){const i=[...r.values()].filter(Number.isFinite);if(i.length===0)return new Map;const t=Math.min(...i),e=Math.max(...i),n=6,o=16.8,a=e-t;return new Map([...r].flatMap(([s,u])=>{if(!Number.isFinite(u))return[];const h=a===0?1:(u-t)/a;return[[s,n+h*(o-n)]]}))}function Ho(r){let i=2166136261;for(let n=0;n<r.length;n++)i^=r.charCodeAt(n),i=Math.imul(i,16777619);const t=(i>>>0)/4294967295*Math.PI*2,e=1+(i>>>8&255)/255*2;return{x:Math.cos(t)*e,y:Math.sin(t)*e}}function ei(r){return!!(r&&Number.isFinite(r.x)&&Number.isFinite(r.y))}const it=new Map;let nt=null,rt=null,pe=null,ce=null,ot="";const Wo=220;function ft(r){return r==="document"?"document":"code"}function ee(r,i,t){return r.getPropertyValue(i).trim()||t}const ti=(r,i,t)=>{if(!i.label)return;const e=t.labelSize,n=i.x+i.size+4,o=i.y+e/3;r.save(),r.font=`${t.labelWeight} ${e}px ${t.labelFont}`;const a=getComputedStyle(document.documentElement);r.strokeStyle=ee(a,"--sidebar","#000"),r.lineWidth=3,r.lineJoin="round",r.strokeText(i.label,n,o),r.fillStyle=i.labelColor||ee(a,"--text","#ededed"),r.fillText(i.label,n,o),r.restore()};function jo({graph:r,onSelect:i,searchNodeSizes:t,selectedNodeId:e,visibleNodes:n}){const o=z.useRef(null),a=z.useRef(null),s=z.useRef(e),u=z.useRef(t),h=z.useRef(n),c=z.useRef(i),d=z.useRef(()=>{});return z.useLayoutEffect(()=>{s.current=e,a.current?.refresh()},[e]),z.useEffect(()=>{h.current=n,a.current?.refresh()},[n]),z.useEffect(()=>{u.current=t,a.current?.refresh()},[t]),z.useEffect(()=>{c.current=i},[i]),z.useEffect(()=>{const l=o.current;if(!l)return;const f=window.getComputedStyle(l),y={document:ee(f,"--graph-document","#ededed"),code:ee(f,"--graph-code","#737373")},m=ee(f,"--graph-node-muted","#404040"),b=ee(f,"--graph-document-rest","#999999"),R=ee(f,"--graph-code-rest","#737373"),x=ee(f,"--muted","#a1a1a1"),_=ee(f,"--graph-edge-active","#686868"),g=ee(f,"--graph-edge","#505050"),p=ee(f,"--graph-edge-muted","#383838"),v=new yt,E=Uo(r);for(const L of r.nodes){const P=it.get(L.id),G=ei(P)?P:E.get(L.id)??Ho(L.id),$=L.inDegree;v.addNode(L.id,{...G,label:zo(L),backlinks:$,category:ft(L.kind),size:$o($),color:y[ft(L.kind)]})}for(const L of r.edges)!v.hasNode(L.from)||!v.hasNode(L.to)||v.addDirectedEdgeWithKey(L.id,L.from,L.to,{color:g,size:.4+Math.log2(L.weight+1)*.15,type:"line",weight:L.weight});const k=()=>{v.forEachNode((L,P)=>{const G={x:P.x,y:P.y};ei(G)?it.set(L,G):it.delete(L)})};k();let N="";const S=new To(v,l,{defaultEdgeColor:g,defaultEdgeType:"arrow",nodeProgramClasses:{circle:zi,selected:Io},defaultDrawNodeHover:ti,defaultDrawNodeLabel:ti,edgeProgramClasses:{line:Mo,arrow:Li()},hideEdgesOnMove:!1,labelColor:{color:"#fff"},labelDensity:.3,labelFont:getComputedStyle(document.documentElement).fontFamily,labelRenderedSizeThreshold:3,labelSize:12,labelWeight:"400",minCameraRatio:.08,maxCameraRatio:8,renderEdgeLabels:!1,stagePadding:40,zIndex:!0,nodeReducer:(L,P)=>{if(!h.current.has(L))return{...P,hidden:!0};const G=u.current?.get(L),$=G===void 0?P:{...P,size:G},O=N||s.current,H=L===s.current;return H||L===O?{...$,type:H?"selected":"circle",forceLabel:!0,highlighted:!0,label:`${P.label} · ${P.backlinks} ${P.backlinks===1?"ref":"refs"}`,zIndex:H?4:3}:O&&L!==O&&!v.areNeighbors(L,O)?{...$,color:m,label:P.category==="document"?P.label:null,labelColor:x,zIndex:0}:{...$,color:O?P.color:P.color===y.document?b:R,forceLabel:!1,zIndex:P.backlinks>=4?2:1}},edgeReducer:(L,P)=>{const[G,$]=v.extremities(L);if(!h.current.has(G)||!h.current.has($))return{...P,hidden:!0};const O=N||s.current;return O&&G!==O&&$!==O?{...P,color:p,size:.4}:O?{...P,color:_,type:"arrow",size:P.size+.2}:P}});a.current=S;const M=()=>({...S.getDimensions(),activeWidth:l.parentElement?.clientWidth??l.clientWidth});let I=M();return S.setSetting("zoomToSizeRatioFunction",L=>Math.sqrt(L/et(M(),S.getGraphDimensions()).ratio)),S.getCamera().setState(nt&&rt?lt(nt,rt,I,S.getGraphDimensions()):et(I,S.getGraphDimensions())),S.on("resize",()=>{const L=M();S.getCamera().setState(lt(S.getCamera().getState(),I,L,S.getGraphDimensions())),I=L}),d.current=()=>{const L=et(M(),S.getGraphDimensions());window.matchMedia("(prefers-reduced-motion: reduce)").matches?S.getCamera().setState(L):S.getCamera().animate(L)},S.on("enterNode",({node:L})=>{N=L,S.refresh()}),S.on("leaveNode",()=>{N="",S.refresh()}),S.on("clickNode",({node:L})=>c.current(L)),()=>{k(),nt=S.getCamera().getState(),rt=I,d.current=()=>{},S.kill(),a.current=null}},[r]),F.jsxs("div",{className:"graph-canvas-shell",children:[F.jsx("div",{"aria-label":"Interactive Lat reference graph",className:"graph-canvas",ref:o}),F.jsx("button",{className:"graph-fit",onClick:()=>d.current(),title:"Fit graph",type:"button",children:"Fit"})]})}function $i(r=0,i=""){if(ot!==i&&(ot=i,pe=null,ce=null),pe&&pe.generation>=r)return Promise.resolve(pe);if(ce)return ce.then(e=>e.generation>=r?e:$i(r,i));const t=ke("/api/graph").then(e=>(ot===i&&(pe=e),e));return ce=t,t.then(()=>{ce===t&&(ce=null)},()=>{ce===t&&(ce=null)}),t}function Vo({gitEnabled:r,graph:i,node:t,onSelect:e,onShowSectionOutput:n,target:o}){const[a,s]=z.useState(null),[u,h]=z.useState(""),c=z.useRef(null),d=z.useMemo(()=>t?at(i,t,o,window.location.origin):"",[i,t,o]),l=t?.kind==="document"?t.url:d,f=z.useMemo(()=>a?.kind==="markdown"?r&&a.document.gitTree?a.document.gitTree:a.document.tree:null,[a,r]);z.useEffect(()=>{const m=new AbortController;if(s(null),h(""),!t)return()=>m.abort();const b=new URL(l||t.url,window.location.origin),R=xt(b.pathname),x=b.searchParams,_=new URLSearchParams({path:t.sourcePath??"",symbol:R===t.sourcePath?Oi(b.hash):t.symbol??"",from:R===t.sourcePath?x.get("from")??"":"",line:R===t.sourcePath?x.get("line")??"0":"0",at:R===t.sourcePath?x.get("at")??"0":String(t.line??0)});return(t.externalTarget?ke(`/api/external?target=${encodeURIComponent(t.externalTarget)}`,m.signal).then(p=>s(p.kind==="markdown"?{kind:"markdown",document:p.document}:{kind:"source",source:p.source})):t.kind==="document"?ke(`/api/document?path=${encodeURIComponent(t.documentPath??"")}`,m.signal).then(p=>s({kind:"markdown",document:p})):ke(`/api/source?${_}`,m.signal).then(p=>s({kind:"source",source:p}))).catch(p=>{m.signal.aborted||h(p.message)}),()=>m.abort()},[l,i.generation,t]),z.useLayoutEffect(()=>{const m=c.current;if(!m||!t||!a||(m.scrollTop=0,a.kind!=="markdown"))return;const b=new URL(d||t.url,window.location.origin).hash.slice(1);if(!b)return;let R=b;try{R=decodeURIComponent(b)}catch{}m.querySelector(`#${CSS.escape(R)}`)?.scrollIntoView({block:"start",behavior:"instant"})},[a,t,d]);function y(m){if(m.button!==0||m.metaKey||m.ctrlKey||m.shiftKey||m.altKey)return;const b=m.target,R=b instanceof Element?b.closest("a"):null;if(!R||R.target||R.hasAttribute("download"))return;const x=R.getAttribute("href");if(!x)return;const _=ji(x,d||t?.url||"/",window.location.origin);if(!_||!Vi(_.pathname)&&!xt(_.pathname)&&!qi(_.pathname,_.hash))return;m.preventDefault();const g=Tt(i,_);g&&e(g.nodeId,g.target)}return t?F.jsx("div",{className:"graph-inspector-scroll",ref:c,children:u?F.jsxs("div",{className:"state error",role:"alert",children:[F.jsx("strong",{children:"Could not open this node"}),F.jsx("span",{children:u})]}):a?.kind==="markdown"?F.jsxs("div",{className:"graph-inspector-document",onClick:y,children:[F.jsxs("div",{className:"document-metadata",children:[F.jsx("div",{className:"document-path",children:a.document.path}),a.document.frontmatter.requireCodeMention&&F.jsx("div",{className:"document-flag",children:"Code mentions required"}),a.document.errors.length>0&&F.jsxs("div",{className:"document-error-toggle",children:[a.document.errors.length," ",a.document.errors.length===1?"error":"errors"]})]}),f&&F.jsx(Bi,{backReferences:a.document.backReferences,onCopySectionLink:m=>Hi(new URL(l||d||t.url||"/",window.location.origin).href,m,b=>{const R=Tt(i,b);R&&e(R.nodeId,R.target)},window.navigator.clipboard),onShowSectionOutput:n,sectionOutputEnabled:!!n,tree:f})]}):a?.kind==="source"?F.jsx("div",{className:"graph-inspector-source",children:F.jsx(Wi,{onContentClick:y,source:a.source},`${a.source.path}#${a.source.focus?.symbol??""}@${a.source.focus?.startLine??0}`)}):F.jsx("div",{className:"state",children:"Loading node…"})}):F.jsx("div",{className:"graph-inspector-empty",children:"Choose a document or code reference in the graph."})}function Yo({generation:r,gitEnabled:i,header:t,instanceId:e,markdownGeneration:n,onNavigate:o,onShowSectionOutput:a,searchEnabled:s,selectedNodeId:u,target:h}){const[c,d]=z.useState(pe),[l,f]=z.useState(""),[y,m]=z.useState(""),[b,R]=z.useState(null),[x,_]=z.useState(!1),[g,p]=z.useState(""),[v,E]=z.useState({document:!0,code:!0});z.useEffect(()=>{let G=!1;return f(""),$i(r,e).then($=>{G||d($)}).catch($=>{G||f($.message)}),()=>{G=!0}},[r,e]);const k=s?y.trim():"";z.useEffect(()=>{const G=new AbortController;if(p(""),_(!!k),!k)return R(null),()=>G.abort();const $=window.setTimeout(()=>{ke(`/api/search?query=${encodeURIComponent(k)}`,G.signal).then(O=>{const H=new Map;for(const Y of O.results)H.set(Y.path,Math.max(H.get(Y.path)??-1/0,Y.score));R({pathScores:H,query:k})}).catch(O=>{G.signal.aborted||p(O.message)}).finally(()=>{G.signal.aborted||_(!1)})},Wo);return()=>{window.clearTimeout($),G.abort()}},[n,k]);const N=z.useMemo(()=>!c||!k||b?.query!==k?null:Oo(c,b.pathScores),[c,k,b]),S=z.useMemo(()=>N?Bo(N):null,[N]),M=z.useMemo(()=>new Set((c?.nodes??[]).filter(G=>v[ft(G.kind)]&&(!N||N.has(G.id))).map(G=>G.id)),[v,c,N]),I=c?.nodes.find(G=>G.id===u)??null,L=c&&I?at(c,I,h,window.location.origin):"";function P(G,$=""){const O=c?.nodes.find(Y=>Y.id===G);if(!c||!O)return;const H=at(c,O,$,window.location.origin);o(new URL(H,window.location.origin))}return F.jsxs(F.Fragment,{children:[F.jsx("div",{className:"graph-topbar",children:F.jsxs("div",{className:"graph-topbar-graph",children:[t(I,L),F.jsx("div",{className:"graph-tools",children:s?F.jsxs("label",{className:"graph-filter",children:[F.jsx("span",{className:"visually-hidden",children:"Search graph with embeddings"}),F.jsx("input",{autoComplete:"off",onChange:G=>m(G.currentTarget.value),placeholder:"Search graph…",spellCheck:"false",type:"search",value:y}),F.jsx("span",{"aria-live":"polite",className:"graph-node-count",children:x?"Searching…":`${M.size} ${M.size===1?"node":"nodes"}`})]}):F.jsxs("span",{className:"graph-node-count",children:[M.size," ",M.size===1?"node":"nodes"]})})]})}),l?F.jsxs("div",{className:"state error graph-state",role:"alert",children:[F.jsx("strong",{children:"Could not build the graph"}),F.jsx("span",{children:l})]}):c?F.jsxs("div",{className:"graph-workspace",children:[F.jsxs("section",{className:"graph-pane",children:[F.jsx(jo,{graph:c,onSelect:P,searchNodeSizes:S,selectedNodeId:u,visibleNodes:M}),F.jsx("div",{"aria-label":"Graph node kinds",className:"graph-kind-filters graph-legend",children:["document","code"].map(G=>F.jsxs("label",{className:G,children:[F.jsx("input",{checked:v[G],onChange:$=>{const O=$.currentTarget.checked;E(H=>({...H,[G]:O}))},type:"checkbox"}),F.jsx("span",{children:G})]},G))}),F.jsx("div",{className:"graph-encoding-note",children:S?"Size: relevance":"Area: incoming refs · includes subsections"}),g?F.jsx("div",{className:"graph-no-results",children:g}):!x&&M.size===0&&F.jsx("div",{className:"graph-no-results",children:"No nodes match this search."})]}),F.jsxs("aside",{className:"graph-inspector",children:[F.jsx("div",{"aria-live":"polite",className:"visually-hidden",children:I?`Selected ${I.label}`:"No node selected"}),F.jsx(Vo,{gitEnabled:i,graph:c,node:I,onSelect:P,onShowSectionOutput:a,target:L})]})]}):F.jsx("div",{className:"state graph-state",children:"Loading graph…"})]})}export{Yo as default,$i as preloadViewGraph};
|