!function(){var t={92861:function(t,e,r){"use strict";var n=r(4811).default,o=r(34577).default,i=r(31573).default,a=r(38689).default,s=r(24270).default,u=r(13720).default,c=r(80619).default,h=r(47074).default,d=r(7134).default,f=r(85573).default,l=r(68995).default,g=r(79800).default,v=r(91232).default,p=r(7557).default,y=r(31468).default,m=r(82100).default,w=r(29186).default;var x=r(34634),b=r(34402),E=" ".repeat(2),N=" ".repeat(4);function M(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.maxRows,n=void 0===r?15:r,o=e.maxColumns,i=void 0===o?10:o,a=e.maxNumSize,s=void 0===a?8:a,u=e.padMinus,c=void 0===u?"auto":u;return"".concat(t.constructor.name," {\n").concat(E,"[\n").concat(N).concat(_(t,n,i,s,c),"\n").concat(E,"]\n").concat(E,"rows: ").concat(t.rows,"\n").concat(E,"columns: ").concat(t.columns,"\n}")}function _(t,e,r,n,o){var i=t.rows,a=t.columns,s=Math.min(i,e),u=Math.min(a,r),c=[];if("auto"===o){o=!1;t:for(var h=0;h=0&&r?" ".concat(A(t,e-1)):A(t,e)).padEnd(e)}function A(t,e){var r=t.toString();if(r.length<=e)return r;var n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;var o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function j(t,e,r){var n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function O(t,e,r){var n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function S(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function z(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function R(t,e){if(!x.isAnyArray(e))throw new TypeError("row indices must be an array");for(var r=0;r=t.rows)throw new RangeError("row indices are out of range")}function I(t,e){if(!x.isAnyArray(e))throw new TypeError("column indices must be an array");for(var r=0;r=t.columns)throw new RangeError("column indices are out of range")}function P(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(C("startRow",e),C("endRow",r),C("startColumn",n),C("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function T(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[],n=0;nr?(o=!0,r=e):(n=!1,o=!0);t++}return n}},{key:"isReducedEchelonForm",value:function(){for(var t=0,e=0,r=-1,n=!0,o=!1;tr?(o=!0,r=e):(n=!1,o=!0);for(var i=e+1;it.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);for(var i=t.get(e,r),a=r;a=0;)if(0===t.maxRow(n))n--;else{for(var o=0,i=!1;o0&&void 0!==arguments[0]?arguments[0]:{};if("object"!==y(t))throw new TypeError("options must be an object");var e=t.rows,r=void 0===e?1:e,n=t.columns,o=void 0===n?1:n;if(!Number.isInteger(r)||r<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(o)||o<=0)throw new TypeError("columns must be a positive integer");for(var i=new Z(this.rows*r,this.columns*o),a=0;ae[r]&&(e[r]=this.get(r,n));return e;case"column":for(var o=new Array(this.columns).fill(Number.NEGATIVE_INFINITY),i=0;io[a]&&(o[a]=this.get(i,a));return o;case void 0:for(var s=this.get(0,0),u=0;us&&(s=this.get(u,c));return s;default:throw new Error("invalid option: ".concat(t))}}},{key:"maxIndex",value:function(){D(this);for(var t=this.get(0,0),e=[0,0],r=0;rt&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}},{key:"min",value:function(t){if(this.isEmpty())return NaN;switch(t){case"row":for(var e=new Array(this.rows).fill(Number.POSITIVE_INFINITY),r=0;re&&(e=this.get(t,r));return e}},{key:"maxRowIndex",value:function(t){j(this,t),D(this);for(var e=this.get(t,0),r=[t,0],n=1;ne&&(e=this.get(t,n),r[1]=n);return r}},{key:"minRow",value:function(t){if(j(this,t),this.isEmpty())return NaN;for(var e=this.get(t,0),r=1;re&&(e=this.get(r,t));return e}},{key:"maxColumnIndex",value:function(t){O(this,t),D(this);for(var e=this.get(0,t),r=[0,t],n=1;ne&&(e=this.get(n,t),r[0]=n);return r}},{key:"minColumn",value:function(t){if(O(this,t),this.isEmpty())return NaN;for(var e=this.get(0,t),r=1;r0&&void 0!==arguments[0]?arguments[0]:"frobenius";switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError("unknown norm type: ".concat(t))}}},{key:"cumulativeSum",value:function(){for(var t=0,e=0;e=1;n/=2)0!=(1&n)&&(e=e.mmul(r)),r=r.mmul(r);return e}},{key:"strassen2x2",value:function(t){t=Z.checkMatrix(t);var e=new Z(2,2),r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),a=this.get(1,0),s=t.get(1,0),u=this.get(1,1),c=t.get(1,1),h=(r+u)*(n+c),d=(a+u)*n,f=r*(i-c),l=u*(s-n),g=(r+o)*c,v=h+l-g+(o-u)*(s+c),p=f+g,y=d+l,m=h-d+f+(a-r)*(n+i);return e.set(0,0,v),e.set(0,1,p),e.set(1,0,y),e.set(1,1,m),e}},{key:"strassen3x3",value:function(t){t=Z.checkMatrix(t);var e=new Z(3,3),r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),a=this.get(1,1),s=this.get(1,2),u=this.get(2,0),c=this.get(2,1),h=this.get(2,2),d=t.get(0,0),f=t.get(0,1),l=t.get(0,2),g=t.get(1,0),v=t.get(1,1),p=t.get(1,2),y=t.get(2,0),m=t.get(2,1),w=t.get(2,2),x=(r-i)*(-f+v),b=(-r+i+a)*(d-f+v),E=(i+a)*(-d+f),N=r*d,M=(-r+u+c)*(d-l+p),_=(-r+u)*(l-p),k=(u+c)*(-d+l),A=(-o+c+h)*(v+y-m),j=(o-h)*(v-m),O=o*y,S=(c+h)*(-y+m),z=(-o+a+s)*(p+y-w),R=(o-s)*(p-w),I=(a+s)*(-y+w),P=N+O+n*g,T=(r+n+o-i-a-c-h)*v+b+E+N+A+O+S,C=N+M+k+(r+n+o-a-s-u-c)*p+O+z+I,D=x+a*(-d+f+g-v-p-y+w)+b+N+O+z+R,L=x+b+E+N+s*m,F=O+z+R+I+i*l,q=N+M+_+c*(-d+l+g-v-p-y+m)+A+j+O,V=A+j+O+S+u*f,B=N+M+_+k+h*w;return e.set(0,0,P),e.set(0,1,T),e.set(0,2,C),e.set(1,0,D),e.set(1,1,L),e.set(1,2,F),e.set(2,0,q),e.set(2,1,V),e.set(2,2,B),e}},{key:"mmulStrassen",value:function(t){t=Z.checkMatrix(t);var r=this.clone(),n=r.rows,o=r.columns,i=t.rows,a=t.columns;function s(t,r,n){var o=t.rows,i=t.columns;if(o===r&&i===n)return t;var a=e.zeros(r,n);return a=a.setSubMatrix(t,0,0)}o!==i&&console.warn("Multiplying ".concat(n," x ").concat(o," and ").concat(i," x ").concat(a," matrix: dimensions do not match."));var u=Math.max(n,i),c=Math.max(o,a);return function t(r,n,o,i){if(o<=512||i<=512)return r.mmul(n);o%2==1&&i%2==1?(r=s(r,o+1,i+1),n=s(n,o+1,i+1)):o%2==1?(r=s(r,o+1,i),n=s(n,o+1,i)):i%2==1&&(r=s(r,o,i+1),n=s(n,o,i+1));var a=parseInt(r.rows/2,10),u=parseInt(r.columns/2,10),c=r.subMatrix(0,a-1,0,u-1),h=n.subMatrix(0,a-1,0,u-1),d=r.subMatrix(0,a-1,u,r.columns-1),f=n.subMatrix(0,a-1,u,n.columns-1),l=r.subMatrix(a,r.rows-1,0,u-1),g=n.subMatrix(a,n.rows-1,0,u-1),v=r.subMatrix(a,r.rows-1,u,r.columns-1),p=n.subMatrix(a,n.rows-1,u,n.columns-1),y=t(e.add(c,v),e.add(h,p),a,u),m=t(e.add(l,v),h,a,u),w=t(c,e.sub(f,p),a,u),x=t(v,e.sub(g,h),a,u),b=t(e.add(c,d),p,a,u),E=t(e.sub(l,c),e.add(h,f),a,u),N=t(e.sub(d,v),e.add(g,p),a,u),M=e.add(y,x);M.sub(b),M.add(N);var _=e.add(w,b),k=e.add(m,x),A=e.sub(y,m);A.add(w),A.add(E);var j=e.zeros(2*M.rows,2*M.columns);return(j=(j=(j=(j=j.setSubMatrix(M,0,0)).setSubMatrix(_,M.rows,0)).setSubMatrix(k,0,M.columns)).setSubMatrix(A,M.rows,M.columns)).subMatrix(0,o-1,0,i-1)}(r=s(r,u,c),t=s(t,u,c),u,c)}},{key:"scaleRows",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("object"!==y(t))throw new TypeError("options must be an object");var e=t.min,r=void 0===e?0:e,n=t.max,o=void 0===n?1:n;if(!Number.isFinite(r))throw new TypeError("min must be a number");if(!Number.isFinite(o))throw new TypeError("max must be a number");if(r>=o)throw new RangeError("min must be smaller than max");for(var i=new Z(this.rows,this.columns),a=0;a0&&b(s,{min:r,max:o,output:s}),i.setRow(a,s)}return i}},{key:"scaleColumns",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("object"!==y(t))throw new TypeError("options must be an object");var e=t.min,r=void 0===e?0:e,n=t.max,o=void 0===n?1:n;if(!Number.isFinite(r))throw new TypeError("min must be a number");if(!Number.isFinite(o))throw new TypeError("max must be a number");if(r>=o)throw new RangeError("min must be smaller than max");for(var i=new Z(this.rows,this.columns),a=0;a0&&void 0!==arguments[0]?arguments[0]:Q,e=0;e0&&void 0!==arguments[0]?arguments[0]:Q,e=0;er||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");for(var n=new Z(t.length,r-e+1),o=0;o=this.rows)throw new RangeError("Row index out of range: ".concat(t[o]));n.set(o,i-e,this.get(t[o],i))}return n}},{key:"subMatrixColumn",value:function(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");for(var n=new Z(r-e+1,t.length),o=0;o=this.columns)throw new RangeError("Column index out of range: ".concat(t[o]));n.set(i-e,o,this.get(i,t[o]))}return n}},{key:"setSubMatrix",value:function(t,e,r){if((t=Z.checkMatrix(t)).isEmpty())return this;P(this,e,e+t.rows-1,r,r+t.columns-1);for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if("object"===y(t)&&(e=t,t=void 0),"object"!==y(e))throw new TypeError("options must be an object");var r=e,n=r.unbiased,o=void 0===n||n,i=r.mean,a=void 0===i?this.mean(t):i;if("boolean"!=typeof o)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!x.isAnyArray(a))throw new TypeError("mean must be an array");return L(this,o,a);case"column":if(!x.isAnyArray(a))throw new TypeError("mean must be an array");return F(this,o,a);case void 0:if("number"!=typeof a)throw new TypeError("mean must be a number");return q(this,o,a);default:throw new Error("invalid option: ".concat(t))}}},{key:"standardDeviation",value:function(t,e){"object"===y(t)&&(e=t,t=void 0);var r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if("object"===y(t)&&(e=t,t=void 0),"object"!==y(e))throw new TypeError("options must be an object");var r=e,n=r.center,o=void 0===n?this.mean(t):n;switch(t){case"row":if(!x.isAnyArray(o))throw new TypeError("center must be an array");return V(this,o),this;case"column":if(!x.isAnyArray(o))throw new TypeError("center must be an array");return B(this,o),this;case void 0:if("number"!=typeof o)throw new TypeError("center must be a number");return G(this,o),this;default:throw new Error("invalid option: ".concat(t))}}},{key:"scale",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"===y(t)&&(e=t,t=void 0),"object"!==y(e))throw new TypeError("options must be an object");var r=e.scale;switch(t){case"row":if(void 0===r)r=U(this);else if(!x.isAnyArray(r))throw new TypeError("scale must be an array");return W(this,r),this;case"column":if(void 0===r)r=$(this);else if(!x.isAnyArray(r))throw new TypeError("scale must be an array");return Y(this,r),this;case void 0:if(void 0===r)r=H(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return K(this,r),this;default:throw new Error("invalid option: ".concat(t))}}},{key:"toString",value:function(t){return M(this,t)}},{key:t,value:function(){return this.entries()}},{key:"entries",value:p().mark((function t(){var e,r;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:if(!(e2&&void 0!==arguments[2]?arguments[2]:{};if("object"!==y(r))throw new TypeError("options must be an object");for(var n=r.random,o=void 0===n?Math.random:n,i=new Z(t,e),a=0;a2&&void 0!==arguments[2]?arguments[2]:{};if("object"!==y(r))throw new TypeError("options must be an object");var n=r.min,o=void 0===n?0:n,i=r.max,a=void 0===i?1e3:i,s=r.random,u=void 0===s?Math.random:s;if(!Number.isInteger(o))throw new TypeError("min must be an integer");if(!Number.isInteger(a))throw new TypeError("max must be an integer");if(o>=a)throw new RangeError("min must be smaller than max");for(var c=a-o,h=new Z(t,e),d=0;d=0)l(u(o),X,tt).call(u(o),t,n);else{if(!x.isAnyArray(t))throw new TypeError("First argument must be a positive number or an array");var i=t;if("number"!=typeof(n=(t=i.length)?i[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");o.data=[];for(var a=0;a=0))throw new TypeError("nColumns must be a positive integer");for(var r=0;r>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(var r=0;r>t.get(r,n));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(var e=0;e>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(var r=0;r>>t.get(r,n));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},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(var t=0;t=0)a(u(n),et,new Z(t,t));else if(a(u(n),et,new Z(t)),!n.isSymmetric())throw new TypeError("not symmetric data");return n}return w(r,[{key:"size",get:function(){return s(this,et).size}},{key:"rows",get:function(){return s(this,et).rows}},{key:"columns",get:function(){return s(this,et).columns}},{key:"diagonalSize",get:function(){return this.rows}},{key:"clone",value:function(){var t,e=new r(this.diagonalSize),n=v(this.upperRightEntries());try{for(n.s();!(t=n.n()).done;){var o=g(t.value,3),i=o[0],a=o[1],s=o[2];e.set(i,a,s)}}catch(t){n.e(t)}finally{n.f()}return e}},{key:"toMatrix",value:function(){return new Z(this)}},{key:"get",value:function(t,e){return s(this,et).get(t,e)}},{key:"set",value:function(t,e,r){return s(this,et).set(t,e,r),s(this,et).set(e,t,r),this}},{key:"removeCross",value:function(t){return s(this,et).removeRow(t),s(this,et).removeColumn(t),this}},{key:"addCross",value:function(t,e){void 0===e&&(e=t,t=this.diagonalSize);var r=e.slice();return r.splice(t,1),s(this,et).addRow(t,r),s(this,et).addColumn(t,e),this}},{key:"applyMask",value:function(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");var e,r=[],n=v(t.entries());try{for(n.s();!(e=n.n()).done;){var o=g(e.value,2),i=o[0];o[1]||r.push(i)}}catch(t){n.e(t)}finally{n.f()}r.reverse();for(var a=0,s=r;a=t&&(r=++n);return e}},{key:"upperRightEntries",value:p().mark((function t(){var e,r,n;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=0,r=0;case 1:if(!(e=this.diagonalSize&&(r=++e);case 6:t.next=1;break;case 9:case"end":return t.stop()}}),t,this)}))},{key:"upperRightValues",value:p().mark((function t(){var e,r,n;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=0,r=0;case 1:if(!(e=this.diagonalSize&&(r=++e);case 6:t.next=1;break;case 9:case"end":return t.stop()}}),t,this)}))}],[{key:"isSymmetricMatrix",value:function(t){return Z.isMatrix(t)&&"SymmetricMatrix"===t.klassType}},{key:"zeros",value:function(t){return new this(t)}},{key:"ones",value:function(t){return new this(t).fill(1)}},{key:"fromCompact",value:function(t){var e=t.length,n=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(n))throw new TypeError("This array is not a compact representation of a Symmetric Matrix, ".concat(JSON.stringify(t)));for(var o=new r(n),i=0,a=0,s=0;s=n&&(i=++a);return o}}]),r}(J);rt.prototype.klassType="SymmetricMatrix";var nt=function(t){c(r,t);var e=h(r);function r(t){var n;if(m(this,r),!(n=e.call(this,t)).isDistance())throw new TypeError("Provided arguments do no produce a distance matrix");return n}return w(r,[{key:"set",value:function(t,e,i){return t===e&&(i=0),n(o(r.prototype),"set",this).call(this,t,e,i)}},{key:"addCross",value:function(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,n(o(r.prototype),"addCross",this).call(this,t,e)}},{key:"toSymmetricMatrix",value:function(){return new rt(this)}},{key:"clone",value:function(){var t,e=new r(this.diagonalSize),n=v(this.upperRightEntries());try{for(n.s();!(t=n.n()).done;){var o=g(t.value,3),i=o[0],a=o[1],s=o[2];i!==a&&e.set(i,a,s)}}catch(t){n.e(t)}finally{n.f()}return e}},{key:"toCompact",value:function(){for(var t=this.diagonalSize,e=new Array((t-1)*t/2),r=1,n=0,o=0;o=t&&(r=1+ ++n);return e}}],[{key:"isDistanceMatrix",value:function(t){return rt.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}},{key:"fromCompact",value:function(t){var e=t.length;if(0===e)return new this(0);var r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError("This array is not a compact representation of a DistanceMatrix, ".concat(JSON.stringify(t)));for(var n=new this(r),o=1,i=0,a=0;a=r&&(o=1+ ++i);return n}}]),r}(rt);nt.prototype.klassSubType="DistanceMatrix";var ot=function(t){c(r,t);var e=h(r);function r(t,n,o){var i;return m(this,r),(i=e.call(this)).matrix=t,i.rows=n,i.columns=o,i}return w(r)}(J),it=function(t){c(r,t);var e=h(r);function r(t,n){var o;return m(this,r),O(t,n),(o=e.call(this,t,t.rows,1)).column=n,o}return w(r,[{key:"set",value:function(t,e,r){return this.matrix.set(t,this.column,r),this}},{key:"get",value:function(t){return this.matrix.get(t,this.column)}}]),r}(ot),at=function(t){c(r,t);var e=h(r);function r(t,n){var o;return m(this,r),I(t,n),(o=e.call(this,t,t.rows,n.length)).columnIndices=n,o}return w(r,[{key:"set",value:function(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}},{key:"get",value:function(t,e){return this.matrix.get(t,this.columnIndices[e])}}]),r}(ot),st=function(t){c(r,t);var e=h(r);function r(t){return m(this,r),e.call(this,t,t.rows,t.columns)}return w(r,[{key:"set",value:function(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}},{key:"get",value:function(t,e){return this.matrix.get(t,this.columns-e-1)}}]),r}(ot),ut=function(t){c(r,t);var e=h(r);function r(t){return m(this,r),e.call(this,t,t.rows,t.columns)}return w(r,[{key:"set",value:function(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}},{key:"get",value:function(t,e){return this.matrix.get(this.rows-t-1,e)}}]),r}(ot),ct=function(t){c(r,t);var e=h(r);function r(t,n){var o;return m(this,r),j(t,n),(o=e.call(this,t,1,t.columns)).row=n,o}return w(r,[{key:"set",value:function(t,e,r){return this.matrix.set(this.row,e,r),this}},{key:"get",value:function(t,e){return this.matrix.get(this.row,e)}}]),r}(ot),ht=function(t){c(r,t);var e=h(r);function r(t,n){var o;return m(this,r),R(t,n),(o=e.call(this,t,n.length,t.columns)).rowIndices=n,o}return w(r,[{key:"set",value:function(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}},{key:"get",value:function(t,e){return this.matrix.get(this.rowIndices[t],e)}}]),r}(ot),dt=function(t){c(r,t);var e=h(r);function r(t,n,o){var i;return m(this,r),R(t,n),I(t,o),(i=e.call(this,t,n.length,o.length)).rowIndices=n,i.columnIndices=o,i}return w(r,[{key:"set",value:function(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}},{key:"get",value:function(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}]),r}(ot),ft=function(t){c(r,t);var e=h(r);function r(t,n,o,i,a){var s;return m(this,r),P(t,n,o,i,a),(s=e.call(this,t,o-n+1,a-i+1)).startRow=n,s.startColumn=i,s}return w(r,[{key:"set",value:function(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}},{key:"get",value:function(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}]),r}(ot),lt=function(t){c(r,t);var e=h(r);function r(t){return m(this,r),e.call(this,t,t.columns,t.rows)}return w(r,[{key:"set",value:function(t,e,r){return this.matrix.set(e,t,r),this}},{key:"get",value:function(t,e){return this.matrix.get(e,t)}}]),r}(ot),gt=function(t){c(r,t);var e=h(r);function r(t){var n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};m(this,r);var i=o.rows,a=void 0===i?1:i;if(t.length%a!=0)throw new Error("the data length is not divisible by the number of rows");return(n=e.call(this)).rows=a,n.columns=t.length/a,n.data=t,n}return w(r,[{key:"set",value:function(t,e,r){var n=this._calculateIndex(t,e);return this.data[n]=r,this}},{key:"get",value:function(t,e){var r=this._calculateIndex(t,e);return this.data[r]}},{key:"_calculateIndex",value:function(t,e){return t*this.columns+e}}]),r}(J),vt=function(t){c(r,t);var e=h(r);function r(t){var n;return m(this,r),(n=e.call(this)).data=t,n.rows=t.length,n.columns=t[0].length,n}return w(r,[{key:"set",value:function(t,e,r){return this.data[t][e]=r,this}},{key:"get",value:function(t,e){return this.data[t][e]}}]),r}(J);var pt=function(){function t(e){m(this,t);var r,n,o,i,a,s,u,c,h,d=(e=vt.checkMatrix(e)).clone(),f=d.rows,l=d.columns,g=new Float64Array(f),v=1;for(r=0;rMath.abs(c[i])&&(i=r);if(i!==n){for(o=0;o=0;o--){for(n=0;ni?n.set(o,i,t.get(o,i)):o===i?n.set(o,i,1):n.set(o,i,0);return n}},{key:"upperTriangularMatrix",get:function(){for(var t=this.LU,e=t.rows,r=t.columns,n=new Z(e,r),o=0;oMath.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}var mt=function(){function t(e){m(this,t);var r,n,o,i,a=(e=vt.checkMatrix(e)).clone(),s=e.rows,u=e.columns,c=new Float64Array(u);for(o=0;o=0;i--){for(o=0;o=0;r--){for(t=0;t1&&void 0!==arguments[1]?arguments[1]:{};if(m(this,t),(e=vt.checkMatrix(e)).isEmpty())throw new Error("Matrix must be non-empty");var n,o=e.rows,i=e.columns,a=r.computeLeftSingularVectors,s=void 0===a||a,u=r.computeRightSingularVectors,c=void 0===u||u,h=r.autoTranspose,d=void 0!==h&&h,f=Boolean(s),l=Boolean(c),g=!1;if(o=0;K--)if(0!==w[K]){for(var J=K+1;J=0;ot--){if(ot0;){var ft=void 0,lt=void 0;for(ft=$-2;ft>=-1&&-1!==ft;ft--){var gt=Number.MIN_VALUE+dt*Math.abs(w[ft]+Math.abs(w[ft+1]));if(Math.abs(E[ft])<=gt||Number.isNaN(E[ft])){E[ft]=0;break}}if(ft===$-2)lt=4;else{var pt=void 0;for(pt=$-1;pt>=ft&&pt!==ft;pt--){var mt=(pt!==$?Math.abs(E[pt]):0)+(pt!==ft+1?Math.abs(E[pt-1]):0);if(Math.abs(w[pt])<=dt*mt){w[pt]=0;break}}pt===ft?lt=3:pt===$-1?lt=1:(lt=2,ft=pt)}switch(ft++,lt){case 1:var wt=E[$-2];E[$-2]=0;for(var xt=$-2;xt>=ft;xt--){var bt=yt(w[xt],wt),Et=w[xt]/bt,Nt=wt/bt;if(w[xt]=bt,xt!==ft&&(wt=-Nt*E[xt-1],E[xt-1]=Et*E[xt-1]),l)for(var Mt=0;Mt=w[ft+1]);){var Kt=w[ft];if(w[ft]=w[ft+1],w[ft+1]=Kt,l&&fte&&o.set(i,a,t.get(i,a)/this.s[a]);for(var s=this.U,u=s.rows,c=s.columns,h=new Z(r,u),d=0;dt&&e++;return e}},{key:"diagonal",get:function(){return Array.from(this.s)}},{key:"threshold",get:function(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}},{key:"leftSingularVectors",get:function(){return this.U}},{key:"rightSingularVectors",get:function(){return this.V}},{key:"diagonalMatrix",get:function(){return Z.diag(this.s)}}]),t}();function xt(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t=vt.checkMatrix(t),e=vt.checkMatrix(e),r?new wt(t).solve(e):t.isSquare()?new pt(t).solve(e):new mt(t).solve(e)}function bt(t,e){for(var r=[],n=0;n3&&void 0!==arguments[3]?arguments[3]:1e-9,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1e-9;if(t>o)return new Array(e.rows+1).fill(0);for(var i=e.addRow(r,[0]),a=0;a1&&void 0!==arguments[1]?arguments[1]:{};m(this,t);var n=r.assumeSymmetric,o=void 0!==n&&n;if(!(e=vt.checkMatrix(e)).isSquare())throw new Error("Matrix is not a square matrix");if(e.isEmpty())throw new Error("Matrix must be non-empty");var i,a,s=e.columns,u=new Z(s,s),c=new Float64Array(s),h=new Float64Array(s),d=e;if(!!o||e.isSymmetric()){for(i=0;i0?i.set(t,t+1,n[t]):n[t]<0&&i.set(t,t-1,n[t])}return i}}]),t}();function Mt(t,e,r,n){var o,i,a,s,u,c,h,d;for(u=0;u0;s--){for(d=0,a=0,c=0;c0&&(i=-i),e[s]=d*i,a-=o*i,r[s-1]=o-i,u=0;uc)do{for(o=r[c],f=yt(d=(r[c+1]-o)/(2*e[c]),1),d<0&&(f=-f),r[c]=e[c]/(d+f),r[c+1]=e[c]*(d+f),l=r[c+1],i=o-r[c],a=c+2;a=c;a--)for(p=v,v=g,w=m,o=g*e[a],i=g*d,f=yt(d,e[a]),e[a+1]=m*f,m=e[a]/f,d=(g=d/f)*r[a]-m*o,r[a+1]=i+m*(g*o+m*r[a]),u=0;uE*b);r[c]=r[c]+x,e[c]=0}for(a=0;a=c;s--)r[s]=e.get(s,c-1)/h,a+=r[s]*r[s];for(i=Math.sqrt(a),r[c]>0&&(i=-i),a-=r[c]*i,r[c]=r[c]-i,u=c;u=c;s--)o+=r[s]*e.get(s,u);for(o/=a,s=c;s<=d;s++)e.set(s,u,e.get(s,u)-o*r[s])}for(s=0;s<=d;s++){for(o=0,u=d;u>=c;u--)o+=r[u]*e.get(s,u);for(o/=a,u=c;u<=d;u++)e.set(s,u,e.get(s,u)-o*r[u])}r[c]=h*r[c],e.set(c,c-1,h*i)}}for(s=0;s=1;c--)if(0!==e.get(c,c-1)){for(s=c+1;s<=d;s++)r[s]=e.get(s,c-1);for(u=c;u<=d;u++){for(i=0,s=c;s<=d;s++)i+=r[s]*n.get(s,u);for(i=i/r[c]/e.get(c,c-1),s=c;s<=d;s++)n.set(s,u,n.get(s,u)+i*r[s])}}}function At(t,e,r,n,o){var i,a,s,u,c,h,d,f,l,g,v,p,y,m,w,x=t-1,b=t-1,E=Number.EPSILON,N=0,M=0,_=0,k=0,A=0,j=0,O=0,S=0;for(i=0;ib)&&(r[i]=o.get(i,i),e[i]=0),a=Math.max(i-1,0);a=0;){for(u=x;u>0&&(0===(j=Math.abs(o.get(u-1,u-1))+Math.abs(o.get(u,u)))&&(j=M),!(Math.abs(o.get(u,u-1))=0){for(O=_>=0?_+O:_-O,r[x-1]=f+O,r[x]=r[x-1],0!==O&&(r[x]=f-d/O),e[x-1]=0,e[x]=0,_=(f=o.get(x,x-1))/(j=Math.abs(f)+Math.abs(O)),k=O/j,_/=A=Math.sqrt(_*_+k*k),k/=A,a=x-1;a0){for(j=Math.sqrt(j),l=u&&(_=((A=f-(O=o.get(c,c)))*(j=l-O)-d)/o.get(c+1,c)+o.get(c,c+1),k=o.get(c+1,c+1)-O-A-j,A=o.get(c+2,c+1),_/=j=Math.abs(_)+Math.abs(k)+Math.abs(A),k/=j,A/=j,c!==u)&&!(Math.abs(o.get(c,c-1))*(Math.abs(k)+Math.abs(A))c+2&&o.set(i,i-3,0);for(s=c;s<=x-1&&(m=s!==x-1,s!==c&&(_=o.get(s,s-1),k=o.get(s+1,s-1),A=m?o.get(s+2,s-1):0,0!==(f=Math.abs(_)+Math.abs(k)+Math.abs(A))&&(_/=f,k/=f,A/=f)),0!==f);s++)if(j=Math.sqrt(_*_+k*k+A*A),_<0&&(j=-j),0!==j){for(s!==c?o.set(s,s-1,-j*f):u!==c&&o.set(s,s-1,-o.get(s,s-1)),f=(_+=j)/j,l=k/j,O=A/j,k/=_,A/=_,a=s;a=0;x--)if(_=r[x],0===(k=e[x]))for(u=x,o.set(x,x,1),i=x-1;i>=0;i--){for(d=o.get(i,i)-_,A=0,a=u;a<=x;a++)A+=o.get(i,a)*o.get(a,x);if(e[i]<0)O=d,j=A;else if(u=i,0===e[i]?o.set(i,x,0!==d?-A/d:-A/(E*M)):(f=o.get(i,i+1),l=o.get(i+1,i),h=(f*j-O*A)/(k=(r[i]-_)*(r[i]-_)+e[i]*e[i]),o.set(i,x,h),o.set(i+1,x,Math.abs(f)>Math.abs(O)?(-A-d*h)/f:(-j-l*h)/O)),E*(h=Math.abs(o.get(i,x)))*h>1)for(a=i;a<=x;a++)o.set(a,x,o.get(a,x)/h)}else if(k<0)for(u=x-1,Math.abs(o.get(x,x-1))>Math.abs(o.get(x-1,x))?(o.set(x-1,x-1,k/o.get(x,x-1)),o.set(x-1,x,-(o.get(x,x)-_)/o.get(x,x-1))):(w=jt(0,-o.get(x-1,x),o.get(x-1,x-1)-_,k),o.set(x-1,x-1,w[0]),o.set(x-1,x,w[1])),o.set(x,x-1,0),o.set(x,x,1),i=x-2;i>=0;i--){for(g=0,v=0,a=u;a<=x;a++)g+=o.get(i,a)*o.get(a,x-1),v+=o.get(i,a)*o.get(a,x);if(d=o.get(i,i)-_,e[i]<0)O=d,A=g,j=v;else if(u=i,0===e[i]?(w=jt(-g,-v,d,k),o.set(i,x-1,w[0]),o.set(i,x,w[1])):(f=o.get(i,i+1),l=o.get(i+1,i),p=(r[i]-_)*(r[i]-_)+e[i]*e[i]-k*k,y=2*(r[i]-_)*k,0===p&&0===y&&(p=E*M*(Math.abs(d)+Math.abs(k)+Math.abs(f)+Math.abs(l)+Math.abs(O))),w=jt(f*A-O*g+k*v,f*j-O*v-k*g,p,y),o.set(i,x-1,w[0]),o.set(i,x,w[1]),Math.abs(f)>Math.abs(O)+Math.abs(k)?(o.set(i+1,x-1,(-g-d*o.get(i,x-1)+k*o.get(i,x))/f),o.set(i+1,x,(-v-d*o.get(i,x)-k*o.get(i,x-1))/f)):(w=jt(-A-l*o.get(i,x-1),-j-l*o.get(i,x),O,k),o.set(i+1,x-1,w[0]),o.set(i+1,x,w[1]))),E*(h=Math.max(Math.abs(o.get(i,x-1)),Math.abs(o.get(i,x))))*h>1)for(a=i;a<=x;a++)o.set(a,x-1,o.get(a,x-1)/h),o.set(a,x,o.get(a,x)/h)}for(i=0;ib)for(a=i;a=0;a--)for(i=0;i<=b;i++){for(O=0,s=0;s<=Math.min(a,b);s++)O+=n.get(i,s)*o.get(s,a);n.set(i,a,O)}}}function jt(t,e,r,n){var o,i;return Math.abs(r)>Math.abs(n)?[(t+(o=n/r)*e)/(i=r+o*n),(e-o*t)/i]:[((o=r/n)*t+e)/(i=n+o*r),(o*e-t)/i]}var Ot=function(){function t(e){if(m(this,t),!(e=vt.checkMatrix(e)).isSymmetric())throw new Error("Matrix is not symmetric");var r,n,o,i=e,a=i.rows,s=new Z(a,a),u=!0;for(n=0;n0),s.set(n,n,Math.sqrt(Math.max(c,0))),o=n+1;o=0;i--)for(o=0;o1&&void 0!==arguments[1]?arguments[1]:{};m(this,t),e=vt.checkMatrix(e);var n,o=r.Y,i=r.scaleScores,a=void 0!==i&&i,s=r.maxIterations,u=void 0===s?1e3:s,c=r.terminationCriteria,h=void 0===c?1e-10:c;if(o){if((o=x.isAnyArray(o)&&"number"==typeof o[0]?Z.columnVector(o):vt.checkMatrix(o)).rows!==e.rows)throw new Error("Y should have the same number of rows as X");n=o.getColumnVector(0)}else n=e.getColumnVector(0);for(var d,f,l,g,v=1,p=0;ph;p++)l=(l=e.transpose().mmul(n).div(n.transpose().mmul(n).get(0,0))).div(l.norm()),d=e.mmul(l).div(l.transpose().mmul(l).get(0,0)),p>0&&(v=d.clone().sub(g).pow(2).sum()),g=d.clone(),o?(f=(f=o.transpose().mmul(d).div(d.transpose().mmul(d).get(0,0))).div(f.norm()),n=o.mmul(f).div(f.transpose().mmul(f).get(0,0))):n=d;if(o){var y=e.transpose().mmul(d).div(d.transpose().mmul(d).get(0,0));y=y.div(y.norm());var w=e.clone().sub(d.clone().mmul(y.transpose())),b=n.transpose().mmul(d).div(d.transpose().mmul(d).get(0,0)),E=o.clone().sub(d.clone().mulS(b.get(0,0)).mmul(f.transpose()));this.t=d,this.p=y.transpose(),this.w=l.transpose(),this.q=f,this.u=n,this.s=d.transpose().mmul(d),this.xResidual=w,this.yResidual=E,this.betas=b}else this.w=l.transpose(),this.s=d.transpose().mmul(d).sqrt(),this.t=a?d.clone().div(this.s.get(0,0)):d,this.xResidual=e.sub(d.mmul(l.transpose()))}));e.XA=J,e.a_=Ot,e.yQ=Ot,e.Hs=nt,e.Ec=Nt,e.dx=Nt,e.LU=pt,e.Rm=pt,e.y3=Z,e.qK=at,e.pb=it,e.j=st,e.sO=ut,e.BZ=ht,e.EK=ct,e.Db=dt,e.Fx=ft,e.tU=lt,e.Ym=St,e.rs=St,e.QR=mt,e.TB=mt,e.oH=wt,e.Sc=wt,e.BN=rt,e.it=gt,e.$r=vt,e.QM=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=new Z(t);var n=!1;if("object"!==y(e)||Z.isMatrix(e)||x.isAnyArray(e)?e=new Z(e):(r=e,e=t,n=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");var o=r,i=o.center,a=void 0===i||i,s=o.scale,u=void 0===s||s;a&&(t.center("column"),n||e.center("column")),u&&(t.scale("column"),n||e.scale("column"));for(var c=t.standardDeviation("column",{unbiased:!0}),h=n?c:e.standardDeviation("column",{unbiased:!0}),d=t.transpose().mmul(e),f=0;f1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=new Z(t);var n=!1;if("object"!==y(e)||Z.isMatrix(e)||x.isAnyArray(e)?e=new Z(e):(r=e,e=t,n=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");var o=r,i=o.center,a=void 0===i||i;a&&(t=t.center("column"),n||(e=e.center("column")));for(var s=t.transpose().mmul(e),u=0;u1&&void 0!==arguments[1]&&arguments[1];return t=vt.checkMatrix(t),e?new wt(t).inverse():xt(t,Z.eye(t.rows))},e.uZ=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.thresholdValue,n=void 0===r?1e-9:r,o=e.thresholdError,i=void 0===o?1e-9:o,a=(t=Z.checkMatrix(t)).rows,s=new Z(a,a),u=0;u1&&void 0!==arguments[1]?arguments[1]:Number.EPSILON;if((t=Z.checkMatrix(t)).isEmpty())return t.transpose();for(var r=new wt(t,{autoTranspose:!0}),n=r.leftSingularVectors,o=r.rightSingularVectors,i=r.diagonal,a=0;ae?i[a]=1/i[a]:i[a]=0;return o.mmul(Z.diag(i).mmul(n.transpose()))},e.F1=xt,e.re=function(t,e){if(x.isAnyArray(t))return t[0]&&x.isAnyArray(t[0])?new vt(t):new gt(t,e);throw new Error("the argument is not an array")}},92546:function(t,e,r){t.exports={graphlib:r(76626),layout:r(47194),debug:r(11303),util:{time:r(53063).time,notime:r(53063).notime},version:r(11897)}},81255:function(t,e,r){"use strict";var n=r(72361),o=r(39240);t.exports={run:function(t){var e="greedy"===t.graph().acyclicer?o(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],r={},o={};function i(a){n.has(o,a)||(o[a]=!0,r[a]=!0,n.forEach(t.outEdges(a),(function(t){n.has(r,t.w)?e.push(t):i(t.w)})),delete r[a])}return n.forEach(t.nodes(),i),e}(t);n.forEach(e,(function(e){var r=t.edge(e);t.removeEdge(e),r.forwardName=e.name,r.reversed=!0,t.setEdge(e.w,e.v,r,n.uniqueId("rev"))}))},undo:function(t){n.forEach(t.edges(),(function(e){var r=t.edge(e);if(r.reversed){t.removeEdge(e);var n=r.forwardName;delete r.reversed,delete r.forwardName,t.setEdge(e.w,e.v,r,n)}}))}}},60765:function(t,e,r){var n=r(72361),o=r(53063);function i(t,e,r,n,i,a){var s={width:0,height:0,rank:a,borderType:e},u=i[e][a-1],c=o.addDummyNode(t,"border",s,r);i[e][a]=c,t.setParent(c,n),u&&t.setEdge(u,c,{weight:1})}t.exports=function(t){n.forEach(t.children(),(function e(r){var o=t.children(r),a=t.node(r);if(o.length&&n.forEach(o,e),n.has(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(var s=a.minRank,u=a.maxRank+1;s0;--u)if(n=e[u].dequeue()){o=o.concat(s(t,e,r,n,!0));break}}return o}(r.graph,r.buckets,r.zeroIdx);return n.flatten(n.map(c,(function(e){return t.outEdges(e.v,e.w)})),!0)};var a=n.constant(1);function s(t,e,r,o,i){var a=i?[]:void 0;return n.forEach(t.inEdges(o.v),(function(n){var o=t.edge(n),s=t.node(n.v);i&&a.push({v:n.v,w:n.w}),s.out-=o,u(e,r,s)})),n.forEach(t.outEdges(o.v),(function(n){var o=t.edge(n),i=n.w,a=t.node(i);a.in-=o,u(e,r,a)})),t.removeNode(o.v),a}function u(t,e,r){r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)}},47194:function(t,e,r){"use strict";var n=r(72361),o=r(81255),i=r(27163),a=r(64505),s=r(53063).normalizeRanks,u=r(71970),c=r(53063).removeEmptyRanks,h=r(31733),d=r(60765),f=r(13257),l=r(62852),g=r(93021),v=r(53063),p=r(76626).Graph;t.exports=function(t,e){var r=e&&e.debugTiming?v.time:v.notime;r("layout",(function(){var e=r(" buildLayoutGraph",(function(){return function(t){var e=new p({multigraph:!0,compound:!0}),r=k(t.graph());return e.setGraph(n.merge({},m,_(r,y),n.pick(r,w))),n.forEach(t.nodes(),(function(r){var o=k(t.node(r));e.setNode(r,n.defaults(_(o,x),b)),e.setParent(r,t.parent(r))})),n.forEach(t.edges(),(function(r){var o=k(t.edge(r));e.setEdge(r,n.merge({},N,_(o,E),n.pick(o,M)))})),e}(t)}));r(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,n.forEach(t.edges(),(function(r){var n=t.edge(r);n.minlen*=2,"c"!==n.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?n.width+=n.labeloffset:n.height+=n.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){n.forEach(t.edges(),(function(e){if(e.v===e.w){var r=t.node(e.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){o.run(t)})),e(" nestingGraph.run",(function(){h.run(t)})),e(" rank",(function(){a(v.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){n.forEach(t.edges(),(function(e){var r=t.edge(e);if(r.width&&r.height){var n=t.node(e.v),o={rank:(t.node(e.w).rank-n.rank)/2+n.rank,e:e};v.addDummyNode(t,"edge-proxy",o,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){c(t)})),e(" nestingGraph.cleanup",(function(){h.cleanup(t)})),e(" normalizeRanks",(function(){s(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;n.forEach(t.nodes(),(function(r){var o=t.node(r);o.borderTop&&(o.minRank=t.node(o.borderTop).rank,o.maxRank=t.node(o.borderBottom).rank,e=n.max(e,o.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){n.forEach(t.nodes(),(function(e){var r=t.node(e);"edge-proxy"===r.dummy&&(t.edge(r.e).labelRank=r.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){i.run(t)})),e(" parentDummyChains",(function(){u(t)})),e(" addBorderSegments",(function(){d(t)})),e(" order",(function(){l(t)})),e(" insertSelfEdges",(function(){!function(t){var e=v.buildLayerMatrix(t);n.forEach(e,(function(e){var r=0;n.forEach(e,(function(e,o){var i=t.node(e);i.order=o+r,n.forEach(i.selfEdges,(function(e){v.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:i.rank,order:o+ ++r,e:e.e,label:e.label},"_se")})),delete i.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){f.adjust(t)})),e(" position",(function(){g(t)})),e(" positionSelfEdges",(function(){!function(t){n.forEach(t.nodes(),(function(e){var r=t.node(e);if("selfedge"===r.dummy){var n=t.node(r.e.v),o=n.x+n.width/2,i=n.y,a=r.x-o,s=n.height/2;t.setEdge(r.e,r.label),t.removeNode(e),r.label.points=[{x:o+2*a/3,y:i-s},{x:o+5*a/6,y:i-s},{x:o+a,y:i},{x:o+5*a/6,y:i+s},{x:o+2*a/3,y:i+s}],r.label.x=r.x,r.label.y=r.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){n.forEach(t.nodes(),(function(e){if(t.children(e).length){var r=t.node(e),o=t.node(r.borderTop),i=t.node(r.borderBottom),a=t.node(n.last(r.borderLeft)),s=t.node(n.last(r.borderRight));r.width=Math.abs(s.x-a.x),r.height=Math.abs(i.y-o.y),r.x=a.x+r.width/2,r.y=o.y+r.height/2}})),n.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){i.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){n.forEach(t.edges(),(function(e){var r=t.edge(e);if(n.has(r,"x"))switch("l"!==r.labelpos&&"r"!==r.labelpos||(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){f.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,r=0,o=Number.POSITIVE_INFINITY,i=0,a=t.graph(),s=a.marginx||0,u=a.marginy||0;function c(t){var n=t.x,a=t.y,s=t.width,u=t.height;e=Math.min(e,n-s/2),r=Math.max(r,n+s/2),o=Math.min(o,a-u/2),i=Math.max(i,a+u/2)}n.forEach(t.nodes(),(function(e){c(t.node(e))})),n.forEach(t.edges(),(function(e){var r=t.edge(e);n.has(r,"x")&&c(r)})),e-=s,o-=u,n.forEach(t.nodes(),(function(r){var n=t.node(r);n.x-=e,n.y-=o})),n.forEach(t.edges(),(function(r){var i=t.edge(r);n.forEach(i.points,(function(t){t.x-=e,t.y-=o})),n.has(i,"x")&&(i.x-=e),n.has(i,"y")&&(i.y-=o)})),a.width=r-e+s,a.height=i-o+u}(t)})),e(" assignNodeIntersects",(function(){!function(t){n.forEach(t.edges(),(function(e){var r,n,o=t.edge(e),i=t.node(e.v),a=t.node(e.w);o.points?(r=o.points[0],n=o.points[o.points.length-1]):(o.points=[],r=a,n=i),o.points.unshift(v.intersectRect(i,r)),o.points.push(v.intersectRect(a,n))}))}(t)})),e(" reversePoints",(function(){!function(t){n.forEach(t.edges(),(function(e){var r=t.edge(e);r.reversed&&r.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){o.undo(t)}))}(e,r)})),r(" updateInputGraph",(function(){!function(t,e){n.forEach(t.nodes(),(function(r){var n=t.node(r),o=e.node(r);n&&(n.x=o.x,n.y=o.y,e.children(r).length&&(n.width=o.width,n.height=o.height))})),n.forEach(t.edges(),(function(r){var o=t.edge(r),i=e.edge(r);o.points=i.points,n.has(i,"x")&&(o.x=i.x,o.y=i.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var y=["nodesep","edgesep","ranksep","marginx","marginy"],m={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],x=["width","height"],b={width:0,height:0},E=["minlen","weight","width","height","labeloffset"],N={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},M=["labelpos"];function _(t,e){return n.mapValues(n.pick(t,e),Number)}function k(t){var e={};return n.forEach(t,(function(t,r){e[r.toLowerCase()]=t})),e}},72361:function(t,e,r){var n;try{n={cloneDeep:r(20250),constant:r(13503),defaults:r(28548),each:r(76934),filter:r(64725),find:r(79785),flatten:r(40151),forEach:r(99204),forIn:r(23190),has:r(99946),isUndefined:r(16513),last:r(10611),map:r(9924),mapValues:r(70642),max:r(95987),merge:r(28440),min:r(73376),minBy:r(83296),now:r(5795),pick:r(89409),range:r(60859),reduce:r(16473),sortBy:r(351),uniqueId:r(95708),values:r(81229),zipObject:r(65441)}}catch(t){}n||(n=window._),t.exports=n},31733:function(t,e,r){var n=r(72361),o=r(53063);function i(t,e,r,a,s,u,c){var h=t.children(c);if(h.length){var d=o.addBorderNode(t,"_bt"),f=o.addBorderNode(t,"_bb"),l=t.node(c);t.setParent(d,c),l.borderTop=d,t.setParent(f,c),l.borderBottom=f,n.forEach(h,(function(n){i(t,e,r,a,s,u,n);var o=t.node(n),h=o.borderTop?o.borderTop:n,l=o.borderBottom?o.borderBottom:n,g=o.borderTop?a:2*a,v=h!==l?1:s-u[c]+1;t.setEdge(d,h,{weight:g,minlen:v,nestingEdge:!0}),t.setEdge(l,f,{weight:g,minlen:v,nestingEdge:!0})})),t.parent(c)||t.setEdge(e,d,{weight:0,minlen:s+u[c]})}else c!==e&&t.setEdge(e,c,{weight:0,minlen:r})}t.exports={run:function(t){var e=o.addDummyNode(t,"root",{},"_root"),r=function(t){var e={};function r(o,i){var a=t.children(o);a&&a.length&&n.forEach(a,(function(t){r(t,i+1)})),e[o]=i}return n.forEach(t.children(),(function(t){r(t,1)})),e}(t),a=n.max(n.values(r))-1,s=2*a+1;t.graph().nestingRoot=e,n.forEach(t.edges(),(function(e){t.edge(e).minlen*=s}));var u=function(t){return n.reduce(t.edges(),(function(e,r){return e+t.edge(r).weight}),0)}(t)+1;n.forEach(t.children(),(function(n){i(t,e,s,u,a,r,n)})),t.graph().nodeRankFactor=s},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,n.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}}},27163:function(t,e,r){"use strict";var n=r(72361),o=r(53063);t.exports={run:function(t){t.graph().dummyChains=[],n.forEach(t.edges(),(function(e){!function(t,e){var r,n,i,a=e.v,s=t.node(a).rank,u=e.w,c=t.node(u).rank,h=e.name,d=t.edge(e),f=d.labelRank;if(c===s+1)return;for(t.removeEdge(e),i=0,++s;s0;)e%2&&(r+=u[e+1]),u[e=e-1>>1]+=t.weight;c+=t.weight*r}))),c}t.exports=function(t,e){for(var r=0,n=1;n=2),s=h.buildLayerMatrix(t);var p=i(t,s);p=t.barycenter)&&function(t,e){var r=0,n=0;t.weight&&(r+=t.barycenter*t.weight,n+=t.weight);e.weight&&(r+=e.barycenter*e.weight,n+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=r/n,t.weight=n,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function o(e){return function(r){r.in.push(e),0==--r.indegree&&t.push(r)}}for(;t.length;){var i=t.pop();e.push(i),n.forEach(i.in.reverse(),r(i)),n.forEach(i.out,o(i))}return n.map(n.filter(e,(function(t){return!t.merged})),(function(t){return n.pick(t,["vs","i","barycenter","weight"])}))}(n.filter(r,(function(t){return!t.indegree})))}},86490:function(t,e,r){var n=r(72361),o=r(99506),i=r(45926),a=r(1349);t.exports=function t(e,r,s,u){var c=e.children(r),h=e.node(r),d=h?h.borderLeft:void 0,f=h?h.borderRight:void 0,l={};d&&(c=n.filter(c,(function(t){return t!==d&&t!==f})));var g=o(e,c);n.forEach(g,(function(r){if(e.children(r.v).length){var o=t(e,r.v,s,u);l[r.v]=o,n.has(o,"barycenter")&&(i=r,a=o,n.isUndefined(i.barycenter)?(i.barycenter=a.barycenter,i.weight=a.weight):(i.barycenter=(i.barycenter*i.weight+a.barycenter*a.weight)/(i.weight+a.weight),i.weight+=a.weight))}var i,a}));var v=i(g,s);!function(t,e){n.forEach(t,(function(t){t.vs=n.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(v,l);var p=a(v,u);if(d&&(p.vs=n.flatten([d,p.vs,f],!0),e.predecessors(d).length)){var y=e.node(e.predecessors(d)[0]),m=e.node(e.predecessors(f)[0]);n.has(p,"barycenter")||(p.barycenter=0,p.weight=0),p.barycenter=(p.barycenter*p.weight+y.order+m.order)/(p.weight+2),p.weight+=2}return p}},1349:function(t,e,r){var n=r(72361),o=r(53063);function i(t,e,r){for(var o;e.length&&(o=n.last(e)).i<=r;)e.pop(),t.push(o.vs),r++;return r}t.exports=function(t,e){var r=o.partition(t,(function(t){return n.has(t,"barycenter")})),a=r.lhs,s=n.sortBy(r.rhs,(function(t){return-t.i})),u=[],c=0,h=0,d=0;a.sort((f=!!e,function(t,e){return t.barycentere.barycenter?1:f?e.i-t.i:t.i-e.i})),d=i(u,s,d),n.forEach(a,(function(t){d+=t.vs.length,u.push(t.vs),c+=t.barycenter*t.weight,h+=t.weight,d=i(u,s,d)}));var f;var l={vs:n.flatten(u,!0)};h&&(l.barycenter=c/h,l.weight=h);return l}},71970:function(t,e,r){var n=r(72361);t.exports=function(t){var e=function(t){var e={},r=0;function o(i){var a=r;n.forEach(t.children(i),o),e[i]={low:a,lim:r++}}return n.forEach(t.children(),o),e}(t);n.forEach(t.graph().dummyChains,(function(r){for(var n=t.node(r),o=n.edgeObj,i=function(t,e,r,n){var o,i,a=[],s=[],u=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);o=r;do{o=t.parent(o),a.push(o)}while(o&&(e[o].low>u||c>e[o].lim));i=o,o=n;for(;(o=t.parent(o))!==i;)s.push(o);return{path:a.concat(s.reverse()),lca:i}}(t,e,o.v,o.w),a=i.path,s=i.lca,u=0,c=a[u],h=!0;r!==o.w;){if(n=t.node(r),h){for(;(c=a[u])!==s&&t.node(c).maxRanks)&&u(r,e,c)}))}))}return n.reduce(e,(function(e,r){var i,a=-1,s=0;return n.forEach(r,(function(n,u){if("border"===t.node(n).dummy){var c=t.predecessors(n);c.length&&(i=t.node(c[0]).order,o(r,s,u,a,i),s=u,a=i)}o(r,s,r.length,i,e.length)})),r})),r}function u(t,e,r){if(e>r){var n=e;e=r,r=n}var o=t[e];o||(t[e]=o={}),o[r]=!0}function c(t,e,r){if(e>r){var o=e;e=r,r=o}return n.has(t[e],r)}function h(t,e,r,o){var i={},a={},s={};return n.forEach(e,(function(t){n.forEach(t,(function(t,e){i[t]=t,a[t]=t,s[t]=e}))})),n.forEach(e,(function(t){var e=-1;n.forEach(t,(function(t){var u=o(t);if(u.length){u=n.sortBy(u,(function(t){return s[t]}));for(var h=(u.length-1)/2,d=Math.floor(h),f=Math.ceil(h);d<=f;++d){var l=u[d];a[t]===t&&eu.lim&&(c=u,h=!0);var d=n.filter(e.edges(),(function(e){return h===m(t,t.node(e.v),c)&&h!==m(t,t.node(e.w),c)}));return n.minBy(d,(function(t){return i(e,t)}))}function y(t,e,r,o){var i=r.v,a=r.w;t.removeEdge(i,a),t.setEdge(o.v,o.w,{}),l(t),d(t,e),function(t,e){var r=n.find(t.nodes(),(function(t){return!e.node(t).parent})),o=s(t,r);o=o.slice(1),n.forEach(o,(function(r){var n=t.node(r).parent,o=e.edge(r,n),i=!1;o||(o=e.edge(n,r),i=!0),e.node(r).rank=e.node(n).rank+(i?o.minlen:-o.minlen)}))}(t,e)}function m(t,e,r){return r.low<=e.lim&&e.lim<=r.lim}t.exports=h,h.initLowLimValues=l,h.initCutValues=d,h.calcCutValue=f,h.leaveEdge=v,h.enterEdge=p,h.exchangeEdges=y},2416:function(t,e,r){"use strict";var n=r(72361);t.exports={longestPath:function(t){var e={};n.forEach(t.sources(),(function r(o){var i=t.node(o);if(n.has(e,o))return i.rank;e[o]=!0;var a=n.min(n.map(t.outEdges(o),(function(e){return r(e.w)-t.edge(e).minlen})));return a!==Number.POSITIVE_INFINITY&&null!=a||(a=0),i.rank=a}))},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}}},53063:function(t,e,r){"use strict";var n=r(72361),o=r(76626).Graph;function i(t,e,r,o){var i;do{i=n.uniqueId(o)}while(t.hasNode(i));return r.dummy=e,t.setNode(i,r),i}function a(t){return n.max(n.map(t.nodes(),(function(e){var r=t.node(e).rank;if(!n.isUndefined(r))return r})))}t.exports={addDummyNode:i,simplify:function(t){var e=(new o).setGraph(t.graph());return n.forEach(t.nodes(),(function(r){e.setNode(r,t.node(r))})),n.forEach(t.edges(),(function(r){var n=e.edge(r.v,r.w)||{weight:0,minlen:1},o=t.edge(r);e.setEdge(r.v,r.w,{weight:n.weight+o.weight,minlen:Math.max(n.minlen,o.minlen)})})),e},asNonCompoundGraph:function(t){var e=new o({multigraph:t.isMultigraph()}).setGraph(t.graph());return n.forEach(t.nodes(),(function(r){t.children(r).length||e.setNode(r,t.node(r))})),n.forEach(t.edges(),(function(r){e.setEdge(r,t.edge(r))})),e},successorWeights:function(t){var e=n.map(t.nodes(),(function(e){var r={};return n.forEach(t.outEdges(e),(function(e){r[e.w]=(r[e.w]||0)+t.edge(e).weight})),r}));return n.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=n.map(t.nodes(),(function(e){var r={};return n.forEach(t.inEdges(e),(function(e){r[e.v]=(r[e.v]||0)+t.edge(e).weight})),r}));return n.zipObject(t.nodes(),e)},intersectRect:function(t,e){var r,n,o=t.x,i=t.y,a=e.x-o,s=e.y-i,u=t.width/2,c=t.height/2;if(!a&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*u>Math.abs(a)*c?(s<0&&(c=-c),r=c*a/s,n=c):(a<0&&(u=-u),r=u,n=u*s/a);return{x:o+r,y:i+n}},buildLayerMatrix:function(t){var e=n.map(n.range(a(t)+1),(function(){return[]}));return n.forEach(t.nodes(),(function(r){var o=t.node(r),i=o.rank;n.isUndefined(i)||(e[i][o.order]=r)})),e},normalizeRanks:function(t){var e=n.min(n.map(t.nodes(),(function(e){return t.node(e).rank})));n.forEach(t.nodes(),(function(r){var o=t.node(r);n.has(o,"rank")&&(o.rank-=e)}))},removeEmptyRanks:function(t){var e=n.min(n.map(t.nodes(),(function(e){return t.node(e).rank}))),r=[];n.forEach(t.nodes(),(function(n){var o=t.node(n).rank-e;r[o]||(r[o]=[]),r[o].push(n)}));var o=0,i=t.graph().nodeRankFactor;n.forEach(r,(function(e,r){n.isUndefined(e)&&r%i!=0?--o:o&&n.forEach(e,(function(e){t.node(e).rank+=o}))}))},addBorderNode:function(t,e,r,n){var o={width:0,height:0};arguments.length>=4&&(o.rank=r,o.order=n);return i(t,"border",o,e)},maxRank:a,partition:function(t,e){var r={lhs:[],rhs:[]};return n.forEach(t,(function(t){e(t)?r.lhs.push(t):r.rhs.push(t)})),r},time:function(t,e){var r=n.now();try{return e()}finally{console.log(t+" time: "+(n.now()-r)+"ms")}},notime:function(t,e){return e()}}},11897:function(t){t.exports="0.8.5"},75172:function(t,e,r){var n=r(89224);t.exports={Graph:n.Graph,json:r(17401),alg:r(54613),version:n.version}},91606:function(t,e,r){var n=r(95329);t.exports=function(t){var e,r={},o=[];function i(o){n.has(r,o)||(r[o]=!0,e.push(o),n.each(t.successors(o),i),n.each(t.predecessors(o),i))}return n.each(t.nodes(),(function(t){e=[],i(t),e.length&&o.push(e)})),o}},21482:function(t,e,r){var n=r(95329);function o(t,e,r,i,a,s){n.has(i,e)||(i[e]=!0,r||s.push(e),n.each(a(e),(function(e){o(t,e,r,i,a,s)})),r&&s.push(e))}t.exports=function(t,e,r){n.isArray(e)||(e=[e]);var i=(t.isDirected()?t.successors:t.neighbors).bind(t),a=[],s={};return n.each(e,(function(e){if(!t.hasNode(e))throw new Error("Graph does not have node: "+e);o(t,e,"post"===r,s,i,a)})),a}},40845:function(t,e,r){var n=r(13746),o=r(95329);t.exports=function(t,e,r){return o.transform(t.nodes(),(function(o,i){o[i]=n(t,i,e,r)}),{})}},13746:function(t,e,r){var n=r(95329),o=r(36614);t.exports=function(t,e,r,n){return function(t,e,r,n){var i,a,s={},u=new o,c=function(t){var e=t.v!==i?t.v:t.w,n=s[e],o=r(t),c=a.distance+o;if(o<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+o);c0&&(i=u.removeMin(),(a=s[i]).distance!==Number.POSITIVE_INFINITY);)n(i).forEach(c);return s}(t,String(e),r||i,n||function(e){return t.outEdges(e)})};var i=n.constant(1)},59324:function(t,e,r){var n=r(95329),o=r(94558);t.exports=function(t){return n.filter(o(t),(function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])}))}},22893:function(t,e,r){var n=r(95329);t.exports=function(t,e,r){return function(t,e,r){var n={},o=t.nodes();return o.forEach((function(t){n[t]={},n[t][t]={distance:0},o.forEach((function(e){t!==e&&(n[t][e]={distance:Number.POSITIVE_INFINITY})})),r(t).forEach((function(r){var o=r.v===t?r.w:r.v,i=e(r);n[t][o]={distance:i,predecessor:t}}))})),o.forEach((function(t){var e=n[t];o.forEach((function(r){var i=n[r];o.forEach((function(r){var n=i[t],o=e[r],a=i[r],s=n.distance+o.distance;s0;){if(r=u.removeMin(),n.has(s,r))a.setEdge(r,s[r]);else{if(h)throw new Error("Input graph is not connected: "+t);h=!0}t.nodeEdges(r).forEach(c)}return a}},94558:function(t,e,r){var n=r(95329);t.exports=function(t){var e=0,r=[],o={},i=[];function a(s){var u=o[s]={onStack:!0,lowlink:e,index:e++};if(r.push(s),t.successors(s).forEach((function(t){n.has(o,t)?o[t].onStack&&(u.lowlink=Math.min(u.lowlink,o[t].index)):(a(t),u.lowlink=Math.min(u.lowlink,o[t].lowlink))})),u.lowlink===u.index){var c,h=[];do{c=r.pop(),o[c].onStack=!1,h.push(c)}while(s!==c);i.push(h)}}return t.nodes().forEach((function(t){n.has(o,t)||a(t)})),i}},7793:function(t,e,r){var n=r(95329);function o(t){var e={},r={},o=[];if(n.each(t.sinks(),(function a(s){if(n.has(r,s))throw new i;n.has(e,s)||(r[s]=!0,e[s]=!0,n.each(t.predecessors(s),a),delete r[s],o.push(s))})),n.size(e)!==t.nodeCount())throw new i;return o}function i(){}t.exports=o,o.CycleException=i,i.prototype=new Error},36614:function(t,e,r){var n=r(95329);function o(){this._arr=[],this._keyIndices={}}t.exports=o,o.prototype.size=function(){return this._arr.length},o.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},o.prototype.has=function(t){return n.has(this._keyIndices,t)},o.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},o.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},o.prototype.add=function(t,e){var r=this._keyIndices;if(t=String(t),!n.has(r,t)){var o=this._arr,i=o.length;return r[t]=i,o.push({key:t,priority:e}),this._decrease(i),!0}return!1},o.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},o.prototype.decrease=function(t,e){var r=this._keyIndices[t];if(e>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[r].priority+" New: "+e);this._arr[r].priority=e,this._decrease(r)},o.prototype._heapify=function(t){var e=this._arr,r=2*t,n=r+1,o=t;r>1].prioritya){var s=i;i=a,a=s}return i+""+a+""+(n.isUndefined(o)?"\0":o)}function c(t,e,r,n){var o=""+e,i=""+r;if(!t&&o>i){var a=o;o=i,i=a}var s={v:o,w:i};return n&&(s.name=n),s}function h(t,e){return u(t,e.v,e.w,e.name)}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(t){return this._label=t,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(t){return n.isFunction(t)||(t=n.constant(t)),this._defaultNodeLabelFn=t,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return n.keys(this._nodes)},i.prototype.sources=function(){var t=this;return n.filter(this.nodes(),(function(e){return n.isEmpty(t._in[e])}))},i.prototype.sinks=function(){var t=this;return n.filter(this.nodes(),(function(e){return n.isEmpty(t._out[e])}))},i.prototype.setNodes=function(t,e){var r=arguments,o=this;return n.each(t,(function(t){r.length>1?o.setNode(t,e):o.setNode(t)})),this},i.prototype.setNode=function(t,e){return n.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=o,this._children[t]={},this._children[o][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},i.prototype.node=function(t){return this._nodes[t]},i.prototype.hasNode=function(t){return n.has(this._nodes,t)},i.prototype.removeNode=function(t){var e=this;if(n.has(this._nodes,t)){var r=function(t){e.removeEdge(e._edgeObjs[t])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],n.each(this.children(t),(function(t){e.setParent(t)})),delete this._children[t]),n.each(n.keys(this._in[t]),r),delete this._in[t],delete this._preds[t],n.each(n.keys(this._out[t]),r),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},i.prototype.setParent=function(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(n.isUndefined(e))e=o;else{for(var r=e+="";!n.isUndefined(r);r=this.parent(r))if(r===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this},i.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},i.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==o)return e}},i.prototype.children=function(t){if(n.isUndefined(t)&&(t=o),this._isCompound){var e=this._children[t];if(e)return n.keys(e)}else{if(t===o)return this.nodes();if(this.hasNode(t))return[]}},i.prototype.predecessors=function(t){var e=this._preds[t];if(e)return n.keys(e)},i.prototype.successors=function(t){var e=this._sucs[t];if(e)return n.keys(e)},i.prototype.neighbors=function(t){var e=this.predecessors(t);if(e)return n.union(e,this.successors(t))},i.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},i.prototype.filterNodes=function(t){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var r=this;n.each(this._nodes,(function(r,n){t(n)&&e.setNode(n,r)})),n.each(this._edgeObjs,(function(t){e.hasNode(t.v)&&e.hasNode(t.w)&&e.setEdge(t,r.edge(t))}));var o={};function i(t){var n=r.parent(t);return void 0===n||e.hasNode(n)?(o[t]=n,n):n in o?o[n]:i(n)}return this._isCompound&&n.each(e.nodes(),(function(t){e.setParent(t,i(t))})),e},i.prototype.setDefaultEdgeLabel=function(t){return n.isFunction(t)||(t=n.constant(t)),this._defaultEdgeLabelFn=t,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return n.values(this._edgeObjs)},i.prototype.setPath=function(t,e){var r=this,o=arguments;return n.reduce(t,(function(t,n){return o.length>1?r.setEdge(t,n,e):r.setEdge(t,n),n})),this},i.prototype.setEdge=function(){var t,e,r,o,i=!1,s=arguments[0];"object"==typeof s&&null!==s&&"v"in s?(t=s.v,e=s.w,r=s.name,2===arguments.length&&(o=arguments[1],i=!0)):(t=s,e=arguments[1],r=arguments[3],arguments.length>2&&(o=arguments[2],i=!0)),t=""+t,e=""+e,n.isUndefined(r)||(r=""+r);var h=u(this._isDirected,t,e,r);if(n.has(this._edgeLabels,h))return i&&(this._edgeLabels[h]=o),this;if(!n.isUndefined(r)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(e),this._edgeLabels[h]=i?o:this._defaultEdgeLabelFn(t,e,r);var d=c(this._isDirected,t,e,r);return t=d.v,e=d.w,Object.freeze(d),this._edgeObjs[h]=d,a(this._preds[e],t),a(this._sucs[t],e),this._in[e][h]=d,this._out[t][h]=d,this._edgeCount++,this},i.prototype.edge=function(t,e,r){var n=1===arguments.length?h(this._isDirected,arguments[0]):u(this._isDirected,t,e,r);return this._edgeLabels[n]},i.prototype.hasEdge=function(t,e,r){var o=1===arguments.length?h(this._isDirected,arguments[0]):u(this._isDirected,t,e,r);return n.has(this._edgeLabels,o)},i.prototype.removeEdge=function(t,e,r){var n=1===arguments.length?h(this._isDirected,arguments[0]):u(this._isDirected,t,e,r),o=this._edgeObjs[n];return o&&(t=o.v,e=o.w,delete this._edgeLabels[n],delete this._edgeObjs[n],s(this._preds[e],t),s(this._sucs[t],e),delete this._in[e][n],delete this._out[t][n],this._edgeCount--),this},i.prototype.inEdges=function(t,e){var r=this._in[t];if(r){var o=n.values(r);return e?n.filter(o,(function(t){return t.v===e})):o}},i.prototype.outEdges=function(t,e){var r=this._out[t];if(r){var o=n.values(r);return e?n.filter(o,(function(t){return t.w===e})):o}},i.prototype.nodeEdges=function(t,e){var r=this.inEdges(t,e);if(r)return r.concat(this.outEdges(t,e))}},89224:function(t,e,r){t.exports={Graph:r(6349),version:r(16544)}},17401:function(t,e,r){var n=r(95329),o=r(6349);function i(t){return n.map(t.nodes(),(function(e){var r=t.node(e),o=t.parent(e),i={v:e};return n.isUndefined(r)||(i.value=r),n.isUndefined(o)||(i.parent=o),i}))}function a(t){return n.map(t.edges(),(function(e){var r=t.edge(e),o={v:e.v,w:e.w};return n.isUndefined(e.name)||(o.name=e.name),n.isUndefined(r)||(o.value=r),o}))}t.exports={write:function(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:i(t),edges:a(t)};n.isUndefined(t.graph())||(e.value=n.clone(t.graph()));return e},read:function(t){var e=new o(t.options).setGraph(t.value);return n.each(t.nodes,(function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent)})),n.each(t.edges,(function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),e}}},95329:function(t,e,r){var n;try{n={clone:r(76833),constant:r(13503),each:r(76934),filter:r(64725),has:r(99946),isArray:r(80744),isEmpty:r(61627),isFunction:r(9363),isUndefined:r(16513),keys:r(55451),map:r(9924),reduce:r(16473),size:r(40617),transform:r(91116),union:r(44065),values:r(81229)}}catch(t){}n||(n=window._),t.exports=n},16544:function(t){t.exports="2.1.8"},34634:function(t,e,r){"use strict";r.r(e),r.d(e,{isAnyArray:function(){return o}});const n=Object.prototype.toString;function o(t){const e=n.call(t);return e.endsWith("Array]")&&!e.includes("Big")}},15584:function(t,e,r){var n=r(73893)(r(33152),"DataView");t.exports=n},76414:function(t,e,r){var n=r(64696),o=r(16824),i=r(23476),a=r(63122),s=r(37279);function u(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e-1}},94874:function(t){t.exports=function(t,e,r){for(var n=-1,o=null==t?0:t.length;++n0&&i(h)?r>1?t(h,r-1,i,a,s):n(s,h):a||(s[s.length]=h)}return s}},14018:function(t,e,r){var n=r(78010)();t.exports=n},1585:function(t,e,r){var n=r(14018),o=r(55451);t.exports=function(t,e){return t&&n(t,e,o)}},89147:function(t,e,r){var n=r(1186),o=r(9171);t.exports=function(t,e){for(var r=0,i=(e=n(e,t)).length;null!=t&&re}},3251:function(t){var e=Object.prototype.hasOwnProperty;t.exports=function(t,r){return null!=t&&e.call(t,r)}},62348:function(t){t.exports=function(t,e){return null!=t&&e in Object(t)}},17424:function(t,e,r){var n=r(51533),o=r(8373),i=r(49237);t.exports=function(t,e,r){return e==e?i(t,e,r):n(t,o,r)}},4977:function(t,e,r){var n=r(86756),o=r(93913);t.exports=function(t){return o(t)&&"[object Arguments]"==n(t)}},77295:function(t,e,r){var n=r(84412),o=r(93913);t.exports=function t(e,r,i,a,s){return e===r||(null==e||null==r||!o(e)&&!o(r)?e!=e&&r!=r:n(e,r,i,a,t,s))}},84412:function(t,e,r){var n=r(91866),o=r(50401),i=r(57710),a=r(4983),s=r(66139),u=r(80744),c=r(57835),h=r(18397),d="[object Arguments]",f="[object Array]",l="[object Object]",g=Object.prototype.hasOwnProperty;t.exports=function(t,e,r,v,p,y){var m=u(t),w=u(e),x=m?f:s(t),b=w?f:s(e),E=(x=x==d?l:x)==l,N=(b=b==d?l:b)==l,M=x==b;if(M&&c(t)){if(!c(e))return!1;m=!0,E=!1}if(M&&!E)return y||(y=new n),m||h(t)?o(t,e,r,v,p,y):i(t,e,x,r,v,p,y);if(!(1&r)){var _=E&&g.call(t,"__wrapped__"),k=N&&g.call(e,"__wrapped__");if(_||k){var A=_?t.value():t,j=k?e.value():e;return y||(y=new n),p(A,j,r,v,y)}}return!!M&&(y||(y=new n),a(t,e,r,v,p,y))}},55005:function(t,e,r){var n=r(66139),o=r(93913);t.exports=function(t){return o(t)&&"[object Map]"==n(t)}},51524:function(t,e,r){var n=r(91866),o=r(77295);t.exports=function(t,e,r,i){var a=r.length,s=a,u=!i;if(null==t)return!s;for(t=Object(t);a--;){var c=r[a];if(u&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++a=200){var v=e?null:s(t);if(v)return u(v);f=!1,h=a,g=new n}else g=e?[]:l;t:for(;++ce||a&&s&&c&&!u&&!h||o&&s&&c||!r&&c||!i)return 1;if(!o&&!a&&!h&&t=u?c:c*("desc"==r[o]?-1:1)}return t.index-e.index}},47760:function(t){t.exports=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r1?r[i-1]:void 0,s=i>2?r[2]:void 0;for(a=t.length>3&&"function"==typeof a?(i--,a):void 0,s&&o(r[0],r[1],s)&&(a=i<3?void 0:a,i=1),e=Object(e);++n-1?s[u?e[c]:c]:void 0}}},76106:function(t,e,r){var n=r(36121),o=r(8138),i=r(97341);t.exports=function(t){return function(e,r,a){return a&&"number"!=typeof a&&o(e,r,a)&&(r=a=void 0),e=i(e),void 0===r?(r=e,e=0):r=i(r),a=void 0===a?eh))return!1;var f=u.get(t),l=u.get(e);if(f&&l)return f==e&&l==t;var g=-1,v=!0,p=2&r?new n:void 0;for(u.set(t,e),u.set(e,t);++g-1&&t%1==0&&t-1}},54238:function(t,e,r){var n=r(67971);t.exports=function(t,e){var r=this.__data__,o=n(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}},35365:function(t,e,r){var n=r(76414),o=r(99746),i=r(40164);t.exports=function(){this.size=0,this.__data__={hash:new n,map:new(i||o),string:new n}}},63765:function(t,e,r){var n=r(89819);t.exports=function(t){var e=n(this,t).delete(t);return this.size-=e?1:0,e}},12608:function(t,e,r){var n=r(89819);t.exports=function(t){return n(this,t).get(t)}},10203:function(t,e,r){var n=r(89819);t.exports=function(t){return n(this,t).has(t)}},11298:function(t,e,r){var n=r(89819);t.exports=function(t,e){var r=n(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}},83383:function(t){t.exports=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}},24122:function(t){t.exports=function(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}},26332:function(t,e,r){var n=r(52858);t.exports=function(t){var e=n(t,(function(t){return 500===r.size&&r.clear(),t})),r=e.cache;return e}},65294:function(t,e,r){var n=r(73893)(Object,"create");t.exports=n},23730:function(t,e,r){var n=r(31030)(Object.keys,Object);t.exports=n},97817:function(t){t.exports=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}},52495:function(t,e,r){t=r.nmd(t);var n=r(37675),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,a=i&&i.exports===o&&n.process,s=function(){try{var t=i&&i.require&&i.require("util").types;return t||a&&a.binding&&a.binding("util")}catch(t){}}();t.exports=s},74702:function(t){var e=Object.prototype.toString;t.exports=function(t){return e.call(t)}},31030:function(t){t.exports=function(t,e){return function(r){return t(e(r))}}},19652:function(t,e,r){var n=r(79628),o=Math.max;t.exports=function(t,e,r){return e=o(void 0===e?t.length-1:e,0),function(){for(var i=arguments,a=-1,s=o(i.length-e,0),u=Array(s);++a0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}},31119:function(t,e,r){var n=r(99746);t.exports=function(){this.__data__=new n,this.size=0}},64399:function(t){t.exports=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}},81897:function(t){t.exports=function(t){return this.__data__.get(t)}},90558:function(t){t.exports=function(t){return this.__data__.has(t)}},64841:function(t,e,r){var n=r(99746),o=r(40164),i=r(52166);t.exports=function(t,e){var r=this.__data__;if(r instanceof n){var a=r.__data__;if(!o||a.length<199)return a.push([t,e]),this.size=++r.size,this;r=this.__data__=new i(a)}return r.set(t,e),this.size=r.size,this}},49237:function(t){t.exports=function(t,e,r){for(var n=r-1,o=t.length;++n2?e[2]:void 0;for(c&&i(e[0],e[1],c)&&(n=1);++r-1&&t%1==0&&t<=9007199254740991}},41626:function(t,e,r){var n=r(55005),o=r(38342),i=r(52495),a=i&&i.isMap,s=a?o(a):n;t.exports=s},20816:function(t){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},93913:function(t){t.exports=function(t){return null!=t&&"object"==typeof t}},19308:function(t,e,r){var n=r(86756),o=r(49217),i=r(93913),a=Function.prototype,s=Object.prototype,u=a.toString,c=s.hasOwnProperty,h=u.call(Object);t.exports=function(t){if(!i(t)||"[object Object]"!=n(t))return!1;var e=o(t);if(null===e)return!0;var r=c.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&u.call(r)==h}},65226:function(t,e,r){var n=r(38652),o=r(38342),i=r(52495),a=i&&i.isSet,s=a?o(a):n;t.exports=s},7941:function(t,e,r){var n=r(86756),o=r(80744),i=r(93913);t.exports=function(t){return"string"==typeof t||!o(t)&&i(t)&&"[object String]"==n(t)}},45029:function(t,e,r){var n=r(86756),o=r(93913);t.exports=function(t){return"symbol"==typeof t||o(t)&&"[object Symbol]"==n(t)}},18397:function(t,e,r){var n=r(10766),o=r(38342),i=r(52495),a=i&&i.isTypedArray,s=a?o(a):n;t.exports=s},16513:function(t){t.exports=function(t){return void 0===t}},55451:function(t,e,r){var n=r(63333),o=r(6019),i=r(24665);t.exports=function(t){return i(t)?n(t):o(t)}},56730:function(t,e,r){var n=r(63333),o=r(33988),i=r(24665);t.exports=function(t){return i(t)?n(t,!0):o(t)}},10611:function(t){t.exports=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}},9924:function(t,e,r){var n=r(75010),o=r(95979),i=r(65487),a=r(80744);t.exports=function(t,e){return(a(t)?n:i)(t,o(e,3))}},70642:function(t,e,r){var n=r(42813),o=r(1585),i=r(95979);t.exports=function(t,e){var r={};return e=i(e,3),o(t,(function(t,o,i){n(r,o,e(t,o,i))})),r}},95987:function(t,e,r){var n=r(2659),o=r(40302),i=r(46962);t.exports=function(t){return t&&t.length?n(t,i,o):void 0}},52858:function(t,e,r){var n=r(52166);function o(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var a=t.apply(this,n);return r.cache=i.set(o,a)||i,a};return r.cache=new(o.Cache||n),r}o.Cache=n,t.exports=o},28440:function(t,e,r){var n=r(50097),o=r(63323)((function(t,e,r){n(t,e,r)}));t.exports=o},73376:function(t,e,r){var n=r(2659),o=r(93757),i=r(46962);t.exports=function(t){return t&&t.length?n(t,i,o):void 0}},83296:function(t,e,r){var n=r(2659),o=r(95979),i=r(93757);t.exports=function(t,e){return t&&t.length?n(t,o(e,2),i):void 0}},9958:function(t){t.exports=function(){}},5795:function(t,e,r){var n=r(33152);t.exports=function(){return n.Date.now()}},89409:function(t,e,r){var n=r(88832),o=r(522)((function(t,e){return null==t?{}:n(t,e)}));t.exports=o},35769:function(t,e,r){var n=r(22310),o=r(96916),i=r(86773),a=r(9171);t.exports=function(t){return i(t)?n(a(t)):o(t)}},60859:function(t,e,r){var n=r(76106)();t.exports=n},16473:function(t,e,r){var n=r(99861),o=r(44107),i=r(95979),a=r(30739),s=r(80744);t.exports=function(t,e,r){var u=s(t)?n:a,c=arguments.length<3;return u(t,i(e,4),r,c,o)}},40617:function(t,e,r){var n=r(6019),o=r(66139),i=r(24665),a=r(7941),s=r(29405);t.exports=function(t){if(null==t)return 0;if(i(t))return a(t)?s(t):t.length;var e=o(t);return"[object Map]"==e||"[object Set]"==e?t.size:n(t).length}},351:function(t,e,r){var n=r(9256),o=r(58506),i=r(92918),a=r(8138),s=i((function(t,e){if(null==t)return[];var r=e.length;return r>1&&a(t,e[0],e[1])?e=[]:r>2&&a(e[0],e[1],e[2])&&(e=[e[0]]),o(t,n(e,1),[])}));t.exports=s},4134:function(t){t.exports=function(){return[]}},55950:function(t){t.exports=function(){return!1}},97341:function(t,e,r){var n=r(59406),o=1/0;t.exports=function(t){return t?(t=n(t))===o||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}},12824:function(t,e,r){var n=r(97341);t.exports=function(t){var e=n(t),r=e%1;return e==e?r?e-r:e:0}},59406:function(t,e,r){var n=r(13927),o=r(20816),i=r(45029),a=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(i(t))return NaN;if(o(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=o(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=n(t);var r=s.test(t);return r||u.test(t)?c(t.slice(2),r?2:8):a.test(t)?NaN:+t}},20480:function(t,e,r){var n=r(95378),o=r(56730);t.exports=function(t){return n(t,o(t))}},44140:function(t,e,r){var n=r(50230);t.exports=function(t){return null==t?"":n(t)}},91116:function(t,e,r){var n=r(74809),o=r(35024),i=r(1585),a=r(95979),s=r(49217),u=r(80744),c=r(57835),h=r(9363),d=r(20816),f=r(18397);t.exports=function(t,e,r){var l=u(t),g=l||c(t)||f(t);if(e=a(e,4),null==r){var v=t&&t.constructor;r=g?l?new v:[]:d(t)&&h(v)?o(s(t)):{}}return(g?n:i)(t,(function(t,n,o){return e(r,t,n,o)})),r}},44065:function(t,e,r){var n=r(9256),o=r(92918),i=r(29098),a=r(41590),s=o((function(t){return i(n(t,1,a,!0))}));t.exports=s},95708:function(t,e,r){var n=r(44140),o=0;t.exports=function(t){var e=++o;return n(t)+e}},81229:function(t,e,r){var n=r(20720),o=r(55451);t.exports=function(t){return null==t?[]:n(t,o(t))}},65441:function(t,e,r){var n=r(60348),o=r(94484);t.exports=function(t,e){return o(t||[],e||[],n)}},34402:function(t,e,r){"use strict";r.r(e),r.d(e,{default:function(){return a}});var n=r(34634);function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.isAnyArray)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,o=void 0===r?0:r,i=e.toIndex,a=void 0===i?t.length:i;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(a<=o||a>t.length||!Number.isInteger(a))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[o],u=o+1;us&&(s=t[u]);return s}function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.isAnyArray)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,o=void 0===r?0:r,i=e.toIndex,a=void 0===i?t.length:i;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(a<=o||a>t.length||!Number.isInteger(a))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[o],u=o+1;u1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.isAnyArray)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!(0,n.isAnyArray)(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var a=i(t),s=o(t);if(a===s)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var u=r.min,c=void 0===u?r.autoMinMax?a:0:u,h=r.max,d=void 0===h?r.autoMinMax?s:1:h;if(c>=d)throw new RangeError("min option must be smaller than max option");for(var f=(d-c)/(s-a),l=0;lt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){u=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}},t.exports.__esModule=!0,t.exports.default=t.exports},47074:function(t,e,r){var n=r(34577),o=r(74716),i=r(34456);t.exports=function(t){var e=o();return function(){var r,o=n(t);if(e){var a=n(this).constructor;r=Reflect.construct(o,arguments,a)}else r=o.apply(this,arguments);return i(this,r)}},t.exports.__esModule=!0,t.exports.default=t.exports},85573:function(t,e,r){var n=r(83411);t.exports=function(t,e,r){return(e=n(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.__esModule=!0,t.exports.default=t.exports},4811:function(t,e,r){var n=r(22652);function o(){return"undefined"!=typeof Reflect&&Reflect.get?(t.exports=o=Reflect.get.bind(),t.exports.__esModule=!0,t.exports.default=t.exports):(t.exports=o=function(t,e,r){var o=n(t,e);if(o){var i=Object.getOwnPropertyDescriptor(o,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},t.exports.__esModule=!0,t.exports.default=t.exports),o.apply(this,arguments)}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},34577:function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},80619:function(t,e,r){var n=r(35745);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&n(t,e)},t.exports.__esModule=!0,t.exports.default=t.exports},74716:function(t){t.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}},t.exports.__esModule=!0,t.exports.default=t.exports},70849:function(t){t.exports=function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}},t.exports.__esModule=!0,t.exports.default=t.exports},35599:function(t){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},34456:function(t,e,r){var n=r(31468).default,o=r(13720);t.exports=function(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return o(t)},t.exports.__esModule=!0,t.exports.default=t.exports},7557:function(t,e,r){var n=r(31468).default;function o(){"use strict";t.exports=o=function(){return r},t.exports.__esModule=!0,t.exports.default=t.exports;var e,r={},i=Object.prototype,a=i.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",h=u.asyncIterator||"@@asyncIterator",d=u.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(e){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,i=Object.create(o.prototype),a=new R(n||[]);return s(i,"_invoke",{value:j(t,r,a)}),i}function g(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=l;var v="suspendedStart",p="executing",y="completed",m={};function w(){}function x(){}function b(){}var E={};f(E,c,(function(){return this}));var N=Object.getPrototypeOf,M=N&&N(N(I([])));M&&M!==i&&a.call(M,c)&&(E=M);var _=b.prototype=w.prototype=Object.create(E);function k(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function A(t,e){function r(o,i,s,u){var c=g(t[o],t,i);if("throw"!==c.type){var h=c.arg,d=h.value;return d&&"object"==n(d)&&a.call(d,"__await")?e.resolve(d.__await).then((function(t){r("next",t,s,u)}),(function(t){r("throw",t,s,u)})):e.resolve(d).then((function(t){h.value=t,s(h)}),(function(t){return r("throw",t,s,u)}))}u(c.arg)}var o;s(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}})}function j(t,r,n){var o=v;return function(i,a){if(o===p)throw new Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var u=O(s,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===v)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var c=g(t,r,n);if("normal"===c.type){if(o=n.done?y:"suspendedYield",c.arg===m)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=y,n.method="throw",n.arg=c.arg)}}}function O(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,O(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=g(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function z(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function I(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),c=a.call(i,"finallyLoc");if(u&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),z(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;z(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},r}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},35745:function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},79800:function(t,e,r){var n=r(27027),o=r(70849),i=r(66109),a=r(35599);t.exports=function(t,e){return n(t)||o(t,e)||i(t,e)||a()},t.exports.__esModule=!0,t.exports.default=t.exports},22652:function(t,e,r){var n=r(34577);t.exports=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=n(t)););return t},t.exports.__esModule=!0,t.exports.default=t.exports},41819:function(t,e,r){var n=r(31468).default;t.exports=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},83411:function(t,e,r){var n=r(31468).default,o=r(41819);t.exports=function(t){var e=o(t,"string");return"symbol"==n(e)?e:String(e)},t.exports.__esModule=!0,t.exports.default=t.exports},31468:function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},66109:function(t,e,r){var n=r(39572);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={id:n,loaded:!1,exports:{}};return t[n](i,i.exports,r),i.loaded=!0,i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=function(t){return t.paths=[],t.children||(t.children=[]),t},function(){"use strict";function t(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function a(t,e,r,n){if(r(t))return!0;e.add(t.id);for(const o of n(t.id))if(!e.has(o.id)&&a(o,e,r,n))return!0;return!1}const s=()=>!0;class u{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||s,r=t.edgeFilter||s;this.nodeFilter=e,this.edgeFilter=t=>{const{source:n,target:o}=this.graph.getEdgeDetail(t.id);return!(!e(n)||!e(o))&&r(t,n,o)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map((t=>t.id)))};updateCache=t=>{const e=new Set;t.forEach((t=>{const r=this.bothEdgesMap.get(t);if(r&&r.forEach((t=>e.add(t.id))),this.hasNode(t)){const r=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),n=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),o=Array.from(new Set([...r,...n]));o.forEach((t=>e.add(t.id))),this.inEdgesMap.set(t,r),this.outEdgesMap.set(t,n),this.bothEdgesMap.set(t,o),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)})),e.forEach((t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)}))};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach((r=>{switch(r.type){case"NodeAdded":case"NodeRemoved":e.add(r.value.id);break;case"NodeDataUpdated":e.add(r.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(r.value.source),e.add(r.value.target);break;case"EdgeUpdated":"source"!==r.propertyName&&"target"!==r.propertyName||(e.add(r.oldValue),e.add(r.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(r.id)){const n=t.graph.getEdge(r.id);e.add(n.source),e.add(n.target)}}})),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),this.cacheEnabled)return"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t);return this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const r=this.graph.getParent(t,e);return r&&this.nodeFilter(r)?r:null}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(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];i([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];a(this.getNode(t),new Set,e,n)}}class c extends o{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),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))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let r=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),r||e.push(t);break}case"EdgeRemoved":{let r=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),r||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const r=e.findIndex((e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName))),n=e[r];n?void 0!==t.propertyName?n.newValue=t.newValue:(e.splice(r,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const r=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));r?r.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}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((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t);this.bothEdgesMap.get(t)?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((r=>{r.childrenMap.get(t)?.forEach((t=>{r.parentMap.delete(t.id)}));const n=r.parentMap.get(t);n&&r.childrenMap.get(n.id)?.delete(e),r.parentMap.delete(t),r.childrenMap.delete(t)})),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,r){const n=this.getNode(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeDataProperty(t,e,r)}))}))}updateNodeData(...t){const e=t[0],r=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:o})}))}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 e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.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 e=this.inEdgesMap.get(t.target),r=this.outEdgesMap.get(t.source),n=this.bothEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.target);e.add(t),r.add(t),n.add(t),o.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),r=this.outEdgesMap.get(e.source),n=this.inEdgesMap.get(e.target),o=this.bothEdgesMap.get(e.source),i=this.bothEdgesMap.get(e.target);r.delete(e),n.delete(e),o.delete(e),i.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.source,o=e;this.outEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.outEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:n,newValue:o})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.target,o=e;this.inEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.inEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:n,newValue:o})}))}updateEdgeDataProperty(t,e,r){const n=this.getEdge(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}updateEdgeData(...t){const e=t[0],r=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:o})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeDataProperty(t,e,r)}))}))}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,e){this.batch((()=>{this.attachTreeStructure(e);const r=[],n=Array.isArray(t)?t:[t];for(;n.length;){const t=n.shift();r.push(t),t.children&&n.push(...t.children)}this.addNodes(r),r.forEach((t=>{t.children?.forEach((r=>{this.setParent(r.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const r=this.treeIndices.get(e).childrenMap.get(t);return Array.from(r||[])}getParent(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);return this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const r=[];let n,o=this.getNode(t);for(;n=this.getParent(o.id,e);)r.push(n),o=n;return r}setParent(t,e,r){this.checkTreeExistence(r);const n=this.treeIndices.get(r);if(!n)return;const o=this.getNode(t),i=n.parentMap.get(t);if(i?.id===e)return;if(null==e)return i&&n.childrenMap.get(i.id)?.delete(o),void n.parentMap.delete(t);const a=this.getNode(e);n.parentMap.set(t,a),i&&n.childrenMap.get(i.id)?.delete(o);let s=n.childrenMap.get(a.id);s||(s=new Set,n.childrenMap.set(a.id,s)),s.add(o),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:i?.id,newParentId:a.id})}))}dfsTree(t,e,r){return a(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return i([this.getNode(t)],new Set,e,(t=>this.getChildren(t,r)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return i([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return a(this.getNode(t),new Set,e,n)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new c({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const o=new Map;t.forEach(((t,e)=>{o.set(e,r.getNode(t.id))}));const i=new Map;e.forEach(((t,e)=>{i.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:o,childrenMap:i})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new u({graph:this,...t})}}const h=Symbol("Comlink.proxy"),d=Symbol("Comlink.endpoint"),f=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.finalizer"),g=Symbol("Comlink.thrown"),v=t=>"object"==typeof t&&null!==t||"function"==typeof t,p={canHandle:t=>v(t)&&t[h],serialize(t){const{port1:e,port2:r}=new MessageChannel;return m(t,e),[r,[r]]},deserialize(t){return t.start(),function(t,e){const r=new Map;return t.addEventListener("message",(function(t){const{data:e}=t;if(!e||!e.id)return;const n=r.get(e.id);if(n)try{n(e)}finally{r.delete(e.id)}})),M(t,r,[],e)}(t)}},y=new Map([["proxy",p],["throw",{canHandle:t=>v(t)&&g in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function m(t,e=globalThis,r=["*"]){e.addEventListener("message",(function n(o){if(!o||!o.data)return;if(!function(t,e){for(const r of t){if(e===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}return!1}(r,o.origin))return void console.warn(`Invalid origin '${o.origin}' for comlink proxy`);const{id:i,type:a,path:s}=Object.assign({path:[]},o.data),u=(o.data.argumentList||[]).map(j);let c;try{const e=s.slice(0,-1).reduce(((t,e)=>t[e]),t),r=s.reduce(((t,e)=>t[e]),t);switch(a){case"GET":c=r;break;case"SET":e[s.slice(-1)[0]]=j(o.data.value),c=!0;break;case"APPLY":c=r.apply(e,u);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[h]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;m(t,r),c=function(t,e){return k.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[g]:0}}Promise.resolve(c).catch((t=>({value:t,[g]:0}))).then((r=>{const[o,s]=A(r);e.postMessage(Object.assign(Object.assign({},o),{id:i}),s),"RELEASE"===a&&(e.removeEventListener("message",n),w(e),l in t&&"function"==typeof t[l]&&t[l]())})).catch((t=>{const[r,n]=A({value:new TypeError("Unserializable return value"),[g]:0});e.postMessage(Object.assign(Object.assign({},r),{id:i}),n)}))})),e.start&&e.start()}function w(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function x(t){if(t)throw new Error("Proxy has been released and is not useable")}function b(t){return O(t,new Map,{type:"RELEASE"}).then((()=>{w(t)}))}const E=new WeakMap,N="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(E.get(t)||0)-1;E.set(t,e),0===e&&b(t)}));function M(t,e,r=[],n=function(){}){let o=!1;const i=new Proxy(n,{get(n,a){if(x(o),a===f)return()=>{!function(t){N&&N.unregister(t)}(i),b(t),e.clear(),o=!0};if("then"===a){if(0===r.length)return{then:()=>i};const n=O(t,e,{type:"GET",path:r.map((t=>t.toString()))}).then(j);return n.then.bind(n)}return M(t,e,[...r,a])},set(n,i,a){x(o);const[s,u]=A(a);return O(t,e,{type:"SET",path:[...r,i].map((t=>t.toString())),value:s},u).then(j)},apply(n,i,a){x(o);const s=r[r.length-1];if(s===d)return O(t,e,{type:"ENDPOINT"}).then(j);if("bind"===s)return M(t,e,r.slice(0,-1));const[u,c]=_(a);return O(t,e,{type:"APPLY",path:r.map((t=>t.toString())),argumentList:u},c).then(j)},construct(n,i){x(o);const[a,s]=_(i);return O(t,e,{type:"CONSTRUCT",path:r.map((t=>t.toString())),argumentList:a},s).then(j)}});return function(t,e){const r=(E.get(e)||0)+1;E.set(e,r),N&&N.register(t,e,t)}(i,t),i}function _(t){const e=t.map(A);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const k=new WeakMap;function A(t){for(const[e,r]of y)if(r.canHandle(t)){const[n,o]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},o]}return[{type:"RAW",value:t},k.get(t)||[]]}function j(t){switch(t.type){case"HANDLER":return y.get(t.name).deserialize(t.value);case"RAW":return t.value}}function O(t,e,r,n){return new Promise((o=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(i,o),t.start&&t.start(),t.postMessage(Object.assign({id:i},r),n)}))}function S(t){return"number"==typeof t}const z=(t,e)=>{if("next"!==t&&"prev"!==t)return e},R=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};class I{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return R(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&R(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let r=e.prev;for(;r!==e;)t.push(JSON.stringify(r,z)),r=null==r?void 0:r.prev;return`[${t.join(", ")}]`}}class P extends I{}const T=()=>1,C=(t,e,r)=>{let n=[];const o=e[e.length-1],i=e[0];let a;for(;t.getAllNodes().length;){for(;a=i.dequeue();)D(t,e,r,a);for(;a=o.dequeue();)D(t,e,r,a);if(t.getAllNodes().length)for(let o=e.length-2;o>0;--o)if(a=e[o].dequeue(),a){n=n.concat(D(t,e,r,a,!0));break}}return n},D=(t,e,r,n,o)=>{var i,a;const s=[];return t.hasNode(n.v)&&(null===(i=t.getRelatedEdges(n.v,"in"))||void 0===i||i.forEach((n=>{const i=n.data.weight,a=t.getNode(n.source);o&&s.push({v:n.source,w:n.target,in:0,out:0}),void 0===a.data.out&&(a.data.out=0),a.data.out-=i,F(e,r,Object.assign({v:a.id},a.data))})),null===(a=t.getRelatedEdges(n.v,"out"))||void 0===a||a.forEach((n=>{const o=n.data.weight,i=n.target,a=t.getNode(i);void 0===a.data.in&&(a.data.in=0),a.data.in-=o,F(e,r,Object.assign({v:a.id},a.data))})),t.removeNode(n.v)),o?s:void 0},L=(t,e)=>{const r=new c;let n=0,o=0;t.getAllNodes().forEach((t=>{r.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((t=>{const i=r.getRelatedEdges(t.source,"out").find((e=>e.target===t.target)),a=(null==e?void 0:e(t))||1;i?r.updateEdgeData(null==i?void 0:i.id,Object.assign(Object.assign({},i.data),{weight:i.data.weight+a})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:a}}),o=Math.max(o,r.getNode(t.source).data.out+=a),n=Math.max(n,r.getNode(t.target).data.in+=a)}));const i=[],a=o+n+3;for(let t=0;t{F(i,s,Object.assign({v:t.id},r.getNode(t.id).data))})),{buckets:i,zeroIdx:s,graph:r}},F=(t,e,r)=>{r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)},q=(t,e)=>{const r="greedy"===e?((t,e)=>{var r;if(t.getAllNodes().length<=1)return[];const n=L(t,e||T);return null===(r=C(n.graph,n.buckets,n.zeroIdx).map((e=>t.getRelatedEdges(e.v,"out").filter((({target:t})=>t===e.w)))))||void 0===r?void 0:r.flat()})(t,(t=>t.data.weight||1)):V(t);null==r||r.forEach((e=>{const r=e.data;t.removeEdge(e.id),r.forwardName=e.data.name,r.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},r)})}))},V=t=>{const e=[],r={},n={},o=i=>{n[i]||(n[i]=!0,r[i]=!0,t.getRelatedEdges(i,"out").forEach((t=>{r[t.target]?e.push(t):o(t.target)})),delete r[i])};return t.getAllNodes().forEach((t=>o(t.id))),e},B=(t,e,r,n)=>{let o;do{o=`${n}${Math.random()}`}while(t.hasNode(o));return r.dummy=e,t.addNode({id:o,data:r}),o},G=t=>{const e=new c;return t.getAllNodes().forEach((r=>{t.getChildren(r.id).length||e.addNode(Object.assign({},r))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},U=(t,e)=>null==t?void 0:t.reduce(((t,r,n)=>(t[r]=e[n],t)),{}),W=(t,e)=>{const r=Number(t.x),n=Number(t.y),o=Number(e.x)-r,i=Number(e.y)-n;let a,s,u=Number(t.width)/2,c=Number(t.height)/2;return o||i?(Math.abs(i)*u>Math.abs(o)*c?(i<0&&(c=-c),a=c*o/i,s=c):(o<0&&(u=-u),a=u,s=u*i/o),{x:r+a,y:n+s}):{x:0,y:0}},$=t=>{const e=[],r=H(t)+1;for(let t=0;t{const r=t.data.rank;void 0!==r&&e[r]&&e[r].push(t.id)}));for(let n=0;n{return n=t.getNode(e).data.order,o=t.getNode(r).data.order,Number(n)-Number(o);var n,o}));return e},Y=(t,e,r,n)=>{const o={width:0,height:0};return S(r)&&S(n)&&(o.rank=r,o.order=n),B(t,"border",o,e)},H=t=>{let e;return t.getAllNodes().forEach((t=>{const r=t.data.rank;void 0!==r&&(void 0===e||r>e)&&(e=r)})),e||(e=0),e},K=(t,e)=>t.reduce(((t,r)=>e(t)>e(r)?r:t)),J=(t,e,r,n,o,i)=>{n.includes(e.id)||(n.push(e.id),r||i.push(e.id),o(e.id).forEach((e=>J(t,e,r,n,o,i))),r&&i.push(e.id))},Q=(t,e,r,n)=>{const o=Array.isArray(e)?e:[e],i=e=>n?t.getSuccessors(e):t.getNeighbors(e),a=[],s=[];return o.forEach((e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);J(t,e,"post"===r,s,i,a)})),a},X=(t,e,r,n,o,i)=>{const a={rank:i,borderType:e,width:0,height:0},s=o.data[e][i-1],u=B(t,"border",a,r);o.data[e][i]=u,t.setParent(u,n),s&&t.addEdge({id:`e${Math.random()}`,source:s,target:u,data:{weight:1}})},Z=t=>{t.getAllNodes().forEach((t=>{tt(t)})),t.getAllEdges().forEach((t=>{tt(t)}))},tt=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},et=t=>{t.getAllNodes().forEach((t=>{rt(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>rt(t))),t.data.hasOwnProperty("y")&&rt(t.data)}))},rt=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},nt=t=>{t.getAllNodes().forEach((t=>{ot(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>ot(t))),t.data.hasOwnProperty("x")&&ot(t.data)}))},ot=t=>{const e=t.x;t.x=t.y,t.y=e},it=(t,e,r,n,o,i,a)=>{const s=t.getChildren(a);if(!(null==s?void 0:s.length))return void(a!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:a,data:{weight:0,minlen:r}}));const u=Y(t,"_bt"),c=Y(t,"_bb"),h=t.getNode(a);t.setParent(u,a),h.data.borderTop=u,t.setParent(c,a),h.data.borderBottom=c,null==s||s.forEach((s=>{it(t,e,r,n,o,i,s.id);const h=s.data.borderTop?s.data.borderTop:s.id,d=s.data.borderBottom?s.data.borderBottom:s.id,f=s.data.borderTop?n:2*n,l=h!==d?1:o-i[a]+1;t.addEdge({id:`e${Math.random()}`,source:u,target:h,data:{minlen:l,weight:f,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:d,target:c,data:{minlen:l,weight:f,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:`e${Math.random()}`,source:e,target:u,data:{weight:0,minlen:o+i[a]}})},at=t=>{const e={},r=(n,o)=>{const i=t.getChildren(n);null==i||i.forEach((t=>r(t.id,o+1))),e[n]=o};return t.getRoots().forEach((t=>r(t.id,1))),e},st=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},ut="edge-label",ct=(t,e,r)=>{let n=e.source,o=t.getNode(n).data.rank;const i=e.target,a=t.getNode(i).data.rank,s=e.data.labelRank;if(a===o+1)return;let u,c,h;for(t.removeEdge(e.id),h=0,++o;o{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},gt=(t,e,r)=>{const n=U(r,r.map(((t,e)=>e))),o=e.map((e=>{const r=t.getRelatedEdges(e,"out").map((t=>({pos:n[t.target]||0,weight:t.data.weight})));return null==r?void 0:r.sort(((t,e)=>t.pos-e.pos))})),i=o.flat().filter((t=>void 0!==t));let a=1;for(;a{if(t){let e=t.pos+a;u[e]+=t.weight;let r=0;for(;e>0;)e%2&&(r+=u[e+1]),e=e-1>>1,u[e]+=t.weight;c+=t.weight*r}})),c},vt=(t,e)=>{let r=0;for(let n=1;n<(null==e?void 0:e.length);n+=1)r+=gt(t,e[n-1],e[n]);return r},pt=t=>{const e={},r=t.getAllNodes(),n=r.map((t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),o=Math.max(...n),i=[];for(let t=0;tt.getNode(e.id).data.rank-t.getNode(r.id).data.rank)),s=a.filter((e=>void 0!==t.getNode(e.id).data.fixorder)).sort(((e,r)=>t.getNode(e.id).data.fixorder-t.getNode(r.id).data.fixorder));return null==s||s.forEach((r=>{isNaN(t.getNode(r.id).data.rank)||i[t.getNode(r.id).data.rank].push(r.id),e[r.id]=!0})),null==a||a.forEach((r=>t.dfsTree(r.id,(t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||i[t.data.rank].push(t.id)})))),i},yt=t=>{var e,r;const n=[];for(;null==t?void 0:t.length;){const o=t.pop();n.push(o),null===(e=o.in.reverse())||void 0===e||e.forEach((t=>{return(e=o,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&mt(e,t)})(t);var e})),null===(r=o.out)||void 0===r||r.forEach((e=>{return(r=o,e=>{e.in.push(r),0==--e.indegree&&t.push(e)})(e);var r}))}const o=n.filter((t=>!t.merged)),i=["vs","i","barycenter","weight"];return o.map((t=>{const e={};return null==i||i.forEach((r=>{void 0!==t[r]&&(e[r]=t[r])})),e}))},mt=(t,e)=>{var r;let n=0,o=0;t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.vs=null===(r=e.vs)||void 0===r?void 0:r.concat(t.vs),t.barycenter=n/o,t.weight=o,t.i=Math.min(e.i,t.i),e.merged=!0};var wt=(t,e)=>{var r,n,o;const i={};null==t||t.forEach(((t,e)=>{i[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const r=i[t.v];void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)})),null===(r=e.getAllEdges())||void 0===r||r.forEach((t=>{const e=i[t.source],r=i[t.target];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(i[t.target]))}));const a=null===(o=(n=Object.values(i)).filter)||void 0===o?void 0:o.call(n,(t=>!t.indegree));return yt(a)};const xt=(t,e,r)=>{let n,o=r;for(;e.length&&(n=e[e.length-1]).i<=o;)e.pop(),null==t||t.push(n.vs),o++;return o},bt=(t,e)=>(r,n)=>{if(void 0!==r.fixorder&&void 0!==n.fixorder)return r.fixorder-n.fixorder;if(r.barycentern.barycenter)return 1;if(e&&void 0!==r.order&&void 0!==n.order){if(r.ordern.order)return 1}return t?n.i-r.i:r.i-n.i},Et=(t,e,r,n,o,i)=>{var a,s,u,c;let h=t.getChildren(e).map((t=>t.id));const d=t.getNode(e),f=d?d.data.borderLeft:void 0,l=d?d.data.borderRight:void 0,g={};f&&(h=null==h?void 0:h.filter((t=>t!==f&&t!==l)));const v=((t,e)=>e.map((e=>{const r=t.getRelatedEdges(e,"in");if(!(null==r?void 0:r.length))return{v:e};const n={sum:0,weight:0};return null==r||r.forEach((e=>{const r=t.getNode(e.source);n.sum+=e.data.weight*r.data.order,n.weight+=e.data.weight})),{v:e,barycenter:n.sum/n.weight,weight:n.weight}})))(t,h||[]);null==v||v.forEach((e=>{var o;if(null===(o=t.getChildren(e.v))||void 0===o?void 0:o.length){const o=Et(t,e.v,r,n,i);g[e.v]=o,o.hasOwnProperty("barycenter")&&Mt(e,o)}}));const p=wt(v,r);Nt(p,g),null===(a=p.filter((t=>t.vs.length>0)))||void 0===a||a.forEach((e=>{const r=t.getNode(e.vs[0]);r&&(e.fixorder=r.data.fixorder,e.order=r.data.order)}));const y=((t,e,r,n)=>{const o=((t,e)=>{const r={lhs:[],rhs:[]};return null==t||t.forEach((t=>{e(t)?r.lhs.push(t):r.rhs.push(t)})),r})(t,(t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return n?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")})),i=o.lhs,a=o.rhs.sort(((t,e)=>-t.i- -e.i)),s=[];let u=0,c=0,h=0;null==i||i.sort(bt(!!e,!!r)),h=xt(s,a,h),null==i||i.forEach((t=>{var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,c+=t.weight,h=xt(s,a,h)}));const d={vs:s.flat()};return c&&(d.barycenter=u/c,d.weight=c),d})(p,n,o,i);if(f&&(y.vs=[f,y.vs,l].flat(),null===(s=t.getPredecessors(f))||void 0===s?void 0:s.length)){const e=t.getNode((null===(u=t.getPredecessors(f))||void 0===u?void 0:u[0].id)||""),r=t.getNode((null===(c=t.getPredecessors(l))||void 0===c?void 0:c[0].id)||"");y.hasOwnProperty("barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+e.data.order+r.data.order)/(y.weight+2),y.weight+=2}return y},Nt=(t,e)=>{null==t||t.forEach((t=>{var r;const n=null===(r=t.vs)||void 0===r?void 0:r.map((t=>e[t]?e[t].vs:t));t.vs=n.flat()}))},Mt=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},_t=(t,e,r)=>e.map((e=>((t,e,r)=>{const n=lt(t),o=new c({tree:[{id:n,children:[],data:{}}]});return t.getAllNodes().forEach((i=>{const a=t.getParent(i.id);(i.data.rank===e||i.data.minRank<=e&&e<=i.data.maxRank)&&(o.hasNode(i.id)||o.addNode(Object.assign({},i)),(null==a?void 0:a.id)&&!o.hasNode(null==a?void 0:a.id)&&o.addNode(Object.assign({},a)),o.setParent(i.id,(null==a?void 0:a.id)||n),t.getRelatedEdges(i.id,r).forEach((e=>{const r=e.source===i.id?e.target:e.source;o.hasNode(r)||o.addNode(Object.assign({},t.getNode(r)));const n=o.getRelatedEdges(r,"out").find((({target:t})=>t===i.id)),a=void 0!==n?n.data.weight:0;n?o.updateEdgeData(n.id,Object.assign(Object.assign({},n.data),{weight:e.data.weight+a})):o.addEdge({id:e.id,source:r,target:i.id,data:{weight:e.data.weight+a}})})),i.data.hasOwnProperty("minRank")&&o.updateNodeData(i.id,Object.assign(Object.assign({},i.data),{borderLeft:i.data.borderLeft[e],borderRight:i.data.borderRight[e]})))})),o})(t,e,r))),kt=(t,e,r,n)=>{const o=new c;null==t||t.forEach((t=>{var i;const a=t.getRoots()[0].id,s=Et(t,a,o,e,r,n);for(let e=0;e<(null===(i=s.vs)||void 0===i?void 0:i.length);e++){const r=t.getNode(s.vs[e]);r&&(r.data.order=e)}((t,e,r)=>{const n={};let o;null==r||r.forEach((r=>{let i,a,s=t.getParent(r);for(;s;){if(i=t.getParent(s.id),i?(a=n[i.id],n[i.id]=s.id):(a=o,o=s.id),a&&a!==s.id)return e.hasNode(a)||e.addNode({id:a,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge(`e${a}-${s.id}`)||e.addEdge({id:`e${a}-${s.id}`,source:a,target:s.id,data:{}}));s=i}}))})(t,o,s.vs)}))},At=(t,e)=>{null==e||e.forEach((e=>{null==e||e.forEach(((e,r)=>{t.getNode(e).data.order=r}))}))},jt=(t,e)=>{const r=(t=>{const e={};let r=0;const n=o=>{const i=r;t.getChildren(o).forEach((t=>n(t.id))),e[o]={low:i,lim:r++}};return t.getRoots().forEach((t=>n(t.id))),e})(t);e.forEach((e=>{var n,o;let i=e,a=t.getNode(i);const s=a.data.originalEdge;if(!s)return;const u=((t,e,r,n)=>{var o,i;const a=[],s=[],u=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);let h,d;h=r;do{h=null===(o=t.getParent(h))||void 0===o?void 0:o.id,a.push(h)}while(h&&(e[h].low>u||c>e[h].lim));for(d=h,h=n;h&&h!==d;)s.push(h),h=null===(i=t.getParent(h))||void 0===i?void 0:i.id;return{lca:d,path:a.concat(s.reverse())}})(t,r,s.source,s.target),c=u.path,h=u.lca;let d=0,f=c[d],l=!0;for(;i!==s.target;){if(a=t.getNode(i),l){for(;f!==h&&(null===(n=t.getNode(f))||void 0===n?void 0:n.data.maxRank){const r={},n=(e,n)=>{let o=0,i=0;const a=e.length,s=null==n?void 0:n[(null==n?void 0:n.length)-1];return null==n||n.forEach(((e,u)=>{var c;const h=zt(t,e),d=h?t.getNode(h.id).data.order:a;(h||e===s)&&(null===(c=n.slice(i,u+1))||void 0===c||c.forEach((e=>{var n;null===(n=t.getPredecessors(e))||void 0===n||n.forEach((n=>{var i;const a=t.getNode(n.id),s=a.data.order;!(s{const r={};function n(e,n){const o=function(t){return JSON.stringify(t.slice(1))}(e);n.get(o)||(!function(e,n,o,i,a){var s,u;let c;for(let h=n;h{const n=t.getNode(e.id);n.data.dummy&&(n.data.ordera)&&Rt(r,e.id,c)})))}(...e),n.set(o,!0))}const o=(e,r)=>{let o,i=-1,a=0;const s=new Map;return null==r||r.forEach(((u,c)=>{var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){const e=t.getPredecessors(u)||[];e.length&&(o=t.getNode(e[0].id).data.order,n([r,a,c,i,o],s),a=c,i=o)}n([r,a,r.length,o,e.length],s)})),r};return(null==e?void 0:e.length)&&e.reduce(o),r},zt=(t,e)=>{var r,n;if(null===(r=t.getNode(e))||void 0===r?void 0:r.data.dummy)return null===(n=t.getPredecessors(e))||void 0===n?void 0:n.find((e=>t.getNode(e.id).data.dummy))},Rt=(t,e,r)=>{let n=e,o=r;if(n>o){const t=n;n=o,o=t}let i=t[n];i||(t[n]=i={}),i[o]=!0},It=(t,e,r)=>{let n=e,o=r;if(n>r){n=r,o=e}return!!t[n]},Pt=(t,e,r,n)=>{const o={},i={},a={};return null==e||e.forEach((t=>{null==t||t.forEach(((t,e)=>{o[t]=t,i[t]=t,a[t]=e}))})),null==e||e.forEach((t=>{let e=-1;null==t||t.forEach((t=>{let s=n(t).map((t=>t.id));if(s.length){s=s.sort(((t,e)=>a[t]-a[e]));const n=(s.length-1)/2;for(let u=Math.floor(n),c=Math.ceil(n);u<=c;++u){const n=s[u];i[t]===t&&e{var s;const u={},c=Ct(t,e,r,o,i,a),h=a?"borderLeft":"borderRight",d=(t,e)=>{let r=c.getAllNodes(),n=r.pop();const o={};for(;n;)o[n.id]?t(n.id):(o[n.id]=!0,r.push(n),r=r.concat(e(n.id))),n=r.pop()};return d((t=>{u[t]=(c.getRelatedEdges(t,"in")||[]).reduce(((t,e)=>Math.max(t,(u[e.source]||0)+e.data.weight)),0)}),c.getPredecessors.bind(c)),d((e=>{const r=(c.getRelatedEdges(e,"out")||[]).reduce(((t,e)=>Math.min(t,(u[e.target]||0)-e.data.weight)),Number.POSITIVE_INFINITY),n=t.getNode(e);r!==Number.POSITIVE_INFINITY&&n.data.borderType!==h&&(u[e]=Math.max(u[e],r))}),c.getSuccessors.bind(c)),null===(s=Object.values(n))||void 0===s||s.forEach((t=>{u[t]=u[r[t]]})),u},Ct=(t,e,r,n,o,i)=>{const a=new c,s=qt(n,o,i);return null==e||e.forEach((e=>{let n;null==e||e.forEach((e=>{const o=r[e];if(a.hasNode(o)||a.addNode({id:o,data:{}}),n){const i=r[n],u=a.getRelatedEdges(i,"out").find((t=>t.target===o));u?a.updateEdgeData(u.id,Object.assign(Object.assign({},u.data),{weight:Math.max(s(t,e,n),u.data.weight||0)})):a.addEdge({id:`e${Math.random()}`,source:i,target:o,data:{weight:Math.max(s(t,e,n),0)}})}n=e}))})),a},Dt=(t,e)=>K(Object.values(e),(e=>{var r;let n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return null===(r=Object.keys(e))||void 0===r||r.forEach((r=>{const i=e[r],a=Vt(t,r)/2;n=Math.max(i+a,n),o=Math.min(i-a,o)})),n-o}));function Lt(t,e){const r=Object.values(e),n=Math.min(...r),o=Math.max(...r);["u","d"].forEach((r=>{["l","r"].forEach((i=>{const a=r+i,s=t[a];let u;if(s===e)return;const c=Object.values(s);u="l"===i?n-Math.min(...c):o-Math.max(...c),u&&(t[a]={},Object.keys(s).forEach((e=>{t[a][e]=s[e]+u})))}))}))}const Ft=(t,e)=>{const r={};return Object.keys(t.ul).forEach((n=>{if(e)r[n]=t[e.toLowerCase()][n];else{const e=Object.values(t).map((t=>t[n]));r[n]=(e[0]+e[1])/2}})),r},qt=(t,e,r)=>(n,o,i)=>{const a=n.getNode(o),s=n.getNode(i);let u=0,c=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":c=-a.data.width/2;break;case"r":c=a.data.width/2}if(c&&(u+=r?c:-c),c=0,u+=(a.data.dummy?e:t)/2,u+=(s.data.dummy?e:t)/2,u+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":c=s.data.width/2;break;case"r":c=-s.data.width/2}return c&&(u+=r?c:-c),c=0,u},Vt=(t,e)=>t.getNode(e).data.width||0,Bt=(t,e)=>{var r;const n=G(t);((t,e)=>{const{ranksep:r=0}=e||{},n=$(t);let o=0;null==n||n.forEach((e=>{const n=e.map((e=>t.getNode(e).data.height)),i=Math.max(...n,0);null==e||e.forEach((e=>{t.getNode(e).data.y=o+i/2})),o+=i+r}))})(n,e);const o=((t,e)=>{const{align:r,nodesep:n=0,edgesep:o=0}=e||{},i=$(t),a=Object.assign(Ot(t,i),St(t,i)),s={};let u=[];["u","d"].forEach((e=>{u="u"===e?i:Object.values(i).reverse(),["l","r"].forEach((r=>{"r"===r&&(u=u.map((t=>Object.values(t).reverse())));const i=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),c=Pt(0,u,a,i),h=Tt(t,u,c.root,c.align,n,o,"r"===r);"r"===r&&Object.keys(h).forEach((t=>h[t]=-h[t])),s[e+r]=h}))}));const c=Dt(t,s);return c&&Lt(s,c),Ft(s,r)})(n,e);null===(r=Object.keys(o))||void 0===r||r.forEach((t=>{n.getNode(t).data.x=o[t]}))},Gt=t=>{const e={},r=n=>{var o;const i=t.getNode(n);if(!i)return 0;if(e[n])return i.data.rank;let a;return e[n]=!0,null===(o=t.getRelatedEdges(n,"out"))||void 0===o||o.forEach((t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===a||e0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>r(t.id)))},Ut=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,Wt=(t,e)=>{const r=n=>{e.getRelatedEdges(n,"both").forEach((o=>{const i=o.source,a=n===i?o.target:i;t.hasNode(a)||Ut(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((t=>r(t.id))),t.getAllNodes().length},$t=(t,e)=>{const r=n=>{var o;null===(o=e.getRelatedEdges(n,"both"))||void 0===o||o.forEach((o=>{const i=o.source,a=n===i?o.target:i;t.hasNode(a)||void 0===e.getNode(a).data.layer&&Ut(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((t=>r(t.id))),t.getAllNodes().length},Yt=(t,e)=>K(e.getAllEdges(),(r=>t.hasNode(r.source)!==t.hasNode(r.target)?Ut(e,r):1/0)),Ht=(t,e,r)=>{t.getAllNodes().forEach((t=>{const n=e.getNode(t.id);n.data.rank||(n.data.rank=0),n.data.rank+=r}))},Kt=t=>{const e=(t=>{const e=new c;return t.getAllNodes().forEach((t=>{e.addNode(Object.assign({},t))})),t.getAllEdges().forEach((t=>{const r=e.getRelatedEdges(t.source,"out").find((e=>e.target===t.target));r?e.updateEdgeData(null==r?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})(t);Gt(e);const r=(t=>{const e=new c({tree:[]}),r=t.getAllNodes()[0],n=t.getAllNodes().length;let o,i;for(e.addNode(r);Wt(e,t){let r=Q(t,t.getAllNodes(),"post",!1);r=r.slice(0,(null==r?void 0:r.length)-1),r.forEach((r=>{Qt(t,e,r)}))},Qt=(t,e,r)=>{const n=t.getNode(r).data.parent;t.getRelatedEdges(r,"both").find((t=>t.target===n||t.source===n)).data.cutvalue=Xt(t,e,r)},Xt=(t,e,r)=>{const n=t.getNode(r).data.parent;let o=!0,i=e.getRelatedEdges(r,"out").find((t=>t.target===n)),a=0;return i||(o=!1,i=e.getRelatedEdges(n,"out").find((t=>t.target===r))),a=i.data.weight,e.getRelatedEdges(r,"both").forEach((e=>{const i=e.source===r,s=i?e.target:e.source;if(s!==n){const n=i===o,u=e.data.weight;if(a+=n?u:-u,ie(t,r,s)){const e=t.getRelatedEdges(r,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=n?-e:e}}})),a},Zt=(t,e=t.getAllNodes()[0].id)=>{te(t,{},1,e)},te=(t,e,r,n,o)=>{var i;const a=r;let s=r;const u=t.getNode(n);return e[n]=!0,null===(i=t.getNeighbors(n))||void 0===i||i.forEach((r=>{e[r.id]||(s=te(t,e,s,r.id,n))})),u.data.low=a,u.data.lim=s++,o?u.data.parent=o:delete u.data.parent,s},ee=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),re=(t,e,r)=>{let n=r.source,o=r.target;e.getRelatedEdges(n,"out").find((t=>t.target===o))||(n=r.target,o=r.source);const i=t.getNode(n),a=t.getNode(o);let s=i,u=!1;i.data.lim>a.data.lim&&(s=a,u=!0);const c=e.getAllEdges().filter((e=>u===ae(t.getNode(e.source),s)&&u!==ae(t.getNode(e.target),s)));return K(c,(t=>Ut(e,t)))},ne=(t,e,r,n)=>{const o=t.getRelatedEdges(r.source,"both").find((t=>t.source===r.target||t.target===r.target));o&&t.removeEdge(o.id),t.addEdge({id:`e${Math.random()}`,source:n.source,target:n.target,data:{}}),Zt(t),Jt(t,e),oe(t,e)},oe=(t,e)=>{const r=t.getAllNodes().find((t=>!t.data.parent));let n=Q(t,r,"pre",!1);n=n.slice(1),n.forEach((r=>{const n=t.getNode(r).data.parent;let o=e.getRelatedEdges(r,"out").find((t=>t.target===n)),i=!1;!o&&e.hasNode(n)&&(o=e.getRelatedEdges(n,"out").find((t=>t.target===r)),i=!0),e.getNode(r).data.rank=(e.hasNode(n)&&e.getNode(n).data.rank||0)+(i?null==o?void 0:o.data.minlen:-(null==o?void 0:o.data.minlen))}))},ie=(t,e,r)=>t.getRelatedEdges(e,"both").find((t=>t.source===r||t.target===r)),ae=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,se=Gt,ue=t=>{(t=>{const e={};let r;const n=o=>{var i;const a=t.getNode(o);if(!a)return 0;if(e[o])return a.data.rank;let s;return e[o]=!0,null===(i=t.getRelatedEdges(o,"out"))||void 0===i||i.forEach((t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===s||e0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>{t&&n(t.id)})),void 0===r&&(r=0);const o={},i=(e,r)=>{var n;const a=t.getNode(e),s=isNaN(a.data.layer)?r:a.data.layer;(void 0===a.data.rank||a.data.rank{i(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=r:i(t.id,e.layer))}))})(t),(t=>{const e=new c({tree:[]}),r=t.getAllNodes()[0],n=t.getAllNodes().length;let o,i;for(e.addNode(r);$t(e,t){Kt(t)},he=(t,e)=>{const{acyclicer:r,ranker:n,rankdir:o="tb",nodeOrder:i,keepNodeOrder:a,align:s,nodesep:u=50,edgesep:c=20,ranksep:h=50}=e;je(t),q(t,r);const{nestingRoot:d,nodeRankFactor:f}=(t=>{const e=B(t,"root",{},"_root"),r=at(t);let n=Math.max(...Object.values(r));Math.abs(n)===1/0&&(n=1);const o=n-1,i=2*o+1;t.getAllEdges().forEach((t=>{t.data.minlen*=i}));const a=st(t)+1;return t.getRoots().forEach((n=>{it(t,e,i,a,o,r,n.id)})),{nestingRoot:e,nodeRankFactor:i}})(t);((t,e)=>{switch(e){case"network-simplex":ce(t);break;case"tight-tree":default:ue(t);break;case"longest-path":se(t)}})(G(t),n),xe(t),((t,e=0)=>{const r=t.getAllNodes(),n=r.filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),o=Math.min(...n),i=[];r.forEach((t=>{const e=(t.data.rank||0)-o;i[e]||(i[e]=[]),i[e].push(t.id)}));let a=0;for(let r=0;r{const r=t.getNode(e);r&&(r.data.rank=r.data.rank||0,r.data.rank+=a)})))}})(t,f),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach((e=>{e.data.nestingEdge&&t.removeEdge(e.id)}))})(t,d),(t=>{const e=t.getAllNodes().filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),r=Math.min(...e);t.getAllNodes().forEach((t=>{t.data.hasOwnProperty("rank")&&r!==1/0&&(t.data.rank-=r)}))})(t),be(t),Ee(t);const l=[];((t,e)=>{t.getAllEdges().forEach((r=>ct(t,r,e)))})(t,l),jt(t,l),(t=>{const e=r=>{const n=t.getChildren(r),o=t.getNode(r);if((null==n?void 0:n.length)&&n.forEach((t=>e(t.id))),o.data.hasOwnProperty("minRank")){o.data.borderLeft=[],o.data.borderRight=[];for(let e=o.data.minRank,n=o.data.maxRank+1;ee(t.id)))})(t),a&&((t,e)=>{const r=t.getAllNodes().filter((e=>{var r;return!(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length)})).map((t=>t.data.rank)),n=Math.max(...r),o=[];for(let t=0;t{const r=t.getNode(e);r&&!r.data.dummy&&(isNaN(r.data.rank)||(r.data.fixorder=o[r.data.rank].length,o[r.data.rank].push(e)))}))})(t,i),((t,e)=>{const r=H(t),n=[],o=[];for(let t=1;t-1;t--)o.push(t);const i=_t(t,n,"in"),a=_t(t,o,"out");let s=pt(t);At(t,s);let u,c=Number.POSITIVE_INFINITY;for(let r=0,n=0;n<4;++r,++n){kt(r%2?i:a,r%4>=2,!1,e),s=$(t);const o=vt(t,s);o=2,!0,e),s=$(t);const o=vt(t,s);o{const r=e.toLowerCase();"lr"!==r&&"rl"!==r||Z(t)})(t,o),Bt(t,{align:s,nodesep:u,edgesep:c,ranksep:h}),Se(t),Ae(t),((t,e)=>{e.forEach((e=>{let r=t.getNode(e);const{data:n}=r,o=n.originalEdge;let i;o&&t.addEdge(o);let a=e;for(;r.data.dummy;)i=t.getSuccessors(a)[0],t.removeNode(a),o.data.points.push({x:r.data.x,y:r.data.y}),r.data.dummy===ut&&(o.data.x=r.data.x,o.data.y=r.data.y,o.data.width=r.data.width,o.data.height=r.data.height),a=i.id,r=t.getNode(a)}))})(t,l),_e(t),((t,e)=>{const r=e.toLowerCase();"bt"!==r&&"rl"!==r||et(t),"lr"!==r&&"rl"!==r||(nt(t),Z(t))})(t,o);const{width:g,height:v}=Ne(t);return Me(t),ke(t),(t=>{t.getAllEdges().forEach((e=>{const r=e.data;if(r.reversed){t.removeEdge(e.id);const n=r.forwardName;delete r.reversed,delete r.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},r),{forwardName:n})})}}))})(t),{width:g,height:v}},de=(t,e)=>{t.getAllNodes().forEach((r=>{const n=t.getNode(r.id);if(e.hasNode(r.id)){const t=e.getNode(r.id);n.data.fixorder=t.data._order,delete t.data._order}else delete n.data.fixorder}))},fe=(t,e)=>{t.getAllNodes().forEach((r=>{var n;const o=t.getNode(r.id);if(o){const t=e.getNode(r.id);o.data.x=t.data.x,o.data.y=t.data.y,o.data._order=t.data.order,o.data._rank=t.data.rank,(null===(n=e.getChildren(r.id))||void 0===n?void 0:n.length)&&(o.data.width=t.data.width,o.data.height=t.data.height)}})),t.getAllEdges().forEach((r=>{const n=t.getEdge(r.id),o=e.getEdge(r.id);n.data.points=o?o.data.points:[],o&&o.data.hasOwnProperty("x")&&(n.data.x=o.data.x,n.data.y=o.data.y)}))},le=["width","height","layer","fixorder"],ge={width:0,height:0},ve=["minlen","weight","width","height","labeloffset"],pe={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},ye=["labelpos"],me=t=>{const e=new c({tree:[]});return t.getAllNodes().forEach((r=>{const n=Re(t.getNode(r.id).data),o=Object.assign(Object.assign({},ge),n),i=ze(o,le);e.hasNode(r.id)||e.addNode({id:r.id,data:Object.assign({},i)});const a=t.hasTreeStructure("combo")?t.getParent(r.id,"combo"):t.getParent(r.id);null!=a&&(e.hasNode(a.id)||e.addNode(Object.assign({},a)),e.setParent(r.id,a.id))})),t.getAllEdges().forEach((r=>{const n=Re(t.getEdge(r.id).data),o={};null==ye||ye.forEach((t=>{void 0!==n[t]&&(o[t]=n[t])})),e.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},pe,ze(n,ve),o)})})),e},we=(t,e)=>{const{ranksep:r=0,rankdir:n}=e;return t.getAllNodes().forEach((t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===n||"BT"===n?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),r/2},xe=t=>{t.getAllEdges().forEach((e=>{if(e.data.width&&e.data.height){const r=t.getNode(e.source),n={e:e,rank:(t.getNode(e.target).data.rank-r.data.rank)/2+r.data.rank};B(t,"edge-proxy",n,"_ep")}}))},be=t=>{let e=0;return t.getAllNodes().forEach((r=>{var n,o;r.data.borderTop&&(r.data.minRank=null===(n=t.getNode(r.data.borderTop))||void 0===n?void 0:n.data.rank,r.data.maxRank=null===(o=t.getNode(r.data.borderBottom))||void 0===o?void 0:o.data.rank,e=Math.max(e,r.data.maxRank||-1/0))})),e},Ee=t=>{t.getAllNodes().forEach((e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Ne=(t,e)=>{let r,n,o=0,i=0;const{marginx:a=0,marginy:s=0}=e||{},u=t=>{if(!t.data)return;const e=t.data.x,a=t.data.y,s=t.data.width,u=t.data.height;isNaN(e)||isNaN(s)||(void 0===r&&(r=e-s/2),r=Math.min(r,e-s/2),o=Math.max(o,e+s/2)),isNaN(a)||isNaN(u)||(void 0===n&&(n=a-u/2),n=Math.min(n,a-u/2),i=Math.max(i,a+u/2))};return t.getAllNodes().forEach((t=>{u(t)})),t.getAllEdges().forEach((t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&u(t)})),r-=a,n-=s,t.getAllNodes().forEach((t=>{t.data.x-=r,t.data.y-=n})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>{t.x-=r,t.y-=n})),t.data.hasOwnProperty("x")&&(t.data.x-=r),t.data.hasOwnProperty("y")&&(t.data.y-=n)})),{width:o-r+a,height:i-n+s}},Me=t=>{t.getAllEdges().forEach((e=>{const r=t.getNode(e.source),n=t.getNode(e.target);let o,i;e.data.points?(o=e.data.points[0],i=e.data.points[e.data.points.length-1]):(e.data.points=[],o={x:n.data.x,y:n.data.y},i={x:r.data.x,y:r.data.y}),e.data.points.unshift(W(r.data,o)),e.data.points.push(W(n.data,i))}))},_e=t=>{t.getAllEdges().forEach((t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},ke=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Ae=t=>{t.getAllNodes().forEach((e=>{var r,n,o;if(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length){const r=t.getNode(e.id),i=t.getNode(r.data.borderTop),a=t.getNode(r.data.borderBottom),s=t.getNode(r.data.borderLeft[(null===(n=r.data.borderLeft)||void 0===n?void 0:n.length)-1]),u=t.getNode(r.data.borderRight[(null===(o=r.data.borderRight)||void 0===o?void 0:o.length)-1]);r.data.width=Math.abs((null==u?void 0:u.data.x)-(null==s?void 0:s.data.x))||10,r.data.height=Math.abs((null==a?void 0:a.data.y)-(null==i?void 0:i.data.y))||10,r.data.x=((null==s?void 0:s.data.x)||0)+r.data.width/2,r.data.y=((null==i?void 0:i.data.y)||0)+r.data.height/2}})),t.getAllNodes().forEach((e=>{"border"===e.data.dummy&&t.removeNode(e.id)}))},je=t=>{t.getAllEdges().forEach((e=>{if(e.source===e.target){const r=t.getNode(e.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(e),t.removeEdge(e.id)}}))},Oe=t=>{const e=$(t);null==e||e.forEach((e=>{let r=0;null==e||e.forEach(((e,n)=>{var o;const i=t.getNode(e);i.data.order=n+r,null===(o=i.data.selfEdges)||void 0===o||o.forEach((e=>{B(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e:e},"_se")})),delete i.data.selfEdges}))}))},Se=t=>{t.getAllNodes().forEach((e=>{const r=t.getNode(e.id);if("selfedge"===r.data.dummy){const n=t.getNode(r.data.e.source),o=n.data.x+n.data.width/2,i=n.data.y,a=r.data.x-o,s=n.data.height/2;t.hasEdge(r.data.e.id)?t.updateEdgeData(r.data.e.id,r.data.e.data):t.addEdge({id:r.data.e.id,source:r.data.e.source,target:r.data.e.target,data:r.data.e.data}),t.removeNode(e.id),r.data.e.data.points=[{x:o+2*a/3,y:i-s},{x:o+5*a/6,y:i-s},{y:i,x:o+a},{x:o+5*a/6,y:i+s},{x:o+2*a/3,y:i+s}],r.data.e.data.x=r.data.x,r.data.e.data.y=r.data.y}}))},ze=(t,e)=>{const r={};return null==e||e.forEach((e=>{void 0!==t[e]&&(r[e]=+t[e])})),r},Re=(t={})=>{const e={};return Object.keys(t).forEach((r=>{e[r.toLowerCase()]=t[r]})),e};function Ie(t){return"function"==typeof t}var Pe=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function Te(t){if(!t)return[0,0,0];if(S(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,r=e,n=e]=t;return[e,r,n]}function Ce(t,e){let r;return r=Ie(e)?e:S(e)?()=>e:()=>t,r}function De(t,e,r=!0){return e||0===e?Ie(e)?e:S(e)?()=>e:Array.isArray(e)?()=>r?Math.max(...e)||t:e:Pe(e)&&e.width&&e.height?()=>r?Math.max(e.width,e.height)||t:[e.width,e.height]:()=>t:e=>{const{size:n}=e.data||{};return n?Array.isArray(n)?r?Math.max(...n)||t:n:Pe(n)&&n.width&&n.height?r?Math.max(n.width,n.height)||t:[n.width,n.height]:n:t}}const Le=(t,e,r=10)=>{let n;const o="function"==typeof e?e:()=>e||0;n=t?Array.isArray(t)?e=>t:Ie(t)?t:e=>t:t=>{var e,n,o;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return null===(n=t.data)||void 0===n?void 0:n.bboxSize;if(null===(o=t.data)||void 0===o?void 0:o.size){const e=t.data.size;return Array.isArray(e)?e:Pe(e)?[e.width,e.height]:e}return r};return t=>{const e=n(t),r=o(t);return Math.max(...Te(e))+r}},Fe=t=>{if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){const e=[];return t.forEach((t=>{e.push(t)})),e.map((t=>Fe(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((r=>{e[r]=Fe(t[r])})),e}return t},qe=(t,e)=>{const r=Fe(t);return r.data=r.data||{},e&&(S(r.data.x)||(r.data.x=Math.random()*e[0]),S(r.data.y)||(r.data.y=Math.random()*e[1])),r},Ve={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};const Be=(t,e,r,n,o,i,a)=>{let s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&r){let{x:t,y:u}=e.data,{x:c,y:h}=r.data;if(o&&(t=e.data.y,u=e.data.x,c=r.data.y,h=r.data.x),h!==u&&t!==c){const d=n.indexOf(u),f=n[d+1];if(f){const t=s[0],e=o?{x:(u+f)/2,y:(null==t?void 0:t.y)||c}:{x:(null==t?void 0:t.x)||c,y:(u+f)/2};t&&!i(t,e)||s.unshift(e)}const l=n.indexOf(h),g=Math.abs(l-d);if(1===g)s=a(s,e.data,r.data),s.length||s.push(o?{x:(u+h)/2,y:t}:{x:t,y:(u+h)/2});else if(g>1){const e=n[l-1];if(e){const r=s[s.length-1],n=o?{x:(h+e)/2,y:(null==r?void 0:r.y)||c}:{x:(null==r?void 0:r.x)||t,y:(h+e)/2};r&&!i(r,n)||s.push(n)}}}}return s},Ge=(t,e,r)=>{const n=t.getAllNodes(),o=t.getAllEdges();if(!(null==n?void 0:n.length)){return{nodes:[],edges:o}}if(1===n.length){e&&t.mergeNodeData(n[0].id,{x:r[0],y:r[1]});return{nodes:[Object.assign(Object.assign({},n[0]),{data:Object.assign(Object.assign({},n[0].data),{x:r[0],y:r[1]})})],edges:o}}},Ue={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};const We=(t,e,r=!1)=>{const n=[qe(e[0])],o={},i=e.length;o[e[0].id]=!0;let a=0;return e.forEach(((s,u)=>{if(0!==u)if(u!==i-1&&t.getDegree(s.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[a].id,s.id)||o[s.id]){const u=r?t.getSuccessors(n[a].id):t.getNeighbors(n[a].id);let c=!1;for(let e=0;e{let n=t,o=e,i=r;return n||"undefined"==typeof window||(n=window.innerWidth),o||"undefined"==typeof window||(o=window.innerHeight),i||(i=[n/2,o/2]),[n,o,i]};function Ye(t){return"string"==typeof t}const He=Array.isArray,Ke={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class Je{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},Ke),t)}execute(t,r){return e(this,void 0,void 0,(function*(){return this.genericConcentricLayout(!1,t,r)}))}assign(t,r){return e(this,void 0,void 0,(function*(){yield this.genericConcentricLayout(!0,t,r)}))}genericConcentricLayout(t,r,n){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},this.options),n),{center:o,width:i,height:a,sortBy:s,maxLevelDiff:u,sweep:c,clockwise:h,equidistant:d,preventOverlap:f,startAngle:l=1.5*Math.PI,nodeSize:g,nodeSpacing:v}=e,p=r.getAllNodes(),y=r.getAllEdges(),m=i||"undefined"==typeof window?i:window.innerWidth,w=a||"undefined"==typeof window?a:window.innerHeight,x=o||[m/2,w/2];if(!(null==p?void 0:p.length)||1===p.length)return Ge(r,t,x);const b=[];let E,N=0;He(g)?E=Math.max(g[0],g[1]):Ie(g)?(E=-1/0,p.forEach((t=>{const e=Math.max(...Te(g(t)));e>E&&(E=e)}))):E=g,He(v)?N=Math.max(v[0],v[1]):S(v)&&(N=v),p.forEach((t=>{const e=qe(t);b.push(e);let r=E;const{data:n}=e;He(n.size)?r=Math.max(n.size[0],n.size[1]):S(n.size)?r=n.size:Pe(n.size)&&(r=Math.max(n.size.width,n.size.height)),E=Math.max(E,r),Ie(v)&&(N=Math.max(v(t),N))}));const M={};b.forEach(((t,e)=>{M[t.id]=e}));let _=s;Ye(_)&&void 0!==b[0].data[_]||(_="degree"),"degree"===_?b.sort(((t,e)=>r.getDegree(e.id,"both")-r.getDegree(t.id,"both"))):b.sort(((t,e)=>e.data[_]-t.data[_]));const k=b[0],A=(u||("degree"===_?r.getDegree(k.id,"both"):k.data[_]))/4,j=[{nodes:[]}];let O=j[0];b.forEach((t=>{if(O.nodes.length>0){const e="degree"===_?Math.abs(r.getDegree(O.nodes[0].id,"both")-r.getDegree(t.id,"both")):Math.abs(O.nodes[0].data[_]-t.data[_]);A&&e>=A&&(O={nodes:[]},j.push(O))}O.nodes.push(t)}));let z=E+N;if(!f){const t=j.length>0&&j[0].nodes.length>1,e=(Math.min(m,w)/2-z)/(j.length+(t?1:0));z=Math.min(z,e)}let R=0;if(j.forEach((t=>{const e=void 0===c?2*Math.PI-2*Math.PI/t.nodes.length:c;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&f){const e=Math.cos(t.dTheta)-Math.cos(0),r=Math.sin(t.dTheta)-Math.sin(0),n=Math.sqrt(z*z/(e*e+r*r));R=Math.max(n,R)}t.r=R,R+=z})),d){let t=0,e=0;for(let r=0;r{0===n&&(e=r.r||0),r.r=e,e+=t}))}j.forEach((t=>{const e=t.dTheta||0,r=t.r||0;t.nodes.forEach(((t,n)=>{const o=l+(h?1:-1)*e*n;t.data.x=x[0]+r*Math.cos(o),t.data.y=x[1]+r*Math.sin(o)}))})),t&&b.forEach((t=>r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:b,edges:y}}))}}function Qe(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,a,s,u,c,h,d,f,l=t._root,g={data:n},v=t._x0,p=t._y0,y=t._x1,m=t._y1;if(!l)return t._root=g,t;for(;l.length;)if((c=e>=(i=(v+y)/2))?v=i:y=i,(h=r>=(a=(p+m)/2))?p=a:m=a,o=l,!(l=l[d=h<<1|c]))return o[d]=g,t;if(s=+t._x.call(null,l.data),u=+t._y.call(null,l.data),e===s&&r===u)return g.next=l,o?o[d]=g:t._root=g,t;do{o=o?o[d]=new Array(4):t._root=new Array(4),(c=e>=(i=(v+y)/2))?v=i:y=i,(h=r>=(a=(p+m)/2))?p=a:m=a}while((d=h<<1|c)==(f=(u>=a)<<1|s>=i));return o[f]=l,o[d]=g,t}function Xe(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function Ze(t){return t[0]}function tr(t){return t[1]}function er(t,e,r){var n=new rr(null==e?Ze:e,null==r?tr:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function rr(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function nr(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var or=er.prototype=rr.prototype;function ir(t,e,r,n,o){if(isNaN(e)||isNaN(r)||isNaN(n))return t;var i,a,s,u,c,h,d,f,l,g,v,p,y=t._root,m={data:o},w=t._x0,x=t._y0,b=t._z0,E=t._x1,N=t._y1,M=t._z1;if(!y)return t._root=m,t;for(;y.length;)if((f=e>=(a=(w+E)/2))?w=a:E=a,(l=r>=(s=(x+N)/2))?x=s:N=s,(g=n>=(u=(b+M)/2))?b=u:M=u,i=y,!(y=y[v=g<<2|l<<1|f]))return i[v]=m,t;if(c=+t._x.call(null,y.data),h=+t._y.call(null,y.data),d=+t._z.call(null,y.data),e===c&&r===h&&n===d)return m.next=y,i?i[v]=m:t._root=m,t;do{i=i?i[v]=new Array(8):t._root=new Array(8),(f=e>=(a=(w+E)/2))?w=a:E=a,(l=r>=(s=(x+N)/2))?x=s:N=s,(g=n>=(u=(b+M)/2))?b=u:M=u}while((v=g<<2|l<<1|f)==(p=(d>=u)<<2|(h>=s)<<1|c>=a));return i[p]=y,i[v]=m,t}function ar(t,e,r,n,o,i,a){this.node=t,this.x0=e,this.y0=r,this.z0=n,this.x1=o,this.y1=i,this.z1=a}or.copy=function(){var t,e,r=new rr(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=nr(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=nr(e));return r},or.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return Qe(this.cover(e,r),e,r,t)},or.addAll=function(t){var e,r,n,o,i=t.length,a=new Array(i),s=new Array(i),u=1/0,c=1/0,h=-1/0,d=-1/0;for(r=0;rh&&(h=n),od&&(d=o));if(u>h||c>d)return this;for(this.cover(u,c).cover(h,d),r=0;rt||t>=o||n>e||e>=i;)switch(s=(ef||(i=u.y0)>l||(a=u.x1)=y)<<1|t>=p)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-c],g[g.length-1-c]=u)}else{var m=t-+this._x.call(null,v.data),w=e-+this._y.call(null,v.data),x=m*m+w*w;if(x=(s=(g+p)/2))?g=s:p=s,(h=a>=(u=(v+y)/2))?v=u:y=u,e=l,!(l=l[d=h<<1|c]))return this;if(!l.length)break;(e[d+1&3]||e[d+2&3]||e[d+3&3])&&(r=e,f=d)}for(;l.data!==t;)if(n=l,!(l=l.next))return this;return(o=l.next)&&delete l.next,n?(o?n.next=o:delete n.next,this):e?(o?e[d]=o:delete e[d],(l=e[0]||e[1]||e[2]||e[3])&&l===(e[3]||e[2]||e[1]||e[0])&&!l.length&&(r?r[f]=l:this._root=l),this):(this._root=o,this)},or.removeAll=function(t){for(var e=0,r=t.length;eMath.sqrt((t-n)**2+(e-o)**2+(r-i)**2);function ur(t){return t[0]}function cr(t){return t[1]}function hr(t){return t[2]}function dr(t,e,r,n){var o=new fr(null==e?ur:e,null==r?cr:r,null==n?hr:n,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?o:o.addAll(t)}function fr(t,e,r,n,o,i,a,s,u){this._x=t,this._y=e,this._z=r,this._x0=n,this._y0=o,this._z0=i,this._x1=a,this._y1=s,this._z1=u,this._root=void 0}function lr(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var gr=dr.prototype=fr.prototype;gr.copy=function(){var t,e,r=new fr(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),n=this._root;if(!n)return r;if(!n.length)return r._root=lr(n),r;for(t=[{source:n,target:r._root=new Array(8)}];n=t.pop();)for(var o=0;o<8;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(8)}):n.target[o]=lr(e));return r},gr.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t),n=+this._z.call(null,t);return ir(this.cover(e,r,n),e,r,n,t)},gr.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,r=new Float64Array(e),n=new Float64Array(e),o=new Float64Array(e);let i=1/0,a=1/0,s=1/0,u=-1/0,c=-1/0,h=-1/0;for(let d,f,l,g,v=0;vu&&(u=f),lc&&(c=l),gh&&(h=g));if(i>u||a>c||s>h)return this;this.cover(i,a,s).cover(u,c,h);for(let i=0;it||t>=a||o>e||e>=s||i>r||r>=u;)switch(h=(rp||(a=d.y0)>y||(s=d.z0)>m||(u=d.x1)=N)<<2|(e>=E)<<1|t>=b)&&(d=w[w.length-1],w[w.length-1]=w[w.length-1-f],w[w.length-1-f]=d)}else{var M=t-+this._x.call(null,x.data),_=e-+this._y.call(null,x.data),k=r-+this._z.call(null,x.data),A=M*M+_*_+k*k;if(A{if(!d.length)do{const i=d.data;sr(t,e,r,this._x(i),this._y(i),this._z(i))<=n&&o.push(i)}while(d=d.next);return f>u||l>c||g>h||v=(u=(y+x)/2))?y=u:x=u,(f=a>=(c=(m+b)/2))?m=c:b=c,(l=s>=(h=(w+E)/2))?w=h:E=h,e=p,!(p=p[g=l<<2|f<<1|d]))return this;if(!p.length)break;(e[g+1&7]||e[g+2&7]||e[g+3&7]||e[g+4&7]||e[g+5&7]||e[g+6&7]||e[g+7&7])&&(r=e,v=g)}for(;p.data!==t;)if(n=p,!(p=p.next))return this;return(o=p.next)&&delete p.next,n?(o?n.next=o:delete n.next,this):e?(o?e[g]=o:delete e[g],(p=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&p===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!p.length&&(r?r[v]=p:this._root=p),this):(this._root=o,this)},gr.removeAll=function(t){for(var e=0,r=t.length;e{const{nodeStrength:r,x:n,y:o,z:a,size:s}=t.data;return{x:n,y:o,z:a,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:i*r}})),u=(2===o?er(s,(t=>t.x),(t=>t.y)):dr(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(yr),c=new Map;return s.forEach((t=>{c.set(t.id,t),function(t,e,r){e.visit(((e,n,o,i,a)=>((t,e,r,n,o,i,a)=>{var s;if((null===(s=t.data)||void 0===s?void 0:s.id)===i.id)return;const u=[r,n,o][a-1],c=i.x-t.x||vr,h=i.y-t.y||vr,d=i.z-t.z||vr,f=[c,h,d],l=u-e;let g=0;for(let t=0;t{const{id:r,data:o}=a[e],{mass:i=1}=o;n[r]={x:t.vx/i,y:t.vy/i,z:t.vz/i}})),n}function yr(t){let e=0,r=0,n=0,o=0,i=0;const a=t.length;if(a){for(let s=0;sthis.lastOptions.minMovement||e<1)&&ethis.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericForceLayout(t,r,n){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},this.options),n),o=r.getAllNodes(),i=r.getAllEdges(),a=this.formatOptions(e,r),{dimensions:s,width:u,height:h,nodeSize:d,getMass:f,nodeStrength:l,edgeStrength:g,linkDistance:v}=a,p=o.map(((t,e)=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{x:S(t.data.x)?t.data.x:Math.random()*u,y:S(t.data.y)?t.data.y:Math.random()*h,z:S(t.data.z)?t.data.z:Math.random()*Math.sqrt(u*h),size:d(t)||30,mass:f(t),nodeStrength:l(t)})}))),y=i.map((t=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{edgeStrength:g(t),linkDistance:v(t,r.getNode(t.source),r.getNode(t.target))})})));if(!(null==o?void 0:o.length))return this.lastResult={nodes:[],edges:i},{nodes:[],edges:i};const m={};o.forEach(((t,e)=>{m[t.id]={x:0,y:0,z:0}}));const w=new c({nodes:p,edges:y});this.formatCentripetal(a,w);const{maxIteration:x,minMovement:b,onTick:E}=a;if(this.lastLayoutNodes=p,this.lastLayoutEdges=y,this.lastAssign=t,this.lastGraph=r,this.lastCalcGraph=w,this.lastOptions=a,this.lastVelMap=m,"undefined"==typeof window)return;let N=0;return new Promise((e=>{this.timeInterval=window.setInterval((()=>{o&&this.running||e({nodes:Mr(r,p),edges:i}),this.runOneStep(w,r,N,m,a),this.updatePosition(r,w,m,a),t&&p.forEach((t=>r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===s?t.data.z:void 0}))),null==E||E({nodes:Mr(r,p),edges:i}),N++,(N>=x||this.judgingDistance{let r=1;S(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);const n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r}),r.nodeSize=Le(t.nodeSize,t.nodeSpacing);const a=t.linkDistance?Ce(1,t.linkDistance):t=>1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target));return r.linkDistance=a,r.nodeStrength=Ce(1,t.nodeStrength),r.edgeStrength=Ce(1,t.edgeStrength),r}formatCentripetal(t,e){const{dimensions:r,centripetalOptions:n,center:o,clusterNodeStrength:i,leafCluster:a,clustering:s,nodeClusterBy:u}=t,c=e.getAllNodes(),h=n||{leaf:2,single:2,others:1,center:t=>({x:o[0],y:o[1],z:3===r?o[2]:void 0})};let d,f;if("function"!=typeof i&&(t.clusterNodeStrength=t=>i),a&&u&&(d=xr(e,u),f=Array.from(new Set(null==c?void 0:c.map((t=>t.data[u]))))||[],t.centripetalOptions=Object.assign(h,{single:100,leaf:e=>{const{siblingLeaves:r,sameTypeLeaves:n}=d[e.id]||{};return(null==n?void 0:n.length)===(null==r?void 0:r.length)||1===(null==f?void 0:f.length)?1:t.clusterNodeStrength(e)},others:1,center:t=>{const r=e.getDegree(t.id,"both");if(!r)return{x:100,y:100,z:0};let n;if(1===r){const{sameTypeLeaves:e=[]}=d[t.id]||{};1===e.length?n=void 0:e.length>1&&(n=Nr(e))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y,z:null==n?void 0:n.z}}})),s&&u){d||(d=xr(e,u)),f||(f=Array.from(new Set(c.map((t=>t.data[u]))))),f=f.filter((t=>void 0!==t));const r={};f.forEach((t=>{const n=c.filter((e=>e.data[u]===t)).map((t=>e.getNode(t.id)));r[t]=Nr(n)})),t.centripetalOptions=Object.assign(h,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=r[t.data[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}const{leaf:l,single:g,others:v}=t.centripetalOptions||{};l&&"function"!=typeof l&&(t.centripetalOptions.leaf=()=>l),g&&"function"!=typeof g&&(t.centripetalOptions.single=()=>g),v&&"function"!=typeof v&&(t.centripetalOptions.others=()=>v)}runOneStep(t,e,r,n,o){const i={},a=t.getAllNodes(),s=t.getAllEdges();if(!(null==a?void 0:a.length))return;const{monitor:u}=o;if(this.calRepulsive(t,i,o),s&&this.calAttractive(t,i,o),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u){u({energy:this.calTotalEnergy(i,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}}calTotalEnergy(t,e){if(!(null==e?void 0:e.length))return 0;let r=0;return e.forEach(((e,n)=>{const o=t[e.id].x,i=t[e.id].y,a=3===this.options.dimensions?t[e.id].z:0,s=o*o+i*i+a*a,{mass:u=1}=e.data;r+=u*s*.5})),r}calRepulsive(t,e,r){const{dimensions:n,factor:o,coulombDisScale:i}=r;pr(t,o,i*i,e,n)}calAttractive(t,e,r){const{dimensions:n,nodeSize:o}=r;t.getAllEdges().forEach(((r,i)=>{const{source:a,target:s}=r,u=t.getNode(a),c=t.getNode(s);if(!u||!c)return;let h=c.data.x-u.data.x,d=c.data.y-u.data.y,f=3===n?c.data.z-u.data.z:0;h||d||(h=.01*Math.random(),d=.01*Math.random(),3!==n||f||(f=.01*Math.random()));const l=Math.sqrt(h*h+d*d+f*f);if(l{const{id:i,data:l}=n,{mass:g,x:v,y:p,z:y}=l,m=e.getNode(i);let w=0,x=0,b=0,E=d;const N=t.getDegree(i,"in"),M=t.getDegree(i,"out"),_=t.getDegree(i,"both"),k=null==o?void 0:o(m,_);if(k){const[t,e,r]=k;w=v-t,x=p-e,E=r}else w=v-h[0],x=p-h[1],b=y-h[2];if(E&&(r[i].x-=E*w/g,r[i].y-=E*x/g,r[i].z-=E*b/g),f){const{leaf:t,single:e,others:n,center:o}=f,{x:h,y:d,z:l,centerStrength:w}=(null==o?void 0:o(m,a,s,u,c))||{x:0,y:0,z:0,centerStrength:0};if(!S(h)||!S(d))return;const x=(v-h)/g,b=(p-d)/g,E=(y-l)/g;if(w&&(r[i].x-=w*x,r[i].y-=w*b,r[i].z-=w*E),0===_){const t=e(m);if(!t)return;return r[i].x-=t*x,r[i].y-=t*b,void(r[i].z-=t*E)}if(0===N||0===M){const e=t(m,a,s);if(!e)return;return r[i].x-=e*x,r[i].y-=e*b,void(r[i].z-=e*E)}const k=n(m);if(!k)return;r[i].x-=k*x,r[i].y-=k*b,r[i].z-=k*E}}))}updateVelocity(t,e,r,n){const{damping:o,maxSpeed:i,interval:a,dimensions:s}=n,u=t.getAllNodes();(null==u?void 0:u.length)&&u.forEach((t=>{const{id:n}=t;let u=(r[n].x+e[n].x*a)*o||.01,c=(r[n].y+e[n].y*a)*o||.01,h=3===s?(r[n].z+e[n].z*a)*o||.01:0;const d=Math.sqrt(u*u+c*c+h*h);if(d>i){const t=i/d;u*=t,c*=t,h*=t}r[n]={x:u,y:c,z:h}}))}updatePosition(t,e,r,n){const{distanceThresholdMode:o,interval:i,dimensions:a}=n,s=e.getAllNodes();if(!(null==s?void 0:s.length))return void(this.judgingDistance=0);let u=0;"max"===o?this.judgingDistance=-1/0:"min"===o&&(this.judgingDistance=1/0),s.forEach((n=>{const{id:s}=n,c=t.getNode(s);if(S(c.data.fx)&&S(c.data.fy))return void e.mergeNodeData(s,{x:c.data.fx,y:c.data.fy,z:3===a?c.data.fz:void 0});const h=r[s].x*i,d=r[s].y*i,f=3===a?r[s].z*i:0;e.mergeNodeData(s,{x:n.data.x+h,y:n.data.y+d,z:n.data.z+f});const l=Math.sqrt(h*h+d*d+f*f);switch(o){case"max":this.judgingDistancel&&(this.judgingDistance=l);break;default:u+=l}})),o&&"mean"!==o||(this.judgingDistance=u/s.length)}}const xr=(t,e)=>{const r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};const n={};return r.forEach(((r,o)=>{1===t.getDegree(r.id,"both")&&(n[r.id]=br(t,"leaf",r,e))})),n},br=(t,e,r,n)=>{const o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out");let a=r,s=[];0===o?(a=t.getSuccessors(r.id)[0],s=t.getNeighbors(a.id)):0===i&&(a=t.getPredecessors(r.id)[0],s=t.getNeighbors(a.id)),s=s.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")));return{coreNode:a,siblingLeaves:s,sameTypeLeaves:Er(t,e,n,r,s)}},Er=(t,e,r,n,o)=>{const i=n.data[r]||"";let a=(null==o?void 0:o.filter((t=>t.data[r]===i)))||[];return"leaf"===e&&(a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")))),a},Nr=t=>{const e={x:0,y:0};t.forEach((t=>{const{x:r,y:n}=t.data;e.x+=r||0,e.y+=n||0}));const r=t.length||1;return{x:e.x/r,y:e.y/r}},Mr=(t,e)=>e.map((e=>{const{id:r,data:n}=e,o=t.getNode(r);return Object.assign(Object.assign({},o),{data:Object.assign(Object.assign({},o.data),{x:n.x,y:n.y,z:n.z})})}));var _r=r(92861),kr=(_r.XA,_r.a_,_r.yQ,_r.Hs,_r.Ec,_r.dx,_r.LU,_r.Rm,_r.y3),Ar=(_r.qK,_r.pb,_r.j,_r.sO,_r.BZ,_r.EK,_r.Db,_r.Fx,_r.tU,_r.Ym,_r.rs,_r.QR,_r.TB,_r.oH,_r.Sc);_r.BN,_r.it,_r.$r,_r.QM,_r.AV,_r.y3,_r.y3,_r.GH,_r.SO,_r.uZ,_r.yU,_r.F1,_r.re;const jr=t=>{const e=[],r=t.length;for(let n=0;ne[n][t]+e[t][o]&&(e[n][o]=e[n][t]+e[t][o]);return e},Or=(t,e)=>{const{nodes:r,edges:n}=t,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach(((t,e)=>{i[t.id]=e;o.push([])})),null==n||n.forEach((t=>{const{source:r,target:n}=t,a=i[r],s=i[n];void 0!==a&&void 0!==s&&(o[a][s]=1,e||(o[s][a]=1))})),o},Sr=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),zr=(t,e,r,n="TB",o,i={})=>{if(!(null==e?void 0:e.length))return;const{stopBranchFn:a,stopAllFn:s}=i;for(let u=0;u{const r=[];return t.forEach((t=>{const n=[];t.forEach((t=>{n.push(t*e)})),r.push(n)})),r})(c,i),d=Tr(h),f=[];d.forEach(((t,e)=>{const r=qe(a[e]);r.data.x=t[0]+o[0],r.data.y=t[1]+o[1],f.push(r)})),t&&f.forEach((t=>r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:f,edges:s}}))}}const Pr=t=>{let e=-999999;t.forEach((t=>{t.forEach((t=>{t!==1/0&&e{r.forEach(((r,o)=>{r===1/0&&(t[n][o]=e)}))}))},Tr=t=>{const e=kr.mul(kr.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);const i=new Ar(e),a=kr.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((t=>kr.mul([t],[a]).toJSON()[0].splice(0,2)))};function Cr(t){return!!t.tick&&!!t.stop}const Dr={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Lr={center:[0,0],comboPadding:10,treeKey:"combo"};function Fr(t,r,n,o){var i;return e(this,void 0,void 0,(function*(){return Cr(t)?(t.execute(r,n),t.stop(),t.tick(null!==(i=n.iterations)&&void 0!==i?i:300)):o?yield t.assign(r,n):yield t.execute(r,n)}))}var qr=function(t){return"object"==typeof t&&null!==t},Vr={}.toString,Br=function(t,e){return Vr.call(t)==="[object "+e+"]"},Gr=function(t){if(!qr(t)||!Br(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};function Ur(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function Wr(t,e,r,n){for(var o in r=r||0,n=n||5,e)if(Ur(e,o)){var i=e[o];null!==i&&Gr(i)?(Gr(t[o])||(t[o]={}),r[s(t,e,n),t])));for(a=0,o=new Array(c);a=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}}))}function an(t,e){for(var r,n=0,o=t.length;n0)for(var r,n,o=new Array(r),i=0;i=0&&e._call.call(void 0,t),e=e._next;--dn}()}finally{dn=0,function(){var t,e,r=un,n=1/0;for(;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:un=e);cn=t,_n(n)}(),vn=0}}function Mn(){var t=yn.now(),e=t-gn;e>1e3&&(pn-=e,gn=t)}function _n(t){dn||(fn&&(fn=clearTimeout(fn)),t-vn>24?(t<1/0&&(fn=setTimeout(Nn,t-yn.now()-pn)),ln&&(ln=clearInterval(ln))):(ln||(gn=yn.now(),ln=setInterval(Mn,1e3)),dn=1,mn(Nn)))}bn.prototype=En.prototype={constructor:bn,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?wn():+r)+(null==e?0:+e),this._next||cn===this||(cn?cn._next=this:un=this,cn=this),this._call=t,this._time=r,_n()},stop:function(){this._call&&(this._call=null,this._time=1/0,_n())}};const kn=4294967296;function An(t){return t.x}function jn(t){return t.y}var On=Math.PI*(3-Math.sqrt(5));function Sn(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,a=.6,s=new Map,u=En(d),c=hn("tick","end"),h=function(){let t=1;return()=>(t=(1664525*t+1013904223)%kn)/kn}();function d(){f(),c.call("tick",e),r1?(null==r?s.delete(t):s.set(t,g(r)),e):s.get(t)},find:function(e,r,n){var o,i,a,s,u,c=0,h=t.length;for(null==n?n=1/0:n*=n,c=0;c1?(c.on(t,r),e):c.on(t)}}}function zn(){var t,e,r,n,o,i=Jr(-30),a=1,s=1/0,u=.81;function c(r){var o,i=t.length,a=er(t,An,jn).visitAfter(d);for(n=r,o=0;o=s)){(t.data!==e||t.next)&&(0===d&&(g+=(d=Qr(r))*d),0===f&&(g+=(f=Qr(r))*f),gc+g||ih+g||au.index){var v=c-s.x-s.vx,p=h-s.y-s.vy,y=v*v+p*p;yt.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;nt.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},$r(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,r){return e(this,void 0,void 0,(function*(){return this.genericLayout(!1,t,r)}))}assign(t,r){return e(this,void 0,void 0,(function*(){yield this.genericLayout(!0,t,r)}))}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const r=this.context.nodes.find((e=>e.id===t));r&&e.forEach(((t,e)=>{if("number"==typeof t||null===t){r[["fx","fy","fz"][e]]=t}}))}getOptions(t){var e,r;const n=$r({},this.options,t);return n.collide&&void 0===(null===(e=n.collide)||void 0===e?void 0:e.radius)&&(n.collide=n.collide||{},n.collide.radius=null!==(r=n.nodeSize)&&void 0!==r?r:10),void 0===n.iterations&&(n.link&&void 0===n.link.iterations&&(n.iterations=n.link.iterations),n.collide&&void 0===n.collide.iterations&&(n.iterations=n.collide.iterations)),this.context.options=n,n}genericLayout(t,r,n){var o;return e(this,void 0,void 0,(function*(){const e=this.getOptions(n),i=r.getAllNodes().map((({id:t,data:e})=>Object.assign(Object.assign({id:t},e),Kr(e.data,this.config.inputNodeAttrs)))),a=r.getAllEdges().map((t=>Object.assign({},t)));Object.assign(this.context,{assign:t,nodes:i,edges:a,graph:r});const s=new Promise((t=>{this.resolver=t})),u=this.setSimulation(e);return u.nodes(i),null===(o=u.force("link"))||void 0===o||o.links(a),s}))}getResult(){const{assign:t,nodes:e,edges:r,graph:n}=this.context,o=e.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),Kr(t,this.config.outputNodeAttrs))}))),i=r.map((({id:t,source:e,target:r,data:n})=>({id:t,source:"object"==typeof e?e.id:e,target:"object"==typeof r?r.id:r,data:n})));return t&&o.forEach((t=>n.mergeNodeData(t.id,t.data))),{nodes:o,edges:i}}initSimulation(){return Sn()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",(()=>{var e;return null===(e=t.onTick)||void 0===e?void 0:e.call(t,this.getResult())})).on("end",(()=>{var t;return null===(t=this.resolver)||void 0===t?void 0:t.call(this,this.getResult())}))),qn(e,this.config.simulationAttrs.map((e=>[e,t[e]]))),Object.entries(this.forceMap).forEach((([r,n])=>{const o=r;if(t[r]){let r=e.force(o);r||(r=n(),e.force(o,r)),qn(r,Object.entries(t[o]))}else e.force(o,null)})),e}}const qn=(t,e)=>e.reduce(((e,[r,n])=>e[r]&&void 0!==n?e[r].call(t,n):e),t);function Vn(t){return function(){return t}}function Bn(t){return 1e-6*(t()-.5)}function Gn(t){return t.index}function Un(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Wn(t){var e,r,n,o,i,a,s,u=Gn,c=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},h=Vn(30),d=1;function f(n){for(var i=0,u=t.length;i1&&(y=f.y+f.vy-h.y-h.vy||Bn(s)),o>2&&(m=f.z+f.vz-h.z-h.vz||Bn(s)),p*=l=((l=Math.sqrt(p*p+y*y+m*m))-r[v])/l*n*e[v],y*=l,m*=l,f.vx-=p*(g=a[v]),o>1&&(f.vy-=y*g),o>2&&(f.vz-=m*g),h.vx+=p*(g=1-g),o>1&&(h.vy+=y*g),o>2&&(h.vz+=m*g)}function l(){if(n){var o,s,c=n.length,h=t.length,d=new Map(n.map(((t,e)=>[u(t,e,n),t])));for(o=0,i=new Array(c);o"function"==typeof t))||Math.random,o=e.find((t=>[1,2,3].includes(t)))||2,l()},f.links=function(e){return arguments.length?(t=e,l(),f):t},f.id=function(t){return arguments.length?(u=t,f):u},f.iterations=function(t){return arguments.length?(d=+t,f):d},f.strength=function(t){return arguments.length?(c="function"==typeof t?t:Vn(+t),g(),f):c},f.distance=function(t){return arguments.length?(h="function"==typeof t?t:Vn(+t),v(),f):h},f}function $n(t,e,r){if(isNaN(e))return t;var n,o,i,a,s,u,c=t._root,h={data:r},d=t._x0,f=t._x1;if(!c)return t._root=h,t;for(;c.length;)if((a=e>=(o=(d+f)/2))?d=o:f=o,n=c,!(c=c[s=+a]))return n[s]=h,t;if(e===(i=+t._x.call(null,c.data)))return h.next=c,n?n[s]=h:t._root=h,t;do{n=n?n[s]=new Array(2):t._root=new Array(2),(a=e>=(o=(d+f)/2))?d=o:f=o}while((s=+a)==(u=+(i>=o)));return n[u]=c,n[s]=h,t}function Yn(t,e,r){this.node=t,this.x0=e,this.x1=r}function Hn(t){return t[0]}function Kn(t,e){var r=new Jn(null==e?Hn:e,NaN,NaN);return null==t?r:r.addAll(t)}function Jn(t,e,r){this._x=t,this._x0=e,this._x1=r,this._root=void 0}function Qn(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var Xn=Kn.prototype=Jn.prototype;Xn.copy=function(){var t,e,r=new Jn(this._x,this._x0,this._x1),n=this._root;if(!n)return r;if(!n.length)return r._root=Qn(n),r;for(t=[{source:n,target:r._root=new Array(2)}];n=t.pop();)for(var o=0;o<2;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(2)}):n.target[o]=Qn(e));return r},Xn.add=function(t){const e=+this._x.call(null,t);return $n(this.cover(e),e,t)},Xn.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,r=new Float64Array(e);let n=1/0,o=-1/0;for(let i,a=0;ao&&(o=i));if(n>o)return this;this.cover(n).cover(o);for(let n=0;nt||t>=r;)switch(o=+(tu||(o=i.x1)=d))&&(i=c[c.length-1],c[c.length-1]=c[c.length-1-a],c[c.length-1-a]=i)}else{var f=Math.abs(t-+this._x.call(null,h.data));f=(a=(d+f)/2))?d=a:f=a,e=h,!(h=h[u=+s]))return this;if(!h.length)break;e[u+1&1]&&(r=e,c=u)}for(;h.data!==t;)if(n=h,!(h=h.next))return this;return(o=h.next)&&delete h.next,n?(o?n.next=o:delete n.next,this):e?(o?e[u]=o:delete e[u],(h=e[0]||e[1])&&h===(e[1]||e[0])&&!h.length&&(r?r[c]=h:this._root=h),this):(this._root=o,this)},Xn.removeAll=function(t){for(var e=0,r=t.length;e(t=(1664525*t+1013904223)%Zn)/Zn}();function l(){g(),d.call("tick",r),o1&&(null==h.fy?h.y+=h.vy*=u:(h.y=h.fy,h.vy=0)),n>2&&(null==h.fz?h.z+=h.vz*=u:(h.z=h.fz,h.vz=0));return r}function v(){for(var e,r=0,o=t.length;r1&&isNaN(e.y)||n>2&&isNaN(e.z)){var i=10*(n>2?Math.cbrt(.5+r):n>1?Math.sqrt(.5+r):r),a=r*no,s=r*oo;1===n?e.x=i:2===n?(e.x=i*Math.cos(a),e.y=i*Math.sin(a)):(e.x=i*Math.sin(a)*Math.cos(s),e.y=i*Math.cos(a),e.z=i*Math.sin(a)*Math.sin(s))}(isNaN(e.vx)||n>1&&isNaN(e.vy)||n>2&&isNaN(e.vz))&&(e.vx=0,n>1&&(e.vy=0),n>2&&(e.vz=0))}}function p(e){return e.initialize&&e.initialize(t,f,n),e}return null==t&&(t=[]),v(),r={tick:g,restart:function(){return h.restart(l),r},stop:function(){return h.stop(),r},numDimensions:function(t){return arguments.length?(n=Math.min(3,Math.max(1,Math.round(t))),c.forEach(p),r):n},nodes:function(e){return arguments.length?(t=e,v(),c.forEach(p),r):t},alpha:function(t){return arguments.length?(o=+t,r):o},alphaMin:function(t){return arguments.length?(i=+t,r):i},alphaDecay:function(t){return arguments.length?(a=+t,r):+a},alphaTarget:function(t){return arguments.length?(s=+t,r):s},velocityDecay:function(t){return arguments.length?(u=1-t,r):1-u},randomSource:function(t){return arguments.length?(f=t,c.forEach(p),r):f},force:function(t,e){return arguments.length>1?(null==e?c.delete(t):c.set(t,p(e)),r):c.get(t)},find:function(){var e,r,o,i,a,s,u=Array.prototype.slice.call(arguments),c=u.shift()||0,h=(n>1?u.shift():null)||0,d=(n>2?u.shift():null)||0,f=u.shift()||1/0,l=0,g=t.length;for(f*=f,l=0;l1?(d.on(t,e),r):d.on(t)}}}function ao(){var t,e,r,n,o,i,a=Vn(-30),s=1,u=1/0,c=.81;function h(n){var i,a=t.length,s=(1===e?Kn(t,to):2===e?er(t,to,eo):3===e?dr(t,to,eo,ro):null).visitAfter(f);for(o=n,i=0;i1&&(t.y=a/h),e>2&&(t.z=s/h)}else{(r=t).x=r.data.x,e>1&&(r.y=r.data.y),e>2&&(r.z=r.data.z);do{c+=i[r.data.index]}while(r=r.next)}t.value=c}function l(t,a,h,d,f){if(!t.value)return!0;var l=[h,d,f][e-1],g=t.x-r.x,v=e>1?t.y-r.y:0,p=e>2?t.z-r.z:0,y=l-a,m=g*g+v*v+p*p;if(y*y/c1&&0===v&&(m+=(v=Bn(n))*v),e>2&&0===p&&(m+=(p=Bn(n))*p),m1&&(r.vy+=v*t.value*o/m),e>2&&(r.vz+=p*t.value*o/m)),!0;if(!(t.length||m>=u)){(t.data!==r||t.next)&&(0===g&&(m+=(g=Bn(n))*g),e>1&&0===v&&(m+=(v=Bn(n))*v),e>2&&0===p&&(m+=(p=Bn(n))*p),m1&&(r.vy+=v*y),e>2&&(r.vz+=p*y))}while(t=t.next)}}return h.initialize=function(r,...o){t=r,n=o.find((t=>"function"==typeof t))||Math.random,e=o.find((t=>[1,2,3].includes(t)))||2,d()},h.strength=function(t){return arguments.length?(a="function"==typeof t?t:Vn(+t),d(),h):a},h.distanceMin=function(t){return arguments.length?(s=t*t,h):Math.sqrt(s)},h.distanceMax=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h.theta=function(t){return arguments.length?(c=t*t,h):Math.sqrt(c)},h}function so(t,e,r){var n,o=1;function i(){var i,a,s=n.length,u=0,c=0,h=0;for(i=0;i1&&(d=c.y+c.vy),r>2&&(f=c.z+c.vz),s.visit(y);function y(t,e,n,a,s,u,v){var p=[e,n,a,s,u,v],y=p[0],m=p[1],w=p[2],x=p[r],b=p[r+1],E=p[r+2],N=t.data,M=t.r,_=l+M;if(!N)return y>h+_||x1&&(m>d+_||b2&&(w>f+_||Ec.index){var k=h-N.x-N.vx,A=r>1?d-N.y-N.vy:0,j=r>2?f-N.z-N.vz:0,O=k*k+A*A+j*j;O<_*_&&(0===k&&(O+=(k=Bn(o))*k),r>1&&0===A&&(O+=(A=Bn(o))*A),r>2&&0===j&&(O+=(j=Bn(o))*j),O=(_-(O=Math.sqrt(O)))/O*i,c.vx+=(k*=O)*(_=(M*=M)/(g+M)),r>1&&(c.vy+=(A*=O)*_),r>2&&(c.vz+=(j*=O)*_),N.vx-=k*(_=1-_),r>1&&(N.vy-=A*_),r>2&&(N.vz-=j*_))}}}function u(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;et.r&&(t.r=t[e].r)}function c(){if(e){var r,o,i=e.length;for(n=new Array(i),r=0;r"function"==typeof t))||Math.random,r=n.find((t=>[1,2,3].includes(t)))||2,c()},s.iterations=function(t){return arguments.length?(a=+t,s):a},s.strength=function(t){return arguments.length?(i=+t,s):i},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:Vn(+e),c(),s):t},s}function lo(t,e,r,n){var o,i,a,s,u=Vn(.1);function c(t){for(var u=0,c=o.length;u1&&(h.vy+=f*v),i>2&&(h.vz+=l*v)}}function h(){if(o){var e,r=o.length;for(a=new Array(r),s=new Array(r),e=0;e[1,2,3].includes(t)))||2,h()},c.strength=function(t){return arguments.length?(u="function"==typeof t?t:Vn(+t),h(),c):u},c.radius=function(e){return arguments.length?(t="function"==typeof e?e:Vn(+e),h(),c):t},c.x=function(t){return arguments.length?(e=+t,c):e},c.y=function(t){return arguments.length?(r=+t,c):r},c.z=function(t){return arguments.length?(n=+t,c):n},c}function go(t){var e,r,n,o=Vn(.1);function i(t){for(var o,i=0,a=e.length;i({})));[...n.getAllNodes(),...n.getAllEdges()].some((({id:t})=>S(t)))&&console.error("Dagre layout only support string id, it will convert number to string."),n.getAllNodes().forEach((t=>{const{id:r}=t,n=Object.assign({},t.data);if(void 0!==e){const[r,o]=Te(Ie(e)?e(t):e);Object.assign(n,{width:r,height:o})}i.setNode(r.toString(),n)})),n.getAllEdges().forEach((({id:t,source:e,target:r})=>{i.setEdge(e.toString(),r.toString(),{id:t})})),mo().layout(i);const a={nodes:[],edges:[]};return i.nodes().forEach((t=>{const e=i.node(t);a.nodes.push({id:t,data:e}),r&&n.mergeNodeData(t,e)})),i.edges().forEach((e=>{const o=i.edge(e),{id:s}=o,u=t(o,["id"]),{v:c,w:h}=e;a.edges.push({id:s,source:c,target:h,data:u}),r&&n.mergeEdgeData(s,u)})),a}))}}wo.defaultOptions={};class xo{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,r=t.ry-this.ry;let n=Math.hypot(e,r);n=n<1e-4?1e-4:n;const o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,r=(this.rx*this.mass+t.rx*t.mass)/e,n=(this.ry*this.mass+t.ry*t.mass)/e,o=this.degree+t.degree;return new xo({rx:r,ry:n,mass:e,degree:o})}}class bo{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,r=this.length/2;return new bo({xmid:t,ymid:e,length:r})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,r=this.length/2;return new bo({xmid:t,ymid:e,length:r})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,r=this.length/2;return new bo({xmid:t,ymid:e,length:r})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,r=this.length/2;return new bo({xmid:t,ymid:e,length:r})}}class Eo{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new Eo(this.quad.NW()),this.NE=new Eo(this.quad.NE()),this.SW=new Eo(this.quad.SW()),this.SE=new Eo(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t){let r;const n=t.rows||5,o=t.cols||5;if(null==e)r=Math.min(n,o);else{Math.min(n,o)===t.rows?t.rows=e:t.cols=e}return r},Ao=(t,e)=>{let r;const n=t.rows||5,o=t.cols||5;if(null==e)r=Math.max(n,o);else{Math.max(n,o)===t.rows?t.rows=e:t.cols=e}return r},jo=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,Oo=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,So=(t,e)=>{const r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},zo=(t,e,r,n,o,i,a,s)=>{let u,c;const h=o[t.id];if(h)u=h.col*r+r/2+e[0],c=h.row*n+n/2+e[1];else{for(;jo(s,a);)So(i,a);u=a.col*r+r/2+e[0],c=a.row*n+n/2+e[1],Oo(s,a),So(i,a)}t.data.x=u,t.data.y=c},Ro={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Io=(t,e,r,n,o,i)=>{e.forEach(((a,s)=>{r[s]={x:0,y:0},e.forEach(((e,u)=>{if(s===u)return;if(o[s]!==o[u])return;let c=a.x-e.x,h=a.y-e.y,d=Math.sqrt(c*c+h*h);if(0===d){d=1;const t=s>u?1:-1;c=.01*t,h=.01*t}if(d{const u=i||a/10;return n&&e.forEach(((e,r)=>{const n=t[r].x-t[o].x,i=t[r].y-t[o].y,a=Math.sqrt(n*n+i*i);let s=i/a,u=-n/a;const c=Math.sqrt(e.x*e.x+e.y*e.y);let h=Math.acos((s*e.x+u*e.y)/c);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,u*=-1);const d=Math.cos(h)*c;e.x=s*d,e.y=u*d})),t.forEach(((i,a)=>{if(a===o)return;const c=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(c>0&&a!==o){const h=Math.min(u*(r/800),c);if(i.x+=e[a].x/c*h,i.y+=e[a].y/c*h,n){let e=i.x-t[o].x,r=i.y-t[o].y;const n=Math.sqrt(e*e+r*r);e=e/n*s[a],r=r/n*s[a],i.x=t[o].x+e,i.y=t[o].y+r}}})),t},To={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};const Co=(t,e,r,n,o,i,a)=>{if(!t)return[];const s=[];if(e){const u={};e.forEach(((e,c)=>{const h=[];e.forEach(((e,s)=>{var d,f;if(c===s)h.push(0);else if(n[c]===n[s])if("data"===i)h.push(e*(Math.abs(c-s)*a)/(n[c]/o));else if(i){let r,l;if(u[t[c].id])r=u[t[c].id];else{const e=("id"===i?t[c].id:null===(d=t[c].data)||void 0===d?void 0:d[i])||0;r=Ye(e)?e.charCodeAt(0):e,u[t[c].id]=r}if(u[t[s].id])l=u[t[s].id];else{const e=("id"===i?t[s].id:null===(f=t[s].data)||void 0===f?void 0:f[i])||0;l=Ye(e)?e.charCodeAt(0):e,u[t[s].id]=l}h.push(e*(Math.abs(r-l)*a)/(n[c]/o))}else h.push(e*r/(n[c]/o));else{const t=(r+o)/2;h.push(e*t)}})),s.push(h)}))}return s},Do=t=>{const e=t.length,r=t[0].length,n=[];for(let o=0;o{let r=-1;return t.forEach(((t,n)=>{t.id===e&&(r=n)})),Math.max(r,0)},Fo=(t,e,r)=>{const n=t.length;for(let o=0;o{let r=0;for(let n=0;nr?t[e][n]:r);return r},Vo={center:[0,0],width:300,height:300};const Bo={circular:class{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},Ue),t)}execute(t,r){return e(this,void 0,void 0,(function*(){return this.genericCircularLayout(!1,t,r)}))}assign(t,r){return e(this,void 0,void 0,(function*(){yield this.genericCircularLayout(!0,t,r)}))}genericCircularLayout(t,r,n){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},this.options),n),{width:o,height:i,center:a,divisions:s,startAngle:u=0,endAngle:c=2*Math.PI,angleRatio:h,ordering:d,clockwise:f,nodeSpacing:l,nodeSize:g}=e,v=r.getAllNodes(),p=r.getAllEdges(),[y,m,w]=$e(o,i,a),x=null==v?void 0:v.length;if(!x||1===x)return Ge(r,t,w);const b=(c-u)/x;let{radius:E,startRadius:N,endRadius:M}=e;if(l){const t=Ce(10,l),e=De(10,g);let r=-1/0;v.forEach((t=>{const n=e(t);r{n+=0===o?r||10:(t(e)||0)+(r||10)})),E=n/(2*Math.PI)}else E||N||M?!N&&M?N=M:N&&!M&&(M=N):E=Math.min(m,y)/2;const _=b*h;let k=[];k="topology"===d?We(r,v):"topology-directed"===d?We(r,v,!0):"degree"===d?function(t,e){const r=[];return e.forEach(((t,e)=>{r.push(qe(t))})),r.sort(((e,r)=>t.getDegree(e.id,"both")-t.getDegree(r.id,"both"))),r}(r,v):v.map((t=>qe(t)));const A=Math.ceil(x/s);for(let t=0;t{r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:k,edges:p}}))}},concentric:Je,mds:Ir,random:class{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},Vo),t)}execute(t,r){return e(this,void 0,void 0,(function*(){return this.genericRandomLayout(!1,t,r)}))}assign(t,r){return e(this,void 0,void 0,(function*(){yield this.genericRandomLayout(!0,t,r)}))}genericRandomLayout(t,r,n){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},this.options),n),{center:o,width:i,height:a}=e,s=r.getAllNodes(),u=i||"undefined"==typeof window?i:window.innerWidth,c=a||"undefined"==typeof window?a:window.innerHeight,h=o||[u/2,c/2],d=[];s&&s.forEach((t=>{d.push({id:t.id,data:{x:.9*(Math.random()-.5)*u+h[0],y:.9*(Math.random()-.5)*c+h[1]}})})),t&&d.forEach((t=>r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:d,edges:r.getAllEdges()}}))}},grid:class{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},_o),t)}execute(t,r){return e(this,void 0,void 0,(function*(){return this.genericGridLayout(!1,t,r)}))}assign(t,r){return e(this,void 0,void 0,(function*(){yield this.genericGridLayout(!0,t,r)}))}genericGridLayout(t,r,n){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},this.options),n),{begin:o=[0,0],condense:i,preventOverlapPadding:a,preventOverlap:s,rows:u,cols:c,nodeSpacing:h,nodeSize:d,width:f,height:l,position:g}=e;let{sortBy:v}=e;const p=r.getAllNodes(),y=r.getAllEdges(),m=null==p?void 0:p.length;if(!m||1===m)return Ge(r,t,o);const w=p.map((t=>qe(t)));"id"===v||Ye(v)&&void 0!==w[0].data[v]||(v="degree"),"degree"===v?w.sort(((t,e)=>r.getDegree(e.id,"both")-r.getDegree(t.id,"both"))):"id"===v?w.sort(((t,e)=>S(e.id)&&S(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):w.sort(((t,e)=>e.data[v]-t.data[v]));const x=f||"undefined"==typeof window?f:window.innerWidth,b=l||"undefined"==typeof window?l:window.innerHeight,E=m,N={rows:u,cols:c};if(null!=u&&null!=c)N.rows=u,N.cols=c;else if(null!=u&&null==c)N.rows=u,N.cols=Math.ceil(E/N.rows);else if(null==u&&null!=c)N.cols=c,N.rows=Math.ceil(E/N.cols);else{const t=Math.sqrt(E*b/x);N.rows=Math.round(t),N.cols=Math.round(x/b*t)}if(N.rows=Math.max(N.rows,1),N.cols=Math.max(N.cols,1),N.cols*N.rows>E){const t=ko(N),e=Ao(N);(t-1)*e>=E?ko(N,t-1):(e-1)*t>=E&&Ao(N,e-1)}else for(;N.cols*N.rows=E?Ao(N,e+1):ko(N,t+1)}let M=i?0:x/N.cols,_=i?0:b/N.rows;if(s||h){const t=Ce(10,h),e=De(30,d,!1);w.forEach((n=>{n.data.x&&n.data.y||(n.data.x=0,n.data.y=0);const o=r.getNode(n.id),[i,s]=Te(e(o)||30),u=void 0!==t?t(n):a,c=i+u,h=s+u;M=Math.max(M,c),_=Math.max(_,h)}))}const k={},A={row:0,col:0},j={};for(let t=0;t{r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),O}))}},radial:class{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},To),t)}execute(t,r){return e(this,void 0,void 0,(function*(){return this.genericRadialLayout(!1,t,r)}))}assign(t,r){return e(this,void 0,void 0,(function*(){yield this.genericRadialLayout(!0,t,r)}))}genericRadialLayout(t,r,n){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},this.options),n),{width:o,height:i,center:a,focusNode:s,unitRadius:u,nodeSize:c,nodeSpacing:h,strictRadial:d,preventOverlap:f,maxPreventOverlapIteration:l,sortBy:g,linkDistance:v=50,sortStrength:p=10,maxIteration:y=1e3}=e,m=r.getAllNodes(),w=r.getAllEdges(),x=o||"undefined"==typeof window?o:window.innerWidth,b=i||"undefined"==typeof window?i:window.innerHeight,E=a||[x/2,b/2];if(!(null==m?void 0:m.length)||1===m.length)return Ge(r,t,E);let N=m[0];if(Ye(s)){for(let t=0;tE[0]?E[0]:x-E[0],S=b-E[1]>E[1]?E[1]:b-E[1];0===O&&(O=x/2),0===S&&(S=b/2);const z=Math.min(O,S),R=Math.max(...j),I=[],P=u||z/R;j.forEach(((t,e)=>{I[e]=t*P}));const T=Co(m,k,v,I,P,g,p),C=Do(T),D=((t,e,r)=>{try{const r=kr.mul(kr.pow(e,2),-.5),n=r.mean("row"),o=r.mean("column"),i=r.mean();r.add(i).subRowVector(n).subColumnVector(o);const a=new Ar(r),s=kr.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>kr.mul([e],[s]).toJSON()[0].splice(0,t)))}catch(t){const n=[];for(let t=0;t({x:(isNaN(t)?Math.random()*v:t)-D[M][0],y:(isNaN(e)?Math.random()*v:e)-D[M][1]})));if(this.run(y,F,C,T,I,M),f){L=Le(c,h);const t={nodes:m,nodeSizeFunc:L,positions:F,radii:I,height:b,width:x,strictRadial:Boolean(d),focusIdx:M,iterations:l||200,k:F.length/4.5};F=((t,e)=>{const r=Object.assign(Object.assign({},Ro),e),{positions:n,iterations:o,width:i,k:a,speed:s=100,strictRadial:u,focusIdx:c,radii:h=[],nodeSizeFunc:d}=r,f=t.getAllNodes(),l=[],g=i/10;for(let t=0;t{l[e]={x:0,y:0}})),Io(f,n,l,a,h,d),Po(n,l,s,u,c,g,i,h);return n})(r,t)}const q=[];F.forEach(((t,e)=>{const r=qe(m[e]);r.data.x=t.x+E[0],r.data.y=t.y+E[1],q.push(r)})),t&&q.forEach((t=>r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:q,edges:w}}))}run(t,e,r,n,o,i){for(let a=0;a<=t;a++){const s=a/t;this.oneIteration(s,e,o,n,r,i)}}oneIteration(t,e,r,n,o,i){const a=1-t;e.forEach(((s,u)=>{const c=Sr(s,{x:0,y:0}),h=0===c?0:1/c;if(u===i)return;let d=0,f=0,l=0;e.forEach(((t,e)=>{if(u===e)return;const r=Sr(s,t),i=0===r?0:1/r,a=n[e][u];l+=o[u][e],d+=o[u][e]*(t.x+a*(s.x-t.x)*i),f+=o[u][e]*(t.y+a*(s.y-t.y)*i)}));const g=0===r[u]?0:1/r[u];l*=a,l+=t*g*g,d*=a,d+=t*g*s.x*h,s.x=d/l,f*=a,f+=t*g*s.y*h,s.y=f/l}))}},force:wr,d3force:Fn,"d3-force-3d":class extends Fn{constructor(){super(...arguments),this.id="d3-force-3d",this.config={inputNodeAttrs:["x","y","z","vx","vy","vz","fx","fy","fz"],outputNodeAttrs:["x","y","z","vx","vy","vz"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource","numDimensions"]},this.forceMap={link:Wn,manyBody:ao,center:so,collide:fo,radial:lo,x:go,y:vo,z:po},this.options={numDimensions:3,link:{id:t=>t.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return io()}},fruchterman:class{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},Mo),t)}execute(t,r){return e(this,void 0,void 0,(function*(){return this.genericFruchtermanLayout(!1,t,r)}))}assign(t,r){return e(this,void 0,void 0,(function*(){yield this.genericFruchtermanLayout(!0,t,r)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;ethis.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericFruchtermanLayout(t,r,n){return e(this,void 0,void 0,(function*(){if(this.running)return;const e=this.formatOptions(n),{dimensions:o,width:i,height:a,center:s,clustering:u,nodeClusterBy:h,maxIteration:d,onTick:f}=e,l=r.getAllNodes(),g=r.getAllEdges();if(!(null==l?void 0:l.length)){const t={nodes:[],edges:g};return this.lastResult=t,t}if(1===l.length){t&&r.mergeNodeData(l[0].id,{x:s[0],y:s[1],z:3===o?s[2]:void 0});const e={nodes:[Object.assign(Object.assign({},l[0]),{data:Object.assign(Object.assign({},l[0].data),{x:s[0],y:s[1],z:3===o?s[2]:void 0})})],edges:g};return this.lastResult=e,e}const v=l.map((t=>qe(t,[i,a]))),p=new c({nodes:v,edges:g}),y={};if(u&&v.forEach((t=>{const e=t.data[h];y[e]||(y[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=v,this.lastLayoutEdges=g,this.lastAssign=t,this.lastGraph=p,this.lastOptions=e,this.lastClusterMap=y,"undefined"==typeof window)return;let m=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{this.running?(this.runOneStep(p,y,e),t&&v.forEach((({id:t,data:e})=>r.mergeNodeData(t,{x:e.x,y:e.y,z:3===o?e.z:void 0}))),null==f||f({nodes:v,edges:g}),m++,m>=d&&(window.clearInterval(this.timeInterval),n({nodes:v,edges:g}))):n({nodes:v,edges:g})}),0),this.running=!0}))}))}formatOptions(t={}){const e=Object.assign(Object.assign({},this.options),t),{clustering:r,nodeClusterBy:n}=e,{center:o,width:i,height:a}=e;return e.width=i||"undefined"==typeof window?i:window.innerWidth,e.height=a||"undefined"==typeof window?a:window.innerHeight,e.center=o||[e.width/2,e.height/2],e.clustering=r&&!!n,e}runOneStep(t,e,r){const{dimensions:n,height:o,width:i,gravity:a,center:s,speed:u,clustering:c,nodeClusterBy:h,clusterGravity:d}=r,f=o*i,l=Math.sqrt(f)/10,g=t.getAllNodes(),v=f/(g.length+1),p=Math.sqrt(v),y={};if(this.applyCalculate(t,y,p,v),c){for(const t in e)e[t].cx=0,e[t].cy=0,e[t].count=0;g.forEach((t=>{const{data:r}=t,n=e[r[h]];S(r.x)&&(n.cx+=r.x),S(r.y)&&(n.cy+=r.y),n.count++}));for(const t in e)e[t].cx/=e[t].count,e[t].cy/=e[t].count;const t=d||a;g.forEach(((r,n)=>{const{id:o,data:i}=r;if(!S(i.x)||!S(i.y))return;const a=e[i[h]],s=Math.sqrt((i.x-a.cx)*(i.x-a.cx)+(i.y-a.cy)*(i.y-a.cy)),u=p*t;y[o].x-=u*(i.x-a.cx)/s,y[o].y-=u*(i.y-a.cy)/s}))}g.forEach(((t,e)=>{const{id:r,data:o}=t;if(!S(o.x)||!S(o.y))return;const i=.01*p*a;y[r].x-=i*(o.x-s[0]),y[r].y-=i*(o.y-s[1]),3===n&&(y[r].z-=i*(o.z-s[2]))})),g.forEach(((e,r)=>{const{id:o,data:i}=e;if(S(i.fx)&&S(i.fy))return i.x=i.fx,i.y=i.fy,void(3===n&&(i.z=i.fz));if(!S(i.x)||!S(i.y))return;const a=Math.sqrt(y[o].x*y[o].x+y[o].y*y[o].y+(3===n?y[o].z*y[o].z:0));if(a>0){const e=Math.min(l*(u/800),a);t.mergeNodeData(o,{x:i.x+y[o].x/a*e,y:i.y+y[o].y/a*e,z:3===n?i.z+y[o].z/a*e:void 0})}}))}applyCalculate(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)}calRepulsive(t,e,r){const n=t.getAllNodes();n.forEach((({data:t,id:o},i)=>{e[o]={x:0,y:0,z:0},n.forEach((({data:n,id:a},s)=>{if(i<=s||!S(t.x)||!S(n.x)||!S(t.y)||!S(n.y))return;let u=t.x-n.x,c=t.y-n.y,h=3===this.options.dimensions?t.z-n.z:0,d=u*u+c*c+h*h;0===d&&(d=1,u=.01,c=.01,h=.01);const f=r/d,l=u*f,g=c*f,v=h*f;e[o].x+=l,e[o].y+=g,e[a].x-=l,e[a].y-=g,3===this.options.dimensions&&(e[o].z+=v,e[a].z-=v)}))}))}calAttractive(t,e,r){t.getAllEdges().forEach((n=>{const{source:o,target:i}=n;if(!o||!i||o===i)return;const{data:a}=t.getNode(o),{data:s}=t.getNode(i);if(!(S(s.x)&&S(a.x)&&S(s.y)&&S(a.y)))return;const u=s.x-a.x,c=s.y-a.y,h=3===this.options.dimensions?s.z-a.z:0,d=Math.sqrt(u*u+c*c+h*h)/r,f=u*d,l=c*d,g=h*d;e[o].x+=f,e[o].y+=l,e[i].x-=f,e[i].y-=l,3===this.options.dimensions&&(e[o].z+=g,e[i].z-=g)}))}},forceAtlas2:class{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},No),t)}execute(t,r){return e(this,void 0,void 0,(function*(){return this.genericForceAtlas2Layout(!1,t,r)}))}assign(t,r){return e(this,void 0,void 0,(function*(){yield this.genericForceAtlas2Layout(!0,t,r)}))}genericForceAtlas2Layout(t,r,n){return e(this,void 0,void 0,(function*(){const e=r.getAllEdges(),o=r.getAllNodes(),i=this.formatOptions(n,o.length),{width:a,height:s,prune:u,maxIteration:h,nodeSize:d,center:f}=i;if(!(null==o?void 0:o.length)||1===o.length)return Ge(r,t,f);const l=o.map((t=>qe(t,[a,s]))),g=e.filter((t=>{const{source:e,target:r}=t;return e!==r})),v=new c({nodes:l,edges:g}),p=this.getSizes(v,d);if(this.run(v,r,h,p,t,i),u){for(let t=0;t250&&(r.barnesHut=!0),void 0===s&&e>100&&(r.prune=!0),0!==u||s?0===u&&s&&(r.maxIteration=100,e<=200&&e>100?r.maxIteration=500:e>200&&(r.maxIteration=950)):(r.maxIteration=250,e<=200&&e>100?r.maxIteration=1e3:e>200&&(r.maxIteration=1200)),c||(r.kr=50,e>100&&e<=500?r.kr=20:e>500&&(r.kr=1)),h||(r.kg=20,e>100&&e<=500?r.kg=10:e>500&&(r.kg=1)),r}run(t,e,r,n,o,i){const{kr:a,barnesHut:s,onTick:u}=i,c=t.getAllNodes();let h=0,d=r;const f={},l={},g={};for(let e=0;e0;)h=this.oneStep(t,{iter:d,preventOverlapIters:50,krPrime:100,sg:h,forces:f,preForces:l,bodies:g,sizes:n},i),d--,null==u||u({nodes:c,edges:e.getAllEdges()});return t}oneStep(t,e,r){const{iter:n,preventOverlapIters:o,krPrime:i,sg:a,preForces:s,bodies:u,sizes:c}=e;let{forces:h}=e;const{preventOverlap:d,barnesHut:f}=r,l=t.getAllNodes();for(let t=0;to||!d)?this.getOptRepGraForces(t,h,u,r):this.getRepGraForces(t,n,o,h,i,c,r),this.updatePos(t,h,s,a,r)}getAttrForces(t,e,r,n,o,i){const{preventOverlap:a,dissuadeHubs:s,mode:u,prune:c}=i,h=t.getAllEdges();for(let i=0;i0&&(w=m,x=m),o[d][0]+=w*y[0],o[f][0]-=x*y[0],o[d][1]+=w*y[1],o[f][1]-=x*y[1]}return o}getOptRepGraForces(t,e,r,n){const{kg:o,center:i,prune:a}=n,s=t.getAllNodes(),u=s.length;let c=9e10,h=-9e10,d=9e10,f=-9e10;for(let e=0;e=h&&(h=o.x),o.x<=c&&(c=o.x),o.y>=f&&(f=o.y),o.y<=d&&(d=o.y))}const l=Math.max(h-c,f-d),g=new bo({xmid:(h+c)/2,ymid:(f+d)/2,length:l,massCenter:i,mass:u}),v=new Eo(g);for(let e=0;e0&&(y=u*(v+1)*(h+1)/p),n[g.id][0]-=y*l[0],n[a.id][0]+=y*l[0],n[g.id][1]-=y*l[1],n[a.id][1]+=y*l[1]}const p=[g.data.x-h[0],g.data.y-h[1]],y=Math.hypot(p[0],p[1]);p[0]=p[0]/y,p[1]=p[1]/y;const m=c*(v+1);n[g.id][0]-=m*p[0],n[g.id][1]-=m*p[1]}return n}updatePos(t,e,r,n,o){const{ks:i,tao:a,prune:s,ksmax:u}=o,c=t.getAllNodes(),h=c.length,d=[],f=[];let l=0,g=0,v=n;for(let n=0;n1.5*p?1.5*p:v);for(let r=0;rl?l:h;const g=h*e[n][0],p=h*e[n][1];t.mergeNodeData(n,{x:o.x+g,y:o.y+p})}return v}},dagre:wo,antvDagre:class{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},Ve),t)}execute(t,r){return e(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,r)}))}assign(t,r){return e(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,r)}))}genericDagreLayout(t,r,n){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},this.options),n),{nodeSize:o,align:i,rankdir:a="TB",ranksep:s,nodesep:u,ranksepFunc:h,nodesepFunc:d,edgeLabelSpace:f,ranker:l,nodeOrder:g,begin:v,controlPoints:p,radial:y,sortByCombo:m,preset:w}=e,x=new c({tree:[]}),b=Ce(s||50,h),E=Ce(u||50,d);let N=E,M=b;"LR"!==a&&"RL"!==a||(N=b,M=E);const _=De(10,o,!1),k=r.getAllNodes(),A=r.getAllEdges();let j;k.forEach((t=>{const e=Te(_(t)),r=M(t),n=N(t),o=e[0]+2*n,i=e[1]+2*r,a=t.data.layer;S(a)?x.addNode({id:t.id,data:{width:o,height:i,layer:a}}):x.addNode({id:t.id,data:{width:o,height:i}})})),m&&(x.attachTreeStructure("combo"),k.forEach((t=>{const{parentId:e}=t.data;void 0!==e&&x.hasNode(e)&&x.setParent(t.id,e,"combo")}))),A.forEach((t=>{x.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),(null==w?void 0:w.length)&&(j=new c({nodes:w})),((t,e)=>{const{edgeLabelSpace:r,keepNodeOrder:n,prevGraph:o,rankdir:i,ranksep:a}=e;!n&&o&&de(t,o);const s=me(t);let u;r&&(e.ranksep=we(s,{rankdir:i,ranksep:a}));try{u=he(s,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void 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:\n",t);throw t}fe(t,s)})(x,{prevGraph:j,edgeLabelSpace:f,keepNodeOrder:!!g,nodeOrder:g||[],acyclicer:"greedy",ranker:l,rankdir:a,nodesep:u,align:i});const O=[0,0];if(v){let t=1/0,e=1/0;x.getAllNodes().forEach((r=>{t>r.data.x&&(t=r.data.x),e>r.data.y&&(e=r.data.y)})),x.getAllEdges().forEach((r=>{var n;null===(n=r.data.points)||void 0===n||n.forEach((r=>{t>r.x&&(t=r.x),e>r.y&&(e=r.y)}))})),O[0]=v[0]-t,O[1]=v[1]-e}const z="LR"===a||"RL"===a;if(y);else{const t=new Set,e="BT"===a||"RL"===a?(t,e)=>e-t:(t,e)=>t-e;x.getAllNodes().forEach((e=>{e.data.x=e.data.x+O[0],e.data.y=e.data.y+O[1],t.add(z?e.data.x:e.data.y)}));const r=Array.from(t).sort(e),n=z?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,o=z?(t,e,r)=>{const n=Math.max(e.y,r.y),o=Math.min(e.y,r.y);return t.filter((t=>t.y<=n&&t.y>=o))}:(t,e,r)=>{const n=Math.max(e.x,r.x),o=Math.min(e.x,r.x);return t.filter((t=>t.x<=n&&t.x>=o))};x.getAllEdges().forEach(((t,e)=>{var i;f&&p&&"loop"!==t.data.type&&(t.data.controlPoints=Be(null===(i=t.data.points)||void 0===i?void 0:i.map((({x:t,y:e})=>({x:t+O[0],y:e+O[1]}))),x.getNode(t.source),x.getNode(t.target),r,z,n,o))}))}let R=[];R=x.getAllNodes().map((t=>qe(t)));const I=x.getAllEdges();t&&(R.forEach((t=>{r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),I.forEach((t=>{r.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})})));return{nodes:R,edges:I}}))}},comboCombined:class{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},Lr),t)}execute(t,r){return e(this,void 0,void 0,(function*(){return this.genericComboCombinedLayout(!1,t,r)}))}assign(t,r){return e(this,void 0,void 0,(function*(){yield this.genericComboCombinedLayout(!0,t,r)}))}genericComboCombinedLayout(t,r,n){return e(this,void 0,void 0,(function*(){const e=this.initVals(Object.assign(Object.assign({},this.options),n)),{center:o,treeKey:i,outerLayout:a}=e,s=r.getAllNodes().filter((t=>!t.data._isCombo)),u=r.getAllNodes().filter((t=>t.data._isCombo)),h=r.getAllEdges(),d=null==s?void 0:s.length;if(!d||1===d)return Ge(r,t,o);const f=[],l=new Map;s.forEach((t=>{l.set(t.id,t)}));const g=new Map;u.forEach((t=>{g.set(t.id,t)}));const v=new Map,p=this.getInnerGraphs(r,i,l,g,h,e,v);yield Promise.all(p);const y=new Map,m=[],w=new Map;let x=!0;r.getRoots(i).forEach((t=>{const e=v.get(t.id),n=g.get(t.id)||l.get(t.id),o={id:t.id,data:Object.assign(Object.assign({},t.data),{x:e.data.x||n.data.x,y:e.data.y||n.data.y,fx:e.data.fx||n.data.fx,fy:e.data.fy||n.data.fy,mass:e.data.mass||n.data.mass,size:e.data.size})};m.push(o),y.set(t.id,!0),isNaN(o.data.x)||0===o.data.x||isNaN(o.data.y)||0===o.data.y?(o.data.x=100*Math.random(),o.data.y=100*Math.random()):x=!1,zr(r,[t],(e=>{e.id!==t.id&&w.set(e.id,t.id)}),"TB",i)}));const b=[];let E;if(h.forEach((t=>{const e=w.get(t.source)||t.source,r=w.get(t.target)||t.target;e!==r&&y.has(e)&&y.has(r)&&b.push({id:t.id,source:e,target:r,data:{}})})),null==m?void 0:m.length){if(1===m.length)m[0].data.x=o[0],m[0].data.y=o[1];else{const t=new c({nodes:m,edges:b}),e=a||new wr;if(x&&Dr[e.id]){const e=m.length<100?new Ir:new Je;yield e.assign(t)}const r=Object.assign({center:o,kg:5,preventOverlap:!0,animate:!1},"force"===e.id?{gravity:1,factor:4,linkDistance:(t,e,r)=>(Math.max(...e.data.size)||32)/2+(Math.max(...r.data.size)||32)/2+200}:{});E=yield Fr(e,t,r)}v.forEach((t=>{var e;const r=E.nodes.find((e=>e.id===t.id));if(r){const{x:e,y:n}=r.data;t.data.visited=!0,t.data.x=e,t.data.y=n,f.push({id:t.id,data:{x:e,y:n}})}const{x:n,y:o}=t.data;null===(e=t.data.nodes)||void 0===e||e.forEach((t=>{f.push({id:t.id,data:{x:t.data.x+n,y:t.data.y+o}})}))})),v.forEach((({data:t})=>{const{x:e,y:r,visited:n,nodes:o}=t;null==o||o.forEach((t=>{if(!n){const n=f.find((e=>e.id===t.id));n.data.x+=e||0,n.data.y+=r||0}}))}))}t&&f.forEach((t=>{r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:f,edges:h}}))}initVals(t){const e=Object.assign({},t),{nodeSize:r,spacing:n,comboPadding:o}=t;let i,a,s;if(a=S(n)?()=>n:Ie(n)?n:()=>0,e.spacing=a,r)if(Ie(r))i=t=>{const e=r(t),n=a(t);if(He(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+n)/2}return((e||32)+n)/2};else if(He(r)){const t=(r[0]>r[1]?r[0]:r[1])/2;i=e=>t+a(e)/2}else{const t=r/2;i=e=>t+a(e)/2}else i=t=>{const e=a(t);if(t.size){if(He(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2}if(Pe(t.size)){return((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2}return(t.size+e)/2}return 32+e/2};return e.nodeSize=i,s=S(o)?()=>o:He(o)?()=>Math.max.apply(null,o):Ie(o)?o:()=>0,e.comboPadding=s,e}getInnerGraphs(t,r,n,o,i,a,s){const{nodeSize:u,comboPadding:h,spacing:d,innerLayout:f}=a,l=f||new Je({}),g={center:[0,0],preventOverlap:!0,nodeSpacing:d},v=[],p=t=>{let e=(null==h?void 0:h(t))||10;return He(e)&&(e=Math.max(...e)),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(r).forEach((a=>{s.set(a.id,{id:a.id,data:{nodes:[],size:p(a).size}});let h=Promise.resolve();zr(t,[a],(a=>{var d;if(!a.data._isCombo)return;const{size:f,padding:v}=p(a);if(null===(d=t.getChildren(a.id,r))||void 0===d?void 0:d.length){const d=s.get(a.id);s.set(a.id,{id:a.id,data:Object.assign({nodes:[]},null==d?void 0:d.data)});const f=new Map,p=t.getChildren(a.id,r).map((t=>{if(t.data._isCombo)return s.has(t.id)||s.set(t.id,{id:t.id,data:Object.assign({},t.data)}),f.set(t.id,!0),s.get(t.id);const e=n.get(t.id)||o.get(t.id);return f.set(t.id,!0),{id:t.id,data:Object.assign(Object.assign({},e.data),t.data)}})),y={nodes:p,edges:i.filter((t=>f.has(t.source)&&f.has(t.target)))};let m=1/0;p.forEach((t=>{var e;let{size:r}=t.data;r||(r=(null===(e=s.get(t.id))||void 0===e?void 0:e.data.size)||(null==u?void 0:u(t))||[30,30]),S(r)&&(r=[r,r]);const[n,o]=r;m>n&&(m=n),m>o&&(m=o),t.data.size=r})),h=h.then((()=>e(this,void 0,void 0,(function*(){const t=new c(y);yield Fr(l,t,g,!0);const{minX:e,minY:r,maxX:n,maxY:o}=(t=>{let e=1/0,r=1/0,n=-1/0,o=-1/0;return t.forEach((t=>{let i=t.data.size;He(i)?1===i.length&&(i=[i[0],i[0]]):S(i)?i=[i,i]:(void 0===i||isNaN(i))&&(i=[30,30]);const a=[i[0]/2,i[1]/2],s=t.data.x-a[0],u=t.data.x+a[0],c=t.data.y-a[1],h=t.data.y+a[1];e>s&&(e=s),r>c&&(r=c),n{t.data.x-=i,t.data.y-=u}));const h=[Math.max(n-e,m)+2*v,Math.max(o-r,m)+2*v];s.get(a.id).data.size=h,s.get(a.id).data.nodes=p}))))}else s.set(a.id,{id:a.id,data:Object.assign(Object.assign({},a.data),{size:f})});return!0}),"BT",r),v.push(h)})),v}}};let Go;m({stopLayout(){(null==Go?void 0:Go.stop)&&Go.stop()},calculateLayout(t,r){return e(this,void 0,void 0,(function*(){const{layout:{id:e,options:n,iterations:o},nodes:i,edges:a}=t,s=new c({nodes:i,edges:a}),u=Bo[e];if(!u)throw new Error(`Unknown layout id: ${e}`);Go=new u(n);let h=yield Go.execute(s);return Cr(Go)&&(Go.stop(),h=Go.tick(o)),[h,r]}))}})}()}();