vizmatic 0.3.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PROMPT.md +75 -525
- package/README.md +87 -578
- package/ROADMAP.md +49 -67
- package/SCIENCE.md +250 -0
- package/assets/THIRD_PARTY_LICENSES.md +40 -1
- package/assets/fonts/InstrumentSerif-Italic.ttf +0 -0
- package/assets/fonts/InstrumentSerif-Regular.ttf +0 -0
- package/assets/licenses/raster-codecs-MIT.txt +74 -0
- package/dist/chunk-3F2VQ7NW.js +1 -0
- package/dist/chunk-4XE64I2U.js +755 -0
- package/dist/chunk-JHHPLALU.js +79 -0
- package/dist/chunk-LTX44BAE.js +112 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-PSBF4TEK.js +1 -0
- package/dist/chunk-RPAHMKAR.js +605 -0
- package/dist/chunk-RWF4VBUL.js +3617 -0
- package/dist/chunk-WHT6HRMX.js +4201 -0
- package/dist/cli.js +371 -10
- package/dist/index.cjs +11129 -2922
- package/dist/index.d.cts +1225 -369
- package/dist/index.d.ts +1225 -369
- package/dist/index.js +6220 -3015
- package/dist/math-LXB4FH4E.js +7 -0
- package/dist/math-QVCETQDQ.js +1 -0
- package/dist/scene-browser-assets.d.ts +38 -0
- package/dist/scene-browser-assets.js +53 -0
- package/dist/scene-browser-chunks/chunk-5MVLYGXM.js +70 -0
- package/dist/scene-browser-chunks/chunk-ASXKN3NU.js +1 -0
- package/dist/scene-browser-chunks/chunk-CM5Y5LZP.js +1 -0
- package/dist/scene-browser-chunks/chunk-DP7NB4EW.js +6 -0
- package/dist/scene-browser-chunks/emscripten-module.browser-M5AEKJGE.js +1 -0
- package/dist/scene-browser-chunks/ffi-FL6ORJU3.js +1 -0
- package/dist/scene-browser-chunks/module-ES6BEMUI-JD5S5VKR.js +1 -0
- package/dist/scene-browser-chunks/module-asyncify-2EFITU5U-HWPFJFJC.js +1 -0
- package/dist/scene-browser-chunks/scene-browser-layout-M3XSXMV4.js +27 -0
- package/dist/scene-browser.d.ts +117 -0
- package/dist/scene-browser.js +220 -0
- package/dist/scene-cli.d.ts +1 -0
- package/dist/scene-cli.js +4 -0
- package/dist/scene-runtime.cjs +995 -0
- package/dist/scene-runtime.d.cts +81 -0
- package/dist/scene-runtime.d.ts +81 -0
- package/dist/scene-runtime.js +22 -0
- package/dist/server-2FYHZ4UO.js +331 -0
- package/dist/stage-browser/browser.d.ts +2482 -0
- package/dist/stage-browser/chunk-SQE76S5B.js +1 -0
- package/dist/stage-browser/chunk-VZNL6JY2.js +59 -0
- package/dist/stage-browser/dagre.esm-N2NIVIAZ.js +6 -0
- package/dist/stage-browser/math-4WFNHVV2.js +18 -0
- package/dist/stage-browser/stage.js +19 -0
- package/dist/stage-export.cjs +4950 -0
- package/dist/stage-export.d.cts +112 -0
- package/dist/stage-export.d.ts +112 -0
- package/dist/stage-export.js +544 -0
- package/dist/stage.cjs +9745 -0
- package/dist/stage.d.cts +1678 -0
- package/dist/stage.d.ts +1678 -0
- package/dist/stage.js +5404 -0
- package/dist/svg-import-Djj2q7Pc.d.cts +742 -0
- package/dist/svg-import-Djj2q7Pc.d.ts +742 -0
- package/dist/video-CcHW1qhV.d.cts +532 -0
- package/dist/video-CcHW1qhV.d.ts +532 -0
- package/examples/README.md +18 -0
- package/examples/agent-pipeline.tsx +4 -4
- package/examples/animated-pipeline.tsx +1 -5
- package/examples/attention-head.tsx +12 -12
- package/examples/aurora-incident.tsx +4 -3
- package/examples/building-blocks.tsx +8 -9
- package/examples/catalog-charts.tsx +4 -4
- package/examples/catalog-content.tsx +7 -9
- package/examples/catalog-convolution-kernel.tsx +116 -0
- package/examples/catalog-data.tsx +2 -8
- package/examples/catalog-dataflow.tsx +5 -9
- package/examples/catalog-dense.tsx +80 -0
- package/examples/catalog-deployment.tsx +5 -11
- package/examples/catalog-diagrams.tsx +13 -16
- package/examples/catalog-drawing.tsx +7 -7
- package/examples/catalog-flows.tsx +4 -4
- package/examples/catalog-foundations.tsx +11 -11
- package/examples/catalog-gaussian-blur.tsx +146 -0
- package/examples/catalog-image-tensors.tsx +115 -0
- package/examples/catalog-ml.tsx +36 -31
- package/examples/catalog-numeric-matrices.tsx +93 -0
- package/examples/catalog-photo-blur.tsx +209 -0
- package/examples/catalog-science-ai.tsx +130 -0
- package/examples/catalog-science-chemistry.tsx +103 -0
- package/examples/catalog-science-math.tsx +93 -0
- package/examples/catalog-science-physics.tsx +84 -0
- package/examples/catalog-sequence.tsx +59 -38
- package/examples/data-pipeline-lineage-presentation.tsx +5 -0
- package/examples/data-pipeline-lineage.tsx +85 -0
- package/examples/daybreak-launch.tsx +1 -0
- package/examples/desired-quadrant.tsx +7 -8
- package/examples/engineering-dashboard-presentation.tsx +13 -0
- package/examples/engineering-dashboard.tsx +160 -0
- package/examples/engineering-flow.tsx +2 -4
- package/examples/eval-dashboard.tsx +6 -6
- package/examples/films/attention.ts +278 -0
- package/examples/films/cache-miss.ts +431 -0
- package/examples/films/catalog.json +132 -0
- package/examples/films/central-limit.ts +269 -0
- package/examples/films/complex-maps.ts +273 -0
- package/examples/films/deck-example.ts +224 -0
- package/examples/films/euler-circle.ts +179 -0
- package/examples/films/fourier-epicycles.ts +265 -0
- package/examples/films/gradient-descent.ts +345 -0
- package/examples/films/linear-maps.ts +175 -0
- package/examples/films/lorenz.ts +207 -0
- package/examples/films/pythagoras.ts +185 -0
- package/examples/films/taylor-series.ts +159 -0
- package/examples/films/vizmatic-title.ts +117 -0
- package/examples/llm-serving-stack-presentation.tsx +5 -0
- package/examples/llm-serving-stack.tsx +94 -0
- package/examples/model-garden.tsx +1 -0
- package/examples/model-router.tsx +6 -6
- package/examples/nccl-all-gather.tsx +3 -3
- package/examples/nccl-all-reduce.tsx +3 -3
- package/examples/nccl-all-to-all.tsx +1 -1
- package/examples/nccl-broadcast.tsx +1 -1
- package/examples/nccl-reduce-scatter.tsx +5 -5
- package/examples/orthogonal-routing.tsx +4 -4
- package/examples/pareto-frontier.tsx +9 -10
- package/examples/presentation-frame.tsx +6 -6
- package/examples/pressure-mechanism.scene.json +14 -0
- package/examples/production-system-map-presentation.tsx +5 -0
- package/examples/production-system-map.tsx +130 -0
- package/examples/rag-graph.tsx +7 -7
- package/examples/release-card.tsx +5 -5
- package/examples/spec-anatomy.tsx +5 -5
- package/examples/system-architecture.tsx +19 -32
- package/examples/theme-system.tsx +1 -1
- package/examples/token-matrix.tsx +4 -2
- package/examples/transparent-badge.tsx +1 -2
- package/examples/videos/README.md +62 -0
- package/examples/videos/calculus-tangent.tsx +101 -0
- package/examples/videos/catalyst-pathway.tsx +56 -0
- package/examples/videos/causal-attention.tsx +91 -0
- package/examples/videos/convolution-kernel.tsx +34 -0
- package/examples/videos/gaussian-blur.tsx +32 -0
- package/examples/videos/image-to-matrix.tsx +22 -0
- package/examples/videos/matrix-multiplication.tsx +128 -0
- package/examples/videos/photo-gaussian-blur.tsx +39 -0
- package/examples/videos/request-lifecycle.tsx +99 -0
- package/examples/videos/signal-to-story.tsx +126 -0
- package/examples/videos/wave-interference.tsx +80 -0
- package/examples/vizmatic-bare.d.ts +1 -0
- package/examples/vizmatic-hero.tsx +9 -18
- package/examples/website-workflow.tsx +7 -7
- package/examples/weekend-field-notes.tsx +3 -2
- package/package.json +77 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>{try{return a||b((a={exports:{}}).exports,a),a.exports}catch(c){throw a=0,c}};var l=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&f(b,d,{get:()=>a[d],enumerable:!(e=h(a,d))||e.enumerable});return b};var n=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{a as B}from"./chunk-SQE76S5B.js";var D=B((b,y)=>{(function(c,u){typeof b=="object"&&typeof y<"u"?y.exports=u():typeof define=="function"&&define.amd?define(u):(c=c||self).parseCssColor=u()})(b,(function(){"use strict";var c={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},u=new RegExp(/^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/,"i"),w="-?\\d*(?:\\.\\d+)",o="("+w+"?)",t="("+w+"?%)",x=(`^
|
|
2
|
+
hsla?\\(
|
|
3
|
+
\\s*(-?\\d*(?:\\.\\d+)?(?:deg|rad|turn)?)\\s*,
|
|
4
|
+
\\s*`+t+`\\s*,
|
|
5
|
+
\\s*`+t+`\\s*
|
|
6
|
+
(?:,\\s*(-?\\d*(?:\\.\\d+)?%?)\\s*)?
|
|
7
|
+
\\)
|
|
8
|
+
$
|
|
9
|
+
`).replace(/\n|\s/g,""),E=new RegExp(x),R=(`^
|
|
10
|
+
hsla?\\(
|
|
11
|
+
\\s*(-?\\d*(?:\\.\\d+)?(?:deg|rad|turn)?)\\s*
|
|
12
|
+
\\s+`+t+`
|
|
13
|
+
\\s+`+t+`
|
|
14
|
+
\\s*(?:\\s*\\/\\s*(-?\\d*(?:\\.\\d+)?%?)\\s*)?
|
|
15
|
+
\\)
|
|
16
|
+
$
|
|
17
|
+
`).replace(/\n|\s/g,""),$=new RegExp(R),q=(`^
|
|
18
|
+
rgba?\\(
|
|
19
|
+
\\s*`+o+`\\s*,
|
|
20
|
+
\\s*`+o+`\\s*,
|
|
21
|
+
\\s*`+o+`\\s*
|
|
22
|
+
(?:,\\s*(-?\\d*(?:\\.\\d+)?%?)\\s*)?
|
|
23
|
+
\\)
|
|
24
|
+
$
|
|
25
|
+
`).replace(/\n|\s/g,""),F=new RegExp(q),M=(`^
|
|
26
|
+
rgba?\\(
|
|
27
|
+
\\s*`+t+`\\s*,
|
|
28
|
+
\\s*`+t+`\\s*,
|
|
29
|
+
\\s*`+t+`\\s*
|
|
30
|
+
(?:,\\s*(-?\\d*(?:\\.\\d+)?%?)\\s*)?
|
|
31
|
+
\\)
|
|
32
|
+
$
|
|
33
|
+
`).replace(/\n|\s/g,""),I=new RegExp(M),N=(`^
|
|
34
|
+
rgba?\\(
|
|
35
|
+
\\s*`+o+`
|
|
36
|
+
\\s+`+o+`
|
|
37
|
+
\\s+`+o+`
|
|
38
|
+
\\s*(?:\\s*\\/\\s*(-?\\d*(?:\\.\\d+)?%?)\\s*)?
|
|
39
|
+
\\)
|
|
40
|
+
$
|
|
41
|
+
`).replace(/\n|\s/g,""),W=new RegExp(N),C=(`^
|
|
42
|
+
rgba?\\(
|
|
43
|
+
\\s*`+t+`
|
|
44
|
+
\\s+`+t+`
|
|
45
|
+
\\s+`+t+`
|
|
46
|
+
\\s*(?:\\s*\\/\\s*(-?\\d*(?:\\.\\d+)?%?)\\s*)?
|
|
47
|
+
\\)
|
|
48
|
+
$
|
|
49
|
+
`).replace(/\n|\s/g,""),j=new RegExp(C),z=new RegExp(/^transparent$/,"i"),L=new RegExp("[^#a-f\\d]","gi"),P=new RegExp("^#?[a-f\\d]{3}[a-f\\d]?$|^#?[a-f\\d]{6}([a-f\\d]{2})?$","i"),f=function(r,n,e){return Math.min(Math.max(n,r),e)},T=function(r){var n=r;return typeof n!="number"&&(n=n.endsWith("%")?255*parseFloat(n)/100:parseFloat(n)),f(Math.round(n),0,255)},k=function(r){return f(parseFloat(r),0,100)};function v(r){var n=r;return typeof n!="number"&&(n=n.endsWith("%")?parseFloat(n)/100:parseFloat(n)),f(n,0,1)}function A(r){var n=(function(e,l){if(l===void 0&&(l={}),typeof e!="string"||L.test(e)||!P.test(e))throw new TypeError("Expected a valid hex string");var a=1;(e=e.replace(/^#/,"")).length===8&&(a=Number.parseInt(e.slice(6,8),16)/255,e=e.slice(0,6)),e.length===4&&(a=Number.parseInt(e.slice(3,4).repeat(2),16)/255,e=e.slice(0,3)),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);var i=Number.parseInt(e,16),g=i>>16,p=i>>8&255,h=255&i,s=typeof l.alpha=="number"?l.alpha:a;return l.format==="array"?[g,p,h,s]:l.format==="css"?"rgb("+g+" "+p+" "+h+(s===1?"":" / "+Number((100*s).toFixed(2))+"%")+")":{red:g,green:p,blue:h,alpha:s}})(r,{format:"array"});return m([null,n[0],n[1],n[2],n[3]])}function m(r){var n=r[1],e=r[2],l=r[3],a=r[4];return a===void 0&&(a=1),{type:"rgb",values:[n,e,l].map(T),alpha:v(a===null?1:a)}}return function(r){if(typeof r!="string")return null;var n=u.exec(r);if(n)return A(n[0]);var e=$.exec(r)||E.exec(r);if(e)return(function(i){var g=i[1],p=i[2],h=i[3],s=i[4];s===void 0&&(s=1);var d=g;return{type:"hsl",values:[d=d.endsWith("turn")?360*parseFloat(d)/1:d.endsWith("rad")?Math.round(180*parseFloat(d)/Math.PI):parseFloat(d),k(p),k(h)],alpha:v(s===null?1:s)}})(e);var l=W.exec(r)||j.exec(r)||F.exec(r)||I.exec(r);if(l)return m(l);if(z.exec(r))return m([null,0,0,0,0]);var a=c[r.toLowerCase()];return a?m([null,a[0],a[1],a[2],1]):null}}))});export{D as a};
|
|
50
|
+
/*! Bundled license information:
|
|
51
|
+
|
|
52
|
+
parse-css-color/dist/index.umd.js:
|
|
53
|
+
(**
|
|
54
|
+
* parse-css-color
|
|
55
|
+
* @version v0.2.1
|
|
56
|
+
* @link http://github.com/noeldelgado/parse-css-color/
|
|
57
|
+
* @license MIT
|
|
58
|
+
*)
|
|
59
|
+
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import"./chunk-SQE76S5B.js";var xe=Object.defineProperty,He=(e,t,r)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ze=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},et=(e,t,r)=>He(e,typeof t!="symbol"?t+"":t,r),je={};Ze(je,{Graph:()=>T,alg:()=>te});var tt=Object.defineProperty,Ie=(e,t)=>{for(var r in t)tt(e,r,{get:t[r],enumerable:!0})},ee=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(r=>{t!==void 0?this.setNode(r,t):this.setNode(r)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=r=>this.removeEdge(this._edgeObjs[r]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(r=>{this.setParent(r)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let r=t;r!==void 0;r=this.parent(r))if(r===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let r=new Set(t),n=this.successors(e);if(n)for(let i of n)r.add(i);return Array.from(r.values())}}isLeaf(e){var t;let r;return this.isDirected()?r=this.successors(e):r=this.neighbors(e),((t=r?.length)!=null?t:0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([i,o])=>{e(i)&&t.setNode(i,o)}),Object.values(this._edgeObjs).forEach(i=>{t.hasNode(i.v)&&t.hasNode(i.w)&&t.setEdge(i,this.edge(i))});let r={},n=i=>{let o=this.parent(i);return!o||t.hasNode(o)?(r[i]=o,o):o in r?r[o]:n(o)};return this._isCompound&&t.nodes().forEach(i=>t.setParent(i,n(i))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((r,n)=>(t!==void 0?this.setEdge(r,n,t):this.setEdge(r,n),n)),this}setEdge(e,t,r,n){let i,o,s,l,a=!1;typeof e=="object"&&e!==null&&"v"in e?(i=e.v,o=e.w,s=e.name,arguments.length===2&&(l=t,a=!0)):(i=e,o=t,s=n,arguments.length>2&&(l=r,a=!0)),i=""+i,o=""+o,s!==void 0&&(s=""+s);let d=V(this._isDirected,i,o,s);if(d in this._edgeLabels)return a&&(this._edgeLabels[d]=l),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(i),this.setNode(o),this._edgeLabels[d]=a?l:this._defaultEdgeLabelFn(i,o,s);let u=rt(this._isDirected,i,o,s);return i=u.v,o=u.w,Object.freeze(u),this._edgeObjs[d]=u,le(this._preds[o],i),le(this._sucs[i],o),this._in[o][d]=u,this._out[i][d]=u,this._edgeCount++,this}edge(e,t,r){let n=arguments.length===1?W(this._isDirected,e):V(this._isDirected,e,t,r);return this._edgeLabels[n]}edgeAsObj(e,t,r){let n=arguments.length===1?this.edge(e):this.edge(e,t,r);return typeof n!="object"||n===null?{label:n}:n}hasEdge(e,t,r){return(arguments.length===1?W(this._isDirected,e):V(this._isDirected,e,t,r))in this._edgeLabels}removeEdge(e,t,r){let n=arguments.length===1?W(this._isDirected,e):V(this._isDirected,e,t,r),i=this._edgeObjs[n];if(i){let o=i.v,s=i.w;delete this._edgeLabels[n],delete this._edgeObjs[n],de(this._preds[s],o),de(this._sucs[o],s),delete this._in[s][n],delete this._out[o][n],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,r){if(!e)return;let n=Object.values(e);return r?n.filter(i=>i.v===t&&i.w===r||i.v===r&&i.w===t):n}};function le(e,t){e[t]?e[t]++:e[t]=1}function de(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function V(e,t,r,n){let i=""+t,o=""+r;if(!e&&i>o){let s=i;i=o,o=s}return i+""+o+""+(n===void 0?"\0":n)}function rt(e,t,r,n){let i=""+t,o=""+r;if(!e&&i>o){let l=i;i=o,o=l}let s={v:i,w:o};return n&&(s.name=n),s}function W(e,t){return V(e,t.v,t.w,t.name)}var nt={};Ie(nt,{read:()=>lt,write:()=>it});function it(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:ot(e),edges:st(e)},r=e.graph();return r!==void 0&&(t.value=structuredClone(r)),t}function ot(e){return e.nodes().map(t=>{let r=e.node(t),n=e.parent(t),i={v:t};return r!==void 0&&(i.value=r),n!==void 0&&(i.parent=n),i})}function st(e){return e.edges().map(t=>{let r=e.edge(t),n={v:t.v,w:t.w};return t.name!==void 0&&(n.name=t.name),r!==void 0&&(n.value=r),n})}function lt(e){let t=new ee(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(r=>{t.setNode(r.v,r.value),r.parent&&t.setParent(r.v,r.parent)}),e.edges.forEach(r=>{t.setEdge({v:r.v,w:r.w,name:r.name},r.value)}),t}var te={};Ie(te,{CycleException:()=>z,bellmanFord:()=>Ce,components:()=>ut,dijkstra:()=>B,dijkstraAll:()=>ft,findCycles:()=>gt,floydWarshall:()=>vt,isAcyclic:()=>wt,postorder:()=>bt,preorder:()=>yt,prim:()=>_t,shortestPaths:()=>kt,tarjan:()=>Le,topsort:()=>Se});var dt=()=>1;function Ce(e,t,r,n){return at(e,String(t),r||dt,n||function(i){var o;return(o=e.outEdges(i))!=null?o:[]})}function at(e,t,r,n){let i={},o,s=0,l=e.nodes(),a=function(h){let c=i[h.v],f=i[h.w];if(!c||!f)return;let p=r(h);c.distance+p<f.distance&&(i[h.w]={distance:c.distance+p,predecessor:h.v},o=!0)},d=function(){l.forEach(function(h){n(h).forEach(function(c){let f=c.v===h?c.v:c.w,p=f===c.v?c.w:c.v;a({v:f,w:p})})})};l.forEach(function(h){let c=h===t?0:Number.POSITIVE_INFINITY;i[h]={distance:c,predecessor:""}});let u=l.length;for(let h=1;h<u&&(o=!1,s++,d(),!!o);h++);if(s===u-1&&(o=!1,d(),o))throw new Error("The graph contains a negative weight cycle");return i}function ut(e){let t={},r=[],n;function i(o){var s,l;o in t||(t[o]=!0,n.push(o),(s=e.successors(o))==null||s.forEach(i),(l=e.predecessors(o))==null||l.forEach(i))}return e.nodes().forEach(function(o){n=[],i(o),n.length&&r.push(n)}),r}var Me=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let r=this._keyIndices,n=String(e);if(!(n in r)){let i=this._arr,o=i.length;return r[n]=o,i.push({key:n,priority:t}),this._decrease(o),!0}return!1}removeMin(){if(this.size()===0)throw new Error("Queue underflow");this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let r=this._keyIndices[e];if(r===void 0)throw new Error(`Key not found: ${e}`);let n=this._arr[r].priority;if(t>n)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${n} New: ${t}`);this._arr[r].priority=t,this._decrease(r)}_heapify(e){let t=this._arr,r=2*e,n=r+1,i=e;r<t.length&&(i=t[r].priority<t[i].priority?r:i,n<t.length&&(i=t[n].priority<t[i].priority?n:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,r=t[e].priority,n;for(;e!==0&&(n=e>>1,!(t[n].priority<r));)this._swap(e,n),e=n}_swap(e,t){let r=this._arr,n=this._keyIndices,i=r[e],o=r[t];r[e]=o,r[t]=i,n[o.key]=e,n[i.key]=t}},ht=()=>1;function B(e,t,r,n){let i=function(o){var s;return(s=e.outEdges(o))!=null?s:[]};return ct(e,String(t),r||ht,n||i)}function ct(e,t,r,n){let i={},o=new Me,s,l,a=function(d){let u=d.v!==s?d.v:d.w,h=i[u];if(!h)return;let c=r(d),f=l.distance+c;if(c<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+c);f<h.distance&&(h.distance=f,h.predecessor=s,o.decrease(u,f))};for(e.nodes().forEach(function(d){let u=d===t?0:Number.POSITIVE_INFINITY;i[d]={distance:u,predecessor:""},o.add(d,u)});o.size()>0;){s=o.removeMin();let d=i[s];if(!d||d.distance===Number.POSITIVE_INFINITY)break;l=d,n(s).forEach(a)}return i}function ft(e,t,r){return e.nodes().reduce(function(n,i){return n[i]=B(e,i,t,r),n},{})}function Le(e){let t=0,r=[],n={},i=[];function o(s){var l;let a=n[s]={onStack:!0,lowlink:t,index:t++};if(r.push(s),(l=e.successors(s))==null||l.forEach(function(d){if(d in n){let u=n[d];u!=null&&u.onStack&&(a.lowlink=Math.min(a.lowlink,u.index))}else{o(d);let u=n[d];u&&(a.lowlink=Math.min(a.lowlink,u.lowlink))}}),a.lowlink===a.index){let d=[],u;do{u=r.pop();let h=n[u];h&&(h.onStack=!1),d.push(u)}while(s!==u);i.push(d)}}return e.nodes().forEach(function(s){s in n||o(s)}),i}function gt(e){return Le(e).filter(function(t){var r;let n=t[0];return n?t.length>1||t.length===1&&((r=e.outEdges(n,n))!=null?r:[]).length>0:!1})}var pt=()=>1;function vt(e,t,r){return mt(e,t||pt,r||function(n){var i;return(i=e.outEdges(n))!=null?i:[]})}function mt(e,t,r){let n={},i=e.nodes();return i.forEach(function(o){let s={};n[o]=s,s[o]={distance:0,predecessor:""},i.forEach(function(l){o!==l&&(s[l]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),r(o).forEach(function(l){let a=l.v===o?l.w:l.v,d=t(l);s[a]={distance:d,predecessor:o}})}),i.forEach(function(o){let s=n[o];s&&i.forEach(function(l){let a=n[l];a&&i.forEach(function(d){let u=a[o],h=s[d],c=a[d];if(u&&h&&c){let f=u.distance+h.distance;f<c.distance&&(c.distance=f,c.predecessor=h.predecessor)}})})}),n}var z=class extends Error{constructor(e){super(e),this.name="CycleException"}};function Se(e){let t={},r={},n=[];function i(o){var s;if(o in r)throw new z;o in t||(r[o]=!0,t[o]=!0,(s=e.predecessors(o))==null||s.forEach(i),delete r[o],n.push(o))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new z;return n}function wt(e){try{Se(e)}catch(t){if(t instanceof z)return!1;throw t}return!0}function Et(e,t,r,n,i){Array.isArray(t)||(t=[t]);let o=(l=>{var a;return(a=e.isDirected()?e.successors(l):e.neighbors(l))!=null?a:[]}),s={};return t.forEach(function(l){if(!e.hasNode(l))throw new Error("Graph does not have node: "+l);i=Te(e,l,r==="post",s,o,n,i)}),i}function Te(e,t,r,n,i,o,s){return t in n||(n[t]=!0,r||(s=o(s,t)),i(t).forEach(function(l){s=Te(e,l,r,n,i,o,s)}),r&&(s=o(s,t))),s}function Pe(e,t,r){return Et(e,t,r,function(n,i){return n.push(i),n},[])}function bt(e,t){return Pe(e,t,"post")}function yt(e,t){return Pe(e,t,"pre")}function _t(e,t){var r;let n=new ee,i={},o=new Me,s;function l(u){let h=u.v===s?u.w:u.v,c=o.priority(h);if(c!==void 0){let f=t(u);f<c&&(i[h]=s,o.decrease(h,f))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(u){o.add(u,Number.POSITIVE_INFINITY),n.setNode(u)});let a=e.nodes()[0];a!==void 0&&o.decrease(a,0);let d=!1;for(;o.size()>0;){if(s=o.removeMin(),s in i)n.setEdge(s,i[s]);else{if(d)throw new Error("Input graph is not connected: "+e);d=!0}(r=e.nodeEdges(s))==null||r.forEach(l)}return n}function kt(e,t,r,n){return Ot(e,t,r,n??(i=>{var o;return(o=e.outEdges(i))!=null?o:[]}))}function Ot(e,t,r,n){if(r===void 0)return B(e,t,r,n);let i=!1,o=e.nodes();for(let s=0;s<o.length;s++){let l=o[s];if(l===void 0)continue;let a=n(l);for(let d=0;d<a.length;d++){let u=a[d];if(!u)continue;let h=u.v===l?u.v:u.w,c=h===u.v?u.w:u.v;r({v:h,w:c})<0&&(i=!0)}if(i)return Ce(e,t,r,n)}return B(e,t,r,n)}var T=ee;function Y(e,t,r,n){let i=n;for(;e.hasNode(i);)i=ne(n);return r.dummy=t,e.setNode(i,r),i}function Nt(e){let t=new T().setGraph(e.graph());return e.nodes().forEach(r=>t.setNode(r,e.node(r))),e.edges().forEach(r=>{let n=t.edge(r.v,r.w)||{weight:0,minlen:1},i=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+i.weight,minlen:Math.max(n.minlen,i.minlen)})}),t}function Fe(e){let t=new T({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(r=>{e.children(r).length||t.setNode(r,e.node(r))}),e.edges().forEach(r=>{t.setEdge(r,e.edge(r))}),t}function ae(e,t){let r=e.x,n=e.y,i=t.x-r,o=t.y-n,s=e.width/2,l=e.height/2;if(!i&&!o)throw new Error("Not possible to find intersection inside of the rectangle");let a,d;return Math.abs(o)*s>Math.abs(i)*l?(o<0&&(l=-l),a=l*i/o,d=l):(i<0&&(s=-s),a=s,d=s*o/i),{x:r+a,y:n+d}}function G(e){let t=A(De(e)+1).map(()=>[]);return e.nodes().forEach(r=>{let n=e.node(r),i=n.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][n.order]=r)}),t}function xt(e){let t=e.nodes().map(n=>{let i=e.node(n).rank;return i===void 0?Number.MAX_VALUE:i}),r=P(Math.min,t);e.nodes().forEach(n=>{let i=e.node(n);Object.hasOwn(i,"rank")&&(i.rank-=r)})}function jt(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),r=P(Math.min,t),n=[];e.nodes().forEach(s=>{let l=e.node(s).rank-r;n[l]||(n[l]=[]),n[l].push(s)});let i=0,o=e.graph().nodeRankFactor;Array.from(n).forEach((s,l)=>{s===void 0&&l%o!==0?--i:s!==void 0&&i&&s.forEach(a=>e.node(a).rank+=i)})}function ue(e,t,r,n){let i={width:0,height:0};return arguments.length>=4&&(i.rank=r,i.order=n),Y(e,"border",i,t)}function It(e,t=Re){let r=[];for(let n=0;n<e.length;n+=t){let i=e.slice(n,n+t);r.push(i)}return r}var Re=65535;function P(e,t){if(t.length>Re){let r=It(t);return e(...r.map(n=>e(...n)))}else return e(...t)}function De(e){let t=e.nodes().map(r=>{let n=e.node(r).rank;return n===void 0?Number.MIN_VALUE:n});return P(Math.max,t)}function Ct(e,t){let r={lhs:[],rhs:[]};return e.forEach(n=>{t(n)?r.lhs.push(n):r.rhs.push(n)}),r}function Ye(e,t){let r=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-r)+"ms")}}function re(e,t){return t()}var Mt=0;function ne(e){let t=++Mt;return e+(""+t)}function A(e,t,r=1){t==null&&(t=e,e=0);let n=o=>o<t;r<0&&(n=o=>t<o);let i=[];for(let o=e;n(o);o+=r)i.push(o);return i}function q(e,t){let r={};for(let n of t)e[n]!==void 0&&(r[n]=e[n]);return r}function $(e,t){let r;return typeof t=="string"?r=n=>n[t]:r=t,Object.entries(e).reduce((n,[i,o])=>(n[i]=r(o,i),n),{})}function Lt(e,t){return e.reduce((r,n,i)=>(r[n]=t[i],r),{})}var X="\0";function Ve(e,t,r){var n,i,o,s,l,a;if(!(e&&t&&r&&t.dummy==="edge"&&r.dummy==="edge"&&t.edgeObj&&r.edgeObj&&e[t.edgeObj.v]&&e[r.edgeObj.v]&&e[t.edgeObj.w]&&e[r.edgeObj.w]))return 0;let d=!0;t.edgeObj.w===r.edgeObj.w&&(d=!1);let u=d?(i=(n=e[t.edgeObj.v])==null?void 0:n.rank)!=null?i:NaN+1:(s=(o=e[t.edgeObj.w])==null?void 0:o.rank)!=null?s:NaN-1,h=Object.entries(e).find(b=>{var y,w;return((y=b[1].edgeObj)==null?void 0:y.v)===t.edgeObj.v&&((w=b[1].edgeObj)==null?void 0:w.w)===t.edgeObj.w&&b[1].rank===u}),c=Object.entries(e).find(b=>{var y,w;return((y=b[1].edgeObj)==null?void 0:y.v)===r.edgeObj.v&&((w=b[1].edgeObj)==null?void 0:w.w)===r.edgeObj.w&&b[1].rank===u});if(!h||!c)return 0;let f=(l=h[1].order)!=null?l:NaN,p=(a=c[1].order)!=null?a:NaN;return isNaN(f-p)?0:f-p}var St="3.1.1",Tt=class{constructor(){et(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return he(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&he(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,r=t._prev;for(;r!==t;)e.push(JSON.stringify(r,Pt)),r=r._prev;return"["+e.join(", ")+"]"}};function he(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Pt(e,t){if(e!=="_next"&&e!=="_prev")return t}var Ft=Tt,Rt=()=>1;function Dt(e,t){if(e.nodeCount()<=1)return[];let r=Vt(e,t||Rt);return Yt(r.graph,r.buckets,r.zeroIdx).flatMap(n=>e.outEdges(n.v,n.w)||[])}function Yt(e,t,r){var n;let i=[],o=t[t.length-1],s=t[0],l;for(;e.nodeCount();){for(;l=s.dequeue();)J(e,t,r,l);for(;l=o.dequeue();)J(e,t,r,l);if(e.nodeCount()){for(let a=t.length-2;a>0;--a)if(l=(n=t[a])==null?void 0:n.dequeue(),l){i=i.concat(J(e,t,r,l,!0)||[]);break}}}return i}function J(e,t,r,n,i){let o=[],s=i?o:void 0;return(e.inEdges(n.v)||[]).forEach(l=>{let a=e.edge(l),d=e.node(l.v);i&&o.push({v:l.v,w:l.w}),d.out-=a,Z(t,r,d)}),(e.outEdges(n.v)||[]).forEach(l=>{let a=e.edge(l),d=l.w,u=e.node(d);u.in-=a,Z(t,r,u)}),e.removeNode(n.v),s}function Vt(e,t){let r=new T,n=0,i=0;e.nodes().forEach(l=>{r.setNode(l,{v:l,in:0,out:0})}),e.edges().forEach(l=>{let a=r.edge(l.v,l.w)||0,d=t(l),u=a+d;r.setEdge(l.v,l.w,u);let h=r.node(l.v),c=r.node(l.w);i=Math.max(i,h.out+=d),n=Math.max(n,c.in+=d)});let o=At(i+n+3).map(()=>new Ft),s=n+1;return r.nodes().forEach(l=>{Z(o,s,r.node(l))}),{graph:r,buckets:o,zeroIdx:s}}function Z(e,t,r){var n,i,o;r.out?r.in?(o=e[r.out-r.in+t])==null||o.enqueue(r):(i=e[e.length-1])==null||i.enqueue(r):(n=e[0])==null||n.enqueue(r)}function At(e){let t=[];for(let r=0;r<e;r++)t.push(r);return t}function Gt(e,t){(e.graph().acyclicer==="greedy"?Dt(e,r(e)):Bt(e,t??null)).forEach(n=>{let i=e.edge(n);e.removeEdge(n),i.forwardName=n.name,i.reversed=!0,e.setEdge(n.w,n.v,i,ne("rev"))});function r(n){return i=>n.edge(i).weight}}function Bt(e,t){let r=[],n={},i={};function o(a){Object.hasOwn(i,a)||(i[a]=!0,n[a]=!0,e.outEdges(a).forEach(d=>{Object.hasOwn(n,d.w)?r.push(d):o(d.w)}),delete n[a])}function s(a){var d;Object.hasOwn(i,a)||(i[a]=!0,n[a]=!0,(d=e.outEdges(a))==null||d.forEach(u=>{var h,c;Object.hasOwn(n,u.w)||((h=t.node(a))==null?void 0:h.rank)>((c=t.node(u.w))==null?void 0:c.rank)&&qt(e,u.w,u)?r.push(u):s(u.w)}),delete n[a])}let l=o;return t&&typeof t.node=="function"&&(l=s),e.sources().forEach(l),e.nodes().forEach(l),r}function zt(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.reversed){e.removeEdge(t);let n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}})}function qt(e,t,r){let n=new Set;function i(o){var s;if(e.sources().includes(o))return!0;n.add(o);for(let l of(s=e.inEdges(o))!=null?s:[])if(!(l.v===r.v&&l.w===r.w)&&!n.has(l.v)&&i(l.v))return!0;return!1}return i(t)}function $t(e){e.graph().dummyChains=[],e.edges().forEach(t=>Xt(e,t))}function Xt(e,t){let r=t.v,n=e.node(r).rank,i=t.w,o=e.node(i).rank,s=t.name,l=e.edge(t),a=l.labelRank;if(o===n+1)return;e.removeEdge(t);let d,u,h;for(h=0,++n;n<o;++h,++n)l.points=[],u={width:0,height:0,edgeLabel:l,edgeObj:t,rank:n},d=Y(e,"edge",u,"_d"),n===a&&(u.width=l.width,u.height=l.height,u.dummy="edge-label",u.labelpos=l.labelpos),e.setEdge(r,d,{weight:l.weight},s),h===0&&e.graph().dummyChains.push(d),r=d;e.setEdge(r,i,{weight:l.weight},s)}function Wt(e){e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeLabel,i;for(e.setEdge(r.edgeObj,n);r.dummy;)i=e.successors(t)[0],e.removeNode(t),n.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height),t=i,r=e.node(t)})}function ie(e){let t={};function r(n){let i=e.node(n);if(Object.hasOwn(t,n))return i.rank;t[n]=!0;let o=e.outEdges(n),s=o?o.map(a=>a==null?Number.POSITIVE_INFINITY:r(a.w)-e.edge(a).minlen):[],l=P(Math.min,s);return l===Number.POSITIVE_INFINITY&&(l=0),i.rank=l}e.sources().forEach(r)}function D(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Ae=Jt;function Jt(e){let t=new T({directed:!1}),r=e.nodes();if(r.length===0)throw new Error("Graph must have at least one node");let n=r[0],i=e.nodeCount();t.setNode(n,{});let o,s;for(;Kt(t,e)<i&&(o=Qt(t,e),!!o);)s=t.hasNode(o.v)?D(e,o):-D(e,o),Ut(t,e,s);return t}function Kt(e,t){function r(n){let i=t.nodeEdges(n);i&&i.forEach(o=>{let s=o.v,l=n===s?o.w:s;!e.hasNode(l)&&!D(t,o)&&(e.setNode(l,{}),e.setEdge(n,l,{}),r(l))})}return e.nodes().forEach(r),e.nodeCount()}function Qt(e,t){return t.edges().reduce((r,n)=>{let i=Number.POSITIVE_INFINITY;return e.hasNode(n.v)!==e.hasNode(n.w)&&(i=D(t,n)),i<r[0]?[i,n]:r},[Number.POSITIVE_INFINITY,null])[1]}function Ut(e,t,r){e.nodes().forEach(n=>t.node(n).rank+=r)}var{preorder:Ht,postorder:Zt}=te,er=F;F.initLowLimValues=se;F.initCutValues=oe;F.calcCutValue=Ge;F.leaveEdge=ze;F.enterEdge=qe;F.exchangeEdges=$e;function F(e){e=Nt(e),ie(e);let t=Ae(e);se(t),oe(t,e);let r,n;for(;r=ze(t);)n=qe(t,e,r),$e(t,e,r,n)}function oe(e,t){let r=Zt(e,e.nodes());r=r.slice(0,r.length-1),r.forEach(n=>tr(e,t,n))}function tr(e,t,r){let n=e.node(r).parent,i=e.edge(r,n);i.cutvalue=Ge(e,t,r)}function Ge(e,t,r){let n=e.node(r).parent,i=!0,o=t.edge(r,n),s=0;o||(i=!1,o=t.edge(n,r)),s=o.weight;let l=t.nodeEdges(r);return l&&l.forEach(a=>{let d=a.v===r,u=d?a.w:a.v;if(u!==n){let h=d===i,c=t.edge(a).weight;if(s+=h?c:-c,nr(e,r,u)){let f=e.edge(r,u).cutvalue;s+=h?-f:f}}}),s}function se(e,t){arguments.length<2&&(t=e.nodes()[0]),Be(e,{},1,t)}function Be(e,t,r,n,i){let o=r,s=e.node(n);t[n]=!0;let l=e.neighbors(n);return l&&l.forEach(a=>{Object.hasOwn(t,a)||(r=Be(e,t,r,a,n))}),s.low=o,s.lim=r++,i?s.parent=i:delete s.parent,r}function ze(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function qe(e,t,r){let n=r.v,i=r.w;t.hasEdge(n,i)||(n=r.w,i=r.v);let o=e.node(n),s=e.node(i),l=o,a=!1;return o.lim>s.lim&&(l=s,a=!0),t.edges().filter(d=>a===ce(e,e.node(d.v),l)&&a!==ce(e,e.node(d.w),l)).reduce((d,u)=>D(t,u)<D(t,d)?u:d)}function $e(e,t,r,n){let i=r.v,o=r.w;e.removeEdge(i,o),e.setEdge(n.v,n.w,{}),se(e),oe(e,t),rr(e,t)}function rr(e,t){let r=e.nodes().find(i=>!e.node(i).parent);if(!r)return;let n=Ht(e,[r]);n=n.slice(1),n.forEach(i=>{let o=e.node(i).parent,s=t.edge(i,o),l=!1;s||(s=t.edge(o,i),l=!0),t.node(i).rank=t.node(o).rank+(l?s.minlen:-s.minlen)})}function nr(e,t,r){return e.hasEdge(t,r)}function ce(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}var ir=or;function or(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":fe(e);break;case"tight-tree":lr(e);break;case"longest-path":sr(e);break;case"none":break;default:fe(e)}}var sr=ie;function lr(e){ie(e),Ae(e)}function fe(e){er(e)}var dr=ar;function ar(e){let t=hr(e),r=e.graph();Array.isArray(r.dummyChains)&&r.dummyChains.forEach(n=>{let i=e.node(n),o=i.edgeObj,s=ur(e,t,o.v,o.w),l=s.path,a=s.lca,d=0,u=l[d],h=!0;for(;n!==o.w;){if(i=e.node(n),h){for(;(u=l[d])!==a&&e.node(u).maxRank<i.rank;)d++;u===a&&(h=!1)}if(!h){for(;d<l.length-1&&e.node(l[d+1]).minRank<=i.rank;)d++;u=l[d]}u!==void 0&&e.setParent(n,u),n=e.successors(n)[0]}})}function ur(e,t,r,n){let i=[],o=[],s=Math.min(t[r].low,t[n].low),l=Math.max(t[r].lim,t[n].lim),a;a=r;do a=e.parent(a),i.push(a);while(a&&(t[a].low>s||l>t[a].lim));let d=a,u=n;for(;(u=e.parent(u))!==d;)o.push(u);return{path:i.concat(o.reverse()),lca:d}}function hr(e){let t={},r=0;function n(i){let o=r;e.children(i).forEach(n),t[i]={low:o,lim:r++}}return e.children(X).forEach(n),t}function cr(e){let t=Y(e,"root",{},"_root"),r=fr(e),n=Object.values(r),i=P(Math.max,n)-1,o=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=o);let s=gr(e)+1;e.children(X).forEach(l=>{Xe(e,t,o,s,i,r,l)}),e.graph().nodeRankFactor=o}function Xe(e,t,r,n,i,o,s){var l;let a=e.children(s);if(!a.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:r});return}let d=ue(e,"_bt"),u=ue(e,"_bb"),h=e.node(s);e.setParent(d,s),h.borderTop=d,e.setParent(u,s),h.borderBottom=u,a.forEach(c=>{var f;Xe(e,t,r,n,i,o,c);let p=e.node(c),b=p.borderTop?p.borderTop:c,y=p.borderBottom?p.borderBottom:c,w=p.borderTop?n:2*n,g=b!==y?1:i-((f=o[s])!=null?f:0)+1;e.setEdge(d,b,{weight:w,minlen:g,nestingEdge:!0}),e.setEdge(y,u,{weight:w,minlen:g,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,d,{weight:0,minlen:i+((l=o[s])!=null?l:0)})}function fr(e){let t={};function r(n,i){let o=e.children(n);o&&o.length&&o.forEach(s=>r(s,i+1)),t[n]=i}return e.children(X).forEach(n=>r(n,1)),t}function gr(e){return e.edges().reduce((t,r)=>t+e.edge(r).weight,0)}function pr(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(r=>{e.edge(r).nestingEdge&&e.removeEdge(r)})}var vr=mr;function mr(e){function t(r){let n=e.children(r),i=e.node(r);if(n.length&&n.forEach(t),i&&Object.hasOwn(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(let o=i.minRank,s=i.maxRank+1;o<s;++o)ge(e,"borderLeft","_bl",r,i,o),ge(e,"borderRight","_br",r,i,o)}}e.children(X).forEach(t)}function ge(e,t,r,n,i,o){let s={width:0,height:0,rank:o,borderType:t},l=i[t][o-1],a=Y(e,"border",s,r);i[t][o]=a,e.setParent(a,n),l&&e.setEdge(l,a,{weight:1})}function wr(e){var t;let r=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(r==="lr"||r==="rl")&&We(e)}function Er(e){var t;let r=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(r==="bt"||r==="rl")&&br(e),(r==="lr"||r==="rl")&&(yr(e),We(e))}function We(e){e.nodes().forEach(t=>pe(e.node(t))),e.edges().forEach(t=>pe(e.edge(t)))}function pe(e){let t=e.width;e.width=e.height,e.height=t}function br(e){e.nodes().forEach(t=>K(e.node(t))),e.edges().forEach(t=>{var r;let n=e.edge(t);(r=n.points)==null||r.forEach(K),Object.hasOwn(n,"y")&&K(n)})}function K(e){e.y=-e.y}function yr(e){e.nodes().forEach(t=>Q(e.node(t))),e.edges().forEach(t=>{var r;let n=e.edge(t);(r=n.points)==null||r.forEach(Q),Object.hasOwn(n,"x")&&Q(n)})}function Q(e){let t=e.x;e.x=e.y,e.y=t}function _r(e,t=null){let r={},n=e.nodes().filter(d=>!e.children(d).length),i=n.map(d=>e.node(d).rank),o=P(Math.max,i),s=A(o+1).map(()=>[]);function l(d){if(r[d])return;r[d]=!0;let u=e.node(d);s[u.rank].push(d);let h=e.successors(d);h&&[...h].sort((c,f)=>a(c,f)).forEach(l)}n.sort((d,u)=>e.node(d).rank-e.node(u).rank).forEach(l);function a(d,u){let h=e.node(d),c=e.node(u);return Ve(t,h,c)}return s}function kr(e,t){let r=0;for(let n=1;n<t.length;++n)r+=Or(e,t[n-1],t[n]);return r}function Or(e,t,r){let n=Lt(r,r.map((d,u)=>u)),i=t.flatMap(d=>{let u=e.outEdges(d);return u?u.map(h=>({pos:n[h.w],weight:e.edge(h).weight})).sort((h,c)=>h.pos-c.pos):[]}),o=1;for(;o<r.length;)o<<=1;let s=2*o-1;o-=1;let l=new Array(s).fill(0),a=0;return i.forEach(d=>{let u=d.pos+o;l[u]+=d.weight;let h=0;for(;u>0;)u%2&&(h+=l[u+1]),u=u-1>>1,l[u]+=d.weight;a+=d.weight*h}),a}function Nr(e,t=[]){return t.map(r=>{let n=e.inEdges(r);if(!n||!n.length)return{v:r};{let i=n.reduce((o,s)=>{let l=e.edge(s),a=e.node(s.v);return{sum:o.sum+l.weight*a.order,weight:o.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:i.sum/i.weight,weight:i.weight}}})}function xr(e,t){let r={};e.forEach((i,o)=>{let s={indegree:0,in:[],out:[],vs:[i.v],i:o};i.barycenter!==void 0&&(s.barycenter=i.barycenter,s.weight=i.weight),r[i.v]=s}),t.edges().forEach(i=>{let o=r[i.v],s=r[i.w];o!==void 0&&s!==void 0&&(s.indegree++,o.out.push(s))});let n=Object.values(r).filter(i=>!i.indegree);return jr(n)}function jr(e){let t=[];function r(i){return o=>{o.merged||(o.barycenter===void 0||i.barycenter===void 0||o.barycenter>=i.barycenter)&&Ir(i,o)}}function n(i){return o=>{o.in.push(i),--o.indegree===0&&e.push(o)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(r(i)),i.out.forEach(n(i))}return t.filter(i=>!i.merged).map(i=>q(i,["vs","i","barycenter","weight"]))}function Ir(e,t){let r=0,n=0;e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),t.weight&&(r+=t.barycenter*t.weight,n+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=r/n,e.weight=n,e.i=Math.min(t.i,e.i),t.merged=!0}function Cr(e,t,r,n,i){let o={},s=null,l=null,a=i;typeof t=="boolean"?(a=t,o={}):t&&(o=t,s=r??null,l=n??null);let d=Ct(e,w=>Object.hasOwn(w,"barycenter")),u=d.lhs,h=d.rhs.sort((w,g)=>g.i-w.i),c=[],f=0,p=0,b=0;u.sort(Mr(l,s,!!a));for(let[w,g]of Object.entries(o)){let v=u.findIndex(m=>m.vs[0]===w);u.splice(v+1,0,g)}b=ve(c,h,b),u.forEach(w=>{b+=w.vs.length,c.push(w.vs),f+=w.barycenter*w.weight,p+=w.weight,b=ve(c,h,b)});let y={vs:c.flat(1)};return p&&(y.barycenter=f/p,y.weight=p),y}function ve(e,t,r){let n;for(;t.length&&(n=t[t.length-1]).i<=r;)t.pop(),e.push(n.vs),r++;return r}function Mr(e,t,r){return(n,i)=>{if(n.barycenter<i.barycenter)return-1;if(n.barycenter>i.barycenter)return 1;if(e&&(typeof n.vs[0]=="string"||typeof i.vs[0]=="string")){let o=e.node(n.vs[0]),s=e.node(i.vs[0]),l=Ve(t,o,s);if(l!==0)return l}return r?i.i-n.i:n.i-i.i}}function Je(e,t,r,n,i){var o,s,l,a,d,u,h,c,f,p,b;let y=null,w=i;typeof n=="boolean"?(w=n,y=null):n!==void 0&&(y=n);let g=e.children(t),v=e.node(t),m=v?v.borderLeft:void 0,E=v?v.borderRight:void 0,N={};m&&(g=g.filter(O=>O!==m&&O!==E));let L=Nr(e,g);L.forEach(O=>{if(e.children(O.v).length){let{result:I}=Je(e,O.v,r,y,w);N[O.v]=I,Object.hasOwn(I,"barycenter")&&Sr(O,I)}});let _=xr(L,r);Lr(_,N);let M={},S=!1;for(let O=0;O<_.length;O++)for(let I=O+1;I<_.length;I++)if(!(!_[O]||!_[I]||!((o=_[O])!=null&&o.barycenter)||!((s=_[I])!=null&&s.barycenter))&&((l=_[O])==null?void 0:l.barycenter)===_[I].barycenter){let x=(d=(a=_[O])==null?void 0:a.vs[0])!=null?d:"",k=(h=(u=_[I])==null?void 0:u.vs[0])!=null?h:"",C=e.node(x),R=e.node(k);if(C.dummy==="edge"&&R.dummy==="edge"&&((c=C.edgeObj)==null?void 0:c.v)===((f=R.edgeObj)==null?void 0:f.v)&&((p=C.edgeObj)==null?void 0:p.w)===((b=R.edgeObj)==null?void 0:b.w))if(C.edgeLabel.reversed){M[k]=_[O],_.splice(O,1),O--;break}else M[x]=_[I],_.splice(I,1),I--;else S=!0}let j=Cr(_,M,y,e,w);if(m&&E){j.vs=[m,j.vs,E].flat(1);let O=e.predecessors(m);if(O&&O.length){let I=e.node(O[0]),x=e.predecessors(E),k=e.node(x[0]);Object.hasOwn(j,"barycenter")||(j.barycenter=0,j.weight=0),j.barycenter=(j.barycenter*j.weight+I.order+k.order)/(j.weight+2),j.weight+=2}}return Object.defineProperty(j,"result",{value:j,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(j,"usedBias",{value:S,enumerable:!1,configurable:!0,writable:!0}),j}function Lr(e,t){e.forEach(r=>{r.vs=r.vs.flatMap(n=>t[n]?t[n].vs:n)})}function Sr(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function Tr(e,t,r,n){n||(n=e.nodes());let i=Pr(e),o=new T({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(s=>e.node(s));return n.forEach(s=>{let l=e.node(s),a=e.parent(s);if(l.rank===t||l.minRank<=t&&t<=l.maxRank){o.setNode(s),o.setParent(s,a||i);let d=e[r](s);d&&d.forEach(u=>{let h=u.v===s?u.w:u.v,c=o.edge(h,s),f=c!==void 0?c.weight:0;o.setEdge(h,s,{weight:e.edge(u).weight+f})}),Object.hasOwn(l,"minRank")&&o.setNode(s,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]})}}),o}function Pr(e){let t;for(;e.hasNode(t=ne("_root")););return t}function Fr(e,t,r){let n={},i;r.forEach(o=>{let s=e.parent(o),l,a;for(;s;){if(l=e.parent(s),l?(a=n[l],n[l]=s):(a=i,i=s),a&&a!==s){t.setEdge(a,s);return}s=l}})}function Ke(e,t={},r=null){if(typeof t.customOrder=="function"){t.customOrder(e,Ke);return}let n=De(e),i=me(e,A(1,n+1),"inEdges"),o=me(e,A(n-1,-1,-1),"outEdges"),s=_r(e,r);if(we(e,s),t.disableOptimalOrderHeuristic)return;let l=Number.POSITIVE_INFINITY,a,d=t.constraints||[];for(let u=0,h=0;h<4;++u,++h){Rr(u%2?i:o,u%4>=2,d,r),s=G(e);let c=kr(e,s);c<l?(h=0,a=Object.assign({},s),l=c):c===l&&(a=structuredClone(s))}we(e,a)}function me(e,t,r){let n=new Map,i=(o,s)=>{n.has(o)||n.set(o,[]),n.get(o).push(s)};for(let o of e.nodes()){let s=e.node(o);if(typeof s.rank=="number"&&i(s.rank,o),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let l=s.minRank;l<=s.maxRank;l++)l!==s.rank&&i(l,o)}return t.map(function(o){return Tr(e,o,r,n.get(o)||[])})}function Rr(e,t,r,n){let i=!0,o=new T;e.forEach(function(s){r.forEach(u=>o.setEdge(u.left,u.right));let l=s.graph().root,{result:a,usedBias:d}=Je(s,l,o,n,i);t&&d&&(i=!i),a.vs.forEach((u,h)=>s.node(u).order=h),Fr(s,o,a.vs)})}function we(e,t){Object.values(t).forEach(r=>r.forEach((n,i)=>e.node(n).order=i))}function Dr(e,t){let r={};function n(i,o){let s=0,l=0,a=i.length,d=o[o.length-1];return o.forEach((u,h)=>{let c=Vr(e,u),f=c?e.node(c).order:a;(c||u===d)&&(o.slice(l,h+1).forEach(p=>{let b=e.predecessors(p);b&&b.forEach(y=>{let w=e.node(y),g=w.order;(g<s||f<g)&&!(w.dummy&&e.node(p).dummy)&&Qe(r,y,p)})}),l=h+1,s=f)}),o}return t.length&&t.reduce(n),r}function Yr(e,t){let r={};function n(o,s,l,a,d){A(s,l).forEach(u=>{let h=o[u];if(h!==void 0&&e.node(h).dummy){let c=e.predecessors(h);c&&c.forEach(f=>{if(f===void 0)return;let p=e.node(f);p.dummy&&(p.order<a||p.order>d)&&Qe(r,f,h)})}})}function i(o,s){let l=-1,a=-1,d=0;return s.forEach((u,h)=>{if(e.node(u).dummy==="border"){let c=e.predecessors(u);if(c&&c.length){let f=c[0];if(f===void 0)return;a=e.node(f).order,n(s,d,h,l,a),d=h,l=a}}n(s,d,s.length,a,o.length)}),s}return t.length&&t.reduce(i),r}function Vr(e,t){if(e.node(t).dummy){let r=e.predecessors(t);if(r)return r.find(n=>e.node(n).dummy)}}function Qe(e,t,r){if(t>r){let i=t;t=r,r=i}let n=e[t];n||(e[t]=n={}),n[r]=!0}function Ar(e,t,r){if(t>r){let i=t;t=r,r=i}let n=e[t];return n!==void 0&&Object.hasOwn(n,r)}function Gr(e,t,r,n,i){let o={},s={},l={};return t.forEach(a=>{a.forEach((d,u)=>{o[d]=d,s[d]=d,l[d]=u})}),t.forEach(a=>{let d=-1,u=-1,h=!1,c=a,f=a.findIndex(p=>i?.includes(p)||Ee(p,e,i));f>0&&(c=[a[f],...a.slice(0,f),...a.slice(f+1)],h=!0),c.forEach(p=>{var b;let y=n(p);if(y&&y.length){i!=null&&i.includes(p)&&(y=y.filter(v=>Ee(v,e,i)));let w=y.sort((v,m)=>{let E=l[v],N=l[m];return(E!==void 0?E:0)-(N!==void 0?N:0)}),g=(w.length-1)/2;for(let v=Math.floor(g),m=Math.ceil(g);v<=m;++v){let E=w[v];if(E===void 0)continue;let N=l[E];if(N!==void 0&&s[p]===p&&d<N&&l[E]!==u&&!Ar(r,p,E)){let L=o[E];L!==void 0&&(s[E]=p,s[p]=o[p]=L,d=N,h&&(d=-1,u=(b=l[E])!=null?b:-1,h=!1))}}}})}),{root:o,align:s}}function Br(e,t,r,n,i=!1){let o={},s=zr(e,t,r,i),l=i?"borderLeft":"borderRight";function a(f,p){let b=s.nodes().slice(),y={},w=b.pop();for(;w;){if(y[w])f(w);else{y[w]=!0,b.push(w);for(let g of p(w))b.push(g)}w=b.pop()}}function d(f){let p=s.inEdges(f);p?o[f]=p.reduce((b,y)=>{var w;let g=(w=o[y.v])!=null?w:0,v=s.edge(y);return Math.max(b,g+(v!==void 0?v:0))},0):o[f]=0}function u(f){let p=s.outEdges(f),b=Number.POSITIVE_INFINITY;p&&(b=p.reduce((w,g)=>{let v=o[g.w],m=s.edge(g);return Math.min(w,(v!==void 0?v:0)-(m!==void 0?m:0))},Number.POSITIVE_INFINITY));let y=e.node(f);b!==Number.POSITIVE_INFINITY&&y.borderType!==l&&(o[f]=Math.max(o[f]!==void 0?o[f]:0,b))}function h(f){return s.predecessors(f)||[]}function c(f){return s.successors(f)||[]}return a(d,h),a(u,c),Object.keys(n).forEach(f=>{var p;let b=r[f];b!==void 0&&(o[f]=(p=o[b])!=null?p:0)}),o}function zr(e,t,r,n){let i=new T,o=e.graph(),s=Jr(o.nodesep,o.edgesep,n);return t.forEach(l=>{let a;l.forEach(d=>{let u=r[d];if(u!==void 0){if(i.setNode(u),a!==void 0){let h=r[a];if(h!==void 0){let c=i.edge(h,u);i.setEdge(h,u,Math.max(s(e,d,a),c||0))}}a=d}})}),i}function qr(e,t){return Object.values(t).reduce((r,n)=>{let i=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;Object.entries(n).forEach(([l,a])=>{let d=Kr(e,l)/2;i=Math.max(a+d,i),o=Math.min(a-d,o)});let s=i-o;return s<r[0]&&(r=[s,n]),r},[Number.POSITIVE_INFINITY,null])[1]}function $r(e,t){let r=Object.values(t),n=P(Math.min,r),i=P(Math.max,r);["u","d"].forEach(o=>{["l","r"].forEach(s=>{let l=o+s,a=e[l];if(!a||a===t)return;let d=Object.values(a),u=n-P(Math.min,d);s!=="l"&&(u=i-P(Math.max,d)),u&&(e[l]=$(a,h=>h+u))})})}function Xr(e,t=void 0){let r=e.ul;return r?$(r,(n,i)=>{var o,s;if(t){let a=t.toLowerCase(),d=e[a];if(d&&d[i]!==void 0)return d[i]}let l=Object.values(e).map(a=>{let d=a[i];return d!==void 0?d:0}).sort((a,d)=>a-d);return(((o=l[1])!=null?o:0)+((s=l[2])!=null?s:0))/2}):{}}function Wr(e,t){let r=G(e),n=Object.assign(Dr(e,r),Yr(e,r)),i={},o;["u","d"].forEach(l=>{o=l==="u"?r:Object.values(r).reverse(),["l","r"].forEach(a=>{a==="r"&&(o=o.map(h=>Object.values(h).reverse()));let d=Gr(e,o,n,h=>(l==="u"?e.predecessors(h):e.successors(h))||[],t),u=Br(e,o,d.root,d.align,a==="r");a==="r"&&(u=$(u,h=>-h)),i[l+a]=u})});let s=qr(e,i);return $r(i,s),Xr(i,e.graph().align)}function Jr(e,t,r){return(n,i,o)=>{let s=n.node(i),l=n.node(o),a=0,d;if(a+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":d=-s.width/2;break;case"r":d=s.width/2;break}if(d&&(a+=r?d:-d),d=void 0,a+=(s.dummy?t:e)/2,a+=(l.dummy?t:e)/2,a+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":d=l.width/2;break;case"r":d=-l.width/2;break}return d&&(a+=r?d:-d),a}}function Kr(e,t){return e.node(t).width}function Ee(e,t,r){var n;if(!r)return!1;let i=(n=t.node(e))==null?void 0:n.edgeObj;if(!i||t.node(e).edgeLabel.reversed)return!1;let o=r.indexOf(i?.v),s=r.indexOf(i?.w);return o!==-1&&s!==-1&&o===(s+1)%r.length||o===(s-1)%r.length}function Qr(e,t){e=Fe(e),Ur(e),Object.entries(Wr(e,t)).forEach(([r,n])=>e.node(r).x=n)}function Ur(e){let t=G(e),r=e.graph(),n=r.ranksep,i=r.rankalign,o=0;t.forEach(s=>{let l=s.reduce((a,d)=>{var u;let h=(u=e.node(d).height)!=null?u:0;return a>h?a:h},0);s.forEach(a=>{let d=e.node(a);i==="top"?d.y=o+d.height/2:i==="bottom"?d.y=o+l-d.height/2:d.y=o+l/2}),o+=l+n})}var be=new WeakMap;function Hr(e,t={}){return Ue(e,re,t),e}function ye(e,t,r){let n=t;for(;n!==void 0;){let i=e.parent(n);if(i===r)return n;n=i}}function Ue(e,t,r){var n;let i=e.nodes().filter(g=>e.children(g).length),o={};i.forEach(g=>{let v=e.node(g);if(v&&v.rankdir){let m=new T({multigraph:!0,compound:!0});m.setGraph({rankdir:v.rankdir});let E=e.children(g);E.forEach(x=>{let k={...e.node(x)};m.setNode(x,k);let C=e.parent(x);C&&C!==g&&E.includes(C)&&m.setParent(x,C)});let N=new Set;e.edges().forEach(x=>{let k=ye(e,x.v,g),C=ye(e,x.w,g);if(k&&C&&k!==C){let R=`${k}\0${C}`;N.has(R)||(N.add(R),m.setEdge(k,C,{...e.edge(x)}))}}),Ue(m,t,r);let L=Ne(m);_e(L,t,r,null),ke(m,L);let _=1/0,M=1/0,S=-1/0,j=-1/0;m.nodes().forEach(x=>{if(x===g)return;let k=m.node(x);k&&typeof k.x=="number"&&typeof k.y=="number"&&typeof k.width=="number"&&typeof k.height=="number"&&(_=Math.min(_,k.x-k.width/2),S=Math.max(S,k.x+k.width/2),M=Math.min(M,k.y-k.height/2),j=Math.max(j,k.y+k.height/2))}),(!isFinite(_)||!isFinite(M)||!isFinite(S)||!isFinite(j))&&(_=M=0,S=j=0);let O=S-_,I=j-M;o[g]={minX:_,minY:M,maxX:S,maxY:j,width:O,height:I,offsetX:_,offsetY:M},v._dagreClusterSubgraph=m}});let s=[],l=g=>{let v=[],m=(e.children(g)||[]).filter(E=>E!==g);for(;m.length>0;){let E=m.shift();v.push(E),(e.children(E)||[]).filter(N=>N!==E).forEach(N=>m.push(N))}return v},a=new Map;i.forEach(g=>{let v=e.node(g);v&&v.rankdir&&o[g]&&a.set(g,(e.children(g)||[]).filter(m=>m!==g))});let d=new Set([...a.values()].flat()),u=new Map;a.forEach((g,v)=>{d.has(v)||u.set(v,l(v))});let h=new Set([...u.values()].flat()),c=g=>{for(let[v,m]of u)if(m.includes(g))return v;return g},f=[];e.edges().forEach(g=>{(h.has(g.v)||h.has(g.w))&&f.push({edge:g,label:e.edge(g)})});let p=new Map;h.forEach(g=>{let v=e.parent(g);p.set(g,typeof v=="string"?v:void 0)}),u.forEach((g,v)=>{let m=e.node(v),E=[];g.forEach(_=>{let M=e.node(_);M&&(E.push({id:_,node:M,parent:p.get(_)}),e.removeNode(_))});let N=f.filter(({edge:_})=>g.includes(_.v)||g.includes(_.w)),L=o[v];m&&(s.push({clusterId:v,subgraph:m._dagreClusterSubgraph,bounds:L,children:g,removedNodes:E,removedEdges:N}),m.width=L.width,m.height=L.height)});let b=new Set;f.forEach(({edge:g,label:v})=>{let m=c(g.v),E=c(g.w);if(m!==E&&e.hasNode(m)&&e.hasNode(E)){let N=`${m}\0${E}`;b.has(N)||(b.add(N),e.setEdge(m,E,{...v,width:0,height:0}))}});let y=Ne(e),w=_e(y,t,r,(n=be.get(e))!=null?n:null);be.set(e,w),ke(e,y),b.forEach(g=>{let v=g.indexOf("\0"),m=g.slice(0,v),E=g.slice(v+1);e.hasEdge(m,E)&&e.removeEdge(m,E)}),s.forEach(({clusterId:g,subgraph:v,bounds:m,removedNodes:E,removedEdges:N})=>{var L,_;let M=e.node(g),S=(L=M?.x)!=null?L:0,j=(_=M?.y)!=null?_:0,O=(m.minX+m.maxX)/2,I=(m.minY+m.maxY)/2;E.forEach(({id:x,node:k,parent:C})=>{e.setNode(x,k),C!==void 0&&e.setParent(x,C)}),N.forEach(({edge:x,label:k})=>{e.setEdge(x,k)}),v.nodes().forEach(x=>{if(x===g)return;let k=v.node(x),C=e.node(x);C&&k&&typeof k.x=="number"&&typeof k.y=="number"&&(C.x=S+(k.x-O),C.y=j+(k.y-I))}),delete M._dagreClusterSubgraph}),i.forEach(g=>{var v,m;let E=e.node(g),N=o[g];if(E&&E.rankdir&&E._dagreClusterSubgraph&&N){let L=E._dagreClusterSubgraph,_=(v=E.x)!=null?v:0,M=(m=E.y)!=null?m:0,S=(N.minX+N.maxX)/2,j=(N.minY+N.maxY)/2;L.nodes().forEach(O=>{if(O===g)return;let I=L.node(O),x=e.node(O);if(x&&I&&typeof I.x=="number"&&typeof I.y=="number"){let k=I.x-S,C=I.y-j;x.x=_+k,x.y=M+C}}),delete E._dagreClusterSubgraph}})}function _e(e,t,r,n=null){var i,o;let s=r?.useDynamic!==!1,l=s&&(i=n?.graph)!=null?i:null,a=s&&(o=n?.rawNodes)!=null?o:null;t(" makeSpaceForEdgeLabels",()=>ln(e)),t(" removeSelfEdges",()=>vn(e)),t(" acyclic",()=>Gt(e,l)),t(" nestingGraph.run",()=>cr(e)),t(" rank",()=>ir(Fe(e))),t(" injectEdgeLabelProxies",()=>dn(e)),t(" removeEmptyRanks",()=>jt(e)),t(" nestingGraph.cleanup",()=>pr(e)),t(" normalizeRanks",()=>xt(e)),t(" assignRankMinMax",()=>an(e)),t(" removeEdgeLabelProxies",()=>un(e)),t(" normalize.run",()=>$t(e)),t(" parentDummyChains",()=>dr(e)),t(" addBorderSegments",()=>vr(e)),t(" order",()=>Ke(e,r,a)),t(" insertSelfEdges",()=>mn(e)),t(" adjustCoordinateSystem",()=>wr(e)),t(" position",()=>Qr(e,r.corePath)),t(" positionSelfEdges",()=>wn(e));let d=JSON.parse(JSON.stringify(e._nodes));return t(" removeBorderNodes",()=>pn(e)),t(" normalize.undo",()=>Wt(e)),t(" fixupEdgeLabelCoords",()=>fn(e)),t(" undoCoordinateSystem",()=>Er(e)),t(" translateGraph",()=>hn(e)),t(" assignNodeIntersects",()=>cn(e)),t(" reversePoints",()=>gn(e)),t(" acyclic.undo",()=>zt(e)),{graph:e,rawNodes:d}}function ke(e,t){e.nodes().forEach(r=>{let n=e.node(r),i=t.node(r);n&&(n.x=i.x,n.y=i.y,n.order=i.order,n.rank=i.rank,t.children(r).length&&(n.width=i.width,n.height=i.height))}),e.edges().forEach(r=>{let n=e.edge(r),i=t.edge(r);n.points=i.points,Object.hasOwn(i,"x")&&(n.x=i.x,n.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Zr=["nodesep","edgesep","ranksep","marginx","marginy"],en={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},tn=["acyclicer","ranker","rankdir","align","rankalign"],rn=["width","height","rank"],Oe={width:0,height:0},nn=["minlen","weight","width","height","labeloffset"],on={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},sn=["labelpos"];function Ne(e){let t=new T({multigraph:!0,compound:!0}),r=H(e.graph());return t.setGraph(Object.assign({},en,U(r,Zr),q(r,tn))),e.nodes().forEach(n=>{let i=H(e.node(n)),o=U(i,rn);Object.keys(Oe).forEach(l=>{o[l]===void 0&&(o[l]=Oe[l])}),t.setNode(n,o);let s=e.parent(n);s!==void 0&&t.setParent(n,s)}),e.edges().forEach(n=>{let i=H(e.edge(n));t.setEdge(n,Object.assign({},on,U(i,nn),q(i,sn)))}),t}function ln(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(r=>{var n;let i=e.edge(r);i.minlen*=2,((n=i.labelpos)!=null?n:"r").toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?i.width+=i.labeloffset:i.height+=i.labeloffset)})}function dn(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.width&&r.height){let n=e.node(t.v),i={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};Y(e,"edge-proxy",i,"_ep")}})}function an(e){let t=0;e.nodes().forEach(r=>{let n=e.node(r);n.borderTop&&(n.minRank=e.node(n.borderTop).rank,n.maxRank=e.node(n.borderBottom).rank,t=Math.max(t,n.maxRank))}),e.graph().maxRank=t}function un(e){e.nodes().forEach(t=>{let r=e.node(t);if(r.dummy==="edge-proxy"){let n=r;e.edge(n.e).labelRank=r.rank,e.removeNode(t)}})}function hn(e){let t=Number.POSITIVE_INFINITY,r=0,n=Number.POSITIVE_INFINITY,i=0,o=e.graph(),s=o.marginx||0,l=o.marginy||0;function a(d){let u=d.x,h=d.y,c=d.width,f=d.height;t=Math.min(t,u-c/2),r=Math.max(r,u+c/2),n=Math.min(n,h-f/2),i=Math.max(i,h+f/2)}e.nodes().forEach(d=>a(e.node(d))),e.edges().forEach(d=>{let u=e.edge(d);Object.hasOwn(u,"x")&&a(u)}),t-=s,n-=l,e.nodes().forEach(d=>{let u=e.node(d);u.x-=t,u.y-=n}),e.edges().forEach(d=>{let u=e.edge(d);u.points.forEach(h=>{h.x-=t,h.y-=n}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=n)}),o.width=r-t+s,o.height=i-n+l}function cn(e){e.edges().forEach(t=>{if(t.v===t.w)return;let r=e.edge(t),n=e.node(t.v),i=e.node(t.w),o,s;r.points?(o=r.points[0],s=r.points[r.points.length-1]):(r.points=[],o=i,s=n),r.points.unshift(ae(n,o)),r.points.push(ae(i,s))})}function fn(e){e.edges().forEach(t=>{let r=e.edge(t);if(Object.hasOwn(r,"x"))switch((r.labelpos==="l"||r.labelpos==="r")&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset;break}})}function gn(e){e.edges().forEach(t=>{let r=e.edge(t);r.reversed&&r.points.reverse()})}function pn(e){e.nodes().forEach(t=>{if(e.children(t).length){let r=e.node(t),n=e.node(r.borderTop),i=e.node(r.borderBottom),o=e.node(r.borderLeft[r.borderLeft.length-1]),s=e.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(s.x-o.x),r.height=Math.abs(i.y-n.y),r.x=o.x+r.width/2,r.y=n.y+r.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function vn(e){e.edges().forEach(t=>{if(t.v===t.w){let r=e.node(t.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function mn(e){G(e).forEach(t=>{let r=0;t.forEach((n,i)=>{let o=e.node(n);typeof o.rank!="number"&&(o.rank=0),o.order=i+r,(o.selfEdges||[]).forEach(s=>{Y(e,"selfedge",{width:s.label.width,height:s.label.height,rank:o.rank,order:i+ ++r,e:s.e,edgeLabel:s.label},"_se"),(!Array.isArray(s.label.points)||s.label.points.length!==7)&&(s.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete o.selfEdges})})}function wn(e){e.nodes().forEach(t=>{let r=e.node(t),n=i=>typeof i=="number"&&isFinite(i);if(r.dummy==="selfedge"){let i=r,o=e.node(i.e.v),s=n(o?.x)?o.x:0,l=n(o?.y)?o.y:0,a=n(o?.width)?o.width:0,d=n(o?.height)?o.height:0,u=n(r.x)?r.x:s,h=n(r.y)?r.y:l,c=a/2,f=d/2;i.edgeLabel.points=[{x:u+c,y:h-f},{x:u+c,y:h-f},{x:u,y:h},{x:u-c,y:h+f},{x:u-c,y:h+f},{x:u,y:h},{x:u,y:h}],i.edgeLabel.x=u,i.edgeLabel.y=h,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else r&&Array.isArray(r.selfEdges)&&r.selfEdges.forEach(i=>{if(!Array.isArray(i.label.points)||i.label.points.length!==7){let o=n(r.x)?r.x:0,s=n(r.y)?r.y:0,l=n(r.width)?r.width:0,a=n(r.height)?r.height:0,d=l/2,u=a/2;i.label.points=[{x:o+d,y:s-u},{x:o+d,y:s-u},{x:o,y:s},{x:o-d,y:s+u},{x:o-d,y:s+u},{x:o,y:s},{x:o,y:s}]}})})}function U(e,t){return $(q(e,t),Number)}function H(e){let t={};return e&&Object.entries(e).forEach(([r,n])=>{typeof r=="string"&&(r=r.toLowerCase()),t[r]=n}),t}function En(e){let t=G(e),r=new T({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(n=>{r.setNode(n,{label:n}),r.setParent(n,"layer"+e.node(n).rank)}),e.edges().forEach(n=>r.setEdge(n.v,n.w,{},n.name)),t.forEach((n,i)=>{let o="layer"+i;r.setNode(o,{rank:"same"}),n.reduce((s,l)=>(r.setEdge(s,l,{style:"invis"}),l))}),r}var yn={time:Ye,notime:re},bn={graphlib:je,version:St,layout:Hr,debug:En,util:{time:Ye,notime:re}},_n=bn;export{T as Graph,En as debug,_n as default,je as graphlib,Hr as layout,yn as util,St as version};
|
|
2
|
+
/*! Bundled license information:
|
|
3
|
+
|
|
4
|
+
@dagrejs/dagre/dist/dagre.esm.js:
|
|
5
|
+
(*! For license information please see dagre.esm.js.LEGAL.txt *)
|
|
6
|
+
*/
|