@mcp-graph-workflow/mcp-graph 5.31.1 → 5.33.1

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 (152) hide show
  1. package/README.md +1 -1
  2. package/dist/api/router.d.ts.map +1 -1
  3. package/dist/api/router.js +2 -0
  4. package/dist/api/router.js.map +1 -1
  5. package/dist/api/routes/davinci.d.ts +3 -0
  6. package/dist/api/routes/davinci.d.ts.map +1 -0
  7. package/dist/api/routes/davinci.js +188 -0
  8. package/dist/api/routes/davinci.js.map +1 -0
  9. package/dist/api/routes/translation-project.js +2 -2
  10. package/dist/api/routes/translation-project.js.map +1 -1
  11. package/dist/api/routes/translation.js +2 -2
  12. package/dist/api/routes/translation.js.map +1 -1
  13. package/dist/core/davinci/build-runner.d.ts +37 -0
  14. package/dist/core/davinci/build-runner.d.ts.map +1 -0
  15. package/dist/core/davinci/build-runner.js +239 -0
  16. package/dist/core/davinci/build-runner.js.map +1 -0
  17. package/dist/core/davinci/davinci-parser.d.ts +6 -0
  18. package/dist/core/davinci/davinci-parser.d.ts.map +1 -0
  19. package/dist/core/davinci/davinci-parser.js +218 -0
  20. package/dist/core/davinci/davinci-parser.js.map +1 -0
  21. package/dist/core/davinci/davinci-store.d.ts +49 -0
  22. package/dist/core/davinci/davinci-store.d.ts.map +1 -0
  23. package/dist/core/davinci/davinci-store.js +121 -0
  24. package/dist/core/davinci/davinci-store.js.map +1 -0
  25. package/dist/core/davinci/davinci-types.d.ts +241 -0
  26. package/dist/core/davinci/davinci-types.d.ts.map +1 -0
  27. package/dist/core/davinci/davinci-types.js +123 -0
  28. package/dist/core/davinci/davinci-types.js.map +1 -0
  29. package/dist/core/davinci/davinci-validators.d.ts +16 -0
  30. package/dist/core/davinci/davinci-validators.d.ts.map +1 -0
  31. package/dist/core/davinci/davinci-validators.js +86 -0
  32. package/dist/core/davinci/davinci-validators.js.map +1 -0
  33. package/dist/core/davinci/descriptor-generator.d.ts +19 -0
  34. package/dist/core/davinci/descriptor-generator.d.ts.map +1 -0
  35. package/dist/core/davinci/descriptor-generator.js +52 -0
  36. package/dist/core/davinci/descriptor-generator.js.map +1 -0
  37. package/dist/core/davinci/plugin-generator.d.ts +29 -0
  38. package/dist/core/davinci/plugin-generator.d.ts.map +1 -0
  39. package/dist/core/davinci/plugin-generator.js +86 -0
  40. package/dist/core/davinci/plugin-generator.js.map +1 -0
  41. package/dist/core/davinci/plugin-type-detector.d.ts +15 -0
  42. package/dist/core/davinci/plugin-type-detector.d.ts.map +1 -0
  43. package/dist/core/davinci/plugin-type-detector.js +114 -0
  44. package/dist/core/davinci/plugin-type-detector.js.map +1 -0
  45. package/dist/core/davinci/pom-generator.d.ts +4 -0
  46. package/dist/core/davinci/pom-generator.d.ts.map +1 -0
  47. package/dist/core/davinci/pom-generator.js +179 -0
  48. package/dist/core/davinci/pom-generator.js.map +1 -0
  49. package/dist/core/davinci/template-registry.d.ts +25 -0
  50. package/dist/core/davinci/template-registry.d.ts.map +1 -0
  51. package/dist/core/davinci/template-registry.js +280 -0
  52. package/dist/core/davinci/template-registry.js.map +1 -0
  53. package/dist/core/davinci/variable-resolver.d.ts +9 -0
  54. package/dist/core/davinci/variable-resolver.d.ts.map +1 -0
  55. package/dist/core/davinci/variable-resolver.js +62 -0
  56. package/dist/core/davinci/variable-resolver.js.map +1 -0
  57. package/dist/core/parser/read-swagger.d.ts.map +1 -1
  58. package/dist/core/parser/read-swagger.js +6 -0
  59. package/dist/core/parser/read-swagger.js.map +1 -1
  60. package/dist/core/siebel/sif-parser.d.ts.map +1 -1
  61. package/dist/core/siebel/sif-parser.js +6 -0
  62. package/dist/core/siebel/sif-parser.js.map +1 -1
  63. package/dist/core/siebel/wsdl-parser.d.ts.map +1 -1
  64. package/dist/core/siebel/wsdl-parser.js +6 -0
  65. package/dist/core/siebel/wsdl-parser.js.map +1 -1
  66. package/dist/core/translation/generators/ast-placeholder-extractor.d.ts +20 -0
  67. package/dist/core/translation/generators/ast-placeholder-extractor.d.ts.map +1 -0
  68. package/dist/core/translation/generators/ast-placeholder-extractor.js +215 -0
  69. package/dist/core/translation/generators/ast-placeholder-extractor.js.map +1 -0
  70. package/dist/core/translation/generators/placeholder-resolver.d.ts +18 -0
  71. package/dist/core/translation/generators/placeholder-resolver.d.ts.map +1 -0
  72. package/dist/core/translation/generators/placeholder-resolver.js +487 -0
  73. package/dist/core/translation/generators/placeholder-resolver.js.map +1 -0
  74. package/dist/core/translation/generators/source-text-extractor.d.ts +20 -0
  75. package/dist/core/translation/generators/source-text-extractor.d.ts.map +1 -0
  76. package/dist/core/translation/generators/source-text-extractor.js +190 -0
  77. package/dist/core/translation/generators/source-text-extractor.js.map +1 -0
  78. package/dist/core/translation/generators/universal-generator.d.ts +23 -0
  79. package/dist/core/translation/generators/universal-generator.d.ts.map +1 -0
  80. package/dist/core/translation/generators/universal-generator.js +315 -0
  81. package/dist/core/translation/generators/universal-generator.js.map +1 -0
  82. package/dist/core/translation/language-detect.d.ts.map +1 -1
  83. package/dist/core/translation/language-detect.js +37 -14
  84. package/dist/core/translation/language-detect.js.map +1 -1
  85. package/dist/core/translation/parsers/parser-adapter.d.ts +4 -0
  86. package/dist/core/translation/parsers/parser-adapter.d.ts.map +1 -1
  87. package/dist/core/translation/project-translation-orchestrator.d.ts +3 -3
  88. package/dist/core/translation/project-translation-orchestrator.d.ts.map +1 -1
  89. package/dist/core/translation/project-translation-orchestrator.js +4 -4
  90. package/dist/core/translation/project-translation-orchestrator.js.map +1 -1
  91. package/dist/core/translation/prompt-builder.d.ts +4 -0
  92. package/dist/core/translation/prompt-builder.d.ts.map +1 -1
  93. package/dist/core/translation/prompt-builder.js +13 -3
  94. package/dist/core/translation/prompt-builder.js.map +1 -1
  95. package/dist/core/translation/translation-orchestrator.d.ts +2 -1
  96. package/dist/core/translation/translation-orchestrator.d.ts.map +1 -1
  97. package/dist/core/translation/translation-orchestrator.js +21 -2
  98. package/dist/core/translation/translation-orchestrator.js.map +1 -1
  99. package/dist/docs-manifest.json +64 -2
  100. package/dist/mcp/app-factory.js +1 -1
  101. package/dist/mcp/app-factory.js.map +1 -1
  102. package/dist/mcp/tools/davinci-analyze.d.ts +4 -0
  103. package/dist/mcp/tools/davinci-analyze.d.ts.map +1 -0
  104. package/dist/mcp/tools/davinci-analyze.js +31 -0
  105. package/dist/mcp/tools/davinci-analyze.js.map +1 -0
  106. package/dist/mcp/tools/davinci-build.d.ts +4 -0
  107. package/dist/mcp/tools/davinci-build.d.ts.map +1 -0
  108. package/dist/mcp/tools/davinci-build.js +43 -0
  109. package/dist/mcp/tools/davinci-build.js.map +1 -0
  110. package/dist/mcp/tools/davinci-convert.d.ts +4 -0
  111. package/dist/mcp/tools/davinci-convert.d.ts.map +1 -0
  112. package/dist/mcp/tools/davinci-convert.js +61 -0
  113. package/dist/mcp/tools/davinci-convert.js.map +1 -0
  114. package/dist/mcp/tools/index.d.ts.map +1 -1
  115. package/dist/mcp/tools/index.js +8 -0
  116. package/dist/mcp/tools/index.js.map +1 -1
  117. package/dist/mcp/tools/translate-code.js +1 -1
  118. package/dist/mcp/tools/translate-code.js.map +1 -1
  119. package/dist/web/dashboard/dist/assets/{benchmark-tab-GHO9Ji5M.js → benchmark-tab-BezNQCQh.js} +1 -1
  120. package/dist/web/dashboard/dist/assets/{circle-alert-CfDAmNcO.js → circle-alert-DKsqBTgC.js} +1 -1
  121. package/dist/web/dashboard/dist/assets/{context-tab-B_6B65lw.js → context-tab-Cmar9i-X.js} +1 -1
  122. package/dist/web/dashboard/dist/assets/davinci-tab-CkWYkDsy.js +10 -0
  123. package/dist/web/dashboard/dist/assets/{docs-tab-Dq7rtZol.js → docs-tab-CYpDJ3Rl.js} +1 -1
  124. package/dist/web/dashboard/dist/assets/file-code-B0t0xVTk.js +11 -0
  125. package/dist/web/dashboard/dist/assets/{gitnexus-tab-DAPpyAe_.js → gitnexus-tab-COEhhMeC.js} +1 -1
  126. package/dist/web/dashboard/dist/assets/{graph-section-O0mwo9kz.js → graph-section-CheOuwv_.js} +1 -1
  127. package/dist/web/dashboard/dist/assets/{graph-tab-CAx8lu7Z.js → graph-tab-B52UV5KP.js} +1 -1
  128. package/dist/web/dashboard/dist/assets/{graph-utils-BwdXFM9h.js → graph-utils-D5HpaYbf.js} +1 -1
  129. package/dist/web/dashboard/dist/assets/{index-f0wNMEe_.js → index--SYA0Gq0.js} +1 -1
  130. package/dist/web/dashboard/dist/assets/index-BcMjWikL.css +1 -0
  131. package/dist/web/dashboard/dist/assets/{index-BxYtgAYc.js → index-DFMBuNWV.js} +1 -1
  132. package/dist/web/dashboard/dist/assets/{index-D_SBClB-.js → index-DdenFaJ5.js} +24 -19
  133. package/dist/web/dashboard/dist/assets/{insights-tab-DfH4O_Gj.js → insights-tab-sPgv-iwt.js} +1 -1
  134. package/dist/web/dashboard/dist/assets/{journey-tab-D2_EXArZ.js → journey-tab-CS416bwg.js} +1 -1
  135. package/dist/web/dashboard/dist/assets/languages-tab-CcB_s-Ic.js +108 -0
  136. package/dist/web/dashboard/dist/assets/{loader-circle-D5Z5DuF4.js → loader-circle-BSNUICqd.js} +1 -1
  137. package/dist/web/dashboard/dist/assets/{logs-tab-DwVCJxNs.js → logs-tab-BbDXtvmz.js} +1 -1
  138. package/dist/web/dashboard/dist/assets/{lsp-tab-D_3asNom.js → lsp-tab-BrytF6mP.js} +3 -3
  139. package/dist/web/dashboard/dist/assets/{memories-tab-BVe3nUf6.js → memories-tab-qCFdXJIV.js} +1 -1
  140. package/dist/web/dashboard/dist/assets/{prd-backlog-tab-DmeNjNES.js → prd-backlog-tab-BiNvyICT.js} +1 -1
  141. package/dist/web/dashboard/dist/assets/{refresh-cw-dY_ihv6e.js → refresh-cw-CqVWFFCW.js} +1 -1
  142. package/dist/web/dashboard/dist/assets/{siebel-tab-CUO3fUiF.js → siebel-tab-DFNHIBbS.js} +3 -3
  143. package/dist/web/dashboard/dist/assets/{sif-parse.worker-DZrybOHz.js → sif-parse.worker-Cty_N-lP.js} +3 -3
  144. package/dist/web/dashboard/dist/assets/{skills-tab-lUKwXrZi.js → skills-tab-DlInZCyj.js} +1 -1
  145. package/dist/web/dashboard/dist/assets/{style-Chqa3iIg.js → style-B4jQtUGE.js} +1 -1
  146. package/dist/web/dashboard/dist/assets/triangle-alert-CqXtIU3H.js +16 -0
  147. package/dist/web/dashboard/dist/assets/upload-Cb3pIYT5.js +16 -0
  148. package/dist/web/dashboard/dist/index.html +2 -2
  149. package/package.json +2 -2
  150. package/dist/web/dashboard/dist/assets/index-BVhCKhGJ.css +0 -1
  151. package/dist/web/dashboard/dist/assets/languages-tab-Cs-EF0mT.js +0 -123
  152. package/dist/web/dashboard/dist/assets/triangle-alert-CkVvjxDP.js +0 -26
@@ -1 +1 @@
1
- import{r as o,a as m,j as e,R as v}from"./index-D_SBClB-.js";function C(){const[t,s]=o.useState(null),[l,n]=o.useState(!0),[a,i]=o.useState(null),x=o.useCallback(async()=>{n(!0),i(null);try{const u=await m.getContextBudget();s(u)}catch(u){i(u instanceof Error?u.message:"Failed to load context budget")}finally{n(!1)}},[]);return o.useEffect(()=>{x()},[x]),{budget:t,loading:l,error:a,refresh:x}}function S(){const[t,s]=o.useState(null),[l,n]=o.useState([]),[a,i]=o.useState(null),[x,u]=o.useState(!0),[g,r]=o.useState(null),d=o.useCallback(async()=>{u(!0),r(null);try{const[c,h,k]=await Promise.all([m.dreamGetStatus(),m.dreamGetHistory(20),m.dreamGetMetrics()]);s(c),n(h),i(k)}catch(c){r(c instanceof Error?c.message:"Failed to load dream data")}finally{u(!1)}},[]);o.useEffect(()=>{d()},[d]);const y=o.useCallback(async c=>{try{await m.dreamStartCycle(c),setTimeout(()=>void d(),500)}catch(h){r(h instanceof Error?h.message:"Failed to start dream cycle")}},[d]),N=o.useCallback(async()=>{try{await m.dreamCancelCycle(),d()}catch(c){r(c instanceof Error?c.message:"Failed to cancel dream cycle")}},[d]),w=o.useCallback(async()=>{try{return await m.dreamGetPreview()}catch(c){return r(c instanceof Error?c.message:"Failed to get dream preview"),null}},[]);return{status:t,history:l,metrics:a,loading:x,error:g,startCycle:y,cancelCycle:N,preview:w,refresh:d}}const b=[{key:"nrem",label:"NREM",subtitle:"Replay + Decay + Prune"},{key:"rem",label:"REM",subtitle:"Priority + Merge + Associate"},{key:"wake-ready",label:"Wake",subtitle:"Report + Synthesize"}],p={completed:"#10b981",active:"#3B82F6",pending:"#6b7280"};function f(t,s,l){if(!l)return"pending";const n=["nrem","rem","wake-ready"],a=n.indexOf(s??""),i=n.indexOf(t);return i<a?"completed":i===a?"active":"pending"}function M({status:t}){return e.jsx("div",{className:"flex items-center gap-2",children:b.map((s,l)=>{const n=f(s.key,t.currentPhase,t.running),a=p[n];return e.jsxs(v.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 min-w-[80px]",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold transition-colors duration-200",style:{backgroundColor:n==="pending"?"transparent":a,border:`2px solid ${a}`,color:n==="pending"?a:"#fff"},children:l+1}),e.jsx("span",{className:"text-[10px] font-semibold transition-colors duration-200",style:{color:a},children:s.label}),e.jsx("span",{className:"text-[9px] text-muted text-center leading-tight",children:s.subtitle})]}),l<b.length-1&&e.jsx("div",{className:"h-0.5 flex-1 transition-colors duration-200",style:{backgroundColor:f(b[l+1].key,t.currentPhase,t.running)!=="pending"?p.completed:p.pending}})]},s.key)})})}function D({status:t,onStartCycle:s,onCancelCycle:l,onPreview:n}){const[a,i]=v.useState(!1),x=async()=>{i(!0);try{await n()}finally{i(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 rounded-xl border border-edge shadow-sm bg-surface-alt",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${t.running?"bg-blue-500 animate-pulse":"bg-gray-500"}`}),e.jsx("span",{className:"text-sm font-medium",children:t.running?"Dream Cycle Running":"Idle"}),t.running&&t.progress!==void 0&&e.jsxs("span",{className:"text-xs text-muted",children:["(",Math.round(t.progress*100),"%)"]})]})}),e.jsx(M,{status:t})]}),e.jsx("div",{className:"flex items-center gap-2",children:t.running?e.jsx("button",{onClick:l,className:"px-4 py-2 text-sm font-medium rounded-lg bg-red-600/80 text-white hover:bg-red-600 cursor-pointer transition-colors duration-200",children:"Cancel Cycle"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:s,className:"px-4 py-2 text-sm font-medium rounded-lg bg-blue-600 text-white hover:bg-blue-700 cursor-pointer transition-colors duration-200",children:"Start Dream Cycle"}),e.jsx("button",{onClick:()=>void x(),disabled:a,className:"px-4 py-2 text-sm font-medium rounded-lg border border-edge text-muted hover:text-white hover:border-blue-500 cursor-pointer transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed",children:a?"Previewing...":"Preview (Dry Run)"})]})})]})}const T=[{key:"totalCycles",label:"Total Cycles",format:t=>t.toString()},{key:"totalPruned",label:"Docs Pruned",format:t=>t.toLocaleString()},{key:"totalMerged",label:"Docs Merged",format:t=>t.toLocaleString()},{key:"avgQualityImprovement",label:"Avg Quality Delta",format:t=>(t>=0?"+":"")+(t*100).toFixed(1)+"%"}];function P({metrics:t}){return t?e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:T.map(({key:s,label:l,format:n})=>e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:n(t[s])}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:l})]},s))}):e.jsx(e.Fragment,{})}const E={completed:"text-green-500",running:"text-blue-500",failed:"text-red-500",cancelled:"text-yellow-500"};function R(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function $(t){return t?new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-"}function L({cycles:t}){return t.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted",children:"No dream cycles yet"}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-muted uppercase text-[10px]",children:[e.jsx("th",{className:"text-left p-2",children:"Date"}),e.jsx("th",{className:"text-left p-2",children:"Status"}),e.jsx("th",{className:"text-right p-2",children:"Pruned"}),e.jsx("th",{className:"text-right p-2",children:"Merged"}),e.jsx("th",{className:"text-right p-2",children:"Duration"})]})}),e.jsx("tbody",{children:t.map(s=>{const l=s.phases.nrem.durationMs+s.phases.rem.durationMs+s.phases.wakeReady.durationMs;return e.jsxs("tr",{className:"border-t border-edge hover:bg-surface-alt/50 transition-colors",children:[e.jsx("td",{className:"p-2",children:$(s.startedAt)}),e.jsx("td",{className:`p-2 font-medium ${E[s.status]??"text-muted"}`,children:s.status}),e.jsx("td",{className:"p-2 text-right",children:s.summary.totalPruned}),e.jsx("td",{className:"p-2 text-right",children:s.summary.totalMerged}),e.jsx("td",{className:"p-2 text-right",children:R(l)})]},s.id)})})]})})}const j={green:{bg:"bg-green-500/10",text:"text-green-500",border:"border-green-500/30"},yellow:{bg:"bg-yellow-500/10",text:"text-yellow-500",border:"border-yellow-500/30"},red:{bg:"bg-red-500/10",text:"text-red-500",border:"border-red-500/30"}};function A(){const{budget:t,loading:s,error:l,refresh:n}=C(),a=S(),[i,x]=o.useState(null);if(l)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load context budget: ",l]});if(s||!t)return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"h-5 w-48 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:Array.from({length:4}).map((r,d)=>e.jsx("div",{className:"h-20 rounded-xl border border-edge bg-surface-alt animate-pulse"},d))}),e.jsx("div",{className:"h-24 rounded-lg border border-edge bg-surface-alt animate-pulse"}),e.jsx("div",{className:"h-12 rounded-xl border border-edge bg-surface-alt animate-pulse"})]});const u=j[t.health]??j.green,g=r=>{i===r?(x(null),m.toggleSkill(r,!1).then(()=>n())):(x(r),setTimeout(()=>x(d=>d===r?null:d),3e3))};return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Context Management"}),e.jsx("button",{onClick:()=>n(),className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:opacity-90 transition-opacity",children:"Refresh"})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.activeTokens.toLocaleString()}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Active Tokens"})]}),e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.totalTokens.toLocaleString()}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Total Tokens"})]}),e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.activeCount}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Active Skills"})]}),e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.totalCount}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Total Skills"})]})]}),e.jsxs("div",{className:`p-4 rounded-lg border ${u.bg} ${u.border}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${t.health==="green"?"bg-green-500":t.health==="yellow"?"bg-yellow-500":"bg-red-500"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:`text-sm font-medium ${u.text}`,children:["Session Health: ",t.health.charAt(0).toUpperCase()+t.health.slice(1)]}),e.jsx("div",{className:"text-xs text-muted mt-0.5",children:t.healthMessage})]})]}),t.recommendations.length>0&&e.jsx("div",{className:"mt-3 space-y-1",children:t.recommendations.map((r,d)=>e.jsx("div",{className:"text-xs text-muted",children:r},d))})]}),e.jsxs("div",{className:"p-4 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-muted",children:[t.activeTokens.toLocaleString()," / 4,000 (",Math.round(t.activeTokens/40),"%)"]})]}),e.jsxs("div",{className:"w-full h-3 rounded-full bg-edge relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-20",style:{width:`${Math.min(Math.round(t.totalTokens/40),100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${Math.min(Math.round(t.activeTokens/40),100)}%`,background:t.health==="red"?"#ef4444":t.health==="yellow"?"#f59e0b":"#10b981"}})]})]}),e.jsxs("div",{className:"border-t border-edge pt-6 space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"DreamMode"}),e.jsx("p",{className:"text-xs text-muted",children:"REM-inspired knowledge consolidation: replay, decay, prune, merge, and synthesize."}),a.error&&e.jsx("div",{className:"text-xs text-red-400",children:a.error}),a.status&&e.jsx(D,{status:a.status,onStartCycle:()=>void a.startCycle(),onCancelCycle:()=>void a.cancelCycle(),onPreview:a.preview}),e.jsx(P,{metrics:a.metrics}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Cycle History"}),e.jsx(L,{cycles:a.history})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Breakdown by Skill"}),e.jsx("div",{className:"space-y-1",children:t.breakdown.map(r=>{const d=t.totalTokens>0?Math.round(r.tokens/t.totalTokens*100):0;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt ${r.enabled?"":"opacity-40"}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",children:r.name}),e.jsx("span",{className:`px-1 py-0.5 rounded text-[9px] ${r.source==="custom"?"bg-purple-500/10 text-purple-500":"bg-blue-500/10 text-blue-500"}`,children:r.source})]}),e.jsx("div",{className:"w-full h-1 rounded-full bg-edge mt-1",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${d}%`,background:r.enabled?"#3b82f6":"#6b7280"}})})]}),e.jsxs("span",{className:"text-[10px] text-muted shrink-0 w-16 text-right",children:[r.tokens.toLocaleString()," tok"]}),r.enabled&&e.jsx("button",{onClick:()=>g(r.name),className:`text-[10px] px-1.5 py-0.5 rounded border shrink-0 cursor-pointer transition-all ${i===r.name?"bg-red-500/10 text-red-400 border-red-500/30 font-medium":"border-edge text-muted hover:text-red-500 hover:border-red-500/50"}`,children:i===r.name?"Sure?":"Disable"})]},r.name)})})]})]})}export{A as ContextTab};
1
+ import{r as o,a as m,j as e,R as v}from"./index-DdenFaJ5.js";function C(){const[t,s]=o.useState(null),[l,n]=o.useState(!0),[a,i]=o.useState(null),x=o.useCallback(async()=>{n(!0),i(null);try{const u=await m.getContextBudget();s(u)}catch(u){i(u instanceof Error?u.message:"Failed to load context budget")}finally{n(!1)}},[]);return o.useEffect(()=>{x()},[x]),{budget:t,loading:l,error:a,refresh:x}}function S(){const[t,s]=o.useState(null),[l,n]=o.useState([]),[a,i]=o.useState(null),[x,u]=o.useState(!0),[g,r]=o.useState(null),d=o.useCallback(async()=>{u(!0),r(null);try{const[c,h,k]=await Promise.all([m.dreamGetStatus(),m.dreamGetHistory(20),m.dreamGetMetrics()]);s(c),n(h),i(k)}catch(c){r(c instanceof Error?c.message:"Failed to load dream data")}finally{u(!1)}},[]);o.useEffect(()=>{d()},[d]);const y=o.useCallback(async c=>{try{await m.dreamStartCycle(c),setTimeout(()=>void d(),500)}catch(h){r(h instanceof Error?h.message:"Failed to start dream cycle")}},[d]),N=o.useCallback(async()=>{try{await m.dreamCancelCycle(),d()}catch(c){r(c instanceof Error?c.message:"Failed to cancel dream cycle")}},[d]),w=o.useCallback(async()=>{try{return await m.dreamGetPreview()}catch(c){return r(c instanceof Error?c.message:"Failed to get dream preview"),null}},[]);return{status:t,history:l,metrics:a,loading:x,error:g,startCycle:y,cancelCycle:N,preview:w,refresh:d}}const b=[{key:"nrem",label:"NREM",subtitle:"Replay + Decay + Prune"},{key:"rem",label:"REM",subtitle:"Priority + Merge + Associate"},{key:"wake-ready",label:"Wake",subtitle:"Report + Synthesize"}],p={completed:"#10b981",active:"#3B82F6",pending:"#6b7280"};function f(t,s,l){if(!l)return"pending";const n=["nrem","rem","wake-ready"],a=n.indexOf(s??""),i=n.indexOf(t);return i<a?"completed":i===a?"active":"pending"}function M({status:t}){return e.jsx("div",{className:"flex items-center gap-2",children:b.map((s,l)=>{const n=f(s.key,t.currentPhase,t.running),a=p[n];return e.jsxs(v.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 min-w-[80px]",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold transition-colors duration-200",style:{backgroundColor:n==="pending"?"transparent":a,border:`2px solid ${a}`,color:n==="pending"?a:"#fff"},children:l+1}),e.jsx("span",{className:"text-[10px] font-semibold transition-colors duration-200",style:{color:a},children:s.label}),e.jsx("span",{className:"text-[9px] text-muted text-center leading-tight",children:s.subtitle})]}),l<b.length-1&&e.jsx("div",{className:"h-0.5 flex-1 transition-colors duration-200",style:{backgroundColor:f(b[l+1].key,t.currentPhase,t.running)!=="pending"?p.completed:p.pending}})]},s.key)})})}function D({status:t,onStartCycle:s,onCancelCycle:l,onPreview:n}){const[a,i]=v.useState(!1),x=async()=>{i(!0);try{await n()}finally{i(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 rounded-xl border border-edge shadow-sm bg-surface-alt",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${t.running?"bg-blue-500 animate-pulse":"bg-gray-500"}`}),e.jsx("span",{className:"text-sm font-medium",children:t.running?"Dream Cycle Running":"Idle"}),t.running&&t.progress!==void 0&&e.jsxs("span",{className:"text-xs text-muted",children:["(",Math.round(t.progress*100),"%)"]})]})}),e.jsx(M,{status:t})]}),e.jsx("div",{className:"flex items-center gap-2",children:t.running?e.jsx("button",{onClick:l,className:"px-4 py-2 text-sm font-medium rounded-lg bg-red-600/80 text-white hover:bg-red-600 cursor-pointer transition-colors duration-200",children:"Cancel Cycle"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:s,className:"px-4 py-2 text-sm font-medium rounded-lg bg-blue-600 text-white hover:bg-blue-700 cursor-pointer transition-colors duration-200",children:"Start Dream Cycle"}),e.jsx("button",{onClick:()=>void x(),disabled:a,className:"px-4 py-2 text-sm font-medium rounded-lg border border-edge text-muted hover:text-white hover:border-blue-500 cursor-pointer transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed",children:a?"Previewing...":"Preview (Dry Run)"})]})})]})}const T=[{key:"totalCycles",label:"Total Cycles",format:t=>t.toString()},{key:"totalPruned",label:"Docs Pruned",format:t=>t.toLocaleString()},{key:"totalMerged",label:"Docs Merged",format:t=>t.toLocaleString()},{key:"avgQualityImprovement",label:"Avg Quality Delta",format:t=>(t>=0?"+":"")+(t*100).toFixed(1)+"%"}];function P({metrics:t}){return t?e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:T.map(({key:s,label:l,format:n})=>e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:n(t[s])}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:l})]},s))}):e.jsx(e.Fragment,{})}const E={completed:"text-green-500",running:"text-blue-500",failed:"text-red-500",cancelled:"text-yellow-500"};function R(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function $(t){return t?new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-"}function L({cycles:t}){return t.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted",children:"No dream cycles yet"}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-muted uppercase text-[10px]",children:[e.jsx("th",{className:"text-left p-2",children:"Date"}),e.jsx("th",{className:"text-left p-2",children:"Status"}),e.jsx("th",{className:"text-right p-2",children:"Pruned"}),e.jsx("th",{className:"text-right p-2",children:"Merged"}),e.jsx("th",{className:"text-right p-2",children:"Duration"})]})}),e.jsx("tbody",{children:t.map(s=>{const l=s.phases.nrem.durationMs+s.phases.rem.durationMs+s.phases.wakeReady.durationMs;return e.jsxs("tr",{className:"border-t border-edge hover:bg-surface-alt/50 transition-colors",children:[e.jsx("td",{className:"p-2",children:$(s.startedAt)}),e.jsx("td",{className:`p-2 font-medium ${E[s.status]??"text-muted"}`,children:s.status}),e.jsx("td",{className:"p-2 text-right",children:s.summary.totalPruned}),e.jsx("td",{className:"p-2 text-right",children:s.summary.totalMerged}),e.jsx("td",{className:"p-2 text-right",children:R(l)})]},s.id)})})]})})}const j={green:{bg:"bg-green-500/10",text:"text-green-500",border:"border-green-500/30"},yellow:{bg:"bg-yellow-500/10",text:"text-yellow-500",border:"border-yellow-500/30"},red:{bg:"bg-red-500/10",text:"text-red-500",border:"border-red-500/30"}};function A(){const{budget:t,loading:s,error:l,refresh:n}=C(),a=S(),[i,x]=o.useState(null);if(l)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load context budget: ",l]});if(s||!t)return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"h-5 w-48 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:Array.from({length:4}).map((r,d)=>e.jsx("div",{className:"h-20 rounded-xl border border-edge bg-surface-alt animate-pulse"},d))}),e.jsx("div",{className:"h-24 rounded-lg border border-edge bg-surface-alt animate-pulse"}),e.jsx("div",{className:"h-12 rounded-xl border border-edge bg-surface-alt animate-pulse"})]});const u=j[t.health]??j.green,g=r=>{i===r?(x(null),m.toggleSkill(r,!1).then(()=>n())):(x(r),setTimeout(()=>x(d=>d===r?null:d),3e3))};return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Context Management"}),e.jsx("button",{onClick:()=>n(),className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:opacity-90 transition-opacity",children:"Refresh"})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.activeTokens.toLocaleString()}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Active Tokens"})]}),e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.totalTokens.toLocaleString()}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Total Tokens"})]}),e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.activeCount}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Active Skills"})]}),e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.totalCount}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Total Skills"})]})]}),e.jsxs("div",{className:`p-4 rounded-lg border ${u.bg} ${u.border}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${t.health==="green"?"bg-green-500":t.health==="yellow"?"bg-yellow-500":"bg-red-500"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:`text-sm font-medium ${u.text}`,children:["Session Health: ",t.health.charAt(0).toUpperCase()+t.health.slice(1)]}),e.jsx("div",{className:"text-xs text-muted mt-0.5",children:t.healthMessage})]})]}),t.recommendations.length>0&&e.jsx("div",{className:"mt-3 space-y-1",children:t.recommendations.map((r,d)=>e.jsx("div",{className:"text-xs text-muted",children:r},d))})]}),e.jsxs("div",{className:"p-4 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-muted",children:[t.activeTokens.toLocaleString()," / 4,000 (",Math.round(t.activeTokens/40),"%)"]})]}),e.jsxs("div",{className:"w-full h-3 rounded-full bg-edge relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-20",style:{width:`${Math.min(Math.round(t.totalTokens/40),100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${Math.min(Math.round(t.activeTokens/40),100)}%`,background:t.health==="red"?"#ef4444":t.health==="yellow"?"#f59e0b":"#10b981"}})]})]}),e.jsxs("div",{className:"border-t border-edge pt-6 space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"DreamMode"}),e.jsx("p",{className:"text-xs text-muted",children:"REM-inspired knowledge consolidation: replay, decay, prune, merge, and synthesize."}),a.error&&e.jsx("div",{className:"text-xs text-red-400",children:a.error}),a.status&&e.jsx(D,{status:a.status,onStartCycle:()=>void a.startCycle(),onCancelCycle:()=>void a.cancelCycle(),onPreview:a.preview}),e.jsx(P,{metrics:a.metrics}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Cycle History"}),e.jsx(L,{cycles:a.history})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Breakdown by Skill"}),e.jsx("div",{className:"space-y-1",children:t.breakdown.map(r=>{const d=t.totalTokens>0?Math.round(r.tokens/t.totalTokens*100):0;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt ${r.enabled?"":"opacity-40"}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",children:r.name}),e.jsx("span",{className:`px-1 py-0.5 rounded text-[9px] ${r.source==="custom"?"bg-purple-500/10 text-purple-500":"bg-blue-500/10 text-blue-500"}`,children:r.source})]}),e.jsx("div",{className:"w-full h-1 rounded-full bg-edge mt-1",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${d}%`,background:r.enabled?"#3b82f6":"#6b7280"}})})]}),e.jsxs("span",{className:"text-[10px] text-muted shrink-0 w-16 text-right",children:[r.tokens.toLocaleString()," tok"]}),r.enabled&&e.jsx("button",{onClick:()=>g(r.name),className:`text-[10px] px-1.5 py-0.5 rounded border shrink-0 cursor-pointer transition-all ${i===r.name?"bg-red-500/10 text-red-400 border-red-500/30 font-medium":"border-edge text-muted hover:text-red-500 hover:border-red-500/50"}`,children:i===r.name?"Sure?":"Disable"})]},r.name)})})]})]})}export{A as ContextTab};
@@ -0,0 +1,10 @@
1
+ import{c as $,r as n,j as e,C as I}from"./index-DdenFaJ5.js";import{U as L,C as v,a as N}from"./upload-Cb3pIYT5.js";import{S as O,T as y,C as U}from"./triangle-alert-CqXtIU3H.js";/**
2
+ * @license lucide-react v1.7.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const V=[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]],k=$("hammer",V),f="/api/v1/davinci";function G(){const[o,j]=n.useState("upload"),[a,S]=n.useState(""),[p,T]=n.useState("pingfederate"),[u,P]=n.useState("my-davinci-plugin"),[h,A]=n.useState("com.example.plugin"),[b,E]=n.useState("MyDaVinciPlugin"),[d,x]=n.useState(!1),[l,B]=n.useState(null),[i,D]=n.useState(null),[m,J]=n.useState(null),[c,z]=n.useState(null),[C,r]=n.useState(null),g=n.useCallback(async()=>{try{const t=await(await fetch(`${f}/environment`)).json();t.ok&&J(t.environment.items)}catch{}},[]),F=n.useCallback(async()=>{if(a.trim()){x(!0),r(null);try{const t=await(await fetch(`${f}/analyze`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:a})})).json();t.ok?(B(t.analysis),j("analysis")):r(t.error)}catch(s){r(s instanceof Error?s.message:"Analysis failed")}finally{x(!1)}}},[a]),w=n.useCallback(async()=>{if(a.trim()){x(!0),r(null);try{const t=await(await fetch(`${f}/convert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:a,pluginName:u,packageName:h,className:b,targetSdk:p})})).json();t.ok?(D(t),j("preview"),g()):r(t.error)}catch(s){r(s instanceof Error?s.message:"Conversion failed")}finally{x(!1)}}},[a,u,h,b,p,g]),R=n.useCallback(async()=>{if(a.trim()){x(!0),r(null),z(null);try{const t=await(await fetch(`${f}/convert-and-build`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:a,pluginName:u,packageName:h,className:b,targetSdk:p})})).json();z(t),!t.ok&&t.phase==="environment_check"?r("Build environment not ready. Install missing tools."):t.ok||r(t.buildErrors||"Build failed"),g(),j("build")}catch(s){r(s instanceof Error?s.message:"Build failed")}finally{x(!1)}}},[a,u,h,b,p,g]);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-zinc-700/50 bg-zinc-900/50",children:["upload","analysis","preview","build"].map(s=>e.jsxs("button",{onClick:()=>j(s),className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs font-medium transition-colors ${o===s?"bg-blue-600 text-white":"text-zinc-400 hover:text-white hover:bg-zinc-800"}`,children:[s==="upload"&&e.jsx(L,{size:14}),s==="analysis"&&e.jsx(O,{size:14}),s==="preview"&&e.jsx(I,{size:14}),s==="build"&&e.jsx(k,{size:14}),s.charAt(0).toUpperCase()+s.slice(1)]},s))}),C&&e.jsxs("div",{className:"mx-4 mt-2 px-3 py-2 bg-red-900/30 border border-red-700/50 rounded text-red-300 text-xs flex items-center gap-2",children:[e.jsx(y,{size:14}),C,e.jsx("button",{onClick:()=>r(null),className:"ml-auto text-red-400 hover:text-red-200",children:"x"})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[o==="upload"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200",children:"DaVinci Custom Code"}),e.jsx("p",{className:"text-xs text-zinc-400",children:"Paste your DaVinci JavaScript code (Custom Function, Code Snippet, or HTML Template)."}),e.jsx("textarea",{value:a,onChange:s=>S(s.target.value),placeholder:`module.exports = a = async ({params}) => {
7
+ const apiKey = "{{global.variables.apiKey}}";
8
+ // your DaVinci logic here
9
+ return { result: "ok" };
10
+ }`,className:"w-full h-64 bg-zinc-900 border border-zinc-700 rounded p-3 text-xs font-mono text-zinc-200 resize-y focus:outline-none focus:border-blue-500"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Target SDK"}),e.jsxs("select",{value:p,onChange:s=>T(s.target.value),className:"w-full bg-zinc-900 border border-zinc-700 rounded px-2 py-1.5 text-xs text-zinc-200",children:[e.jsx("option",{value:"pingfederate",children:"PingFederate"}),e.jsx("option",{value:"pingaccess",children:"PingAccess"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Plugin Name"}),e.jsx("input",{value:u,onChange:s=>P(s.target.value),className:"w-full bg-zinc-900 border border-zinc-700 rounded px-2 py-1.5 text-xs text-zinc-200"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Package Name"}),e.jsx("input",{value:h,onChange:s=>A(s.target.value),className:"w-full bg-zinc-900 border border-zinc-700 rounded px-2 py-1.5 text-xs text-zinc-200"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:"Class Name"}),e.jsx("input",{value:b,onChange:s=>E(s.target.value),className:"w-full bg-zinc-900 border border-zinc-700 rounded px-2 py-1.5 text-xs text-zinc-200"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:F,disabled:d||!a.trim(),className:"px-4 py-2 bg-blue-600 hover:bg-blue-500 disabled:opacity-50 text-white text-xs rounded font-medium",children:d?"Analyzing...":"Analyze"}),e.jsx("button",{onClick:w,disabled:d||!a.trim(),className:"px-4 py-2 bg-green-600 hover:bg-green-500 disabled:opacity-50 text-white text-xs rounded font-medium",children:d?"Converting...":"Convert to Java"})]})]}),o==="analysis"&&l&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200",children:"Analysis Results"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-zinc-900 border border-zinc-700 rounded p-3",children:[e.jsx("div",{className:"text-xs text-zinc-400",children:"Variables"}),e.jsx("div",{className:"text-lg font-bold text-blue-400",children:l.variables.length})]}),e.jsxs("div",{className:"bg-zinc-900 border border-zinc-700 rounded p-3",children:[e.jsx("div",{className:"text-xs text-zinc-400",children:"API Calls"}),e.jsx("div",{className:"text-lg font-bold text-purple-400",children:l.apiCalls.length})]}),e.jsxs("div",{className:"bg-zinc-900 border border-zinc-700 rounded p-3",children:[e.jsx("div",{className:"text-xs text-zinc-400",children:"Plugin Type"}),e.jsx("div",{className:"text-sm font-bold text-green-400",children:l.recommendedPluginType}),e.jsxs("div",{className:"text-xs text-zinc-500",children:[(l.pluginTypeConfidence*100).toFixed(0),"% confidence"]})]})]}),l.variables.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-zinc-300 mb-2",children:"Variables Detected"}),e.jsx("div",{className:"space-y-1",children:l.variables.map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs bg-zinc-900/50 px-2 py-1 rounded",children:[e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${s.kind==="global"?"bg-blue-900/50 text-blue-300":s.kind==="local"?"bg-yellow-900/50 text-yellow-300":s.kind==="flow"?"bg-purple-900/50 text-purple-300":"bg-zinc-800 text-zinc-300"}`,children:s.kind}),e.jsx("span",{className:"font-mono text-zinc-300",children:s.fieldName}),e.jsx("span",{className:"text-zinc-500 ml-auto",children:s.rawTemplate})]},t))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-zinc-300 mb-2",children:"Flow Logic"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(l.flowLogic).map(([s,t])=>e.jsxs("span",{className:`px-2 py-1 rounded text-[10px] font-medium ${t?"bg-green-900/30 text-green-400":"bg-zinc-800 text-zinc-500"}`,children:[t?e.jsx(v,{size:10,className:"inline mr-1"}):null,s.replace("has","")]},s))})]}),l.warnings.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-yellow-400 mb-2",children:"Warnings"}),l.warnings.map((s,t)=>e.jsxs("div",{className:"text-xs text-yellow-300 bg-yellow-900/20 px-2 py-1 rounded mb-1 flex items-start gap-1.5",children:[e.jsx(y,{size:12,className:"mt-0.5 shrink-0"}),s]},t))]}),e.jsxs("button",{onClick:w,disabled:d,className:"px-4 py-2 bg-green-600 hover:bg-green-500 disabled:opacity-50 text-white text-xs rounded font-medium flex items-center gap-1.5",children:[e.jsx(U,{size:14}),d?"Converting...":"Convert to Java"]})]}),o==="analysis"&&!l&&e.jsx("div",{className:"text-center text-zinc-500 text-sm py-12",children:"No analysis yet. Go to Upload and click Analyze."}),o==="preview"&&i&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200",children:"Generated Java Plugin"}),e.jsxs("span",{className:"text-xs px-2 py-1 bg-green-900/30 text-green-400 rounded",children:[i.pluginType," (",(i.confidence*100).toFixed(0),"%)"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-medium text-zinc-400",children:"Java Source"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(i.javaCode),className:"text-[10px] text-blue-400 hover:text-blue-300",children:"Copy"})]}),e.jsx("pre",{className:"bg-zinc-950 border border-zinc-700 rounded p-3 text-[11px] font-mono text-zinc-300 overflow-auto max-h-96",children:i.javaCode})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-medium text-zinc-400",children:"pom.xml"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(i.pomXml),className:"text-[10px] text-blue-400 hover:text-blue-300",children:"Copy"})]}),e.jsx("pre",{className:"bg-zinc-950 border border-zinc-700 rounded p-3 text-[11px] font-mono text-zinc-300 overflow-auto max-h-96",children:i.pomXml})]})]}),e.jsxs("div",{className:"bg-zinc-900 border border-zinc-700 rounded p-3",children:[e.jsx("span",{className:"text-xs text-zinc-400",children:"PF-INF Descriptor: "}),e.jsxs("span",{className:"text-xs font-mono text-zinc-200",children:[i.pfInfType,"/",i.pfInfContent]})]}),i.warnings.length>0&&e.jsx("div",{children:i.warnings.map((s,t)=>e.jsxs("div",{className:"text-xs text-yellow-300 bg-yellow-900/20 px-2 py-1 rounded mb-1 flex items-start gap-1.5",children:[e.jsx(y,{size:12,className:"mt-0.5 shrink-0"}),s]},t))})]}),o==="preview"&&!i&&e.jsx("div",{className:"text-center text-zinc-500 text-sm py-12",children:"No conversion yet. Go to Upload and click Convert."}),o==="build"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200",children:"Build Environment"}),e.jsx("p",{className:"text-xs text-zinc-400",children:"Check if your environment has JDK + Maven installed to compile the plugin JAR."}),e.jsx("button",{onClick:g,className:"px-3 py-1.5 bg-zinc-800 hover:bg-zinc-700 text-zinc-200 text-xs rounded font-medium",children:"Check Environment"}),m&&e.jsxs("div",{className:"space-y-2",children:[m.map(s=>e.jsxs("div",{className:"flex items-center gap-3 bg-zinc-900 border border-zinc-700 rounded p-3",children:[s.available?e.jsx(v,{size:18,className:"text-green-500 shrink-0"}):e.jsx(N,{size:18,className:"text-red-500 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-medium text-zinc-200",children:s.name}),s.available&&s.version&&e.jsxs("div",{className:"text-[10px] text-zinc-500",children:["v",s.version]}),!s.available&&s.instruction&&e.jsx("div",{className:"text-[10px] text-red-400",children:s.instruction})]}),!s.available&&s.installUrl&&e.jsx("a",{href:s.installUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-blue-400 hover:text-blue-300 underline",children:"Install"})]},s.name)),e.jsx("div",{className:`flex items-center gap-2 p-3 rounded border ${m.every(s=>s.available)?"bg-green-900/20 border-green-700/50 text-green-400":"bg-red-900/20 border-red-700/50 text-red-400"}`,children:m.every(s=>s.available)?e.jsxs(e.Fragment,{children:[e.jsx(v,{size:16}),e.jsx("span",{className:"text-xs font-medium",children:"Ready to Build"})]}):e.jsxs(e.Fragment,{children:[e.jsx(N,{size:16}),e.jsx("span",{className:"text-xs font-medium",children:"Not Ready — install missing tools"})]})})]}),m&&m.every(s=>s.available)&&a.trim()&&e.jsx("div",{className:"pt-2 border-t border-zinc-700/50",children:e.jsxs("button",{onClick:R,disabled:d,className:"px-4 py-2 bg-green-600 hover:bg-green-500 disabled:opacity-50 text-white text-xs rounded font-medium flex items-center gap-1.5",children:[e.jsx(k,{size:14}),d?"Building...":"Build JAR"]})}),c&&e.jsx("div",{className:`p-3 rounded border ${c.ok?"bg-green-900/20 border-green-700/50":"bg-red-900/20 border-red-700/50"}`,children:c.ok?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-green-400",children:[e.jsx(v,{size:16}),e.jsx("span",{className:"text-xs font-medium",children:"Build Successful!"}),c.buildDurationMs&&e.jsxs("span",{className:"text-[10px] text-zinc-500 ml-auto",children:[(c.buildDurationMs/1e3).toFixed(1),"s"]})]}),c.jarPath&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-zinc-300 font-mono bg-zinc-950 px-2 py-1 rounded",children:c.jarPath}),e.jsxs("div",{className:"text-[10px] text-zinc-500",children:["Project: ",c.projectDir]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[e.jsx(N,{size:16}),e.jsx("span",{className:"text-xs font-medium",children:"Build Failed"})]}),c.buildErrors&&e.jsx("pre",{className:"text-[10px] text-red-300 bg-zinc-950 px-2 py-1 rounded overflow-auto max-h-32",children:c.buildErrors})]})})]})]})]})}export{G as DavinciTab};
@@ -1 +1 @@
1
- import{r as c,a as p,j as e}from"./index-D_SBClB-.js";function $(){const[t,l]=c.useState([]),[n,s]=c.useState([]),[o,b]=c.useState([]),[f,r]=c.useState(null),[u,a]=c.useState(!0),[N,x]=c.useState(null),h=c.useCallback(async()=>{try{a(!0),x(null);const[d,g,v,z]=await Promise.all([p.getDocsTools().catch(()=>({tools:[]})),p.getDocsRoutes().catch(()=>({routes:[]})),p.getDocsList().catch(()=>({docs:[]})),p.getDocsStats().catch(()=>null)]);l(d.tools),s(g.routes),b(v.docs),r(z)}catch(d){x(d instanceof Error?d.message:"Failed to load docs")}finally{a(!1)}},[]);c.useEffect(()=>{h()},[h]);const C=c.useCallback(async(d,g)=>(await p.getDocContent(d,g)).content,[]);return{tools:t,routes:n,docs:o,stats:f,loading:u,error:N,fetchDocContent:C,refresh:h}}const E={Core:"bg-blue-500/20 text-blue-400","Siebel CRM":"bg-purple-500/20 text-purple-400",Translation:"bg-green-500/20 text-green-400",Knowledge:"bg-yellow-500/20 text-yellow-400","Code Intelligence":"bg-cyan-500/20 text-cyan-400",Deprecated:"bg-red-500/20 text-red-400"},M={get:"bg-green-600/30 text-green-300",post:"bg-blue-600/30 text-blue-300",patch:"bg-yellow-600/30 text-yellow-300",put:"bg-orange-600/30 text-orange-300",delete:"bg-red-600/30 text-red-300"};function H(){const{tools:t,routes:l,docs:n,stats:s,loading:o,error:b,fetchDocContent:f}=$(),[r,u]=c.useState("overview"),[a,N]=c.useState(""),[x,h]=c.useState("all"),[C,d]=c.useState(""),[g,v]=c.useState(""),[z,S]=c.useState(!1),L=c.useMemo(()=>{const i=new Set(t.map(m=>m.category));return["all",...Array.from(i).sort()]},[t]),D=c.useMemo(()=>t.filter(i=>!(x!=="all"&&i.category!==x||a&&!i.name.toLowerCase().includes(a.toLowerCase())&&!i.description.toLowerCase().includes(a.toLowerCase()))),[t,x,a]),R=c.useMemo(()=>l.filter(i=>!(a&&!i.mountPath.toLowerCase().includes(a.toLowerCase())&&!i.routerName.toLowerCase().includes(a.toLowerCase()))),[l,a]),T=c.useMemo(()=>{const i=new Map;for(const m of n){const j=i.get(m.category)??[];j.push(m),i.set(m.category,j)}return i},[n]),G=c.useCallback(async(i,m,j)=>{S(!0),v(j),u("guide-content");try{const k=m.split("/"),P=await f(k[0],k[1]);d(P)}catch{d("Failed to load document.")}finally{S(!1)}},[f]);return o?e.jsx("div",{className:"flex items-center justify-center h-64 text-zinc-400",children:"Loading docs..."}):b?e.jsxs("div",{className:"p-4 text-red-400",children:["Error: ",b]}):e.jsxs("div",{className:"flex h-full",children:[e.jsxs("nav",{className:"w-56 shrink-0 border-r border-zinc-700 p-3 space-y-1 overflow-y-auto",children:[e.jsx(y,{label:"Overview",active:r==="overview",onClick:()=>u("overview"),count:null}),e.jsx(y,{label:"MCP Tools",active:r==="tools",onClick:()=>u("tools"),count:(s==null?void 0:s.tools.active)??0}),e.jsx(y,{label:"API Routes",active:r==="routes",onClick:()=>u("routes"),count:(s==null?void 0:s.routes.endpoints)??0}),e.jsx(y,{label:"Guides",active:r==="guides"||r==="guide-content",onClick:()=>u("guides"),count:n.length})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[(r==="tools"||r==="routes")&&e.jsx("div",{className:"mb-4",children:e.jsx("input",{type:"text",placeholder:`Search ${r}...`,value:a,onChange:i=>N(i.target.value),className:"w-full px-3 py-2 bg-zinc-800 border border-zinc-600 rounded-md text-zinc-200 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-blue-500"})}),r==="overview"&&e.jsx(A,{stats:s,toolCount:t.length,routeCount:l.length,docCount:n.length}),r==="tools"&&e.jsx(O,{tools:D,categories:L,categoryFilter:x,onCategoryChange:h}),r==="routes"&&e.jsx(I,{routes:R}),r==="guides"&&e.jsx(F,{categories:T,onGuideClick:G}),r==="guide-content"&&e.jsx(B,{title:g,content:C,loading:z,onBack:()=>u("guides")})]})]})}function y({label:t,active:l,onClick:n,count:s}){return e.jsxs("button",{onClick:n,className:`w-full text-left px-3 py-2 rounded-md text-sm transition-colors ${l?"bg-blue-600/20 text-blue-400 font-medium":"text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200"}`,children:[t,s!==null&&e.jsxs("span",{className:"ml-2 text-xs text-zinc-500",children:["(",s,")"]})]})}function A({stats:t,toolCount:l,routeCount:n,docCount:s}){return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-zinc-100",children:"mcp-graph Documentation"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(w,{label:"MCP Tools",value:(t==null?void 0:t.tools.active)??l,sub:`+ ${(t==null?void 0:t.tools.deprecated)??0} deprecated`}),e.jsx(w,{label:"API Endpoints",value:(t==null?void 0:t.routes.endpoints)??0,sub:`${(t==null?void 0:t.routes.routers)??n} routers`}),e.jsx(w,{label:"Guides",value:(t==null?void 0:t.docs)??s,sub:"markdown docs"})]}),e.jsx("p",{className:"text-zinc-400 text-sm",children:"Use the sidebar to browse MCP tools, API routes, and project guides. All data is introspected live from the source code."})]})}function w({label:t,value:l,sub:n}){return e.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4 border border-zinc-700",children:[e.jsx("div",{className:"text-2xl font-bold text-zinc-100",children:l}),e.jsx("div",{className:"text-sm font-medium text-zinc-300",children:t}),e.jsx("div",{className:"text-xs text-zinc-500 mt-1",children:n})]})}function O({tools:t,categories:l,categoryFilter:n,onCategoryChange:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:l.map(o=>e.jsx("button",{onClick:()=>s(o),className:`px-3 py-1 rounded-full text-xs font-medium transition-colors ${n===o?"bg-blue-600 text-white":"bg-zinc-800 text-zinc-400 hover:bg-zinc-700"}`,children:o==="all"?"All":o},o))}),e.jsxs("div",{className:"text-xs text-zinc-500 mb-2",children:[t.length," tools"]}),e.jsx("div",{className:"space-y-1",children:t.map(o=>e.jsxs("div",{className:`flex items-start gap-3 p-3 rounded-md ${o.deprecated?"opacity-50":"hover:bg-zinc-800/50"}`,children:[e.jsx("code",{className:"text-sm font-mono text-blue-400 shrink-0 w-40",children:o.name}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full shrink-0 ${E[o.category]??"bg-zinc-700 text-zinc-300"}`,children:o.category}),e.jsx("span",{className:"text-sm text-zinc-400 flex-1",children:o.description})]},o.name))})]})}function I({routes:t}){const l=t.reduce((n,s)=>n+s.endpoints.length,0);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs text-zinc-500",children:[t.length," routers, ",l," endpoints"]}),t.map(n=>e.jsxs("div",{className:"border border-zinc-700 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-zinc-800 px-4 py-2 flex items-center justify-between",children:[e.jsx("code",{className:"text-sm font-mono text-green-400",children:n.mountPath}),e.jsxs("span",{className:"text-xs text-zinc-500",children:[n.endpoints.length," endpoints"]})]}),e.jsx("div",{className:"divide-y divide-zinc-800",children:n.endpoints.map((s,o)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-3",children:[e.jsx("span",{className:`text-xs font-mono uppercase px-2 py-0.5 rounded ${M[s.method]??"bg-zinc-700 text-zinc-300"}`,children:s.method}),e.jsxs("code",{className:"text-sm text-zinc-300",children:[n.mountPath,s.path]})]},`${s.method}-${s.path}-${o}`))})]},n.mountPath))]})}function F({categories:t,onGuideClick:l}){return e.jsx("div",{className:"space-y-6",children:Array.from(t).map(([n,s])=>e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-300 uppercase tracking-wider mb-2",children:n}),e.jsx("div",{className:"space-y-1",children:s.map(o=>e.jsx("button",{onClick:()=>l(o.category,o.slug,o.title),className:"w-full text-left px-3 py-2 rounded-md text-sm text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200 transition-colors",children:o.title},o.slug))})]},n))})}function B({title:t,content:l,loading:n,onBack:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("button",{onClick:s,className:"text-sm text-blue-400 hover:text-blue-300",children:"← Back to Guides"}),e.jsx("h2",{className:"text-lg font-semibold text-zinc-100",children:t}),n?e.jsx("div",{className:"text-zinc-400",children:"Loading..."}):e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-zinc-300 bg-zinc-900 rounded-lg p-4 border border-zinc-700 overflow-auto max-h-[70vh]",children:l})]})}export{H as DocsTab};
1
+ import{r as c,a as p,j as e}from"./index-DdenFaJ5.js";function $(){const[t,l]=c.useState([]),[n,s]=c.useState([]),[o,b]=c.useState([]),[f,r]=c.useState(null),[u,a]=c.useState(!0),[N,x]=c.useState(null),h=c.useCallback(async()=>{try{a(!0),x(null);const[d,g,v,z]=await Promise.all([p.getDocsTools().catch(()=>({tools:[]})),p.getDocsRoutes().catch(()=>({routes:[]})),p.getDocsList().catch(()=>({docs:[]})),p.getDocsStats().catch(()=>null)]);l(d.tools),s(g.routes),b(v.docs),r(z)}catch(d){x(d instanceof Error?d.message:"Failed to load docs")}finally{a(!1)}},[]);c.useEffect(()=>{h()},[h]);const C=c.useCallback(async(d,g)=>(await p.getDocContent(d,g)).content,[]);return{tools:t,routes:n,docs:o,stats:f,loading:u,error:N,fetchDocContent:C,refresh:h}}const E={Core:"bg-blue-500/20 text-blue-400","Siebel CRM":"bg-purple-500/20 text-purple-400",Translation:"bg-green-500/20 text-green-400",Knowledge:"bg-yellow-500/20 text-yellow-400","Code Intelligence":"bg-cyan-500/20 text-cyan-400",Deprecated:"bg-red-500/20 text-red-400"},M={get:"bg-green-600/30 text-green-300",post:"bg-blue-600/30 text-blue-300",patch:"bg-yellow-600/30 text-yellow-300",put:"bg-orange-600/30 text-orange-300",delete:"bg-red-600/30 text-red-300"};function H(){const{tools:t,routes:l,docs:n,stats:s,loading:o,error:b,fetchDocContent:f}=$(),[r,u]=c.useState("overview"),[a,N]=c.useState(""),[x,h]=c.useState("all"),[C,d]=c.useState(""),[g,v]=c.useState(""),[z,S]=c.useState(!1),L=c.useMemo(()=>{const i=new Set(t.map(m=>m.category));return["all",...Array.from(i).sort()]},[t]),D=c.useMemo(()=>t.filter(i=>!(x!=="all"&&i.category!==x||a&&!i.name.toLowerCase().includes(a.toLowerCase())&&!i.description.toLowerCase().includes(a.toLowerCase()))),[t,x,a]),R=c.useMemo(()=>l.filter(i=>!(a&&!i.mountPath.toLowerCase().includes(a.toLowerCase())&&!i.routerName.toLowerCase().includes(a.toLowerCase()))),[l,a]),T=c.useMemo(()=>{const i=new Map;for(const m of n){const j=i.get(m.category)??[];j.push(m),i.set(m.category,j)}return i},[n]),G=c.useCallback(async(i,m,j)=>{S(!0),v(j),u("guide-content");try{const k=m.split("/"),P=await f(k[0],k[1]);d(P)}catch{d("Failed to load document.")}finally{S(!1)}},[f]);return o?e.jsx("div",{className:"flex items-center justify-center h-64 text-zinc-400",children:"Loading docs..."}):b?e.jsxs("div",{className:"p-4 text-red-400",children:["Error: ",b]}):e.jsxs("div",{className:"flex h-full",children:[e.jsxs("nav",{className:"w-56 shrink-0 border-r border-zinc-700 p-3 space-y-1 overflow-y-auto",children:[e.jsx(y,{label:"Overview",active:r==="overview",onClick:()=>u("overview"),count:null}),e.jsx(y,{label:"MCP Tools",active:r==="tools",onClick:()=>u("tools"),count:(s==null?void 0:s.tools.active)??0}),e.jsx(y,{label:"API Routes",active:r==="routes",onClick:()=>u("routes"),count:(s==null?void 0:s.routes.endpoints)??0}),e.jsx(y,{label:"Guides",active:r==="guides"||r==="guide-content",onClick:()=>u("guides"),count:n.length})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[(r==="tools"||r==="routes")&&e.jsx("div",{className:"mb-4",children:e.jsx("input",{type:"text",placeholder:`Search ${r}...`,value:a,onChange:i=>N(i.target.value),className:"w-full px-3 py-2 bg-zinc-800 border border-zinc-600 rounded-md text-zinc-200 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-blue-500"})}),r==="overview"&&e.jsx(A,{stats:s,toolCount:t.length,routeCount:l.length,docCount:n.length}),r==="tools"&&e.jsx(O,{tools:D,categories:L,categoryFilter:x,onCategoryChange:h}),r==="routes"&&e.jsx(I,{routes:R}),r==="guides"&&e.jsx(F,{categories:T,onGuideClick:G}),r==="guide-content"&&e.jsx(B,{title:g,content:C,loading:z,onBack:()=>u("guides")})]})]})}function y({label:t,active:l,onClick:n,count:s}){return e.jsxs("button",{onClick:n,className:`w-full text-left px-3 py-2 rounded-md text-sm transition-colors ${l?"bg-blue-600/20 text-blue-400 font-medium":"text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200"}`,children:[t,s!==null&&e.jsxs("span",{className:"ml-2 text-xs text-zinc-500",children:["(",s,")"]})]})}function A({stats:t,toolCount:l,routeCount:n,docCount:s}){return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-zinc-100",children:"mcp-graph Documentation"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(w,{label:"MCP Tools",value:(t==null?void 0:t.tools.active)??l,sub:`+ ${(t==null?void 0:t.tools.deprecated)??0} deprecated`}),e.jsx(w,{label:"API Endpoints",value:(t==null?void 0:t.routes.endpoints)??0,sub:`${(t==null?void 0:t.routes.routers)??n} routers`}),e.jsx(w,{label:"Guides",value:(t==null?void 0:t.docs)??s,sub:"markdown docs"})]}),e.jsx("p",{className:"text-zinc-400 text-sm",children:"Use the sidebar to browse MCP tools, API routes, and project guides. All data is introspected live from the source code."})]})}function w({label:t,value:l,sub:n}){return e.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4 border border-zinc-700",children:[e.jsx("div",{className:"text-2xl font-bold text-zinc-100",children:l}),e.jsx("div",{className:"text-sm font-medium text-zinc-300",children:t}),e.jsx("div",{className:"text-xs text-zinc-500 mt-1",children:n})]})}function O({tools:t,categories:l,categoryFilter:n,onCategoryChange:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:l.map(o=>e.jsx("button",{onClick:()=>s(o),className:`px-3 py-1 rounded-full text-xs font-medium transition-colors ${n===o?"bg-blue-600 text-white":"bg-zinc-800 text-zinc-400 hover:bg-zinc-700"}`,children:o==="all"?"All":o},o))}),e.jsxs("div",{className:"text-xs text-zinc-500 mb-2",children:[t.length," tools"]}),e.jsx("div",{className:"space-y-1",children:t.map(o=>e.jsxs("div",{className:`flex items-start gap-3 p-3 rounded-md ${o.deprecated?"opacity-50":"hover:bg-zinc-800/50"}`,children:[e.jsx("code",{className:"text-sm font-mono text-blue-400 shrink-0 w-40",children:o.name}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full shrink-0 ${E[o.category]??"bg-zinc-700 text-zinc-300"}`,children:o.category}),e.jsx("span",{className:"text-sm text-zinc-400 flex-1",children:o.description})]},o.name))})]})}function I({routes:t}){const l=t.reduce((n,s)=>n+s.endpoints.length,0);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs text-zinc-500",children:[t.length," routers, ",l," endpoints"]}),t.map(n=>e.jsxs("div",{className:"border border-zinc-700 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-zinc-800 px-4 py-2 flex items-center justify-between",children:[e.jsx("code",{className:"text-sm font-mono text-green-400",children:n.mountPath}),e.jsxs("span",{className:"text-xs text-zinc-500",children:[n.endpoints.length," endpoints"]})]}),e.jsx("div",{className:"divide-y divide-zinc-800",children:n.endpoints.map((s,o)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-3",children:[e.jsx("span",{className:`text-xs font-mono uppercase px-2 py-0.5 rounded ${M[s.method]??"bg-zinc-700 text-zinc-300"}`,children:s.method}),e.jsxs("code",{className:"text-sm text-zinc-300",children:[n.mountPath,s.path]})]},`${s.method}-${s.path}-${o}`))})]},n.mountPath))]})}function F({categories:t,onGuideClick:l}){return e.jsx("div",{className:"space-y-6",children:Array.from(t).map(([n,s])=>e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-300 uppercase tracking-wider mb-2",children:n}),e.jsx("div",{className:"space-y-1",children:s.map(o=>e.jsx("button",{onClick:()=>l(o.category,o.slug,o.title),className:"w-full text-left px-3 py-2 rounded-md text-sm text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200 transition-colors",children:o.title},o.slug))})]},n))})}function B({title:t,content:l,loading:n,onBack:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("button",{onClick:s,className:"text-sm text-blue-400 hover:text-blue-300",children:"← Back to Guides"}),e.jsx("h2",{className:"text-lg font-semibold text-zinc-100",children:t}),n?e.jsx("div",{className:"text-zinc-400",children:"Loading..."}):e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-zinc-300 bg-zinc-900 rounded-lg p-4 border border-zinc-700 overflow-auto max-h-[70vh]",children:l})]})}export{H as DocsTab};
@@ -0,0 +1,11 @@
1
+ import{c as o}from"./index-DdenFaJ5.js";/**
2
+ * @license lucide-react v1.7.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],t=o("chevron-down",e);/**
7
+ * @license lucide-react v1.7.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const a=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],c=o("file-code",a);export{t as C,c as F};
@@ -1,4 +1,4 @@
1
- import{g as $r,r as N,R as Et,j as f,a as Oe,O as Ii}from"./index-D_SBClB-.js";import{C as we,b as pt,c as jr}from"./constants-Dd6A34aQ.js";var st={exports:{}},Xt;function Oi(){if(Xt)return st.exports;Xt=1;var n=typeof Reflect=="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(y,S,C){return Function.prototype.apply.call(y,S,C)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(y){return Object.getOwnPropertyNames(y).concat(Object.getOwnPropertySymbols(y))}:t=function(y){return Object.getOwnPropertyNames(y)};function e(m){console&&console.warn&&console.warn(m)}var i=Number.isNaN||function(y){return y!==y};function a(){a.init.call(this)}st.exports=a,st.exports.once=D,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function s(m){if(typeof m!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof m)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(m){if(typeof m!="number"||m<0||i(m))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+m+".");o=m}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(y){if(typeof y!="number"||y<0||i(y))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+y+".");return this._maxListeners=y,this};function u(m){return m._maxListeners===void 0?a.defaultMaxListeners:m._maxListeners}a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(y){for(var S=[],C=1;C<arguments.length;C++)S.push(arguments[C]);var P=y==="error",O=this._events;if(O!==void 0)P=P&&O.error===void 0;else if(!P)return!1;if(P){var z;if(S.length>0&&(z=S[0]),z instanceof Error)throw z;var Z=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw Z.context=z,Z}var U=O[y];if(U===void 0)return!1;if(typeof U=="function")r(U,this,S);else for(var p=U.length,Q=b(U,p),C=0;C<p;++C)r(Q[C],this,S);return!0};function l(m,y,S,C){var P,O,z;if(s(S),O=m._events,O===void 0?(O=m._events=Object.create(null),m._eventsCount=0):(O.newListener!==void 0&&(m.emit("newListener",y,S.listener?S.listener:S),O=m._events),z=O[y]),z===void 0)z=O[y]=S,++m._eventsCount;else if(typeof z=="function"?z=O[y]=C?[S,z]:[z,S]:C?z.unshift(S):z.push(S),P=u(m),P>0&&z.length>P&&!z.warned){z.warned=!0;var Z=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(y)+" listeners added. Use emitter.setMaxListeners() to increase limit");Z.name="MaxListenersExceededWarning",Z.emitter=m,Z.type=y,Z.count=z.length,e(Z)}return m}a.prototype.addListener=function(y,S){return l(this,y,S,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(y,S){return l(this,y,S,!0)};function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(m,y,S){var C={fired:!1,wrapFn:void 0,target:m,type:y,listener:S},P=h.bind(C);return P.listener=S,C.wrapFn=P,P}a.prototype.once=function(y,S){return s(S),this.on(y,d(this,y,S)),this},a.prototype.prependOnceListener=function(y,S){return s(S),this.prependListener(y,d(this,y,S)),this},a.prototype.removeListener=function(y,S){var C,P,O,z,Z;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){Z=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,Z||S)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(y){var S,C,P;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[y]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[y]),this;if(arguments.length===0){var O=Object.keys(C),z;for(P=0;P<O.length;++P)z=O[P],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=C[y],typeof S=="function")this.removeListener(y,S);else if(S!==void 0)for(P=S.length-1;P>=0;P--)this.removeListener(y,S[P]);return this};function c(m,y,S){var C=m._events;if(C===void 0)return[];var P=C[y];return P===void 0?[]:typeof P=="function"?S?[P.listener||P]:[P]:S?E(P):b(P,P.length)}a.prototype.listeners=function(y){return c(this,y,!0)},a.prototype.rawListeners=function(y){return c(this,y,!1)},a.listenerCount=function(m,y){return typeof m.listenerCount=="function"?m.listenerCount(y):g.call(m,y)},a.prototype.listenerCount=g;function g(m){var y=this._events;if(y!==void 0){var S=y[m];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function b(m,y){for(var S=new Array(y),C=0;C<y;++C)S[C]=m[C];return S}function w(m,y){for(;y+1<m.length;y++)m[y]=m[y+1];m.pop()}function E(m){for(var y=new Array(m.length),S=0;S<y.length;++S)y[S]=m[S].listener||m[S];return y}function D(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 Ur=Oi();function zi(){const n=arguments[0];for(let r=1,t=arguments.length;r<t;r++)if(arguments[r])for(const e in arguments[r])n[e]=arguments[r][e];return n}let te=zi;typeof Object.assign=="function"&&(te=Object.assign);function fe(n,r,t,e){const i=n._nodes.get(r);let a=null;return i&&(e==="mixed"?a=i.out&&i.out[t]||i.undirected&&i.undirected[t]:e==="directed"?a=i.out&&i.out[t]:a=i.undirected&&i.undirected[t]),a}function oe(n){return typeof n=="object"&&n!==null}function Mr(n){let r;for(r in n)return!1;return!0}function de(n,r,t){Object.defineProperty(n,r,{enumerable:!1,configurable:!1,writable:!0,value:t})}function ve(n,r,t){const e={enumerable:!0,configurable:!0};typeof t=="function"?e.get=t:(e.value=t,e.writable=!1),Object.defineProperty(n,r,e)}function Qt(n){return!(!oe(n)||n.attributes&&!Array.isArray(n.attributes))}function $i(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function ke(){const n=arguments;let r=null,t=-1;return{[Symbol.iterator](){return this},next(){let e=null;do{if(r===null){if(t++,t>=n.length)return{done:!0};r=n[t][Symbol.iterator]()}if(e=r.next(),e.done){r=null;continue}break}while(!0);return e}}}function Ve(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Bt extends Error{constructor(r){super(),this.name="GraphError",this.message=r}}class L extends Bt{constructor(r){super(r),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,L.prototype.constructor)}}class A extends Bt{constructor(r){super(r),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,A.prototype.constructor)}}class j extends Bt{constructor(r){super(r),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,j.prototype.constructor)}}function Br(n,r){this.key=n,this.attributes=r,this.clear()}Br.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Hr(n,r){this.key=n,this.attributes=r,this.clear()}Hr.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Wr(n,r){this.key=n,this.attributes=r,this.clear()}Wr.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function qe(n,r,t,e,i){this.key=r,this.attributes=i,this.undirected=n,this.source=t,this.target=e}qe.prototype.attach=function(){let n="out",r="in";this.undirected&&(n=r="undirected");const t=this.source.key,e=this.target.key;this.source[n][e]=this,!(this.undirected&&t===e)&&(this.target[r][t]=this)};qe.prototype.attachMulti=function(){let n="out",r="in";const t=this.source.key,e=this.target.key;this.undirected&&(n=r="undirected");const i=this.source[n],a=i[e];if(typeof a>"u"){i[e]=this,this.undirected&&t===e||(this.target[r][t]=this);return}a.previous=this,this.next=a,i[e]=this,this.target[r][t]=this};qe.prototype.detach=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),delete this.source[t][r],delete this.target[e][n]};qe.prototype.detachMulti=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][r],delete this.target[e][n]):(this.next.previous=void 0,this.source[t][r]=this.next,this.target[e][n]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Vr=0,qr=1,ji=2,Kr=3;function Ae(n,r,t,e,i,a,o){let s,u,l,h;if(e=""+e,t===Vr){if(s=n._nodes.get(e),!s)throw new A(`Graph.${r}: could not find the "${e}" node in the graph.`);l=i,h=a}else if(t===Kr){if(i=""+i,u=n._edges.get(i),!u)throw new A(`Graph.${r}: could not find the "${i}" edge in the graph.`);const d=u.source.key,c=u.target.key;if(e===d)s=u.target;else if(e===c)s=u.source;else throw new A(`Graph.${r}: the "${e}" node is not attached to the "${i}" edge (${d}, ${c}).`);l=a,h=o}else{if(u=n._edges.get(e),!u)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`);t===qr?s=u.source:s=u.target,l=i,h=a}return[s,l,h]}function Ui(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return o.attributes[s]}}function Mi(n,r,t){n.prototype[r]=function(e,i){const[a]=Ae(this,r,t,e,i);return a.attributes}}function Bi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return o.attributes.hasOwnProperty(s)}}function Hi(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,l]=Ae(this,r,t,e,i,a,o);return s.attributes[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Wi(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,l]=Ae(this,r,t,e,i,a,o);if(typeof l!="function")throw new L(`Graph.${r}: updater should be a function.`);const h=s.attributes,d=l(h[u]);return h[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Vi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return delete o.attributes[s],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:s}),this}}function qi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(!oe(s))throw new L(`Graph.${r}: provided attributes are not a plain object.`);return o.attributes=s,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Ki(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(!oe(s))throw new L(`Graph.${r}: provided attributes are not a plain object.`);return te(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Yi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(typeof s!="function")throw new L(`Graph.${r}: provided updater is not a function.`);return o.attributes=s(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const Zi=[{name:n=>`get${n}Attribute`,attacher:Ui},{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"),ji),t(n,r("Opposite"),Kr)})}function Qi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes[i]}}function Ji(n,r,t){n.prototype[r]=function(e){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,o=""+arguments[1];if(i=fe(this,a,o,t),!i)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,i=this._edges.get(e),!i)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return i.attributes}}function en(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function tn(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+i;if(i=arguments[2],a=arguments[3],o=fe(this,s,u,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return o.attributes[i]=a,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function rn(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+i;if(i=arguments[2],a=arguments[3],o=fe(this,s,u,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof a!="function")throw new L(`Graph.${r}: updater should be a function.`);return o.attributes[i]=a(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function nn(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return delete a.attributes[i],this.emit("edgeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:i}),this}}function an(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!oe(i))throw new L(`Graph.${r}: provided attributes are not a plain object.`);return a.attributes=i,this.emit("edgeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function on(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!oe(i))throw new L(`Graph.${r}: provided attributes are not a plain object.`);return te(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function sn(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof i!="function")throw new L(`Graph.${r}: provided updater is not a function.`);return a.attributes=i(a.attributes),this.emit("edgeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const un=[{name:n=>`get${n}Attribute`,attacher:Qi},{name:n=>`get${n}Attributes`,attacher:Ji},{name:n=>`has${n}Attribute`,attacher:en},{name:n=>`set${n}Attribute`,attacher:tn},{name:n=>`update${n}Attribute`,attacher:rn},{name:n=>`remove${n}Attribute`,attacher:nn},{name:n=>`replace${n}Attributes`,attacher:an},{name:n=>`merge${n}Attributes`,attacher:on},{name:n=>`update${n}Attributes`,attacher:sn}];function ln(n){un.forEach(function({name:r,attacher:t}){t(n,r("Edge"),"mixed"),t(n,r("DirectedEdge"),"directed"),t(n,r("UndirectedEdge"),"undirected")})}const hn=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function dn(n,r,t,e){let i=!1;for(const a in r){if(a===e)continue;const o=r[a];if(i=t(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),n&&i)return o.key}}function cn(n,r,t,e){let i,a,o,s=!1;for(const u in r)if(u!==e){i=r[u];do{if(a=i.source,o=i.target,s=t(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),n&&s)return i.key;i=i.next}while(i!==void 0)}}function xt(n,r){const t=Object.keys(n),e=t.length;let i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=e)return{done:!0};const o=t[a++];if(o===r){i=void 0;continue}i=n[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function fn(n,r,t,e){const i=r[t];if(!i)return;const a=i.source,o=i.target;if(e(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&n)return i.key}function gn(n,r,t,e){let i=r[t];if(!i)return;let a=!1;do{if(a=e(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),n&&a)return i.key;i=i.next}while(i!==void 0)}function _t(n,r){let t=n[r];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const i={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:i}}};let e=!1;return{[Symbol.iterator](){return this},next(){return e===!0?{done:!0}:(e=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function pn(n,r){if(n.size===0)return[];if(r==="mixed"||r===n.type)return Array.from(n._edges.keys());const t=r==="undirected"?n.undirectedSize:n.directedSize,e=new Array(t),i=r==="undirected",a=n._edges.values();let o=0,s,u;for(;s=a.next(),s.done!==!0;)u=s.value,u.undirected===i&&(e[o++]=u.key);return e}function Yr(n,r,t,e){if(r.size===0)return;const i=t!=="mixed"&&t!==r.type,a=t==="undirected";let o,s,u=!1;const l=r._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;const{key:h,attributes:d,source:c,target:g}=s;if(u=e(h,d,c.key,g.key,c.attributes,g.attributes,s.undirected),n&&u)return h}}function mn(n,r){if(n.size===0)return Ve();const t=r!=="mixed"&&r!==n.type,e=r==="undirected",i=n._edges.values();return{[Symbol.iterator](){return this},next(){let a,o;for(;;){if(a=i.next(),a.done)return a;if(o=a.value,!(t&&o.undirected!==e))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function Ht(n,r,t,e,i,a){const o=r?cn:dn;let s;if(t!=="undirected"&&(e!=="out"&&(s=o(n,i.in,a),n&&s)||e!=="in"&&(s=o(n,i.out,a,e?void 0:i.key),n&&s))||t!=="directed"&&(s=o(n,i.undirected,a),n&&s))return s}function vn(n,r,t,e){const i=[];return Ht(!1,n,r,t,e,function(a){i.push(a)}),i}function yn(n,r,t){let e=Ve();return n!=="undirected"&&(r!=="out"&&typeof t.in<"u"&&(e=ke(e,xt(t.in))),r!=="in"&&typeof t.out<"u"&&(e=ke(e,xt(t.out,r?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(e=ke(e,xt(t.undirected))),e}function Wt(n,r,t,e,i,a,o){const s=t?gn:fn;let u;if(r!=="undirected"&&(typeof i.in<"u"&&e!=="out"&&(u=s(n,i.in,a,o),n&&u)||typeof i.out<"u"&&e!=="in"&&(e||i.key!==a)&&(u=s(n,i.out,a,o),n&&u))||r!=="directed"&&typeof i.undirected<"u"&&(u=s(n,i.undirected,a,o),n&&u))return u}function bn(n,r,t,e,i){const a=[];return Wt(!1,n,r,t,e,i,function(o){a.push(o)}),a}function wn(n,r,t,e){let i=Ve();return n!=="undirected"&&(typeof t.in<"u"&&r!=="out"&&e in t.in&&(i=ke(i,_t(t.in,e))),typeof t.out<"u"&&r!=="in"&&e in t.out&&(r||t.key!==e)&&(i=ke(i,_t(t.out,e)))),n!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(i=ke(i,_t(t.undirected,e))),i}function En(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(a,o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];if(!arguments.length)return pn(this,e);if(arguments.length===1){a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${t}: could not find the "${a}" node in the graph.`);return vn(this.multi,e==="mixed"?this.type:e,i,s)}if(arguments.length===2){a=""+a,o=""+o;const s=this._nodes.get(a);if(!s)throw new A(`Graph.${t}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new A(`Graph.${t}: could not find the "${o}" target node in the graph.`);return bn(e,this.multi,i,s,o)}throw new L(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function xn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(l,h,d){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return d=l,Yr(!1,this,e,d);if(arguments.length===2){l=""+l,d=h;const c=this._nodes.get(l);if(typeof c>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);return Ht(!1,this.multi,e==="mixed"?this.type:e,i,c,d)}if(arguments.length===3){l=""+l,h=""+h;const c=this._nodes.get(l);if(!c)throw new A(`Graph.${a}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(h))throw new A(`Graph.${a}: could not find the "${h}" target node in the graph.`);return Wt(!1,e,this.multi,i,c,h,d)}throw new L(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop();let d;if(l.length===0){let c=0;e!=="directed"&&(c+=this.undirectedSize),e!=="undirected"&&(c+=this.directedSize),d=new Array(c);let g=0;l.push((b,w,E,D,_,R,m)=>{d[g++]=h(b,w,E,D,_,R,m)})}else d=[],l.push((c,g,b,w,E,D,_)=>{d.push(h(c,g,b,w,E,D,_))});return this[a].apply(this,l),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop(),d=[];return l.push((c,g,b,w,E,D,_)=>{h(c,g,b,w,E,D,_)&&d.push(c)}),this[a].apply(this,l),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(){let l=Array.prototype.slice.call(arguments);if(l.length<2||l.length>4)throw new L(`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 L(`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((g,b,w,E,D,_,R)=>{c=h(c,g,b,w,E,D,_,R)}),this[a].apply(this,l),c}}function _n(n,r){const{name:t,type:e,direction:i}=r,a="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(u,l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return h=u,Yr(!0,this,e,h);if(arguments.length===2){u=""+u,h=l;const d=this._nodes.get(u);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${u}" node in the graph.`);return Ht(!0,this.multi,e==="mixed"?this.type:e,i,d,h)}if(arguments.length===3){u=""+u,l=""+l;const d=this._nodes.get(u);if(!d)throw new A(`Graph.${a}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new A(`Graph.${a}: could not find the "${l}" target node in the graph.`);return Wt(!0,e,this.multi,i,d,l,h)}throw new L(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,g,b,w,E,D)=>l(d,c,g,b,w,E,D)),!!this[a].apply(this,u)};const s="every"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,g,b,w,E,D)=>!l(d,c,g,b,w,E,D)),!this[a].apply(this,u)}}function Cn(n,r){const{name:t,type:e,direction:i}=r,a=t.slice(0,-1)+"Entries";n.prototype[a]=function(o,s){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();if(!arguments.length)return mn(this,e);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(!u)throw new A(`Graph.${a}: could not find the "${o}" node in the graph.`);return yn(e,i,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new A(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new A(`Graph.${a}: could not find the "${s}" target node in the graph.`);return wn(e,i,u,s)}throw new L(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Sn(n){hn.forEach(r=>{En(n,r),xn(n,r),_n(n,r),Cn(n,r)})}const Tn=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function mt(){this.A=null,this.B=null}mt.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};mt.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function Ze(n,r,t,e,i){for(const a in e){const o=e[a],s=o.source,u=o.target,l=s===t?u:s;if(r&&r.has(l.key))continue;const h=i(l.key,l.attributes);if(n&&h)return l.key}}function Vt(n,r,t,e,i){if(r!=="mixed"){if(r==="undirected")return Ze(n,null,e,e.undirected,i);if(typeof t=="string")return Ze(n,null,e,e[t],i)}const a=new mt;let o;if(r!=="undirected"){if(t!=="out"){if(o=Ze(n,null,e,e.in,i),n&&o)return o;a.wrap(e.in)}if(t!=="in"){if(o=Ze(n,a,e,e.out,i),n&&o)return o;a.wrap(e.out)}}if(r!=="directed"&&(o=Ze(n,a,e,e.undirected,i),n&&o))return o}function Rn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Object.keys(t.undirected);if(typeof r=="string")return Object.keys(t[r])}const e=[];return Vt(!1,n,r,t,function(i){e.push(i)}),e}function Xe(n,r,t){const e=Object.keys(t),i=e.length;let a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return n&&n.wrap(t),{done:!0};const s=t[e[a++]],u=s.source,l=s.target;if(o=u===r?l:u,n&&n.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function kn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Xe(null,t,t.undirected);if(typeof r=="string")return Xe(null,t,t[r])}let e=Ve();const i=new mt;return n!=="undirected"&&(r!=="out"&&(e=ke(e,Xe(i,t,t.in))),r!=="in"&&(e=ke(e,Xe(i,t,t.out)))),n!=="directed"&&(e=ke(e,Xe(i,t,t.undirected))),e}function An(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];a=""+a;const o=this._nodes.get(a);if(typeof o>"u")throw new A(`Graph.${t}: could not find the "${a}" node in the graph.`);return Rn(e==="mixed"?this.type:e,i,o)}}function Dn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);Vt(!1,e==="mixed"?this.type:e,i,d,h)};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(l,h){const d=[];return this[a](l,(c,g)=>{d.push(h(c,g))}),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(l,h){const d=[];return this[a](l,(c,g)=>{h(c,g)&&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 L(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c=d;return this[a](l,(g,b)=>{c=h(c,g,b)}),c}}function Ln(n,r){const{name:t,type:e,direction:i}=r,a=t[0].toUpperCase()+t.slice(1,-1),o="find"+a;n.prototype[o]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);return Vt(!0,e==="mixed"?this.type:e,i,d,h)};const s="some"+a;n.prototype[s]=function(l,h){return!!this[o](l,h)};const u="every"+a;n.prototype[u]=function(l,h){return!this[o](l,(c,g)=>!h(c,g))}}function Nn(n,r){const{name:t,type:e,direction:i}=r,a=t.slice(0,-1)+"Entries";n.prototype[a]=function(o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new A(`Graph.${a}: could not find the "${o}" node in the graph.`);return kn(e==="mixed"?this.type:e,i,s)}}function Gn(n){Tn.forEach(r=>{An(n,r),Dn(n,r),Ln(n,r),Nn(n,r)})}function ut(n,r,t,e,i){const a=e._nodes.values(),o=e.type;let s,u,l,h,d,c;for(;s=a.next(),s.done!==!0;){let g=!1;if(u=s.value,o!=="undirected"){h=u.out;for(l in h){d=h[l];do c=d.target,g=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(o!=="directed"){h=u.undirected;for(l in h)if(!(r&&u.key>l)){d=h[l];do c=d.target,c.key!==l&&(c=d.source),g=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}t&&!g&&i(u.key,null,u.attributes,null,null,null,null)}}function Fn(n,r){const t={key:n};return Mr(r.attributes)||(t.attributes=te({},r.attributes)),t}function Pn(n,r,t){const e={key:r,source:t.source.key,target:t.target.key};return Mr(t.attributes)||(e.attributes=te({},t.attributes)),n==="mixed"&&t.undirected&&(e.undirected=!0),e}function In(n){if(!oe(n))throw new L('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 L("Graph.import: serialized node is missing its key.");if("attributes"in n&&(!oe(n.attributes)||n.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function On(n){if(!oe(n))throw new L('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 L("Graph.import: serialized edge is missing its source.");if(!("target"in n))throw new L("Graph.import: serialized edge is missing its target.");if("attributes"in n&&(!oe(n.attributes)||n.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in n&&typeof n.undirected!="boolean")throw new L("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"]),jn=[{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"}],Un={allowSelfLoops:!0,multi:!1,type:"mixed"};function Mn(n,r,t){if(t&&!oe(t))throw new L(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(r=""+r,t=t||{},n._nodes.has(r))throw new j(`Graph.addNode: the "${r}" node already exist in the graph.`);const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function er(n,r,t){const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function Zr(n,r,t,e,i,a,o,s){if(!e&&n.type==="undirected")throw new j(`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 j(`Graph.${r}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!oe(s))throw new L(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`);if(a=""+a,o=""+o,s=s||{},!n.allowSelfLoops&&a===o)throw new j(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=n._nodes.get(a),l=n._nodes.get(o);if(!u)throw new A(`Graph.${r}: source node "${a}" not found.`);if(!l)throw new A(`Graph.${r}: target node "${o}" not found.`);const h={key:null,undirected:e,source:a,target:o,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new j(`Graph.${r}: the "${i}" edge already exists in the graph.`);if(!n.multi&&(e?typeof u.undirected[o]<"u":typeof u.out[o]<"u"))throw new j(`Graph.${r}: an edge linking "${a}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new qe(e,i,u,l,s);n._edges.set(i,d);const c=a===o;return e?(u.undirectedDegree++,l.undirectedDegree++,c&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,c&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?d.attachMulti():d.attach(),e?n._undirectedSize++:n._directedSize++,h.key=i,n.emit("edgeAdded",h),i}function Bn(n,r,t,e,i,a,o,s,u){if(!e&&n.type==="undirected")throw new j(`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 j(`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 L(`Graph.${r}: invalid updater function. Expecting a function but got "${s}"`)}else if(!oe(s))throw new L(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let l;if(u&&(l=s,s=void 0),!n.allowSelfLoops&&a===o)throw new j(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let h=n._nodes.get(a),d=n._nodes.get(o),c,g;if(!t&&(c=n._edges.get(i),c)){if((c.source.key!==a||c.target.key!==o)&&(!e||c.source.key!==o||c.target.key!==a))throw new j(`Graph.${r}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${c.source.key}", "${c.target.key}").`);g=c}if(!g&&!n.multi&&h&&(g=e?h.undirected[o]:h.out[o]),g){const _=[g.key,!1,!1,!1];if(u?!l:!s)return _;if(u){const R=g.attributes;g.attributes=l(R),n.emit("edgeAttributesUpdated",{type:"replace",key:g.key,attributes:g.attributes})}else te(g.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:g.key,attributes:g.attributes,data:s});return _}s=s||{},u&&l&&(s=l(s));const b={key:null,undirected:e,source:a,target:o,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new j(`Graph.${r}: the "${i}" edge already exists in the graph.`);let w=!1,E=!1;h||(h=er(n,a,{}),w=!0,a===o&&(d=h,E=!0)),d||(d=er(n,o,{}),E=!0),c=new qe(e,i,h,d,s),n._edges.set(i,c);const D=a===o;return e?(h.undirectedDegree++,d.undirectedDegree++,D&&(h.undirectedLoops++,n._undirectedSelfLoopCount++)):(h.outDegree++,d.inDegree++,D&&(h.directedLoops++,n._directedSelfLoopCount++)),n.multi?c.attachMulti():c.attach(),e?n._undirectedSize++:n._directedSize++,b.key=i,n.emit("edgeAdded",b),[i,!0,w,E]}function Me(n,r){n._edges.delete(r.key);const{source:t,target:e,attributes:i}=r,a=r.undirected,o=t===e;a?(t.undirectedDegree--,e.undirectedDegree--,o&&(t.undirectedLoops--,n._undirectedSelfLoopCount--)):(t.outDegree--,e.inDegree--,o&&(t.directedLoops--,n._directedSelfLoopCount--)),n.multi?r.detachMulti():r.detach(),a?n._undirectedSize--:n._directedSize--,n.emit("edgeDropped",{key:r.key,attributes:i,source:t.key,target:e.key,undirected:a})}class X extends Ur.EventEmitter{constructor(r){if(super(),r=te({},Un,r),typeof r.multi!="boolean")throw new L(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${r.multi}".`);if(!$n.has(r.type))throw new L(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${r.type}".`);if(typeof r.allowSelfLoops!="boolean")throw new L(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${r.allowSelfLoops}".`);const t=r.type==="mixed"?Br:r.type==="directed"?Hr:Wr;de(this,"NodeDataClass",t);const e="geid_"+zn()+"_";let i=0;const a=()=>{let o;do o=e+i++;while(this._edges.has(o));return o};de(this,"_attributes",{}),de(this,"_nodes",new Map),de(this,"_edges",new Map),de(this,"_directedSize",0),de(this,"_undirectedSize",0),de(this,"_directedSelfLoopCount",0),de(this,"_undirectedSelfLoopCount",0),de(this,"_edgeKeyGenerator",a),de(this,"_options",r),Jt.forEach(o=>de(this,o,this[o])),ve(this,"order",()=>this._nodes.size),ve(this,"size",()=>this._edges.size),ve(this,"directedSize",()=>this._directedSize),ve(this,"undirectedSize",()=>this._undirectedSize),ve(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ve(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ve(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ve(this,"multi",this._options.multi),ve(this,"type",this._options.type),ve(this,"allowSelfLoops",this._options.allowSelfLoops),ve(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(r){return this._nodes.has(""+r)}hasDirectedEdge(r,t){if(this.type==="undirected")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&!i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.out.hasOwnProperty(t):!1}throw new L(`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 L(`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 L(`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 j("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 j("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 j("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.edge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||e.undirected&&e.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areDirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in||t in e.out}areOutNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.out}areInNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in}areUndirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areUndirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="directed"?!1:t in e.undirected}areNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&(t in e.in||t in e.out)||this.type!=="directed"&&t in e.undirected}areInboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.in||this.type!=="directed"&&t in e.undirected}areOutboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.out||this.type!=="directed"&&t in e.undirected}inDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegree: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree),e}outboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.outDegree),e}degree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree),e}inDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree,i+=t.directedLoops),e-i}outboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.outDegree,i+=t.directedLoops),e-i}degreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree,i+=t.directedLoops*2),e-i}source(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.source: could not find the "${r}" edge in the graph.`);return t.source.key}target(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.target: could not find the "${r}" edge in the graph.`);return t.target.key}extremities(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.extremities: could not find the "${r}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(r,t){r=""+r,t=""+t;const e=this._edges.get(t);if(!e)throw new A(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=e.source.key,a=e.target.key;if(r===i)return a;if(r===a)return i;throw new A(`Graph.opposite: the "${r}" node is not attached to the "${t}" edge (${i}, ${a}).`)}hasExtremity(r,t){r=""+r,t=""+t;const e=this._edges.get(r);if(!e)throw new A(`Graph.hasExtremity: could not find the "${r}" edge in the graph.`);return e.source.key===t||e.target.key===t}isUndirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isUndirected: could not find the "${r}" edge in the graph.`);return t.undirected}isDirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isDirected: could not find the "${r}" edge in the graph.`);return!t.undirected}isSelfLoop(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isSelfLoop: could not find the "${r}" edge in the graph.`);return t.source===t.target}addNode(r,t){return Mn(this,r,t).key}mergeNode(r,t){if(t&&!oe(t))throw new L(`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 L(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);r=""+r;let e=this._nodes.get(r);if(e){if(t){const a=e.attributes;e.attributes=t(a),this.emit("nodeAttributesUpdated",{type:"replace",key:r,attributes:e.attributes})}return[r,!1]}const i=t?t({}):{};return e=new this.NodeDataClass(r,i),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:i}),[r,!0]}dropNode(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.dropNode: could not find the "${r}" node in the graph.`);let e;if(this.type!=="undirected"){for(const i in t.out){e=t.out[i];do Me(this,e),e=e.next;while(e)}for(const i in t.in){e=t.in[i];do Me(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const i in t.undirected){e=t.undirected[i];do Me(this,e),e=e.next;while(e)}this._nodes.delete(r),this.emit("nodeDropped",{key:r,attributes:t.attributes})}dropEdge(r){let t;if(arguments.length>1){const e=""+arguments[0],i=""+arguments[1];if(t=fe(this,e,i,this.type),!t)throw new A(`Graph.dropEdge: could not find the "${e}" -> "${i}" edge in the graph.`)}else if(r=""+r,t=this._edges.get(r),!t)throw new A(`Graph.dropEdge: could not find the "${r}" edge in the graph.`);return Me(this,t),this}dropDirectedEdge(r,t){if(arguments.length<2)throw new j("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 j("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 j("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 j("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 L("Graph.updateAttribute: updater should be a function.");const e=this._attributes[r];return this._attributes[r]=t(e),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}removeAttribute(r){return delete this._attributes[r],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:r}),this}replaceAttributes(r){if(!oe(r))throw new L("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=r,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(r){if(!oe(r))throw new L("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 L("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 L("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new L("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._nodes.values();let i,a;for(;i=e.next(),i.done!==!0;)a=i.value,a.attributes=r(a.key,a.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(r,t){if(typeof r!="function")throw new L("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new L("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._edges.values();let i,a,o,s;for(;i=e.next(),i.done!==!0;)a=i.value,o=a.source,s=a.target,a.attributes=r(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(r){if(typeof r!="function")throw new L("Graph.forEachAdjacencyEntry: expecting a callback.");ut(!1,!1,!1,this,r)}forEachAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new L("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!1,!0,this,r)}forEachAssymetricAdjacencyEntry(r){if(typeof r!="function")throw new L("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ut(!1,!0,!1,this,r)}forEachAssymetricAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new L("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 L("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 L("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 L("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let e,i;const a=new Array(this.order);let o=0;for(;e=t.next(),e.done!==!0;)i=e.value,a[o++]=r(i.key,i.attributes);return a}someNode(r){if(typeof r!="function")throw new L("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 L("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 L("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let e,i;const a=[];for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)&&a.push(i.key);return a}reduceNodes(r,t){if(typeof r!="function")throw new L("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new L("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let e=t;const i=this._nodes.values();let a,o;for(;a=i.next(),a.done!==!0;)o=a.value,e=r(e,o.key,o.attributes);return e}nodeEntries(){const r=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=r.next();if(t.done)return t;const e=t.value;return{value:{node:e.key,attributes:e.attributes},done:!1}}}}export(){const r=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,a)=>{r[t++]=Fn(a,i)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((i,a)=>{e[t++]=Pn(this.type,a,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:r,edges:e}}import(r,t=!1){if(r instanceof X)return r.forEachNode((u,l)=>{t?this.mergeNode(u,l):this.addNode(u,l)}),r.forEachEdge((u,l,h,d,c,g,b)=>{t?b?this.mergeUndirectedEdgeWithKey(u,h,d,l):this.mergeDirectedEdgeWithKey(u,h,d,l):b?this.addUndirectedEdgeWithKey(u,h,d,l):this.addDirectedEdgeWithKey(u,h,d,l)}),this;if(!oe(r))throw new L("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!oe(r.attributes))throw new L("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(r.attributes):this.replaceAttributes(r.attributes)}let e,i,a,o,s;if(r.nodes){if(a=r.nodes,!Array.isArray(a))throw new L("Graph.import: invalid nodes. Expecting an array.");for(e=0,i=a.length;e<i;e++){o=a[e],In(o);const{key:u,attributes:l}=o;t?this.mergeNode(u,l):this.addNode(u,l)}}if(r.edges){let u=!1;if(this.type==="undirected"&&(u=!0),a=r.edges,!Array.isArray(a))throw new L("Graph.import: invalid edges. Expecting an array.");for(e=0,i=a.length;e<i;e++){s=a[e],On(s);const{source:l,target:h,attributes:d,undirected:c=u}=s;let g;"key"in s?(g=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,g.call(this,s.key,l,h,d)):(g=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,g.call(this,l,h,d))}}return this}nullCopy(r){const t=new X(te({},this._options,r));return t.replaceAttributes(te({},this.getAttributes())),t}emptyCopy(r){const t=this.nullCopy(r);return this._nodes.forEach((e,i)=>{const a=te({},e.attributes);e=new t.NodeDataClass(i,a),t._nodes.set(i,e)}),t}copy(r){if(r=r||{},typeof r.type=="string"&&r.type!==this.type&&r.type!=="mixed")throw new j(`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 j("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 j("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(r),e=this._edges.values();let i,a;for(;i=e.next(),i.done!==!0;)a=i.value,Zr(t,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,te({},a.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const r={};this._nodes.forEach((a,o)=>{r[o]=a.attributes});const t={},e={};this._edges.forEach((a,o)=>{const s=a.undirected?"--":"->";let u="",l=a.source.key,h=a.target.key,d;a.undirected&&l>h&&(d=l,l=h,h=d);const c=`(${l})${s}(${h})`;o.startsWith("geid_")?this.multi&&(typeof e[c]>"u"?e[c]=0:e[c]++,u+=`${e[c]}. `):u+=`[${o}]: `,u+=c,t[u]=a.attributes});const i={};for(const a in this)this.hasOwnProperty(a)&&!Jt.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=r,i.edges=t,de(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(X.prototype[Symbol.for("nodejs.util.inspect.custom")]=X.prototype.inspect);jn.forEach(n=>{["add","merge","update"].forEach(r=>{const t=n.name(r),e=r==="add"?Zr:Bn;n.generateKey?X.prototype[t]=function(i,a,o){return e(this,t,!0,(n.type||this.type)==="undirected",null,i,a,o,r==="update")}:X.prototype[t]=function(i,a,o,s){return e(this,t,!1,(n.type||this.type)==="undirected",i,a,o,s,r==="update")}})});Xi(X);ln(X);Sn(X);Gn(X);class Xr extends X{constructor(r){const t=te({type:"directed"},r);if("multi"in t&&t.multi!==!1)throw new L("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new L('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 L("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new L('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 L("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 L("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new L('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 L("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new L('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=L;X.NotFoundGraphError=A;X.UsageGraphError=j;function Hn(n,r){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var e=t.call(n,r);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function it(n){var r=Hn(n,"string");return typeof r=="symbol"?r:r+""}function re(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}function tr(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,it(e.key),e)}}function ie(n,r,t){return r&&tr(n.prototype,r),t&&tr(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function He(n){return He=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},He(n)}function ri(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ri=function(){return!!n})()}function Wn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Vn(n,r){if(r&&(typeof r=="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wn(n)}function le(n,r,t){return r=He(r),Vn(n,ri()?Reflect.construct(r,t||[],He(n).constructor):r.apply(n,t))}function It(n,r){return It=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},It(n,r)}function he(n,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(r&&r.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),r&&It(n,r)}function qn(n){if(Array.isArray(n))return n}function Kn(n,r){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var e,i,a,o,s=[],u=!0,l=!1;try{if(a=(t=t.call(n)).next,r===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(e=a.call(t)).done)&&(s.push(e.value),s.length!==r);u=!0);}catch(h){l=!0,i=h}finally{try{if(!u&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Ot(n,r){(r==null||r>n.length)&&(r=n.length);for(var t=0,e=Array(r);t<r;t++)e[t]=n[t];return e}function ii(n,r){if(n){if(typeof n=="string")return Ot(n,r);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ot(n,r):void 0}}function Yn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{g as $r,r as N,R as Et,j as f,a as Oe,O as Ii}from"./index-DdenFaJ5.js";import{C as we,b as pt,c as jr}from"./constants-Dd6A34aQ.js";var st={exports:{}},Xt;function Oi(){if(Xt)return st.exports;Xt=1;var n=typeof Reflect=="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(y,S,C){return Function.prototype.apply.call(y,S,C)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(y){return Object.getOwnPropertyNames(y).concat(Object.getOwnPropertySymbols(y))}:t=function(y){return Object.getOwnPropertyNames(y)};function e(m){console&&console.warn&&console.warn(m)}var i=Number.isNaN||function(y){return y!==y};function a(){a.init.call(this)}st.exports=a,st.exports.once=D,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function s(m){if(typeof m!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof m)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(m){if(typeof m!="number"||m<0||i(m))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+m+".");o=m}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(y){if(typeof y!="number"||y<0||i(y))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+y+".");return this._maxListeners=y,this};function u(m){return m._maxListeners===void 0?a.defaultMaxListeners:m._maxListeners}a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(y){for(var S=[],C=1;C<arguments.length;C++)S.push(arguments[C]);var P=y==="error",O=this._events;if(O!==void 0)P=P&&O.error===void 0;else if(!P)return!1;if(P){var z;if(S.length>0&&(z=S[0]),z instanceof Error)throw z;var Z=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw Z.context=z,Z}var U=O[y];if(U===void 0)return!1;if(typeof U=="function")r(U,this,S);else for(var p=U.length,Q=b(U,p),C=0;C<p;++C)r(Q[C],this,S);return!0};function l(m,y,S,C){var P,O,z;if(s(S),O=m._events,O===void 0?(O=m._events=Object.create(null),m._eventsCount=0):(O.newListener!==void 0&&(m.emit("newListener",y,S.listener?S.listener:S),O=m._events),z=O[y]),z===void 0)z=O[y]=S,++m._eventsCount;else if(typeof z=="function"?z=O[y]=C?[S,z]:[z,S]:C?z.unshift(S):z.push(S),P=u(m),P>0&&z.length>P&&!z.warned){z.warned=!0;var Z=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(y)+" listeners added. Use emitter.setMaxListeners() to increase limit");Z.name="MaxListenersExceededWarning",Z.emitter=m,Z.type=y,Z.count=z.length,e(Z)}return m}a.prototype.addListener=function(y,S){return l(this,y,S,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(y,S){return l(this,y,S,!0)};function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(m,y,S){var C={fired:!1,wrapFn:void 0,target:m,type:y,listener:S},P=h.bind(C);return P.listener=S,C.wrapFn=P,P}a.prototype.once=function(y,S){return s(S),this.on(y,d(this,y,S)),this},a.prototype.prependOnceListener=function(y,S){return s(S),this.prependListener(y,d(this,y,S)),this},a.prototype.removeListener=function(y,S){var C,P,O,z,Z;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){Z=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,Z||S)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(y){var S,C,P;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[y]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[y]),this;if(arguments.length===0){var O=Object.keys(C),z;for(P=0;P<O.length;++P)z=O[P],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=C[y],typeof S=="function")this.removeListener(y,S);else if(S!==void 0)for(P=S.length-1;P>=0;P--)this.removeListener(y,S[P]);return this};function c(m,y,S){var C=m._events;if(C===void 0)return[];var P=C[y];return P===void 0?[]:typeof P=="function"?S?[P.listener||P]:[P]:S?E(P):b(P,P.length)}a.prototype.listeners=function(y){return c(this,y,!0)},a.prototype.rawListeners=function(y){return c(this,y,!1)},a.listenerCount=function(m,y){return typeof m.listenerCount=="function"?m.listenerCount(y):g.call(m,y)},a.prototype.listenerCount=g;function g(m){var y=this._events;if(y!==void 0){var S=y[m];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function b(m,y){for(var S=new Array(y),C=0;C<y;++C)S[C]=m[C];return S}function w(m,y){for(;y+1<m.length;y++)m[y]=m[y+1];m.pop()}function E(m){for(var y=new Array(m.length),S=0;S<y.length;++S)y[S]=m[S].listener||m[S];return y}function D(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 Ur=Oi();function zi(){const n=arguments[0];for(let r=1,t=arguments.length;r<t;r++)if(arguments[r])for(const e in arguments[r])n[e]=arguments[r][e];return n}let te=zi;typeof Object.assign=="function"&&(te=Object.assign);function fe(n,r,t,e){const i=n._nodes.get(r);let a=null;return i&&(e==="mixed"?a=i.out&&i.out[t]||i.undirected&&i.undirected[t]:e==="directed"?a=i.out&&i.out[t]:a=i.undirected&&i.undirected[t]),a}function oe(n){return typeof n=="object"&&n!==null}function Mr(n){let r;for(r in n)return!1;return!0}function de(n,r,t){Object.defineProperty(n,r,{enumerable:!1,configurable:!1,writable:!0,value:t})}function ve(n,r,t){const e={enumerable:!0,configurable:!0};typeof t=="function"?e.get=t:(e.value=t,e.writable=!1),Object.defineProperty(n,r,e)}function Qt(n){return!(!oe(n)||n.attributes&&!Array.isArray(n.attributes))}function $i(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function ke(){const n=arguments;let r=null,t=-1;return{[Symbol.iterator](){return this},next(){let e=null;do{if(r===null){if(t++,t>=n.length)return{done:!0};r=n[t][Symbol.iterator]()}if(e=r.next(),e.done){r=null;continue}break}while(!0);return e}}}function Ve(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Bt extends Error{constructor(r){super(),this.name="GraphError",this.message=r}}class L extends Bt{constructor(r){super(r),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,L.prototype.constructor)}}class A extends Bt{constructor(r){super(r),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,A.prototype.constructor)}}class j extends Bt{constructor(r){super(r),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,j.prototype.constructor)}}function Br(n,r){this.key=n,this.attributes=r,this.clear()}Br.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Hr(n,r){this.key=n,this.attributes=r,this.clear()}Hr.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Wr(n,r){this.key=n,this.attributes=r,this.clear()}Wr.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function qe(n,r,t,e,i){this.key=r,this.attributes=i,this.undirected=n,this.source=t,this.target=e}qe.prototype.attach=function(){let n="out",r="in";this.undirected&&(n=r="undirected");const t=this.source.key,e=this.target.key;this.source[n][e]=this,!(this.undirected&&t===e)&&(this.target[r][t]=this)};qe.prototype.attachMulti=function(){let n="out",r="in";const t=this.source.key,e=this.target.key;this.undirected&&(n=r="undirected");const i=this.source[n],a=i[e];if(typeof a>"u"){i[e]=this,this.undirected&&t===e||(this.target[r][t]=this);return}a.previous=this,this.next=a,i[e]=this,this.target[r][t]=this};qe.prototype.detach=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),delete this.source[t][r],delete this.target[e][n]};qe.prototype.detachMulti=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][r],delete this.target[e][n]):(this.next.previous=void 0,this.source[t][r]=this.next,this.target[e][n]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Vr=0,qr=1,ji=2,Kr=3;function Ae(n,r,t,e,i,a,o){let s,u,l,h;if(e=""+e,t===Vr){if(s=n._nodes.get(e),!s)throw new A(`Graph.${r}: could not find the "${e}" node in the graph.`);l=i,h=a}else if(t===Kr){if(i=""+i,u=n._edges.get(i),!u)throw new A(`Graph.${r}: could not find the "${i}" edge in the graph.`);const d=u.source.key,c=u.target.key;if(e===d)s=u.target;else if(e===c)s=u.source;else throw new A(`Graph.${r}: the "${e}" node is not attached to the "${i}" edge (${d}, ${c}).`);l=a,h=o}else{if(u=n._edges.get(e),!u)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`);t===qr?s=u.source:s=u.target,l=i,h=a}return[s,l,h]}function Ui(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return o.attributes[s]}}function Mi(n,r,t){n.prototype[r]=function(e,i){const[a]=Ae(this,r,t,e,i);return a.attributes}}function Bi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return o.attributes.hasOwnProperty(s)}}function Hi(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,l]=Ae(this,r,t,e,i,a,o);return s.attributes[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Wi(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,l]=Ae(this,r,t,e,i,a,o);if(typeof l!="function")throw new L(`Graph.${r}: updater should be a function.`);const h=s.attributes,d=l(h[u]);return h[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Vi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return delete o.attributes[s],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:s}),this}}function qi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(!oe(s))throw new L(`Graph.${r}: provided attributes are not a plain object.`);return o.attributes=s,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Ki(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(!oe(s))throw new L(`Graph.${r}: provided attributes are not a plain object.`);return te(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Yi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(typeof s!="function")throw new L(`Graph.${r}: provided updater is not a function.`);return o.attributes=s(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const Zi=[{name:n=>`get${n}Attribute`,attacher:Ui},{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"),ji),t(n,r("Opposite"),Kr)})}function Qi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes[i]}}function Ji(n,r,t){n.prototype[r]=function(e){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,o=""+arguments[1];if(i=fe(this,a,o,t),!i)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,i=this._edges.get(e),!i)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return i.attributes}}function en(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function tn(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+i;if(i=arguments[2],a=arguments[3],o=fe(this,s,u,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return o.attributes[i]=a,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function rn(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+i;if(i=arguments[2],a=arguments[3],o=fe(this,s,u,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof a!="function")throw new L(`Graph.${r}: updater should be a function.`);return o.attributes[i]=a(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function nn(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return delete a.attributes[i],this.emit("edgeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:i}),this}}function an(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!oe(i))throw new L(`Graph.${r}: provided attributes are not a plain object.`);return a.attributes=i,this.emit("edgeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function on(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!oe(i))throw new L(`Graph.${r}: provided attributes are not a plain object.`);return te(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function sn(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new j(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new j(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof i!="function")throw new L(`Graph.${r}: provided updater is not a function.`);return a.attributes=i(a.attributes),this.emit("edgeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const un=[{name:n=>`get${n}Attribute`,attacher:Qi},{name:n=>`get${n}Attributes`,attacher:Ji},{name:n=>`has${n}Attribute`,attacher:en},{name:n=>`set${n}Attribute`,attacher:tn},{name:n=>`update${n}Attribute`,attacher:rn},{name:n=>`remove${n}Attribute`,attacher:nn},{name:n=>`replace${n}Attributes`,attacher:an},{name:n=>`merge${n}Attributes`,attacher:on},{name:n=>`update${n}Attributes`,attacher:sn}];function ln(n){un.forEach(function({name:r,attacher:t}){t(n,r("Edge"),"mixed"),t(n,r("DirectedEdge"),"directed"),t(n,r("UndirectedEdge"),"undirected")})}const hn=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function dn(n,r,t,e){let i=!1;for(const a in r){if(a===e)continue;const o=r[a];if(i=t(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),n&&i)return o.key}}function cn(n,r,t,e){let i,a,o,s=!1;for(const u in r)if(u!==e){i=r[u];do{if(a=i.source,o=i.target,s=t(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),n&&s)return i.key;i=i.next}while(i!==void 0)}}function xt(n,r){const t=Object.keys(n),e=t.length;let i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=e)return{done:!0};const o=t[a++];if(o===r){i=void 0;continue}i=n[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function fn(n,r,t,e){const i=r[t];if(!i)return;const a=i.source,o=i.target;if(e(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&n)return i.key}function gn(n,r,t,e){let i=r[t];if(!i)return;let a=!1;do{if(a=e(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),n&&a)return i.key;i=i.next}while(i!==void 0)}function _t(n,r){let t=n[r];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const i={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:i}}};let e=!1;return{[Symbol.iterator](){return this},next(){return e===!0?{done:!0}:(e=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function pn(n,r){if(n.size===0)return[];if(r==="mixed"||r===n.type)return Array.from(n._edges.keys());const t=r==="undirected"?n.undirectedSize:n.directedSize,e=new Array(t),i=r==="undirected",a=n._edges.values();let o=0,s,u;for(;s=a.next(),s.done!==!0;)u=s.value,u.undirected===i&&(e[o++]=u.key);return e}function Yr(n,r,t,e){if(r.size===0)return;const i=t!=="mixed"&&t!==r.type,a=t==="undirected";let o,s,u=!1;const l=r._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;const{key:h,attributes:d,source:c,target:g}=s;if(u=e(h,d,c.key,g.key,c.attributes,g.attributes,s.undirected),n&&u)return h}}function mn(n,r){if(n.size===0)return Ve();const t=r!=="mixed"&&r!==n.type,e=r==="undirected",i=n._edges.values();return{[Symbol.iterator](){return this},next(){let a,o;for(;;){if(a=i.next(),a.done)return a;if(o=a.value,!(t&&o.undirected!==e))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function Ht(n,r,t,e,i,a){const o=r?cn:dn;let s;if(t!=="undirected"&&(e!=="out"&&(s=o(n,i.in,a),n&&s)||e!=="in"&&(s=o(n,i.out,a,e?void 0:i.key),n&&s))||t!=="directed"&&(s=o(n,i.undirected,a),n&&s))return s}function vn(n,r,t,e){const i=[];return Ht(!1,n,r,t,e,function(a){i.push(a)}),i}function yn(n,r,t){let e=Ve();return n!=="undirected"&&(r!=="out"&&typeof t.in<"u"&&(e=ke(e,xt(t.in))),r!=="in"&&typeof t.out<"u"&&(e=ke(e,xt(t.out,r?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(e=ke(e,xt(t.undirected))),e}function Wt(n,r,t,e,i,a,o){const s=t?gn:fn;let u;if(r!=="undirected"&&(typeof i.in<"u"&&e!=="out"&&(u=s(n,i.in,a,o),n&&u)||typeof i.out<"u"&&e!=="in"&&(e||i.key!==a)&&(u=s(n,i.out,a,o),n&&u))||r!=="directed"&&typeof i.undirected<"u"&&(u=s(n,i.undirected,a,o),n&&u))return u}function bn(n,r,t,e,i){const a=[];return Wt(!1,n,r,t,e,i,function(o){a.push(o)}),a}function wn(n,r,t,e){let i=Ve();return n!=="undirected"&&(typeof t.in<"u"&&r!=="out"&&e in t.in&&(i=ke(i,_t(t.in,e))),typeof t.out<"u"&&r!=="in"&&e in t.out&&(r||t.key!==e)&&(i=ke(i,_t(t.out,e)))),n!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(i=ke(i,_t(t.undirected,e))),i}function En(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(a,o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];if(!arguments.length)return pn(this,e);if(arguments.length===1){a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${t}: could not find the "${a}" node in the graph.`);return vn(this.multi,e==="mixed"?this.type:e,i,s)}if(arguments.length===2){a=""+a,o=""+o;const s=this._nodes.get(a);if(!s)throw new A(`Graph.${t}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new A(`Graph.${t}: could not find the "${o}" target node in the graph.`);return bn(e,this.multi,i,s,o)}throw new L(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function xn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(l,h,d){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return d=l,Yr(!1,this,e,d);if(arguments.length===2){l=""+l,d=h;const c=this._nodes.get(l);if(typeof c>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);return Ht(!1,this.multi,e==="mixed"?this.type:e,i,c,d)}if(arguments.length===3){l=""+l,h=""+h;const c=this._nodes.get(l);if(!c)throw new A(`Graph.${a}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(h))throw new A(`Graph.${a}: could not find the "${h}" target node in the graph.`);return Wt(!1,e,this.multi,i,c,h,d)}throw new L(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop();let d;if(l.length===0){let c=0;e!=="directed"&&(c+=this.undirectedSize),e!=="undirected"&&(c+=this.directedSize),d=new Array(c);let g=0;l.push((b,w,E,D,_,R,m)=>{d[g++]=h(b,w,E,D,_,R,m)})}else d=[],l.push((c,g,b,w,E,D,_)=>{d.push(h(c,g,b,w,E,D,_))});return this[a].apply(this,l),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop(),d=[];return l.push((c,g,b,w,E,D,_)=>{h(c,g,b,w,E,D,_)&&d.push(c)}),this[a].apply(this,l),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(){let l=Array.prototype.slice.call(arguments);if(l.length<2||l.length>4)throw new L(`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 L(`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((g,b,w,E,D,_,R)=>{c=h(c,g,b,w,E,D,_,R)}),this[a].apply(this,l),c}}function _n(n,r){const{name:t,type:e,direction:i}=r,a="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(u,l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return h=u,Yr(!0,this,e,h);if(arguments.length===2){u=""+u,h=l;const d=this._nodes.get(u);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${u}" node in the graph.`);return Ht(!0,this.multi,e==="mixed"?this.type:e,i,d,h)}if(arguments.length===3){u=""+u,l=""+l;const d=this._nodes.get(u);if(!d)throw new A(`Graph.${a}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new A(`Graph.${a}: could not find the "${l}" target node in the graph.`);return Wt(!0,e,this.multi,i,d,l,h)}throw new L(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,g,b,w,E,D)=>l(d,c,g,b,w,E,D)),!!this[a].apply(this,u)};const s="every"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,g,b,w,E,D)=>!l(d,c,g,b,w,E,D)),!this[a].apply(this,u)}}function Cn(n,r){const{name:t,type:e,direction:i}=r,a=t.slice(0,-1)+"Entries";n.prototype[a]=function(o,s){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();if(!arguments.length)return mn(this,e);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(!u)throw new A(`Graph.${a}: could not find the "${o}" node in the graph.`);return yn(e,i,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new A(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new A(`Graph.${a}: could not find the "${s}" target node in the graph.`);return wn(e,i,u,s)}throw new L(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Sn(n){hn.forEach(r=>{En(n,r),xn(n,r),_n(n,r),Cn(n,r)})}const Tn=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function mt(){this.A=null,this.B=null}mt.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};mt.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function Ze(n,r,t,e,i){for(const a in e){const o=e[a],s=o.source,u=o.target,l=s===t?u:s;if(r&&r.has(l.key))continue;const h=i(l.key,l.attributes);if(n&&h)return l.key}}function Vt(n,r,t,e,i){if(r!=="mixed"){if(r==="undirected")return Ze(n,null,e,e.undirected,i);if(typeof t=="string")return Ze(n,null,e,e[t],i)}const a=new mt;let o;if(r!=="undirected"){if(t!=="out"){if(o=Ze(n,null,e,e.in,i),n&&o)return o;a.wrap(e.in)}if(t!=="in"){if(o=Ze(n,a,e,e.out,i),n&&o)return o;a.wrap(e.out)}}if(r!=="directed"&&(o=Ze(n,a,e,e.undirected,i),n&&o))return o}function Rn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Object.keys(t.undirected);if(typeof r=="string")return Object.keys(t[r])}const e=[];return Vt(!1,n,r,t,function(i){e.push(i)}),e}function Xe(n,r,t){const e=Object.keys(t),i=e.length;let a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return n&&n.wrap(t),{done:!0};const s=t[e[a++]],u=s.source,l=s.target;if(o=u===r?l:u,n&&n.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function kn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Xe(null,t,t.undirected);if(typeof r=="string")return Xe(null,t,t[r])}let e=Ve();const i=new mt;return n!=="undirected"&&(r!=="out"&&(e=ke(e,Xe(i,t,t.in))),r!=="in"&&(e=ke(e,Xe(i,t,t.out)))),n!=="directed"&&(e=ke(e,Xe(i,t,t.undirected))),e}function An(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];a=""+a;const o=this._nodes.get(a);if(typeof o>"u")throw new A(`Graph.${t}: could not find the "${a}" node in the graph.`);return Rn(e==="mixed"?this.type:e,i,o)}}function Dn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);Vt(!1,e==="mixed"?this.type:e,i,d,h)};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(l,h){const d=[];return this[a](l,(c,g)=>{d.push(h(c,g))}),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(l,h){const d=[];return this[a](l,(c,g)=>{h(c,g)&&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 L(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c=d;return this[a](l,(g,b)=>{c=h(c,g,b)}),c}}function Ln(n,r){const{name:t,type:e,direction:i}=r,a=t[0].toUpperCase()+t.slice(1,-1),o="find"+a;n.prototype[o]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);return Vt(!0,e==="mixed"?this.type:e,i,d,h)};const s="some"+a;n.prototype[s]=function(l,h){return!!this[o](l,h)};const u="every"+a;n.prototype[u]=function(l,h){return!this[o](l,(c,g)=>!h(c,g))}}function Nn(n,r){const{name:t,type:e,direction:i}=r,a=t.slice(0,-1)+"Entries";n.prototype[a]=function(o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new A(`Graph.${a}: could not find the "${o}" node in the graph.`);return kn(e==="mixed"?this.type:e,i,s)}}function Gn(n){Tn.forEach(r=>{An(n,r),Dn(n,r),Ln(n,r),Nn(n,r)})}function ut(n,r,t,e,i){const a=e._nodes.values(),o=e.type;let s,u,l,h,d,c;for(;s=a.next(),s.done!==!0;){let g=!1;if(u=s.value,o!=="undirected"){h=u.out;for(l in h){d=h[l];do c=d.target,g=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(o!=="directed"){h=u.undirected;for(l in h)if(!(r&&u.key>l)){d=h[l];do c=d.target,c.key!==l&&(c=d.source),g=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}t&&!g&&i(u.key,null,u.attributes,null,null,null,null)}}function Fn(n,r){const t={key:n};return Mr(r.attributes)||(t.attributes=te({},r.attributes)),t}function Pn(n,r,t){const e={key:r,source:t.source.key,target:t.target.key};return Mr(t.attributes)||(e.attributes=te({},t.attributes)),n==="mixed"&&t.undirected&&(e.undirected=!0),e}function In(n){if(!oe(n))throw new L('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 L("Graph.import: serialized node is missing its key.");if("attributes"in n&&(!oe(n.attributes)||n.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function On(n){if(!oe(n))throw new L('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 L("Graph.import: serialized edge is missing its source.");if(!("target"in n))throw new L("Graph.import: serialized edge is missing its target.");if("attributes"in n&&(!oe(n.attributes)||n.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in n&&typeof n.undirected!="boolean")throw new L("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"]),jn=[{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"}],Un={allowSelfLoops:!0,multi:!1,type:"mixed"};function Mn(n,r,t){if(t&&!oe(t))throw new L(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(r=""+r,t=t||{},n._nodes.has(r))throw new j(`Graph.addNode: the "${r}" node already exist in the graph.`);const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function er(n,r,t){const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function Zr(n,r,t,e,i,a,o,s){if(!e&&n.type==="undirected")throw new j(`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 j(`Graph.${r}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!oe(s))throw new L(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`);if(a=""+a,o=""+o,s=s||{},!n.allowSelfLoops&&a===o)throw new j(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=n._nodes.get(a),l=n._nodes.get(o);if(!u)throw new A(`Graph.${r}: source node "${a}" not found.`);if(!l)throw new A(`Graph.${r}: target node "${o}" not found.`);const h={key:null,undirected:e,source:a,target:o,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new j(`Graph.${r}: the "${i}" edge already exists in the graph.`);if(!n.multi&&(e?typeof u.undirected[o]<"u":typeof u.out[o]<"u"))throw new j(`Graph.${r}: an edge linking "${a}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new qe(e,i,u,l,s);n._edges.set(i,d);const c=a===o;return e?(u.undirectedDegree++,l.undirectedDegree++,c&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,c&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?d.attachMulti():d.attach(),e?n._undirectedSize++:n._directedSize++,h.key=i,n.emit("edgeAdded",h),i}function Bn(n,r,t,e,i,a,o,s,u){if(!e&&n.type==="undirected")throw new j(`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 j(`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 L(`Graph.${r}: invalid updater function. Expecting a function but got "${s}"`)}else if(!oe(s))throw new L(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let l;if(u&&(l=s,s=void 0),!n.allowSelfLoops&&a===o)throw new j(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let h=n._nodes.get(a),d=n._nodes.get(o),c,g;if(!t&&(c=n._edges.get(i),c)){if((c.source.key!==a||c.target.key!==o)&&(!e||c.source.key!==o||c.target.key!==a))throw new j(`Graph.${r}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${c.source.key}", "${c.target.key}").`);g=c}if(!g&&!n.multi&&h&&(g=e?h.undirected[o]:h.out[o]),g){const _=[g.key,!1,!1,!1];if(u?!l:!s)return _;if(u){const R=g.attributes;g.attributes=l(R),n.emit("edgeAttributesUpdated",{type:"replace",key:g.key,attributes:g.attributes})}else te(g.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:g.key,attributes:g.attributes,data:s});return _}s=s||{},u&&l&&(s=l(s));const b={key:null,undirected:e,source:a,target:o,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new j(`Graph.${r}: the "${i}" edge already exists in the graph.`);let w=!1,E=!1;h||(h=er(n,a,{}),w=!0,a===o&&(d=h,E=!0)),d||(d=er(n,o,{}),E=!0),c=new qe(e,i,h,d,s),n._edges.set(i,c);const D=a===o;return e?(h.undirectedDegree++,d.undirectedDegree++,D&&(h.undirectedLoops++,n._undirectedSelfLoopCount++)):(h.outDegree++,d.inDegree++,D&&(h.directedLoops++,n._directedSelfLoopCount++)),n.multi?c.attachMulti():c.attach(),e?n._undirectedSize++:n._directedSize++,b.key=i,n.emit("edgeAdded",b),[i,!0,w,E]}function Me(n,r){n._edges.delete(r.key);const{source:t,target:e,attributes:i}=r,a=r.undirected,o=t===e;a?(t.undirectedDegree--,e.undirectedDegree--,o&&(t.undirectedLoops--,n._undirectedSelfLoopCount--)):(t.outDegree--,e.inDegree--,o&&(t.directedLoops--,n._directedSelfLoopCount--)),n.multi?r.detachMulti():r.detach(),a?n._undirectedSize--:n._directedSize--,n.emit("edgeDropped",{key:r.key,attributes:i,source:t.key,target:e.key,undirected:a})}class X extends Ur.EventEmitter{constructor(r){if(super(),r=te({},Un,r),typeof r.multi!="boolean")throw new L(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${r.multi}".`);if(!$n.has(r.type))throw new L(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${r.type}".`);if(typeof r.allowSelfLoops!="boolean")throw new L(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${r.allowSelfLoops}".`);const t=r.type==="mixed"?Br:r.type==="directed"?Hr:Wr;de(this,"NodeDataClass",t);const e="geid_"+zn()+"_";let i=0;const a=()=>{let o;do o=e+i++;while(this._edges.has(o));return o};de(this,"_attributes",{}),de(this,"_nodes",new Map),de(this,"_edges",new Map),de(this,"_directedSize",0),de(this,"_undirectedSize",0),de(this,"_directedSelfLoopCount",0),de(this,"_undirectedSelfLoopCount",0),de(this,"_edgeKeyGenerator",a),de(this,"_options",r),Jt.forEach(o=>de(this,o,this[o])),ve(this,"order",()=>this._nodes.size),ve(this,"size",()=>this._edges.size),ve(this,"directedSize",()=>this._directedSize),ve(this,"undirectedSize",()=>this._undirectedSize),ve(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ve(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ve(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ve(this,"multi",this._options.multi),ve(this,"type",this._options.type),ve(this,"allowSelfLoops",this._options.allowSelfLoops),ve(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(r){return this._nodes.has(""+r)}hasDirectedEdge(r,t){if(this.type==="undirected")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&!i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.out.hasOwnProperty(t):!1}throw new L(`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 L(`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 L(`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 j("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 j("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 j("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.edge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||e.undirected&&e.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areDirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in||t in e.out}areOutNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.out}areInNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in}areUndirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areUndirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="directed"?!1:t in e.undirected}areNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&(t in e.in||t in e.out)||this.type!=="directed"&&t in e.undirected}areInboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.in||this.type!=="directed"&&t in e.undirected}areOutboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.out||this.type!=="directed"&&t in e.undirected}inDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegree: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree),e}outboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.outDegree),e}degree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree),e}inDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree,i+=t.directedLoops),e-i}outboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.outDegree,i+=t.directedLoops),e-i}degreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree,i+=t.directedLoops*2),e-i}source(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.source: could not find the "${r}" edge in the graph.`);return t.source.key}target(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.target: could not find the "${r}" edge in the graph.`);return t.target.key}extremities(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.extremities: could not find the "${r}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(r,t){r=""+r,t=""+t;const e=this._edges.get(t);if(!e)throw new A(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=e.source.key,a=e.target.key;if(r===i)return a;if(r===a)return i;throw new A(`Graph.opposite: the "${r}" node is not attached to the "${t}" edge (${i}, ${a}).`)}hasExtremity(r,t){r=""+r,t=""+t;const e=this._edges.get(r);if(!e)throw new A(`Graph.hasExtremity: could not find the "${r}" edge in the graph.`);return e.source.key===t||e.target.key===t}isUndirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isUndirected: could not find the "${r}" edge in the graph.`);return t.undirected}isDirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isDirected: could not find the "${r}" edge in the graph.`);return!t.undirected}isSelfLoop(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isSelfLoop: could not find the "${r}" edge in the graph.`);return t.source===t.target}addNode(r,t){return Mn(this,r,t).key}mergeNode(r,t){if(t&&!oe(t))throw new L(`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 L(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);r=""+r;let e=this._nodes.get(r);if(e){if(t){const a=e.attributes;e.attributes=t(a),this.emit("nodeAttributesUpdated",{type:"replace",key:r,attributes:e.attributes})}return[r,!1]}const i=t?t({}):{};return e=new this.NodeDataClass(r,i),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:i}),[r,!0]}dropNode(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.dropNode: could not find the "${r}" node in the graph.`);let e;if(this.type!=="undirected"){for(const i in t.out){e=t.out[i];do Me(this,e),e=e.next;while(e)}for(const i in t.in){e=t.in[i];do Me(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const i in t.undirected){e=t.undirected[i];do Me(this,e),e=e.next;while(e)}this._nodes.delete(r),this.emit("nodeDropped",{key:r,attributes:t.attributes})}dropEdge(r){let t;if(arguments.length>1){const e=""+arguments[0],i=""+arguments[1];if(t=fe(this,e,i,this.type),!t)throw new A(`Graph.dropEdge: could not find the "${e}" -> "${i}" edge in the graph.`)}else if(r=""+r,t=this._edges.get(r),!t)throw new A(`Graph.dropEdge: could not find the "${r}" edge in the graph.`);return Me(this,t),this}dropDirectedEdge(r,t){if(arguments.length<2)throw new j("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 j("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 j("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 j("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 L("Graph.updateAttribute: updater should be a function.");const e=this._attributes[r];return this._attributes[r]=t(e),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}removeAttribute(r){return delete this._attributes[r],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:r}),this}replaceAttributes(r){if(!oe(r))throw new L("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=r,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(r){if(!oe(r))throw new L("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 L("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 L("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new L("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._nodes.values();let i,a;for(;i=e.next(),i.done!==!0;)a=i.value,a.attributes=r(a.key,a.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(r,t){if(typeof r!="function")throw new L("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new L("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._edges.values();let i,a,o,s;for(;i=e.next(),i.done!==!0;)a=i.value,o=a.source,s=a.target,a.attributes=r(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(r){if(typeof r!="function")throw new L("Graph.forEachAdjacencyEntry: expecting a callback.");ut(!1,!1,!1,this,r)}forEachAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new L("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!1,!0,this,r)}forEachAssymetricAdjacencyEntry(r){if(typeof r!="function")throw new L("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ut(!1,!0,!1,this,r)}forEachAssymetricAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new L("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 L("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 L("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 L("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let e,i;const a=new Array(this.order);let o=0;for(;e=t.next(),e.done!==!0;)i=e.value,a[o++]=r(i.key,i.attributes);return a}someNode(r){if(typeof r!="function")throw new L("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 L("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 L("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let e,i;const a=[];for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)&&a.push(i.key);return a}reduceNodes(r,t){if(typeof r!="function")throw new L("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new L("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let e=t;const i=this._nodes.values();let a,o;for(;a=i.next(),a.done!==!0;)o=a.value,e=r(e,o.key,o.attributes);return e}nodeEntries(){const r=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=r.next();if(t.done)return t;const e=t.value;return{value:{node:e.key,attributes:e.attributes},done:!1}}}}export(){const r=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,a)=>{r[t++]=Fn(a,i)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((i,a)=>{e[t++]=Pn(this.type,a,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:r,edges:e}}import(r,t=!1){if(r instanceof X)return r.forEachNode((u,l)=>{t?this.mergeNode(u,l):this.addNode(u,l)}),r.forEachEdge((u,l,h,d,c,g,b)=>{t?b?this.mergeUndirectedEdgeWithKey(u,h,d,l):this.mergeDirectedEdgeWithKey(u,h,d,l):b?this.addUndirectedEdgeWithKey(u,h,d,l):this.addDirectedEdgeWithKey(u,h,d,l)}),this;if(!oe(r))throw new L("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!oe(r.attributes))throw new L("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(r.attributes):this.replaceAttributes(r.attributes)}let e,i,a,o,s;if(r.nodes){if(a=r.nodes,!Array.isArray(a))throw new L("Graph.import: invalid nodes. Expecting an array.");for(e=0,i=a.length;e<i;e++){o=a[e],In(o);const{key:u,attributes:l}=o;t?this.mergeNode(u,l):this.addNode(u,l)}}if(r.edges){let u=!1;if(this.type==="undirected"&&(u=!0),a=r.edges,!Array.isArray(a))throw new L("Graph.import: invalid edges. Expecting an array.");for(e=0,i=a.length;e<i;e++){s=a[e],On(s);const{source:l,target:h,attributes:d,undirected:c=u}=s;let g;"key"in s?(g=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,g.call(this,s.key,l,h,d)):(g=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,g.call(this,l,h,d))}}return this}nullCopy(r){const t=new X(te({},this._options,r));return t.replaceAttributes(te({},this.getAttributes())),t}emptyCopy(r){const t=this.nullCopy(r);return this._nodes.forEach((e,i)=>{const a=te({},e.attributes);e=new t.NodeDataClass(i,a),t._nodes.set(i,e)}),t}copy(r){if(r=r||{},typeof r.type=="string"&&r.type!==this.type&&r.type!=="mixed")throw new j(`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 j("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 j("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(r),e=this._edges.values();let i,a;for(;i=e.next(),i.done!==!0;)a=i.value,Zr(t,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,te({},a.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const r={};this._nodes.forEach((a,o)=>{r[o]=a.attributes});const t={},e={};this._edges.forEach((a,o)=>{const s=a.undirected?"--":"->";let u="",l=a.source.key,h=a.target.key,d;a.undirected&&l>h&&(d=l,l=h,h=d);const c=`(${l})${s}(${h})`;o.startsWith("geid_")?this.multi&&(typeof e[c]>"u"?e[c]=0:e[c]++,u+=`${e[c]}. `):u+=`[${o}]: `,u+=c,t[u]=a.attributes});const i={};for(const a in this)this.hasOwnProperty(a)&&!Jt.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=r,i.edges=t,de(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(X.prototype[Symbol.for("nodejs.util.inspect.custom")]=X.prototype.inspect);jn.forEach(n=>{["add","merge","update"].forEach(r=>{const t=n.name(r),e=r==="add"?Zr:Bn;n.generateKey?X.prototype[t]=function(i,a,o){return e(this,t,!0,(n.type||this.type)==="undirected",null,i,a,o,r==="update")}:X.prototype[t]=function(i,a,o,s){return e(this,t,!1,(n.type||this.type)==="undirected",i,a,o,s,r==="update")}})});Xi(X);ln(X);Sn(X);Gn(X);class Xr extends X{constructor(r){const t=te({type:"directed"},r);if("multi"in t&&t.multi!==!1)throw new L("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new L('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 L("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new L('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 L("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 L("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new L('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 L("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new L('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=L;X.NotFoundGraphError=A;X.UsageGraphError=j;function Hn(n,r){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var e=t.call(n,r);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function it(n){var r=Hn(n,"string");return typeof r=="symbol"?r:r+""}function re(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}function tr(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,it(e.key),e)}}function ie(n,r,t){return r&&tr(n.prototype,r),t&&tr(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function He(n){return He=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},He(n)}function ri(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ri=function(){return!!n})()}function Wn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Vn(n,r){if(r&&(typeof r=="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wn(n)}function le(n,r,t){return r=He(r),Vn(n,ri()?Reflect.construct(r,t||[],He(n).constructor):r.apply(n,t))}function It(n,r){return It=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},It(n,r)}function he(n,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(r&&r.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),r&&It(n,r)}function qn(n){if(Array.isArray(n))return n}function Kn(n,r){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var e,i,a,o,s=[],u=!0,l=!1;try{if(a=(t=t.call(n)).next,r===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(e=a.call(t)).done)&&(s.push(e.value),s.length!==r);u=!0);}catch(h){l=!0,i=h}finally{try{if(!u&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Ot(n,r){(r==null||r>n.length)&&(r=n.length);for(var t=0,e=Array(r);t<r;t++)e[t]=n[t];return e}function ii(n,r){if(n){if(typeof n=="string")return Ot(n,r);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ot(n,r):void 0}}function Yn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function We(n,r){return qn(n)||Kn(n,r)||ii(n,r)||Yn()}var Ct={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},ni=new Int8Array(4),St=new Int32Array(ni.buffer,0,1),Zn=new Float32Array(ni.buffer,0,1),Xn=/^\s*rgba?\s*\(/,Qn=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Jn(n){var r=0,t=0,e=0,i=1;if(n[0]==="#")n.length===4?(r=parseInt(n.charAt(1)+n.charAt(1),16),t=parseInt(n.charAt(2)+n.charAt(2),16),e=parseInt(n.charAt(3)+n.charAt(3),16)):(r=parseInt(n.charAt(1)+n.charAt(2),16),t=parseInt(n.charAt(3)+n.charAt(4),16),e=parseInt(n.charAt(5)+n.charAt(6),16)),n.length===9&&(i=parseInt(n.charAt(7)+n.charAt(8),16)/255);else if(Xn.test(n)){var a=n.match(Qn);a&&(r=+a[1],t=+a[2],e=+a[3],a[4]&&(i=+a[4]))}return{r,g:t,b:e,a:i}}var Be={};for(var lt in Ct)Be[lt]=$e(Ct[lt]),Be[Ct[lt]]=Be[lt];function ai(n,r,t,e,i){return St[0]=e<<24|t<<16|r<<8|n,St[0]=St[0]&4278190079,Zn[0]}function $e(n){if(n=n.toLowerCase(),typeof Be[n]<"u")return Be[n];var r=Jn(n),t=r.r,e=r.g,i=r.b,a=r.a;a=a*255|0;var o=ai(t,e,i,a);return Be[n]=o,o}var Tt={};function oi(n){if(typeof Tt[n]<"u")return Tt[n];var r=(n&16711680)>>>16,t=(n&65280)>>>8,e=n&255,i=255,a=ai(r,t,e,i);return Tt[n]=a,a}function rr(n,r,t,e){return t+(r<<8)+(n<<16)}function ir(n,r,t,e,i,a){var o=Math.floor(t/a*i),s=Math.floor(n.drawingBufferHeight/a-e/a*i),u=new Uint8Array(4);n.bindFramebuffer(n.FRAMEBUFFER,r),n.readPixels(o,s,1,1,n.RGBA,n.UNSIGNED_BYTE,u);var l=We(u,4),h=l[0],d=l[1],c=l[2],g=l[3];return[h,d,c,g]}function T(n,r,t){return(r=it(r))in n?Object.defineProperty(n,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[r]=t,n}function nr(n,r){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(n);r&&(e=e.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,e)}return t}function F(n){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?nr(Object(t),!0).forEach(function(e){T(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):nr(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function ea(n,r){for(;!{}.hasOwnProperty.call(n,r)&&(n=He(n))!==null;);return n}function zt(){return zt=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,r,t){var e=ea(n,r);if(e){var i=Object.getOwnPropertyDescriptor(e,r);return i.get?i.get.call(arguments.length<3?n:t):i.value}},zt.apply(null,arguments)}function si(n,r,t,e){var i=zt(He(n.prototype),r,t);return typeof i=="function"?function(a){return i.apply(t,a)}:i}function ta(n){return n.normalized?1:n.size}function Rt(n){var r=0;return n.forEach(function(t){return r+=ta(t)}),r}function ui(n,r,t){var e=n==="VERTEX"?r.VERTEX_SHADER:r.FRAGMENT_SHADER,i=r.createShader(e);if(i===null)throw new Error("loadShader: error while creating the shader");r.shaderSource(i,t),r.compileShader(i);var a=r.getShaderParameter(i,r.COMPILE_STATUS);if(!a){var o=r.getShaderInfoLog(i);throw r.deleteShader(i),new Error(`loadShader: error while compiling the shader:
3
3
  `.concat(o,`
4
4
  `).concat(t))}return i}function ra(n,r){return ui("VERTEX",n,r)}function ia(n,r){return ui("FRAGMENT",n,r)}function na(n,r){var t=n.createProgram();if(t===null)throw new Error("loadProgram: error while creating the program.");var e,i;for(e=0,i=r.length;e<i;e++)n.attachShader(t,r[e]);n.linkProgram(t);var a=n.getProgramParameter(t,n.LINK_STATUS);if(!a)throw n.deleteProgram(t),new Error("loadProgram: error while linking the program.");return t}function ar(n){var r=n.gl,t=n.buffer,e=n.program,i=n.vertexShader,a=n.fragmentShader;r.deleteShader(i),r.deleteShader(a),r.deleteProgram(e),r.deleteBuffer(t)}var or=`#define PICKING_MODE