import{A as b,a as N,c as vr,d as K,e as _r,f as P,g as s,h as I,i as z,j as _,k as wr,l as Er,m as l,n as C,o as y,p as V,q as x,r as T,s as B,t as A,u as k,v as F,w as br,x as L,y as D,z as Q}from"./chunk-GT3P3F7J.min.js";import{Ba as Y,ha as mr,xa as G}from"./chunk-L5V3YLAC.min.js";function g(r,e,n,o){var t;do t=D(o);while(r.hasNode(t));return n.dummy=e,r.setNode(t,n),t}function yr(r){var e=new b().setGraph(r.graph());return s(r.nodes(),function(n){e.setNode(n,r.node(n))}),s(r.edges(),function(n){var o=e.edge(n.v,n.w)||{weight:0,minlen:1},t=r.edge(n);e.setEdge(n.v,n.w,{weight:o.weight+t.weight,minlen:Math.max(o.minlen,t.minlen)})}),e}function q(r){var e=new b({multigraph:r.isMultigraph()}).setGraph(r.graph());return s(r.nodes(),function(n){r.children(n).length||e.setNode(n,r.node(n))}),s(r.edges(),function(n){e.setEdge(n,r.edge(n))}),e}function Z(r,e){var n=r.x,o=r.y,t=e.x-n,i=e.y-o,a=r.width/2,f=r.height/2;if(!t&&!i)throw new Error("Not possible to find intersection inside of the rectangle");var u,d;return Math.abs(i)*a>Math.abs(t)*f?(i<0&&(f=-f),u=f*t/i,d=f):(t<0&&(a=-a),u=a,d=a*i/t),{x:n+u,y:o+d}}function R(r){var e=_(k(rr(r)+1),function(){return[]});return s(r.nodes(),function(n){var o=r.node(n),t=o.rank;y(t)||(e[t][o.order]=n)}),e}function xr(r){var e=T(_(r.nodes(),function(n){return r.node(n).rank}));s(r.nodes(),function(n){var o=r.node(n);l(o,"rank")&&(o.rank-=e)})}function kr(r){var e=T(_(r.nodes(),function(i){return r.node(i).rank})),n=[];s(r.nodes(),function(i){var a=r.node(i).rank-e;n[a]||(n[a]=[]),n[a].push(i)});var o=0,t=r.graph().nodeRankFactor;s(n,function(i,a){y(i)&&a%t!==0?--o:o&&s(i,function(f){r.node(f).rank+=o})})}function $(r,e,n,o){var t={width:0,height:0};return arguments.length>=4&&(t.rank=n,t.order=o),g(r,"border",t,e)}function rr(r){return x(_(r.nodes(),function(e){var n=r.node(e).rank;if(!y(n))return n}))}function gr(r,e){var n={lhs:[],rhs:[]};return s(r,function(o){e(o)?n.lhs.push(o):n.rhs.push(o)}),n}function Nr(r,e){var n=K();try{return e()}finally{console.log(r+" time: "+(K()-n)+"ms")}}function Ir(r,e){return e()}function Cr(r){function e(n){var o=r.children(n),t=r.node(n);if(o.length&&s(o,e),l(t,"minRank")){t.borderLeft=[],t.borderRight=[];for(var i=t.minRank,a=t.maxRank+1;i0;--f)if(a=e[f].dequeue(),a){o=o.concat(or(r,e,n,a,!0));break}}}return o}function or(r,e,n,o,t){var i=t?[]:void 0;return s(r.inEdges(o.v),function(a){var f=r.edge(a),u=r.node(a.v);t&&i.push({v:a.v,w:a.w}),u.out-=f,tr(e,n,u)}),s(r.outEdges(o.v),function(a){var f=r.edge(a),u=a.w,d=r.node(u);d.in-=f,tr(e,n,d)}),r.removeNode(o.v),i}function Ee(r,e){var n=new b,o=0,t=0;s(r.nodes(),function(f){n.setNode(f,{v:f,in:0,out:0})}),s(r.edges(),function(f){var u=n.edge(f.v,f.w)||0,d=e(f),c=u+d;n.setEdge(f.v,f.w,c),t=Math.max(t,n.node(f.v).out+=d),o=Math.max(o,n.node(f.w).in+=d)});var i=k(t+o+3).map(function(){return new X}),a=o+1;return s(n.nodes(),function(f){tr(i,a,n.node(f))}),{graph:n,buckets:i,zeroIdx:a}}function tr(r,e,n){n.out?n.in?r[n.out-n.in+e].enqueue(n):r[r.length-1].enqueue(n):r[0].enqueue(n)}function Or(r){var e=r.graph().acyclicer==="greedy"?Fr(r,n(r)):be(r);s(e,function(o){var t=r.edge(o);r.removeEdge(o),t.forwardName=o.name,t.reversed=!0,r.setEdge(o.w,o.v,t,D("rev"))});function n(o){return function(t){return o.edge(t).weight}}}function be(r){var e=[],n={},o={};function t(i){l(o,i)||(o[i]=!0,n[i]=!0,s(r.outEdges(i),function(a){l(n,a.w)?e.push(a):t(a.w)}),delete n[i])}return s(r.nodes(),t),e}function Gr(r){s(r.edges(),function(e){var n=r.edge(e);if(n.reversed){r.removeEdge(e);var o=n.forwardName;delete n.reversed,delete n.forwardName,r.setEdge(e.w,e.v,n,o)}})}function Br(r){r.graph().dummyChains=[],s(r.edges(),function(e){ye(r,e)})}function ye(r,e){var n=e.v,o=r.node(n).rank,t=e.w,i=r.node(t).rank,a=e.name,f=r.edge(e),u=f.labelRank;if(i!==o+1){r.removeEdge(e);var d,c,h;for(h=0,++o;oa.lim&&(f=a,u=!0);var d=I(e.edges(),function(c){return u===Yr(r,r.node(c.v),f)&&u!==Yr(r,r.node(c.w),f)});return B(d,function(c){return O(e,c)})}function Xr(r,e,n,o){var t=n.v,i=n.w;r.removeEdge(t,i),r.setEdge(o.v,o.w,{}),ur(r),sr(r,e),Re(r,e)}function Re(r,e){var n=z(r.nodes(),function(t){return!e.node(t).parent}),o=fr(r,n);o=o.slice(1),s(o,function(t){var i=r.node(t).parent,a=e.edge(t,i),f=!1;a||(a=e.edge(i,t),f=!0),e.node(t).rank=e.node(i).rank+(f?a.minlen:-a.minlen)})}function Se(r,e,n){return r.hasEdge(e,n)}function Yr(r,e,n){return n.low<=e.lim&&e.lim<=n.lim}function dr(r){switch(r.graph().ranker){case"network-simplex":Hr(r);break;case"tight-tree":Pe(r);break;case"longest-path":Me(r);break;default:Hr(r)}}var Me=U;function Pe(r){U(r),H(r)}function Hr(r){M(r)}function Jr(r){var e=g(r,"root",{},"_root"),n=Fe(r),o=x(C(n))-1,t=2*o+1;r.graph().nestingRoot=e,s(r.edges(),function(a){r.edge(a).minlen*=t});var i=Oe(r)+1;s(r.children(),function(a){Kr(r,e,t,i,o,n,a)}),r.graph().nodeRankFactor=t}function Kr(r,e,n,o,t,i,a){var f=r.children(a);if(!f.length){a!==e&&r.setEdge(e,a,{weight:0,minlen:n});return}var u=$(r,"_bt"),d=$(r,"_bb"),c=r.node(a);r.setParent(u,a),c.borderTop=u,r.setParent(d,a),c.borderBottom=d,s(f,function(h){Kr(r,e,n,o,t,i,h);var p=r.node(h),m=p.borderTop?p.borderTop:h,v=p.borderBottom?p.borderBottom:h,E=p.borderTop?o:2*o,j=m!==v?1:t-i[a]+1;r.setEdge(u,m,{weight:E,minlen:j,nestingEdge:!0}),r.setEdge(v,d,{weight:E,minlen:j,nestingEdge:!0})}),r.parent(a)||r.setEdge(e,u,{weight:0,minlen:t+i[a]})}function Fe(r){var e={};function n(o,t){var i=r.children(o);i&&i.length&&s(i,function(a){n(a,t+1)}),e[o]=t}return s(r.children(),function(o){n(o,1)}),e}function Oe(r){return F(r.edges(),function(e,n){return e+r.edge(n).weight},0)}function Qr(r){var e=r.graph();r.removeNode(e.nestingRoot),delete e.nestingRoot,s(r.edges(),function(n){var o=r.edge(n);o.nestingEdge&&r.removeEdge(n)})}function Zr(r,e,n){var o={},t;s(n,function(i){for(var a=r.parent(i),f,u;a;){if(f=r.parent(a),f?(u=o[f],o[f]=a):(u=t,t=a),u&&u!==a){e.setEdge(u,a);return}a=f}})}function $r(r,e,n){var o=Ve(r),t=new b({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(function(i){return r.node(i)});return s(r.nodes(),function(i){var a=r.node(i),f=r.parent(i);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(t.setNode(i),t.setParent(i,f||o),s(r[n](i),function(u){var d=u.v===i?u.w:u.v,c=t.edge(d,i),h=y(c)?0:c.weight;t.setEdge(d,i,{weight:r.edge(u).weight+h})}),l(a,"minRank")&&t.setNode(i,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))}),t}function Ve(r){for(var e;r.hasNode(e=D("_root")););return e}function re(r,e){for(var n=0,o=1;o0;)c%2&&(h+=f[c+1]),c=c-1>>1,f[c]+=d.weight;u+=d.weight*h})),u}function ee(r){var e={},n=I(r.nodes(),function(f){return!r.children(f).length}),o=x(_(n,function(f){return r.node(f).rank})),t=_(k(o+1),function(){return[]});function i(f){if(!l(e,f)){e[f]=!0;var u=r.node(f);t[u.rank].push(f),s(r.successors(f),i)}}var a=L(n,function(f){return r.node(f).rank});return s(a,i),t}function ne(r,e){return _(e,function(n){var o=r.inEdges(n);if(o.length){var t=F(o,function(i,a){var f=r.edge(a),u=r.node(a.v);return{sum:i.sum+f.weight*u.order,weight:i.weight+f.weight}},{sum:0,weight:0});return{v:n,barycenter:t.sum/t.weight,weight:t.weight}}else return{v:n}})}function oe(r,e){var n={};s(r,function(t,i){var a=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i};y(t.barycenter)||(a.barycenter=t.barycenter,a.weight=t.weight)}),s(e.edges(),function(t){var i=n[t.v],a=n[t.w];!y(i)&&!y(a)&&(a.indegree++,i.out.push(n[t.w]))});var o=I(n,function(t){return!t.indegree});return Ae(o)}function Ae(r){var e=[];function n(i){return function(a){a.merged||(y(a.barycenter)||y(i.barycenter)||a.barycenter>=i.barycenter)&&De(i,a)}}function o(i){return function(a){a.in.push(i),--a.indegree===0&&r.push(a)}}for(;r.length;){var t=r.pop();e.push(t),s(t.in.reverse(),n(t)),s(t.out,o(t))}return _(I(e,function(i){return!i.merged}),function(i){return A(i,["vs","i","barycenter","weight"])})}function De(r,e){var n=0,o=0;r.weight&&(n+=r.barycenter*r.weight,o+=r.weight),e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),r.vs=e.vs.concat(r.vs),r.barycenter=n/o,r.weight=o,r.i=Math.min(e.i,r.i),e.merged=!0}function ie(r,e){var n=gr(r,function(c){return l(c,"barycenter")}),o=n.lhs,t=L(n.rhs,function(c){return-c.i}),i=[],a=0,f=0,u=0;o.sort(je(!!e)),u=te(i,t,u),s(o,function(c){u+=c.vs.length,i.push(c.vs),a+=c.barycenter*c.weight,f+=c.weight,u=te(i,t,u)});var d={vs:N(i)};return f&&(d.barycenter=a/f,d.weight=f),d}function te(r,e,n){for(var o;e.length&&(o=P(e)).i<=n;)e.pop(),r.push(o.vs),n++;return n}function je(r){return function(e,n){return e.barycentern.barycenter?1:r?n.i-e.i:e.i-n.i}}function cr(r,e,n,o){var t=r.children(e),i=r.node(e),a=i?i.borderLeft:void 0,f=i?i.borderRight:void 0,u={};a&&(t=I(t,function(v){return v!==a&&v!==f}));var d=ne(r,t);s(d,function(v){if(r.children(v.v).length){var E=cr(r,v.v,n,o);u[v.v]=E,l(E,"barycenter")&&ze(v,E)}});var c=oe(d,n);Ye(c,u);var h=ie(c,o);if(a&&(h.vs=N([a,h.vs,f]),r.predecessors(a).length)){var p=r.node(r.predecessors(a)[0]),m=r.node(r.predecessors(f)[0]);l(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+p.order+m.order)/(h.weight+2),h.weight+=2}return h}function Ye(r,e){s(r,function(n){n.vs=N(n.vs.map(function(o){return e[o]?e[o].vs:o}))})}function ze(r,e){y(r.barycenter)?(r.barycenter=e.barycenter,r.weight=e.weight):(r.barycenter=(r.barycenter*r.weight+e.barycenter*e.weight)/(r.weight+e.weight),r.weight+=e.weight)}function se(r){var e=rr(r),n=ae(r,k(1,e+1),"inEdges"),o=ae(r,k(e-1,-1,-1),"outEdges"),t=ee(r);fe(r,t);for(var i=Number.POSITIVE_INFINITY,a,f=0,u=0;u<4;++f,++u){Ue(f%2?n:o,f%4>=2),t=R(r);var d=re(r,t);da||f>e[u].lim));for(d=u,u=o;(u=r.parent(u))!==d;)i.push(u);return{path:t.concat(i.reverse()),lca:d}}function qe(r){var e={},n=0;function o(t){var i=n;s(r.children(t),o),e[t]={low:i,lim:n++}}return s(r.children(),o),e}function Xe(r,e){var n={};function o(t,i){var a=0,f=0,u=t.length,d=P(i);return s(i,function(c,h){var p=Je(r,c),m=p?r.node(p).order:u;(p||c===d)&&(s(i.slice(f,h+1),function(v){s(r.predecessors(v),function(E){var j=r.node(E),pr=j.order;(prd)&&de(n,p,c)})})}function t(i,a){var f=-1,u,d=0;return s(a,function(c,h){if(r.node(c).dummy==="border"){var p=r.predecessors(c);p.length&&(u=r.node(p[0]).order,o(a,d,h,f,u),d=h,f=u)}o(a,d,a.length,u,i.length)}),a}return F(e,t),n}function Je(r,e){if(r.node(e).dummy)return z(r.predecessors(e),function(n){return r.node(n).dummy})}function de(r,e,n){if(e>n){var o=e;e=n,n=o}var t=r[e];t||(r[e]=t={}),t[n]=!0}function Ke(r,e,n){if(e>n){var o=e;e=n,n=o}return l(r[e],n)}function Qe(r,e,n,o){var t={},i={},a={};return s(e,function(f){s(f,function(u,d){t[u]=u,i[u]=u,a[u]=d})}),s(e,function(f){var u=-1;s(f,function(d){var c=o(d);if(c.length){c=L(c,function(E){return a[E]});for(var h=(c.length-1)/2,p=Math.floor(h),m=Math.ceil(h);p<=m;++p){var v=c[p];i[d]===d&&u