!(function(){var $u=Object.defineProperty,Xu=Object.defineProperties;var Ku=Object.getOwnPropertyDescriptors;var ti=Object.getOwnPropertySymbols;var _u=Object.prototype.hasOwnProperty,Zu=Object.prototype.propertyIsEnumerable;var ur=Math.pow,Yr=(Ke,je,me)=>je in Ke?$u(Ke,je,{enumerable:!0,configurable:!0,writable:!0,value:me}):Ke[je]=me,kn=(Ke,je)=>{for(var me in je||(je={}))_u.call(je,me)&&Yr(Ke,me,je[me]);if(ti)for(var me of ti(je))Zu.call(je,me)&&Yr(Ke,me,je[me]);return Ke},$r=(Ke,je)=>Xu(Ke,Ku(je));var be=(Ke,je,me)=>Yr(Ke,typeof je!="symbol"?je+"":je,me);(function(){var Ke={78585:function(w,P,a){"use strict";var f,x=Object.defineProperty,E=T=>{throw TypeError(T)},b=Math.pow,v=(T,u,c)=>u in T?x(T,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):T[u]=c,N=(T,u,c)=>v(T,typeof u!="symbol"?u+"":u,c),S=(T,u,c)=>u.has(T)||E("Cannot "+c),M=(T,u,c)=>(S(T,u,"read from private field"),c?c.call(T):u.get(T)),A=(T,u,c)=>u.has(T)?E("Cannot add the same private member more than once"):u instanceof WeakSet?u.add(T):u.set(T,c),I=(T,u,c,i)=>(S(T,u,"write to private field"),i?i.call(T,c):u.set(T,c),c),j=(T,u,c)=>(S(T,u,"access private method"),c),D,Y,K;f={value:!0};var ot=a(34634),nt=a(34402);const Q=" ".repeat(2),et=" ".repeat(4);function H(){return it(this)}function it(T,u={}){const{maxRows:c=15,maxColumns:i=10,maxNumSize:l=8,padMinus:m="auto"}=u;return`${T.constructor.name} { ${Q}[ ${et}${at(T,c,i,l,m)} ${Q}] ${Q}rows: ${T.rows} ${Q}columns: ${T.columns} }`}function at(T,u,c,i,l){const{rows:m,columns:B}=T,U=Math.min(m,u),V=Math.min(B,c),G=[];if(l==="auto"){l=!1;t:for(let rt=0;rt=0&&c?` ${ht(T,u-1)}`:ht(T,u)).padEnd(u)}function ht(T,u){let c=T.toString();if(c.length<=u)return c;let i=T.toFixed(u);if(i.length>u&&(i=T.toFixed(Math.max(0,u-(i.length-u)))),i.length<=u&&!i.startsWith("0.000")&&!i.startsWith("-0.000"))return i;let l=T.toExponential(u);return l.length>u&&(l=T.toExponential(Math.max(0,u-(l.length-u)))),l.slice(0)}function dt(T,u){T.prototype.add=function(i){return typeof i=="number"?this.addS(i):this.addM(i)},T.prototype.addS=function(i){for(let l=0;l>i);return this},T.prototype.signPropagatingRightShiftM=function(i){if(i=u.checkMatrix(i),this.rows!==i.rows||this.columns!==i.columns)throw new RangeError("Matrices dimensions must be equal");for(let l=0;l>i.get(l,m));return this},T.signPropagatingRightShift=function(i,l){return new u(i).signPropagatingRightShift(l)},T.prototype.rightShift=function(i){return typeof i=="number"?this.rightShiftS(i):this.rightShiftM(i)},T.prototype.rightShiftS=function(i){for(let l=0;l>>i);return this},T.prototype.rightShiftM=function(i){if(i=u.checkMatrix(i),this.rows!==i.rows||this.columns!==i.columns)throw new RangeError("Matrices dimensions must be equal");for(let l=0;l>>i.get(l,m));return this},T.rightShift=function(i,l){return new u(i).rightShift(l)},T.prototype.zeroFillRightShift=T.prototype.rightShift,T.prototype.zeroFillRightShiftS=T.prototype.rightShiftS,T.prototype.zeroFillRightShiftM=T.prototype.rightShiftM,T.zeroFillRightShift=T.rightShift,T.prototype.not=function(){for(let i=0;ii)throw new RangeError("Row index out of range")}function yt(T,u,c){let i=c?T.columns:T.columns-1;if(u<0||u>i)throw new RangeError("Column index out of range")}function Nt(T,u){if(u.to1DArray&&(u=u.to1DArray()),u.length!==T.columns)throw new RangeError("vector size must be the same as the number of columns");return u}function Ot(T,u){if(u.to1DArray&&(u=u.to1DArray()),u.length!==T.rows)throw new RangeError("vector size must be the same as the number of rows");return u}function Bt(T,u){if(!ot.isAnyArray(u))throw new TypeError("row indices must be an array");for(let c=0;c=T.rows)throw new RangeError("row indices are out of range")}function Vt(T,u){if(!ot.isAnyArray(u))throw new TypeError("column indices must be an array");for(let c=0;c=T.columns)throw new RangeError("column indices are out of range")}function Ht(T,u,c,i,l){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(ye("startRow",u),ye("endRow",c),ye("startColumn",i),ye("endColumn",l),u>c||i>l||u<0||u>=T.rows||c<0||c>=T.rows||i<0||i>=T.columns||l<0||l>=T.columns)throw new RangeError("Submatrix indices are out of range")}function ee(T,u=0){let c=[];for(let i=0;i=m)throw new RangeError("min must be smaller than max");let U=m-l,V=new It(u,c);for(let G=0;Gi?(m=!0,i=c):(l=!1,m=!0);u++}return l}isReducedEchelonForm(){let u=0,c=0,i=-1,l=!0,m=!1;for(;ui?(m=!0,i=c):(l=!1,m=!0);for(let B=c+1;Bu.get(l,i)&&(l=m);if(u.get(l,i)===0)i++;else{u.swapRows(c,l);let m=u.get(c,i);for(let B=i;B=0;)if(u.maxRow(l)===0)l--;else{let m=0,B=!1;for(;mc[i]&&(c[i]=this.get(i,l));return c}case"column":{const c=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let i=0;ic[l]&&(c[l]=this.get(i,l));return c}case void 0:{let c=this.get(0,0);for(let i=0;ic&&(c=this.get(i,l));return c}default:throw new Error(`invalid option: ${u}`)}}maxIndex(){$e(this);let u=this.get(0,0),c=[0,0];for(let i=0;iu&&(u=this.get(i,l),c[0]=i,c[1]=l);return c}min(u){if(this.isEmpty())return NaN;switch(u){case"row":{const c=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let i=0;ic&&(c=this.get(u,i));return c}maxRowIndex(u){xt(this,u),$e(this);let c=this.get(u,0),i=[u,0];for(let l=1;lc&&(c=this.get(u,l),i[1]=l);return i}minRow(u){if(xt(this,u),this.isEmpty())return NaN;let c=this.get(u,0);for(let i=1;ic&&(c=this.get(i,u));return c}maxColumnIndex(u){yt(this,u),$e(this);let c=this.get(0,u),i=[0,u];for(let l=1;lc&&(c=this.get(l,u),i[0]=l);return i}minColumn(u){if(yt(this,u),this.isEmpty())return NaN;let c=this.get(0,u);for(let i=1;i=1;l/=2)l&1&&(c=c.mmul(i)),i=i.mmul(i);return c}strassen2x2(u){u=It.checkMatrix(u);let c=new It(2,2);const i=this.get(0,0),l=u.get(0,0),m=this.get(0,1),B=u.get(0,1),U=this.get(1,0),V=u.get(1,0),G=this.get(1,1),rt=u.get(1,1),_=(i+G)*(l+rt),lt=(U+G)*l,Tt=i*(B-rt),ct=G*(V-l),pt=(i+m)*rt,Rt=(U-i)*(l+B),Z=(m-G)*(V+rt),St=_+ct-pt+Z,Ct=Tt+pt,Kt=lt+ct,Zt=_-lt+Tt+Rt;return c.set(0,0,St),c.set(0,1,Ct),c.set(1,0,Kt),c.set(1,1,Zt),c}strassen3x3(u){u=It.checkMatrix(u);let c=new It(3,3);const i=this.get(0,0),l=this.get(0,1),m=this.get(0,2),B=this.get(1,0),U=this.get(1,1),V=this.get(1,2),G=this.get(2,0),rt=this.get(2,1),_=this.get(2,2),lt=u.get(0,0),Tt=u.get(0,1),ct=u.get(0,2),pt=u.get(1,0),Rt=u.get(1,1),Z=u.get(1,2),St=u.get(2,0),Ct=u.get(2,1),Kt=u.get(2,2),Zt=(i+l+m-B-U-rt-_)*Rt,ge=(i-B)*(-Tt+Rt),Ut=U*(-lt+Tt+pt-Rt-Z-St+Kt),Yt=(-i+B+U)*(lt-Tt+Rt),ce=(B+U)*(-lt+Tt),tt=i*lt,wt=(-i+G+rt)*(lt-ct+Z),Lt=(-i+G)*(ct-Z),Mt=(G+rt)*(-lt+ct),we=(i+l+m-U-V-G-rt)*Z,ae=rt*(-lt+ct+pt-Rt-Z-St+Ct),fe=(-m+rt+_)*(Rt+St-Ct),pe=(m-_)*(Rt-Ct),Re=m*St,_e=(rt+_)*(-St+Ct),Se=(-m+U+V)*(Z+St-Kt),Qe=(m-V)*(Z-Kt),He=(U+V)*(-St+Kt),te=l*pt,Le=V*Ct,Ue=B*ct,Ve=G*Tt,Oe=_*Kt,wr=tt+Re+te,xr=Zt+Yt+ce+tt+fe+Re+_e,Qn=tt+wt+Mt+we+Re+Se+He,Er=ge+Ut+Yt+tt+Re+Se+Qe,Hn=ge+Yt+ce+tt+Le,br=Re+Se+Qe+He+Ue,Nr=tt+wt+Lt+ae+fe+pe+Re,Mr=fe+pe+Re+_e+Ve,qn=tt+wt+Lt+Mt+Oe;return c.set(0,0,wr),c.set(0,1,xr),c.set(0,2,Qn),c.set(1,0,Er),c.set(1,1,Hn),c.set(1,2,br),c.set(2,0,Nr),c.set(2,1,Mr),c.set(2,2,qn),c}mmulStrassen(u){u=It.checkMatrix(u);let c=this.clone(),i=c.rows,l=c.columns,m=u.rows,B=u.columns;l!==m&&console.warn(`Multiplying ${i} x ${l} and ${m} x ${B} matrix: dimensions do not match.`);function U(_,lt,Tt){let ct=_.rows,pt=_.columns;if(ct===lt&&pt===Tt)return _;{let Rt=Wt.zeros(lt,Tt);return Rt=Rt.setSubMatrix(_,0,0),Rt}}let V=Math.max(i,m),G=Math.max(l,B);c=U(c,V,G),u=U(u,V,G);function rt(_,lt,Tt,ct){if(Tt<=512||ct<=512)return _.mmul(lt);Tt%2===1&&ct%2===1?(_=U(_,Tt+1,ct+1),lt=U(lt,Tt+1,ct+1)):Tt%2===1?(_=U(_,Tt+1,ct),lt=U(lt,Tt+1,ct)):ct%2===1&&(_=U(_,Tt,ct+1),lt=U(lt,Tt,ct+1));let pt=parseInt(_.rows/2,10),Rt=parseInt(_.columns/2,10),Z=_.subMatrix(0,pt-1,0,Rt-1),St=lt.subMatrix(0,pt-1,0,Rt-1),Ct=_.subMatrix(0,pt-1,Rt,_.columns-1),Kt=lt.subMatrix(0,pt-1,Rt,lt.columns-1),Zt=_.subMatrix(pt,_.rows-1,0,Rt-1),ge=lt.subMatrix(pt,lt.rows-1,0,Rt-1),Ut=_.subMatrix(pt,_.rows-1,Rt,_.columns-1),Yt=lt.subMatrix(pt,lt.rows-1,Rt,lt.columns-1),ce=rt(Wt.add(Z,Ut),Wt.add(St,Yt),pt,Rt),tt=rt(Wt.add(Zt,Ut),St,pt,Rt),wt=rt(Z,Wt.sub(Kt,Yt),pt,Rt),Lt=rt(Ut,Wt.sub(ge,St),pt,Rt),Mt=rt(Wt.add(Z,Ct),Yt,pt,Rt),we=rt(Wt.sub(Zt,Z),Wt.add(St,Kt),pt,Rt),ae=rt(Wt.sub(Ct,Ut),Wt.add(ge,Yt),pt,Rt),fe=Wt.add(ce,Lt);fe.sub(Mt),fe.add(ae);let pe=Wt.add(wt,Mt),Re=Wt.add(tt,Lt),_e=Wt.sub(ce,tt);_e.add(wt),_e.add(we);let Se=Wt.zeros(2*fe.rows,2*fe.columns);return Se=Se.setSubMatrix(fe,0,0),Se=Se.setSubMatrix(pe,fe.rows,0),Se=Se.setSubMatrix(Re,0,fe.columns),Se=Se.setSubMatrix(_e,fe.rows,fe.columns),Se.subMatrix(0,Tt-1,0,ct-1)}return rt(c,u,V,G)}scaleRows(u={}){if(typeof u!="object")throw new TypeError("options must be an object");const{min:c=0,max:i=1}=u;if(!Number.isFinite(c))throw new TypeError("min must be a number");if(!Number.isFinite(i))throw new TypeError("max must be a number");if(c>=i)throw new RangeError("min must be smaller than max");let l=new It(this.rows,this.columns);for(let m=0;m0&&nt(B,{min:c,max:i,output:B}),l.setRow(m,B)}return l}scaleColumns(u={}){if(typeof u!="object")throw new TypeError("options must be an object");const{min:c=0,max:i=1}=u;if(!Number.isFinite(c))throw new TypeError("min must be a number");if(!Number.isFinite(i))throw new TypeError("max must be a number");if(c>=i)throw new RangeError("min must be smaller than max");let l=new It(this.rows,this.columns);for(let m=0;mi||c<0||c>=this.columns||i<0||i>=this.columns)throw new RangeError("Argument out of range");let l=new It(u.length,i-c+1);for(let m=0;m=this.rows)throw new RangeError(`Row index out of range: ${u[m]}`);l.set(m,B-c,this.get(u[m],B))}return l}subMatrixColumn(u,c,i){if(c===void 0&&(c=0),i===void 0&&(i=this.rows-1),c>i||c<0||c>=this.rows||i<0||i>=this.rows)throw new RangeError("Argument out of range");let l=new It(i-c+1,u.length);for(let m=0;m=this.columns)throw new RangeError(`Column index out of range: ${u[m]}`);l.set(B-c,m,this.get(B,u[m]))}return l}setSubMatrix(u,c,i){if(u=It.checkMatrix(u),u.isEmpty())return this;let l=c+u.rows-1,m=i+u.columns-1;Ht(this,c,l,i,m);for(let B=0;Btypeof u=="number")}Wt.random=Wt.rand,Wt.randomInt=Wt.randInt,Wt.diagonal=Wt.diag,Wt.prototype.diagonal=Wt.prototype.diag,Wt.identity=Wt.eye,Wt.prototype.negate=Wt.prototype.neg,Wt.prototype.tensorProduct=Wt.prototype.kroneckerProduct;const un=class Xr extends Wt{constructor(u,c){if(super(),A(this,D),N(this,"data"),Xr.isMatrix(u))j(this,D,Y).call(this,u.rows,u.columns),Xr.copy(u,this);else if(Number.isInteger(u)&&u>=0)j(this,D,Y).call(this,u,c);else if(ot.isAnyArray(u)){const i=u;if(u=i.length,c=u?i[0].length:0,typeof c!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let l=0;l=0)for(let c=0;c=0)I(this,K,new It(u,u));else if(I(this,K,new It(u)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return M(this,K).size}get rows(){return M(this,K).rows}get columns(){return M(this,K).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(u){return It.isMatrix(u)&&u.klassType==="SymmetricMatrix"}static zeros(u){return new this(u)}static ones(u){return new this(u).fill(1)}clone(){const u=new Kr(this.diagonalSize);for(const[c,i,l]of this.upperRightEntries())u.set(c,i,l);return u}toMatrix(){return new It(this)}get(u,c){return M(this,K).get(u,c)}set(u,c,i){return M(this,K).set(u,c,i),M(this,K).set(c,u,i),this}removeCross(u){return M(this,K).removeRow(u),M(this,K).removeColumn(u),this}addCross(u,c){c===void 0&&(c=u,u=this.diagonalSize);const i=c.slice();return i.splice(u,1),M(this,K).addRow(u,i),M(this,K).addColumn(u,c),this}applyMask(u){if(u.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const c=[];for(const[i,l]of u.entries())l||c.push(i);c.reverse();for(const i of c)this.removeCross(i);return this}toCompact(){const{diagonalSize:u}=this,c=new Array(u*(u+1)/2);for(let i=0,l=0,m=0;m=u&&(i=++l);return c}static fromCompact(u){const c=u.length,i=(Math.sqrt(8*c+1)-1)/2;if(!Number.isInteger(i))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(u)}`);const l=new Kr(i);for(let m=0,B=0,U=0;U=i&&(m=++B);return l}*upperRightEntries(){for(let u=0,c=0;u=this.diagonalSize&&(c=++u)}}*upperRightValues(){for(let u=0,c=0;u=this.diagonalSize&&(c=++u)}};K=new WeakMap;let Pe=fn;Pe.prototype.klassType="SymmetricMatrix";class xe extends Pe{static isDistanceMatrix(u){return Pe.isSymmetricMatrix(u)&&u.klassSubType==="DistanceMatrix"}constructor(u){if(super(u),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(u,c,i){return u===c&&(i=0),super.set(u,c,i)}addCross(u,c){return c===void 0&&(c=u,u=this.diagonalSize),c=c.slice(),c[u]=0,super.addCross(u,c)}toSymmetricMatrix(){return new Pe(this)}clone(){const u=new xe(this.diagonalSize);for(const[c,i,l]of this.upperRightEntries())c!==i&&u.set(c,i,l);return u}toCompact(){const{diagonalSize:u}=this,c=(u-1)*u/2,i=new Array(c);for(let l=1,m=0,B=0;B=u&&(l=++m+1);return i}static fromCompact(u){const c=u.length;if(c===0)return new this(0);const i=(Math.sqrt(8*c+1)+1)/2;if(!Number.isInteger(i))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(u)}`);const l=new this(i);for(let m=1,B=0,U=0;U=i&&(m=++B+1);return l}}xe.prototype.klassSubType="DistanceMatrix";class ke extends Wt{constructor(u,c,i){super(),this.matrix=u,this.rows=c,this.columns=i}}class vn extends ke{constructor(u,c){yt(u,c),super(u,u.rows,1),this.column=c}set(u,c,i){return this.matrix.set(u,this.column,i),this}get(u){return this.matrix.get(u,this.column)}}class On extends ke{constructor(u,c){Vt(u,c),super(u,u.rows,c.length),this.columnIndices=c}set(u,c,i){return this.matrix.set(u,this.columnIndices[c],i),this}get(u,c){return this.matrix.get(u,this.columnIndices[c])}}class Pn extends ke{constructor(u){super(u,u.rows,u.columns)}set(u,c,i){return this.matrix.set(u,this.columns-c-1,i),this}get(u,c){return this.matrix.get(u,this.columns-c-1)}}class sn extends ke{constructor(u){super(u,u.rows,u.columns)}set(u,c,i){return this.matrix.set(this.rows-u-1,c,i),this}get(u,c){return this.matrix.get(this.rows-u-1,c)}}class An extends ke{constructor(u,c){xt(u,c),super(u,1,u.columns),this.row=c}set(u,c,i){return this.matrix.set(this.row,c,i),this}get(u,c){return this.matrix.get(this.row,c)}}class Rn extends ke{constructor(u,c){Bt(u,c),super(u,c.length,u.columns),this.rowIndices=c}set(u,c,i){return this.matrix.set(this.rowIndices[u],c,i),this}get(u,c){return this.matrix.get(this.rowIndices[u],c)}}class mn extends ke{constructor(u,c,i){Bt(u,c),Vt(u,i),super(u,c.length,i.length),this.rowIndices=c,this.columnIndices=i}set(u,c,i){return this.matrix.set(this.rowIndices[u],this.columnIndices[c],i),this}get(u,c){return this.matrix.get(this.rowIndices[u],this.columnIndices[c])}}class Bn extends ke{constructor(u,c,i,l,m){Ht(u,c,i,l,m),super(u,i-c+1,m-l+1),this.startRow=c,this.startColumn=l}set(u,c,i){return this.matrix.set(this.startRow+u,this.startColumn+c,i),this}get(u,c){return this.matrix.get(this.startRow+u,this.startColumn+c)}}class Be extends ke{constructor(u){super(u,u.columns,u.rows)}set(u,c,i){return this.matrix.set(c,u,i),this}get(u,c){return this.matrix.get(c,u)}}class ze extends Wt{constructor(u,c={}){const{rows:i=1}=c;if(u.length%i!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=i,this.columns=u.length/i,this.data=u}set(u,c,i){let l=this._calculateIndex(u,c);return this.data[l]=i,this}get(u,c){let i=this._calculateIndex(u,c);return this.data[i]}_calculateIndex(u,c){return u*this.columns+c}}class Ae extends Wt{constructor(u){super(),this.data=u,this.rows=u.length,this.columns=u[0].length}set(u,c,i){return this.data[u][c]=i,this}get(u,c){return this.data[u][c]}}function cr(T,u){if(ot.isAnyArray(T))return T[0]&&ot.isAnyArray(T[0])?new Ae(T):new ze(T,u);throw new Error("the argument is not an array")}class $t{constructor(u){u=Ae.checkMatrix(u);let c=u.clone(),i=c.rows,l=c.columns,m=new Float64Array(i),B=1,U,V,G,rt,_,lt,Tt,ct,pt;for(U=0;UMath.abs(ct[rt])&&(rt=U);if(rt!==V){for(G=0;G=0;G--){for(V=0;VB?l.set(m,B,u.get(m,B)):m===B?l.set(m,B,1):l.set(m,B,0);return l}get upperTriangularMatrix(){let u=this.LU,c=u.rows,i=u.columns,l=new It(c,i);for(let m=0;mMath.abs(u)?(c=u/T,Math.abs(T)*Math.sqrt(1+c*c)):u!==0?(c=T/u,Math.abs(u)*Math.sqrt(1+c*c)):0}class Un{constructor(u){u=Ae.checkMatrix(u);let c=u.clone(),i=u.rows,l=u.columns,m=new Float64Array(l),B,U,V,G;for(V=0;V=0;G--){for(V=0;V=0;U--){for(m=0;m=0;tt--)if(ct[tt]!==0){for(let wt=tt+1;wt=0;tt--){if(tt0;){let tt,wt;for(tt=Ut-2;tt>=-1&&tt!==-1;tt--){const Lt=Number.MIN_VALUE+ce*Math.abs(ct[tt]+Math.abs(ct[tt+1]));if(Math.abs(Z[tt])<=Lt||Number.isNaN(Z[tt])){Z[tt]=0;break}}if(tt===Ut-2)wt=4;else{let Lt;for(Lt=Ut-1;Lt>=tt&&Lt!==tt;Lt--){let Mt=(Lt!==Ut?Math.abs(Z[Lt]):0)+(Lt!==tt+1?Math.abs(Z[Lt-1]):0);if(Math.abs(ct[Lt])<=ce*Mt){ct[Lt]=0;break}}Lt===tt?wt=3:Lt===Ut-1?wt=1:(wt=2,tt=Lt)}switch(tt++,wt){case 1:{let Lt=Z[Ut-2];Z[Ut-2]=0;for(let Mt=Ut-2;Mt>=tt;Mt--){let we=on(ct[Mt],Lt),ae=ct[Mt]/we,fe=Lt/we;if(ct[Mt]=we,Mt!==tt&&(Lt=-fe*Z[Mt-1],Z[Mt-1]=ae*Z[Mt-1]),G)for(let pe=0;pe=ct[tt+1]);){let Lt=ct[tt];if(ct[tt]=ct[tt+1],ct[tt+1]=Lt,G&&ttc&&m.set(rt,_,u.get(rt,_)/this.s[_]);let B=this.U,U=B.rows,V=B.columns,G=new It(i,U);for(let rt=0;rtu&&c++;return c}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return It.diag(this.s)}}function fr(T,u=!1){return T=Ae.checkMatrix(T),u?new ln(T).inverse():Zn(T,It.eye(T.rows))}function Zn(T,u,c=!1){return T=Ae.checkMatrix(T),u=Ae.checkMatrix(u),c?new ln(T).solve(u):T.isSquare()?new $t(T).solve(u):new Un(T).solve(u)}function Ln(T){if(T=It.checkMatrix(T),T.isSquare()){if(T.columns===0)return 1;let u,c,i,l;if(T.columns===2)return u=T.get(0,0),c=T.get(0,1),i=T.get(1,0),l=T.get(1,1),u*l-c*i;if(T.columns===3){let m,B,U;return m=new mn(T,[1,2],[1,2]),B=new mn(T,[1,2],[0,2]),U=new mn(T,[1,2],[0,1]),u=T.get(0,0),c=T.get(0,1),i=T.get(0,2),u*Ln(m)-c*Ln(B)+i*Ln(U)}else return new $t(T).determinant}else throw Error("determinant can only be calculated for a square matrix")}function lr(T,u){let c=[];for(let i=0;il)return new Array(u.rows+1).fill(0);{let m=u.addRow(c,[0]);for(let B=0;Bu?m[B]=1/m[B]:m[B]=0;return l.mmul(It.diag(m).mmul(i.transpose()))}function Gn(T,u=T,c={}){T=new It(T);let i=!1;if(typeof u=="object"&&!It.isMatrix(u)&&!ot.isAnyArray(u)?(c=u,u=T,i=!0):u=new It(u),T.rows!==u.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:l=!0}=c;l&&(T=T.center("column"),i||(u=u.center("column")));const m=T.transpose().mmul(u);for(let B=0;B0?l.set(m,m+1,c[m]):c[m]<0&&l.set(m,m-1,c[m])}return l}}function pr(T,u,c,i){let l,m,B,U,V,G,rt,_;for(V=0;V0;U--){for(_=0,B=0,G=0;G0&&(m=-m),u[U]=_*m,B=B-l*m,c[U-1]=l-m,V=0;VG)do{for(l=c[G],_=(c[G+1]-l)/(2*u[G]),lt=on(_,1),_<0&&(lt=-lt),c[G]=u[G]/(_+lt),c[G+1]=u[G]*(_+lt),Tt=c[G+1],m=l-c[G],B=G+2;B=G;B--)for(Rt=pt,pt=ct,Ct=St,l=ct*u[B],m=ct*_,lt=on(_,u[B]),u[B+1]=St*lt,St=u[B]/lt,ct=_/lt,_=ct*c[B]-St*l,c[B+1]=m+St*(ct*l+St*c[B]),V=0;Vge*Zt);c[G]=c[G]+Kt,u[G]=0}for(B=0;B=_;G--)c[G]=u.get(G,_-1)/lt,V+=c[G]*c[G];for(U=Math.sqrt(V),c[_]>0&&(U=-U),V=V-c[_]*U,c[_]=c[_]-U,rt=_;rt=_;G--)B+=c[G]*u.get(G,rt);for(B=B/V,G=_;G<=m;G++)u.set(G,rt,u.get(G,rt)-B*c[G])}for(G=0;G<=m;G++){for(B=0,rt=m;rt>=_;rt--)B+=c[rt]*u.get(G,rt);for(B=B/V,rt=_;rt<=m;rt++)u.set(G,rt,u.get(G,rt)-B*c[rt])}c[_]=lt*c[_],u.set(_,_-1,lt*U)}}for(G=0;G=l+1;_--)if(u.get(_,_-1)!==0){for(G=_+1;G<=m;G++)c[G]=u.get(G,_-1);for(rt=_;rt<=m;rt++){for(U=0,G=_;G<=m;G++)U+=c[G]*i.get(G,rt);for(U=U/c[_]/u.get(_,_-1),G=_;G<=m;G++)i.set(G,rt,i.get(G,rt)+U*c[G])}}}function mr(T,u,c,i,l){let m=T-1,B=0,U=T-1,V=Number.EPSILON,G=0,rt=0,_=0,lt=0,Tt=0,ct=0,pt=0,Rt=0,Z,St,Ct,Kt,Zt,ge,Ut,Yt,ce,tt,wt,Lt,Mt,we,ae;for(Z=0;ZU)&&(c[Z]=l.get(Z,Z),u[Z]=0),St=Math.max(Z-1,0);St=B;){for(Kt=m;Kt>B&&(ct=Math.abs(l.get(Kt-1,Kt-1))+Math.abs(l.get(Kt,Kt)),ct===0&&(ct=rt),!(Math.abs(l.get(Kt,Kt-1))=0){for(pt=_>=0?_+pt:_-pt,c[m-1]=Yt+pt,c[m]=c[m-1],pt!==0&&(c[m]=Yt-Ut/pt),u[m-1]=0,u[m]=0,Yt=l.get(m,m-1),ct=Math.abs(Yt)+Math.abs(pt),_=Yt/ct,lt=pt/ct,Tt=Math.sqrt(_*_+lt*lt),_=_/Tt,lt=lt/Tt,St=m-1;St0)){for(ct=Math.sqrt(ct),ce=Kt&&(pt=l.get(Zt,Zt),Tt=Yt-pt,ct=ce-pt,_=(Tt*ct-Ut)/l.get(Zt+1,Zt)+l.get(Zt,Zt+1),lt=l.get(Zt+1,Zt+1)-pt-Tt-ct,Tt=l.get(Zt+2,Zt+1),ct=Math.abs(_)+Math.abs(lt)+Math.abs(Tt),_=_/ct,lt=lt/ct,Tt=Tt/ct,!(Zt===Kt||Math.abs(l.get(Zt,Zt-1))*(Math.abs(lt)+Math.abs(Tt))Zt+2&&l.set(Z,Z-3,0);for(Ct=Zt;Ct<=m-1&&(we=Ct!==m-1,Ct!==Zt&&(_=l.get(Ct,Ct-1),lt=l.get(Ct+1,Ct-1),Tt=we?l.get(Ct+2,Ct-1):0,Yt=Math.abs(_)+Math.abs(lt)+Math.abs(Tt),Yt!==0&&(_=_/Yt,lt=lt/Yt,Tt=Tt/Yt)),Yt!==0);Ct++)if(ct=Math.sqrt(_*_+lt*lt+Tt*Tt),_<0&&(ct=-ct),ct!==0){for(Ct!==Zt?l.set(Ct,Ct-1,-ct*Yt):Kt!==Zt&&l.set(Ct,Ct-1,-l.get(Ct,Ct-1)),_=_+ct,Yt=_/ct,ce=lt/ct,pt=Tt/ct,lt=lt/_,Tt=Tt/_,St=Ct;St=0;m--)if(_=c[m],lt=u[m],lt===0)for(Kt=m,l.set(m,m,1),Z=m-1;Z>=0;Z--){for(Ut=l.get(Z,Z)-_,Tt=0,St=Kt;St<=m;St++)Tt=Tt+l.get(Z,St)*l.get(St,m);if(u[Z]<0)pt=Ut,ct=Tt;else if(Kt=Z,u[Z]===0?l.set(Z,m,Ut!==0?-Tt/Ut:-Tt/(V*rt)):(Yt=l.get(Z,Z+1),ce=l.get(Z+1,Z),lt=(c[Z]-_)*(c[Z]-_)+u[Z]*u[Z],ge=(Yt*ct-pt*Tt)/lt,l.set(Z,m,ge),l.set(Z+1,m,Math.abs(Yt)>Math.abs(pt)?(-Tt-Ut*ge)/Yt:(-ct-ce*ge)/pt)),ge=Math.abs(l.get(Z,m)),V*ge*ge>1)for(St=Z;St<=m;St++)l.set(St,m,l.get(St,m)/ge)}else if(lt<0)for(Kt=m-1,Math.abs(l.get(m,m-1))>Math.abs(l.get(m-1,m))?(l.set(m-1,m-1,lt/l.get(m,m-1)),l.set(m-1,m,-(l.get(m,m)-_)/l.get(m,m-1))):(ae=Tn(0,-l.get(m-1,m),l.get(m-1,m-1)-_,lt),l.set(m-1,m-1,ae[0]),l.set(m-1,m,ae[1])),l.set(m,m-1,0),l.set(m,m,1),Z=m-2;Z>=0;Z--){for(tt=0,wt=0,St=Kt;St<=m;St++)tt=tt+l.get(Z,St)*l.get(St,m-1),wt=wt+l.get(Z,St)*l.get(St,m);if(Ut=l.get(Z,Z)-_,u[Z]<0)pt=Ut,Tt=tt,ct=wt;else if(Kt=Z,u[Z]===0?(ae=Tn(-tt,-wt,Ut,lt),l.set(Z,m-1,ae[0]),l.set(Z,m,ae[1])):(Yt=l.get(Z,Z+1),ce=l.get(Z+1,Z),Lt=(c[Z]-_)*(c[Z]-_)+u[Z]*u[Z]-lt*lt,Mt=(c[Z]-_)*2*lt,Lt===0&&Mt===0&&(Lt=V*rt*(Math.abs(Ut)+Math.abs(lt)+Math.abs(Yt)+Math.abs(ce)+Math.abs(pt))),ae=Tn(Yt*Tt-pt*tt+lt*wt,Yt*ct-pt*wt-lt*tt,Lt,Mt),l.set(Z,m-1,ae[0]),l.set(Z,m,ae[1]),Math.abs(Yt)>Math.abs(pt)+Math.abs(lt)?(l.set(Z+1,m-1,(-tt-Ut*l.get(Z,m-1)+lt*l.get(Z,m))/Yt),l.set(Z+1,m,(-wt-Ut*l.get(Z,m)-lt*l.get(Z,m-1))/Yt)):(ae=Tn(-Tt-ce*l.get(Z,m-1),-ct-ce*l.get(Z,m),pt,lt),l.set(Z+1,m-1,ae[0]),l.set(Z+1,m,ae[1]))),ge=Math.max(Math.abs(l.get(Z,m-1)),Math.abs(l.get(Z,m))),V*ge*ge>1)for(St=Z;St<=m;St++)l.set(St,m-1,l.get(St,m-1)/ge),l.set(St,m,l.get(St,m)/ge)}for(Z=0;ZU)for(St=Z;St=B;St--)for(Z=B;Z<=U;Z++){for(pt=0,Ct=B;Ct<=Math.min(St,U);Ct++)pt=pt+i.get(Z,Ct)*l.get(Ct,St);i.set(Z,St,pt)}}}function Tn(T,u,c,i){let l,m;return Math.abs(c)>Math.abs(i)?(l=i/c,m=c+l*i,[(T+l*u)/m,(u-l*T)/m]):(l=c/i,m=i+l*c,[(l*T+u)/m,(l*u-T)/m])}class Wn{constructor(u){if(u=Ae.checkMatrix(u),!u.isSymmetric())throw new Error("Matrix is not symmetric");let c=u,i=c.rows,l=new It(i,i),m=!0,B,U,V;for(U=0;U0),l.set(U,U,Math.sqrt(Math.max(G,0))),V=U+1;V=0;V--)for(U=0;UB;Tt++)_=u.transpose().mmul(U).div(U.transpose().mmul(U).get(0,0)),_=_.div(_.norm()),G=u.mmul(_).div(_.transpose().mmul(_).get(0,0)),Tt>0&&(V=G.clone().sub(lt).pow(2).sum()),lt=G.clone(),i?(rt=i.transpose().mmul(G).div(G.transpose().mmul(G).get(0,0)),rt=rt.div(rt.norm()),U=i.mmul(rt).div(rt.transpose().mmul(rt).get(0,0))):U=G;if(i){let Tt=u.transpose().mmul(G).div(G.transpose().mmul(G).get(0,0));Tt=Tt.div(Tt.norm());let ct=u.clone().sub(G.clone().mmul(Tt.transpose())),pt=U.transpose().mmul(G).div(G.transpose().mmul(G).get(0,0)),Rt=i.clone().sub(G.clone().mulS(pt.get(0,0)).mmul(rt.transpose()));this.t=G,this.p=Tt.transpose(),this.w=_.transpose(),this.q=rt,this.u=U,this.s=G.transpose().mmul(G),this.xResidual=ct,this.yResidual=Rt,this.betas=pt}else this.w=_.transpose(),this.s=G.transpose().mmul(G).sqrt(),l?this.t=G.clone().div(this.s.get(0,0)):this.t=G,this.xResidual=u.sub(G.mmul(_.transpose()))}}P.XA=Wt,P.a_=Wn,P.yQ=Wn,P.Hs=xe,P.Ec=Jn,P.dx=Jn,P.LU=$t,P.Rm=$t,P.y3=It,P.qK=On,P.pb=vn,P.j=Pn,P.sO=sn,P.BZ=Rn,P.EK=An,P.Db=mn,P.Fx=Bn,P.tU=Be,P.Ym=yr,P.rs=yr,P.QR=Un,P.TB=Un,P.oH=ln,P.Sc=ln,P.BN=Pe,P.it=ze,P.$r=Ae,P.QM=gr,P.AV=Gn,f=It,P.GH=Ln,P.SO=fr,P.uZ=Vn,P.yU=hr,P.F1=Zn,P.re=cr},92546:function(w,P,a){w.exports={graphlib:a(76626),layout:a(47194),debug:a(11303),util:{time:a(53063).time,notime:a(53063).notime},version:a(11897)}},81255:function(w,P,a){"use strict";var f=a(72361),x=a(39240);w.exports={run:E,undo:v};function E(N){var S=N.graph().acyclicer==="greedy"?x(N,M(N)):b(N);f.forEach(S,function(A){var I=N.edge(A);N.removeEdge(A),I.forwardName=A.name,I.reversed=!0,N.setEdge(A.w,A.v,I,f.uniqueId("rev"))});function M(A){return function(I){return A.edge(I).weight}}}function b(N){var S=[],M={},A={};function I(j){f.has(A,j)||(A[j]=!0,M[j]=!0,f.forEach(N.outEdges(j),function(D){f.has(M,D.w)?S.push(D):I(D.w)}),delete M[j])}return f.forEach(N.nodes(),I),S}function v(N){f.forEach(N.edges(),function(S){var M=N.edge(S);if(M.reversed){N.removeEdge(S);var A=M.forwardName;delete M.reversed,delete M.forwardName,N.setEdge(S.w,S.v,M,A)}})}},60765:function(w,P,a){var f=a(72361),x=a(53063);w.exports=E;function E(v){function N(S){var M=v.children(S),A=v.node(S);if(M.length&&f.forEach(M,N),f.has(A,"minRank")){A.borderLeft=[],A.borderRight=[];for(var I=A.minRank,j=A.maxRank+1;I0;--Q)if(nt=j[Q].dequeue(),nt){Y=Y.concat(S(I,j,D,nt,!0));break}}}return Y}function S(I,j,D,Y,K){var ot=K?[]:void 0;return f.forEach(I.inEdges(Y.v),function(nt){var Q=I.edge(nt),et=I.node(nt.v);K&&ot.push({v:nt.v,w:nt.w}),et.out-=Q,A(j,D,et)}),f.forEach(I.outEdges(Y.v),function(nt){var Q=I.edge(nt),et=nt.w,H=I.node(et);H.in-=Q,A(j,D,H)}),I.removeNode(Y.v),ot}function M(I,j){var D=new x,Y=0,K=0;f.forEach(I.nodes(),function(Q){D.setNode(Q,{v:Q,in:0,out:0})}),f.forEach(I.edges(),function(Q){var et=D.edge(Q.v,Q.w)||0,H=j(Q),it=et+H;D.setEdge(Q.v,Q.w,it),K=Math.max(K,D.node(Q.v).out+=H),Y=Math.max(Y,D.node(Q.w).in+=H)});var ot=f.range(K+Y+3).map(function(){return new E}),nt=Y+1;return f.forEach(D.nodes(),function(Q){A(ot,nt,D.node(Q))}),{graph:D,buckets:ot,zeroIdx:nt}}function A(I,j,D){D.out?D.in?I[D.out-D.in+j].enqueue(D):I[I.length-1].enqueue(D):I[0].enqueue(D)}},47194:function(w,P,a){"use strict";var f=a(72361),x=a(81255),E=a(27163),b=a(64505),v=a(53063).normalizeRanks,N=a(71970),S=a(53063).removeEmptyRanks,M=a(31733),A=a(60765),I=a(13257),j=a(62852),D=a(93021),Y=a(53063),K=a(76626).Graph;w.exports=ot;function ot(gt,vt){var At=vt&&vt.debugTiming?Y.time:Y.notime;At("layout",function(){var Ft=At(" buildLayoutGraph",function(){return yt(gt)});At(" runLayout",function(){nt(Ft,At)}),At(" updateInputGraph",function(){Q(gt,Ft)})})}function nt(gt,vt){vt(" makeSpaceForEdgeLabels",function(){Nt(gt)}),vt(" removeSelfEdges",function(){Mn(gt)}),vt(" acyclic",function(){x.run(gt)}),vt(" nestingGraph.run",function(){M.run(gt)}),vt(" rank",function(){b(Y.asNonCompoundGraph(gt))}),vt(" injectEdgeLabelProxies",function(){Ot(gt)}),vt(" removeEmptyRanks",function(){S(gt)}),vt(" nestingGraph.cleanup",function(){M.cleanup(gt)}),vt(" normalizeRanks",function(){v(gt)}),vt(" assignRankMinMax",function(){Bt(gt)}),vt(" removeEdgeLabelProxies",function(){Vt(gt)}),vt(" normalize.run",function(){E.run(gt)}),vt(" parentDummyChains",function(){N(gt)}),vt(" addBorderSegments",function(){A(gt)}),vt(" order",function(){j(gt)}),vt(" insertSelfEdges",function(){Sn(gt)}),vt(" adjustCoordinateSystem",function(){I.adjust(gt)}),vt(" position",function(){D(gt)}),vt(" positionSelfEdges",function(){cn(gt)}),vt(" removeBorderNodes",function(){nn(gt)}),vt(" normalize.undo",function(){E.undo(gt)}),vt(" fixupEdgeLabelCoords",function(){ye(gt)}),vt(" undoCoordinateSystem",function(){I.undo(gt)}),vt(" translateGraph",function(){Ht(gt)}),vt(" assignNodeIntersects",function(){ee(gt)}),vt(" reversePoints",function(){$e(gt)}),vt(" acyclic.undo",function(){x.undo(gt)})}function Q(gt,vt){f.forEach(gt.nodes(),function(At){var Ft=gt.node(At),qt=vt.node(At);Ft&&(Ft.x=qt.x,Ft.y=qt.y,vt.children(At).length&&(Ft.width=qt.width,Ft.height=qt.height))}),f.forEach(gt.edges(),function(At){var Ft=gt.edge(At),qt=vt.edge(At);Ft.points=qt.points,f.has(qt,"x")&&(Ft.x=qt.x,Ft.y=qt.y)}),gt.graph().width=vt.graph().width,gt.graph().height=vt.graph().height}var et=["nodesep","edgesep","ranksep","marginx","marginy"],H={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},it=["acyclicer","ranker","rankdir","align"],at=["width","height"],ft={width:0,height:0},ht=["minlen","weight","width","height","labeloffset"],dt={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},xt=["labelpos"];function yt(gt){var vt=new K({multigraph:!0,compound:!0}),At=an(gt.graph());return vt.setGraph(f.merge({},H,Je(At,et),f.pick(At,it))),f.forEach(gt.nodes(),function(Ft){var qt=an(gt.node(Ft));vt.setNode(Ft,f.defaults(Je(qt,at),ft)),vt.setParent(Ft,gt.parent(Ft))}),f.forEach(gt.edges(),function(Ft){var qt=an(gt.edge(Ft));vt.setEdge(Ft,f.merge({},dt,Je(qt,ht),f.pick(qt,xt)))}),vt}function Nt(gt){var vt=gt.graph();vt.ranksep/=2,f.forEach(gt.edges(),function(At){var Ft=gt.edge(At);Ft.minlen*=2,Ft.labelpos.toLowerCase()!=="c"&&(vt.rankdir==="TB"||vt.rankdir==="BT"?Ft.width+=Ft.labeloffset:Ft.height+=Ft.labeloffset)})}function Ot(gt){f.forEach(gt.edges(),function(vt){var At=gt.edge(vt);if(At.width&&At.height){var Ft=gt.node(vt.v),qt=gt.node(vt.w),ue={rank:(qt.rank-Ft.rank)/2+Ft.rank,e:vt};Y.addDummyNode(gt,"edge-proxy",ue,"_ep")}})}function Bt(gt){var vt=0;f.forEach(gt.nodes(),function(At){var Ft=gt.node(At);Ft.borderTop&&(Ft.minRank=gt.node(Ft.borderTop).rank,Ft.maxRank=gt.node(Ft.borderBottom).rank,vt=f.max(vt,Ft.maxRank))}),gt.graph().maxRank=vt}function Vt(gt){f.forEach(gt.nodes(),function(vt){var At=gt.node(vt);At.dummy==="edge-proxy"&&(gt.edge(At.e).labelRank=At.rank,gt.removeNode(vt))})}function Ht(gt){var vt=Number.POSITIVE_INFINITY,At=0,Ft=Number.POSITIVE_INFINITY,qt=0,ue=gt.graph(),he=ue.marginx||0,Ie=ue.marginy||0;function pn(De){var Me=De.x,se=De.y,Wt=De.width,re=De.height;vt=Math.min(vt,Me-Wt/2),At=Math.max(At,Me+Wt/2),Ft=Math.min(Ft,se-re/2),qt=Math.max(qt,se+re/2)}f.forEach(gt.nodes(),function(De){pn(gt.node(De))}),f.forEach(gt.edges(),function(De){var Me=gt.edge(De);f.has(Me,"x")&&pn(Me)}),vt-=he,Ft-=Ie,f.forEach(gt.nodes(),function(De){var Me=gt.node(De);Me.x-=vt,Me.y-=Ft}),f.forEach(gt.edges(),function(De){var Me=gt.edge(De);f.forEach(Me.points,function(se){se.x-=vt,se.y-=Ft}),f.has(Me,"x")&&(Me.x-=vt),f.has(Me,"y")&&(Me.y-=Ft)}),ue.width=At-vt+he,ue.height=qt-Ft+Ie}function ee(gt){f.forEach(gt.edges(),function(vt){var At=gt.edge(vt),Ft=gt.node(vt.v),qt=gt.node(vt.w),ue,he;At.points?(ue=At.points[0],he=At.points[At.points.length-1]):(At.points=[],ue=qt,he=Ft),At.points.unshift(Y.intersectRect(Ft,ue)),At.points.push(Y.intersectRect(qt,he))})}function ye(gt){f.forEach(gt.edges(),function(vt){var At=gt.edge(vt);if(f.has(At,"x"))switch((At.labelpos==="l"||At.labelpos==="r")&&(At.width-=At.labeloffset),At.labelpos){case"l":At.x-=At.width/2+At.labeloffset;break;case"r":At.x+=At.width/2+At.labeloffset;break}})}function $e(gt){f.forEach(gt.edges(),function(vt){var At=gt.edge(vt);At.reversed&&At.points.reverse()})}function nn(gt){f.forEach(gt.nodes(),function(vt){if(gt.children(vt).length){var At=gt.node(vt),Ft=gt.node(At.borderTop),qt=gt.node(At.borderBottom),ue=gt.node(f.last(At.borderLeft)),he=gt.node(f.last(At.borderRight));At.width=Math.abs(he.x-ue.x),At.height=Math.abs(qt.y-Ft.y),At.x=ue.x+At.width/2,At.y=Ft.y+At.height/2}}),f.forEach(gt.nodes(),function(vt){gt.node(vt).dummy==="border"&>.removeNode(vt)})}function Mn(gt){f.forEach(gt.edges(),function(vt){if(vt.v===vt.w){var At=gt.node(vt.v);At.selfEdges||(At.selfEdges=[]),At.selfEdges.push({e:vt,label:gt.edge(vt)}),gt.removeEdge(vt)}})}function Sn(gt){var vt=Y.buildLayerMatrix(gt);f.forEach(vt,function(At){var Ft=0;f.forEach(At,function(qt,ue){var he=gt.node(qt);he.order=ue+Ft,f.forEach(he.selfEdges,function(Ie){Y.addDummyNode(gt,"selfedge",{width:Ie.label.width,height:Ie.label.height,rank:he.rank,order:ue+ ++Ft,e:Ie.e,label:Ie.label},"_se")}),delete he.selfEdges})})}function cn(gt){f.forEach(gt.nodes(),function(vt){var At=gt.node(vt);if(At.dummy==="selfedge"){var Ft=gt.node(At.e.v),qt=Ft.x+Ft.width/2,ue=Ft.y,he=At.x-qt,Ie=Ft.height/2;gt.setEdge(At.e,At.label),gt.removeNode(vt),At.label.points=[{x:qt+2*he/3,y:ue-Ie},{x:qt+5*he/6,y:ue-Ie},{x:qt+he,y:ue},{x:qt+5*he/6,y:ue+Ie},{x:qt+2*he/3,y:ue+Ie}],At.label.x=At.x,At.label.y=At.y}})}function Je(gt,vt){return f.mapValues(f.pick(gt,vt),Number)}function an(gt){var vt={};return f.forEach(gt,function(At,Ft){vt[Ft.toLowerCase()]=At}),vt}},72361:function(w,P,a){var f;try{f={cloneDeep:a(44187),constant:a(46221),defaults:a(34981),each:a(61475),filter:a(3130),find:a(48835),flatten:a(1332),forEach:a(47177),forIn:a(59946),has:a(64760),isUndefined:a(68408),last:a(47522),map:a(81426),mapValues:a(60032),max:a(18038),merge:a(55056),min:a(60169),minBy:a(13604),now:a(76308),pick:a(72333),range:a(69235),reduce:a(9695),sortBy:a(35020),uniqueId:a(69624),values:a(72834),zipObject:a(79261)}}catch(x){}f||(f=window._),w.exports=f},31733:function(w,P,a){var f=a(72361),x=a(53063);w.exports={run:E,cleanup:S};function E(M){var A=x.addDummyNode(M,"root",{},"_root"),I=v(M),j=f.max(f.values(I))-1,D=2*j+1;M.graph().nestingRoot=A,f.forEach(M.edges(),function(K){M.edge(K).minlen*=D});var Y=N(M)+1;f.forEach(M.children(),function(K){b(M,A,D,Y,j,I,K)}),M.graph().nodeRankFactor=D}function b(M,A,I,j,D,Y,K){var ot=M.children(K);if(!ot.length){K!==A&&M.setEdge(A,K,{weight:0,minlen:I});return}var nt=x.addBorderNode(M,"_bt"),Q=x.addBorderNode(M,"_bb"),et=M.node(K);M.setParent(nt,K),et.borderTop=nt,M.setParent(Q,K),et.borderBottom=Q,f.forEach(ot,function(H){b(M,A,I,j,D,Y,H);var it=M.node(H),at=it.borderTop?it.borderTop:H,ft=it.borderBottom?it.borderBottom:H,ht=it.borderTop?j:2*j,dt=at!==ft?1:D-Y[K]+1;M.setEdge(nt,at,{weight:ht,minlen:dt,nestingEdge:!0}),M.setEdge(ft,Q,{weight:ht,minlen:dt,nestingEdge:!0})}),M.parent(K)||M.setEdge(A,nt,{weight:0,minlen:D+Y[K]})}function v(M){var A={};function I(j,D){var Y=M.children(j);Y&&Y.length&&f.forEach(Y,function(K){I(K,D+1)}),A[j]=D}return f.forEach(M.children(),function(j){I(j,1)}),A}function N(M){return f.reduce(M.edges(),function(A,I){return A+M.edge(I).weight},0)}function S(M){var A=M.graph();M.removeNode(A.nestingRoot),delete A.nestingRoot,f.forEach(M.edges(),function(I){var j=M.edge(I);j.nestingEdge&&M.removeEdge(I)})}},27163:function(w,P,a){"use strict";var f=a(72361),x=a(53063);w.exports={run:E,undo:v};function E(N){N.graph().dummyChains=[],f.forEach(N.edges(),function(S){b(N,S)})}function b(N,S){var M=S.v,A=N.node(M).rank,I=S.w,j=N.node(I).rank,D=S.name,Y=N.edge(S),K=Y.labelRank;if(j!==A+1){N.removeEdge(S);var ot,nt,Q;for(Q=0,++A;A0;)K%2&&(ot+=j[K+1]),K=K-1>>1,j[K]+=Y.weight;D+=Y.weight*ot})),D}},62852:function(w,P,a){"use strict";var f=a(72361),x=a(18043),E=a(45456),b=a(86490),v=a(59105),N=a(52205),S=a(76626).Graph,M=a(53063);w.exports=A;function A(Y){var K=M.maxRank(Y),ot=I(Y,f.range(1,K+1),"inEdges"),nt=I(Y,f.range(K-1,-1,-1),"outEdges"),Q=x(Y);D(Y,Q);for(var et=Number.POSITIVE_INFINITY,H,it=0,at=0;at<4;++it,++at){j(it%2?ot:nt,it%4>=2),Q=M.buildLayerMatrix(Y);var ft=E(Y,Q);ft=I.barycenter)&&b(I,j)}}function M(I){return function(j){j.in.push(I),--j.indegree===0&&v.push(j)}}for(;v.length;){var A=v.pop();N.push(A),f.forEach(A.in.reverse(),S(A)),f.forEach(A.out,M(A))}return f.map(f.filter(N,function(I){return!I.merged}),function(I){return f.pick(I,["vs","i","barycenter","weight"])})}function b(v,N){var S=0,M=0;v.weight&&(S+=v.barycenter*v.weight,M+=v.weight),N.weight&&(S+=N.barycenter*N.weight,M+=N.weight),v.vs=N.vs.concat(v.vs),v.barycenter=S/M,v.weight=M,v.i=Math.min(N.i,v.i),N.merged=!0}},86490:function(w,P,a){var f=a(72361),x=a(99506),E=a(45926),b=a(1349);w.exports=v;function v(M,A,I,j){var D=M.children(A),Y=M.node(A),K=Y?Y.borderLeft:void 0,ot=Y?Y.borderRight:void 0,nt={};K&&(D=f.filter(D,function(ft){return ft!==K&&ft!==ot}));var Q=x(M,D);f.forEach(Q,function(ft){if(M.children(ft.v).length){var ht=v(M,ft.v,I,j);nt[ft.v]=ht,f.has(ht,"barycenter")&&S(ft,ht)}});var et=E(Q,I);N(et,nt);var H=b(et,j);if(K&&(H.vs=f.flatten([K,H.vs,ot],!0),M.predecessors(K).length)){var it=M.node(M.predecessors(K)[0]),at=M.node(M.predecessors(ot)[0]);f.has(H,"barycenter")||(H.barycenter=0,H.weight=0),H.barycenter=(H.barycenter*H.weight+it.order+at.order)/(H.weight+2),H.weight+=2}return H}function N(M,A){f.forEach(M,function(I){I.vs=f.flatten(I.vs.map(function(j){return A[j]?A[j].vs:j}),!0)})}function S(M,A){f.isUndefined(M.barycenter)?(M.barycenter=A.barycenter,M.weight=A.weight):(M.barycenter=(M.barycenter*M.weight+A.barycenter*A.weight)/(M.weight+A.weight),M.weight+=A.weight)}},1349:function(w,P,a){var f=a(72361),x=a(53063);w.exports=E;function E(N,S){var M=x.partition(N,function(nt){return f.has(nt,"barycenter")}),A=M.lhs,I=f.sortBy(M.rhs,function(nt){return-nt.i}),j=[],D=0,Y=0,K=0;A.sort(v(!!S)),K=b(j,I,K),f.forEach(A,function(nt){K+=nt.vs.length,j.push(nt.vs),D+=nt.barycenter*nt.weight,Y+=nt.weight,K=b(j,I,K)});var ot={vs:f.flatten(j,!0)};return Y&&(ot.barycenter=D/Y,ot.weight=Y),ot}function b(N,S,M){for(var A;S.length&&(A=f.last(S)).i<=M;)S.pop(),N.push(A.vs),M++;return M}function v(N){return function(S,M){return S.barycenterM.barycenter?1:N?M.i-S.i:S.i-M.i}}},71970:function(w,P,a){var f=a(72361);w.exports=x;function x(v){var N=b(v);f.forEach(v.graph().dummyChains,function(S){for(var M=v.node(S),A=M.edgeObj,I=E(v,N,A.v,A.w),j=I.path,D=I.lca,Y=0,K=j[Y],ot=!0;S!==A.w;){if(M=v.node(S),ot){for(;(K=j[Y])!==D&&v.node(K).maxRankj||D>N[Y].lim));for(K=Y,Y=M;(Y=v.parent(Y))!==K;)I.push(Y);return{path:A.concat(I.reverse()),lca:K}}function b(v){var N={},S=0;function M(A){var I=S;f.forEach(v.children(A),M),N[A]={low:I,lim:S++}}return f.forEach(v.children(),M),N}},25515:function(w,P,a){"use strict";var f=a(72361),x=a(76626).Graph,E=a(53063);w.exports={positionX:ot,findType1Conflicts:b,findType2Conflicts:v,addConflict:S,hasConflict:M,verticalAlignment:A,horizontalCompaction:I,alignCoordinates:Y,findSmallestWidthAlignment:D,balance:K};function b(et,H){var it={};function at(ft,ht){var dt=0,xt=0,yt=ft.length,Nt=f.last(ht);return f.forEach(ht,function(Ot,Bt){var Vt=N(et,Ot),Ht=Vt?et.node(Vt).order:yt;(Vt||Ot===Nt)&&(f.forEach(ht.slice(xt,Bt+1),function(ee){f.forEach(et.predecessors(ee),function(ye){var $e=et.node(ye),nn=$e.order;(nnNt)&&S(it,Vt,Ot)})})}function ft(ht,dt){var xt=-1,yt,Nt=0;return f.forEach(dt,function(Ot,Bt){if(et.node(Ot).dummy==="border"){var Vt=et.predecessors(Ot);Vt.length&&(yt=et.node(Vt[0]).order,at(dt,Nt,Bt,xt,yt),Nt=Bt,xt=yt)}at(dt,Nt,dt.length,yt,ht.length)}),dt}return f.reduce(H,ft),it}function N(et,H){if(et.node(H).dummy)return f.find(et.predecessors(H),function(it){return et.node(it).dummy})}function S(et,H,it){if(H>it){var at=H;H=it,it=at}var ft=et[H];ft||(et[H]=ft={}),ft[it]=!0}function M(et,H,it){if(H>it){var at=H;H=it,it=at}return f.has(et[H],it)}function A(et,H,it,at){var ft={},ht={},dt={};return f.forEach(H,function(xt){f.forEach(xt,function(yt,Nt){ft[yt]=yt,ht[yt]=yt,dt[yt]=Nt})}),f.forEach(H,function(xt){var yt=-1;f.forEach(xt,function(Nt){var Ot=at(Nt);if(Ot.length){Ot=f.sortBy(Ot,function(ye){return dt[ye]});for(var Bt=(Ot.length-1)/2,Vt=Math.floor(Bt),Ht=Math.ceil(Bt);Vt<=Ht;++Vt){var ee=Ot[Vt];ht[Nt]===Nt&&ytyt.lim&&(Nt=yt,Ot=!0);var Bt=f.filter(at.edges(),function(Vt){return Ot===H(it,it.node(Vt.v),Nt)&&Ot!==H(it,it.node(Vt.w),Nt)});return f.minBy(Bt,function(Vt){return E(at,Vt)})}function nt(it,at,ft,ht){var dt=ft.v,xt=ft.w;it.removeEdge(dt,xt),it.setEdge(ht.v,ht.w,{}),D(it),A(it,at),Q(it,at)}function Q(it,at){var ft=f.find(it.nodes(),function(dt){return!at.node(dt).parent}),ht=v(it,ft);ht=ht.slice(1),f.forEach(ht,function(dt){var xt=it.node(dt).parent,yt=at.edge(dt,xt),Nt=!1;yt||(yt=at.edge(xt,dt),Nt=!0),at.node(dt).rank=at.node(xt).rank+(Nt?yt.minlen:-yt.minlen)})}function et(it,at,ft){return it.hasEdge(at,ft)}function H(it,at,ft){return ft.low<=at.lim&&at.lim<=ft.lim}},2416:function(w,P,a){"use strict";var f=a(72361);w.exports={longestPath:x,slack:E};function x(b){var v={};function N(S){var M=b.node(S);if(f.has(v,S))return M.rank;v[S]=!0;var A=f.min(f.map(b.outEdges(S),function(I){return N(I.w)-b.edge(I).minlen}));return(A===Number.POSITIVE_INFINITY||A===void 0||A===null)&&(A=0),M.rank=A}f.forEach(b.sources(),N)}function E(b,v){return b.node(v.w).rank-b.node(v.v).rank-b.edge(v).minlen}},53063:function(w,P,a){"use strict";var f=a(72361),x=a(76626).Graph;w.exports={addDummyNode:E,simplify:b,asNonCompoundGraph:v,successorWeights:N,predecessorWeights:S,intersectRect:M,buildLayerMatrix:A,normalizeRanks:I,removeEmptyRanks:j,addBorderNode:D,maxRank:Y,partition:K,time:ot,notime:nt};function E(Q,et,H,it){var at;do at=f.uniqueId(it);while(Q.hasNode(at));return H.dummy=et,Q.setNode(at,H),at}function b(Q){var et=new x().setGraph(Q.graph());return f.forEach(Q.nodes(),function(H){et.setNode(H,Q.node(H))}),f.forEach(Q.edges(),function(H){var it=et.edge(H.v,H.w)||{weight:0,minlen:1},at=Q.edge(H);et.setEdge(H.v,H.w,{weight:it.weight+at.weight,minlen:Math.max(it.minlen,at.minlen)})}),et}function v(Q){var et=new x({multigraph:Q.isMultigraph()}).setGraph(Q.graph());return f.forEach(Q.nodes(),function(H){Q.children(H).length||et.setNode(H,Q.node(H))}),f.forEach(Q.edges(),function(H){et.setEdge(H,Q.edge(H))}),et}function N(Q){var et=f.map(Q.nodes(),function(H){var it={};return f.forEach(Q.outEdges(H),function(at){it[at.w]=(it[at.w]||0)+Q.edge(at).weight}),it});return f.zipObject(Q.nodes(),et)}function S(Q){var et=f.map(Q.nodes(),function(H){var it={};return f.forEach(Q.inEdges(H),function(at){it[at.v]=(it[at.v]||0)+Q.edge(at).weight}),it});return f.zipObject(Q.nodes(),et)}function M(Q,et){var H=Q.x,it=Q.y,at=et.x-H,ft=et.y-it,ht=Q.width/2,dt=Q.height/2;if(!at&&!ft)throw new Error("Not possible to find intersection inside of the rectangle");var xt,yt;return Math.abs(ft)*ht>Math.abs(at)*dt?(ft<0&&(dt=-dt),xt=dt*at/ft,yt=dt):(at<0&&(ht=-ht),xt=ht,yt=ht*ft/at),{x:H+xt,y:it+yt}}function A(Q){var et=f.map(f.range(Y(Q)+1),function(){return[]});return f.forEach(Q.nodes(),function(H){var it=Q.node(H),at=it.rank;f.isUndefined(at)||(et[at][it.order]=H)}),et}function I(Q){var et=f.min(f.map(Q.nodes(),function(H){return Q.node(H).rank}));f.forEach(Q.nodes(),function(H){var it=Q.node(H);f.has(it,"rank")&&(it.rank-=et)})}function j(Q){var et=f.min(f.map(Q.nodes(),function(ft){return Q.node(ft).rank})),H=[];f.forEach(Q.nodes(),function(ft){var ht=Q.node(ft).rank-et;H[ht]||(H[ht]=[]),H[ht].push(ft)});var it=0,at=Q.graph().nodeRankFactor;f.forEach(H,function(ft,ht){f.isUndefined(ft)&&ht%at!==0?--it:it&&f.forEach(ft,function(dt){Q.node(dt).rank+=it})})}function D(Q,et,H,it){var at={width:0,height:0};return arguments.length>=4&&(at.rank=H,at.order=it),E(Q,"border",at,et)}function Y(Q){return f.max(f.map(Q.nodes(),function(et){var H=Q.node(et).rank;if(!f.isUndefined(H))return H}))}function K(Q,et){var H={lhs:[],rhs:[]};return f.forEach(Q,function(it){et(it)?H.lhs.push(it):H.rhs.push(it)}),H}function ot(Q,et){var H=f.now();try{return et()}finally{console.log(Q+" time: "+(f.now()-H)+"ms")}}function nt(Q,et){return et()}},11897:function(w){w.exports="0.8.5"},75172:function(w,P,a){var f=a(89224);w.exports={Graph:f.Graph,json:a(17401),alg:a(54613),version:f.version}},91606:function(w,P,a){var f=a(95329);w.exports=x;function x(E){var b={},v=[],N;function S(M){f.has(b,M)||(b[M]=!0,N.push(M),f.each(E.successors(M),S),f.each(E.predecessors(M),S))}return f.each(E.nodes(),function(M){N=[],S(M),N.length&&v.push(N)}),v}},21482:function(w,P,a){var f=a(95329);w.exports=x;function x(b,v,N){f.isArray(v)||(v=[v]);var S=(b.isDirected()?b.successors:b.neighbors).bind(b),M=[],A={};return f.each(v,function(I){if(!b.hasNode(I))throw new Error("Graph does not have node: "+I);E(b,I,N==="post",A,S,M)}),M}function E(b,v,N,S,M,A){f.has(S,v)||(S[v]=!0,N||A.push(v),f.each(M(v),function(I){E(b,I,N,S,M,A)}),N&&A.push(v))}},40845:function(w,P,a){var f=a(13746),x=a(95329);w.exports=E;function E(b,v,N){return x.transform(b.nodes(),function(S,M){S[M]=f(b,M,v,N)},{})}},13746:function(w,P,a){var f=a(95329),x=a(36614);w.exports=b;var E=f.constant(1);function b(N,S,M,A){return v(N,String(S),M||E,A||function(I){return N.outEdges(I)})}function v(N,S,M,A){var I={},j=new x,D,Y,K=function(ot){var nt=ot.v!==D?ot.v:ot.w,Q=I[nt],et=M(ot),H=Y.distance+et;if(et<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+ot+" Weight: "+et);H0&&(D=j.removeMin(),Y=I[D],Y.distance!==Number.POSITIVE_INFINITY);)A(D).forEach(K);return I}},59324:function(w,P,a){var f=a(95329),x=a(94558);w.exports=E;function E(b){return f.filter(x(b),function(v){return v.length>1||v.length===1&&b.hasEdge(v[0],v[0])})}},22893:function(w,P,a){var f=a(95329);w.exports=E;var x=f.constant(1);function E(v,N,S){return b(v,N||x,S||function(M){return v.outEdges(M)})}function b(v,N,S){var M={},A=v.nodes();return A.forEach(function(I){M[I]={},M[I][I]={distance:0},A.forEach(function(j){I!==j&&(M[I][j]={distance:Number.POSITIVE_INFINITY})}),S(I).forEach(function(j){var D=j.v===I?j.w:j.v,Y=N(j);M[I][D]={distance:Y,predecessor:I}})}),A.forEach(function(I){var j=M[I];A.forEach(function(D){var Y=M[D];A.forEach(function(K){var ot=Y[I],nt=j[K],Q=Y[K],et=ot.distance+nt.distance;et0;){if(I=A.removeMin(),f.has(M,I))S.setEdge(I,M[I]);else{if(D)throw new Error("Input graph is not connected: "+v);D=!0}v.nodeEdges(I).forEach(j)}return S}},94558:function(w,P,a){var f=a(95329);w.exports=x;function x(E){var b=0,v=[],N={},S=[];function M(A){var I=N[A]={onStack:!0,lowlink:b,index:b++};if(v.push(A),E.successors(A).forEach(function(Y){f.has(N,Y)?N[Y].onStack&&(I.lowlink=Math.min(I.lowlink,N[Y].index)):(M(Y),I.lowlink=Math.min(I.lowlink,N[Y].lowlink))}),I.lowlink===I.index){var j=[],D;do D=v.pop(),N[D].onStack=!1,j.push(D);while(A!==D);S.push(j)}}return E.nodes().forEach(function(A){f.has(N,A)||M(A)}),S}},7793:function(w,P,a){var f=a(95329);w.exports=x,x.CycleException=E;function x(b){var v={},N={},S=[];function M(A){if(f.has(N,A))throw new E;f.has(v,A)||(N[A]=!0,v[A]=!0,f.each(b.predecessors(A),M),delete N[A],S.push(A))}if(f.each(b.sinks(),M),f.size(v)!==b.nodeCount())throw new E;return S}function E(){}E.prototype=new Error},36614:function(w,P,a){var f=a(95329);w.exports=x;function x(){this._arr=[],this._keyIndices={}}x.prototype.size=function(){return this._arr.length},x.prototype.keys=function(){return this._arr.map(function(E){return E.key})},x.prototype.has=function(E){return f.has(this._keyIndices,E)},x.prototype.priority=function(E){var b=this._keyIndices[E];if(b!==void 0)return this._arr[b].priority},x.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},x.prototype.add=function(E,b){var v=this._keyIndices;if(E=String(E),!f.has(v,E)){var N=this._arr,S=N.length;return v[E]=S,N.push({key:E,priority:b}),this._decrease(S),!0}return!1},x.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var E=this._arr.pop();return delete this._keyIndices[E.key],this._heapify(0),E.key},x.prototype.decrease=function(E,b){var v=this._keyIndices[E];if(b>this._arr[v].priority)throw new Error("New priority is greater than current priority. Key: "+E+" Old: "+this._arr[v].priority+" New: "+b);this._arr[v].priority=b,this._decrease(v)},x.prototype._heapify=function(E){var b=this._arr,v=2*E,N=v+1,S=E;v>1,!(b[N].priority1?K.setNode(ot,D):K.setNode(ot)}),this},v.prototype.setNode=function(j,D){return f.has(this._nodes,j)?(arguments.length>1&&(this._nodes[j]=D),this):(this._nodes[j]=arguments.length>1?D:this._defaultNodeLabelFn(j),this._isCompound&&(this._parent[j]=E,this._children[j]={},this._children[E][j]=!0),this._in[j]={},this._preds[j]={},this._out[j]={},this._sucs[j]={},++this._nodeCount,this)},v.prototype.node=function(j){return this._nodes[j]},v.prototype.hasNode=function(j){return f.has(this._nodes,j)},v.prototype.removeNode=function(j){var D=this;if(f.has(this._nodes,j)){var Y=function(K){D.removeEdge(D._edgeObjs[K])};delete this._nodes[j],this._isCompound&&(this._removeFromParentsChildList(j),delete this._parent[j],f.each(this.children(j),function(K){D.setParent(K)}),delete this._children[j]),f.each(f.keys(this._in[j]),Y),delete this._in[j],delete this._preds[j],f.each(f.keys(this._out[j]),Y),delete this._out[j],delete this._sucs[j],--this._nodeCount}return this},v.prototype.setParent=function(j,D){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(f.isUndefined(D))D=E;else{D+="";for(var Y=D;!f.isUndefined(Y);Y=this.parent(Y))if(Y===j)throw new Error("Setting "+D+" as parent of "+j+" would create a cycle");this.setNode(D)}return this.setNode(j),this._removeFromParentsChildList(j),this._parent[j]=D,this._children[D][j]=!0,this},v.prototype._removeFromParentsChildList=function(j){delete this._children[this._parent[j]][j]},v.prototype.parent=function(j){if(this._isCompound){var D=this._parent[j];if(D!==E)return D}},v.prototype.children=function(j){if(f.isUndefined(j)&&(j=E),this._isCompound){var D=this._children[j];if(D)return f.keys(D)}else{if(j===E)return this.nodes();if(this.hasNode(j))return[]}},v.prototype.predecessors=function(j){var D=this._preds[j];if(D)return f.keys(D)},v.prototype.successors=function(j){var D=this._sucs[j];if(D)return f.keys(D)},v.prototype.neighbors=function(j){var D=this.predecessors(j);if(D)return f.union(D,this.successors(j))},v.prototype.isLeaf=function(j){var D;return this.isDirected()?D=this.successors(j):D=this.neighbors(j),D.length===0},v.prototype.filterNodes=function(j){var D=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});D.setGraph(this.graph());var Y=this;f.each(this._nodes,function(nt,Q){j(Q)&&D.setNode(Q,nt)}),f.each(this._edgeObjs,function(nt){D.hasNode(nt.v)&&D.hasNode(nt.w)&&D.setEdge(nt,Y.edge(nt))});var K={};function ot(nt){var Q=Y.parent(nt);return Q===void 0||D.hasNode(Q)?(K[nt]=Q,Q):Q in K?K[Q]:ot(Q)}return this._isCompound&&f.each(D.nodes(),function(nt){D.setParent(nt,ot(nt))}),D},v.prototype.setDefaultEdgeLabel=function(j){return f.isFunction(j)||(j=f.constant(j)),this._defaultEdgeLabelFn=j,this},v.prototype.edgeCount=function(){return this._edgeCount},v.prototype.edges=function(){return f.values(this._edgeObjs)},v.prototype.setPath=function(j,D){var Y=this,K=arguments;return f.reduce(j,function(ot,nt){return K.length>1?Y.setEdge(ot,nt,D):Y.setEdge(ot,nt),nt}),this},v.prototype.setEdge=function(){var j,D,Y,K,ot=!1,nt=arguments[0];typeof nt=="object"&&nt!==null&&"v"in nt?(j=nt.v,D=nt.w,Y=nt.name,arguments.length===2&&(K=arguments[1],ot=!0)):(j=nt,D=arguments[1],Y=arguments[3],arguments.length>2&&(K=arguments[2],ot=!0)),j=""+j,D=""+D,f.isUndefined(Y)||(Y=""+Y);var Q=M(this._isDirected,j,D,Y);if(f.has(this._edgeLabels,Q))return ot&&(this._edgeLabels[Q]=K),this;if(!f.isUndefined(Y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(j),this.setNode(D),this._edgeLabels[Q]=ot?K:this._defaultEdgeLabelFn(j,D,Y);var et=A(this._isDirected,j,D,Y);return j=et.v,D=et.w,Object.freeze(et),this._edgeObjs[Q]=et,N(this._preds[D],j),N(this._sucs[j],D),this._in[D][Q]=et,this._out[j][Q]=et,this._edgeCount++,this},v.prototype.edge=function(j,D,Y){var K=arguments.length===1?I(this._isDirected,arguments[0]):M(this._isDirected,j,D,Y);return this._edgeLabels[K]},v.prototype.hasEdge=function(j,D,Y){var K=arguments.length===1?I(this._isDirected,arguments[0]):M(this._isDirected,j,D,Y);return f.has(this._edgeLabels,K)},v.prototype.removeEdge=function(j,D,Y){var K=arguments.length===1?I(this._isDirected,arguments[0]):M(this._isDirected,j,D,Y),ot=this._edgeObjs[K];return ot&&(j=ot.v,D=ot.w,delete this._edgeLabels[K],delete this._edgeObjs[K],S(this._preds[D],j),S(this._sucs[j],D),delete this._in[D][K],delete this._out[j][K],this._edgeCount--),this},v.prototype.inEdges=function(j,D){var Y=this._in[j];if(Y){var K=f.values(Y);return D?f.filter(K,function(ot){return ot.v===D}):K}},v.prototype.outEdges=function(j,D){var Y=this._out[j];if(Y){var K=f.values(Y);return D?f.filter(K,function(ot){return ot.w===D}):K}},v.prototype.nodeEdges=function(j,D){var Y=this.inEdges(j,D);if(Y)return Y.concat(this.outEdges(j,D))};function N(j,D){j[D]?j[D]++:j[D]=1}function S(j,D){--j[D]||delete j[D]}function M(j,D,Y,K){var ot=""+D,nt=""+Y;if(!j&&ot>nt){var Q=ot;ot=nt,nt=Q}return ot+b+nt+b+(f.isUndefined(K)?x:K)}function A(j,D,Y,K){var ot=""+D,nt=""+Y;if(!j&&ot>nt){var Q=ot;ot=nt,nt=Q}var et={v:ot,w:nt};return K&&(et.name=K),et}function I(j,D){return M(j,D.v,D.w,D.name)}},89224:function(w,P,a){w.exports={Graph:a(6349),version:a(16544)}},17401:function(w,P,a){var f=a(95329),x=a(6349);w.exports={write:E,read:N};function E(S){var M={options:{directed:S.isDirected(),multigraph:S.isMultigraph(),compound:S.isCompound()},nodes:b(S),edges:v(S)};return f.isUndefined(S.graph())||(M.value=f.clone(S.graph())),M}function b(S){return f.map(S.nodes(),function(M){var A=S.node(M),I=S.parent(M),j={v:M};return f.isUndefined(A)||(j.value=A),f.isUndefined(I)||(j.parent=I),j})}function v(S){return f.map(S.edges(),function(M){var A=S.edge(M),I={v:M.v,w:M.w};return f.isUndefined(M.name)||(I.name=M.name),f.isUndefined(A)||(I.value=A),I})}function N(S){var M=new x(S.options).setGraph(S.value);return f.each(S.nodes,function(A){M.setNode(A.v,A.value),A.parent&&M.setParent(A.v,A.parent)}),f.each(S.edges,function(A){M.setEdge({v:A.v,w:A.w,name:A.name},A.value)}),M}},95329:function(w,P,a){var f;try{f={clone:a(40633),constant:a(46221),each:a(61475),filter:a(3130),has:a(64760),isArray:a(41594),isEmpty:a(74336),isFunction:a(92581),isUndefined:a(68408),keys:a(66357),map:a(81426),reduce:a(9695),size:a(24727),transform:a(61477),union:a(99477),values:a(72834)}}catch(x){}f||(f=window._),w.exports=f},16544:function(w){w.exports="2.1.8"},34634:function(w,P,a){"use strict";a.r(P),a.d(P,{isAnyArray:function(){return x}});const f=Object.prototype.toString;function x(E){const b=f.call(E);return b.endsWith("Array]")&&!b.includes("Big")}},23346:function(w,P,a){var f=a(93454),x=a(40911),E=f(x,"DataView");w.exports=E},79955:function(w,P,a){var f=a(65812),x=a(87e3),E=a(66198),b=a(64800),v=a(8602);function N(S){var M=-1,A=S==null?0:S.length;for(this.clear();++M-1}w.exports=x},90746:function(w){function P(a,f,x){for(var E=-1,b=a==null?0:a.length;++E0&&N(j)?v>1?E(j,v-1,N,S,M):f(M,j):S||(M[M.length]=j)}return M}w.exports=E},43294:function(w,P,a){var f=a(78323),x=f();w.exports=x},23543:function(w,P,a){var f=a(43294),x=a(66357);function E(b,v){return b&&f(b,v,x)}w.exports=E},96980:function(w,P,a){var f=a(89382),x=a(90370);function E(b,v){v=f(v,b);for(var N=0,S=v.length;b!=null&&Nf}w.exports=P},11874:function(w){var P=Object.prototype,a=P.hasOwnProperty;function f(x,E){return x!=null&&a.call(x,E)}w.exports=f},45146:function(w){function P(a,f){return a!=null&&f in Object(a)}w.exports=P},17713:function(w,P,a){var f=a(33405),x=a(17406),E=a(68048);function b(v,N,S){return N===N?E(v,N,S):f(v,x,S)}w.exports=b},3841:function(w,P,a){var f=a(17325),x=a(71161),E="[object Arguments]";function b(v){return x(v)&&f(v)==E}w.exports=b},30433:function(w,P,a){var f=a(98317),x=a(71161);function E(b,v,N,S,M){return b===v?!0:b==null||v==null||!x(b)&&!x(v)?b!==b&&v!==v:f(b,v,N,S,E,M)}w.exports=E},98317:function(w,P,a){var f=a(26163),x=a(70670),E=a(23499),b=a(83544),v=a(29148),N=a(41594),S=a(33636),M=a(53745),A=1,I="[object Arguments]",j="[object Array]",D="[object Object]",Y=Object.prototype,K=Y.hasOwnProperty;function ot(nt,Q,et,H,it,at){var ft=N(nt),ht=N(Q),dt=ft?j:v(nt),xt=ht?j:v(Q);dt=dt==I?D:dt,xt=xt==I?D:xt;var yt=dt==D,Nt=xt==D,Ot=dt==xt;if(Ot&&S(nt)){if(!S(Q))return!1;ft=!0,yt=!1}if(Ot&&!yt)return at||(at=new f),ft||M(nt)?x(nt,Q,et,H,it,at):E(nt,Q,dt,et,H,it,at);if(!(et&A)){var Bt=yt&&K.call(nt,"__wrapped__"),Vt=Nt&&K.call(Q,"__wrapped__");if(Bt||Vt){var Ht=Bt?nt.value():nt,ee=Vt?Q.value():Q;return at||(at=new f),it(Ht,ee,et,H,at)}}return Ot?(at||(at=new f),b(nt,Q,et,H,it,at)):!1}w.exports=ot},9961:function(w,P,a){var f=a(29148),x=a(71161),E="[object Map]";function b(v){return x(v)&&f(v)==E}w.exports=b},44626:function(w,P,a){var f=a(26163),x=a(30433),E=1,b=2;function v(N,S,M,A){var I=M.length,j=I,D=!A;if(N==null)return!j;for(N=Object(N);I--;){var Y=M[I];if(D&&Y[2]?Y[1]!==N[Y[0]]:!(Y[0]in N))return!1}for(;++I=S){var et=I?null:v(A);if(et)return N(et);ot=!1,Y=b,Q=new f}else Q=I?[]:nt;t:for(;++Db||M&&A&&j&&!I&&!D||N&&A&&j||!v&&j||!S)return 1;if(!N&&!M&&!D&&E=I)return j;var D=v[N];return j*(D=="desc"?-1:1)}}return E.index-b.index}w.exports=x},63272:function(w){function P(a,f){var x=-1,E=a.length;for(f||(f=Array(E));++x1?N[M-1]:void 0,I=M>2?N[2]:void 0;for(A=b.length>3&&typeof A=="function"?(M--,A):void 0,I&&x(N[0],N[1],I)&&(A=M<3?void 0:A,M=1),v=Object(v);++S-1?A[I?N[j]:j]:void 0}}w.exports=b},6651:function(w,P,a){var f=a(91018),x=a(20688),E=a(925);function b(v){return function(N,S,M){return M&&typeof M!="number"&&x(N,S,M)&&(S=M=void 0),N=E(N),S===void 0?(S=N,N=0):S=E(S),M=M===void 0?NK))return!1;var nt=D.get(S),Q=D.get(M);if(nt&&Q)return nt==M&&Q==S;var et=-1,H=!0,it=A&v?new f:void 0;for(D.set(S,M),D.set(M,S);++et-1&&x%1==0&&x-1}w.exports=x},43475:function(w,P,a){var f=a(82249);function x(E,b){var v=this.__data__,N=f(v,E);return N<0?(++this.size,v.push([E,b])):v[N][1]=b,this}w.exports=x},91642:function(w,P,a){var f=a(79955),x=a(53110),E=a(25281);function b(){this.size=0,this.__data__={hash:new f,map:new(E||x),string:new f}}w.exports=b},71646:function(w,P,a){var f=a(27856);function x(E){var b=f(this,E).delete(E);return this.size-=b?1:0,b}w.exports=x},70200:function(w,P,a){var f=a(27856);function x(E){return f(this,E).get(E)}w.exports=x},85304:function(w,P,a){var f=a(27856);function x(E){return f(this,E).has(E)}w.exports=x},57862:function(w,P,a){var f=a(27856);function x(E,b){var v=f(this,E),N=v.size;return v.set(E,b),this.size+=v.size==N?0:1,this}w.exports=x},85120:function(w){function P(a){var f=-1,x=Array(a.size);return a.forEach(function(E,b){x[++f]=[b,E]}),x}w.exports=P},47366:function(w){function P(a,f){return function(x){return x==null?!1:x[a]===f&&(f!==void 0||a in Object(x))}}w.exports=P},72902:function(w,P,a){var f=a(88530),x=500;function E(b){var v=f(b,function(S){return N.size===x&&N.clear(),S}),N=v.cache;return v}w.exports=E},60865:function(w,P,a){var f=a(93454),x=f(Object,"create");w.exports=x},90535:function(w,P,a){var f=a(1276),x=f(Object.keys,Object);w.exports=x},54229:function(w){function P(a){var f=[];if(a!=null)for(var x in Object(a))f.push(x);return f}w.exports=P},37340:function(w,P,a){w=a.nmd(w);var f=a(89413),x=P&&!P.nodeType&&P,E=x&&!0&&w&&!w.nodeType&&w,b=E&&E.exports===x,v=b&&f.process,N=function(){try{var S=E&&E.require&&E.require("util").types;return S||v&&v.binding&&v.binding("util")}catch(M){}}();w.exports=N},92631:function(w){var P=Object.prototype,a=P.toString;function f(x){return a.call(x)}w.exports=f},1276:function(w){function P(a,f){return function(x){return a(f(x))}}w.exports=P},9291:function(w,P,a){var f=a(33546),x=Math.max;function E(b,v,N){return v=x(v===void 0?b.length-1:v,0),function(){for(var S=arguments,M=-1,A=x(S.length-v,0),I=Array(A);++M0){if(++b>=P)return arguments[0]}else b=0;return E.apply(void 0,arguments)}}w.exports=x},83214:function(w,P,a){var f=a(53110);function x(){this.__data__=new f,this.size=0}w.exports=x},52806:function(w){function P(a){var f=this.__data__,x=f.delete(a);return this.size=f.size,x}w.exports=P},52032:function(w){function P(a){return this.__data__.get(a)}w.exports=P},51118:function(w){function P(a){return this.__data__.has(a)}w.exports=P},36321:function(w,P,a){var f=a(53110),x=a(25281),E=a(97800),b=200;function v(N,S){var M=this.__data__;if(M instanceof f){var A=M.__data__;if(!x||A.length2?A[2]:void 0;for(D&&E(A[0],A[1],D)&&(j=1);++I-1&&f%1==0&&f<=P}w.exports=a},32455:function(w,P,a){var f=a(9961),x=a(82230),E=a(37340),b=E&&E.isMap,v=b?x(b):f;w.exports=v},71721:function(w){function P(a){var f=typeof a;return a!=null&&(f=="object"||f=="function")}w.exports=P},71161:function(w){function P(a){return a!=null&&typeof a=="object"}w.exports=P},29538:function(w,P,a){var f=a(17325),x=a(13530),E=a(71161),b="[object Object]",v=Function.prototype,N=Object.prototype,S=v.toString,M=N.hasOwnProperty,A=S.call(Object);function I(j){if(!E(j)||f(j)!=b)return!1;var D=x(j);if(D===null)return!0;var Y=M.call(D,"constructor")&&D.constructor;return typeof Y=="function"&&Y instanceof Y&&S.call(Y)==A}w.exports=I},60437:function(w,P,a){var f=a(65562),x=a(82230),E=a(37340),b=E&&E.isSet,v=b?x(b):f;w.exports=v},13720:function(w,P,a){var f=a(17325),x=a(41594),E=a(71161),b="[object String]";function v(N){return typeof N=="string"||!x(N)&&E(N)&&f(N)==b}w.exports=v},66459:function(w,P,a){var f=a(17325),x=a(71161),E="[object Symbol]";function b(v){return typeof v=="symbol"||x(v)&&f(v)==E}w.exports=b},53745:function(w,P,a){var f=a(61651),x=a(82230),E=a(37340),b=E&&E.isTypedArray,v=b?x(b):f;w.exports=v},68408:function(w){function P(a){return a===void 0}w.exports=P},66357:function(w,P,a){var f=a(91762),x=a(63427),E=a(9015);function b(v){return E(v)?f(v):x(v)}w.exports=b},331:function(w,P,a){var f=a(91762),x=a(54193),E=a(9015);function b(v){return E(v)?f(v,!0):x(v)}w.exports=b},47522:function(w){function P(a){var f=a==null?0:a.length;return f?a[f-1]:void 0}w.exports=P},81426:function(w,P,a){var f=a(43453),x=a(71499),E=a(27592),b=a(41594);function v(N,S){var M=b(N)?f:E;return M(N,x(S,3))}w.exports=v},60032:function(w,P,a){var f=a(67109),x=a(23543),E=a(71499);function b(v,N){var S={};return N=E(N,3),x(v,function(M,A,I){f(S,A,N(M,A,I))}),S}w.exports=b},18038:function(w,P,a){var f=a(87542),x=a(52538),E=a(44525);function b(v){return v&&v.length?f(v,E,x):void 0}w.exports=b},88530:function(w,P,a){var f=a(97800),x="Expected a function";function E(b,v){if(typeof b!="function"||v!=null&&typeof v!="function")throw new TypeError(x);var N=function(){var S=arguments,M=v?v.apply(this,S):S[0],A=N.cache;if(A.has(M))return A.get(M);var I=b.apply(this,S);return N.cache=A.set(M,I)||A,I};return N.cache=new(E.Cache||f),N}E.Cache=f,w.exports=E},55056:function(w,P,a){var f=a(37111),x=a(94792),E=x(function(b,v,N){f(b,v,N)});w.exports=E},60169:function(w,P,a){var f=a(87542),x=a(85679),E=a(44525);function b(v){return v&&v.length?f(v,E,x):void 0}w.exports=b},13604:function(w,P,a){var f=a(87542),x=a(71499),E=a(85679);function b(v,N){return v&&v.length?f(v,x(N,2),E):void 0}w.exports=b},65075:function(w){function P(){}w.exports=P},76308:function(w,P,a){var f=a(40911),x=function(){return f.Date.now()};w.exports=x},72333:function(w,P,a){var f=a(80073),x=a(33944),E=x(function(b,v){return b==null?{}:f(b,v)});w.exports=E},59932:function(w,P,a){var f=a(11372),x=a(91315),E=a(10866),b=a(90370);function v(N){return E(N)?f(b(N)):x(N)}w.exports=v},69235:function(w,P,a){var f=a(6651),x=f();w.exports=x},9695:function(w,P,a){var f=a(85665),x=a(89264),E=a(71499),b=a(88120),v=a(41594);function N(S,M,A){var I=v(S)?f:b,j=arguments.length<3;return I(S,E(M,4),A,j,x)}w.exports=N},24727:function(w,P,a){var f=a(63427),x=a(29148),E=a(9015),b=a(13720),v=a(62961),N="[object Map]",S="[object Set]";function M(A){if(A==null)return 0;if(E(A))return b(A)?v(A):A.length;var I=x(A);return I==N||I==S?A.size:f(A).length}w.exports=M},35020:function(w,P,a){var f=a(27417),x=a(50447),E=a(2440),b=a(20688),v=E(function(N,S){if(N==null)return[];var M=S.length;return M>1&&b(N,S[0],S[1])?S=[]:M>2&&b(S[0],S[1],S[2])&&(S=[S[0]]),x(N,f(S,1),[])});w.exports=v},57004:function(w){function P(){return[]}w.exports=P},75374:function(w){function P(){return!1}w.exports=P},925:function(w,P,a){var f=a(13933),x=1/0,E=17976931348623157e292;function b(v){if(!v)return v===0?v:0;if(v=f(v),v===x||v===-x){var N=v<0?-1:1;return N*E}return v===v?v:0}w.exports=b},46588:function(w,P,a){var f=a(925);function x(E){var b=f(E),v=b%1;return b===b?v?b-v:b:0}w.exports=x},13933:function(w,P,a){var f=a(8944),x=a(71721),E=a(66459),b=NaN,v=/^[-+]0x[0-9a-f]+$/i,N=/^0b[01]+$/i,S=/^0o[0-7]+$/i,M=parseInt;function A(I){if(typeof I=="number")return I;if(E(I))return b;if(x(I)){var j=typeof I.valueOf=="function"?I.valueOf():I;I=x(j)?j+"":j}if(typeof I!="string")return I===0?I:+I;I=f(I);var D=N.test(I);return D||S.test(I)?M(I.slice(2),D?2:8):v.test(I)?b:+I}w.exports=A},8416:function(w,P,a){var f=a(39408),x=a(331);function E(b){return f(b,x(b))}w.exports=E},14135:function(w,P,a){var f=a(12580);function x(E){return E==null?"":f(E)}w.exports=x},61477:function(w,P,a){var f=a(22899),x=a(93511),E=a(23543),b=a(71499),v=a(13530),N=a(41594),S=a(33636),M=a(92581),A=a(71721),I=a(53745);function j(D,Y,K){var ot=N(D),nt=ot||S(D)||I(D);if(Y=b(Y,4),K==null){var Q=D&&D.constructor;nt?K=ot?new Q:[]:A(D)?K=M(Q)?x(v(D)):{}:K={}}return(nt?f:E)(D,function(et,H,it){return Y(K,et,H,it)}),K}w.exports=j},99477:function(w,P,a){var f=a(27417),x=a(2440),E=a(75996),b=a(20577),v=x(function(N){return E(f(N,1,b,!0))});w.exports=v},69624:function(w,P,a){var f=a(14135),x=0;function E(b){var v=++x;return f(b)+v}w.exports=E},72834:function(w,P,a){var f=a(98030),x=a(66357);function E(b){return b==null?[]:f(b,x(b))}w.exports=E},79261:function(w,P,a){var f=a(78436),x=a(30232);function E(b,v){return x(b||[],v||[],f)}w.exports=E},34402:function(w,P,a){"use strict";a.r(P),a.d(P,{default:function(){return b}});var f=a(34634);function x(v){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(0,f.isAnyArray)(v))throw new TypeError("input must be an array");if(v.length===0)throw new TypeError("input must not be empty");var S=N.fromIndex,M=S===void 0?0:S,A=N.toIndex,I=A===void 0?v.length:A;if(M<0||M>=v.length||!Number.isInteger(M))throw new Error("fromIndex must be a positive integer smaller than length");if(I<=M||I>v.length||!Number.isInteger(I))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var j=v[M],D=M+1;Dj&&(j=v[D]);return j}function E(v){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(0,f.isAnyArray)(v))throw new TypeError("input must be an array");if(v.length===0)throw new TypeError("input must not be empty");var S=N.fromIndex,M=S===void 0?0:S,A=N.toIndex,I=A===void 0?v.length:A;if(M<0||M>=v.length||!Number.isInteger(M))throw new Error("fromIndex must be a positive integer smaller than length");if(I<=M||I>v.length||!Number.isInteger(I))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var j=v[M],D=M+1;D1&&arguments[1]!==void 0?arguments[1]:{};if((0,f.isAnyArray)(v)){if(v.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var S;if(N.output!==void 0){if(!(0,f.isAnyArray)(N.output))throw new TypeError("output option must be an array if specified");S=N.output}else S=new Array(v.length);var M=E(v),A=x(v);if(M===A)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var I=N.min,j=I===void 0?N.autoMinMax?M:0:I,D=N.max,Y=D===void 0?N.autoMinMax?A:1:D;if(j>=Y)throw new RangeError("min option must be smaller than max option");for(var K=(Y-j)/(A-M),ot=0;ot=0;d--)(h=n[d])&&(o=(s<3?h(o):s>3?h(e,t,o):h(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function E(n,e){return function(t,r){e(t,r,n)}}function b(n,e,t,r,s,o){function h(C){if(C!==void 0&&typeof C!="function")throw new TypeError("Function expected");return C}for(var d=r.kind,p=d==="getter"?"get":d==="setter"?"set":"value",g=!e&&n?r.static?n:n.prototype:null,y=e||(g?Object.getOwnPropertyDescriptor(g,r.name):{}),O,L=!1,R=t.length-1;R>=0;R--){var k={};for(var F in r)k[F]=F==="access"?{}:r[F];for(var F in r.access)k.access[F]=r.access[F];k.addInitializer=function(C){if(L)throw new TypeError("Cannot add initializers after decoration has completed");o.push(h(C||null))};var z=(0,t[R])(d==="accessor"?{get:y.get,set:y.set}:y[p],k);if(d==="accessor"){if(z===void 0)continue;if(z===null||typeof z!="object")throw new TypeError("Object expected");(O=h(z.get))&&(y.get=O),(O=h(z.set))&&(y.set=O),(O=h(z.init))&&s.unshift(O)}else(O=h(z))&&(d==="field"?s.unshift(O):y[p]=O)}g&&Object.defineProperty(g,r.name,y),L=!0}function v(n,e,t){for(var r=arguments.length>2,s=0;s0&&o[o.length-1])&&(g[0]===6||g[0]===2)){t=0;continue}if(g[0]===3&&(!o||g[1]>o[0]&&g[1]=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function K(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,o=[],h;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(d){h={error:d}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(h)throw h.error}}return o}function ot(){for(var n=[],e=0;e1||p(R,F)})},k&&(s[R]=k(s[R])))}function p(R,k){try{g(r[R](k))}catch(F){L(o[0][3],F)}}function g(R){R.value instanceof et?Promise.resolve(R.value.v).then(y,O):L(o[0][2],R)}function y(R){p("next",R)}function O(R){p("throw",R)}function L(R,k){R(k),o.shift(),o.length&&p(o[0][0],o[0][1])}}function it(n){var e,t;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,o){e[s]=n[s]?function(h){return(t=!t)?{value:et(n[s](h)),done:!1}:o?o(h):h}:o}}function at(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof Y=="function"?Y(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(o){t[o]=n[o]&&function(h){return new Promise(function(d,p){h=n[o](h),s(d,p,h.done,h.value)})}}function s(o,h,d,p){Promise.resolve(p).then(function(g){o({value:g,done:d})},h)}}function ft(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}var ht=Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e},dt=function(n){return dt=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},dt(n)};function xt(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t=dt(n),r=0;r{e.has(h.id)||(e.add(h.id),n.push(h))})}return!1}function Je(n,e,t,r){if(t(n))return!0;e.add(n.id);for(const o of r(n.id))if(!e.has(o.id)&&Je(o,e,t,r))return!0;return!1}const an=()=>!0;class gt{constructor(e){be(this,"graph");be(this,"nodeFilter");be(this,"edgeFilter");be(this,"cacheEnabled");be(this,"inEdgesMap",new Map);be(this,"outEdgesMap",new Map);be(this,"bothEdgesMap",new Map);be(this,"allNodesMap",new Map);be(this,"allEdgesMap",new Map);be(this,"clearCache",()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()});be(this,"refreshCache",()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(e=>e.id))});be(this,"updateCache",e=>{const t=new Set;e.forEach(r=>{const s=this.bothEdgesMap.get(r);if(s&&s.forEach(o=>t.add(o.id)),!this.hasNode(r))this.inEdgesMap.delete(r),this.outEdgesMap.delete(r),this.bothEdgesMap.delete(r),this.allNodesMap.delete(r);else{const o=this.graph.getRelatedEdges(r,"in").filter(this.edgeFilter),h=this.graph.getRelatedEdges(r,"out").filter(this.edgeFilter),d=Array.from(new Set([...o,...h]));d.forEach(p=>t.add(p.id)),this.inEdgesMap.set(r,o),this.outEdgesMap.set(r,h),this.bothEdgesMap.set(r,d),this.allNodesMap.set(r,this.graph.getNode(r))}}),t.forEach(r=>{this.hasEdge(r)?this.allEdgesMap.set(r,this.graph.getEdge(r)):this.allEdgesMap.delete(r)})});be(this,"handleGraphChanged",e=>{const t=new Set;e.changes.forEach(r=>{switch(r.type){case"NodeAdded":t.add(r.value.id);break;case"NodeDataUpdated":t.add(r.id);break;case"EdgeAdded":t.add(r.value.source),t.add(r.value.target);break;case"EdgeUpdated":(r.propertyName==="source"||r.propertyName==="target")&&(t.add(r.oldValue),t.add(r.newValue));break;case"EdgeDataUpdated":if(e.graph.hasEdge(r.id)){const s=e.graph.getEdge(r.id);t.add(s.source),t.add(s.target)}break;case"EdgeRemoved":t.add(r.value.source),t.add(r.value.target);break;case"NodeRemoved":t.add(r.value.id);break;default:break}}),this.updateCache(t)});this.graph=e.graph;const t=e.nodeFilter||an,r=e.edgeFilter||an;this.nodeFilter=t,this.edgeFilter=s=>{const{source:o,target:h}=this.graph.getEdgeDetail(s.id);return!t(o)||!t(h)?!1:r(s,o,h)},e.cache==="auto"?(this.cacheEnabled=!0,this.startAutoCache()):e.cache==="manual"?this.cacheEnabled=!0:this.cacheEnabled=!1}startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}checkNodeExistence(e){this.getNode(e)}hasNode(e){if(!this.graph.hasNode(e))return!1;const t=this.graph.getNode(e);return this.nodeFilter(t)}areNeighbors(e,t){return this.checkNodeExistence(e),this.getNeighbors(t).some(r=>r.id===e)}getNode(e){const t=this.graph.getNode(e);if(!this.nodeFilter(t))throw new Error("Node not found for id: "+e);return t}getRelatedEdges(e,t){return this.checkNodeExistence(e),this.cacheEnabled?t==="in"?this.inEdgesMap.get(e):t==="out"?this.outEdgesMap.get(e):this.bothEdgesMap.get(e):this.graph.getRelatedEdges(e,t).filter(this.edgeFilter)}getDegree(e,t){return this.getRelatedEdges(e,t).length}getSuccessors(e){const r=this.getRelatedEdges(e,"out").map(s=>this.getNode(s.target));return Array.from(new Set(r))}getPredecessors(e){const r=this.getRelatedEdges(e,"in").map(s=>this.getNode(s.source));return Array.from(new Set(r))}getNeighbors(e){const t=this.getPredecessors(e),r=this.getSuccessors(e);return Array.from(new Set([...t,...r]))}hasEdge(e){if(!this.graph.hasEdge(e))return!1;const t=this.graph.getEdge(e);return this.edgeFilter(t)}getEdge(e){const t=this.graph.getEdge(e);if(!this.edgeFilter(t))throw new Error("Edge not found for id: "+e);return t}getEdgeDetail(e){const t=this.getEdge(e);return{edge:t,source:this.getNode(t.source),target:this.getNode(t.target)}}hasTreeStructure(e){return this.graph.hasTreeStructure(e)}getRoots(e){return this.graph.getRoots(e).filter(this.nodeFilter)}getChildren(e,t){return this.checkNodeExistence(e),this.graph.getChildren(e,t).filter(this.nodeFilter)}getParent(e,t){this.checkNodeExistence(e);const r=this.graph.getParent(e,t);return!r||!this.nodeFilter(r)?null:r}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(e,t,r="out"){const s={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];cn([this.getNode(e)],new Set,t,s)}dfs(e,t,r="out"){const s={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];Je(this.getNode(e),new Set,t,s)}}class vt extends Sn{constructor(t){super();be(this,"nodeMap",new Map);be(this,"edgeMap",new Map);be(this,"inEdgesMap",new Map);be(this,"outEdgesMap",new Map);be(this,"bothEdgesMap",new Map);be(this,"treeIndices",new Map);be(this,"changes",[]);be(this,"batchCount",0);be(this,"onChanged",()=>{});be(this,"batch",t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()});t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}commit(){const t=this.changes;this.changes=[];const r={graph:this,changes:t};this.emit("changed",r),this.onChanged(r)}reduceChanges(t){let r=[];return t.forEach(s=>{switch(s.type){case"NodeRemoved":{let o=!1;r=r.filter(h=>{if(h.type==="NodeAdded"){const d=h.value.id===s.value.id;return d&&(o=!0),!d}else{if(h.type==="NodeDataUpdated")return h.id!==s.value.id;if(h.type==="TreeStructureChanged")return h.nodeId!==s.value.id}return!0}),o||r.push(s);break}case"EdgeRemoved":{let o=!1;r=r.filter(h=>{if(h.type==="EdgeAdded"){const d=h.value.id===s.value.id;return d&&(o=!0),!d}else if(h.type==="EdgeDataUpdated"||h.type==="EdgeUpdated")return h.id!==s.value.id;return!0}),o||r.push(s);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const o=r.findIndex(d=>d.type===s.type&&d.id===s.id&&(s.propertyName===void 0||d.propertyName===s.propertyName)),h=r[o];h?s.propertyName!==void 0?h.newValue=s.newValue:(r.splice(o,1),r.push(s)):r.push(s);break}case"TreeStructureDetached":{r=r.filter(o=>o.type==="TreeStructureAttached"||o.type==="TreeStructureChanged"?o.treeKey!==s.treeKey:!0),r.push(s);break}case"TreeStructureChanged":{const o=r.find(h=>h.type==="TreeStructureChanged"&&h.treeKey===s.treeKey&&h.nodeId===s.nodeId);o?o.newParentId=s.newParentId:r.push(s);break}default:r.push(s);break}}),r}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,r){return this.getNeighbors(r).some(s=>s.id===t)}getNode(t){const r=this.nodeMap.get(t);if(!r)throw new Error("Node not found for id: "+t);return r}getRelatedEdges(t,r){if(this.checkNodeExistence(t),r==="in"){const s=this.inEdgesMap.get(t);return Array.from(s)}else if(r==="out"){const s=this.outEdgesMap.get(t);return Array.from(s)}else{const s=this.bothEdgesMap.get(t);return Array.from(s)}}getDegree(t,r){return this.getRelatedEdges(t,r).length}getSuccessors(t){const s=this.getRelatedEdges(t,"out").map(o=>this.getNode(o.target));return Array.from(new Set(s))}getPredecessors(t){const s=this.getRelatedEdges(t,"in").map(o=>this.getNode(o.source));return Array.from(new Set(s))}getNeighbors(t){const r=this.getPredecessors(t),s=this.getSuccessors(t);return Array.from(new Set([...r,...s]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach(r=>{r.childrenMap.set(t.id,new Set)}),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch(()=>{for(const r of t)this.doAddNode(r)})}addNode(t){this.addNodes([t])}doRemoveNode(t){const r=this.getNode(t),s=this.bothEdgesMap.get(t);s==null||s.forEach(o=>this.doRemoveEdge(o.id)),this.nodeMap.delete(t),this.treeIndices.forEach(o=>{var d,p;(d=o.childrenMap.get(t))==null||d.forEach(g=>{o.parentMap.delete(g.id)});const h=o.parentMap.get(t);h&&((p=o.childrenMap.get(h.id))==null||p.delete(r)),o.parentMap.delete(t),o.childrenMap.delete(t)}),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.changes.push({type:"NodeRemoved",value:r})}removeNodes(t){this.batch(()=>{t.forEach(r=>this.doRemoveNode(r))})}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,r,s){const o=this.getNode(t);this.batch(()=>{const h=o.data[r],d=s;o.data[r]=d,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:r,oldValue:h,newValue:d})})}mergeNodeData(t,r){this.batch(()=>{Object.entries(r).forEach(([s,o])=>{this.updateNodeDataProperty(t,s,o)})})}updateNodeData(...t){const r=t[0],s=this.getNode(r);if(typeof t[1]=="string"){this.updateNodeDataProperty(r,t[1],t[2]);return}let o;if(typeof t[1]=="function"){const h=t[1];o=h(s.data)}else typeof t[1]=="object"&&(o=t[1]);this.batch(()=>{const h=s.data,d=o;s.data=o,this.changes.push({type:"NodeDataUpdated",id:r,oldValue:h,newValue:d})})}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const r=this.getEdge(t);return{edge:r,source:this.getNode(r.source),target:this.getNode(r.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const r=this.inEdgesMap.get(t.target),s=this.outEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.source),h=this.bothEdgesMap.get(t.target);r.add(t),s.add(t),o.add(t),h.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch(()=>{for(const r of t)this.doAddEdge(r)})}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const r=this.getEdge(t),s=this.outEdgesMap.get(r.source),o=this.inEdgesMap.get(r.target),h=this.bothEdgesMap.get(r.source),d=this.bothEdgesMap.get(r.target);s.delete(r),o.delete(r),h.delete(r),d.delete(r),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:r})}removeEdges(t){this.batch(()=>{t.forEach(r=>this.doRemoveEdge(r))})}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,r){const s=this.getEdge(t);this.checkNodeExistence(r);const o=s.source,h=r;this.outEdgesMap.get(o).delete(s),this.bothEdgesMap.get(o).delete(s),this.outEdgesMap.get(h).add(s),this.bothEdgesMap.get(h).add(s),s.source=r,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:o,newValue:h})})}updateEdgeTarget(t,r){const s=this.getEdge(t);this.checkNodeExistence(r);const o=s.target,h=r;this.inEdgesMap.get(o).delete(s),this.bothEdgesMap.get(o).delete(s),this.inEdgesMap.get(h).add(s),this.bothEdgesMap.get(h).add(s),s.target=r,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:o,newValue:h})})}updateEdgeDataProperty(t,r,s){const o=this.getEdge(t);this.batch(()=>{const h=o.data[r],d=s;o.data[r]=d,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:r,oldValue:h,newValue:d})})}updateEdgeData(...t){const r=t[0],s=this.getEdge(r);if(typeof t[1]=="string"){this.updateEdgeDataProperty(r,t[1],t[2]);return}let o;if(typeof t[1]=="function"){const h=t[1];o=h(s.data)}else typeof t[1]=="object"&&(o=t[1]);this.batch(()=>{const h=s.data,d=o;s.data=o,this.changes.push({type:"EdgeDataUpdated",id:r,oldValue:h,newValue:d})})}mergeEdgeData(t,r){this.batch(()=>{Object.entries(r).forEach(([s,o])=>{this.updateEdgeDataProperty(t,s,o)})})}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})}))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})})}addTree(t,r){this.batch(()=>{this.attachTreeStructure(r);const s=[],o=Array.isArray(t)?t:[t];for(;o.length;){const h=o.shift();s.push(h),h.children&&o.push(...h.children)}this.addNodes(s),s.forEach(h=>{var d;(d=h.children)==null||d.forEach(p=>{this.setParent(p.id,h.id,r)})})})}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter(r=>!this.getParent(r.id,t))}getChildren(t,r){this.checkNodeExistence(t),this.checkTreeExistence(r);const o=this.treeIndices.get(r).childrenMap.get(t);return Array.from(o||[])}getParent(t,r){return this.checkNodeExistence(t),this.checkTreeExistence(r),this.treeIndices.get(r).parentMap.get(t)||null}getAncestors(t,r){const s=[];let o=this.getNode(t),h;for(;h=this.getParent(o.id,r);)s.push(h),o=h;return s}setParent(t,r,s){var y,O;this.checkTreeExistence(s);const o=this.treeIndices.get(s);if(!o)return;const h=this.getNode(t),d=o.parentMap.get(t);if((d==null?void 0:d.id)===r)return;if(r==null){d&&((y=o.childrenMap.get(d.id))==null||y.delete(h)),o.parentMap.delete(t);return}const p=this.getNode(r);o.parentMap.set(t,p),d&&((O=o.childrenMap.get(d.id))==null||O.delete(h));let g=o.childrenMap.get(p.id);g||(g=new Set,o.childrenMap.set(p.id,g)),g.add(h),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:s,nodeId:t,oldParentId:d==null?void 0:d.id,newParentId:p.id})})}dfsTree(t,r,s){const o=h=>this.getChildren(h,s);return Je(this.getNode(t),new Set,r,o)}bfsTree(t,r,s){const o=h=>this.getChildren(h,s);return cn([this.getNode(t)],new Set,r,o)}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,r,s="out"){const o={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[s];return cn([this.getNode(t)],new Set,r,o)}dfs(t,r,s="out"){const o={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[s];return Je(this.getNode(t),new Set,r,o)}clone(){const t=this.getAllNodes().map(o=>$r(kn({},o),{data:kn({},o.data)})),r=this.getAllEdges().map(o=>$r(kn({},o),{data:kn({},o.data)})),s=new vt({nodes:t,edges:r});return this.treeIndices.forEach(({parentMap:o,childrenMap:h},d)=>{const p=new Map;o.forEach((y,O)=>{p.set(O,s.getNode(y.id))});const g=new Map;h.forEach((y,O)=>{g.set(O,new Set(Array.from(y).map(L=>s.getNode(L.id))))}),s.treeIndices.set(d,{parentMap:p,childrenMap:g})}),s}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new gt(kn({graph:this},t))}}const At=Symbol("Comlink.proxy"),Ft=Symbol("Comlink.endpoint"),qt=Symbol("Comlink.releaseProxy"),ue=Symbol("Comlink.finalizer"),he=Symbol("Comlink.thrown"),Ie=n=>typeof n=="object"&&n!==null||typeof n=="function",pn={canHandle:n=>Ie(n)&&n[At],serialize(n){const{port1:e,port2:t}=new MessageChannel;return Wt(n,e),[t,[t]]},deserialize(n){return n.start(),un(n)}},De={canHandle:n=>Ie(n)&&he in n,serialize({value:n}){let e;return n instanceof Error?e={isError:!0,value:{message:n.message,name:n.name,stack:n.stack}}:e={isError:!1,value:n},[e,[]]},deserialize(n){throw n.isError?Object.assign(new Error(n.value.message),n.value):n.value}},Me=new Map([["proxy",pn],["throw",De]]);function se(n,e){for(const t of n)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Wt(n,e=globalThis,t=["*"]){e.addEventListener("message",function r(s){if(!s||!s.data)return;if(!se(t,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}const{id:o,type:h,path:d}=Object.assign({path:[]},s.data),p=(s.data.argumentList||[]).map(ze);let g;try{const y=d.slice(0,-1).reduce((L,R)=>L[R],n),O=d.reduce((L,R)=>L[R],n);switch(h){case"GET":g=O;break;case"SET":y[d.slice(-1)[0]]=ze(s.data.value),g=!0;break;case"APPLY":g=O.apply(y,p);break;case"CONSTRUCT":{const L=new O(...p);g=mn(L)}break;case"ENDPOINT":{const{port1:L,port2:R}=new MessageChannel;Wt(n,R),g=Rn(L,[L])}break;case"RELEASE":g=void 0;break;default:return}}catch(y){g={value:y,[he]:0}}Promise.resolve(g).catch(y=>({value:y,[he]:0})).then(y=>{const[O,L]=Be(y);e.postMessage(Object.assign(Object.assign({},O),{id:o}),L),h==="RELEASE"&&(e.removeEventListener("message",r),rn(e),ue in n&&typeof n[ue]=="function"&&n[ue]())}).catch(y=>{const[O,L]=Be({value:new TypeError("Unserializable return value"),[he]:0});e.postMessage(Object.assign(Object.assign({},O),{id:o}),L)})}),e.start&&e.start()}function re(n){return n.constructor.name==="MessagePort"}function rn(n){re(n)&&n.close()}function un(n,e){const t=new Map;return n.addEventListener("message",function(s){const{data:o}=s;if(!o||!o.id)return;const h=t.get(o.id);if(h)try{h(o)}finally{t.delete(o.id)}}),On(n,t,[],e)}function It(n){if(n)throw new Error("Proxy has been released and is not useable")}function fn(n){return Ae(n,new Map,{type:"RELEASE"}).then(()=>{rn(n)})}const Pe=new WeakMap,xe="FinalizationRegistry"in globalThis&&new FinalizationRegistry(n=>{const e=(Pe.get(n)||0)-1;Pe.set(n,e),e===0&&fn(n)});function ke(n,e){const t=(Pe.get(e)||0)+1;Pe.set(e,t),xe&&xe.register(n,e,n)}function vn(n){xe&&xe.unregister(n)}function On(n,e,t=[],r=function(){}){let s=!1;const o=new Proxy(r,{get(h,d){if(It(s),d===qt)return()=>{vn(o),fn(n),e.clear(),s=!0};if(d==="then"){if(t.length===0)return{then:()=>o};const p=Ae(n,e,{type:"GET",path:t.map(g=>g.toString())}).then(ze);return p.then.bind(p)}return On(n,e,[...t,d])},set(h,d,p){It(s);const[g,y]=Be(p);return Ae(n,e,{type:"SET",path:[...t,d].map(O=>O.toString()),value:g},y).then(ze)},apply(h,d,p){It(s);const g=t[t.length-1];if(g===Ft)return Ae(n,e,{type:"ENDPOINT"}).then(ze);if(g==="bind")return On(n,e,t.slice(0,-1));const[y,O]=sn(p);return Ae(n,e,{type:"APPLY",path:t.map(L=>L.toString()),argumentList:y},O).then(ze)},construct(h,d){It(s);const[p,g]=sn(d);return Ae(n,e,{type:"CONSTRUCT",path:t.map(y=>y.toString()),argumentList:p},g).then(ze)}});return ke(o,n),o}function Pn(n){return Array.prototype.concat.apply([],n)}function sn(n){const e=n.map(Be);return[e.map(t=>t[0]),Pn(e.map(t=>t[1]))]}const An=new WeakMap;function Rn(n,e){return An.set(n,e),n}function mn(n){return Object.assign(n,{[At]:!0})}function Bn(n,e=globalThis,t="*"){return{postMessage:(r,s)=>n.postMessage(r,t,s),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function Be(n){for(const[e,t]of Me)if(t.canHandle(n)){const[r,s]=t.serialize(n);return[{type:"HANDLER",name:e,value:r},s]}return[{type:"RAW",value:n},An.get(n)||[]]}function ze(n){switch(n.type){case"HANDLER":return Me.get(n.name).deserialize(n.value);case"RAW":return n.value}}function Ae(n,e,t,r){return new Promise(s=>{const o=cr();e.set(o,s),n.start&&n.start(),n.postMessage(Object.assign({id:o},t),r)})}function cr(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function $t(n){return typeof n=="number"}function on(n){return n==null}const Un=(n,e)=>{if(n!=="next"&&n!=="prev")return e},ln=n=>{n.prev.next=n.next,n.next.prev=n.prev,delete n.next,delete n.prev};class fr{constructor(){const e={};e.prev=e,e.next=e.prev,this.shortcut=e}dequeue(){const e=this.shortcut,t=e.prev;if(t&&t!==e)return ln(t),t}enqueue(e){const t=this.shortcut;e.prev&&e.next&&ln(e),e.next=t.next,t.next.prev=e,t.next=e,e.prev=t}toString(){const e=[],t=this.shortcut;let r=t.prev;for(;r!==t;)e.push(JSON.stringify(r,Un)),r=r==null?void 0:r.prev;return`[${e.join(", ")}]`}}class Zn extends fr{}const Ln=()=>1,lr=(n,e)=>{var t;if(n.getAllNodes().length<=1)return[];const r=hr(n,e||Ln);return(t=dr(r.graph,r.buckets,r.zeroIdx).map(o=>n.getRelatedEdges(o.v,"out").filter(({target:h})=>h===o.w)))===null||t===void 0?void 0:t.flat()},dr=(n,e,t)=>{let r=[];const s=e[e.length-1],o=e[0];let h;for(;n.getAllNodes().length;){for(;h=o.dequeue();)Vn(n,e,t,h);for(;h=s.dequeue();)Vn(n,e,t,h);if(n.getAllNodes().length){for(let d=e.length-2;d>0;--d)if(h=e[d].dequeue(),h){r=r.concat(Vn(n,e,t,h,!0));break}}}return r},Vn=(n,e,t,r,s)=>{var o,h;const d=[];return n.hasNode(r.v)&&((o=n.getRelatedEdges(r.v,"in"))===null||o===void 0||o.forEach(p=>{const g=p.data.weight,y=n.getNode(p.source);s&&d.push({v:p.source,w:p.target,in:0,out:0}),y.data.out===void 0&&(y.data.out=0),y.data.out-=g,Gn(e,t,Object.assign({v:y.id},y.data))}),(h=n.getRelatedEdges(r.v,"out"))===null||h===void 0||h.forEach(p=>{const g=p.data.weight,y=p.target,O=n.getNode(y);O.data.in===void 0&&(O.data.in=0),O.data.in-=g,Gn(e,t,Object.assign({v:O.id},O.data))}),n.removeNode(r.v)),s?d:void 0},hr=(n,e)=>{const t=new vt;let r=0,s=0;n.getAllNodes().forEach(p=>{t.addNode({id:p.id,data:{v:p.id,in:0,out:0}})}),n.getAllEdges().forEach(p=>{const g=t.getRelatedEdges(p.source,"out").find(O=>O.target===p.target),y=(e==null?void 0:e(p))||1;g?t.updateEdgeData(g==null?void 0:g.id,Object.assign(Object.assign({},g.data),{weight:g.data.weight+y})):t.addEdge({id:p.id,source:p.source,target:p.target,data:{weight:y}}),s=Math.max(s,t.getNode(p.source).data.out+=y),r=Math.max(r,t.getNode(p.target).data.in+=y)});const o=[],h=s+r+3;for(let p=0;p{Gn(o,d,Object.assign({v:p.id},t.getNode(p.id).data))}),{buckets:o,zeroIdx:d,graph:t}},Gn=(n,e,t)=>{t.out?t.in?n[t.out-t.in+e].enqueue(t):n[n.length-1].enqueue(t):n[0].enqueue(t)},gr=(n,e)=>{const r=e==="greedy"?lr(n,(s=>o=>o.data.weight||1)(n)):Jn(n);r==null||r.forEach(s=>{const o=s.data;n.removeEdge(s.id),o.forwardName=s.data.name,o.reversed=!0,n.addEdge({id:s.id,source:s.target,target:s.source,data:Object.assign({},o)})})},Jn=n=>{const e=[],t={},r={},s=o=>{r[o]||(r[o]=!0,t[o]=!0,n.getRelatedEdges(o,"out").forEach(h=>{t[h.target]?e.push(h):s(h.target)}),delete t[o])};return n.getAllNodes().forEach(o=>s(o.id)),e},pr=n=>{n.getAllEdges().forEach(e=>{const t=e.data;if(t.reversed){n.removeEdge(e.id);const r=t.forwardName;delete t.reversed,delete t.forwardName,n.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},t),{forwardName:r})})}})},vr=(n,e)=>Number(n)-Number(e),yn=(n,e,t,r)=>{let s;do s=`${r}${Math.random()}`;while(n.hasNode(s));return t.dummy=e,n.addNode({id:s,data:t}),s},mr=n=>{const e=new vt;return n.getAllNodes().forEach(t=>{e.addNode(Object.assign({},t))}),n.getAllEdges().forEach(t=>{const r=e.getRelatedEdges(t.source,"out").find(s=>s.target===t.target);r?e.updateEdgeData(r==null?void 0:r.id,Object.assign(Object.assign({},r.data),{weight:r.data.weight+t.data.weight||0,minlen:Math.max(r.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})}),e},Tn=n=>{const e=new vt;return n.getAllNodes().forEach(t=>{n.getChildren(t.id).length||e.addNode(Object.assign({},t))}),n.getAllEdges().forEach(t=>{e.addEdge(t)}),e},Wn=(n,e)=>n==null?void 0:n.reduce((t,r,s)=>(t[r]=e[s],t),{}),yr=n=>{const e={};return n.getAllNodes().forEach(t=>{const r={};n.getRelatedEdges(t.id,"out").forEach(s=>{r[s.target]=(r[s.target]||0)+(s.data.weight||0)}),e[t.id]=r}),e},T=n=>{const e=n.getAllNodes(),t=e.map(r=>{const s={};return n.getRelatedEdges(r.id,"in").forEach(o=>{s[o.source]=(s[o.source]||0)+o.data.weight}),s});return Wn(e.map(r=>r.id),t)},u=(n,e)=>{const t=Number(n.x),r=Number(n.y),s=Number(e.x)-t,o=Number(e.y)-r;let h=Number(n.width)/2,d=Number(n.height)/2;if(!s&&!o)return{x:0,y:0};let p,g;return Math.abs(o)*h>Math.abs(s)*d?(o<0&&(d=-d),p=d*s/o,g=d):(s<0&&(h=-h),p=h,g=h*o/s),{x:t+p,y:r+g}},c=n=>{const e=[],t=B(n)+1;for(let r=0;r{const s=r.data.rank;s!==void 0&&e[s]&&e[s].push(r.id)});for(let r=0;rvr(n.getNode(s).data.order,n.getNode(o).data.order));return e},i=n=>{const e=n.getAllNodes().filter(r=>r.data.rank!==void 0).map(r=>r.data.rank),t=Math.min(...e);n.getAllNodes().forEach(r=>{r.data.hasOwnProperty("rank")&&t!==1/0&&(r.data.rank-=t)})},l=(n,e=0)=>{const t=n.getAllNodes(),r=t.filter(d=>d.data.rank!==void 0).map(d=>d.data.rank),s=Math.min(...r),o=[];t.forEach(d=>{const p=(d.data.rank||0)-s;o[p]||(o[p]=[]),o[p].push(d.id)});let h=0;for(let d=0;d{const y=n.getNode(g);y&&(y.data.rank=y.data.rank||0,y.data.rank+=h)}))}},m=(n,e,t,r)=>{const s={width:0,height:0};return $t(t)&&$t(r)&&(s.rank=t,s.order=r),yn(n,"border",s,e)},B=n=>{let e;return n.getAllNodes().forEach(t=>{const r=t.data.rank;r!==void 0&&(e===void 0||r>e)&&(e=r)}),e||(e=0),e},U=(n,e)=>{const t={lhs:[],rhs:[]};return n==null||n.forEach(r=>{e(r)?t.lhs.push(r):t.rhs.push(r)}),t},V=(n,e)=>n.reduce((t,r)=>{const s=e(t),o=e(r);return s>o?r:t}),G=(n,e,t,r,s,o)=>{r.includes(e.id)||(r.push(e.id),t||o.push(e.id),s(e.id).forEach(h=>G(n,h,t,r,s,o)),t&&o.push(e.id))},rt=(n,e,t,r)=>{const s=Array.isArray(e)?e:[e],o=p=>r?n.getSuccessors(p):n.getNeighbors(p),h=[],d=[];return s.forEach(p=>{if(n.hasNode(p.id))G(n,p,t==="post",d,o,h);else throw new Error(`Graph does not have node: ${p}`)}),h},_=n=>{const e=t=>{const r=n.getChildren(t),s=n.getNode(t);if(r!=null&&r.length&&r.forEach(o=>e(o.id)),s.data.hasOwnProperty("minRank")){s.data.borderLeft=[],s.data.borderRight=[];for(let o=s.data.minRank,h=s.data.maxRank+1;oe(t.id))},lt=(n,e,t,r,s,o)=>{const h={rank:o,borderType:e,width:0,height:0},d=s.data[e][o-1],p=yn(n,"border",h,t);s.data[e][o]=p,n.setParent(p,r),d&&n.addEdge({id:`e${Math.random()}`,source:d,target:p,data:{weight:1}})},Tt=(n,e)=>{const t=e.toLowerCase();(t==="lr"||t==="rl")&&pt(n)},ct=(n,e)=>{const t=e.toLowerCase();(t==="bt"||t==="rl")&&Z(n),(t==="lr"||t==="rl")&&(Ct(n),pt(n))},pt=n=>{n.getAllNodes().forEach(e=>{Rt(e)}),n.getAllEdges().forEach(e=>{Rt(e)})},Rt=n=>{const e=n.data.width;n.data.width=n.data.height,n.data.height=e},Z=n=>{n.getAllNodes().forEach(e=>{St(e.data)}),n.getAllEdges().forEach(e=>{var t;(t=e.data.points)===null||t===void 0||t.forEach(r=>St(r)),e.data.hasOwnProperty("y")&&St(e.data)})},St=n=>{n!=null&&n.y&&(n.y=-n.y)},Ct=n=>{n.getAllNodes().forEach(e=>{Kt(e.data)}),n.getAllEdges().forEach(e=>{var t;(t=e.data.points)===null||t===void 0||t.forEach(r=>Kt(r)),e.data.hasOwnProperty("x")&&Kt(e.data)})},Kt=n=>{const e=n.x;n.x=n.y,n.y=e},Zt=n=>{const e=yn(n,"root",{},"_root"),t=Ut(n);let r=Math.max(...Object.values(t));Math.abs(r)===1/0&&(r=1);const s=r-1,o=2*s+1;n.getAllEdges().forEach(d=>{d.data.minlen*=o});const h=Yt(n)+1;return n.getRoots().forEach(d=>{ge(n,e,o,h,s,t,d.id)}),{nestingRoot:e,nodeRankFactor:o}},ge=(n,e,t,r,s,o,h)=>{const d=n.getChildren(h);if(!(d!=null&&d.length)){h!==e&&n.addEdge({id:`e${Math.random()}`,source:e,target:h,data:{weight:0,minlen:t}});return}const p=m(n,"_bt"),g=m(n,"_bb"),y=n.getNode(h);n.setParent(p,h),y.data.borderTop=p,n.setParent(g,h),y.data.borderBottom=g,d==null||d.forEach(O=>{ge(n,e,t,r,s,o,O.id);const L=O.data.borderTop?O.data.borderTop:O.id,R=O.data.borderBottom?O.data.borderBottom:O.id,k=O.data.borderTop?r:2*r,F=L!==R?1:s-o[h]+1;n.addEdge({id:`e${Math.random()}`,source:p,target:L,data:{minlen:F,weight:k,nestingEdge:!0}}),n.addEdge({id:`e${Math.random()}`,source:R,target:g,data:{minlen:F,weight:k,nestingEdge:!0}})}),n.getParent(h)||n.addEdge({id:`e${Math.random()}`,source:e,target:p,data:{weight:0,minlen:s+o[h]}})},Ut=n=>{const e={},t=(r,s)=>{const o=n.getChildren(r);o==null||o.forEach(h=>t(h.id,s+1)),e[r]=s};return n.getRoots().forEach(r=>t(r.id,1)),e},Yt=n=>{let e=0;return n.getAllEdges().forEach(t=>{e+=t.data.weight}),e},ce=(n,e)=>{e&&n.removeNode(e),n.getAllEdges().forEach(t=>{t.data.nestingEdge&&n.removeEdge(t.id)})},tt="edge",wt="edge-label",Lt=(n,e)=>{n.getAllEdges().forEach(t=>Mt(n,t,e))},Mt=(n,e,t)=>{let r=e.source,s=n.getNode(r).data.rank;const o=e.target,h=n.getNode(o).data.rank,d=e.data.labelRank;if(h===s+1)return;n.removeEdge(e.id);let p,g,y;for(y=0,++s;s{e.forEach(t=>{let r=n.getNode(t);const{data:s}=r,o=s.originalEdge;let h;o&&n.addEdge(o);let d=t;for(;r.data.dummy;)h=n.getSuccessors(d)[0],n.removeNode(d),o.data.points.push({x:r.data.x,y:r.data.y}),r.data.dummy===wt&&(o.data.x=r.data.x,o.data.y=r.data.y,o.data.width=r.data.width,o.data.height=r.data.height),d=h.id,r=n.getNode(d)})};function ae(n){return Array.isArray(n)}var fe=function(n){if(typeof n!="object"||n===null)return n;var e;if(ae(n)){e=[];for(var t=0,r=n.length;t{const r={};let s;t==null||t.forEach(o=>{let h=n.getParent(o),d,p;for(;h;){if(d=n.getParent(h.id),d?(p=r[d.id],r[d.id]=h.id):(p=s,s=h.id),p&&p!==h.id){e.hasNode(p)||e.addNode({id:p,data:{}}),e.hasNode(h.id)||e.addNode({id:h.id,data:{}}),e.hasEdge(`e${p}-${h.id}`)||e.addEdge({id:`e${p}-${h.id}`,source:p,target:h.id,data:{}});return}h=d}})},_e=(n,e,t)=>{const r=Se(n),s=new vt({tree:[{id:r,children:[],data:{}}]});return n.getAllNodes().forEach(o=>{const h=n.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(s.hasNode(o.id)||s.addNode(Object.assign({},o)),h!=null&&h.id&&!s.hasNode(h==null?void 0:h.id)&&s.addNode(Object.assign({},h)),s.setParent(o.id,(h==null?void 0:h.id)||r),n.getRelatedEdges(o.id,t).forEach(d=>{const p=d.source===o.id?d.target:d.source;s.hasNode(p)||s.addNode(Object.assign({},n.getNode(p)));const g=s.getRelatedEdges(p,"out").find(({target:O})=>O===o.id),y=g!==void 0?g.data.weight:0;g?s.updateEdgeData(g.id,Object.assign(Object.assign({},g.data),{weight:d.data.weight+y})):s.addEdge({id:d.id,source:p,target:o.id,data:{weight:d.data.weight+y}})}),o.data.hasOwnProperty("minRank")&&s.updateNodeData(o.id,Object.assign(Object.assign({},o.data),{borderLeft:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))}),s},Se=n=>{let e;for(;n.hasNode(e=`_root${Math.random()}`););return e},Qe=(n,e,t)=>{const r=Wn(t,t.map((y,O)=>O)),o=e.map(y=>{const O=n.getRelatedEdges(y,"out").map(L=>({pos:r[L.target]||0,weight:L.data.weight}));return O==null?void 0:O.sort((L,R)=>L.pos-R.pos)}).flat().filter(y=>y!==void 0);let h=1;for(;h{if(y){let O=y.pos+h;p[O]+=y.weight;let L=0;for(;O>0;)O%2&&(L+=p[O+1]),O=O-1>>1,p[O]+=y.weight;g+=y.weight*L}}),g},He=(n,e)=>{let t=0;for(let r=1;r<(e==null?void 0:e.length);r+=1)t+=Qe(n,e[r-1],e[r]);return t},te=n=>{const e={},t=n.getAllNodes(),r=t.map(g=>{var y;return(y=g.data.rank)!==null&&y!==void 0?y:-1/0}),s=Math.max(...r),o=[];for(let g=0;gn.getNode(g.id).data.rank-n.getNode(y.id).data.rank),p=h.filter(g=>n.getNode(g.id).data.fixorder!==void 0).sort((g,y)=>n.getNode(g.id).data.fixorder-n.getNode(y.id).data.fixorder);return p==null||p.forEach(g=>{isNaN(n.getNode(g.id).data.rank)||o[n.getNode(g.id).data.rank].push(g.id),e[g.id]=!0}),h==null||h.forEach(g=>n.dfsTree(g.id,y=>{if(e.hasOwnProperty(y.id))return!0;e[y.id]=!0,isNaN(y.data.rank)||o[y.data.rank].push(y.id)})),o},Le=(n,e)=>e.map(t=>{const r=n.getRelatedEdges(t,"in");if(!(r!=null&&r.length))return{v:t};const s={sum:0,weight:0};return r==null||r.forEach(o=>{const h=n.getNode(o.source);s.sum+=o.data.weight*h.data.order,s.weight+=o.data.weight}),{v:t,barycenter:s.sum/s.weight,weight:s.weight}}),Ue=(n,e)=>{var t,r,s;const o={};n==null||n.forEach((d,p)=>{o[d.v]={i:p,indegree:0,in:[],out:[],vs:[d.v]};const g=o[d.v];d.barycenter!==void 0&&(g.barycenter=d.barycenter,g.weight=d.weight)}),(t=e.getAllEdges())===null||t===void 0||t.forEach(d=>{const p=o[d.source],g=o[d.target];p!==void 0&&g!==void 0&&(g.indegree++,p.out.push(o[d.target]))});const h=(s=(r=Object.values(o)).filter)===null||s===void 0?void 0:s.call(r,d=>!d.indegree);return Ve(h)},Ve=n=>{var e,t;const r=[],s=p=>g=>{g.merged||(g.barycenter===void 0||p.barycenter===void 0||g.barycenter>=p.barycenter)&&Oe(p,g)},o=p=>g=>{g.in.push(p),--g.indegree===0&&n.push(g)};for(;n!=null&&n.length;){const p=n.pop();r.push(p),(e=p.in.reverse())===null||e===void 0||e.forEach(g=>s(p)(g)),(t=p.out)===null||t===void 0||t.forEach(g=>o(p)(g))}const h=r.filter(p=>!p.merged),d=["vs","i","barycenter","weight"];return h.map(p=>{const g={};return d==null||d.forEach(y=>{p[y]!==void 0&&(g[y]=p[y])}),g})},Oe=(n,e)=>{var t;let r=0,s=0;n.weight&&(r+=n.barycenter*n.weight,s+=n.weight),e.weight&&(r+=e.barycenter*e.weight,s+=e.weight),n.vs=(t=e.vs)===null||t===void 0?void 0:t.concat(n.vs),n.barycenter=r/s,n.weight=s,n.i=Math.min(e.i,n.i),e.merged=!0};var wr=Ue;const xr=(n,e,t,r)=>{const s=U(n,L=>{const R=L.hasOwnProperty("fixorder")&&!isNaN(L.fixorder);return r?!R&&L.hasOwnProperty("barycenter"):R||L.hasOwnProperty("barycenter")}),o=s.lhs,h=s.rhs.sort((L,R)=>-L.i- -R.i),d=[];let p=0,g=0,y=0;o==null||o.sort(Er(!!e,!!t)),y=Qn(d,h,y),o==null||o.forEach(L=>{var R;y+=(R=L.vs)===null||R===void 0?void 0:R.length,d.push(L.vs),p+=L.barycenter*L.weight,g+=L.weight,y=Qn(d,h,y)});const O={vs:d.flat()};return g&&(O.barycenter=p/g,O.weight=g),O},Qn=(n,e,t)=>{let r=t,s;for(;e.length&&(s=e[e.length-1]).i<=r;)e.pop(),n==null||n.push(s.vs),r++;return r},Er=(n,e)=>(t,r)=>{if(t.fixorder!==void 0&&r.fixorder!==void 0)return t.fixorder-r.fixorder;if(t.barycenterr.barycenter)return 1;if(e&&t.order!==void 0&&r.order!==void 0){if(t.orderr.order)return 1}return n?r.i-t.i:t.i-r.i},Hn=(n,e,t,r,s,o)=>{var h,d,p,g;let y=n.getChildren(e).map(W=>W.id);const O=n.getNode(e),L=O?O.data.borderLeft:void 0,R=O?O.data.borderRight:void 0,k={};L&&(y=y==null?void 0:y.filter(W=>W!==L&&W!==R));const F=Le(n,y||[]);F==null||F.forEach(W=>{var $;if(!(($=n.getChildren(W.v))===null||$===void 0)&&$.length){const X=Hn(n,W.v,t,r,o);k[W.v]=X,X.hasOwnProperty("barycenter")&&Nr(W,X)}});const z=wr(F,t);br(z,k),(h=z.filter(W=>W.vs.length>0))===null||h===void 0||h.forEach(W=>{const $=n.getNode(W.vs[0]);$&&(W.fixorder=$.data.fixorder,W.order=$.data.order)});const C=xr(z,r,s,o);if(L&&(C.vs=[L,C.vs,R].flat(),!((d=n.getPredecessors(L))===null||d===void 0)&&d.length)){const W=n.getNode(((p=n.getPredecessors(L))===null||p===void 0?void 0:p[0].id)||""),$=n.getNode(((g=n.getPredecessors(R))===null||g===void 0?void 0:g[0].id)||"");C.hasOwnProperty("barycenter")||(C.barycenter=0,C.weight=0),C.barycenter=(C.barycenter*C.weight+W.data.order+$.data.order)/(C.weight+2),C.weight+=2}return C},br=(n,e)=>{n==null||n.forEach(t=>{var r;const s=(r=t.vs)===null||r===void 0?void 0:r.map(o=>e[o]?e[o].vs:o);t.vs=s.flat()})},Nr=(n,e)=>{n.barycenter!==void 0?(n.barycenter=(n.barycenter*n.weight+e.barycenter*e.weight)/(n.weight+e.weight),n.weight+=e.weight):(n.barycenter=e.barycenter,n.weight=e.weight)},Mr=(n,e)=>{const t=B(n),r=[],s=[];for(let y=1;y-1;y--)s.push(y);const o=qn(n,r,"in"),h=qn(n,s,"out");let d=te(n);Sr(n,d);let p=Number.POSITIVE_INFINITY,g;for(let y=0,O=0;O<4;++y,++O){_r(y%2?o:h,y%4>=2,!1,e),d=c(n);const L=He(n,d);L=2,!0,e),d=c(n);const L=He(n,d);Le.map(r=>_e(n,r,t)),_r=(n,e,t,r)=>{const s=new vt;n==null||n.forEach(o=>{var h;const d=o.getRoots()[0].id,p=Hn(o,d,s,e,t,r);for(let g=0;g<((h=p.vs)===null||h===void 0?void 0:h.length);g++){const y=o.getNode(p.vs[g]);y&&(y.data.order=g)}Re(o,s,p.vs)})},Sr=(n,e)=>{e==null||e.forEach(t=>{t==null||t.forEach((r,s)=>{n.getNode(r).data.order=s})})},ei=(n,e)=>{const r=n.getAllNodes().filter(h=>{var d;return!(!((d=n.getChildren(h.id))===null||d===void 0)&&d.length)}).map(h=>h.data.rank),s=Math.max(...r),o=[];for(let h=0;h{const d=n.getNode(h);!d||d.data.dummy||isNaN(d.data.rank)||(d.data.fixorder=o[d.data.rank].length,o[d.data.rank].push(h))})},ni=n=>{const e={};let t=0;const r=s=>{const o=t;n.getChildren(s).forEach(h=>r(h.id)),e[s]={low:o,lim:t++}};return n.getRoots().forEach(s=>r(s.id)),e},ri=(n,e,t,r)=>{var s,o;const h=[],d=[],p=Math.min(e[t].low,e[r].low),g=Math.max(e[t].lim,e[r].lim);let y,O;y=t;do y=(s=n.getParent(y))===null||s===void 0?void 0:s.id,h.push(y);while(y&&(e[y].low>p||g>e[y].lim));for(O=y,y=r;y&&y!==O;)d.push(y),y=(o=n.getParent(y))===null||o===void 0?void 0:o.id;return{lca:O,path:h.concat(d.reverse())}},si=(n,e)=>{const t=ni(n);e.forEach(r=>{var s,o;let h=r,d=n.getNode(h);const p=d.data.originalEdge;if(!p)return;const g=ri(n,t,p.source,p.target),y=g.path,O=g.lca;let L=0,R=y[L],k=!0;for(;h!==p.target;){if(d=n.getNode(h),k){for(;R!==O&&((s=n.getNode(R))===null||s===void 0?void 0:s.data.maxRank){const t={},r=(s,o)=>{let h=0,d=0;const p=s.length,g=o==null?void 0:o[(o==null?void 0:o.length)-1];return o==null||o.forEach((y,O)=>{var L;const R=ii(n,y),k=R?n.getNode(R.id).data.order:p;(R||y===g)&&((L=o.slice(d,O+1))===null||L===void 0||L.forEach(F=>{var z;(z=n.getPredecessors(F))===null||z===void 0||z.forEach(C=>{var W;const $=n.getNode(C.id),X=$.data.order;(X{const t={};function r(d,p,g,y,O){var L,R;let k;for(let F=p;F{const C=n.getNode(z.id);C.data.dummy&&(C.data.orderO)&&Qr(t,z.id,k)}))}function s(d){return JSON.stringify(d.slice(1))}function o(d,p){const g=s(d);p.get(g)||(r(...d),p.set(g,!0))}const h=(d,p)=>{let g=-1,y,O=0;const L=new Map;return p==null||p.forEach((R,k)=>{var F;if(((F=n.getNode(R))===null||F===void 0?void 0:F.data.dummy)==="border"){const z=n.getPredecessors(R)||[];z.length&&(y=n.getNode(z[0].id).data.order,o([p,O,k,g,y],L),O=k,g=y)}o([p,O,p.length,y,d.length],L)}),p};return e!=null&&e.length&&e.reduce(h),t},ii=(n,e)=>{var t,r;if(!((t=n.getNode(e))===null||t===void 0)&&t.data.dummy)return(r=n.getPredecessors(e))===null||r===void 0?void 0:r.find(s=>n.getNode(s.id).data.dummy)},Qr=(n,e,t)=>{let r=e,s=t;if(r>s){const h=r;r=s,s=h}let o=n[r];o||(n[r]=o={}),o[s]=!0},oi=(n,e,t)=>{let r=e,s=t;if(r>s){const o=e;r=s,s=o}return!!n[r]},Hr=(n,e,t,r)=>{const s={},o={},h={};return e==null||e.forEach(d=>{d==null||d.forEach((p,g)=>{s[p]=p,o[p]=p,h[p]=g})}),e==null||e.forEach(d=>{let p=-1;d==null||d.forEach(g=>{let y=r(g).map(O=>O.id);if(y.length){y=y.sort((L,R)=>h[L]-h[R]);const O=(y.length-1)/2;for(let L=Math.floor(O),R=Math.ceil(O);L<=R;++L){const k=y[L];o[g]===g&&p{var d;const p={},g=ai(n,e,t,s,o,h),y=h?"borderLeft":"borderRight",O=(k,F)=>{let z=g.getAllNodes(),C=z.pop();const W={};for(;C;)W[C.id]?k(C.id):(W[C.id]=!0,z.push(C),z=z.concat(F(C.id))),C=z.pop()},L=k=>{p[k]=(g.getRelatedEdges(k,"in")||[]).reduce((F,z)=>Math.max(F,(p[z.source]||0)+z.data.weight),0)},R=k=>{const F=(g.getRelatedEdges(k,"out")||[]).reduce((C,W)=>Math.min(C,(p[W.target]||0)-W.data.weight),Number.POSITIVE_INFINITY),z=n.getNode(k);F!==Number.POSITIVE_INFINITY&&z.data.borderType!==y&&(p[k]=Math.max(p[k],F))};return O(L,g.getPredecessors.bind(g)),O(R,g.getSuccessors.bind(g)),(d=Object.values(r))===null||d===void 0||d.forEach(k=>{p[k]=p[t[k]]}),p},ai=(n,e,t,r,s,o)=>{const h=new vt,d=ui(r,s,o);return e==null||e.forEach(p=>{let g;p==null||p.forEach(y=>{const O=t[y];if(h.hasNode(O)||h.addNode({id:O,data:{}}),g){const L=t[g],R=h.getRelatedEdges(L,"out").find(k=>k.target===O);R?h.updateEdgeData(R.id,Object.assign(Object.assign({},R.data),{weight:Math.max(d(n,y,g),R.data.weight||0)})):h.addEdge({id:`e${Math.random()}`,source:L,target:O,data:{weight:Math.max(d(n,y,g),0)}})}g=y})}),h},ts=(n,e)=>V(Object.values(e),t=>{var r;let s=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return(r=Object.keys(t))===null||r===void 0||r.forEach(h=>{const d=t[h],p=ci(n,h)/2;s=Math.max(d+p,s),o=Math.min(d-p,o)}),s-o});function es(n,e){const t=Object.values(e),r=Math.min(...t),s=Math.max(...t);["u","d"].forEach(o=>{["l","r"].forEach(h=>{const d=o+h,p=n[d];let g;if(p===e)return;const y=Object.values(p);g=h==="l"?r-Math.min(...y):s-Math.max(...y),g&&(n[d]={},Object.keys(p).forEach(O=>{n[d][O]=p[O]+g}))})})}const ns=(n,e)=>{const t={};return Object.keys(n.ul).forEach(r=>{if(e)t[r]=n[e.toLowerCase()][r];else{const s=Object.values(n).map(o=>o[r]);t[r]=(s[0]+s[1])/2}}),t},Qu=(n,e)=>{const{align:t,nodesep:r=0,edgesep:s=0}=e||{},o=buildLayerMatrix(n),h=Object.assign(Zr(n,o),Jr(n,o)),d={};let p;["u","d"].forEach(y=>{p=y==="u"?o:Object.values(o).reverse(),["l","r"].forEach(O=>{O==="r"&&(p=p.map(F=>Object.values(F).reverse()));const L=(y==="u"?n.getPredecessors:n.getSuccessors).bind(n),R=Hr(n,p,h,L),k=qr(n,p,R.root,R.align,r,s,O==="r");O==="r"&&Object.keys(k).forEach(F=>{k[F]=-k[F]}),d[y+O]=k})});const g=ts(n,d);return es(d,g),ns(d,t)},ui=(n,e,t)=>(r,s,o)=>{const h=r.getNode(s),d=r.getNode(o);let p=0,g=0;if(p+=h.data.width/2,h.data.hasOwnProperty("labelpos"))switch((h.data.labelpos||"").toLowerCase()){case"l":g=-h.data.width/2;break;case"r":g=h.data.width/2;break}if(g&&(p+=t?g:-g),g=0,p+=(h.data.dummy?e:n)/2,p+=(d.data.dummy?e:n)/2,p+=d.data.width/2,d.data.labelpos)switch((d.data.labelpos||"").toLowerCase()){case"l":g=d.data.width/2;break;case"r":g=-d.data.width/2;break}return g&&(p+=t?g:-g),g=0,p},ci=(n,e)=>n.getNode(e).data.width||0,fi=(n,e)=>{const{ranksep:t=0}=e||{},r=c(n);let s=0;r==null||r.forEach(o=>{const h=o.map(p=>n.getNode(p).data.height),d=Math.max(...h,0);o==null||o.forEach(p=>{n.getNode(p).data.y=s+d/2}),s+=d+t})},li=(n,e)=>{const{align:t,nodesep:r=0,edgesep:s=0}=e||{},o=c(n),h=Object.assign(Zr(n,o),Jr(n,o)),d={};let p=[];["u","d"].forEach(y=>{p=y==="u"?o:Object.values(o).reverse(),["l","r"].forEach(O=>{O==="r"&&(p=p.map(F=>Object.values(F).reverse()));const L=(y==="u"?n.getPredecessors:n.getSuccessors).bind(n),R=Hr(n,p,h,L),k=qr(n,p,R.root,R.align,r,s,O==="r");O==="r"&&Object.keys(k).forEach(F=>k[F]=-k[F]),d[y+O]=k})});const g=ts(n,d);return g&&es(d,g),ns(d,t)},di=(n,e)=>{var t;const r=Tn(n);fi(r,e);const s=li(r,e);(t=Object.keys(s))===null||t===void 0||t.forEach(o=>{r.getNode(o).data.x=s[o]})},rs=n=>{const e={},t=r=>{var s;const o=n.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;e[r]=!0;let h;return(s=n.getRelatedEdges(r,"out"))===null||s===void 0||s.forEach(d=>{const p=t(d.target),g=d.data.minlen,y=p-g;y&&(h===void 0||yn.getRelatedEdges(r.id,"in").length===0).forEach(r=>t(r.id))},hi=n=>{const e={};let t;const r=h=>{var d;const p=n.getNode(h);if(!p)return 0;if(e[h])return p.data.rank;e[h]=!0;let g;return(d=n.getRelatedEdges(h,"out"))===null||d===void 0||d.forEach(y=>{const O=r(y.target),L=y.data.minlen,R=O-L;R&&(g===void 0||Rn.getRelatedEdges(h.id,"in").length===0).forEach(h=>{h&&r(h.id)}),t===void 0&&(t=0);const s={},o=(h,d)=>{var p;const g=n.getNode(h),y=isNaN(g.data.layer)?d:g.data.layer;(g.data.rank===void 0||g.data.rank{o(O.target,y+O.data.minlen)}))};n.getAllNodes().forEach(h=>{const d=h.data;d&&(isNaN(d.layer)?d.rank-=t:o(h.id,d.layer))})},wn=(n,e)=>n.getNode(e.target).data.rank-n.getNode(e.source).data.rank-e.data.minlen,gi=n=>{const e=new vt({tree:[]}),t=n.getAllNodes()[0],r=n.getAllNodes().length;e.addNode(t);let s,o;for(;pi(e,n){const t=r=>{e.getRelatedEdges(r,"both").forEach(s=>{const o=s.source,h=r===o?s.target:o;!n.hasNode(h)&&!wn(e,s)&&(n.addNode({id:h,data:{}}),n.addEdge({id:s.id,source:r,target:h,data:{}}),t(h))})};return n.getAllNodes().forEach(r=>t(r.id)),n.getAllNodes().length},vi=n=>{const e=new vt({tree:[]}),t=n.getAllNodes()[0],r=n.getAllNodes().length;e.addNode(t);let s,o;for(;mi(e,n){const t=r=>{var s;(s=e.getRelatedEdges(r,"both"))===null||s===void 0||s.forEach(o=>{const h=o.source,d=r===h?o.target:h;!n.hasNode(d)&&(e.getNode(d).data.layer!==void 0||!wn(e,o))&&(n.addNode({id:d,data:{}}),n.addEdge({id:o.id,source:r,target:d,data:{}}),t(d))})};return n.getAllNodes().forEach(r=>t(r.id)),n.getAllNodes().length},ss=(n,e)=>V(e.getAllEdges(),t=>n.hasNode(t.source)!==n.hasNode(t.target)?wn(e,t):1/0),is=(n,e,t)=>{n.getAllNodes().forEach(r=>{const s=e.getNode(r.id);s.data.rank||(s.data.rank=0),s.data.rank+=t})},yi=n=>{const e=mr(n);rs(e);const t=gi(e);as(t),os(t,e);let r,s;for(;r=Ei(t);)s=bi(t,e,r),Ni(t,e,r,s)},os=(n,e)=>{let t=rt(n,n.getAllNodes(),"post",!1);t=t.slice(0,(t==null?void 0:t.length)-1),t.forEach(r=>{wi(n,e,r)})},wi=(n,e,t)=>{const s=n.getNode(t).data.parent,o=n.getRelatedEdges(t,"both").find(h=>h.target===s||h.source===s);o.data.cutvalue=xi(n,e,t)},xi=(n,e,t)=>{const s=n.getNode(t).data.parent;let o=!0,h=e.getRelatedEdges(t,"out").find(p=>p.target===s),d=0;return h||(o=!1,h=e.getRelatedEdges(s,"out").find(p=>p.target===t)),d=h.data.weight,e.getRelatedEdges(t,"both").forEach(p=>{const g=p.source===t,y=g?p.target:p.source;if(y!==s){const O=g===o,L=p.data.weight;if(d+=O?L:-L,Si(n,t,y)){const R=n.getRelatedEdges(t,"both").find(k=>k.source===y||k.target===y).data.cutvalue;d+=O?-R:R}}}),d},as=(n,e=n.getAllNodes()[0].id)=>{us(n,{},1,e)},us=(n,e,t,r,s)=>{var o;const h=t;let d=t;const p=n.getNode(r);return e[r]=!0,(o=n.getNeighbors(r))===null||o===void 0||o.forEach(g=>{e[g.id]||(d=us(n,e,d,g.id,r))}),p.data.low=h,p.data.lim=d++,s?p.data.parent=s:delete p.data.parent,d},Ei=n=>n.getAllEdges().find(e=>e.data.cutvalue<0),bi=(n,e,t)=>{let r=t.source,s=t.target;e.getRelatedEdges(r,"out").find(y=>y.target===s)||(r=t.target,s=t.source);const o=n.getNode(r),h=n.getNode(s);let d=o,p=!1;o.data.lim>h.data.lim&&(d=h,p=!0);const g=e.getAllEdges().filter(y=>p===cs(n.getNode(y.source),d)&&p!==cs(n.getNode(y.target),d));return V(g,y=>wn(e,y))},Ni=(n,e,t,r)=>{const s=n.getRelatedEdges(t.source,"both").find(o=>o.source===t.target||o.target===t.target);s&&n.removeEdge(s.id),n.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),as(n),os(n,e),Mi(n,e)},Mi=(n,e)=>{const t=n.getAllNodes().find(s=>!s.data.parent);let r=rt(n,t,"pre",!1);r=r.slice(1),r.forEach(s=>{const o=n.getNode(s).data.parent;let h=e.getRelatedEdges(s,"out").find(p=>p.target===o),d=!1;!h&&e.hasNode(o)&&(h=e.getRelatedEdges(o,"out").find(p=>p.target===s),d=!0),e.getNode(s).data.rank=(e.hasNode(o)&&e.getNode(o).data.rank||0)+(d?h==null?void 0:h.data.minlen:-(h==null?void 0:h.data.minlen))})},Si=(n,e,t)=>n.getRelatedEdges(e,"both").find(r=>r.source===t||r.target===t),cs=(n,e)=>e.data.low<=n.data.lim&&n.data.lim<=e.data.lim,Oi=(n,e)=>{switch(e){case"network-simplex":Ti(n);break;case"tight-tree":fs(n);break;case"longest-path":Ai(n);break;default:fs(n)}},Ai=rs,fs=n=>{hi(n),vi(n)},Ti=n=>{yi(n)},ji=(n,e)=>{const{edgeLabelSpace:t,keepNodeOrder:r,prevGraph:s,rankdir:o,ranksep:h}=e;!r&&s&&Pi(n,s);const d=Fi(n);t&&(e.ranksep=ki(d,{rankdir:o,ranksep:h}));let p;try{p=Ii(d,e)}catch(g){if(g.message==="Not possible to find intersection inside of the rectangle"){console.error(`The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure: `,g);return}throw g}return Ri(n,d),p},Ii=(n,e)=>{const{acyclicer:t,ranker:r,rankdir:s="tb",nodeOrder:o,keepNodeOrder:h,align:d,nodesep:p=50,edgesep:g=20,ranksep:y=50}=e;Ki(n),gr(n,t);const{nestingRoot:O,nodeRankFactor:L}=Zt(n);Oi(Tn(n),r),Bi(n),l(n,L),ce(n,O),i(n),Ui(n),Vi(n);const R=[];Lt(n,R),si(n,R),_(n),h&&ei(n,o),Mr(n,h),_i(n),Tt(n,s),di(n,{align:d,nodesep:p,edgesep:g,ranksep:y}),Zi(n),Xi(n),we(n,R),Yi(n),ct(n,s);const{width:k,height:F}=Gi(n);return Wi(n),$i(n),pr(n),{width:k,height:F}},Pi=(n,e)=>{n.getAllNodes().forEach(t=>{const r=n.getNode(t.id);if(e.hasNode(t.id)){const s=e.getNode(t.id);r.data.fixorder=s.data._order,delete s.data._order}else delete r.data.fixorder})},Ri=(n,e)=>{n.getAllNodes().forEach(t=>{var r;const s=n.getNode(t.id);if(s){const o=e.getNode(t.id);s.data.x=o.data.x,s.data.y=o.data.y,s.data._order=o.data.order,s.data._rank=o.data.rank,!((r=e.getChildren(t.id))===null||r===void 0)&&r.length&&(s.data.width=o.data.width,s.data.height=o.data.height)}}),n.getAllEdges().forEach(t=>{const r=n.getEdge(t.id),s=e.getEdge(t.id);r.data.points=s?s.data.points:[],s&&s.data.hasOwnProperty("x")&&(r.data.x=s.data.x,r.data.y=s.data.y)})},Li=["width","height","layer","fixorder"],Ci={width:0,height:0},Di=["minlen","weight","width","height","labeloffset"],zi={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Or=["labelpos"],Fi=n=>{const e=new vt({tree:[]});return n.getAllNodes().forEach(t=>{const r=ds(n.getNode(t.id).data),s=Object.assign(Object.assign({},Ci),r),o=ls(s,Li);e.hasNode(t.id)||e.addNode({id:t.id,data:Object.assign({},o)});const h=n.hasTreeStructure("combo")?n.getParent(t.id,"combo"):n.getParent(t.id);on(h)||(e.hasNode(h.id)||e.addNode(Object.assign({},h)),e.setParent(t.id,h.id))}),n.getAllEdges().forEach(t=>{const r=ds(n.getEdge(t.id).data),s={};Or==null||Or.forEach(o=>{r[o]!==void 0&&(s[o]=r[o])}),e.addEdge({id:t.id,source:t.source,target:t.target,data:Object.assign({},zi,ls(r,Di),s)})}),e},ki=(n,e)=>{const{ranksep:t=0,rankdir:r}=e;return n.getAllNodes().forEach(s=>{isNaN(s.data.layer)||s.data.layer||(s.data.layer=0)}),n.getAllEdges().forEach(s=>{var o;s.data.minlen*=2,((o=s.data.labelpos)===null||o===void 0?void 0:o.toLowerCase())!=="c"&&(r==="TB"||r==="BT"?s.data.width+=s.data.labeloffset:s.data.height+=s.data.labeloffset)}),t/2},Bi=n=>{n.getAllEdges().forEach(e=>{if(e.data.width&&e.data.height){const t=n.getNode(e.source),r=n.getNode(e.target),s={e,rank:(r.data.rank-t.data.rank)/2+t.data.rank};yn(n,"edge-proxy",s,"_ep")}})},Ui=n=>{let e=0;return n.getAllNodes().forEach(t=>{var r,s;t.data.borderTop&&(t.data.minRank=(r=n.getNode(t.data.borderTop))===null||r===void 0?void 0:r.data.rank,t.data.maxRank=(s=n.getNode(t.data.borderBottom))===null||s===void 0?void 0:s.data.rank,e=Math.max(e,t.data.maxRank||-1/0))}),e},Vi=n=>{n.getAllNodes().forEach(e=>{e.data.dummy==="edge-proxy"&&(n.getEdge(e.data.e.id).data.labelRank=e.data.rank,n.removeNode(e.id))})},Gi=(n,e)=>{let t,r=0,s,o=0;const{marginx:h=0,marginy:d=0}=e||{},p=g=>{if(!g.data)return;const y=g.data.x,O=g.data.y,L=g.data.width,R=g.data.height;!isNaN(y)&&!isNaN(L)&&(t===void 0&&(t=y-L/2),t=Math.min(t,y-L/2),r=Math.max(r,y+L/2)),!isNaN(O)&&!isNaN(R)&&(s===void 0&&(s=O-R/2),s=Math.min(s,O-R/2),o=Math.max(o,O+R/2))};return n.getAllNodes().forEach(g=>{p(g)}),n.getAllEdges().forEach(g=>{g!=null&&g.data.hasOwnProperty("x")&&p(g)}),t-=h,s-=d,n.getAllNodes().forEach(g=>{g.data.x-=t,g.data.y-=s}),n.getAllEdges().forEach(g=>{var y;(y=g.data.points)===null||y===void 0||y.forEach(O=>{O.x-=t,O.y-=s}),g.data.hasOwnProperty("x")&&(g.data.x-=t),g.data.hasOwnProperty("y")&&(g.data.y-=s)}),{width:r-t+h,height:o-s+d}},Wi=n=>{n.getAllEdges().forEach(e=>{const t=n.getNode(e.source),r=n.getNode(e.target);let s,o;e.data.points?(s=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],s={x:r.data.x,y:r.data.y},o={x:t.data.x,y:t.data.y}),e.data.points.unshift(u(t.data,s)),e.data.points.push(u(r.data,o))})},Yi=n=>{n.getAllEdges().forEach(e=>{if(e.data.hasOwnProperty("x"))switch((e.data.labelpos==="l"||e.data.labelpos==="r")&&(e.data.width-=e.data.labeloffset),e.data.labelpos){case"l":e.data.x-=e.data.width/2+e.data.labeloffset;break;case"r":e.data.x+=e.data.width/2+e.data.labeloffset;break}})},$i=n=>{n.getAllEdges().forEach(e=>{var t;e.data.reversed&&((t=e.data.points)===null||t===void 0||t.reverse())})},Xi=n=>{n.getAllNodes().forEach(e=>{var t,r,s;if(!((t=n.getChildren(e.id))===null||t===void 0)&&t.length){const o=n.getNode(e.id),h=n.getNode(o.data.borderTop),d=n.getNode(o.data.borderBottom),p=n.getNode(o.data.borderLeft[((r=o.data.borderLeft)===null||r===void 0?void 0:r.length)-1]),g=n.getNode(o.data.borderRight[((s=o.data.borderRight)===null||s===void 0?void 0:s.length)-1]);o.data.width=Math.abs((g==null?void 0:g.data.x)-(p==null?void 0:p.data.x))||10,o.data.height=Math.abs((d==null?void 0:d.data.y)-(h==null?void 0:h.data.y))||10,o.data.x=((p==null?void 0:p.data.x)||0)+o.data.width/2,o.data.y=((h==null?void 0:h.data.y)||0)+o.data.height/2}}),n.getAllNodes().forEach(e=>{e.data.dummy==="border"&&n.removeNode(e.id)})},Ki=n=>{n.getAllEdges().forEach(e=>{if(e.source===e.target){const t=n.getNode(e.source);t.data.selfEdges||(t.data.selfEdges=[]),t.data.selfEdges.push(e),n.removeEdge(e.id)}})},_i=n=>{const e=c(n);e==null||e.forEach(t=>{let r=0;t==null||t.forEach((s,o)=>{var h;const d=n.getNode(s);d.data.order=o+r,(h=d.data.selfEdges)===null||h===void 0||h.forEach(p=>{yn(n,"selfedge",{width:p.data.width,height:p.data.height,rank:d.data.rank,order:o+ ++r,e:p},"_se")}),delete d.data.selfEdges})})},Zi=n=>{n.getAllNodes().forEach(e=>{const t=n.getNode(e.id);if(t.data.dummy==="selfedge"){const r=n.getNode(t.data.e.source),s=r.data.x+r.data.width/2,o=r.data.y,h=t.data.x-s,d=r.data.height/2;n.hasEdge(t.data.e.id)?n.updateEdgeData(t.data.e.id,t.data.e.data):n.addEdge({id:t.data.e.id,source:t.data.e.source,target:t.data.e.target,data:t.data.e.data}),n.removeNode(e.id),t.data.e.data.points=[{x:s+2*h/3,y:o-d},{x:s+5*h/6,y:o-d},{y:o,x:s+h},{x:s+5*h/6,y:o+d},{x:s+2*h/3,y:o+d}],t.data.e.data.x=t.data.x,t.data.e.data.y=t.data.y}})},ls=(n,e)=>{const t={};return e==null||e.forEach(r=>{n[r]!==void 0&&(t[r]=+n[r])}),t},ds=(n={})=>{const e={};return Object.keys(n).forEach(t=>{e[t.toLowerCase()]=n[t]}),e};function qe(n){return typeof n=="function"}var xn=function(n){var e=typeof n;return n!==null&&e==="object"||e==="function"};function En(n,e){let t;return qe(e)?t=e:$t(e)?t=()=>e:t=()=>n,t}function hs(n,e,t=!0){return!e&&e!==0?r=>{const{size:s}=r.data||{};return s?Array.isArray(s)?s[0]>s[1]?s[0]:s[1]:xn(s)?s.width>s.height?s.width:s.height:s:n}:qe(e)?e:$t(e)?()=>e:Array.isArray(e)?()=>{if(t){const r=Math.max(...e);return isNaN(r)?n:r}return e}:xn(e)?()=>{if(t){const r=Math.max(e.width,e.height);return isNaN(r)?n:r}return[e.width,e.height]}:()=>n}const gs=(n,e)=>{let t,r;return $t(e)?r=()=>e:qe(e)?r=e:r=()=>0,n?Array.isArray(n)?t=s=>(n[0]>n[1]?n[0]:n[1])+r(s):qe(n)?t=n:t=s=>n+r(s):t=s=>{var o,h;if(!((o=s.data)===null||o===void 0)&&o.bboxSize)return Math.max(s.data.bboxSize[0],s.data.bboxSize[1])+r(s);if(!((h=s.data)===null||h===void 0)&&h.size){if(Array.isArray(s.data.size))return Math.max(s.data.size[0],s.data.size[1])+r(s);const d=s.data.size;return xn(d)?(d.width>d.height?d.width:d.height)+r(s):d+r(s)}return 10+r(s)},t},Ar=n=>{if(n===null)return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof Array){const e=[];return n.forEach(t=>{e.push(t)}),e.map(t=>Ar(t))}if(typeof n=="object"){const e={};return Object.keys(n).forEach(t=>{e[t]=Ar(n[t])}),e}return n},Ze=(n,e)=>{const t=Ar(n);return t.data=t.data||{},e&&($t(t.data.x)||(t.data.x=Math.random()*e[0]),$t(t.data.y)||(t.data.y=Math.random()*e[1])),t},Ji={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class Qi{constructor(e={}){this.options=e,this.id="antv-dagre",this.options=Object.assign(Object.assign({},Ji),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,e,t)})}genericDagreLayout(e,t,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{nodeSize:o,align:h,rankdir:d="TB",ranksep:p,nodesep:g,ranksepFunc:y,nodesepFunc:O,edgeLabelSpace:L,ranker:R,nodeOrder:k,begin:F,controlPoints:z,radial:C,sortByCombo:W,preset:$}=s,X=new vt({tree:[]}),q=En(p||50,y),st=En(g||50,O);let ut=st,J=q;(d==="LR"||d==="RL")&&(ut=q,J=st);const mt=gs(o,void 0),Et=t.getAllNodes(),jt=t.getAllEdges();Et.forEach(bt=>{const kt=mt(bt),Qt=J(bt),Xt=ut(bt),ie=kt+2*Xt,de=kt+2*Qt,Jt=bt.data.layer;$t(Jt)?X.addNode({id:bt.id,data:{width:ie,height:de,layer:Jt}}):X.addNode({id:bt.id,data:{width:ie,height:de}})}),W&&(X.attachTreeStructure("combo"),Et.forEach(bt=>{const{parentId:kt}=bt.data;kt!==void 0&&X.hasNode(kt)&&X.setParent(bt.id,kt,"combo")})),jt.forEach(bt=>{X.addEdge({id:bt.id,source:bt.source,target:bt.target,data:{weight:bt.data.weight||1}})});let Pt;$!=null&&$.length&&(Pt=new vt({nodes:$})),ji(X,{prevGraph:Pt,edgeLabelSpace:L,keepNodeOrder:!!k,nodeOrder:k||[],acyclicer:"greedy",ranker:R,rankdir:d,nodesep:g,align:h});const Dt=[0,0];if(F){let bt=1/0,kt=1/0;X.getAllNodes().forEach(Qt=>{bt>Qt.data.x&&(bt=Qt.data.x),kt>Qt.data.y&&(kt=Qt.data.y)}),X.getAllEdges().forEach(Qt=>{var Xt;(Xt=Qt.data.points)===null||Xt===void 0||Xt.forEach(ie=>{bt>ie.x&&(bt=ie.x),kt>ie.y&&(kt=ie.y)})}),Dt[0]=F[0]-bt,Dt[1]=F[1]-kt}const Gt=d==="LR"||d==="RL";if(!C){const bt=new Set,Qt=d==="BT"||d==="RL"?(Jt,oe)=>oe-Jt:(Jt,oe)=>Jt-oe;X.getAllNodes().forEach(Jt=>{Jt.data.x=Jt.data.x+Dt[0],Jt.data.y=Jt.data.y+Dt[1],bt.add(Gt?Jt.data.x:Jt.data.y)});const Xt=Array.from(bt).sort(Qt),ie=Gt?(Jt,oe)=>Jt.x!==oe.x:(Jt,oe)=>Jt.y!==oe.y,de=Gt?(Jt,oe,Te)=>{const Ee=Math.max(oe.y,Te.y),en=Math.min(oe.y,Te.y);return Jt.filter(gn=>gn.y<=Ee&&gn.y>=en)}:(Jt,oe,Te)=>{const Ee=Math.max(oe.x,Te.x),en=Math.min(oe.x,Te.x);return Jt.filter(gn=>gn.x<=Ee&&gn.x>=en)};X.getAllEdges().forEach((Jt,oe)=>{var Te;L&&z&&Jt.data.type!=="loop"&&(Jt.data.controlPoints=Hi((Te=Jt.data.points)===null||Te===void 0?void 0:Te.map(({x:Ee,y:en})=>({x:Ee+Dt[0],y:en+Dt[1]})),X.getNode(Jt.source),X.getNode(Jt.target),Xt,Gt,ie,de))})}let zt=[];zt=X.getAllNodes().map(bt=>Ze(bt));const _t=X.getAllEdges();return e&&(zt.forEach(bt=>{t.mergeNodeData(bt.id,{x:bt.data.x,y:bt.data.y})}),_t.forEach(bt=>{t.mergeEdgeData(bt.id,{controlPoints:bt.data.controlPoints})})),{nodes:zt,edges:_t}})}}const Hi=(n,e,t,r,s,o,h)=>{let d=(n==null?void 0:n.slice(1,n.length-1))||[];if(e&&t){let{x:p,y:g}=e.data,{x:y,y:O}=t.data;if(s&&(p=e.data.y,g=e.data.x,y=t.data.y,O=t.data.x),O!==g&&p!==y){const L=r.indexOf(g),R=r[L+1];if(R){const z=d[0],C=s?{x:(g+R)/2,y:(z==null?void 0:z.y)||y}:{x:(z==null?void 0:z.x)||y,y:(g+R)/2};(!z||o(z,C))&&d.unshift(C)}const k=r.indexOf(O),F=Math.abs(k-L);if(F===1)d=h(d,e.data,t.data),d.length||d.push(s?{x:(g+O)/2,y:p}:{x:p,y:(g+O)/2});else if(F>1){const z=r[k-1];if(z){const C=d[d.length-1],W=s?{x:(O+z)/2,y:(C==null?void 0:C.y)||y}:{x:(C==null?void 0:C.x)||p,y:(O+z)/2};(!C||o(C,W))&&d.push(W)}}}}return d},jn=(n,e,t)=>{const r=n.getAllNodes(),s=n.getAllEdges();if(!(r!=null&&r.length))return{nodes:[],edges:s};if(r.length===1)return e&&n.mergeNodeData(r[0].id,{x:t[0],y:t[1]}),{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:t[0],y:t[1]})})],edges:s}},qi={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class to{constructor(e={}){this.options=e,this.id="circular",this.options=Object.assign(Object.assign({},qi),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericCircularLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericCircularLayout(!0,e,t)})}genericCircularLayout(e,t,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{width:o,height:h,center:d,divisions:p,startAngle:g=0,endAngle:y=2*Math.PI,angleRatio:O,ordering:L,clockwise:R,nodeSpacing:k,nodeSize:F}=s,z=t.getAllNodes(),C=t.getAllEdges(),[W,$,X]=no(o,h,d),q=z==null?void 0:z.length;if(!q||q===1)return jn(t,e,X);const st=(y-g)/q;let{radius:ut,startRadius:J,endRadius:mt}=s;if(k){const Gt=En(10,k),zt=hs(10,F);let _t=-1/0;z.forEach(bt=>{const kt=zt(bt);_t{kt===0?le+=_t||10:le+=(Gt(bt)||0)+(_t||10)}),ut=le/(2*Math.PI)}else!ut&&!J&&!mt?ut=Math.min($,W)/2:!J&&mt?J=mt:J&&!mt&&(mt=J);const Et=st*O;let jt=[];L==="topology"?jt=ps(t,z):L==="topology-directed"?jt=ps(t,z,!0):L==="degree"?jt=eo(t,z):jt=z.map(Gt=>Ze(Gt));const Pt=Math.ceil(q/p);for(let Gt=0;Gt{t.mergeNodeData(Gt.id,{x:Gt.data.x,y:Gt.data.y})}),{nodes:jt,edges:C}})}}const ps=(n,e,t=!1)=>{const r=[Ze(e[0])],s={},o=e.length;s[e[0].id]=!0;let h=0;return e.forEach((d,p)=>{if(p!==0)if((p===o-1||n.getDegree(d.id,"both")!==n.getDegree(e[p+1].id,"both")||n.areNeighbors(r[h].id,d.id))&&!s[d.id])r.push(Ze(d)),s[d.id]=!0,h++;else{const g=t?n.getSuccessors(r[h].id):n.getNeighbors(r[h].id);let y=!1;for(let L=0;L{t.push(Ze(r))}),t.sort((r,s)=>n.getDegree(r.id,"both")-n.getDegree(s.id,"both")),t}const no=(n,e,t)=>{let r=n,s=e,o=t;return!r&&typeof window!="undefined"&&(r=window.innerWidth),!s&&typeof window!="undefined"&&(s=window.innerHeight),o||(o=[r/2,s/2]),[r,s,o]};function Yn(n){return typeof n=="string"}const Ge=Array.isArray,ro={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:3/2*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class Tr{constructor(e={}){this.options=e,this.id="concentric",this.options=Object.assign(Object.assign({},ro),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericConcentricLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericConcentricLayout(!0,e,t)})}genericConcentricLayout(e,t,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{center:o,width:h,height:d,sortBy:p,maxLevelDiff:g,sweep:y,clockwise:O,equidistant:L,preventOverlap:R,startAngle:k=3/2*Math.PI,nodeSize:F,nodeSpacing:z}=s,C=t.getAllNodes(),W=t.getAllEdges(),$=!h&&typeof window!="undefined"?window.innerWidth:h,X=!d&&typeof window!="undefined"?window.innerHeight:d,q=o||[$/2,X/2];if(!(C!=null&&C.length)||C.length===1)return jn(t,e,q);const st=[];let ut,J=0;Ge(F)?ut=Math.max(F[0],F[1]):qe(F)?(ut=-1/0,C.forEach(bt=>{const kt=F(bt);kt>ut&&(ut=kt)})):ut=F,Ge(z)?J=Math.max(z[0],z[1]):$t(z)&&(J=z),C.forEach(bt=>{const kt=Ze(bt);st.push(kt);let Qt=ut;const{data:Xt}=kt;Ge(Xt.size)?Qt=Math.max(Xt.size[0],Xt.size[1]):$t(Xt.size)?Qt=Xt.size:xn(Xt.size)&&(Qt=Math.max(Xt.size.width,Xt.size.height)),ut=Math.max(ut,Qt),qe(z)&&(J=Math.max(z(bt),J))});const mt={};st.forEach((bt,kt)=>{mt[bt.id]=kt});let Et=p;(!Yn(Et)||st[0].data[Et]===void 0)&&(Et="degree"),Et==="degree"?st.sort((bt,kt)=>t.getDegree(kt.id,"both")-t.getDegree(bt.id,"both")):st.sort((bt,kt)=>kt.data[Et]-bt.data[Et]);const jt=st[0],Pt=(g||(Et==="degree"?t.getDegree(jt.id,"both"):jt.data[Et]))/4,Dt=[{nodes:[]}];let Gt=Dt[0];st.forEach(bt=>{if(Gt.nodes.length>0){const kt=Math.abs(Et==="degree"?t.getDegree(Gt.nodes[0].id,"both")-t.getDegree(bt.id,"both"):Gt.nodes[0].data[Et]-bt.data[Et]);Pt&&kt>=Pt&&(Gt={nodes:[]},Dt.push(Gt))}Gt.nodes.push(bt)});let zt=ut+J;if(!R){const bt=Dt.length>0&&Dt[0].nodes.length>1,Qt=(Math.min($,X)/2-zt)/(Dt.length+(bt?1:0));zt=Math.min(zt,Qt)}let _t=0;if(Dt.forEach(bt=>{const kt=y===void 0?2*Math.PI-2*Math.PI/bt.nodes.length:y;if(bt.dTheta=kt/Math.max(1,bt.nodes.length-1),bt.nodes.length>1&&R){const Qt=Math.cos(bt.dTheta)-Math.cos(0),Xt=Math.sin(bt.dTheta)-Math.sin(0),ie=Math.sqrt(zt*zt/(Qt*Qt+Xt*Xt));_t=Math.max(ie,_t)}bt.r=_t,_t+=zt}),L){let bt=0,kt=0;for(let Qt=0;Qt{Xt===0&&(kt=Qt.r||0),Qt.r=kt,kt+=bt})}return Dt.forEach(bt=>{const kt=bt.dTheta||0,Qt=bt.r||0;bt.nodes.forEach((Xt,ie)=>{const de=k+(O?1:-1)*kt*ie;Xt.data.x=q[0]+Qt*Math.cos(de),Xt.data.y=q[1]+Qt*Math.sin(de)})}),e&&st.forEach(bt=>t.mergeNodeData(bt.id,{x:bt.data.x,y:bt.data.y})),{nodes:st,edges:W}})}}function so(n){const e=+this._x.call(null,n),t=+this._y.call(null,n);return vs(this.cover(e,t),e,t,n)}function vs(n,e,t,r){if(isNaN(e)||isNaN(t))return n;var s,o=n._root,h={data:r},d=n._x0,p=n._y0,g=n._x1,y=n._y1,O,L,R,k,F,z,C,W;if(!o)return n._root=h,n;for(;o.length;)if((F=e>=(O=(d+g)/2))?d=O:g=O,(z=t>=(L=(p+y)/2))?p=L:y=L,s=o,!(o=o[C=z<<1|F]))return s[C]=h,n;if(R=+n._x.call(null,o.data),k=+n._y.call(null,o.data),e===R&&t===k)return h.next=o,s?s[C]=h:n._root=h,n;do s=s?s[C]=new Array(4):n._root=new Array(4),(F=e>=(O=(d+g)/2))?d=O:g=O,(z=t>=(L=(p+y)/2))?p=L:y=L;while((C=z<<1|F)===(W=(k>=L)<<1|R>=O));return s[W]=o,s[C]=h,n}function io(n){var e,t,r=n.length,s,o,h=new Array(r),d=new Array(r),p=1/0,g=1/0,y=-1/0,O=-1/0;for(t=0;ty&&(y=s),oO&&(O=o));if(p>y||g>O)return this;for(this.cover(p,g).cover(y,O),t=0;tn||n>=s||r>e||e>=o;)switch(g=(ey||(d=k.y0)>O||(p=k.x1)=C)<<1|n>=z)&&(k=L[L.length-1],L[L.length-1]=L[L.length-1-F],L[L.length-1-F]=k)}else{var W=n-+this._x.call(null,R.data),$=e-+this._y.call(null,R.data),X=W*W+$*$;if(X=(L=(h+p)/2))?h=L:p=L,(F=O>=(R=(d+g)/2))?d=R:g=R,e=t,!(t=t[z=F<<1|k]))return this;if(!t.length)break;(e[z+1&3]||e[z+2&3]||e[z+3&3])&&(r=e,C=z)}for(;t.data!==n;)if(s=t,!(t=t.next))return this;return(o=t.next)&&delete t.next,s?(o?s.next=o:delete s.next,this):e?(o?e[z]=o:delete e[z],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(r?r[C]=t:this._root=t),this):(this._root=o,this)}function lo(n){for(var e=0,t=n.length;e=(k=(p+O)/2))?p=k:O=k,(q=t>=(F=(g+L)/2))?g=F:L=F,(st=r>=(z=(y+R)/2))?y=z:R=z,o=h,!(h=h[ut=st<<2|q<<1|X]))return o[ut]=d,n;if(C=+n._x.call(null,h.data),W=+n._y.call(null,h.data),$=+n._z.call(null,h.data),e===C&&t===W&&r===$)return d.next=h,o?o[ut]=d:n._root=d,n;do o=o?o[ut]=new Array(8):n._root=new Array(8),(X=e>=(k=(p+O)/2))?p=k:O=k,(q=t>=(F=(g+L)/2))?g=F:L=F,(st=r>=(z=(y+R)/2))?y=z:R=z;while((ut=st<<2|q<<1|X)===(J=($>=z)<<2|(W>=F)<<1|C>=k));return o[J]=h,o[ut]=d,n}function bo(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e),r=new Float64Array(e),s=new Float64Array(e);let o=1/0,h=1/0,d=1/0,p=-1/0,g=-1/0,y=-1/0;for(let O=0,L,R,k,F;Op&&(p=R),kg&&(g=k),Fy&&(y=F));if(o>p||h>g||d>y)return this;this.cover(o,h,d).cover(p,g,y);for(let O=0;On||n>=h||s>e||e>=d||o>t||t>=p;)switch(L=(tk||(g=$.y0)>F||(y=$.z0)>z||(O=$.x1)=ut)<<2|(e>=st)<<1|n>=q)&&($=C[C.length-1],C[C.length-1]=C[C.length-1-X],C[C.length-1-X]=$)}else{var J=n-+this._x.call(null,W.data),mt=e-+this._y.call(null,W.data),Et=t-+this._z.call(null,W.data),jt=J*J+mt*mt+Et*Et;if(jtMath.sqrt(ur(n-r,2)+ur(e-s,2)+ur(t-o,2));function To(n,e,t,r){const s=[],o=n-r,h=e-r,d=t-r,p=n+r,g=e+r,y=t+r;return this.visit((O,L,R,k,F,z,C)=>{if(!O.length)do{const W=O.data;Ao(n,e,t,this._x(W),this._y(W),this._z(W))<=r&&s.push(W)}while(O=O.next);return L>p||R>g||k>y||F=(F=(h+g)/2))?h=F:g=F,($=R>=(z=(d+y)/2))?d=z:y=z,(X=k>=(C=(p+O)/2))?p=C:O=C,e=t,!(t=t[q=X<<2|$<<1|W]))return this;if(!t.length)break;(e[q+1&7]||e[q+2&7]||e[q+3&7]||e[q+4&7]||e[q+5&7]||e[q+6&7]||e[q+7&7])&&(r=e,st=q)}for(;t.data!==n;)if(s=t,!(t=t.next))return this;return(o=t.next)&&delete t.next,s?(o?s.next=o:delete s.next,this):e?(o?e[q]=o:delete e[q],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(r?r[st]=t:this._root=t),this):(this._root=o,this)}function Io(n){for(var e=0,t=n.length;e{const{nodeStrength:L,x:R,y:k,z:F,size:z}=y.data;return{x:R,y:k,z:F,size:z,index:O,id:y.id,vx:0,vy:0,vz:0,weight:o*L}}),p=(s===2?Cn(d,y=>y.x,y=>y.y):tr(d,y=>y.x,y=>y.y,y=>y.z)).visitAfter(Wo),g=new Map;return d.forEach(y=>{g.set(y.id,y),$o(y,p,s)}),d.map((y,O)=>{const{id:L,data:R}=h[O],{mass:k=1}=R;r[L]={x:y.vx/k,y:y.vy/k,z:y.vz/k}}),r}function Wo(n){let e=0,t=0,r=0,s=0,o=0;const h=n.length;if(h){for(let d=0;d{var d;if(((d=n.data)===null||d===void 0?void 0:d.id)===o.id)return;const p=[t,r,s][h-1],g=o.x-n.x||Pr,y=o.y-n.y||Pr,O=o.z-n.z||Pr,L=[g,y,O],R=p-e;let k=0;for(let C=0;CYo(r,s,o,h,d,n,t))}const Xo={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"};class xs{constructor(e={}){this.options=e,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Xo),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericForceLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericForceLayout(!0,e,t)})}stop(){this.timeInterval&&typeof window!="undefined"&&window.clearInterval(this.timeInterval),this.running=!1}tick(e=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&rthis.lastGraph.mergeNodeData(r.id,{x:r.data.x,y:r.data.y,z:this.options.dimensions===3?r.data.z:void 0})),t}genericForceLayout(e,t,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),o=t.getAllNodes(),h=t.getAllEdges(),d=this.formatOptions(s,t),{dimensions:p,width:g,height:y,nodeSize:O,getMass:L,nodeStrength:R,edgeStrength:k,linkDistance:F}=d,z=o.map((J,mt)=>Object.assign(Object.assign({},J),{data:Object.assign(Object.assign({},J.data),{x:$t(J.data.x)?J.data.x:Math.random()*g,y:$t(J.data.y)?J.data.y:Math.random()*y,z:$t(J.data.z)?J.data.z:Math.random()*Math.sqrt(g*y),size:O(J)||30,mass:L(J),nodeStrength:R(J)})})),C=h.map(J=>Object.assign(Object.assign({},J),{data:Object.assign(Object.assign({},J.data),{edgeStrength:k(J),linkDistance:F(J,t.getNode(J.source),t.getNode(J.target))})}));if(!(o!=null&&o.length))return this.lastResult={nodes:[],edges:h},{nodes:[],edges:h};const W={};o.forEach((J,mt)=>{W[J.id]={x:0,y:0,z:0}});const $=new vt({nodes:z,edges:C});this.formatCentripetal(d,$);const{maxIteration:X,minMovement:q,onTick:st}=d;if(this.lastLayoutNodes=z,this.lastLayoutEdges=C,this.lastAssign=e,this.lastGraph=t,this.lastCalcGraph=$,this.lastOptions=d,this.lastVelMap=W,typeof window=="undefined")return;let ut=0;return new Promise(J=>{this.timeInterval=window.setInterval(()=>{(!o||!this.running)&&J({nodes:Rr(t,z),edges:h}),this.runOneStep($,t,ut,W,d),this.updatePosition(t,$,W,d),e&&z.forEach(mt=>t.mergeNodeData(mt.id,{x:mt.data.x,y:mt.data.y,z:p===3?mt.data.z:void 0})),st==null||st({nodes:Rr(t,z),edges:h}),ut++,(ut>=X||this.judgingDistance{let L=1;$t(O==null?void 0:O.data.mass)&&(L=O==null?void 0:O.data.mass);const R=t.getDegree(O.id,"both");return!R||R<5?L:R*5*L});const p=En(0,e.nodeSpacing);let g;d?qe(d)?g=O=>d(O)+p(O):Ge(d)?g=O=>{const L=d;return Math.max(L[0],L[1])+p(O)}:g=O=>d+p(O):g=O=>{const{size:L}=(O==null?void 0:O.data)||{};return L?Ge(L)?Math.max(L[0],L[1])+p(O):xn(L)?Math.max(L.width,L.height)+p(O):L+p(O):10+p(O)},r.nodeSize=g;const y=e.linkDistance?En(1,e.linkDistance):O=>1+r.nodeSize(t.getNode(O.source))+r.nodeSize(t.getNode(O.target));return r.linkDistance=y,r.nodeStrength=En(1,e.nodeStrength),r.edgeStrength=En(1,e.edgeStrength),r}formatCentripetal(e,t){const{dimensions:r,centripetalOptions:s,center:o,clusterNodeStrength:h,leafCluster:d,clustering:p,nodeClusterBy:g}=e,y=t.getAllNodes(),O=s||{leaf:2,single:2,others:1,center:C=>({x:o[0],y:o[1],z:r===3?o[2]:void 0})};typeof h!="function"&&(e.clusterNodeStrength=C=>h);let L,R;if(d&&g&&(L=Es(t,g),R=Array.from(new Set(y==null?void 0:y.map(C=>C.data[g])))||[],e.centripetalOptions=Object.assign(O,{single:100,leaf:C=>{const{siblingLeaves:W,sameTypeLeaves:$}=L[C.id]||{};return($==null?void 0:$.length)===(W==null?void 0:W.length)||(R==null?void 0:R.length)===1?1:e.clusterNodeStrength(C)},others:1,center:C=>{const W=t.getDegree(C.id,"both");if(!W)return{x:100,y:100,z:0};let $;if(W===1){const{sameTypeLeaves:X=[]}=L[C.id]||{};X.length===1?$=void 0:X.length>1&&($=bs(X))}else $=void 0;return{x:$==null?void 0:$.x,y:$==null?void 0:$.y,z:$==null?void 0:$.z}}})),p&&g){L||(L=Es(t,g)),R||(R=Array.from(new Set(y.map(W=>W.data[g])))),R=R.filter(W=>W!==void 0);const C={};R.forEach(W=>{const $=y.filter(X=>X.data[g]===W).map(X=>t.getNode(X.id));C[W]=bs($)}),e.centripetalOptions=Object.assign(O,{single:W=>e.clusterNodeStrength(W),leaf:W=>e.clusterNodeStrength(W),others:W=>e.clusterNodeStrength(W),center:W=>{const $=C[W.data[g]];return{x:$==null?void 0:$.x,y:$==null?void 0:$.y,z:$==null?void 0:$.z}}})}const{leaf:k,single:F,others:z}=e.centripetalOptions||{};k&&typeof k!="function"&&(e.centripetalOptions.leaf=()=>k),F&&typeof F!="function"&&(e.centripetalOptions.single=()=>F),z&&typeof z!="function"&&(e.centripetalOptions.others=()=>z)}runOneStep(e,t,r,s,o){const h={},d=e.getAllNodes(),p=e.getAllEdges();if(!(d!=null&&d.length))return;const{monitor:g}=o;if(this.calRepulsive(e,h,o),p&&this.calAttractive(e,h,o),this.calGravity(e,t,h,o),this.updateVelocity(e,h,s,o),g){const y=this.calTotalEnergy(h,d);g({energy:y,nodes:t.getAllNodes(),edges:t.getAllEdges(),iterations:r})}}calTotalEnergy(e,t){if(!(t!=null&&t.length))return 0;let r=0;return t.forEach((s,o)=>{const h=e[s.id].x,d=e[s.id].y,p=this.options.dimensions===3?e[s.id].z:0,g=h*h+d*d+p*p,{mass:y=1}=s.data;r+=y*g*.5}),r}calRepulsive(e,t,r){const{dimensions:s,factor:o,coulombDisScale:h}=r;Go(e,o,h*h,t,s)}calAttractive(e,t,r){const{dimensions:s,nodeSize:o}=r;e.getAllEdges().forEach((h,d)=>{const{source:p,target:g}=h,y=e.getNode(p),O=e.getNode(g);if(!y||!O)return;let L=O.data.x-y.data.x,R=O.data.y-y.data.y,k=s===3?O.data.z-y.data.z:0;!L&&!R&&(L=Math.random()*.01,R=Math.random()*.01,s===3&&!k&&(k=Math.random()*.01));const F=Math.sqrt(L*L+R*R+k*k);if(F{const{id:F,data:z}=k,{mass:C,x:W,y:$,z:X}=z,q=t.getNode(F);let st=0,ut=0,J=0,mt=L;const Et=e.getDegree(F,"in"),jt=e.getDegree(F,"out"),Pt=e.getDegree(F,"both"),Dt=o==null?void 0:o(q,Pt);if(Dt){const[Gt,zt,_t]=Dt;st=W-Gt,ut=$-zt,mt=_t}else st=W-O[0],ut=$-O[1],J=X-O[2];if(mt&&(r[F].x-=mt*st/C,r[F].y-=mt*ut/C,r[F].z-=mt*J/C),R){const{leaf:Gt,single:zt,others:_t,center:le}=R,{x:bt,y:kt,z:Qt,centerStrength:Xt}=(le==null?void 0:le(q,d,p,g,y))||{x:0,y:0,z:0,centerStrength:0};if(!$t(bt)||!$t(kt))return;const ie=(W-bt)/C,de=($-kt)/C,Jt=(X-Qt)/C;if(Xt&&(r[F].x-=Xt*ie,r[F].y-=Xt*de,r[F].z-=Xt*Jt),Pt===0){const Te=zt(q);if(!Te)return;r[F].x-=Te*ie,r[F].y-=Te*de,r[F].z-=Te*Jt;return}if(Et===0||jt===0){const Te=Gt(q,d,p);if(!Te)return;r[F].x-=Te*ie,r[F].y-=Te*de,r[F].z-=Te*Jt;return}const oe=_t(q);if(!oe)return;r[F].x-=oe*ie,r[F].y-=oe*de,r[F].z-=oe*Jt}})}updateVelocity(e,t,r,s){const{damping:o,maxSpeed:h,interval:d,dimensions:p}=s,g=e.getAllNodes();g!=null&&g.length&&g.forEach(y=>{const{id:O}=y;let L=(r[O].x+t[O].x*d)*o||.01,R=(r[O].y+t[O].y*d)*o||.01,k=p===3?(r[O].z+t[O].z*d)*o||.01:0;const F=Math.sqrt(L*L+R*R+k*k);if(F>h){const z=h/F;L=z*L,R=z*R,k=z*k}r[O]={x:L,y:R,z:k}})}updatePosition(e,t,r,s){const{distanceThresholdMode:o,interval:h,dimensions:d}=s,p=t.getAllNodes();if(!(p!=null&&p.length)){this.judgingDistance=0;return}let g=0;o==="max"?this.judgingDistance=-1/0:o==="min"&&(this.judgingDistance=1/0),p.forEach(y=>{const{id:O}=y,L=e.getNode(O);if($t(L.data.fx)&&$t(L.data.fy)){t.mergeNodeData(O,{x:L.data.fx,y:L.data.fy,z:d===3?L.data.fz:void 0});return}const R=r[O].x*h,k=r[O].y*h,F=d===3?r[O].z*h:0;t.mergeNodeData(O,{x:y.data.x+R,y:y.data.y+k,z:y.data.z+F});const z=Math.sqrt(R*R+k*k+F*F);switch(o){case"max":this.judgingDistancez&&(this.judgingDistance=z);break;default:g=g+z;break}}),(!o||o==="mean")&&(this.judgingDistance=g/p.length)}}const Es=(n,e)=>{const t=n.getAllNodes();if(!(t!=null&&t.length))return{};const r={};return t.forEach((s,o)=>{n.getDegree(s.id,"both")===1&&(r[s.id]=Ko(n,"leaf",s,e))}),r},Ko=(n,e,t,r)=>{const s=n.getDegree(t.id,"in"),o=n.getDegree(t.id,"out");let h=t,d=[];s===0?(h=n.getSuccessors(t.id)[0],d=n.getNeighbors(h.id)):o===0&&(h=n.getPredecessors(t.id)[0],d=n.getNeighbors(h.id)),d=d.filter(g=>n.getDegree(g.id,"in")===0||n.getDegree(g.id,"out")===0);const p=_o(n,e,r,t,d);return{coreNode:h,siblingLeaves:d,sameTypeLeaves:p}},_o=(n,e,t,r,s)=>{const o=r.data[t]||"";let h=(s==null?void 0:s.filter(d=>d.data[t]===o))||[];return e==="leaf"&&(h=h.filter(d=>n.getDegree(d.id,"in")===0||n.getDegree(d.id,"out")===0)),h},bs=n=>{const e={x:0,y:0};n.forEach(r=>{const{x:s,y:o}=r.data;e.x+=s||0,e.y+=o||0});const t=n.length||1;return{x:e.x/t,y:e.y/t}},Rr=(n,e)=>e.map(t=>{const{id:r,data:s}=t,o=n.getNode(r);return Object.assign(Object.assign({},o),{data:Object.assign(Object.assign({},o.data),{x:s.x,y:s.y,z:s.z})})});var ne=me(78585);const Hu=ne.XA,qu=ne.a_,tc=ne.yQ,ec=ne.Hs,nc=ne.Ec,rc=ne.dx,sc=ne.LU,ic=ne.Rm,bn=ne.y3,oc=ne.qK,ac=ne.pb,uc=ne.j,cc=ne.sO,fc=ne.BZ,lc=ne.EK,dc=ne.Db,hc=ne.Fx,gc=ne.tU,pc=ne.Ym,vc=ne.rs,mc=ne.QR,yc=ne.TB,wc=ne.oH,Ns=ne.Sc,xc=ne.BN,Ec=ne.it,bc=ne.$r,Nc=ne.QM,Mc=ne.AV;var Sc=(ne.y3,ne.y3);const Oc=ne.GH,Ac=ne.SO,Tc=ne.uZ,jc=ne.yU,Ic=ne.F1,Pc=ne.re,Ms=n=>{const e=[],t=n.length;for(let r=0;re[s][r]+e[r][o]&&(e[s][o]=e[s][r]+e[r][o]);return e},Ss=(n,e)=>{const{nodes:t,edges:r}=n,s=[],o={};if(!t)throw new Error("invalid nodes data!");return t&&t.forEach((h,d)=>{o[h.id]=d;const p=[];s.push(p)}),r==null||r.forEach(h=>{const{source:d,target:p}=h,g=o[d],y=o[p];g===void 0||y===void 0||(s[g][y]=1,e||(s[y][g]=1))}),s},Zo=(n,e)=>{const t=[];return n.forEach(r=>{const s=[];r.forEach(o=>{s.push(o*e)}),t.push(s)}),t},Jo=n=>{let e=1/0,t=1/0,r=-1/0,s=-1/0;return n.forEach(o=>{let h=o.data.size;Ge(h)?h.length===1&&(h=[h[0],h[0]]):$t(h)?h=[h,h]:(h===void 0||isNaN(h))&&(h=[30,30]);const d=[h[0]/2,h[1]/2],p=o.data.x-d[0],g=o.data.x+d[0],y=o.data.y-d[1],O=o.data.y+d[1];e>p&&(e=p),t>y&&(t=y),rMath.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)),Lr=(n,e,t,r="TB",s,o={})=>{if(!(e!=null&&e.length))return;const{stopBranchFn:h,stopAllFn:d}=o;for(let p=0;p{const C=Ze(d[z]);C.data.x=F[0]+o[0],C.data.y=F[1]+o[1],R.push(C)}),e&&R.forEach(F=>t.mergeNodeData(F.id,{x:F.data.x,y:F.data.y})),{nodes:R,edges:p}})}}const Ho=n=>{let e=-999999;n.forEach(t=>{t.forEach(r=>{r!==1/0&&e{t.forEach((s,o)=>{s===1/0&&(n[r][o]=e)})})},qo=n=>{const t=bn.mul(bn.pow(n,2),-.5),r=t.mean("row"),s=t.mean("column"),o=t.mean();t.add(o).subRowVector(r).subColumnVector(s);const h=new Ns(t),d=bn.sqrt(h.diagonalMatrix).diagonal();return h.leftSingularVectors.toJSON().map(p=>bn.mul([p],[d]).toJSON()[0].splice(0,2))};function Ts(n){return!!n.tick&&!!n.stop}const ta={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},ea={center:[0,0],comboPadding:10,treeKey:"combo"};class na{constructor(e={}){this.options=e,this.id="comboCombined",this.options=Object.assign(Object.assign({},ea),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericComboCombinedLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericComboCombinedLayout(!0,e,t)})}genericComboCombinedLayout(e,t,r){return A(this,void 0,void 0,function*(){const s=this.initVals(Object.assign(Object.assign({},this.options),r)),{center:o,treeKey:h,outerLayout:d}=s,p=t.getAllNodes().filter(J=>!J.data._isCombo),g=t.getAllNodes().filter(J=>J.data._isCombo),y=t.getAllEdges(),O=p==null?void 0:p.length;if(!O||O===1)return jn(t,e,o);const L=[],R=new Map;p.forEach(J=>{R.set(J.id,J)});const k=new Map;g.forEach(J=>{k.set(J.id,J)});const F=new Map,z=this.getInnerGraphs(t,h,R,k,y,s,F);yield Promise.all(z);const C=new Map,W=[],$=new Map;let X=!0;t.getRoots(h).forEach(J=>{const mt=F.get(J.id),Et=k.get(J.id)||R.get(J.id),jt={id:J.id,data:Object.assign(Object.assign({},J.data),{x:mt.data.x||Et.data.x,y:mt.data.y||Et.data.y,fx:mt.data.fx||Et.data.fx,fy:mt.data.fy||Et.data.fy,mass:mt.data.mass||Et.data.mass,size:mt.data.size})};W.push(jt),C.set(J.id,!0),!isNaN(jt.data.x)&&jt.data.x!==0&&!isNaN(jt.data.y)&&jt.data.y!==0?X=!1:(jt.data.x=Math.random()*100,jt.data.y=Math.random()*100),Lr(t,[J],Pt=>{Pt.id!==J.id&&$.set(Pt.id,J.id)},"TB",h)});const q=[];y.forEach(J=>{const mt=$.get(J.source)||J.source,Et=$.get(J.target)||J.target;mt!==Et&&C.has(mt)&&C.has(Et)&&q.push({id:J.id,source:mt,target:Et,data:{}})});let st;if(W!=null&&W.length){if(W.length===1)W[0].data.x=o[0],W[0].data.y=o[1];else{const J=new vt({nodes:W,edges:q}),mt=d||new xs;X&&ta[mt.id]&&(yield(W.length<100?new As:new Tr).assign(J));const Et=Object.assign({center:o,kg:5,preventOverlap:!0,animate:!1},mt.id==="force"?{gravity:1,factor:4,linkDistance:(jt,Pt,Dt)=>{const Gt=Math.max(...Pt.data.size)||32,zt=Math.max(...Dt.data.size)||32;return Gt/2+zt/2+200}}:{});st=yield js(mt,J,Et)}F.forEach(J=>{var mt;const Et=st.nodes.find(Dt=>Dt.id===J.id);if(Et){const{x:Dt,y:Gt}=Et.data;J.data.visited=!0,J.data.x=Dt,J.data.y=Gt,L.push({id:J.id,data:{x:Dt,y:Gt}})}const{x:jt,y:Pt}=J.data;(mt=J.data.nodes)===null||mt===void 0||mt.forEach(Dt=>{L.push({id:Dt.id,data:{x:Dt.data.x+jt,y:Dt.data.y+Pt}})})}),F.forEach(({data:J})=>{const{x:mt,y:Et,visited:jt,nodes:Pt}=J;Pt==null||Pt.forEach(Dt=>{if(!jt){const Gt=L.find(zt=>zt.id===Dt.id);Gt.data.x+=mt||0,Gt.data.y+=Et||0}})})}return e&&L.forEach(J=>{t.mergeNodeData(J.id,{x:J.data.x,y:J.data.y})}),{nodes:L,edges:y}})}initVals(e){const t=Object.assign({},e),{nodeSize:r,spacing:s,comboPadding:o}=e;let h,d;if($t(s)?d=()=>s:qe(s)?d=s:d=()=>0,t.spacing=d,!r)h=g=>{const y=d(g);return g.size?Ge(g.size)?((g.size[0]>g.size[1]?g.size[0]:g.size[1])+y)/2:xn(g.size)?((g.size.width>g.size.height?g.size.width:g.size.height)+y)/2:(g.size+y)/2:32+y/2};else if(qe(r))h=g=>{const y=r(g),O=d(g);return Ge(g.size)?((g.size[0]>g.size[1]?g.size[0]:g.size[1])+O)/2:((y||32)+O)/2};else if(Ge(r)){const y=(r[0]>r[1]?r[0]:r[1])/2;h=O=>y+d(O)/2}else{const g=r/2;h=y=>g+d(y)/2}t.nodeSize=h;let p;return $t(o)?p=()=>o:Ge(o)?p=()=>Math.max.apply(null,o):qe(o)?p=o:p=()=>0,t.comboPadding=p,t}getInnerGraphs(e,t,r,s,o,h,d){const{nodeSize:p,comboPadding:g,spacing:y,innerLayout:O}=h,L=O||new Tr({}),R={center:[0,0],preventOverlap:!0,nodeSpacing:y},k=[],F=z=>{let C=(g==null?void 0:g(z))||10;return Ge(C)&&(C=Math.max(...C)),{size:C?[C*2,C*2]:[30,30],padding:C}};return e.getRoots(t).forEach(z=>{d.set(z.id,{id:z.id,data:{nodes:[],size:F(z).size}});let C=Promise.resolve();Lr(e,[z],W=>{var $;if(!W.data._isCombo)return;const{size:X,padding:q}=F(W);if(!(!(($=e.getChildren(W.id,t))===null||$===void 0)&&$.length))d.set(W.id,{id:W.id,data:Object.assign(Object.assign({},W.data),{size:X})});else{const st=d.get(W.id);d.set(W.id,{id:W.id,data:Object.assign({nodes:[]},st==null?void 0:st.data)});const ut=new Map,J=e.getChildren(W.id,t).map(jt=>{if(jt.data._isCombo)return d.has(jt.id)||d.set(jt.id,{id:jt.id,data:Object.assign({},jt.data)}),ut.set(jt.id,!0),d.get(jt.id);const Pt=r.get(jt.id)||s.get(jt.id);return ut.set(jt.id,!0),{id:jt.id,data:Object.assign(Object.assign({},Pt.data),jt.data)}}),mt={nodes:J,edges:o.filter(jt=>ut.has(jt.source)&&ut.has(jt.target))};let Et=1/0;J.forEach(jt=>{var Pt;let{size:Dt}=jt.data;Dt||(Dt=((Pt=d.get(jt.id))===null||Pt===void 0?void 0:Pt.data.size)||(p==null?void 0:p(jt))||[30,30]),$t(Dt)&&(Dt=[Dt,Dt]);const[Gt,zt]=Dt;Et>Gt&&(Et=Gt),Et>zt&&(Et=zt),jt.data.size=Dt}),C=C.then(()=>A(this,void 0,void 0,function*(){const jt=new vt(mt);yield js(L,jt,R,!0);const{minX:Pt,minY:Dt,maxX:Gt,maxY:zt}=Jo(J),_t={x:(Gt+Pt)/2,y:(zt+Dt)/2};mt.nodes.forEach(bt=>{bt.data.x-=_t.x,bt.data.y-=_t.y});const le=[Math.max(Gt-Pt,Et)+q*2,Math.max(zt-Dt,Et)+q*2];d.get(W.id).data.size=le,d.get(W.id).data.nodes=J}))}return!0},"BT",t),k.push(C)}),k}}function js(n,e,t,r){var s;return A(this,void 0,void 0,function*(){return Ts(n)?(n.execute(e,t),n.stop(),n.tick((s=t.iterations)!==null&&s!==void 0?s:300)):r?yield n.assign(e,t):yield n.execute(e,t)})}var ra=function(n){return typeof n=="object"&&n!==null},sa=ra,ia={}.toString,oa=function(n,e){return ia.call(n)==="[object "+e+"]"},aa=oa,ua=function(n){if(!sa(n)||!aa(n,"Object"))return!1;if(Object.getPrototypeOf(n)===null)return!0;for(var e=n;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(n)===e},Cr=ua,ca=5;function fa(n,e){if(Object.hasOwn)return Object.hasOwn(n,e);if(n==null)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(n),e)}function Is(n,e,t,r){t=t||0,r=r||ca;for(var s in e)if(fa(e,s)){var o=e[s];o!==null&&Cr(o)?(Cr(n[s])||(n[s]={}),t[e(q,st,h),q])),X;for(z=0,d=new Array(C);z{}};function Cs(){for(var n=0,e=arguments.length,t={},r;n=0&&(r=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}})}er.prototype=Cs.prototype={constructor:er,on:function(n,e){var t=this._,r=ya(n+"",t),s,o=-1,h=r.length;if(arguments.length<2){for(;++o0)for(var t=new Array(s),r=0,s,o;r=0&&n._call.call(void 0,e),n=n._next;--Dn}function Us(){In=(rr=_n.now())+sr,Dn=$n=0;try{Ea()}finally{Dn=0,Na(),In=0}}function ba(){var n=_n.now(),e=n-rr;e>Fs&&(sr-=e,rr=n)}function Na(){for(var n,e=nr,t,r=1/0;e;)e._call?(r>e._time&&(r=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:nr=t);Kn=n,Fr(r)}function Fr(n){if(!Dn){$n&&($n=clearTimeout($n));var e=n-In;e>24?(n<1/0&&($n=setTimeout(Us,n-_n.now()-sr)),Xn&&(Xn=clearInterval(Xn))):(Xn||(rr=_n.now(),Xn=setInterval(ba,Fs)),Dn=1,ks(Us))}}const Ma=1664525,Sa=1013904223,Vs=4294967296;function Oa(){let n=1;return()=>(n=(Ma*n+Sa)%Vs)/Vs}function Aa(n){return n.x}function Ta(n){return n.y}var ja=10,Ia=Math.PI*(3-Math.sqrt(5));function Pa(n){var e,t=1,r=.001,s=1-Math.pow(r,1/300),o=0,h=.6,d=new Map,p=zr(O),g=zs("tick","end"),y=Oa();n==null&&(n=[]);function O(){L(),g.call("tick",e),t1?(z==null?d.delete(F):d.set(F,k(z)),e):d.get(F)},find:function(F,z,C){var W=0,$=n.length,X,q,st,ut,J;for(C==null?C=1/0:C*=C,W=0;W<$;++W)ut=n[W],X=F-ut.x,q=z-ut.y,st=X*X+q*q,st1?(g.on(F,z),e):g.on(F)}}}function Ra(){var n,e,t,r,s=Ce(-30),o,h=1,d=1/0,p=.81;function g(R){var k,F=n.length,z=Cn(n,Aa,Ta).visitAfter(O);for(r=R,k=0;k=d)return;(R.data!==e||R.next)&&(C===0&&(C=Nn(t),X+=C*C),W===0&&(W=Nn(t),X+=W*W),XL.index){var jt=R-J.x-J.vx,Pt=k-J.y-J.vy,Dt=jt*jt+Pt*Pt;DtR+Et||stk+Et||utg.r&&(g.r=g[y].r)}function p(){if(e){var g,y=e.length,O;for(t=new Array(y),g=0;gt.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},Ps(this.options,e),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericLayout(!0,e,t)})}stop(){this.simulation.stop()}tick(e){return this.simulation.tick(e),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(e,t){const r=this.context.nodes.find(s=>s.id===e);r&&t.forEach((s,o)=>{if(typeof s=="number"||s===null){const h=["fx","fy","fz"][o];r[h]=s}})}getOptions(e){var t,r;const s=Ps({},this.options,e);return s.collide&&((t=s.collide)===null||t===void 0?void 0:t.radius)===void 0&&(s.collide=s.collide||{},s.collide.radius=(r=s.nodeSize)!==null&&r!==void 0?r:10),s.iterations===void 0&&(s.link&&s.link.iterations===void 0&&(s.iterations=s.link.iterations),s.collide&&s.collide.iterations===void 0&&(s.iterations=s.collide.iterations)),this.context.options=s,s}genericLayout(e,t,r){var s;return A(this,void 0,void 0,function*(){const o=this.getOptions(r),h=t.getAllNodes().map(({id:y,data:O})=>Object.assign(Object.assign({id:y},O),Rs(O.data,this.config.inputNodeAttrs))),d=t.getAllEdges().map(y=>Object.assign({},y));Object.assign(this.context,{assign:e,nodes:h,edges:d,graph:t});const p=new Promise(y=>{this.resolver=y}),g=this.setSimulation(o);return g.nodes(h),(s=g.force("link"))===null||s===void 0||s.links(d),p})}getResult(){const{assign:e,nodes:t,edges:r,graph:s}=this.context,o=t.map(d=>({id:d.id,data:Object.assign(Object.assign({},d.data),Rs(d,this.config.outputNodeAttrs))})),h=r.map(({id:d,source:p,target:g,data:y})=>({id:d,source:typeof p=="object"?p.id:p,target:typeof g=="object"?g.id:g,data:y}));return e&&o.forEach(d=>s.mergeNodeData(d.id,d.data)),{nodes:o,edges:h}}initSimulation(){return Pa()}setSimulation(e){const t=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=t.on("tick",()=>{var r;return(r=e.onTick)===null||r===void 0?void 0:r.call(e,this.getResult())}).on("end",()=>{var r;return(r=this.resolver)===null||r===void 0?void 0:r.call(this,this.getResult())})),Ws(t,this.config.simulationAttrs.map(r=>[r,e[r]])),Object.entries(this.forceMap).forEach(([r,s])=>{const o=r;if(e[r]){let h=t.force(o);h||(h=s(),t.force(o,h)),Ws(h,Object.entries(e[o]))}else t.force(o,null)}),t}}const Ws=(n,e)=>e.reduce((t,[r,s])=>!t[r]||s===void 0?t:t[r].call(n,s),n);function Ne(n){return function(){return n}}function tn(n){return(n()-.5)*1e-6}function Ua(n){return n.index}function Ys(n,e){var t=n.get(e);if(!t)throw new Error("node not found: "+e);return t}function Va(n){var e=Ua,t=L,r,s=Ne(30),o,h,d,p,g,y,O=1;n==null&&(n=[]);function L(C){return 1/Math.min(p[C.source.index],p[C.target.index])}function R(C){for(var W=0,$=n.length;W1&&(mt=ut.y+ut.vy-st.y-st.vy||tn(y)),d>2&&(Et=ut.z+ut.vz-st.z-st.vz||tn(y)),jt=Math.sqrt(J*J+mt*mt+Et*Et),jt=(jt-o[X])/jt*C*r[X],J*=jt,mt*=jt,Et*=jt,ut.vx-=J*(Pt=g[X]),d>1&&(ut.vy-=mt*Pt),d>2&&(ut.vz-=Et*Pt),st.vx+=J*(Pt=1-Pt),d>1&&(st.vy+=mt*Pt),d>2&&(st.vz+=Et*Pt)}function k(){if(h){var C,W=h.length,$=n.length,X=new Map(h.map((st,ut)=>[e(st,ut,h),st])),q;for(C=0,p=new Array(W);C<$;++C)q=n[C],q.index=C,typeof q.source!="object"&&(q.source=Ys(X,q.source)),typeof q.target!="object"&&(q.target=Ys(X,q.target)),p[q.source.index]=(p[q.source.index]||0)+1,p[q.target.index]=(p[q.target.index]||0)+1;for(C=0,g=new Array($);C<$;++C)q=n[C],g[C]=p[q.source.index]/(p[q.source.index]+p[q.target.index]);r=new Array($),F(),o=new Array($),z()}}function F(){if(h)for(var C=0,W=n.length;Ctypeof $=="function")||Math.random,d=W.find($=>[1,2,3].includes($))||2,k()},R.links=function(C){return arguments.length?(n=C,k(),R):n},R.id=function(C){return arguments.length?(e=C,R):e},R.iterations=function(C){return arguments.length?(O=+C,R):O},R.strength=function(C){return arguments.length?(t=typeof C=="function"?C:Ne(+C),F(),R):t},R.distance=function(C){return arguments.length?(s=typeof C=="function"?C:Ne(+C),z(),R):s},R}function Ga(n){const e=+this._x.call(null,n);return $s(this.cover(e),e,n)}function $s(n,e,t){if(isNaN(e))return n;var r,s=n._root,o={data:t},h=n._x0,d=n._x1,p,g,y,O,L;if(!s)return n._root=o,n;for(;s.length;)if((y=e>=(p=(h+d)/2))?h=p:d=p,r=s,!(s=s[O=+y]))return r[O]=o,n;if(g=+n._x.call(null,s.data),e===g)return o.next=s,r?r[O]=o:n._root=o,n;do r=r?r[O]=new Array(2):n._root=new Array(2),(y=e>=(p=(h+d)/2))?h=p:d=p;while((O=+y)==(L=+(g>=p)));return r[L]=s,r[O]=o,n}function Wa(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e);let r=1/0,s=-1/0;for(let o=0,h;os&&(s=h));if(r>s)return this;this.cover(r).cover(s);for(let o=0;on||n>=t;)switch(h=+(nh||(o=g.x1)=O))&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-y],d[d.length-1-y]=g)}else{var L=Math.abs(n-+this._x.call(null,p.data));L=(g=(h+d)/2))?h=g:d=g,e=t,!(t=t[O=+y]))return this;if(!t.length)break;e[O+1&1]&&(r=e,L=O)}for(;t.data!==n;)if(s=t,!(t=t.next))return this;return(o=t.next)&&delete t.next,s?(o?s.next=o:delete s.next,this):e?(o?e[O]=o:delete e[O],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(r?r[L]=t:this._root=t),this):(this._root=o,this)}function Za(n){for(var e=0,t=n.length;e(n=(nu*n+ru)%Ks)/Ks}var _s=3;function Ur(n){return n.x}function Zs(n){return n.y}function iu(n){return n.z}var ou=10,au=Math.PI*(3-Math.sqrt(5)),uu=Math.PI*20/(9+Math.sqrt(221));function cu(n,e){e=e||2;var t=Math.min(_s,Math.max(1,Math.round(e))),r,s=1,o=.001,h=1-Math.pow(o,1/300),d=0,p=.6,g=new Map,y=zr(R),O=zs("tick","end"),L=su();n==null&&(n=[]);function R(){k(),O.call("tick",r),s1&&(X.fy==null?X.y+=X.vy*=p:(X.y=X.fy,X.vy=0)),t>2&&(X.fz==null?X.z+=X.vz*=p:(X.z=X.fz,X.vz=0));return r}function F(){for(var C=0,W=n.length,$;C1&&isNaN($.y)||t>2&&isNaN($.z)){var X=ou*(t>2?Math.cbrt(.5+C):t>1?Math.sqrt(.5+C):C),q=C*au,st=C*uu;t===1?$.x=X:t===2?($.x=X*Math.cos(q),$.y=X*Math.sin(q)):($.x=X*Math.sin(q)*Math.cos(st),$.y=X*Math.cos(q),$.z=X*Math.sin(q)*Math.sin(st))}(isNaN($.vx)||t>1&&isNaN($.vy)||t>2&&isNaN($.vz))&&($.vx=0,t>1&&($.vy=0),t>2&&($.vz=0))}}function z(C){return C.initialize&&C.initialize(n,L,t),C}return F(),r={tick:k,restart:function(){return y.restart(R),r},stop:function(){return y.stop(),r},numDimensions:function(C){return arguments.length?(t=Math.min(_s,Math.max(1,Math.round(C))),g.forEach(z),r):t},nodes:function(C){return arguments.length?(n=C,F(),g.forEach(z),r):n},alpha:function(C){return arguments.length?(s=+C,r):s},alphaMin:function(C){return arguments.length?(o=+C,r):o},alphaDecay:function(C){return arguments.length?(h=+C,r):+h},alphaTarget:function(C){return arguments.length?(d=+C,r):d},velocityDecay:function(C){return arguments.length?(p=1-C,r):1-p},randomSource:function(C){return arguments.length?(L=C,g.forEach(z),r):L},force:function(C,W){return arguments.length>1?(W==null?g.delete(C):g.set(C,z(W)),r):g.get(C)},find:function(){var C=Array.prototype.slice.call(arguments),W=C.shift()||0,$=(t>1?C.shift():null)||0,X=(t>2?C.shift():null)||0,q=C.shift()||1/0,st=0,ut=n.length,J,mt,Et,jt,Pt,Dt;for(q*=q,st=0;st1?(O.on(C,W),r):O.on(C)}}}function fu(){var n,e,t,r,s,o=Ne(-30),h,d=1,p=1/0,g=.81;function y(k){var F,z=n.length,C=(e===1?kr(n,Ur):e===2?Cn(n,Ur,Zs):e===3?tr(n,Ur,Zs,iu):null).visitAfter(L);for(s=k,F=0;F1&&(k.y=X/W),e>2&&(k.z=q/W)}else{z=k,z.x=z.data.x,e>1&&(z.y=z.data.y),e>2&&(z.z=z.data.z);do F+=h[z.data.index];while(z=z.next)}k.value=F}function R(k,F,z,C,W){if(!k.value)return!0;var $=[z,C,W][e-1],X=k.x-t.x,q=e>1?k.y-t.y:0,st=e>2?k.z-t.z:0,ut=$-F,J=X*X+q*q+st*st;if(ut*ut/g1&&q===0&&(q=tn(r),J+=q*q),e>2&&st===0&&(st=tn(r),J+=st*st),J1&&(t.vy+=q*k.value*s/J),e>2&&(t.vz+=st*k.value*s/J)),!0;if(k.length||J>=p)return;(k.data!==t||k.next)&&(X===0&&(X=tn(r),J+=X*X),e>1&&q===0&&(q=tn(r),J+=q*q),e>2&&st===0&&(st=tn(r),J+=st*st),J1&&(t.vy+=q*ut),e>2&&(t.vz+=st*ut));while(k=k.next)}return y.initialize=function(k,...F){n=k,r=F.find(z=>typeof z=="function")||Math.random,e=F.find(z=>[1,2,3].includes(z))||2,O()},y.strength=function(k){return arguments.length?(o=typeof k=="function"?k:Ne(+k),O(),y):o},y.distanceMin=function(k){return arguments.length?(d=k*k,y):Math.sqrt(d)},y.distanceMax=function(k){return arguments.length?(p=k*k,y):Math.sqrt(p)},y.theta=function(k){return arguments.length?(g=k*k,y):Math.sqrt(g)},y}function lu(n,e,t){var r,s=1;n==null&&(n=0),e==null&&(e=0),t==null&&(t=0);function o(){var h,d=r.length,p,g=0,y=0,O=0;for(h=0;h1&&(F=R.y+R.vy),t>2&&(z=R.z+R.vz),L.visit(X);function X(q,st,ut,J,mt,Et,jt){var Pt=[st,ut,J,mt,Et,jt],Dt=Pt[0],Gt=Pt[1],zt=Pt[2],_t=Pt[t],le=Pt[t+1],bt=Pt[t+2],kt=q.data,Qt=q.r,Xt=C+Qt;if(kt){if(kt.index>R.index){var ie=k-kt.x-kt.vx,de=t>1?F-kt.y-kt.vy:0,Jt=t>2?z-kt.z-kt.vz:0,oe=ie*ie+de*de+Jt*Jt;oe1&&de===0&&(de=tn(s),oe+=de*de),t>2&&Jt===0&&(Jt=tn(s),oe+=Jt*Jt),oe=(Xt-(oe=Math.sqrt(oe)))/oe*o,R.vx+=(ie*=oe)*(Xt=(Qt*=Qt)/(W+Qt)),t>1&&(R.vy+=(de*=oe)*Xt),t>2&&(R.vz+=(Jt*=oe)*Xt),kt.vx-=ie*(Xt=1-Xt),t>1&&(kt.vy-=de*Xt),t>2&&(kt.vz-=Jt*Xt))}return}return Dt>k+Xt||_t1&&(Gt>F+Xt||le2&&(zt>z+Xt||bty.r&&(y.r=y[O].r)}function g(){if(e){var y,O=e.length,L;for(r=new Array(O),y=0;ytypeof L=="function")||Math.random,t=O.find(L=>[1,2,3].includes(L))||2,g()},d.iterations=function(y){return arguments.length?(h=+y,d):h},d.strength=function(y){return arguments.length?(o=+y,d):o},d.radius=function(y){return arguments.length?(n=typeof y=="function"?y:Ne(+y),g(),d):n},d}function gu(n,e,t,r){var s,o,h=Ne(.1),d,p;typeof n!="function"&&(n=Ne(+n)),e==null&&(e=0),t==null&&(t=0),r==null&&(r=0);function g(O){for(var L=0,R=s.length;L1&&(k.vy+=z*$),o>2&&(k.vz+=C*$)}}function y(){if(s){var O,L=s.length;for(d=new Array(L),p=new Array(L),O=0;O[1,2,3].includes(R))||2,y()},g.strength=function(O){return arguments.length?(h=typeof O=="function"?O:Ne(+O),y(),g):h},g.radius=function(O){return arguments.length?(n=typeof O=="function"?O:Ne(+O),y(),g):n},g.x=function(O){return arguments.length?(e=+O,g):e},g.y=function(O){return arguments.length?(t=+O,g):t},g.z=function(O){return arguments.length?(r=+O,g):r},g}function pu(n){var e=Ne(.1),t,r,s;typeof n!="function"&&(n=Ne(n==null?0:+n));function o(d){for(var p=0,g=t.length,y;pe.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return cu()}}var Qs=me(92546),wu=me.n(Qs);function xu(n){if(!n)return[0,0,0];if($t(n))return[n,n,n];if(n.length===0)return[0,0,0];const[e,t=e,r=e]=n;return[e,t,r]}class ir{constructor(e){this.id="dagre",this.options={},Object.assign(this.options,ir.defaultOptions,e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,e,Object.assign(Object.assign({},this.options),t))})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,e,Object.assign(Object.assign({},this.options),t))})}genericDagreLayout(e,t,r){return A(this,void 0,void 0,function*(){const{nodeSize:s}=r,o=new Qs.graphlib.Graph;o.setGraph(r),o.setDefaultEdgeLabel(()=>({}));const h=t.getAllNodes(),d=t.getAllEdges();[...h,...d].some(({id:g})=>$t(g))&&console.error("Dagre layout only support string id, it will convert number to string."),t.getAllNodes().forEach(g=>{const{id:y}=g,O=Object.assign({},g.data);if(s!==void 0){const[L,R]=xu(qe(s)?s(g):s);Object.assign(O,{width:L,height:R})}o.setNode(y.toString(),O)}),t.getAllEdges().forEach(({id:g,source:y,target:O})=>{o.setEdge(y.toString(),O.toString(),{id:g})}),wu().layout(o);const p={nodes:[],edges:[]};return o.nodes().forEach(g=>{const y=o.node(g);p.nodes.push({id:g,data:y}),e&&t.mergeNodeData(g,y)}),o.edges().forEach(g=>{const y=o.edge(g),{id:O}=y,L=f(y,["id"]),{v:R,w:k}=g;p.edges.push({id:O,source:R,target:k,data:L}),e&&t.mergeEdgeData(O,L)}),p})}}ir.defaultOptions={};class Gr{constructor(e){this.id=e.id||0,this.rx=e.rx,this.ry=e.ry,this.fx=0,this.fy=0,this.mass=e.mass,this.degree=e.degree,this.g=e.g||0}distanceTo(e){const t=this.rx-e.rx,r=this.ry-e.ry;return Math.hypot(t,r)}setPos(e,t){this.rx=e,this.ry=t}resetForce(){this.fx=0,this.fy=0}addForce(e){const t=e.rx-this.rx,r=e.ry-this.ry;let s=Math.hypot(t,r);s=s<1e-4?1e-4:s;const o=this.g*(this.degree+1)*(e.degree+1)/s;this.fx+=o*t/s,this.fy+=o*r/s}in(e){return e.contains(this.rx,this.ry)}add(e){const t=this.mass+e.mass,r=(this.rx*this.mass+e.rx*e.mass)/t,s=(this.ry*this.mass+e.ry*e.mass)/t,o=this.degree+e.degree,h={rx:r,ry:s,mass:t,degree:o};return new Gr(h)}}class zn{constructor(e){this.xmid=e.xmid,this.ymid=e.ymid,this.length=e.length,this.massCenter=e.massCenter||[0,0],this.mass=e.mass||1}getLength(){return this.length}contains(e,t){const r=this.length/2;return e<=this.xmid+r&&e>=this.xmid-r&&t<=this.ymid+r&&t>=this.ymid-r}NW(){const e=this.xmid-this.length/4,t=this.ymid+this.length/4,r=this.length/2,s={xmid:e,ymid:t,length:r};return new zn(s)}NE(){const e=this.xmid+this.length/4,t=this.ymid+this.length/4,r=this.length/2,s={xmid:e,ymid:t,length:r};return new zn(s)}SW(){const e=this.xmid-this.length/4,t=this.ymid-this.length/4,r=this.length/2,s={xmid:e,ymid:t,length:r};return new zn(s)}SE(){const e=this.xmid+this.length/4,t=this.ymid-this.length/4,r=this.length/2,s={xmid:e,ymid:t,length:r};return new zn(s)}}class Fn{constructor(e){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,e!=null&&(this.quad=e)}insert(e){if(this.body==null){this.body=e;return}this._isExternal()?(this.quad&&(this.NW=new Fn(this.quad.NW()),this.NE=new Fn(this.quad.NE()),this.SW=new Fn(this.quad.SW()),this.SE=new Fn(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e))}_putBody(e){this.quad&&(e.in(this.quad.NW())&&this.NW?this.NW.insert(e):e.in(this.quad.NE())&&this.NE?this.NE.insert(e):e.in(this.quad.SW())&&this.SW?this.SW.insert(e):e.in(this.quad.SE())&&this.SE&&this.SE.insert(e))}_isExternal(){return this.NW==null&&this.NE==null&&this.SW==null&&this.SE==null}updateForce(e){if(!(this.body==null||e===this.body))if(this._isExternal())e.addForce(this.body);else{const t=this.quad?this.quad.getLength():0,r=this.body.distanceTo(e);t/rZe(C,[d,p])),k=s.filter(C=>{const{source:W,target:$}=C;return W!==$}),F=new vt({nodes:R,edges:k}),z=this.getSizes(F,t,O);if(this.run(F,t,y,z,e,h),g){for(let W=0;W250&&(r.barnesHut=!0),p===void 0&&t>100&&(r.prune=!0),g===0&&!p?(r.maxIteration=250,t<=200&&t>100?r.maxIteration=1e3:t>200&&(r.maxIteration=1200)):g===0&&p&&(r.maxIteration=100,t<=200&&t>100?r.maxIteration=500:t>200&&(r.maxIteration=950)),y||(r.kr=50,t>100&&t<=500?r.kr=20:t>500&&(r.kr=1)),O||(r.kg=20,t>100&&t<=500?r.kg=10:t>500&&(r.kg=1)),r}run(e,t,r,s,o,h){const{kr:d,barnesHut:p,onTick:g}=h,y=e.getAllNodes();let O=0,L=r;const R={},k={},F={};for(let z=0;z0;)O=this.oneStep(e,{iter:L,preventOverlapIters:50,krPrime:100,sg:O,forces:R,preForces:k,bodies:F,sizes:s},h),L--,g==null||g({nodes:y,edges:t.getAllEdges()});return e}oneStep(e,t,r){const{iter:s,preventOverlapIters:o,krPrime:h,sg:d,preForces:p,bodies:g,sizes:y}=t;let{forces:O}=t;const{preventOverlap:L,barnesHut:R}=r,k=e.getAllNodes();for(let F=0;Fo||!L)?O=this.getOptRepGraForces(e,O,g,r):O=this.getRepGraForces(e,s,o,O,h,y,r),this.updatePos(e,O,p,d,r)}getAttrForces(e,t,r,s,o,h){const{preventOverlap:d,dissuadeHubs:p,mode:g,prune:y}=h,O=e.getAllEdges();for(let L=0;L0&&(q=X,st=X),o[R][0]+=q*$[0],o[k][0]-=st*$[0],o[R][1]+=q*$[1],o[k][1]-=st*$[1]}return o}getOptRepGraForces(e,t,r,s){const{kg:o,center:h,prune:d}=s,p=e.getAllNodes(),g=p.length;let y=9e10,O=-9e10,L=9e10,R=-9e10;for(let W=0;W=O&&(O=X.x),X.x<=y&&(y=X.x),X.y>=R&&(R=X.y),X.y<=L&&(L=X.y))}const k=Math.max(O-y,R-L),F={xmid:(O+y)/2,ymid:(R+L)/2,length:k,massCenter:h,mass:g},z=new zn(F),C=new Fn(z);for(let W=0;W0&&(Et=g*(C+1)*(ut+1)/mt),s[z.id][0]-=Et*J[0],s[st.id][0]+=Et*J[0],s[z.id][1]-=Et*J[1],s[st.id][1]+=Et*J[1]}const W=[z.data.x-O[0],z.data.y-O[1]],$=Math.hypot(W[0],W[1]);W[0]=W[0]/$,W[1]=W[1]/$;const X=y*(C+1);s[z.id][0]-=X*W[0],s[z.id][1]-=X*W[1]}return s}updatePos(e,t,r,s,o){const{ks:h,tao:d,prune:p,ksmax:g}=o,y=e.getAllNodes(),O=y.length,L=[],R=[];let k=0,F=0,z=s;for(let W=0;W1.5*C?1.5*C:z);for(let W=0;WJ?J:st;const mt=st*t[$][0],Et=st*t[$][1];e.mergeNodeData($,{x:X.x+mt,y:X.y+Et})}return z}}const Nu={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Mu=800;class Su{constructor(e={}){this.options=e,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},Nu),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericFruchtermanLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericFruchtermanLayout(!0,e,t)})}stop(){this.timeInterval&&typeof window!="undefined"&&window.clearInterval(this.timeInterval),this.running=!1}tick(e=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let r=0;rthis.lastGraph.mergeNodeData(r.id,{x:r.data.x,y:r.data.y,z:this.options.dimensions===3?r.data.z:void 0})),t}genericFruchtermanLayout(e,t,r){return A(this,void 0,void 0,function*(){if(this.running)return;const s=this.formatOptions(r),{dimensions:o,width:h,height:d,center:p,clustering:g,nodeClusterBy:y,maxIteration:O,onTick:L}=s,R=t.getAllNodes(),k=t.getAllEdges();if(!(R!=null&&R.length)){const $={nodes:[],edges:k};return this.lastResult=$,$}if(R.length===1){e&&t.mergeNodeData(R[0].id,{x:p[0],y:p[1],z:o===3?p[2]:void 0});const $={nodes:[Object.assign(Object.assign({},R[0]),{data:Object.assign(Object.assign({},R[0].data),{x:p[0],y:p[1],z:o===3?p[2]:void 0})})],edges:k};return this.lastResult=$,$}const F=R.map($=>Ze($,[h,d])),z=new vt({nodes:F,edges:k}),C={};if(g&&F.forEach($=>{const X=$.data[y];C[X]||(C[X]={name:X,cx:0,cy:0,count:0})}),this.lastLayoutNodes=F,this.lastLayoutEdges=k,this.lastAssign=e,this.lastGraph=z,this.lastOptions=s,this.lastClusterMap=C,typeof window=="undefined")return;let W=0;return new Promise($=>{this.timeInterval=window.setInterval(()=>{if(!this.running){$({nodes:F,edges:k});return}this.runOneStep(z,C,s),e&&F.forEach(({id:X,data:q})=>t.mergeNodeData(X,{x:q.x,y:q.y,z:o===3?q.z:void 0})),L==null||L({nodes:F,edges:k}),W++,W>=O&&(window.clearInterval(this.timeInterval),$({nodes:F,edges:k}))},0),this.running=!0})})}formatOptions(e={}){const t=Object.assign(Object.assign({},this.options),e),{clustering:r,nodeClusterBy:s}=t,{center:o,width:h,height:d}=t;return t.width=!h&&typeof window!="undefined"?window.innerWidth:h,t.height=!d&&typeof window!="undefined"?window.innerHeight:d,t.center=o||[t.width/2,t.height/2],t.clustering=r&&!!s,t}runOneStep(e,t,r){const{dimensions:s,height:o,width:h,gravity:d,center:p,speed:g,clustering:y,nodeClusterBy:O,clusterGravity:L}=r,R=o*h,k=Math.sqrt(R)/10,F=e.getAllNodes(),z=R/(F.length+1),C=Math.sqrt(z),W={};if(this.applyCalculate(e,W,C,z),y){for(const X in t)t[X].cx=0,t[X].cy=0,t[X].count=0;F.forEach(X=>{const{data:q}=X,st=t[q[O]];$t(q.x)&&(st.cx+=q.x),$t(q.y)&&(st.cy+=q.y),st.count++});for(const X in t)t[X].cx/=t[X].count,t[X].cy/=t[X].count;const $=L||d;F.forEach((X,q)=>{const{id:st,data:ut}=X;if(!$t(ut.x)||!$t(ut.y))return;const J=t[ut[O]],mt=Math.sqrt((ut.x-J.cx)*(ut.x-J.cx)+(ut.y-J.cy)*(ut.y-J.cy)),Et=C*$;W[st].x-=Et*(ut.x-J.cx)/mt,W[st].y-=Et*(ut.y-J.cy)/mt})}F.forEach(($,X)=>{const{id:q,data:st}=$;if(!$t(st.x)||!$t(st.y))return;const ut=.01*C*d;W[q].x-=ut*(st.x-p[0]),W[q].y-=ut*(st.y-p[1]),s===3&&(W[q].z-=ut*(st.z-p[2]))}),F.forEach(($,X)=>{const{id:q,data:st}=$;if($t(st.fx)&&$t(st.fy)){st.x=st.fx,st.y=st.fy,s===3&&(st.z=st.fz);return}if(!$t(st.x)||!$t(st.y))return;const ut=Math.sqrt(W[q].x*W[q].x+W[q].y*W[q].y+(s===3?W[q].z*W[q].z:0));if(ut>0){const J=Math.min(k*(g/Mu),ut);e.mergeNodeData(q,{x:st.x+W[q].x/ut*J,y:st.y+W[q].y/ut*J,z:s===3?st.z+W[q].z/ut*J:void 0})}})}applyCalculate(e,t,r,s){this.calRepulsive(e,t,s),this.calAttractive(e,t,r)}calRepulsive(e,t,r){const s=e.getAllNodes();s.forEach(({data:o,id:h},d)=>{t[h]={x:0,y:0,z:0},s.forEach(({data:p,id:g},y)=>{if(d<=y||!$t(o.x)||!$t(p.x)||!$t(o.y)||!$t(p.y))return;let O=o.x-p.x,L=o.y-p.y,R=this.options.dimensions===3?o.z-p.z:0,k=O*O+L*L+R*R;k===0&&(k=1,O=.01,L=.01,R=.01);const F=r/k,z=O*F,C=L*F,W=R*F;t[h].x+=z,t[h].y+=C,t[g].x-=z,t[g].y-=C,this.options.dimensions===3&&(t[h].z+=W,t[g].z-=W)})})}calAttractive(e,t,r){e.getAllEdges().forEach(o=>{const{source:h,target:d}=o;if(!h||!d||h===d)return;const{data:p}=e.getNode(h),{data:g}=e.getNode(d);if(!$t(g.x)||!$t(p.x)||!$t(g.y)||!$t(p.y))return;const y=g.x-p.x,O=g.y-p.y,L=this.options.dimensions===3?g.z-p.z:0,R=Math.sqrt(y*y+O*O+L*L)/r,k=y*R,F=O*R,z=L*R;t[h].x+=k,t[h].y+=F,t[d].x-=k,t[d].y-=F,this.options.dimensions===3&&(t[h].z+=z,t[d].z-=z)})}}const Ou={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300};class Au{constructor(e={}){this.options=e,this.id="grid",this.options=Object.assign(Object.assign({},Ou),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericGridLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericGridLayout(!0,e,t)})}genericGridLayout(e,t,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{begin:o=[0,0],condense:h,preventOverlapPadding:d,preventOverlap:p,rows:g,cols:y,nodeSpacing:O,nodeSize:L,width:R,height:k,position:F}=s;let{sortBy:z}=s;const C=t.getAllNodes(),W=t.getAllEdges(),$=C==null?void 0:C.length;if(!$||$===1)return jn(t,e,o);const X=C.map(zt=>Ze(zt));z!=="id"&&(!Yn(z)||X[0].data[z]===void 0)&&(z="degree"),z==="degree"?X.sort((zt,_t)=>t.getDegree(_t.id,"both")-t.getDegree(zt.id,"both")):z==="id"?X.sort((zt,_t)=>$t(_t.id)&&$t(zt.id)?_t.id-zt.id:`${zt.id}`.localeCompare(`${_t.id}`)):X.sort((zt,_t)=>_t.data[z]-zt.data[z]);const q=!R&&typeof window!="undefined"?window.innerWidth:R,st=!k&&typeof window!="undefined"?window.innerHeight:k,ut=$,J={rows:g,cols:y};if(g!=null&&y!=null)J.rows=g,J.cols=y;else if(g!=null&&y==null)J.rows=g,J.cols=Math.ceil(ut/J.rows);else if(g==null&&y!=null)J.cols=y,J.rows=Math.ceil(ut/J.cols);else{const zt=Math.sqrt(ut*st/q);J.rows=Math.round(zt),J.cols=Math.round(q/st*zt)}if(J.rows=Math.max(J.rows,1),J.cols=Math.max(J.cols,1),J.cols*J.rows>ut){const zt=or(J),_t=ar(J);(zt-1)*_t>=ut?or(J,zt-1):(_t-1)*zt>=ut&&ar(J,_t-1)}else for(;J.cols*J.rows=ut?ar(J,_t+1):or(J,zt+1)}let mt=h?0:q/J.cols,Et=h?0:st/J.rows;if(p||O){const zt=En(10,O),_t=hs(30,L,!1);X.forEach(le=>{(!le.data.x||!le.data.y)&&(le.data.x=0,le.data.y=0);const bt=t.getNode(le.id),kt=_t(bt)||30;let Qt,Xt;Ge(kt)?(Qt=kt[0],Xt=kt[1]):(Qt=kt,Xt=kt);const ie=zt!==void 0?zt(le):d,de=Qt+ie,Jt=Xt+ie;mt=Math.max(mt,de),Et=Math.max(Et,Jt)})}const jt={},Pt={row:0,col:0},Dt={};for(let zt=0;zt{t.mergeNodeData(zt.id,{x:zt.data.x,y:zt.data.y})}),Gt})}}const or=(n,e)=>{let t;const r=n.rows||5,s=n.cols||5;return e==null?t=Math.min(r,s):Math.min(r,s)===n.rows?n.rows=e:n.cols=e,t},ar=(n,e)=>{let t;const r=n.rows||5,s=n.cols||5;return e==null?t=Math.max(r,s):Math.max(r,s)===n.rows?n.rows=e:n.cols=e,t},Wr=(n,e)=>n[`c-${e.row}-${e.col}`]||!1,Hs=(n,e)=>n[`c-${e.row}-${e.col}`]=!0,qs=(n,e)=>{const t=n.cols||5;e.col++,e.col>=t&&(e.col=0,e.row++)},Tu=(n,e,t,r,s,o,h,d)=>{let p,g;const y=s[n.id];if(y)p=y.col*t+t/2+e[0],g=y.row*r+r/2+e[1];else{for(;Wr(d,h);)qs(o,h);p=h.col*t+t/2+e[0],g=h.row*r+r/2+e[1],Hs(d,h),qs(o,h)}n.data.x=p,n.data.y=g},ju=(n,e,t)=>{try{const r=bn.mul(bn.pow(e,2),-.5),s=r.mean("row"),o=r.mean("column"),h=r.mean();r.add(h).subRowVector(s).subColumnVector(o);const d=new Ns(r),p=bn.sqrt(d.diagonalMatrix).diagonal();return d.leftSingularVectors.toJSON().map(g=>bn.mul([g],[p]).toJSON()[0].splice(0,n))}catch(r){const s=[];for(let o=0;o{const t=Object.assign(Object.assign({},Pu),e),{positions:r,iterations:s,width:o,k:h,speed:d=100,strictRadial:p,focusIdx:g,radii:y=[],nodeSizeFunc:O}=t,L=n.getAllNodes(),R=[],k=o/10;for(let F=0;F{R[C]={x:0,y:0}}),Lu(L,r,R,h,y,O),Cu(r,R,d,p,g,k,o,y);return r},Lu=(n,e,t,r,s,o)=>{e.forEach((h,d)=>{t[d]={x:0,y:0},e.forEach((p,g)=>{if(d===g||s[d]!==s[g])return;let y=h.x-p.x,O=h.y-p.y,L=Math.sqrt(y*y+O*O);if(L===0){L=1;const R=d>g?1:-1;y=.01*R,O=.01*R}if(L{const p=o||h/10;return r&&e.forEach((g,y)=>{const O=n[y].x-n[s].x,L=n[y].y-n[s].y,R=Math.sqrt(O*O+L*L);let k=L/R,F=-O/R;const z=Math.sqrt(g.x*g.x+g.y*g.y);let C=Math.acos((k*g.x+F*g.y)/z);C>Math.PI/2&&(C-=Math.PI/2,k*=-1,F*=-1);const W=Math.cos(C)*z;g.x=k*W,g.y=F*W}),n.forEach((g,y)=>{if(y===s)return;const O=Math.sqrt(e[y].x*e[y].x+e[y].y*e[y].y);if(O>0&&y!==s){const L=Math.min(p*(t/Iu),O);if(g.x+=e[y].x/O*L,g.y+=e[y].y/O*L,r){let R=g.x-n[s].x,k=g.y-n[s].y;const F=Math.sqrt(R*R+k*k);R=R/F*d[y],k=k/F*d[y],g.x=n[s].x+R,g.y=n[s].y+k}}}),n},Du={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class zu{constructor(e={}){this.options=e,this.id="radial",this.options=Object.assign(Object.assign({},Du),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericRadialLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericRadialLayout(!0,e,t)})}genericRadialLayout(e,t,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{width:o,height:h,center:d,focusNode:p,unitRadius:g,nodeSize:y,nodeSpacing:O,strictRadial:L,preventOverlap:R,maxPreventOverlapIteration:k,sortBy:F,linkDistance:z=50,sortStrength:C=10,maxIteration:W=1e3}=s,$=t.getAllNodes(),X=t.getAllEdges(),q=!o&&typeof window!="undefined"?window.innerWidth:o,st=!h&&typeof window!="undefined"?window.innerHeight:h,ut=d||[q/2,st/2];if(!($!=null&&$.length)||$.length===1)return jn(t,e,ut);let J=$[0];if(Yn(p)){for(let Ee=0;Ee<$.length;Ee++)if($[Ee].id===p){J=$[Ee];break}}else J=p||$[0];const mt=Bu($,J.id),Et=Ss({nodes:$,edges:X},!1),jt=Ms(Et),Pt=Vu(jt,mt);Uu(jt,mt,Pt+1);const Dt=jt[mt];let Gt=q-ut[0]>ut[0]?ut[0]:q-ut[0],zt=st-ut[1]>ut[1]?ut[1]:st-ut[1];Gt===0&&(Gt=q/2),zt===0&&(zt=st/2);const _t=Math.min(Gt,zt),le=Math.max(...Dt),bt=[],kt=g||_t/le;Dt.forEach((Ee,en)=>{bt[en]=Ee*kt});const Qt=Fu($,jt,z,bt,kt,F,C),Xt=ku(Qt),ie=ju(z,Qt,z);let de=ie.map(([Ee,en])=>({x:(isNaN(Ee)?Math.random()*z:Ee)-ie[mt][0],y:(isNaN(en)?Math.random()*z:en)-ie[mt][1]}));this.run(W,de,Xt,Qt,bt,mt);let Jt;if(R){Jt=gs(y,O);const Ee={nodes:$,nodeSizeFunc:Jt,positions:de,radii:bt,height:st,width:q,strictRadial:!!L,focusIdx:mt,iterations:k||200,k:de.length/4.5};de=Ru(t,Ee)}const oe=[];return de.forEach((Ee,en)=>{const gn=Ze($[en]);gn.data.x=Ee.x+ut[0],gn.data.y=Ee.y+ut[1],oe.push(gn)}),e&&oe.forEach(Ee=>t.mergeNodeData(Ee.id,{x:Ee.data.x,y:Ee.data.y})),{nodes:oe,edges:X}})}run(e,t,r,s,o,h){for(let d=0;d<=e;d++){const p=d/e;this.oneIteration(p,t,o,s,r,h)}}oneIteration(e,t,r,s,o,h){const d=1-e;t.forEach((p,g)=>{const y=Os(p,{x:0,y:0}),O=y===0?0:1/y;if(g===h)return;let L=0,R=0,k=0;t.forEach((z,C)=>{if(g===C)return;const W=Os(p,z),$=W===0?0:1/W,X=s[C][g];k+=o[g][C],L+=o[g][C]*(z.x+X*(p.x-z.x)*$),R+=o[g][C]*(z.y+X*(p.y-z.y)*$)});const F=r[g]===0?0:1/r[g];k*=d,k+=e*F*F,L*=d,L+=e*F*p.x*O,p.x=L/k,R*=d,R+=e*F*p.y*O,p.y=R/k})}}const Fu=(n,e,t,r,s,o,h)=>{if(!n)return[];const d=[];if(e){const p={};e.forEach((g,y)=>{const O=[];g.forEach((L,R)=>{var k,F;if(y===R)O.push(0);else if(r[y]===r[R])if(o==="data")O.push(L*(Math.abs(y-R)*h)/(r[y]/s));else if(o){let z,C;if(p[n[y].id])z=p[n[y].id];else{const W=(o==="id"?n[y].id:(k=n[y].data)===null||k===void 0?void 0:k[o])||0;Yn(W)?z=W.charCodeAt(0):z=W,p[n[y].id]=z}if(p[n[R].id])C=p[n[R].id];else{const W=(o==="id"?n[R].id:(F=n[R].data)===null||F===void 0?void 0:F[o])||0;Yn(W)?C=W.charCodeAt(0):C=W,p[n[R].id]=C}O.push(L*(Math.abs(z-C)*h)/(r[y]/s))}else O.push(L*t/(r[y]/s));else{const z=(t+s)/2;O.push(L*z)}}),d.push(O)})}return d},ku=n=>{const e=n.length,t=n[0].length,r=[];for(let s=0;s{let t=-1;return n.forEach((r,s)=>{r.id===e&&(t=s)}),Math.max(t,0)},Uu=(n,e,t)=>{const r=n.length;for(let s=0;s{let t=0;for(let r=0;rt?n[e][r]:t);return t},Gu={center:[0,0],width:300,height:300};class Wu{constructor(e={}){this.options=e,this.id="random",this.options=Object.assign(Object.assign({},Gu),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericRandomLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericRandomLayout(!0,e,t)})}genericRandomLayout(e,t,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{center:o,width:h,height:d}=s,p=t.getAllNodes(),g=.9,y=!h&&typeof window!="undefined"?window.innerWidth:h,O=!d&&typeof window!="undefined"?window.innerHeight:d,L=o||[y/2,O/2],R=[];return p&&p.forEach(F=>{R.push({id:F.id,data:{x:(Math.random()-.5)*g*y+L[0],y:(Math.random()-.5)*g*O+L[1]}})}),e&&R.forEach(F=>t.mergeNodeData(F.id,{x:F.data.x,y:F.data.y})),{nodes:R,edges:t.getAllEdges()}})}}const Yu={circular:to,concentric:Tr,mds:As,random:Wu,grid:Au,radial:zu,force:xs,d3force:Gs,"d3-force-3d":yu,fruchterman:Su,forceAtlas2:bu,dagre:ir,antvDagre:Qi,comboCombined:na};let hn;Wt({stopLayout(){hn!=null&&hn.stop&&hn.stop()},calculateLayout(n,e){return A(this,void 0,void 0,function*(){const{layout:{id:t,options:r,iterations:s},nodes:o,edges:h}=n,d=new vt({nodes:o,edges:h}),p=Yu[t];if(p)hn=new p(r);else throw new Error(`Unknown layout id: ${t}`);let g=yield hn.execute(d);return Ts(hn)&&(hn.stop(),g=hn.tick(s)),[g,e]})}})})()})(); }());