@mcp-graph-workflow/mcp-graph 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/api/router.d.ts +0 -1
  2. package/dist/api/router.d.ts.map +1 -1
  3. package/dist/api/router.js +3 -4
  4. package/dist/api/router.js.map +1 -1
  5. package/dist/api/routes/benchmark.d.ts.map +1 -1
  6. package/dist/api/routes/benchmark.js +47 -2
  7. package/dist/api/routes/benchmark.js.map +1 -1
  8. package/dist/api/routes/code-graph.d.ts +12 -0
  9. package/dist/api/routes/code-graph.d.ts.map +1 -0
  10. package/dist/api/routes/code-graph.js +154 -0
  11. package/dist/api/routes/code-graph.js.map +1 -0
  12. package/dist/api/routes/folder.d.ts +1 -4
  13. package/dist/api/routes/folder.d.ts.map +1 -1
  14. package/dist/api/routes/folder.js +19 -17
  15. package/dist/api/routes/folder.js.map +1 -1
  16. package/dist/api/routes/integrations.d.ts.map +1 -1
  17. package/dist/api/routes/integrations.js +60 -16
  18. package/dist/api/routes/integrations.js.map +1 -1
  19. package/dist/api/routes/knowledge.js +1 -1
  20. package/dist/api/routes/knowledge.js.map +1 -1
  21. package/dist/api/routes/skills.d.ts.map +1 -1
  22. package/dist/api/routes/skills.js +57 -3
  23. package/dist/api/routes/skills.js.map +1 -1
  24. package/dist/cli/commands/index-cmd.js +5 -5
  25. package/dist/cli/commands/index-cmd.js.map +1 -1
  26. package/dist/core/code/code-indexer.d.ts +20 -0
  27. package/dist/core/code/code-indexer.d.ts.map +1 -0
  28. package/dist/core/code/code-indexer.js +161 -0
  29. package/dist/core/code/code-indexer.js.map +1 -0
  30. package/dist/core/code/code-search.d.ts +16 -0
  31. package/dist/core/code/code-search.d.ts.map +1 -0
  32. package/dist/core/code/code-search.js +77 -0
  33. package/dist/core/code/code-search.js.map +1 -0
  34. package/dist/core/code/code-store.d.ts +35 -0
  35. package/dist/core/code/code-store.d.ts.map +1 -0
  36. package/dist/core/code/code-store.js +228 -0
  37. package/dist/core/code/code-store.js.map +1 -0
  38. package/dist/core/code/code-types.d.ts +209 -0
  39. package/dist/core/code/code-types.d.ts.map +1 -0
  40. package/dist/core/code/code-types.js +94 -0
  41. package/dist/core/code/code-types.js.map +1 -0
  42. package/dist/core/code/graph-traversal.d.ts +27 -0
  43. package/dist/core/code/graph-traversal.d.ts.map +1 -0
  44. package/dist/core/code/graph-traversal.js +122 -0
  45. package/dist/core/code/graph-traversal.js.map +1 -0
  46. package/dist/core/code/process-detector.d.ts +11 -0
  47. package/dist/core/code/process-detector.d.ts.map +1 -0
  48. package/dist/core/code/process-detector.js +65 -0
  49. package/dist/core/code/process-detector.js.map +1 -0
  50. package/dist/core/code/ts-analyzer.d.ts +12 -0
  51. package/dist/core/code/ts-analyzer.d.ts.map +1 -0
  52. package/dist/core/code/ts-analyzer.js +331 -0
  53. package/dist/core/code/ts-analyzer.js.map +1 -0
  54. package/dist/core/config/ai-memory-generator.d.ts.map +1 -1
  55. package/dist/core/config/ai-memory-generator.js +149 -61
  56. package/dist/core/config/ai-memory-generator.js.map +1 -1
  57. package/dist/core/config/config-loader.d.ts.map +1 -1
  58. package/dist/core/config/config-loader.js +2 -10
  59. package/dist/core/config/config-loader.js.map +1 -1
  60. package/dist/core/config/config-schema.d.ts +1 -2
  61. package/dist/core/config/config-schema.d.ts.map +1 -1
  62. package/dist/core/config/config-schema.js +2 -3
  63. package/dist/core/config/config-schema.js.map +1 -1
  64. package/dist/core/context/compact-context.d.ts +51 -0
  65. package/dist/core/context/compact-context.d.ts.map +1 -1
  66. package/dist/core/context/compact-context.js +292 -0
  67. package/dist/core/context/compact-context.js.map +1 -1
  68. package/dist/core/context/context-assembler.d.ts +1 -1
  69. package/dist/core/context/context-assembler.js +1 -1
  70. package/dist/core/doctor/doctor-checks.d.ts +1 -1
  71. package/dist/core/doctor/doctor-checks.js +21 -21
  72. package/dist/core/doctor/doctor-checks.js.map +1 -1
  73. package/dist/core/insights/bottleneck-detector.js +1 -1
  74. package/dist/core/insights/bottleneck-detector.js.map +1 -1
  75. package/dist/core/integrations/enriched-context.d.ts +10 -6
  76. package/dist/core/integrations/enriched-context.d.ts.map +1 -1
  77. package/dist/core/integrations/enriched-context.js +35 -35
  78. package/dist/core/integrations/enriched-context.js.map +1 -1
  79. package/dist/core/integrations/integration-orchestrator.js +2 -2
  80. package/dist/core/integrations/integration-orchestrator.js.map +1 -1
  81. package/dist/core/integrations/mcp-deps-installer.d.ts +1 -1
  82. package/dist/core/integrations/mcp-deps-installer.d.ts.map +1 -1
  83. package/dist/core/integrations/mcp-deps-installer.js +1 -60
  84. package/dist/core/integrations/mcp-deps-installer.js.map +1 -1
  85. package/dist/core/integrations/mcp-servers-config.d.ts +1 -1
  86. package/dist/core/integrations/mcp-servers-config.d.ts.map +1 -1
  87. package/dist/core/integrations/mcp-servers-config.js +0 -17
  88. package/dist/core/integrations/mcp-servers-config.js.map +1 -1
  89. package/dist/core/integrations/tool-status.d.ts +8 -3
  90. package/dist/core/integrations/tool-status.d.ts.map +1 -1
  91. package/dist/core/integrations/tool-status.js +38 -48
  92. package/dist/core/integrations/tool-status.js.map +1 -1
  93. package/dist/core/memory/memory-migrator.d.ts +15 -0
  94. package/dist/core/memory/memory-migrator.d.ts.map +1 -0
  95. package/dist/core/memory/memory-migrator.js +64 -0
  96. package/dist/core/memory/memory-migrator.js.map +1 -0
  97. package/dist/core/memory/memory-reader.d.ts +30 -0
  98. package/dist/core/memory/memory-reader.d.ts.map +1 -0
  99. package/dist/core/memory/memory-reader.js +106 -0
  100. package/dist/core/memory/memory-reader.js.map +1 -0
  101. package/dist/core/planner/lifecycle-phase.d.ts +1 -0
  102. package/dist/core/planner/lifecycle-phase.d.ts.map +1 -1
  103. package/dist/core/planner/lifecycle-phase.js +11 -8
  104. package/dist/core/planner/lifecycle-phase.js.map +1 -1
  105. package/dist/core/rag/memory-indexer.d.ts +16 -0
  106. package/dist/core/rag/memory-indexer.d.ts.map +1 -0
  107. package/dist/core/rag/{serena-indexer.js → memory-indexer.js} +12 -12
  108. package/dist/core/rag/memory-indexer.js.map +1 -0
  109. package/dist/core/rag/{serena-rag-query.d.ts → memory-rag-query.d.ts} +11 -9
  110. package/dist/core/rag/memory-rag-query.d.ts.map +1 -0
  111. package/dist/core/rag/{serena-rag-query.js → memory-rag-query.js} +18 -15
  112. package/dist/core/rag/memory-rag-query.js.map +1 -0
  113. package/dist/core/rag/skill-indexer.d.ts +16 -0
  114. package/dist/core/rag/skill-indexer.d.ts.map +1 -0
  115. package/dist/core/rag/skill-indexer.js +98 -0
  116. package/dist/core/rag/skill-indexer.js.map +1 -0
  117. package/dist/core/skills/built-in-skills.d.ts +26 -0
  118. package/dist/core/skills/built-in-skills.d.ts.map +1 -0
  119. package/dist/core/skills/built-in-skills.js +203 -0
  120. package/dist/core/skills/built-in-skills.js.map +1 -0
  121. package/dist/core/store/knowledge-store.d.ts +1 -1
  122. package/dist/core/store/knowledge-store.js +1 -1
  123. package/dist/core/store/migrations.d.ts.map +1 -1
  124. package/dist/core/store/migrations.js +89 -0
  125. package/dist/core/store/migrations.js.map +1 -1
  126. package/dist/core/store/tool-token-store.d.ts +39 -0
  127. package/dist/core/store/tool-token-store.d.ts.map +1 -0
  128. package/dist/core/store/tool-token-store.js +79 -0
  129. package/dist/core/store/tool-token-store.js.map +1 -0
  130. package/dist/mcp/app-factory.d.ts +0 -1
  131. package/dist/mcp/app-factory.d.ts.map +1 -1
  132. package/dist/mcp/app-factory.js +2 -2
  133. package/dist/mcp/app-factory.js.map +1 -1
  134. package/dist/mcp/lifecycle-wrapper.d.ts +1 -0
  135. package/dist/mcp/lifecycle-wrapper.d.ts.map +1 -1
  136. package/dist/mcp/lifecycle-wrapper.js +21 -0
  137. package/dist/mcp/lifecycle-wrapper.js.map +1 -1
  138. package/dist/mcp/server.js +19 -14
  139. package/dist/mcp/server.js.map +1 -1
  140. package/dist/mcp/tools/index.d.ts.map +1 -1
  141. package/dist/mcp/tools/index.js +4 -0
  142. package/dist/mcp/tools/index.js.map +1 -1
  143. package/dist/mcp/tools/list-skills.d.ts +7 -0
  144. package/dist/mcp/tools/list-skills.d.ts.map +1 -0
  145. package/dist/mcp/tools/list-skills.js +68 -0
  146. package/dist/mcp/tools/list-skills.js.map +1 -0
  147. package/dist/mcp/tools/memory.d.ts +8 -0
  148. package/dist/mcp/tools/memory.d.ts.map +1 -0
  149. package/dist/mcp/tools/memory.js +106 -0
  150. package/dist/mcp/tools/memory.js.map +1 -0
  151. package/dist/mcp/tools/reindex-knowledge.d.ts.map +1 -1
  152. package/dist/mcp/tools/reindex-knowledge.js +11 -7
  153. package/dist/mcp/tools/reindex-knowledge.js.map +1 -1
  154. package/dist/schemas/knowledge.schema.d.ts +4 -0
  155. package/dist/schemas/knowledge.schema.d.ts.map +1 -1
  156. package/dist/schemas/knowledge.schema.js +1 -1
  157. package/dist/schemas/knowledge.schema.js.map +1 -1
  158. package/dist/web/dashboard/dist/assets/benchmark-tab-B5Sr8Cah.js +1 -0
  159. package/dist/web/dashboard/dist/assets/constants-kpH_c6vY.js +1 -0
  160. package/dist/web/dashboard/dist/assets/gitnexus-tab-DqmbSdzV.js +430 -0
  161. package/dist/web/dashboard/dist/assets/graph-tab-BKns5HdW.js +1 -0
  162. package/dist/web/dashboard/dist/assets/graph-utils-BxUWNvsI.js +7 -0
  163. package/dist/web/dashboard/dist/assets/index-CZOiKbTP.js +53 -0
  164. package/dist/web/dashboard/dist/assets/index-Dd4vKyDX.js +17 -0
  165. package/dist/web/dashboard/dist/assets/index-xyMN-_UV.css +1 -0
  166. package/dist/web/dashboard/dist/assets/insights-tab-B1kPckBM.js +52 -0
  167. package/dist/web/dashboard/dist/assets/{logs-tab-Cxpcv_ni.js → logs-tab-BWfsrRlB.js} +1 -1
  168. package/dist/web/dashboard/dist/assets/memories-tab-D3zm-1Sq.js +1 -0
  169. package/dist/web/dashboard/dist/assets/prd-backlog-tab-DXP4dFP-.js +1 -0
  170. package/dist/web/dashboard/dist/assets/skills-tab-CAlVL80S.js +1 -0
  171. package/dist/web/dashboard/dist/index.html +2 -2
  172. package/package.json +2 -2
  173. package/dist/api/routes/gitnexus.d.ts +0 -12
  174. package/dist/api/routes/gitnexus.d.ts.map +0 -1
  175. package/dist/api/routes/gitnexus.js +0 -164
  176. package/dist/api/routes/gitnexus.js.map +0 -1
  177. package/dist/core/integrations/gitnexus-launcher.d.ts +0 -67
  178. package/dist/core/integrations/gitnexus-launcher.d.ts.map +0 -1
  179. package/dist/core/integrations/gitnexus-launcher.js +0 -268
  180. package/dist/core/integrations/gitnexus-launcher.js.map +0 -1
  181. package/dist/core/integrations/gitnexus-queries.d.ts +0 -55
  182. package/dist/core/integrations/gitnexus-queries.d.ts.map +0 -1
  183. package/dist/core/integrations/gitnexus-queries.js +0 -168
  184. package/dist/core/integrations/gitnexus-queries.js.map +0 -1
  185. package/dist/core/integrations/serena-reader.d.ts +0 -18
  186. package/dist/core/integrations/serena-reader.d.ts.map +0 -1
  187. package/dist/core/integrations/serena-reader.js +0 -68
  188. package/dist/core/integrations/serena-reader.js.map +0 -1
  189. package/dist/core/rag/serena-indexer.d.ts +0 -16
  190. package/dist/core/rag/serena-indexer.d.ts.map +0 -1
  191. package/dist/core/rag/serena-indexer.js.map +0 -1
  192. package/dist/core/rag/serena-rag-query.d.ts.map +0 -1
  193. package/dist/core/rag/serena-rag-query.js.map +0 -1
  194. package/dist/web/dashboard/dist/assets/benchmark-tab-DE6hAHVG.js +0 -1
  195. package/dist/web/dashboard/dist/assets/constants-BIEJOBya.js +0 -1
  196. package/dist/web/dashboard/dist/assets/gitnexus-tab-DsBjJHx8.js +0 -312
  197. package/dist/web/dashboard/dist/assets/graph-tab-C09DzeZ_.js +0 -1
  198. package/dist/web/dashboard/dist/assets/graph-utils-D4LFspTf.js +0 -23
  199. package/dist/web/dashboard/dist/assets/index-B2fTJ4AS.js +0 -53
  200. package/dist/web/dashboard/dist/assets/index-CkqEqKiH.css +0 -1
  201. package/dist/web/dashboard/dist/assets/insights-tab-Bm7CDckb.js +0 -1
  202. package/dist/web/dashboard/dist/assets/prd-backlog-tab-X84Rj-IB.js +0 -1
  203. package/dist/web/dashboard/dist/assets/serena-tab-BunULNvw.js +0 -1
@@ -0,0 +1,430 @@
1
+ import{g as $r,r as G,t as Et,j as p,a as Oe,O as Ii}from"./index-CZOiKbTP.js";import{C as we,b as pt,c as Ur}from"./constants-kpH_c6vY.js";var st={exports:{}},Xt;function Oi(){if(Xt)return st.exports;Xt=1;var n=typeof Reflect=="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(y,S,C){return Function.prototype.apply.call(y,S,C)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(y){return Object.getOwnPropertyNames(y).concat(Object.getOwnPropertySymbols(y))}:t=function(y){return Object.getOwnPropertyNames(y)};function e(m){console&&console.warn&&console.warn(m)}var i=Number.isNaN||function(y){return y!==y};function o(){o.init.call(this)}st.exports=o,st.exports.once=L,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(m){if(typeof m!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof m)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(m){if(typeof m!="number"||m<0||i(m))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+m+".");a=m}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(y){if(typeof y!="number"||y<0||i(y))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+y+".");return this._maxListeners=y,this};function u(m){return m._maxListeners===void 0?o.defaultMaxListeners:m._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(y){for(var S=[],C=1;C<arguments.length;C++)S.push(arguments[C]);var P=y==="error",O=this._events;if(O!==void 0)P=P&&O.error===void 0;else if(!P)return!1;if(P){var z;if(S.length>0&&(z=S[0]),z instanceof Error)throw z;var Y=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw Y.context=z,Y}var j=O[y];if(j===void 0)return!1;if(typeof j=="function")r(j,this,S);else for(var g=j.length,Q=b(j,g),C=0;C<g;++C)r(Q[C],this,S);return!0};function l(m,y,S,C){var P,O,z;if(s(S),O=m._events,O===void 0?(O=m._events=Object.create(null),m._eventsCount=0):(O.newListener!==void 0&&(m.emit("newListener",y,S.listener?S.listener:S),O=m._events),z=O[y]),z===void 0)z=O[y]=S,++m._eventsCount;else if(typeof z=="function"?z=O[y]=C?[S,z]:[z,S]:C?z.unshift(S):z.push(S),P=u(m),P>0&&z.length>P&&!z.warned){z.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(y)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=m,Y.type=y,Y.count=z.length,e(Y)}return m}o.prototype.addListener=function(y,S){return l(this,y,S,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(y,S){return l(this,y,S,!0)};function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(m,y,S){var C={fired:!1,wrapFn:void 0,target:m,type:y,listener:S},P=h.bind(C);return P.listener=S,C.wrapFn=P,P}o.prototype.once=function(y,S){return s(S),this.on(y,d(this,y,S)),this},o.prototype.prependOnceListener=function(y,S){return s(S),this.prependListener(y,d(this,y,S)),this},o.prototype.removeListener=function(y,S){var C,P,O,z,Y;if(s(S),P=this._events,P===void 0)return this;if(C=P[y],C===void 0)return this;if(C===S||C.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete P[y],P.removeListener&&this.emit("removeListener",y,C.listener||S));else if(typeof C!="function"){for(O=-1,z=C.length-1;z>=0;z--)if(C[z]===S||C[z].listener===S){Y=C[z].listener,O=z;break}if(O<0)return this;O===0?C.shift():w(C,O),C.length===1&&(P[y]=C[0]),P.removeListener!==void 0&&this.emit("removeListener",y,Y||S)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(y){var S,C,P;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[y]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[y]),this;if(arguments.length===0){var O=Object.keys(C),z;for(P=0;P<O.length;++P)z=O[P],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=C[y],typeof S=="function")this.removeListener(y,S);else if(S!==void 0)for(P=S.length-1;P>=0;P--)this.removeListener(y,S[P]);return this};function c(m,y,S){var C=m._events;if(C===void 0)return[];var P=C[y];return P===void 0?[]:typeof P=="function"?S?[P.listener||P]:[P]:S?E(P):b(P,P.length)}o.prototype.listeners=function(y){return c(this,y,!0)},o.prototype.rawListeners=function(y){return c(this,y,!1)},o.listenerCount=function(m,y){return typeof m.listenerCount=="function"?m.listenerCount(y):f.call(m,y)},o.prototype.listenerCount=f;function f(m){var y=this._events;if(y!==void 0){var S=y[m];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function b(m,y){for(var S=new Array(y),C=0;C<y;++C)S[C]=m[C];return S}function w(m,y){for(;y+1<m.length;y++)m[y]=m[y+1];m.pop()}function E(m){for(var y=new Array(m.length),S=0;S<y.length;++S)y[S]=m[S].listener||m[S];return y}function L(m,y){return new Promise(function(S,C){function P(z){m.removeListener(y,O),C(z)}function O(){typeof m.removeListener=="function"&&m.removeListener("error",P),S([].slice.call(arguments))}R(m,y,O,{once:!0}),y!=="error"&&_(m,P,{once:!0})})}function _(m,y,S){typeof m.on=="function"&&R(m,"error",y,S)}function R(m,y,S,C){if(typeof m.on=="function")C.once?m.once(y,S):m.on(y,S);else if(typeof m.addEventListener=="function")m.addEventListener(y,function P(O){C.once&&m.removeEventListener(y,P),S(O)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof m)}return st.exports}var jr=Oi();function zi(){const n=arguments[0];for(let r=1,t=arguments.length;r<t;r++)if(arguments[r])for(const e in arguments[r])n[e]=arguments[r][e];return n}let te=zi;typeof Object.assign=="function"&&(te=Object.assign);function fe(n,r,t,e){const i=n._nodes.get(r);let o=null;return i&&(e==="mixed"?o=i.out&&i.out[t]||i.undirected&&i.undirected[t]:e==="directed"?o=i.out&&i.out[t]:o=i.undirected&&i.undirected[t]),o}function ae(n){return typeof n=="object"&&n!==null}function Mr(n){let r;for(r in n)return!1;return!0}function de(n,r,t){Object.defineProperty(n,r,{enumerable:!1,configurable:!1,writable:!0,value:t})}function ve(n,r,t){const e={enumerable:!0,configurable:!0};typeof t=="function"?e.get=t:(e.value=t,e.writable=!1),Object.defineProperty(n,r,e)}function Qt(n){return!(!ae(n)||n.attributes&&!Array.isArray(n.attributes))}function $i(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function ke(){const n=arguments;let r=null,t=-1;return{[Symbol.iterator](){return this},next(){let e=null;do{if(r===null){if(t++,t>=n.length)return{done:!0};r=n[t][Symbol.iterator]()}if(e=r.next(),e.done){r=null;continue}break}while(!0);return e}}}function Ve(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Bt extends Error{constructor(r){super(),this.name="GraphError",this.message=r}}class D extends Bt{constructor(r){super(r),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}class A extends Bt{constructor(r){super(r),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,A.prototype.constructor)}}class U extends Bt{constructor(r){super(r),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,U.prototype.constructor)}}function Br(n,r){this.key=n,this.attributes=r,this.clear()}Br.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Hr(n,r){this.key=n,this.attributes=r,this.clear()}Hr.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Wr(n,r){this.key=n,this.attributes=r,this.clear()}Wr.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function qe(n,r,t,e,i){this.key=r,this.attributes=i,this.undirected=n,this.source=t,this.target=e}qe.prototype.attach=function(){let n="out",r="in";this.undirected&&(n=r="undirected");const t=this.source.key,e=this.target.key;this.source[n][e]=this,!(this.undirected&&t===e)&&(this.target[r][t]=this)};qe.prototype.attachMulti=function(){let n="out",r="in";const t=this.source.key,e=this.target.key;this.undirected&&(n=r="undirected");const i=this.source[n],o=i[e];if(typeof o>"u"){i[e]=this,this.undirected&&t===e||(this.target[r][t]=this);return}o.previous=this,this.next=o,i[e]=this,this.target[r][t]=this};qe.prototype.detach=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),delete this.source[t][r],delete this.target[e][n]};qe.prototype.detachMulti=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][r],delete this.target[e][n]):(this.next.previous=void 0,this.source[t][r]=this.next,this.target[e][n]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Vr=0,qr=1,Ui=2,Kr=3;function Ae(n,r,t,e,i,o,a){let s,u,l,h;if(e=""+e,t===Vr){if(s=n._nodes.get(e),!s)throw new A(`Graph.${r}: could not find the "${e}" node in the graph.`);l=i,h=o}else if(t===Kr){if(i=""+i,u=n._edges.get(i),!u)throw new A(`Graph.${r}: could not find the "${i}" edge in the graph.`);const d=u.source.key,c=u.target.key;if(e===d)s=u.target;else if(e===c)s=u.source;else throw new A(`Graph.${r}: the "${e}" node is not attached to the "${i}" edge (${d}, ${c}).`);l=o,h=a}else{if(u=n._edges.get(e),!u)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`);t===qr?s=u.source:s=u.target,l=i,h=o}return[s,l,h]}function ji(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);return a.attributes[s]}}function Mi(n,r,t){n.prototype[r]=function(e,i){const[o]=Ae(this,r,t,e,i);return o.attributes}}function Bi(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);return a.attributes.hasOwnProperty(s)}}function Hi(n,r,t){n.prototype[r]=function(e,i,o,a){const[s,u,l]=Ae(this,r,t,e,i,o,a);return s.attributes[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Wi(n,r,t){n.prototype[r]=function(e,i,o,a){const[s,u,l]=Ae(this,r,t,e,i,o,a);if(typeof l!="function")throw new D(`Graph.${r}: updater should be a function.`);const h=s.attributes,d=l(h[u]);return h[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Vi(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function qi(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);if(!ae(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function Ki(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);if(!ae(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return te(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function Yi(n,r,t){n.prototype[r]=function(e,i,o){const[a,s]=Ae(this,r,t,e,i,o);if(typeof s!="function")throw new D(`Graph.${r}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const Zi=[{name:n=>`get${n}Attribute`,attacher:ji},{name:n=>`get${n}Attributes`,attacher:Mi},{name:n=>`has${n}Attribute`,attacher:Bi},{name:n=>`set${n}Attribute`,attacher:Hi},{name:n=>`update${n}Attribute`,attacher:Wi},{name:n=>`remove${n}Attribute`,attacher:Vi},{name:n=>`replace${n}Attributes`,attacher:qi},{name:n=>`merge${n}Attributes`,attacher:Ki},{name:n=>`update${n}Attributes`,attacher:Yi}];function Xi(n){Zi.forEach(function({name:r,attacher:t}){t(n,r("Node"),Vr),t(n,r("Source"),qr),t(n,r("Target"),Ui),t(n,r("Opposite"),Kr)})}function Qi(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return o.attributes[i]}}function Ji(n,r,t){n.prototype[r]=function(e){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,a=""+arguments[1];if(i=fe(this,o,a,t),!i)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,i=this._edges.get(e),!i)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return i.attributes}}function en(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function tn(n,r,t){n.prototype[r]=function(e,i,o){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+i;if(i=arguments[2],o=arguments[3],a=fe(this,s,u,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function rn(n,r,t){n.prototype[r]=function(e,i,o){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+i;if(i=arguments[2],o=arguments[3],a=fe(this,s,u,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof o!="function")throw new D(`Graph.${r}: updater should be a function.`);return a.attributes[i]=o(a.attributes[i]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function nn(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function on(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!ae(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function an(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!ae(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return te(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function sn(n,r,t){n.prototype[r]=function(e,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+i;if(i=arguments[2],o=fe(this,a,s,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof i!="function")throw new D(`Graph.${r}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const un=[{name:n=>`get${n}Attribute`,attacher:Qi},{name:n=>`get${n}Attributes`,attacher:Ji},{name:n=>`has${n}Attribute`,attacher:en},{name:n=>`set${n}Attribute`,attacher:tn},{name:n=>`update${n}Attribute`,attacher:rn},{name:n=>`remove${n}Attribute`,attacher:nn},{name:n=>`replace${n}Attributes`,attacher:on},{name:n=>`merge${n}Attributes`,attacher:an},{name:n=>`update${n}Attributes`,attacher:sn}];function ln(n){un.forEach(function({name:r,attacher:t}){t(n,r("Edge"),"mixed"),t(n,r("DirectedEdge"),"directed"),t(n,r("UndirectedEdge"),"undirected")})}const hn=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function dn(n,r,t,e){let i=!1;for(const o in r){if(o===e)continue;const a=r[o];if(i=t(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),n&&i)return a.key}}function cn(n,r,t,e){let i,o,a,s=!1;for(const u in r)if(u!==e){i=r[u];do{if(o=i.source,a=i.target,s=t(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),n&&s)return i.key;i=i.next}while(i!==void 0)}}function xt(n,r){const t=Object.keys(n),e=t.length;let i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=e)return{done:!0};const a=t[o++];if(a===r){i=void 0;continue}i=n[a]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function fn(n,r,t,e){const i=r[t];if(!i)return;const o=i.source,a=i.target;if(e(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&n)return i.key}function gn(n,r,t,e){let i=r[t];if(!i)return;let o=!1;do{if(o=e(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),n&&o)return i.key;i=i.next}while(i!==void 0)}function _t(n,r){let t=n[r];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const i={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:i}}};let e=!1;return{[Symbol.iterator](){return this},next(){return e===!0?{done:!0}:(e=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function pn(n,r){if(n.size===0)return[];if(r==="mixed"||r===n.type)return Array.from(n._edges.keys());const t=r==="undirected"?n.undirectedSize:n.directedSize,e=new Array(t),i=r==="undirected",o=n._edges.values();let a=0,s,u;for(;s=o.next(),s.done!==!0;)u=s.value,u.undirected===i&&(e[a++]=u.key);return e}function Yr(n,r,t,e){if(r.size===0)return;const i=t!=="mixed"&&t!==r.type,o=t==="undirected";let a,s,u=!1;const l=r._edges.values();for(;a=l.next(),a.done!==!0;){if(s=a.value,i&&s.undirected!==o)continue;const{key:h,attributes:d,source:c,target:f}=s;if(u=e(h,d,c.key,f.key,c.attributes,f.attributes,s.undirected),n&&u)return h}}function mn(n,r){if(n.size===0)return Ve();const t=r!=="mixed"&&r!==n.type,e=r==="undirected",i=n._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(t&&a.undirected!==e))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function Ht(n,r,t,e,i,o){const a=r?cn:dn;let s;if(t!=="undirected"&&(e!=="out"&&(s=a(n,i.in,o),n&&s)||e!=="in"&&(s=a(n,i.out,o,e?void 0:i.key),n&&s))||t!=="directed"&&(s=a(n,i.undirected,o),n&&s))return s}function vn(n,r,t,e){const i=[];return Ht(!1,n,r,t,e,function(o){i.push(o)}),i}function yn(n,r,t){let e=Ve();return n!=="undirected"&&(r!=="out"&&typeof t.in<"u"&&(e=ke(e,xt(t.in))),r!=="in"&&typeof t.out<"u"&&(e=ke(e,xt(t.out,r?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(e=ke(e,xt(t.undirected))),e}function Wt(n,r,t,e,i,o,a){const s=t?gn:fn;let u;if(r!=="undirected"&&(typeof i.in<"u"&&e!=="out"&&(u=s(n,i.in,o,a),n&&u)||typeof i.out<"u"&&e!=="in"&&(e||i.key!==o)&&(u=s(n,i.out,o,a),n&&u))||r!=="directed"&&typeof i.undirected<"u"&&(u=s(n,i.undirected,o,a),n&&u))return u}function bn(n,r,t,e,i){const o=[];return Wt(!1,n,r,t,e,i,function(a){o.push(a)}),o}function wn(n,r,t,e){let i=Ve();return n!=="undirected"&&(typeof t.in<"u"&&r!=="out"&&e in t.in&&(i=ke(i,_t(t.in,e))),typeof t.out<"u"&&r!=="in"&&e in t.out&&(r||t.key!==e)&&(i=ke(i,_t(t.out,e)))),n!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(i=ke(i,_t(t.undirected,e))),i}function En(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(o,a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];if(!arguments.length)return pn(this,e);if(arguments.length===1){o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new A(`Graph.${t}: could not find the "${o}" node in the graph.`);return vn(this.multi,e==="mixed"?this.type:e,i,s)}if(arguments.length===2){o=""+o,a=""+a;const s=this._nodes.get(o);if(!s)throw new A(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new A(`Graph.${t}: could not find the "${a}" target node in the graph.`);return bn(e,this.multi,i,s,a)}throw new D(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function xn(n,r){const{name:t,type:e,direction:i}=r,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(l,h,d){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return d=l,Yr(!1,this,e,d);if(arguments.length===2){l=""+l,d=h;const c=this._nodes.get(l);if(typeof c>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);return Ht(!1,this.multi,e==="mixed"?this.type:e,i,c,d)}if(arguments.length===3){l=""+l,h=""+h;const c=this._nodes.get(l);if(!c)throw new A(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(h))throw new A(`Graph.${o}: could not find the "${h}" target node in the graph.`);return Wt(!1,e,this.multi,i,c,h,d)}throw new D(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const a="map"+t[0].toUpperCase()+t.slice(1);n.prototype[a]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop();let d;if(l.length===0){let c=0;e!=="directed"&&(c+=this.undirectedSize),e!=="undirected"&&(c+=this.directedSize),d=new Array(c);let f=0;l.push((b,w,E,L,_,R,m)=>{d[f++]=h(b,w,E,L,_,R,m)})}else d=[],l.push((c,f,b,w,E,L,_)=>{d.push(h(c,f,b,w,E,L,_))});return this[o].apply(this,l),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop(),d=[];return l.push((c,f,b,w,E,L,_)=>{h(c,f,b,w,E,L,_)&&d.push(c)}),this[o].apply(this,l),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(){let l=Array.prototype.slice.call(arguments);if(l.length<2||l.length>4)throw new D(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${l.length}).`);if(typeof l[l.length-1]=="function"&&typeof l[l.length-2]!="function")throw new D(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let h,d;l.length===2?(h=l[0],d=l[1],l=[]):l.length===3?(h=l[1],d=l[2],l=[l[0]]):l.length===4&&(h=l[2],d=l[3],l=[l[0],l[1]]);let c=d;return l.push((f,b,w,E,L,_,R)=>{c=h(c,f,b,w,E,L,_,R)}),this[o].apply(this,l),c}}function _n(n,r){const{name:t,type:e,direction:i}=r,o="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(u,l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return h=u,Yr(!0,this,e,h);if(arguments.length===2){u=""+u,h=l;const d=this._nodes.get(u);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${u}" node in the graph.`);return Ht(!0,this.multi,e==="mixed"?this.type:e,i,d,h)}if(arguments.length===3){u=""+u,l=""+l;const d=this._nodes.get(u);if(!d)throw new A(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new A(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Wt(!0,e,this.multi,i,d,l,h)}throw new D(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const a="some"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,f,b,w,E,L)=>l(d,c,f,b,w,E,L)),!!this[o].apply(this,u)};const s="every"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,f,b,w,E,L)=>!l(d,c,f,b,w,E,L)),!this[o].apply(this,u)}}function Cn(n,r){const{name:t,type:e,direction:i}=r,o=t.slice(0,-1)+"Entries";n.prototype[o]=function(a,s){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();if(!arguments.length)return mn(this,e);if(arguments.length===1){a=""+a;const u=this._nodes.get(a);if(!u)throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return yn(e,i,u)}if(arguments.length===2){a=""+a,s=""+s;const u=this._nodes.get(a);if(!u)throw new A(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new A(`Graph.${o}: could not find the "${s}" target node in the graph.`);return wn(e,i,u,s)}throw new D(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Sn(n){hn.forEach(r=>{En(n,r),xn(n,r),_n(n,r),Cn(n,r)})}const Tn=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function mt(){this.A=null,this.B=null}mt.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};mt.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function Ze(n,r,t,e,i){for(const o in e){const a=e[o],s=a.source,u=a.target,l=s===t?u:s;if(r&&r.has(l.key))continue;const h=i(l.key,l.attributes);if(n&&h)return l.key}}function Vt(n,r,t,e,i){if(r!=="mixed"){if(r==="undirected")return Ze(n,null,e,e.undirected,i);if(typeof t=="string")return Ze(n,null,e,e[t],i)}const o=new mt;let a;if(r!=="undirected"){if(t!=="out"){if(a=Ze(n,null,e,e.in,i),n&&a)return a;o.wrap(e.in)}if(t!=="in"){if(a=Ze(n,o,e,e.out,i),n&&a)return a;o.wrap(e.out)}}if(r!=="directed"&&(a=Ze(n,o,e,e.undirected,i),n&&a))return a}function Rn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Object.keys(t.undirected);if(typeof r=="string")return Object.keys(t[r])}const e=[];return Vt(!1,n,r,t,function(i){e.push(i)}),e}function Xe(n,r,t){const e=Object.keys(t),i=e.length;let o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=i)return n&&n.wrap(t),{done:!0};const s=t[e[o++]],u=s.source,l=s.target;if(a=u===r?l:u,n&&n.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function kn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Xe(null,t,t.undirected);if(typeof r=="string")return Xe(null,t,t[r])}let e=Ve();const i=new mt;return n!=="undirected"&&(r!=="out"&&(e=ke(e,Xe(i,t,t.in))),r!=="in"&&(e=ke(e,Xe(i,t,t.out)))),n!=="directed"&&(e=ke(e,Xe(i,t,t.undirected))),e}function An(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new A(`Graph.${t}: could not find the "${o}" node in the graph.`);return Rn(e==="mixed"?this.type:e,i,a)}}function Ln(n,r){const{name:t,type:e,direction:i}=r,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);Vt(!1,e==="mixed"?this.type:e,i,d,h)};const a="map"+t[0].toUpperCase()+t.slice(1);n.prototype[a]=function(l,h){const d=[];return this[o](l,(c,f)=>{d.push(h(c,f))}),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(l,h){const d=[];return this[o](l,(c,f)=>{h(c,f)&&d.push(c)}),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(l,h,d){if(arguments.length<3)throw new D(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c=d;return this[o](l,(f,b)=>{c=h(c,f,b)}),c}}function Dn(n,r){const{name:t,type:e,direction:i}=r,o=t[0].toUpperCase()+t.slice(1,-1),a="find"+o;n.prototype[a]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);return Vt(!0,e==="mixed"?this.type:e,i,d,h)};const s="some"+o;n.prototype[s]=function(l,h){return!!this[a](l,h)};const u="every"+o;n.prototype[u]=function(l,h){return!this[a](l,(c,f)=>!h(c,f))}}function Gn(n,r){const{name:t,type:e,direction:i}=r,o=t.slice(0,-1)+"Entries";n.prototype[o]=function(a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return kn(e==="mixed"?this.type:e,i,s)}}function Nn(n){Tn.forEach(r=>{An(n,r),Ln(n,r),Dn(n,r),Gn(n,r)})}function ut(n,r,t,e,i){const o=e._nodes.values(),a=e.type;let s,u,l,h,d,c;for(;s=o.next(),s.done!==!0;){let f=!1;if(u=s.value,a!=="undirected"){h=u.out;for(l in h){d=h[l];do c=d.target,f=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(a!=="directed"){h=u.undirected;for(l in h)if(!(r&&u.key>l)){d=h[l];do c=d.target,c.key!==l&&(c=d.source),f=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}t&&!f&&i(u.key,null,u.attributes,null,null,null,null)}}function Fn(n,r){const t={key:n};return Mr(r.attributes)||(t.attributes=te({},r.attributes)),t}function Pn(n,r,t){const e={key:r,source:t.source.key,target:t.target.key};return Mr(t.attributes)||(e.attributes=te({},t.attributes)),n==="mixed"&&t.undirected&&(e.undirected=!0),e}function In(n){if(!ae(n))throw new D('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in n))throw new D("Graph.import: serialized node is missing its key.");if("attributes"in n&&(!ae(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function On(n){if(!ae(n))throw new D('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in n))throw new D("Graph.import: serialized edge is missing its source.");if(!("target"in n))throw new D("Graph.import: serialized edge is missing its target.");if("attributes"in n&&(!ae(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in n&&typeof n.undirected!="boolean")throw new D("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const zn=$i(),$n=new Set(["directed","undirected","mixed"]),Jt=new Set(["domain","_events","_eventsCount","_maxListeners"]),Un=[{name:n=>`${n}Edge`,generateKey:!0},{name:n=>`${n}DirectedEdge`,generateKey:!0,type:"directed"},{name:n=>`${n}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:n=>`${n}EdgeWithKey`},{name:n=>`${n}DirectedEdgeWithKey`,type:"directed"},{name:n=>`${n}UndirectedEdgeWithKey`,type:"undirected"}],jn={allowSelfLoops:!0,multi:!1,type:"mixed"};function Mn(n,r,t){if(t&&!ae(t))throw new D(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(r=""+r,t=t||{},n._nodes.has(r))throw new U(`Graph.addNode: the "${r}" node already exist in the graph.`);const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function er(n,r,t){const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function Zr(n,r,t,e,i,o,a,s){if(!e&&n.type==="undirected")throw new U(`Graph.${r}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(e&&n.type==="directed")throw new U(`Graph.${r}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!ae(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!n.allowSelfLoops&&o===a)throw new U(`Graph.${r}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=n._nodes.get(o),l=n._nodes.get(a);if(!u)throw new A(`Graph.${r}: source node "${o}" not found.`);if(!l)throw new A(`Graph.${r}: target node "${a}" not found.`);const h={key:null,undirected:e,source:o,target:a,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new U(`Graph.${r}: the "${i}" edge already exists in the graph.`);if(!n.multi&&(e?typeof u.undirected[a]<"u":typeof u.out[a]<"u"))throw new U(`Graph.${r}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new qe(e,i,u,l,s);n._edges.set(i,d);const c=o===a;return e?(u.undirectedDegree++,l.undirectedDegree++,c&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,c&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?d.attachMulti():d.attach(),e?n._undirectedSize++:n._directedSize++,h.key=i,n.emit("edgeAdded",h),i}function Bn(n,r,t,e,i,o,a,s,u){if(!e&&n.type==="undirected")throw new U(`Graph.${r}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(e&&n.type==="directed")throw new U(`Graph.${r}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(u){if(typeof s!="function")throw new D(`Graph.${r}: invalid updater function. Expecting a function but got "${s}"`)}else if(!ae(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let l;if(u&&(l=s,s=void 0),!n.allowSelfLoops&&o===a)throw new U(`Graph.${r}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let h=n._nodes.get(o),d=n._nodes.get(a),c,f;if(!t&&(c=n._edges.get(i),c)){if((c.source.key!==o||c.target.key!==a)&&(!e||c.source.key!==a||c.target.key!==o))throw new U(`Graph.${r}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${c.source.key}", "${c.target.key}").`);f=c}if(!f&&!n.multi&&h&&(f=e?h.undirected[a]:h.out[a]),f){const _=[f.key,!1,!1,!1];if(u?!l:!s)return _;if(u){const R=f.attributes;f.attributes=l(R),n.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else te(f.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return _}s=s||{},u&&l&&(s=l(s));const b={key:null,undirected:e,source:o,target:a,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new U(`Graph.${r}: the "${i}" edge already exists in the graph.`);let w=!1,E=!1;h||(h=er(n,o,{}),w=!0,o===a&&(d=h,E=!0)),d||(d=er(n,a,{}),E=!0),c=new qe(e,i,h,d,s),n._edges.set(i,c);const L=o===a;return e?(h.undirectedDegree++,d.undirectedDegree++,L&&(h.undirectedLoops++,n._undirectedSelfLoopCount++)):(h.outDegree++,d.inDegree++,L&&(h.directedLoops++,n._directedSelfLoopCount++)),n.multi?c.attachMulti():c.attach(),e?n._undirectedSize++:n._directedSize++,b.key=i,n.emit("edgeAdded",b),[i,!0,w,E]}function Me(n,r){n._edges.delete(r.key);const{source:t,target:e,attributes:i}=r,o=r.undirected,a=t===e;o?(t.undirectedDegree--,e.undirectedDegree--,a&&(t.undirectedLoops--,n._undirectedSelfLoopCount--)):(t.outDegree--,e.inDegree--,a&&(t.directedLoops--,n._directedSelfLoopCount--)),n.multi?r.detachMulti():r.detach(),o?n._undirectedSize--:n._directedSize--,n.emit("edgeDropped",{key:r.key,attributes:i,source:t.key,target:e.key,undirected:o})}class X extends jr.EventEmitter{constructor(r){if(super(),r=te({},jn,r),typeof r.multi!="boolean")throw new D(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${r.multi}".`);if(!$n.has(r.type))throw new D(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${r.type}".`);if(typeof r.allowSelfLoops!="boolean")throw new D(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${r.allowSelfLoops}".`);const t=r.type==="mixed"?Br:r.type==="directed"?Hr:Wr;de(this,"NodeDataClass",t);const e="geid_"+zn()+"_";let i=0;const o=()=>{let a;do a=e+i++;while(this._edges.has(a));return a};de(this,"_attributes",{}),de(this,"_nodes",new Map),de(this,"_edges",new Map),de(this,"_directedSize",0),de(this,"_undirectedSize",0),de(this,"_directedSelfLoopCount",0),de(this,"_undirectedSelfLoopCount",0),de(this,"_edgeKeyGenerator",o),de(this,"_options",r),Jt.forEach(a=>de(this,a,this[a])),ve(this,"order",()=>this._nodes.size),ve(this,"size",()=>this._edges.size),ve(this,"directedSize",()=>this._directedSize),ve(this,"undirectedSize",()=>this._undirectedSize),ve(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ve(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ve(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ve(this,"multi",this._options.multi),ve(this,"type",this._options.type),ve(this,"allowSelfLoops",this._options.allowSelfLoops),ve(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(r){return this._nodes.has(""+r)}hasDirectedEdge(r,t){if(this.type==="undirected")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&!i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.out.hasOwnProperty(t):!1}throw new D(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(r,t){if(this.type==="directed")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.undirected.hasOwnProperty(t):!1}throw new D(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(r,t){if(arguments.length===1){const e=""+r;return this._edges.has(e)}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?typeof e.out<"u"&&e.out.hasOwnProperty(t)||typeof e.undirected<"u"&&e.undirected.hasOwnProperty(t):!1}throw new D(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(r,t){if(this.type==="undirected")return;if(r=""+r,t=""+t,this.multi)throw new U("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const e=this._nodes.get(r);if(!e)throw new A(`Graph.directedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||void 0;if(i)return i.key}undirectedEdge(r,t){if(this.type==="directed")return;if(r=""+r,t=""+t,this.multi)throw new U("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const e=this._nodes.get(r);if(!e)throw new A(`Graph.undirectedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=e.undirected&&e.undirected[t]||void 0;if(i)return i.key}edge(r,t){if(this.multi)throw new U("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.edge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||e.undirected&&e.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areDirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in||t in e.out}areOutNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.out}areInNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in}areUndirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areUndirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="directed"?!1:t in e.undirected}areNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&(t in e.in||t in e.out)||this.type!=="directed"&&t in e.undirected}areInboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.in||this.type!=="directed"&&t in e.undirected}areOutboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.out||this.type!=="directed"&&t in e.undirected}inDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegree: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree),e}outboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.outDegree),e}degree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree),e}inDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree,i+=t.directedLoops),e-i}outboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.outDegree,i+=t.directedLoops),e-i}degreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree,i+=t.directedLoops*2),e-i}source(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.source: could not find the "${r}" edge in the graph.`);return t.source.key}target(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.target: could not find the "${r}" edge in the graph.`);return t.target.key}extremities(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.extremities: could not find the "${r}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(r,t){r=""+r,t=""+t;const e=this._edges.get(t);if(!e)throw new A(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=e.source.key,o=e.target.key;if(r===i)return o;if(r===o)return i;throw new A(`Graph.opposite: the "${r}" node is not attached to the "${t}" edge (${i}, ${o}).`)}hasExtremity(r,t){r=""+r,t=""+t;const e=this._edges.get(r);if(!e)throw new A(`Graph.hasExtremity: could not find the "${r}" edge in the graph.`);return e.source.key===t||e.target.key===t}isUndirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isUndirected: could not find the "${r}" edge in the graph.`);return t.undirected}isDirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isDirected: could not find the "${r}" edge in the graph.`);return!t.undirected}isSelfLoop(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isSelfLoop: could not find the "${r}" edge in the graph.`);return t.source===t.target}addNode(r,t){return Mn(this,r,t).key}mergeNode(r,t){if(t&&!ae(t))throw new D(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);r=""+r,t=t||{};let e=this._nodes.get(r);return e?(t&&(te(e.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:r,attributes:e.attributes,data:t})),[r,!1]):(e=new this.NodeDataClass(r,t),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:t}),[r,!0])}updateNode(r,t){if(t&&typeof t!="function")throw new D(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);r=""+r;let e=this._nodes.get(r);if(e){if(t){const o=e.attributes;e.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:r,attributes:e.attributes})}return[r,!1]}const i=t?t({}):{};return e=new this.NodeDataClass(r,i),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:i}),[r,!0]}dropNode(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.dropNode: could not find the "${r}" node in the graph.`);let e;if(this.type!=="undirected"){for(const i in t.out){e=t.out[i];do Me(this,e),e=e.next;while(e)}for(const i in t.in){e=t.in[i];do Me(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const i in t.undirected){e=t.undirected[i];do Me(this,e),e=e.next;while(e)}this._nodes.delete(r),this.emit("nodeDropped",{key:r,attributes:t.attributes})}dropEdge(r){let t;if(arguments.length>1){const e=""+arguments[0],i=""+arguments[1];if(t=fe(this,e,i,this.type),!t)throw new A(`Graph.dropEdge: could not find the "${e}" -> "${i}" edge in the graph.`)}else if(r=""+r,t=this._edges.get(r),!t)throw new A(`Graph.dropEdge: could not find the "${r}" edge in the graph.`);return Me(this,t),this}dropDirectedEdge(r,t){if(arguments.length<2)throw new U("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new U("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");r=""+r,t=""+t;const e=fe(this,r,t,"directed");if(!e)throw new A(`Graph.dropDirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Me(this,e),this}dropUndirectedEdge(r,t){if(arguments.length<2)throw new U("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new U("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const e=fe(this,r,t,"undirected");if(!e)throw new A(`Graph.dropUndirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Me(this,e),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const r=this._nodes.values();let t;for(;t=r.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(r){return this._attributes[r]}getAttributes(){return this._attributes}hasAttribute(r){return this._attributes.hasOwnProperty(r)}setAttribute(r,t){return this._attributes[r]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}updateAttribute(r,t){if(typeof t!="function")throw new D("Graph.updateAttribute: updater should be a function.");const e=this._attributes[r];return this._attributes[r]=t(e),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}removeAttribute(r){return delete this._attributes[r],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:r}),this}replaceAttributes(r){if(!ae(r))throw new D("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=r,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(r){if(!ae(r))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return te(this._attributes,r),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:r}),this}updateAttributes(r){if(typeof r!="function")throw new D("Graph.updateAttributes: provided updater is not a function.");return this._attributes=r(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(r,t){if(typeof r!="function")throw new D("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new D("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._nodes.values();let i,o;for(;i=e.next(),i.done!==!0;)o=i.value,o.attributes=r(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(r,t){if(typeof r!="function")throw new D("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new D("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._edges.values();let i,o,a,s;for(;i=e.next(),i.done!==!0;)o=i.value,a=o.source,s=o.target,o.attributes=r(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntry: expecting a callback.");ut(!1,!1,!1,this,r)}forEachAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!1,!0,this,r)}forEachAssymetricAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ut(!1,!0,!1,this,r)}forEachAssymetricAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!0,!0,this,r)}nodes(){return Array.from(this._nodes.keys())}forEachNode(r){if(typeof r!="function")throw new D("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)}findNode(r){if(typeof r!="function")throw new D("Graph.findNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,r(i.key,i.attributes))return i.key}mapNodes(r){if(typeof r!="function")throw new D("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let e,i;const o=new Array(this.order);let a=0;for(;e=t.next(),e.done!==!0;)i=e.value,o[a++]=r(i.key,i.attributes);return o}someNode(r){if(typeof r!="function")throw new D("Graph.someNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,r(i.key,i.attributes))return!0;return!1}everyNode(r){if(typeof r!="function")throw new D("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,!r(i.key,i.attributes))return!1;return!0}filterNodes(r){if(typeof r!="function")throw new D("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let e,i;const o=[];for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(r,t){if(typeof r!="function")throw new D("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new D("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let e=t;const i=this._nodes.values();let o,a;for(;o=i.next(),o.done!==!0;)a=o.value,e=r(e,a.key,a.attributes);return e}nodeEntries(){const r=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=r.next();if(t.done)return t;const e=t.value;return{value:{node:e.key,attributes:e.attributes},done:!1}}}}export(){const r=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,o)=>{r[t++]=Fn(o,i)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((i,o)=>{e[t++]=Pn(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:r,edges:e}}import(r,t=!1){if(r instanceof X)return r.forEachNode((u,l)=>{t?this.mergeNode(u,l):this.addNode(u,l)}),r.forEachEdge((u,l,h,d,c,f,b)=>{t?b?this.mergeUndirectedEdgeWithKey(u,h,d,l):this.mergeDirectedEdgeWithKey(u,h,d,l):b?this.addUndirectedEdgeWithKey(u,h,d,l):this.addDirectedEdgeWithKey(u,h,d,l)}),this;if(!ae(r))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!ae(r.attributes))throw new D("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(r.attributes):this.replaceAttributes(r.attributes)}let e,i,o,a,s;if(r.nodes){if(o=r.nodes,!Array.isArray(o))throw new D("Graph.import: invalid nodes. Expecting an array.");for(e=0,i=o.length;e<i;e++){a=o[e],In(a);const{key:u,attributes:l}=a;t?this.mergeNode(u,l):this.addNode(u,l)}}if(r.edges){let u=!1;if(this.type==="undirected"&&(u=!0),o=r.edges,!Array.isArray(o))throw new D("Graph.import: invalid edges. Expecting an array.");for(e=0,i=o.length;e<i;e++){s=o[e],On(s);const{source:l,target:h,attributes:d,undirected:c=u}=s;let f;"key"in s?(f=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,l,h,d)):(f=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,l,h,d))}}return this}nullCopy(r){const t=new X(te({},this._options,r));return t.replaceAttributes(te({},this.getAttributes())),t}emptyCopy(r){const t=this.nullCopy(r);return this._nodes.forEach((e,i)=>{const o=te({},e.attributes);e=new t.NodeDataClass(i,o),t._nodes.set(i,e)}),t}copy(r){if(r=r||{},typeof r.type=="string"&&r.type!==this.type&&r.type!=="mixed")throw new U(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${r.type}" because this would mean losing information about the current graph.`);if(typeof r.multi=="boolean"&&r.multi!==this.multi&&r.multi!==!0)throw new U("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof r.allowSelfLoops=="boolean"&&r.allowSelfLoops!==this.allowSelfLoops&&r.allowSelfLoops!==!0)throw new U("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(r),e=this._edges.values();let i,o;for(;i=e.next(),i.done!==!0;)o=i.value,Zr(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,te({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const r={};this._nodes.forEach((o,a)=>{r[a]=o.attributes});const t={},e={};this._edges.forEach((o,a)=>{const s=o.undirected?"--":"->";let u="",l=o.source.key,h=o.target.key,d;o.undirected&&l>h&&(d=l,l=h,h=d);const c=`(${l})${s}(${h})`;a.startsWith("geid_")?this.multi&&(typeof e[c]>"u"?e[c]=0:e[c]++,u+=`${e[c]}. `):u+=`[${a}]: `,u+=c,t[u]=o.attributes});const i={};for(const o in this)this.hasOwnProperty(o)&&!Jt.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=r,i.edges=t,de(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(X.prototype[Symbol.for("nodejs.util.inspect.custom")]=X.prototype.inspect);Un.forEach(n=>{["add","merge","update"].forEach(r=>{const t=n.name(r),e=r==="add"?Zr:Bn;n.generateKey?X.prototype[t]=function(i,o,a){return e(this,t,!0,(n.type||this.type)==="undirected",null,i,o,a,r==="update")}:X.prototype[t]=function(i,o,a,s){return e(this,t,!1,(n.type||this.type)==="undirected",i,o,a,s,r==="update")}})});Xi(X);ln(X);Sn(X);Nn(X);class Xr extends X{constructor(r){const t=te({type:"directed"},r);if("multi"in t&&t.multi!==!1)throw new D("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new D('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Qr extends X{constructor(r){const t=te({type:"undirected"},r);if("multi"in t&&t.multi!==!1)throw new D("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new D('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Jr extends X{constructor(r){const t=te({multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class ei extends X{constructor(r){const t=te({type:"directed",multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new D('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class ti extends X{constructor(r){const t=te({type:"undirected",multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new D('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Ke(n){n.from=function(r,t){const e=te({},r.options,t),i=new n(e);return i.import(r),i}}Ke(X);Ke(Xr);Ke(Qr);Ke(Jr);Ke(ei);Ke(ti);X.Graph=X;X.DirectedGraph=Xr;X.UndirectedGraph=Qr;X.MultiGraph=Jr;X.MultiDirectedGraph=ei;X.MultiUndirectedGraph=ti;X.InvalidArgumentsGraphError=D;X.NotFoundGraphError=A;X.UsageGraphError=U;function Hn(n,r){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var e=t.call(n,r);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function it(n){var r=Hn(n,"string");return typeof r=="symbol"?r:r+""}function re(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}function tr(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,it(e.key),e)}}function ie(n,r,t){return r&&tr(n.prototype,r),t&&tr(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function He(n){return He=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},He(n)}function ri(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ri=function(){return!!n})()}function Wn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Vn(n,r){if(r&&(typeof r=="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wn(n)}function le(n,r,t){return r=He(r),Vn(n,ri()?Reflect.construct(r,t||[],He(n).constructor):r.apply(n,t))}function It(n,r){return It=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},It(n,r)}function he(n,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(r&&r.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),r&&It(n,r)}function qn(n){if(Array.isArray(n))return n}function Kn(n,r){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var e,i,o,a,s=[],u=!0,l=!1;try{if(o=(t=t.call(n)).next,r===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(e=o.call(t)).done)&&(s.push(e.value),s.length!==r);u=!0);}catch(h){l=!0,i=h}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw i}}return s}}function Ot(n,r){(r==null||r>n.length)&&(r=n.length);for(var t=0,e=Array(r);t<r;t++)e[t]=n[t];return e}function ii(n,r){if(n){if(typeof n=="string")return Ot(n,r);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ot(n,r):void 0}}function Yn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function We(n,r){return qn(n)||Kn(n,r)||ii(n,r)||Yn()}var Ct={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},ni=new Int8Array(4),St=new Int32Array(ni.buffer,0,1),Zn=new Float32Array(ni.buffer,0,1),Xn=/^\s*rgba?\s*\(/,Qn=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Jn(n){var r=0,t=0,e=0,i=1;if(n[0]==="#")n.length===4?(r=parseInt(n.charAt(1)+n.charAt(1),16),t=parseInt(n.charAt(2)+n.charAt(2),16),e=parseInt(n.charAt(3)+n.charAt(3),16)):(r=parseInt(n.charAt(1)+n.charAt(2),16),t=parseInt(n.charAt(3)+n.charAt(4),16),e=parseInt(n.charAt(5)+n.charAt(6),16)),n.length===9&&(i=parseInt(n.charAt(7)+n.charAt(8),16)/255);else if(Xn.test(n)){var o=n.match(Qn);o&&(r=+o[1],t=+o[2],e=+o[3],o[4]&&(i=+o[4]))}return{r,g:t,b:e,a:i}}var Be={};for(var lt in Ct)Be[lt]=$e(Ct[lt]),Be[Ct[lt]]=Be[lt];function oi(n,r,t,e,i){return St[0]=e<<24|t<<16|r<<8|n,St[0]=St[0]&4278190079,Zn[0]}function $e(n){if(n=n.toLowerCase(),typeof Be[n]<"u")return Be[n];var r=Jn(n),t=r.r,e=r.g,i=r.b,o=r.a;o=o*255|0;var a=oi(t,e,i,o);return Be[n]=a,a}var Tt={};function ai(n){if(typeof Tt[n]<"u")return Tt[n];var r=(n&16711680)>>>16,t=(n&65280)>>>8,e=n&255,i=255,o=oi(r,t,e,i);return Tt[n]=o,o}function rr(n,r,t,e){return t+(r<<8)+(n<<16)}function ir(n,r,t,e,i,o){var a=Math.floor(t/o*i),s=Math.floor(n.drawingBufferHeight/o-e/o*i),u=new Uint8Array(4);n.bindFramebuffer(n.FRAMEBUFFER,r),n.readPixels(a,s,1,1,n.RGBA,n.UNSIGNED_BYTE,u);var l=We(u,4),h=l[0],d=l[1],c=l[2],f=l[3];return[h,d,c,f]}function T(n,r,t){return(r=it(r))in n?Object.defineProperty(n,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[r]=t,n}function nr(n,r){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(n);r&&(e=e.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,e)}return t}function F(n){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?nr(Object(t),!0).forEach(function(e){T(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):nr(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function eo(n,r){for(;!{}.hasOwnProperty.call(n,r)&&(n=He(n))!==null;);return n}function zt(){return zt=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,r,t){var e=eo(n,r);if(e){var i=Object.getOwnPropertyDescriptor(e,r);return i.get?i.get.call(arguments.length<3?n:t):i.value}},zt.apply(null,arguments)}function si(n,r,t,e){var i=zt(He(n.prototype),r,t);return typeof i=="function"?function(o){return i.apply(t,o)}:i}function to(n){return n.normalized?1:n.size}function Rt(n){var r=0;return n.forEach(function(t){return r+=to(t)}),r}function ui(n,r,t){var e=n==="VERTEX"?r.VERTEX_SHADER:r.FRAGMENT_SHADER,i=r.createShader(e);if(i===null)throw new Error("loadShader: error while creating the shader");r.shaderSource(i,t),r.compileShader(i);var o=r.getShaderParameter(i,r.COMPILE_STATUS);if(!o){var a=r.getShaderInfoLog(i);throw r.deleteShader(i),new Error(`loadShader: error while compiling the shader:
3
+ `.concat(a,`
4
+ `).concat(t))}return i}function ro(n,r){return ui("VERTEX",n,r)}function io(n,r){return ui("FRAGMENT",n,r)}function no(n,r){var t=n.createProgram();if(t===null)throw new Error("loadProgram: error while creating the program.");var e,i;for(e=0,i=r.length;e<i;e++)n.attachShader(t,r[e]);n.linkProgram(t);var o=n.getProgramParameter(t,n.LINK_STATUS);if(!o)throw n.deleteProgram(t),new Error("loadProgram: error while linking the program.");return t}function or(n){var r=n.gl,t=n.buffer,e=n.program,i=n.vertexShader,o=n.fragmentShader;r.deleteShader(i),r.deleteShader(o),r.deleteProgram(e),r.deleteBuffer(t)}var ar=`#define PICKING_MODE
5
+ `,oo=T(T(T(T(T(T(T(T({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),li=(function(){function n(r,t,e){re(this,n),T(this,"array",new Float32Array),T(this,"constantArray",new Float32Array),T(this,"capacity",0),T(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=Rt(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=e,this.normalProgram=this.getProgramInfo("normal",r,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=t?this.getProgramInfo("pick",r,ar+i.VERTEX_SHADER_SOURCE,ar+i.FRAGMENT_SHADER_SOURCE,t):null,this.isInstanced){var o=Rt(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*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 ie(n,[{key:"kill",value:function(){or(this.normalProgram),this.pickProgram&&(or(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(t,e,i,o,a){var s=this.getDefinition(),u=e.createBuffer();if(u===null)throw new Error("Program: error while creating the WebGL buffer.");var l=ro(e,i),h=io(e,o),d=no(e,[l,h]),c={};s.UNIFORMS.forEach(function(w){var E=e.getUniformLocation(d,w);E&&(c[w]=E)});var f={};s.ATTRIBUTES.forEach(function(w){f[w.name]=e.getAttribLocation(d,w.name)});var b;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(w){f[w.name]=e.getAttribLocation(d,w.name)}),b=e.createBuffer(),b===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:t,program:d,gl:e,frameBuffer:a,buffer:u,constantBuffer:b||{},uniformLocations:c,attributeLocations:f,isPicking:t==="pick",vertexShader:l,fragmentShader:h}}},{key:"bindProgram",value:function(t){var e=this,i=0,o=t.gl,a=t.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,t.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return i+=e.bindAttribute(s,t,i,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,t.buffer),i=0,this.ATTRIBUTES.forEach(function(s){return i+=e.bindAttribute(s,t,i,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),i=0,this.ATTRIBUTES.forEach(function(s){return i+=e.bindAttribute(s,t,i)}),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(i){return e.unbindAttribute(i,t,!1)}),this.ATTRIBUTES.forEach(function(i){return e.unbindAttribute(i,t,!0)})):this.ATTRIBUTES.forEach(function(i){return e.unbindAttribute(i,t)})}},{key:"bindAttribute",value:function(t,e,i,o){var a=oo[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 l=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:Rt(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(u.vertexAttribPointer(s,t.size,t.type,t.normalized||!1,l,i),this.isInstanced&&o)if(u instanceof WebGL2RenderingContext)u.vertexAttribDivisor(s,1);else{var h=u.getExtension("ANGLE_instanced_arrays");h&&h.vertexAttribDivisorANGLE(s,1)}}return t.size*a}},{key:"unbindAttribute",value:function(t,e,i){var o=e.attributeLocations[t.name],a=e.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&i))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 i=e.gl,o=e.program;i.enable(i.BLEND),i.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(F(F({},t),{},{pixelRatio:t.pixelRatio/t.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,t.width*t.pixelRatio,t.height*t.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(t,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(t,e){var i=e.gl,o=e.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,o),!this.isInstanced)i.drawArrays(t,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(t,0,this.VERTICES,this.capacity);else{var a=i.getExtension("ANGLE_instanced_arrays");a&&a.drawArraysInstancedANGLE(t,0,this.VERTICES,this.capacity)}}}])})(),ao=(function(n){function r(){return re(this,r),le(this,r,arguments)}return he(r,n),ie(r,[{key:"kill",value:function(){si(r,"kill",this)([])}},{key:"process",value:function(e,i,o){var a=i*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(ai(e),a,o)}}])})(li),nt=(function(n){function r(){var t;re(this,r);for(var e=arguments.length,i=new Array(e),o=0;o<e;o++)i[o]=arguments[o];return t=le(this,r,[].concat(i)),T(t,"drawLabel",void 0),t}return he(r,n),ie(r,[{key:"kill",value:function(){si(r,"kill",this)([])}},{key:"process",value:function(e,i,o,a,s){var u=i*this.STRIDE;if(s.hidden||o.hidden||a.hidden){for(var l=u+this.STRIDE;u<l;u++)this.array[u]=0;return}return this.processVisibleItem(ai(e),u,o,a,s)}}])})(li);function hi(n,r){return(function(){function t(e,i,o){re(this,t),T(this,"drawLabel",r),this.programs=n.map(function(a){return new a(e,i,o)})}return ie(t,[{key:"reallocate",value:function(i){this.programs.forEach(function(o){return o.reallocate(i)})}},{key:"process",value:function(i,o,a,s,u){this.programs.forEach(function(l){return l.process(i,o,a,s,u)})}},{key:"render",value:function(i){this.programs.forEach(function(o){return o.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function so(n,r,t,e,i){var o=i.edgeLabelSize,a=i.edgeLabelFont,s=i.edgeLabelWeight,u=i.edgeLabelColor.attribute?r[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,l=r.label;if(l){n.fillStyle=u,n.font="".concat(s," ").concat(o,"px ").concat(a);var h=t.size,d=e.size,c=t.x,f=t.y,b=e.x,w=e.y,E=(c+b)/2,L=(f+w)/2,_=b-c,R=w-f,m=Math.sqrt(_*_+R*R);if(!(m<h+d)){c+=_*h/m,f+=R*h/m,b-=_*d/m,w-=R*d/m,E=(c+b)/2,L=(f+w)/2,_=b-c,R=w-f,m=Math.sqrt(_*_+R*R);var y=n.measureText(l).width;if(y>m){var S="…";for(l=l+S,y=n.measureText(l).width;y>m&&l.length>1;)l=l.slice(0,-2)+S,y=n.measureText(l).width;if(l.length<4)return}var C;_>0?R>0?C=Math.acos(_/m):C=Math.asin(R/m):R>0?C=Math.acos(_/m)+Math.PI:C=Math.asin(_/m)+Math.PI/2,n.save(),n.translate(E,L),n.rotate(C),n.fillText(l,-y/2,r.size/2+o),n.restore()}}}function di(n,r,t){if(r.label){var e=t.labelSize,i=t.labelFont,o=t.labelWeight,a=t.labelColor.attribute?r[t.labelColor.attribute]||t.labelColor.color||"#000":t.labelColor.color;n.fillStyle=a,n.font="".concat(o," ").concat(e,"px ").concat(i),n.fillText(r.label,r.x+r.size+3,r.y+e/3)}}function uo(n,r,t){var e=t.labelSize,i=t.labelFont,o=t.labelWeight;n.font="".concat(o," ").concat(e,"px ").concat(i),n.fillStyle="#FFF",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=8,n.shadowColor="#000";var a=2;if(typeof r.label=="string"){var s=n.measureText(r.label).width,u=Math.round(s+5),l=Math.round(e+2*a),h=Math.max(r.size,e/2)+a,d=Math.asin(l/2/h),c=Math.sqrt(Math.abs(Math.pow(h,2)-Math.pow(l/2,2)));n.beginPath(),n.moveTo(r.x+c,r.y+l/2),n.lineTo(r.x+h+u,r.y+l/2),n.lineTo(r.x+h+u,r.y-l/2),n.lineTo(r.x+c,r.y-l/2),n.arc(r.x,r.y,h,d,-d),n.closePath(),n.fill()}else n.beginPath(),n.arc(r.x,r.y,r.size+a,0,Math.PI*2),n.closePath(),n.fill();n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,di(n,r,t)}var lo=`
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
+ `,ho=lo,co=`
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
+ `,fo=co,ci=WebGLRenderingContext,sr=ci.UNSIGNED_BYTE,kt=ci.FLOAT,go=["u_sizeRatio","u_correctionRatio","u_matrix"],vt=(function(n){function r(){return re(this,r),le(this,r,arguments)}return he(r,n),ie(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:fo,FRAGMENT_SHADER_SOURCE:ho,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:go,ATTRIBUTES:[{name:"a_position",size:2,type:kt},{name:"a_size",size:1,type:kt},{name:"a_color",size:4,type:sr,normalized:!0},{name:"a_id",size:4,type:sr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:kt}],CONSTANT_DATA:[[r.ANGLE_1],[r.ANGLE_2],[r.ANGLE_3]]}}},{key:"processVisibleItem",value:function(e,i,o){var a=this.array,s=$e(o.color);a[i++]=o.x,a[i++]=o.y,a[i++]=o.size,a[i++]=s,a[i++]=e}},{key:"setUniforms",value:function(e,i){var o=i.gl,a=i.uniformLocations,s=a.u_sizeRatio,u=a.u_correctionRatio,l=a.u_matrix;o.uniform1f(u,e.correctionRatio),o.uniform1f(s,e.sizeRatio),o.uniformMatrix3fv(l,!1,e.matrix)}}])})(ao);T(vt,"ANGLE_1",0);T(vt,"ANGLE_2",2*Math.PI/3);T(vt,"ANGLE_3",4*Math.PI/3);var po=`
79
+ precision mediump float;
80
+
81
+ varying vec4 v_color;
82
+
83
+ void main(void) {
84
+ gl_FragColor = v_color;
85
+ }
86
+ `,mo=po,vo=`
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
+ `,yo=vo,fi=WebGLRenderingContext,ur=fi.UNSIGNED_BYTE,ht=fi.FLOAT,bo=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],qt={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function gt(n){var r=F(F({},qt),n||{});return(function(t){function e(){return re(this,e),le(this,e,arguments)}return he(e,t),ie(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:yo,FRAGMENT_SHADER_SOURCE:mo,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:bo,ATTRIBUTES:[{name:"a_position",size:2,type:ht},{name:"a_normal",size:2,type:ht},{name:"a_radius",size:1,type:ht},{name:"a_color",size:4,type:ur,normalized:!0},{name:"a_id",size:4,type:ur,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:ht}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,u,l){if(r.extremity==="source"){var h=[u,s];s=h[0],u=h[1]}var d=l.size||1,c=u.size||1,f=s.x,b=s.y,w=u.x,E=u.y,L=$e(l.color),_=w-f,R=E-b,m=_*_+R*R,y=0,S=0;m&&(m=1/Math.sqrt(m),y=-R*m*d,S=_*m*d);var C=this.array;C[a++]=w,C[a++]=E,C[a++]=-y,C[a++]=-S,C[a++]=c,C[a++]=L,C[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,l=u.u_matrix,h=u.u_sizeRatio,d=u.u_correctionRatio,c=u.u_minEdgeThickness,f=u.u_lengthToThicknessRatio,b=u.u_widenessToThicknessRatio;s.uniformMatrix3fv(l,!1,o.matrix),s.uniform1f(h,o.sizeRatio),s.uniform1f(d,o.correctionRatio),s.uniform1f(c,o.minEdgeThickness),s.uniform1f(f,r.lengthToThicknessRatio),s.uniform1f(b,r.widenessToThicknessRatio)}}])})(nt)}gt();var wo=`
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
+ `,Kt=wo,Eo=`
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
+ `,xo=Eo,gi=WebGLRenderingContext,lr=gi.UNSIGNED_BYTE,ze=gi.FLOAT,_o=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Co={lengthToThicknessRatio:qt.lengthToThicknessRatio};function pi(n){var r=F(F({},Co),{});return(function(t){function e(){return re(this,e),le(this,e,arguments)}return he(e,t),ie(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:xo,FRAGMENT_SHADER_SOURCE:Kt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:_o,ATTRIBUTES:[{name:"a_positionStart",size:2,type:ze},{name:"a_positionEnd",size:2,type:ze},{name:"a_normal",size:2,type:ze},{name:"a_color",size:4,type:lr,normalized:!0},{name:"a_id",size:4,type:lr,normalized:!0},{name:"a_radius",size:1,type:ze}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:ze},{name:"a_normalCoef",size:1,type:ze},{name:"a_radiusCoef",size:1,type:ze}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,u,l){var h=l.size||1,d=s.x,c=s.y,f=u.x,b=u.y,w=$e(l.color),E=f-d,L=b-c,_=u.size||1,R=E*E+L*L,m=0,y=0;R&&(R=1/Math.sqrt(R),m=-L*R*h,y=E*R*h);var S=this.array;S[a++]=d,S[a++]=c,S[a++]=f,S[a++]=b,S[a++]=m,S[a++]=y,S[a++]=w,S[a++]=o,S[a++]=_}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,l=u.u_matrix,h=u.u_zoomRatio,d=u.u_feather,c=u.u_pixelRatio,f=u.u_correctionRatio,b=u.u_sizeRatio,w=u.u_minEdgeThickness,E=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(l,!1,o.matrix),s.uniform1f(h,o.zoomRatio),s.uniform1f(b,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(c,o.pixelRatio),s.uniform1f(d,o.antiAliasingFeather),s.uniform1f(w,o.minEdgeThickness),s.uniform1f(E,r.lengthToThicknessRatio)}}])})(nt)}pi();function So(n){return hi([pi(),gt(n)])}var To=So(),mi=To,Ro=`
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
+ `,ko=Ro,vi=WebGLRenderingContext,hr=vi.UNSIGNED_BYTE,Qe=vi.FLOAT,Ao=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Lo=(function(n){function r(){return re(this,r),le(this,r,arguments)}return he(r,n),ie(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:ko,FRAGMENT_SHADER_SOURCE:Kt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ao,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Qe},{name:"a_positionEnd",size:2,type:Qe},{name:"a_normal",size:2,type:Qe},{name:"a_color",size:4,type:hr,normalized:!0},{name:"a_id",size:4,type:hr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Qe},{name:"a_normalCoef",size:1,type:Qe}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(e,i,o,a,s){var u=s.size||1,l=o.x,h=o.y,d=a.x,c=a.y,f=$e(s.color),b=d-l,w=c-h,E=b*b+w*w,L=0,_=0;E&&(E=1/Math.sqrt(E),L=-w*E*u,_=b*E*u);var R=this.array;R[i++]=l,R[i++]=h,R[i++]=d,R[i++]=c,R[i++]=L,R[i++]=_,R[i++]=f,R[i++]=e}},{key:"setUniforms",value:function(e,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,u=a.u_zoomRatio,l=a.u_feather,h=a.u_pixelRatio,d=a.u_correctionRatio,c=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,e.matrix),o.uniform1f(u,e.zoomRatio),o.uniform1f(c,e.sizeRatio),o.uniform1f(d,e.correctionRatio),o.uniform1f(h,e.pixelRatio),o.uniform1f(l,e.antiAliasingFeather),o.uniform1f(f,e.minEdgeThickness)}}])})(nt),Yt=(function(n){function r(){var t;return re(this,r),t=le(this,r),t.rawEmitter=t,t}return he(r,n),ie(r)})(jr.EventEmitter),At,dr;function yi(){return dr||(dr=1,At=function(r){return r!==null&&typeof r=="object"&&typeof r.addUndirectedEdgeWithKey=="function"&&typeof r.dropNode=="function"&&typeof r.multi=="boolean"}),At}var Do=yi();const Go=$r(Do);var No=function(r){return r},Fo=function(r){return r*r},Po=function(r){return r*(2-r)},Io=function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)},Oo=function(r){return r*r*r},zo=function(r){return--r*r*r+1},$o=function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)},Uo={linear:No,quadraticIn:Fo,quadraticOut:Po,quadraticInOut:Io,cubicIn:Oo,cubicOut:zo,cubicInOut:$o},jo={easing:"quadraticInOut",duration:150};function ye(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function dt(n,r,t){return n[0]=r,n[4]=typeof t=="number"?t:r,n}function cr(n,r){var t=Math.sin(r),e=Math.cos(r);return n[0]=e,n[1]=t,n[3]=-t,n[4]=e,n}function fr(n,r,t){return n[6]=r,n[7]=t,n}function Pe(n,r){var t=n[0],e=n[1],i=n[2],o=n[3],a=n[4],s=n[5],u=n[6],l=n[7],h=n[8],d=r[0],c=r[1],f=r[2],b=r[3],w=r[4],E=r[5],L=r[6],_=r[7],R=r[8];return n[0]=d*t+c*o+f*u,n[1]=d*e+c*a+f*l,n[2]=d*i+c*s+f*h,n[3]=b*t+w*o+E*u,n[4]=b*e+w*a+E*l,n[5]=b*i+w*s+E*h,n[6]=L*t+_*o+R*u,n[7]=L*e+_*a+R*l,n[8]=L*i+_*s+R*h,n}function $t(n,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,e=n[0],i=n[1],o=n[3],a=n[4],s=n[6],u=n[7],l=r.x,h=r.y;return{x:l*e+h*o+s*t,y:l*i+h*a+u*t}}function Mo(n,r){var t=n.height/n.width,e=r.height/r.width;return t<1&&e>1||t>1&&e<1?1:Math.min(Math.max(e,1/e),Math.max(1/t,t))}function Je(n,r,t,e,i){var o=n.angle,a=n.ratio,s=n.x,u=n.y,l=r.width,h=r.height,d=ye(),c=Math.min(l,h)-2*e,f=Mo(r,t);return i?(Pe(d,fr(ye(),s,u)),Pe(d,dt(ye(),a)),Pe(d,cr(ye(),o)),Pe(d,dt(ye(),l/c/2/f,h/c/2/f))):(Pe(d,dt(ye(),2*(c/l)*f,2*(c/h)*f)),Pe(d,cr(ye(),-o)),Pe(d,dt(ye(),1/a)),Pe(d,fr(ye(),-s,-u))),d}function Bo(n,r,t){var e=$t(n,{x:Math.cos(r.angle),y:Math.sin(r.angle)},0),i=e.x,o=e.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/t.width}function Ho(n){if(!n.order)return{x:[0,1],y:[0,1]};var r=1/0,t=-1/0,e=1/0,i=-1/0;return n.forEachNode(function(o,a){var s=a.x,u=a.y;s<r&&(r=s),s>t&&(t=s),u<e&&(e=u),u>i&&(i=u)}),{x:[r,t],y:[e,i]}}function Wo(n){if(!Go(n))throw new Error("Sigma: invalid graph instance.");n.forEachNode(function(r,t){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new Error("Sigma: Coordinates of node ".concat(r," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Vo(n,r,t){var e=document.createElement(n);if(r)for(var i in r)e.style[i]=r[i];if(t)for(var o in t)e.setAttribute(o,t[o]);return e}function gr(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function pr(n,r,t){return t.sort(function(e,i){var o=r(e)||0,a=r(i)||0;return o<a?-1:o>a?1:0})}function mr(n){var r=We(n.x,2),t=r[0],e=r[1],i=We(n.y,2),o=i[0],a=i[1],s=Math.max(e-t,a-o),u=(e+t)/2,l=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(u)&&(u=0),isNaN(l)&&(l=0);var h=function(c){return{x:.5+(c.x-u)/s,y:.5+(c.y-l)/s}};return h.applyTo=function(d){d.x=.5+(d.x-u)/s,d.y=.5+(d.y-l)/s},h.inverse=function(d){return{x:u+s*(d.x-.5),y:l+s*(d.y-.5)}},h.ratio=s,h}function Ut(n){"@babel/helpers - typeof";return Ut=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ut(n)}function vr(n,r){var t=r.size;if(t!==0){var e=n.length;n.length+=t;var i=0;r.forEach(function(o){n[e+i]=o,i++})}}function Lt(n){n=n||{};for(var r=0,t=arguments.length<=1?0:arguments.length-1;r<t;r++){var e=r+1<1||arguments.length<=r+1?void 0:arguments[r+1];e&&Object.assign(n,e)}return n}var Zt={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:so,defaultDrawNodeLabel:di,defaultDrawNodeHover:uo,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},qo={circle:vt},Ko={arrow:mi,line:Lo};function Dt(n){if(typeof n.labelDensity!="number"||n.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var r=n.minCameraRatio,t=n.maxCameraRatio;if(typeof r=="number"&&typeof t=="number"&&t<r)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Yo(n){var r=Lt({},Zt,n);return r.nodeProgramClasses=Lt({},qo,r.nodeProgramClasses),r.edgeProgramClasses=Lt({},Ko,r.edgeProgramClasses),r}var ct=1.5,yr=(function(n){function r(){var t;return re(this,r),t=le(this,r),T(t,"x",.5),T(t,"y",.5),T(t,"angle",0),T(t,"ratio",1),T(t,"minRatio",null),T(t,"maxRatio",null),T(t,"enabledZooming",!0),T(t,"enabledPanning",!0),T(t,"enabledRotation",!0),T(t,"clean",null),T(t,"nextFrame",null),T(t,"previousState",null),T(t,"enabled",!0),t.previousState=t.getState(),t}return he(r,n),ie(r,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(e){return this.x===e.x&&this.y===e.y&&this.ratio===e.ratio&&this.angle===e.angle}},{key:"getPreviousState",value:function(){var e=this.previousState;return e?{x:e.x,y:e.y,angle:e.angle,ratio:e.ratio}:null}},{key:"getBoundedRatio",value:function(e){var i=e;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(e){var i={};return this.enabledPanning&&typeof e.x=="number"&&(i.x=e.x),this.enabledPanning&&typeof e.y=="number"&&(i.y=e.y),this.enabledZooming&&typeof e.ratio=="number"&&(i.ratio=this.getBoundedRatio(e.ratio)),this.enabledRotation&&typeof e.angle=="number"&&(i.angle=e.angle),this.clean?this.clean(F(F({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(e){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(e);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(e){return this.setState(e(this.getState())),this}},{key:"animate",value:function(e){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(f){return i.animate(e,o,f)});if(this.enabled){var s=F(F({},jo),o),u=this.validateState(e),l=typeof s.easing=="function"?s.easing:Uo[s.easing],h=Date.now(),d=this.getState(),c=function(){var b=(Date.now()-h)/s.duration;if(b>=1){i.nextFrame=null,i.setState(u),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var w=l(b),E={};typeof u.x=="number"&&(E.x=d.x+(u.x-d.x)*w),typeof u.y=="number"&&(E.y=d.y+(u.y-d.y)*w),i.enabledRotation&&typeof u.angle=="number"&&(E.angle=d.angle+(u.angle-d.angle)*w),typeof u.ratio=="number"&&(E.ratio=d.ratio+(u.ratio-d.ratio)*w),i.setState(E),i.nextFrame=requestAnimationFrame(c)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(c)):c(),this.animationCallback=a}}},{key:"animatedZoom",value:function(e){return e?typeof e=="number"?this.animate({ratio:this.ratio/e}):this.animate({ratio:this.ratio/(e.factor||ct)},e):this.animate({ratio:this.ratio/ct})}},{key:"animatedUnzoom",value:function(e){return e?typeof e=="number"?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||ct)},e):this.animate({ratio:this.ratio*ct})}},{key:"animatedReset",value:function(e){return this.animate({x:.5,y:.5,ratio:1,angle:0},e)}},{key:"copy",value:function(){return r.from(this.getState())}}],[{key:"from",value:function(e){var i=new r;return i.setState(e)}}])})(Yt);function be(n,r){var t=r.getBoundingClientRect();return{x:n.clientX-t.left,y:n.clientY-t.top}}function Te(n,r){var t=F(F({},be(n,r)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0},original:n});return t}function et(n){var r="x"in n?n:F(F({},n.touches[0]||n.previousTouches[0]),{},{original:n.original,sigmaDefaultPrevented:n.sigmaDefaultPrevented,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0,r.sigmaDefaultPrevented=!0}});return r}function Zo(n,r){return F(F({},Te(n,r)),{},{delta:bi(n)})}var Xo=2;function ft(n){for(var r=[],t=0,e=Math.min(n.length,Xo);t<e;t++)r.push(n[t]);return r}function tt(n,r,t){var e={touches:ft(n.touches).map(function(i){return be(i,t)}),previousTouches:r.map(function(i){return be(i,t)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:n};return e}function bi(n){if(typeof n.deltaY<"u")return n.deltaY*-3/360;if(typeof n.detail<"u")return n.detail/-9;throw new Error("Captor: could not extract delta from event.")}var wi=(function(n){function r(t,e){var i;return re(this,r),i=le(this,r),i.container=t,i.renderer=e,i}return he(r,n),ie(r)})(Yt),Qo=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],Jo=Qo.reduce(function(n,r){return F(F({},n),{},T({},r,Zt[r]))},{}),ea=(function(n){function r(t,e){var i;return re(this,r),i=le(this,r,[t,e]),T(i,"enabled",!0),T(i,"draggedEvents",0),T(i,"downStartTime",null),T(i,"lastMouseX",null),T(i,"lastMouseY",null),T(i,"isMouseDown",!1),T(i,"isMoving",!1),T(i,"movingTimeout",null),T(i,"startCameraState",null),T(i,"clicks",0),T(i,"doubleClickTimeout",null),T(i,"currentWheelDirection",0),T(i,"settings",Jo),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),t.addEventListener("click",i.handleClick,{capture:!1}),t.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),t.addEventListener("mousedown",i.handleDown,{capture:!1}),t.addEventListener("wheel",i.handleWheel,{capture:!1}),t.addEventListener("mouseleave",i.handleLeave,{capture:!1}),t.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return he(r,n),ie(r,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("click",this.handleClick),e.removeEventListener("contextmenu",this.handleRightClick),e.removeEventListener("mousedown",this.handleDown),e.removeEventListener("wheel",this.handleWheel),e.removeEventListener("mouseleave",this.handleLeave),e.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(e){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(e);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",Te(e,this.container))}}},{key:"handleRightClick",value:function(e){this.enabled&&this.emit("rightClick",Te(e,this.container))}},{key:"handleDoubleClick",value:function(e){if(this.enabled){e.preventDefault(),e.stopPropagation();var i=Te(e,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(be(e,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(e){if(this.enabled){if(e.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=be(e,this.container),o=i.x,a=i.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Te(e,this.container))}}},{key:"handleUp",value:function(e){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var a=be(e,this.container),s=a.x,u=a.y,l=o.getState(),h=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:l.x+this.settings.inertiaRatio*(l.x-h.x),y:l.y+this.settings.inertiaRatio*(l.y-h.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==u)&&o.setState({x:l.x,y:l.y}),this.isMoving=!1,setTimeout(function(){var d=i.draggedEvents>0;i.draggedEvents=0,d&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",Te(e,this.container))}}},{key:"handleMove",value:function(e){var i=this;if(this.enabled){var o=Te(e,this.container);if(this.emit("mousemovebody",o),(e.target===this.container||e.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=be(e,this.container),u=s.x,l=s.y,h=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:u,y:l}),c=h.x-d.x,f=h.y-d.y,b=a.getState(),w=b.x+c,E=b.y+f;a.setState({x:w,y:E}),this.lastMouseX=u,this.lastMouseY=l,e.preventDefault(),e.stopPropagation()}}}},{key:"handleLeave",value:function(e){this.emit("mouseleave",Te(e,this.container))}},{key:"handleEnter",value:function(e){this.emit("mouseenter",Te(e,this.container))}},{key:"handleWheel",value:function(e){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=bi(e);if(a){var s=Zo(e,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){e.preventDefault(),e.stopPropagation();return}var u=o.getState().ratio,l=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,h=o.getBoundedRatio(u*l),d=a>0?1:-1,c=Date.now();u!==h&&(e.preventDefault(),e.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&c-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(be(e,this.container),h),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=c))}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(wi),ta=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],ra=ta.reduce(function(n,r){return F(F({},n),{},T({},r,Zt[r]))},{}),ia=(function(n){function r(t,e){var i;return re(this,r),i=le(this,r,[t,e]),T(i,"enabled",!0),T(i,"isMoving",!1),T(i,"hasMoved",!1),T(i,"touchMode",0),T(i,"startTouchesPositions",[]),T(i,"lastTouches",[]),T(i,"lastTap",null),T(i,"settings",ra),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),t.addEventListener("touchstart",i.handleStart,{capture:!1}),t.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return he(r,n),ie(r,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("touchstart",this.handleStart),e.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(e){var i=this;if(this.enabled){e.preventDefault();var o=ft(e.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return be(f,i.container)}),this.touchMode===2){var a=We(this.startTouchesPositions,2),s=a[0],u=s.x,l=s.y,h=a[1],d=h.x,c=h.y;this.startTouchesAngle=Math.atan2(c-l,d-u),this.startTouchesDistance=Math.sqrt(Math.pow(d-u,2)+Math.pow(c-l,2))}this.emit("touchdown",tt(e,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(e){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(e.cancelable&&e.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(e.touches.length===1){this.handleStart(e),e.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),a=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-a.x),y:o.y+this.settings.inertiaRatio*(o.y-a.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",tt(e,this.lastTouches,this.container)),!e.touches.length){var s=be(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],l=Math.pow(s.x-u.x,2)+Math.pow(s.y-u.y,2);if(!e.touches.length&&l<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var h=tt(e,this.lastTouches,this.container);if(this.emit("doubletap",h),this.lastTap=null,!h.sigmaDefaultPrevented){var d=this.renderer.getCamera(),c=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(s,c),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=tt(e,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=ft(e.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(e){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){e.preventDefault();var o=ft(e.touches),a=o.map(function(oe){return be(oe,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var u=tt(e,s,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(oe,J){var I=i.startTouchesPositions[J];return I&&(oe.x!==I.x||oe.y!==I.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var l=this.renderer.getCamera(),h=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var c=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=c.x,b=c.y,w=this.renderer.viewportToFramedGraph(a[0]),E=w.x,L=w.y;l.setState({x:h.x+f-E,y:h.y+b-L});break}case 2:{var _={x:.5,y:.5,angle:0,ratio:1},R=a[0],m=R.x,y=R.y,S=a[1],C=S.x,P=S.y,O=Math.atan2(P-y,C-m)-this.startTouchesAngle,z=Math.hypot(P-y,C-m)/this.startTouchesDistance,Y=l.getBoundedRatio(h.ratio/z);_.ratio=Y,_.angle=h.angle+O;var j=this.getDimensions(),g=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:h}),Q=Math.min(j.width,j.height)-2*d,ne=Q/j.width,k=Q/j.height,v=Y/Q,B=m-Q/2/ne,q=y-Q/2/k,ee=[B*Math.cos(-_.angle)-q*Math.sin(-_.angle),q*Math.cos(-_.angle)+B*Math.sin(-_.angle)];B=ee[0],q=ee[1],_.x=g.x-B*v,_.y=g.y+q*v,l.setState(_);break}}}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(wi);function na(n){if(Array.isArray(n))return Ot(n)}function oa(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function aa(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
312
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function br(n){return na(n)||oa(n)||ii(n)||aa()}function sa(n,r){if(n==null)return{};var t={};for(var e in n)if({}.hasOwnProperty.call(n,e)){if(r.indexOf(e)!==-1)continue;t[e]=n[e]}return t}function Gt(n,r){if(n==null)return{};var t,e,i=sa(n,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(e=0;e<o.length;e++)t=o[e],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(i[t]=n[t])}return i}var wr=(function(){function n(r,t){re(this,n),this.key=r,this.size=t}return ie(n,null,[{key:"compare",value:function(t,e){return t.size>e.size?-1:t.size<e.size||t.key>e.key?1:-1}}])})(),Er=(function(){function n(){re(this,n),T(this,"width",0),T(this,"height",0),T(this,"cellSize",0),T(this,"columns",0),T(this,"rows",0),T(this,"cells",{})}return ie(n,[{key:"resizeAndClear",value:function(t,e){this.width=t.width,this.height=t.height,this.cellSize=e,this.columns=Math.ceil(t.width/e),this.rows=Math.ceil(t.height/e),this.cells={}}},{key:"getIndex",value:function(t){var e=Math.floor(t.x/this.cellSize),i=Math.floor(t.y/this.cellSize);return i*this.columns+e}},{key:"add",value:function(t,e,i){var o=new wr(t,e),a=this.getIndex(i),s=this.cells[a];s||(s=[],this.cells[a]=s),s.push(o)}},{key:"organize",value:function(){for(var t in this.cells){var e=this.cells[t];e.sort(wr.compare)}}},{key:"getLabelsToDisplay",value:function(t,e){var i=this.cellSize*this.cellSize,o=i/t/t,a=o*e/i,s=Math.ceil(a),u=[];for(var l in this.cells)for(var h=this.cells[l],d=0;d<Math.min(s,h.length);d++)u.push(h[d].key);return u}}])})();function ua(n){var r=n.graph,t=n.hoveredNode,e=n.highlightedNodes,i=n.displayedNodeLabels,o=[];return r.forEachEdge(function(a,s,u,l){(u===t||l===t||e.has(u)||e.has(l)||i.has(u)&&i.has(l))&&o.push(a)}),o}var xr=150,_r=50,Re=Object.prototype.hasOwnProperty;function la(n,r,t){if(!Re.call(t,"x")||!Re.call(t,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(r,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return t.color||(t.color=n.defaultNodeColor),!t.label&&t.label!==""&&(t.label=null),t.label!==void 0&&t.label!==null?t.label=""+t.label:t.label=null,t.size||(t.size=2),Re.call(t,"hidden")||(t.hidden=!1),Re.call(t,"highlighted")||(t.highlighted=!1),Re.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=n.defaultNodeType),t.zIndex||(t.zIndex=0),t}function ha(n,r,t){return t.color||(t.color=n.defaultEdgeColor),t.label||(t.label=""),t.size||(t.size=.5),Re.call(t,"hidden")||(t.hidden=!1),Re.call(t,"forceLabel")||(t.forceLabel=!1),(!t.type||t.type==="")&&(t.type=n.defaultEdgeType),t.zIndex||(t.zIndex=0),t}var da=(function(n){function r(t,e){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(re(this,r),i=le(this,r),T(i,"elements",{}),T(i,"canvasContexts",{}),T(i,"webGLContexts",{}),T(i,"pickingLayers",new Set),T(i,"textures",{}),T(i,"frameBuffers",{}),T(i,"activeListeners",{}),T(i,"labelGrid",new Er),T(i,"nodeDataCache",{}),T(i,"edgeDataCache",{}),T(i,"nodeProgramIndex",{}),T(i,"edgeProgramIndex",{}),T(i,"nodesWithForcedLabels",new Set),T(i,"edgesWithForcedLabels",new Set),T(i,"nodeExtent",{x:[0,1],y:[0,1]}),T(i,"nodeZExtent",[1/0,-1/0]),T(i,"edgeZExtent",[1/0,-1/0]),T(i,"matrix",ye()),T(i,"invMatrix",ye()),T(i,"correctionRatio",1),T(i,"customBBox",null),T(i,"normalizationFunction",mr({x:[0,1],y:[0,1]})),T(i,"graphToViewportRatio",1),T(i,"itemIDsIndex",{}),T(i,"nodeIndices",{}),T(i,"edgeIndices",{}),T(i,"width",0),T(i,"height",0),T(i,"pixelRatio",gr()),T(i,"pickingDownSizingRatio",2*i.pixelRatio),T(i,"displayedNodeLabels",new Set),T(i,"displayedEdgeLabels",new Set),T(i,"highlightedNodes",new Set),T(i,"hoveredNode",null),T(i,"hoveredEdge",null),T(i,"renderFrame",null),T(i,"renderHighlightedNodesFrame",null),T(i,"needToProcess",!1),T(i,"checkEdgesEventsFrame",null),T(i,"nodePrograms",{}),T(i,"nodeHoverPrograms",{}),T(i,"edgePrograms",{}),i.settings=Yo(o),Dt(i.settings),Wo(t),!(e instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=t,i.container=e,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var a in i.settings.nodeProgramClasses)i.registerNodeProgram(a,i.settings.nodeProgramClasses[a],i.settings.nodeHoverProgramClasses[a]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new yr,i.bindCameraHandlers(),i.mouseCaptor=new ea(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new ia(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return he(r,n),ie(r,[{key:"registerNodeProgram",value:function(e,i,o){return this.nodePrograms[e]&&this.nodePrograms[e].kill(),this.nodeHoverPrograms[e]&&this.nodeHoverPrograms[e].kill(),this.nodePrograms[e]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[e]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(e,i){return this.edgePrograms[e]&&this.edgePrograms[e].kill(),this.edgePrograms[e]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(e){if(this.nodePrograms[e]){var i=this.nodePrograms,o=i[e],a=Gt(i,[e].map(it));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[e]){var s=this.nodeHoverPrograms,u=s[e],l=Gt(s,[e].map(it));u.kill(),this.nodePrograms=l}return this}},{key:"unregisterEdgeProgram",value:function(e){if(this.edgePrograms[e]){var i=this.edgePrograms,o=i[e],a=Gt(i,[e].map(it));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(e){var i=this.webGLContexts[e],o=this.frameBuffers[e],a=this.textures[e];a&&i.deleteTexture(a);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,s,0),this.textures[e]=s,this}},{key:"bindCameraHandlers",value:function(){var e=this;return this.activeListeners.camera=function(){e.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(e){var i=e.x,o=e.y,a=ir(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=rr.apply(void 0,br(a)),u=this.itemIDsIndex[s];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var e=this;this.activeListeners.handleResize=function(){e.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var a=et(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},u=e.getNodeAtPosition(a);if(u&&e.hoveredNode!==u&&!e.nodeDataCache[u].hidden){e.hoveredNode&&e.emit("leaveNode",F(F({},s),{},{node:e.hoveredNode})),e.hoveredNode=u,e.emit("enterNode",F(F({},s),{},{node:u})),e.scheduleHighlightedNodesRender();return}if(e.hoveredNode&&e.getNodeAtPosition(a)!==e.hoveredNode){var l=e.hoveredNode;e.hoveredNode=null,e.emit("leaveNode",F(F({},s),{},{node:l})),e.scheduleHighlightedNodesRender();return}if(e.settings.enableEdgeEvents){var h=e.hoveredNode?null:e.getEdgeAtPoint(s.event.x,s.event.y);h!==e.hoveredEdge&&(e.hoveredEdge&&e.emit("leaveEdge",F(F({},s),{},{edge:e.hoveredEdge})),h&&e.emit("enterEdge",F(F({},s),{},{edge:h})),e.hoveredEdge=h)}},this.activeListeners.handleMoveBody=function(o){var a=et(o);e.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=et(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};e.hoveredNode&&(e.emit("leaveNode",F(F({},s),{},{node:e.hoveredNode})),e.scheduleHighlightedNodesRender()),e.settings.enableEdgeEvents&&e.hoveredEdge&&(e.emit("leaveEdge",F(F({},s),{},{edge:e.hoveredEdge})),e.scheduleHighlightedNodesRender()),e.emit("leaveStage",F({},s))},this.activeListeners.handleEnter=function(o){var a=et(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};e.emit("enterStage",F({},s))};var i=function(a){return function(s){var u=et(s),l={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},h=e.getNodeAtPosition(u);if(h)return e.emit("".concat(a,"Node"),F(F({},l),{},{node:h}));if(e.settings.enableEdgeEvents){var d=e.getEdgeAtPoint(u.x,u.y);if(d)return e.emit("".concat(a,"Edge"),F(F({},l),{},{edge:d}))}return e.emit("".concat(a,"Stage"),l)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var e=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,u=(s=a.hints)===null||s===void 0?void 0:s.attributes;e.graph.forEachNode(function(h){return e.updateNode(h)});var l=!u||u.some(function(h){return o.has(h)});e.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!l,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,u=(s=a.hints)===null||s===void 0?void 0:s.attributes;e.graph.forEachEdge(function(h){return e.updateEdge(h)});var l=u&&["zIndex","type"].some(function(h){return u==null?void 0:u.includes(h)});e.refresh({partialGraph:{edges:i.edges()},skipIndexation:!l,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;e.addNode(s),e.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;e.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;e.removeNode(s),e.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;e.addEdge(s),e.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;e.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;e.removeEdge(s),e.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){e.clearEdgeState(),e.clearEdgeIndices(),e.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){e.clearEdgeState(),e.clearNodeState(),e.clearEdgeIndices(),e.clearNodeIndices(),e.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var e=this.graph;e.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),e.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),e.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),e.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),e.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),e.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),e.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),e.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),e.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),e.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(e,i){var o=ir(this.webGLContexts.edges,this.frameBuffers.edges,e,i,this.pixelRatio,this.pickingDownSizingRatio),a=rr.apply(void 0,br(o)),s=this.itemIDsIndex[a];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var e=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,a=this.getDimensions();if(this.nodeExtent=Ho(this.graph),!this.settings.autoRescale){var s=a.width,u=a.height,l=this.nodeExtent,h=l.x,d=l.y;this.nodeExtent={x:[(h[0]+h[1])/2-s/2,(h[0]+h[1])/2+s/2],y:[(d[0]+d[1])/2-u/2,(d[0]+d[1])/2+u/2]}}this.normalizationFunction=mr(this.customBBox||this.nodeExtent);var c=new yr,f=Je(c.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var b={},w={},E={},L={},_=1,R=i.nodes(),m=0,y=R.length;m<y;m++){var S=R[m],C=this.nodeDataCache[S],P=i.getNodeAttributes(S);C.x=P.x,C.y=P.y,this.normalizationFunction.applyTo(C),typeof C.label=="string"&&!C.hidden&&this.labelGrid.add(S,C.size,this.framedGraphToViewport(C,{matrix:f})),b[C.type]=(b[C.type]||0)+1}this.labelGrid.organize();for(var O in this.nodePrograms){if(!Re.call(this.nodePrograms,O))throw new Error('Sigma: could not find a suitable program for node type "'.concat(O,'"!'));this.nodePrograms[O].reallocate(b[O]||0),b[O]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(R=pr(this.nodeZExtent,function(se){return e.nodeDataCache[se].zIndex},R));for(var z=0,Y=R.length;z<Y;z++){var j=R[z];w[j]=_,L[w[j]]={type:"node",id:j},_++;var g=this.nodeDataCache[j];this.addNodeToProgram(j,w[j],b[g.type]++)}for(var Q={},ne=i.edges(),k=0,v=ne.length;k<v;k++){var B=ne[k],q=this.edgeDataCache[B];Q[q.type]=(Q[q.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(ne=pr(this.edgeZExtent,function(se){return e.edgeDataCache[se].zIndex},ne));for(var ee in this.edgePrograms){if(!Re.call(this.edgePrograms,ee))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ee,'"!'));this.edgePrograms[ee].reallocate(Q[ee]||0),Q[ee]=0}for(var oe=0,J=ne.length;oe<J;oe++){var I=ne[oe];E[I]=_,L[E[I]]={type:"edge",id:I},_++;var Le=this.edgeDataCache[I];this.addEdgeToProgram(I,E[I],Q[Le.type]++)}return this.itemIDsIndex=L,this.nodeIndices=w,this.edgeIndices=E,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(e){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(h){return i.cleanCameraState(h,o.cameraPanBoundaries&&Ut(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),e){if(e.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==e.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in e.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(e.nodeProgramClasses!==o.nodeProgramClasses||e.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var u in o.nodeProgramClasses)(o.nodeProgramClasses[u]!==e.nodeProgramClasses[u]||o.nodeHoverProgramClasses[u]!==e.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,o.nodeProgramClasses[u],o.nodeHoverProgramClasses[u]);for(var l in e.nodeProgramClasses)o.nodeProgramClasses[l]||this.unregisterNodeProgram(l)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,a=o===void 0?0:o,s=i.boundaries,u=F({},e),l=s||this.nodeExtent,h=We(l.x,2),d=h[0],c=h[1],f=We(l.y,2),b=f[0],w=f[1],E=[this.graphToViewport({x:d,y:b},{cameraState:e}),this.graphToViewport({x:c,y:b},{cameraState:e}),this.graphToViewport({x:d,y:w},{cameraState:e}),this.graphToViewport({x:c,y:w},{cameraState:e})],L=1/0,_=-1/0,R=1/0,m=-1/0;E.forEach(function(Q){var ne=Q.x,k=Q.y;L=Math.min(L,ne),_=Math.max(_,ne),R=Math.min(R,k),m=Math.max(m,k)});var y=_-L,S=m-R,C=this.getDimensions(),P=C.width,O=C.height,z=0,Y=0;if(y>=P?_<P-a?z=_-(P-a):L>a&&(z=L-a):_>P+a?z=_-(P+a):L<-a&&(z=L+a),S>=O?m<O-a?Y=m-(O-a):R>a&&(Y=R-a):m>O+a?Y=m-(O+a):R<-a&&(Y=R+a),z||Y){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:e}),g=this.viewportToFramedGraph({x:z,y:Y},{cameraState:e});z=g.x-j.x,Y=g.y-j.y,u.x+=z,u.y+=Y}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var e=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(e.ratio,this.settings.labelDensity);vr(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=i.length;a<s;a++){var u=i[a],l=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!l.hidden){var h=this.framedGraphToViewport(l),d=h.x,c=h.y,f=this.scaleSize(l.size);if(!(!l.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(d<-xr||d>this.width+xr||c<-_r||c>this.height+_r)){this.displayedNodeLabels.add(u);var b=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[l.type],E=(w==null?void 0:w.drawLabel)||b;E(o,F(F({key:u},l),{},{size:f,x:d,y:c}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var e=this.canvasContexts.edgeLabels;e.clearRect(0,0,this.width,this.height);var i=ua({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});vr(i,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=i.length;a<s;a++){var u=i[a],l=this.graph.extremities(u),h=this.nodeDataCache[l[0]],d=this.nodeDataCache[l[1]],c=this.edgeDataCache[u];if(!o.has(u)&&!(c.hidden||h.hidden||d.hidden)){var f=this.settings.defaultDrawEdgeLabel,b=this.edgePrograms[c.type],w=(b==null?void 0:b.drawLabel)||f;w(e,F(F({key:u},c),{},{size:this.scaleSize(c.size)}),F(F(F({key:l[0]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),F(F(F({key:l[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),o.add(u)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var e=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(f){var b=e.nodeDataCache[f],w=e.framedGraphToViewport(b),E=w.x,L=w.y,_=e.scaleSize(b.size),R=e.settings.defaultDrawNodeHover,m=e.nodePrograms[b.type],y=(m==null?void 0:m.drawHover)||R;y(i,F(F({key:f},b),{},{size:_,x:E,y:L}),e.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(c){c!==e.hoveredNode&&a.push(c)}),a.forEach(function(c){return o(c)});var s={};a.forEach(function(c){var f=e.nodeDataCache[c].type;s[f]=(s[f]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(s[u]||0),s[u]=0;a.forEach(function(c){var f=e.nodeDataCache[c];e.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var l=this.getRenderParams();for(var h in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[h];d.render(l)}}},{key:"scheduleHighlightedNodesRender",value:function(){var e=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){e.renderHighlightedNodesFrame=null,e.renderHighlightedNodes(),e.renderEdgeLabels()}))}},{key:"render",value:function(){var e=this;this.emit("beforeRender");var i=function(){return e.emit("afterRender"),e};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(E){return e.resetWebGLTexture(E)}),!this.graph.order)return i();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),u=this.getDimensions(),l=this.getGraphDimensions(),h=this.getStagePadding();this.matrix=Je(s,u,l,h),this.invMatrix=Je(s,u,l,h,!0),this.correctionRatio=Bo(this.matrix,s,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var c in this.nodePrograms){var f=this.nodePrograms[c];f.render(d)}if(!this.settings.hideEdgesOnMove||!a)for(var b in this.edgePrograms){var w=this.edgePrograms[b];w.render(d)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(e){var i=Object.assign({},this.graph.getNodeAttributes(e));this.settings.nodeReducer&&(i=this.settings.nodeReducer(e,i));var o=la(this.settings,e,i);this.nodeDataCache[e]=o,this.nodesWithForcedLabels.delete(e),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(e),this.highlightedNodes.delete(e),o.highlighted&&!o.hidden&&this.highlightedNodes.add(e),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(e){this.addNode(e);var i=this.nodeDataCache[e];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(e){delete this.nodeDataCache[e],delete this.nodeProgramIndex[e],this.highlightedNodes.delete(e),this.hoveredNode===e&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(e)}},{key:"addEdge",value:function(e){var i=Object.assign({},this.graph.getEdgeAttributes(e));this.settings.edgeReducer&&(i=this.settings.edgeReducer(e,i));var o=ha(this.settings,e,i);this.edgeDataCache[e]=o,this.edgesWithForcedLabels.delete(e),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(e),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(e){this.addEdge(e)}},{key:"removeEdge",value:function(e){delete this.edgeDataCache[e],delete this.edgeProgramIndex[e],this.hoveredEdge===e&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(e)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Er,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(e,i,o){var a=this.nodeDataCache[e],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(i,o,a),this.nodeProgramIndex[e]=o}},{key:"addEdgeToProgram",value:function(e,i,o){var a=this.edgeDataCache[e],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var u=this.graph.extremities(e),l=this.nodeDataCache[u[0]],h=this.nodeDataCache[u[1]];s.process(i,o,l,h,a),this.edgeProgramIndex[e]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var e=this.settings,i=e.stagePadding,o=e.autoRescale;return o&&i||0}},{key:"createLayer",value:function(e,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[e])throw new Error('Sigma: a layer named "'.concat(e,'" already exists'));var a=Vo(i,{position:"absolute"},{class:"sigma-".concat(e)});return o.style&&Object.assign(a.style,o.style),this.elements[e]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(e,"canvas",i)}},{key:"createCanvasContext",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(e,i),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[e]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=(i==null?void 0:i.canvas)||this.createCanvas(e,i);i.hidden&&o.remove();var a=F({preserveDrawingBuffer:!1,antialias:!1},i),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var u=s;if(this.webGLContexts[e]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(e);var l=u.createFramebuffer();if(!l)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(e));this.frameBuffers[e]=l}return u}},{key:"killLayer",value:function(e){var i=this.elements[e];if(!i)throw new Error("Sigma: cannot kill layer ".concat(e,", which does not exist"));if(this.webGLContexts[e]){var o,a=this.webGLContexts[e];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[e]}else this.canvasContexts[e]&&delete this.canvasContexts[e];return i.remove(),delete this.elements[e],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(e){this.unbindCameraHandlers(),this.camera=e,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(e){e!==this.graph&&(this.hoveredNode&&!e.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!e.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=e,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var e=this.customBBox||this.nodeExtent;return{width:e.x[1]-e.x[0]||1,height:e.y[1]-e.y[0]||1}}},{key:"getNodeDisplayData",value:function(e){var i=this.nodeDataCache[e];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(e){var i=this.edgeDataCache[e];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return F({},this.settings)}},{key:"getSetting",value:function(e){return this.settings[e]}},{key:"setSetting",value:function(e,i){var o=F({},this.settings);return this.settings[e]=i,Dt(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(e,i){return this.setSetting(e,i(this.settings[e])),this}},{key:"setSettings",value:function(e){var i=F({},this.settings);return this.settings=F(F({},this.settings),e),Dt(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(e){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=gr(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!e&&i===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var u in this.canvasContexts)this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[u].scale(this.pixelRatio,this.pixelRatio);for(var l in this.webGLContexts){this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px");var h=this.webGLContexts[l];if(h.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(l)){var d=this.textures[l];d&&h.deleteTexture(d)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(e){var i=this,o=(e==null?void 0:e.skipIndexation)!==void 0?e==null?void 0:e.skipIndexation:!1,a=(e==null?void 0:e.schedule)!==void 0?e.schedule:!1,s=!e||!e.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(m){return i.addNode(m)}),this.graph.forEachEdge(function(m){return i.addEdge(m)});else{for(var u,l,h=((u=e.partialGraph)===null||u===void 0?void 0:u.nodes)||[],d=0,c=(h==null?void 0:h.length)||0;d<c;d++){var f=h[d];if(this.updateNode(f),o){var b=this.nodeProgramIndex[f];if(b===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],b)}}for(var w=(e==null||(l=e.partialGraph)===null||l===void 0?void 0:l.edges)||[],E=0,L=w.length;E<L;E++){var _=w[E];if(this.updateEdge(_),o){var R=this.edgeProgramIndex[_];if(R===void 0)throw new Error('Sigma: edge "'.concat(_,`" can't be repaint`));this.addEdgeToProgram(_,this.edgeIndices[_],R)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var e=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){e.render()})),this}},{key:"scheduleRefresh",value:function(e){return this.refresh(F(F({},e),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(e,i){var o=this.camera.getState(),a=o.ratio,s=o.angle,u=o.x,l=o.y,h=this.settings,d=h.minCameraRatio,c=h.maxCameraRatio;typeof c=="number"&&(i=Math.min(i,c)),typeof d=="number"&&(i=Math.max(i,d));var f=i/a,b={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(e),E=this.viewportToFramedGraph(b);return{angle:s,x:(w.x-E.x)*(1-f)+u,y:(w.y-E.y)*(1-f)+l,ratio:i}}},{key:"viewRectangle",value:function(){var e=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:e.x,y1:e.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,a=i.matrix?i.matrix:o?Je(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=$t(a,e);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,a=i.matrix?i.matrix:o?Je(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=$t(a,{x:e.x/this.width*2-1,y:1-e.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(e,i))}},{key:"graphToViewport",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(e),i)}},{key:"getGraphToViewportRatio",value:function(){var e={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=this.graphToViewport(e),s=this.graphToViewport(i),u=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return u/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(e){return this.customBBox=e,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var e=this.container;e.firstChild;)e.removeChild(e.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return e/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var e={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(e[i]=this.elements[i]);return e}}])})(Yt);const Ei=G.createContext(null),ca=Ei.Provider;function xi(){const n=G.useContext(Ei);if(n==null)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return n}function yt(){return xi().sigma}function fa(){const{sigma:n}=xi();return G.useCallback((r=>{n&&Object.keys(r).forEach((t=>{n.setSetting(t,r[t])}))}),[n])}function bt(n){return new Set(Object.keys(n))}const Cr=bt({clickNode:!0,rightClickNode:!0,downNode:!0,enterNode:!0,leaveNode:!0,doubleClickNode:!0,wheelNode:!0,clickEdge:!0,rightClickEdge:!0,downEdge:!0,enterEdge:!0,leaveEdge:!0,doubleClickEdge:!0,wheelEdge:!0,clickStage:!0,rightClickStage:!0,downStage:!0,doubleClickStage:!0,wheelStage:!0,beforeRender:!0,afterRender:!0,kill:!0,upStage:!0,upEdge:!0,upNode:!0,enterStage:!0,leaveStage:!0,resize:!0,afterClear:!0,afterProcess:!0,beforeClear:!0,beforeProcess:!0,moveBody:!0}),Sr=bt({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),Tr=bt({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),Rr=bt({updated:!0});function ga(){const n=yt(),r=fa(),[t,e]=G.useState({});return G.useEffect((()=>{if(!n||!t)return;const i=t,o=Object.keys(i);return o.forEach((a=>{const s=i[a];Cr.has(a)&&n.on(a,s),Sr.has(a)&&n.getMouseCaptor().on(a,s),Tr.has(a)&&n.getTouchCaptor().on(a,s),Rr.has(a)&&n.getCamera().on(a,s)})),()=>{n&&o.forEach((a=>{const s=i[a];Cr.has(a)&&n.off(a,s),Sr.has(a)&&n.getMouseCaptor().off(a,s),Tr.has(a)&&n.getTouchCaptor().off(a,s),Rr.has(a)&&n.getCamera().off(a,s)}))}}),[n,t,r]),e}function pa(){const n=yt();return G.useCallback(((r,t=!0)=>{n&&r&&(t&&n.getGraph().order>0&&n.getGraph().clear(),n.getGraph().import(r),n.refresh())}),[n])}function _i(n,r){if(n===r)return!0;if(typeof n=="object"&&n!=null&&typeof r=="object"&&r!=null){if(Object.keys(n).length!=Object.keys(r).length)return!1;for(const t in n)if(!Object.hasOwn(r,t)||!_i(n[t],r[t]))return!1;return!0}return!1}const ma=G.forwardRef((({graph:n,id:r,className:t,style:e,settings:i={},children:o},a)=>{const s=G.useRef(null),u=G.useRef(null),l={className:`react-sigma ${t||""}`,id:r,style:e},[h,d]=G.useState(null),[c,f]=G.useState(i);G.useEffect((()=>{f((E=>_i(E,i)?E:i))}),[i]),G.useEffect((()=>{let E=null;if(u.current!==null){let L=new X;n&&(L=typeof n=="function"?new n:n),E=new da(L,u.current,c),d((_=>{let R=null;return _&&(R=_.getCamera().getState()),R&&E.getCamera().setState(R),E}))}return()=>{E&&E.kill()}}),[u,n,c]),G.useImperativeHandle(a,(()=>h),[h]);const b=G.useMemo((()=>h&&s.current?{sigma:h,container:s.current}:null),[h,s]),w=b!==null?Et.createElement(ca,{value:b},o):null;return Et.createElement("div",Object.assign({},l,{ref:s}),Et.createElement("div",{className:"sigma-container",ref:u}),w)}));var rt={},kr;function va(){if(kr)return rt;kr=1;function n(e){return typeof e!="number"||isNaN(e)?1:e}function r(e,i){var o={},a=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(a=i);var s=function(l){return a(l[e])},u=function(){return a(void 0)};return typeof e=="string"?(o.fromAttributes=s,o.fromGraph=function(l,h){return s(l.getNodeAttributes(h))},o.fromEntry=function(l,h){return s(h)}):typeof e=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},o.fromGraph=function(l,h){return a(e(h,l.getNodeAttributes(h)))},o.fromEntry=function(l,h){return a(e(l,h))}):(o.fromAttributes=u,o.fromGraph=u,o.fromEntry=u),o}function t(e,i){var o={},a=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(a=i);var s=function(l){return a(l[e])},u=function(){return a(void 0)};return typeof e=="string"?(o.fromAttributes=s,o.fromGraph=function(l,h){return s(l.getEdgeAttributes(h))},o.fromEntry=function(l,h){return s(h)},o.fromPartialEntry=o.fromEntry,o.fromMinimalEntry=o.fromEntry):typeof e=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},o.fromGraph=function(l,h){var d=l.extremities(h);return a(e(h,l.getEdgeAttributes(h),d[0],d[1],l.getNodeAttributes(d[0]),l.getNodeAttributes(d[1]),l.isUndirected(h)))},o.fromEntry=function(l,h,d,c,f,b,w){return a(e(l,h,d,c,f,b,w))},o.fromPartialEntry=function(l,h,d,c){return a(e(l,h,d,c))},o.fromMinimalEntry=function(l,h){return a(e(l,h))}):(o.fromAttributes=u,o.fromGraph=u,o.fromEntry=u,o.fromMinimalEntry=u),o}return rt.createNodeValueGetter=r,rt.createEdgeValueGetter=t,rt.createEdgeWeightGetter=function(e){return t(e,n)},rt}var Nt,Ar;function ya(){if(Ar)return Nt;Ar=1;var n=0,r=1,t=2,e=3,i=4,o=5,a=6,s=7,u=8,l=9,h=0,d=1,c=2,f=0,b=1,w=2,E=3,L=4,_=5,R=6,m=7,y=8,S=3,C=10,P=3,O=9,z=10;return Nt=function(j,g,Q){var ne,k,v,B,q,ee,oe,J,I,Le,se=g.length,ot=Q.length,Ie=j.adjustSizes,at=j.barnesHutTheta*j.barnesHutTheta,Ue,K,W,H,ge,M,$,x=[];for(v=0;v<se;v+=C)g[v+i]=g[v+t],g[v+o]=g[v+e],g[v+t]=0,g[v+e]=0;if(j.outboundAttractionDistribution){for(Ue=0,v=0;v<se;v+=C)Ue+=g[v+a];Ue/=se/C}if(j.barnesHutOptimize){var pe=1/0,De=-1/0,Ee=1/0,Ge=-1/0,ue,Ne,Ye;for(v=0;v<se;v+=C)pe=Math.min(pe,g[v+n]),De=Math.max(De,g[v+n]),Ee=Math.min(Ee,g[v+r]),Ge=Math.max(Ge,g[v+r]);var je=De-pe,Fe=Ge-Ee;for(je>Fe?(Ee-=(je-Fe)/2,Ge=Ee+je):(pe-=(Fe-je)/2,De=pe+Fe),x[0+f]=-1,x[0+b]=(pe+De)/2,x[0+w]=(Ee+Ge)/2,x[0+E]=Math.max(De-pe,Ge-Ee),x[0+L]=-1,x[0+_]=-1,x[0+R]=0,x[0+m]=0,x[0+y]=0,ne=1,v=0;v<se;v+=C)for(k=0,Ye=S;;)if(x[k+_]>=0){g[v+n]<x[k+b]?g[v+r]<x[k+w]?ue=x[k+_]:ue=x[k+_]+O:g[v+r]<x[k+w]?ue=x[k+_]+O*2:ue=x[k+_]+O*3,x[k+m]=(x[k+m]*x[k+R]+g[v+n]*g[v+a])/(x[k+R]+g[v+a]),x[k+y]=(x[k+y]*x[k+R]+g[v+r]*g[v+a])/(x[k+R]+g[v+a]),x[k+R]+=g[v+a],k=ue;continue}else if(x[k+f]<0){x[k+f]=v;break}else{if(x[k+_]=ne*O,J=x[k+E]/2,I=x[k+_],x[I+f]=-1,x[I+b]=x[k+b]-J,x[I+w]=x[k+w]-J,x[I+E]=J,x[I+L]=I+O,x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,I+=O,x[I+f]=-1,x[I+b]=x[k+b]-J,x[I+w]=x[k+w]+J,x[I+E]=J,x[I+L]=I+O,x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,I+=O,x[I+f]=-1,x[I+b]=x[k+b]+J,x[I+w]=x[k+w]-J,x[I+E]=J,x[I+L]=I+O,x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,I+=O,x[I+f]=-1,x[I+b]=x[k+b]+J,x[I+w]=x[k+w]+J,x[I+E]=J,x[I+L]=x[k+L],x[I+_]=-1,x[I+R]=0,x[I+m]=0,x[I+y]=0,ne+=4,g[x[k+f]+n]<x[k+b]?g[x[k+f]+r]<x[k+w]?ue=x[k+_]:ue=x[k+_]+O:g[x[k+f]+r]<x[k+w]?ue=x[k+_]+O*2:ue=x[k+_]+O*3,x[k+R]=g[x[k+f]+a],x[k+m]=g[x[k+f]+n],x[k+y]=g[x[k+f]+r],x[ue+f]=x[k+f],x[k+f]=-1,g[v+n]<x[k+b]?g[v+r]<x[k+w]?Ne=x[k+_]:Ne=x[k+_]+O:g[v+r]<x[k+w]?Ne=x[k+_]+O*2:Ne=x[k+_]+O*3,ue===Ne)if(Ye--){k=ue;continue}else{Ye=S;break}x[Ne+f]=v;break}}if(j.barnesHutOptimize)for(K=j.scalingRatio,v=0;v<se;v+=C)for(k=0;;)if(x[k+_]>=0)if(M=Math.pow(g[v+n]-x[k+m],2)+Math.pow(g[v+r]-x[k+y],2),Le=x[k+E],4*Le*Le/M<at){if(W=g[v+n]-x[k+m],H=g[v+r]-x[k+y],Ie===!0?M>0?($=K*g[v+a]*x[k+R]/M,g[v+t]+=W*$,g[v+e]+=H*$):M<0&&($=-K*g[v+a]*x[k+R]/Math.sqrt(M),g[v+t]+=W*$,g[v+e]+=H*$):M>0&&($=K*g[v+a]*x[k+R]/M,g[v+t]+=W*$,g[v+e]+=H*$),k=x[k+L],k<0)break;continue}else{k=x[k+_];continue}else{if(ee=x[k+f],ee>=0&&ee!==v&&(W=g[v+n]-g[ee+n],H=g[v+r]-g[ee+r],M=W*W+H*H,Ie===!0?M>0?($=K*g[v+a]*g[ee+a]/M,g[v+t]+=W*$,g[v+e]+=H*$):M<0&&($=-K*g[v+a]*g[ee+a]/Math.sqrt(M),g[v+t]+=W*$,g[v+e]+=H*$):M>0&&($=K*g[v+a]*g[ee+a]/M,g[v+t]+=W*$,g[v+e]+=H*$)),k=x[k+L],k<0)break;continue}else for(K=j.scalingRatio,B=0;B<se;B+=C)for(q=0;q<B;q+=C)W=g[B+n]-g[q+n],H=g[B+r]-g[q+r],Ie===!0?(M=Math.sqrt(W*W+H*H)-g[B+u]-g[q+u],M>0?($=K*g[B+a]*g[q+a]/M/M,g[B+t]+=W*$,g[B+e]+=H*$,g[q+t]-=W*$,g[q+e]-=H*$):M<0&&($=100*K*g[B+a]*g[q+a],g[B+t]+=W*$,g[B+e]+=H*$,g[q+t]-=W*$,g[q+e]-=H*$)):(M=Math.sqrt(W*W+H*H),M>0&&($=K*g[B+a]*g[q+a]/M/M,g[B+t]+=W*$,g[B+e]+=H*$,g[q+t]-=W*$,g[q+e]-=H*$));for(I=j.gravity/j.scalingRatio,K=j.scalingRatio,v=0;v<se;v+=C)$=0,W=g[v+n],H=g[v+r],M=Math.sqrt(Math.pow(W,2)+Math.pow(H,2)),j.strongGravityMode?M>0&&($=K*g[v+a]*I):M>0&&($=K*g[v+a]*I/M),g[v+t]-=W*$,g[v+e]-=H*$;for(K=1*(j.outboundAttractionDistribution?Ue:1),oe=0;oe<ot;oe+=P)B=Q[oe+h],q=Q[oe+d],J=Q[oe+c],ge=Math.pow(J,j.edgeWeightInfluence),W=g[B+n]-g[q+n],H=g[B+r]-g[q+r],Ie===!0?(M=Math.sqrt(W*W+H*H)-g[B+u]-g[q+u],j.linLogMode?j.outboundAttractionDistribution?M>0&&($=-K*ge*Math.log(1+M)/M/g[B+a]):M>0&&($=-K*ge*Math.log(1+M)/M):j.outboundAttractionDistribution?M>0&&($=-K*ge/g[B+a]):M>0&&($=-K*ge)):(M=Math.sqrt(Math.pow(W,2)+Math.pow(H,2)),j.linLogMode?j.outboundAttractionDistribution?M>0&&($=-K*ge*Math.log(1+M)/M/g[B+a]):M>0&&($=-K*ge*Math.log(1+M)/M):j.outboundAttractionDistribution?(M=1,$=-K*ge/g[B+a]):(M=1,$=-K*ge)),M>0&&(g[B+t]+=W*$,g[B+e]+=H*$,g[q+t]-=W*$,g[q+e]-=H*$);var xe,N,Z,V,me,_e;if(Ie===!0)for(v=0;v<se;v+=C)g[v+l]!==1&&(xe=Math.sqrt(Math.pow(g[v+t],2)+Math.pow(g[v+e],2)),xe>z&&(g[v+t]=g[v+t]*z/xe,g[v+e]=g[v+e]*z/xe),N=g[v+a]*Math.sqrt((g[v+i]-g[v+t])*(g[v+i]-g[v+t])+(g[v+o]-g[v+e])*(g[v+o]-g[v+e])),Z=Math.sqrt((g[v+i]+g[v+t])*(g[v+i]+g[v+t])+(g[v+o]+g[v+e])*(g[v+o]+g[v+e]))/2,V=.1*Math.log(1+Z)/(1+Math.sqrt(N)),me=g[v+n]+g[v+t]*(V/j.slowDown),g[v+n]=me,_e=g[v+r]+g[v+e]*(V/j.slowDown),g[v+r]=_e);else for(v=0;v<se;v+=C)g[v+l]!==1&&(N=g[v+a]*Math.sqrt((g[v+i]-g[v+t])*(g[v+i]-g[v+t])+(g[v+o]-g[v+e])*(g[v+o]-g[v+e])),Z=Math.sqrt((g[v+i]+g[v+t])*(g[v+i]+g[v+t])+(g[v+o]+g[v+e])*(g[v+o]+g[v+e]))/2,V=g[v+s]*Math.log(1+Z)/(1+Math.sqrt(N)),g[v+s]=Math.min(1,Math.sqrt(V*(Math.pow(g[v+t],2)+Math.pow(g[v+e],2))/(1+Math.sqrt(N)))),me=g[v+n]+g[v+t]*(V/j.slowDown),g[v+n]=me,_e=g[v+r]+g[v+e]*(V/j.slowDown),g[v+r]=_e);return{}},Nt}var Ce={},Lr;function ba(){if(Lr)return Ce;Lr=1;var n=10,r=3;return Ce.assign=function(t){t=t||{};var e=Array.prototype.slice.call(arguments).slice(1),i,o,a;for(i=0,a=e.length;i<a;i++)if(e[i])for(o in e[i])t[o]=e[i][o];return t},Ce.validateSettings=function(t){return"linLogMode"in t&&typeof t.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&typeof t.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&typeof t.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&typeof t.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in t&&!(typeof t.scalingRatio=="number"&&t.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&typeof t.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&!(typeof t.gravity=="number"&&t.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&!(typeof t.slowDown=="number"||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&typeof t.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&!(typeof t.barnesHutTheta=="number"&&t.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Ce.graphToByteArrays=function(t,e){var i=t.order,o=t.size,a={},s,u=new Float32Array(i*n),l=new Float32Array(o*r);return s=0,t.forEachNode(function(h,d){a[h]=s,u[s]=d.x,u[s+1]=d.y,u[s+2]=0,u[s+3]=0,u[s+4]=0,u[s+5]=0,u[s+6]=1,u[s+7]=1,u[s+8]=d.size||1,u[s+9]=d.fixed?1:0,s+=n}),s=0,t.forEachEdge(function(h,d,c,f,b,w,E){var L=a[c],_=a[f],R=e(h,d,c,f,b,w,E);u[L+6]+=R,u[_+6]+=R,l[s]=L,l[s+1]=_,l[s+2]=R,s+=r}),{nodes:u,edges:l}},Ce.assignLayoutChanges=function(t,e,i){var o=0;t.updateEachNodeAttributes(function(a,s){return s.x=e[o],s.y=e[o+1],o+=n,i?i(a,s):s})},Ce.readGraphPositions=function(t,e){var i=0;t.forEachNode(function(o,a){e[i]=a.x,e[i+1]=a.y,i+=n})},Ce.collectLayoutChanges=function(t,e,i){for(var o=t.nodes(),a={},s=0,u=0,l=e.length;s<l;s+=n){if(i){var h=Object.assign({},t.getNodeAttributes(o[u]));h.x=e[s],h.y=e[s+1],h=i(o[u],h),a[o[u]]={x:h.x,y:h.y}}else a[o[u]]={x:e[s],y:e[s+1]};u++}return a},Ce.createWorker=function(e){var i=window.URL||window.webkitURL,o=e.toString(),a=i.createObjectURL(new Blob(["("+o+").call(this);"],{type:"text/javascript"})),s=new Worker(a);return i.revokeObjectURL(a),s},Ce}var Ft,Dr;function wa(){return Dr||(Dr=1,Ft={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),Ft}var Pt,Gr;function Ea(){if(Gr)return Pt;Gr=1;var n=yi(),r=va().createEdgeWeightGetter,t=ya(),e=ba(),i=wa();function o(u,l,h){if(!n(l))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof h=="number"&&(h={iterations:h});var d=h.iterations;if(typeof d!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(d<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=r("getEdgeWeight"in h?h.getEdgeWeight:"weight").fromEntry,f=typeof h.outputReducer=="function"?h.outputReducer:null,b=e.assign({},i,h.settings),w=e.validateSettings(b);if(w)throw new Error("graphology-layout-forceatlas2: "+w.message);var E=e.graphToByteArrays(l,c),L;for(L=0;L<d;L++)t(b,E.nodes,E.edges);if(u){e.assignLayoutChanges(l,E.nodes,f);return}return e.collectLayoutChanges(l,E.nodes)}function a(u){var l=typeof u=="number"?u:u.order;return{barnesHutOptimize:l>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(l)}}var s=o.bind(null,!1);return s.assign=o.bind(null,!0),s.inferSettings=a,Pt=s,Pt}var xa=Ea();const _a=$r(xa);function jt(n){return n!=null&&typeof n=="object"&&"symbols"in n&&Array.isArray(n.symbols)}function Ci(n){return n!=null&&typeof n=="object"&&"riskLevel"in n&&"affectedSymbols"in n}function Ca(n){return n!=null&&typeof n=="object"&&"result"in n&&Array.isArray(n.result)&&n.result.length>0&&typeof n.result[0]=="object"}function Sa(n){if(!Array.isArray(n)||n.length===0)return!1;const r=n[0];return r!=null&&typeof r=="object"&&!Array.isArray(r)}function Nr({data:n,pageSize:r=50}){const[t,e]=G.useState(0),i=G.useMemo(()=>{if(n.length===0)return[];const s=new Set;for(const u of n)for(const l of Object.keys(u))s.add(l);return Array.from(s)},[n]),o=Math.ceil(n.length/r),a=n.slice(t*r,(t+1)*r);return n.length===0?p.jsx("div",{className:"p-4 text-sm text-[var(--color-text-muted)]",children:"No results"}):p.jsxs("div",{children:[p.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] mb-2",children:[n.length," rows"]}),p.jsx("div",{className:"overflow-x-auto rounded-lg border border-[var(--color-border)]",children:p.jsxs("table",{className:"w-full text-xs",children:[p.jsx("thead",{children:p.jsx("tr",{className:"border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)] text-left text-[var(--color-text-muted)]",children:i.map(s=>p.jsx("th",{className:"py-1.5 px-2 font-medium whitespace-nowrap",children:s},s))})}),p.jsx("tbody",{children:a.map((s,u)=>p.jsx("tr",{className:"border-b border-[var(--color-border)] hover:bg-[var(--color-bg-tertiary)] transition-colors",children:i.map(l=>p.jsx("td",{className:"py-1 px-2 max-w-[300px] truncate",children:Ta(s[l])},l))},u))})]})}),o>1&&p.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2 text-xs",children:[p.jsx("button",{onClick:()=>e(s=>Math.max(0,s-1)),disabled:t===0,className:"px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] disabled:opacity-30",children:"Prev"}),p.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[t+1," / ",o]}),p.jsx("button",{onClick:()=>e(s=>Math.min(o-1,s+1)),disabled:t>=o-1,className:"px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] disabled:opacity-30",children:"Next"})]})]})}function Ta(n){return n==null?"—":typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):typeof n=="object"?JSON.stringify(n):String(n)}function Ra({data:n}){const[r,t]=G.useState(!1),[e,i]=G.useState(!1),o=JSON.stringify(n,null,2),a=G.useCallback(async()=>{try{await navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),2e3)}catch{}},[o]);return p.jsxs("div",{className:"rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]",children:[p.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-[var(--color-border)]",children:[p.jsx("button",{onClick:()=>t(s=>!s),className:"text-[10px] text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition-colors",children:r?"▸ Show JSON":"▾ JSON"}),p.jsx("button",{onClick:()=>void a(),className:"text-[10px] px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition-colors",children:e?"Copied!":"Copy"})]}),!r&&p.jsx("pre",{className:"p-3 text-xs whitespace-pre-wrap overflow-x-auto max-h-[400px] overflow-y-auto",children:o})]})}function ka(n){const r=[],t=new Map;for(const e of n){if(!e.file)continue;const i=t.get(e.file);i?i.push(e):t.set(e.file,[e])}for(const[e,i]of t){const o=e.split("/");let a=r;for(let s=0;s<o.length;s++){const u=o[s],l=o.slice(0,s+1).join("/"),h=s===o.length-1;let d=a.find(c=>c.name===u);d||(d={name:u,path:l,isDirectory:!h,children:[],symbolCount:0,symbols:[]},a.push(d)),h&&(d.symbols=i),a=d.children}}return Mt(r),r}function Mt(n){let r=0;for(const t of n)if(t.isDirectory){const e=Mt(t.children);t.symbolCount=e,r+=e}else t.symbolCount=t.symbols.length,r+=t.symbols.length,Mt(t.children);return n.sort((t,e)=>t.isDirectory!==e.isDirectory?t.isDirectory?-1:1:t.name.localeCompare(e.name)),r}function Aa(n,r){if(!r.trim())return n;const t=r.toLowerCase();return Si(n,t)}function Si(n,r){const t=[];for(const e of n){const i=e.path.toLowerCase().includes(r);if(i&&!e.isDirectory)t.push(e);else if(e.isDirectory)if(i)t.push(e);else{const o=Si(e.children,r);o.length>0&&t.push({...e,children:o})}}return t}const La=G.memo(function({tree:r,searchQuery:t,onSearchChange:e,expandedPaths:i,onToggleExpand:o,selectedPath:a,onSelectPath:s}){return p.jsxs("div",{className:"flex flex-col min-h-0",children:[p.jsx("div",{className:"px-3 py-2 border-b border-[var(--color-border)]",children:p.jsx("input",{type:"text",value:t,onChange:u=>e(u.target.value),placeholder:"Search files...",className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]"})}),p.jsx("div",{className:"overflow-y-auto flex-1 py-1",children:r.length===0?p.jsx("div",{className:"px-3 py-4 text-xs text-[var(--color-text-muted)] text-center",children:t?"No files match":"No files indexed"}):r.map(u=>p.jsx(Ti,{item:u,depth:0,expandedPaths:i,selectedPath:a,onToggleExpand:o,onSelectPath:s},u.path))})]})});function Ti({item:n,depth:r,expandedPaths:t,selectedPath:e,onToggleExpand:i,onSelectPath:o}){const a=t.has(n.path),s=e===n.path,u=n.children.length>0,l=n.isDirectory?we.folder:we.file,h=G.useCallback(c=>{c.stopPropagation(),i(n.path)},[n.path,i]),d=G.useCallback(()=>{n.isDirectory&&i(n.path),o(n.path,n.isDirectory)},[n.path,n.isDirectory,i,o]);return p.jsxs(p.Fragment,{children:[p.jsxs("button",{onClick:d,className:`w-full text-left flex items-center gap-1.5 px-2 py-0.5 text-xs hover:bg-[var(--color-bg-tertiary)] transition-colors ${s?"bg-[var(--color-bg-tertiary)] font-semibold":""}`,style:{paddingLeft:`${r*14+8}px`},children:[u||n.isDirectory?p.jsx("span",{onClick:h,className:"w-3 text-center text-[var(--color-text-muted)] hover:text-[var(--color-text)] cursor-pointer shrink-0 text-[10px]",children:a?"▾":"▸"}):p.jsx("span",{className:"w-3 shrink-0"}),p.jsx("span",{style:{color:l},className:"shrink-0 text-[10px]",children:n.isDirectory?"📁":"📄"}),p.jsx("span",{className:"truncate",style:{color:l},children:n.name}),n.symbolCount>0&&p.jsx("span",{className:"text-[9px] text-[var(--color-text-muted)] ml-auto shrink-0",children:n.symbolCount})]}),a&&n.children.map(c=>p.jsx(Ti,{item:c,depth:r+1,expandedPaths:t,selectedPath:e,onToggleExpand:i,onSelectPath:o},c.path))]})}const Fr=Object.keys(we),Da=Object.keys(pt),Ga=[{label:"All",value:null},{label:"1 hop",value:1},{label:"2 hops",value:2},{label:"3 hops",value:3}],Na=G.memo(function({visibleNodeKinds:r,visibleEdgeTypes:t,focusDepth:e,onToggleNodeKind:i,onToggleEdgeType:o,onSetFocusDepth:a,symbolCounts:s,relationCounts:u}){return p.jsxs("div",{className:"p-4 overflow-y-auto flex-1 space-y-6",children:[p.jsxs("section",{children:[p.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--color-text-muted)] mb-1",children:"Node Types"}),p.jsx("p",{className:"text-[9px] text-[var(--color-text-muted)] mb-2",children:"Toggle visibility of node types in the graph"}),p.jsx("div",{className:"space-y-1",children:Fr.map(l=>{const h=we[l],d=r.has(l),c=s[l]??0;return p.jsxs("button",{onClick:()=>i(l),className:"w-full flex items-center gap-2 px-2 py-1 rounded text-xs hover:bg-[var(--color-bg-tertiary)] transition-colors",children:[p.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:d?h:"#333"}}),p.jsx("span",{className:d?"":"text-[var(--color-text-muted)] line-through",children:l.charAt(0).toUpperCase()+l.slice(1)}),p.jsx("span",{className:"text-[9px] text-[var(--color-text-muted)] ml-auto",children:c}),p.jsx(Pr,{open:d})]},l)})})]}),p.jsxs("section",{children:[p.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--color-text-muted)] mb-1",children:"Edge Types"}),p.jsx("p",{className:"text-[9px] text-[var(--color-text-muted)] mb-2",children:"Toggle visibility of relationship types"}),p.jsx("div",{className:"space-y-1",children:Da.map(l=>{const h=pt[l],d=Ur[l]??l,c=t.has(l),f=u[l]??0;return p.jsxs("button",{onClick:()=>o(l),className:"w-full flex items-center gap-2 px-2 py-1 rounded text-xs hover:bg-[var(--color-bg-tertiary)] transition-colors",children:[p.jsx("span",{className:"w-4 shrink-0 flex items-center",children:p.jsx("span",{className:"w-full h-0.5 rounded",style:{background:c?h:"#333"}})}),p.jsx("span",{className:c?"":"text-[var(--color-text-muted)] line-through",children:d}),p.jsx("span",{className:"text-[9px] text-[var(--color-text-muted)] ml-auto",children:f}),p.jsx(Pr,{open:c})]},l)})})]}),p.jsxs("section",{children:[p.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--color-text-muted)] mb-1",children:"Focus Depth"}),p.jsx("p",{className:"text-[9px] text-[var(--color-text-muted)] mb-2",children:"Show nodes within N hops of selected node"}),p.jsx("div",{className:"flex gap-1",children:Ga.map(l=>p.jsx("button",{onClick:()=>a(l.value),className:`text-[10px] px-2.5 py-1 rounded transition-colors ${e===l.value?"bg-[var(--color-accent)] text-white":"bg-[var(--color-bg-tertiary)] text-[var(--color-text-muted)] hover:bg-[var(--color-bg)]"}`,children:l.label},l.label))})]}),p.jsxs("section",{children:[p.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--color-text-muted)] mb-2",children:"Color Legend"}),p.jsx("div",{className:"grid grid-cols-2 gap-1",children:Fr.map(l=>p.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[p.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:we[l]}}),p.jsx("span",{children:l.charAt(0).toUpperCase()+l.slice(1)})]},l))})]})]})});function Pr({open:n}){return n?p.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-[var(--color-text-muted)]",children:[p.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),p.jsx("circle",{cx:"12",cy:"12",r:"3"})]}):p.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-[var(--color-text-muted)] opacity-40",children:[p.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),p.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),p.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Fa(n,r,t){if(!n.hasNode(r))return new Set;const e=new Set([r]),i=[[r,0]];for(;i.length>0;){const[o,a]=i.shift();if(!(a>=t))for(const s of n.neighbors(o))e.has(s)||(e.add(s),i.push([s,a+1]))}return e}var Pa=`
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
+ `,Ia=Pa,Ri=WebGLRenderingContext,Ir=Ri.UNSIGNED_BYTE,Se=Ri.FLOAT,Oa=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],za={lengthToThicknessRatio:qt.lengthToThicknessRatio};function ki(n){var r=F(F({},za),{});return(function(t){function e(){return re(this,e),le(this,e,arguments)}return he(e,t),ie(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Ia,FRAGMENT_SHADER_SOURCE:Kt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Oa,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Se},{name:"a_positionEnd",size:2,type:Se},{name:"a_normal",size:2,type:Se},{name:"a_color",size:4,type:Ir,normalized:!0},{name:"a_id",size:4,type:Ir,normalized:!0},{name:"a_sourceRadius",size:1,type:Se},{name:"a_targetRadius",size:1,type:Se}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Se},{name:"a_normalCoef",size:1,type:Se},{name:"a_sourceRadiusCoef",size:1,type:Se},{name:"a_targetRadiusCoef",size:1,type:Se}],CONSTANT_DATA:[[0,1,-1,0],[0,-1,1,0],[1,1,0,1],[1,1,0,1],[0,-1,1,0],[1,-1,0,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,u,l){var h=l.size||1,d=s.x,c=s.y,f=u.x,b=u.y,w=$e(l.color),E=f-d,L=b-c,_=s.size||1,R=u.size||1,m=E*E+L*L,y=0,S=0;m&&(m=1/Math.sqrt(m),y=-L*m*h,S=E*m*h);var C=this.array;C[a++]=d,C[a++]=c,C[a++]=f,C[a++]=b,C[a++]=y,C[a++]=S,C[a++]=w,C[a++]=o,C[a++]=_,C[a++]=R}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,l=u.u_matrix,h=u.u_zoomRatio,d=u.u_feather,c=u.u_pixelRatio,f=u.u_correctionRatio,b=u.u_sizeRatio,w=u.u_minEdgeThickness,E=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(l,!1,o.matrix),s.uniform1f(h,o.zoomRatio),s.uniform1f(b,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(c,o.pixelRatio),s.uniform1f(d,o.antiAliasingFeather),s.uniform1f(w,o.minEdgeThickness),s.uniform1f(E,r.lengthToThicknessRatio)}}])})(nt)}ki();function $a(n){return hi([ki(),gt(n),gt(F(F({},n),{},{extremity:"source"}))])}$a();var Ua=`
394
+ precision mediump float;
395
+
396
+ varying vec4 v_color;
397
+
398
+ void main(void) {
399
+ gl_FragColor = v_color;
400
+ }
401
+ `,ja=Ua,Ma=`
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
+ `,Ba=Ma,Ai=WebGLRenderingContext,Or=Ai.UNSIGNED_BYTE,Ha=Ai.FLOAT,Wa=["u_matrix"],Va=(function(n){function r(){return re(this,r),le(this,r,arguments)}return he(r,n),ie(r,[{key:"getDefinition",value:function(){return{VERTICES:2,VERTEX_SHADER_SOURCE:Ba,FRAGMENT_SHADER_SOURCE:ja,METHOD:WebGLRenderingContext.LINES,UNIFORMS:Wa,ATTRIBUTES:[{name:"a_position",size:2,type:Ha},{name:"a_color",size:4,type:Or,normalized:!0},{name:"a_id",size:4,type:Or,normalized:!0}]}}},{key:"processVisibleItem",value:function(e,i,o,a,s){var u=this.array,l=o.x,h=o.y,d=a.x,c=a.y,f=$e(s.color);u[i++]=l,u[i++]=h,u[i++]=f,u[i++]=e,u[i++]=d,u[i++]=c,u[i++]=f,u[i++]=e}},{key:"setUniforms",value:function(e,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix;o.uniformMatrix3fv(s,!1,e.matrix)}}])})(nt);function ce(n,r){return(n.startsWith("#")&&n.length>7?n.slice(0,7):n)+r}function os(){const[n,r]=G.useState(null),[t,e]=G.useState(null),[i,o]=G.useState(!0),[a,s]=G.useState(null),[u,l]=G.useState(""),[h,d]=G.useState({data:null,loading:!1,error:null}),[c,f]=G.useState(""),[b,w]=G.useState(null),[E,L]=G.useState(null),[_,R]=G.useState(null),[m,y]=G.useState(null),[S,C]=G.useState(!1),[P,O]=G.useState(null),[z,Y]=G.useState(!1),[j,g]=G.useState("explorer"),[Q,ne]=G.useState(""),[k,v]=G.useState(new Set),[B,q]=G.useState(null),[ee,oe]=G.useState(!1),[J,I]=G.useState(!1),[Le,se]=G.useState(new Set(Object.keys(we))),[ot,Ie]=G.useState(new Set(Object.keys(pt))),[at,Ue]=G.useState(null),K=G.useCallback(async()=>{try{o(!0);const[N,Z]=await Promise.all([Oe.getCodeGraphStatus().catch(()=>null),Oe.getFolder().catch(()=>null)]);if(r(N),O((Z==null?void 0:Z.currentPath)??(N==null?void 0:N.basePath)??null),N!=null&&N.indexed)try{const V=await Oe.getFullCodeGraph();V!=null&&V.symbols&&R(V)}catch{}}catch(N){e(N instanceof Error?N.message:"Failed to load")}finally{o(!1)}},[]);G.useEffect(()=>{K()},[K]);const W=G.useCallback(async()=>{if(u.trim()){d({data:null,loading:!0,error:null});try{const N=await Oe.searchCodeGraph(u);d({data:N,loading:!1,error:null}),jt(N)&&y(N)}catch(N){d({data:null,loading:!1,error:N instanceof Error?N.message:"Query failed"})}}},[u]),H=G.useCallback(async N=>{if(N.trim())try{const Z=await Oe.getSymbolContext(N);jt(Z)&&(w(Z),y(Z))}catch{}},[]),ge=G.useCallback(async N=>{if(N.trim())try{const Z=await Oe.getSymbolImpact(N);Ci(Z)&&L(Z)}catch{}},[]),M=G.useCallback(async()=>{Y(!0);try{await Oe.triggerReindex(),await K()}catch{}finally{Y(!1)}},[K]),$=G.useCallback(()=>{K()},[K]),x=G.useCallback(N=>{s(N),f(N),I(!0),H(N)},[H]),pe=G.useMemo(()=>_?ka(_.symbols):[],[_]),De=G.useMemo(()=>Q.trim()?Aa(pe,Q):pe,[pe,Q]),Ee=G.useMemo(()=>{const N={};if(_)for(const Z of _.symbols)N[Z.kind]=(N[Z.kind]??0)+1;return N},[_]),Ge=G.useMemo(()=>{const N={};if(_)for(const Z of _.relations)N[Z.type]=(N[Z.type]??0)+1;return N},[_]),ue=G.useCallback(N=>{v(Z=>{const V=new Set(Z);return V.has(N)?V.delete(N):V.add(N),V})},[]),Ne=G.useCallback((N,Z)=>{if(q(N),!_)return;const V=_.symbols.filter(me=>me.file?Z?me.file.startsWith(N+"/")||me.file.startsWith(N):me.file===N:!1);if(V.length>0){const me={symbols:V,relations:_.relations.filter(_e=>{const Gi=_e.from??_e.fromSymbol??"",Ni=_e.to??_e.toSymbol??"",Fi=V.some(wt=>wt.name===Gi),Pi=V.some(wt=>wt.name===Ni);return Fi||Pi})};y(me)}},[_]),Ye=G.useCallback(N=>{se(Z=>{const V=new Set(Z);return V.has(N)?V.delete(N):V.add(N),V})},[]),je=G.useCallback(N=>{Ie(Z=>{const V=new Set(Z);return V.has(N)?V.delete(N):V.add(N),V})},[]);if(i)return p.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:"Loading Code Graph..."});if(t)return p.jsxs("div",{className:"flex items-center justify-center h-full text-[var(--color-danger)]",children:["Failed to load: ",t]});const Fe=(n==null?void 0:n.indexed)??!1,xe=_??m;return p.jsxs("div",{className:"h-full flex flex-col",children:[p.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[p.jsx("h2",{className:"text-sm font-semibold",children:"Code Graph — Code Intelligence"}),p.jsx(qa,{label:"Code Graph",indexed:(n==null?void 0:n.indexed)??!1,running:Fe,onAction:M,actionLoading:z}),xe&&p.jsxs("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:[xe.symbols.length," symbols · ",xe.relations.length," relations"]})]}),p.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[p.jsx("span",{className:"text-[10px] text-[var(--color-text-muted)] whitespace-nowrap font-mono",children:P?`Current: ${P}`:"No project path"}),p.jsx("button",{onClick:()=>C(!0),className:"text-[10px] font-medium px-3 py-1 rounded bg-[var(--color-accent)] text-white hover:opacity-90 transition-opacity whitespace-nowrap",children:"Open Folder..."})]}),p.jsx(Ii,{open:S,onClose:()=>C(!1),onFolderChanged:$}),p.jsxs("div",{className:"flex flex-1 min-h-0",children:[p.jsxs("div",{className:"w-[30%] min-w-[320px] border-r border-[var(--color-border)] flex flex-col min-h-0",children:[p.jsx("div",{className:"flex border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:["explorer","filters"].map(N=>p.jsx("button",{onClick:()=>g(N),className:`flex-1 text-xs px-3 py-2 font-medium transition-colors ${j===N?"border-b-2 border-[var(--color-accent)] text-[var(--color-accent)]":"text-[var(--color-text-muted)] hover:text-[var(--color-text)]"}`,children:N==="explorer"?"Explorer":"Filters"},N))}),j==="explorer"&&p.jsxs("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden",children:[p.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:p.jsx(La,{tree:De,searchQuery:Q,onSearchChange:ne,expandedPaths:k,onToggleExpand:ue,selectedPath:B,onSelectPath:Ne})}),p.jsx(zr,{title:"Query",open:ee,onToggle:()=>oe(N=>!N),children:p.jsx(Ka,{queryInput:u,onQueryChange:l,onSubmit:W,result:h,gitNexusRunning:Fe,onSymbolSelect:x})}),p.jsx(zr,{title:"Symbol Explorer",open:J,onToggle:()=>I(N=>!N),children:p.jsx(Xa,{symbolInput:c,onSymbolInputChange:f,onContext:H,onImpact:ge,contextData:b,impactData:E,gitNexusRunning:Fe,onSymbolSelect:x})})]}),j==="filters"&&p.jsx(Na,{visibleNodeKinds:Le,visibleEdgeTypes:ot,focusDepth:at,onToggleNodeKind:Ye,onToggleEdgeType:je,onSetFocusDepth:Ue,symbolCounts:Ee,relationCounts:Ge})]}),p.jsx(Qa,{fullGraph:xe,contextGraph:m,selectedSymbol:a,onNodeClick:x,visibleNodeKinds:Le,visibleEdgeTypes:ot,focusDepth:at})]})]})}function zr({title:n,open:r,onToggle:t,children:e}){return p.jsxs("div",{className:"border-t border-[var(--color-border)]",children:[p.jsxs("button",{onClick:t,className:"w-full flex items-center gap-2 px-3 py-2 text-xs font-medium text-[var(--color-text-muted)] hover:text-[var(--color-text)] hover:bg-[var(--color-bg-tertiary)] transition-colors",children:[p.jsx("span",{className:"text-[10px]",children:r?"▾":"▸"}),n]}),r&&p.jsx("div",{className:"max-h-[300px] overflow-auto",children:e})]})}function qa({label:n,indexed:r,running:t,onAction:e,actionLoading:i}){const o=r?"var(--color-success)":"var(--color-text-muted)",a=r?`Indexed (${t?"active":"ready"})`:"Not indexed";return p.jsxs("span",{className:"inline-flex items-center gap-1",children:[p.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${o}20`,color:o},children:[n,": ",a]}),e&&p.jsx("button",{onClick:e,disabled:i,className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-[var(--color-accent)] text-white disabled:opacity-50 hover:opacity-90 transition-opacity",children:i?"Indexing...":"Reindex"})]})}function Ka({queryInput:n,onQueryChange:r,onSubmit:t,result:e,gitNexusRunning:i,onSymbolSelect:o}){return p.jsxs("div",{className:"p-4",children:[p.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Query Code Graph"}),!i&&p.jsx("div",{className:"mb-4 p-3 rounded-lg bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] text-sm text-[var(--color-text-muted)]",children:"Code index not available. Click Reindex to enable code graph queries."}),p.jsxs("div",{className:"flex gap-2 mb-4",children:[p.jsx("input",{type:"text",value:n,onChange:a=>r(a.target.value),onKeyDown:a=>a.key==="Enter"&&t(),placeholder:"e.g., MATCH (n) RETURN n.name LIMIT 20",className:"flex-1 text-sm px-3 py-2 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",disabled:!i}),p.jsx("button",{onClick:t,disabled:!i||e.loading,className:"text-sm px-4 py-2 rounded-lg bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:e.loading?"...":"Query"})]}),e.error&&p.jsx("div",{className:"p-3 rounded-lg bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] text-sm text-[var(--color-danger)]",children:e.error}),e.data!=null&&p.jsx(Ya,{data:e.data,onSymbolSelect:o})]})}function Ya({data:n,onSymbolSelect:r}){return jt(n)?p.jsx(Li,{symbols:n.symbols,onSymbolSelect:r}):Ci(n)?p.jsx(Di,{impact:n,onSymbolSelect:r}):Ca(n)?p.jsx(Nr,{data:n.result}):Sa(n)?p.jsx(Nr,{data:n}):p.jsx(Ra,{data:n})}function Li({symbols:n,onSymbolSelect:r}){const[t,e]=G.useState(0),i=50,o=Math.ceil(n.length/i),a=n.slice(t*i,(t+1)*i);return p.jsxs("div",{children:[p.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] mb-2",children:[n.length," symbols found"]}),p.jsxs("table",{className:"w-full text-xs",children:[p.jsx("thead",{children:p.jsxs("tr",{className:"border-b border-[var(--color-border)] text-left text-[var(--color-text-muted)]",children:[p.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Name"}),p.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Kind"}),p.jsx("th",{className:"py-1.5 px-2 font-medium",children:"File"}),p.jsx("th",{className:"py-1.5 px-2 font-medium",children:"Lines"})]})}),p.jsx("tbody",{children:a.map(s=>p.jsxs("tr",{onClick:()=>r(s.name),className:"border-b border-[var(--color-border)] hover:bg-[var(--color-bg-tertiary)] cursor-pointer transition-colors",children:[p.jsx("td",{className:"py-1 px-2 font-medium",children:s.name}),p.jsx("td",{className:"py-1 px-2",children:p.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:`${we[s.kind]??"#9e9e9e"}20`,color:we[s.kind]??"#9e9e9e"},children:s.kind})}),p.jsx("td",{className:"py-1 px-2 text-[var(--color-text-muted)] truncate max-w-[200px]",children:s.file??"—"}),p.jsx("td",{className:"py-1 px-2 text-[var(--color-text-muted)]",children:s.startLine!=null?`${s.startLine}–${s.endLine??s.startLine}`:"—"})]},`${s.name}-${s.file??""}-${s.startLine??""}`))})]}),o>1&&p.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2 text-xs",children:[p.jsx("button",{onClick:()=>e(s=>Math.max(0,s-1)),disabled:t===0,className:"px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] disabled:opacity-30",children:"Prev"}),p.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[t+1," / ",o]}),p.jsx("button",{onClick:()=>e(s=>Math.min(o-1,s+1)),disabled:t>=o-1,className:"px-2 py-0.5 rounded bg-[var(--color-bg-tertiary)] disabled:opacity-30",children:"Next"})]})]})}const Za={low:"#4caf50",medium:"#ff9800",high:"#f44336"};function Di({impact:n,onSymbolSelect:r}){const t=Za[n.riskLevel]??"#9e9e9e";return p.jsxs("div",{className:"rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] p-4",children:[p.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[p.jsxs("span",{className:"text-sm font-semibold",children:["Impact: ",n.symbol]}),p.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${t}20`,color:t},children:[n.riskLevel," risk"]})]}),p.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] mb-2",children:[n.affectedSymbols.length," affected symbols"]}),p.jsx("div",{className:"space-y-1",children:n.affectedSymbols.map(e=>p.jsxs("button",{onClick:()=>r(e.name),className:"w-full text-left flex items-center justify-between px-2 py-1 rounded hover:bg-[var(--color-bg-tertiary)] transition-colors text-xs",children:[p.jsx("span",{className:"font-medium",children:e.name}),p.jsxs("span",{className:"text-[var(--color-text-muted)] flex items-center gap-2",children:[p.jsx("span",{className:"truncate max-w-[150px]",children:e.file}),p.jsxs("span",{children:[Math.round(e.confidence*100),"%"]})]})]},`${e.name}-${e.file}`))})]})}function Xa({symbolInput:n,onSymbolInputChange:r,onContext:t,onImpact:e,contextData:i,impactData:o,gitNexusRunning:a,onSymbolSelect:s}){return p.jsxs("div",{className:"p-4",children:[p.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Symbol Explorer"}),!a&&p.jsx("div",{className:"mb-4 p-3 rounded-lg bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] text-sm text-[var(--color-text-muted)]",children:"Code index not available. Click Reindex to explore symbols."}),p.jsxs("div",{className:"flex gap-2 mb-4",children:[p.jsx("input",{type:"text",value:n,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&t(n),placeholder:"e.g., SqliteStore, buildTaskContext",className:"flex-1 text-sm px-3 py-2 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",disabled:!a}),p.jsx("button",{onClick:()=>t(n),disabled:!a||!n.trim(),className:"text-sm px-3 py-2 rounded-lg bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:"Context"}),p.jsx("button",{onClick:()=>e(n),disabled:!a||!n.trim(),className:"text-sm px-3 py-2 rounded-lg bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:"Impact"})]}),i&&p.jsxs("div",{className:"mb-4",children:[p.jsxs("h4",{className:"text-xs font-semibold mb-2 text-[var(--color-text-muted)]",children:["Context — ",i.symbols.length," symbols"]}),p.jsx(Li,{symbols:i.symbols,onSymbolSelect:s})]}),o&&p.jsx(Di,{impact:o,onSymbolSelect:s}),!i&&!o&&p.jsx("div",{className:"text-center text-[var(--color-text-muted)] text-sm py-8",children:"Enter a symbol name and click Context or Impact to explore"})]})}function Qa({fullGraph:n,contextGraph:r,selectedSymbol:t,onNodeClick:e,visibleNodeKinds:i,visibleEdgeTypes:o,focusDepth:a}){const[s,u]=G.useState(null);if(!n||n.symbols.length===0)return p.jsx("div",{className:"flex-1 min-w-[300px] flex items-center justify-center",style:{background:"#06060f"},children:p.jsxs("div",{className:"text-center text-[#3a3a5a]",children:[p.jsx("p",{className:"text-sm mb-1",children:"No symbol graph"}),p.jsx("p",{className:"text-xs",children:"Query or select a symbol to see its graph"})]})});const l=G.useMemo(()=>{const d=new Set;if(r)for(const c of r.symbols)d.add(c.name);return d},[r]),h=s??t;return p.jsxs("div",{className:"flex-1 min-w-[300px] relative",style:{background:"#06060f"},children:[p.jsx("div",{className:"absolute top-2 left-2 z-10 flex flex-wrap gap-1 rounded-lg px-2 py-1.5",style:{background:"#06060fdd"},children:Object.entries(we).map(([d,c])=>p.jsx("span",{className:"text-[8px] font-medium px-1.5 py-0.5 rounded-full",style:{background:`${c}20`,color:c,textShadow:`0 0 8px ${c}`},children:d},d))}),p.jsxs("div",{className:"absolute bottom-2 right-2 z-10 text-[9px]",style:{color:"#3a3a5a"},children:[n.symbols.length," nodes · ",n.relations.length," edges"]}),p.jsxs(ma,{style:{width:"100%",height:"100%",background:"#06060f"},settings:{defaultNodeColor:"#3a3a5a",defaultEdgeColor:"#151525",stagePadding:40,labelColor:{color:"#c0c0e0"},labelSize:11,labelFont:"monospace",labelWeight:"bold",labelRenderedSizeThreshold:10,labelDensity:.5,renderLabels:!0,renderEdgeLabels:!0,enableEdgeEvents:!1,defaultEdgeType:"arrow",edgeProgramClasses:{arrow:mi,line:Va},defaultDrawNodeHover:es,defaultDrawNodeLabel:Ja,minEdgeThickness:.5,minCameraRatio:.05,maxCameraRatio:10,zIndex:!0},children:[p.jsx(ts,{fullGraph:n,highlightedNodes:l,selectedSymbol:t}),p.jsx(rs,{onNodeClick:e,onNodeHover:u,activeNode:h,highlightedNodes:l,visibleNodeKinds:i,visibleEdgeTypes:o,focusDepth:a,selectedSymbol:t})]})]})}function Ja(n,r,t){const{x:e,y:i,size:o,color:a,label:s}=r;if(!s)return;const u=t.labelSize;n.font=`${t.labelWeight} ${u}px ${t.labelFont}`,n.shadowColor=a,n.shadowBlur=6,n.fillStyle="#d0d0f0",n.fillText(s,e+o*1.5,i+u/3),n.shadowBlur=0}function es(n,r){const{x:t,y:e,size:i,color:o,label:a}=r,s=n.createRadialGradient(t,e,i*.5,t,e,i*6);s.addColorStop(0,ce(o,"80")),s.addColorStop(.3,ce(o,"30")),s.addColorStop(.6,ce(o,"10")),s.addColorStop(1,ce(o,"00")),n.beginPath(),n.arc(t,e,i*6,0,Math.PI*2),n.fillStyle=s,n.fill(),n.beginPath(),n.arc(t,e,i*1.5,0,Math.PI*2),n.fillStyle=o,n.fill(),n.beginPath(),n.arc(t,e,i*.5,0,Math.PI*2),n.fillStyle="#ffffff",n.fill(),a&&(n.font="bold 13px monospace",n.shadowColor=o,n.shadowBlur=12,n.fillStyle="#ffffff",n.fillText(a,t+i*2,e+4),n.shadowBlur=0)}function ts({fullGraph:n,highlightedNodes:r,selectedSymbol:t}){const e=pa(),i=yt();return G.useEffect(()=>{const o=new X({type:"directed",multi:!1,allowSelfLoops:!1});for(const u of n.symbols)if(!o.hasNode(u.name)){const l=we[u.kind]??"#6a6a8a";o.addNode(u.name,{label:u.name,size:3,color:l,baseColor:l,kind:u.kind,x:Math.random()*200-100,y:Math.random()*200-100})}const a=new Set;for(const u of n.relations){const l=u.from??u.fromSymbol??"",h=u.to??u.toSymbol??"",d=`${l}\0${h}`;if(!l||!h||!o.hasNode(l)||!o.hasNode(h)||l===h||a.has(d))continue;a.add(d);const c=pt[u.type]??"#2a2a50";try{o.addEdge(l,h,{color:ce(c,"a0"),size:.5,baseColor:c,relType:u.type,label:Ur[u.type]??u.type,type:u.type==="belongs_to"?"line":"arrow"})}catch{}}o.order>0&&_a.assign(o,{iterations:o.order>500?250:180,settings:{gravity:.3,scalingRatio:o.order>200?8:4,barnesHutOptimize:o.order>50,barnesHutTheta:.5,strongGravityMode:!1,slowDown:3,adjustSizes:!0,linLogMode:!0,outboundAttractionDistribution:!0}}),e(o);const s=i.getGraph();s.forEachNode(u=>{const l=s.degree(u),h=Math.min(10,Math.max(1.5,1.5+Math.pow(l,.6)*.8));s.setNodeAttribute(u,"size",h)})},[n,e,i]),G.useEffect(()=>{const o=i.getGraph(),a=r.size>0;o.forEachNode(s=>{const u=o.getNodeAttribute(s,"baseColor")??"#6a6a8a",l=o.degree(s),h=r.has(s),d=s===t,c=a&&!h;if(d)o.setNodeAttribute(s,"size",14),o.setNodeAttribute(s,"zIndex",2);else if(h){const f=Math.min(10,Math.max(5,5+Math.sqrt(l)*1.2));o.setNodeAttribute(s,"size",f),o.setNodeAttribute(s,"zIndex",1)}else{const f=Math.min(10,Math.max(1.5,1.5+Math.pow(l,.6)*.8));o.setNodeAttribute(s,"size",f),o.setNodeAttribute(s,"zIndex",0)}d?o.setNodeAttribute(s,"color","#ffffff"):c?o.setNodeAttribute(s,"color",ce(u,"30")):o.setNodeAttribute(s,"color",u)}),o.forEachEdge((s,u,l,h)=>{const d=o.getEdgeAttribute(s,"baseColor")??"#2a2a50",c=r.has(l),f=r.has(h),b=t!=null&&(l===t||h===t),w=c&&f;b?(o.setEdgeAttribute(s,"color",ce(d,"f0")),o.setEdgeAttribute(s,"size",3),o.setEdgeAttribute(s,"zIndex",2)):w?(o.setEdgeAttribute(s,"color",ce(d,"90")),o.setEdgeAttribute(s,"size",1.5),o.setEdgeAttribute(s,"zIndex",1)):a&&!w&&!b?(o.setEdgeAttribute(s,"color",ce("#080815","20")),o.setEdgeAttribute(s,"size",.15),o.setEdgeAttribute(s,"zIndex",0)):(o.setEdgeAttribute(s,"color",ce(d,"50")),o.setEdgeAttribute(s,"size",.4),o.setEdgeAttribute(s,"zIndex",0))}),i.refresh()},[r,t,i]),null}function rs({onNodeClick:n,onNodeHover:r,activeNode:t,highlightedNodes:e,visibleNodeKinds:i,visibleEdgeTypes:o,focusDepth:a,selectedSymbol:s}){const u=ga(),l=yt();return G.useEffect(()=>{u({clickNode:h=>{n(h.node)},enterNode:h=>{r(h.node)},leaveNode:()=>{r(null)}})},[u,n,r]),G.useEffect(()=>{const h=l.getGraph();let d=null;a!=null&&s&&h.hasNode(s)&&(d=Fa(h,s,a)),l.setSetting("nodeReducer",(c,f)=>{const b=h.getNodeAttribute(c,"kind");if(!i.has(b))return{...f,hidden:!0};if(d&&!d.has(c))return{...f,hidden:!0};if(t&&h.hasNode(t)){const w=new Set(h.neighbors(t));if(w.add(t),c===t)return{...f,color:"#ffffff",size:(f.size??3)*1.3,zIndex:3};if(w.has(c)){const E=h.getNodeAttribute(c,"baseColor")??"#6a6a8a";return{...f,color:E.startsWith("#")&&E.length>7?E.slice(0,7):E,zIndex:2}}if(e.size===0){const E=h.getNodeAttribute(c,"baseColor")??"#6a6a8a";return{...f,color:ce(E,"25"),zIndex:0}}{const E=f.color??"#6a6a8a";return{...f,color:E.startsWith("#")&&E.length>7?E.slice(0,7):E}}}return f}),l.setSetting("edgeReducer",(c,f)=>{const b=h.source(c),w=h.target(c),E=h.getEdgeAttribute(c,"relType");if(!o.has(E))return{...f,hidden:!0};const L=h.getNodeAttribute(b,"kind"),_=h.getNodeAttribute(w,"kind");if(!i.has(L)||!i.has(_))return{...f,hidden:!0};if(d&&(!d.has(b)||!d.has(w)))return{...f,hidden:!0};if(t&&h.hasNode(t)){if(b===t||w===t){const m=h.getEdgeAttribute(c,"baseColor")??"#4a4a7a";return{...f,color:ce(m,"f0"),size:3,zIndex:2,forceLabel:!0}}if(e.size===0)return{...f,color:"#1e1e3a",size:.2,zIndex:0}}return f})},[t,e,i,o,a,s,l]),null}export{os as GitNexusTab};