@dagrejs/dagre 2.0.4 → 3.1.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/dist/dagre.cjs.js +1 -1
- package/dist/dagre.cjs.js.map +4 -4
- package/dist/dagre.d.ts +1 -0
- package/dist/dagre.esm.js +1 -1
- package/dist/dagre.esm.js.map +4 -4
- package/dist/dagre.js +3049 -2176
- package/dist/dagre.js.map +4 -4
- package/dist/dagre.min.js +1 -1
- package/dist/dagre.min.js.map +4 -4
- package/dist/types/index.d.ts +26 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/acyclic.d.ts +6 -0
- package/dist/types/lib/acyclic.d.ts.map +1 -0
- package/dist/types/lib/add-border-segments.d.ts +4 -0
- package/dist/types/lib/add-border-segments.d.ts.map +1 -0
- package/dist/types/lib/coordinate-system.d.ts +26 -0
- package/dist/types/lib/coordinate-system.d.ts.map +1 -0
- package/dist/types/lib/data/list.d.ts +14 -0
- package/dist/types/lib/data/list.d.ts.map +1 -0
- package/dist/types/lib/debug.d.ts +3 -0
- package/dist/types/lib/debug.d.ts.map +1 -0
- package/dist/types/lib/graph-lib.d.ts +3 -0
- package/dist/types/lib/graph-lib.d.ts.map +1 -0
- package/dist/types/lib/greedy-fas.d.ts +4 -0
- package/dist/types/lib/greedy-fas.d.ts.map +1 -0
- package/dist/types/lib/layout.d.ts +4 -0
- package/dist/types/lib/layout.d.ts.map +1 -0
- package/dist/types/lib/nesting-graph.d.ts +5 -0
- package/dist/types/lib/nesting-graph.d.ts.map +1 -0
- package/dist/types/lib/normalize.d.ts +5 -0
- package/dist/types/lib/normalize.d.ts.map +1 -0
- package/dist/types/lib/order/add-subgraph-constraints.d.ts +3 -0
- package/dist/types/lib/order/add-subgraph-constraints.d.ts.map +1 -0
- package/dist/types/lib/order/barycenter.d.ts +9 -0
- package/dist/types/lib/order/barycenter.d.ts.map +1 -0
- package/dist/types/lib/order/build-layer-graph.d.ts +3 -0
- package/dist/types/lib/order/build-layer-graph.d.ts.map +1 -0
- package/dist/types/lib/order/cross-count.d.ts +3 -0
- package/dist/types/lib/order/cross-count.d.ts.map +1 -0
- package/dist/types/lib/order/index.d.ts +3 -0
- package/dist/types/lib/order/index.d.ts.map +1 -0
- package/dist/types/lib/order/init-order.d.ts +3 -0
- package/dist/types/lib/order/init-order.d.ts.map +1 -0
- package/dist/types/lib/order/resolve-conflicts.d.ts +15 -0
- package/dist/types/lib/order/resolve-conflicts.d.ts.map +1 -0
- package/dist/types/lib/order/sort-subgraph.d.ts +12 -0
- package/dist/types/lib/order/sort-subgraph.d.ts.map +1 -0
- package/dist/types/lib/order/sort.d.ts +16 -0
- package/dist/types/lib/order/sort.d.ts.map +1 -0
- package/dist/types/lib/parent-dummy-chains.d.ts +4 -0
- package/dist/types/lib/parent-dummy-chains.d.ts.map +1 -0
- package/dist/types/lib/position/bk.d.ts +37 -0
- package/dist/types/lib/position/bk.d.ts.map +1 -0
- package/dist/types/lib/position/index.d.ts +5 -0
- package/dist/types/lib/position/index.d.ts.map +1 -0
- package/dist/types/lib/rank/feasible-tree.d.ts +14 -0
- package/dist/types/lib/rank/feasible-tree.d.ts.map +1 -0
- package/dist/types/lib/rank/index.d.ts +4 -0
- package/dist/types/lib/rank/index.d.ts.map +1 -0
- package/dist/types/lib/rank/network-simplex.d.ts +13 -0
- package/dist/types/lib/rank/network-simplex.d.ts.map +1 -0
- package/dist/types/lib/rank/util.d.ts +5 -0
- package/dist/types/lib/rank/util.d.ts.map +1 -0
- package/dist/types/lib/type.d.ts +2 -0
- package/dist/types/lib/type.d.ts.map +1 -0
- package/dist/types/lib/types.d.ts +142 -0
- package/dist/types/lib/types.d.ts.map +1 -0
- package/dist/types/lib/util.d.ts +40 -0
- package/dist/types/lib/util.d.ts.map +1 -0
- package/dist/types/lib/version.d.ts +2 -0
- package/dist/types/lib/version.d.ts.map +1 -0
- package/package.json +32 -11
package/dist/dagre.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var dagre=(()=>{var g=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var p=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Y=p((ai,A)=>{var L=class{constructor(){let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,r=t._prev;if(r!==t)return D(r),r}enqueue(t){let r=this._sentinel;t._prev&&t._next&&D(t),t._next=r._next,r._next._prev=t,r._next=t,t._prev=r}toString(){let t=[],r=this._sentinel,n=r._prev;for(;n!==r;)t.push(JSON.stringify(n,Ot)),n=n._prev;return"["+t.join(", ")+"]"}};function D(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Ot(e,t){if(e!=="_next"&&e!=="_prev")return t}A.exports=L});var z=p((li,W)=>{var It=g("@dagrejs/graphlib").Graph,qt=Y();W.exports=Rt;var Lt=()=>1;function Rt(e,t){if(e.nodeCount()<=1)return[];let r=Mt(e,t||Lt);return Ct(r.graph,r.buckets,r.zeroIdx).flatMap(i=>e.outEdges(i.v,i.w))}function Ct(e,t,r){let n=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)R(e,t,r,o);for(;o=i.dequeue();)R(e,t,r,o);if(e.nodeCount()){for(let l=t.length-2;l>0;--l)if(o=t[l].dequeue(),o){n=n.concat(R(e,t,r,o,!0));break}}}return n}function R(e,t,r,n,i){let a=i?[]:void 0;return e.inEdges(n.v).forEach(o=>{let l=e.edge(o),s=e.node(o.v);i&&a.push({v:o.v,w:o.w}),s.out-=l,C(t,r,s)}),e.outEdges(n.v).forEach(o=>{let l=e.edge(o),s=o.w,d=e.node(s);d.in-=l,C(t,r,d)}),e.removeNode(n.v),a}function Mt(e,t){let r=new It,n=0,i=0;e.nodes().forEach(l=>{r.setNode(l,{v:l,in:0,out:0})}),e.edges().forEach(l=>{let s=r.edge(l.v,l.w)||0,d=t(l),u=s+d;r.setEdge(l.v,l.w,u),i=Math.max(i,r.node(l.v).out+=d),n=Math.max(n,r.node(l.w).in+=d)});let a=Tt(i+n+3).map(()=>new qt),o=n+1;return r.nodes().forEach(l=>{C(a,o,r.node(l))}),{graph:r,buckets:a,zeroIdx:o}}function C(e,t,r){r.out?r.in?e[r.out-r.in+t].enqueue(r):e[e.length-1].enqueue(r):e[0].enqueue(r)}function Tt(e){let t=[];for(let r=0;r<e;r++)t.push(r);return t}});var m=p((si,Z)=>{"use strict";var X=g("@dagrejs/graphlib").Graph;Z.exports={addBorderNode:Dt,addDummyNode:H,applyWithChunking:N,asNonCompoundGraph:_t,buildLayerMatrix:Vt,intersectRect:Gt,mapValues:Ut,maxRank:J,normalizeRanks:Ft,notime:zt,partition:Yt,pick:Ht,predecessorWeights:Pt,range:Q,removeEmptyRanks:Bt,simplify:jt,successorWeights:St,time:Wt,uniqueId:K,zipObject:M};function H(e,t,r,n){for(var i=n;e.hasNode(i);)i=K(n);return r.dummy=t,e.setNode(i,r),i}function jt(e){let t=new X().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 _t(e){let t=new X({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 St(e){let t=e.nodes().map(r=>{let n={};return e.outEdges(r).forEach(i=>{n[i.w]=(n[i.w]||0)+e.edge(i).weight}),n});return M(e.nodes(),t)}function Pt(e){let t=e.nodes().map(r=>{let n={};return e.inEdges(r).forEach(i=>{n[i.v]=(n[i.v]||0)+e.edge(i).weight}),n});return M(e.nodes(),t)}function Gt(e,t){let r=e.x,n=e.y,i=t.x-r,a=t.y-n,o=e.width/2,l=e.height/2;if(!i&&!a)throw new Error("Not possible to find intersection inside of the rectangle");let s,d;return Math.abs(a)*o>Math.abs(i)*l?(a<0&&(l=-l),s=l*i/a,d=l):(i<0&&(o=-o),s=o,d=o*a/i),{x:r+s,y:n+d}}function Vt(e){let t=Q(J(e)+1).map(()=>[]);return e.nodes().forEach(r=>{let n=e.node(r),i=n.rank;i!==void 0&&(t[i][n.order]=r)}),t}function Ft(e){let t=e.nodes().map(n=>{let i=e.node(n).rank;return i===void 0?Number.MAX_VALUE:i}),r=N(Math.min,t);e.nodes().forEach(n=>{let i=e.node(n);Object.hasOwn(i,"rank")&&(i.rank-=r)})}function Bt(e){let t=e.nodes().map(o=>e.node(o).rank).filter(o=>o!==void 0),r=N(Math.min,t),n=[];e.nodes().forEach(o=>{let l=e.node(o).rank-r;n[l]||(n[l]=[]),n[l].push(o)});let i=0,a=e.graph().nodeRankFactor;Array.from(n).forEach((o,l)=>{o===void 0&&l%a!==0?--i:o!==void 0&&i&&o.forEach(s=>e.node(s).rank+=i)})}function Dt(e,t,r,n){let i={width:0,height:0};return arguments.length>=4&&(i.rank=r,i.order=n),H(e,"border",i,t)}function At(e,t=U){let r=[];for(let n=0;n<e.length;n+=t){let i=e.slice(n,n+t);r.push(i)}return r}var U=65535;function N(e,t){if(t.length>U){let r=At(t);return e.apply(null,r.map(n=>e.apply(null,n)))}else return e.apply(null,t)}function J(e){let r=e.nodes().map(n=>{let i=e.node(n).rank;return i===void 0?Number.MIN_VALUE:i});return N(Math.max,r)}function Yt(e,t){let r={lhs:[],rhs:[]};return e.forEach(n=>{t(n)?r.lhs.push(n):r.rhs.push(n)}),r}function Wt(e,t){let r=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-r)+"ms")}}function zt(e,t){return t()}var Xt=0;function K(e){var t=++Xt;return e+(""+t)}function Q(e,t,r=1){t==null&&(t=e,e=0);let n=a=>a<t;r<0&&(n=a=>t<a);let i=[];for(let a=e;n(a);a+=r)i.push(a);return i}function Ht(e,t){let r={};for(let n of t)e[n]!==void 0&&(r[n]=e[n]);return r}function Ut(e,t){let r=t;return typeof t=="string"&&(r=n=>n[t]),Object.entries(e).reduce((n,[i,a])=>(n[i]=r(a,i),n),{})}function M(e,t){return e.reduce((r,n,i)=>(r[n]=t[i],r),{})}});var ee=p((di,$)=>{"use strict";var Jt=z(),Kt=m().uniqueId;$.exports={run:Qt,undo:$t};function Qt(e){(e.graph().acyclicer==="greedy"?Jt(e,r(e)):Zt(e)).forEach(n=>{let i=e.edge(n);e.removeEdge(n),i.forwardName=n.name,i.reversed=!0,e.setEdge(n.w,n.v,i,Kt("rev"))});function r(n){return i=>n.edge(i).weight}}function Zt(e){let t=[],r={},n={};function i(a){Object.hasOwn(n,a)||(n[a]=!0,r[a]=!0,e.outEdges(a).forEach(o=>{Object.hasOwn(r,o.w)?t.push(o):i(o.w)}),delete r[a])}return e.nodes().forEach(i),t}function $t(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)}})}});var re=p((ui,te)=>{"use strict";var er=m();te.exports={run:tr,undo:nr};function tr(e){e.graph().dummyChains=[],e.edges().forEach(t=>rr(e,t))}function rr(e,t){let r=t.v,n=e.node(r).rank,i=t.w,a=e.node(i).rank,o=t.name,l=e.edge(t),s=l.labelRank;if(a===n+1)return;e.removeEdge(t);let d,u,h;for(h=0,++n;n<a;++h,++n)l.points=[],u={width:0,height:0,edgeLabel:l,edgeObj:t,rank:n},d=er.addDummyNode(e,"edge",u,"_d"),n===s&&(u.width=l.width,u.height=l.height,u.dummy="edge-label",u.labelpos=l.labelpos),e.setEdge(r,d,{weight:l.weight},o),h===0&&e.graph().dummyChains.push(d),r=d;e.setEdge(r,i,{weight:l.weight},o)}function nr(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)})}});var v=p((hi,ne)=>{"use strict";var{applyWithChunking:ir}=m();ne.exports={longestPath:or,slack:ar};function or(e){var t={};function r(n){var i=e.node(n);if(Object.hasOwn(t,n))return i.rank;t[n]=!0;let a=e.outEdges(n).map(l=>l==null?Number.POSITIVE_INFINITY:r(l.w)-e.edge(l).minlen);var o=ir(Math.min,a);return o===Number.POSITIVE_INFINITY&&(o=0),i.rank=o}e.sources().forEach(r)}function ar(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}});var T=p((fi,ie)=>{"use strict";var lr=g("@dagrejs/graphlib").Graph,O=v().slack;ie.exports=sr;function sr(e){var t=new lr({directed:!1}),r=e.nodes()[0],n=e.nodeCount();t.setNode(r,{});for(var i,a;dr(t,e)<n;)i=ur(t,e),a=t.hasNode(i.v)?O(e,i):-O(e,i),hr(t,e,a);return t}function dr(e,t){function r(n){t.nodeEdges(n).forEach(i=>{var a=i.v,o=n===a?i.w:a;!e.hasNode(o)&&!O(t,i)&&(e.setNode(o,{}),e.setEdge(n,o,{}),r(o))})}return e.nodes().forEach(r),e.nodeCount()}function ur(e,t){return t.edges().reduce((n,i)=>{let a=Number.POSITIVE_INFINITY;return e.hasNode(i.v)!==e.hasNode(i.w)&&(a=O(t,i)),a<n[0]?[a,i]:n},[Number.POSITIVE_INFINITY,null])[1]}function hr(e,t,r){e.nodes().forEach(n=>t.node(n).rank+=r)}});var ce=p((ci,fe)=>{"use strict";var fr=T(),oe=v().slack,cr=v().longestPath,pr=g("@dagrejs/graphlib").alg.preorder,mr=g("@dagrejs/graphlib").alg.postorder,br=m().simplify;fe.exports=y;y.initLowLimValues=_;y.initCutValues=j;y.calcCutValue=le;y.leaveEdge=de;y.enterEdge=ue;y.exchangeEdges=he;function y(e){e=br(e),cr(e);var t=fr(e);_(t),j(t,e);for(var r,n;r=de(t);)n=ue(t,e,r),he(t,e,r,n)}function j(e,t){var r=mr(e,e.nodes());r=r.slice(0,r.length-1),r.forEach(n=>wr(e,t,n))}function wr(e,t,r){var n=e.node(r),i=n.parent;e.edge(r,i).cutvalue=le(e,t,r)}function le(e,t,r){var n=e.node(r),i=n.parent,a=!0,o=t.edge(r,i),l=0;return o||(a=!1,o=t.edge(i,r)),l=o.weight,t.nodeEdges(r).forEach(s=>{var d=s.v===r,u=d?s.w:s.v;if(u!==i){var h=d===a,f=t.edge(s).weight;if(l+=h?f:-f,gr(e,r,u)){var c=e.edge(r,u).cutvalue;l+=h?-c:c}}}),l}function _(e,t){arguments.length<2&&(t=e.nodes()[0]),se(e,{},1,t)}function se(e,t,r,n,i){var a=r,o=e.node(n);return t[n]=!0,e.neighbors(n).forEach(l=>{Object.hasOwn(t,l)||(r=se(e,t,r,l,n))}),o.low=a,o.lim=r++,i?o.parent=i:delete o.parent,r}function de(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function ue(e,t,r){var n=r.v,i=r.w;t.hasEdge(n,i)||(n=r.w,i=r.v);var a=e.node(n),o=e.node(i),l=a,s=!1;a.lim>o.lim&&(l=o,s=!0);var d=t.edges().filter(u=>s===ae(e,e.node(u.v),l)&&s!==ae(e,e.node(u.w),l));return d.reduce((u,h)=>oe(t,h)<oe(t,u)?h:u)}function he(e,t,r,n){var i=r.v,a=r.w;e.removeEdge(i,a),e.setEdge(n.v,n.w,{}),_(e),j(e,t),Er(e,t)}function Er(e,t){var r=e.nodes().find(i=>!t.node(i).parent),n=pr(e,r);n=n.slice(1),n.forEach(i=>{var a=e.node(i).parent,o=t.edge(i,a),l=!1;o||(o=t.edge(a,i),l=!0),t.node(i).rank=t.node(a).rank+(l?o.minlen:-o.minlen)})}function gr(e,t,r){return e.hasEdge(t,r)}function ae(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}});var we=p((pi,be)=>{"use strict";var kr=v(),me=kr.longestPath,xr=T(),yr=ce();be.exports=vr;function vr(e){var t=e.graph().ranker;if(t instanceof Function)return t(e);switch(e.graph().ranker){case"network-simplex":pe(e);break;case"tight-tree":Or(e);break;case"longest-path":Nr(e);break;case"none":break;default:pe(e)}}var Nr=me;function Or(e){me(e),xr(e)}function pe(e){yr(e)}});var ge=p((mi,Ee)=>{Ee.exports=Ir;function Ir(e){let t=Lr(e);e.graph().dummyChains.forEach(r=>{let n=e.node(r),i=n.edgeObj,a=qr(e,t,i.v,i.w),o=a.path,l=a.lca,s=0,d=o[s],u=!0;for(;r!==i.w;){if(n=e.node(r),u){for(;(d=o[s])!==l&&e.node(d).maxRank<n.rank;)s++;d===l&&(u=!1)}if(!u){for(;s<o.length-1&&e.node(d=o[s+1]).minRank<=n.rank;)s++;d=o[s]}e.setParent(r,d),r=e.successors(r)[0]}})}function qr(e,t,r,n){let i=[],a=[],o=Math.min(t[r].low,t[n].low),l=Math.max(t[r].lim,t[n].lim),s,d;s=r;do s=e.parent(s),i.push(s);while(s&&(t[s].low>o||l>t[s].lim));for(d=s,s=n;(s=e.parent(s))!==d;)a.push(s);return{path:i.concat(a.reverse()),lca:d}}function Lr(e){let t={},r=0;function n(i){let a=r;e.children(i).forEach(n),t[i]={low:a,lim:r++}}return e.children().forEach(n),t}});var ye=p((bi,xe)=>{var I=m();xe.exports={run:Rr,cleanup:Tr};function Rr(e){let t=I.addDummyNode(e,"root",{},"_root"),r=Cr(e),n=Object.values(r),i=I.applyWithChunking(Math.max,n)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=a);let o=Mr(e)+1;e.children().forEach(l=>ke(e,t,a,o,i,r,l)),e.graph().nodeRankFactor=a}function ke(e,t,r,n,i,a,o){let l=e.children(o);if(!l.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:r});return}let s=I.addBorderNode(e,"_bt"),d=I.addBorderNode(e,"_bb"),u=e.node(o);e.setParent(s,o),u.borderTop=s,e.setParent(d,o),u.borderBottom=d,l.forEach(h=>{ke(e,t,r,n,i,a,h);let f=e.node(h),c=f.borderTop?f.borderTop:h,b=f.borderBottom?f.borderBottom:h,w=f.borderTop?n:2*n,x=c!==b?1:i-a[o]+1;e.setEdge(s,c,{weight:w,minlen:x,nestingEdge:!0}),e.setEdge(b,d,{weight:w,minlen:x,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,s,{weight:0,minlen:i+a[o]})}function Cr(e){var t={};function r(n,i){var a=e.children(n);a&&a.length&&a.forEach(o=>r(o,i+1)),t[n]=i}return e.children().forEach(n=>r(n,1)),t}function Mr(e){return e.edges().reduce((t,r)=>t+e.edge(r).weight,0)}function Tr(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(r=>{var n=e.edge(r);n.nestingEdge&&e.removeEdge(r)})}});var Oe=p((wi,Ne)=>{var jr=m();Ne.exports=_r;function _r(e){function t(r){let n=e.children(r),i=e.node(r);if(n.length&&n.forEach(t),Object.hasOwn(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(let a=i.minRank,o=i.maxRank+1;a<o;++a)ve(e,"borderLeft","_bl",r,i,a),ve(e,"borderRight","_br",r,i,a)}}e.children().forEach(t)}function ve(e,t,r,n,i,a){let o={width:0,height:0,rank:a,borderType:t},l=i[t][a-1],s=jr.addDummyNode(e,"border",o,r);i[t][a]=s,e.setParent(s,n),l&&e.setEdge(l,s,{weight:1})}});var Re=p((Ei,Le)=>{"use strict";Le.exports={adjust:Sr,undo:Pr};function Sr(e){let t=e.graph().rankdir.toLowerCase();(t==="lr"||t==="rl")&&qe(e)}function Pr(e){let t=e.graph().rankdir.toLowerCase();(t==="bt"||t==="rl")&&Gr(e),(t==="lr"||t==="rl")&&(Vr(e),qe(e))}function qe(e){e.nodes().forEach(t=>Ie(e.node(t))),e.edges().forEach(t=>Ie(e.edge(t)))}function Ie(e){let t=e.width;e.width=e.height,e.height=t}function Gr(e){e.nodes().forEach(t=>S(e.node(t))),e.edges().forEach(t=>{let r=e.edge(t);r.points.forEach(S),Object.hasOwn(r,"y")&&S(r)})}function S(e){e.y=-e.y}function Vr(e){e.nodes().forEach(t=>P(e.node(t))),e.edges().forEach(t=>{let r=e.edge(t);r.points.forEach(P),Object.hasOwn(r,"x")&&P(r)})}function P(e){let t=e.x;e.x=e.y,e.y=t}});var Te=p((gi,Me)=>{"use strict";var Ce=m();Me.exports=Fr;function Fr(e){let t={},r=e.nodes().filter(s=>!e.children(s).length),n=r.map(s=>e.node(s).rank),i=Ce.applyWithChunking(Math.max,n),a=Ce.range(i+1).map(()=>[]);function o(s){if(t[s])return;t[s]=!0;let d=e.node(s);a[d.rank].push(s),e.successors(s).forEach(o)}return r.sort((s,d)=>e.node(s).rank-e.node(d).rank).forEach(o),a}});var _e=p((ki,je)=>{"use strict";var Br=m().zipObject;je.exports=Dr;function Dr(e,t){let r=0;for(let n=1;n<t.length;++n)r+=Ar(e,t[n-1],t[n]);return r}function Ar(e,t,r){let n=Br(r,r.map((d,u)=>u)),i=t.flatMap(d=>e.outEdges(d).map(u=>({pos:n[u.w],weight:e.edge(u).weight})).sort((u,h)=>u.pos-h.pos)),a=1;for(;a<r.length;)a<<=1;let o=2*a-1;a-=1;let l=new Array(o).fill(0),s=0;return i.forEach(d=>{let u=d.pos+a;l[u]+=d.weight;let h=0;for(;u>0;)u%2&&(h+=l[u+1]),u=u-1>>1,l[u]+=d.weight;s+=d.weight*h}),s}});var Pe=p((xi,Se)=>{Se.exports=Yr;function Yr(e,t=[]){return t.map(r=>{let n=e.inEdges(r);if(n.length){let i=n.reduce((a,o)=>{let l=e.edge(o),s=e.node(o.v);return{sum:a.sum+l.weight*s.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:r}})}});var Ve=p((yi,Ge)=>{"use strict";var Wr=m();Ge.exports=zr;function zr(e,t){let r={};e.forEach((i,a)=>{let o=r[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:a};i.barycenter!==void 0&&(o.barycenter=i.barycenter,o.weight=i.weight)}),t.edges().forEach(i=>{let a=r[i.v],o=r[i.w];a!==void 0&&o!==void 0&&(o.indegree++,a.out.push(r[i.w]))});let n=Object.values(r).filter(i=>!i.indegree);return Xr(n)}function Xr(e){let t=[];function r(i){return a=>{a.merged||(a.barycenter===void 0||i.barycenter===void 0||a.barycenter>=i.barycenter)&&Hr(i,a)}}function n(i){return a=>{a.in.push(i),--a.indegree===0&&e.push(a)}}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=>Wr.pick(i,["vs","i","barycenter","weight"]))}function Hr(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}});var De=p((vi,Be)=>{var Ur=m();Be.exports=Jr;function Jr(e,t){let r=Ur.partition(e,u=>Object.hasOwn(u,"barycenter")),n=r.lhs,i=r.rhs.sort((u,h)=>h.i-u.i),a=[],o=0,l=0,s=0;n.sort(Kr(!!t)),s=Fe(a,i,s),n.forEach(u=>{s+=u.vs.length,a.push(u.vs),o+=u.barycenter*u.weight,l+=u.weight,s=Fe(a,i,s)});let d={vs:a.flat(!0)};return l&&(d.barycenter=o/l,d.weight=l),d}function Fe(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 Kr(e){return(t,r)=>t.barycenter<r.barycenter?-1:t.barycenter>r.barycenter?1:e?r.i-t.i:t.i-r.i}});var We=p((Ni,Ye)=>{var Qr=Pe(),Zr=Ve(),$r=De();Ye.exports=Ae;function Ae(e,t,r,n){let i=e.children(t),a=e.node(t),o=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,s={};o&&(i=i.filter(f=>f!==o&&f!==l));let d=Qr(e,i);d.forEach(f=>{if(e.children(f.v).length){let c=Ae(e,f.v,r,n);s[f.v]=c,Object.hasOwn(c,"barycenter")&&tn(f,c)}});let u=Zr(d,r);en(u,s);let h=$r(u,n);if(o&&(h.vs=[o,h.vs,l].flat(!0),e.predecessors(o).length)){let f=e.node(e.predecessors(o)[0]),c=e.node(e.predecessors(l)[0]);Object.hasOwn(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+f.order+c.order)/(h.weight+2),h.weight+=2}return h}function en(e,t){e.forEach(r=>{r.vs=r.vs.flatMap(n=>t[n]?t[n].vs:n)})}function tn(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)}});var Xe=p((Oi,ze)=>{var rn=g("@dagrejs/graphlib").Graph,nn=m();ze.exports=on;function on(e,t,r,n){n||(n=e.nodes());let i=an(e),a=new rn({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(o=>e.node(o));return n.forEach(o=>{let l=e.node(o),s=e.parent(o);(l.rank===t||l.minRank<=t&&t<=l.maxRank)&&(a.setNode(o),a.setParent(o,s||i),e[r](o).forEach(d=>{let u=d.v===o?d.w:d.v,h=a.edge(u,o),f=h!==void 0?h.weight:0;a.setEdge(u,o,{weight:e.edge(d).weight+f})}),Object.hasOwn(l,"minRank")&&a.setNode(o,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]}))}),a}function an(e){for(var t;e.hasNode(t=nn.uniqueId("_root")););return t}});var Ue=p((Ii,He)=>{He.exports=ln;function ln(e,t,r){let n={},i;r.forEach(a=>{let o=e.parent(a),l,s;for(;o;){if(l=e.parent(o),l?(s=n[l],n[l]=o):(s=i,i=o),s&&s!==o){t.setEdge(s,o);return}o=l}})}});var $e=p((qi,Ze)=>{"use strict";var sn=Te(),dn=_e(),un=We(),hn=Xe(),fn=Ue(),cn=g("@dagrejs/graphlib").Graph,q=m();Ze.exports=Qe;function Qe(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,Qe);return}let r=q.maxRank(e),n=Je(e,q.range(1,r+1),"inEdges"),i=Je(e,q.range(r-1,-1,-1),"outEdges"),a=sn(e);if(Ke(e,a),t.disableOptimalOrderHeuristic)return;let o=Number.POSITIVE_INFINITY,l,s=t.constraints||[];for(let d=0,u=0;u<4;++d,++u){pn(d%2?n:i,d%4>=2,s),a=q.buildLayerMatrix(e);let h=dn(e,a);h<o?(u=0,l=Object.assign({},a),o=h):h===o&&(l=structuredClone(a))}Ke(e,l)}function Je(e,t,r){let n=new Map,i=(a,o)=>{n.has(a)||n.set(a,[]),n.get(a).push(o)};for(let a of e.nodes()){let o=e.node(a);if(typeof o.rank=="number"&&i(o.rank,a),typeof o.minRank=="number"&&typeof o.maxRank=="number")for(let l=o.minRank;l<=o.maxRank;l++)l!==o.rank&&i(l,a)}return t.map(function(a){return hn(e,a,r,n.get(a)||[])})}function pn(e,t,r){let n=new cn;e.forEach(function(i){r.forEach(l=>n.setEdge(l.left,l.right));let a=i.graph().root,o=un(i,a,n,t);o.vs.forEach((l,s)=>i.node(l).order=s),fn(i,n,o.vs)})}function Ke(e,t){Object.values(t).forEach(r=>r.forEach((n,i)=>e.node(n).order=i))}});var dt=p((Li,st)=>{"use strict";var mn=g("@dagrejs/graphlib").Graph,k=m();st.exports={positionX:En,findType1Conflicts:et,findType2Conflicts:tt,addConflict:G,hasConflict:rt,verticalAlignment:nt,horizontalCompaction:it,alignCoordinates:at,findSmallestWidthAlignment:ot,balance:lt};function et(e,t){let r={};function n(i,a){let o=0,l=0,s=i.length,d=a[a.length-1];return a.forEach((u,h)=>{let f=bn(e,u),c=f?e.node(f).order:s;(f||u===d)&&(a.slice(l,h+1).forEach(b=>{e.predecessors(b).forEach(w=>{let x=e.node(w),B=x.order;(B<o||c<B)&&!(x.dummy&&e.node(b).dummy)&&G(r,w,b)})}),l=h+1,o=c)}),a}return t.length&&t.reduce(n),r}function tt(e,t){let r={};function n(a,o,l,s,d){let u;k.range(o,l).forEach(h=>{u=a[h],e.node(u).dummy&&e.predecessors(u).forEach(f=>{let c=e.node(f);c.dummy&&(c.order<s||c.order>d)&&G(r,f,u)})})}function i(a,o){let l=-1,s,d=0;return o.forEach((u,h)=>{if(e.node(u).dummy==="border"){let f=e.predecessors(u);f.length&&(s=e.node(f[0]).order,n(o,d,h,l,s),d=h,l=s)}n(o,d,o.length,s,a.length)}),o}return t.length&&t.reduce(i),r}function bn(e,t){if(e.node(t).dummy)return e.predecessors(t).find(r=>e.node(r).dummy)}function G(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 rt(e,t,r){if(t>r){let n=t;t=r,r=n}return!!e[t]&&Object.hasOwn(e[t],r)}function nt(e,t,r,n){let i={},a={},o={};return t.forEach(l=>{l.forEach((s,d)=>{i[s]=s,a[s]=s,o[s]=d})}),t.forEach(l=>{let s=-1;l.forEach(d=>{let u=n(d);if(u.length){u=u.sort((f,c)=>o[f]-o[c]);let h=(u.length-1)/2;for(let f=Math.floor(h),c=Math.ceil(h);f<=c;++f){let b=u[f];a[d]===d&&s<o[b]&&!rt(r,d,b)&&(a[b]=d,a[d]=i[d]=i[b],s=o[b])}}})}),{root:i,align:a}}function it(e,t,r,n,i){let a={},o=wn(e,t,r,i),l=i?"borderLeft":"borderRight";function s(h,f){let c=o.nodes().slice(),b={},w=c.pop();for(;w;){if(b[w])h(w);else{b[w]=!0,c.push(w);for(let x of f(w))c.push(x)}w=c.pop()}}function d(h){a[h]=o.inEdges(h).reduce((f,c)=>Math.max(f,a[c.v]+o.edge(c)),0)}function u(h){let f=o.outEdges(h).reduce((b,w)=>Math.min(b,a[w.w]-o.edge(w)),Number.POSITIVE_INFINITY),c=e.node(h);f!==Number.POSITIVE_INFINITY&&c.borderType!==l&&(a[h]=Math.max(a[h],f))}return s(d,o.predecessors.bind(o)),s(u,o.successors.bind(o)),Object.keys(n).forEach(h=>a[h]=a[r[h]]),a}function wn(e,t,r,n){let i=new mn,a=e.graph(),o=gn(a.nodesep,a.edgesep,n);return t.forEach(l=>{let s;l.forEach(d=>{let u=r[d];if(i.setNode(u),s){var h=r[s],f=i.edge(h,u);i.setEdge(h,u,Math.max(o(e,d,s),f||0))}s=d})}),i}function ot(e,t){return Object.values(t).reduce((r,n)=>{let i=Number.NEGATIVE_INFINITY,a=Number.POSITIVE_INFINITY;Object.entries(n).forEach(([l,s])=>{let d=kn(e,l)/2;i=Math.max(s+d,i),a=Math.min(s-d,a)});let o=i-a;return o<r[0]&&(r=[o,n]),r},[Number.POSITIVE_INFINITY,null])[1]}function at(e,t){let r=Object.values(t),n=k.applyWithChunking(Math.min,r),i=k.applyWithChunking(Math.max,r);["u","d"].forEach(a=>{["l","r"].forEach(o=>{let l=a+o,s=e[l];if(s===t)return;let d=Object.values(s),u=n-k.applyWithChunking(Math.min,d);o!=="l"&&(u=i-k.applyWithChunking(Math.max,d)),u&&(e[l]=k.mapValues(s,h=>h+u))})})}function lt(e,t){return k.mapValues(e.ul,(r,n)=>{if(t)return e[t.toLowerCase()][n];{let i=Object.values(e).map(a=>a[n]).sort((a,o)=>a-o);return(i[1]+i[2])/2}})}function En(e){let t=k.buildLayerMatrix(e),r=Object.assign(et(e,t),tt(e,t)),n={},i;["u","d"].forEach(o=>{i=o==="u"?t:Object.values(t).reverse(),["l","r"].forEach(l=>{l==="r"&&(i=i.map(h=>Object.values(h).reverse()));let s=(o==="u"?e.predecessors:e.successors).bind(e),d=nt(e,i,r,s),u=it(e,i,d.root,d.align,l==="r");l==="r"&&(u=k.mapValues(u,h=>-h)),n[o+l]=u})});let a=ot(e,n);return at(n,a),lt(n,e.graph().align)}function gn(e,t,r){return(n,i,a)=>{let o=n.node(i),l=n.node(a),s=0,d;if(s+=o.width/2,Object.hasOwn(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":d=-o.width/2;break;case"r":d=o.width/2;break}if(d&&(s+=r?d:-d),d=0,s+=(o.dummy?t:e)/2,s+=(l.dummy?t:e)/2,s+=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&&(s+=r?d:-d),d=0,s}}function kn(e,t){return e.node(t).width}});var ft=p((Ri,ht)=>{"use strict";var ut=m(),xn=dt().positionX;ht.exports=yn;function yn(e){e=ut.asNonCompoundGraph(e),vn(e),Object.entries(xn(e)).forEach(([t,r])=>e.node(t).x=r)}function vn(e){let t=ut.buildLayerMatrix(e),r=e.graph().ranksep,n=e.graph().rankalign,i=0;t.forEach(a=>{let o=a.reduce((l,s)=>{let d=e.node(s).height;return l>d?l:d},0);a.forEach(l=>{let s=e.node(l);n==="top"?s.y=i+s.height/2:n==="bottom"?s.y=i+o-s.height/2:s.y=i+o/2}),i+=o+r})}});var gt=p((Ci,Et)=>{"use strict";var ct=ee(),pt=re(),Nn=we(),On=m().normalizeRanks,In=ge(),qn=m().removeEmptyRanks,mt=ye(),Ln=Oe(),bt=Re(),Rn=$e(),Cn=ft(),E=m(),Mn=g("@dagrejs/graphlib").Graph;Et.exports=Tn;function Tn(e,t={}){let r=t.debugTiming?E.time:E.notime;return r("layout",()=>{let n=r(" buildLayoutGraph",()=>An(e));return r(" runLayout",()=>jn(n,r,t)),r(" updateInputGraph",()=>_n(e,n)),n})}function jn(e,t,r){t(" makeSpaceForEdgeLabels",()=>Yn(e)),t(" removeSelfEdges",()=>Zn(e)),t(" acyclic",()=>ct.run(e)),t(" nestingGraph.run",()=>mt.run(e)),t(" rank",()=>Nn(E.asNonCompoundGraph(e))),t(" injectEdgeLabelProxies",()=>Wn(e)),t(" removeEmptyRanks",()=>qn(e)),t(" nestingGraph.cleanup",()=>mt.cleanup(e)),t(" normalizeRanks",()=>On(e)),t(" assignRankMinMax",()=>zn(e)),t(" removeEdgeLabelProxies",()=>Xn(e)),t(" normalize.run",()=>pt.run(e)),t(" parentDummyChains",()=>In(e)),t(" addBorderSegments",()=>Ln(e)),t(" order",()=>Rn(e,r)),t(" insertSelfEdges",()=>$n(e)),t(" adjustCoordinateSystem",()=>bt.adjust(e)),t(" position",()=>Cn(e)),t(" positionSelfEdges",()=>ei(e)),t(" removeBorderNodes",()=>Qn(e)),t(" normalize.undo",()=>pt.undo(e)),t(" fixupEdgeLabelCoords",()=>Jn(e)),t(" undoCoordinateSystem",()=>bt.undo(e)),t(" translateGraph",()=>Hn(e)),t(" assignNodeIntersects",()=>Un(e)),t(" reversePoints",()=>Kn(e)),t(" acyclic.undo",()=>ct.undo(e))}function _n(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 Sn=["nodesep","edgesep","ranksep","marginx","marginy"],Pn={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},Gn=["acyclicer","ranker","rankdir","align","rankalign"],Vn=["width","height","rank"],wt={width:0,height:0},Fn=["minlen","weight","width","height","labeloffset"],Bn={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Dn=["labelpos"];function An(e){let t=new Mn({multigraph:!0,compound:!0}),r=F(e.graph());return t.setGraph(Object.assign({},Pn,V(r,Sn),E.pick(r,Gn))),e.nodes().forEach(n=>{let i=F(e.node(n)),a=V(i,Vn);Object.keys(wt).forEach(o=>{a[o]===void 0&&(a[o]=wt[o])}),t.setNode(n,a),t.setParent(n,e.parent(n))}),e.edges().forEach(n=>{let i=F(e.edge(n));t.setEdge(n,Object.assign({},Bn,V(i,Fn),E.pick(i,Dn)))}),t}function Yn(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(r=>{let n=e.edge(r);n.minlen*=2,n.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?n.width+=n.labeloffset:n.height+=n.labeloffset)})}function Wn(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.width&&r.height){let n=e.node(t.v),a={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};E.addDummyNode(e,"edge-proxy",a,"_ep")}})}function zn(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 Xn(e){e.nodes().forEach(t=>{let r=e.node(t);r.dummy==="edge-proxy"&&(e.edge(r.e).labelRank=r.rank,e.removeNode(t))})}function Hn(e){let t=Number.POSITIVE_INFINITY,r=0,n=Number.POSITIVE_INFINITY,i=0,a=e.graph(),o=a.marginx||0,l=a.marginy||0;function s(d){let u=d.x,h=d.y,f=d.width,c=d.height;t=Math.min(t,u-f/2),r=Math.max(r,u+f/2),n=Math.min(n,h-c/2),i=Math.max(i,h+c/2)}e.nodes().forEach(d=>s(e.node(d))),e.edges().forEach(d=>{let u=e.edge(d);Object.hasOwn(u,"x")&&s(u)}),t-=o,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)}),a.width=r-t+o,a.height=i-n+l}function Un(e){e.edges().forEach(t=>{let r=e.edge(t),n=e.node(t.v),i=e.node(t.w),a,o;r.points?(a=r.points[0],o=r.points[r.points.length-1]):(r.points=[],a=i,o=n),r.points.unshift(E.intersectRect(n,a)),r.points.push(E.intersectRect(i,o))})}function Jn(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 Kn(e){e.edges().forEach(t=>{let r=e.edge(t);r.reversed&&r.points.reverse()})}function Qn(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),a=e.node(r.borderLeft[r.borderLeft.length-1]),o=e.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(o.x-a.x),r.height=Math.abs(i.y-n.y),r.x=a.x+r.width/2,r.y=n.y+r.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Zn(e){e.edges().forEach(t=>{if(t.v===t.w){var r=e.node(t.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function $n(e){var t=E.buildLayerMatrix(e);t.forEach(r=>{var n=0;r.forEach((i,a)=>{var o=e.node(i);o.order=a+n,(o.selfEdges||[]).forEach(l=>{E.addDummyNode(e,"selfedge",{width:l.label.width,height:l.label.height,rank:o.rank,order:a+ ++n,e:l.e,label:l.label},"_se")}),delete o.selfEdges})})}function ei(e){e.nodes().forEach(t=>{var r=e.node(t);if(r.dummy==="selfedge"){var n=e.node(r.e.v),i=n.x+n.width/2,a=n.y,o=r.x-i,l=n.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:i+2*o/3,y:a-l},{x:i+5*o/6,y:a-l},{x:i+o,y:a},{x:i+5*o/6,y:a+l},{x:i+2*o/3,y:a+l}],r.label.x=r.x,r.label.y=r.y}})}function V(e,t){return E.mapValues(E.pick(e,t),Number)}function F(e){var t={};return e&&Object.entries(e).forEach(([r,n])=>{typeof r=="string"&&(r=r.toLowerCase()),t[r]=n}),t}});var xt=p((Mi,kt)=>{var ti=m(),ri=g("@dagrejs/graphlib").Graph;kt.exports={debugOrdering:ni};function ni(e){let t=ti.buildLayerMatrix(e),r=new ri({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 a="layer"+i;r.setNode(a,{rank:"same"}),n.reduce((o,l)=>(r.setEdge(o,l,{style:"invis"}),l))}),r}});var vt=p((Ti,yt)=>{yt.exports="2.0.4"});var ii=p((ji,Nt)=>{Nt.exports={graphlib:g("@dagrejs/graphlib"),layout:gt(),debug:xt(),util:{time:m().time,notime:m().notime},version:vt()}});return ii();})();
|
|
1
|
+
"use strict";var dagre=(()=>{var U=Object.defineProperty;var Mn=Object.getOwnPropertyDescriptor;var Pn=Object.getOwnPropertyNames;var Fn=Object.prototype.hasOwnProperty;var An=(e,n,t)=>n in e?U(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var je=(e,n)=>{for(var t in n)U(e,t,{get:n[t],enumerable:!0})},Vn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of Pn(n))!Fn.call(e,o)&&o!==t&&U(e,o,{get:()=>n[o],enumerable:!(r=Mn(n,o))||r.enumerable});return e};var Dn=e=>Vn(U({},"__esModule",{value:!0}),e);var Ie=(e,n,t)=>An(e,typeof n!="symbol"?n+"":n,t);var Sr={};je(Sr,{Graph:()=>k,debug:()=>se,default:()=>Ir,graphlib:()=>Q,layout:()=>ie,util:()=>Rr,version:()=>ne});var Q={};je(Q,{Graph:()=>k,alg:()=>X,json:()=>Fe,version:()=>Bn});var Yn=Object.defineProperty,Pe=(e,n)=>{for(var t in n)Yn(e,t,{get:n[t],enumerable:!0})},k=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,n){return e.forEach(t=>{n!==void 0?this.setNode(t,n):this.setNode(t)}),this}setNode(e,n){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=n),this):(this._nodes[e]=arguments.length>1?n: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 n=t=>this.removeEdge(this._edgeObjs[t]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(t=>{this.setParent(t)}),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(n===void 0)n="\0";else{n+="";for(let t=n;t!==void 0;t=this.parent(t))if(t===e)throw new Error("Setting "+n+" as parent of "+e+" would create a cycle");this.setNode(n)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=n,this._children[n][e]=!0,this}parent(e){if(this._isCompound){let n=this._parent[e];if(n!=="\0")return n}}children(e="\0"){if(this._isCompound){let n=this._children[e];if(n)return Object.keys(n)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let n=this._preds[e];if(n)return Object.keys(n)}successors(e){let n=this._sucs[e];if(n)return Object.keys(n)}neighbors(e){let n=this.predecessors(e);if(n){let t=new Set(n);for(let r of this.successors(e))t.add(r);return Array.from(t.values())}}isLeaf(e){let n;return this.isDirected()?n=this.successors(e):n=this.neighbors(e),n.length===0}filterNodes(e){let n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&n.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{n.hasNode(o.v)&&n.hasNode(o.w)&&n.setEdge(o,this.edge(o))});let t={},r=o=>{let i=this.parent(o);return!i||n.hasNode(i)?(t[o]=i!=null?i:void 0,i!=null?i:void 0):i in t?t[i]:r(i)};return this._isCompound&&n.nodes().forEach(o=>n.setParent(o,r(o))),n}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,n){return e.reduce((t,r)=>(n!==void 0?this.setEdge(t,r,n):this.setEdge(t,r),r)),this}setEdge(e,n,t,r){let o,i,s,a,d=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(a=n,d=!0)):(o=e,i=n,s=r,arguments.length>2&&(a=t,d=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let l=B(this._isDirected,o,i,s);if(l in this._edgeLabels)return d&&(this._edgeLabels[l]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[l]=d?a:this._defaultEdgeLabelFn(o,i,s);let u=Wn(this._isDirected,o,i,s);return o=u.v,i=u.w,Object.freeze(u),this._edgeObjs[l]=u,Se(this._preds[i],o),Se(this._sucs[o],i),this._in[i][l]=u,this._out[o][l]=u,this._edgeCount++,this}edge(e,n,t){let r=arguments.length===1?de(this._isDirected,e):B(this._isDirected,e,n,t);return this._edgeLabels[r]}edgeAsObj(e,n,t){let r=arguments.length===1?this.edge(e):this.edge(e,n,t);return typeof r!="object"?{label:r}:r}hasEdge(e,n,t){return(arguments.length===1?de(this._isDirected,e):B(this._isDirected,e,n,t))in this._edgeLabels}removeEdge(e,n,t){let r=arguments.length===1?de(this._isDirected,e):B(this._isDirected,e,n,t),o=this._edgeObjs[r];if(o){let i=o.v,s=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],Me(this._preds[s],i),Me(this._sucs[i],s),delete this._in[s][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,n){return this.isDirected()?this.filterEdges(this._in[e],e,n):this.nodeEdges(e,n)}outEdges(e,n){return this.isDirected()?this.filterEdges(this._out[e],e,n):this.nodeEdges(e,n)}nodeEdges(e,n){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,n)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,n,t){if(!e)return;let r=Object.values(e);return t?r.filter(o=>o.v===n&&o.w===t||o.v===t&&o.w===n):r}};function Se(e,n){e[n]?e[n]++:e[n]=1}function Me(e,n){e[n]!==void 0&&!--e[n]&&delete e[n]}function B(e,n,t,r){let o=""+n,i=""+t;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(r===void 0?"\0":r)}function Wn(e,n,t,r){let o=""+n,i=""+t;if(!e&&o>i){let a=o;o=i,i=a}let s={v:o,w:i};return r&&(s.name=r),s}function de(e,n){return B(e,n.v,n.w,n.name)}var Bn="4.0.1",Fe={};Pe(Fe,{read:()=>qn,write:()=>Xn});function Xn(e){let n={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:zn(e),edges:Hn(e)},t=e.graph();return t!==void 0&&(n.value=structuredClone(t)),n}function zn(e){return e.nodes().map(n=>{let t=e.node(n),r=e.parent(n),o={v:n};return t!==void 0&&(o.value=t),r!==void 0&&(o.parent=r),o})}function Hn(e){return e.edges().map(n=>{let t=e.edge(n),r={v:n.v,w:n.w};return n.name!==void 0&&(r.name=n.name),t!==void 0&&(r.value=t),r})}function qn(e){let n=new k(e.options);return e.value!==void 0&&n.setGraph(e.value),e.nodes.forEach(t=>{n.setNode(t.v,t.value),t.parent&&n.setParent(t.v,t.parent)}),e.edges.forEach(t=>{n.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),n}var X={};Pe(X,{CycleException:()=>K,bellmanFord:()=>Ae,components:()=>Jn,dijkstra:()=>J,dijkstraAll:()=>Zn,findCycles:()=>et,floydWarshall:()=>tt,isAcyclic:()=>ot,postorder:()=>st,preorder:()=>at,prim:()=>dt,shortestPaths:()=>lt,tarjan:()=>De,topsort:()=>Ye});var $n=()=>1;function Ae(e,n,t,r){return Un(e,String(n),t||$n,r||function(o){return e.outEdges(o)})}function Un(e,n,t,r){let o={},i,s=0,a=e.nodes(),d=function(c){let f=t(c);o[c.v].distance+f<o[c.w].distance&&(o[c.w]={distance:o[c.v].distance+f,predecessor:c.v},i=!0)},l=function(){a.forEach(function(c){r(c).forEach(function(f){let b=f.v===c?f.v:f.w,m=b===f.v?f.w:f.v;d({v:b,w:m})})})};a.forEach(function(c){let f=c===n?0:Number.POSITIVE_INFINITY;o[c]={distance:f,predecessor:""}});let u=a.length;for(let c=1;c<u&&(i=!1,s++,l(),!!i);c++);if(s===u-1&&(i=!1,l(),i))throw new Error("The graph contains a negative weight cycle");return o}function Jn(e){let n={},t=[],r;function o(i){i in n||(n[i]=!0,r.push(i),e.successors(i).forEach(o),e.predecessors(i).forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&t.push(r)}),t}var Ve=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 n=this._keyIndices[e];if(n!==void 0)return this._arr[n].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,n){let t=this._keyIndices,r=String(e);if(!(r in t)){let o=this._arr,i=o.length;return t[r]=i,o.push({key:r,priority:n}),this._decrease(i),!0}return!1}removeMin(){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,n){let t=this._keyIndices[e];if(t===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[t].priority;if(n>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${n}`);this._arr[t].priority=n,this._decrease(t)}_heapify(e){let n=this._arr,t=2*e,r=t+1,o=e;t<n.length&&(o=n[t].priority<n[o].priority?t:o,r<n.length&&(o=n[r].priority<n[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let n=this._arr,t=n[e].priority,r;for(;e!==0&&(r=e>>1,!(n[r].priority<t));)this._swap(e,r),e=r}_swap(e,n){let t=this._arr,r=this._keyIndices,o=t[e],i=t[n];t[e]=i,t[n]=o,r[i.key]=e,r[o.key]=n}},Kn=()=>1;function J(e,n,t,r){let o=function(i){return e.outEdges(i)};return Qn(e,String(n),t||Kn,r||o)}function Qn(e,n,t,r){let o={},i=new Ve,s,a,d=function(l){let u=l.v!==s?l.v:l.w,c=o[u],f=t(l),b=a.distance+f;if(f<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+l+" Weight: "+f);b<c.distance&&(c.distance=b,c.predecessor=s,i.decrease(u,b))};for(e.nodes().forEach(function(l){let u=l===n?0:Number.POSITIVE_INFINITY;o[l]={distance:u,predecessor:""},i.add(l,u)});i.size()>0&&(s=i.removeMin(),a=o[s],a.distance!==Number.POSITIVE_INFINITY);)r(s).forEach(d);return o}function Zn(e,n,t){return e.nodes().reduce(function(r,o){return r[o]=J(e,o,n,t),r},{})}function De(e){let n=0,t=[],r={},o=[];function i(s){let a=r[s]={onStack:!0,lowlink:n,index:n++};if(t.push(s),e.successors(s).forEach(function(d){d in r?r[d].onStack&&(a.lowlink=Math.min(a.lowlink,r[d].index)):(i(d),a.lowlink=Math.min(a.lowlink,r[d].lowlink))}),a.lowlink===a.index){let d=[],l;do l=t.pop(),r[l].onStack=!1,d.push(l);while(s!==l);o.push(d)}}return e.nodes().forEach(function(s){s in r||i(s)}),o}function et(e){return De(e).filter(function(n){return n.length>1||n.length===1&&e.hasEdge(n[0],n[0])})}var nt=()=>1;function tt(e,n,t){return rt(e,n||nt,t||function(r){return e.outEdges(r)})}function rt(e,n,t){let r={},o=e.nodes();return o.forEach(function(i){r[i]={},r[i][i]={distance:0,predecessor:""},o.forEach(function(s){i!==s&&(r[i][s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),t(i).forEach(function(s){let a=s.v===i?s.w:s.v,d=n(s);r[i][a]={distance:d,predecessor:i}})}),o.forEach(function(i){let s=r[i];o.forEach(function(a){let d=r[a];o.forEach(function(l){let u=d[i],c=s[l],f=d[l],b=u.distance+c.distance;b<f.distance&&(f.distance=b,f.predecessor=c.predecessor)})})}),r}var K=class extends Error{constructor(...e){super(...e)}};function Ye(e){let n={},t={},r=[];function o(i){if(i in t)throw new K;i in n||(t[i]=!0,n[i]=!0,e.predecessors(i).forEach(o),delete t[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(n).length!==e.nodeCount())throw new K;return r}function ot(e){try{Ye(e)}catch(n){if(n instanceof K)return!1;throw n}return!0}function it(e,n,t,r,o){Array.isArray(n)||(n=[n]);let i=(a=>{var d;return(d=e.isDirected()?e.successors(a):e.neighbors(a))!=null?d:[]}),s={};return n.forEach(function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);o=We(e,a,t==="post",s,i,r,o)}),o}function We(e,n,t,r,o,i,s){return n in r||(r[n]=!0,t||(s=i(s,n)),o(n).forEach(function(a){s=We(e,a,t,r,o,i,s)}),t&&(s=i(s,n))),s}function Be(e,n,t){return it(e,n,t,function(r,o){return r.push(o),r},[])}function st(e,n){return Be(e,n,"post")}function at(e,n){return Be(e,n,"pre")}function dt(e,n){let t=new k,r={},o=new Ve,i;function s(d){let l=d.v===i?d.w:d.v,u=o.priority(l);if(u!==void 0){let c=n(d);c<u&&(r[l]=i,o.decrease(l,c))}}if(e.nodeCount()===0)return t;e.nodes().forEach(function(d){o.add(d,Number.POSITIVE_INFINITY),t.setNode(d)}),o.decrease(e.nodes()[0],0);let a=!1;for(;o.size()>0;){if(i=o.removeMin(),i in r)t.setEdge(i,r[i]);else{if(a)throw new Error("Input graph is not connected: "+e);a=!0}e.nodeEdges(i).forEach(s)}return t}function lt(e,n,t,r){return ut(e,n,t,r!=null?r:(o=>{let i=e.outEdges(o);return i!=null?i:[]}))}function ut(e,n,t,r){if(t===void 0)return J(e,n,t,r);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let a=r(i[s]);for(let d=0;d<a.length;d++){let l=a[d],u=l.v===i[s]?l.v:l.w,c=u===l.v?l.w:l.v;t({v:u,w:c})<0&&(o=!0)}if(o)return Ae(e,n,t,r)}return J(e,n,t,r)}function I(e,n,t,r){let o=r;for(;e.hasNode(o);)o=H(r);return t.dummy=n,e.setNode(o,t),o}function Xe(e){let n=new k().setGraph(e.graph());return e.nodes().forEach(t=>n.setNode(t,e.node(t))),e.edges().forEach(t=>{let r=n.edge(t.v,t.w)||{weight:0,minlen:1},o=e.edge(t);n.setEdge(t.v,t.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),n}function Z(e){let n=new k({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(t=>{e.children(t).length||n.setNode(t,e.node(t))}),e.edges().forEach(t=>{n.setEdge(t,e.edge(t))}),n}function le(e,n){let t=e.x,r=e.y,o=n.x-t,i=n.y-r,s=e.width/2,a=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let d,l;return Math.abs(i)*s>Math.abs(o)*a?(i<0&&(a=-a),d=a*o/i,l=a):(o<0&&(s=-s),d=s,l=s*i/o),{x:t+d,y:r+l}}function S(e){let n=P(ce(e)+1).map(()=>[]);return e.nodes().forEach(t=>{let r=e.node(t),o=r.rank;o!==void 0&&(n[o]||(n[o]=[]),n[o][r.order]=t)}),n}function ze(e){let n=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),t=O(Math.min,n);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=t)})}function He(e){let n=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),t=O(Math.min,n),r=[];e.nodes().forEach(s=>{let a=e.node(s).rank-t;r[a]||(r[a]=[]),r[a].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((s,a)=>{s===void 0&&a%i!==0?--o:s!==void 0&&o&&s.forEach(d=>e.node(d).rank+=o)})}function ue(e,n,t,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=t,o.order=r),I(e,"border",o,n)}function ct(e,n=qe){let t=[];for(let r=0;r<e.length;r+=n){let o=e.slice(r,r+n);t.push(o)}return t}var qe=65535;function O(e,n){if(n.length>qe){let t=ct(n);return e(...t.map(r=>e(...r)))}else return e(...n)}function ce(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MIN_VALUE:o});return O(Math.max,t)}function $e(e,n){let t={lhs:[],rhs:[]};return e.forEach(r=>{n(r)?t.lhs.push(r):t.rhs.push(r)}),t}function fe(e,n){let t=Date.now();try{return n()}finally{console.log(e+" time: "+(Date.now()-t)+"ms")}}function z(e,n){return n()}var ft=0;function H(e){let n=++ft;return e+(""+n)}function P(e,n,t=1){n==null&&(n=e,e=0);let r=i=>i<n;t<0&&(r=i=>n<i);let o=[];for(let i=e;r(i);i+=t)o.push(i);return o}function Y(e,n){let t={};for(let r of n)e[r]!==void 0&&(t[r]=e[r]);return t}function W(e,n){let t;return typeof n=="string"?t=r=>r[n]:t=n,Object.entries(e).reduce((r,[o,i])=>(r[o]=t(i,o),r),{})}function Ue(e,n){return e.reduce((t,r,o)=>(t[r]=n[o],t),{})}var V="\0";function ee(e,n,t){var l,u,c,f,b,m;if(!(e&&n&&t&&n.dummy==="edge"&&t.dummy==="edge"&&n.edgeObj&&t.edgeObj&&e[n.edgeObj.v]&&e[t.edgeObj.v]&&e[n.edgeObj.w]&&e[t.edgeObj.w]))return 0;let r=!0;n.edgeObj.w===t.edgeObj.w&&(r=!1);let o=r?(u=(l=e[n.edgeObj.v])==null?void 0:l.rank)!=null?u:NaN+1:(f=(c=e[n.edgeObj.w])==null?void 0:c.rank)!=null?f:NaN-1,i=Object.entries(e).find(E=>{var h,g;return((h=E[1].edgeObj)==null?void 0:h.v)===n.edgeObj.v&&((g=E[1].edgeObj)==null?void 0:g.w)===n.edgeObj.w&&E[1].rank===o}),s=Object.entries(e).find(E=>{var h,g;return((h=E[1].edgeObj)==null?void 0:h.v)===t.edgeObj.v&&((g=E[1].edgeObj)==null?void 0:g.w)===t.edgeObj.w&&E[1].rank===o});if(!i||!s)return 0;let a=(b=i[1].order)!=null?b:NaN,d=(m=s[1].order)!=null?m:NaN;return isNaN(a-d)?0:a-d}var ne="3.1.0";var be=class{constructor(){Ie(this,"_sentinel");let n={};n._next=n._prev=n,this._sentinel=n}dequeue(){let n=this._sentinel,t=n._prev;if(t!==n)return Je(t),t}enqueue(n){let t=this._sentinel;n._prev&&n._next&&Je(n),n._next=t._next,t._next._prev=n,t._next=n,n._prev=t}toString(){let n=[],t=this._sentinel,r=t._prev;for(;r!==t;)n.push(JSON.stringify(r,bt)),r=r._prev;return"["+n.join(", ")+"]"}};function Je(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function bt(e,n){if(e!=="_next"&&e!=="_prev")return n}var Ke=be;var ht=()=>1;function pe(e,n){if(e.nodeCount()<=1)return[];let t=pt(e,n||ht);return gt(t.graph,t.buckets,t.zeroIdx).flatMap(o=>e.outEdges(o.v,o.w)||[])}function gt(e,n,t){var a;let r=[],o=n[n.length-1],i=n[0],s;for(;e.nodeCount();){for(;s=i.dequeue();)he(e,n,t,s);for(;s=o.dequeue();)he(e,n,t,s);if(e.nodeCount()){for(let d=n.length-2;d>0;--d)if(s=(a=n[d])==null?void 0:a.dequeue(),s){r=r.concat(he(e,n,t,s,!0)||[]);break}}}return r}function he(e,n,t,r,o){let i=[],s=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(a=>{let d=e.edge(a),l=e.node(a.v);o&&i.push({v:a.v,w:a.w}),l.out-=d,ge(n,t,l)}),(e.outEdges(r.v)||[]).forEach(a=>{let d=e.edge(a),l=a.w,u=e.node(l);u.in-=d,ge(n,t,u)}),e.removeNode(r.v),s}function pt(e,n){let t=new k,r=0,o=0;e.nodes().forEach(a=>{t.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let d=t.edge(a.v,a.w)||0,l=n(a),u=d+l;t.setEdge(a.v,a.w,u);let c=t.node(a.v),f=t.node(a.w);o=Math.max(o,c.out+=l),r=Math.max(r,f.in+=l)});let i=mt(o+r+3).map(()=>new Ke),s=r+1;return t.nodes().forEach(a=>{ge(i,s,t.node(a))}),{graph:t,buckets:i,zeroIdx:s}}function ge(e,n,t){var r,o,i;t.out?t.in?(i=e[t.out-t.in+n])==null||i.enqueue(t):(o=e[e.length-1])==null||o.enqueue(t):(r=e[0])==null||r.enqueue(t)}function mt(e){let n=[];for(let t=0;t<e;t++)n.push(t);return n}function Qe(e,n){(e.graph().acyclicer==="greedy"?pe(e,r(e)):Et(e,n!=null?n:null)).forEach(o=>{let i=e.edge(o);e.removeEdge(o),i.forwardName=o.name,i.reversed=!0,e.setEdge(o.w,o.v,i,H("rev"))});function r(o){return i=>o.edge(i).weight}}function Et(e,n){let t=[],r={},o={};function i(d){Object.hasOwn(o,d)||(o[d]=!0,r[d]=!0,e.outEdges(d).forEach(l=>{Object.hasOwn(r,l.w)?t.push(l):i(l.w)}),delete r[d])}function s(d){var l;Object.hasOwn(o,d)||(o[d]=!0,r[d]=!0,(l=e.outEdges(d))==null||l.forEach(u=>{var c,f;Object.hasOwn(r,u.w)||((c=n.node(d))==null?void 0:c.rank)>((f=n.node(u.w))==null?void 0:f.rank)&&Lt(e,u.w,u)?t.push(u):s(u.w)}),delete r[d])}let a=i;return n&&typeof n.node=="function"&&(a=s),e.sources().forEach(a),e.nodes().forEach(a),t}function Ze(e){e.edges().forEach(n=>{let t=e.edge(n);if(t.reversed){e.removeEdge(n);let r=t.forwardName;delete t.reversed,delete t.forwardName,e.setEdge(n.w,n.v,t,r)}})}function Lt(e,n,t){let r=new Set;function o(i){var s;if(e.sources().includes(i))return!0;r.add(i);for(let a of(s=e.inEdges(i))!=null?s:[])if(!(a.v===t.v&&a.w===t.w)&&!r.has(a.v)&&o(a.v))return!0;return!1}return o(n)}function en(e){e.graph().dummyChains=[],e.edges().forEach(n=>wt(e,n))}function wt(e,n){let t=n.v,r=e.node(t).rank,o=n.w,i=e.node(o).rank,s=n.name,a=e.edge(n),d=a.labelRank;if(i===r+1)return;e.removeEdge(n);let l,u,c;for(c=0,++r;r<i;++c,++r)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:n,rank:r},l=I(e,"edge",u,"_d"),r===d&&(u.width=a.width,u.height=a.height,u.dummy="edge-label",u.labelpos=a.labelpos),e.setEdge(t,l,{weight:a.weight},s),c===0&&e.graph().dummyChains.push(l),t=l;e.setEdge(t,o,{weight:a.weight},s)}function nn(e){e.graph().dummyChains.forEach(n=>{let t=e.node(n),r=t.edgeLabel,o;for(e.setEdge(t.edgeObj,r);t.dummy;)o=e.successors(n)[0],e.removeNode(n),r.points.push({x:t.x,y:t.y}),t.dummy==="edge-label"&&(r.x=t.x,r.y=t.y,r.width=t.width,r.height=t.height),n=o,t=e.node(n)})}function q(e){let n={};function t(r){let o=e.node(r);if(Object.hasOwn(n,r))return o.rank;n[r]=!0;let i=e.outEdges(r),s=i?i.map(d=>d==null?Number.POSITIVE_INFINITY:t(d.w)-e.edge(d).minlen):[],a=O(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),o.rank=a}e.sources().forEach(t)}function F(e,n){return e.node(n.w).rank-e.node(n.v).rank-e.edge(n).minlen}var te=Gt;function Gt(e){let n=new k({directed:!1}),t=e.nodes();if(t.length===0)throw new Error("Graph must have at least one node");let r=t[0],o=e.nodeCount();n.setNode(r,{});let i,s;for(;vt(n,e)<o&&(i=kt(n,e),!!i);)s=n.hasNode(i.v)?F(e,i):-F(e,i),xt(n,e,s);return n}function vt(e,n){function t(r){let o=n.nodeEdges(r);o&&o.forEach(i=>{let s=i.v,a=r===s?i.w:s;!e.hasNode(a)&&!F(n,i)&&(e.setNode(a,{}),e.setEdge(r,a,{}),t(a))})}return e.nodes().forEach(t),e.nodeCount()}function kt(e,n){return n.edges().reduce((r,o)=>{let i=Number.POSITIVE_INFINITY;return e.hasNode(o.v)!==e.hasNode(o.w)&&(i=F(n,o)),i<r[0]?[i,o]:r},[Number.POSITIVE_INFINITY,null])[1]}function xt(e,n,t){e.nodes().forEach(r=>n.node(r).rank+=t)}var{preorder:_t,postorder:Ot}=X,rn=D;D.initLowLimValues=Ee;D.initCutValues=me;D.calcCutValue=on;D.leaveEdge=an;D.enterEdge=dn;D.exchangeEdges=ln;function D(e){e=Xe(e),q(e);let n=te(e);Ee(n),me(n,e);let t,r;for(;t=an(n);)r=dn(n,e,t),ln(n,e,t,r)}function me(e,n){let t=Ot(e,e.nodes());t=t.slice(0,t.length-1),t.forEach(r=>Ct(e,n,r))}function Ct(e,n,t){let o=e.node(t).parent,i=e.edge(t,o);i.cutvalue=on(e,n,t)}function on(e,n,t){let o=e.node(t).parent,i=!0,s=n.edge(t,o),a=0;s||(i=!1,s=n.edge(o,t)),a=s.weight;let d=n.nodeEdges(t);return d&&d.forEach(l=>{let u=l.v===t,c=u?l.w:l.v;if(c!==o){let f=u===i,b=n.edge(l).weight;if(a+=f?b:-b,Rt(e,t,c)){let E=e.edge(t,c).cutvalue;a+=f?-E:E}}}),a}function Ee(e,n){arguments.length<2&&(n=e.nodes()[0]),sn(e,{},1,n)}function sn(e,n,t,r,o){let i=t,s=e.node(r);n[r]=!0;let a=e.neighbors(r);return a&&a.forEach(d=>{Object.hasOwn(n,d)||(t=sn(e,n,t,d,r))}),s.low=i,s.lim=t++,o?s.parent=o:delete s.parent,t}function an(e){return e.edges().find(n=>e.edge(n).cutvalue<0)}function dn(e,n,t){let r=t.v,o=t.w;n.hasEdge(r,o)||(r=t.w,o=t.v);let i=e.node(r),s=e.node(o),a=i,d=!1;return i.lim>s.lim&&(a=s,d=!0),n.edges().filter(u=>d===tn(e,e.node(u.v),a)&&d!==tn(e,e.node(u.w),a)).reduce((u,c)=>F(n,c)<F(n,u)?c:u)}function ln(e,n,t,r){let o=t.v,i=t.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),Ee(e),me(e,n),Tt(e,n)}function Tt(e,n){let t=e.nodes().find(o=>!e.node(o).parent);if(!t)return;let r=_t(e,[t]);r=r.slice(1),r.forEach(o=>{let s=e.node(o).parent,a=n.edge(o,s),d=!1;a||(a=n.edge(s,o),d=!0),n.node(o).rank=n.node(s).rank+(d?a.minlen:-a.minlen)})}function Rt(e,n,t){return e.hasEdge(n,t)}function tn(e,n,t){return t.low<=n.lim&&n.lim<=t.lim}var cn=jt;function jt(e){let n=e.graph().ranker;if(typeof n=="function")return n(e);switch(n){case"network-simplex":un(e);break;case"tight-tree":St(e);break;case"longest-path":It(e);break;case"none":break;default:un(e)}}var It=q;function St(e){q(e),te(e)}function un(e){rn(e)}var fn=Mt;function Mt(e){let n=Ft(e),t=e.graph();if(!Array.isArray(t.dummyChains))return;t.dummyChains.forEach(o=>{let i=e.node(o),s=i.edgeObj,a=Pt(e,n,s.v,s.w),d=a.path,l=a.lca,u=0,c=d[u],f=!0;for(;o!==s.w;){if(i=e.node(o),f){for(;(c=d[u])!==l&&e.node(c).maxRank<i.rank;)u++;c===l&&(f=!1)}if(!f){for(;u<d.length-1&&e.node(d[u+1]).minRank<=i.rank;)u++;c=d[u]}c!==void 0&&e.setParent(o,c),o=e.successors(o)[0]}})}function Pt(e,n,t,r){let o=[],i=[],s=Math.min(n[t].low,n[r].low),a=Math.max(n[t].lim,n[r].lim),d;d=t;do d=e.parent(d),o.push(d);while(d&&(n[d].low>s||a>n[d].lim));let l=d,u=r;for(;(u=e.parent(u))!==l;)i.push(u);return{path:o.concat(i.reverse()),lca:l}}function Ft(e){let n={},t=0;function r(o){let i=t;e.children(o).forEach(r),n[o]={low:i,lim:t++}}return e.children(V).forEach(r),n}function bn(e){let n=I(e,"root",{},"_root"),t=At(e),r=Object.values(t),o=O(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=n,e.edges().forEach(a=>e.edge(a).minlen*=i);let s=Vt(e)+1;e.children(V).forEach(a=>{hn(e,n,i,s,o,t,a)}),e.graph().nodeRankFactor=i}function hn(e,n,t,r,o,i,s){var c;let a=e.children(s);if(!a.length){s!==n&&e.setEdge(n,s,{weight:0,minlen:t});return}let d=ue(e,"_bt"),l=ue(e,"_bb"),u=e.node(s);e.setParent(d,s),u.borderTop=d,e.setParent(l,s),u.borderBottom=l,a.forEach(f=>{var p;hn(e,n,t,r,o,i,f);let b=e.node(f),m=b.borderTop?b.borderTop:f,E=b.borderBottom?b.borderBottom:f,h=b.borderTop?r:2*r,g=m!==E?1:o-((p=i[s])!=null?p:0)+1;e.setEdge(d,m,{weight:h,minlen:g,nestingEdge:!0}),e.setEdge(E,l,{weight:h,minlen:g,nestingEdge:!0})}),e.parent(s)||e.setEdge(n,d,{weight:0,minlen:o+((c=i[s])!=null?c:0)})}function At(e){let n={};function t(r,o){let i=e.children(r);i&&i.length&&i.forEach(s=>t(s,o+1)),n[r]=o}return e.children(V).forEach(r=>t(r,1)),n}function Vt(e){return e.edges().reduce((n,t)=>n+e.edge(t).weight,0)}function gn(e){let n=e.graph();e.removeNode(n.nestingRoot),delete n.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var mn=Yt;function Yt(e){function n(t){let r=e.children(t),o=e.node(t);if(r.length&&r.forEach(n),o&&Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)pn(e,"borderLeft","_bl",t,o,i),pn(e,"borderRight","_br",t,o,i)}}e.children(V).forEach(n)}function pn(e,n,t,r,o,i){let s={width:0,height:0,rank:i,borderType:n},a=o[n][i-1],d=I(e,"border",s,t);o[n][i]=d,e.setParent(d,r),a&&e.setEdge(a,d,{weight:1})}function Ln(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&wn(e)}function yn(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Wt(e),(n==="lr"||n==="rl")&&(Bt(e),wn(e))}function wn(e){e.nodes().forEach(n=>En(e.node(n))),e.edges().forEach(n=>En(e.edge(n)))}function En(e){let n=e.width;e.width=e.height,e.height=n}function Wt(e){e.nodes().forEach(n=>Le(e.node(n))),e.edges().forEach(n=>{var r;let t=e.edge(n);(r=t.points)==null||r.forEach(Le),Object.hasOwn(t,"y")&&Le(t)})}function Le(e){e.y=-e.y}function Bt(e){e.nodes().forEach(n=>ye(e.node(n))),e.edges().forEach(n=>{var r;let t=e.edge(n);(r=t.points)==null||r.forEach(ye),Object.hasOwn(t,"x")&&ye(t)})}function ye(e){let n=e.x;e.x=e.y,e.y=n}function we(e,n=null){let t={},r=e.nodes().filter(u=>!e.children(u).length),o=r.map(u=>e.node(u).rank),i=O(Math.max,o),s=P(i+1).map(()=>[]);function a(u){if(t[u])return;t[u]=!0;let c=e.node(u);s[c.rank].push(u);let f=e.successors(u);f&&[...f].sort((m,E)=>l(m,E)).forEach(a)}r.sort((u,c)=>e.node(u).rank-e.node(c).rank).forEach(a);function l(u,c){let f=e.node(u),b=e.node(c);return ee(n,f,b)}return s}function Ne(e,n){let t=0;for(let r=1;r<n.length;++r)t+=zt(e,n[r-1],n[r]);return t}function zt(e,n,t){let r=Ue(t,t.map((l,u)=>u)),o=n.flatMap(l=>{let u=e.outEdges(l);return u?u.map(c=>({pos:r[c.w],weight:e.edge(c).weight})).sort((c,f)=>c.pos-f.pos):[]}),i=1;for(;i<t.length;)i<<=1;let s=2*i-1;i-=1;let a=new Array(s).fill(0),d=0;return o.forEach(l=>{let u=l.pos+i;a[u]+=l.weight;let c=0;for(;u>0;)u%2&&(c+=a[u+1]),u=u-1>>1,a[u]+=l.weight;d+=l.weight*c}),d}function Ge(e,n=[]){return n.map(t=>{let r=e.inEdges(t);if(!r||!r.length)return{v:t};{let o=r.reduce((i,s)=>{let a=e.edge(s),d=e.node(s.v);return{sum:i.sum+a.weight*d.order,weight:i.weight+a.weight}},{sum:0,weight:0});return{v:t,barycenter:o.sum/o.weight,weight:o.weight}}})}function ve(e,n){let t={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),t[o.v]=s}),n.edges().forEach(o=>{let i=t[o.v],s=t[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let r=Object.values(t).filter(o=>!o.indegree);return Ht(r)}function Ht(e){let n=[];function t(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&qt(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();n.push(o),o.in.reverse().forEach(t(o)),o.out.forEach(r(o))}return n.filter(o=>!o.merged).map(o=>Y(o,["vs","i","barycenter","weight"]))}function qt(e,n){let t=0,r=0;e.weight&&(t+=e.barycenter*e.weight,r+=e.weight),n.weight&&(t+=n.barycenter*n.weight,r+=n.weight),e.vs=n.vs.concat(e.vs),e.barycenter=t/r,e.weight=r,e.i=Math.min(n.i,e.i),n.merged=!0}function ke(e,n,t,r,o){let i={},s=null,a=null,d=o;typeof n=="boolean"?(d=n,i={}):n&&(i=n,s=t!=null?t:null,a=r!=null?r:null);let l=$e(e,g=>Object.hasOwn(g,"barycenter")),u=l.lhs,c=l.rhs.sort((g,p)=>p.i-g.i),f=[],b=0,m=0,E=0;u.sort($t(a,s,!!d));for(let[g,p]of Object.entries(i)){let w=u.findIndex(v=>v.vs[0]===g);u.splice(w+1,0,p)}E=Nn(f,c,E),u.forEach(g=>{E+=g.vs.length,f.push(g.vs),b+=g.barycenter*g.weight,m+=g.weight,E=Nn(f,c,E)});let h={vs:f.flat(1)};return m&&(h.barycenter=b/m,h.weight=m),h}function Nn(e,n,t){let r;for(;n.length&&(r=n[n.length-1]).i<=t;)n.pop(),e.push(r.vs),t++;return t}function $t(e,n,t){return(r,o)=>{if(r.barycenter<o.barycenter)return-1;if(r.barycenter>o.barycenter)return 1;if(e&&(typeof r.vs[0]=="string"||typeof o.vs[0]=="string")){let i=e.node(r.vs[0]),s=e.node(o.vs[0]),a=ee(n,i,s);if(a!==0)return a}return t?o.i-r.i:r.i-o.i}}function re(e,n,t,r,o){var g,p,w,v,N,G,_,C,T,j,R;let i=null,s=o;typeof r=="boolean"?(s=r,i=null):r!==void 0&&(i=r);let a=e.children(n),d=e.node(n),l=d?d.borderLeft:void 0,u=d?d.borderRight:void 0,c={};l&&(a=a.filter(y=>y!==l&&y!==u));let f=Ge(e,a);f.forEach(y=>{if(e.children(y.v).length){let{result:L}=re(e,y.v,t,i,s);c[y.v]=L,Object.hasOwn(L,"barycenter")&&Jt(y,L)}});let b=ve(f,t);Ut(b,c);let m={},E=!1;for(let y=0;y<b.length;y++)for(let L=y+1;L<b.length;L++)if(!(!b[y]||!b[L]||!((g=b[y])!=null&&g.barycenter)||!((p=b[L])!=null&&p.barycenter))&&((w=b[y])==null?void 0:w.barycenter)===b[L].barycenter){let x=(N=(v=b[y])==null?void 0:v.vs[0])!=null?N:"",A=(_=(G=b[L])==null?void 0:G.vs[0])!=null?_:"",$=e.node(x),ae=e.node(A);if($.dummy==="edge"&&ae.dummy==="edge"&&((C=$.edgeObj)==null?void 0:C.v)===((T=ae.edgeObj)==null?void 0:T.v)&&((j=$.edgeObj)==null?void 0:j.w)===((R=ae.edgeObj)==null?void 0:R.w))if($.edgeLabel.reversed){m[A]=b[y],b.splice(y,1),y--;break}else m[x]=b[L],b.splice(L,1),L--;else E=!0}let h=ke(b,m,i,e,s);if(l&&u){h.vs=[l,h.vs,u].flat(1);let y=e.predecessors(l);if(y&&y.length){let L=e.node(y[0]),x=e.predecessors(u),A=e.node(x[0]);Object.hasOwn(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+L.order+A.order)/(h.weight+2),h.weight+=2}}return Object.defineProperty(h,"result",{value:h,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(h,"usedBias",{value:E,enumerable:!1,configurable:!0,writable:!0}),h}function Ut(e,n){e.forEach(t=>{t.vs=t.vs.flatMap(r=>n[r]?n[r].vs:r)})}function Jt(e,n){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+n.barycenter*n.weight)/(e.weight+n.weight),e.weight+=n.weight):(e.barycenter=n.barycenter,e.weight=n.weight)}function xe(e,n,t,r){r||(r=e.nodes());let o=Kt(e),i=new k({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let a=e.node(s),d=e.parent(s);if(a.rank===n||a.minRank<=n&&n<=a.maxRank){i.setNode(s),i.setParent(s,d||o);let l=e[t](s);l&&l.forEach(u=>{let c=u.v===s?u.w:u.v,f=i.edge(c,s),b=f!==void 0?f.weight:0;i.setEdge(c,s,{weight:e.edge(u).weight+b})}),Object.hasOwn(a,"minRank")&&i.setNode(s,{borderLeft:a.borderLeft[n],borderRight:a.borderRight[n]})}}),i}function Kt(e){let n;for(;e.hasNode(n=H("_root")););return n}function _e(e,n,t){let r={},o;t.forEach(i=>{let s=e.parent(i),a,d;for(;s;){if(a=e.parent(s),a?(d=r[a],r[a]=s):(d=o,o=s),d&&d!==s){n.setEdge(d,s);return}s=a}})}function oe(e,n={},t=null){if(typeof n.customOrder=="function"){n.customOrder(e,oe);return}let r=ce(e),o=Gn(e,P(1,r+1),"inEdges"),i=Gn(e,P(r-1,-1,-1),"outEdges"),s=we(e,t);if(vn(e,s),n.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,d,l=n.constraints||[];for(let u=0,c=0;c<4;++u,++c){Qt(u%2?o:i,u%4>=2,l,t),s=S(e);let f=Ne(e,s);f<a?(c=0,d=Object.assign({},s),a=f):f===a&&(d=structuredClone(s))}vn(e,d)}function Gn(e,n,t){let r=new Map,o=(i,s)=>{r.has(i)||r.set(i,[]),r.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&o(a,i)}return n.map(function(i){return xe(e,i,t,r.get(i)||[])})}function Qt(e,n,t,r){let o=!0,i=new k;e.forEach(function(s){t.forEach(u=>i.setEdge(u.left,u.right));let a=s.graph().root,{result:d,usedBias:l}=re(s,a,i,r,o);n&&l&&(o=!o),d.vs.forEach((u,c)=>s.node(u).order=c),_e(s,i,d.vs)})}function vn(e,n){Object.values(n).forEach(t=>t.forEach((r,o)=>e.node(r).order=o))}function Zt(e,n){let t={};function r(o,i){let s=0,a=0,d=o.length,l=i[i.length-1];return i.forEach((u,c)=>{let f=nr(e,u),b=f?e.node(f).order:d;(f||u===l)&&(i.slice(a,c+1).forEach(m=>{let E=e.predecessors(m);E&&E.forEach(h=>{let g=e.node(h),p=g.order;(p<s||b<p)&&!(g.dummy&&e.node(m).dummy)&&xn(t,h,m)})}),a=c+1,s=b)}),i}return n.length&&n.reduce(r),t}function er(e,n){let t={};function r(i,s,a,d,l){P(s,a).forEach(u=>{let c=i[u];if(c!==void 0&&e.node(c).dummy){let f=e.predecessors(c);f&&f.forEach(b=>{if(b===void 0)return;let m=e.node(b);m.dummy&&(m.order<d||m.order>l)&&xn(t,b,c)})}})}function o(i,s){let a=-1,d=-1,l=0;return s.forEach((u,c)=>{if(e.node(u).dummy==="border"){let f=e.predecessors(u);if(f&&f.length){let b=f[0];if(b===void 0)return;d=e.node(b).order,r(s,l,c,a,d),l=c,a=d}}r(s,l,s.length,d,i.length)}),s}return n.length&&n.reduce(o),t}function nr(e,n){if(e.node(n).dummy){let t=e.predecessors(n);if(t)return t.find(r=>e.node(r).dummy)}}function xn(e,n,t){if(n>t){let o=n;n=t,t=o}let r=e[n];r||(e[n]=r={}),r[t]=!0}function tr(e,n,t){if(n>t){let o=n;n=t,t=o}let r=e[n];return r!==void 0&&Object.hasOwn(r,t)}function rr(e,n,t,r,o){let i={},s={},a={};return n.forEach(d=>{d.forEach((l,u)=>{i[l]=l,s[l]=l,a[l]=u})}),n.forEach(d=>{let l=-1,u=-1,c=!1,f=d,b=d.findIndex(m=>(o==null?void 0:o.includes(m))||kn(m,e,o));b>0&&(f=[d[b],...d.slice(0,b),...d.slice(b+1)],c=!0),f.forEach(m=>{var h;let E=r(m);if(E&&E.length){o!=null&&o.includes(m)&&(E=E.filter(w=>kn(w,e,o)));let g=E.sort((w,v)=>{let N=a[w],G=a[v];return(N!==void 0?N:0)-(G!==void 0?G:0)}),p=(g.length-1)/2;for(let w=Math.floor(p),v=Math.ceil(p);w<=v;++w){let N=g[w];if(N===void 0)continue;let G=a[N];if(G!==void 0&&s[m]===m&&l<G&&a[N]!==u&&!tr(t,m,N)){let _=i[N];_!==void 0&&(s[N]=m,s[m]=i[m]=_,l=G,c&&(l=-1,u=(h=a[N])!=null?h:-1,c=!1))}}}})}),{root:i,align:s}}function or(e,n,t,r,o=!1){let i={},s=ir(e,n,t,o),a=o?"borderLeft":"borderRight";function d(b,m){let E=s.nodes().slice(),h={},g=E.pop();for(;g;){if(h[g])b(g);else{h[g]=!0,E.push(g);for(let p of m(g))E.push(p)}g=E.pop()}}function l(b){let m=s.inEdges(b);m?i[b]=m.reduce((E,h)=>{var w;let g=(w=i[h.v])!=null?w:0,p=s.edge(h);return Math.max(E,g+(p!==void 0?p:0))},0):i[b]=0}function u(b){let m=s.outEdges(b),E=Number.POSITIVE_INFINITY;m&&(E=m.reduce((g,p)=>{let w=i[p.w],v=s.edge(p);return Math.min(g,(w!==void 0?w:0)-(v!==void 0?v:0))},Number.POSITIVE_INFINITY));let h=e.node(b);E!==Number.POSITIVE_INFINITY&&h.borderType!==a&&(i[b]=Math.max(i[b]!==void 0?i[b]:0,E))}function c(b){return s.predecessors(b)||[]}function f(b){return s.successors(b)||[]}return d(l,c),d(u,f),Object.keys(r).forEach(b=>{var E;let m=t[b];m!==void 0&&(i[b]=(E=i[m])!=null?E:0)}),i}function ir(e,n,t,r){let o=new k,i=e.graph(),s=lr(i.nodesep,i.edgesep,r);return n.forEach(a=>{let d;a.forEach(l=>{let u=t[l];if(u!==void 0){if(o.setNode(u),d!==void 0){let c=t[d];if(c!==void 0){let f=o.edge(c,u);o.setEdge(c,u,Math.max(s(e,l,d),f||0))}}d=l}})}),o}function sr(e,n){return Object.values(n).reduce((t,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,d])=>{let l=ur(e,a)/2;o=Math.max(d+l,o),i=Math.min(d-l,i)});let s=o-i;return s<t[0]&&(t=[s,r]),t},[Number.POSITIVE_INFINITY,null])[1]}function ar(e,n){let t=Object.values(n),r=O(Math.min,t),o=O(Math.max,t);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let a=i+s,d=e[a];if(!d||d===n)return;let l=Object.values(d),u=r-O(Math.min,l);s!=="l"&&(u=o-O(Math.max,l)),u&&(e[a]=W(d,c=>c+u))})})}function dr(e,n=void 0){let t=e.ul;return t?W(t,(r,o)=>{var s,a;if(n){let d=n.toLowerCase(),l=e[d];if(l&&l[o]!==void 0)return l[o]}let i=Object.values(e).map(d=>{let l=d[o];return l!==void 0?l:0}).sort((d,l)=>d-l);return(((s=i[1])!=null?s:0)+((a=i[2])!=null?a:0))/2}):{}}function _n(e,n){let t=S(e),r=Object.assign(Zt(e,t),er(e,t)),o={},i;["u","d"].forEach(a=>{i=a==="u"?t:Object.values(t).reverse(),["l","r"].forEach(d=>{d==="r"&&(i=i.map(f=>Object.values(f).reverse()));let u=rr(e,i,r,f=>(a==="u"?e.predecessors(f):e.successors(f))||[],n),c=or(e,i,u.root,u.align,d==="r");d==="r"&&(c=W(c,f=>-f)),o[a+d]=c})});let s=sr(e,o);return ar(o,s),dr(o,e.graph().align)}function lr(e,n,t){return(r,o,i)=>{let s=r.node(o),a=r.node(i),d=0,l;if(d+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":l=-s.width/2;break;case"r":l=s.width/2;break}if(l&&(d+=t?l:-l),l=void 0,d+=(s.dummy?n:e)/2,d+=(a.dummy?n:e)/2,d+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":l=a.width/2;break;case"r":l=-a.width/2;break}return l&&(d+=t?l:-l),d}}function ur(e,n){return e.node(n).width}function kn(e,n,t){var s;if(!t)return!1;let r=(s=n.node(e))==null?void 0:s.edgeObj;if(!r||n.node(e).edgeLabel.reversed)return!1;let o=t.indexOf(r==null?void 0:r.v),i=t.indexOf(r==null?void 0:r.w);return o!==-1&&i!==-1&&o===(i+1)%t.length||o===(i-1)%t.length}function On(e,n){e=Z(e),cr(e),Object.entries(_n(e,n)).forEach(([t,r])=>e.node(t).x=r)}function cr(e){let n=S(e),t=e.graph(),r=t.ranksep,o=t.rankalign,i=0;n.forEach(s=>{let a=s.reduce((d,l)=>{var c;let u=(c=e.node(l).height)!=null?c:0;return d>u?d:u},0);s.forEach(d=>{let l=e.node(d);o==="top"?l.y=i+l.height/2:o==="bottom"?l.y=i+a-l.height/2:l.y=i+a/2}),i+=a+r})}var Oe=null,Ce=null;function ie(e,n={}){return Sn(e,z,n),e}function Cn(e,n,t){let r=n;for(;r!==void 0;){let o=e.parent(r);if(o===t)return r;r=o}}function Sn(e,n,t){let r=e.nodes().filter(h=>e.children(h).length),o={};r.forEach(h=>{let g=e.node(h);if(g&&g.rankdir){let p=new k({multigraph:!0,compound:!0});p.setGraph({rankdir:g.rankdir});let w=e.children(h);w.forEach(y=>{let L={...e.node(y)};p.setNode(y,L);let x=e.parent(y);x&&x!==h&&w.includes(x)&&p.setParent(y,x)});let v=new Set;e.edges().forEach(y=>{let L=Cn(e,y.v,h),x=Cn(e,y.w,h);if(L&&x&&L!==x){let A=`${L}\0${x}`;v.has(A)||(v.add(A),p.setEdge(L,x,{...e.edge(y)}))}}),Sn(p,n,t);let N=In(p);Tn(N,n,t),Rn(p,N);let G=1/0,_=1/0,C=-1/0,T=-1/0;p.nodes().forEach(y=>{if(y===h)return;let L=p.node(y);L&&typeof L.x=="number"&&typeof L.y=="number"&&typeof L.width=="number"&&typeof L.height=="number"&&(G=Math.min(G,L.x-L.width/2),C=Math.max(C,L.x+L.width/2),_=Math.min(_,L.y-L.height/2),T=Math.max(T,L.y+L.height/2))}),(!isFinite(G)||!isFinite(_)||!isFinite(C)||!isFinite(T))&&(G=_=0,C=T=0);let j=C-G,R=T-_;o[h]={minX:G,minY:_,maxX:C,maxY:T,width:j,height:R,offsetX:G,offsetY:_},g._dagreClusterSubgraph=p}});let i=[],s=h=>{let g=[],p=(e.children(h)||[]).filter(w=>w!==h);for(;p.length>0;){let w=p.shift();g.push(w),(e.children(w)||[]).filter(v=>v!==w).forEach(v=>p.push(v))}return g},a=new Map;r.forEach(h=>{let g=e.node(h);g&&g.rankdir&&o[h]&&a.set(h,(e.children(h)||[]).filter(p=>p!==h))});let d=new Set([...a.values()].flat()),l=new Map;a.forEach((h,g)=>{d.has(g)||l.set(g,s(g))});let u=new Set([...l.values()].flat()),c=h=>{for(let[g,p]of l)if(p.includes(h))return g;return h},f=[];e.edges().forEach(h=>{(u.has(h.v)||u.has(h.w))&&f.push({edge:h,label:e.edge(h)})});let b=new Map;u.forEach(h=>{let g=e.parent(h);b.set(h,typeof g=="string"?g:void 0)}),l.forEach((h,g)=>{let p=e.node(g),w=[];h.forEach(G=>{let _=e.node(G);_&&(w.push({id:G,node:_,parent:b.get(G)}),e.removeNode(G))});let v=f.filter(({edge:G})=>h.includes(G.v)||h.includes(G.w)),N=o[g];p&&(i.push({clusterId:g,subgraph:p._dagreClusterSubgraph,bounds:N,children:h,removedNodes:w,removedEdges:v}),p.width=N.width,p.height=N.height)});let m=new Set;f.forEach(({edge:h,label:g})=>{let p=c(h.v),w=c(h.w);if(p!==w&&e.hasNode(p)&&e.hasNode(w)){let v=`${p}\0${w}`;m.has(v)||(m.add(v),e.setEdge(p,w,{...g,width:0,height:0}))}});let E=In(e);Tn(E,n,t),Rn(e,E),m.forEach(h=>{let g=h.indexOf("\0"),p=h.slice(0,g),w=h.slice(g+1);e.hasEdge(p,w)&&e.removeEdge(p,w)}),i.forEach(({clusterId:h,subgraph:g,bounds:p,removedNodes:w,removedEdges:v})=>{var j,R;let N=e.node(h),G=(j=N==null?void 0:N.x)!=null?j:0,_=(R=N==null?void 0:N.y)!=null?R:0,C=(p.minX+p.maxX)/2,T=(p.minY+p.maxY)/2;w.forEach(({id:y,node:L,parent:x})=>{e.setNode(y,L),x!==void 0&&e.setParent(y,x)}),v.forEach(({edge:y,label:L})=>{e.setEdge(y,L)}),g.nodes().forEach(y=>{if(y===h)return;let L=g.node(y),x=e.node(y);x&&L&&typeof L.x=="number"&&typeof L.y=="number"&&(x.x=G+(L.x-C),x.y=_+(L.y-T))}),delete N._dagreClusterSubgraph}),r.forEach(h=>{var w,v;let g=e.node(h),p=o[h];if(g&&g.rankdir&&g._dagreClusterSubgraph&&p){let N=g._dagreClusterSubgraph,G=(w=g.x)!=null?w:0,_=(v=g.y)!=null?v:0,C=(p.minX+p.maxX)/2,T=(p.minY+p.maxY)/2;N.nodes().forEach(j=>{if(j===h)return;let R=N.node(j),y=e.node(j);if(y&&R&&typeof R.x=="number"&&typeof R.y=="number"){let L=R.x-C,x=R.y-T;y.x=G+L,y.y=_+x}}),delete g._dagreClusterSubgraph}})}function Tn(e,n,t){(t==null?void 0:t.useDynamic)===!1&&(Oe=null,Ce=null),n(" makeSpaceForEdgeLabels",()=>Lr(e)),n(" removeSelfEdges",()=>Or(e)),n(" acyclic",()=>Qe(e,Oe)),n(" nestingGraph.run",()=>bn(e)),n(" rank",()=>cn(Z(e))),n(" injectEdgeLabelProxies",()=>yr(e)),n(" removeEmptyRanks",()=>He(e)),n(" nestingGraph.cleanup",()=>gn(e)),n(" normalizeRanks",()=>ze(e)),n(" assignRankMinMax",()=>wr(e)),n(" removeEdgeLabelProxies",()=>Nr(e)),n(" normalize.run",()=>en(e)),n(" parentDummyChains",()=>fn(e)),n(" addBorderSegments",()=>mn(e)),n(" order",()=>oe(e,t,Ce)),n(" insertSelfEdges",()=>Cr(e)),n(" adjustCoordinateSystem",()=>Ln(e)),n(" position",()=>On(e,t.corePath)),n(" positionSelfEdges",()=>Tr(e)),Ce=JSON.parse(JSON.stringify(e._nodes)),n(" removeBorderNodes",()=>_r(e)),n(" normalize.undo",()=>nn(e)),n(" fixupEdgeLabelCoords",()=>kr(e)),n(" undoCoordinateSystem",()=>yn(e)),n(" translateGraph",()=>Gr(e)),n(" assignNodeIntersects",()=>vr(e)),n(" reversePoints",()=>xr(e)),n(" acyclic.undo",()=>Ze(e)),Oe=e}function Rn(e,n){e.nodes().forEach(t=>{let r=e.node(t),o=n.node(t);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,n.children(t).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(t=>{let r=e.edge(t),o=n.edge(t);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=n.graph().width,e.graph().height=n.graph().height}var fr=["nodesep","edgesep","ranksep","marginx","marginy"],br={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},hr=["acyclicer","ranker","rankdir","align","rankalign"],gr=["width","height","rank"],jn={width:0,height:0},pr=["minlen","weight","width","height","labeloffset"],mr={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Er=["labelpos"];function In(e){let n=new k({multigraph:!0,compound:!0}),t=Re(e.graph());return n.setGraph(Object.assign({},br,Te(t,fr),Y(t,hr))),e.nodes().forEach(r=>{let o=Re(e.node(r)),i=Te(o,gr);Object.keys(jn).forEach(a=>{i[a]===void 0&&(i[a]=jn[a])}),n.setNode(r,i);let s=e.parent(r);s!==void 0&&n.setParent(r,s)}),e.edges().forEach(r=>{let o=Re(e.edge(r));n.setEdge(r,Object.assign({},mr,Te(o,pr),Y(o,Er)))}),n}function Lr(e){let n=e.graph();n.ranksep/=2,e.edges().forEach(t=>{var o;let r=e.edge(t);r.minlen*=2,((o=r.labelpos)!=null?o:"r").toLowerCase()!=="c"&&(n.rankdir==="TB"||n.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function yr(e){e.edges().forEach(n=>{let t=e.edge(n);if(t.width&&t.height){let r=e.node(n.v),i={rank:(e.node(n.w).rank-r.rank)/2+r.rank,e:n};I(e,"edge-proxy",i,"_ep")}})}function wr(e){let n=0;e.nodes().forEach(t=>{let r=e.node(t);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,n=Math.max(n,r.maxRank))}),e.graph().maxRank=n}function Nr(e){e.nodes().forEach(n=>{let t=e.node(n);if(t.dummy==="edge-proxy"){let r=t;e.edge(r.e).labelRank=t.rank,e.removeNode(n)}})}function Gr(e){let n=Number.POSITIVE_INFINITY,t=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,a=i.marginy||0;function d(l){let u=l.x,c=l.y,f=l.width,b=l.height;n=Math.min(n,u-f/2),t=Math.max(t,u+f/2),r=Math.min(r,c-b/2),o=Math.max(o,c+b/2)}e.nodes().forEach(l=>d(e.node(l))),e.edges().forEach(l=>{let u=e.edge(l);Object.hasOwn(u,"x")&&d(u)}),n-=s,r-=a,e.nodes().forEach(l=>{let u=e.node(l);u.x-=n,u.y-=r}),e.edges().forEach(l=>{let u=e.edge(l);u.points.forEach(c=>{c.x-=n,c.y-=r}),Object.hasOwn(u,"x")&&(u.x-=n),Object.hasOwn(u,"y")&&(u.y-=r)}),i.width=t-n+s,i.height=o-r+a}function vr(e){e.edges().forEach(n=>{if(n.v===n.w)return;let t=e.edge(n),r=e.node(n.v),o=e.node(n.w),i,s;t.points?(i=t.points[0],s=t.points[t.points.length-1]):(t.points=[],i=o,s=r),t.points.unshift(le(r,i)),t.points.push(le(o,s))})}function kr(e){e.edges().forEach(n=>{let t=e.edge(n);if(Object.hasOwn(t,"x"))switch((t.labelpos==="l"||t.labelpos==="r")&&(t.width-=t.labeloffset),t.labelpos){case"l":t.x-=t.width/2+t.labeloffset;break;case"r":t.x+=t.width/2+t.labeloffset;break}})}function xr(e){e.edges().forEach(n=>{let t=e.edge(n);t.reversed&&t.points.reverse()})}function _r(e){e.nodes().forEach(n=>{if(e.children(n).length){let t=e.node(n),r=e.node(t.borderTop),o=e.node(t.borderBottom),i=e.node(t.borderLeft[t.borderLeft.length-1]),s=e.node(t.borderRight[t.borderRight.length-1]);t.width=Math.abs(s.x-i.x),t.height=Math.abs(o.y-r.y),t.x=i.x+t.width/2,t.y=r.y+t.height/2}}),e.nodes().forEach(n=>{e.node(n).dummy==="border"&&e.removeNode(n)})}function Or(e){e.edges().forEach(n=>{if(n.v===n.w){let t=e.node(n.v);t.selfEdges||(t.selfEdges=[]),t.selfEdges.push({e:n,label:e.edge(n)}),e.removeEdge(n)}})}function Cr(e){S(e).forEach(t=>{let r=0;t.forEach((o,i)=>{let s=e.node(o);typeof s.rank!="number"&&(s.rank=0),s.order=i+r,(s.selfEdges||[]).forEach(a=>{I(e,"selfedge",{width:a.label.width,height:a.label.height,rank:s.rank,order:i+ ++r,e:a.e,edgeLabel:a.label},"_se"),(!Array.isArray(a.label.points)||a.label.points.length!==7)&&(a.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 s.selfEdges})})}function Tr(e){e.nodes().forEach(n=>{let t=e.node(n),r=o=>typeof o=="number"&&isFinite(o);if(t.dummy==="selfedge"){let o=t,i=e.node(o.e.v),s=r(i==null?void 0:i.x)?i.x:0,a=r(i==null?void 0:i.y)?i.y:0,d=r(i==null?void 0:i.width)?i.width:0,l=r(i==null?void 0:i.height)?i.height:0,u=r(t.x)?t.x:s,c=r(t.y)?t.y:a,f=d/2,b=l/2;o.edgeLabel.points=[{x:u+f,y:c-b},{x:u+f,y:c-b},{x:u,y:c},{x:u-f,y:c+b},{x:u-f,y:c+b},{x:u,y:c},{x:u,y:c}],o.edgeLabel.x=u,o.edgeLabel.y=c,e.setEdge(o.e,o.edgeLabel),e.removeNode(n)}else t&&Array.isArray(t.selfEdges)&&t.selfEdges.forEach(o=>{if(!Array.isArray(o.label.points)||o.label.points.length!==7){let i=r(t.x)?t.x:0,s=r(t.y)?t.y:0,a=r(t.width)?t.width:0,d=r(t.height)?t.height:0,l=a/2,u=d/2;o.label.points=[{x:i+l,y:s-u},{x:i+l,y:s-u},{x:i,y:s},{x:i-l,y:s+u},{x:i-l,y:s+u},{x:i,y:s},{x:i,y:s}]}})})}function Te(e,n){return W(Y(e,n),Number)}function Re(e){let n={};return e&&Object.entries(e).forEach(([t,r])=>{typeof t=="string"&&(t=t.toLowerCase()),n[t]=r}),n}function se(e){let n=S(e),t=new k({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{t.setNode(r,{label:r}),t.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>t.setEdge(r.v,r.w,{},r.name)),n.forEach((r,o)=>{let i="layer"+o;t.setNode(i,{rank:"same"}),r.reduce((s,a)=>(t.setEdge(s,a,{style:"invis"}),a))}),t}var Rr={time:fe,notime:z},jr={graphlib:Q,version:ne,layout:ie,debug:se,util:{time:fe,notime:z}},Ir=jr;return Dn(Sr);})();
|
|
2
2
|
/*! For license information please see dagre.min.js.LEGAL.txt */
|
|
3
3
|
//# sourceMappingURL=dagre.min.js.map
|