-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path3682.90318475.async.js
1 lines (1 loc) · 231 KB
/
3682.90318475.async.js
1
!function(){var t={22599:function(t,e,r){"use strict";var n=r(78846).default,o=r(54088).default,i=r(27047).default,a=r(3851).default,s=r(99365).default,u=r(41553).default,h=r(49488).default,d=r(84047).default,c=r(7793).default,f=r(10154).default,l=r(23658).default,g=r(45332).default,v=r(86222).default,p=r(90819).default,y=r(89957).default,m=r(78796).default,w=r(4977).default;var x=r(12751),b=r(6701),E=" ".repeat(2),M=" ".repeat(4);function N(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,h=void 0===u?"auto":u;return"".concat(t.constructor.name," {\n").concat(E,"[\n").concat(M).concat(k(t,n,i,s,h),"\n").concat(E,"]\n").concat(E,"rows: ").concat(t.rows,"\n").concat(E,"columns: ").concat(t.columns,"\n}")}function k(t,e,r,n,o){var i=t.rows,a=t.columns,s=Math.min(i,e),u=Math.min(a,r),h=[];if("auto"===o){o=!1;t:for(var d=0;d<s;d++)for(var c=0;c<u;c++)if(t.get(d,c)<0){o=!0;break t}}for(var f=0;f<s;f++){for(var l=[],g=0;g<u;g++)l.push(S(t.get(f,g),n,o));h.push("".concat(l.join(" ")))}return u!==a&&(h[h.length-1]+=" ... ".concat(a-r," more columns")),s!==i&&h.push("... ".concat(i-e," more rows")),h.join("\n".concat(M))}function S(t,e,r){return(t>=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 _(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 z(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 R(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 O(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 I(t,e){if(!x.isAnyArray(e))throw new TypeError("row indices must be an array");for(var r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}function T(t,e){if(!x.isAnyArray(e))throw new TypeError("column indices must be an array");for(var r=0;r<e.length;r++)if(e[r]<0||e[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 D(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[],n=0;n<t;n++)r.push(e);return r}function C(t,e){if("number"!=typeof e)throw new TypeError("".concat(t," must be a number"))}function L(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}function j(t,e,r){for(var n=t.rows,o=t.columns,i=[],a=0;a<n;a++){for(var s=0,u=0,h=0,d=0;d<o;d++)s+=h=t.get(a,d)-r[a],u+=h*h;e?i.push((u-s*s/o)/(o-1)):i.push((u-s*s/o)/o)}return i}function F(t,e,r){for(var n=t.rows,o=t.columns,i=[],a=0;a<o;a++){for(var s=0,u=0,h=0,d=0;d<n;d++)s+=h=t.get(d,a)-r[a],u+=h*h;e?i.push((u-s*s/n)/(n-1)):i.push((u-s*s/n)/n)}return i}function q(t,e,r){for(var n=t.rows,o=t.columns,i=n*o,a=0,s=0,u=0,h=0;h<n;h++)for(var d=0;d<o;d++)a+=u=t.get(h,d)-r,s+=u*u;return e?(s-a*a/i)/(i-1):(s-a*a/i)/i}function V(t,e){for(var r=0;r<t.rows;r++)for(var n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}function G(t,e){for(var r=0;r<t.rows;r++)for(var n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}function B(t,e){for(var r=0;r<t.rows;r++)for(var n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}function U(t){for(var e=[],r=0;r<t.rows;r++){for(var n=0,o=0;o<t.columns;o++)n+=Math.pow(t.get(r,o),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}function W(t,e){for(var r=0;r<t.rows;r++)for(var n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}function H(t){for(var e=[],r=0;r<t.columns;r++){for(var n=0,o=0;o<t.rows;o++)n+=Math.pow(t.get(o,r),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}function Y(t,e){for(var r=0;r<t.rows;r++)for(var n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}function K(t){for(var e=t.size-1,r=0,n=0;n<t.columns;n++)for(var o=0;o<t.rows;o++)r+=Math.pow(t.get(o,n),2)/e;return Math.sqrt(r)}function J(t,e){for(var r=0;r<t.rows;r++)for(var n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}var Q=function(t){function e(){m(this,e)}return w(e,[{key:"size",get:function(){return this.rows*this.columns}},{key:"apply",value:function(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)t.call(this,e,r);return this}},{key:"to1DArray",value:function(){for(var t=[],e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)t.push(this.get(e,r));return t}},{key:"to2DArray",value:function(){for(var t=[],e=0;e<this.rows;e++){t.push([]);for(var r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}},{key:"toJSON",value:function(){return this.to2DArray()}},{key:"isRowVector",value:function(){return 1===this.rows}},{key:"isColumnVector",value:function(){return 1===this.columns}},{key:"isVector",value:function(){return 1===this.rows||1===this.columns}},{key:"isSquare",value:function(){return this.rows===this.columns}},{key:"isEmpty",value:function(){return 0===this.rows||0===this.columns}},{key:"isSymmetric",value:function(){if(this.isSquare()){for(var t=0;t<this.rows;t++)for(var e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}},{key:"isDistance",value:function(){if(!this.isSymmetric())return!1;for(var t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}},{key:"isEchelonForm",value:function(){for(var t=0,e=0,r=-1,n=!0,o=!1;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(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;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(var i=e+1;i<this.rows;i++)0!==this.get(t,i)&&(n=!1);t++}return n}},{key:"echelonForm",value:function(){for(var t=this.clone(),e=0,r=0;e<t.rows&&r<t.columns;){for(var n=e,o=e;o<t.rows;o++)t.get(o,r)>t.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<t.columns;a++)t.set(e,a,t.get(e,a)/i);for(var s=e+1;s<t.rows;s++){var u=t.get(s,r)/t.get(e,r);t.set(s,r,0);for(var h=r+1;h<t.columns;h++)t.set(s,h,t.get(s,h)-t.get(e,h)*u)}e++,r++}}return t}},{key:"reducedEchelonForm",value:function(){for(var t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;n>=0;)if(0===t.maxRow(n))n--;else{for(var o=0,i=!1;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(var a=0;a<n;a++)for(var s=t.get(a,o),u=o;u<e;u++){var h=t.get(a,u)-s*t.get(n,u);t.set(a,u,h)}n--}return t}},{key:"set",value:function(){throw new Error("set method is unimplemented")}},{key:"get",value:function(){throw new Error("get method is unimplemented")}},{key:"repeat",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.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 $(this.rows*r,this.columns*o),a=0;a<r;a++)for(var s=0;s<o;s++)i.setSubMatrix(this,this.rows*a,this.columns*s);return i}},{key:"fill",value:function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,t);return this}},{key:"neg",value:function(){return this.mulS(-1)}},{key:"getRow",value:function(t){_(this,t);for(var e=[],r=0;r<this.columns;r++)e.push(this.get(t,r));return e}},{key:"getRowVector",value:function(t){return $.rowVector(this.getRow(t))}},{key:"setRow",value:function(t,e){_(this,t),e=R(this,e);for(var r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}},{key:"swapRows",value:function(t,e){_(this,t),_(this,e);for(var r=0;r<this.columns;r++){var n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}},{key:"getColumn",value:function(t){z(this,t);for(var e=[],r=0;r<this.rows;r++)e.push(this.get(r,t));return e}},{key:"getColumnVector",value:function(t){return $.columnVector(this.getColumn(t))}},{key:"setColumn",value:function(t,e){z(this,t),e=O(this,e);for(var r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}},{key:"swapColumns",value:function(t,e){z(this,t),z(this,e);for(var r=0;r<this.rows;r++){var n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}},{key:"addRowVector",value:function(t){t=R(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}},{key:"subRowVector",value:function(t){t=R(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}},{key:"mulRowVector",value:function(t){t=R(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}},{key:"divRowVector",value:function(t){t=R(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}},{key:"addColumnVector",value:function(t){t=O(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}},{key:"subColumnVector",value:function(t){t=O(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}},{key:"mulColumnVector",value:function(t){t=O(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}},{key:"divColumnVector",value:function(t){t=O(this,t);for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}},{key:"mulRow",value:function(t,e){_(this,t);for(var r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}},{key:"mulColumn",value:function(t,e){z(this,t);for(var r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}},{key:"max",value:function(t){if(this.isEmpty())return NaN;switch(t){case"row":for(var e=new Array(this.rows).fill(Number.NEGATIVE_INFINITY),r=0;r<this.rows;r++)for(var n=0;n<this.columns;n++)this.get(r,n)>e[r]&&(e[r]=this.get(r,n));return e;case"column":for(var o=new Array(this.columns).fill(Number.NEGATIVE_INFINITY),i=0;i<this.rows;i++)for(var a=0;a<this.columns;a++)this.get(i,a)>o[a]&&(o[a]=this.get(i,a));return o;case void 0:for(var s=this.get(0,0),u=0;u<this.rows;u++)for(var h=0;h<this.columns;h++)this.get(u,h)>s&&(s=this.get(u,h));return s;default:throw new Error("invalid option: ".concat(t))}}},{key:"maxIndex",value:function(){L(this);for(var t=this.get(0,0),e=[0,0],r=0;r<this.rows;r++)for(var n=0;n<this.columns;n++)this.get(r,n)>t&&(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;r<this.rows;r++)for(var n=0;n<this.columns;n++)this.get(r,n)<e[r]&&(e[r]=this.get(r,n));return e;case"column":for(var o=new Array(this.columns).fill(Number.POSITIVE_INFINITY),i=0;i<this.rows;i++)for(var a=0;a<this.columns;a++)this.get(i,a)<o[a]&&(o[a]=this.get(i,a));return o;case void 0:for(var s=this.get(0,0),u=0;u<this.rows;u++)for(var h=0;h<this.columns;h++)this.get(u,h)<s&&(s=this.get(u,h));return s;default:throw new Error("invalid option: ".concat(t))}}},{key:"minIndex",value:function(){L(this);for(var t=this.get(0,0),e=[0,0],r=0;r<this.rows;r++)for(var n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}},{key:"maxRow",value:function(t){if(_(this,t),this.isEmpty())return NaN;for(var e=this.get(t,0),r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}},{key:"maxRowIndex",value:function(t){_(this,t),L(this);for(var e=this.get(t,0),r=[t,0],n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}},{key:"minRow",value:function(t){if(_(this,t),this.isEmpty())return NaN;for(var e=this.get(t,0),r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}},{key:"minRowIndex",value:function(t){_(this,t),L(this);for(var e=this.get(t,0),r=[t,0],n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}},{key:"maxColumn",value:function(t){if(z(this,t),this.isEmpty())return NaN;for(var e=this.get(0,t),r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}},{key:"maxColumnIndex",value:function(t){z(this,t),L(this);for(var e=this.get(0,t),r=[0,t],n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}},{key:"minColumn",value:function(t){if(z(this,t),this.isEmpty())return NaN;for(var e=this.get(0,t),r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}},{key:"minColumnIndex",value:function(t){z(this,t),L(this);for(var e=this.get(0,t),r=[0,t],n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}},{key:"diag",value:function(){for(var t=Math.min(this.rows,this.columns),e=[],r=0;r<t;r++)e.push(this.get(r,r));return e}},{key:"norm",value:function(){var t=arguments.length>0&&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<this.rows;e++)for(var r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}},{key:"dot",value:function(t){e.isMatrix(t)&&(t=t.to1DArray());var r=this.to1DArray();if(r.length!==t.length)throw new RangeError("vectors do not have the same size");for(var n=0,o=0;o<r.length;o++)n+=r[o]*t[o];return n}},{key:"mmul",value:function(t){t=$.checkMatrix(t);for(var e=this.rows,r=this.columns,n=t.columns,o=new $(e,n),i=new Float64Array(r),a=0;a<n;a++){for(var s=0;s<r;s++)i[s]=t.get(s,a);for(var u=0;u<e;u++){for(var h=0,d=0;d<r;d++)h+=this.get(u,d)*i[d];o.set(u,a,h)}}return o}},{key:"mpow",value:function(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");for(var e=$.eye(this.rows),r=this,n=t;n>1;n/=2)0!=(1&n)&&(e=e.mmul(r)),r=r.mmul(r);return e}},{key:"strassen2x2",value:function(t){t=$.checkMatrix(t);var e=new $(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),h=t.get(1,1),d=(r+u)*(n+h),c=(a+u)*n,f=r*(i-h),l=u*(s-n),g=(r+o)*h,v=d+l-g+(o-u)*(s+h),p=f+g,y=c+l,m=d-c+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=$.checkMatrix(t);var e=new $(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),h=this.get(2,1),d=this.get(2,2),c=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)*(c-f+v),E=(i+a)*(-c+f),M=r*c,N=(-r+u+h)*(c-l+p),k=(-r+u)*(l-p),S=(u+h)*(-c+l),A=(-o+h+d)*(v+y-m),_=(o-d)*(v-m),z=o*y,R=(h+d)*(-y+m),O=(-o+a+s)*(p+y-w),I=(o-s)*(p-w),T=(a+s)*(-y+w),P=M+z+n*g,D=(r+n+o-i-a-h-d)*v+b+E+M+A+z+R,C=M+N+S+(r+n+o-a-s-u-h)*p+z+O+T,L=x+a*(-c+f+g-v-p-y+w)+b+M+z+O+I,j=x+b+E+M+s*m,F=z+O+I+T+i*l,q=M+N+k+h*(-c+l+g-v-p-y+m)+A+_+z,V=A+_+z+R+u*f,G=M+N+k+S+d*w;return e.set(0,0,P),e.set(0,1,D),e.set(0,2,C),e.set(1,0,L),e.set(1,1,j),e.set(1,2,F),e.set(2,0,q),e.set(2,1,V),e.set(2,2,G),e}},{key:"mmulStrassen",value:function(t){t=$.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),h=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),h=r.subMatrix(0,a-1,0,u-1),d=n.subMatrix(0,a-1,0,u-1),c=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(h,v),e.add(d,p),a,u),m=t(e.add(l,v),d,a,u),w=t(h,e.sub(f,p),a,u),x=t(v,e.sub(g,d),a,u),b=t(e.add(h,c),p,a,u),E=t(e.sub(l,h),e.add(d,f),a,u),M=t(e.sub(c,v),e.add(g,p),a,u),N=e.add(y,x);N.sub(b),N.add(M);var k=e.add(w,b),S=e.add(m,x),A=e.sub(y,m);A.add(w),A.add(E);var _=e.zeros(2*N.rows,2*N.columns);return(_=(_=(_=(_=_.setSubMatrix(N,0,0)).setSubMatrix(k,N.rows,0)).setSubMatrix(S,0,N.columns)).setSubMatrix(A,N.rows,N.columns)).subMatrix(0,o-1,0,i-1)}(r=s(r,u,h),t=s(t,u,h),u,h)}},{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 $(this.rows,this.columns),a=0;a<this.rows;a++){var s=this.getRow(a);s.length>0&&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 $(this.rows,this.columns),a=0;a<this.columns;a++){var s=this.getColumn(a);s.length&&b(s,{min:r,max:o,output:s}),i.setColumn(a,s)}return i}},{key:"flipRows",value:function(){for(var t=Math.ceil(this.columns/2),e=0;e<this.rows;e++)for(var r=0;r<t;r++){var n=this.get(e,r),o=this.get(e,this.columns-1-r);this.set(e,r,o),this.set(e,this.columns-1-r,n)}return this}},{key:"flipColumns",value:function(){for(var t=Math.ceil(this.rows/2),e=0;e<this.columns;e++)for(var r=0;r<t;r++){var n=this.get(r,e),o=this.get(this.rows-1-r,e);this.set(r,e,o),this.set(this.rows-1-r,e,n)}return this}},{key:"kroneckerProduct",value:function(t){t=$.checkMatrix(t);for(var e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new $(e*n,r*o),a=0;a<e;a++)for(var s=0;s<r;s++)for(var u=0;u<n;u++)for(var h=0;h<o;h++)i.set(n*a+u,o*s+h,this.get(a,s)*t.get(u,h));return i}},{key:"kroneckerSum",value:function(t){if(t=$.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");var e=this.rows,r=t.rows,n=this.kroneckerProduct($.eye(r,r)),o=$.eye(e,e).kroneckerProduct(t);return n.add(o)}},{key:"transpose",value:function(){for(var t=new $(this.columns,this.rows),e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}},{key:"sortRows",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:X,e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}},{key:"sortColumns",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:X,e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}},{key:"subMatrix",value:function(t,e,r,n){P(this,t,e,r,n);for(var o=new $(e-t+1,n-r+1),i=t;i<=e;i++)for(var a=r;a<=n;a++)o.set(i-t,a-r,this.get(i,a));return o}},{key:"subMatrixRow",value:function(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");for(var n=new $(t.length,r-e+1),o=0;o<t.length;o++)for(var i=e;i<=r;i++){if(t[o]<0||t[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 $(r-e+1,t.length),o=0;o<t.length;o++)for(var i=e;i<=r;i++){if(t[o]<0||t[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=$.checkMatrix(t)).isEmpty())return this;P(this,e,e+t.rows-1,r,r+t.columns-1);for(var n=0;n<t.rows;n++)for(var o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}},{key:"selection",value:function(t,e){I(this,t),T(this,e);for(var r=new $(t.length,e.length),n=0;n<t.length;n++)for(var o=t[n],i=0;i<e.length;i++){var a=e[i];r.set(n,i,this.get(o,a))}return r}},{key:"trace",value:function(){for(var t=Math.min(this.rows,this.columns),e=0,r=0;r<t;r++)e+=this.get(r,r);return e}},{key:"clone",value:function(){return this.constructor.copy(this,new $(this.rows,this.columns))}},{key:"sum",value:function(t){switch(t){case"row":return function(t){for(var e=D(t.rows),r=0;r<t.rows;++r)for(var n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){for(var e=D(t.columns),r=0;r<t.rows;++r)for(var n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){for(var e=0,r=0;r<t.rows;r++)for(var n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error("invalid option: ".concat(t))}}},{key:"product",value:function(t){switch(t){case"row":return function(t){for(var e=D(t.rows,1),r=0;r<t.rows;++r)for(var n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){for(var e=D(t.columns,1),r=0;r<t.rows;++r)for(var n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){for(var e=1,r=0;r<t.rows;r++)for(var n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error("invalid option: ".concat(t))}}},{key:"mean",value:function(t){var e=this.sum(t);switch(t){case"row":for(var r=0;r<this.rows;r++)e[r]/=this.columns;return e;case"column":for(var n=0;n<this.columns;n++)e[n]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error("invalid option: ".concat(t))}}},{key:"variance",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,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 j(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;n<r.length;n++)r[n]=Math.sqrt(r[n]);return r}},{key:"center",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,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 G(this,o),this;case void 0:if("number"!=typeof o)throw new TypeError("center must be a number");return B(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=H(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=K(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return J(this,r),this;default:throw new Error("invalid option: ".concat(t))}}},{key:"toString",value:function(t){return N(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(!(e<this.rows)){t.next=12;break}r=0;case 3:if(!(r<this.columns)){t.next=9;break}return t.next=6,[e,r,this.get(e,r)];case 6:r++,t.next=3;break;case 9:e++,t.next=1;break;case 12:case"end":return t.stop()}}),t,this)}))},{key:"values",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(!(e<this.rows)){t.next=12;break}r=0;case 3:if(!(r<this.columns)){t.next=9;break}return t.next=6,this.get(e,r);case 6:r++,t.next=3;break;case 9:e++,t.next=1;break;case 12:case"end":return t.stop()}}),t,this)}))}],[{key:"from1DArray",value:function(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");for(var n=new $(t,e),o=0;o<t;o++)for(var i=0;i<e;i++)n.set(o,i,r[o*e+i]);return n}},{key:"rowVector",value:function(t){for(var e=new $(1,t.length),r=0;r<t.length;r++)e.set(0,r,t[r]);return e}},{key:"columnVector",value:function(t){for(var e=new $(t.length,1),r=0;r<t.length;r++)e.set(r,0,t[r]);return e}},{key:"zeros",value:function(t,e){return new $(t,e)}},{key:"ones",value:function(t,e){return new $(t,e).fill(1)}},{key:"rand",value:function(t,e){var r=arguments.length>2&&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 $(t,e),a=0;a<t;a++)for(var s=0;s<e;s++)i.set(a,s,o());return i}},{key:"randInt",value:function(t,e){var r=arguments.length>2&&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 h=a-o,d=new $(t,e),c=0;c<t;c++)for(var f=0;f<e;f++){var l=o+Math.round(u()*h);d.set(c,f,l)}return d}},{key:"eye",value:function(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);for(var n=Math.min(t,e),o=this.zeros(t,e),i=0;i<n;i++)o.set(i,i,r);return o}},{key:"diag",value:function(t,e,r){var n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);for(var o=Math.min(n,e,r),i=this.zeros(e,r),a=0;a<o;a++)i.set(a,a,t[a]);return i}},{key:"min",value:function(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);for(var r=t.rows,n=t.columns,o=new $(r,n),i=0;i<r;i++)for(var a=0;a<n;a++)o.set(i,a,Math.min(t.get(i,a),e.get(i,a)));return o}},{key:"max",value:function(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);for(var r=t.rows,n=t.columns,o=new this(r,n),i=0;i<r;i++)for(var a=0;a<n;a++)o.set(i,a,Math.max(t.get(i,a),e.get(i,a)));return o}},{key:"checkMatrix",value:function(t){return e.isMatrix(t)?t:new $(t)}},{key:"isMatrix",value:function(t){return null!=t&&"Matrix"===t.klass}},{key:"copy",value:function(t,e){var r,n=v(t.entries());try{for(n.s();!(r=n.n()).done;){var o=g(r.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}}]),e}(Symbol.iterator);function X(t,e){return t-e}Q.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Q.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return N(this)}),Q.random=Q.rand,Q.randomInt=Q.randInt,Q.diagonal=Q.diag,Q.prototype.diagonal=Q.prototype.diag,Q.identity=Q.eye,Q.prototype.negate=Q.prototype.neg,Q.prototype.tensorProduct=Q.prototype.kroneckerProduct;var Z=new WeakSet,$=function(t){h(r,t);var e=d(r);function r(t,n){var o;if(m(this,r),o=e.call(this),c(u(o),Z),f(u(o),"data",void 0),r.isMatrix(t))l(u(o),Z,tt).call(u(o),t.rows,t.columns),r.copy(t,u(o));else if(Number.isInteger(t)&&t>=0)l(u(o),Z,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<t;a++){if(i[a].length!==n)throw new RangeError("Inconsistent array dimensions");if(!i[a].every((function(t){return"number"==typeof t})))throw new TypeError("Input data contains non-numeric values");o.data.push(Float64Array.from(i[a]))}o.rows=t,o.columns=n}return o}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]}},{key:"removeRow",value:function(t){return _(this,t),this.data.splice(t,1),this.rows-=1,this}},{key:"addRow",value:function(t,e){return void 0===e&&(e=t,t=this.rows),_(this,t,!0),e=Float64Array.from(R(this,e)),this.data.splice(t,0,e),this.rows+=1,this}},{key:"removeColumn",value:function(t){z(this,t);for(var e=0;e<this.rows;e++){for(var r=new Float64Array(this.columns-1),n=0;n<t;n++)r[n]=this.data[e][n];for(var o=t+1;o<this.columns;o++)r[o-1]=this.data[e][o];this.data[e]=r}return this.columns-=1,this}},{key:"addColumn",value:function(t,e){void 0===e&&(e=t,t=this.columns),z(this,t,!0),e=O(this,e);for(var r=0;r<this.rows;r++){for(var n=new Float64Array(this.columns+1),o=0;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}]),r}(Q);function tt(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(var r=0;r<t;r++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)+t.get(r,n));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)-t.get(r,n));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)*t.get(r,n));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)/t.get(r,n));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)%t.get(r,n));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)&t.get(r,n));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)|t.get(r,n));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)^t.get(r,n));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)<<t.get(r,n));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)>>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<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,this.get(r,n)>>>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<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(var t=0;t<this.rows;t++)for(var e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(var e=0;e<this.rows;e++)for(var r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t));return this},t.prototype.powM=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<this.rows;r++)for(var n=0;n<this.columns;n++)this.set(r,n,Math.pow(this.get(r,n),t.get(r,n)));return this}}(Q,$);var et=new WeakMap,rt=function(t){h(r,t);var e=d(r);function r(t){var n;if(m(this,r),n=e.call(this),i(u(n),et,{writable:!0,value:void 0}),$.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");a(u(n),et,$.copy(t,new $(t.rows,t.rows)))}else if(Number.isInteger(t)&&t>=0)a(u(n),et,new $(t,t));else if(a(u(n),et,new $(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 $(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<s.length;a++){var u=s[a];this.removeCross(u)}return this}},{key:"toCompact",value:function(){for(var t=this.diagonalSize,e=new Array(t*(t+1)/2),r=0,n=0,o=0;o<e.length;o++)e[o]=this.get(n,r),++r>=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)){t.next=9;break}return n=this.get(e,r),t.next=5,[e,r,n];case 5:++r>=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)){t.next=9;break}return n=this.get(e,r),t.next=5,n;case 5:++r>=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 $.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<e;s++)o.set(i,a,t[s]),++i>=n&&(i=++a);return o}}]),r}(Q);rt.prototype.klassType="SymmetricMatrix";var nt=function(t){h(r,t);var e=d(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<e.length;o++)e[o]=this.get(n,r),++r>=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<e;a++)n.set(o,i,t[a]),++o>=r&&(o=1+ ++i);return n}}]),r}(rt);nt.prototype.klassSubType="DistanceMatrix";var ot=function(t){h(r,t);var e=d(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)}(Q),it=function(t){h(r,t);var e=d(r);function r(t,n){var o;return m(this,r),z(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){h(r,t);var e=d(r);function r(t,n){var o;return m(this,r),T(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){h(r,t);var e=d(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){h(r,t);var e=d(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),ht=function(t){h(r,t);var e=d(r);function r(t,n){var o;return m(this,r),_(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),dt=function(t){h(r,t);var e=d(r);function r(t,n){var o;return m(this,r),I(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),ct=function(t){h(r,t);var e=d(r);function r(t,n,o){var i;return m(this,r),I(t,n),T(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){h(r,t);var e=d(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){h(r,t);var e=d(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){h(r,t);var e=d(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}(Q),vt=function(t){h(r,t);var e=d(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}(Q);var pt=function(){function t(e){m(this,t);var r,n,o,i,a,s,u,h,d,c=(e=vt.checkMatrix(e)).clone(),f=c.rows,l=c.columns,g=new Float64Array(f),v=1;for(r=0;r<f;r++)g[r]=r;for(h=new Float64Array(f),n=0;n<l;n++){for(r=0;r<f;r++)h[r]=c.get(r,n);for(r=0;r<f;r++){for(d=Math.min(r,n),a=0,o=0;o<d;o++)a+=c.get(r,o)*h[o];h[r]-=a,c.set(r,n,h[r])}for(i=n,r=n+1;r<f;r++)Math.abs(h[r])>Math.abs(h[i])&&(i=r);if(i!==n){for(o=0;o<l;o++)s=c.get(i,o),c.set(i,o,c.get(n,o)),c.set(n,o,s);u=g[i],g[i]=g[n],g[n]=u,v=-v}if(n<f&&0!==c.get(n,n))for(r=n+1;r<f;r++)c.set(r,n,c.get(r,n)/c.get(n,n))}this.LU=c,this.pivotVector=g,this.pivotSign=v}return w(t,[{key:"isSingular",value:function(){for(var t=this.LU,e=t.columns,r=0;r<e;r++)if(0===t.get(r,r))return!0;return!1}},{key:"solve",value:function(t){t=$.checkMatrix(t);var e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");var r,n,o,i=t.columns,a=t.subMatrixRow(this.pivotVector,0,i-1),s=e.columns;for(o=0;o<s;o++)for(r=o+1;r<s;r++)for(n=0;n<i;n++)a.set(r,n,a.get(r,n)-a.get(o,n)*e.get(r,o));for(o=s-1;o>=0;o--){for(n=0;n<i;n++)a.set(o,n,a.get(o,n)/e.get(o,o));for(r=0;r<o;r++)for(n=0;n<i;n++)a.set(r,n,a.get(r,n)-a.get(o,n)*e.get(r,o))}return a}},{key:"determinant",get:function(){var t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");for(var e=this.pivotSign,r=t.columns,n=0;n<r;n++)e*=t.get(n,n);return e}},{key:"lowerTriangularMatrix",get:function(){for(var t=this.LU,e=t.rows,r=t.columns,n=new $(e,r),o=0;o<e;o++)for(var i=0;i<r;i++)o>i?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 $(e,r),o=0;o<e;o++)for(var i=0;i<r;i++)o<=i?n.set(o,i,t.get(o,i)):n.set(o,i,0);return n}},{key:"pivotPermutationVector",get:function(){return Array.from(this.pivotVector)}}]),t}();function yt(t,e){var r=0;return Math.abs(t)>Math.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,h=new Float64Array(u);for(o=0;o<u;o++){var d=0;for(r=o;r<s;r++)d=yt(d,a.get(r,o));if(0!==d){for(a.get(o,o)<0&&(d=-d),r=o;r<s;r++)a.set(r,o,a.get(r,o)/d);for(a.set(o,o,a.get(o,o)+1),n=o+1;n<u;n++){for(i=0,r=o;r<s;r++)i+=a.get(r,o)*a.get(r,n);for(i=-i/a.get(o,o),r=o;r<s;r++)a.set(r,n,a.get(r,n)+i*a.get(r,o))}}h[o]=-d}this.QR=a,this.Rdiag=h}return w(t,[{key:"solve",value:function(t){t=$.checkMatrix(t);var e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");var n,o,i,a,s=t.columns,u=t.clone(),h=e.columns;for(i=0;i<h;i++)for(o=0;o<s;o++){for(a=0,n=i;n<r;n++)a+=e.get(n,i)*u.get(n,o);for(a=-a/e.get(i,i),n=i;n<r;n++)u.set(n,o,u.get(n,o)+a*e.get(n,i))}for(i=h-1;i>=0;i--){for(o=0;o<s;o++)u.set(i,o,u.get(i,o)/this.Rdiag[i]);for(n=0;n<i;n++)for(o=0;o<s;o++)u.set(n,o,u.get(n,o)-u.get(i,o)*e.get(n,i))}return u.subMatrix(0,h-1,0,s-1)}},{key:"isFullRank",value:function(){for(var t=this.QR.columns,e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}},{key:"upperTriangularMatrix",get:function(){var t,e,r=this.QR,n=r.columns,o=new $(n,n);for(t=0;t<n;t++)for(e=0;e<n;e++)t<e?o.set(t,e,r.get(t,e)):t===e?o.set(t,e,this.Rdiag[t]):o.set(t,e,0);return o}},{key:"orthogonalMatrix",get:function(){var t,e,r,n,o=this.QR,i=o.rows,a=o.columns,s=new $(i,a);for(r=a-1;r>=0;r--){for(t=0;t<i;t++)s.set(t,r,0);for(s.set(r,r,1),e=r;e<a;e++)if(0!==o.get(r,r)){for(n=0,t=r;t<i;t++)n+=o.get(t,r)*s.get(t,e);for(n=-n/o.get(r,r),t=r;t<i;t++)s.set(t,e,s.get(t,e)+n*o.get(t,r))}}return s}}]),t}(),wt=function(){function t(e){var r=arguments.length>1&&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,h=void 0===u||u,d=r.autoTranspose,c=void 0!==d&&d,f=Boolean(s),l=Boolean(h),g=!1;if(o<i)if(c){o=(n=e.transpose()).rows,i=n.columns,g=!0;var v=f;f=l,l=v}else n=e.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else n=e.clone();for(var p=Math.min(o,i),y=Math.min(o+1,i),w=new Float64Array(y),x=new $(o,p),b=new $(i,i),E=new Float64Array(i),M=new Float64Array(o),N=new Float64Array(y),k=0;k<y;k++)N[k]=k;for(var S=Math.min(o-1,i),A=Math.max(0,Math.min(i-2,o)),_=Math.max(S,A),z=0;z<_;z++){if(z<S){w[z]=0;for(var R=z;R<o;R++)w[z]=yt(w[z],n.get(R,z));if(0!==w[z]){n.get(z,z)<0&&(w[z]=-w[z]);for(var O=z;O<o;O++)n.set(O,z,n.get(O,z)/w[z]);n.set(z,z,n.get(z,z)+1)}w[z]=-w[z]}for(var I=z+1;I<i;I++){if(z<S&&0!==w[z]){for(var T=0,P=z;P<o;P++)T+=n.get(P,z)*n.get(P,I);T=-T/n.get(z,z);for(var D=z;D<o;D++)n.set(D,I,n.get(D,I)+T*n.get(D,z))}E[I]=n.get(z,I)}if(f&&z<S)for(var C=z;C<o;C++)x.set(C,z,n.get(C,z));if(z<A){E[z]=0;for(var L=z+1;L<i;L++)E[z]=yt(E[z],E[L]);if(0!==E[z]){E[z+1]<0&&(E[z]=0-E[z]);for(var j=z+1;j<i;j++)E[j]/=E[z];E[z+1]+=1}if(E[z]=-E[z],z+1<o&&0!==E[z]){for(var F=z+1;F<o;F++)M[F]=0;for(var q=z+1;q<o;q++)for(var V=z+1;V<i;V++)M[q]+=E[V]*n.get(q,V);for(var G=z+1;G<i;G++)for(var B=-E[G]/E[z+1],U=z+1;U<o;U++)n.set(U,G,n.get(U,G)+B*M[U])}if(l)for(var W=z+1;W<i;W++)b.set(W,z,E[W])}}var H=Math.min(i,o+1);if(S<i&&(w[S]=n.get(S,S)),o<H&&(w[H-1]=0),A+1<H&&(E[A]=n.get(A,H-1)),E[H-1]=0,f){for(var Y=S;Y<p;Y++){for(var K=0;K<o;K++)x.set(K,Y,0);x.set(Y,Y,1)}for(var J=S-1;J>=0;J--)if(0!==w[J]){for(var Q=J+1;Q<p;Q++){for(var X=0,Z=J;Z<o;Z++)X+=x.get(Z,J)*x.get(Z,Q);X=-X/x.get(J,J);for(var tt=J;tt<o;tt++)x.set(tt,Q,x.get(tt,Q)+X*x.get(tt,J))}for(var et=J;et<o;et++)x.set(et,J,-x.get(et,J));x.set(J,J,1+x.get(J,J));for(var rt=0;rt<J-1;rt++)x.set(rt,J,0)}else{for(var nt=0;nt<o;nt++)x.set(nt,J,0);x.set(J,J,1)}}if(l)for(var ot=i-1;ot>=0;ot--){if(ot<A&&0!==E[ot])for(var it=ot+1;it<i;it++){for(var at=0,st=ot+1;st<i;st++)at+=b.get(st,ot)*b.get(st,it);at=-at/b.get(ot+1,ot);for(var ut=ot+1;ut<i;ut++)b.set(ut,it,b.get(ut,it)+at*b.get(ut,ot))}for(var ht=0;ht<i;ht++)b.set(ht,ot,0);b.set(ot,ot,1)}for(var dt=H-1,ct=Number.EPSILON;H>0;){var ft=void 0,lt=void 0;for(ft=H-2;ft>=-1&&-1!==ft;ft--){var gt=Number.MIN_VALUE+ct*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===H-2)lt=4;else{var pt=void 0;for(pt=H-1;pt>=ft&&pt!==ft;pt--){var mt=(pt!==H?Math.abs(E[pt]):0)+(pt!==ft+1?Math.abs(E[pt-1]):0);if(Math.abs(w[pt])<=ct*mt){w[pt]=0;break}}pt===ft?lt=3:pt===H-1?lt=1:(lt=2,ft=pt)}switch(ft++,lt){case 1:var wt=E[H-2];E[H-2]=0;for(var xt=H-2;xt>=ft;xt--){var bt=yt(w[xt],wt),Et=w[xt]/bt,Mt=wt/bt;if(w[xt]=bt,xt!==ft&&(wt=-Mt*E[xt-1],E[xt-1]=Et*E[xt-1]),l)for(var Nt=0;Nt<i;Nt++)bt=Et*b.get(Nt,xt)+Mt*b.get(Nt,H-1),b.set(Nt,H-1,-Mt*b.get(Nt,xt)+Et*b.get(Nt,H-1)),b.set(Nt,xt,bt)}break;case 2:var kt=E[ft-1];E[ft-1]=0;for(var St=ft;St<H;St++){var At=yt(w[St],kt),_t=w[St]/At,zt=kt/At;if(w[St]=At,kt=-zt*E[St],E[St]=_t*E[St],f)for(var Rt=0;Rt<o;Rt++)At=_t*x.get(Rt,St)+zt*x.get(Rt,ft-1),x.set(Rt,ft-1,-zt*x.get(Rt,St)+_t*x.get(Rt,ft-1)),x.set(Rt,St,At)}break;case 3:var Ot=Math.max(Math.abs(w[H-1]),Math.abs(w[H-2]),Math.abs(E[H-2]),Math.abs(w[ft]),Math.abs(E[ft])),It=w[H-1]/Ot,Tt=w[H-2]/Ot,Pt=E[H-2]/Ot,Dt=w[ft]/Ot,Ct=E[ft]/Ot,Lt=((Tt+It)*(Tt-It)+Pt*Pt)/2,jt=It*Pt*(It*Pt),Ft=0;0===Lt&&0===jt||(Ft=jt/(Lt+(Ft=Lt<0?0-Math.sqrt(Lt*Lt+jt):Math.sqrt(Lt*Lt+jt))));for(var qt=(Dt+It)*(Dt-It)+Ft,Vt=Dt*Ct,Gt=ft;Gt<H-1;Gt++){var Bt=yt(qt,Vt);0===Bt&&(Bt=Number.MIN_VALUE);var Ut=qt/Bt,Wt=Vt/Bt;if(Gt!==ft&&(E[Gt-1]=Bt),qt=Ut*w[Gt]+Wt*E[Gt],E[Gt]=Ut*E[Gt]-Wt*w[Gt],Vt=Wt*w[Gt+1],w[Gt+1]=Ut*w[Gt+1],l)for(var Ht=0;Ht<i;Ht++)Bt=Ut*b.get(Ht,Gt)+Wt*b.get(Ht,Gt+1),b.set(Ht,Gt+1,-Wt*b.get(Ht,Gt)+Ut*b.get(Ht,Gt+1)),b.set(Ht,Gt,Bt);if(0===(Bt=yt(qt,Vt))&&(Bt=Number.MIN_VALUE),Ut=qt/Bt,Wt=Vt/Bt,w[Gt]=Bt,qt=Ut*E[Gt]+Wt*w[Gt+1],w[Gt+1]=-Wt*E[Gt]+Ut*w[Gt+1],Vt=Wt*E[Gt+1],E[Gt+1]=Ut*E[Gt+1],f&&Gt<o-1)for(var Yt=0;Yt<o;Yt++)Bt=Ut*x.get(Yt,Gt)+Wt*x.get(Yt,Gt+1),x.set(Yt,Gt+1,-Wt*x.get(Yt,Gt)+Ut*x.get(Yt,Gt+1)),x.set(Yt,Gt,Bt)}E[H-2]=qt;break;case 4:if(w[ft]<=0&&(w[ft]=w[ft]<0?-w[ft]:0,l))for(var Kt=0;Kt<=dt;Kt++)b.set(Kt,ft,-b.get(Kt,ft));for(;ft<dt&&!(w[ft]>=w[ft+1]);){var Jt=w[ft];if(w[ft]=w[ft+1],w[ft+1]=Jt,l&&ft<i-1)for(var Qt=0;Qt<i;Qt++)Jt=b.get(Qt,ft+1),b.set(Qt,ft+1,b.get(Qt,ft)),b.set(Qt,ft,Jt);if(f&&ft<o-1)for(var Xt=0;Xt<o;Xt++)Jt=x.get(Xt,ft+1),x.set(Xt,ft+1,x.get(Xt,ft)),x.set(Xt,ft,Jt);ft++}H--}}if(g){var Zt=b;b=x,x=Zt}this.m=o,this.n=i,this.s=w,this.U=x,this.V=b}return w(t,[{key:"solve",value:function(t){for(var e=t,r=this.threshold,n=this.s.length,o=$.zeros(n,n),i=0;i<n;i++)Math.abs(this.s[i])<=r?o.set(i,i,0):o.set(i,i,1/this.s[i]);for(var a=this.U,s=this.rightSingularVectors,u=s.mmul(o),h=s.rows,d=a.rows,c=$.zeros(h,d),f=0;f<h;f++)for(var l=0;l<d;l++){for(var g=0,v=0;v<n;v++)g+=u.get(f,v)*a.get(l,v);c.set(f,l,g)}return c.mmul(e)}},{key:"solveForDiagonal",value:function(t){return this.solve($.diag(t))}},{key:"inverse",value:function(){for(var t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new $(r,this.s.length),i=0;i<r;i++)for(var a=0;a<n;a++)Math.abs(this.s[a])>e&&o.set(i,a,t.get(i,a)/this.s[a]);for(var s=this.U,u=s.rows,h=s.columns,d=new $(r,u),c=0;c<r;c++)for(var f=0;f<u;f++){for(var l=0,g=0;g<h;g++)l+=o.get(c,g)*s.get(f,g);d.set(c,f,l)}return d}},{key:"condition",get:function(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}},{key:"norm2",get:function(){return this.s[0]}},{key:"rank",get:function(){for(var t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s,n=0,o=r.length;n<o;n++)r[n]>t&&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 $.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;n<t;n++)n!==e&&r.push(n);return r}function Et(t,e,r){var n=arguments.length>3&&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;a<i.rows;a++)Math.abs(i.get(a,0))<n&&i.set(a,0,0);return i.to1DArray()}var Mt=function(){function t(e){var r=arguments.length>1&&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 $(s,s),h=new Float64Array(s),d=new Float64Array(s),c=e;if(!!o||e.isSymmetric()){for(i=0;i<s;i++)for(a=0;a<s;a++)u.set(i,a,c.get(i,a));Nt(s,d,h,u),kt(s,d,h,u)}else{var f=new $(s,s),l=new Float64Array(s);for(a=0;a<s;a++)for(i=0;i<s;i++)f.set(i,a,c.get(i,a));St(s,f,l,u),At(s,d,h,u,f)}this.n=s,this.e=d,this.d=h,this.V=u}return w(t,[{key:"realEigenvalues",get:function(){return Array.from(this.d)}},{key:"imaginaryEigenvalues",get:function(){return Array.from(this.e)}},{key:"eigenvectorMatrix",get:function(){return this.V}},{key:"diagonalMatrix",get:function(){var t,e,r=this.n,n=this.e,o=this.d,i=new $(r,r);for(t=0;t<r;t++){for(e=0;e<r;e++)i.set(t,e,0);i.set(t,t,o[t]),n[t]>0?i.set(t,t+1,n[t]):n[t]<0&&i.set(t,t-1,n[t])}return i}}]),t}();function Nt(t,e,r,n){var o,i,a,s,u,h,d,c;for(u=0;u<t;u++)r[u]=n.get(t-1,u);for(s=t-1;s>0;s--){for(c=0,a=0,h=0;h<s;h++)c+=Math.abs(r[h]);if(0===c)for(e[s]=r[s-1],u=0;u<s;u++)r[u]=n.get(s-1,u),n.set(s,u,0),n.set(u,s,0);else{for(h=0;h<s;h++)r[h]/=c,a+=r[h]*r[h];for(o=r[s-1],i=Math.sqrt(a),o>0&&(i=-i),e[s]=c*i,a-=o*i,r[s-1]=o-i,u=0;u<s;u++)e[u]=0;for(u=0;u<s;u++){for(o=r[u],n.set(u,s,o),i=e[u]+n.get(u,u)*o,h=u+1;h<=s-1;h++)i+=n.get(h,u)*r[h],e[h]+=n.get(h,u)*o;e[u]=i}for(o=0,u=0;u<s;u++)e[u]/=a,o+=e[u]*r[u];for(d=o/(a+a),u=0;u<s;u++)e[u]-=d*r[u];for(u=0;u<s;u++){for(o=r[u],i=e[u],h=u;h<=s-1;h++)n.set(h,u,n.get(h,u)-(o*e[h]+i*r[h]));r[u]=n.get(s-1,u),n.set(s,u,0)}}r[s]=a}for(s=0;s<t-1;s++){if(n.set(t-1,s,n.get(s,s)),n.set(s,s,1),0!==(a=r[s+1])){for(h=0;h<=s;h++)r[h]=n.get(h,s+1)/a;for(u=0;u<=s;u++){for(i=0,h=0;h<=s;h++)i+=n.get(h,s+1)*n.get(h,u);for(h=0;h<=s;h++)n.set(h,u,n.get(h,u)-i*r[h])}}for(h=0;h<=s;h++)n.set(h,s+1,0)}for(u=0;u<t;u++)r[u]=n.get(t-1,u),n.set(t-1,u,0);n.set(t-1,t-1,1),e[0]=0}function kt(t,e,r,n){var o,i,a,s,u,h,d,c,f,l,g,v,p,y,m,w;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;var x=0,b=0,E=Number.EPSILON;for(h=0;h<t;h++){for(b=Math.max(b,Math.abs(r[h])+Math.abs(e[h])),d=h;d<t&&!(Math.abs(e[d])<=E*b);)d++;if(d>h)do{for(o=r[h],f=yt(c=(r[h+1]-o)/(2*e[h]),1),c<0&&(f=-f),r[h]=e[h]/(c+f),r[h+1]=e[h]*(c+f),l=r[h+1],i=o-r[h],a=h+2;a<t;a++)r[a]-=i;for(x+=i,c=r[d],v=g=1,p=g,y=e[h+1],m=0,w=0,a=d-1;a>=h;a--)for(p=v,v=g,w=m,o=g*e[a],i=g*c,f=yt(c,e[a]),e[a+1]=m*f,m=e[a]/f,c=(g=c/f)*r[a]-m*o,r[a+1]=i+m*(g*o+m*r[a]),u=0;u<t;u++)i=n.get(u,a+1),n.set(u,a+1,m*n.get(u,a)+g*i),n.set(u,a,g*n.get(u,a)-m*i);c=-m*w*p*y*e[h]/l,e[h]=m*c,r[h]=g*c}while(Math.abs(e[h])>E*b);r[h]=r[h]+x,e[h]=0}for(a=0;a<t-1;a++){for(u=a,c=r[a],s=a+1;s<t;s++)r[s]<c&&(u=s,c=r[s]);if(u!==a)for(r[u]=r[a],r[a]=c,s=0;s<t;s++)c=n.get(s,a),n.set(s,a,n.get(s,u)),n.set(s,u,c)}}function St(t,e,r,n){var o,i,a,s,u,h,d,c=t-1;for(h=1;h<=c-1;h++){for(d=0,s=h;s<=c;s++)d+=Math.abs(e.get(s,h-1));if(0!==d){for(a=0,s=c;s>=h;s--)r[s]=e.get(s,h-1)/d,a+=r[s]*r[s];for(i=Math.sqrt(a),r[h]>0&&(i=-i),a-=r[h]*i,r[h]=r[h]-i,u=h;u<t;u++){for(o=0,s=c;s>=h;s--)o+=r[s]*e.get(s,u);for(o/=a,s=h;s<=c;s++)e.set(s,u,e.get(s,u)-o*r[s])}for(s=0;s<=c;s++){for(o=0,u=c;u>=h;u--)o+=r[u]*e.get(s,u);for(o/=a,u=h;u<=c;u++)e.set(s,u,e.get(s,u)-o*r[u])}r[h]=d*r[h],e.set(h,h-1,d*i)}}for(s=0;s<t;s++)for(u=0;u<t;u++)n.set(s,u,s===u?1:0);for(h=c-1;h>=1;h--)if(0!==e.get(h,h-1)){for(s=h+1;s<=c;s++)r[s]=e.get(s,h-1);for(u=h;u<=c;u++){for(i=0,s=h;s<=c;s++)i+=r[s]*n.get(s,u);for(i=i/r[h]/e.get(h,h-1),s=h;s<=c;s++)n.set(s,u,n.get(s,u)+i*r[s])}}}function At(t,e,r,n,o){var i,a,s,u,h,d,c,f,l,g,v,p,y,m,w,x=t-1,b=t-1,E=Number.EPSILON,M=0,N=0,k=0,S=0,A=0,_=0,z=0,R=0;for(i=0;i<t;i++)for((i<0||i>b)&&(r[i]=o.get(i,i),e[i]=0),a=Math.max(i-1,0);a<t;a++)N+=Math.abs(o.get(i,a));for(;x>=0;){for(u=x;u>0&&(0===(_=Math.abs(o.get(u-1,u-1))+Math.abs(o.get(u,u)))&&(_=N),!(Math.abs(o.get(u,u-1))<E*_));)u--;if(u===x)o.set(x,x,o.get(x,x)+M),r[x]=o.get(x,x),e[x]=0,x--,R=0;else if(u===x-1){if(c=o.get(x,x-1)*o.get(x-1,x),S=(k=(o.get(x-1,x-1)-o.get(x,x))/2)*k+c,z=Math.sqrt(Math.abs(S)),o.set(x,x,o.get(x,x)+M),o.set(x-1,x-1,o.get(x-1,x-1)+M),f=o.get(x,x),S>=0){for(z=k>=0?k+z:k-z,r[x-1]=f+z,r[x]=r[x-1],0!==z&&(r[x]=f-c/z),e[x-1]=0,e[x]=0,k=(f=o.get(x,x-1))/(_=Math.abs(f)+Math.abs(z)),S=z/_,k/=A=Math.sqrt(k*k+S*S),S/=A,a=x-1;a<t;a++)z=o.get(x-1,a),o.set(x-1,a,S*z+k*o.get(x,a)),o.set(x,a,S*o.get(x,a)-k*z);for(i=0;i<=x;i++)z=o.get(i,x-1),o.set(i,x-1,S*z+k*o.get(i,x)),o.set(i,x,S*o.get(i,x)-k*z);for(i=0;i<=b;i++)z=n.get(i,x-1),n.set(i,x-1,S*z+k*n.get(i,x)),n.set(i,x,S*n.get(i,x)-k*z)}else r[x-1]=f+k,r[x]=f+k,e[x-1]=z,e[x]=-z;x-=2,R=0}else{if(f=o.get(x,x),l=0,c=0,u<x&&(l=o.get(x-1,x-1),c=o.get(x,x-1)*o.get(x-1,x)),10===R){for(M+=f,i=0;i<=x;i++)o.set(i,i,o.get(i,i)-f);f=l=.75*(_=Math.abs(o.get(x,x-1))+Math.abs(o.get(x-1,x-2))),c=-.4375*_*_}if(30===R&&(_=(_=(l-f)/2)*_+c)>0){for(_=Math.sqrt(_),l<f&&(_=-_),_=f-c/((l-f)/2+_),i=0;i<=x;i++)o.set(i,i,o.get(i,i)-_);M+=_,f=l=c=.964}for(R+=1,h=x-2;h>=u&&(k=((A=f-(z=o.get(h,h)))*(_=l-z)-c)/o.get(h+1,h)+o.get(h,h+1),S=o.get(h+1,h+1)-z-A-_,A=o.get(h+2,h+1),k/=_=Math.abs(k)+Math.abs(S)+Math.abs(A),S/=_,A/=_,h!==u)&&!(Math.abs(o.get(h,h-1))*(Math.abs(S)+Math.abs(A))<E*(Math.abs(k)*(Math.abs(o.get(h-1,h-1))+Math.abs(z)+Math.abs(o.get(h+1,h+1)))));)h--;for(i=h+2;i<=x;i++)o.set(i,i-2,0),i>h+2&&o.set(i,i-3,0);for(s=h;s<=x-1&&(m=s!==x-1,s!==h&&(k=o.get(s,s-1),S=o.get(s+1,s-1),A=m?o.get(s+2,s-1):0,0!==(f=Math.abs(k)+Math.abs(S)+Math.abs(A))&&(k/=f,S/=f,A/=f)),0!==f);s++)if(_=Math.sqrt(k*k+S*S+A*A),k<0&&(_=-_),0!==_){for(s!==h?o.set(s,s-1,-_*f):u!==h&&o.set(s,s-1,-o.get(s,s-1)),f=(k+=_)/_,l=S/_,z=A/_,S/=k,A/=k,a=s;a<t;a++)k=o.get(s,a)+S*o.get(s+1,a),m&&(k+=A*o.get(s+2,a),o.set(s+2,a,o.get(s+2,a)-k*z)),o.set(s,a,o.get(s,a)-k*f),o.set(s+1,a,o.get(s+1,a)-k*l);for(i=0;i<=Math.min(x,s+3);i++)k=f*o.get(i,s)+l*o.get(i,s+1),m&&(k+=z*o.get(i,s+2),o.set(i,s+2,o.get(i,s+2)-k*A)),o.set(i,s,o.get(i,s)-k),o.set(i,s+1,o.get(i,s+1)-k*S);for(i=0;i<=b;i++)k=f*n.get(i,s)+l*n.get(i,s+1),m&&(k+=z*n.get(i,s+2),n.set(i,s+2,n.get(i,s+2)-k*A)),n.set(i,s,n.get(i,s)-k),n.set(i,s+1,n.get(i,s+1)-k*S)}}}if(0!==N){for(x=t-1;x>=0;x--)if(k=r[x],0===(S=e[x]))for(u=x,o.set(x,x,1),i=x-1;i>=0;i--){for(c=o.get(i,i)-k,A=0,a=u;a<=x;a++)A+=o.get(i,a)*o.get(a,x);if(e[i]<0)z=c,_=A;else if(u=i,0===e[i]?o.set(i,x,0!==c?-A/c:-A/(E*N)):(f=o.get(i,i+1),l=o.get(i+1,i),d=(f*_-z*A)/(S=(r[i]-k)*(r[i]-k)+e[i]*e[i]),o.set(i,x,d),o.set(i+1,x,Math.abs(f)>Math.abs(z)?(-A-c*d)/f:(-_-l*d)/z)),E*(d=Math.abs(o.get(i,x)))*d>1)for(a=i;a<=x;a++)o.set(a,x,o.get(a,x)/d)}else if(S<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,S/o.get(x,x-1)),o.set(x-1,x,-(o.get(x,x)-k)/o.get(x,x-1))):(w=_t(0,-o.get(x-1,x),o.get(x-1,x-1)-k,S),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(c=o.get(i,i)-k,e[i]<0)z=c,A=g,_=v;else if(u=i,0===e[i]?(w=_t(-g,-v,c,S),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]-k)*(r[i]-k)+e[i]*e[i]-S*S,y=2*(r[i]-k)*S,0===p&&0===y&&(p=E*N*(Math.abs(c)+Math.abs(S)+Math.abs(f)+Math.abs(l)+Math.abs(z))),w=_t(f*A-z*g+S*v,f*_-z*v-S*g,p,y),o.set(i,x-1,w[0]),o.set(i,x,w[1]),Math.abs(f)>Math.abs(z)+Math.abs(S)?(o.set(i+1,x-1,(-g-c*o.get(i,x-1)+S*o.get(i,x))/f),o.set(i+1,x,(-v-c*o.get(i,x)-S*o.get(i,x-1))/f)):(w=_t(-A-l*o.get(i,x-1),-_-l*o.get(i,x),z,S),o.set(i+1,x-1,w[0]),o.set(i+1,x,w[1]))),E*(d=Math.max(Math.abs(o.get(i,x-1)),Math.abs(o.get(i,x))))*d>1)for(a=i;a<=x;a++)o.set(a,x-1,o.get(a,x-1)/d),o.set(a,x,o.get(a,x)/d)}for(i=0;i<t;i++)if(i<0||i>b)for(a=i;a<t;a++)n.set(i,a,o.get(i,a));for(a=t-1;a>=0;a--)for(i=0;i<=b;i++){for(z=0,s=0;s<=Math.min(a,b);s++)z+=n.get(i,s)*o.get(s,a);n.set(i,a,z)}}}function _t(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 zt=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 $(a,a),u=!0;for(n=0;n<a;n++){var h=0;for(o=0;o<n;o++){var d=0;for(r=0;r<o;r++)d+=s.get(o,r)*s.get(n,r);d=(i.get(n,o)-d)/s.get(o,o),s.set(n,o,d),h+=d*d}for(h=i.get(n,n)-h,u&&(u=h>0),s.set(n,n,Math.sqrt(Math.max(h,0))),o=n+1;o<a;o++)s.set(n,o,0)}this.L=s,this.positiveDefinite=u}return w(t,[{key:"isPositiveDefinite",value:function(){return this.positiveDefinite}},{key:"solve",value:function(t){t=vt.checkMatrix(t);var e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");var n,o,i,a=t.columns,s=t.clone();for(i=0;i<r;i++)for(o=0;o<a;o++){for(n=0;n<i;n++)s.set(i,o,s.get(i,o)-s.get(n,o)*e.get(i,n));s.set(i,o,s.get(i,o)/e.get(i,i))}for(i=r-1;i>=0;i--)for(o=0;o<a;o++){for(n=i+1;n<r;n++)s.set(i,o,s.get(i,o)-s.get(n,o)*e.get(n,i));s.set(i,o,s.get(i,o)/e.get(i,i))}return s}},{key:"lowerTriangularMatrix",get:function(){return this.L}}]),t}(),Rt=w((function t(e){var r=arguments.length>1&&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,h=r.terminationCriteria,d=void 0===h?1e-10:h;if(o){if((o=x.isAnyArray(o)&&"number"==typeof o[0]?$.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 c,f,l,g,v=1,p=0;p<u&&v>d;p++)l=(l=e.transpose().mmul(n).div(n.transpose().mmul(n).get(0,0))).div(l.norm()),c=e.mmul(l).div(l.transpose().mmul(l).get(0,0)),p>0&&(v=c.clone().sub(g).pow(2).sum()),g=c.clone(),o?(f=(f=o.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0))).div(f.norm()),n=o.mmul(f).div(f.transpose().mmul(f).get(0,0))):n=c;if(o){var y=e.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0));y=y.div(y.norm());var w=e.clone().sub(c.clone().mmul(y.transpose())),b=n.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0)),E=o.clone().sub(c.clone().mulS(b.get(0,0)).mmul(f.transpose()));this.t=c,this.p=y.transpose(),this.w=l.transpose(),this.q=f,this.u=n,this.s=c.transpose().mmul(c),this.xResidual=w,this.yResidual=E,this.betas=b}else this.w=l.transpose(),this.s=c.transpose().mmul(c).sqrt(),this.t=a?c.clone().div(this.s.get(0,0)):c,this.xResidual=e.sub(c.mmul(l.transpose()))}));e.XA=Q,e.a_=zt,e.yQ=zt,e.Hs=nt,e.Ec=Mt,e.dx=Mt,e.LU=pt,e.Rm=pt,e.y3=$,e.qK=at,e.pb=it,e.j=st,e.sO=ut,e.BZ=dt,e.EK=ht,e.Db=ct,e.Fx=ft,e.tU=lt,e.Ym=Rt,e.rs=Rt,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 $(t);var n=!1;if("object"!==y(e)||$.isMatrix(e)||x.isAnyArray(e)?e=new $(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 h=t.standardDeviation("column",{unbiased:!0}),d=n?h:e.standardDeviation("column",{unbiased:!0}),c=t.transpose().mmul(e),f=0;f<c.rows;f++)for(var l=0;l<c.columns;l++)c.set(f,l,c.get(f,l)*(1/(h[f]*d[l]))*(1/(t.rows-1)));return c},e.AV=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 $(t);var n=!1;if("object"!==y(e)||$.isMatrix(e)||x.isAnyArray(e)?e=new $(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;u<s.rows;u++)for(var h=0;h<s.columns;h++)s.set(u,h,s.get(u,h)*(1/(t.rows-1)));return s},e.GH=function t(e){var r,n,o,i,a,s;if((e=$.checkMatrix(e)).isSquare())return 0===e.columns?1:2===e.columns?(r=e.get(0,0),n=e.get(0,1),o=e.get(1,0),r*e.get(1,1)-n*o):3===e.columns?(i=new ct(e,[1,2],[1,2]),a=new ct(e,[1,2],[0,2]),s=new ct(e,[1,2],[0,1]),r=e.get(0,0),n=e.get(0,1),o=e.get(0,2),r*t(i)-n*t(a)+o*t(s)):new pt(e).determinant;throw Error("determinant can only be calculated for a square matrix")},e.SO=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t=vt.checkMatrix(t),e?new wt(t).inverse():xt(t,$.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=$.checkMatrix(t)).rows,s=new $(a,a),u=0;u<a;u++){var h=$.columnVector(t.getRow(u)),d=t.subMatrixRow(bt(a,u)).transpose(),c=new wt(d),f=c.solve(h),l=$.sub(h,d.mmul(f)).abs().max();s.setRow(u,Et(l,f,u,n,i))}return s},e.yU=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.EPSILON;if((t=$.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;a<i.length;a++)Math.abs(i[a])>e?i[a]=1/i[a]:i[a]=0;return o.mmul($.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")}},12751: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")}},6701:function(t,e,r){"use strict";r.r(e),r.d(e,{default:function(){return a}});var n=r(12751);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;u<a;u++)t[u]>s&&(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;u<a;u++)t[u]<s&&(s=t[u]);return s}function a(t){var e,r=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");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,h=void 0===u?r.autoMinMax?a:0:u,d=r.max,c=void 0===d?r.autoMinMax?s:1:d;if(h>=c)throw new RangeError("min option must be smaller than max option");for(var f=(c-h)/(s-a),l=0;l<t.length;l++)e[l]=(t[l]-a)*f+h;return e}},88513:function(t){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n},t.exports.__esModule=!0,t.exports.default=t.exports},51464:function(t){t.exports=function(t){if(Array.isArray(t))return t},t.exports.__esModule=!0,t.exports.default=t.exports},41553:function(t){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports.__esModule=!0,t.exports.default=t.exports},11722:function(t){t.exports=function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")},t.exports.__esModule=!0,t.exports.default=t.exports},8591:function(t){t.exports=function(t,e){return e.get?e.get.call(t):e.value},t.exports.__esModule=!0,t.exports.default=t.exports},90011:function(t){t.exports=function(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}},t.exports.__esModule=!0,t.exports.default=t.exports},78796:function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},44373:function(t){t.exports=function(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)},t.exports.__esModule=!0,t.exports.default=t.exports},99365:function(t,e,r){var n=r(8591),o=r(44373);t.exports=function(t,e){var r=o(t,e,"get");return n(t,r)},t.exports.__esModule=!0,t.exports.default=t.exports},27047:function(t,e,r){var n=r(11722);t.exports=function(t,e,r){n(t,e),e.set(t,r)},t.exports.__esModule=!0,t.exports.default=t.exports},3851:function(t,e,r){var n=r(90011),o=r(44373);t.exports=function(t,e,r){var i=o(t,e,"set");return n(t,i,r),r},t.exports.__esModule=!0,t.exports.default=t.exports},23658:function(t){t.exports=function(t,e,r){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return r},t.exports.__esModule=!0,t.exports.default=t.exports},7793:function(t,e,r){var n=r(11722);t.exports=function(t,e){n(t,e),e.add(t)},t.exports.__esModule=!0,t.exports.default=t.exports},4977:function(t,e,r){var n=r(53049);function o(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,n(o.key),o)}}t.exports=function(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},86222:function(t,e,r){var n=r(15274);t.exports=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=n(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function(){};return{s:i,n:function(){return o>=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},84047:function(t,e,r){var n=r(54088),o=r(40991),i=r(50819);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},10154:function(t,e,r){var n=r(53049);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},78846:function(t,e,r){var n=r(58903);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},54088: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},49488:function(t,e,r){var n=r(16206);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},40991: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},9578: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,h=!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){h=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(h)throw o}}return s}},t.exports.__esModule=!0,t.exports.default=t.exports},63589: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},50819:function(t,e,r){var n=r(89957).default,o=r(41553);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},90819:function(t,e,r){var n=r(89957).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:{},h=u.iterator||"@@iterator",d=u.asyncIterator||"@@asyncIterator",c=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 I(n||[]);return s(i,"_invoke",{value:_(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,h,(function(){return this}));var M=Object.getPrototypeOf,N=M&&M(M(T([])));N&&N!==i&&a.call(N,h)&&(E=N);var k=b.prototype=w.prototype=Object.create(E);function S(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 h=g(t[o],t,i);if("throw"!==h.type){var d=h.arg,c=d.value;return c&&"object"==n(c)&&a.call(c,"__await")?e.resolve(c.__await).then((function(t){r("next",t,s,u)}),(function(t){r("throw",t,s,u)})):e.resolve(c).then((function(t){d.value=t,s(d)}),(function(t){return r("throw",t,s,u)}))}u(h.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 _(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=z(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 h=g(t,r,n);if("normal"===h.type){if(o=n.done?y:"suspendedYield",h.arg===m)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(o=y,n.method="throw",n.arg=h.arg)}}}function z(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,z(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 R(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 O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(R,this),this.reset(!0)}function T(t){if(t||""===t){var r=t[h];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<t.length;)if(a.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(n(t)+" is not iterable")}return x.prototype=b,s(k,"constructor",{value:b,configurable:!0}),s(b,"constructor",{value:x,configurable:!0}),x.displayName=f(b,c,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,f(t,c,"GeneratorFunction")),t.prototype=Object.create(k),t},r.awrap=function(t){return{__await:t}},S(A.prototype),f(A.prototype,d,(function(){return this})),r.AsyncIterator=A,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new A(l(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(k),f(k,c,"Generator"),f(k,h,(function(){return this})),f(k,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=T,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var o=this.tryEntries.length-1;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"),h=a.call(i,"finallyLoc");if(u&&h){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(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;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:T(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},16206: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},45332:function(t,e,r){var n=r(51464),o=r(9578),i=r(15274),a=r(63589);t.exports=function(t,e){return n(t)||o(t,e)||i(t,e)||a()},t.exports.__esModule=!0,t.exports.default=t.exports},58903:function(t,e,r){var n=r(54088);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},62517:function(t,e,r){var n=r(89957).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},53049:function(t,e,r){var n=r(89957).default,o=r(62517);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},89957: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},15274:function(t,e,r){var n=r(88513);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]={exports:{}};return t[n](i,i.exports,r),i.exports}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.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})},function(){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};function e(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function o(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<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function i(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function s(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))}function a(t,e){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}Object.create;function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function u(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}Object.create;"function"==typeof SuppressedError&&SuppressedError;var h=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events["*"]||[],a=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var a=n[i],s=a.callback;a.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),s.apply(e,r)}};a(o),a(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}(),d=h;function c(t,e,r,n){for(;t.length;){const o=t.shift();if(r(o))return!0;e.add(o.id),n(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function f(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)&&f(o,e,r,n))return!0;return!1}const l=()=>!0;class g{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||l,r=t.edgeFilter||l;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];c([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];f(this.getNode(t),new Set,e,n)}}class v extends d{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),o=this.getNode(t),i=n.parentMap.get(t);if(i?.id===e)return;if(void 0===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 f(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return c([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 c([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 f(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 v({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 g({graph:this,...t})}}const p=Symbol("Comlink.proxy"),y=Symbol("Comlink.endpoint"),m=Symbol("Comlink.releaseProxy"),w=Symbol("Comlink.finalizer"),x=Symbol("Comlink.thrown"),b=t=>"object"==typeof t&&null!==t||"function"==typeof t,E={canHandle:t=>b(t)&&t[p],serialize(t){const{port1:e,port2:r}=new MessageChannel;return N(t,e),[r,[r]]},deserialize(t){return t.start(),R(t,[],e);var e}},M=new Map([["proxy",E],["throw",{canHandle:t=>b(t)&&x 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 N(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(P);let h;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":h=r;break;case"SET":e[s.slice(-1)[0]]=P(o.data.value),h=!0;break;case"APPLY":h=r.apply(e,u);break;case"CONSTRUCT":h=function(t){return Object.assign(t,{[p]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;N(t,r),h=function(t,e){return I.set(t,e),t}(e,[e])}break;case"RELEASE":h=void 0;break;default:return}}catch(t){h={value:t,[x]:0}}Promise.resolve(h).catch((t=>({value:t,[x]:0}))).then((r=>{const[o,s]=T(r);e.postMessage(Object.assign(Object.assign({},o),{id:i}),s),"RELEASE"===a&&(e.removeEventListener("message",n),k(e),w in t&&"function"==typeof t[w]&&t[w]())})).catch((t=>{const[r,n]=T({value:new TypeError("Unserializable return value"),[x]:0});e.postMessage(Object.assign(Object.assign({},r),{id:i}),n)}))})),e.start&&e.start()}function k(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function S(t){if(t)throw new Error("Proxy has been released and is not useable")}function A(t){return D(t,{type:"RELEASE"}).then((()=>{k(t)}))}const _=new WeakMap,z="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(_.get(t)||0)-1;_.set(t,e),0===e&&A(t)}));function R(t,e=[],r=function(){}){let n=!1;const o=new Proxy(r,{get(r,i){if(S(n),i===m)return()=>{!function(t){z&&z.unregister(t)}(o),A(t),n=!0};if("then"===i){if(0===e.length)return{then:()=>o};const r=D(t,{type:"GET",path:e.map((t=>t.toString()))}).then(P);return r.then.bind(r)}return R(t,[...e,i])},set(r,o,i){S(n);const[a,s]=T(i);return D(t,{type:"SET",path:[...e,o].map((t=>t.toString())),value:a},s).then(P)},apply(r,o,i){S(n);const a=e[e.length-1];if(a===y)return D(t,{type:"ENDPOINT"}).then(P);if("bind"===a)return R(t,e.slice(0,-1));const[s,u]=O(i);return D(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:s},u).then(P)},construct(r,o){S(n);const[i,a]=O(o);return D(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:i},a).then(P)}});return function(t,e){const r=(_.get(e)||0)+1;_.set(e,r),z&&z.register(t,e,t)}(o,t),o}function O(t){const e=t.map(T);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const I=new WeakMap;function T(t){for(const[e,r]of M)if(r.canHandle(t)){const[n,o]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},o]}return[{type:"RAW",value:t},I.get(t)||[]]}function P(t){switch(t.type){case"HANDLER":return M.get(t.name).deserialize(t.value);case"RAW":return t.value}}function D(t,e,r){return new Promise((n=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(r){r.data&&r.data.id&&r.data.id===o&&(t.removeEventListener("message",e),n(r.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:o},e),r)}))}function C(t){return"function"==typeof t}function L(t){return"number"==typeof t}var j=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function F(t,e){return C(e)?e:L(e)?function(){return e}:function(){return t}}function q(t,e,r){return void 0===r&&(r=!0),e||0===e?C(e)?e:L(e)?function(){return e}:Array.isArray(e)?function(){if(r){var n=Math.max.apply(Math,u([],s(e)));return isNaN(n)?t:n}return e}:j(e)?function(){if(r){var n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?Array.isArray(r)?r[0]>r[1]?r[0]:r[1]:j(r)?r.width>r.height?r.width:r.height:r:t}}var V=function(t,e){var r;return r=L(e)?function(){return e}:C(e)?e:function(){return 0},t?Array.isArray(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:C(t)?t:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(Array.isArray(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return j(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},G=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return G(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=G(t[e])})),r}return t},B=function(t,e){var r=G(t);return r.data=r.data||{},e&&(L(r.data.x)||(r.data.x=Math.random()*e[0]),L(r.data.y)||(r.data.y=Math.random()*e[1])),r},U=function(t,e,r){var o=t.getAllNodes(),i=t.getAllEdges();return(null==o?void 0:o.length)?1===o.length?(e&&t.mergeNodeData(o[0].id,{x:r[0],y:r[1]}),{nodes:[n(n({},o[0]),{data:n(n({},o[0].data),{x:r[0],y:r[1]})})],edges:i}):void 0:{nodes:[],edges:i}},W={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},H=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=n(n({},W),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,u,h,d,c,f,l,g,v,p,y,m,w,x,b,E,M,N,k,S,A,_,z,R,O,I,T,P,D,C,L,j,V,G;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,u=o.height,h=o.center,d=o.divisions,c=o.startAngle,f=void 0===c?0:c,l=o.endAngle,g=void 0===l?2*Math.PI:l,v=o.angleRatio,p=o.ordering,y=o.clockwise,m=o.nodeSpacing,w=o.nodeSize,x=e.getAllNodes(),b=e.getAllEdges(),E=s(K(i,u,h),3),M=E[0],N=E[1],k=E[2],!(S=null==x?void 0:x.length)||1===S)return[2,U(e,t,k)];for(A=(g-f)/S,_=o.radius,z=o.startRadius,R=o.endRadius,m?(O=F(10,m),I=q(10,w),T=-1/0,x.forEach((function(t){var e=I(t);T<e&&(T=e)})),P=0,x.forEach((function(t,e){P+=0===e?T||10:(O(t)||0)+(T||10)})),_=P/(2*Math.PI)):_||z||R?!z&&R?z=R:z&&!R&&(R=z):_=Math.min(N,M)/2,D=A*v,C=[],C="topology"===p?Y(e,x):"topology-directed"===p?Y(e,x,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(B(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,x):x.map((function(t){return B(t)})),L=Math.ceil(S/d),j=0;j<S;++j)(V=_)||null===z||null===R||(V=z+j*(R-z)/(S-1)),V||(V=10+100*j/(S-1)),G=f+j%L*D+2*Math.PI/d*Math.floor(j/L),y||(G=g-j%L*D-2*Math.PI/d*Math.floor(j/L)),C[j].data.x=k[0]+Math.cos(G)*V,C[j].data.y=k[1]+Math.sin(G)*V;return t&&C.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:C,edges:b}]}))}))},t}(),Y=function(t,e,r){void 0===r&&(r=!1);var n=[B(e[0])],o={},i=e.length;o[e[0].id]=!0;var a=0;return e.forEach((function(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]){for(var h=r?t.getSuccessors(n[a].id):t.getNeighbors(n[a].id),d=!1,c=0;c<h.length;c++){var f=h[c];if(t.getDegree(f.id)===t.getDegree(s.id)&&!o[f.id]){n.push(B(f)),o[f.id]=!0,d=!0;break}}for(var l=0;!d&&(o[e[l].id]||(n.push(B(e[l])),o[e[l].id]=!0,d=!0),++l!==i););}else n.push(B(s)),o[s.id]=!0,a++})),n};var K=function(t,e,r){var 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]},J=Array.isArray,Q=function(t){for(var e=[],r=t.length,n=0;n<r;n+=1){e[n]=[];for(var o=0;o<r;o+=1)n===o?e[n][o]=0:0!==t[n][o]&&t[n][o]?e[n][o]=t[n][o]:e[n][o]=1/0}for(var i=0;i<r;i+=1)for(n=0;n<r;n+=1)for(o=0;o<r;o+=1)e[n][o]>e[n][i]+e[i][o]&&(e[n][o]=e[n][i]+e[i][o]);return e},X=function(t,e){var r=t.nodes,n=t.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){i[t.id]=e;o.push([])})),null==n||n.forEach((function(t){var r=t.source,n=t.target,a=i[r],s=i[n];void 0!==a&&void 0!==s&&(o[a][s]=1,e||(o[s][a]=1))})),o},Z=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},$=function(t,e,r,n,o,i){if(void 0===n&&(n="TB"),void 0===i&&(i={}),null==e?void 0:e.length)for(var a=i.stopBranchFn,s=i.stopAllFn,u=0;u<e.length;u++){var h=e[u];if(t.hasNode(h.id)&&!(null==a?void 0:a(h))){if(null==s?void 0:s(h))return;"TB"===n&&r(h),$(t,t.getChildren(h.id,o),r,n,o,i),"TB"!==n&&r(h)}}},tt=r(22599),et=(tt.XA,tt.a_,tt.yQ,tt.Hs,tt.Ec,tt.dx,tt.LU,tt.Rm,tt.y3),rt=(tt.qK,tt.pb,tt.j,tt.sO,tt.BZ,tt.EK,tt.Db,tt.Fx,tt.tU,tt.Ym,tt.rs,tt.QR,tt.TB,tt.oH,tt.Sc),nt=(tt.BN,tt.it,tt.$r,tt.QM,tt.AV,tt.y3,tt.y3,tt.GH,tt.SO,tt.uZ,tt.yU,tt.F1,tt.re,{center:[0,0],linkDistance:50}),ot=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=n(n({},nt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,h,d,c,f,l,g,v,p;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=void 0===i?[0,0]:i,u=o.linkDistance,h=void 0===u?50:u,d=e.getAllNodes(),c=e.getAllEdges(),(null==d?void 0:d.length)&&1!==d.length?(f=X({nodes:d,edges:c},!1),l=Q(f),it(l),g=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r}(l,h),v=at(g),p=[],v.forEach((function(t,e){var r=B(d[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],p.push(r)})),t&&p.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:p,edges:c}]):[2,U(e,t,s)]}))}))},t}(),it=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,n){r.forEach((function(r,o){r===1/0&&(t[n][o]=e)}))}))},at=function(t){var e=et.mul(et.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new rt(e),a=et.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return et.mul([t],[a]).toJSON()[0].splice(0,2)}))};function st(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,a,s,u,h,d,c,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((h=e>=(i=(v+y)/2))?v=i:y=i,(d=r>=(a=(p+m)/2))?p=a:m=a,o=l,!(l=l[c=d<<1|h]))return o[c]=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[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(h=e>=(i=(v+y)/2))?v=i:y=i,(d=r>=(a=(p+m)/2))?p=a:m=a}while((c=d<<1|h)==(f=(u>=a)<<1|s>=i));return o[f]=l,o[c]=g,t}function ut(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function ht(t){return t[0]}function dt(t){return t[1]}function ct(t,e,r){var n=new ft(null==e?ht:e,null==r?dt:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function ft(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 lt(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var gt=ct.prototype=ft.prototype;function vt(t,e,r,n,o){if(isNaN(e)||isNaN(r)||isNaN(n))return t;var i,a,s,u,h,d,c,f,l,g,v,p,y=t._root,m={data:o},w=t._x0,x=t._y0,b=t._z0,E=t._x1,M=t._y1,N=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+M)/2))?x=s:M=s,(g=n>=(u=(b+N)/2))?b=u:N=u,i=y,!(y=y[v=g<<2|l<<1|f]))return i[v]=m,t;if(h=+t._x.call(null,y.data),d=+t._y.call(null,y.data),c=+t._z.call(null,y.data),e===h&&r===d&&n===c)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+M)/2))?x=s:M=s,(g=n>=(u=(b+N)/2))?b=u:N=u}while((v=g<<2|l<<1|f)==(p=(c>=u)<<2|(d>=s)<<1|h>=a));return i[p]=y,i[v]=m,t}function pt(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}function yt(t){return t[0]}function mt(t){return t[1]}function wt(t){return t[2]}function xt(t,e,r,n){var o=new bt(null==e?yt:e,null==r?mt:r,null==n?wt:n,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?o:o.addAll(t)}function bt(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 Et(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}gt.copy=function(){var t,e,r=new ft(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=lt(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]=lt(e));return r},gt.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return st(this.cover(e,r),e,r,t)},gt.addAll=function(t){var e,r,n,o,i=t.length,a=new Array(i),s=new Array(i),u=1/0,h=1/0,d=-1/0,c=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(a[r]=n,s[r]=o,n<u&&(u=n),n>d&&(d=n),o<h&&(h=o),o>c&&(c=o));if(u>d||h>c)return this;for(this.cover(u,h).cover(d,c),r=0;r<i;++r)st(this,a[r],s[r],t[r]);return this},gt.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var a,s,u=o-r||1,h=this._root;r>t||t>=o||n>e||e>=i;)switch(s=(e<n)<<1|t<r,(a=new Array(4))[s]=h,h=a,u*=2,s){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},gt.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},gt.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},gt.find=function(t,e,r){var n,o,i,a,s,u,h,d=this._x0,c=this._y0,f=this._x1,l=this._y1,g=[],v=this._root;for(v&&g.push(new ut(v,d,c,f,l)),null==r?r=1/0:(d=t-r,c=e-r,f=t+r,l=e+r,r*=r);u=g.pop();)if(!(!(v=u.node)||(o=u.x0)>f||(i=u.y0)>l||(a=u.x1)<d||(s=u.y1)<c))if(v.length){var p=(o+a)/2,y=(i+s)/2;g.push(new ut(v[3],p,y,a,s),new ut(v[2],o,y,p,s),new ut(v[1],p,i,a,y),new ut(v[0],o,i,p,y)),(h=(e>=y)<<1|t>=p)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-h],g[g.length-1-h]=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<r){var b=Math.sqrt(r=x);d=t-b,c=e-b,f=t+b,l=e+b,n=v.data}}return n},gt.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,r,n,o,i,a,s,u,h,d,c,f,l=this._root,g=this._x0,v=this._y0,p=this._x1,y=this._y1;if(!l)return this;if(l.length)for(;;){if((h=i>=(s=(g+p)/2))?g=s:p=s,(d=a>=(u=(v+y)/2))?v=u:y=u,e=l,!(l=l[c=d<<1|h]))return this;if(!l.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,f=c)}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[c]=o:delete e[c],(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)},gt.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},gt.root=function(){return this._root},gt.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},gt.visit=function(t){var e,r,n,o,i,a,s=[],u=this._root;for(u&&s.push(new ut(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,a=e.y1)&&u.length){var h=(n+i)/2,d=(o+a)/2;(r=u[3])&&s.push(new ut(r,h,d,i,a)),(r=u[2])&&s.push(new ut(r,n,d,h,a)),(r=u[1])&&s.push(new ut(r,h,o,i,d)),(r=u[0])&&s.push(new ut(r,n,o,h,d))}return this},gt.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new ut(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.x1,h=e.y1,d=(a+u)/2,c=(s+h)/2;(i=o[0])&&r.push(new ut(i,a,s,d,c)),(i=o[1])&&r.push(new ut(i,d,s,u,c)),(i=o[2])&&r.push(new ut(i,a,c,d,h)),(i=o[3])&&r.push(new ut(i,d,c,u,h))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},gt.x=function(t){return arguments.length?(this._x=t,this):this._x},gt.y=function(t){return arguments.length?(this._y=t,this):this._y};var Mt=xt.prototype=bt.prototype;Mt.copy=function(){var t,e,r=new bt(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=Et(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]=Et(e));return r},Mt.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t),n=+this._z.call(null,t);return vt(this.cover(e,r,n),e,r,n,t)},Mt.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,h=-1/0,d=-1/0;for(let c,f,l,g,v=0;v<e;++v)isNaN(f=+this._x.call(null,c=t[v]))||isNaN(l=+this._y.call(null,c))||isNaN(g=+this._z.call(null,c))||(r[v]=f,n[v]=l,o[v]=g,f<i&&(i=f),f>u&&(u=f),l<a&&(a=l),l>h&&(h=l),g<s&&(s=g),g>d&&(d=g));if(i>u||a>h||s>d)return this;this.cover(i,a,s).cover(u,h,d);for(let i=0;i<e;++i)vt(this,r[i],n[i],o[i],t[i]);return this},Mt.cover=function(t,e,r){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(r=+r))return this;var n=this._x0,o=this._y0,i=this._z0,a=this._x1,s=this._y1,u=this._z1;if(isNaN(n))a=(n=Math.floor(t))+1,s=(o=Math.floor(e))+1,u=(i=Math.floor(r))+1;else{for(var h,d,c=a-n||1,f=this._root;n>t||t>=a||o>e||e>=s||i>r||r>=u;)switch(d=(r<i)<<2|(e<o)<<1|t<n,(h=new Array(8))[d]=f,f=h,c*=2,d){case 0:a=n+c,s=o+c,u=i+c;break;case 1:n=a-c,s=o+c,u=i+c;break;case 2:a=n+c,o=s-c,u=i+c;break;case 3:n=a-c,o=s-c,u=i+c;break;case 4:a=n+c,s=o+c,i=u-c;break;case 5:n=a-c,s=o+c,i=u-c;break;case 6:a=n+c,o=s-c,i=u-c;break;case 7:n=a-c,o=s-c,i=u-c}this._root&&this._root.length&&(this._root=f)}return this._x0=n,this._y0=o,this._z0=i,this._x1=a,this._y1=s,this._z1=u,this},Mt.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Mt.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Mt.find=function(t,e,r,n){var o,i,a,s,u,h,d,c,f,l=this._x0,g=this._y0,v=this._z0,p=this._x1,y=this._y1,m=this._z1,w=[],x=this._root;for(x&&w.push(new pt(x,l,g,v,p,y,m)),null==n?n=1/0:(l=t-n,g=e-n,v=r-n,p=t+n,y=e+n,m=r+n,n*=n);c=w.pop();)if(!(!(x=c.node)||(i=c.x0)>p||(a=c.y0)>y||(s=c.z0)>m||(u=c.x1)<l||(h=c.y1)<g||(d=c.z1)<v))if(x.length){var b=(i+u)/2,E=(a+h)/2,M=(s+d)/2;w.push(new pt(x[7],b,E,M,u,h,d),new pt(x[6],i,E,M,b,h,d),new pt(x[5],b,a,M,u,E,d),new pt(x[4],i,a,M,b,E,d),new pt(x[3],b,E,s,u,h,M),new pt(x[2],i,E,s,b,h,M),new pt(x[1],b,a,s,u,E,M),new pt(x[0],i,a,s,b,E,M)),(f=(r>=M)<<2|(e>=E)<<1|t>=b)&&(c=w[w.length-1],w[w.length-1]=w[w.length-1-f],w[w.length-1-f]=c)}else{var N=t-+this._x.call(null,x.data),k=e-+this._y.call(null,x.data),S=r-+this._z.call(null,x.data),A=N*N+k*k+S*S;if(A<n){var _=Math.sqrt(n=A);l=t-_,g=e-_,v=r-_,p=t+_,y=e+_,m=r+_,o=x.data}}return o},Mt.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,r,n,o,i,a,s,u,h,d,c,f,l,g,v,p=this._root,y=this._x0,m=this._y0,w=this._z0,x=this._x1,b=this._y1,E=this._z1;if(!p)return this;if(p.length)for(;;){if((c=i>=(u=(y+x)/2))?y=u:x=u,(f=a>=(h=(m+b)/2))?m=h:b=h,(l=s>=(d=(w+E)/2))?w=d:E=d,e=p,!(p=p[g=l<<2|f<<1|c]))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)},Mt.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},Mt.root=function(){return this._root},Mt.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Mt.visit=function(t){var e,r,n,o,i,a,s,u,h=[],d=this._root;for(d&&h.push(new pt(d,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=h.pop();)if(!t(d=e.node,n=e.x0,o=e.y0,i=e.z0,a=e.x1,s=e.y1,u=e.z1)&&d.length){var c=(n+a)/2,f=(o+s)/2,l=(i+u)/2;(r=d[7])&&h.push(new pt(r,c,f,l,a,s,u)),(r=d[6])&&h.push(new pt(r,n,f,l,c,s,u)),(r=d[5])&&h.push(new pt(r,c,o,l,a,f,u)),(r=d[4])&&h.push(new pt(r,n,o,l,c,f,u)),(r=d[3])&&h.push(new pt(r,c,f,i,a,s,l)),(r=d[2])&&h.push(new pt(r,n,f,i,c,s,l)),(r=d[1])&&h.push(new pt(r,c,o,i,a,f,l)),(r=d[0])&&h.push(new pt(r,n,o,i,c,f,l))}return this},Mt.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new pt(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.z0,h=e.x1,d=e.y1,c=e.z1,f=(a+h)/2,l=(s+d)/2,g=(u+c)/2;(i=o[0])&&r.push(new pt(i,a,s,u,f,l,g)),(i=o[1])&&r.push(new pt(i,f,s,u,h,l,g)),(i=o[2])&&r.push(new pt(i,a,l,u,f,d,g)),(i=o[3])&&r.push(new pt(i,f,l,u,h,d,g)),(i=o[4])&&r.push(new pt(i,a,s,g,f,l,c)),(i=o[5])&&r.push(new pt(i,f,s,g,h,l,c)),(i=o[6])&&r.push(new pt(i,a,l,g,f,d,c)),(i=o[7])&&r.push(new pt(i,f,l,g,h,d,c))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Mt.x=function(t){return arguments.length?(this._x=t,this):this._x},Mt.y=function(t){return arguments.length?(this._y=t,this):this._y},Mt.z=function(t){return arguments.length?(this._z=t,this):this._z};var Nt=.1;function kt(t,e,r,n,o){void 0===o&&(o=2);var i=e/r,a=t.getAllNodes(),s=a.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,z:r.z,size:r.size,index:e,id:t.id,vx:0,vy:0,vz:0,weight:i*n}})),u=(2===o?ct(s,(function(t){return t.x}),(function(t){return t.y})):xt(s,(function(t){return t.x}),(function(t){return t.y}),(function(t){return t.z}))).visitAfter(St),h=new Map;return s.forEach((function(t){h.set(t.id,t),function(t,e,r){e.visit((function(e,n,o,i,a){return function(t,e,r,n,o,i,a){var s;if((null===(s=t.data)||void 0===s?void 0:s.id)===i.id)return;for(var u=[r,n,o][a-1],h=i.x-t.x||Nt,d=i.y-t.y||Nt,c=i.z-t.z||Nt,f=[h,d,c],l=u-e,g=0,v=0;v<a;v++)g+=f[v]*f[v];var p=Math.sqrt(g)*g;if(l*l*.81<g){var y=t.weight/p;return i.vx+=h*y,i.vy+=d*y,i.vz+=c*y,!0}if(t.length)return!1;if(t.data!==i){y=t.data.weight/p;i.vx+=h*y,i.vy+=d*y,i.vz+=c*y}}(e,n,o,i,a,t,r)}))}(t,u,o)})),s.map((function(t,e){var r=a[e],o=r.id,i=r.data.mass,s=void 0===i?1:i;n[o]={x:t.vx/s,y:t.vy/s,z:t.vz/s}})),n}function St(t){var e=0,r=0,n=0,o=0,i=0,a=t.length;if(a){for(var s=0;s<a;s++){(u=t[s])&&u.weight&&(e+=u.weight,r+=u.x*u.weight,n+=u.y*u.weight,o+=u.z*u.weight,i+=u.size*u.weight)}t.x=r/e,t.y=n/e,t.z=o/e,t.size=i/e,t.weight=e}else{var u=t;t.x=u.data.x,t.y=u.data.y,t.z=u.data.z,t.size=u.data.size,t.weight=u.data.weight}}var At={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},_t=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=n(n({},At),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<t;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),n},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,h,d,c,f,l,g,p,y,m,w,x,b,E,M,N,k,S=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=this.formatOptions(o,e),h=u.dimensions,d=u.width,c=u.height,f=u.nodeSize,l=u.getMass,g=u.nodeStrength,p=u.edgeStrength,y=u.linkDistance,m=i.map((function(t,e){return n(n({},t),{data:n(n({},t.data),{x:L(t.data.x)?t.data.x:Math.random()*d,y:L(t.data.y)?t.data.y:Math.random()*c,z:L(t.data.z)?t.data.z:Math.random()*Math.sqrt(d*c),size:f(t)||30,mass:l(t),nodeStrength:g(t)})})})),w=s.map((function(t){return n(n({},t),{data:n(n({},t.data),{edgeStrength:p(t),linkDistance:y(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==i?void 0:i.length)?(x={},i.forEach((function(t,e){x[t.id]={x:0,y:0,z:0}})),b=new v({nodes:m,edges:w}),this.formatCentripetal(u,b),E=u.maxIteration,M=u.minMovement,N=u.onTick,this.lastLayoutNodes=m,this.lastLayoutEdges=w,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=b,this.lastOptions=u,this.lastVelMap=x,"undefined"==typeof window?[2]:(k=0,[2,new Promise((function(r){S.timeInterval=window.setInterval((function(){i&&S.running||r({nodes:Tt(e,m),edges:s}),S.runOneStep(b,e,k,x,u),S.updatePosition(e,b,x,u),t&&m.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===h?t.data.z:void 0})})),null==N||N({nodes:Tt(e,m),edges:s}),(++k>=E||S.judgingDistance<M)&&(window.clearInterval(S.timeInterval),r({nodes:Tt(e,m),edges:s}))}),0),S.running=!0}))])):(this.lastResult={nodes:[],edges:s},[2,{nodes:[],edges:s}])}))}))},t.prototype.formatOptions=function(t,e){var r=n({},t),o=t.width,i=t.height,a=t.getMass,s=t.nodeSize;r.width=o||"undefined"==typeof window?o:window.innerWidth,r.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),a||(r.getMass=function(t){var r=1;L(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);var n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r});var u,h=F(0,t.nodeSpacing);u=s?C(s)?function(t){return s(t)+h(t)}:J(s)?function(t){var e=s;return Math.max(e[0],e[1])+h(t)}:function(t){return s+h(t)}:function(t){var e=((null==t?void 0:t.data)||{}).size;return e?J(e)?Math.max(e[0],e[1])+h(t):j(e)?Math.max(e.width,e.height)+h(t):e+h(t):10+h(t)},r.nodeSize=u;var d=t.linkDistance?F(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))};return r.linkDistance=d,r.nodeStrength=F(1,t.nodeStrength),r.edgeStrength=F(1,t.edgeStrength),r},t.prototype.formatCentripetal=function(t,e){var r,n,o=t.dimensions,i=t.centripetalOptions,a=t.center,s=t.clusterNodeStrength,u=t.leafCluster,h=t.clustering,d=t.nodeClusterBy,c=e.getAllNodes(),f=i||{leaf:2,single:2,others:1,center:function(t){return{x:a[0],y:a[1],z:3===o?a[2]:void 0}}};if("function"!=typeof s&&(t.clusterNodeStrength=function(t){return s}),u&&d&&(r=zt(e,d),n=Array.from(new Set(null==c?void 0:c.map((function(t){return t.data[d]}))))||[],t.centripetalOptions=Object.assign(f,{single:100,leaf:function(e){var o=r[e.id]||{},i=o.siblingLeaves,a=o.sameTypeLeaves;return(null==a?void 0:a.length)===(null==i?void 0:i.length)||1===(null==n?void 0:n.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var n,o=e.getDegree(t.id,"both");if(!o)return{x:100,y:100,z:0};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,a=void 0===i?[]:i;1===a.length?n=void 0:a.length>1&&(n=It(a))}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}}})),h&&d){r||(r=zt(e,d)),n||(n=Array.from(new Set(c.map((function(t){return t.data[d]}))))),n=n.filter((function(t){return void 0!==t}));var l={};n.forEach((function(t){var r=c.filter((function(e){return e.data[d]===t})).map((function(t){return e.getNode(t.id)}));l[t]=It(r)})),t.centripetalOptions=Object.assign(f,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=l[t.data[d]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}var g=t.centripetalOptions||{},v=g.leaf,p=g.single,y=g.others;v&&"function"!=typeof v&&(t.centripetalOptions.leaf=function(){return v}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),y&&"function"!=typeof y&&(t.centripetalOptions.others=function(){return y})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},a=t.getAllNodes(),s=t.getAllEdges();if(null==a?void 0:a.length){var u=o.monitor;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})}},t.prototype.calTotalEnergy=function(t,e){var r=this;if(!(null==e?void 0:e.length))return 0;var n=0;return e.forEach((function(e,o){var i=t[e.id].x,a=t[e.id].y,s=3===r.options.dimensions?t[e.id].z:0,u=i*i+a*a+s*s,h=e.data.mass;n+=(void 0===h?1:h)*u*.5})),n},t.prototype.calRepulsive=function(t,e,r){var n=r.dimensions,o=r.factor,i=r.coulombDisScale;kt(t,o,i*i,e,n)},t.prototype.calAttractive=function(t,e,r){var n=r.dimensions,o=r.nodeSize;t.getAllEdges().forEach((function(r,i){var a=r.source,s=r.target,u=t.getNode(a),h=t.getNode(s);if(u&&h){var d=h.data.x-u.data.x,c=h.data.y-u.data.y,f=3===n?h.data.z-u.data.z:0;d||c||(d=.01*Math.random(),c=.01*Math.random(),3!==n||f||(f=.01*Math.random()));var l=Math.sqrt(d*d+c*c+f*f);if(!(l<o(u)+o(h))){var g=d/l,v=c/l,p=f/l,y=r.data||{},m=y.linkDistance,w=void 0===m?200:m,x=y.edgeStrength,b=(w-l)*(void 0===x?200:x),E=1/(u.data.mass||1),M=1/(h.data.mass||1),N=g*b,k=v*b,S=p*b;e[a].x-=N*E,e[a].y-=k*E,e[a].z-=S*E,e[s].x+=N*M,e[s].y+=k*M,e[s].z+=S*M}}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,i=t.getAllNodes(),a=e.getAllNodes(),u=e.getAllEdges(),h=n.width,d=n.height,c=n.center,f=n.gravity,l=n.centripetalOptions;i&&i.forEach((function(n){var i=n.id,g=n.data,v=g.mass,p=g.x,y=g.y,m=g.z,w=e.getNode(i),x=0,b=0,E=0,M=f,N=t.getDegree(i,"in"),k=t.getDegree(i,"out"),S=t.getDegree(i,"both"),A=null==o?void 0:o(w,S);if(A){var _=s(A,3);x=p-_[0],b=y-_[1],M=_[2]}else x=p-c[0],b=y-c[1],E=m-c[2];if(M&&(r[i].x-=M*x/v,r[i].y-=M*b/v,r[i].z-=M*E/v),l){var z=l.leaf,R=l.single,O=l.others,I=l.center,T=(null==I?void 0:I(w,a,u,h,d))||{x:0,y:0,z:0,centerStrength:0},P=T.x,D=T.y,C=T.z,j=T.centerStrength;if(!L(P)||!L(D))return;var F=(p-P)/v,q=(y-D)/v,V=(m-C)/v;if(j&&(r[i].x-=j*F,r[i].y-=j*q,r[i].z-=j*V),0===S){var G=R(w);if(!G)return;return r[i].x-=G*F,r[i].y-=G*q,void(r[i].z-=G*V)}if(0===N||0===k){var B=z(w,a,u);if(!B)return;return r[i].x-=B*F,r[i].y-=B*q,void(r[i].z-=B*V)}var U=O(w);if(!U)return;r[i].x-=U*F,r[i].y-=U*q,r[i].z-=U*V}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,a=n.interval,s=n.dimensions,u=t.getAllNodes();(null==u?void 0:u.length)&&u.forEach((function(t){var n=t.id,u=(r[n].x+e[n].x*a)*o||.01,h=(r[n].y+e[n].y*a)*o||.01,d=3===s?(r[n].z+e[n].z*a)*o||.01:0,c=Math.sqrt(u*u+h*h+d*d);if(c>i){var f=i/c;u*=f,h*=f,d*=f}r[n]={x:u,y:h,z:d}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,a=n.interval,s=n.dimensions,u=e.getAllNodes();if(null==u?void 0:u.length){var h=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),u.forEach((function(n){var u=n.id,d=t.getNode(u);if(L(d.data.fx)&&L(d.data.fy))e.mergeNodeData(u,{x:d.data.fx,y:d.data.fy,z:3===s?d.data.fz:void 0});else{var c=r[u].x*a,f=r[u].y*a,l=3===s?r[u].z*a:0;e.mergeNodeData(u,{x:n.data.x+c,y:n.data.y+f,z:n.data.z+l});var g=Math.sqrt(c*c+f*f+l*l);switch(i){case"max":o.judgingDistance<g&&(o.judgingDistance=g);break;case"min":o.judgingDistance>g&&(o.judgingDistance=g);break;default:h+=g}}})),i&&"mean"!==i||(this.judgingDistance=h/u.length)}else this.judgingDistance=0},t}(),zt=function(t,e){var r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};var n={};return r.forEach((function(r,o){1===t.getDegree(r.id,"both")&&(n[r.id]=Rt(t,"leaf",r,e))})),n},Rt=function(t,e,r,n){var o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out"),a=r,s=[];return 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((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:a,siblingLeaves:s,sameTypeLeaves:Ot(t,e,n,r,s)}},Ot=function(t,e,r,n,o){var i=n.data[r]||"",a=(null==o?void 0:o.filter((function(t){return t.data[r]===i})))||[];return"leaf"===e&&(a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),a},It=function(t){var e={x:0,y:0};t.forEach((function(t){var r=t.data,n=r.x,o=r.y;e.x+=n||0,e.y+=o||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},Tt=function(t,e){return e.map((function(e){var r=e.id,o=e.data,i=t.getNode(r);return n(n({},i),{data:n(n({},i.data),{x:o.x,y:o.y,z:o.z})})}))};function Pt(t){return"string"==typeof t}var Dt={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},Ct=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=n(n({},Dt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,h,d,c,f,l,g,v,p,y,m,w,x,b,E,M,N,k,S,A,_,z,R,O,I,T,P,D,F,q,V,G,W,H,Y;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,h=o.sortBy,d=o.maxLevelDiff,c=o.sweep,f=o.clockwise,l=o.equidistant,g=o.preventOverlap,v=o.startAngle,p=void 0===v?1.5*Math.PI:v,y=o.nodeSize,m=o.nodeSpacing,w=e.getAllNodes(),x=e.getAllEdges(),b=s||"undefined"==typeof window?s:window.innerWidth,E=u||"undefined"==typeof window?u:window.innerHeight,M=i||[b/2,E/2],!(null==w?void 0:w.length)||1===w.length)return[2,U(e,t,M)];if(N=[],S=0,J(y)?k=Math.max(y[0],y[1]):C(y)?(k=-1/0,w.forEach((function(t){var e=y(t);e>k&&(k=e)}))):k=y,J(m)?S=Math.max(m[0],m[1]):L(m)&&(S=m),w.forEach((function(t){var e=B(t);N.push(e);var r=k,n=e.data;J(n.size)?r=Math.max(n.size[0],n.size[1]):L(n.size)?r=n.size:j(n.size)&&(r=Math.max(n.size.width,n.size.height)),k=Math.max(k,r),C(m)&&(S=Math.max(m(t),S))})),A={},N.forEach((function(t,e){A[t.id]=e})),Pt(_=h)&&void 0!==N[0].data[_]||(_="degree"),"degree"===_?N.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):N.sort((function(t,e){return e.data[_]-t.data[_]})),z=N[0],R=(d||("degree"===_?e.getDegree(z.id,"both"):z.data[_]))/4,I=(O=[{nodes:[]}])[0],N.forEach((function(t){if(I.nodes.length>0){var r="degree"===_?Math.abs(e.getDegree(I.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(I.nodes[0].data[_]-t.data[_]);R&&r>=R&&(I={nodes:[]},O.push(I))}I.nodes.push(t)})),T=k+S,g||(P=O.length>0&&O[0].nodes.length>1,D=Math.min(b,E)/2-T,F=D/(O.length+(P?1:0)),T=Math.min(T,F)),q=0,O.forEach((function(t){var 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&&g){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(T*T/(r*r+n*n));q=Math.max(o,q)}t.r=q,q+=T})),l){for(V=0,G=0,W=0;W<O.length;W++)H=O[W],Y=(H.r||0)-G,V=Math.max(V,Y);G=0,O.forEach((function(t,e){0===e&&(G=t.r||0),t.r=G,G+=V}))}return O.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=p+(f?1:-1)*e*n;t.data.x=M[0]+r*Math.cos(o),t.data.y=M[1]+r*Math.sin(o)}))})),t&&N.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:N,edges:x}]}))}))},t}(),Lt={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},jt={center:[0,0],comboPadding:10,treeKey:"combo"},Ft=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="comboCombined",this.options=n(n({},jt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericComboCombinedLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericComboCombinedLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericComboCombinedLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,h,d,c,f,l,g,p,y,m,w,x,b,E,M,N,k,S,A,_;return a(this,(function(a){switch(a.label){case 0:return o=this.initVals(n(n({},this.options),r)),i=o.center,h=o.treeKey,d=o.outerLayout,c=e.getAllNodes().filter((function(t){return!t.data._isCombo})),f=e.getAllNodes().filter((function(t){return t.data._isCombo})),l=e.getAllEdges(),(g=null==c?void 0:c.length)&&1!==g?(p=[],y=new Map,c.forEach((function(t){y.set(t.id,t)})),m=new Map,f.forEach((function(t){m.set(t.id,t)})),w=new Map,x=this.getInnerGraphs(e,h,y,m,l,o,w),[4,Promise.all(x)]):[2,U(e,t,i)];case 1:return a.sent(),b=new Map,E=[],M=new Map,N=!0,e.getRoots(h).forEach((function(t){var r=w.get(t.id),o=m.get(t.id)||y.get(t.id),i={id:t.id,data:n(n({},t.data),{x:r.data.x||o.data.x,y:r.data.y||o.data.y,fx:r.data.fx||o.data.fx,fy:r.data.fy||o.data.fy,mass:r.data.mass||o.data.mass,size:r.data.size})};E.push(i),b.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):N=!1,$(e,[t],(function(e){e.id!==t.id&&M.set(e.id,t.id)}),"TB",h)})),k=[],l.forEach((function(t){var e=M.get(t.source)||t.source,r=M.get(t.target)||t.target;e!==r&&b.has(e)&&b.has(r)&&k.push({id:t.id,source:e,target:r,data:{}})})),(null==E?void 0:E.length)?1!==E.length?[3,2]:(E[0].data.x=i[0],E[0].data.y=i[1],[3,6]):[3,7];case 2:return A=new v({nodes:E,edges:k}),_=d||new _t,N&&Lt[_.id]?[4,(E.length<100?new ot:new Ct).assign(A)]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,_.execute(A,n({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===_.id?{gravity:1,factor:4,linkDistance:function(t,e,r){return(Math.max.apply(Math,u([],s(e.data.size)))||32)/2+(Math.max.apply(Math,u([],s(r.data.size)))||32)/2+200}}:{}))];case 5:S=a.sent(),a.label=6;case 6:w.forEach((function(t){var e,r=S.nodes.find((function(e){return e.id===t.id}));if(r){var n=r.data,o=n.x,i=n.y;t.data.visited=!0,t.data.x=o,t.data.y=i,p.push({id:t.id,data:{x:o,y:i}})}var a=t.data,s=a.x,u=a.y;null===(e=t.data.nodes)||void 0===e||e.forEach((function(t){p.push({id:t.id,data:{x:t.data.x+s,y:t.data.y+u}})}))})),w.forEach((function(t){var e,r=t.data,n=r.x,o=r.y,i=r.visited;null===(e=r.nodes)||void 0===e||e.forEach((function(t){if(!i){var e=p.find((function(e){return e.id===t.id}));e.data.x+=n||0,e.data.y+=o||0}}))})),a.label=7;case 7:return t&&p.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:p,edges:l}]}}))}))},t.prototype.initVals=function(t){var e,r,o,i=n({},t),a=t.nodeSize,s=t.spacing,u=t.comboPadding;if(r=L(s)?function(){return s}:C(s)?s:function(){return 0},i.spacing=r,a)if(C(a))e=function(t){var e=a(t),n=r(t);return J(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+n)/2:((e||32)+n)/2};else if(J(a)){var h=(a[0]>a[1]?a[0]:a[1])/2;e=function(t){return h+r(t)/2}}else{var d=a/2;e=function(t){return d+r(t)/2}}else e=function(t){var e=r(t);return t.size?J(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2:j(t.size)?((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2:(t.size+e)/2:32+e/2};return i.nodeSize=e,o=L(u)?function(){return u}:J(u)?function(){return Math.max.apply(null,u)}:C(u)?u:function(){return 0},i.comboPadding=o,i},t.prototype.getInnerGraphs=function(t,e,r,o,h,d,c){var f=this,l=d.nodeSize,g=d.comboPadding,p=d.spacing,y=d.innerLayout||new Ct({}),m={center:[0,0],preventOverlap:!0,nodeSpacing:p},w=[],x=function(t){var e=(null==g?void 0:g(t))||10;return J(e)&&(e=Math.max.apply(Math,u([],s(e)))),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((function(u){c.set(u.id,{id:u.id,data:{nodes:[],size:x(u).size}});var d=Promise.resolve();$(t,[u],(function(u){var g;if(u.data._isCombo){var p=x(u),w=p.size,b=p.padding;if(null===(g=t.getChildren(u.id,e))||void 0===g?void 0:g.length){var E=c.get(u.id);c.set(u.id,{id:u.id,data:n({nodes:[]},null==E?void 0:E.data)});var M=new Map,N=t.getChildren(u.id,e).map((function(t){if(t.data._isCombo)return c.has(t.id)||c.set(t.id,{id:t.id,data:n({},t.data)}),M.set(t.id,!0),c.get(t.id);var e=r.get(t.id)||o.get(t.id);return M.set(t.id,!0),{id:t.id,data:n(n({},e.data),t.data)}})),k={nodes:N,edges:h.filter((function(t){return M.has(t.source)&&M.has(t.target)}))},S=1/0;N.forEach((function(t){var e,r,n=t.data.size;n||(n=(null===(e=c.get(t.id))||void 0===e?void 0:e.data.size)||(null===(r=l)||void 0===r?void 0:r(t))||[30,30]),L(n)&&(n=[n,n]);var o=s(n,2),i=o[0],a=o[1];S>i&&(S=i),S>a&&(S=a),t.data.size=n})),d=d.then((function(){return i(f,void 0,void 0,(function(){var t,e,r,n,o,i,s,h,d;return a(this,(function(a){switch(a.label){case 0:return t=new v(k),[4,y.assign(t,m)];case 1:return e=a.sent(),r=function(t){var e=1/0,r=1/0,n=-1/0,o=-1/0;return t.forEach((function(t){var i=t.data.size;J(i)?1===i.length&&(i=[i[0],i[0]]):L(i)?i=[i,i]:(void 0===i||isNaN(i))&&(i=[30,30]);var a=[i[0]/2,i[1]/2],s=t.data.x-a[0],u=t.data.x+a[0],h=t.data.y-a[1],d=t.data.y+a[1];e>s&&(e=s),r>h&&(r=h),n<u&&(n=u),o<d&&(o=d)})),{minX:e,minY:r,maxX:n,maxY:o}}(N),n=r.minX,o=r.minY,i=r.maxX,s=r.maxY,h={x:(i+n)/2,y:(s+o)/2},k.nodes.forEach((function(t){t.data.x-=h.x,t.data.y-=h.y})),d=[Math.max(i-n,S)+2*b,Math.max(s-o,S)+2*b],c.get(u.id).data.size=d,c.get(u.id).data.nodes=N,[2,e]}}))}))}))}else c.set(u.id,{id:u.id,data:n(n({},u.data),{size:w})});return!0}}),"BT",e),w.push(d)})),w},t}();function qt(t){return function(){return t}}function Vt(t){return 1e-6*(t()-.5)}var Gt={value:function(){}};function Bt(){for(var t,e=0,r=arguments.length,n={};e<r;++e){if(!(t=arguments[e]+"")||t in n||/[\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new Ut(n)}function Ut(t){this._=t}function Wt(t,e){return t.trim().split(/^|\s+/).map((function(t){var r="",n=t.indexOf(".");if(n>=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 Ht(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function Yt(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=Gt,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}Ut.prototype=Bt.prototype={constructor:Ut,on:function(t,e){var r,n=this._,o=Wt(t+"",n),i=-1,a=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++i<a;)if(r=(t=o[i]).type)n[r]=Yt(n[r],t.name,e);else if(null==e)for(r in n)n[r]=Yt(n[r],t.name,null);return this}for(;++i<a;)if((r=(t=o[i]).type)&&(r=Ht(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new Ut(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var r,n,o=new Array(r),i=0;i<r;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,r=(n=this._[t]).length;i<r;++i)n[i].value.apply(e,o)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};var Kt,Jt,Qt=Bt,Xt=0,Zt=0,$t=0,te=0,ee=0,re=0,ne="object"==typeof performance&&performance.now?performance:Date,oe="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ie(){return ee||(oe(ae),ee=ne.now()+re)}function ae(){ee=0}function se(){this._call=this._time=this._next=null}function ue(t,e,r){var n=new se;return n.restart(t,e,r),n}function he(){ee=(te=ne.now())+re,Xt=Zt=0;try{!function(){ie(),++Xt;for(var t,e=Kt;e;)(t=ee-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Xt}()}finally{Xt=0,function(){var t,e,r=Kt,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:Kt=e);Jt=t,ce(n)}(),ee=0}}function de(){var t=ne.now(),e=t-te;e>1e3&&(re-=e,te=t)}function ce(t){Xt||(Zt&&(Zt=clearTimeout(Zt)),t-ee>24?(t<1/0&&(Zt=setTimeout(he,t-ne.now()-re)),$t&&($t=clearInterval($t))):($t||(te=ne.now(),$t=setInterval(de,1e3)),Xt=1,oe(he)))}se.prototype=ue.prototype={constructor:se,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?ie():+r)+(null==e?0:+e),this._next||Jt===this||(Jt?Jt._next=this:Kt=this,Jt=this),this._call=t,this._time=r,ce()},stop:function(){this._call&&(this._call=null,this._time=1/0,ce())}};const fe=4294967296;function le(t){return t.x}function ge(t){return t.y}var ve=Math.PI*(3-Math.sqrt(5));function pe(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,a=.6,s=new Map,u=ue(c),h=Qt("tick","end"),d=function(){let t=1;return()=>(t=(1664525*t+1013904223)%fe)/fe}();function c(){f(),h.call("tick",e),r<n&&(u.stop(),h.call("end",e))}function f(n){var u,h,d=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,s.forEach((function(t){t(r)})),u=0;u<d;++u)null==(h=t[u]).fx?h.x+=h.vx*=a:(h.x=h.fx,h.vx=0),null==h.fy?h.y+=h.vy*=a:(h.y=h.fy,h.vy=0);return e}function l(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=10*Math.sqrt(.5+r),i=r*ve;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,d),e}return null==t&&(t=[]),l(),e={tick:f,restart:function(){return u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,l(),s.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(d=t,s.forEach(g),e):d},force:function(t,r){return arguments.length>1?(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,h=0,d=t.length;for(null==n?n=1/0:n*=n,h=0;h<d;++h)(a=(o=e-(s=t[h]).x)*o+(i=r-s.y)*i)<n&&(u=s,n=a);return u},on:function(t,r){return arguments.length>1?(h.on(t,r),e):h.on(t)}}}function ye(){var t,e,r,n,o,i=qt(-30),a=1,s=1/0,u=.81;function h(r){var o,i=t.length,a=ct(t,le,ge).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],a.visit(f)}function d(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function c(t){var e,r,n,i,a,s=0,u=0;if(t.length){for(n=i=a=0;a<4;++a)(e=t[a])&&(r=Math.abs(e.value))&&(s+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=o[e.data.index]}while(e=e.next)}t.value=s}function f(t,i,h,d){if(!t.value)return!0;var c=t.x-e.x,f=t.y-e.y,l=d-i,g=c*c+f*f;if(l*l/u<g)return g<s&&(0===c&&(g+=(c=Vt(r))*c),0===f&&(g+=(f=Vt(r))*f),g<a&&(g=Math.sqrt(a*g)),e.vx+=c*t.value*n/g,e.vy+=f*t.value*n/g),!0;if(!(t.length||g>=s)){(t.data!==e||t.next)&&(0===c&&(g+=(c=Vt(r))*c),0===f&&(g+=(f=Vt(r))*f),g<a&&(g=Math.sqrt(a*g)));do{t.data!==e&&(l=o[t.data.index]*n/g,e.vx+=c*l,e.vy+=f*l)}while(t=t.next)}}return h.initialize=function(e,n){t=e,r=n,d()},h.strength=function(t){return arguments.length?(i="function"==typeof t?t:qt(+t),d(),h):i},h.distanceMin=function(t){return arguments.length?(a=t*t,h):Math.sqrt(a)},h.distanceMax=function(t){return arguments.length?(s=t*t,h):Math.sqrt(s)},h.theta=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h}function me(t){return t.index}function we(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function xe(t){var e,r,n,o,i,a,s=me,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},h=qt(30),d=1;function c(n){for(var o=0,s=t.length;o<d;++o)for(var u,h,c,f,l,g,v,p=0;p<s;++p)h=(u=t[p]).source,f=(c=u.target).x+c.vx-h.x-h.vx||Vt(a),l=c.y+c.vy-h.y-h.vy||Vt(a),f*=g=((g=Math.sqrt(f*f+l*l))-r[p])/g*n*e[p],l*=g,c.vx-=f*(v=i[p]),c.vy-=l*v,h.vx+=f*(v=1-v),h.vy+=l*v}function f(){if(n){var a,u,h=n.length,d=t.length,c=new Map(n.map(((t,e)=>[s(t,e,n),t])));for(a=0,o=new Array(h);a<d;++a)(u=t[a]).index=a,"object"!=typeof u.source&&(u.source=we(c,u.source)),"object"!=typeof u.target&&(u.target=we(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(a=0,i=new Array(d);a<d;++a)u=t[a],i[a]=o[u.source.index]/(o[u.source.index]+o[u.target.index]);e=new Array(d),l(),r=new Array(d),g()}}function l(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+h(t[e],e,t)}return null==t&&(t=[]),c.initialize=function(t,e){n=t,a=e,f()},c.links=function(e){return arguments.length?(t=e,f(),c):t},c.id=function(t){return arguments.length?(s=t,c):s},c.iterations=function(t){return arguments.length?(d=+t,c):d},c.strength=function(t){return arguments.length?(u="function"==typeof t?t:qt(+t),l(),c):u},c.distance=function(t){return arguments.length?(h="function"==typeof t?t:qt(+t),g(),c):h},c}function be(t){return t.x+t.vx}function Ee(t){return t.y+t.vy}function Me(t){var e,r,n,o=1,i=1;function a(){for(var t,a,u,h,d,c,f,l=e.length,g=0;g<i;++g)for(a=ct(e,be,Ee).visitAfter(s),t=0;t<l;++t)u=e[t],c=r[u.index],f=c*c,h=u.x+u.vx,d=u.y+u.vy,a.visit(v);function v(t,e,r,i,a){var s=t.data,l=t.r,g=c+l;if(!s)return e>h+g||i<h-g||r>d+g||a<d-g;if(s.index>u.index){var v=h-s.x-s.vx,p=d-s.y-s.vy,y=v*v+p*p;y<g*g&&(0===v&&(y+=(v=Vt(n))*v),0===p&&(y+=(p=Vt(n))*p),y=(g-(y=Math.sqrt(y)))/y*o,u.vx+=(v*=y)*(g=(l*=l)/(f+l)),u.vy+=(p*=y)*g,s.vx-=v*(g=1-g),s.vy-=p*g)}}}function s(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=qt(null==t?1:+t)),a.initialize=function(t,r){e=t,n=r,u()},a.iterations=function(t){return arguments.length?(i=+t,a):i},a.strength=function(t){return arguments.length?(o=+t,a):o},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:qt(+e),u(),a):t},a}function Ne(t){var e,r,n,o=qt(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vx+=(n[i]-o.x)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=qt(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:qt(+t),a(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:qt(+e),a(),i):t},i}function ke(t){var e,r,n,o=qt(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vy+=(n[i]-o.y)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=qt(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:qt(+t),a(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:qt(+e),a(),i):t},i}function Se(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),i=t(100),a=t(.1),u=[0,0],h=[],d={},c=[],f=100,l=100,g={none:{x:0,y:0}},v=[],p="force",y=!0,m=.1;function w(t){if(!y)return w;e.tick(),b();for(var n=0,o=h.length,i=void 0,a=t*m;n<o;++n)(i=h[n]).vx+=(g[r(i)].x-i.x)*a,i.vy+=(g[r(i)].y-i.y)*a}function x(){h&&function(){if(!h||!h.length)return;if(void 0===r(h[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t=(u=[],g=[],p={},y={},m=[],y=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),a=e[o];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=a})),e}(h),m=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,a,s,u=(o=(n=t).source,i=n.target,a=r(d[o]),s=r(d[i]),a<=s?a+"~"+s:s+"~"+a),h=0;void 0!==e[u]&&(h=e[u]),h+=1,e[u]=h})),Object.entries(e).forEach((function(t){var e=s(t,2),r=e[0],o=e[1],i=r.split("~")[0],a=r.split("~")[1];void 0!==i&&void 0!==a&&n.push({source:i,target:a,count:o})})),n}(c),Object.keys(y).forEach((function(t,e){var r=y[t];u.push({id:t,size:r.count,r:Math.sqrt(r.sumforceNodeSize/Math.PI)}),p[t]=e})),m.forEach((function(t){var e=t.source,r=t.target,n=p[e],o=p[r];void 0!==n&&void 0!==o&&g.push({source:n,target:o,count:t.count})})),{nodes:u,links:g});var u,g,p,y,m;e=pe(t.nodes).force("x",Ne(f).strength(.1)).force("y",ke(l).strength(.1)).force("collide",Me((function(t){return t.r})).iterations(4)).force("charge",ye().strength(o)).force("links",xe(t.nodes.length?t.links:[]).distance(i).strength(a)),v=e.nodes(),b()}()}function b(){return g={none:{x:0,y:0}},v.forEach((function(t){g[t.id]={x:t.x-u[0],y:t.y-u[1]}})),g}function E(t){d={},t.forEach((function(t){d[t.id]=t}))}return w.initialize=function(t){h=t,x()},w.template=function(t){return arguments.length?(p=t,x(),w):p},w.groupBy=function(t){return arguments.length?"string"==typeof t?(r=function(e){return e[t]},w):(r=t,w):r},w.enableGrouping=function(t){return arguments.length?(y=t,w):y},w.strength=function(t){return arguments.length?(m=t,w):m},w.centerX=function(t){return arguments.length?(f=t,w):f},w.centerY=function(t){return arguments.length?(l=t,w):l},w.nodes=function(t){return arguments.length?(E(t||[]),h=t||[],w):h},w.links=function(t){return arguments.length?(c=t||[],x(),w):c},w.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),x(),w):n},w.nodeSize=w.forceNodeSize,w.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),w):o},w.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),w):i},w.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),w):a},w.offset=function(t){return arguments.length?(u=t,w):u},w.getFocis=b,w}var Ae={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},_e=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=n(n({},Ae),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:ze(this.lastLayoutNodes),edges:Re(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,h,d,c,f,l,g,v,p,y,m,w,x,b,E,M,N,k,S,A,_,z,R,O=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=i.map((function(t){var e,r;return n(n({},B(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(r=t.data)||void 0===r?void 0:r.y})})),h=s.map((function(t){return B(t)})),this.lastLayoutNodes=u,this.lastLayoutEdges=h,this.lastAssign=t,this.lastGraph=e,d=o.alphaMin,c=o.alphaDecay,f=o.alpha,l=o.nodeStrength,g=o.edgeStrength,v=o.linkDistance,p=o.clustering,y=o.clusterFociStrength,m=o.clusterEdgeDistance,w=o.clusterEdgeStrength,x=o.clusterNodeStrength,b=o.clusterNodeSize,E=o.collideStrength,M=void 0===E?1:E,N=o.center,k=void 0===N?[0,0]:N,S=o.preventOverlap,A=o.nodeSize,_=o.nodeSpacing,z=o.onTick,R=o.forceSimulation,[2,new Promise((function(r){if(R){if(p)(i=Se()).nodes(u),i.links(h);if(R.nodes(u),h){s=xe().id((function(t){return t.id})).links(h);g&&s.strength(g),v&&s.distance(v),R.force("link",s)}S&&O.overlapProcess(R,{nodeSize:A,nodeSpacing:_,collideStrength:M}),R.alpha(f).restart();var n=ze(u),o=Re(h);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:o})}else try{var i,a=ye();if(l&&a.strength(l),R=pe().nodes(u),p)(i=Se()).centerX(k[0]).centerY(k[1]).template("force").strength(y),h&&i.links(h),u&&i.nodes(u),i.forceLinkDistance(m).forceLinkStrength(w).forceCharge(x).forceNodeSize(b),R.force("group",i);if(R.force("center",function(t,e){var r,n=1;function o(){var o,i,a=r.length,s=0,u=0;for(o=0;o<a;++o)s+=(i=r[o]).x,u+=i.y;for(s=(s/a-t)*n,u=(u/a-e)*n,o=0;o<a;++o)(i=r[o]).x-=s,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(k[0],k[1])).force("charge",a).alpha(f).alphaDecay(c).alphaMin(d),S&&O.overlapProcess(R,{nodeSize:A,nodeSpacing:_,collideStrength:M}),h){var s=xe().id((function(t){return t.id})).links(h);g&&s.strength(g),v&&s.distance(v),R.force("link",s)}R.on("tick",(function(){var r=ze(u);null==z||z({nodes:r,edges:Re(h)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=ze(u);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:Re(h)})}))}catch(t){console.warn(t)}O.forceSimulation=R}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,a=e.collideStrength;if(n=L(i)?function(){return i}:C(i)?i:function(){return 0},o)if(C(o))r=function(t){return o(t)+n(t)};else if(J(o)){var s=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return s+n(t)}}else if(L(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?J(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):j(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+n(t):t.size/2+n(t):10+n(t)};t.force("collisionForce",Me(r).strength(a))},t}(),ze=function(t){return t.map((function(t){var e=t.x,r=t.y,i=o(t,["x","y"]);return n(n({},i),{data:n(n({},i.data),{x:e,y:r})})}))},Re=function(t){return t.map((function(t){var e=t.source,r=t.target,i=o(t,["source","target"]);return n(n({},i),{source:e.id,target:r.id})}))};var Oe=function(t,e){if("next"!==t&&"prev"!==t)return e},Ie=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},Te=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return e(r,t),r}(function(){function t(){var t={};t.prev=t,t.next=t.prev,this.shortcut=t}return t.prototype.dequeue=function(){var t=this.shortcut,e=t.prev;if(e&&e!==t)return Ie(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&Ie(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e},t.prototype.toString=function(){for(var t=[],e=this.shortcut,r=e.prev;r!==e;)t.push(JSON.stringify(r,Oe)),r=null==r?void 0:r.prev;return"["+t.join(", ")+"]"},t}()),Pe=function(){return 1},De=function(t,e,r){for(var n,o=[],i=e[e.length-1],a=e[0];t.getAllNodes().length;){for(;n=a.dequeue();)Ce(t,e,r,n);for(;n=i.dequeue();)Ce(t,e,r,n);if(t.getAllNodes().length)for(var s=e.length-2;s>0;--s)if(n=e[s].dequeue()){o=o.concat(Ce(t,e,r,n,!0));break}}return o},Ce=function(t,e,r,o,i){var a,s,u=[];return t.hasNode(o.v)&&(null===(a=t.getRelatedEdges(o.v,"in"))||void 0===a||a.forEach((function(o){var a=o.data.weight,s=t.getNode(o.source);i&&u.push({v:o.source,w:o.target,in:0,out:0}),void 0===s.data.out&&(s.data.out=0),s.data.out-=a,je(e,r,n({v:s.id},s.data))})),null===(s=t.getRelatedEdges(o.v,"out"))||void 0===s||s.forEach((function(o){var i=o.data.weight,a=o.target,s=t.getNode(a);void 0===s.data.in&&(s.data.in=0),s.data.in-=i,je(e,r,n({v:s.id},s.data))})),t.removeNode(o.v)),i?u:void 0},Le=function(t,e){var r=new v,o=0,i=0;t.getAllNodes().forEach((function(t){r.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((function(t){var a=r.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target})),s=(null==e?void 0:e(t))||1;a?r.updateEdgeData(null==a?void 0:a.id,n(n({},a.data),{weight:a.data.weight+s})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:s}}),i=Math.max(i,r.getNode(t.source).data.out+=s),o=Math.max(o,r.getNode(t.target).data.in+=s)}));for(var a=[],s=i+o+3,u=0;u<s;u++)a.push(new Te);var h=o+1;return r.getAllNodes().forEach((function(t){je(a,h,n({v:t.id},r.getNode(t.id).data))})),{buckets:a,zeroIdx:h,graph:r}},je=function(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)},Fe=function(t,e){var r="greedy"===e?function(t,e){var r;if(t.getAllNodes().length<=1)return[];var n=Le(t,e||Pe);return null===(r=De(n.graph,n.buckets,n.zeroIdx).map((function(e){return t.getRelatedEdges(e.v,"out").filter((function(t){return t.target===e.w}))})))||void 0===r?void 0:r.flat()}(t,(function(t){return t.data.weight||1})):qe(t);null==r||r.forEach((function(e){var 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:n({},r)})}))},qe=function(t){var e=[],r={},n={},o=function(i){n[i]||(n[i]=!0,r[i]=!0,t.getRelatedEdges(i,"out").forEach((function(t){r[t.target]?e.push(t):o(t.target)})),delete r[i])};return t.getAllNodes().forEach((function(t){return o(t.id)})),e},Ve=function(t,e,r,n){var o;do{o=""+n+Math.random()}while(t.hasNode(o));return r.dummy=e,t.addNode({id:o,data:r}),o},Ge=function(t){var e=new v;return t.getAllNodes().forEach((function(r){t.getChildren(r.id).length||e.addNode(n({},r))})),t.getAllEdges().forEach((function(t){e.addEdge(t)})),e},Be=function(t,e){return null==t?void 0:t.reduce((function(t,r,n){return t[r]=e[n],t}),{})},Ue=function(t,e){var r,n,o=Number(t.x),i=Number(t.y),a=Number(e.x)-o,s=Number(e.y)-i,u=Number(t.width)/2,h=Number(t.height)/2;return a||s?(Math.abs(s)*u>Math.abs(a)*h?(s<0&&(h=-h),r=h*a/s,n=h):(a<0&&(u=-u),r=u,n=u*s/a),{x:o+r,y:i+n}):{x:0,y:0}},We=function(t){for(var e=[],r=Ye(t)+1,n=0;n<r;n++)e.push([]);t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&e[r]&&e[r].push(t.id)}));for(n=0;n<r;n++)e[n]=e[n].sort((function(e,r){return n=t.getNode(e).data.order,o=t.getNode(r).data.order,Number(n)-Number(o);var n,o}));return e},He=function(t,e,r,n){var o={width:0,height:0};return L(r)&&L(n)&&(o.rank=r,o.order=n),Ve(t,"border",o,e)},Ye=function(t){var e;return t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&(void 0===e||r>e)&&(e=r)})),e||(e=0),e},Ke=function(t,e){return t.reduce((function(t,r){return e(t)>e(r)?r:t}))},Je=function(t,e,r,n,o,i){n.includes(e.id)||(n.push(e.id),r||i.push(e.id),o(e.id).forEach((function(e){return Je(t,e,r,n,o,i)})),r&&i.push(e.id))},Qe=function(t,e,r,n){var o=Array.isArray(e)?e:[e],i=function(e){return n?t.getSuccessors(e):t.getNeighbors(e)},a=[],s=[];return o.forEach((function(e){if(!t.hasNode(e.id))throw new Error("Graph does not have node: "+e);Je(t,e,"post"===r,s,i,a)})),a},Xe="edge-label",Ze=function(t,e,r){var n=e.source,o=t.getNode(n).data.rank,i=e.target,a=t.getNode(i).data.rank,s=e.data.labelRank;if(a!==o+1){var u,h,d;for(t.removeEdge(e.id),d=0,++o;o<a;++d,++o)e.data.points=[],u=Ve(t,"edge",h={originalEdge:e,width:0,height:0,rank:o},"_d"),o===s&&(h.width=e.data.width,h.height=e.data.height,h.dummy=Xe,h.labelpos=e.data.labelpos),t.addEdge({id:"e"+Math.random(),source:n,target:u,data:{weight:e.data.weight}}),0===d&&r.push(u),n=u;t.addEdge({id:"e"+Math.random(),source:n,target:i,data:{weight:e.data.weight}})}},$e=function(t){var e={},r=function(n){var o,i,a=t.getNode(n);return a?e[n]?a.data.rank:(e[n]=!0,null===(o=t.getRelatedEdges(n,"out"))||void 0===o||o.forEach((function(t){var e=r(t.target)-t.data.minlen;e&&(void 0===i||e<i)&&(i=e)})),i||(i=0),a.data.rank=i,i):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){return r(t.id)}))},tr=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},er=function(t,e){var r=function(n){e.getRelatedEdges(n,"both").forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||tr(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},rr=function(t,e){var r=function(n){var o;null===(o=e.getRelatedEdges(n,"both"))||void 0===o||o.forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||void 0===e.getNode(a).data.layer&&tr(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},nr=function(t,e){return Ke(e.getAllEdges(),(function(r){return t.hasNode(r.source)!==t.hasNode(r.target)?tr(e,r):1/0}))},or=function(t,e,r){t.getAllNodes().forEach((function(t){var n=e.getNode(t.id);n.data.rank||(n.data.rank=0),n.data.rank+=r}))},ir=function(t){var e=function(t){var e=new v;return t.getAllNodes().forEach((function(t){e.addNode(n({},t))})),t.getAllEdges().forEach((function(t){var r=e.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target}));r?e.updateEdgeData(null==r?void 0:r.id,n(n({},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);$e(e);var r,o,i=function(t){var e,r,n=new v({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);er(n,t)<i;)e=nr(n,t),r=n.hasNode(e.source)?tr(t,e):-tr(t,e),or(n,t,r);return n}(e);for(hr(i),ar(i,e);r=cr(i);)o=fr(i,e,r),lr(i,e,r,o)},ar=function(t,e){var r=Qe(t,t.getAllNodes(),"post",!1);(r=r.slice(0,(null==r?void 0:r.length)-1)).forEach((function(r){sr(t,e,r)}))},sr=function(t,e,r){var n=t.getNode(r).data.parent;t.getRelatedEdges(r,"both").find((function(t){return t.target===n||t.source===n})).data.cutvalue=ur(t,e,r)},ur=function(t,e,r){var n=t.getNode(r).data.parent,o=!0,i=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),a=0;return i||(o=!1,i=e.getRelatedEdges(n,"out").find((function(t){return t.target===r}))),a=i.data.weight,e.getRelatedEdges(r,"both").forEach((function(e){var i=e.source===r,s=i?e.target:e.source;if(s!==n){var u=i===o,h=e.data.weight;if(a+=u?h:-h,vr(t,r,s)){var d=t.getRelatedEdges(r,"both").find((function(t){return t.source===s||t.target===s})).data.cutvalue;a+=u?-d:d}}})),a},hr=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),dr(t,{},1,e)},dr=function(t,e,r,n,o){var i,a=r,s=r,u=t.getNode(n);return e[n]=!0,null===(i=t.getNeighbors(n))||void 0===i||i.forEach((function(r){e[r.id]||(s=dr(t,e,s,r.id,n))})),u.data.low=a,u.data.lim=s++,o?u.data.parent=o:delete u.data.parent,s},cr=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},fr=function(t,e,r){var n=r.source,o=r.target;e.getRelatedEdges(n,"out").find((function(t){return t.target===o}))||(n=r.target,o=r.source);var i=t.getNode(n),a=t.getNode(o),s=i,u=!1;i.data.lim>a.data.lim&&(s=a,u=!0);var h=e.getAllEdges().filter((function(e){return u===pr(t.getNode(e.source),s)&&u!==pr(t.getNode(e.target),s)}));return Ke(h,(function(t){return tr(e,t)}))},lr=function(t,e,r,n){var o=t.getRelatedEdges(r.source,"both").find((function(t){return 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:{}}),hr(t),ar(t,e),gr(t,e)},gr=function(t,e){var r=t.getAllNodes().find((function(t){return!t.data.parent})),n=Qe(t,r,"pre",!1);(n=n.slice(1)).forEach((function(r){var n=t.getNode(r).data.parent,o=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),i=!1;!o&&e.hasNode(n)&&(o=e.getRelatedEdges(n,"out").find((function(t){return 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))}))},vr=function(t,e,r){return t.getRelatedEdges(e,"both").find((function(t){return t.source===r||t.target===r}))},pr=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},yr=$e,mr=function(t){!function(t){var e,r={},n=function(o){var i,a,s=t.getNode(o);return s?r[o]?s.data.rank:(r[o]=!0,null===(i=t.getRelatedEdges(o,"out"))||void 0===i||i.forEach((function(t){var e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),(void 0===e||a<e)&&(e=a),s.data.rank=a,a):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){t&&n(t.id)})),void 0===e&&(e=0);var o={},i=function(e,r){var n,a=t.getNode(e),s=isNaN(a.data.layer)?r:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),o[e]||(o[e]=!0,null===(n=t.getRelatedEdges(e,"out"))||void 0===n||n.forEach((function(t){i(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((function(t){var r=t.data;r&&(isNaN(r.layer)?r.rank-=e:i(t.id,r.layer))}))}(t),function(t){var e,r,n=new v({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);rr(n,t)<i;)e=nr(n,t),r=n.hasNode(e.source)?tr(t,e):-tr(t,e),or(n,t,r)}(t)},wr=function(t){ir(t)},xr=function(t,e){var r=function(t){var e={},r=0,n=function(o){var i=r;t.getChildren(o).forEach((function(t){return n(t.id)})),e[o]={low:i,lim:r++}};return t.getRoots().forEach((function(t){return n(t.id)})),e}(t);e.forEach((function(e){var n,o,i=e,a=t.getNode(i),s=a.data.originalEdge;if(s)for(var u=function(t,e,r,n){var o,i,a,s,u=[],h=[],d=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);a=r;do{a=null===(o=t.getParent(a))||void 0===o?void 0:o.id,u.push(a)}while(a&&(e[a].low>d||c>e[a].lim));for(s=a,a=n;a&&a!==s;)h.push(a),a=null===(i=t.getParent(a))||void 0===i?void 0:i.id;return{lca:s,path:u.concat(h.reverse())}}(t,r,s.source,s.target),h=u.path,d=u.lca,c=0,f=h[c],l=!0;i!==s.target;){if(a=t.getNode(i),l){for(;f!==d&&(null===(n=t.getNode(f))||void 0===n?void 0:n.data.maxRank)<a.data.rank;)f=h[++c];f===d&&(l=!1)}if(!l){for(;c<h.length-1&&(null===(o=t.getNode(h[c+1]))||void 0===o?void 0:o.data.minRank)<=a.data.rank;)c++;f=h[c]}t.hasNode(f)&&t.setParent(i,f),i=t.getSuccessors(i)[0].id}}))},br=function(t,e,r,n,o,i,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var u=He(t,"_bt"),h=He(t,"_bb"),d=t.getNode(a);t.setParent(u,a),d.data.borderTop=u,t.setParent(h,a),d.data.borderBottom=h,null==s||s.forEach((function(s){br(t,e,r,n,o,i,s.id);var d=s.data.borderTop?s.data.borderTop:s.id,c=s.data.borderBottom?s.data.borderBottom:s.id,f=s.data.borderTop?n:2*n,l=d!==c?1:o-i[a]+1;t.addEdge({id:"e"+Math.random(),source:u,target:d,data:{minlen:l,weight:f,nestingEdge:!0}}),t.addEdge({id:"e"+Math.random(),source:c,target:h,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]}})}else a!==e&&t.addEdge({id:"e"+Math.random(),source:e,target:a,data:{weight:0,minlen:r}})},Er=function(t){var e={},r=function(n,o){var i=t.getChildren(n);null==i||i.forEach((function(t){return r(t.id,o+1)})),e[n]=o};return t.getRoots().forEach((function(t){return r(t.id,1)})),e},Mr=function(t){var e=0;return t.getAllEdges().forEach((function(t){e+=t.data.weight})),e},Nr=function(t,e,r,n,o,i){var a={rank:i,borderType:e,width:0,height:0},s=o.data[e][i-1],u=Ve(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}})},kr=function(t){t.getAllNodes().forEach((function(t){Sr(t)})),t.getAllEdges().forEach((function(t){Sr(t)}))},Sr=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},Ar=function(t){t.getAllNodes().forEach((function(t){_r(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return _r(t)})),t.data.hasOwnProperty("y")&&_r(t.data)}))},_r=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},zr=function(t){t.getAllNodes().forEach((function(t){Rr(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return Rr(t)})),t.data.hasOwnProperty("x")&&Rr(t.data)}))},Rr=function(t){var e=t.x;t.x=t.y,t.y=e},Or=function(t){for(var e={},r=t.getAllNodes(),n=r.map((function(t){var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),o=Math.max.apply(Math,u([],s(n))),i=[],a=0;a<o+1;a++)i.push([]);var h=r.sort((function(e,r){return t.getNode(e.id).data.rank-t.getNode(r.id).data.rank})),d=h.filter((function(e){return void 0!==t.getNode(e.id).data.fixorder})).sort((function(e,r){return t.getNode(e.id).data.fixorder-t.getNode(r.id).data.fixorder}));return null==d||d.forEach((function(r){isNaN(t.getNode(r.id).data.rank)||i[t.getNode(r.id).data.rank].push(r.id),e[r.id]=!0})),null==h||h.forEach((function(r){return t.dfsTree(r.id,(function(t){if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||i[t.data.rank].push(t.id)}))})),i},Ir=function(t,e,r){for(var n=Be(r,r.map((function(t,e){return e}))),o=e.map((function(e){var r=t.getRelatedEdges(e,"out").map((function(t){return{pos:n[t.target]||0,weight:t.data.weight}}));return null==r?void 0:r.sort((function(t,e){return t.pos-e.pos}))})),i=o.flat().filter((function(t){return void 0!==t})),a=1;a<r.length;)a<<=1;var s=2*a-1;a-=1;var u=Array(s).fill(0,0,s),h=0;return null==i||i.forEach((function(t){if(t){var e=t.pos+a;u[e]+=t.weight;for(var r=0;e>0;)e%2&&(r+=u[e+1]),u[e=e-1>>1]+=t.weight;h+=t.weight*r}})),h},Tr=function(t,e){for(var r=0,n=1;n<(null==e?void 0:e.length);n+=1)r+=Ir(t,e[n-1],e[n]);return r},Pr=function(t){for(var e;t.hasNode(e="_root"+Math.random()););return e},Dr=function(t){for(var e,r,n=[],o=function(){var o=t.pop();n.push(o),null===(e=o.in.reverse())||void 0===e||e.forEach((function(t){return(e=o,function(t){t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&Cr(e,t)})(t);var e})),null===(r=o.out)||void 0===r||r.forEach((function(e){return(r=o,function(e){e.in.push(r),0==--e.indegree&&t.push(e)})(e);var r}))};null==t?void 0:t.length;)o();var i=n.filter((function(t){return!t.merged})),a=["vs","i","barycenter","weight"];return i.map((function(t){var e={};return null==a||a.forEach((function(r){void 0!==t[r]&&(e[r]=t[r])})),e}))},Cr=function(t,e){var r,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},Lr=function(t,e){var r,n,o,i={};null==t||t.forEach((function(t,e){i[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};var 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((function(t){var e=i[t.source],r=i[t.target];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(i[t.target]))}));var a=null===(o=(n=Object.values(i)).filter)||void 0===o?void 0:o.call(n,(function(t){return!t.indegree}));return Dr(a)},jr=function(t,e,r){for(var n,o=r;e.length&&(n=e[e.length-1]).i<=o;)e.pop(),null==t||t.push(n.vs),o++;return o},Fr=function(t,e){return function(r,n){if(void 0!==r.fixorder&&void 0!==n.fixorder)return r.fixorder-n.fixorder;if(r.barycenter<n.barycenter)return-1;if(r.barycenter>n.barycenter)return 1;if(e&&void 0!==r.order&&void 0!==n.order){if(r.order<n.order)return-1;if(r.order>n.order)return 1}return t?n.i-r.i:r.i-n.i}},qr=function(t,e,r,n,o,i){var a,s,u,h,d=t.getChildren(e).map((function(t){return t.id})),c=t.getNode(e),f=c?c.data.borderLeft:void 0,l=c?c.data.borderRight:void 0,g={};f&&(d=null==d?void 0:d.filter((function(t){return t!==f&&t!==l})));var v=function(t,e){return e.map((function(e){var r=t.getRelatedEdges(e,"in");if(!(null==r?void 0:r.length))return{v:e};var n={sum:0,weight:0};return null==r||r.forEach((function(e){var 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,d||[]);null==v||v.forEach((function(e){var o;if(null===(o=t.getChildren(e.v))||void 0===o?void 0:o.length){var a=qr(t,e.v,r,n,i);g[e.v]=a,a.hasOwnProperty("barycenter")&&Gr(e,a)}}));var p=Lr(v,r);Vr(p,g),null===(a=p.filter((function(t){return t.vs.length>0})))||void 0===a||a.forEach((function(e){var r=t.getNode(e.vs[0]);r&&(e.fixorder=r.data.fixorder,e.order=r.data.order)}));var y=function(t,e,r,n){var o=function(t,e){var r={lhs:[],rhs:[]};return null==t||t.forEach((function(t){e(t)?r.lhs.push(t):r.rhs.push(t)})),r}(t,(function(t){var e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return n?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")})),i=o.lhs,a=o.rhs.sort((function(t,e){return-t.i- -e.i})),s=[],u=0,h=0,d=0;null==i||i.sort(Fr(!!e,!!r)),d=jr(s,a,d),null==i||i.forEach((function(t){var e;d+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,h+=t.weight,d=jr(s,a,d)}));var c={vs:s.flat()};return h&&(c.barycenter=u/h,c.weight=h),c}(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)){var m=t.getNode((null===(u=t.getPredecessors(f))||void 0===u?void 0:u[0].id)||""),w=t.getNode((null===(h=t.getPredecessors(l))||void 0===h?void 0:h[0].id)||"");y.hasOwnProperty("barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+m.data.order+w.data.order)/(y.weight+2),y.weight+=2}return y},Vr=function(t,e){null==t||t.forEach((function(t){var r,n=null===(r=t.vs)||void 0===r?void 0:r.map((function(t){return e[t]?e[t].vs:t}));t.vs=n.flat()}))},Gr=function(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)};var Br=function(t){if("object"!=typeof t||null===t)return t;var e,r;if(r=t,Array.isArray(r)){e=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=Br(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=Br(t[i]):e[i]=t[i];return e},Ur=Br,Wr=function(t,e,r){return e.map((function(e){return function(t,e,r){var o=Pr(t),i=new v({tree:[{id:o,children:[],data:{}}]});return t.getAllNodes().forEach((function(a){var s=t.getParent(a.id);(a.data.rank===e||a.data.minRank<=e&&e<=a.data.maxRank)&&(i.hasNode(a.id)||i.addNode(n({},a)),(null==s?void 0:s.id)&&!i.hasNode(null==s?void 0:s.id)&&i.addNode(n({},s)),i.setParent(a.id,(null==s?void 0:s.id)||o),t.getRelatedEdges(a.id,r).forEach((function(e){var r=e.source===a.id?e.target:e.source;i.hasNode(r)||i.addNode(n({},t.getNode(r)));var o=i.getRelatedEdges(r,"out").find((function(t){return t.target===a.id})),s=void 0!==o?o.data.weight:0;o?i.updateEdgeData(o.id,n(n({},o.data),{weight:e.data.weight+s})):i.addEdge({id:e.id,source:r,target:a.id,data:{weight:e.data.weight+s}})})),a.data.hasOwnProperty("minRank")&&i.updateNodeData(a.id,n(n({},a.data),{borderLeft:a.data.borderLeft[e],borderRight:a.data.borderRight[e]})))})),i}(t,e,r)}))},Hr=function(t,e,r,n){var o=new v;null==t||t.forEach((function(t){for(var i,a=t.getRoots()[0].id,s=qr(t,a,o,e,r,n),u=0;u<(null===(i=s.vs)||void 0===i?void 0:i.length);u++){var h=t.getNode(s.vs[u]);h&&(h.data.order=u)}!function(t,e,r){var n,o={};null==r||r.forEach((function(r){for(var i,a,s=t.getParent(r);s;){if((i=t.getParent(s.id))?(a=o[i.id],o[i.id]=s.id):(a=n,n=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)}))},Yr=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,r){t.getNode(e).data.order=r}))}))},Kr=function(t,e){var r={};return(null==e?void 0:e.length)&&e.reduce((function(e,n){var o=0,i=0,a=e.length,s=null==n?void 0:n[(null==n?void 0:n.length)-1];return null==n||n.forEach((function(e,u){var h,d=Qr(t,e),c=d?t.getNode(d.id).data.order:a;(d||e===s)&&(null===(h=n.slice(i,u+1))||void 0===h||h.forEach((function(e){var n;null===(n=t.getPredecessors(e))||void 0===n||n.forEach((function(n){var i,a=t.getNode(n.id),s=a.data.order;!(s<o||c<s)||a.data.dummy&&(null===(i=t.getNode(e))||void 0===i?void 0:i.data.dummy)||Xr(r,n.id,e)}))})),i=u+1,o=c)})),n})),r},Jr=function(t,e){var r={};function n(e,n,o,i,a){for(var s,u,h,d=n;d<o;d++)h=e[d],(null===(s=t.getNode(h))||void 0===s?void 0:s.data.dummy)&&(null===(u=t.getPredecessors(h))||void 0===u||u.forEach((function(e){var n=t.getNode(e.id);n.data.dummy&&(n.data.order<i||n.data.order>a)&&Xr(r,e.id,h)})))}function o(t,e){var r=function(t){return JSON.stringify(t.slice(1))}(t);e.get(r)||(n.apply(void 0,u([],s(t))),e.set(r,!0))}return(null==e?void 0:e.length)&&e.reduce((function(e,r){var n,i=-1,a=0,s=new Map;return null==r||r.forEach((function(u,h){var d;if("border"===(null===(d=t.getNode(u))||void 0===d?void 0:d.data.dummy)){var c=t.getPredecessors(u)||[];c.length&&(n=t.getNode(c[0].id).data.order,o([r,a,h,i,n],s),a=h,i=n)}o([r,a,r.length,n,e.length],s)})),r})),r},Qr=function(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((function(e){return t.getNode(e.id).data.dummy}))},Xr=function(t,e,r){var n=e,o=r;if(n>o){var i=n;n=o,o=i}var a=t[n];a||(t[n]=a={}),a[o]=!0},Zr=function(t,e,r){var n=e;n>r&&(n=r);return!!t[n]},$r=function(t,e,r,n){var o={},i={},a={};return null==e||e.forEach((function(t){null==t||t.forEach((function(t,e){o[t]=t,i[t]=t,a[t]=e}))})),null==e||e.forEach((function(t){var e=-1;null==t||t.forEach((function(t){var s=n(t).map((function(t){return t.id}));if(s.length){s=s.sort((function(t,e){return a[t]-a[e]}));for(var u=(s.length-1)/2,h=Math.floor(u),d=Math.ceil(u);h<=d;++h){var c=s[h];i[t]===t&&e<a[c]&&!Zr(r,t,c)&&(i[c]=t,i[t]=o[t]=o[c],e=a[c])}}}))})),{root:o,align:i}},tn=function(t,e,r,n,o,i,a){var s,u={},h=en(t,e,r,o,i,a),d=a?"borderLeft":"borderRight",c=function(t,e){for(var r=h.getAllNodes(),n=r.pop(),o={};n;)o[n.id]?t(n.id):(o[n.id]=!0,r.push(n),r=r.concat(e(n.id))),n=r.pop()};return c((function(t){u[t]=(h.getRelatedEdges(t,"in")||[]).reduce((function(t,e){return Math.max(t,(u[e.source]||0)+e.data.weight)}),0)}),h.getPredecessors.bind(h)),c((function(e){var r=(h.getRelatedEdges(e,"out")||[]).reduce((function(t,e){return Math.min(t,(u[e.target]||0)-e.data.weight)}),Number.POSITIVE_INFINITY),n=t.getNode(e);r!==Number.POSITIVE_INFINITY&&n.data.borderType!==d&&(u[e]=Math.max(u[e],r))}),h.getSuccessors.bind(h)),null===(s=Object.values(n))||void 0===s||s.forEach((function(t){u[t]=u[r[t]]})),u},en=function(t,e,r,o,i,a){var s=new v,u=sn(o,i,a);return null==e||e.forEach((function(e){var o;null==e||e.forEach((function(e){var i=r[e];if(s.hasNode(i)||s.addNode({id:i,data:{}}),o){var a=r[o],h=s.getRelatedEdges(a,"out").find((function(t){return t.target===i}));h?s.updateEdgeData(h.id,n(n({},h.data),{weight:Math.max(u(t,e,o),h.data.weight||0)})):s.addEdge({id:"e"+Math.random(),source:a,target:i,data:{weight:Math.max(u(t,e,o),0)}})}o=e}))})),s},rn=function(t,e){return Ke(Object.values(e),(function(e){var r,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return null===(r=Object.keys(e))||void 0===r||r.forEach((function(r){var i=e[r],a=un(t,r)/2;n=Math.max(i+a,n),o=Math.min(i-a,o)})),n-o}))};function nn(t,e){var r=Object.values(e),n=Math.min.apply(Math,u([],s(r))),o=Math.max.apply(Math,u([],s(r)));["u","d"].forEach((function(r){["l","r"].forEach((function(i){var a,h=r+i,d=t[h];if(d!==e){var c=Object.values(d);(a="l"===i?n-Math.min.apply(Math,u([],s(c))):o-Math.max.apply(Math,u([],s(c))))&&(t[h]={},Object.keys(d).forEach((function(e){t[h][e]=d[e]+a})))}}))}))}var on,an=function(t,e){var r={};return Object.keys(t.ul).forEach((function(n){if(e)r[n]=t[e.toLowerCase()][n];else{var o=Object.values(t).map((function(t){return t[n]}));r[n]=(o[0]+o[1])/2}})),r},sn=function(t,e,r){return function(n,o,i){var a=n.getNode(o),s=n.getNode(i),u=0,h=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":h=-a.data.width/2;break;case"r":h=a.data.width/2}if(h&&(u+=r?h:-h),h=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":h=s.data.width/2;break;case"r":h=-s.data.width/2}return h&&(u+=r?h:-h),h=0,u}},un=function(t,e){return t.getNode(e).data.width||0},hn=function(t,e){var r,n=Ge(t);!function(t,e){var r=(e||{}).ranksep,n=void 0===r?0:r,o=We(t),i=0;null==o||o.forEach((function(e){var r=e.map((function(e){return t.getNode(e).data.height})),o=Math.max.apply(Math,u(u([],s(r)),[0]));null==e||e.forEach((function(e){t.getNode(e).data.y=i+o/2})),i+=o+n}))}(n,e);var o=function(t,e){var r=e||{},n=r.align,o=r.nodesep,i=void 0===o?0:o,a=r.edgesep,s=void 0===a?0:a,u=We(t),h=Object.assign(Kr(t,u),Jr(t,u)),d={},c=[];["u","d"].forEach((function(e){c="u"===e?u:Object.values(u).reverse(),["l","r"].forEach((function(r){"r"===r&&(c=c.map((function(t){return Object.values(t).reverse()})));var n=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),o=$r(0,c,h,n),a=tn(t,c,o.root,o.align,i,s,"r"===r);"r"===r&&Object.keys(a).forEach((function(t){return a[t]=-a[t]})),d[e+r]=a}))}));var f=rn(t,d);return f&&nn(d,f),an(d,n)}(n,e);null===(r=Object.keys(o))||void 0===r||r.forEach((function(t){n.getNode(t).data.x=o[t]}))},dn=function(t,e){var r=e.acyclicer,o=e.ranker,i=e.rankdir,a=void 0===i?"tb":i,h=e.nodeOrder,d=e.keepNodeOrder,c=e.align,f=e.nodesep,l=void 0===f?50:f,g=e.edgesep,v=void 0===g?20:g,p=e.ranksep,y=void 0===p?50:p;_n(t),Fe(t,r);var m=function(t){var e=Ve(t,"root",{},"_root"),r=Er(t),n=Math.max.apply(Math,u([],s(Object.values(r))));Math.abs(n)===1/0&&(n=1);var o=n-1,i=2*o+1;t.getAllEdges().forEach((function(t){t.data.minlen*=i}));var a=Mr(t)+1;return t.getRoots().forEach((function(n){br(t,e,i,a,o,r,n.id)})),{nestingRoot:e,nodeRankFactor:i}}(t),w=m.nestingRoot,x=m.nodeRankFactor;!function(t,e){switch(e){case"network-simplex":wr(t);break;case"tight-tree":default:mr(t);break;case"longest-path":yr(t)}}(Ge(t),o),xn(t),function(t,e){void 0===e&&(e=0);var r=t.getAllNodes(),n=r.filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),o=Math.min.apply(Math,u([],s(n))),i=[];r.forEach((function(t){var e=(t.data.rank||0)-o;i[e]||(i[e]=[]),i[e].push(t.id)}));for(var a=0,h=0;h<i.length;h++){var d=i[h];void 0===d?h%e!=0&&(a-=1):a&&(null==d||d.forEach((function(e){var r=t.getNode(e);r&&(r.data.rank=r.data.rank||0,r.data.rank+=a)})))}}(t,x),function(t,e){e&&t.removeNode(e),t.getAllEdges().forEach((function(e){e.data.nestingEdge&&t.removeEdge(e.id)}))}(t,w),function(t){var e=t.getAllNodes().filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),r=Math.min.apply(Math,u([],s(e)));t.getAllNodes().forEach((function(t){t.data.hasOwnProperty("rank")&&r!==1/0&&(t.data.rank-=r)}))}(t),bn(t),En(t);var b=[];!function(t,e){t.getAllEdges().forEach((function(r){return Ze(t,r,e)}))}(t,b),xr(t,b),function(t){var e=function(r){var n=t.getChildren(r),o=t.getNode(r);if((null==n?void 0:n.length)&&n.forEach((function(t){return e(t.id)})),o.data.hasOwnProperty("minRank")){o.data.borderLeft=[],o.data.borderRight=[];for(var i=o.data.minRank,a=o.data.maxRank+1;i<a;i+=1)Nr(t,"borderLeft","_bl",r,o,i),Nr(t,"borderRight","_br",r,o,i)}};t.getRoots().forEach((function(t){return e(t.id)}))}(t),d&&function(t,e){for(var r=t.getAllNodes().filter((function(e){var r;return!(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length)})).map((function(t){return t.data.rank})),n=Math.max.apply(Math,u([],s(r))),o=[],i=0;i<n+1;i++)o[i]=[];null==e||e.forEach((function(e){var 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,h),function(t,e){for(var r=Ye(t),n=[],o=[],i=1;i<r+1;i++)n.push(i);for(i=r-1;i>-1;i--)o.push(i);var a=Wr(t,n,"in"),s=Wr(t,o,"out"),u=Or(t);Yr(t,u);for(var h,d=Number.POSITIVE_INFINITY,c=(i=0,0);c<4;++i,++c)Hr(i%2?a:s,i%4>=2,!1,e),u=We(t),(f=Tr(t,u))<d&&(c=0,h=Ur(u),d=f);for(u=Or(t),Yr(t,u),i=0,c=0;c<4;++i,++c){var f;Hr(i%2?a:s,i%4>=2,!0,e),u=We(t),(f=Tr(t,u))<d&&(c=0,h=Ur(u),d=f)}Yr(t,h)}(t,d),zn(t),function(t,e){var r=e.toLowerCase();"lr"!==r&&"rl"!==r||kr(t)}(t,a),hn(t,{align:c,nodesep:l,edgesep:v,ranksep:y}),Rn(t),An(t),function(t,e){e.forEach((function(e){var r,n=t.getNode(e),o=n.data.originalEdge;o&&t.addEdge(o);for(var i=e;n.data.dummy;)r=t.getSuccessors(i)[0],t.removeNode(i),o.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===Xe&&(o.data.x=n.data.x,o.data.y=n.data.y,o.data.width=n.data.width,o.data.height=n.data.height),i=r.id,n=t.getNode(i)}))}(t,b),kn(t),function(t,e){var r=e.toLowerCase();"bt"!==r&&"rl"!==r||Ar(t),"lr"!==r&&"rl"!==r||(zr(t),kr(t))}(t,a);var E=Mn(t),M=E.width,N=E.height;return Nn(t),Sn(t),function(t){t.getAllEdges().forEach((function(e){var r=e.data;if(r.reversed){t.removeEdge(e.id);var o=r.forwardName;delete r.reversed,delete r.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:n(n({},r),{forwardName:o})})}}))}(t),{width:M,height:N}},cn=function(t,e){t.getAllNodes().forEach((function(r){var n=t.getNode(r.id);if(e.hasNode(r.id)){var o=e.getNode(r.id);n.data.fixorder=o.data._order,delete o.data._order}else delete n.data.fixorder}))},fn=function(t,e){t.getAllNodes().forEach((function(r){var n,o=t.getNode(r.id);if(o){var i=e.getNode(r.id);o.data.x=i.data.x,o.data.y=i.data.y,o.data._order=i.data.order,o.data._rank=i.data.rank,(null===(n=e.getChildren(r.id))||void 0===n?void 0:n.length)&&(o.data.width=i.data.width,o.data.height=i.data.height)}})),t.getAllEdges().forEach((function(r){var 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)}))},ln=["width","height","layer","fixorder"],gn={width:0,height:0},vn=["minlen","weight","width","height","labeloffset"],pn={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},yn=["labelpos"],mn=function(t){var e=new v({tree:[]});return t.getAllNodes().forEach((function(r){var o=In(t.getNode(r.id).data),i=n(n({},gn),o),a=On(i,ln);e.hasNode(r.id)||e.addNode({id:r.id,data:n({},a)});var s=t.hasTreeStructure("combo")?t.getParent(r.id,"combo"):t.getParent(r.id);null!=s&&(e.hasNode(s.id)||e.addNode(n({},s)),e.setParent(r.id,s.id))})),t.getAllEdges().forEach((function(r){var n=In(t.getEdge(r.id).data),o={};null==yn||yn.forEach((function(t){void 0!==n[t]&&(o[t]=n[t])})),e.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},pn,On(n,vn),o)})})),e},wn=function(t,e){var r=e.ranksep,n=void 0===r?0:r,o=e.rankdir;return t.getAllNodes().forEach((function(t){isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((function(t){var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===o||"BT"===o?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2},xn=function(t){t.getAllEdges().forEach((function(e){if(e.data.width&&e.data.height){var r=t.getNode(e.source),n={e:e,rank:(t.getNode(e.target).data.rank-r.data.rank)/2+r.data.rank};Ve(t,"edge-proxy",n,"_ep")}}))},bn=function(t){var e=0;return t.getAllNodes().forEach((function(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},En=function(t){t.getAllNodes().forEach((function(e){"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Mn=function(t,e){var r,n,o=0,i=0,a=e||{},s=a.marginx,u=void 0===s?0:s,h=a.marginy,d=void 0===h?0:h,c=function(t){if(t.data){var 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((function(t){c(t)})),t.getAllEdges().forEach((function(t){(null==t?void 0:t.data.hasOwnProperty("x"))&&c(t)})),r-=u,n-=d,t.getAllNodes().forEach((function(t){t.data.x-=r,t.data.y-=n})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(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+u,height:i-n+d}},Nn=function(t){t.getAllEdges().forEach((function(e){var r,n,o=t.getNode(e.source),i=t.getNode(e.target);e.data.points?(r=e.data.points[0],n=e.data.points[e.data.points.length-1]):(e.data.points=[],r={x:i.data.x,y:i.data.y},n={x:o.data.x,y:o.data.y}),e.data.points.unshift(Ue(o.data,r)),e.data.points.push(Ue(i.data,n))}))},kn=function(t){t.getAllEdges().forEach((function(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}}))},Sn=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},An=function(t){t.getAllNodes().forEach((function(e){var r,n,o;if(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length){var i=t.getNode(e.id),a=t.getNode(i.data.borderTop),s=t.getNode(i.data.borderBottom),u=t.getNode(i.data.borderLeft[(null===(n=i.data.borderLeft)||void 0===n?void 0:n.length)-1]),h=t.getNode(i.data.borderRight[(null===(o=i.data.borderRight)||void 0===o?void 0:o.length)-1]);i.data.width=Math.abs((null==h?void 0:h.data.x)-(null==u?void 0:u.data.x))||10,i.data.height=Math.abs((null==s?void 0:s.data.y)-(null==a?void 0:a.data.y))||10,i.data.x=((null==u?void 0:u.data.x)||0)+i.data.width/2,i.data.y=((null==a?void 0:a.data.y)||0)+i.data.height/2}})),t.getAllNodes().forEach((function(e){"border"===e.data.dummy&&t.removeNode(e.id)}))},_n=function(t){t.getAllEdges().forEach((function(e){if(e.source===e.target){var r=t.getNode(e.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(e),t.removeEdge(e.id)}}))},zn=function(t){var e=We(t);null==e||e.forEach((function(e){var r=0;null==e||e.forEach((function(e,n){var o,i=t.getNode(e);i.data.order=n+r,null===(o=i.data.selfEdges)||void 0===o||o.forEach((function(e){Ve(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e:e},"_se")})),delete i.data.selfEdges}))}))},Rn=function(t){t.getAllNodes().forEach((function(e){var r=t.getNode(e.id);if("selfedge"===r.data.dummy){var 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}}))},On=function(t,e){var r={};return null==e||e.forEach((function(e){void 0!==t[e]&&(r[e]=+t[e])})),r},In=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(r){e[r.toLowerCase()]=t[r]})),e},Tn={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null},Pn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.options=n(n({},Tn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericDagreLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericDagreLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericDagreLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,h,d,c,f,l,g,p,y,m,w,x,b,E,M,N,k,S,A,_,z,R,O,I,T,P,D,C,j,q,G,U,W,H;return a(this,(function(a){return o=n(n({},this.options),r),i=o.nodeSize,s=o.align,u=o.rankdir,h=void 0===u?"TB":u,d=o.ranksep,c=o.nodesep,f=o.ranksepFunc,l=o.nodesepFunc,g=o.edgeLabelSpace,p=o.ranker,y=o.nodeOrder,m=o.begin,w=o.controlPoints,x=o.radial,b=o.sortByCombo,E=o.preset,M=new v({tree:[]}),N=F(d||50,f),k=F(c||50,l),S=k,A=N,"LR"!==h&&"RL"!==h||(S=N,A=k),_=V(i,void 0),z=e.getAllNodes(),R=e.getAllEdges(),z.forEach((function(t){var e=_(t),r=A(t),n=e+2*S(t),o=e+2*r,i=t.data.layer;L(i)?M.addNode({id:t.id,data:{width:n,height:o,layer:i}}):M.addNode({id:t.id,data:{width:n,height:o}})})),b&&(M.attachTreeStructure("combo"),z.forEach((function(t){var e=t.data.parentId;void 0!==e&&M.hasNode(e)&&M.setParent(t.id,e,"combo")}))),R.forEach((function(t){M.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),O=void 0,(null==E?void 0:E.length)&&(O=new v({nodes:E})),function(t,e){var r=e.edgeLabelSpace,n=e.keepNodeOrder,o=e.prevGraph,i=e.rankdir,a=e.ranksep;!n&&o&&cn(t,o);var s,u=mn(t);r&&(e.ranksep=wn(u,{rankdir:i,ranksep:a}));try{s=dn(u,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}fn(t,u)}(M,{prevGraph:O,edgeLabelSpace:g,keepNodeOrder:!!y,nodeOrder:y||[],acyclicer:"greedy",ranker:p,rankdir:h,nodesep:c,align:s}),I=[0,0],m&&(T=1/0,P=1/0,M.getAllNodes().forEach((function(t){T>t.data.x&&(T=t.data.x),P>t.data.y&&(P=t.data.y)})),M.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){T>t.x&&(T=t.x),P>t.y&&(P=t.y)}))})),I[0]=m[0]-T,I[1]=m[1]-P),D="LR"===h||"RL"===h,x||(C=new Set,j="BT"===h||"RL"===h?function(t,e){return e-t}:function(t,e){return t-e},M.getAllNodes().forEach((function(t){t.data.x=t.data.x+I[0],t.data.y=t.data.y+I[1],C.add(D?t.data.x:t.data.y)})),q=Array.from(C).sort(j),G=D?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},U=D?function(t,e,r){var n=Math.max(e.y,r.y),o=Math.min(e.y,r.y);return t.filter((function(t){return t.y<=n&&t.y>=o}))}:function(t,e,r){var n=Math.max(e.x,r.x),o=Math.min(e.x,r.x);return t.filter((function(t){return t.x<=n&&t.x>=o}))},M.getAllEdges().forEach((function(t,e){var r;g&&w&&"loop"!==t.data.type&&(t.data.controlPoints=Dn(null===(r=t.data.points)||void 0===r?void 0:r.map((function(t){var e=t.x,r=t.y;return{x:e+I[0],y:r+I[1]}})),M.getNode(t.source),M.getNode(t.target),q,D,G,U))}))),W=[],W=M.getAllNodes().map((function(t){return B(t)})),H=M.getAllEdges(),t&&(W.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),H.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:W,edges:H}]}))}))},t}(),Dn=function(t,e,r,n,o,i,a){var s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&r){var u=e.data,h=u.x,d=u.y,c=r.data,f=c.x,l=c.y;if(o&&(h=e.data.y,d=e.data.x,f=r.data.y,l=r.data.x),l!==d&&h!==f){var g=n.indexOf(d),v=n[g+1];if(v){var p=s[0],y=o?{x:(d+v)/2,y:(null==p?void 0:p.y)||f}:{x:(null==p?void 0:p.x)||f,y:(d+v)/2};p&&!i(p,y)||s.unshift(y)}var m=n.indexOf(l),w=Math.abs(m-g);if(1===w)(s=a(s,e.data,r.data)).length||s.push(o?{x:(d+l)/2,y:h}:{x:h,y:(d+l)/2});else if(w>1){var x=n[m-1];if(x){var b=s[s.length-1],E=o?{x:(l+x)/2,y:(null==b?void 0:b.y)||f}:{x:(null==b?void 0:b.x)||h,y:(l+x)/2};b&&!i(b,E)||s.push(E)}}}}return s},Cn=function(){function t(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}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,r=t.ry-this.ry,n=Math.hypot(e,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var r=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/r,ry:(this.ry*this.mass+e.ry*e.mass)/r,mass:r,degree:this.degree+e.degree})},t}(),Ln=Cn,jn=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),Fn=jn,qn=function(){function t(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)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(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))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}(),Vn={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1},Gn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=n(n({},Vn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,h,d,c,f,l,g,p,y,m,w,x,b,E,M,N,k,S,A;return a(this,(function(a){if(o=e.getAllEdges(),i=e.getAllNodes(),s=this.formatOptions(r,i.length),u=s.width,h=s.height,d=s.prune,c=s.maxIteration,f=s.nodeSize,l=s.center,!(null==i?void 0:i.length)||1===i.length)return[2,U(e,t,l)];if(g=i.map((function(t){return B(t,[u,h])})),p=o.filter((function(t){return t.source!==t.target})),y=new v({nodes:g,edges:p}),m=this.getSizes(y,e,f),this.run(y,e,c,m,t,s),d){for(w=0;w<p.length;w+=1)x=p[w],b=x.source,E=x.target,M=y.getDegree(b),N=y.getDegree(b),M<=1?(k=y.getNode(E),y.mergeNodeData(b,{x:k.data.x,y:k.data.y})):N<=1&&(S=y.getNode(b),y.mergeNodeData(E,{x:S.data.x,y:S.data.y}));A=n(n({},s),{prune:!1,barnesHut:!1}),this.run(y,e,100,m,t,A)}return[2,{nodes:g,edges:o}]}))}))},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},i=0;i<n.length;i+=1){var a=n[i],h=a.id,d=a.data;if(o[h]=10,L(d.size))o[h]=d.size;else if(J(d.size))isNaN(d.size[0])||(o[h]=Math.max(d.size[0])),isNaN(d.size[1])||(o[h]=Math.max(d.size[1]));else if(j(d.size))o[h]=Math.max(d.size.width,d.size.height);else if(C(r)){var c=r(e.getNode(h));J(c)?o[h]=Math.max.apply(Math,u([],s(c))):o[h]=c}else J(r)?o[h]=Math.max.apply(Math,u([],s(r))):L(r)&&(o[h]=r)}return o},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var r=n(n({},this.options),t),o=r.center,i=r.width,a=r.height,s=r.barnesHut,u=r.prune,h=r.maxIteration,d=r.kr,c=r.kg;return r.width=i||"undefined"==typeof window?i:window.innerWidth,r.height=a||"undefined"==typeof window?a:window.innerHeight,r.center=o||[r.width/2,r.height/2],void 0===s&&e>250&&(r.barnesHut=!0),void 0===u&&e>100&&(r.prune=!0),0!==h||u?0===h&&u&&(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)),d||(r.kr=50,e>100&&e<=500?r.kr=20:e>500&&(r.kr=1)),c||(r.kg=20,e>100&&e<=500?r.kg=10:e>500&&(r.kg=1)),r},t.prototype.run=function(t,e,r,n,o,i){for(var a=i.kr,s=i.barnesHut,u=i.onTick,h=t.getAllNodes(),d=0,c=r,f={},l={},g={},v=0;v<h.length;v+=1){var p=h[v],y=p.data,m=p.id;if(f[m]=[0,0],s){var w={id:v,rx:y.x,ry:y.y,mass:1,g:a,degree:t.getDegree(m)};g[m]=new Ln(w)}}for(;c>0;)d=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:d,forces:f,preForces:l,bodies:g,sizes:n},i),c--,null==u||u({nodes:h,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,o=e.preventOverlapIters,i=e.krPrime,a=e.sg,h=e.preForces,d=e.bodies,c=e.sizes,f=e.forces,l=r.preventOverlap,g=r.barnesHut,v=t.getAllNodes(),p=0;p<v.length;p+=1){var y=v[p].id;h[y]=u([],s(f[y])),f[y]=[0,0]}return f=this.getAttrForces(t,n,o,c,f,r),f=g&&(l&&n>o||!l)?this.getOptRepGraForces(t,f,d,r):this.getRepGraForces(t,n,o,f,i,c,r),this.updatePos(t,f,h,a,r)},t.prototype.getAttrForces=function(t,e,r,n,o,i){for(var a=i.preventOverlap,s=i.dissuadeHubs,u=i.mode,h=i.prune,d=t.getAllEdges(),c=0;c<d.length;c+=1){var f=d[c],l=f.source,g=f.target,v=t.getNode(l),p=t.getNode(g),y=t.getDegree(l),m=t.getDegree(g);if(!h||!(y<=1||m<=1)){var w=[p.data.x-v.data.x,p.data.y-v.data.y],x=Math.hypot(w[0],w[1]);x=x<1e-4?1e-4:x,w[0]=w[0]/x,w[1]=w[1]/x,a&&e<r&&(x=x-n[l]-n[g]);var b=x,E=b;"linlog"===u&&(E=b=Math.log(1+x)),s&&(b=x/y,E=x/m),a&&e<r&&x<=0?(b=0,E=0):a&&e<r&&x>0&&(b=x,E=x),o[l][0]+=b*w[0],o[g][0]-=E*w[0],o[l][1]+=b*w[1],o[g][1]-=E*w[1]}}return o},t.prototype.getOptRepGraForces=function(t,e,r,n){for(var o=n.kg,i=n.center,a=n.prune,s=t.getAllNodes(),u=s.length,h=9e10,d=-9e10,c=9e10,f=-9e10,l=0;l<u;l+=1){var g=s[l],v=g.id,p=g.data;a&&t.getDegree(v)<=1||(r[v].setPos(p.x,p.y),p.x>=d&&(d=p.x),p.x<=h&&(h=p.x),p.y>=f&&(f=p.y),p.y<=c&&(c=p.y))}var y=Math.max(d-h,f-c),m=new Fn({xmid:(d+h)/2,ymid:(f+c)/2,length:y,massCenter:i,mass:u}),w=new qn(m);for(l=0;l<u;l+=1){v=s[l].id;a&&t.getDegree(v)<=1||r[v].in(m)&&w.insert(r[v])}for(l=0;l<u;l+=1){var x=s[l],b=(v=x.id,p=x.data,t.getDegree(v));if(!(a&&b<=1)){r[v].resetForce(),w.updateForce(r[v]),e[v][0]-=r[v].fx,e[v][1]-=r[v].fy;var E=[p.x-i[0],p.y-i[1]],M=Math.hypot(E[0],E[1]);M=M<1e-4?1e-4:M,E[0]=E[0]/M,E[1]=E[1]/M;var N=o*(b+1);e[v][0]-=N*E[0],e[v][1]-=N*E[1]}}return e},t.prototype.getRepGraForces=function(t,e,r,n,o,i,a){for(var s=a.preventOverlap,u=a.kr,h=a.kg,d=a.center,c=a.prune,f=t.getAllNodes(),l=f.length,g=0;g<l;g+=1){for(var v=f[g],p=t.getDegree(v.id),y=g+1;y<l;y+=1){var m=f[y],w=t.getDegree(m.id);if(!c||!(p<=1||w<=1)){var x=[m.data.x-v.data.x,m.data.y-v.data.y],b=Math.hypot(x[0],x[1]);b=b<1e-4?1e-4:b,x[0]=x[0]/b,x[1]=x[1]/b,s&&e<r&&(b=b-i[v.id]-i[m.id]);var E=u*(p+1)*(w+1)/b;s&&e<r&&b<0?E=o*(p+1)*(w+1):s&&e<r&&0===b?E=0:s&&e<r&&b>0&&(E=u*(p+1)*(w+1)/b),n[v.id][0]-=E*x[0],n[m.id][0]+=E*x[0],n[v.id][1]-=E*x[1],n[m.id][1]+=E*x[1]}}var M=[v.data.x-d[0],v.data.y-d[1]],N=Math.hypot(M[0],M[1]);M[0]=M[0]/N,M[1]=M[1]/N;var k=h*(p+1);n[v.id][0]-=k*M[0],n[v.id][1]-=k*M[1]}return n},t.prototype.updatePos=function(t,e,r,n,o){for(var i=o.ks,a=o.tao,s=o.prune,u=o.ksmax,h=t.getAllNodes(),d=h.length,c=[],f=[],l=0,g=0,v=n,p=0;p<d;p+=1){var y=h[p].id,m=t.getDegree(y);if(!(s&&m<=1)){var w=[e[y][0]-r[y][0],e[y][1]-r[y][1]],x=Math.hypot(w[0],w[1]),b=[e[y][0]+r[y][0],e[y][1]+r[y][1]],E=Math.hypot(b[0],b[1]);c[p]=x,f[p]=E/2,l+=(m+1)*c[p],g+=(m+1)*f[p]}}var M=v;v=a*g/l,0!==M&&(v=v>1.5*M?1.5*M:v);for(p=0;p<d;p+=1){var N=h[p],k=(y=N.id,N.data);m=t.getDegree(y);if(!(s&&m<=1)&&(!L(k.fx)||!L(k.fy))){var S=i*v/(1+v*Math.sqrt(c[p])),A=Math.hypot(e[y][0],e[y][1]),_=u/(A=A<1e-4?1e-4:A),z=(S=S>_?_:S)*e[y][0],R=S*e[y][1];t.mergeNodeData(y,{x:k.x+z,y:k.y+R})}}return v},t}(),Bn={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Un=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=n(n({},Bn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<t;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),n},t.prototype.genericFruchtermanLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,h,d,c,f,l,g,p,y,m,w,x,b,E=this;return a(this,(function(a){return this.running?[2]:(o=this.formatOptions(r),i=o.dimensions,s=o.width,u=o.height,h=o.center,d=o.clustering,c=o.nodeClusterBy,f=o.maxIteration,l=o.onTick,g=e.getAllNodes(),p=e.getAllEdges(),(null==g?void 0:g.length)?1===g.length?(t&&e.mergeNodeData(g[0].id,{x:h[0],y:h[1],z:3===i?h[2]:void 0}),y={nodes:[n(n({},g[0]),{data:n(n({},g[0].data),{x:h[0],y:h[1],z:3===i?h[2]:void 0})})],edges:p},this.lastResult=y,[2,y]):(m=g.map((function(t){return B(t,[s,u])})),w=new v({nodes:m,edges:p}),x={},d&&m.forEach((function(t){var e=t.data[c];x[e]||(x[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=m,this.lastLayoutEdges=p,this.lastAssign=t,this.lastGraph=w,this.lastOptions=o,this.lastClusterMap=x,"undefined"==typeof window?[2]:(b=0,[2,new Promise((function(r){E.timeInterval=window.setInterval((function(){E.running?(E.runOneStep(w,x,o),t&&m.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y,z:3===i?n.z:void 0})})),null==l||l({nodes:m,edges:p}),++b>=f&&(window.clearInterval(E.timeInterval),r({nodes:m,edges:p}))):r({nodes:m,edges:p})}),0),E.running=!0}))])):(y={nodes:[],edges:p},this.lastResult=y,[2,y]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=n(n({},this.options),t),r=e.clustering,o=e.nodeClusterBy,i=e.center,a=e.width,s=e.height;return e.width=a||"undefined"==typeof window?a:window.innerWidth,e.height=s||"undefined"==typeof window?s:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=r&&!!o,e},t.prototype.runOneStep=function(t,e,r){var n=r.dimensions,o=r.height,i=r.width,a=r.gravity,s=r.center,u=r.speed,h=r.clustering,d=r.nodeClusterBy,c=r.clusterGravity,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),h){for(var m in e)e[m].cx=0,e[m].cy=0,e[m].count=0;for(var m in g.forEach((function(t){var r=t.data,n=e[r[d]];L(r.x)&&(n.cx+=r.x),L(r.y)&&(n.cy+=r.y),n.count++})),e)e[m].cx/=e[m].count,e[m].cy/=e[m].count;var w=c||a;g.forEach((function(t,r){var n=t.id,o=t.data;if(L(o.x)&&L(o.y)){var i=e[o[d]],a=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),s=p*w;y[n].x-=s*(o.x-i.cx)/a,y[n].y-=s*(o.y-i.cy)/a}}))}g.forEach((function(t,e){var r=t.id,o=t.data;if(L(o.x)&&L(o.y)){var 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((function(e,r){var o=e.id,i=e.data;if(L(i.fx)&&L(i.fy))return i.x=i.fx,i.y=i.fy,void(3===n&&(i.z=i.fz));if(L(i.x)&&L(i.y)){var 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){var s=Math.min(l*(u/800),a);t.mergeNodeData(o,{x:i.x+y[o].x/a*s,y:i.y+y[o].y/a*s,z:3===n?i.z+y[o].z/a*s:void 0})}}}))},t.prototype.applyCalculate=function(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)},t.prototype.calRepulsive=function(t,e,r){var n=this,o=t.getAllNodes();o.forEach((function(t,i){var a=t.data,s=t.id;e[s]={x:0,y:0,z:0},o.forEach((function(t,o){var u=t.data,h=t.id;if(!(i<=o)&&L(a.x)&&L(u.x)&&L(a.y)&&L(u.y)){var d=a.x-u.x,c=a.y-u.y,f=3===n.options.dimensions?a.z-u.z:0,l=d*d+c*c+f*f;0===l&&(l=1,d=.01,c=.01,f=.01);var g=r/l,v=d*g,p=c*g,y=f*g;e[s].x+=v,e[s].y+=p,e[h].x-=v,e[h].y-=p,3===n.options.dimensions&&(e[s].z+=y,e[h].z-=y)}}))}))},t.prototype.calAttractive=function(t,e,r){var n=this;t.getAllEdges().forEach((function(o){var i=o.source,a=o.target;if(i&&a&&i!==a){var s=t.getNode(i).data,u=t.getNode(a).data;if(L(u.x)&&L(s.x)&&L(u.y)&&L(s.y)){var h=u.x-s.x,d=u.y-s.y,c=3===n.options.dimensions?u.z-s.z:0,f=Math.sqrt(h*h+d*d+c*c)/r,l=h*f,g=d*f,v=c*f;e[i].x+=l,e[i].y+=g,e[a].x-=l,e[a].y-=g,3===n.options.dimensions&&(e[i].z+=v,e[a].z-=v)}}}))},t}(),Wn={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300},Hn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=n(n({},Wn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,h,d,c,f,l,g,v,p,y,m,w,x,b,E,M,N,k,S,A,_,z,R,O,I,T,P,D,C,j,V,G,W,H;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.begin,s=void 0===i?[0,0]:i,u=o.condense,h=o.preventOverlapPadding,d=o.preventOverlap,c=o.rows,f=o.cols,l=o.nodeSpacing,g=o.nodeSize,v=o.width,p=o.height,y=o.position,m=o.sortBy,w=e.getAllNodes(),x=e.getAllEdges(),!(b=null==w?void 0:w.length)||1===b)return[2,U(e,t,s)];if(E=w.map((function(t){return B(t)})),"id"===m||Pt(m)&&void 0!==E[0].data[m]||(m="degree"),"degree"===m?E.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===m?E.sort((function(t,e){return L(e.id)&&L(t.id)?e.id-t.id:(""+t.id).localeCompare(""+e.id)})):E.sort((function(t,e){return e.data[m]-t.data[m]})),M=v||"undefined"==typeof window?v:window.innerWidth,N=p||"undefined"==typeof window?p:window.innerHeight,k=b,S={rows:c,cols:f},null!=c&&null!=f?(S.rows=c,S.cols=f):null!=c&&null==f?(S.rows=c,S.cols=Math.ceil(k/S.rows)):null==c&&null!=f?(S.cols=f,S.rows=Math.ceil(k/S.cols)):(A=Math.sqrt(k*N/M),S.rows=Math.round(A),S.cols=Math.round(M/N*A)),S.rows=Math.max(S.rows,1),S.cols=Math.max(S.cols,1),S.cols*S.rows>k)_=Yn(S),z=Kn(S),(_-1)*z>=k?Yn(S,_-1):(z-1)*_>=k&&Kn(S,z-1);else for(;S.cols*S.rows<k;)_=Yn(S),((z=Kn(S))+1)*_>=k?Kn(S,z+1):Yn(S,_+1);for(R=u?0:M/S.cols,O=u?0:N/S.rows,(d||l)&&(I=F(10,l),T=q(30,g,!1),E.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var r,n,o=e.getNode(t.id),i=T(o)||30;J(i)?(r=i[0],n=i[1]):(r=i,n=i);var a=void 0!==I?I(t):h,s=r+a,u=n+a;R=Math.max(R,s),O=Math.max(O,u)}))),P={},D={row:0,col:0},C={},j=0;j<E.length;j++){if(V=E[j],G=void 0,y&&(G=y(e.getNode(V.id))),G&&(void 0!==G.row||void 0!==G.col)){if(void 0===(W={row:G.row,col:G.col}).col)for(W.col=0;Jn(P,W);)W.col++;else if(void 0===W.row)for(W.row=0;Jn(P,W);)W.row++;C[V.id]=W,Qn(P,W)}Zn(V,s,R,O,C,S,D,P)}return H={nodes:E,edges:x},t&&E.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,H]}))}))},t}(),Yn=function(t,e){var r,n=t.rows||5,o=t.cols||5;null==e?r=Math.min(n,o):Math.min(n,o)===t.rows?t.rows=e:t.cols=e;return r},Kn=function(t,e){var r,n=t.rows||5,o=t.cols||5;null==e?r=Math.max(n,o):Math.max(n,o)===t.rows?t.rows=e:t.cols=e;return r},Jn=function(t,e){return t["c-"+e.row+"-"+e.col]||!1},Qn=function(t,e){return t["c-"+e.row+"-"+e.col]=!0},Xn=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Zn=function(t,e,r,n,o,i,a,s){var u,h,d=o[t.id];if(d)u=d.col*r+r/2+e[0],h=d.row*n+n/2+e[1];else{for(;Jn(s,a);)Xn(i,a);u=a.col*r+r/2+e[0],h=a.row*n+n/2+e[1],Qn(s,a),Xn(i,a)}t.data.x=u,t.data.y=h},$n={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},to=function(t,e,r,n,o,i){e.forEach((function(a,s){r[s]={x:0,y:0},e.forEach((function(e,u){if(s!==u&&o[s]===o[u]){var h=a.x-e.x,d=a.y-e.y,c=Math.sqrt(h*h+d*d);if(0===c){c=1;var f=s>u?1:-1;h=.01*f,d=.01*f}if(c<i(t[s])/2+i(t[u])/2){var l=n*n/c;r[s].x+=h/c*l,r[s].y+=d/c*l}}}))}))},eo=function(t,e,r,n,o,i,a,s){var u=i||a/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,a=Math.sqrt(n*n+i*i),s=i/a,u=-n/a,h=Math.sqrt(e.x*e.x+e.y*e.y),d=Math.acos((s*e.x+u*e.y)/h);d>Math.PI/2&&(d-=Math.PI/2,s*=-1,u*=-1);var c=Math.cos(d)*h;e.x=s*c,e.y=u*c})),t.forEach((function(i,a){if(a!==o){var h=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(h>0&&a!==o){var d=Math.min(u*(r/800),h);if(i.x+=e[a].x/h*d,i.y+=e[a].y/h*d,n){var c=i.x-t[o].x,f=i.y-t[o].y,l=Math.sqrt(c*c+f*f);c=c/l*s[a],f=f/l*s[a],i.x=t[o].x+c,i.y=t[o].y+f}}}})),t},ro={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},no=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=n(n({},ro),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,h,d,c,f,l,g,v,p,y,m,w,x,b,E,M,N,k,S,A,_,z,R,O,I,T,P,D,C,L,j,F,q,G,W,H,Y,K,J,Z,$,tt;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,h=o.height,d=o.center,c=o.focusNode,f=o.unitRadius,l=o.nodeSize,g=o.nodeSpacing,v=o.strictRadial,p=o.preventOverlap,y=o.maxPreventOverlapIteration,m=o.sortBy,w=o.linkDistance,x=void 0===w?50:w,b=o.sortStrength,E=void 0===b?10:b,M=o.maxIteration,N=void 0===M?1e3:M,k=e.getAllNodes(),S=e.getAllEdges(),A=i||"undefined"==typeof window?i:window.innerWidth,_=h||"undefined"==typeof window?h:window.innerHeight,z=d||[A/2,_/2],!(null==k?void 0:k.length)||1===k.length)return[2,U(e,t,z)];if(R=k[0],Pt(c)){for(O=0;O<k.length;O++)if(k[O].id===c){R=k[O];break}}else R=c||k[0];return I=ao(k,R.id),T=X({nodes:k,edges:S},!1),P=Q(T),D=uo(P,I),so(P,I,D+1),C=P[I],L=A-z[0]>z[0]?z[0]:A-z[0],j=_-z[1]>z[1]?z[1]:_-z[1],0===L&&(L=A/2),0===j&&(j=_/2),F=Math.min(L,j),q=Math.max.apply(Math,u([],s(C))),G=[],W=f||F/q,C.forEach((function(t,e){G[e]=t*W})),H=oo(k,P,x,G,W,m,E),Y=io(H),K=function(t,e,r){try{var n=et.mul(et.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),a=n.mean();n.add(a).subRowVector(o).subColumnVector(i);var s=new rt(n),u=et.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return et.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var h=[],d=0;d<e.length;d++){var c=Math.random()*r,f=Math.random()*r;h.push([c,f])}return h}}(x,H,x),J=K.map((function(t){var e=s(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*x:r)-K[I][0],y:(isNaN(n)?Math.random()*x:n)-K[I][1]}})),this.run(N,J,Y,H,G,I),p&&(Z=V(l,g),$={nodes:k,nodeSizeFunc:Z,positions:J,radii:G,height:_,width:A,strictRadial:Boolean(v),focusIdx:I,iterations:y||200,k:J.length/4.5},J=function(t,e){for(var r=n(n({},$n),e),o=r.positions,i=r.iterations,a=r.width,s=r.k,u=r.speed,h=void 0===u?100:u,d=r.strictRadial,c=r.focusIdx,f=r.radii,l=void 0===f?[]:f,g=r.nodeSizeFunc,v=t.getAllNodes(),p=[],y=a/10,m=0;m<i;m++)o.forEach((function(t,e){p[e]={x:0,y:0}})),to(v,o,p,s,l,g),eo(o,p,h,d,c,y,a,l);return o}(e,$)),tt=[],J.forEach((function(t,e){var r=B(k[e]);r.data.x=t.x+z[0],r.data.y=t.y+z[1],tt.push(r)})),t&&tt.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:tt,edges:S}]}))}))},t.prototype.run=function(t,e,r,n,o,i){for(var a=0;a<=t;a++){var s=a/t;this.oneIteration(s,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var a=1-t;e.forEach((function(s,u){var h=Z(s,{x:0,y:0}),d=0===h?0:1/h;if(u!==i){var c=0,f=0,l=0;e.forEach((function(t,e){if(u!==e){var r=Z(s,t),i=0===r?0:1/r,a=n[e][u];l+=o[u][e],c+=o[u][e]*(t.x+a*(s.x-t.x)*i),f+=o[u][e]*(t.y+a*(s.y-t.y)*i)}}));var g=0===r[u]?0:1/r[u];l*=a,l+=t*g*g,c*=a,c+=t*g*s.x*d,s.x=c/l,f*=a,f+=t*g*s.y*d,s.y=f/l}}))},t}(),oo=function(t,e,r,n,o,i,a){if(!t)return[];var s=[];if(e){var u={};e.forEach((function(e,h){var d=[];e.forEach((function(e,s){var c,f;if(h===s)d.push(0);else if(n[h]===n[s])if("data"===i)d.push(e*(Math.abs(h-s)*a)/(n[h]/o));else if(i){var l,g=void 0,v=void 0;if(u[t[h].id])g=u[t[h].id];else g=Pt(l=("id"===i?t[h].id:null===(c=t[h].data)||void 0===c?void 0:c[i])||0)?l.charCodeAt(0):l,u[t[h].id]=g;if(u[t[s].id])v=u[t[s].id];else v=Pt(l=("id"===i?t[s].id:null===(f=t[s].data)||void 0===f?void 0:f[i])||0)?l.charCodeAt(0):l,u[t[s].id]=v;d.push(e*(Math.abs(g-v)*a)/(n[h]/o))}else d.push(e*r/(n[h]/o));else{var p=(r+o)/2;d.push(e*p)}})),s.push(d)}))}return s},io=function(t){for(var e=t.length,r=t[0].length,n=[],o=0;o<e;o++){for(var i=[],a=0;a<r;a++)0!==t[o][a]?i.push(1/(t[o][a]*t[o][a])):i.push(0);n.push(i)}return n},ao=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},so=function(t,e,r){for(var n=t.length,o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(var i=0;i<n;i++)t[o][i]!==1/0&&t[e][i]===1/0&&(t[e][i]=r+t[o][i],t[i][e]=r+t[o][i])}for(o=0;o<n;o++)if(o!==e)for(i=0;i<n;i++)if(t[o][i]===1/0){var a=Math.abs(t[e][o]-t[e][i]);a=0===a?1:a,t[o][i]=a}},uo=function(t,e){for(var r=0,n=0;n<t[e].length;n++)t[e][n]!==1/0&&(r=t[e][n]>r?t[e][n]:r);return r},ho={center:[0,0],width:300,height:300},co=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=n(n({},ho),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,h,d,c,f,l;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,h=e.getAllNodes(),.9,d=s||"undefined"==typeof window?s:window.innerWidth,c=u||"undefined"==typeof window?u:window.innerHeight,f=i||[d/2,c/2],l=[],h&&h.forEach((function(t){l.push({id:t.id,data:{x:.9*(Math.random()-.5)*d+f[0],y:.9*(Math.random()-.5)*c+f[1]}})})),t&&l.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:l,edges:e.getAllEdges()}]}))}))},t}(),fo={circular:H,concentric:Ct,mds:ot,random:co,grid:Hn,radial:no,force:_t,d3force:_e,fruchterman:Un,forceAtlas2:Gn,dagre:Pn,comboCombined:Ft};var lo={stopLayout:function(){(null==on?void 0:on.stop)&&on.stop()},calculateLayout:function(t,e){return i(this,void 0,void 0,(function(){var r,n,o,i,s,u,h,d,c;return a(this,(function(a){switch(a.label){case 0:if(r=t.layout,n=r.id,o=r.options,i=r.iterations,s=t.nodes,u=t.edges,h=new v({nodes:s,edges:u}),!(d=fo[n]))throw new Error("Unknown layout id: "+n);return[4,(on=new d(o)).execute(h)];case 1:return c=a.sent(),function(t){return!!t.tick&&!!t.stop}(on)&&(on.stop(),c=on.tick(i)),[2,[c,e]]}}))}))}};N(lo)}()}();