@plebeiantech/lat.md 0.12.3-fork.20 → 0.12.3-fork.21

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 (71) hide show
  1. package/dist/src/cli/hook.js +4 -25
  2. package/dist/src/search/chunks.js +3 -0
  3. package/dist/src/view/client/assets/{GraphView-Dij8mAA_.js → GraphView-0bPe_Q5I.js} +1 -1
  4. package/dist/src/view/client/assets/{MarkdownEditor-88Wbt0M1.js → MarkdownEditor-1_8mI7lO.js} +1 -1
  5. package/dist/src/view/client/assets/{abnfDiagram-VCTEODGH-y0DlYa8E.js → abnfDiagram-VCTEODGH-BLIuikwY.js} +1 -1
  6. package/dist/src/view/client/assets/{arc-FlMu8dnO.js → arc-D4PzdKSA.js} +1 -1
  7. package/dist/src/view/client/assets/{architectureDiagram-5GKGNRK7-DA_uWZW1.js → architectureDiagram-5GKGNRK7-35Egww62.js} +1 -1
  8. package/dist/src/view/client/assets/{blockDiagram-I7D4REHJ-BHQ5LU85.js → blockDiagram-I7D4REHJ-tqNy53-W.js} +1 -1
  9. package/dist/src/view/client/assets/{c4Diagram-7LVT6UL2-BRucKCt2.js → c4Diagram-7LVT6UL2-DZ_GcD9K.js} +1 -1
  10. package/dist/src/view/client/assets/channel-DensupHE.js +1 -0
  11. package/dist/src/view/client/assets/{chunk-2Q5K7J3B-BJPcFivt.js → chunk-2Q5K7J3B-BUjq4Q7b.js} +1 -1
  12. package/dist/src/view/client/assets/{chunk-5VM5RSS4-v2q99bGz.js → chunk-5VM5RSS4-BsIix6I5.js} +1 -1
  13. package/dist/src/view/client/assets/{chunk-F27PBJKO-CcHOuJCs.js → chunk-F27PBJKO-Dxo7UheG.js} +1 -1
  14. package/dist/src/view/client/assets/{chunk-IMKFNOWR-DNxYuJNq.js → chunk-IMKFNOWR-C5lzUDK5.js} +1 -1
  15. package/dist/src/view/client/assets/{chunk-JWPE2WC7-C0eHKvLW.js → chunk-JWPE2WC7-qCHQlKfY.js} +1 -1
  16. package/dist/src/view/client/assets/{chunk-POPQ4Y6H-57CWp2Ve.js → chunk-POPQ4Y6H-CDPKw21I.js} +1 -1
  17. package/dist/src/view/client/assets/{chunk-SVP7TREG-BqcoxIJw.js → chunk-SVP7TREG-CD_C-9M-.js} +1 -1
  18. package/dist/src/view/client/assets/{chunk-TICWLB2K-DRUJR5zH.js → chunk-TICWLB2K-ZMatRvad.js} +1 -1
  19. package/dist/src/view/client/assets/{chunk-XXDRQBXY-Dez0oRoM.js → chunk-XXDRQBXY-dDs4quwg.js} +1 -1
  20. package/dist/src/view/client/assets/classDiagram-ZZMXUADV-CV7ArHLW.js +1 -0
  21. package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-CV7ArHLW.js +1 -0
  22. package/dist/src/view/client/assets/{cose-bilkent-JH36ORCC-BHtud6Hg.js → cose-bilkent-JH36ORCC-CwH3-T1N.js} +1 -1
  23. package/dist/src/view/client/assets/{cynefin-OW5HDTMX-BjBW8VGk.js → cynefin-OW5HDTMX-DodS6r00.js} +1 -1
  24. package/dist/src/view/client/assets/{cynefinDiagram-5FMLGOSQ-DwGuD7oF.js → cynefinDiagram-5FMLGOSQ-D7WDoy0K.js} +1 -1
  25. package/dist/src/view/client/assets/{dagre-GXQ25YYZ-C5zSlGK9.js → dagre-GXQ25YYZ-yc2GTi5h.js} +1 -1
  26. package/dist/src/view/client/assets/{diagram-S7CK7UJ4-C_NhA3bj.js → diagram-S7CK7UJ4-CEP0FGL8.js} +1 -1
  27. package/dist/src/view/client/assets/{diagram-UQ7AKVKN-az7QPYNb.js → diagram-UQ7AKVKN-BZIEojBf.js} +1 -1
  28. package/dist/src/view/client/assets/{diagram-VSXAHHWV-BRvDuM8_.js → diagram-VSXAHHWV-BSB6COmM.js} +1 -1
  29. package/dist/src/view/client/assets/{diagram-VX7I27RA-BWLgF6S-.js → diagram-VX7I27RA-DqfR3psV.js} +1 -1
  30. package/dist/src/view/client/assets/{diagram-Z3DM3KII-DV3d6mL5.js → diagram-Z3DM3KII-B79t0s5P.js} +1 -1
  31. package/dist/src/view/client/assets/{ebnfDiagram-PWID7BFC-yUXrEAvK.js → ebnfDiagram-PWID7BFC-CqbCQhE1.js} +1 -1
  32. package/dist/src/view/client/assets/{erDiagram-RLTQ6QDP-D35FN1Pt.js → erDiagram-RLTQ6QDP-BVfoYIhJ.js} +1 -1
  33. package/dist/src/view/client/assets/{flowDiagram-HODETNUW-BciZqsjT.js → flowDiagram-HODETNUW-Dfyjm6ib.js} +1 -1
  34. package/dist/src/view/client/assets/{ganttDiagram-EL5Y4UJY-BysPGgXS.js → ganttDiagram-EL5Y4UJY-Da9ta_k3.js} +1 -1
  35. package/dist/src/view/client/assets/{gitGraphDiagram-WWUBYQGX-C3DdJ5xG.js → gitGraphDiagram-WWUBYQGX-BDqlQ6LG.js} +1 -1
  36. package/dist/src/view/client/assets/{index-CJokoRSp.js → index-heNSjszK.js} +3 -3
  37. package/dist/src/view/client/assets/{infoDiagram-27XIBGKW-D3HZrDRb.js → infoDiagram-27XIBGKW-CozIUYm1.js} +1 -1
  38. package/dist/src/view/client/assets/{ishikawaDiagram-5VMMS53U-BXyVIXTU.js → ishikawaDiagram-5VMMS53U-tkBLr-Tn.js} +1 -1
  39. package/dist/src/view/client/assets/{journeyDiagram-3NMN7TZE-D4-1NxVU.js → journeyDiagram-3NMN7TZE-Dcd_Ofwc.js} +1 -1
  40. package/dist/src/view/client/assets/{kanban-definition-UXKFOSKX-4Gu_5yBA.js → kanban-definition-UXKFOSKX-CQvZmdAf.js} +1 -1
  41. package/dist/src/view/client/assets/{layout-Jf1K3TMM.js → layout-BxuGL0Ip.js} +1 -1
  42. package/dist/src/view/client/assets/{linear-DWfwzUT_.js → linear-D8tR6G5K.js} +1 -1
  43. package/dist/src/view/client/assets/{mermaid.core-DMx_DAl8.js → mermaid.core-BlHZooLK.js} +5 -5
  44. package/dist/src/view/client/assets/{mindmap-definition-YA3MSWOX-8pxY_RWi.js → mindmap-definition-YA3MSWOX-BqvVz5lC.js} +1 -1
  45. package/dist/src/view/client/assets/{pegDiagram-XKGWAZYB-DNAw_O5t.js → pegDiagram-XKGWAZYB-BkbOOTxX.js} +1 -1
  46. package/dist/src/view/client/assets/{pieDiagram-E7YTZNPT-uuvRCDkC.js → pieDiagram-E7YTZNPT-BToTpG0m.js} +1 -1
  47. package/dist/src/view/client/assets/{quadrantDiagram-AXDQQJYC-BER2O4Aq.js → quadrantDiagram-AXDQQJYC-CerD2TfT.js} +1 -1
  48. package/dist/src/view/client/assets/{railroadDiagram-O6MQD6OU-CxEsJ_0n.js → railroadDiagram-O6MQD6OU-B2oElPYD.js} +1 -1
  49. package/dist/src/view/client/assets/{requirementDiagram-BXWQKSXE-yS9rspca.js → requirementDiagram-BXWQKSXE-BCL8RGFd.js} +1 -1
  50. package/dist/src/view/client/assets/{sankeyDiagram-P5KCCOFB-Bqt70a2j.js → sankeyDiagram-P5KCCOFB-BqnkNRPm.js} +1 -1
  51. package/dist/src/view/client/assets/{sequenceDiagram-WJ2MYXX4-BvOOEJNr.js → sequenceDiagram-WJ2MYXX4-DKSKYknp.js} +1 -1
  52. package/dist/src/view/client/assets/{sizeCapture-INFHLROL-CvO_Pjjo.js → sizeCapture-INFHLROL-D8reQ7IM.js} +1 -1
  53. package/dist/src/view/client/assets/{stateDiagram-D77RDMKH-KLmVOZkq.js → stateDiagram-D77RDMKH-B-Eme-BN.js} +1 -1
  54. package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-yXL-Y-Ym.js +1 -0
  55. package/dist/src/view/client/assets/{swimlanes-42K2YHIH-DC1r4_sq.js → swimlanes-42K2YHIH-lK0158X4.js} +1 -1
  56. package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-CGn5WOGw.js +8 -0
  57. package/dist/src/view/client/assets/{timeline-definition-24CTP7MA-ChXLOuBL.js → timeline-definition-24CTP7MA-imh-edhJ.js} +1 -1
  58. package/dist/src/view/client/assets/{vennDiagram-4TSXK5OY-D9_h25-Y.js → vennDiagram-4TSXK5OY-Ixwhcd6r.js} +1 -1
  59. package/dist/src/view/client/assets/{wardleyDiagram-VM6X3IG4-CsQJGGW0.js → wardleyDiagram-VM6X3IG4-Cvr_zzKI.js} +1 -1
  60. package/dist/src/view/client/assets/{xychartDiagram-S5SC5T6Z-DGMuPMlm.js → xychartDiagram-S5SC5T6Z-BvcmHKlQ.js} +1 -1
  61. package/dist/src/view/client/index.html +1 -1
  62. package/dist/src/view/highlight.js +50335 -6037
  63. package/dist/src/view/markdown.js +3 -0
  64. package/package.json +2 -2
  65. package/templates/AGENTS.md +1 -3
  66. package/templates/cursor-rules.md +1 -3
  67. package/dist/src/view/client/assets/channel-BgDNA_Ay.js +0 -1
  68. package/dist/src/view/client/assets/classDiagram-ZZMXUADV-CFZ_Sgh5.js +0 -1
  69. package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-CFZ_Sgh5.js +0 -1
  70. package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-KCS8Mdzu.js +0 -1
  71. package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-B2TcAwis.js +0 -8
@@ -4,7 +4,6 @@ import { dirname, extname, join } from 'node:path';
4
4
  import { findLatticeDir } from '@plebeiantech/lat.md-core/project-discovery';
5
5
  import { findSections } from '@plebeiantech/lat.md-core/lattice-model';
6
6
  import { plainStyler, } from '@plebeiantech/lat.md-core/context';
7
- import { expandPrompt } from '@plebeiantech/lat.md-core/cli/expand';
8
7
  import { runSearch } from './search.js';
9
8
  import { DEFAULT_SEARCH_LIMIT } from '../search/search.js';
10
9
  import { getSection, formatSectionOutput, } from '@plebeiantech/lat.md-core/cli/section';
@@ -59,9 +58,6 @@ async function readStdin() {
59
58
  }
60
59
  return Buffer.concat(chunks).toString('utf-8');
61
60
  }
62
- function hasWikiLinks(text) {
63
- return /\[\[[^\]]+\]\]/.test(text);
64
- }
65
61
  function makeHookCtx(latDir) {
66
62
  return {
67
63
  latDir,
@@ -70,7 +66,7 @@ function makeHookCtx(latDir) {
70
66
  mode: 'cli',
71
67
  };
72
68
  }
73
- async function searchAndExpand(ctx, userPrompt) {
69
+ async function searchContextForPrompt(ctx, userPrompt) {
74
70
  let result;
75
71
  try {
76
72
  // Read-only: search an existing index but never build/update it here. A fresh
@@ -119,29 +115,12 @@ async function handleUserPromptSubmit() {
119
115
  const latDir = findLatticeDir();
120
116
  if (latDir && userPrompt) {
121
117
  const ctx = makeHookCtx(latDir);
122
- // Parsed once for expansion, search, and federation below. The analysis is
123
- // memoised on `ctx`, so passing that one object everywhere is what keeps
124
- // the three of them from walking and parsing the tree three times.
118
+ // Search and federation share the analysis memoised on `ctx`.
125
119
  const { allSections } = await commandProjectAnalysis(ctx);
126
- // If the user prompt contains [[refs]], resolve them inline
127
- if (hasWikiLinks(userPrompt)) {
128
- try {
129
- const expanded = await expandPrompt(ctx, userPrompt);
130
- if (expanded) {
131
- parts.push('', 'Expanded user prompt with resolved [[refs]]:', expanded);
132
- }
133
- else {
134
- parts.push('', 'NOTE: The user prompt contains [[refs]] but they could not be resolved. Ask the user to correct them.');
135
- }
136
- }
137
- catch {
138
- parts.push('', 'NOTE: The user prompt contains [[refs]] but resolution failed. Run `lat expand` on the prompt text manually.');
139
- }
140
- }
141
120
  // Search for relevant sections and include their full content
142
121
  let searchFilePaths = [];
143
122
  try {
144
- const searchContext = await searchAndExpand(ctx, userPrompt);
123
+ const searchContext = await searchContextForPrompt(ctx, userPrompt);
145
124
  searchFilePaths = searchContext.filePaths;
146
125
  if (searchContext.text) {
147
126
  parts.push('', searchContext.text);
@@ -168,7 +147,7 @@ async function handleUserPromptSubmit() {
168
147
  }
169
148
  }
170
149
  }
171
- // Reuses what searchAndExpand already matched. Searching again here
150
+ // Reuses what searchContextForPrompt already matched. Searching again here
172
151
  // would double the cost of every prompt, and an unusable index makes
173
152
  // runSearch throw — which abandoned the [[ref]] paths collected above,
174
153
  // even though resolving those never touches the index at all.
@@ -46,6 +46,9 @@ export function chunkFile(file, sections, embedder) {
46
46
  for (const block of file.blocks) {
47
47
  if (block.type === 'heading' || block.type === 'yaml')
48
48
  continue;
49
+ // Content before the first heading is outside the section graph.
50
+ if (!ordered.length || block.endLine < ordered[0].startLine)
51
+ continue;
49
52
  while (sectionIndex < ordered.length &&
50
53
  ordered[sectionIndex].startLine <= block.startLine) {
51
54
  const next = ordered[sectionIndex++];
@@ -1,4 +1,4 @@
1
- import{r as z,f as ke,g as at,j as F,s as xt,a as Oi,M as Bi,n as Hi,S as Wi,b as ji,d as Vi,e as qi,c as Tt}from"./index-CJokoRSp.js";import{g as Ki}from"./_commonjsHelpers-CqkleIqs.js";var De={exports:{}},Rt;function Yi(){if(Rt)return De.exports;Rt=1;var r=typeof Reflect=="object"?Reflect:null,i=r&&typeof r.apply=="function"?r.apply:function(p,v,E){return Function.prototype.apply.call(p,v,E)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(p){return Object.getOwnPropertyNames(p).concat(Object.getOwnPropertySymbols(p))}:t=function(p){return Object.getOwnPropertyNames(p)};function e(g){console&&console.warn&&console.warn(g)}var n=Number.isNaN||function(p){return p!==p};function o(){o.init.call(this)}De.exports=o,De.exports.once=R,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(g){if(typeof g!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof g)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(g){if(typeof g!="number"||g<0||n(g))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+g+".");a=g}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(p){if(typeof p!="number"||p<0||n(p))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+p+".");return this._maxListeners=p,this};function u(g){return g._maxListeners===void 0?o.defaultMaxListeners:g._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(p){for(var v=[],E=1;E<arguments.length;E++)v.push(arguments[E]);var k=p==="error",N=this._events;if(N!==void 0)k=k&&N.error===void 0;else if(!k)return!1;if(k){var S;if(v.length>0&&(S=v[0]),S instanceof Error)throw S;var M=new Error("Unhandled error."+(S?" ("+S.message+")":""));throw M.context=S,M}var I=N[p];if(I===void 0)return!1;if(typeof I=="function")i(I,this,v);else for(var L=I.length,P=y(I,L),E=0;E<L;++E)i(P[E],this,v);return!0};function h(g,p,v,E){var k,N,S;if(s(v),N=g._events,N===void 0?(N=g._events=Object.create(null),g._eventsCount=0):(N.newListener!==void 0&&(g.emit("newListener",p,v.listener?v.listener:v),N=g._events),S=N[p]),S===void 0)S=N[p]=v,++g._eventsCount;else if(typeof S=="function"?S=N[p]=E?[v,S]:[S,v]:E?S.unshift(v):S.push(v),k=u(g),k>0&&S.length>k&&!S.warned){S.warned=!0;var M=new Error("Possible EventEmitter memory leak detected. "+S.length+" "+String(p)+" listeners added. Use emitter.setMaxListeners() to increase limit");M.name="MaxListenersExceededWarning",M.emitter=g,M.type=p,M.count=S.length,e(M)}return g}o.prototype.addListener=function(p,v){return h(this,p,v,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(p,v){return h(this,p,v,!0)};function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(g,p,v){var E={fired:!1,wrapFn:void 0,target:g,type:p,listener:v},k=c.bind(E);return k.listener=v,E.wrapFn=k,k}o.prototype.once=function(p,v){return s(v),this.on(p,d(this,p,v)),this},o.prototype.prependOnceListener=function(p,v){return s(v),this.prependListener(p,d(this,p,v)),this},o.prototype.removeListener=function(p,v){var E,k,N,S,M;if(s(v),k=this._events,k===void 0)return this;if(E=k[p],E===void 0)return this;if(E===v||E.listener===v)--this._eventsCount===0?this._events=Object.create(null):(delete k[p],k.removeListener&&this.emit("removeListener",p,E.listener||v));else if(typeof E!="function"){for(N=-1,S=E.length-1;S>=0;S--)if(E[S]===v||E[S].listener===v){M=E[S].listener,N=S;break}if(N<0)return this;N===0?E.shift():m(E,N),E.length===1&&(k[p]=E[0]),k.removeListener!==void 0&&this.emit("removeListener",p,M||v)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(p){var v,E,k;if(E=this._events,E===void 0)return this;if(E.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):E[p]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete E[p]),this;if(arguments.length===0){var N=Object.keys(E),S;for(k=0;k<N.length;++k)S=N[k],S!=="removeListener"&&this.removeAllListeners(S);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(v=E[p],typeof v=="function")this.removeListener(p,v);else if(v!==void 0)for(k=v.length-1;k>=0;k--)this.removeListener(p,v[k]);return this};function l(g,p,v){var E=g._events;if(E===void 0)return[];var k=E[p];return k===void 0?[]:typeof k=="function"?v?[k.listener||k]:[k]:v?b(k):y(k,k.length)}o.prototype.listeners=function(p){return l(this,p,!0)},o.prototype.rawListeners=function(p){return l(this,p,!1)},o.listenerCount=function(g,p){return typeof g.listenerCount=="function"?g.listenerCount(p):f.call(g,p)},o.prototype.listenerCount=f;function f(g){var p=this._events;if(p!==void 0){var v=p[g];if(typeof v=="function")return 1;if(v!==void 0)return v.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function y(g,p){for(var v=new Array(p),E=0;E<p;++E)v[E]=g[E];return v}function m(g,p){for(;p+1<g.length;p++)g[p]=g[p+1];g.pop()}function b(g){for(var p=new Array(g.length),v=0;v<p.length;++v)p[v]=g[v].listener||g[v];return p}function R(g,p){return new Promise(function(v,E){function k(S){g.removeListener(p,N),E(S)}function N(){typeof g.removeListener=="function"&&g.removeListener("error",k),v([].slice.call(arguments))}_(g,p,N,{once:!0}),p!=="error"&&x(g,k,{once:!0})})}function x(g,p,v){typeof g.on=="function"&&_(g,"error",p,v)}function _(g,p,v,E){if(typeof g.on=="function")E.once?g.once(p,v):g.on(p,v);else if(typeof g.addEventListener=="function")g.addEventListener(p,function k(N){E.once&&g.removeEventListener(p,k),v(N)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof g)}return De.exports}var ii=Yi();function Zi(){const r=arguments[0];for(let i=1,t=arguments.length;i<t;i++)if(arguments[i])for(const e in arguments[i])r[e]=arguments[i][e];return r}let B=Zi;typeof Object.assign=="function"&&(B=Object.assign);function X(r,i,t,e){const n=r._nodes.get(i);let o=null;return n&&(e==="mixed"?o=n.out&&n.out[t]||n.undirected&&n.undirected[t]:e==="directed"?o=n.out&&n.out[t]:o=n.undirected&&n.undirected[t]),o}function V(r){return typeof r=="object"&&r!==null}function ni(r){let i;for(i in r)return!1;return!0}function Z(r,i,t){Object.defineProperty(r,i,{enumerable:!1,configurable:!1,writable:!0,value:t})}function J(r,i,t){const e={enumerable:!0,configurable:!0};typeof t=="function"?e.get=t:(e.value=t,e.writable=!1),Object.defineProperty(r,i,e)}function St(r){return!(!V(r)||r.attributes&&!Array.isArray(r.attributes))}function Xi(){let r=Math.floor(Math.random()*256)&255;return()=>r++}function ae(){const r=arguments;let i=null,t=-1;return{[Symbol.iterator](){return this},next(){let e=null;do{if(i===null){if(t++,t>=r.length)return{done:!0};i=r[t][Symbol.iterator]()}if(e=i.next(),e.done){i=null;continue}break}while(!0);return e}}}function be(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class gt extends Error{constructor(i){super(),this.name="GraphError",this.message=i}}class C extends gt{constructor(i){super(i),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,C.prototype.constructor)}}class T extends gt{constructor(i){super(i),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,T.prototype.constructor)}}class D extends gt{constructor(i){super(i),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}function ri(r,i){this.key=r,this.attributes=i,this.clear()}ri.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function oi(r,i){this.key=r,this.attributes=i,this.clear()}oi.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function ai(r,i){this.key=r,this.attributes=i,this.clear()}ai.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function we(r,i,t,e,n){this.key=i,this.attributes=n,this.undirected=r,this.source=t,this.target=e}we.prototype.attach=function(){let r="out",i="in";this.undirected&&(r=i="undirected");const t=this.source.key,e=this.target.key;this.source[r][e]=this,!(this.undirected&&t===e)&&(this.target[i][t]=this)};we.prototype.attachMulti=function(){let r="out",i="in";const t=this.source.key,e=this.target.key;this.undirected&&(r=i="undirected");const n=this.source[r],o=n[e];if(typeof o>"u"){n[e]=this,this.undirected&&t===e||(this.target[i][t]=this);return}o.previous=this,this.next=o,n[e]=this,this.target[i][t]=this};we.prototype.detach=function(){const r=this.source.key,i=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),delete this.source[t][i],delete this.target[e][r]};we.prototype.detachMulti=function(){const r=this.source.key,i=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][i],delete this.target[e][r]):(this.next.previous=void 0,this.source[t][i]=this.next,this.target[e][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const si=0,ui=1,Ji=2,hi=3;function se(r,i,t,e,n,o,a){let s,u,h,c;if(e=""+e,t===si){if(s=r._nodes.get(e),!s)throw new T(`Graph.${i}: could not find the "${e}" node in the graph.`);h=n,c=o}else if(t===hi){if(n=""+n,u=r._edges.get(n),!u)throw new T(`Graph.${i}: could not find the "${n}" edge in the graph.`);const d=u.source.key,l=u.target.key;if(e===d)s=u.target;else if(e===l)s=u.source;else throw new T(`Graph.${i}: the "${e}" node is not attached to the "${n}" edge (${d}, ${l}).`);h=o,c=a}else{if(u=r._edges.get(e),!u)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`);t===ui?s=u.source:s=u.target,h=n,c=o}return[s,h,c]}function Qi(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);return a.attributes[s]}}function en(r,i,t){r.prototype[i]=function(e,n){const[o]=se(this,i,t,e,n);return o.attributes}}function tn(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);return a.attributes.hasOwnProperty(s)}}function nn(r,i,t){r.prototype[i]=function(e,n,o,a){const[s,u,h]=se(this,i,t,e,n,o,a);return s.attributes[u]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function rn(r,i,t){r.prototype[i]=function(e,n,o,a){const[s,u,h]=se(this,i,t,e,n,o,a);if(typeof h!="function")throw new C(`Graph.${i}: updater should be a function.`);const c=s.attributes,d=h(c[u]);return c[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function on(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function an(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);if(!V(s))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function sn(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);if(!V(s))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return B(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function un(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);if(typeof s!="function")throw new C(`Graph.${i}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const hn=[{name:r=>`get${r}Attribute`,attacher:Qi},{name:r=>`get${r}Attributes`,attacher:en},{name:r=>`has${r}Attribute`,attacher:tn},{name:r=>`set${r}Attribute`,attacher:nn},{name:r=>`update${r}Attribute`,attacher:rn},{name:r=>`remove${r}Attribute`,attacher:on},{name:r=>`replace${r}Attributes`,attacher:an},{name:r=>`merge${r}Attributes`,attacher:sn},{name:r=>`update${r}Attributes`,attacher:un}];function dn(r){hn.forEach(function({name:i,attacher:t}){t(r,i("Node"),si),t(r,i("Source"),ui),t(r,i("Target"),Ji),t(r,i("Opposite"),hi)})}function cn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return o.attributes[n]}}function ln(r,i,t){r.prototype[i]=function(e){let n;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,a=""+arguments[1];if(n=X(this,o,a,t),!n)throw new T(`Graph.${i}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,n=this._edges.get(e),!n)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return n.attributes}}function fn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return o.attributes.hasOwnProperty(n)}}function gn(r,i,t){r.prototype[i]=function(e,n,o){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+n;if(n=arguments[2],o=arguments[3],a=X(this,s,u,t),!a)throw new T(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return a.attributes[n]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:n}),this}}function pn(r,i,t){r.prototype[i]=function(e,n,o){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+n;if(n=arguments[2],o=arguments[3],a=X(this,s,u,t),!a)throw new T(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(typeof o!="function")throw new C(`Graph.${i}: updater should be a function.`);return a.attributes[n]=o(a.attributes[n]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:n}),this}}function mn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return delete o.attributes[n],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:n}),this}}function vn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(!V(n))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return o.attributes=n,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function yn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(!V(n))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return B(o.attributes,n),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:n}),this}}function bn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(typeof n!="function")throw new C(`Graph.${i}: provided updater is not a function.`);return o.attributes=n(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const wn=[{name:r=>`get${r}Attribute`,attacher:cn},{name:r=>`get${r}Attributes`,attacher:ln},{name:r=>`has${r}Attribute`,attacher:fn},{name:r=>`set${r}Attribute`,attacher:gn},{name:r=>`update${r}Attribute`,attacher:pn},{name:r=>`remove${r}Attribute`,attacher:mn},{name:r=>`replace${r}Attributes`,attacher:vn},{name:r=>`merge${r}Attributes`,attacher:yn},{name:r=>`update${r}Attributes`,attacher:bn}];function En(r){wn.forEach(function({name:i,attacher:t}){t(r,i("Edge"),"mixed"),t(r,i("DirectedEdge"),"directed"),t(r,i("UndirectedEdge"),"undirected")})}const _n=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function xn(r,i,t,e){let n=!1;for(const o in i){if(o===e)continue;const a=i[o];if(n=t(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),r&&n)return a.key}}function Tn(r,i,t,e){let n,o,a,s=!1;for(const u in i)if(u!==e){n=i[u];do{if(o=n.source,a=n.target,s=t(n.key,n.attributes,o.key,a.key,o.attributes,a.attributes,n.undirected),r&&s)return n.key;n=n.next}while(n!==void 0)}}function He(r,i){const t=Object.keys(r),e=t.length;let n,o=0;return{[Symbol.iterator](){return this},next(){do if(n)n=n.next;else{if(o>=e)return{done:!0};const a=t[o++];if(a===i){n=void 0;continue}n=r[a]}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}}}}function Rn(r,i,t,e){const n=i[t];if(!n)return;const o=n.source,a=n.target;if(e(n.key,n.attributes,o.key,a.key,o.attributes,a.attributes,n.undirected)&&r)return n.key}function Sn(r,i,t,e){let n=i[t];if(!n)return;let o=!1;do{if(o=e(n.key,n.attributes,n.source.key,n.target.key,n.source.attributes,n.target.attributes,n.undirected),r&&o)return n.key;n=n.next}while(n!==void 0)}function We(r,i){let t=r[i];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const n={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:n}}};let e=!1;return{[Symbol.iterator](){return this},next(){return e===!0?{done:!0}:(e=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function Cn(r,i){if(r.size===0)return[];if(i==="mixed"||i===r.type)return Array.from(r._edges.keys());const t=i==="undirected"?r.undirectedSize:r.directedSize,e=new Array(t),n=i==="undirected",o=r._edges.values();let a=0,s,u;for(;s=o.next(),s.done!==!0;)u=s.value,u.undirected===n&&(e[a++]=u.key);return e}function di(r,i,t,e){if(i.size===0)return;const n=t!=="mixed"&&t!==i.type,o=t==="undirected";let a,s,u=!1;const h=i._edges.values();for(;a=h.next(),a.done!==!0;){if(s=a.value,n&&s.undirected!==o)continue;const{key:c,attributes:d,source:l,target:f}=s;if(u=e(c,d,l.key,f.key,l.attributes,f.attributes,s.undirected),r&&u)return c}}function kn(r,i){if(r.size===0)return be();const t=i!=="mixed"&&i!==r.type,e=i==="undirected",n=r._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=n.next(),o.done)return o;if(a=o.value,!(t&&a.undirected!==e))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function pt(r,i,t,e,n,o){const a=i?Tn:xn;let s;if(t!=="undirected"&&(e!=="out"&&(s=a(r,n.in,o),r&&s)||e!=="in"&&(s=a(r,n.out,o,e?void 0:n.key),r&&s))||t!=="directed"&&(s=a(r,n.undirected,o),r&&s))return s}function An(r,i,t,e){const n=[];return pt(!1,r,i,t,e,function(o){n.push(o)}),n}function Ln(r,i,t){let e=be();return r!=="undirected"&&(i!=="out"&&typeof t.in<"u"&&(e=ae(e,He(t.in))),i!=="in"&&typeof t.out<"u"&&(e=ae(e,He(t.out,i?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(e=ae(e,He(t.undirected))),e}function mt(r,i,t,e,n,o,a){const s=t?Sn:Rn;let u;if(i!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&(u=s(r,n.in,o,a),r&&u)||typeof n.out<"u"&&e!=="in"&&(e||n.key!==o)&&(u=s(r,n.out,o,a),r&&u))||i!=="directed"&&typeof n.undirected<"u"&&(u=s(r,n.undirected,o,a),r&&u))return u}function Nn(r,i,t,e,n){const o=[];return mt(!1,r,i,t,e,n,function(a){o.push(a)}),o}function Dn(r,i,t,e){let n=be();return r!=="undirected"&&(typeof t.in<"u"&&i!=="out"&&e in t.in&&(n=ae(n,We(t.in,e))),typeof t.out<"u"&&i!=="in"&&e in t.out&&(i||t.key!==e)&&(n=ae(n,We(t.out,e)))),r!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(n=ae(n,We(t.undirected,e))),n}function Gn(r,i){const{name:t,type:e,direction:n}=i;r.prototype[t]=function(o,a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];if(!arguments.length)return Cn(this,e);if(arguments.length===1){o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new T(`Graph.${t}: could not find the "${o}" node in the graph.`);return An(this.multi,e==="mixed"?this.type:e,n,s)}if(arguments.length===2){o=""+o,a=""+a;const s=this._nodes.get(o);if(!s)throw new T(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new T(`Graph.${t}: could not find the "${a}" target node in the graph.`);return Nn(e,this.multi,n,s,a)}throw new C(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Fn(r,i){const{name:t,type:e,direction:n}=i,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(h,c,d){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return d=h,di(!1,this,e,d);if(arguments.length===2){h=""+h,d=c;const l=this._nodes.get(h);if(typeof l>"u")throw new T(`Graph.${o}: could not find the "${h}" node in the graph.`);return pt(!1,this.multi,e==="mixed"?this.type:e,n,l,d)}if(arguments.length===3){h=""+h,c=""+c;const l=this._nodes.get(h);if(!l)throw new T(`Graph.${o}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(c))throw new T(`Graph.${o}: could not find the "${c}" target node in the graph.`);return mt(!1,e,this.multi,n,l,c,d)}throw new C(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const a="map"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(){const h=Array.prototype.slice.call(arguments),c=h.pop();let d;if(h.length===0){let l=0;e!=="directed"&&(l+=this.undirectedSize),e!=="undirected"&&(l+=this.directedSize),d=new Array(l);let f=0;h.push((y,m,b,R,x,_,g)=>{d[f++]=c(y,m,b,R,x,_,g)})}else d=[],h.push((l,f,y,m,b,R,x)=>{d.push(c(l,f,y,m,b,R,x))});return this[o].apply(this,h),d};const s="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),c=h.pop(),d=[];return h.push((l,f,y,m,b,R,x)=>{c(l,f,y,m,b,R,x)&&d.push(l)}),this[o].apply(this,h),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[u]=function(){let h=Array.prototype.slice.call(arguments);if(h.length<2||h.length>4)throw new C(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${h.length}).`);if(typeof h[h.length-1]=="function"&&typeof h[h.length-2]!="function")throw new C(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c,d;h.length===2?(c=h[0],d=h[1],h=[]):h.length===3?(c=h[1],d=h[2],h=[h[0]]):h.length===4&&(c=h[2],d=h[3],h=[h[0],h[1]]);let l=d;return h.push((f,y,m,b,R,x,_)=>{l=c(l,f,y,m,b,R,x,_)}),this[o].apply(this,h),l}}function Pn(r,i){const{name:t,type:e,direction:n}=i,o="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(u,h,c){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return c=u,di(!0,this,e,c);if(arguments.length===2){u=""+u,c=h;const d=this._nodes.get(u);if(typeof d>"u")throw new T(`Graph.${o}: could not find the "${u}" node in the graph.`);return pt(!0,this.multi,e==="mixed"?this.type:e,n,d,c)}if(arguments.length===3){u=""+u,h=""+h;const d=this._nodes.get(u);if(!d)throw new T(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(h))throw new T(`Graph.${o}: could not find the "${h}" target node in the graph.`);return mt(!0,e,this.multi,n,d,h,c)}throw new C(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const a="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((d,l,f,y,m,b,R)=>h(d,l,f,y,m,b,R)),!!this[o].apply(this,u)};const s="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((d,l,f,y,m,b,R)=>!h(d,l,f,y,m,b,R)),!this[o].apply(this,u)}}function Mn(r,i){const{name:t,type:e,direction:n}=i,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(a,s){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return be();if(!arguments.length)return kn(this,e);if(arguments.length===1){a=""+a;const u=this._nodes.get(a);if(!u)throw new T(`Graph.${o}: could not find the "${a}" node in the graph.`);return Ln(e,n,u)}if(arguments.length===2){a=""+a,s=""+s;const u=this._nodes.get(a);if(!u)throw new T(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new T(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Dn(e,n,u,s)}throw new C(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function In(r){_n.forEach(i=>{Gn(r,i),Fn(r,i),Pn(r,i),Mn(r,i)})}const zn=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Ue(){this.A=null,this.B=null}Ue.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};Ue.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function _e(r,i,t,e,n){for(const o in e){const a=e[o],s=a.source,u=a.target,h=s===t?u:s;if(i&&i.has(h.key))continue;const c=n(h.key,h.attributes);if(r&&c)return h.key}}function vt(r,i,t,e,n){if(i!=="mixed"){if(i==="undirected")return _e(r,null,e,e.undirected,n);if(typeof t=="string")return _e(r,null,e,e[t],n)}const o=new Ue;let a;if(i!=="undirected"){if(t!=="out"){if(a=_e(r,null,e,e.in,n),r&&a)return a;o.wrap(e.in)}if(t!=="in"){if(a=_e(r,o,e,e.out,n),r&&a)return a;o.wrap(e.out)}}if(i!=="directed"&&(a=_e(r,o,e,e.undirected,n),r&&a))return a}function $n(r,i,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof i=="string")return Object.keys(t[i])}const e=[];return vt(!1,r,i,t,function(n){e.push(n)}),e}function xe(r,i,t){const e=Object.keys(t),n=e.length;let o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=n)return r&&r.wrap(t),{done:!0};const s=t[e[o++]],u=s.source,h=s.target;if(a=u===i?h:u,r&&r.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function Un(r,i,t){if(r!=="mixed"){if(r==="undirected")return xe(null,t,t.undirected);if(typeof i=="string")return xe(null,t,t[i])}let e=be();const n=new Ue;return r!=="undirected"&&(i!=="out"&&(e=ae(e,xe(n,t,t.in))),i!=="in"&&(e=ae(e,xe(n,t,t.out)))),r!=="directed"&&(e=ae(e,xe(n,t,t.undirected))),e}function On(r,i){const{name:t,type:e,direction:n}=i;r.prototype[t]=function(o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new T(`Graph.${t}: could not find the "${o}" node in the graph.`);return $n(e==="mixed"?this.type:e,n,a)}}function Bn(r,i){const{name:t,type:e,direction:n}=i,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(h,c){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const d=this._nodes.get(h);if(typeof d>"u")throw new T(`Graph.${o}: could not find the "${h}" node in the graph.`);vt(!1,e==="mixed"?this.type:e,n,d,c)};const a="map"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(h,c){const d=[];return this[o](h,(l,f)=>{d.push(c(l,f))}),d};const s="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(h,c){const d=[];return this[o](h,(l,f)=>{c(l,f)&&d.push(l)}),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[u]=function(h,c,d){if(arguments.length<3)throw new C(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let l=d;return this[o](h,(f,y)=>{l=c(l,f,y)}),l}}function Hn(r,i){const{name:t,type:e,direction:n}=i,o=t[0].toUpperCase()+t.slice(1,-1),a="find"+o;r.prototype[a]=function(h,c){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const d=this._nodes.get(h);if(typeof d>"u")throw new T(`Graph.${a}: could not find the "${h}" node in the graph.`);return vt(!0,e==="mixed"?this.type:e,n,d,c)};const s="some"+o;r.prototype[s]=function(h,c){return!!this[a](h,c)};const u="every"+o;r.prototype[u]=function(h,c){return!this[a](h,(l,f)=>!c(l,f))}}function Wn(r,i){const{name:t,type:e,direction:n}=i,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return be();a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new T(`Graph.${o}: could not find the "${a}" node in the graph.`);return Un(e==="mixed"?this.type:e,n,s)}}function jn(r){zn.forEach(i=>{On(r,i),Bn(r,i),Hn(r,i),Wn(r,i)})}function Ge(r,i,t,e,n){const o=e._nodes.values(),a=e.type;let s,u,h,c,d,l;for(;s=o.next(),s.done!==!0;){let f=!1;if(u=s.value,a!=="undirected"){c=u.out;for(h in c){d=c[h];do l=d.target,f=!0,n(u.key,l.key,u.attributes,l.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(a!=="directed"){c=u.undirected;for(h in c)if(!(i&&u.key>h)){d=c[h];do l=d.target,l.key!==h&&(l=d.source),f=!0,n(u.key,l.key,u.attributes,l.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}t&&!f&&n(u.key,null,u.attributes,null,null,null,null)}}function Vn(r,i){const t={key:r};return ni(i.attributes)||(t.attributes=B({},i.attributes)),t}function qn(r,i,t){const e={key:i,source:t.source.key,target:t.target.key};return ni(t.attributes)||(e.attributes=B({},t.attributes)),r==="mixed"&&t.undirected&&(e.undirected=!0),e}function Kn(r){if(!V(r))throw new C('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new C("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!V(r.attributes)||r.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Yn(r){if(!V(r))throw new C('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new C("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new C("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!V(r.attributes)||r.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new C("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Zn=Xi(),Xn=new Set(["directed","undirected","mixed"]),Ct=new Set(["domain","_events","_eventsCount","_maxListeners"]),Jn=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],Qn={allowSelfLoops:!0,multi:!1,type:"mixed"};function er(r,i,t){if(t&&!V(t))throw new C(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(i=""+i,t=t||{},r._nodes.has(i))throw new D(`Graph.addNode: the "${i}" node already exist in the graph.`);const e=new r.NodeDataClass(i,t);return r._nodes.set(i,e),r.emit("nodeAdded",{key:i,attributes:t}),e}function kt(r,i,t){const e=new r.NodeDataClass(i,t);return r._nodes.set(i,e),r.emit("nodeAdded",{key:i,attributes:t}),e}function ci(r,i,t,e,n,o,a,s){if(!e&&r.type==="undirected")throw new D(`Graph.${i}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(e&&r.type==="directed")throw new D(`Graph.${i}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!V(s))throw new C(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!r.allowSelfLoops&&o===a)throw new D(`Graph.${i}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=r._nodes.get(o),h=r._nodes.get(a);if(!u)throw new T(`Graph.${i}: source node "${o}" not found.`);if(!h)throw new T(`Graph.${i}: target node "${a}" not found.`);const c={key:null,undirected:e,source:o,target:a,attributes:s};if(t)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new D(`Graph.${i}: the "${n}" edge already exists in the graph.`);if(!r.multi&&(e?typeof u.undirected[a]<"u":typeof u.out[a]<"u"))throw new D(`Graph.${i}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new we(e,n,u,h,s);r._edges.set(n,d);const l=o===a;return e?(u.undirectedDegree++,h.undirectedDegree++,l&&(u.undirectedLoops++,r._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,l&&(u.directedLoops++,r._directedSelfLoopCount++)),r.multi?d.attachMulti():d.attach(),e?r._undirectedSize++:r._directedSize++,c.key=n,r.emit("edgeAdded",c),n}function tr(r,i,t,e,n,o,a,s,u){if(!e&&r.type==="undirected")throw new D(`Graph.${i}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(e&&r.type==="directed")throw new D(`Graph.${i}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(u){if(typeof s!="function")throw new C(`Graph.${i}: invalid updater function. Expecting a function but got "${s}"`)}else if(!V(s))throw new C(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let h;if(u&&(h=s,s=void 0),!r.allowSelfLoops&&o===a)throw new D(`Graph.${i}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=r._nodes.get(o),d=r._nodes.get(a),l,f;if(!t&&(l=r._edges.get(n),l)){if((l.source.key!==o||l.target.key!==a)&&(!e||l.source.key!==a||l.target.key!==o))throw new D(`Graph.${i}: inconsistency detected when attempting to merge the "${n}" edge with "${o}" source & "${a}" target vs. ("${l.source.key}", "${l.target.key}").`);f=l}if(!f&&!r.multi&&c&&(f=e?c.undirected[a]:c.out[a]),f){const x=[f.key,!1,!1,!1];if(u?!h:!s)return x;if(u){const _=f.attributes;f.attributes=h(_),r.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else B(f.attributes,s),r.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return x}s=s||{},u&&h&&(s=h(s));const y={key:null,undirected:e,source:o,target:a,attributes:s};if(t)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new D(`Graph.${i}: the "${n}" edge already exists in the graph.`);let m=!1,b=!1;c||(c=kt(r,o,{}),m=!0,o===a&&(d=c,b=!0)),d||(d=kt(r,a,{}),b=!0),l=new we(e,n,c,d,s),r._edges.set(n,l);const R=o===a;return e?(c.undirectedDegree++,d.undirectedDegree++,R&&(c.undirectedLoops++,r._undirectedSelfLoopCount++)):(c.outDegree++,d.inDegree++,R&&(c.directedLoops++,r._directedSelfLoopCount++)),r.multi?l.attachMulti():l.attach(),e?r._undirectedSize++:r._directedSize++,y.key=n,r.emit("edgeAdded",y),[n,!0,m,b]}function ge(r,i){r._edges.delete(i.key);const{source:t,target:e,attributes:n}=i,o=i.undirected,a=t===e;o?(t.undirectedDegree--,e.undirectedDegree--,a&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,e.inDegree--,a&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?i.detachMulti():i.detach(),o?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:i.key,attributes:n,source:t.key,target:e.key,undirected:o})}class U extends ii.EventEmitter{constructor(i){if(super(),i=B({},Qn,i),typeof i.multi!="boolean")throw new C(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${i.multi}".`);if(!Xn.has(i.type))throw new C(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${i.type}".`);if(typeof i.allowSelfLoops!="boolean")throw new C(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${i.allowSelfLoops}".`);const t=i.type==="mixed"?ri:i.type==="directed"?oi:ai;Z(this,"NodeDataClass",t);const e="geid_"+Zn()+"_";let n=0;const o=()=>{let a;do a=e+n++;while(this._edges.has(a));return a};Z(this,"_attributes",{}),Z(this,"_nodes",new Map),Z(this,"_edges",new Map),Z(this,"_directedSize",0),Z(this,"_undirectedSize",0),Z(this,"_directedSelfLoopCount",0),Z(this,"_undirectedSelfLoopCount",0),Z(this,"_edgeKeyGenerator",o),Z(this,"_options",i),Ct.forEach(a=>Z(this,a,this[a])),J(this,"order",()=>this._nodes.size),J(this,"size",()=>this._edges.size),J(this,"directedSize",()=>this._directedSize),J(this,"undirectedSize",()=>this._undirectedSize),J(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),J(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),J(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),J(this,"multi",this._options.multi),J(this,"type",this._options.type),J(this,"allowSelfLoops",this._options.allowSelfLoops),J(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(i){return this._nodes.has(""+i)}hasDirectedEdge(i,t){if(this.type==="undirected")return!1;if(arguments.length===1){const e=""+i,n=this._edges.get(e);return!!n&&!n.undirected}else if(arguments.length===2){i=""+i,t=""+t;const e=this._nodes.get(i);return e?e.out.hasOwnProperty(t):!1}throw new C(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(i,t){if(this.type==="directed")return!1;if(arguments.length===1){const e=""+i,n=this._edges.get(e);return!!n&&n.undirected}else if(arguments.length===2){i=""+i,t=""+t;const e=this._nodes.get(i);return e?e.undirected.hasOwnProperty(t):!1}throw new C(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(i,t){if(arguments.length===1){const e=""+i;return this._edges.has(e)}else if(arguments.length===2){i=""+i,t=""+t;const e=this._nodes.get(i);return e?typeof e.out<"u"&&e.out.hasOwnProperty(t)||typeof e.undirected<"u"&&e.undirected.hasOwnProperty(t):!1}throw new C(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(i,t){if(this.type==="undirected")return;if(i=""+i,t=""+t,this.multi)throw new D("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const e=this._nodes.get(i);if(!e)throw new T(`Graph.directedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(t))throw new T(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const n=e.out&&e.out[t]||void 0;if(n)return n.key}undirectedEdge(i,t){if(this.type==="directed")return;if(i=""+i,t=""+t,this.multi)throw new D("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const e=this._nodes.get(i);if(!e)throw new T(`Graph.undirectedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(t))throw new T(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const n=e.undirected&&e.undirected[t]||void 0;if(n)return n.key}edge(i,t){if(this.multi)throw new D("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.edge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(t))throw new T(`Graph.edge: could not find the "${t}" target node in the graph.`);const n=e.out&&e.out[t]||e.undirected&&e.undirected[t]||void 0;if(n)return n.key}areDirectedNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areDirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:t in e.in||t in e.out}areOutNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areOutNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:t in e.out}areInNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areInNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:t in e.in}areUndirectedNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areUndirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="directed"?!1:t in e.undirected}areNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&(t in e.in||t in e.out)||this.type!=="directed"&&t in e.undirected}areInboundNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areInboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&t in e.in||this.type!=="directed"&&t in e.undirected}areOutboundNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areOutboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&t in e.out||this.type!=="directed"&&t in e.undirected}inDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.directedDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.undirectedDegree: could not find the "${i}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inboundDegree: could not find the "${i}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree),e}outboundDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outboundDegree: could not find the "${i}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.outDegree),e}degree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.degree: could not find the "${i}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree),e}inDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.directedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let e=0,n=0;return this.type!=="directed"&&(e+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree,n+=t.directedLoops),e-n}outboundDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let e=0,n=0;return this.type!=="directed"&&(e+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.outDegree,n+=t.directedLoops),e-n}degreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.degreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let e=0,n=0;return this.type!=="directed"&&(e+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree,n+=t.directedLoops*2),e-n}source(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.source: could not find the "${i}" edge in the graph.`);return t.source.key}target(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.target: could not find the "${i}" edge in the graph.`);return t.target.key}extremities(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.extremities: could not find the "${i}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(i,t){i=""+i,t=""+t;const e=this._edges.get(t);if(!e)throw new T(`Graph.opposite: could not find the "${t}" edge in the graph.`);const n=e.source.key,o=e.target.key;if(i===n)return o;if(i===o)return n;throw new T(`Graph.opposite: the "${i}" node is not attached to the "${t}" edge (${n}, ${o}).`)}hasExtremity(i,t){i=""+i,t=""+t;const e=this._edges.get(i);if(!e)throw new T(`Graph.hasExtremity: could not find the "${i}" edge in the graph.`);return e.source.key===t||e.target.key===t}isUndirected(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.isUndirected: could not find the "${i}" edge in the graph.`);return t.undirected}isDirected(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.isDirected: could not find the "${i}" edge in the graph.`);return!t.undirected}isSelfLoop(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.isSelfLoop: could not find the "${i}" edge in the graph.`);return t.source===t.target}addNode(i,t){return er(this,i,t).key}mergeNode(i,t){if(t&&!V(t))throw new C(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);i=""+i,t=t||{};let e=this._nodes.get(i);return e?(t&&(B(e.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:i,attributes:e.attributes,data:t})),[i,!1]):(e=new this.NodeDataClass(i,t),this._nodes.set(i,e),this.emit("nodeAdded",{key:i,attributes:t}),[i,!0])}updateNode(i,t){if(t&&typeof t!="function")throw new C(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);i=""+i;let e=this._nodes.get(i);if(e){if(t){const o=e.attributes;e.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:i,attributes:e.attributes})}return[i,!1]}const n=t?t({}):{};return e=new this.NodeDataClass(i,n),this._nodes.set(i,e),this.emit("nodeAdded",{key:i,attributes:n}),[i,!0]}dropNode(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.dropNode: could not find the "${i}" node in the graph.`);let e;if(this.type!=="undirected"){for(const n in t.out){e=t.out[n];do ge(this,e),e=e.next;while(e)}for(const n in t.in){e=t.in[n];do ge(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const n in t.undirected){e=t.undirected[n];do ge(this,e),e=e.next;while(e)}this._nodes.delete(i),this.emit("nodeDropped",{key:i,attributes:t.attributes})}dropEdge(i){let t;if(arguments.length>1){const e=""+arguments[0],n=""+arguments[1];if(t=X(this,e,n,this.type),!t)throw new T(`Graph.dropEdge: could not find the "${e}" -> "${n}" edge in the graph.`)}else if(i=""+i,t=this._edges.get(i),!t)throw new T(`Graph.dropEdge: could not find the "${i}" edge in the graph.`);return ge(this,t),this}dropDirectedEdge(i,t){if(arguments.length<2)throw new D("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new D("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");i=""+i,t=""+t;const e=X(this,i,t,"directed");if(!e)throw new T(`Graph.dropDirectedEdge: could not find a "${i}" -> "${t}" edge in the graph.`);return ge(this,e),this}dropUndirectedEdge(i,t){if(arguments.length<2)throw new D("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new D("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const e=X(this,i,t,"undirected");if(!e)throw new T(`Graph.dropUndirectedEdge: could not find a "${i}" -> "${t}" edge in the graph.`);return ge(this,e),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const i=this._nodes.values();let t;for(;t=i.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(i){return this._attributes[i]}getAttributes(){return this._attributes}hasAttribute(i){return this._attributes.hasOwnProperty(i)}setAttribute(i,t){return this._attributes[i]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}updateAttribute(i,t){if(typeof t!="function")throw new C("Graph.updateAttribute: updater should be a function.");const e=this._attributes[i];return this._attributes[i]=t(e),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}removeAttribute(i){return delete this._attributes[i],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:i}),this}replaceAttributes(i){if(!V(i))throw new C("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=i,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(i){if(!V(i))throw new C("Graph.mergeAttributes: provided attributes are not a plain object.");return B(this._attributes,i),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:i}),this}updateAttributes(i){if(typeof i!="function")throw new C("Graph.updateAttributes: provided updater is not a function.");return this._attributes=i(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(i,t){if(typeof i!="function")throw new C("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!St(t))throw new C("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._nodes.values();let n,o;for(;n=e.next(),n.done!==!0;)o=n.value,o.attributes=i(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(i,t){if(typeof i!="function")throw new C("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!St(t))throw new C("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._edges.values();let n,o,a,s;for(;n=e.next(),n.done!==!0;)o=n.value,a=o.source,s=o.target,o.attributes=i(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(i){if(typeof i!="function")throw new C("Graph.forEachAdjacencyEntry: expecting a callback.");Ge(!1,!1,!1,this,i)}forEachAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new C("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Ge(!1,!1,!0,this,i)}forEachAssymetricAdjacencyEntry(i){if(typeof i!="function")throw new C("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Ge(!1,!0,!1,this,i)}forEachAssymetricAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new C("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Ge(!1,!0,!0,this,i)}nodes(){return Array.from(this._nodes.keys())}forEachNode(i){if(typeof i!="function")throw new C("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)n=e.value,i(n.key,n.attributes)}findNode(i){if(typeof i!="function")throw new C("Graph.findNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)if(n=e.value,i(n.key,n.attributes))return n.key}mapNodes(i){if(typeof i!="function")throw new C("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let e,n;const o=new Array(this.order);let a=0;for(;e=t.next(),e.done!==!0;)n=e.value,o[a++]=i(n.key,n.attributes);return o}someNode(i){if(typeof i!="function")throw new C("Graph.someNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)if(n=e.value,i(n.key,n.attributes))return!0;return!1}everyNode(i){if(typeof i!="function")throw new C("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)if(n=e.value,!i(n.key,n.attributes))return!1;return!0}filterNodes(i){if(typeof i!="function")throw new C("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let e,n;const o=[];for(;e=t.next(),e.done!==!0;)n=e.value,i(n.key,n.attributes)&&o.push(n.key);return o}reduceNodes(i,t){if(typeof i!="function")throw new C("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new C("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let e=t;const n=this._nodes.values();let o,a;for(;o=n.next(),o.done!==!0;)a=o.value,e=i(e,a.key,a.attributes);return e}nodeEntries(){const i=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=i.next();if(t.done)return t;const e=t.value;return{value:{node:e.key,attributes:e.attributes},done:!1}}}}export(){const i=new Array(this._nodes.size);let t=0;this._nodes.forEach((n,o)=>{i[t++]=Vn(o,n)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((n,o)=>{e[t++]=qn(this.type,o,n)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:i,edges:e}}import(i,t=!1){if(i instanceof U)return i.forEachNode((u,h)=>{t?this.mergeNode(u,h):this.addNode(u,h)}),i.forEachEdge((u,h,c,d,l,f,y)=>{t?y?this.mergeUndirectedEdgeWithKey(u,c,d,h):this.mergeDirectedEdgeWithKey(u,c,d,h):y?this.addUndirectedEdgeWithKey(u,c,d,h):this.addDirectedEdgeWithKey(u,c,d,h)}),this;if(!V(i))throw new C("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(i.attributes){if(!V(i.attributes))throw new C("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(i.attributes):this.replaceAttributes(i.attributes)}let e,n,o,a,s;if(i.nodes){if(o=i.nodes,!Array.isArray(o))throw new C("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=o.length;e<n;e++){a=o[e],Kn(a);const{key:u,attributes:h}=a;t?this.mergeNode(u,h):this.addNode(u,h)}}if(i.edges){let u=!1;if(this.type==="undirected"&&(u=!0),o=i.edges,!Array.isArray(o))throw new C("Graph.import: invalid edges. Expecting an array.");for(e=0,n=o.length;e<n;e++){s=o[e],Yn(s);const{source:h,target:c,attributes:d,undirected:l=u}=s;let f;"key"in s?(f=t?l?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:l?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,h,c,d)):(f=t?l?this.mergeUndirectedEdge:this.mergeDirectedEdge:l?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,h,c,d))}}return this}nullCopy(i){const t=new U(B({},this._options,i));return t.replaceAttributes(B({},this.getAttributes())),t}emptyCopy(i){const t=this.nullCopy(i);return this._nodes.forEach((e,n)=>{const o=B({},e.attributes);e=new t.NodeDataClass(n,o),t._nodes.set(n,e)}),t}copy(i){if(i=i||{},typeof i.type=="string"&&i.type!==this.type&&i.type!=="mixed")throw new D(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${i.type}" because this would mean losing information about the current graph.`);if(typeof i.multi=="boolean"&&i.multi!==this.multi&&i.multi!==!0)throw new D("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof i.allowSelfLoops=="boolean"&&i.allowSelfLoops!==this.allowSelfLoops&&i.allowSelfLoops!==!0)throw new D("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(i),e=this._edges.values();let n,o;for(;n=e.next(),n.done!==!0;)o=n.value,ci(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,B({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const i={};this._nodes.forEach((o,a)=>{i[a]=o.attributes});const t={},e={};this._edges.forEach((o,a)=>{const s=o.undirected?"--":"->";let u="",h=o.source.key,c=o.target.key,d;o.undirected&&h>c&&(d=h,h=c,c=d);const l=`(${h})${s}(${c})`;a.startsWith("geid_")?this.multi&&(typeof e[l]>"u"?e[l]=0:e[l]++,u+=`${e[l]}. `):u+=`[${a}]: `,u+=l,t[u]=o.attributes});const n={};for(const o in this)this.hasOwnProperty(o)&&!Ct.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(n[o]=this[o]);return n.attributes=this._attributes,n.nodes=i,n.edges=t,Z(n,"constructor",this.constructor),n}}typeof Symbol<"u"&&(U.prototype[Symbol.for("nodejs.util.inspect.custom")]=U.prototype.inspect);Jn.forEach(r=>{["add","merge","update"].forEach(i=>{const t=r.name(i),e=i==="add"?ci:tr;r.generateKey?U.prototype[t]=function(n,o,a){return e(this,t,!0,(r.type||this.type)==="undirected",null,n,o,a,i==="update")}:U.prototype[t]=function(n,o,a,s){return e(this,t,!1,(r.type||this.type)==="undirected",n,o,a,s,i==="update")}})});dn(U);En(U);In(U);jn(U);class li extends U{constructor(i){const t=B({type:"directed"},i);if("multi"in t&&t.multi!==!1)throw new C("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new C('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class fi extends U{constructor(i){const t=B({type:"undirected"},i);if("multi"in t&&t.multi!==!1)throw new C("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new C('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class gi extends U{constructor(i){const t=B({multi:!0},i);if("multi"in t&&t.multi!==!0)throw new C("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class yt extends U{constructor(i){const t=B({type:"directed",multi:!0},i);if("multi"in t&&t.multi!==!0)throw new C("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new C('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class pi extends U{constructor(i){const t=B({type:"undirected",multi:!0},i);if("multi"in t&&t.multi!==!0)throw new C("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new C('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Ee(r){r.from=function(i,t){const e=B({},i.options,t),n=new r(e);return n.import(i),n}}Ee(U);Ee(li);Ee(fi);Ee(gi);Ee(yt);Ee(pi);U.Graph=U;U.DirectedGraph=li;U.UndirectedGraph=fi;U.MultiGraph=gi;U.MultiDirectedGraph=yt;U.MultiUndirectedGraph=pi;U.InvalidArgumentsGraphError=C;U.NotFoundGraphError=T;U.UsageGraphError=D;function ir(r,i){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var e=t.call(r,i);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(r)}function Ae(r){var i=ir(r,"string");return typeof i=="symbol"?i:i+""}function W(r,i){if(!(r instanceof i))throw new TypeError("Cannot call a class as a function")}function At(r,i){for(var t=0;t<i.length;t++){var e=i[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,Ae(e.key),e)}}function j(r,i,t){return i&&At(r.prototype,i),t&&At(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function ve(r){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ve(r)}function mi(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(mi=function(){return!!r})()}function nr(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function rr(r,i){if(i&&(typeof i=="object"||typeof i=="function"))return i;if(i!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return nr(r)}function q(r,i,t){return i=ve(i),rr(r,mi()?Reflect.construct(i,t||[],ve(r).constructor):i.apply(r,t))}function st(r,i){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},st(r,i)}function K(r,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(i&&i.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),i&&st(r,i)}function or(r){if(Array.isArray(r))return r}function ar(r,i){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var e,n,o,a,s=[],u=!0,h=!1;try{if(o=(t=t.call(r)).next,i===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(e=o.call(t)).done)&&(s.push(e.value),s.length!==i);u=!0);}catch(c){h=!0,n=c}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw n}}return s}}function ut(r,i){(i==null||i>r.length)&&(i=r.length);for(var t=0,e=Array(i);t<i;t++)e[t]=r[t];return e}function vi(r,i){if(r){if(typeof r=="string")return ut(r,i);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ut(r,i):void 0}}function sr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{r as z,f as ke,g as at,j as F,s as xt,a as Oi,M as Bi,n as Hi,S as Wi,b as ji,d as Vi,e as qi,c as Tt}from"./index-heNSjszK.js";import{g as Ki}from"./_commonjsHelpers-CqkleIqs.js";var De={exports:{}},Rt;function Yi(){if(Rt)return De.exports;Rt=1;var r=typeof Reflect=="object"?Reflect:null,i=r&&typeof r.apply=="function"?r.apply:function(p,v,E){return Function.prototype.apply.call(p,v,E)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(p){return Object.getOwnPropertyNames(p).concat(Object.getOwnPropertySymbols(p))}:t=function(p){return Object.getOwnPropertyNames(p)};function e(g){console&&console.warn&&console.warn(g)}var n=Number.isNaN||function(p){return p!==p};function o(){o.init.call(this)}De.exports=o,De.exports.once=R,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(g){if(typeof g!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof g)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(g){if(typeof g!="number"||g<0||n(g))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+g+".");a=g}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(p){if(typeof p!="number"||p<0||n(p))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+p+".");return this._maxListeners=p,this};function u(g){return g._maxListeners===void 0?o.defaultMaxListeners:g._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(p){for(var v=[],E=1;E<arguments.length;E++)v.push(arguments[E]);var k=p==="error",N=this._events;if(N!==void 0)k=k&&N.error===void 0;else if(!k)return!1;if(k){var S;if(v.length>0&&(S=v[0]),S instanceof Error)throw S;var M=new Error("Unhandled error."+(S?" ("+S.message+")":""));throw M.context=S,M}var I=N[p];if(I===void 0)return!1;if(typeof I=="function")i(I,this,v);else for(var L=I.length,P=y(I,L),E=0;E<L;++E)i(P[E],this,v);return!0};function h(g,p,v,E){var k,N,S;if(s(v),N=g._events,N===void 0?(N=g._events=Object.create(null),g._eventsCount=0):(N.newListener!==void 0&&(g.emit("newListener",p,v.listener?v.listener:v),N=g._events),S=N[p]),S===void 0)S=N[p]=v,++g._eventsCount;else if(typeof S=="function"?S=N[p]=E?[v,S]:[S,v]:E?S.unshift(v):S.push(v),k=u(g),k>0&&S.length>k&&!S.warned){S.warned=!0;var M=new Error("Possible EventEmitter memory leak detected. "+S.length+" "+String(p)+" listeners added. Use emitter.setMaxListeners() to increase limit");M.name="MaxListenersExceededWarning",M.emitter=g,M.type=p,M.count=S.length,e(M)}return g}o.prototype.addListener=function(p,v){return h(this,p,v,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(p,v){return h(this,p,v,!0)};function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(g,p,v){var E={fired:!1,wrapFn:void 0,target:g,type:p,listener:v},k=c.bind(E);return k.listener=v,E.wrapFn=k,k}o.prototype.once=function(p,v){return s(v),this.on(p,d(this,p,v)),this},o.prototype.prependOnceListener=function(p,v){return s(v),this.prependListener(p,d(this,p,v)),this},o.prototype.removeListener=function(p,v){var E,k,N,S,M;if(s(v),k=this._events,k===void 0)return this;if(E=k[p],E===void 0)return this;if(E===v||E.listener===v)--this._eventsCount===0?this._events=Object.create(null):(delete k[p],k.removeListener&&this.emit("removeListener",p,E.listener||v));else if(typeof E!="function"){for(N=-1,S=E.length-1;S>=0;S--)if(E[S]===v||E[S].listener===v){M=E[S].listener,N=S;break}if(N<0)return this;N===0?E.shift():m(E,N),E.length===1&&(k[p]=E[0]),k.removeListener!==void 0&&this.emit("removeListener",p,M||v)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(p){var v,E,k;if(E=this._events,E===void 0)return this;if(E.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):E[p]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete E[p]),this;if(arguments.length===0){var N=Object.keys(E),S;for(k=0;k<N.length;++k)S=N[k],S!=="removeListener"&&this.removeAllListeners(S);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(v=E[p],typeof v=="function")this.removeListener(p,v);else if(v!==void 0)for(k=v.length-1;k>=0;k--)this.removeListener(p,v[k]);return this};function l(g,p,v){var E=g._events;if(E===void 0)return[];var k=E[p];return k===void 0?[]:typeof k=="function"?v?[k.listener||k]:[k]:v?b(k):y(k,k.length)}o.prototype.listeners=function(p){return l(this,p,!0)},o.prototype.rawListeners=function(p){return l(this,p,!1)},o.listenerCount=function(g,p){return typeof g.listenerCount=="function"?g.listenerCount(p):f.call(g,p)},o.prototype.listenerCount=f;function f(g){var p=this._events;if(p!==void 0){var v=p[g];if(typeof v=="function")return 1;if(v!==void 0)return v.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function y(g,p){for(var v=new Array(p),E=0;E<p;++E)v[E]=g[E];return v}function m(g,p){for(;p+1<g.length;p++)g[p]=g[p+1];g.pop()}function b(g){for(var p=new Array(g.length),v=0;v<p.length;++v)p[v]=g[v].listener||g[v];return p}function R(g,p){return new Promise(function(v,E){function k(S){g.removeListener(p,N),E(S)}function N(){typeof g.removeListener=="function"&&g.removeListener("error",k),v([].slice.call(arguments))}_(g,p,N,{once:!0}),p!=="error"&&x(g,k,{once:!0})})}function x(g,p,v){typeof g.on=="function"&&_(g,"error",p,v)}function _(g,p,v,E){if(typeof g.on=="function")E.once?g.once(p,v):g.on(p,v);else if(typeof g.addEventListener=="function")g.addEventListener(p,function k(N){E.once&&g.removeEventListener(p,k),v(N)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof g)}return De.exports}var ii=Yi();function Zi(){const r=arguments[0];for(let i=1,t=arguments.length;i<t;i++)if(arguments[i])for(const e in arguments[i])r[e]=arguments[i][e];return r}let B=Zi;typeof Object.assign=="function"&&(B=Object.assign);function X(r,i,t,e){const n=r._nodes.get(i);let o=null;return n&&(e==="mixed"?o=n.out&&n.out[t]||n.undirected&&n.undirected[t]:e==="directed"?o=n.out&&n.out[t]:o=n.undirected&&n.undirected[t]),o}function V(r){return typeof r=="object"&&r!==null}function ni(r){let i;for(i in r)return!1;return!0}function Z(r,i,t){Object.defineProperty(r,i,{enumerable:!1,configurable:!1,writable:!0,value:t})}function J(r,i,t){const e={enumerable:!0,configurable:!0};typeof t=="function"?e.get=t:(e.value=t,e.writable=!1),Object.defineProperty(r,i,e)}function St(r){return!(!V(r)||r.attributes&&!Array.isArray(r.attributes))}function Xi(){let r=Math.floor(Math.random()*256)&255;return()=>r++}function ae(){const r=arguments;let i=null,t=-1;return{[Symbol.iterator](){return this},next(){let e=null;do{if(i===null){if(t++,t>=r.length)return{done:!0};i=r[t][Symbol.iterator]()}if(e=i.next(),e.done){i=null;continue}break}while(!0);return e}}}function be(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class gt extends Error{constructor(i){super(),this.name="GraphError",this.message=i}}class C extends gt{constructor(i){super(i),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,C.prototype.constructor)}}class T extends gt{constructor(i){super(i),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,T.prototype.constructor)}}class D extends gt{constructor(i){super(i),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}function ri(r,i){this.key=r,this.attributes=i,this.clear()}ri.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function oi(r,i){this.key=r,this.attributes=i,this.clear()}oi.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function ai(r,i){this.key=r,this.attributes=i,this.clear()}ai.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function we(r,i,t,e,n){this.key=i,this.attributes=n,this.undirected=r,this.source=t,this.target=e}we.prototype.attach=function(){let r="out",i="in";this.undirected&&(r=i="undirected");const t=this.source.key,e=this.target.key;this.source[r][e]=this,!(this.undirected&&t===e)&&(this.target[i][t]=this)};we.prototype.attachMulti=function(){let r="out",i="in";const t=this.source.key,e=this.target.key;this.undirected&&(r=i="undirected");const n=this.source[r],o=n[e];if(typeof o>"u"){n[e]=this,this.undirected&&t===e||(this.target[i][t]=this);return}o.previous=this,this.next=o,n[e]=this,this.target[i][t]=this};we.prototype.detach=function(){const r=this.source.key,i=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),delete this.source[t][i],delete this.target[e][r]};we.prototype.detachMulti=function(){const r=this.source.key,i=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][i],delete this.target[e][r]):(this.next.previous=void 0,this.source[t][i]=this.next,this.target[e][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const si=0,ui=1,Ji=2,hi=3;function se(r,i,t,e,n,o,a){let s,u,h,c;if(e=""+e,t===si){if(s=r._nodes.get(e),!s)throw new T(`Graph.${i}: could not find the "${e}" node in the graph.`);h=n,c=o}else if(t===hi){if(n=""+n,u=r._edges.get(n),!u)throw new T(`Graph.${i}: could not find the "${n}" edge in the graph.`);const d=u.source.key,l=u.target.key;if(e===d)s=u.target;else if(e===l)s=u.source;else throw new T(`Graph.${i}: the "${e}" node is not attached to the "${n}" edge (${d}, ${l}).`);h=o,c=a}else{if(u=r._edges.get(e),!u)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`);t===ui?s=u.source:s=u.target,h=n,c=o}return[s,h,c]}function Qi(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);return a.attributes[s]}}function en(r,i,t){r.prototype[i]=function(e,n){const[o]=se(this,i,t,e,n);return o.attributes}}function tn(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);return a.attributes.hasOwnProperty(s)}}function nn(r,i,t){r.prototype[i]=function(e,n,o,a){const[s,u,h]=se(this,i,t,e,n,o,a);return s.attributes[u]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function rn(r,i,t){r.prototype[i]=function(e,n,o,a){const[s,u,h]=se(this,i,t,e,n,o,a);if(typeof h!="function")throw new C(`Graph.${i}: updater should be a function.`);const c=s.attributes,d=h(c[u]);return c[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function on(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function an(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);if(!V(s))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function sn(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);if(!V(s))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return B(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function un(r,i,t){r.prototype[i]=function(e,n,o){const[a,s]=se(this,i,t,e,n,o);if(typeof s!="function")throw new C(`Graph.${i}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const hn=[{name:r=>`get${r}Attribute`,attacher:Qi},{name:r=>`get${r}Attributes`,attacher:en},{name:r=>`has${r}Attribute`,attacher:tn},{name:r=>`set${r}Attribute`,attacher:nn},{name:r=>`update${r}Attribute`,attacher:rn},{name:r=>`remove${r}Attribute`,attacher:on},{name:r=>`replace${r}Attributes`,attacher:an},{name:r=>`merge${r}Attributes`,attacher:sn},{name:r=>`update${r}Attributes`,attacher:un}];function dn(r){hn.forEach(function({name:i,attacher:t}){t(r,i("Node"),si),t(r,i("Source"),ui),t(r,i("Target"),Ji),t(r,i("Opposite"),hi)})}function cn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return o.attributes[n]}}function ln(r,i,t){r.prototype[i]=function(e){let n;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,a=""+arguments[1];if(n=X(this,o,a,t),!n)throw new T(`Graph.${i}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,n=this._edges.get(e),!n)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return n.attributes}}function fn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return o.attributes.hasOwnProperty(n)}}function gn(r,i,t){r.prototype[i]=function(e,n,o){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+n;if(n=arguments[2],o=arguments[3],a=X(this,s,u,t),!a)throw new T(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return a.attributes[n]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:n}),this}}function pn(r,i,t){r.prototype[i]=function(e,n,o){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+n;if(n=arguments[2],o=arguments[3],a=X(this,s,u,t),!a)throw new T(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(typeof o!="function")throw new C(`Graph.${i}: updater should be a function.`);return a.attributes[n]=o(a.attributes[n]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:n}),this}}function mn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}return delete o.attributes[n],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:n}),this}}function vn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(!V(n))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return o.attributes=n,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function yn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(!V(n))throw new C(`Graph.${i}: provided attributes are not a plain object.`);return B(o.attributes,n),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:n}),this}}function bn(r,i,t){r.prototype[i]=function(e,n){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,s=""+n;if(n=arguments[2],o=X(this,a,s,t),!o)throw new T(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(t!=="mixed")throw new D(`Graph.${i}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new T(`Graph.${i}: could not find the "${e}" edge in the graph.`)}if(typeof n!="function")throw new C(`Graph.${i}: provided updater is not a function.`);return o.attributes=n(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const wn=[{name:r=>`get${r}Attribute`,attacher:cn},{name:r=>`get${r}Attributes`,attacher:ln},{name:r=>`has${r}Attribute`,attacher:fn},{name:r=>`set${r}Attribute`,attacher:gn},{name:r=>`update${r}Attribute`,attacher:pn},{name:r=>`remove${r}Attribute`,attacher:mn},{name:r=>`replace${r}Attributes`,attacher:vn},{name:r=>`merge${r}Attributes`,attacher:yn},{name:r=>`update${r}Attributes`,attacher:bn}];function En(r){wn.forEach(function({name:i,attacher:t}){t(r,i("Edge"),"mixed"),t(r,i("DirectedEdge"),"directed"),t(r,i("UndirectedEdge"),"undirected")})}const _n=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function xn(r,i,t,e){let n=!1;for(const o in i){if(o===e)continue;const a=i[o];if(n=t(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),r&&n)return a.key}}function Tn(r,i,t,e){let n,o,a,s=!1;for(const u in i)if(u!==e){n=i[u];do{if(o=n.source,a=n.target,s=t(n.key,n.attributes,o.key,a.key,o.attributes,a.attributes,n.undirected),r&&s)return n.key;n=n.next}while(n!==void 0)}}function He(r,i){const t=Object.keys(r),e=t.length;let n,o=0;return{[Symbol.iterator](){return this},next(){do if(n)n=n.next;else{if(o>=e)return{done:!0};const a=t[o++];if(a===i){n=void 0;continue}n=r[a]}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}}}}function Rn(r,i,t,e){const n=i[t];if(!n)return;const o=n.source,a=n.target;if(e(n.key,n.attributes,o.key,a.key,o.attributes,a.attributes,n.undirected)&&r)return n.key}function Sn(r,i,t,e){let n=i[t];if(!n)return;let o=!1;do{if(o=e(n.key,n.attributes,n.source.key,n.target.key,n.source.attributes,n.target.attributes,n.undirected),r&&o)return n.key;n=n.next}while(n!==void 0)}function We(r,i){let t=r[i];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const n={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:n}}};let e=!1;return{[Symbol.iterator](){return this},next(){return e===!0?{done:!0}:(e=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function Cn(r,i){if(r.size===0)return[];if(i==="mixed"||i===r.type)return Array.from(r._edges.keys());const t=i==="undirected"?r.undirectedSize:r.directedSize,e=new Array(t),n=i==="undirected",o=r._edges.values();let a=0,s,u;for(;s=o.next(),s.done!==!0;)u=s.value,u.undirected===n&&(e[a++]=u.key);return e}function di(r,i,t,e){if(i.size===0)return;const n=t!=="mixed"&&t!==i.type,o=t==="undirected";let a,s,u=!1;const h=i._edges.values();for(;a=h.next(),a.done!==!0;){if(s=a.value,n&&s.undirected!==o)continue;const{key:c,attributes:d,source:l,target:f}=s;if(u=e(c,d,l.key,f.key,l.attributes,f.attributes,s.undirected),r&&u)return c}}function kn(r,i){if(r.size===0)return be();const t=i!=="mixed"&&i!==r.type,e=i==="undirected",n=r._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=n.next(),o.done)return o;if(a=o.value,!(t&&a.undirected!==e))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function pt(r,i,t,e,n,o){const a=i?Tn:xn;let s;if(t!=="undirected"&&(e!=="out"&&(s=a(r,n.in,o),r&&s)||e!=="in"&&(s=a(r,n.out,o,e?void 0:n.key),r&&s))||t!=="directed"&&(s=a(r,n.undirected,o),r&&s))return s}function An(r,i,t,e){const n=[];return pt(!1,r,i,t,e,function(o){n.push(o)}),n}function Ln(r,i,t){let e=be();return r!=="undirected"&&(i!=="out"&&typeof t.in<"u"&&(e=ae(e,He(t.in))),i!=="in"&&typeof t.out<"u"&&(e=ae(e,He(t.out,i?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(e=ae(e,He(t.undirected))),e}function mt(r,i,t,e,n,o,a){const s=t?Sn:Rn;let u;if(i!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&(u=s(r,n.in,o,a),r&&u)||typeof n.out<"u"&&e!=="in"&&(e||n.key!==o)&&(u=s(r,n.out,o,a),r&&u))||i!=="directed"&&typeof n.undirected<"u"&&(u=s(r,n.undirected,o,a),r&&u))return u}function Nn(r,i,t,e,n){const o=[];return mt(!1,r,i,t,e,n,function(a){o.push(a)}),o}function Dn(r,i,t,e){let n=be();return r!=="undirected"&&(typeof t.in<"u"&&i!=="out"&&e in t.in&&(n=ae(n,We(t.in,e))),typeof t.out<"u"&&i!=="in"&&e in t.out&&(i||t.key!==e)&&(n=ae(n,We(t.out,e)))),r!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(n=ae(n,We(t.undirected,e))),n}function Gn(r,i){const{name:t,type:e,direction:n}=i;r.prototype[t]=function(o,a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];if(!arguments.length)return Cn(this,e);if(arguments.length===1){o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new T(`Graph.${t}: could not find the "${o}" node in the graph.`);return An(this.multi,e==="mixed"?this.type:e,n,s)}if(arguments.length===2){o=""+o,a=""+a;const s=this._nodes.get(o);if(!s)throw new T(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new T(`Graph.${t}: could not find the "${a}" target node in the graph.`);return Nn(e,this.multi,n,s,a)}throw new C(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Fn(r,i){const{name:t,type:e,direction:n}=i,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(h,c,d){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return d=h,di(!1,this,e,d);if(arguments.length===2){h=""+h,d=c;const l=this._nodes.get(h);if(typeof l>"u")throw new T(`Graph.${o}: could not find the "${h}" node in the graph.`);return pt(!1,this.multi,e==="mixed"?this.type:e,n,l,d)}if(arguments.length===3){h=""+h,c=""+c;const l=this._nodes.get(h);if(!l)throw new T(`Graph.${o}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(c))throw new T(`Graph.${o}: could not find the "${c}" target node in the graph.`);return mt(!1,e,this.multi,n,l,c,d)}throw new C(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const a="map"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(){const h=Array.prototype.slice.call(arguments),c=h.pop();let d;if(h.length===0){let l=0;e!=="directed"&&(l+=this.undirectedSize),e!=="undirected"&&(l+=this.directedSize),d=new Array(l);let f=0;h.push((y,m,b,R,x,_,g)=>{d[f++]=c(y,m,b,R,x,_,g)})}else d=[],h.push((l,f,y,m,b,R,x)=>{d.push(c(l,f,y,m,b,R,x))});return this[o].apply(this,h),d};const s="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),c=h.pop(),d=[];return h.push((l,f,y,m,b,R,x)=>{c(l,f,y,m,b,R,x)&&d.push(l)}),this[o].apply(this,h),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[u]=function(){let h=Array.prototype.slice.call(arguments);if(h.length<2||h.length>4)throw new C(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${h.length}).`);if(typeof h[h.length-1]=="function"&&typeof h[h.length-2]!="function")throw new C(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c,d;h.length===2?(c=h[0],d=h[1],h=[]):h.length===3?(c=h[1],d=h[2],h=[h[0]]):h.length===4&&(c=h[2],d=h[3],h=[h[0],h[1]]);let l=d;return h.push((f,y,m,b,R,x,_)=>{l=c(l,f,y,m,b,R,x,_)}),this[o].apply(this,h),l}}function Pn(r,i){const{name:t,type:e,direction:n}=i,o="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(u,h,c){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return c=u,di(!0,this,e,c);if(arguments.length===2){u=""+u,c=h;const d=this._nodes.get(u);if(typeof d>"u")throw new T(`Graph.${o}: could not find the "${u}" node in the graph.`);return pt(!0,this.multi,e==="mixed"?this.type:e,n,d,c)}if(arguments.length===3){u=""+u,h=""+h;const d=this._nodes.get(u);if(!d)throw new T(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(h))throw new T(`Graph.${o}: could not find the "${h}" target node in the graph.`);return mt(!0,e,this.multi,n,d,h,c)}throw new C(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const a="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((d,l,f,y,m,b,R)=>h(d,l,f,y,m,b,R)),!!this[o].apply(this,u)};const s="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((d,l,f,y,m,b,R)=>!h(d,l,f,y,m,b,R)),!this[o].apply(this,u)}}function Mn(r,i){const{name:t,type:e,direction:n}=i,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(a,s){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return be();if(!arguments.length)return kn(this,e);if(arguments.length===1){a=""+a;const u=this._nodes.get(a);if(!u)throw new T(`Graph.${o}: could not find the "${a}" node in the graph.`);return Ln(e,n,u)}if(arguments.length===2){a=""+a,s=""+s;const u=this._nodes.get(a);if(!u)throw new T(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new T(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Dn(e,n,u,s)}throw new C(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function In(r){_n.forEach(i=>{Gn(r,i),Fn(r,i),Pn(r,i),Mn(r,i)})}const zn=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Ue(){this.A=null,this.B=null}Ue.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};Ue.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function _e(r,i,t,e,n){for(const o in e){const a=e[o],s=a.source,u=a.target,h=s===t?u:s;if(i&&i.has(h.key))continue;const c=n(h.key,h.attributes);if(r&&c)return h.key}}function vt(r,i,t,e,n){if(i!=="mixed"){if(i==="undirected")return _e(r,null,e,e.undirected,n);if(typeof t=="string")return _e(r,null,e,e[t],n)}const o=new Ue;let a;if(i!=="undirected"){if(t!=="out"){if(a=_e(r,null,e,e.in,n),r&&a)return a;o.wrap(e.in)}if(t!=="in"){if(a=_e(r,o,e,e.out,n),r&&a)return a;o.wrap(e.out)}}if(i!=="directed"&&(a=_e(r,o,e,e.undirected,n),r&&a))return a}function $n(r,i,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof i=="string")return Object.keys(t[i])}const e=[];return vt(!1,r,i,t,function(n){e.push(n)}),e}function xe(r,i,t){const e=Object.keys(t),n=e.length;let o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=n)return r&&r.wrap(t),{done:!0};const s=t[e[o++]],u=s.source,h=s.target;if(a=u===i?h:u,r&&r.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function Un(r,i,t){if(r!=="mixed"){if(r==="undirected")return xe(null,t,t.undirected);if(typeof i=="string")return xe(null,t,t[i])}let e=be();const n=new Ue;return r!=="undirected"&&(i!=="out"&&(e=ae(e,xe(n,t,t.in))),i!=="in"&&(e=ae(e,xe(n,t,t.out)))),r!=="directed"&&(e=ae(e,xe(n,t,t.undirected))),e}function On(r,i){const{name:t,type:e,direction:n}=i;r.prototype[t]=function(o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new T(`Graph.${t}: could not find the "${o}" node in the graph.`);return $n(e==="mixed"?this.type:e,n,a)}}function Bn(r,i){const{name:t,type:e,direction:n}=i,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(h,c){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const d=this._nodes.get(h);if(typeof d>"u")throw new T(`Graph.${o}: could not find the "${h}" node in the graph.`);vt(!1,e==="mixed"?this.type:e,n,d,c)};const a="map"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(h,c){const d=[];return this[o](h,(l,f)=>{d.push(c(l,f))}),d};const s="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(h,c){const d=[];return this[o](h,(l,f)=>{c(l,f)&&d.push(l)}),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[u]=function(h,c,d){if(arguments.length<3)throw new C(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let l=d;return this[o](h,(f,y)=>{l=c(l,f,y)}),l}}function Hn(r,i){const{name:t,type:e,direction:n}=i,o=t[0].toUpperCase()+t.slice(1,-1),a="find"+o;r.prototype[a]=function(h,c){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const d=this._nodes.get(h);if(typeof d>"u")throw new T(`Graph.${a}: could not find the "${h}" node in the graph.`);return vt(!0,e==="mixed"?this.type:e,n,d,c)};const s="some"+o;r.prototype[s]=function(h,c){return!!this[a](h,c)};const u="every"+o;r.prototype[u]=function(h,c){return!this[a](h,(l,f)=>!c(l,f))}}function Wn(r,i){const{name:t,type:e,direction:n}=i,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return be();a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new T(`Graph.${o}: could not find the "${a}" node in the graph.`);return Un(e==="mixed"?this.type:e,n,s)}}function jn(r){zn.forEach(i=>{On(r,i),Bn(r,i),Hn(r,i),Wn(r,i)})}function Ge(r,i,t,e,n){const o=e._nodes.values(),a=e.type;let s,u,h,c,d,l;for(;s=o.next(),s.done!==!0;){let f=!1;if(u=s.value,a!=="undirected"){c=u.out;for(h in c){d=c[h];do l=d.target,f=!0,n(u.key,l.key,u.attributes,l.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(a!=="directed"){c=u.undirected;for(h in c)if(!(i&&u.key>h)){d=c[h];do l=d.target,l.key!==h&&(l=d.source),f=!0,n(u.key,l.key,u.attributes,l.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}t&&!f&&n(u.key,null,u.attributes,null,null,null,null)}}function Vn(r,i){const t={key:r};return ni(i.attributes)||(t.attributes=B({},i.attributes)),t}function qn(r,i,t){const e={key:i,source:t.source.key,target:t.target.key};return ni(t.attributes)||(e.attributes=B({},t.attributes)),r==="mixed"&&t.undirected&&(e.undirected=!0),e}function Kn(r){if(!V(r))throw new C('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new C("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!V(r.attributes)||r.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Yn(r){if(!V(r))throw new C('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new C("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new C("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!V(r.attributes)||r.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new C("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Zn=Xi(),Xn=new Set(["directed","undirected","mixed"]),Ct=new Set(["domain","_events","_eventsCount","_maxListeners"]),Jn=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],Qn={allowSelfLoops:!0,multi:!1,type:"mixed"};function er(r,i,t){if(t&&!V(t))throw new C(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(i=""+i,t=t||{},r._nodes.has(i))throw new D(`Graph.addNode: the "${i}" node already exist in the graph.`);const e=new r.NodeDataClass(i,t);return r._nodes.set(i,e),r.emit("nodeAdded",{key:i,attributes:t}),e}function kt(r,i,t){const e=new r.NodeDataClass(i,t);return r._nodes.set(i,e),r.emit("nodeAdded",{key:i,attributes:t}),e}function ci(r,i,t,e,n,o,a,s){if(!e&&r.type==="undirected")throw new D(`Graph.${i}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(e&&r.type==="directed")throw new D(`Graph.${i}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!V(s))throw new C(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!r.allowSelfLoops&&o===a)throw new D(`Graph.${i}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=r._nodes.get(o),h=r._nodes.get(a);if(!u)throw new T(`Graph.${i}: source node "${o}" not found.`);if(!h)throw new T(`Graph.${i}: target node "${a}" not found.`);const c={key:null,undirected:e,source:o,target:a,attributes:s};if(t)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new D(`Graph.${i}: the "${n}" edge already exists in the graph.`);if(!r.multi&&(e?typeof u.undirected[a]<"u":typeof u.out[a]<"u"))throw new D(`Graph.${i}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new we(e,n,u,h,s);r._edges.set(n,d);const l=o===a;return e?(u.undirectedDegree++,h.undirectedDegree++,l&&(u.undirectedLoops++,r._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,l&&(u.directedLoops++,r._directedSelfLoopCount++)),r.multi?d.attachMulti():d.attach(),e?r._undirectedSize++:r._directedSize++,c.key=n,r.emit("edgeAdded",c),n}function tr(r,i,t,e,n,o,a,s,u){if(!e&&r.type==="undirected")throw new D(`Graph.${i}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(e&&r.type==="directed")throw new D(`Graph.${i}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(u){if(typeof s!="function")throw new C(`Graph.${i}: invalid updater function. Expecting a function but got "${s}"`)}else if(!V(s))throw new C(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let h;if(u&&(h=s,s=void 0),!r.allowSelfLoops&&o===a)throw new D(`Graph.${i}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=r._nodes.get(o),d=r._nodes.get(a),l,f;if(!t&&(l=r._edges.get(n),l)){if((l.source.key!==o||l.target.key!==a)&&(!e||l.source.key!==a||l.target.key!==o))throw new D(`Graph.${i}: inconsistency detected when attempting to merge the "${n}" edge with "${o}" source & "${a}" target vs. ("${l.source.key}", "${l.target.key}").`);f=l}if(!f&&!r.multi&&c&&(f=e?c.undirected[a]:c.out[a]),f){const x=[f.key,!1,!1,!1];if(u?!h:!s)return x;if(u){const _=f.attributes;f.attributes=h(_),r.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else B(f.attributes,s),r.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return x}s=s||{},u&&h&&(s=h(s));const y={key:null,undirected:e,source:o,target:a,attributes:s};if(t)n=r._edgeKeyGenerator();else if(n=""+n,r._edges.has(n))throw new D(`Graph.${i}: the "${n}" edge already exists in the graph.`);let m=!1,b=!1;c||(c=kt(r,o,{}),m=!0,o===a&&(d=c,b=!0)),d||(d=kt(r,a,{}),b=!0),l=new we(e,n,c,d,s),r._edges.set(n,l);const R=o===a;return e?(c.undirectedDegree++,d.undirectedDegree++,R&&(c.undirectedLoops++,r._undirectedSelfLoopCount++)):(c.outDegree++,d.inDegree++,R&&(c.directedLoops++,r._directedSelfLoopCount++)),r.multi?l.attachMulti():l.attach(),e?r._undirectedSize++:r._directedSize++,y.key=n,r.emit("edgeAdded",y),[n,!0,m,b]}function ge(r,i){r._edges.delete(i.key);const{source:t,target:e,attributes:n}=i,o=i.undirected,a=t===e;o?(t.undirectedDegree--,e.undirectedDegree--,a&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,e.inDegree--,a&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?i.detachMulti():i.detach(),o?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:i.key,attributes:n,source:t.key,target:e.key,undirected:o})}class U extends ii.EventEmitter{constructor(i){if(super(),i=B({},Qn,i),typeof i.multi!="boolean")throw new C(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${i.multi}".`);if(!Xn.has(i.type))throw new C(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${i.type}".`);if(typeof i.allowSelfLoops!="boolean")throw new C(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${i.allowSelfLoops}".`);const t=i.type==="mixed"?ri:i.type==="directed"?oi:ai;Z(this,"NodeDataClass",t);const e="geid_"+Zn()+"_";let n=0;const o=()=>{let a;do a=e+n++;while(this._edges.has(a));return a};Z(this,"_attributes",{}),Z(this,"_nodes",new Map),Z(this,"_edges",new Map),Z(this,"_directedSize",0),Z(this,"_undirectedSize",0),Z(this,"_directedSelfLoopCount",0),Z(this,"_undirectedSelfLoopCount",0),Z(this,"_edgeKeyGenerator",o),Z(this,"_options",i),Ct.forEach(a=>Z(this,a,this[a])),J(this,"order",()=>this._nodes.size),J(this,"size",()=>this._edges.size),J(this,"directedSize",()=>this._directedSize),J(this,"undirectedSize",()=>this._undirectedSize),J(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),J(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),J(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),J(this,"multi",this._options.multi),J(this,"type",this._options.type),J(this,"allowSelfLoops",this._options.allowSelfLoops),J(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(i){return this._nodes.has(""+i)}hasDirectedEdge(i,t){if(this.type==="undirected")return!1;if(arguments.length===1){const e=""+i,n=this._edges.get(e);return!!n&&!n.undirected}else if(arguments.length===2){i=""+i,t=""+t;const e=this._nodes.get(i);return e?e.out.hasOwnProperty(t):!1}throw new C(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(i,t){if(this.type==="directed")return!1;if(arguments.length===1){const e=""+i,n=this._edges.get(e);return!!n&&n.undirected}else if(arguments.length===2){i=""+i,t=""+t;const e=this._nodes.get(i);return e?e.undirected.hasOwnProperty(t):!1}throw new C(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(i,t){if(arguments.length===1){const e=""+i;return this._edges.has(e)}else if(arguments.length===2){i=""+i,t=""+t;const e=this._nodes.get(i);return e?typeof e.out<"u"&&e.out.hasOwnProperty(t)||typeof e.undirected<"u"&&e.undirected.hasOwnProperty(t):!1}throw new C(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(i,t){if(this.type==="undirected")return;if(i=""+i,t=""+t,this.multi)throw new D("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const e=this._nodes.get(i);if(!e)throw new T(`Graph.directedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(t))throw new T(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const n=e.out&&e.out[t]||void 0;if(n)return n.key}undirectedEdge(i,t){if(this.type==="directed")return;if(i=""+i,t=""+t,this.multi)throw new D("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const e=this._nodes.get(i);if(!e)throw new T(`Graph.undirectedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(t))throw new T(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const n=e.undirected&&e.undirected[t]||void 0;if(n)return n.key}edge(i,t){if(this.multi)throw new D("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.edge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(t))throw new T(`Graph.edge: could not find the "${t}" target node in the graph.`);const n=e.out&&e.out[t]||e.undirected&&e.undirected[t]||void 0;if(n)return n.key}areDirectedNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areDirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:t in e.in||t in e.out}areOutNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areOutNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:t in e.out}areInNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areInNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:t in e.in}areUndirectedNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areUndirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="directed"?!1:t in e.undirected}areNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&(t in e.in||t in e.out)||this.type!=="directed"&&t in e.undirected}areInboundNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areInboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&t in e.in||this.type!=="directed"&&t in e.undirected}areOutboundNeighbors(i,t){i=""+i,t=""+t;const e=this._nodes.get(i);if(!e)throw new T(`Graph.areOutboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&t in e.out||this.type!=="directed"&&t in e.undirected}inDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.directedDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.undirectedDegree: could not find the "${i}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inboundDegree: could not find the "${i}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree),e}outboundDegree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outboundDegree: could not find the "${i}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.outDegree),e}degree(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.degree: could not find the "${i}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree),e}inDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.directedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let e=0,n=0;return this.type!=="directed"&&(e+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree,n+=t.directedLoops),e-n}outboundDegreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let e=0,n=0;return this.type!=="directed"&&(e+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.outDegree,n+=t.directedLoops),e-n}degreeWithoutSelfLoops(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.degreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let e=0,n=0;return this.type!=="directed"&&(e+=t.undirectedDegree,n+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree,n+=t.directedLoops*2),e-n}source(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.source: could not find the "${i}" edge in the graph.`);return t.source.key}target(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.target: could not find the "${i}" edge in the graph.`);return t.target.key}extremities(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.extremities: could not find the "${i}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(i,t){i=""+i,t=""+t;const e=this._edges.get(t);if(!e)throw new T(`Graph.opposite: could not find the "${t}" edge in the graph.`);const n=e.source.key,o=e.target.key;if(i===n)return o;if(i===o)return n;throw new T(`Graph.opposite: the "${i}" node is not attached to the "${t}" edge (${n}, ${o}).`)}hasExtremity(i,t){i=""+i,t=""+t;const e=this._edges.get(i);if(!e)throw new T(`Graph.hasExtremity: could not find the "${i}" edge in the graph.`);return e.source.key===t||e.target.key===t}isUndirected(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.isUndirected: could not find the "${i}" edge in the graph.`);return t.undirected}isDirected(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.isDirected: could not find the "${i}" edge in the graph.`);return!t.undirected}isSelfLoop(i){i=""+i;const t=this._edges.get(i);if(!t)throw new T(`Graph.isSelfLoop: could not find the "${i}" edge in the graph.`);return t.source===t.target}addNode(i,t){return er(this,i,t).key}mergeNode(i,t){if(t&&!V(t))throw new C(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);i=""+i,t=t||{};let e=this._nodes.get(i);return e?(t&&(B(e.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:i,attributes:e.attributes,data:t})),[i,!1]):(e=new this.NodeDataClass(i,t),this._nodes.set(i,e),this.emit("nodeAdded",{key:i,attributes:t}),[i,!0])}updateNode(i,t){if(t&&typeof t!="function")throw new C(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);i=""+i;let e=this._nodes.get(i);if(e){if(t){const o=e.attributes;e.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:i,attributes:e.attributes})}return[i,!1]}const n=t?t({}):{};return e=new this.NodeDataClass(i,n),this._nodes.set(i,e),this.emit("nodeAdded",{key:i,attributes:n}),[i,!0]}dropNode(i){i=""+i;const t=this._nodes.get(i);if(!t)throw new T(`Graph.dropNode: could not find the "${i}" node in the graph.`);let e;if(this.type!=="undirected"){for(const n in t.out){e=t.out[n];do ge(this,e),e=e.next;while(e)}for(const n in t.in){e=t.in[n];do ge(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const n in t.undirected){e=t.undirected[n];do ge(this,e),e=e.next;while(e)}this._nodes.delete(i),this.emit("nodeDropped",{key:i,attributes:t.attributes})}dropEdge(i){let t;if(arguments.length>1){const e=""+arguments[0],n=""+arguments[1];if(t=X(this,e,n,this.type),!t)throw new T(`Graph.dropEdge: could not find the "${e}" -> "${n}" edge in the graph.`)}else if(i=""+i,t=this._edges.get(i),!t)throw new T(`Graph.dropEdge: could not find the "${i}" edge in the graph.`);return ge(this,t),this}dropDirectedEdge(i,t){if(arguments.length<2)throw new D("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new D("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");i=""+i,t=""+t;const e=X(this,i,t,"directed");if(!e)throw new T(`Graph.dropDirectedEdge: could not find a "${i}" -> "${t}" edge in the graph.`);return ge(this,e),this}dropUndirectedEdge(i,t){if(arguments.length<2)throw new D("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new D("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const e=X(this,i,t,"undirected");if(!e)throw new T(`Graph.dropUndirectedEdge: could not find a "${i}" -> "${t}" edge in the graph.`);return ge(this,e),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const i=this._nodes.values();let t;for(;t=i.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(i){return this._attributes[i]}getAttributes(){return this._attributes}hasAttribute(i){return this._attributes.hasOwnProperty(i)}setAttribute(i,t){return this._attributes[i]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}updateAttribute(i,t){if(typeof t!="function")throw new C("Graph.updateAttribute: updater should be a function.");const e=this._attributes[i];return this._attributes[i]=t(e),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}removeAttribute(i){return delete this._attributes[i],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:i}),this}replaceAttributes(i){if(!V(i))throw new C("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=i,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(i){if(!V(i))throw new C("Graph.mergeAttributes: provided attributes are not a plain object.");return B(this._attributes,i),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:i}),this}updateAttributes(i){if(typeof i!="function")throw new C("Graph.updateAttributes: provided updater is not a function.");return this._attributes=i(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(i,t){if(typeof i!="function")throw new C("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!St(t))throw new C("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._nodes.values();let n,o;for(;n=e.next(),n.done!==!0;)o=n.value,o.attributes=i(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(i,t){if(typeof i!="function")throw new C("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!St(t))throw new C("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._edges.values();let n,o,a,s;for(;n=e.next(),n.done!==!0;)o=n.value,a=o.source,s=o.target,o.attributes=i(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(i){if(typeof i!="function")throw new C("Graph.forEachAdjacencyEntry: expecting a callback.");Ge(!1,!1,!1,this,i)}forEachAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new C("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Ge(!1,!1,!0,this,i)}forEachAssymetricAdjacencyEntry(i){if(typeof i!="function")throw new C("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Ge(!1,!0,!1,this,i)}forEachAssymetricAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new C("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Ge(!1,!0,!0,this,i)}nodes(){return Array.from(this._nodes.keys())}forEachNode(i){if(typeof i!="function")throw new C("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)n=e.value,i(n.key,n.attributes)}findNode(i){if(typeof i!="function")throw new C("Graph.findNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)if(n=e.value,i(n.key,n.attributes))return n.key}mapNodes(i){if(typeof i!="function")throw new C("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let e,n;const o=new Array(this.order);let a=0;for(;e=t.next(),e.done!==!0;)n=e.value,o[a++]=i(n.key,n.attributes);return o}someNode(i){if(typeof i!="function")throw new C("Graph.someNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)if(n=e.value,i(n.key,n.attributes))return!0;return!1}everyNode(i){if(typeof i!="function")throw new C("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let e,n;for(;e=t.next(),e.done!==!0;)if(n=e.value,!i(n.key,n.attributes))return!1;return!0}filterNodes(i){if(typeof i!="function")throw new C("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let e,n;const o=[];for(;e=t.next(),e.done!==!0;)n=e.value,i(n.key,n.attributes)&&o.push(n.key);return o}reduceNodes(i,t){if(typeof i!="function")throw new C("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new C("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let e=t;const n=this._nodes.values();let o,a;for(;o=n.next(),o.done!==!0;)a=o.value,e=i(e,a.key,a.attributes);return e}nodeEntries(){const i=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=i.next();if(t.done)return t;const e=t.value;return{value:{node:e.key,attributes:e.attributes},done:!1}}}}export(){const i=new Array(this._nodes.size);let t=0;this._nodes.forEach((n,o)=>{i[t++]=Vn(o,n)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((n,o)=>{e[t++]=qn(this.type,o,n)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:i,edges:e}}import(i,t=!1){if(i instanceof U)return i.forEachNode((u,h)=>{t?this.mergeNode(u,h):this.addNode(u,h)}),i.forEachEdge((u,h,c,d,l,f,y)=>{t?y?this.mergeUndirectedEdgeWithKey(u,c,d,h):this.mergeDirectedEdgeWithKey(u,c,d,h):y?this.addUndirectedEdgeWithKey(u,c,d,h):this.addDirectedEdgeWithKey(u,c,d,h)}),this;if(!V(i))throw new C("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(i.attributes){if(!V(i.attributes))throw new C("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(i.attributes):this.replaceAttributes(i.attributes)}let e,n,o,a,s;if(i.nodes){if(o=i.nodes,!Array.isArray(o))throw new C("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=o.length;e<n;e++){a=o[e],Kn(a);const{key:u,attributes:h}=a;t?this.mergeNode(u,h):this.addNode(u,h)}}if(i.edges){let u=!1;if(this.type==="undirected"&&(u=!0),o=i.edges,!Array.isArray(o))throw new C("Graph.import: invalid edges. Expecting an array.");for(e=0,n=o.length;e<n;e++){s=o[e],Yn(s);const{source:h,target:c,attributes:d,undirected:l=u}=s;let f;"key"in s?(f=t?l?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:l?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,h,c,d)):(f=t?l?this.mergeUndirectedEdge:this.mergeDirectedEdge:l?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,h,c,d))}}return this}nullCopy(i){const t=new U(B({},this._options,i));return t.replaceAttributes(B({},this.getAttributes())),t}emptyCopy(i){const t=this.nullCopy(i);return this._nodes.forEach((e,n)=>{const o=B({},e.attributes);e=new t.NodeDataClass(n,o),t._nodes.set(n,e)}),t}copy(i){if(i=i||{},typeof i.type=="string"&&i.type!==this.type&&i.type!=="mixed")throw new D(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${i.type}" because this would mean losing information about the current graph.`);if(typeof i.multi=="boolean"&&i.multi!==this.multi&&i.multi!==!0)throw new D("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof i.allowSelfLoops=="boolean"&&i.allowSelfLoops!==this.allowSelfLoops&&i.allowSelfLoops!==!0)throw new D("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(i),e=this._edges.values();let n,o;for(;n=e.next(),n.done!==!0;)o=n.value,ci(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,B({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const i={};this._nodes.forEach((o,a)=>{i[a]=o.attributes});const t={},e={};this._edges.forEach((o,a)=>{const s=o.undirected?"--":"->";let u="",h=o.source.key,c=o.target.key,d;o.undirected&&h>c&&(d=h,h=c,c=d);const l=`(${h})${s}(${c})`;a.startsWith("geid_")?this.multi&&(typeof e[l]>"u"?e[l]=0:e[l]++,u+=`${e[l]}. `):u+=`[${a}]: `,u+=l,t[u]=o.attributes});const n={};for(const o in this)this.hasOwnProperty(o)&&!Ct.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(n[o]=this[o]);return n.attributes=this._attributes,n.nodes=i,n.edges=t,Z(n,"constructor",this.constructor),n}}typeof Symbol<"u"&&(U.prototype[Symbol.for("nodejs.util.inspect.custom")]=U.prototype.inspect);Jn.forEach(r=>{["add","merge","update"].forEach(i=>{const t=r.name(i),e=i==="add"?ci:tr;r.generateKey?U.prototype[t]=function(n,o,a){return e(this,t,!0,(r.type||this.type)==="undirected",null,n,o,a,i==="update")}:U.prototype[t]=function(n,o,a,s){return e(this,t,!1,(r.type||this.type)==="undirected",n,o,a,s,i==="update")}})});dn(U);En(U);In(U);jn(U);class li extends U{constructor(i){const t=B({type:"directed"},i);if("multi"in t&&t.multi!==!1)throw new C("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new C('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class fi extends U{constructor(i){const t=B({type:"undirected"},i);if("multi"in t&&t.multi!==!1)throw new C("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new C('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class gi extends U{constructor(i){const t=B({multi:!0},i);if("multi"in t&&t.multi!==!0)throw new C("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class yt extends U{constructor(i){const t=B({type:"directed",multi:!0},i);if("multi"in t&&t.multi!==!0)throw new C("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new C('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class pi extends U{constructor(i){const t=B({type:"undirected",multi:!0},i);if("multi"in t&&t.multi!==!0)throw new C("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new C('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Ee(r){r.from=function(i,t){const e=B({},i.options,t),n=new r(e);return n.import(i),n}}Ee(U);Ee(li);Ee(fi);Ee(gi);Ee(yt);Ee(pi);U.Graph=U;U.DirectedGraph=li;U.UndirectedGraph=fi;U.MultiGraph=gi;U.MultiDirectedGraph=yt;U.MultiUndirectedGraph=pi;U.InvalidArgumentsGraphError=C;U.NotFoundGraphError=T;U.UsageGraphError=D;function ir(r,i){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var e=t.call(r,i);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(r)}function Ae(r){var i=ir(r,"string");return typeof i=="symbol"?i:i+""}function W(r,i){if(!(r instanceof i))throw new TypeError("Cannot call a class as a function")}function At(r,i){for(var t=0;t<i.length;t++){var e=i[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,Ae(e.key),e)}}function j(r,i,t){return i&&At(r.prototype,i),t&&At(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function ve(r){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ve(r)}function mi(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(mi=function(){return!!r})()}function nr(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function rr(r,i){if(i&&(typeof i=="object"||typeof i=="function"))return i;if(i!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return nr(r)}function q(r,i,t){return i=ve(i),rr(r,mi()?Reflect.construct(i,t||[],ve(r).constructor):i.apply(r,t))}function st(r,i){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},st(r,i)}function K(r,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(i&&i.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),i&&st(r,i)}function or(r){if(Array.isArray(r))return r}function ar(r,i){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var e,n,o,a,s=[],u=!0,h=!1;try{if(o=(t=t.call(r)).next,i===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(e=o.call(t)).done)&&(s.push(e.value),s.length!==i);u=!0);}catch(c){h=!0,n=c}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw n}}return s}}function ut(r,i){(i==null||i>r.length)&&(i=r.length);for(var t=0,e=Array(i);t<i;t++)e[t]=r[t];return e}function vi(r,i){if(r){if(typeof r=="string")return ut(r,i);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ut(r,i):void 0}}function sr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ye(r,i){return or(r)||ar(r,i)||vi(r,i)||sr()}var je={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},yi=new Int8Array(4),Ve=new Int32Array(yi.buffer,0,1),ur=new Float32Array(yi.buffer,0,1),hr=/^\s*rgba?\s*\(/,dr=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function cr(r){var i=0,t=0,e=0,n=1;if(r[0]==="#")r.length===4?(i=parseInt(r.charAt(1)+r.charAt(1),16),t=parseInt(r.charAt(2)+r.charAt(2),16),e=parseInt(r.charAt(3)+r.charAt(3),16)):(i=parseInt(r.charAt(1)+r.charAt(2),16),t=parseInt(r.charAt(3)+r.charAt(4),16),e=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(n=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(hr.test(r)){var o=r.match(dr);o&&(i=+o[1],t=+o[2],e=+o[3],o[4]&&(n=+o[4]))}return{r:i,g:t,b:e,a:n}}var me={};for(var Fe in je)me[Fe]=fe(je[Fe]),me[je[Fe]]=me[Fe];function bi(r,i,t,e,n){return Ve[0]=e<<24|t<<16|i<<8|r,Ve[0]=Ve[0]&4278190079,ur[0]}function fe(r){if(r=r.toLowerCase(),typeof me[r]<"u")return me[r];var i=cr(r),t=i.r,e=i.g,n=i.b,o=i.a;o=o*255|0;var a=bi(t,e,n,o);return me[r]=a,a}var qe={};function wi(r){if(typeof qe[r]<"u")return qe[r];var i=(r&16711680)>>>16,t=(r&65280)>>>8,e=r&255,n=255,o=bi(i,t,e,n);return qe[r]=o,o}function Lt(r,i,t,e){return t+(i<<8)+(r<<16)}function Nt(r,i,t,e,n,o){var a=Math.floor(t/o*n),s=Math.floor(r.drawingBufferHeight/o-e/o*n),u=new Uint8Array(4);r.bindFramebuffer(r.FRAMEBUFFER,i),r.readPixels(a,s,1,1,r.RGBA,r.UNSIGNED_BYTE,u);var h=ye(u,4),c=h[0],d=h[1],l=h[2],f=h[3];return[c,d,l,f]}function w(r,i,t){return(i=Ae(i))in r?Object.defineProperty(r,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[i]=t,r}function Dt(r,i){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);i&&(e=e.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,e)}return t}function A(r){for(var i=1;i<arguments.length;i++){var t=arguments[i]!=null?arguments[i]:{};i%2?Dt(Object(t),!0).forEach(function(e){w(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Dt(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function lr(r,i){for(;!{}.hasOwnProperty.call(r,i)&&(r=ve(r))!==null;);return r}function ht(){return ht=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,i,t){var e=lr(r,i);if(e){var n=Object.getOwnPropertyDescriptor(e,i);return n.get?n.get.call(arguments.length<3?r:t):n.value}},ht.apply(null,arguments)}function Ei(r,i,t,e){var n=ht(ve(r.prototype),i,t);return typeof n=="function"?function(o){return n.apply(t,o)}:n}function fr(r){return r.normalized?1:r.size}function Ke(r){var i=0;return r.forEach(function(t){return i+=fr(t)}),i}function _i(r,i,t){var e=r==="VERTEX"?i.VERTEX_SHADER:i.FRAGMENT_SHADER,n=i.createShader(e);if(n===null)throw new Error("loadShader: error while creating the shader");i.shaderSource(n,t),i.compileShader(n);var o=i.getShaderParameter(n,i.COMPILE_STATUS);if(!o){var a=i.getShaderInfoLog(n);throw i.deleteShader(n),new Error(`loadShader: error while compiling the shader:
3
3
  `.concat(a,`
4
4
  `).concat(t))}return n}function gr(r,i){return _i("VERTEX",r,i)}function pr(r,i){return _i("FRAGMENT",r,i)}function mr(r,i){var t=r.createProgram();if(t===null)throw new Error("loadProgram: error while creating the program.");var e,n;for(e=0,n=i.length;e<n;e++)r.attachShader(t,i[e]);r.linkProgram(t);var o=r.getProgramParameter(t,r.LINK_STATUS);if(!o){var a=r.getProgramInfoLog(t);throw r.deleteProgram(t),new Error("loadProgram: error while linking the program: ".concat(a))}return t}function Gt(r){var i=r.gl,t=r.buffer,e=r.program,n=r.vertexShader,o=r.fragmentShader;i.deleteShader(n),i.deleteShader(o),i.deleteProgram(e),i.deleteBuffer(t)}var Ft=`#define PICKING_MODE
@@ -1,4 +1,4 @@
1
- import{r as K,u as cO,h as io,j as lt}from"./index-CJokoRSp.js";let ps=[],$h=[];(()=>{let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<r.length;e++)(e%2?$h:ps).push(t=t+r[e])})();function fO(r){if(r<768)return!1;for(let e=0,t=ps.length;;){let i=e+t>>1;if(r<ps[i])t=i;else if(r>=$h[i])e=i+1;else return!0;if(e==t)return!1}}function ro(r){return r>=127462&&r<=127487}const no=8205;function uO(r,e,t=!0,i=!0){return(t?wh:OO)(r,e,i)}function wh(r,e,t){if(e==r.length)return e;e&&Ph(r.charCodeAt(e))&&vh(r.charCodeAt(e-1))&&e--;let i=Cn(r,e);for(e+=so(i);e<r.length;){let n=Cn(r,e);if(i==no||n==no||t&&fO(n))e+=so(n),i=n;else if(ro(n)){let s=0,l=e-2;for(;l>=0&&ro(Cn(r,l));)s++,l-=2;if(s%2==0)break;e+=2}else break}return e}function OO(r,e,t){for(;e>1;){let i=wh(r,e-2,t);if(i<e)return i;e--}return 0}function Cn(r,e){let t=r.charCodeAt(e);if(!vh(t)||e+1==r.length)return t;let i=r.charCodeAt(e+1);return Ph(i)?(t-55296<<10)+(i-56320)+65536:t}function Ph(r){return r>=56320&&r<57344}function vh(r){return r>=55296&&r<56320}function so(r){return r<65536?1:2}class E{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=ii(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),Fe.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ii(this,e,t);let i=[];return this.decompose(e,t,i,0),Fe.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new Ri(this),s=new Ri(e);for(let l=t,o=t;;){if(n.next(l),s.next(l),l=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(e=1){return new Ri(this,e)}iterRange(e,t=this.length){return new Th(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Zh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?E.empty:e.length<=32?new ie(e):Fe.from(ie.split(e,[]))}}class ie extends E{constructor(e,t=dO(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let s=0;;s++){let l=this.text[s],o=n+l.length;if((t?i:o)>=e)return new pO(n,o,i,l);n=o+1,i++}}decompose(e,t,i,n){let s=e<=0&&t>=this.length?this:new ie(lo(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let l=i.pop(),o=Xr(s.text,l.text.slice(),0,s.length);if(o.length<=32)i.push(new ie(o,l.length+s.length));else{let a=o.length>>1;i.push(new ie(o.slice(0,a)),new ie(o.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof ie))return super.replace(e,t,i);[e,t]=ii(this,e,t);let n=Xr(this.text,Xr(i.text,lo(this.text,0,e)),t),s=this.length+i.length-(t-e);return n.length<=32?new ie(n,s):Fe.from(ie.split(n,[]),s)}sliceString(e,t=this.length,i=`
1
+ import{r as K,u as cO,h as io,j as lt}from"./index-heNSjszK.js";let ps=[],$h=[];(()=>{let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<r.length;e++)(e%2?$h:ps).push(t=t+r[e])})();function fO(r){if(r<768)return!1;for(let e=0,t=ps.length;;){let i=e+t>>1;if(r<ps[i])t=i;else if(r>=$h[i])e=i+1;else return!0;if(e==t)return!1}}function ro(r){return r>=127462&&r<=127487}const no=8205;function uO(r,e,t=!0,i=!0){return(t?wh:OO)(r,e,i)}function wh(r,e,t){if(e==r.length)return e;e&&Ph(r.charCodeAt(e))&&vh(r.charCodeAt(e-1))&&e--;let i=Cn(r,e);for(e+=so(i);e<r.length;){let n=Cn(r,e);if(i==no||n==no||t&&fO(n))e+=so(n),i=n;else if(ro(n)){let s=0,l=e-2;for(;l>=0&&ro(Cn(r,l));)s++,l-=2;if(s%2==0)break;e+=2}else break}return e}function OO(r,e,t){for(;e>1;){let i=wh(r,e-2,t);if(i<e)return i;e--}return 0}function Cn(r,e){let t=r.charCodeAt(e);if(!vh(t)||e+1==r.length)return t;let i=r.charCodeAt(e+1);return Ph(i)?(t-55296<<10)+(i-56320)+65536:t}function Ph(r){return r>=56320&&r<57344}function vh(r){return r>=55296&&r<56320}function so(r){return r<65536?1:2}class E{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=ii(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),Fe.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ii(this,e,t);let i=[];return this.decompose(e,t,i,0),Fe.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new Ri(this),s=new Ri(e);for(let l=t,o=t;;){if(n.next(l),s.next(l),l=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(e=1){return new Ri(this,e)}iterRange(e,t=this.length){return new Th(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Zh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?E.empty:e.length<=32?new ie(e):Fe.from(ie.split(e,[]))}}class ie extends E{constructor(e,t=dO(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let s=0;;s++){let l=this.text[s],o=n+l.length;if((t?i:o)>=e)return new pO(n,o,i,l);n=o+1,i++}}decompose(e,t,i,n){let s=e<=0&&t>=this.length?this:new ie(lo(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let l=i.pop(),o=Xr(s.text,l.text.slice(),0,s.length);if(o.length<=32)i.push(new ie(o,l.length+s.length));else{let a=o.length>>1;i.push(new ie(o.slice(0,a)),new ie(o.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof ie))return super.replace(e,t,i);[e,t]=ii(this,e,t);let n=Xr(this.text,Xr(i.text,lo(this.text,0,e)),t),s=this.length+i.length-(t-e);return n.length<=32?new ie(n,s):Fe.from(ie.split(n,[]),s)}sliceString(e,t=this.length,i=`
2
2
  `){[e,t]=ii(this,e,t);let n="";for(let s=0,l=0;s<=t&&l<this.text.length;l++){let o=this.text[l],a=s+o.length;s>e&&l&&(n+=i),e<a&&t>s&&(n+=o.slice(Math.max(0,e-s),t-s)),s=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let s of e)i.push(s),n+=s.length+1,i.length==32&&(t.push(new ie(i,n)),i=[],n=-1);return n>-1&&t.push(new ie(i,n)),t}}class Fe extends E{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let s=0;;s++){let l=this.children[s],o=n+l.length,a=i+l.lines-1;if((t?a:o)>=e)return l.lineInner(e,t,i,n);n=o+1,i=a+1}}decompose(e,t,i,n){for(let s=0,l=0;l<=t&&s<this.children.length;s++){let o=this.children[s],a=l+o.length;if(e<=a&&t>=l){let h=n&((l<=e?1:0)|(a>=t?2:0));l>=e&&a<=t&&!h?i.push(o):o.decompose(e-l,t-l,i,h)}l=a+1}}replace(e,t,i){if([e,t]=ii(this,e,t),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let l=this.children[n],o=s+l.length;if(e>=s&&t<=o){let a=l.replace(e-s,t-s,i),h=this.lines-l.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[n]=a,new Fe(c,this.length-(t-e)+i.length)}return super.replace(s,o,a)}s=o+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
3
3
  `){[e,t]=ii(this,e,t);let n="";for(let s=0,l=0;s<this.children.length&&l<=t;s++){let o=this.children[s],a=l+o.length;l>e&&s&&(n+=i),e<a&&t>l&&(n+=o.sliceString(e-l,t-l,i)),l=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Fe))return 0;let i=0,[n,s,l,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,s+=t){if(n==l||s==o)return i;let a=this.children[n],h=e.children[s];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let O of e)i+=O.lines;if(i<32){let O=[];for(let d of e)d.flatten(O);return new ie(O,t)}let n=Math.max(32,i>>5),s=n<<1,l=n>>1,o=[],a=0,h=-1,c=[];function f(O){let d;if(O.lines>s&&O instanceof Fe)for(let p of O.children)f(p);else O.lines>l&&(a>l||!a)?(u(),o.push(O)):O instanceof ie&&a&&(d=c[c.length-1])instanceof ie&&O.lines+d.lines<=32?(a+=O.lines,h+=O.length+1,c[c.length-1]=new ie(d.text.concat(O.text),d.length+1+O.length)):(a+O.lines>n&&u(),a+=O.lines,h+=O.length+1,c.push(O))}function u(){a!=0&&(o.push(c.length==1?c[0]:Fe.from(c,h)),h=-1,a=c.length=0)}for(let O of e)f(O);return u(),o.length==1?o[0]:new Fe(o,t)}}E.empty=new ie([""],0);function dO(r){let e=-1;for(let t of r)e+=t.length+1;return e}function Xr(r,e,t=0,i=1e9){for(let n=0,s=0,l=!0;s<r.length&&n<=i;s++){let o=r[s],a=n+o.length;a>=t&&(a>i&&(o=o.slice(0,i-n)),n<t&&(o=o.slice(t-n)),l?(e[e.length-1]+=o,l=!1):e.push(o)),n=a+1}return e}function lo(r,e,t){return Xr(r,[""],e,t)}class Ri{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ie?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],l=s>>1,o=n instanceof ie?n.text.length:n.children.length;if(l==(t>0?o:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
4
4
  `,this;e--}else if(n instanceof ie){let a=n.text[l+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[l+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ie?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Th{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Ri(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Zh{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(E.prototype[Symbol.iterator]=function(){return this.iter()},Ri.prototype[Symbol.iterator]=Th.prototype[Symbol.iterator]=Zh.prototype[Symbol.iterator]=function(){return this});let pO=class{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}};function ii(r,e,t){return e=Math.max(0,Math.min(r.length,e)),[e,Math.max(e,Math.min(r.length,t))]}function fe(r,e,t=!0,i=!0){return uO(r,e,t,i)}function gO(r){return r>=56320&&r<57344}function mO(r){return r>=55296&&r<56320}function Ch(r,e){let t=r.charCodeAt(e);if(!mO(t)||e+1==r.length)return t;let i=r.charCodeAt(e+1);return gO(i)?(t-55296<<10)+(i-56320)+65536:t}function SO(r){return r<65536?1:2}const gs=/\r\n?|\n/;var ge=(function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r})(ge||(ge={}));class it{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let s=this.sections[t++],l=this.sections[t++];l<0?(e(i,n,s),n+=s):n+=l,i+=s}}iterChangedRanges(e,t=!1){ms(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new it(e)}composeDesc(e){return this.empty?e:e.empty?this:Xh(this,e)}mapDesc(e,t=!1){return e.empty?this:Ss(this,e,t)}mapPos(e,t=-1,i=ge.Simple){let n=0,s=0;for(let l=0;l<this.sections.length;){let o=this.sections[l++],a=this.sections[l++],h=n+o;if(a<0){if(h>e)return s+(e-n);s+=o}else{if(i!=ge.Simple&&h>=e&&(i==ge.TrackDel&&n<e&&h>e||i==ge.TrackBefore&&n<e||i==ge.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!o)return e==n||t<0?s:s+a;s+=a}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return s}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let s=this.sections[i++],l=this.sections[i++],o=n+s;if(l>=0&&n<=t&&o>=e)return n<e&&o>t?"cover":!0;n=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new it(e)}static create(e){return new it(e)}}class ne extends it{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ms(this,(t,i,n,s,l)=>e=e.replace(n,n+(i-t),l),!1),e}mapDesc(e,t=!1){return Ss(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,s=0;n<t.length;n+=2){let l=t[n],o=t[n+1];if(o>=0){t[n]=o,t[n+1]=l;let a=n>>1;for(;i.length<a;)i.push(E.empty);i.push(l?e.slice(s,s+l):E.empty)}s+=l}return new ne(t,i)}compose(e){return this.empty?e:e.empty?this:Xh(this,e,!0)}map(e,t=!1){return e.empty?this:Ss(this,e,t,!0)}iterChanges(e,t=!1){ms(this,e,t)}get desc(){return it.create(this.sections)}filter(e){let t=[],i=[],n=[],s=new Wi(this);e:for(let l=0,o=0;;){let a=l==e.length?1e9:e[l++];for(;o<a||o==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-o);ce(n,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;ce(t,c,f),f>0&&yt(i,t,s.text),s.forward(c),o+=c}let h=e[l++];for(;o<h;){if(s.done)break e;let c=Math.min(s.len,h-o);ce(t,c,-1),ce(n,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),o+=c}}return{changes:new ne(t,i),filtered:it.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],s=[],l=0,o=null;function a(c=!1){if(!c&&!n.length)return;l<t&&ce(n,t-l,-1);let f=new ne(n,s);o=o?o.compose(f.map(o)):f,n=[],s=[],l=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof ne){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),o=o?o.compose(c.map(o)):c}else{let{from:f,to:u=f,insert:O}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let d=O?typeof O=="string"?E.of(O.split(i||gs)):O:E.empty,p=d.length;if(f==u&&p==0)return;f<l&&a(),f>l&&ce(n,f-l,-1),ce(n,u-f,p),yt(s,n,d),l=u}}return h(e),a(!o),o}static empty(e){return new ne(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let s=e[n];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((l,o)=>o&&typeof l!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<n;)i.push(E.empty);i[n]=E.of(s.slice(1)),t.push(s[0],i[n].length)}}}return new ne(t,i)}static createSet(e,t){return new ne(e,t)}}function ce(r,e,t,i=!1){if(e==0&&t<=0)return;let n=r.length-2;n>=0&&t<=0&&t==r[n+1]?r[n]+=e:n>=0&&e==0&&r[n]==0?r[n+1]+=t:i?(r[n]+=e,r[n+1]+=t):r.push(e,t)}function yt(r,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<r.length)r[r.length-1]=r[r.length-1].append(t);else{for(;r.length<i;)r.push(E.empty);r.push(t)}}function ms(r,e,t){let i=r.inserted;for(let n=0,s=0,l=0;l<r.sections.length;){let o=r.sections[l++],a=r.sections[l++];if(a<0)n+=o,s+=o;else{let h=n,c=s,f=E.empty;for(;h+=o,c+=a,a&&i&&(f=f.append(i[l-2>>1])),!(t||l==r.sections.length||r.sections[l+1]<0);)o=r.sections[l++],a=r.sections[l++];e(n,h,s,c,f),n=h,s=c}}}function Ss(r,e,t,i=!1){let n=[],s=i?[]:null,l=new Wi(r),o=new Wi(e);for(let a=-1;;){if(l.done&&o.len||o.done&&l.len)throw new Error("Mismatched change set lengths");if(l.ins==-1&&o.ins==-1){let h=Math.min(l.len,o.len);ce(n,h,-1),l.forward(h),o.forward(h)}else if(o.ins>=0&&(l.ins<0||a==l.i||l.off==0&&(o.len<l.len||o.len==l.len&&!t))){let h=o.len;for(ce(n,o.ins,-1);h;){let c=Math.min(l.len,h);l.ins>=0&&a<l.i&&l.len<=c&&(ce(n,0,l.ins),s&&yt(s,n,l.text),a=l.i),l.forward(c),h-=c}o.next()}else if(l.ins>=0){let h=0,c=l.len;for(;c;)if(o.ins==-1){let f=Math.min(c,o.len);h+=f,c-=f,o.forward(f)}else if(o.ins==0&&o.len<c)c-=o.len,o.next();else break;ce(n,h,a<l.i?l.ins:0),s&&a<l.i&&yt(s,n,l.text),a=l.i,l.forward(l.len-c)}else{if(l.done&&o.done)return s?ne.createSet(n,s):it.create(n);throw new Error("Mismatched change set lengths")}}}function Xh(r,e,t=!1){let i=[],n=t?[]:null,s=new Wi(r),l=new Wi(e);for(let o=!1;;){if(s.done&&l.done)return n?ne.createSet(i,n):it.create(i);if(s.ins==0)ce(i,s.len,0,o),s.next();else if(l.len==0&&!l.done)ce(i,0,l.ins,o),n&&yt(n,i,l.text),l.next();else{if(s.done||l.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,l.len),h=i.length;if(s.ins==-1){let c=l.ins==-1?-1:l.off?0:l.ins;ce(i,a,c,o),n&&c&&yt(n,i,l.text)}else l.ins==-1?(ce(i,s.off?0:s.len,a,o),n&&yt(n,i,s.textBit(a))):(ce(i,s.off?0:s.len,l.off?0:l.ins,o),n&&!l.off&&yt(n,i,l.text));o=(s.ins>a||l.ins>=0&&l.len>a)&&(o||i.length>h),s.forward2(a),l.forward(a)}}}}class Wi{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?E.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?E.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Qt{constructor(e,t,i,n){this.from=e,this.to=t,this.flags=i,this.goalColumn=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new Qt(i,n,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return Q.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Q.range(this.anchor,n,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Q.range(e.anchor,e.head)}static create(e,t,i,n){return new Qt(e,t,i,n)}}class Q{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:Q.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new Q([this.main],0)}addRange(e,t=!0){return Q.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,Q.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Q(e.ranges.map(t=>Qt.fromJSON(t)),e.main)}static single(e,t=e){return new Q([Q.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let s=e[n];if(s.empty?s.from<=i:s.from<i)return Q.normalized(e.slice(),t);i=s.to}return new Q(e,t)}static cursor(e,t=0,i,n){return Qt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),n)}static range(e,t,i,n,s){let l=n==null?7:Math.min(6,n);return!s&&e!=t&&(s=t<e?1:-1),s&&(l|=s<0?8:16),t<e?Qt.create(t,e,l|32,i):Qt.create(e,t,l,i)}static undirectionalRange(e,t){return Qt.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((n,s)=>n.from-s.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let s=e[n],l=e[n-1];if(s.empty?s.from<=l.to:s.from<l.to){let o=l.from,a=Math.max(s.to,l.to);n<=t&&t--,e.splice(--n,2,s.anchor>s.head?Q.range(a,o):Q.range(o,a))}}return new Q(e,t)}}function Ah(r,e){for(let t of r.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let pl=0;class C{constructor(e,t,i,n,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=pl++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new C(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:gl),!!e.static,e.enables)}of(e){return new Ar([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ar(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ar(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function gl(r,e){return r==e||r.length==e.length&&r.every((t,i)=>t===e[i])}class Ar{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=pl++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,s=this.id,l=e[s]>>1,o=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[l]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Qs(f,c)){let O=i(f);if(o?!oo(O,f.values[l],n):!n(O,f.values[l]))return f.values[l]=O,1}return 0},reconfigure:(f,u)=>{let O,d=u.config.address[s];if(d!=null){let p=qr(u,d);if(this.dependencies.every(m=>m instanceof C?u.facet(m)===f.facet(m):m instanceof We?u.field(m,!1)==f.field(m,!1):!0)||(o?oo(O=i(f),p,n):n(O=i(f),p)))return f.values[l]=p,0}else O=i(f);return f.values[l]=O,1}}}get extension(){return this}}function oo(r,e,t){if(r.length!=e.length)return!1;for(let i=0;i<r.length;i++)if(!t(r[i],e[i]))return!1;return!0}function Qs(r,e){let t=!1;for(let i of e)Mi(r,i)&1&&(t=!0);return t}function QO(r,e,t){let i=t.map(a=>r[a.id]),n=t.map(a=>a.type),s=i.filter(a=>!(a&1)),l=r[e.id]>>1;function o(a){let h=[];for(let c=0;c<i.length;c++){let f=qr(a,i[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Mi(a,h);return a.values[l]=o(a),1},update(a,h){if(!Qs(a,s))return 0;let c=o(a);return e.compare(c,a.values[l])?0:(a.values[l]=c,1)},reconfigure(a,h){let c=Qs(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&gl(t,f))return a.values[l]=u,0;let O=o(a);return e.compare(O,u)?(a.values[l]=u,0):(a.values[l]=O,1)}}}const ur=C.define({static:!0});class We{constructor(e,t,i,n,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(e){let t=new We(pl++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ur).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let s=i.values[t],l=this.updateF(s,n);return this.compareF(s,l)?0:(i.values[t]=l,1)},reconfigure:(i,n)=>{let s=i.facet(ur),l=n.facet(ur),o;return(o=s.find(a=>a.field==this))&&o!=l.find(a=>a.field==this)?(i.values[t]=o.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,ur.of({field:this,create:e})]}get extension(){return this}}const Xt={lowest:4,low:3,default:2,high:1,highest:0};function Qi(r){return e=>new Rh(e,r)}const pi={highest:Qi(Xt.highest),high:Qi(Xt.high),default:Qi(Xt.default),low:Qi(Xt.low),lowest:Qi(Xt.lowest)};class Rh{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class pn{of(e){return new ks(this,e)}reconfigure(e){return pn.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ks{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class Br{constructor(e,t,i,n,s,l){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=l,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],s=Object.create(null),l=new Map;for(let u of kO(e,t,l))u instanceof We?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),a=[],h=[];for(let u of n)o[u.id]=h.length<<1,h.push(O=>u.slot(O));let c=i?.config.facets;for(let u in s){let O=s[u],d=O[0].facet,p=c&&c[u]||[];if(O.every(m=>m.type==0))if(o[d.id]=a.length<<1|1,gl(p,O))a.push(i.facet(d));else{let m=d.combine(O.map(S=>S.value));a.push(i&&d.compare(m,i.facet(d))?i.facet(d):m)}else{for(let m of O)m.type==0?(o[m.id]=a.length<<1|1,a.push(m.value)):(o[m.id]=h.length<<1,h.push(S=>m.dynamicSlot(S)));o[d.id]=h.length<<1,h.push(m=>QO(m,d,O))}}let f=h.map(u=>u(o));return new Br(e,l,f,o,a,s)}}function kO(r,e,t){let i=[[],[],[],[],[]],n=new Map;function s(l,o){let a=n.get(l);if(a!=null){if(a<=o)return;let h=i[a].indexOf(l);h>-1&&i[a].splice(h,1),l instanceof ks&&t.delete(l.compartment)}if(n.set(l,o),Array.isArray(l))for(let h of l)s(h,o);else if(l instanceof ks){if(t.has(l.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(l.compartment)||l.inner;t.set(l.compartment,h),s(h,o)}else if(l instanceof Rh)s(l.inner,l.prec);else if(l instanceof We)i[o].push(l),l.provides&&s(l.provides,o);else if(l instanceof Ar)i[o].push(l),l.facet.extensions&&s(l.facet.extensions,Xt.default);else{let h=l.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${l}).`);if(h==l)throw new Error(`Unrecognized extension value in extension set (${l}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,o)}}return s(r,Xt.default),i.reduce((l,o)=>l.concat(o))}function Mi(r,e){if(e&1)return 2;let t=e>>1,i=r.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;r.status[t]=4;let n=r.computeSlot(r,r.config.dynamicSlots[t]);return r.status[t]=2|n}function qr(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}const Mh=C.define(),ys=C.define({combine:r=>r.some(e=>e),static:!0}),jh=C.define({combine:r=>r.length?r[0]:void 0,static:!0}),Lh=C.define(),Yh=C.define(),zh=C.define(),Eh=C.define({combine:r=>r.length?r[0]:!1});class pt{constructor(e,t){this.type=e,this.value=t}static define(){return new yO}}class yO{of(e){return new pt(this,e)}}class bO{constructor(e){this.map=e}of(e){return new F(this,e)}}class F{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new F(this.type,t)}is(e){return this.type==e}static define(e={}){return new bO(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let s=n.map(t);s&&i.push(s)}return i}}F.reconfigure=F.define();F.appendConfig=F.define();class J{constructor(e,t,i,n,s,l){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=l,this._doc=null,this._state=null,i&&Ah(i,t.newLength),s.some(o=>o.type==J.time)||(this.annotations=s.concat(J.time.of(Date.now())))}static create(e,t,i,n,s,l){return new J(e,t,i,n,s,l)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(J.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}J.time=pt.define();J.userEvent=pt.define();J.addToHistory=pt.define();J.remote=pt.define();function xO(r,e){let t=[];for(let i=0,n=0;;){let s,l;if(i<r.length&&(n==e.length||e[n]>=r[i]))s=r[i++],l=r[i++];else if(n<e.length)s=e[n++],l=e[n++];else return t;!t.length||t[t.length-1]<s?t.push(s,l):t[t.length-1]<l&&(t[t.length-1]=l)}}function _h(r,e,t){var i;let n,s,l;return t?(n=e.changes,s=ne.empty(e.changes.length),l=r.changes.compose(e.changes)):(n=e.changes.map(r.changes),s=r.changes.mapDesc(e.changes,!0),l=r.changes.compose(n)),{changes:l,selection:e.selection?e.selection.map(s):(i=r.selection)===null||i===void 0?void 0:i.map(n),effects:F.mapEffects(r.effects,n).concat(F.mapEffects(e.effects,s)),annotations:r.annotations.length?r.annotations.concat(e.annotations):e.annotations,scrollIntoView:r.scrollIntoView||e.scrollIntoView}}function bs(r,e,t){let i=e.selection,n=Gt(e.annotations);return e.userEvent&&(n=n.concat(J.userEvent.of(e.userEvent))),{changes:e.changes instanceof ne?e.changes:ne.of(e.changes||[],t,r.facet(jh)),selection:i&&(i instanceof Q?i:Q.single(i.anchor,i.head)),effects:Gt(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function Wh(r,e,t){let i=bs(r,e.length?e[0]:{},r.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let l=!!e[s].sequential;i=_h(i,bs(r,e[s],l?i.changes.newLength:r.doc.length),l)}let n=J.create(r,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return wO(t?$O(n):n)}function $O(r){let e=r.startState,t=!0;for(let n of e.facet(Lh)){let s=n(r);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:xO(t,s))}if(t!==!0){let n,s;if(t===!1)s=r.changes.invertedDesc,n=ne.empty(e.doc.length);else{let l=r.changes.filter(t);n=l.changes,s=l.filtered.mapDesc(l.changes).invertedDesc}r=J.create(e,n,r.selection&&r.selection.map(s),F.mapEffects(r.effects,s),r.annotations,r.scrollIntoView)}let i=e.facet(Yh);for(let n=i.length-1;n>=0;n--){let s=i[n](r);s instanceof J?r=s:Array.isArray(s)&&s.length==1&&s[0]instanceof J?r=s[0]:r=Wh(e,Gt(s),!1)}return r}function wO(r){let e=r.startState,t=e.facet(zh),i=r;for(let n=t.length-1;n>=0;n--){let s=t[n](r);s&&Object.keys(s).length&&(i=_h(i,bs(e,s,r.changes.newLength),!0))}return i==r?r:J.create(e,r.changes,r.selection,i.effects,i.annotations,i.scrollIntoView)}const PO=[];function Gt(r){return r==null?PO:Array.isArray(r)?r:[r]}var ct=(function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r})(ct||(ct={}));const vO=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let xs;try{xs=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function TO(r){if(xs)return xs.test(r);for(let e=0;e<r.length;e++){let t=r[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||vO.test(t)))return!0}return!1}function ZO(r){return e=>{if(!/\S/.test(e))return ct.Space;if(TO(e))return ct.Word;for(let t=0;t<r.length;t++)if(e.indexOf(r[t])>-1)return ct.Word;return ct.Other}}class V{constructor(e,t,i,n,s,l){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=s,l&&(l._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)Mi(this,o<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Mi(this,i),qr(this,i)}update(...e){return Wh(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let o of e.effects)o.is(pn.reconfigure)?(t&&(n=new Map,t.compartments.forEach((a,h)=>n.set(h,a)),t=null),n.set(o.value.compartment,o.value.extension)):o.is(F.reconfigure)?(t=null,i=o.value):o.is(F.appendConfig)&&(t=null,i=Gt(i).concat(o.value));let s;t?s=e.startState.values.slice():(t=Br.resolve(i,n,this),s=new V(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let l=e.startState.facet(ys)?e.newSelection:e.newSelection.asSingle();new V(t,e.newDoc,l,s,(o,a)=>a.update(o,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:Q.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),s=[i.range],l=Gt(i.effects);for(let o=1;o<t.ranges.length;o++){let a=e(t.ranges[o]),h=this.changes(a.changes),c=h.map(n);for(let u=0;u<o;u++)s[u]=s[u].map(c);let f=n.mapDesc(h,!0);s.push(a.range.map(f)),n=n.compose(c),l=F.mapEffects(l,c).concat(F.mapEffects(Gt(a.effects),f))}return{changes:n,selection:Q.create(s,t.mainIndex),effects:l}}changes(e=[]){return e instanceof ne?e:ne.of(e,this.doc.length,this.facet(V.lineSeparator))}toText(e){return E.of(e.split(this.facet(V.lineSeparator)||gs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Mi(this,t),qr(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof We&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let l=i[s],o=e[s];n.push(l.init(a=>l.spec.fromJSON(o,a)))}}return V.create({doc:e.doc,selection:Q.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=Br.resolve(e.extensions||[],new Map),i=e.doc instanceof E?e.doc:E.of((e.doc||"").split(t.staticFacet(V.lineSeparator)||gs)),n=e.selection?e.selection instanceof Q?e.selection:Q.single(e.selection.anchor,e.selection.head):Q.single(0);return Ah(n,i.length),t.staticFacet(ys)||(n=n.asSingle()),new V(t,i,n,t.dynamicSlots.map(()=>null),(s,l)=>l.create(s),null)}get tabSize(){return this.facet(V.tabSize)}get lineBreak(){return this.facet(V.lineSeparator)||`
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-SVP7TREG-BqcoxIJw.js";import{p as f}from"./chunk-JWPE2WC7-C0eHKvLW.js";import{_ as n,l as o}from"./mermaid.core-DMx_DAl8.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-BjBW8VGk.js";import"./index-CJokoRSp.js";import"./_commonjsHelpers-CqkleIqs.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},F={parser:R,db:a,renderer:u,styles:p};export{F as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-SVP7TREG-CD_C-9M-.js";import{p as f}from"./chunk-JWPE2WC7-qCHQlKfY.js";import{_ as n,l as o}from"./mermaid.core-BlHZooLK.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-DodS6r00.js";import"./index-heNSjszK.js";import"./_commonjsHelpers-CqkleIqs.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},F={parser:R,db:a,renderer:u,styles:p};export{F as diagram};