ohlcv-indicators 3.5.41 → 3.5.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var OHLCV_INDICATORS;(()=>{"use strict";var t={788:(t,e,r)=>{r.r(e),r.d(e,{isAnyArray:()=>o});const n=Object.prototype.toString;function o(t){const e=n.call(t);return e.endsWith("Array]")&&!e.includes("Big")}},718:(t,e,r)=>{r.r(e),r.d(e,{default:()=>o});var n=r(788);function o(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 o=function(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,s=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(s<=o||s>t.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],u=o+1;u<s;u++)t[u]<a&&(a=t[u]);return a}(t),i=function(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,s=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(s<=o||s>t.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],u=o+1;u<s;u++)t[u]>a&&(a=t[u]);return a}(t);if(o===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=r.min,a=void 0===s?r.autoMinMax?o:0:s,u=r.max,l=void 0===u?r.autoMinMax?i:1:u;if(a>=l)throw new RangeError("min option must be smaller than max option");for(var c=(l-a)/(i-o),h=0;h<t.length;h++)e[h]=(t[h]-o)*c+a;return e}},673:(t,e,r)=>{var n=r(788),o=r(718);const i=" ".repeat(2),s=" ".repeat(4);function a(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:a="auto"}=e;return`${t.constructor.name} {\n${i}[\n${s}${function(t,e,r,n,o){const{rows:i,columns:a}=t,l=Math.min(i,e),c=Math.min(a,r),h=[];if("auto"===o){o=!1;t:for(let e=0;e<l;e++)for(let r=0;r<c;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<l;e++){let r=[];for(let i=0;i<c;i++)r.push(u(t.get(e,i),n,o));h.push(`${r.join(" ")}`)}return c!==a&&(h[h.length-1]+=` ... ${a-r} more columns`),l!==i&&h.push(`... ${i-e} more rows`),h.join(`\n${s}`)}(t,r,n,o,a)}\n${i}]\n${i}rows: ${t.rows}\n${i}columns: ${t.columns}\n}`}function u(t,e,r){return(t>=0&&r?` ${l(t,e-1)}`:l(t,e)).padEnd(e)}function l(t,e){let r=t.toString();if(r.length<=e)return r;let 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;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function c(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function h(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function f(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 m(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 p(t,e){if(!n.isAnyArray(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}function y(t,e){if(!n.isAnyArray(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}function g(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(v("startRow",e),v("endRow",r),v("startColumn",n),v("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,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function v(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function w(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class b{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new x(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new x(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new x(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new x(t,e)}static ones(t,e){return new x(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new x(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new x(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new x(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return b.isMatrix(t)?t:new x(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;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}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;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(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let 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);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new x(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){c(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return x.rowVector(this.getRow(t))}setRow(t,e){c(this,t),e=f(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){c(this,t),c(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){h(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return x.columnVector(this.getColumn(t))}setColumn(t,e){h(this,t),e=m(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){h(this,t),h(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=f(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=f(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=f(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=f(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=m(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=m(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=m(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=m(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){c(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){h(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){w(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){w(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(c(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){c(this,t),w(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(c(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){c(this,t),w(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(h(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){h(this,t),w(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(h(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){h(this,t),w(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){b.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=x.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new x(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}mpow(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");let e=x.eye(this.rows),r=this;for(let n=t;n>=1;n/=2)1&n&&(e=e.mmul(r)),r=r.mmul(r);return e}strassen2x2(t){t=x.checkMatrix(t);let e=new x(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),u=this.get(1,1),l=t.get(1,1),c=(r+u)*(n+l),h=(s+u)*n,f=r*(i-l),m=u*(a-n),p=(r+o)*l,y=c+m-p+(o-u)*(a+l),g=f+p,d=h+m,v=c-h+f+(s-r)*(n+i);return e.set(0,0,y),e.set(0,1,g),e.set(1,0,d),e.set(1,1,v),e}strassen3x3(t){t=x.checkMatrix(t);let e=new x(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),u=this.get(2,0),l=this.get(2,1),c=this.get(2,2),h=t.get(0,0),f=t.get(0,1),m=t.get(0,2),p=t.get(1,0),y=t.get(1,1),g=t.get(1,2),d=t.get(2,0),v=t.get(2,1),w=t.get(2,2),b=(r-i)*(-f+y),S=(-r+i+s)*(h-f+y),M=(i+s)*(-h+f),O=r*h,E=(-r+u+l)*(h-m+g),j=(-r+u)*(m-g),A=(u+l)*(-h+m),N=(-o+l+c)*(y+d-v),P=(o-c)*(y-v),_=o*d,T=(l+c)*(-d+v),k=(-o+s+a)*(g+d-w),I=(o-a)*(g-w),R=(s+a)*(-d+w),C=O+_+n*p,D=(r+n+o-i-s-l-c)*y+S+M+O+N+_+T,F=O+E+A+(r+n+o-s-a-u-l)*g+_+k+R,V=b+s*(-h+f+p-y-g-d+w)+S+O+_+k+I,q=b+S+M+O+a*v,L=_+k+I+R+i*m,z=O+E+j+l*(-h+m+p-y-g-d+v)+N+P+_,U=N+P+_+T+u*f,$=O+E+j+A+c*w;return e.set(0,0,C),e.set(0,1,D),e.set(0,2,F),e.set(1,0,V),e.set(1,1,q),e.set(1,2,L),e.set(2,0,z),e.set(2,1,U),e.set(2,2,$),e}mmulStrassen(t){t=x.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=b.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),u=Math.max(n,i);return e=s(e,a,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,a-1),l=r.subMatrix(0,i-1,0,a-1),c=e.subMatrix(0,i-1,a,e.columns-1),h=r.subMatrix(0,i-1,a,r.columns-1),f=e.subMatrix(i,e.rows-1,0,a-1),m=r.subMatrix(i,r.rows-1,0,a-1),p=e.subMatrix(i,e.rows-1,a,e.columns-1),y=r.subMatrix(i,r.rows-1,a,r.columns-1),g=t(b.add(u,p),b.add(l,y),i,a),d=t(b.add(f,p),l,i,a),v=t(u,b.sub(h,y),i,a),w=t(p,b.sub(m,l),i,a),S=t(b.add(u,c),y,i,a),x=t(b.sub(f,u),b.add(l,h),i,a),M=t(b.sub(c,p),b.add(m,y),i,a),O=b.add(g,w);O.sub(S),O.add(M);let E=b.add(v,S),j=b.add(d,w),A=b.sub(g,d);A.add(v),A.add(x);let N=b.zeros(2*O.rows,2*O.columns);return N=N.setSubMatrix(O,0,0),N=N.setSubMatrix(E,O.rows,0),N=N.setSubMatrix(j,0,O.columns),N=N.setSubMatrix(A,O.rows,O.columns),N.subMatrix(0,n-1,0,o-1)}(e,t=s(t,a,u),a,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new x(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&o(i,{min:e,max:r,output:i}),n.setRow(t,i)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new x(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&o(i,{min:e,max:r,output:i}),n.setColumn(t,i)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=x.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new x(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=x.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(x.eye(r,r)),o=x.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new x(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=S){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=S){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){g(this,t,e,r,n);let o=new x(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(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");let n=new x(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(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");let n=new x(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=x.checkMatrix(t)).isEmpty())return this;g(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){p(this,t),y(this,e);let r=new x(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){return this.constructor.copy(this,new x(this.rows,this.columns))}static copy(t,e){for(const[r,n,o]of t.entries())e.set(r,n,o);return e}sum(t){switch(t){case"row":return function(t){let e=d(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=d(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=d(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=d(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:o=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!n.isAnyArray(o))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,u=0;for(let e=0;e<o;e++)u=t.get(s,e)-r[s],n+=u,a+=u*u;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,o);case"column":if(!n.isAnyArray(o))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,u=0;for(let e=0;e<n;e++)u=t.get(e,s)-r[s],o+=u,a+=u*u;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,o);case void 0:if("number"!=typeof o)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,s+=u,a+=u*u;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,o);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!n.isAnyArray(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!n.isAnyArray(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=t.get(r,e)**2/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!n.isAnyArray(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=t.get(e,r)**2/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!n.isAnyArray(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=t.get(o,n)**2/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return a(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function S(t,e){return t-e}b.prototype.klass="Matrix","undefined"!=typeof Symbol&&(b.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return a(this)}),b.random=b.rand,b.randomInt=b.randInt,b.diagonal=b.diag,b.prototype.diagonal=b.prototype.diag,b.identity=b.eye,b.prototype.negate=b.prototype.neg,b.prototype.tensorProduct=b.prototype.kroneckerProduct;class x extends b{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(t,e){if(super(),x.isMatrix(t))this.#t(t.rows,t.columns),x.copy(t,this);else if(Number.isInteger(t)&&t>=0)this.#t(t,e);else{if(!n.isAnyArray(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}this.rows=t,this.columns=e}}}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return c(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),c(this,t,!0),e=Float64Array.from(f(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){h(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),h(this,t,!0),e=m(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;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}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));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(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));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(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));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(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));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(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));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(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));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(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));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(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));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(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));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(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));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(let e=0;e<this.rows;e++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let t=0;t<this.rows;t++)for(let 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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,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(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)**t.get(e,r));return this}}(b,x);class M extends b{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return x.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),x.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=x.copy(t,new x(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new x(t,t);else if(this.#e=new x(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new M(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())t.set(e,r,n);return t}toMatrix(){return new x(this)}get(t,e){return this.#e.get(t,e)}set(t,e,r){return this.#e.set(t,e,r),this.#e.set(e,t,r),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const r=e.slice();return r.splice(t,1),this.#e.addRow(t,r),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[r,n]of t.entries())n||e.push(r);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let r=0,n=0,o=0;o<e.length;o++)e[o]=this.get(n,r),++r>=t&&(r=++n);return e}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const n=new M(r);for(let o=0,i=0,s=0;s<e;s++)n.set(o,i,t[s]),++o>=r&&(o=++i);return n}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const r=this.get(t,e);yield[t,e,r],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const r=this.get(t,e);yield r,++e>=this.diagonalSize&&(e=++t)}}}M.prototype.klassType="SymmetricMatrix";class O extends M{static isDistanceMatrix(t){return M.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new M(this)}clone(){const t=new O(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let r=1,n=0,o=0;o<e.length;o++)e[o]=this.get(n,r),++r>=t&&(r=1+ ++n);return e}static fromCompact(t){const e=t.length;if(0===e)return new this(0);const 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, ${JSON.stringify(t)}`);const n=new this(r);for(let o=1,i=0,s=0;s<e;s++)n.set(o,i,t[s]),++o>=r&&(o=1+ ++i);return n}}O.prototype.klassSubType="DistanceMatrix";class E extends b{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class j extends E{constructor(t,e,r){p(t,e),y(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class A extends b{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!=0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class N extends b{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}class P{constructor(t){let e,r,n,o,i,s,a,u,l,c=(t=N.checkMatrix(t)).clone(),h=c.rows,f=c.columns,m=new Float64Array(h),p=1;for(e=0;e<h;e++)m[e]=e;for(u=new Float64Array(h),r=0;r<f;r++){for(e=0;e<h;e++)u[e]=c.get(e,r);for(e=0;e<h;e++){for(l=Math.min(e,r),i=0,n=0;n<l;n++)i+=c.get(e,n)*u[n];u[e]-=i,c.set(e,r,u[e])}for(o=r,e=r+1;e<h;e++)Math.abs(u[e])>Math.abs(u[o])&&(o=e);if(o!==r){for(n=0;n<f;n++)s=c.get(o,n),c.set(o,n,c.get(r,n)),c.set(r,n,s);a=m[o],m[o]=m[r],m[r]=a,p=-p}if(r<h&&0!==c.get(r,r))for(e=r+1;e<h;e++)c.set(e,r,c.get(e,r)/c.get(r,r))}this.LU=c,this.pivotVector=m,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(0===t.get(r,r))return!0;return!1}solve(t){t=x.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let r,n,o,i=t.columns,s=t.subMatrixRow(this.pivotVector,0,i-1),a=e.columns;for(o=0;o<a;o++)for(r=o+1;r<a;r++)for(n=0;n<i;n++)s.set(r,n,s.get(r,n)-s.get(o,n)*e.get(r,o));for(o=a-1;o>=0;o--){for(n=0;n<i;n++)s.set(o,n,s.get(o,n)/e.get(o,o));for(r=0;r<o;r++)for(n=0;n<i;n++)s.set(r,n,s.get(r,n)-s.get(o,n)*e.get(r,o))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new x(e,r);for(let o=0;o<e;o++)for(let e=0;e<r;e++)o>e?n.set(o,e,t.get(o,e)):o===e?n.set(o,e,1):n.set(o,e,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new x(e,r);for(let o=0;o<e;o++)for(let e=0;e<r;e++)o<=e?n.set(o,e,t.get(o,e)):n.set(o,e,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function _(t,e){let 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}class T{constructor(t){let e,r,n,o,i=(t=N.checkMatrix(t)).clone(),s=t.rows,a=t.columns,u=new Float64Array(a);for(n=0;n<a;n++){let t=0;for(e=n;e<s;e++)t=_(t,i.get(e,n));if(0!==t){for(i.get(n,n)<0&&(t=-t),e=n;e<s;e++)i.set(e,n,i.get(e,n)/t);for(i.set(n,n,i.get(n,n)+1),r=n+1;r<a;r++){for(o=0,e=n;e<s;e++)o+=i.get(e,n)*i.get(e,r);for(o=-o/i.get(n,n),e=n;e<s;e++)i.set(e,r,i.get(e,r)+o*i.get(e,n))}}u[n]=-t}this.QR=i,this.Rdiag=u}solve(t){t=x.checkMatrix(t);let 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");let n,o,i,s,a=t.columns,u=t.clone(),l=e.columns;for(i=0;i<l;i++)for(o=0;o<a;o++){for(s=0,n=i;n<r;n++)s+=e.get(n,i)*u.get(n,o);for(s=-s/e.get(i,i),n=i;n<r;n++)u.set(n,o,u.get(n,o)+s*e.get(n,i))}for(i=l-1;i>=0;i--){for(o=0;o<a;o++)u.set(i,o,u.get(i,o)/this.Rdiag[i]);for(n=0;n<i;n++)for(o=0;o<a;o++)u.set(n,o,u.get(n,o)-u.get(i,o)*e.get(n,i))}return u.subMatrix(0,l-1,0,a-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,r=this.QR,n=r.columns,o=new x(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}get orthogonalMatrix(){let t,e,r,n,o=this.QR,i=o.rows,s=o.columns,a=new x(i,s);for(r=s-1;r>=0;r--){for(t=0;t<i;t++)a.set(t,r,0);for(a.set(r,r,1),e=r;e<s;e++)if(0!==o.get(r,r)){for(n=0,t=r;t<i;t++)n+=o.get(t,r)*a.get(t,e);for(n=-n/o.get(r,r),t=r;t<i;t++)a.set(t,e,a.get(t,e)+n*o.get(t,r))}}return a}}class k{constructor(t,e={}){if((t=N.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,u=Boolean(o),l=Boolean(i),c=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,c=!0;let e=u;u=l,l=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let h=Math.min(r,n),f=Math.min(r+1,n),m=new Float64Array(f),p=new x(r,h),y=new x(n,n),g=new Float64Array(n),d=new Float64Array(r),v=new Float64Array(f);for(let t=0;t<f;t++)v[t]=t;let w=Math.min(r-1,n),b=Math.max(0,Math.min(n-2,r)),S=Math.max(w,b);for(let t=0;t<S;t++){if(t<w){m[t]=0;for(let e=t;e<r;e++)m[t]=_(m[t],a.get(e,t));if(0!==m[t]){a.get(t,t)<0&&(m[t]=-m[t]);for(let e=t;e<r;e++)a.set(e,t,a.get(e,t)/m[t]);a.set(t,t,a.get(t,t)+1)}m[t]=-m[t]}for(let e=t+1;e<n;e++){if(t<w&&0!==m[t]){let n=0;for(let o=t;o<r;o++)n+=a.get(o,t)*a.get(o,e);n=-n/a.get(t,t);for(let o=t;o<r;o++)a.set(o,e,a.get(o,e)+n*a.get(o,t))}g[e]=a.get(t,e)}if(u&&t<w)for(let e=t;e<r;e++)p.set(e,t,a.get(e,t));if(t<b){g[t]=0;for(let e=t+1;e<n;e++)g[t]=_(g[t],g[e]);if(0!==g[t]){g[t+1]<0&&(g[t]=0-g[t]);for(let e=t+1;e<n;e++)g[e]/=g[t];g[t+1]+=1}if(g[t]=-g[t],t+1<r&&0!==g[t]){for(let e=t+1;e<r;e++)d[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)d[e]+=g[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-g[e]/g[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*d[o])}}if(l)for(let e=t+1;e<n;e++)y.set(e,t,g[e])}}let M=Math.min(n,r+1);if(w<n&&(m[w]=a.get(w,w)),r<M&&(m[M-1]=0),b+1<M&&(g[b]=a.get(b,M-1)),g[M-1]=0,u){for(let t=w;t<h;t++){for(let e=0;e<r;e++)p.set(e,t,0);p.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==m[t]){for(let e=t+1;e<h;e++){let n=0;for(let o=t;o<r;o++)n+=p.get(o,t)*p.get(o,e);n=-n/p.get(t,t);for(let o=t;o<r;o++)p.set(o,e,p.get(o,e)+n*p.get(o,t))}for(let e=t;e<r;e++)p.set(e,t,-p.get(e,t));p.set(t,t,1+p.get(t,t));for(let e=0;e<t-1;e++)p.set(e,t,0)}else{for(let e=0;e<r;e++)p.set(e,t,0);p.set(t,t,1)}}if(l)for(let t=n-1;t>=0;t--){if(t<b&&0!==g[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=y.get(o,t)*y.get(o,e);r=-r/y.get(t+1,t);for(let o=t+1;o<n;o++)y.set(o,e,y.get(o,e)+r*y.get(o,t))}for(let e=0;e<n;e++)y.set(e,t,0);y.set(t,t,1)}let O=M-1,E=Number.EPSILON;for(;M>0;){let t,e;for(t=M-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+E*Math.abs(m[t]+Math.abs(m[t+1]));if(Math.abs(g[t])<=e||Number.isNaN(g[t])){g[t]=0;break}}if(t===M-2)e=4;else{let r;for(r=M-1;r>=t&&r!==t;r--){let e=(r!==M?Math.abs(g[r]):0)+(r!==t+1?Math.abs(g[r-1]):0);if(Math.abs(m[r])<=E*e){m[r]=0;break}}r===t?e=3:r===M-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=g[M-2];g[M-2]=0;for(let r=M-2;r>=t;r--){let o=_(m[r],e),i=m[r]/o,s=e/o;if(m[r]=o,r!==t&&(e=-s*g[r-1],g[r-1]=i*g[r-1]),l)for(let t=0;t<n;t++)o=i*y.get(t,r)+s*y.get(t,M-1),y.set(t,M-1,-s*y.get(t,r)+i*y.get(t,M-1)),y.set(t,r,o)}break}case 2:{let e=g[t-1];g[t-1]=0;for(let n=t;n<M;n++){let o=_(m[n],e),i=m[n]/o,s=e/o;if(m[n]=o,e=-s*g[n],g[n]=i*g[n],u)for(let e=0;e<r;e++)o=i*p.get(e,n)+s*p.get(e,t-1),p.set(e,t-1,-s*p.get(e,n)+i*p.get(e,t-1)),p.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(m[M-1]),Math.abs(m[M-2]),Math.abs(g[M-2]),Math.abs(m[t]),Math.abs(g[t])),o=m[M-1]/e,i=m[M-2]/e,s=g[M-2]/e,a=m[t]/e,c=g[t]/e,h=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let d=0;0===h&&0===f||(d=h<0?0-Math.sqrt(h*h+f):Math.sqrt(h*h+f),d=f/(h+d));let v=(a+o)*(a-o)+d,w=a*c;for(let e=t;e<M-1;e++){let o=_(v,w);0===o&&(o=Number.MIN_VALUE);let i=v/o,s=w/o;if(e!==t&&(g[e-1]=o),v=i*m[e]+s*g[e],g[e]=i*g[e]-s*m[e],w=s*m[e+1],m[e+1]=i*m[e+1],l)for(let t=0;t<n;t++)o=i*y.get(t,e)+s*y.get(t,e+1),y.set(t,e+1,-s*y.get(t,e)+i*y.get(t,e+1)),y.set(t,e,o);if(o=_(v,w),0===o&&(o=Number.MIN_VALUE),i=v/o,s=w/o,m[e]=o,v=i*g[e]+s*m[e+1],m[e+1]=-s*g[e]+i*m[e+1],w=s*g[e+1],g[e+1]=i*g[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o)}g[M-2]=v;break}case 4:if(m[t]<=0&&(m[t]=m[t]<0?-m[t]:0,l))for(let e=0;e<=O;e++)y.set(e,t,-y.get(e,t));for(;t<O&&!(m[t]>=m[t+1]);){let e=m[t];if(m[t]=m[t+1],m[t+1]=e,l&&t<n-1)for(let r=0;r<n;r++)e=y.get(r,t+1),y.set(r,t+1,y.get(r,t)),y.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=p.get(n,t+1),p.set(n,t+1,p.get(n,t)),p.set(n,t,e);t++}M--}}if(c){let t=y;y=p,p=t}this.m=r,this.n=n,this.s=m,this.U=p,this.V=y}solve(t){let e=t,r=this.threshold,n=this.s.length,o=x.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),u=s.rows,l=i.rows,c=x.zeros(u,l);for(let t=0;t<u;t++)for(let e=0;e<l;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);c.set(t,e,r)}return c.mmul(e)}solveForDiagonal(t){return this.solve(x.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new x(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,u=new x(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return x.diag(this.s)}}function I(t,e,r=!1){return t=N.checkMatrix(t),e=N.checkMatrix(e),r?new k(t).solve(e):t.isSquare()?new P(t).solve(e):new T(t).solve(e)}function R(t,e){let r=[];for(let n=0;n<t;n++)n!==e&&r.push(n);return r}function C(t,e,r,n=1e-9,o=1e-9){if(t>o)return new Array(e.rows+1).fill(0);{let t=e.addRow(r,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<n&&t.set(e,0,0);return t.to1DArray()}}class D{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(!(t=N.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n,o,i=t.columns,s=new x(i,i),a=new Float64Array(i),u=new Float64Array(i),l=t,c=!1;if(c=!!r||t.isSymmetric(),c){for(n=0;n<i;n++)for(o=0;o<i;o++)s.set(n,o,l.get(n,o));!function(t,e,r,n){let o,i,s,a,u,l,c,h;for(u=0;u<t;u++)r[u]=n.get(t-1,u);for(a=t-1;a>0;a--){for(h=0,s=0,l=0;l<a;l++)h+=Math.abs(r[l]);if(0===h)for(e[a]=r[a-1],u=0;u<a;u++)r[u]=n.get(a-1,u),n.set(a,u,0),n.set(u,a,0);else{for(l=0;l<a;l++)r[l]/=h,s+=r[l]*r[l];for(o=r[a-1],i=Math.sqrt(s),o>0&&(i=-i),e[a]=h*i,s-=o*i,r[a-1]=o-i,u=0;u<a;u++)e[u]=0;for(u=0;u<a;u++){for(o=r[u],n.set(u,a,o),i=e[u]+n.get(u,u)*o,l=u+1;l<=a-1;l++)i+=n.get(l,u)*r[l],e[l]+=n.get(l,u)*o;e[u]=i}for(o=0,u=0;u<a;u++)e[u]/=s,o+=e[u]*r[u];for(c=o/(s+s),u=0;u<a;u++)e[u]-=c*r[u];for(u=0;u<a;u++){for(o=r[u],i=e[u],l=u;l<=a-1;l++)n.set(l,u,n.get(l,u)-(o*e[l]+i*r[l]));r[u]=n.get(a-1,u),n.set(a,u,0)}}r[a]=s}for(a=0;a<t-1;a++){if(n.set(t-1,a,n.get(a,a)),n.set(a,a,1),s=r[a+1],0!==s){for(l=0;l<=a;l++)r[l]=n.get(l,a+1)/s;for(u=0;u<=a;u++){for(i=0,l=0;l<=a;l++)i+=n.get(l,a+1)*n.get(l,u);for(l=0;l<=a;l++)n.set(l,u,n.get(l,u)-i*r[l])}}for(l=0;l<=a;l++)n.set(l,a+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}(i,u,a,s),function(t,e,r,n){let o,i,s,a,u,l,c,h,f,m,p,y,g,d,v,w;for(s=1;s<t;s++)e[s-1]=e[s];e[t-1]=0;let b=0,S=0,x=Number.EPSILON;for(l=0;l<t;l++){for(S=Math.max(S,Math.abs(r[l])+Math.abs(e[l])),c=l;c<t&&!(Math.abs(e[c])<=x*S);)c++;if(c>l)do{for(o=r[l],h=(r[l+1]-o)/(2*e[l]),f=_(h,1),h<0&&(f=-f),r[l]=e[l]/(h+f),r[l+1]=e[l]*(h+f),m=r[l+1],i=o-r[l],s=l+2;s<t;s++)r[s]-=i;for(b+=i,h=r[c],p=1,y=p,g=p,d=e[l+1],v=0,w=0,s=c-1;s>=l;s--)for(g=y,y=p,w=v,o=p*e[s],i=p*h,f=_(h,e[s]),e[s+1]=v*f,v=e[s]/f,p=h/f,h=p*r[s]-v*o,r[s+1]=i+v*(p*o+v*r[s]),u=0;u<t;u++)i=n.get(u,s+1),n.set(u,s+1,v*n.get(u,s)+p*i),n.set(u,s,p*n.get(u,s)-v*i);h=-v*w*g*d*e[l]/m,e[l]=v*h,r[l]=p*h}while(Math.abs(e[l])>x*S);r[l]=r[l]+b,e[l]=0}for(s=0;s<t-1;s++){for(u=s,h=r[s],a=s+1;a<t;a++)r[a]<h&&(u=a,h=r[a]);if(u!==s)for(r[u]=r[s],r[s]=h,a=0;a<t;a++)h=n.get(a,s),n.set(a,s,n.get(a,u)),n.set(a,u,h)}}(i,u,a,s)}else{let t=new x(i,i),e=new Float64Array(i);for(o=0;o<i;o++)for(n=0;n<i;n++)t.set(n,o,l.get(n,o));!function(t,e,r,n){let o,i,s,a,u,l,c,h=t-1;for(l=1;l<=h-1;l++){for(c=0,a=l;a<=h;a++)c+=Math.abs(e.get(a,l-1));if(0!==c){for(s=0,a=h;a>=l;a--)r[a]=e.get(a,l-1)/c,s+=r[a]*r[a];for(i=Math.sqrt(s),r[l]>0&&(i=-i),s-=r[l]*i,r[l]=r[l]-i,u=l;u<t;u++){for(o=0,a=h;a>=l;a--)o+=r[a]*e.get(a,u);for(o/=s,a=l;a<=h;a++)e.set(a,u,e.get(a,u)-o*r[a])}for(a=0;a<=h;a++){for(o=0,u=h;u>=l;u--)o+=r[u]*e.get(a,u);for(o/=s,u=l;u<=h;u++)e.set(a,u,e.get(a,u)-o*r[u])}r[l]=c*r[l],e.set(l,l-1,c*i)}}for(a=0;a<t;a++)for(u=0;u<t;u++)n.set(a,u,a===u?1:0);for(l=h-1;l>=1;l--)if(0!==e.get(l,l-1)){for(a=l+1;a<=h;a++)r[a]=e.get(a,l-1);for(u=l;u<=h;u++){for(i=0,a=l;a<=h;a++)i+=r[a]*n.get(a,u);for(i=i/r[l]/e.get(l,l-1),a=l;a<=h;a++)n.set(a,u,n.get(a,u)+i*r[a])}}}(i,t,e,s),function(t,e,r,n,o){let i,s,a,u,l,c,h,f,m,p,y,g,d,v,w,b=t-1,S=t-1,x=Number.EPSILON,M=0,O=0,E=0,j=0,A=0,N=0,P=0,_=0;for(i=0;i<t;i++)for((i<0||i>S)&&(r[i]=o.get(i,i),e[i]=0),s=Math.max(i-1,0);s<t;s++)O+=Math.abs(o.get(i,s));for(;b>=0;){for(u=b;u>0&&(N=Math.abs(o.get(u-1,u-1))+Math.abs(o.get(u,u)),0===N&&(N=O),!(Math.abs(o.get(u,u-1))<x*N));)u--;if(u===b)o.set(b,b,o.get(b,b)+M),r[b]=o.get(b,b),e[b]=0,b--,_=0;else if(u===b-1){if(h=o.get(b,b-1)*o.get(b-1,b),E=(o.get(b-1,b-1)-o.get(b,b))/2,j=E*E+h,P=Math.sqrt(Math.abs(j)),o.set(b,b,o.get(b,b)+M),o.set(b-1,b-1,o.get(b-1,b-1)+M),f=o.get(b,b),j>=0){for(P=E>=0?E+P:E-P,r[b-1]=f+P,r[b]=r[b-1],0!==P&&(r[b]=f-h/P),e[b-1]=0,e[b]=0,f=o.get(b,b-1),N=Math.abs(f)+Math.abs(P),E=f/N,j=P/N,A=Math.sqrt(E*E+j*j),E/=A,j/=A,s=b-1;s<t;s++)P=o.get(b-1,s),o.set(b-1,s,j*P+E*o.get(b,s)),o.set(b,s,j*o.get(b,s)-E*P);for(i=0;i<=b;i++)P=o.get(i,b-1),o.set(i,b-1,j*P+E*o.get(i,b)),o.set(i,b,j*o.get(i,b)-E*P);for(i=0;i<=S;i++)P=n.get(i,b-1),n.set(i,b-1,j*P+E*n.get(i,b)),n.set(i,b,j*n.get(i,b)-E*P)}else r[b-1]=f+E,r[b]=f+E,e[b-1]=P,e[b]=-P;b-=2,_=0}else{if(f=o.get(b,b),m=0,h=0,u<b&&(m=o.get(b-1,b-1),h=o.get(b,b-1)*o.get(b-1,b)),10===_){for(M+=f,i=0;i<=b;i++)o.set(i,i,o.get(i,i)-f);N=Math.abs(o.get(b,b-1))+Math.abs(o.get(b-1,b-2)),f=m=.75*N,h=-.4375*N*N}if(30===_&&(N=(m-f)/2,N=N*N+h,N>0)){for(N=Math.sqrt(N),m<f&&(N=-N),N=f-h/((m-f)/2+N),i=0;i<=b;i++)o.set(i,i,o.get(i,i)-N);M+=N,f=m=h=.964}for(_+=1,l=b-2;l>=u&&(P=o.get(l,l),A=f-P,N=m-P,E=(A*N-h)/o.get(l+1,l)+o.get(l,l+1),j=o.get(l+1,l+1)-P-A-N,A=o.get(l+2,l+1),N=Math.abs(E)+Math.abs(j)+Math.abs(A),E/=N,j/=N,A/=N,l!==u)&&!(Math.abs(o.get(l,l-1))*(Math.abs(j)+Math.abs(A))<x*(Math.abs(E)*(Math.abs(o.get(l-1,l-1))+Math.abs(P)+Math.abs(o.get(l+1,l+1)))));)l--;for(i=l+2;i<=b;i++)o.set(i,i-2,0),i>l+2&&o.set(i,i-3,0);for(a=l;a<=b-1&&(v=a!==b-1,a!==l&&(E=o.get(a,a-1),j=o.get(a+1,a-1),A=v?o.get(a+2,a-1):0,f=Math.abs(E)+Math.abs(j)+Math.abs(A),0!==f&&(E/=f,j/=f,A/=f)),0!==f);a++)if(N=Math.sqrt(E*E+j*j+A*A),E<0&&(N=-N),0!==N){for(a!==l?o.set(a,a-1,-N*f):u!==l&&o.set(a,a-1,-o.get(a,a-1)),E+=N,f=E/N,m=j/N,P=A/N,j/=E,A/=E,s=a;s<t;s++)E=o.get(a,s)+j*o.get(a+1,s),v&&(E+=A*o.get(a+2,s),o.set(a+2,s,o.get(a+2,s)-E*P)),o.set(a,s,o.get(a,s)-E*f),o.set(a+1,s,o.get(a+1,s)-E*m);for(i=0;i<=Math.min(b,a+3);i++)E=f*o.get(i,a)+m*o.get(i,a+1),v&&(E+=P*o.get(i,a+2),o.set(i,a+2,o.get(i,a+2)-E*A)),o.set(i,a,o.get(i,a)-E),o.set(i,a+1,o.get(i,a+1)-E*j);for(i=0;i<=S;i++)E=f*n.get(i,a)+m*n.get(i,a+1),v&&(E+=P*n.get(i,a+2),n.set(i,a+2,n.get(i,a+2)-E*A)),n.set(i,a,n.get(i,a)-E),n.set(i,a+1,n.get(i,a+1)-E*j)}}}if(0!==O){for(b=t-1;b>=0;b--)if(E=r[b],j=e[b],0===j)for(u=b,o.set(b,b,1),i=b-1;i>=0;i--){for(h=o.get(i,i)-E,A=0,s=u;s<=b;s++)A+=o.get(i,s)*o.get(s,b);if(e[i]<0)P=h,N=A;else if(u=i,0===e[i]?o.set(i,b,0!==h?-A/h:-A/(x*O)):(f=o.get(i,i+1),m=o.get(i+1,i),j=(r[i]-E)*(r[i]-E)+e[i]*e[i],c=(f*N-P*A)/j,o.set(i,b,c),o.set(i+1,b,Math.abs(f)>Math.abs(P)?(-A-h*c)/f:(-N-m*c)/P)),c=Math.abs(o.get(i,b)),x*c*c>1)for(s=i;s<=b;s++)o.set(s,b,o.get(s,b)/c)}else if(j<0)for(u=b-1,Math.abs(o.get(b,b-1))>Math.abs(o.get(b-1,b))?(o.set(b-1,b-1,j/o.get(b,b-1)),o.set(b-1,b,-(o.get(b,b)-E)/o.get(b,b-1))):(w=F(0,-o.get(b-1,b),o.get(b-1,b-1)-E,j),o.set(b-1,b-1,w[0]),o.set(b-1,b,w[1])),o.set(b,b-1,0),o.set(b,b,1),i=b-2;i>=0;i--){for(p=0,y=0,s=u;s<=b;s++)p+=o.get(i,s)*o.get(s,b-1),y+=o.get(i,s)*o.get(s,b);if(h=o.get(i,i)-E,e[i]<0)P=h,A=p,N=y;else if(u=i,0===e[i]?(w=F(-p,-y,h,j),o.set(i,b-1,w[0]),o.set(i,b,w[1])):(f=o.get(i,i+1),m=o.get(i+1,i),g=(r[i]-E)*(r[i]-E)+e[i]*e[i]-j*j,d=2*(r[i]-E)*j,0===g&&0===d&&(g=x*O*(Math.abs(h)+Math.abs(j)+Math.abs(f)+Math.abs(m)+Math.abs(P))),w=F(f*A-P*p+j*y,f*N-P*y-j*p,g,d),o.set(i,b-1,w[0]),o.set(i,b,w[1]),Math.abs(f)>Math.abs(P)+Math.abs(j)?(o.set(i+1,b-1,(-p-h*o.get(i,b-1)+j*o.get(i,b))/f),o.set(i+1,b,(-y-h*o.get(i,b)-j*o.get(i,b-1))/f)):(w=F(-A-m*o.get(i,b-1),-N-m*o.get(i,b),P,j),o.set(i+1,b-1,w[0]),o.set(i+1,b,w[1]))),c=Math.max(Math.abs(o.get(i,b-1)),Math.abs(o.get(i,b))),x*c*c>1)for(s=i;s<=b;s++)o.set(s,b-1,o.get(s,b-1)/c),o.set(s,b,o.get(s,b)/c)}for(i=0;i<t;i++)if(i<0||i>S)for(s=i;s<t;s++)n.set(i,s,o.get(i,s));for(s=t-1;s>=0;s--)for(i=0;i<=S;i++){for(P=0,a=0;a<=Math.min(s,S);a++)P+=n.get(i,a)*o.get(a,s);n.set(i,s,P)}}}(i,u,a,s,t)}this.n=i,this.e=u,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,r=this.n,n=this.e,o=this.d,i=new x(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}}function F(t,e,r,n){let o,i;return Math.abs(r)>Math.abs(n)?(o=n/r,i=r+o*n,[(t+o*e)/i,(e-o*t)/i]):(o=r/n,i=n+o*r,[(o*t+e)/i,(o*e-t)/i])}class V{constructor(t){if(!(t=N.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,r,n,o=t,i=o.rows,s=new x(i,i),a=!0;for(r=0;r<i;r++){let t=0;for(n=0;n<r;n++){let i=0;for(e=0;e<n;e++)i+=s.get(n,e)*s.get(r,e);i=(o.get(r,n)-i)/s.get(n,n),s.set(r,n,i),t+=i*i}for(t=o.get(r,r)-t,a&&=t>0,s.set(r,r,Math.sqrt(Math.max(t,0))),n=r+1;n<i;n++)s.set(r,n,0)}this.L=s,this.positiveDefinite=a}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=N.checkMatrix(t);let 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");let n,o,i,s=t.columns,a=t.clone();for(i=0;i<r;i++)for(o=0;o<s;o++){for(n=0;n<i;n++)a.set(i,o,a.get(i,o)-a.get(n,o)*e.get(i,n));a.set(i,o,a.get(i,o)/e.get(i,i))}for(i=r-1;i>=0;i--)for(o=0;o<s;o++){for(n=i+1;n<r;n++)a.set(i,o,a.get(i,o)-a.get(n,o)*e.get(n,i));a.set(i,o,a.get(i,o)/e.get(i,i))}return a}get lowerTriangularMatrix(){return this.L}}class q{constructor(t,e={}){t=N.checkMatrix(t);let{Y:r}=e;const{scaleScores:o=!1,maxIterations:i=1e3,terminationCriteria:s=1e-10}=e;let a;if(r){if(r=n.isAnyArray(r)&&"number"==typeof r[0]?x.columnVector(r):N.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=r.getColumnVector(0)}else a=t.getColumnVector(0);let u,l,c,h,f=1;for(let e=0;e<i&&f>s;e++)c=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),c=c.div(c.norm()),u=t.mmul(c).div(c.transpose().mmul(c).get(0,0)),e>0&&(f=u.clone().sub(h).pow(2).sum()),h=u.clone(),r?(l=r.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),l=l.div(l.norm()),a=r.mmul(l).div(l.transpose().mmul(l).get(0,0))):a=u;if(r){let e=t.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0));e=e.div(e.norm());let n=t.clone().sub(u.clone().mmul(e.transpose())),o=a.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),i=r.clone().sub(u.clone().mulS(o.get(0,0)).mmul(l.transpose()));this.t=u,this.p=e.transpose(),this.w=c.transpose(),this.q=l,this.u=a,this.s=u.transpose().mmul(u),this.xResidual=n,this.yResidual=i,this.betas=o}else this.w=c.transpose(),this.s=u.transpose().mmul(u).sqrt(),this.t=o?u.clone().div(this.s.get(0,0)):u,this.xResidual=t.sub(u.mmul(c.transpose()))}}e.y3=b,e.jy=V,e.oN=V,e.Hc=O,e.cg=D,e.hj=D,e.LU=P,e.Tb=P,e.uq=x,e.Zm=class extends E{constructor(t,e){y(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},e.Dq=class extends E{constructor(t,e){h(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}},e.__=class extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},e.q0=class extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},e.lh=class extends E{constructor(t,e){p(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},e.pI=class extends E{constructor(t,e){c(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}},e.zC=j,e.zg=class extends E{constructor(t,e,r,n,o){g(t,e,r,n,o),super(t,r-e+1,o-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},e.g6=class extends E{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}},e.OL=q,e.ks=q,e.QR=T,e.jp=T,e.mk=k,e.W2=k,e.l=M,e.KY=A,e.dv=N,e.BR=function(t,e=t,r={}){t=new x(t);let o=!1;if("object"!=typeof e||x.isMatrix(e)||n.isAnyArray(e)?e=new x(e):(r=e,e=t,o=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:s=!0}=r;i&&(t.center("column"),o||e.center("column")),s&&(t.scale("column"),o||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),u=o?a:e.standardDeviation("column",{unbiased:!0}),l=t.transpose().mmul(e);for(let e=0;e<l.rows;e++)for(let r=0;r<l.columns;r++)l.set(e,r,l.get(e,r)*(1/(a[e]*u[r]))*(1/(t.rows-1)));return l},e.Wu=function(t,e=t,r={}){t=new x(t);let o=!1;if("object"!=typeof e||x.isMatrix(e)||n.isAnyArray(e)?e=new x(e):(r=e,e=t,o=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=r;i&&(t=t.center("column"),o||(e=e.center("column")));const s=t.transpose().mmul(e);for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)*(1/(t.rows-1)));return s},e.a4=function t(e){if((e=x.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let r,n,o,i;if(2===e.columns)return r=e.get(0,0),n=e.get(0,1),o=e.get(1,0),i=e.get(1,1),r*i-n*o;if(3===e.columns){let i,s,a;return i=new j(e,[1,2],[1,2]),s=new j(e,[1,2],[0,2]),a=new j(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(s)+o*t(a)}return new P(e).determinant}throw Error("determinant can only be calculated for a square matrix")},e.DI=function(t,e=!1){return t=N.checkMatrix(t),e?new k(t).inverse():I(t,x.eye(t.rows))},e.Jo=function(t,e={}){const{thresholdValue:r=1e-9,thresholdError:n=1e-9}=e;let o=(t=x.checkMatrix(t)).rows,i=new x(o,o);for(let e=0;e<o;e++){let s=x.columnVector(t.getRow(e)),a=t.subMatrixRow(R(o,e)).transpose(),u=new k(a).solve(s),l=x.sub(s,a.mmul(u)).abs().max();i.setRow(e,C(l,u,e,r,n))}return i},e.Zi=function(t,e=Number.EPSILON){if((t=x.checkMatrix(t)).isEmpty())return t.transpose();let r=new k(t,{autoTranspose:!0}),n=r.leftSingularVectors,o=r.rightSingularVectors,i=r.diagonal;for(let t=0;t<i.length;t++)Math.abs(i[t])>e?i[t]=1/i[t]:i[t]=0;return o.mmul(x.diag(i).mmul(n.transpose()))},e.kH=I,e.LV=function(t,e){if(n.isAnyArray(t))return t[0]&&n.isAnyArray(t[0])?new N(t):new A(t,e);throw new Error("the argument is not an array")}}},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=(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=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{function t(e){return t="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(e)}function e(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=o(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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 s,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw s}}}}function o(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.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)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}r.r(n),r.d(n,{default:()=>jr});var s=function(t,r){if(!Array.isArray(t))throw new Error('Property "inputParams" must be an "Array" or "Set".');var n,o=e(t);try{for(o.s();!(n=o.n()).done;){var i,s=e(n.value.params);try{for(s.s();!(i=s.n()).done;){var a=i.value;if("number"==typeof a&&a>r)throw console.log(a,r),new Error("At least one of the params of the indicator is greater than the input OHLCV length. Make sure to have enough datapoints in the input OHLCV.")}}catch(t){s.e(t)}finally{s.f()}}}catch(t){o.e(t)}finally{o.f()}},a=function(t){if(!0===t.isComputed)throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" , "getDataAsCols" or "getData" methods are called.')},u=function(t,e,r){if(!Array.isArray(t))throw new Error('Param "'.concat(e,'" must be an array in "').concat(r,'".'));return!0},l=function(e,r,n){if(!Boolean(e)||"object"==!t(e))throw new Error('Param "'.concat(r,'" must be an object in "').concat(n,'".'));return!0},c=function(t,e,r,n){if(u(t,"arrayOptions","".concat(n,".").concat(r,".validateArrayOptions")),!t.includes(e.toString()))throw new Error('Param "'.concat(r,'" must be any of the following values [').concat(t.join(", "),'] in "').concat(n,'".'));return!0},h=function(t,e,r){if("boolean"!=typeof t)throw new Error('Param "'.concat(e,'" must be an boolean in "').concat(r,'".'));return!0},f=function(t,e,r,n){l(e,"options","".concat(n,".").concat(r,".validateNumber"));var o=e.allowDecimals,i=void 0!==o&&o,s=e.min,a=e.max,u=i?"number":"integer";if("number"!=typeof t||!1===i&&!Number.isInteger(t))throw new Error('Param "'.concat(r,'" must be an integer in "').concat(n,'".'));if("number"!=typeof s||"number"!=typeof a||s>=a)throw new Error('Param "min" must be a valid '.concat(u,' lower than "max" "').concat(n,".").concat(r,'.validateNumber".'));if(t<s)throw new Error('Param "'.concat(r,'" must be an ').concat(u," greater than or equal to ").concat(s,' in "').concat(n,'".'));if(t>a)throw new Error('Param "'.concat(r,'" must be an ').concat(u," lower than or equal to ").concat(a,' in "').concat(n,'".'));return!0},m=1e6,p="[big.js] ",y=p+"Invalid ",g=y+"decimal places",d=y+"rounding mode",v=p+"Division by zero",w={},b=void 0,S=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function x(t,e,r,n){var o=t.c;if(r===b&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(d);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==b))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==b||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function M(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}function O(t){return O="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},O(t)}function E(t){var e="function"==typeof Map?new Map:void 0;return E=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(j())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&A(o,r.prototype),o}(t,arguments,N(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),A(r,t)},E(t)}function j(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(j=function(){return!!t})()}function A(t,e){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},A(t,e)}function N(t){return N=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},N(t)}w.abs=function(){var t=new this.constructor(this);return t.s=1,t},w.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,s=t.s,a=r.e,u=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-s:0;if(i!=s)return i;if(e=i<0,a!=u)return a>u^e?1:-1;for(s=(a=n.length)<(u=o.length)?a:u,i=-1;++i<s;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return a==u?0:a>u^e?1:-1},w.div=function(t){var e=this,r=e.constructor,n=e.c,o=(t=new r(t)).c,i=e.s==t.s?1:-1,s=r.DP;if(s!==~~s||s<0||s>m)throw Error(g);if(!o[0])throw Error(v);if(!n[0])return t.s=i,t.c=[t.e=0],t;var a,u,l,c,h,f=o.slice(),p=a=o.length,y=n.length,d=n.slice(0,a),w=d.length,S=t,M=S.c=[],O=0,E=s+(S.e=e.e-t.e)+1;for(S.s=i,i=E<0?0:E,f.unshift(0);w++<a;)d.push(0);do{for(l=0;l<10;l++){if(a!=(w=d.length))c=a>w?1:-1;else for(h=-1,c=0;++h<a;)if(o[h]!=d[h]){c=o[h]>d[h]?1:-1;break}if(!(c<0))break;for(u=w==a?o:f;w;){if(d[--w]<u[w]){for(h=w;h&&!d[--h];)d[h]=9;--d[h],d[w]+=10}d[w]-=u[w]}for(;!d[0];)d.shift()}M[O++]=c?l:++l,d[0]&&c?d[w]=n[p]||0:d=[n[p]]}while((p++<y||d[0]!==b)&&i--);return M[0]||1==O||(M.shift(),S.e--,E--),O>E&&x(S,E,r.RM,d[0]!==b),S},w.eq=function(t){return 0===this.cmp(t)},w.gt=function(t){return this.cmp(t)>0},w.gte=function(t){return this.cmp(t)>-1},w.lt=function(t){return this.cmp(t)<0},w.lte=function(t){return this.cmp(t)<1},w.minus=w.sub=function(t){var e,r,n,o,i=this,s=i.constructor,a=i.s,u=(t=new s(t)).s;if(a!=u)return t.s=-u,i.plus(t);var l=i.c.slice(),c=i.e,h=t.c,f=t.e;if(!l[0]||!h[0])return h[0]?t.s=-u:l[0]?t=new s(i):t.s=1,t;if(a=c-f){for((o=a<0)?(a=-a,n=l):(f=c,n=h),n.reverse(),u=a;u--;)n.push(0);n.reverse()}else for(r=((o=l.length<h.length)?l:h).length,a=u=0;u<r;u++)if(l[u]!=h[u]){o=l[u]<h[u];break}if(o&&(n=l,l=h,h=n,t.s=-t.s),(u=(r=h.length)-(e=l.length))>0)for(;u--;)l[e++]=0;for(u=e;r>a;){if(l[--r]<h[r]){for(e=r;e&&!l[--e];)l[e]=9;--l[e],l[r]+=10}l[r]-=h[r]}for(;0===l[--u];)l.pop();for(;0===l[0];)l.shift(),--f;return l[0]||(t.s=1,l=[f=0]),t.c=l,t.e=f,t},w.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(v);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},w.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},w.plus=w.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var s=o.e,a=o.c,u=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new i(o):t.s=o.s),t;if(a=a.slice(),e=s-u){for(e>0?(u=s,n=l):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-l.length<0&&(n=l,l=a,a=n),e=l.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+l[e]+r)/10|0;for(r&&(a.unshift(r),++u),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=u,t},w.pow=function(t){var e=this,r=new e.constructor("1"),n=r,o=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(y+"exponent");for(o&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return o?r.div(n):n},w.prec=function(t,e){if(t!==~~t||t<1||t>m)throw Error(y+"precision");return x(new this.constructor(this),t,e)},w.round=function(t,e){if(t===b)t=0;else if(t!==~~t||t<-m||t>m)throw Error(g);return x(new this.constructor(this),t+this.e+1,e)},w.sqrt=function(){var t,e,r,n=this,o=n.constructor,i=n.s,s=n.e,a=new o("0.5");if(!n.c[0])return new o(n);if(i<0)throw Error(p+"No square root");0===(i=Math.sqrt(n+""))||i===1/0?((e=n.c.join("")).length+s&1||(e+="0"),s=((s+1)/2|0)-(s<0||1&s),t=new o(((i=Math.sqrt(e))==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+s)):t=new o(i+""),s=t.e+(o.DP+=4);do{r=t,t=a.times(r.plus(n.div(r)))}while(r.c.slice(0,s).join("")!==t.c.slice(0,s).join(""));return x(t,(o.DP-=4)+t.e+1,o.RM)},w.times=w.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,s=o.length,a=i.length,u=r.e,l=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=u+l,s<a&&(e=o,o=i,i=e,l=s,s=a,a=l),e=new Array(l=s+a);l--;)e[l]=0;for(u=a;u--;){for(a=0,l=s+u;l>u;)a=e[l]+i[u]*o[l-u-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),u=e.length;!e[--u];)e.pop();return t.c=e,t},w.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==b){if(t!==~~t||t<0||t>m)throw Error(g);for(r=x(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return M(r,!0,!!n)},w.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==b){if(t!==~~t||t<0||t>m)throw Error(g);for(t=t+(r=x(new r.constructor(r),t+r.e+1,e)).e+1;r.c.length<t;)r.c.push(0)}return M(r,!1,!!n)},w[Symbol.for("nodejs.util.inspect.custom")]=w.toJSON=w.toString=function(){var t=this,e=t.constructor;return M(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},w.toNumber=function(){var t=Number(M(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(p+"Imprecise conversion");return t},w.toPrecision=function(t,e){var r=this,n=r.constructor,o=r.c[0];if(t!==b){if(t!==~~t||t<1||t>m)throw Error(y+"precision");for(r=x(new n(r),t,e);r.c.length<t;)r.c.push(0)}return M(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!o)},w.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(p+"valueOf disallowed");return M(t,t.e<=e.NE||t.e>=e.PE,!0)},function t(){function e(r){var n=this;if(!(n instanceof e))return r===b?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(y+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!S.test(e))throw Error(y+"number");for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),o=e.length,n=0;n<o&&"0"==e.charAt(n);)++n;if(n==o)t.c=[t.e=0];else{for(;o>0&&"0"==e.charAt(--o););for(t.e=r-n-1,t.c=[],r=0;n<=o;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=w,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();var P=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=N(e),function(t,e){if(e&&("object"==O(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,j()?Reflect.construct(e,r||[],N(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return 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&&A(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(E(Error));function _(t){return _="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)}function T(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,I(n.key),n)}}function k(t,e,r){return(e=I(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function I(t){var e=function(t,e){if("object"!=_(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_(e)?e:e+""}var R=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),k(this,"previousHighest",void 0),k(this,"highest",void 0),k(this,"previousLowest",void 0),k(this,"lowest",void 0),k(this,"previousResult",void 0),k(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new P;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&T(t.prototype,e),r&&T(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function C(t){return C="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},C(t)}function D(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,z(n.key),n)}}function F(t,e,r){return e=q(e),function(t,e){if(e&&("object"==C(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,V()?Reflect.construct(e,r||[],q(t).constructor):e.apply(t,r))}function V(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(V=function(){return!!t})()}function q(t){return q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},q(t)}function L(t,e){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},L(t,e)}function z(t){var e=function(t,e){if("object"!=C(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=C(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==C(e)?e:e+""}var U=function(t){function e(t){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=F(this,e),i=void 0,(o=z(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return 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&&L(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&D(r.prototype,n),o&&D(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(R);function $(t){return $="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)}function B(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,W(n.key),n)}}function H(t,e,r){return e=G(e),function(t,e){if(e&&("object"==$(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Y()?Reflect.construct(e,r||[],G(t).constructor):e.apply(t,r))}function Y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Y=function(){return!!t})()}function G(t){return G=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},G(t)}function K(t,e){return K=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},K(t,e)}function W(t){var e=function(t,e){if("object"!=$(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=$(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$(e)?e:e+""}var J=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];return r=t=H(this,e,[].concat(s)),o=[],(n=W(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return 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&&K(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var r=this.prices.reduce((function(t,e){return t+e}),0);return this.setResult(r/this.prices.length,e)}}}],n&&B(r.prototype,n),o&&B(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(U);function Q(t){return Q="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},Q(t)}function Z(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ot(n.key),n)}}function X(t,e,r){return e=et(e),function(t,e){if(e&&("object"==Q(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,tt()?Reflect.construct(e,r||[],et(t).constructor):e.apply(t,r))}function tt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(tt=function(){return!!t})()}function et(t){return et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},et(t)}function rt(t,e){return rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},rt(t,e)}function nt(t,e,r){return(e=ot(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ot(t){var e=function(t,e){if("object"!=Q(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Q(e)?e:e+""}var it=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),nt(r=X(this,e),"interval",void 0),nt(r,"indicator",void 0),nt(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new J(t),r.smoothingFactor=1/r.interval,r}return 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&&rt(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&Z(r.prototype,n),o&&Z(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(R);function st(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}function at(t){return at="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},at(t)}function ut(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,pt(n.key),n)}}function lt(t,e,r){return e=ht(e),function(t,e){if(e&&("object"==at(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ct()?Reflect.construct(e,r||[],ht(t).constructor):e.apply(t,r))}function ct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ct=function(){return!!t})()}function ht(t){return ht=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ht(t)}function ft(t,e){return ft=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ft(t,e)}function mt(t,e,r){return(e=pt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pt(t){var e=function(t,e){if("object"!=at(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=at(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==at(e)?e:e+""}var yt=function(t){function e(){var t;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return mt(t=lt(this,e,[].concat(n)),"previousCandle",void 0),mt(t,"twoPreviousCandle",void 0),t}return 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&&ft(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.high,n=t.low,o=r-n;if(this.previousCandle&&e&&(this.previousCandle=this.twoPreviousCandle),this.previousCandle){var i=Math.abs(r-this.previousCandle.close),s=Math.abs(n-this.previousCandle.close);return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(Math.max(o,i,s),e)}return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(o,e)}}],n&&ut(r.prototype,n),o&&ut(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(R);function gt(t){return gt="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},gt(t)}function dt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Mt(n.key),n)}}function vt(t,e,r){return e=bt(e),function(t,e){if(e&&("object"==gt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,wt()?Reflect.construct(e,r||[],bt(t).constructor):e.apply(t,r))}function wt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(wt=function(){return!!t})()}function bt(t){return bt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},bt(t)}function St(t,e){return St=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},St(t,e)}function xt(t,e,r){return(e=Mt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Mt(t){var e=function(t,e){if("object"!=gt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=gt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gt(e)?e:e+""}var Ot=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:it;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),xt(r=vt(this,e),"interval",void 0),xt(r,"tr",void 0),xt(r,"smoothing",void 0),r.interval=t,r.tr=new yt,r.smoothing=new n(t),r}return 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&&St(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.tr.update(t,e);if(this.smoothing.update(r,e),this.smoothing.isStable)return this.setResult(this.smoothing.getResult(),e)}}],n&&dt(r.prototype,n),o&&dt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(R);function Et(t){return Et="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},Et(t)}function jt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Nt(n.key),n)}}function At(t,e,r){return(e=Nt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Nt(t){var e=function(t,e){if("object"!=Et(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Et(e)?e:e+""}var Pt=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),At(this,"interval",void 0),At(this,"deviationMultiplier",void 0),At(this,"prices",[]),At(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=st(this.prices),r=function(t,e){var r=e||st(t),n=st(t.map((function(t){return t-r})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,e);return this.result={lower:e-r*this.deviationMultiplier,middle:e,upper:e+r*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new P;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&jt(t.prototype,e),r&&jt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function _t(t){return _t="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(t)}function Tt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ft(n.key),n)}}function kt(t,e,r){return e=Rt(e),function(t,e){if(e&&("object"==_t(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,It()?Reflect.construct(e,r||[],Rt(t).constructor):e.apply(t,r))}function It(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(It=function(){return!!t})()}function Rt(t){return Rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Rt(t)}function Ct(t,e){return Ct=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ct(t,e)}function Dt(t,e,r){return(e=Ft(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ft(t){var e=function(t,e){if("object"!=_t(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=_t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_t(e)?e:e+""}var Vt=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Dt(r=kt(this,e,[t]),"interval",void 0),Dt(r,"pricesCounter",0),Dt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return 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&&Ct(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e?e&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,e&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),e):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),e)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new P;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&Tt(r.prototype,n),o&&Tt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(U);function qt(t){return qt="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},qt(t)}function Lt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ut(n.key),n)}}function zt(t,e,r){return(e=Ut(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ut(t){var e=function(t,e){if("object"!=qt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=qt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qt(e)?e:e+""}var $t=function(){return t=function t(e,r,n){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),zt(this,"short",void 0),zt(this,"long",void 0),zt(this,"signal",void 0),zt(this,"prices",[]),zt(this,"result",void 0),this.short=e,this.long=r,this.signal=n},e=[{key:"getResult",value:function(){if(void 0===this.result)throw new P;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t);var r=this.short.update(t,e),n=this.long.update(t,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=r-n,i=this.signal.update(o,e);return this.result={histogram:o-i,macd:o,signal:i}}}}],e&&Lt(t.prototype,e),r&&Lt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function Bt(t){return Bt="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},Bt(t)}function Ht(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Qt(n.key),n)}}function Yt(t,e,r){return e=Kt(e),function(t,e){if(e&&("object"==Bt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Gt()?Reflect.construct(e,r||[],Kt(t).constructor):e.apply(t,r))}function Gt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Gt=function(){return!!t})()}function Kt(t){return Kt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Kt(t)}function Wt(t,e){return Wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Wt(t,e)}function Jt(t,e,r){return(e=Qt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Qt(t){var e=function(t,e){if("object"!=Bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bt(e)?e:e+""}var Zt=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:it;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Jt(r=Yt(this,e),"interval",void 0),Jt(r,"previousPrices",[]),Jt(r,"avgGain",void 0),Jt(r,"avgLoss",void 0),Jt(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return 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&&Wt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=t,n=this.previousPrices[this.previousPrices.length-2];if(r>n?(this.avgLoss.update(0,e),this.avgGain.update(t-n,e)):(this.avgLoss.update(n-r,e),this.avgGain.update(0,e)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,e);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),e)}}}}],n&&Ht(r.prototype,n),o&&Ht(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(R);function Xt(t){return Xt="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},Xt(t)}function te(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Xt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Xt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var ee={ema:Vt,sma:J},re=function(t,e,r,n,o){var i=o.target,s=(o.lag,o.precomputed),a=t.verticalOhlcv,u=t.instances,l=s.keyName;if(0===e&&!a.hasOwnProperty(i))throw new Error("Target property ".concat(i," not found in verticalOhlcv for ").concat(r,"."));var c=a[i][e],h=u[l];h.update(c);var f=NaN;try{f=h.getResult()}catch(t){}return t.pushToMain({index:e,key:l,value:f}),!0},ne=function(t){var e=t.main,r=t.size,n=t.target,o=t.lag,i=t.methodName,s=e.instances,a=e.verticalOhlcv,u=e.priceBased,l=e.arrayTypes,c=e.len,h="close"!==n?"_".concat(n):"",f="".concat(i,"_").concat(r).concat(h);return s[f]=new ee[i](r),a[f]=new Float64Array(c).fill(NaN),u.add(f),o>0&&e.lag([f],o),l[f]="Float64Array",{keyName:f}};function oe(t){return oe="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},oe(t)}function ie(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=oe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==oe(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function se(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ae="close";function ue(t){return ue="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},ue(t)}var le={number:function(t){return t},numberCleanString:function(t){return Number(t)},numberDirtyString:function(t){return Number(t.replace(/(?!^-)[^0-9.]/g,""))}},ce=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"==typeof t&&!Number.isNaN(t))return"number";if("string"==typeof t){var r=t.trim(),n=/^-?\d+(\.\d+)?$/;if(n.test(r))return"numberCleanString";var o=r.replace(/[^0-9.]/g,"");if(o&&n.test(o))return"numberDirtyString"}if(e)throw new TypeError("Invalid input: expected a number or numeric string");return ue(t)},he=function(t,e){var r=Math.pow(10,e);return Math.round((t+Number.EPSILON)*r)/r};function fe(t){return function(t){if(Array.isArray(t))return pe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||me(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function me(t,e){if(t){if("string"==typeof t)return pe(t,e);var r={}.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)?pe(t,e):void 0}}function pe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ye(t){return ye="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},ye(t)}function ge(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function de(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=ye(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ye(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ye(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ve(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return we(t,e);var r={}.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)?we(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function we(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function be(t){return be="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},be(t)}function Se(t){return Se="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},Se(t)}var xe={string:function(t){return t.toISOString()},milliseconds:function(t){return t.getTime()},seconds:function(t){return t.getTime()/1e3},object:function(t){return t}},Me={dateObject:function(t){return t},dateMilliseconds:function(t){return new Date(t)},dateSeconds:function(t){return new Date(1e3*t)},dateIncompleteDayString:function(t){return new Date("".concat(t," 00:00:00"))},dateCompleteDateString:function(t){return new Date(t)}},Oe=function(t){var e=["Date -> object","Milliseconds Timestamp -> integer","Seconds Timestamp -> integer","UTC Time Format (ISO 8601) -> string","Including a Timezone Offset (ISO 8601) -> string","Local Time Format (ISO 8601) -> string","YYYY/MM/DD or YYYY-MM-DD -> string"],r=function(){throw new Error('Invalid "'.concat(Se(t),'" date value passed in selectDateFormatter. Supported formats: \n-').concat(e.join("\n- ")))};if("object"===Se(t)){if(t instanceof Date&&!isNaN(t.valueOf()))return"dateObject";r()}else{if("number"==typeof t)return Math.abs(t)<1e11?"dateSeconds":"dateMillseconds";if("string"==typeof t){if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/i.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?([+-]\d{2}:\d{2})$/.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(t)&&t.length>10||/^\d{4}\/\d{2}\/\d{2}$/.test(t))return"dateCompleteDateString";if(/^\d{4}-\d{2}-\d{2}$/.test(t))return"dateIncompleteDayString";r()}else r()}};function Ee(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!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)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return je(t,e);var r={}.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)?je(t,e):void 0}}(t,e)||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.")}()}function je(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ae=new Set(["open","high","low","close"]),Ne=function(t,e){return"Array"===t?new Array(e).fill(null):"Float64Array"===t?new Float64Array(e).fill(NaN):"Int32Array"===t?new Int32Array(e).fill(NaN):void 0};function Pe(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!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)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||Te(t,e)||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.")}()}function _e(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Te(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function Te(t,e){if(t){if("string"==typeof t)return ke(t,e);var r={}.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)?ke(t,e):void 0}}function ke(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ie=function(t,e){var r=t.instances,n=t.verticalOhlcv,o=t.len,i=t.arrayTypes,s=t.priceBased;if(0===e){var a,u=[],l=_e(t.inputParams);try{for(l.s();!(a=l.n()).done;){var c=a.value;"lag"===c.key&&u.push(c.params)}}catch(t){l.e(t)}finally{l.f()}for(var h=0,f=u;h<f.length;h++){var m,p=Pe(f[h],2),y=p[0],g=p[1],d=_e(y);try{for(d.s();!(m=d.n()).done;){var v=m.value;if(s.has(v))for(var w=1;w<=g;w++)s.add("".concat(v,"_lag_").concat(w))}}catch(t){d.e(t)}finally{d.f()}}r.lag={lagParams:u}}var b,S=_e(r.lag.lagParams);try{for(S.s();!(b=S.n()).done;){var x,M=Pe(b.value,2),O=M[0],E=M[1],j=_e(O);try{for(j.s();!(x=j.n()).done;){var A=x.value,N=n[A];if(0===e)for(var P=1;P<=E;P++){var _="".concat(A,"_lag_").concat(P);if(!i.hasOwnProperty(A))throw new Error('Lag processing invoked by "'.concat(A,'" expected arrayTypes to have a "').concat(A,'" property, but it wasn’t found.'));n[_]=Ne(i[A],o),i[_]=i[A]}for(var T=1;T<=E;T++){var k="".concat(A,"_lag_").concat(T),I=e-T,R=I<=0||void 0===N[I]?null:N[I];t.pushToMain({index:e,key:k,value:R})}}}catch(t){j.e(t)}finally{j.f()}}}catch(t){S.e(t)}finally{S.f()}return!0};function Re(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Ce(t,e);var r={}.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)?Ce(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function Ce(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function De(t){return De="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},De(t)}function Fe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ve(n.key),n)}}function Ve(t){var e=function(t,e){if("object"!=De(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=De(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==De(e)?e:e+""}var qe=function(t,e){return t>e},Le=function(t,e){return t<e},ze=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,{interval:0,prevState:.5,prevFast:NaN,prevSlow:NaN,prevHigh:NaN,prevLow:NaN,areHighAndLowUndefined:!1,crossIndexes:{up:[],down:[]}})},(e=[{key:"update",value:function(t,e){var r=e.fast,n=e.high,o=e.slow,i=e.low,s=this.prevState;this.areHighAndLowUndefined||void 0!==n&&void 0!==i||(this.areHighAndLowUndefined=!0),Number.isNaN(r)||Number.isNaN(o)||function(t,e){return t===e}(r,o)?s=.5:qe(r,o)?s=this.areHighAndLowUndefined?1:[i,o,this.prevLow,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&Le(i,o)&&qe(this.prevLow,this.prevSlow)?0:1:Le(r,o)&&(s=this.areHighAndLowUndefined?0:[n,o,this.prevHigh,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&qe(n,o)&&Le(this.prevHigh,this.prevSlow)?1:0),.5===s?this.interval=0:1===s?this.prevState<=.5?this.interval=1:this.interval++:0===s&&(this.prevState>=.5?this.interval=-1:this.interval--),1===this.interval&&this.crossIndexes.up.push(t),-1===this.interval&&this.crossIndexes.down.push(t),Object.assign(this,{prevState:s,prevFast:r,prevSlow:o,prevHigh:n,prevLow:i})}},{key:"getResult",value:function(){return this.interval}}])&&Fe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Ue=function(t,e){var r=t.verticalOhlcv,n=t.instances,o=t.len,i=t.arrayTypes,s=t.verticalOhlcvTempCols;if(0===e){var a=t.inputParams;n.crossPairsList=a.reduce((function(t,e){var r=e.key,n=e.params;if("crossPairs"===r){var o,i=Re(n);try{for(i.s();!(o=i.n()).done;){var s,a=Re(o.value);try{for(a.s();!(s=a.n()).done;){var u=s.value;t.push(u)}}catch(t){a.e(t)}finally{a.f()}}}catch(t){i.e(t)}finally{i.f()}}return t}),[])}var u,l=Re(n.crossPairsList);try{for(l.s();!(u=l.n()).done;){var c=u.value,h=c.fast,f=c.slow;if(null!=h&&null!=f){var m="".concat(h,"_x_").concat(f);if(0===e){if("number"==typeof f&&(s.add(f.toString()),r[f.toString()]=new Int32Array(o).fill(f)),"price"!==h&&!r.hasOwnProperty(h))throw Error('fast "'.concat(h,' not found in crossPairs"'));if(!r.hasOwnProperty(f))throw Error('slow "'.concat(f,' not found in crossPairs"'));n[m]=new ze,r[m]=new Int32Array(o).fill(NaN),i[m]="Int32Array"}var p=void 0,y=void 0,g=void 0,d=void 0,v=void 0;"price"===h?(y=r.close[e],g=r.high[e],d=r.low[e],v=r[f][e],n[m].update(e,{fast:y,slow:v,high:g,low:d})):(p=r[h][e],v=r[f][e],n[m].update(e,{fast:p,slow:v})),t.pushToMain({index:e,key:m,value:n[m].getResult()})}}}catch(t){l.e(t)}finally{l.f()}};function $e(t){return $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},$e(t)}function Be(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function He(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=$e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=$e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$e(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ye(t){return function(t){if(Array.isArray(t))return We(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ke(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ge(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ke(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function Ke(t,e){if(t){if("string"==typeof t)return We(t,e);var r={}.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)?We(t,e):void 0}}function We(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Je=r(673);Je.y3,Je.jy,Je.oN,Je.Hc;const Qe=Je.cg,Ze=(Je.hj,Je.LU,Je.Tb,Je.uq),Xe=(Je.Zm,Je.Dq,Je.__,Je.q0,Je.lh,Je.pI,Je.zC,Je.zg,Je.g6),tr=Je.OL,er=(Je.ks,Je.QR,Je.jp,Je.mk);Je.W2,Je.l,Je.KY,Je.dv,Je.BR,Je.Wu,Je.uq,Je.uq,Je.a4,Je.DI,Je.Jo,Je.Zi,Je.kH,Je.LV;class rr{constructor(t,e={},r){if(this.U=null,this.S=null,r)return this.center=r.center,this.scale=r.scale,this.means=r.means,this.stdevs=r.stdevs,this.U=Ze.checkMatrix(r.U),this.S=r.S,this.R=r.R,void(this.excludedFeatures=r.excludedFeatures||[]);let n;Array.isArray(t),n=new Ze(t);const{isCovarianceMatrix:o=!1,method:i="SVD",nCompNIPALS:s=2,center:a=!0,scale:u=!1,ignoreZeroVariance:l=!1}=e;if(this.center=a,this.scale=u,this.means=null,this.stdevs=null,this.excludedFeatures=[],o)this._computeFromCovarianceMatrix(n);else switch(this._adjust(n,l),i){case"covarianceMatrix":{const t=new Xe(n).mmul(n).div(n.rows-1);this._computeFromCovarianceMatrix(t);break}case"NIPALS":this._computeWithNIPALS(n,s);break;case"SVD":{const t=new er(n,{computeLeftSingularVectors:!1,computeRightSingularVectors:!0,autoTranspose:!0});this.U=t.rightSingularVectors;const e=t.diagonal,r=[];for(const t of e)r.push(t*t/(n.rows-1));this.S=r;break}default:throw new Error(`unknown method: ${i}`)}}static load(t){if("string"!=typeof t.name)throw new TypeError("model must have a name property");if("PCA"!==t.name)throw new RangeError(`invalid model: ${t.name}`);return new rr(void 0,void 0,t)}predict(t,e={}){const{nComponents:r=this.U.columns}=e;let n;if(Array.isArray(t),n=new Ze(t),this.center&&(n.subRowVector(this.means),this.scale)){for(let t of this.excludedFeatures)n.removeColumn(t);n.divRowVector(this.stdevs)}let o=n.mmul(this.U);return o.subMatrix(0,o.rows-1,0,r-1)}invert(t){let e=(t=Ze.checkMatrix(t)).mmul(this.U.transpose());return this.center&&(this.scale&&e.mulRowVector(this.stdevs),e.addRowVector(this.means)),e}getExplainedVariance(){let t=0;if(this.S)for(const e of this.S)t+=e;return this.S?this.S.map((e=>e/t)):[]}getCumulativeVariance(){let t=this.getExplainedVariance();for(let e=1;e<t.length;e++)t[e]+=t[e-1];return t}getEigenvectors(){return this.U}getEigenvalues(){return this.S}getStandardDeviations(){return this.S.map((t=>Math.sqrt(t)))}getLoadings(){return this.U.transpose()}toJSON(){return{name:"PCA",center:this.center,scale:this.scale,means:this.means,stdevs:this.stdevs,U:this.U,S:this.S,excludedFeatures:this.excludedFeatures}}_adjust(t,e){if(this.center){const r=t.mean("column"),n=this.scale?t.standardDeviation("column",{mean:r}):null;if(this.means=r,t.subRowVector(r),this.scale){for(let r=0;r<n.length;r++)if(0===n[r]){if(!e)throw new RangeError(`Cannot scale the dataset (standard deviation is zero at index ${r}`);t.removeColumn(r),n.splice(r,1),this.excludedFeatures.push(r),r--}this.stdevs=n,t.divRowVector(n)}}}_computeFromCovarianceMatrix(t){const e=new Qe(t,{assumeSymmetric:!0});this.U=e.eigenvectorMatrix,this.U.flipRows(),this.S=e.realEigenvalues,this.S.reverse()}_computeWithNIPALS(t,e){this.U=new Ze(e,t.columns),this.S=[];let r=t;for(let t=0;t<e;t++){let e=new tr(r);this.U.setRow(t,e.w.transpose()),this.S.push(Math.pow(e.s.get(0,0),2)),r=e.xResidual}this.U=this.U.transpose()}}function nr(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=or(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function or(t,e){if(t){if("string"==typeof t)return ir(t,e);var r={}.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)?ir(t,e):void 0}}function ir(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function sr(t){return function(t){if(Array.isArray(t))return lr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ur(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ar(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ur(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function ur(t,e){if(t){if("string"==typeof t)return lr(t,e);var r={}.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)?lr(t,e):void 0}}function lr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var cr={dateTime:function(t,e,r){var n=r.lag,o=t.instances,i=t.verticalOhlcv;if(0===e){var s=t.len,a=t.dateType,u=t.arrayTypes;if(!a)throw Error('dateTime method found and invalid "date" in input ohlcv');Object.assign(o,{dateTime:{prevDateStr:i.date[0],sessionDailyIndexCount:0,sessionIntradayIndexCount:0,cachedDayInfo:i.date[0]}});for(var l=["day_of_the_week","day_of_the_month","week_of_the_month","minute","hour","month","year","session_daily_index","session_intraday_index"],c=0,h=l;c<h.length;c++)u[h[c]]="Int32Array";Object.assign(i,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Be(Object(r),!0).forEach((function(e){He(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Be(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},Object.fromEntries(l.map((function(t){return[t,new Int32Array(s).fill(NaN)]}))))),n>0&&t.lag(l,n)}var f=i.date[e],m=function(t){var e=t.getMonth(),r=t.getFullYear(),n=t.getHours(),o=t.getMinutes(),i=t.getDay(),s=t.getDate(),a=new Date(t.getFullYear(),t.getMonth(),1).getDay();return{month:e,year:r,hour:n,minute:o,day_of_the_week:i,day_of_the_month:s,week_of_the_month:Math.ceil((s+a)/7)}}(f),p=m.day_of_the_week,y=m.day_of_the_month,g=m.week_of_the_month,d=m.month,v=m.year,w=m.hour,b=m.minute,S=f;S!==o.dateTime.prevDateStr&&(o.dateTime.prevDateStr=S,o.dateTime.sessionDailyIndexCount++,o.dateTime.sessionIntradayIndexCount=0),t.pushToMain({index:e,key:"session_daily_index",value:o.dateTime.sessionDailyIndexCount}),t.pushToMain({index:e,key:"session_intraday_index",value:o.dateTime.sessionIntradayIndexCount}),t.pushToMain({index:e,key:"day_of_the_week",value:p}),t.pushToMain({index:e,key:"day_of_the_month",value:y}),t.pushToMain({index:e,key:"week_of_the_month",value:g}),t.pushToMain({index:e,key:"month",value:d}),t.pushToMain({index:e,key:"year",value:v}),t.pushToMain({index:e,key:"hour",value:w}),t.pushToMain({index:e,key:"minute",value:b}),o.dateTime.sessionIntradayIndexCount++},rsi:function(t,e,r,n){var o=n.target,i=n.lag,s=t.verticalOhlcv,a=t.instances,u="close"===o?"":"_".concat(o),l="rsi_".concat(r).concat(u),c="rsi_sma_".concat(r).concat(u);if(0===e){var h=t.crossPairsList,f=t.len,m=t.arrayTypes;if(!s.hasOwnProperty(o))throw new Error("Target property ".concat(o," not found in verticalOhlcv for rsi."));h.push({fast:l,slow:c,isDefault:!0}),Object.assign(a,te(te({},l,new Zt(r)),c,new J(r))),Object.assign(s,te(te({},l,new Float64Array(f).fill(NaN)),c,new Float64Array(f).fill(NaN)));var p=[l,c];i>0&&t.lag(p,i);for(var y=0,g=p;y<g.length;y++)m[g[y]]="Float64Array"}var d=s[o][e],v=NaN,w=NaN;a[l].update(d);try{v=a[l].getResult()}catch(t){v=NaN}t.pushToMain({index:e,key:l,value:v}),Number.isNaN(v)||a[c].update(v);try{w=a[c].getResult()}catch(t){w=NaN}t.pushToMain({index:e,key:c,value:w})},atr:function(t,e,r,n){var o=n.lag,i=n.percentage,s=n.upper,a=n.lower,u=t.verticalOhlcv,l=t.instances,c="atr_".concat(r);if(0===e){var h=t.instances,f=t.verticalOhlcv,m=t.arrayTypes,p=t.len,y=t.priceBased;h[c]=new Ot(r,it);var g=[c];i&&g.push("".concat(c,"_percentage")),null!==s&&g.push("".concat(c,"_upper")),null!==a&&g.push("".concat(c,"_lower"));for(var d=0,v=g;d<v.length;d++){var w=v[d];w.endsWith("_percentage")||y.add(w),f[w]=new Float64Array(p).fill(NaN),m[w]="Float64Array"}o>0&&t.lag(g,o)}var b={high:u.high[e],low:u.low[e],close:u.close[e]},S=l[c];S.update(b);var x=NaN;try{x=S.getResult()}catch(t){}if(i){var M=Number.isNaN(x)?NaN:x/b.close;t.pushToMain({index:e,key:"".concat(c,"_percentage"),value:M})}if(null!==s){var O=Number.isNaN(x)?NaN:b.close+x*s;t.pushToMain({index:e,key:"".concat(c,"_upper"),value:O})}if(null!==a){var E=Number.isNaN(x)?NaN:b.close-x*a;t.pushToMain({index:e,key:"".concat(c,"_lower"),value:E})}return t.pushToMain({index:e,key:c,value:x}),!0},ema:re,sma:re,macd:function(t,e,r,n,o,i){var s=i.target,a=i.lag,u=i.precomputed,l=t.verticalOhlcv,c=t.instances,h=u.instanceKey;if(0===e){var f=t.inputParams,m=t.crossPairsList,p=t.priceBased,y=t.len,g=t.arrayTypes;if(!l.hasOwnProperty(s))throw new Error("Target property ".concat(s," not found in verticalOhlcv for macd."));var d,v=0,w=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return se(t,e);var r={}.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)?se(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}(f);try{for(w.s();!(d=w.n()).done;)"macd"===d.value.key&&v++}catch(t){w.e(t)}finally{w.f()}var b=v>1?"macd_".concat(r,"_").concat(n,"_").concat(o):"macd",S=s===ae?"".concat(b,"_diff"):"".concat(b,"_diff_").concat(s),x=s===ae?"".concat(b,"_dea"):"".concat(b,"_dea_").concat(s),M=s===ae?"".concat(b,"_histogram"):"".concat(b,"_histogram_").concat(s);m.push({fast:S,slow:x,isDefault:!0}),c.hasOwnProperty("macd")||(c.macd={numberOfIndicators:v,settings:{}}),c.macd.settings[h]=new $t(new Vt(r),new Vt(n),new Vt(o)),Object.assign(l,ie(ie(ie({},S,new Float64Array(y).fill(NaN)),x,new Float64Array(y).fill(NaN)),M,new Float64Array(y).fill(NaN)))[M].forEach((function(t){p.add(t)}));var O=[S,x,M];a>0&&t.lag(O,a);for(var E=0,j=O;E<j.length;E++)g[j[E]]="Float64Array"}var A=c.macd,N=A.numberOfIndicators,P=A.settings,_=N>1?"macd_".concat(r,"_").concat(n,"_").concat(o):"macd",T=s===ae?"".concat(_,"_diff"):"".concat(_,"_diff_").concat(s),k=s===ae?"".concat(_,"_dea"):"".concat(_,"_dea_").concat(s),I=s===ae?"".concat(_,"_histogram"):"".concat(_,"_histogram_").concat(s),R=P[h],C=l[s][e];R.update(C);var D={};try{D=R.getResult()}catch(t){}return t.pushToMain({index:e,key:T,value:D?D.macd:NaN}),t.pushToMain({index:e,key:k,value:D?D.signal:NaN}),t.pushToMain({index:e,key:I,value:D?D.histogram:NaN}),!0},relativeVolume:function(t,e,r,n){var o=n.lag,i="relative_volume_".concat(r),s=t.instances,a=t.verticalOhlcv;if(0===e){var u=t.len,l=t.arrayTypes;s[i]={instance:new J(r),prevRelativeVolumeSma:NaN},a[i]=new Float64Array(u).fill(NaN),o>0&&t.lag([i],o),l[i]="Float64Array"}var c=a.volume[e],h=s[i].instance;h.update(c);var f=NaN;try{f=h.getResult()}catch(t){}var m=s[i].prevRelativeVolumeSma,p=NaN;return Number.isNaN(f)||Number.isNaN(m)||(p=c/m),t.pushToMain({index:e,key:i,value:p}),s[i].prevRelativeVolumeSma=f,!0},donchianChannels:function(t,e,r,n,o){var i=t.verticalOhlcv,s=t.instances,a=t.len,u=t.inputParams,l=t.priceBased,c=t.arrayTypes,h=t.lag,f=o.height,m=o.range,p=o.decimals,y="".concat(r,"_").concat(n);if(0===e){var g=u.filter((function(t){return"donchianChannels"===t.key})).length,d="donchian_channel",v=g>1?"".concat(d,"_").concat(y):d,w=["upper","basis","lower"].map((function(t){return"".concat(v,"_").concat(t)}));f&&w.push("".concat(v,"_height"));var b,S=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=me(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}(m);try{for(S.s();!(b=S.n()).done;){var x=b.value;if(!(x in i)||!l.has(x))throw new Error('Invalid range key "'.concat(x,'". Only price-based keys are allowed: ').concat(fe(l)));w.push("".concat(v,"_range_").concat(x))}}catch(t){S.e(t)}finally{S.f()}s.donchian_channel||(s.donchian_channel={numberOfIndicators:g,settings:{}}),s.donchian_channel.numberOfIndicators=g,s.donchian_channel.settings[y]={maxDeque:[],minDeque:[]},Object.assign(i,Object.fromEntries(w.map((function(t){return[t,new Float64Array(a).fill(NaN)]})))),h>0&&t.lag(w,h),["upper","basis","lower"].forEach((function(t){return l.add("".concat(v,"_").concat(t))})),w.forEach((function(t){return c[t]="Float64Array"}))}var M=s.donchian_channel,O=M.numberOfIndicators,E=M.settings,j=O>1?"donchian_channel_".concat(y):"donchian_channel",A=E[y],N=A.maxDeque,P=A.minDeque,_=e-n,T=_-r+1,k=["upper","basis","lower"].map((function(t){return"".concat(j,"_").concat(t)}));f&&k.push("".concat(j,"_height"));var I=m.map((function(t){return"".concat(j,"_range_").concat(t)}));if(T<0||_+1>a)return[].concat(fe(k),fe(I)).forEach((function(r){return t.pushToMain({index:e,key:r,value:NaN})})),!0;var R=i.high,C=i.low,D=function(t,e,r){for(;t.length&&t[0]<T;)t.shift();for(;t.length&&r(e[t.at(-1)],e[_]);)t.pop();t.push(_)};D(N,R,(function(t,e){return t<=e})),D(P,C,(function(t,e){return t>=e}));var F=N.length&&P.length,V=F?R[N[0]]:NaN,q=F?C[P[0]]:NaN,L=F?(V+q)/2:NaN;if(t.pushToMain({index:e,key:"".concat(j,"_upper"),value:V}),t.pushToMain({index:e,key:"".concat(j,"_basis"),value:L}),t.pushToMain({index:e,key:"".concat(j,"_lower"),value:q}),f){var z=F&&q?(V-q)/q:NaN;t.pushToMain({index:e,key:"".concat(j,"_height"),value:null===p?z:he(z,p)})}for(var U=F?V-q:NaN,$=0;$<m.length;$++){var B=i[m[$]][e],H=F&&B==B&&U?(B-q)/U:NaN;t.pushToMain({index:e,key:I[$],value:null===p?H:he(H,p)})}return!0},bollingerBands:function(t,e,r,n,o){var i,s,a,u,l,c,h,f=o.height,m=o.range,p=void 0===m?[]:m,y=o.target,g=o.lag,d=o.decimals,v=t.verticalOhlcv,w=t.instances,b="close"===y?"":"_".concat(y),S="".concat(r,"_").concat(n).concat(b);if(0===e){var x=t.priceBased,M=t.inputParams,O=t.verticalOhlcv,E=t.len,j=t.arrayTypes;if(!(y in O))throw new Error('bollingerBands could not find target "'.concat(y,'"'));var A,N=0,P=ve(M);try{for(P.s();!(A=P.n()).done;)"bollingerBands"===A.value.key&&N++}catch(t){P.e(t)}finally{P.f()}h=N>1?"bollinger_bands_".concat(S):"bollinger_bands".concat(b),w.bollinger_bands||(w.bollinger_bands={numberOfIndicators:N,settings:{}}),w.bollinger_bands.settings[S]=new Pt(r,n);var _=["".concat(h,"_upper"),"".concat(h,"_middle"),"".concat(h,"_lower")];f&&_.push("".concat(h,"_height"));var T,k=ve(p);try{for(k.s();!(T=k.n()).done;){var I=T.value;if(!(I in O)||!x.has(I))throw new Error('Invalid range item value "'.concat(I,'" property for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(x)));_.push("".concat(h,"_range_").concat(I))}}catch(t){k.e(t)}finally{k.f()}var R=Object.fromEntries(_.map((function(t){return[t,new Float64Array(E).fill(NaN)]})));Object.assign(O,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ge(Object(r),!0).forEach((function(e){de(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ge(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},R)),g>0&&t.lag(_,g),["".concat(h,"_upper"),"".concat(h,"_middle"),"".concat(h,"_lower")].forEach((function(t){x.add(t)}));for(var C=0,D=_;C<D.length;C++)j[D[C]]="Float64Array"}h||(h=w.bollinger_bands.numberOfIndicators>1?"bollinger_bands_".concat(S):"bollinger_bands".concat(b));var F=h,V=w.bollinger_bands.settings[S],q=v[y][e];V.update(q);var L={};try{L=V.getResult()}catch(t){}var z=null!==(i=null===(s=L)||void 0===s?void 0:s.upper)&&void 0!==i?i:NaN,U=null!==(a=null===(u=L)||void 0===u?void 0:u.middle)&&void 0!==a?a:NaN,$=null!==(l=null===(c=L)||void 0===c?void 0:c.lower)&&void 0!==l?l:NaN;if(t.pushToMain({index:e,key:"".concat(F,"_upper"),value:z}),t.pushToMain({index:e,key:"".concat(F,"_middle"),value:U}),t.pushToMain({index:e,key:"".concat(F,"_lower"),value:$}),f){var B=NaN;Number.isNaN($)||Number.isNaN(z)||(B=(z-$)/$),t.pushToMain({index:e,key:"".concat(F,"_height"),value:null===d?B:he(B,d)})}var H,Y=ve(p);try{for(Y.s();!(H=Y.n()).done;){var G=H.value,K=NaN,W=v[G][e];Number.isNaN(W)||Number.isNaN($)||Number.isNaN(z)||(K=(W-$)/(z-$)),t.pushToMain({index:e,key:"".concat(F,"_range_").concat(G),value:null===d?K:he(K,d)})}}catch(t){Y.e(t)}finally{Y.f()}return!0},volumeOscillator:function(t,e,r,n,o){var i,s,a,u=o.lag,l=t.verticalOhlcv,c=t.instances,h=l.volume[e],f="volume_oscillator_".concat(r,"_").concat(n);if(0===e){var m=t.crossPairsList,p=t.len,y=t.arrayTypes;Object.assign(c,(i={},s=f,a={fastEMA:new Vt(r),slowEMA:new Vt(n)},(s=function(t){var e=function(t,e){if("object"!=be(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=be(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==be(e)?e:e+""}(s))in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,i)),l[f]=new Float64Array(p).fill(NaN),m.push({fast:f,slow:0,isDefault:!0}),u>0&&t.lag([f],u),y[f]="Float64Array"}var g=c[f],d=g.fastEMA,v=g.slowEMA;d.update(h),v.update(h);var w=NaN,b=NaN;try{w=d.getResult()}catch(t){}try{b=v.getResult()}catch(t){}var S=NaN;return Number.isNaN(w)||Number.isNaN(b)||(S=100*(w-b)/b),t.pushToMain({index:e,key:f,value:S}),!0},scaler:function(t,e,r,n,o){var i=o.type,s=o.group,a=o.range,u=o.lag,l=o.precomputed,c=o.decimals,h=l.groupKey,f=l.groupKeyLen,m=t.verticalOhlcv,p=t.instances,y=t.arrayTypes,g="".concat(i,"_").concat(r);if(0===e){var d=t.len,v=t.scaledLabels;if(v.has(g))throw new Error('Method "scaler" cannot have both "size" and "options.type" parameters specified together.');v.add(g),p.hasOwnProperty("scaler")||(p.scaler={windows:{}});var w,b=Ge(n);try{var S=function(){var e=w.value;if(!m.hasOwnProperty(e))throw new Error('Target property "'.concat(e,'" not found in verticalOhlcv'));var r="".concat(g,"_").concat(e);m[r]=new Float64Array(d).fill(NaN),y[r]="Float64Array";var n=s?h:e;if(p.scaler.windows[n]=[],s&&(t.scaledGroups[h]||(t.scaledGroups[h]=[]),t.scaledGroups[h].push(r)),u>0){if(s){var o,i=Array.from({length:u}).map((function(t,e){return"".concat(r,"_lag_").concat(e+1)}));(o=t.scaledGroups[h]).push.apply(o,Ye(i))}t.lag([r],u)}};for(b.s();!(w=b.n()).done;)S()}catch(t){b.e(t)}finally{b.f()}}var x,M=p.scaler.windows,O=Ge(n);try{for(O.s();!(x=O.n()).done;){var E=x.value,j=m[E][e],A=M[s?h:E];A.push(j),A.length>(s?r*f:r)&&A.shift()}}catch(t){O.e(t)}finally{O.f()}var N,P=e+1>=r,_=Ge(n);try{var T=function(){var r,n,o,u,l,f,p,y,d=N.value,v=m[d][e],w="".concat(g,"_").concat(d),b=null;if(P){var S=M[s?h:d];if("minmax"===i){r=v,n=Math.min.apply(Math,Ye(S)),o=Math.max.apply(Math,Ye(S)),y=2,u=function(t){if(Array.isArray(t))return t}(p=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!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)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(p,y)||Ke(p,y)||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.")}(),l=u[0],f=u[1],b=(Math.min(Math.max(r,n),o)-n)/(o-n)*(f-l)+l}else{if("zscore"!==i)throw new Error('Unknown scaler type "'.concat(i,'"'));var x=S.reduce((function(t,e){return t+e}),0)/S.length,O=S.reduce((function(t,e){return t+Math.pow(e-x,2)}),0)/S.length,E=Math.sqrt(O);b=function(t,e,r){return 0===r?0:(t-e)/r}(v,x,E)}}t.pushToMain({index:e,key:w,value:null===c?b:he(b,c)})};for(_.s();!(N=_.n()).done;)T()}catch(t){_.e(t)}finally{_.f()}}},hr=function(t,e){var r,n,o=e.len,i=e.inputParams,a=e.priceBased,u=e.precisionMultiplier,l=e.arrayTypes,c=e.verticalOhlcv,h=e.verticalOhlcvKeyNames,f=e.inputTypes,m=e.chunkProcess;e.scaledGroups,s(i,o);for(var p=0,y=Object.keys(f);p<y.length;p++){var g=y[p];c[g]=Ne(l[g],o)}for(var d=0;d<o;d+=m)for(var v=Math.min(d+m,o),w=d;w<v;w++){for(var b=t[w],S=0,x=Object.entries(f);S<x.length;S++){var M=(r=x[S],n=2,function(t){if(Array.isArray(t))return t}(r)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!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)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(r,n)||ur(r,n)||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.")}()),O=M[0],E=M[1],j=b[O];if(le.hasOwnProperty(E)){var A=le[E](j);u>1&&a.has(O)&&(A*=u),e.pushToMain({index:w,key:O,value:A})}else Me.hasOwnProperty(E)?e.pushToMain({index:w,key:O,value:Me[E](j)}):e.pushToMain({index:w,key:O,value:j})}var N,P=ar(i);try{for(P.s();!(N=P.n()).done;){var _=N.value,T=_.key,k=_.params;"lag"!==T&&"crossPairs"!==T&&cr[T].apply(cr,[e,w].concat(sr(k)))}}catch(t){P.e(t)}finally{P.f()}Ie(e,w),Ue(e,w),t[w]=null}!function(t){var e,r=t.inputParams,n=t.invalidValueIndex,o=t.len,i=t.verticalOhlcv,s=n+1,a=nr(r);try{var u=function(){var t=e.value,r=t.key,n=t.params;if("scaler"!==r)return 0;var a=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!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)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||or(t,e)||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.")}()}(n,3),u=a[0],l=a[1],c=a[2],h=c.type,f=c.group,m=c.lag,p=c.pca,y=c.pcaSource;if(!f||!p)return 0;var g,d=l.map((function(t){return"".concat(h,"_").concat(u,"_").concat(t)})),v=[],w=nr(d);try{for(w.s();!(g=w.n()).done;)for(var b=g.value,S=1;S<=m;S++)v.push("".concat(b,"_lag_").concat(S))}catch(t){w.e(t)}finally{w.f()}d.push.apply(d,v);for(var x=o-s,M=d.length,O=new Array(x),E=s;E<o;E++){var j,A=new Float64Array(M),N=0,P=nr(d);try{for(P.s();!(j=P.n()).done;){var _=j.value;A[N++]=i[_][E]}}catch(t){P.e(t)}finally{P.f()}O[E-s]=A}if(!y){var T,k=nr(d);try{for(k.s();!(T=k.n()).done;){var I=T.value;delete i[I]}}catch(t){k.e(t)}finally{k.f()}}var R=function(t){return function(t){if(Array.isArray(t))return ir(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||or(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(new rr(O).predict(O)),C="pca_".concat(h,"_").concat(u);i[C]=new Array(o).fill(null);for(var D=0;D<R.length;D++)i[C][D+s+1]=R[D]};for(a.s();!(e=a.n()).done;)u()}catch(t){a.e(t)}finally{a.f()}}(e),h.push.apply(h,sr(Object.keys(c)))},fr=function(t,e){for(var r=t.length,n=new J(e),o=new Array(r),i=0,s=0,a=0,u=0;u<r;u++)if(n.update(t[u]),n.isStable){var l=n.getResult();o[u]=l,i+=l,s+=l*l,a++}else o[u]=null;var c=i/a,h=s/a-c*c,f=Math.sqrt(h);return o.map((function(t){return null!==t?(t-c)/f:null}))},mr=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)throw new Error("Both arrays must have the same length");for(var n=fr(t,r),o=fr(e,r),i=t.length,s=[],a=0,u=0,l=0,c=0,h=0,f=0,m=-1,p=0;p<i;p++){if(null!==n[p]&&null!==o[p]){m=p;break}s.push(0)}if(-1===m)return new Array(i).fill(0);for(var y=m;y<i;y++){var g=n[y],d=o[y];if(null!==g&&null!==d)if(a+=g,u+=d,l+=g*d,c+=g*g,h+=d*d,++f<2)s.push(0);else{var v=f*l-a*u,w=Math.sqrt((f*c-a*a)*(f*h-u*u)),b=0===w?0:v/w;s.push(b)}else a=u=l=c=h=f=0,s.push(0)}return s};function pr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var yr=function(t){var e,r,n=t.main,o=t.skipNull,i=void 0!==o&&o,s=t.startIndex,a=void 0===s?0:s,u=t.dateFormat,l=n.precisionMultiplier,c=n.priceBased,h=n.precision,f=n.verticalOhlcv,m=n.invalidValueIndex,p=n.len,y=n.verticalOhlcvKeyNames,g=n.verticalOhlcvTempCols;if(0===y.length)return[];for(var d=i&&m>=0?m+1:0,v=Math.max(d,a),w=p-v,b=Array.from({length:w},(function(){return{}})),S=0,x=Object.entries(f);S<x.length;S++){var M=(e=x[S],r=2,function(t){if(Array.isArray(t))return t}(e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!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)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(e,r)||function(t,e){if(t){if("string"==typeof t)return pr(t,e);var r={}.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)?pr(t,e):void 0}}(e,r)||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.")}()),O=M[0],E=M[1];if(!g.has(O))for(var j=c.has(O)&&h,A=v;A<p;A++)b[A-v][O]=j?E[A]/l:"date"===O?xe[u](E[A]):E[A]}return b};function gr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!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)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||dr(t,e)||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.")}()}function dr(t,e){if(t){if("string"==typeof t)return vr(t,e);var r={}.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)?vr(t,e):void 0}}function vr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function wr(t){return wr="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},wr(t)}function br(t){return function(t){if(Array.isArray(t))return Mr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||xr(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Sr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!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)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||xr(t,e)||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.")}()}function xr(t,e){if(t){if("string"==typeof t)return Mr(t,e);var r={}.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)?Mr(t,e):void 0}}function Mr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Or(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Er(n.key),n)}}function Er(t){var e=function(t,e){if("object"!=wr(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=wr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wr(e)?e:e+""}var jr=function(){return t=function t(e){var r=this,n=e.input,o=e.ticker,i=void 0===o?null:o,a=e.precision,l=void 0===a||a,c=e.inputParams,m=void 0===c?null:c,p=e.chunkProcess,y=void 0===p?2e3:p;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),u(n,"input",null!==i?"contructor ".concat(i):"constuctor"),0===n.length)throw Error("input OHLCV must not be empty: "+i);h(l,"precision","constructor"),f(y,{min:100,max:5e4,allowDecimals:!1},"chunkProcess","constructor"),this.chunkProcess=y,this.firstRow=n[0];var g=function(t){for(var e={},r={},n=0,o=Object.entries(t);n<o.length;n++){var i=Ee(o[n],2),s=i[0],a=i[1];if("date"===s)e[s]=Oe(a),r[s]="Array";else if("volume"===s)e[s]=ce(a,!0),r[s]="Int32Array";else if(Ae.has(s))e[s]=ce(a,!0),r[s]="Float64Array";else{var u=ce(a,!1);e[s]=u,r[s]="number"===u?"Float64Array":"Array"}}return{inputTypes:e,arrayTypes:r}}(this.firstRow),d=g.inputTypes,v=g.arrayTypes;if(this.inputTypes=d,this.arrayTypes=v,!this.firstRow.hasOwnProperty("close"))throw Error('input OHLCV array objects require at least "close" property: '.concat(i));return this.dateType=this.inputTypes.date?this.inputTypes.date:null,this.isComputed=!1,this.input=n,this.priceBased=new Set(["open","high","low","close"]),this.len=n.length,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.verticalOhlcvKeyNames=[],this.verticalOhlcvTempCols=new Set,this.utilities={correlation:mr},this.invalidValueIndex=-1,this.precision=l,this.precisionMultiplier=function(t,e){var r=t.precision,n=t.priceBased;if(!1===r)return 1;var o,i=1,s=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=dr(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}(Object.entries(e).filter((function(t){var e=gr(t,2),r=e[0];return e[1],n.has(r)})).map((function(t){var e=gr(t,2);return e[0],e[1]})));try{for(s.s();!(o=s.n()).done;){var a=o.value,u=gr(String(a).split("."),2)[1],l=void 0===u?"":u,c=Math.max(4,l.length),h=c>1?Math.pow(10,c-1):1;h>i&&(i=h)}}catch(t){s.e(t)}finally{s.f()}return i}(this,this.firstRow),this.scaledGroups={},this.scaledLabels=new Set,this.pushToMain=function(t){var e=t.index,n=t.key,o=t.value;return function(t){var e=t.main,r=t.index,n=t.key,o=t.value,i=e.verticalOhlcv;return null==o||Number.isNaN(o)?(e.invalidValueIndex=r,i[n][r]=o,!1):(i[n][r]=o,!0)}({main:r,index:e,key:n,value:o})},null!==m&&(s(m,this.len),this.inputParams=m,this.compute()),this.inputParams=[],this},e=[{key:"getDataAsCols",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.skipNull,r=void 0===e||e,n=t.dateFormat,o=void 0===n?"string":n;c(Object.keys(xe),o,"dateFormat","getDataAsCols"),l(t,"options","getDataAsCols");for(var i=this.precisionMultiplier,s=this.precision,a=this.invalidValueIndex,u=this.len,h=this.verticalOhlcv,f=this.priceBased,m=this.arrayTypes,p=this.verticalOhlcvTempCols,y={},g=r?a+1:0,d=u-g,v=0,w=Object.entries(h);v<w.length;v++){var b=Sr(w[v],2),S=b[0],x=b[1];if(!p.has(S)){var M=f.has(S)&&s;y[S]=Ne(m[S],d);for(var O=g;O<u;O++)y[S][O]=M?x[O]/i:"date"===S?xe[o](x[O]):x[O]}}return y}},{key:"getData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.skipNull,r=void 0===e||e,n=t.dateFormat,o=void 0===n?"string":n;return c(Object.keys(xe),o,"dateFormat","getData"),l(t,"options","getData"),yr({main:this,skipNull:r,startIndex:0,dateFormat:o})}},{key:"getLastValues",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.dateFormat,r=void 0===e?"string":e;return c(Object.keys(xe),r,"dateFormat","getData"),yr({skipNull:!1,main:this,startIndex:this.len-1,dateFormat:r})[0]}},{key:"compute",value:function(){return this.isComputed||(this.isComputed=!1,this.len>0&&(hr(this.input,this),this.isComputed=!0,this.input=[],this.instances={},this.firstRow=[])),this}},{key:"crossPairs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e="crossPairs";return a(this),u(t,"arr",e),this.crossPairsList=[].concat(br(this.crossPairsList),br(t)),this.inputParams.push({key:e,params:[this.crossPairsList]}),this}},{key:"lag",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r="lag";a(this),u(t,"colKeys",r),f(e,{min:1,max:this.len,allowDecimals:!1},"lookback",r),this.inputParams.push({key:r,params:[t,e]});var n,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=xr(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}(t);try{for(o.s();!(n=o.n()).done;){var i=n.value;this.priceBased.has(i)&&this.priceBased.add(i)}}catch(t){o.e(t)}finally{o.f()}return this}},{key:"relativeVolume",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="relativeVolume";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),l(e,"options",r);var n=e.lag,o=void 0===n?0:n;return f(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),this.inputParams.push({key:r,params:[t,{lag:o}]}),this}},{key:"atr",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="atr";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),l(e,"options",r);var n=e.lag,o=void 0===n?0:n,i=e.percentage,s=void 0!==i&&i,u=e.upper,c=void 0===u?null:u,m=e.lower,p=void 0===m?null:m;return f(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),h(s,"options.percentage","atr"),null!==c&&f(c,{min:.001,max:100,allowDecimals:!0},"options.upper","atr"),null!==p&&f(p,{min:.001,max:100,allowDecimals:!0},"options.lower","atr"),this.inputParams.push({key:r,params:[t,{lag:o,percentage:s,upper:c,lower:p}]}),this}},{key:"ema",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="ema";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),l(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,s=void 0===i?0:i;f(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",r);var u=ne({main:this,size:t,target:o,lag:s,methodName:r});return this.inputParams.push({key:r,params:[r,t,{target:o,lag:s,precomputed:u}]}),this}},{key:"sma",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="sma";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),l(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,s=void 0===i?0:i;f(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",r);var u=ne({main:this,size:t,target:o,lag:s,methodName:r});return this.inputParams.push({key:r,params:[r,t,{target:o,lag:s,precomputed:u}]}),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="macd";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"fast",o),f(e,{min:1,max:this.len,allowDecimals:!1},"slow",o),f(r,{min:1,max:this.len,allowDecimals:!1},"signal",o),l(n,"options",o);var i=n.target,s=void 0===i?"close":i,u=n.lag,c=void 0===u?0:u;f(c,{min:0,max:this.len,allowDecimals:!1},"options.lag",o);var h={instanceKey:"".concat(t,"_").concat(e,"_").concat(r).concat("close"===s?"":"_".concat(s))};return this.inputParams.push({key:o,params:[t,e,r,{target:s,lag:c,precomputed:h}]}),this}},{key:"bollingerBands",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="bollingerBands";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",n),f(e,{min:.01,max:50,allowDecimals:!0},"stdDev",n),l(r,"options",n);var o=r.target,i=void 0===o?"close":o,s=r.height,c=void 0!==s&&s,m=r.range,p=void 0===m?[]:m,y=r.lag,g=void 0===y?0:y,d=r.decimals,v=void 0===d?null:d;return u(p,"options.range",n),f(g,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),h(c,"options.height",n),null!==v&&f(v,{min:1,max:15,allowDecimals:!1},"decimals",n),this.inputParams.push({key:n,params:[t,e,{target:i,height:c,range:p,lag:g,decimals:v}]}),this}},{key:"rsi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="rsi";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),l(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,s=void 0===i?0:i;return f(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),this.inputParams.push({key:r,params:[t,{target:o,lag:s}]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="donchianChannels";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",n),f(e,{min:0,max:this.len,allowDecimals:!1},"offset",n),l(r,"options",n);var o=r.height,i=void 0!==o&&o,s=r.range,c=void 0===s?[]:s,m=r.lag,p=void 0===m?0:m,y=r.decimals,g=void 0===y?null:y;return u(c,"options.range",n),f(p,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),h(i,"options.height",n),null!==g&&f(g,{min:1,max:15,allowDecimals:!1},"decimals",n),this.inputParams.push({key:n,params:[t,e,{height:i,range:c,lag:p,decimals:g}]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="volumeOscillator";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"fastSize",n),f(e,{min:t,max:this.len,allowDecimals:!1},"slowSize",n),l(r,"options",n);var o=r.lag,i=void 0===o?0:o;return f(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),this.inputParams.push({key:n,params:[t,e,{lag:i}]}),this}},{key:"dateTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="dateTime";a(this),l(t,"options",e);var r=t.lag,n=void 0===r?0:r;return f(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),this.inputParams.push({key:e,params:[{lag:n}]}),this}},{key:"scaler",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="scaler";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",n),u(e,"colKeys",n);var i=r.group,s=void 0!==i&&i,l=r.range,m=void 0===l?[0,1]:l,p=r.lag,y=void 0===p?0:p,g=r.type,d=void 0===g?"zscore":g,v=r.decimals,w=void 0===v?null:v,b=r.pca,S=void 0!==b&&b,x=r.pcaSource,M=void 0!==x&&x;h(s,"options.group",n),h(S,"options.pca",n),h(M,"options.pcaSource",n),function(t,e,r){if(u(t,e,r),2!==t.length)throw new Error('Invalid "'.concat(e,'" array length: expected 2 items, but got ').concat(t.length,' in "').concat(r,".").concat(e,'".'));var n=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!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)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||o(t,e)||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,2),i=n[0],s=n[1];if(f(i,{min:-100,max:s,allowDecimals:!1},"min",r),f(s,{min:i,max:100,allowDecimals:!1},"max",r),i===s)throw new Error('Invalid "min" can not be equal to "max" property in "'.concat(r,".").concat(e,'".'))}(m,"options.range",n),c(["minmax","zscore"],d,"options.type",n),null!==w&&f(w,{min:1,max:15,allowDecimals:!1},"decimals",n);var O={groupKey:s?"".concat(d,"_").concat(t,"_group_").concat(e.join("_")):"",groupKeyLen:e.length};return this.inputParams.push({key:n,params:[t,e,{type:d,group:s,range:m,lag:y,precomputed:O,decimals:w,pca:S,pcaSource:M}]}),this}}],e&&Or(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=n})();
1
+ var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(r,e)=>{for(var n in e)t.o(e,n)&&!t.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},r={};(()=>{t.r(r),t.d(r,{default:()=>On});var e=function(t,r,e){if(0===e.length)return!1;for(var n=t.verticalOhlcv,o=!0,i=0;i<e.length;i++){var a=e[i];if(!n.hasOwnProperty(a)){o=!1;break}var l=n[a][r];if(null==l||Number.isNaN(l)){o=!1;break}}return o};function n(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=o(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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,l=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return l=t.done,t},e:function(t){u=!0,a=t},f:function(){try{l||null==e.return||e.return()}finally{if(u)throw a}}}}function o(t,r){if(t){if("string"==typeof t)return i(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?i(t,r):void 0}}function i(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var a=function(t,r){if(!Array.isArray(t))throw new Error('Property "inputParams" must be an "Array" or "Set".');var e,o=n(t);try{for(o.s();!(e=o.n()).done;){var i,a=n(e.value.params);try{for(a.s();!(i=a.n()).done;){var l=i.value;if("number"==typeof l&&l>r)throw console.log(l,r),new Error("At least one of the params of the indicator is greater than the input OHLCV length. Make sure to have enough datapoints in the input OHLCV.")}}catch(t){a.e(t)}finally{a.f()}}}catch(t){o.e(t)}finally{o.f()}},l=function(t){if(!0===t.isComputed)throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" , "getDataAsCols" or "getData" methods are called.')},u=function(t,r,e){if(!Array.isArray(t))throw new Error('Param "'.concat(r,'" must be an array in "').concat(e,'".'));return!0},c=function(t,r,e){if(t instanceof Object==0)throw new Error('Param "'.concat(r,'" must be an object in "').concat(e,'".'));return!0},s=function(t,r,e,n){if(u(t,"arrayOptions","".concat(n,".").concat(e,".validateArrayOptions")),!t.includes(r.toString()))throw new Error('Param "'.concat(e,'" must be any of the following values [').concat(t.join(", "),'] in "').concat(n,'".'));return!0},f=function(t,r,e){if("boolean"!=typeof t)throw new Error('Param "'.concat(r,'" must be an boolean in "').concat(e,'".'));return!0},y=function(t,r,e,n){c(r,"options","".concat(n,".").concat(e,".validateNumber"));var o=r.allowDecimals,i=void 0!==o&&o,a=r.min,l=r.max,u=i?"number":"integer";if("number"!=typeof t||!1===i&&!Number.isInteger(t))throw new Error('Param "'.concat(e,'" must be an ').concat(u,' in "').concat(n,'".'));if(void 0!==a&&"number"!=typeof a)throw new Error('Param "min" must be a valid '.concat(u,' (if provided) in "').concat(n,".").concat(e,'.validateNumber".'));if(void 0!==l&&"number"!=typeof l)throw new Error('Param "max" must be a valid '.concat(u,' (if provided) in "').concat(n,".").concat(e,'.validateNumber".'));if(void 0!==a&&void 0!==l&&a>=l)throw new Error('Param "min" must be less than "max" in "'.concat(n,".").concat(e,'.validateNumber".'));if(void 0!==a&&t<a)throw new Error('Param "'.concat(e,'" must be an ').concat(u," ≥ ").concat(a,' in "').concat(n,'".'));if(void 0!==l&&t>l)throw new Error('Param "'.concat(e,'" must be an ').concat(u," ≤ ").concat(l,' in "').concat(n,'".'));return!0},p=function(t,r,e){if(u(t,r,e),2!==t.length)throw new Error('Invalid "'.concat(r,'" array length: expected 2 items, but got ').concat(t.length,' in "').concat(e,".").concat(r,'".'));var n,i,a=(i=2,function(t){if(Array.isArray(t))return t}(n=t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(n,i)||o(n,i)||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.")}()),l=a[0],c=a[1];if(y(l,{min:-100,max:c,allowDecimals:!1},"min",e),y(c,{min:l,max:100,allowDecimals:!1},"max",e),l===c)throw new Error('Invalid "min" can not be equal to "max" property in "'.concat(e,".").concat(r,'".'));return!0},h=function(t,r,e){if("string"!=typeof t||!t.length)throw new Error('Invalid "'.concat(r,'" property in "').concat(e,'". Only strings are accepted.'));return!0},v=1e6,d="[big.js] ",m=d+"Invalid ",b=m+"decimal places",g=m+"rounding mode",w=d+"Division by zero",S={},O=void 0,A=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function j(t,r,e,n){var o=t.c;if(e===O&&(e=t.constructor.RM),0!==e&&1!==e&&2!==e&&3!==e)throw Error(g);if(r<1)n=3===e&&(n||!!o[0])||0===r&&(1===e&&o[0]>=5||2===e&&(o[0]>5||5===o[0]&&(n||o[1]!==O))),o.length=1,n?(t.e=t.e-r+1,o[0]=1):o[0]=t.e=0;else if(r<o.length){if(n=1===e&&o[r]>=5||2===e&&(o[r]>5||5===o[r]&&(n||o[r+1]!==O||1&o[r-1]))||3===e&&(n||!!o[0]),o.length=r,n)for(;++o[--r]>9;)if(o[r]=0,0===r){++t.e,o.unshift(1);break}for(r=o.length;!o[--r];)o.pop()}return t}function P(t,r,e){var n=t.e,o=t.c.join(""),i=o.length;if(r)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&e?"-"+o:o}function N(t){return N="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},N(t)}function x(t){var r="function"==typeof Map?new Map:void 0;return x=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(r){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return function(t,r,e){if(_())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,r);var o=new(t.bind.apply(t,n));return e&&k(o,e.prototype),o}(t,arguments,C(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),k(e,t)},x(t)}function _(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(_=function(){return!!t})()}function k(t,r){return k=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},k(t,r)}function C(t){return C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},C(t)}S.abs=function(){var t=new this.constructor(this);return t.s=1,t},S.cmp=function(t){var r,e=this,n=e.c,o=(t=new e.constructor(t)).c,i=e.s,a=t.s,l=e.e,u=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(r=i<0,l!=u)return l>u^r?1:-1;for(a=(l=n.length)<(u=o.length)?l:u,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^r?1:-1;return l==u?0:l>u^r?1:-1},S.div=function(t){var r=this,e=r.constructor,n=r.c,o=(t=new e(t)).c,i=r.s==t.s?1:-1,a=e.DP;if(a!==~~a||a<0||a>v)throw Error(b);if(!o[0])throw Error(w);if(!n[0])return t.s=i,t.c=[t.e=0],t;var l,u,c,s,f,y=o.slice(),p=l=o.length,h=n.length,d=n.slice(0,l),m=d.length,g=t,S=g.c=[],A=0,P=a+(g.e=r.e-t.e)+1;for(g.s=i,i=P<0?0:P,y.unshift(0);m++<l;)d.push(0);do{for(c=0;c<10;c++){if(l!=(m=d.length))s=l>m?1:-1;else for(f=-1,s=0;++f<l;)if(o[f]!=d[f]){s=o[f]>d[f]?1:-1;break}if(!(s<0))break;for(u=m==l?o:y;m;){if(d[--m]<u[m]){for(f=m;f&&!d[--f];)d[f]=9;--d[f],d[m]+=10}d[m]-=u[m]}for(;!d[0];)d.shift()}S[A++]=s?c:++c,d[0]&&s?d[m]=n[p]||0:d=[n[p]]}while((p++<h||d[0]!==O)&&i--);return S[0]||1==A||(S.shift(),g.e--,P--),A>P&&j(g,P,e.RM,d[0]!==O),g},S.eq=function(t){return 0===this.cmp(t)},S.gt=function(t){return this.cmp(t)>0},S.gte=function(t){return this.cmp(t)>-1},S.lt=function(t){return this.cmp(t)<0},S.lte=function(t){return this.cmp(t)<1},S.minus=S.sub=function(t){var r,e,n,o,i=this,a=i.constructor,l=i.s,u=(t=new a(t)).s;if(l!=u)return t.s=-u,i.plus(t);var c=i.c.slice(),s=i.e,f=t.c,y=t.e;if(!c[0]||!f[0])return f[0]?t.s=-u:c[0]?t=new a(i):t.s=1,t;if(l=s-y){for((o=l<0)?(l=-l,n=c):(y=s,n=f),n.reverse(),u=l;u--;)n.push(0);n.reverse()}else for(e=((o=c.length<f.length)?c:f).length,l=u=0;u<e;u++)if(c[u]!=f[u]){o=c[u]<f[u];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(u=(e=f.length)-(r=c.length))>0)for(;u--;)c[r++]=0;for(u=r;e>l;){if(c[--e]<f[e]){for(r=e;r&&!c[--r];)c[r]=9;--c[r],c[e]+=10}c[e]-=f[e]}for(;0===c[--u];)c.pop();for(;0===c[0];)c.shift(),--y;return c[0]||(t.s=1,c=[y=0]),t.c=c,t.e=y,t},S.mod=function(t){var r,e=this,n=e.constructor,o=e.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(w);return e.s=t.s=1,r=1==t.cmp(e),e.s=o,t.s=i,r?new n(e):(o=n.DP,i=n.RM,n.DP=n.RM=0,e=e.div(t),n.DP=o,n.RM=i,this.minus(e.times(t)))},S.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},S.plus=S.add=function(t){var r,e,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var a=o.e,l=o.c,u=t.e,c=t.c;if(!l[0]||!c[0])return c[0]||(l[0]?t=new i(o):t.s=o.s),t;if(l=l.slice(),r=a-u){for(r>0?(u=a,n=c):(r=-r,n=l),n.reverse();r--;)n.push(0);n.reverse()}for(l.length-c.length<0&&(n=c,c=l,l=n),r=c.length,e=0;r;l[r]%=10)e=(l[--r]=l[r]+c[r]+e)/10|0;for(e&&(l.unshift(e),++u),r=l.length;0===l[--r];)l.pop();return t.c=l,t.e=u,t},S.pow=function(t){var r=this,e=new r.constructor("1"),n=e,o=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(m+"exponent");for(o&&(t=-t);1&t&&(n=n.times(r)),t>>=1;)r=r.times(r);return o?e.div(n):n},S.prec=function(t,r){if(t!==~~t||t<1||t>v)throw Error(m+"precision");return j(new this.constructor(this),t,r)},S.round=function(t,r){if(t===O)t=0;else if(t!==~~t||t<-v||t>v)throw Error(b);return j(new this.constructor(this),t+this.e+1,r)},S.sqrt=function(){var t,r,e,n=this,o=n.constructor,i=n.s,a=n.e,l=new o("0.5");if(!n.c[0])return new o(n);if(i<0)throw Error(d+"No square root");0===(i=Math.sqrt(n+""))||i===1/0?((r=n.c.join("")).length+a&1||(r+="0"),a=((a+1)/2|0)-(a<0||1&a),t=new o(((i=Math.sqrt(r))==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+a)):t=new o(i+""),a=t.e+(o.DP+=4);do{e=t,t=l.times(e.plus(n.div(e)))}while(e.c.slice(0,a).join("")!==t.c.slice(0,a).join(""));return j(t,(o.DP-=4)+t.e+1,o.RM)},S.times=S.mul=function(t){var r,e=this,n=e.constructor,o=e.c,i=(t=new n(t)).c,a=o.length,l=i.length,u=e.e,c=t.e;if(t.s=e.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=u+c,a<l&&(r=o,o=i,i=r,c=a,a=l,l=c),r=new Array(c=a+l);c--;)r[c]=0;for(u=l;u--;){for(l=0,c=a+u;c>u;)l=r[c]+i[u]*o[c-u-1]+l,r[c--]=l%10,l=l/10|0;r[c]=l}for(l?++t.e:r.shift(),u=r.length;!r[--u];)r.pop();return t.c=r,t},S.toExponential=function(t,r){var e=this,n=e.c[0];if(t!==O){if(t!==~~t||t<0||t>v)throw Error(b);for(e=j(new e.constructor(e),++t,r);e.c.length<t;)e.c.push(0)}return P(e,!0,!!n)},S.toFixed=function(t,r){var e=this,n=e.c[0];if(t!==O){if(t!==~~t||t<0||t>v)throw Error(b);for(t=t+(e=j(new e.constructor(e),t+e.e+1,r)).e+1;e.c.length<t;)e.c.push(0)}return P(e,!1,!!n)},S[Symbol.for("nodejs.util.inspect.custom")]=S.toJSON=S.toString=function(){var t=this,r=t.constructor;return P(t,t.e<=r.NE||t.e>=r.PE,!!t.c[0])},S.toNumber=function(){var t=Number(P(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(d+"Imprecise conversion");return t},S.toPrecision=function(t,r){var e=this,n=e.constructor,o=e.c[0];if(t!==O){if(t!==~~t||t<1||t>v)throw Error(m+"precision");for(e=j(new n(e),t,r);e.c.length<t;)e.c.push(0)}return P(e,t<=e.e||e.e<=n.NE||e.e>=n.PE,!!o)},S.valueOf=function(){var t=this,r=t.constructor;if(!0===r.strict)throw Error(d+"valueOf disallowed");return P(t,t.e<=r.NE||t.e>=r.PE,!0)},function t(){function r(e){var n=this;if(!(n instanceof r))return e===O?t():new r(e);if(e instanceof r)n.s=e.s,n.e=e.e,n.c=e.c.slice();else{if("string"!=typeof e){if(!0===r.strict&&"bigint"!=typeof e)throw TypeError(m+"value");e=0===e&&1/e<0?"-0":String(e)}!function(t,r){var e,n,o;if(!A.test(r))throw Error(m+"number");for(t.s="-"==r.charAt(0)?(r=r.slice(1),-1):1,(e=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(e<0&&(e=n),e+=+r.slice(n+1),r=r.substring(0,n)):e<0&&(e=r.length),o=r.length,n=0;n<o&&"0"==r.charAt(n);)++n;if(n==o)t.c=[t.e=0];else{for(;o>0&&"0"==r.charAt(--o););for(t.e=e-n-1,t.c=[],e=0;n<=o;)t.c[e++]=+r.charAt(n++)}}(n,e)}n.constructor=r}return r.prototype=S,r.DP=20,r.RM=1,r.NE=-7,r.PE=21,r.strict=!1,r.roundDown=0,r.roundHalfUp=1,r.roundHalfEven=2,r.roundUp=3,r}();var E=function(t){function r(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),t=function(t,r,e){return r=C(r),function(t,r){if(r&&("object"==N(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_()?Reflect.construct(r,e||[],C(t).constructor):r.apply(t,e))}(this,r,[e]),Object.setPrototypeOf(t,(this instanceof r?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&k(t,r)}(r,t),e=r,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}(x(Error));function T(t){return T="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(t)}function I(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,R(n.key),n)}}function M(t,r,e){return(r=R(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function R(t){var r=function(t,r){if("object"!=T(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==T(r)?r:r+""}var D=function(){return t=function t(){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),M(this,"previousHighest",void 0),M(this,"highest",void 0),M(this,"previousLowest",void 0),M(this,"lowest",void 0),M(this,"previousResult",void 0),M(this,"result",void 0)},(r=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new E;return this.result}},{key:"setResult",value:function(t,r){return r&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&I(t.prototype,r),e&&I(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function F(t){return F="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},F(t)}function L(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,K(n.key),n)}}function z(t,r,e){return r=U(r),function(t,r){if(r&&("object"==F(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Y()?Reflect.construct(r,e||[],U(t).constructor):r.apply(t,e))}function Y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Y=function(){return!!t})()}function U(t){return U=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},U(t)}function G(t,r){return G=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},G(t,r)}function K(t){var r=function(t,r){if("object"!=F(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=F(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==F(r)?r:r+""}var V=function(t){function r(t){var e,n,o,i;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),n=e=z(this,r),i=void 0,(o=K(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,e.interval=t,e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&G(t,r)}(r,t),e=r,(n=[{key:"updates",value:function(t){var r=this;return t.forEach((function(t){return r.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&L(e.prototype,n),o&&L(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(D);function H(t){return H="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},H(t)}function $(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,W(n.key),n)}}function q(t,r,e){return r=J(r),function(t,r){if(r&&("object"==H(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,B()?Reflect.construct(r,e||[],J(t).constructor):r.apply(t,e))}function B(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(B=function(){return!!t})()}function J(t){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},J(t)}function X(t,r){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},X(t,r)}function W(t){var r=function(t,r){if("object"!=H(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=H(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==H(r)?r:r+""}var Z=function(t){function r(){var t,e,n,o;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);for(var i=arguments.length,a=new Array(i),l=0;l<i;l++)a[l]=arguments[l];return e=t=q(this,r,[].concat(a)),o=[],(n=W(n="prices"))in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&X(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var e=this.prices.reduce((function(t,r){return t+r}),0);return this.setResult(e/this.prices.length,r)}}}],n&&$(e.prototype,n),o&&$(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(V);function Q(t){return Q="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},Q(t)}function tt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,at(n.key),n)}}function rt(t,r,e){return r=nt(r),function(t,r){if(r&&("object"==Q(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,et()?Reflect.construct(r,e||[],nt(t).constructor):r.apply(t,e))}function et(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(et=function(){return!!t})()}function nt(t){return nt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},nt(t)}function ot(t,r){return ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ot(t,r)}function it(t,r,e){return(r=at(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function at(t){var r=function(t,r){if("object"!=Q(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Q(r)?r:r+""}var lt=function(t){function r(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),it(e=rt(this,r),"interval",void 0),it(e,"indicator",void 0),it(e,"smoothingFactor",void 0),e.interval=t,e.indicator=new Z(t),e.smoothingFactor=1/e.interval,e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&ot(t,r)}(r,t),e=r,n=[{key:"updates",value:function(t){var r=this;return t.forEach((function(t){return r.update(t)})),this.result}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=this.indicator.update(t);if(r&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,r)}if(!r&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,r)}if(void 0===this.result&&void 0!==e)return this.setResult(e,r)}}],n&&tt(e.prototype,n),o&&tt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(D);function ut(t){return t.length?t.reduce((function(t,r){return t+r}),0)/t.length:0}function ct(t){return ct="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},ct(t)}function st(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,dt(n.key),n)}}function ft(t,r,e){return r=pt(r),function(t,r){if(r&&("object"==ct(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,yt()?Reflect.construct(r,e||[],pt(t).constructor):r.apply(t,e))}function yt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(yt=function(){return!!t})()}function pt(t){return pt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},pt(t)}function ht(t,r){return ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ht(t,r)}function vt(t,r,e){return(r=dt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function dt(t){var r=function(t,r){if("object"!=ct(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ct(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ct(r)?r:r+""}var mt=function(t){function r(){var t;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];return vt(t=ft(this,r,[].concat(n)),"previousCandle",void 0),vt(t,"twoPreviousCandle",void 0),t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&ht(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=t.high,n=t.low,o=e-n;if(this.previousCandle&&r&&(this.previousCandle=this.twoPreviousCandle),this.previousCandle){var i=Math.abs(e-this.previousCandle.close),a=Math.abs(n-this.previousCandle.close);return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(Math.max(o,i,a),r)}return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(o,r)}}],n&&st(e.prototype,n),o&&st(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(D);function bt(t){return bt="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},bt(t)}function gt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Pt(n.key),n)}}function wt(t,r,e){return r=Ot(r),function(t,r){if(r&&("object"==bt(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,St()?Reflect.construct(r,e||[],Ot(t).constructor):r.apply(t,e))}function St(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(St=function(){return!!t})()}function Ot(t){return Ot=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ot(t)}function At(t,r){return At=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},At(t,r)}function jt(t,r,e){return(r=Pt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Pt(t){var r=function(t,r){if("object"!=bt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bt(r)?r:r+""}var Nt=function(t){function r(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:lt;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),jt(e=wt(this,r),"interval",void 0),jt(e,"tr",void 0),jt(e,"smoothing",void 0),e.interval=t,e.tr=new mt,e.smoothing=new n(t),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&At(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=this.tr.update(t,r);if(this.smoothing.update(e,r),this.smoothing.isStable)return this.setResult(this.smoothing.getResult(),r)}}],n&&gt(e.prototype,n),o&&gt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(D);function xt(t){return xt="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},xt(t)}function _t(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ct(n.key),n)}}function kt(t,r,e){return(r=Ct(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Ct(t){var r=function(t,r){if("object"!=xt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=xt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xt(r)?r:r+""}var Et=function(){return t=function t(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),kt(this,"interval",void 0),kt(this,"deviationMultiplier",void 0),kt(this,"prices",[]),kt(this,"result",void 0),this.interval=r,this.deviationMultiplier=e},(r=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var r=ut(this.prices),e=function(t,r){var e=r||ut(t),n=ut(t.map((function(t){return t-e})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,r);return this.result={lower:r-e*this.deviationMultiplier,middle:r,upper:r+e*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new E;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&_t(t.prototype,r),e&&_t(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function Tt(t){return Tt="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},Tt(t)}function It(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,zt(n.key),n)}}function Mt(t,r,e){return r=Dt(r),function(t,r){if(r&&("object"==Tt(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Rt()?Reflect.construct(r,e||[],Dt(t).constructor):r.apply(t,e))}function Rt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Rt=function(){return!!t})()}function Dt(t){return Dt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Dt(t)}function Ft(t,r){return Ft=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Ft(t,r)}function Lt(t,r,e){return(r=zt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function zt(t){var r=function(t,r){if("object"!=Tt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Tt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tt(r)?r:r+""}var Yt=function(t){function r(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),Lt(e=Mt(this,r,[t]),"interval",void 0),Lt(e,"pricesCounter",0),Lt(e,"weightFactor",void 0),e.interval=t,e.weightFactor=2/(e.interval+1),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Ft(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return r?r&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,r&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),r):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),r)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new E;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&It(e.prototype,n),o&&It(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(V);function Ut(t){return Ut="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},Ut(t)}function Gt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Vt(n.key),n)}}function Kt(t,r,e){return(r=Vt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Vt(t){var r=function(t,r){if("object"!=Ut(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ut(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ut(r)?r:r+""}var Ht=function(){return t=function t(r,e,n){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),Kt(this,"short",void 0),Kt(this,"long",void 0),Kt(this,"signal",void 0),Kt(this,"prices",[]),Kt(this,"result",void 0),this.short=r,this.long=e,this.signal=n},r=[{key:"getResult",value:function(){if(void 0===this.result)throw new E;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t);var e=this.short.update(t,r),n=this.long.update(t,r);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=e-n,i=this.signal.update(o,r);return this.result={histogram:o-i,macd:o,signal:i}}}}],r&&Gt(t.prototype,r),e&&Gt(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function $t(t){return $t="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(t)}function qt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Qt(n.key),n)}}function Bt(t,r,e){return r=Xt(r),function(t,r){if(r&&("object"==$t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Jt()?Reflect.construct(r,e||[],Xt(t).constructor):r.apply(t,e))}function Jt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Jt=function(){return!!t})()}function Xt(t){return Xt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Xt(t)}function Wt(t,r){return Wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Wt(t,r)}function Zt(t,r,e){return(r=Qt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Qt(t){var r=function(t,r){if("object"!=$t(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=$t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$t(r)?r:r+""}var tr=function(t){function r(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:lt;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),Zt(e=Bt(this,r),"interval",void 0),Zt(e,"previousPrices",[]),Zt(e,"avgGain",void 0),Zt(e,"avgLoss",void 0),Zt(e,"maxValue",100),e.interval=t,e.avgGain=new n(e.interval),e.avgLoss=new n(e.interval),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Wt(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&r?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var e=t,n=this.previousPrices[this.previousPrices.length-2];if(e>n?(this.avgLoss.update(0,r),this.avgGain.update(t-n,r)):(this.avgLoss.update(n-e,r),this.avgGain.update(0,r)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,r);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),r)}}}}],n&&qt(e.prototype,n),o&&qt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(D);function rr(t){return rr="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},rr(t)}function er(t){return function(t){if(Array.isArray(t))return nr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return nr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?nr(t,r):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function nr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function or(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ar(n.key),n)}}function ir(t,r,e){return(r=ar(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function ar(t){var r=function(t,r){if("object"!=rr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=rr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rr(r)?r:r+""}var lr=function(){return t=function t(r,e,n){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),ir(this,"n",void 0),ir(this,"m",void 0),ir(this,"p",void 0),ir(this,"candles",[]),ir(this,"result",void 0),ir(this,"periodM",void 0),ir(this,"periodP",void 0),this.n=r,this.m=e,this.p=n,this.periodM=new Z(e),this.periodP=new Z(n)},(r=[{key:"getResult",value:function(){if(void 0===this.result)throw new E;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){if(this.candles.push(t),this.candles.length>this.n&&this.candles.shift(),this.candles.length===this.n){var r=Math.max.apply(Math,er(this.candles.map((function(t){return t.high})))),e=Math.min.apply(Math,er(this.candles.map((function(t){return t.low})))),n=r-e,o=100*(t.close-e);o/=0===n?1:n;var i=this.periodM.update(o),a=i&&this.periodP.update(i);if(void 0!==i&&void 0!==a)return this.result={stochD:a,stochK:i}}}}])&&or(t.prototype,r),e&&or(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function ur(t){return ur="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},ur(t)}function cr(t){return function(t){if(Array.isArray(t))return fr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||sr(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sr(t,r){if(t){if("string"==typeof t)return fr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?fr(t,r):void 0}}function fr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function yr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=ur(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ur(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ur(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function pr(t){return pr="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},pr(t)}function hr(t){return function(t){if(Array.isArray(t))return dr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||vr(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function vr(t,r){if(t){if("string"==typeof t)return dr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?dr(t,r):void 0}}function dr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function mr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=pr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=pr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pr(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}var br={ema:Yt,sma:Z},gr=function(t,r,e,n,o){var i=o.target,a=o.lag,l=t.verticalOhlcv,u=t.instances,c="close"!==i?"_".concat(i):"",s="".concat(e,"_").concat(n).concat(c);if(0===r){var f=t.arrayTypes,y=t.len;if(!l.hasOwnProperty(i))throw new Error("Target property ".concat(i," not found in verticalOhlcv for ").concat(e,"."));u[s]=new br[e](n),l[s]=new Float64Array(y).fill(NaN),a>0&&t.lag([s],a),f[s]="Float64Array"}var p=l[i][r],h=u[s];h.update(p);var v=NaN;try{v=h.getResult()}catch(t){}return t.pushToMain({index:r,key:s,value:v}),!0};function wr(t){return wr="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},wr(t)}function Sr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=wr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=wr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wr(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Or(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ar="close";function jr(t){return jr="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},jr(t)}var Pr={number:function(t){return t},numberCleanString:function(t){return Number(t)},numberDirtyString:function(t){return Number(t.replace(/(?!^-)[^0-9.]/g,""))}},Nr=function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"==typeof t&&!Number.isNaN(t))return"number";if("string"==typeof t){var e=t.trim(),n=/^-?\d+(\.\d+)?$/;if(n.test(e))return"numberCleanString";var o=e.replace(/[^0-9.]/g,"");if(o&&n.test(o))return"numberDirtyString"}if(r)throw new TypeError("Invalid input: expected a number or numeric string");return jr(t)},xr=function(t,r){var e=Math.pow(10,r);return Math.round((t+Number.EPSILON)*e)/e};function _r(t){return function(t){if(Array.isArray(t))return Cr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||kr(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function kr(t,r){if(t){if("string"==typeof t)return Cr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Cr(t,r):void 0}}function Cr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Er(t){return Er="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},Er(t)}function Tr(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function Ir(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=Er(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Er(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Er(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Mr(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Rr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Rr(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function Rr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Dr="close";function Fr(t){return Fr="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},Fr(t)}function Lr(t){return Lr="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},Lr(t)}var zr={string:function(t){return t.toISOString()},milliseconds:function(t){return t.getTime()},seconds:function(t){return t.getTime()/1e3},object:function(t){return t}},Yr={dateObject:function(t){return t},dateMilliseconds:function(t){return new Date(t)},dateSeconds:function(t){return new Date(1e3*t)},dateIncompleteDayString:function(t){return new Date("".concat(t," 00:00:00"))},dateCompleteDateString:function(t){return new Date(t)}},Ur=function(t){var r=["Date -> object","Milliseconds Timestamp -> integer","Seconds Timestamp -> integer","UTC Time Format (ISO 8601) -> string","Including a Timezone Offset (ISO 8601) -> string","Local Time Format (ISO 8601) -> string","YYYY/MM/DD or YYYY-MM-DD -> string"],e=function(){throw new Error('Invalid "'.concat(Lr(t),'" date value passed in selectDateFormatter. Supported formats: \n-').concat(r.join("\n- ")))};if("object"===Lr(t)){if(t instanceof Date&&!isNaN(t.valueOf()))return"dateObject";e()}else{if("number"==typeof t)return Math.abs(t)<1e11?"dateSeconds":"dateMillseconds";if("string"==typeof t){if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/i.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?([+-]\d{2}:\d{2})$/.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(t)&&t.length>10||/^\d{4}\/\d{2}\/\d{2}$/.test(t))return"dateCompleteDateString";if(/^\d{4}-\d{2}-\d{2}$/.test(t))return"dateIncompleteDayString";e()}else e()}};function Gr(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||function(t,r){if(t){if("string"==typeof t)return Kr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Kr(t,r):void 0}}(t,r)||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.")}()}function Kr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Vr=new Set(["open","high","low","close"]),Hr=function(t,r){var e={Array,Float64Array,Float32Array,Int32Array,Uint8Array,Int8Array,Int16Array}[t];if(!e||"function"!=typeof e.from)throw new Error("Unsupported array type: ".concat(t));var n="Array"===t?null:NaN;return e.from({length:r},(function(){return n}))};function $r(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return qr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?qr(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function qr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Br(t){return function(t){if(Array.isArray(t))return Xr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Jr(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jr(t,r){if(t){if("string"==typeof t)return Xr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Xr(t,r):void 0}}function Xr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Wr=function(t,r){var e=new Uint8Array(r);return e[t]=1,e},Zr=function(t){var r=t.featureCols,e=t.flatFeaturesColLen,n=t.type,o=t.trainingSize,i=r.length!==e?" (including flat one-hot encoded array values) ":"";console.log('---\nInitialized "'.concat(n,'" with ').concat(e," features ").concat(i," and ").concat(o," rows: \n").concat(JSON.stringify(r),"\n\n"))},Qr=function(t,r,e,n){var o,i,a=(i=2,function(t){if(Array.isArray(t))return t}(o=n)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(o,i)||Jr(o,i)||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.")}()),l=a[0],u=a[1];return(Math.min(Math.max(t,r),e)-r)/(e-r)*(u-l)+l},te=function(t,r){var e=[];if(t.length>0)for(var n=0;n<t.length;n++){var o=t[n],i=o.type,a=o.size,l=void 0===a?null:a,u=o.groupName,c=void 0===u?null:u,s=null!==l?"".concat(i,"_").concat(l):"".concat(i,"_").concat(c);if(!r.hasOwnProperty(s))throw new Error("Scaled group (".concat(s,") not found for regressor.options.findGroups[").concat(n,"]: ").concat(JSON.stringify(o)));e.push.apply(e,Br(r[s]))}return e},re=function(t,r,e){var n,o=0,i=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Jr(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(t);try{for(i.s();!(n=i.n()).done;){var a=n.value;if(!r.hasOwnProperty(a))throw new Error('Property "'.concat(a,'" not found in "verticalOhlcv".'));var l=r[a][e];if(null==l||Number.isNaN(l))throw new Error('Invalid value of property "'.concat(a,'".'));a.startsWith("one_hot_")||a.startsWith("pca_")?o+=r[a][e].length:o+=1}}catch(t){i.e(t)}finally{i.f()}return o},ee=function(t){var r=Array.isArray(t[0])?t:t.map((function(t){return[t]})),e=r[0].length;return Array.from({length:e}).reduce((function(t,e,n){return t+new Set(r.map((function(t){return t[n]}))).size}),0)+1},ne=function(t){var r=t.trainingCols,e=t.findGroups,n=t.verticalOhlcv,o=t.scaledGroups,i=[].concat(Br(r),Br(te(e,o)));if(0===i.length)return[];for(var a=!1,l=0;l<i.length;l++){var u=i[l];if(!n.hasOwnProperty(u)){a=!0;break}}return a?[]:i},oe=function(t){var r=t.metrics,e=t.trueLabel,n=t.predictedLabel;r.total=(r.total||0)+1,r.correct=r.correct||0,r.labels=r.labels||{};var o=n.toString();for(var i in r.labels[o]||(r.labels[o]={total:0,correct:0,accuracy:0}),r.labels[o].total++,n===e&&(r.correct++,r.labels[o].correct++),r.accuracy=r.correct/r.total,r.labels){var a=r.labels[i];a.accuracy=a.correct/a.total}};function ie(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function ae(t){return ae="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},ae(t)}function le(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ue(n.key),n)}}function ue(t){var r=function(t,r){if("object"!=ae(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ae(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ae(r)?r:r+""}var ce=function(t,r){return t>r},se=function(t,r){return t<r},fe=function(){return t=function t(){!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,{interval:0,prevState:.5,prevFast:NaN,prevSlow:NaN,prevHigh:NaN,prevLow:NaN,areHighAndLowUndefined:!1,crossIndexes:{up:[],down:[]}})},(r=[{key:"update",value:function(t,r){var e=r.fast,n=r.high,o=r.slow,i=r.low,a=this.prevState;this.areHighAndLowUndefined||void 0!==n&&void 0!==i||(this.areHighAndLowUndefined=!0),Number.isNaN(e)||Number.isNaN(o)||function(t,r){return t===r}(e,o)?a=.5:ce(e,o)?a=this.areHighAndLowUndefined?1:[i,o,this.prevLow,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&se(i,o)&&ce(this.prevLow,this.prevSlow)?0:1:se(e,o)&&(a=this.areHighAndLowUndefined?0:[n,o,this.prevHigh,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&ce(n,o)&&se(this.prevHigh,this.prevSlow)?1:0),.5===a?this.interval=0:1===a?this.prevState<=.5?this.interval=1:this.interval++:0===a&&(this.prevState>=.5?this.interval=-1:this.interval--),1===this.interval&&this.crossIndexes.up.push(t),-1===this.interval&&this.crossIndexes.down.push(t),Object.assign(this,{prevState:a,prevFast:e,prevSlow:o,prevHigh:n,prevLow:i})}},{key:"getResult",value:function(){return this.interval}}])&&le(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}();function ye(t){return ye="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},ye(t)}function pe(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||me(t,r)||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.")}()}function he(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function ve(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?he(Object(e),!0).forEach((function(r){de(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):he(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function de(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=ye(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ye(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ye(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function me(t,r){if(t){if("string"==typeof t)return be(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?be(t,r):void 0}}function be(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function ge(t){return function(t){if(Array.isArray(t))return Se(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||we(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function we(t,r){if(t){if("string"==typeof t)return Se(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Se(t,r):void 0}}function Se(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Oe(t,r){if(t){if("string"==typeof t)return Ae(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ae(t,r):void 0}}function Ae(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var je=function(t){var r=t.main,e=t.index,n=r.verticalOhlcv,o=n.close[e],i=n.close[e-1];return void 0===i?null:{change:(o-i)/i}};function Pe(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ne=function(t){var r,e=t.featureCols,n=t.flatFeaturesColLen,o=t.type,i=t.index,a=t.lookbackAbs,l=t.main.verticalOhlcv,u=!1,c=[],s=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Pe(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Pe(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(e);try{for(s.s();!(r=s.n()).done;){var f=r.value;if(f.startsWith("one_hot_")||f.startsWith("pca_"))for(var y=l[f][i].length,p=0;p<y;p++)c.push({key:f,bit:p});else c.push({key:f})}}catch(t){s.e(t)}finally{s.f()}if(c.length!==n)throw new Error("slots (".concat(c.length,") ≠ flatFeaturesColLen (").concat(n,") in ").concat(o," index ").concat(i));for(var h=new Array(n*a).fill(NaN),v=0;v<a;v++){for(var d=i-v,m=0;m<c.length;m++){var b=c[m],g=b.key,w=b.bit,S=l[g][d],O=null!=w?S[w]:S;if(!Number.isFinite(O)){u=!0;break}h[v*n+m]=O}if(u)break}return u?null:h};function xe(t){return function(t){if(Array.isArray(t))return ke(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_e(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _e(t,r){if(t){if("string"==typeof t)return ke(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?ke(t,r):void 0}}function ke(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ce="pca",Ee=function(t,r,n){var o=n.prefix,i=n.trainingSize,a=n.findGroups,l=n.trainingCols,u=n.lookbackAbs,c=n.modelArgs,s=n.filterCallback,f=t.verticalOhlcv,y=t.scaledGroups,p=t.len,h=t.instances,v=t.ML,d=t.invalidValueIndex+2,m=v.models;if(r===d)h.hasOwnProperty(Ce)||(h[Ce]={}),h[Ce][o]={flatFeaturesColLen:0,featureCols:[],X:[]},f[o]=new Array(p).fill(null),t.notNumberKeys.add(o);else{if(r<d||r<u)return;if(!1===s(f,r))return;if(r+1===p){if(0===h[Ce][o].featureCols.length){var b=[].concat(xe(l),xe(te(a,y)));throw new Error("Some of the provided features in ".concat(o,' features where not found in "verticalOhlcv": ').concat(JSON.stringify(b)))}var g,w=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=_e(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(h[Ce][o].featureCols);try{for(w.s();!(g=w.n()).done;){var S=g.value;if(!f.hasOwnProperty(S))throw new Error('Feature "'.concat(S,'" not found in verticalOhlcv for pca.'))}}catch(t){w.e(t)}finally{w.f()}if(h[Ce][o].X.length<i){var O=h[Ce][o].X.length-i;throw new Error('The current "trainingSize" at "'.concat(o,'" requires at least ').concat(O,' more datapoints. Try adding more input ohlcv rows or reducing the "trainingSize" by ').concat(O,"."))}}}var A=h[Ce][o];if(0===A.flatFeaturesColLen){if(A.featureCols=ne({trainingCols:l,findGroups:a,verticalOhlcv:f,scaledGroups:y}),!e(t,r,A.featureCols))return;A.flatFeaturesColLen=re(A.featureCols,f,r)}if(0!==A.flatFeaturesColLen){var j=A.X,P=A.featureCols,N=A.flatFeaturesColLen,x=Ne({featureCols:P,flatFeaturesColLen:N,type:Ce,index:r,lookbackAbs:u,main:t});if(null!=x){if(m.hasOwnProperty(o)){var _=m[o].predict([x]).to2DArray();f[o][r]=_[0]}j.push(x),j.length>i&&j.shift(),j.length===i&&(m[o]=new v.classes.PCA(j,c))}}};function Te(t){return Te="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},Te(t)}function Ie(t){return function(t){if(Array.isArray(t))return Re(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Me(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Me(t,r){if(t){if("string"==typeof t)return Re(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Re(t,r):void 0}}function Re(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var De=function(t,r,n,o){var i=o.target,a=o.predictions,l=o.retrain,u=o.trainingCols,c=o.findGroups,s=o.type,f=o.modelArgs,y=o.precompute,p=o.filterCallback,h=o.modelConfig,v=o.modelClass,d=y.lookbackAbs,m=y.prefix,b=y.flatX,g=y.flatY,w=t.verticalOhlcv,S=t.len,O=t.instances,A=t.scaledGroups,j=t.invalidValueIndex,P=t.ML.models,N=j+1;if(r===N){O.hasOwnProperty("regressor")||(O.regressor={}),O.regressor.hasOwnProperty(m)||(O.regressor[m]={});var x=g?a:1;O.regressor[m]={expectedLoops:x,trainingSize:n,isTrained:new Array(x).fill(!1),shouldRetrain:l,featureCols:[],flatFeaturesColLen:0,X:[],Y:Array.from({length:x},(function(){return[]}))};for(var _=0;_<a;_++){var k="".concat(m,"_").concat(_+1);w[k]=new Float64Array(S).fill(NaN),P.hasOwnProperty(k)||(P[k]=[])}}else{if(r<N||r<d)return;if(!1===p(w,r))return;if(r+1===S){if(0===O.regressor[m].featureCols.length){var C=[].concat(Ie(u),Ie(te(c,A)));throw new Error("Some of the provided features in ".concat(m,' features where not found in "verticalOhlcv": ').concat(JSON.stringify(C)))}var E,T=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Me(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(O.regressor[m].featureCols);try{for(T.s();!(E=T.n()).done;){var I=E.value;if(!w.hasOwnProperty(I))throw new Error('Feature "'.concat(I,'" not found in verticalOhlcv for ').concat(m,"."))}}catch(t){T.e(t)}finally{T.f()}if(O.regressor[m].X.length<n){var M=O.regressor[m].X.length-n;throw new Error('The current "trainingSize" at "'.concat(m,'" requires at least ').concat(M,' more datapoints. Try adding more input ohlcv rows or reducing the "trainingSize" by ').concat(M,"."))}}}var R=O.regressor[m];if(0===R.flatFeaturesColLen){if(R.featureCols=ne({trainingCols:u,findGroups:c,verticalOhlcv:w,scaledGroups:A}),!e(t,r,R.featureCols))return;R.flatFeaturesColLen=re(R.featureCols,w,r),Zr({featureCols:R.featureCols,flatFeaturesColLen:R.flatFeaturesColLen,type:s,trainingSize:n})}if(0!==R.flatFeaturesColLen){if(!w.hasOwnProperty(i))throw new Error('Target property "'.concat(i,'" not found in verticalOhlcv for regressor.'));var D=R.expectedLoops,F=R.X,L=R.Y,z=R.flatFeaturesColLen,Y=R.featureCols,U=R.shouldRetrain;if(!Y.includes(i))throw new Error('Target property "'.concat(i,'" not found in ').concat(s," features: ").concat(JSON.stringify(Y)));var G=b?w[i][r]:Ne({featureCols:Y,flatFeaturesColLen:z,type:s,index:r,lookbackAbs:d,main:t});if(b){if(!Number.isFinite(G))return}else if(null==G)return;for(var K=[],V=0;V<a;V++){var H=w[i][r+V+1];if(!Number.isFinite(H))break;K.push(H)}for(var $=h.train,q=h.unsupervised,B=0;B<D;B++){var J="".concat(m,"_").concat(B+1),X=L[B],W=g?void 0===K[B]?null:K[B]:K,Z=R.isTrained[B];if(P.hasOwnProperty(J)&&Z&&P[J].length===D){var Q=P[J][0],tt=q?Q.predict(a)[0]:Q.predict([G])[0];if(g){if(Number.isNaN(tt))throw new Error("Prediction of ".concat(s," at index ").concat(r," was expecting a number."));t.pushToMain({index:r,key:J,value:tt})}else{if(!Array.isArray(tt)||tt.length!==a)throw new Error('Prediction output of "'.concat(s,'" at index ').concat(r," was expecting an array of values."));for(var rt=0;rt<a;rt++)t.pushToMain({index:r,key:"".concat(m,"_").concat(rt+1),value:tt[rt]})}}if(!(r+a+1>S||K.length<a||null===W)){if(g){if("number"!=typeof W||Number.isNaN(W))throw new Error("currTrainY must return number, got ".concat(Te(W)," at index ").concat(r))}else{if(!Array.isArray(W))throw new Error("currTrainY must return an array, got ".concat(Te(W)," at index ").concat(r));if(W.length!==a)throw new Error("currTrainY length (".concat(W.length,') ≠ "options.predictions" (').concat(a,') for regressor "').concat(s,'"'))}if(X.push(W),X.length>n&&X.shift(),0===B&&(F.push(G),F.length>n&&F.shift()),(U||!Z)&&F.length===n&&X.length===n){var et=$({modelClass:v,xRows:F,yRows:X,modelArgs:f,uniqueLabels:0});q?P[J]=[et]:(P[J].push(et),P[J].length>a&&P[J].shift()),R.isTrained[B]=!0}}}}};function Fe(t){return Fe="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},Fe(t)}function Le(t){return function(t){if(Array.isArray(t))return Ye(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ze(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ze(t,r){if(t){if("string"==typeof t)return Ye(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ye(t,r):void 0}}function Ye(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ue="classifier",Ge=function(t,r,n,o){var i=o.yCallback,a=o.trainingCols,l=o.findGroups,u=void 0===l?[]:l,c=o.retrain,s=o.type,f=o.modelArgs,y=o.horizon,p=o.precompute,h=o.predictions,v=o.filterCallback,d=o.modelConfig,m=o.modelClass,b=p.lookbackAbs,g=p.prefix,w=p.flatY,S=t.verticalOhlcv,O=t.len,A=t.instances,j=t.scaledGroups,P=t.invalidValueIndex,N=t.ML,x=N.models,_=P+1;if(r===_){A.hasOwnProperty(Ue)||(A[Ue]={}),A[Ue].hasOwnProperty(g)||(A[Ue][g]={});var k=w?h:1;A[Ue][g]={expectedLoops:k,isTrained:new Array(k).fill(!1),uniqueLabels:new Array(k).fill(0),shouldRetrain:c,featureCols:[],flatFeaturesColLen:0,X:[],Y:Array.from({length:k},(function(){return[]}))};for(var C=0;C<h;C++){var E="".concat(g,"_").concat(C+1);S[E]="KNN"===s?new Array(O).fill(null):new Float32Array(O).fill(NaN),N.metrics[E]={accuracy:{},total:0,correct:0,labels:{}},x.hasOwnProperty(E)||(x[E]=[])}}else{if(r<_||r<b)return;if(!1===v(S,r))return;if(r+1===O){if(0===A[Ue][g].featureCols.length){var T=[].concat(Le(a),Le(te(u,j)));throw new Error("Some of the provided features in ".concat(Ue,' "').concat(g,'" features where not found in "verticalOhlcv": ').concat(JSON.stringify(T)))}var I,M=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=ze(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(A[Ue][g].featureCols);try{for(M.s();!(I=M.n()).done;){var R=I.value;if(!S.hasOwnProperty(R))throw new Error('Feature "'.concat(R,'" not found in verticalOhlcv for ').concat(g,"."))}}catch(t){M.e(t)}finally{M.f()}if(A[Ue][g].X.length<n){var D=A[Ue][g].X.length-n;throw new Error('The current "trainingSize" at '.concat(Ue,' "').concat(g,'" requires at least ').concat(D,' more datapoints. Try adding more input ohlcv rows or reducing the "trainingSize" by ').concat(D,"."))}}}var F=A[Ue][g];if(0===F.flatFeaturesColLen){if(F.featureCols=ne({trainingCols:a,findGroups:u,verticalOhlcv:S,scaledGroups:j}),!e(t,r,F.featureCols))return;F.flatFeaturesColLen=re(F.featureCols,S,r),Zr({featureCols:F.featureCols,flatFeaturesColLen:F.flatFeaturesColLen,type:s,trainingSize:n})}if(0!==F.flatFeaturesColLen){var L=F.uniqueLabels,z=F.expectedLoops,Y=F.featureCols,U=F.flatFeaturesColLen,G=F.shouldRetrain,K=F.X,V=Ne({featureCols:Y,flatFeaturesColLen:U,type:s,index:r,lookbackAbs:b,main:t});if(V){var H=i(r,S,y);if(null!==H&&(!Array.isArray(H)||H.length!==h))throw new Error("trainY must be null or an array with ".concat(h,' items, got "').concat(JSON.stringify(H),'" at index ').concat(r," for ").concat(s));for(var $=0;$<z;$++){var q="".concat(g,"_").concat($+1),B=F.Y[$],J=w?null===H?null:H[$]:H,X=F.isTrained[$];if(x.hasOwnProperty(q)&&X&&(!1===G||x[q].length===y)){var W=x[q][0].predict([V])[0];if(w){if(null==W)throw new Error("Prediction of ".concat(g," at index ").concat(r," was expecting a number."));t.pushToMain({index:r,key:q,value:W}),null!=J&&oe({metrics:N.metrics[q],trueLabel:J,predictedLabel:W})}else{if(!Array.isArray(W)||W.length!==h)throw new Error("Prediction output of ".concat(Ue,' "').concat(g,'" at index ').concat(r," was expecting an array of values."));for(var Z=0;Z<h;Z++)t.pushToMain({index:r,key:"".concat(g,"_").concat(Z+1),value:W[Z]}),Array.isArray(J)&&J.length===h&&oe({metrics:N.metrics["".concat(g,"_").concat(Z+1)],trueLabel:J[Z],predictedLabel:W[Z]})}}if(!(r+h+1>O)&&null!==J){if(w){if(void 0===J||null==J)throw new Error("currTrainY must return number, string or boolean got ".concat(Fe(J)," at index ").concat(r))}else if(J.length!==h)throw new Error("The number of label columns returned (".concat(J.length,") doesn’t match the options.predictions (").concat(h,") setting for the ").concat(Ue,' "').concat(g,'" classifier. ')+"Please update your yCallback function so its output array items align with options.predictions.");if(B.push(J),B.length>n&&B.shift(),0===$&&(K.push(V),K.length>n&&K.shift()),(G||!X)&&K.length===n&&B.length===n){if(!1===X&&(L[$]=ee(B),L[$]<2))throw new Error("Invalid number or labels in ".concat(g,'. Check the logic of your "yCallback" function.'));var Q=(0,d.train)({modelClass:m,xRows:K,yRows:B,modelArgs:f,uniqueLabels:L[$]});x[q].push(Q),x[q].length>y&&x[q].shift(),F.isTrained[$]=!0}}}return!0}}};function Ke(t){return function(t){if(Array.isArray(t))return qe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||$e(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ve(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=$e(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function He(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||$e(t,r)||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.")}()}function $e(t,r){if(t){if("string"==typeof t)return qe(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?qe(t,r):void 0}}function qe(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Be={dateTime:function(t,r,e){var n,o=e.lag,i=e.oneHot,a=e.precompute,l=t.instances,u=t.verticalOhlcv,c=t.notNumberKeys,s=a.prefix;if(0===r){var f=t.len,y=t.dateType,p=t.arrayTypes;if(!y)throw Error('dateTime method found and invalid "date" in input ohlcv');var h=u.date[0].getUTCFullYear(),v=(new Date).getUTCFullYear();Object.assign(l,{dateTime:{colKeys:[].concat((n=a.colKeys,function(t){if(Array.isArray(t))return be(t)}(n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||me(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),["".concat(s,"year")]),colKeySizes:ve(ve({},a.colKeySizes),{},de({},"".concat(s,"year"),v-h+1)),startYear:h}});var d,m=l.dateTime.colKeys,b=i?Array:Int16Array,g=i?null:NaN,w=i?"Array":"Int16Array",S=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=me(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(m);try{for(S.s();!(d=S.n()).done;){var O=d.value;p[O]=w,u[O]=new b(f).fill(g),c.add(O)}}catch(t){S.e(t)}finally{S.f()}o>0&&t.lag(m,o)}for(var A=l.dateTime,j=A.colKeySizes,P=A.startYear,N=function(t,r,e,n,o){for(var i=function(t,e){return r?Wr(t,e):t},a=de(de(de(de(de(de({},"".concat(n,"year"),t.getUTCFullYear()),"".concat(n,"month"),t.getUTCMonth()),"".concat(n,"hour"),t.getUTCHours()),"".concat(n,"minute"),t.getUTCMinutes()),"".concat(n,"day_of_the_week"),t.getUTCDay()),"".concat(n,"day_of_the_month"),t.getUTCDate()-1),l=0,u=Object.entries(e);l<u.length;l++){var c=pe(u[l],2),s=c[0],f=c[1],y=s==="".concat(n,"year")?a[s]-o:a[s];a[s]=i(y,f)}return a}(u.date[r],i,j,s,P),x=0,_=Object.entries(N);x<_.length;x++){var k=pe(_[x],2),C=k[0],E=k[1];t.pushToMain({index:r,key:C,value:E})}},rsi:function(t,r,e,n){var o=n.target,i=n.lag,a=n.parser,l=n.prefix,u=n.minmax,c=t.verticalOhlcv,s=t.instances,f="close"===o?"":"_".concat(o),y="".concat(l,"rsi_").concat(e).concat(f),p="".concat(l,"rsi_sma_").concat(e).concat(f);if(0===r){var h=t.len,v=t.arrayTypes;if(!c.hasOwnProperty(o))throw new Error("Target property ".concat(o," not found in verticalOhlcv for rsi."));Object.assign(s,yr(yr({},y,new tr(e)),p,new Z(e))),Object.assign(c,yr(yr({},y,new Float64Array(h).fill(NaN)),p,new Float64Array(h).fill(NaN)));var d=[y,p];i>0&&t.lag(d,i);var m=i>0?d.flatMap((function(t){return[t].concat(cr(Array.from({length:i},(function(r,e){return"".concat(t,"_lag_").concat(e+1)}))))})):d;if(Array.isArray(u)){var b,g,w=null!==(g=(b=t.scaledGroups).minmax_rsi)&&void 0!==g?g:b.minmax_rsi=[];w.push.apply(w,cr(m))}var S,O=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=sr(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(m);try{for(O.s();!(S=O.n()).done;)v[S.value]="Float64Array"}catch(t){O.e(t)}finally{O.f()}}var A=c[o][r],j=NaN,P=NaN;s[y].update(A);try{j=s[y].getResult()}catch(t){j=NaN}t.pushToMain({index:r,key:y,value:Number.isNaN(j)?NaN:a(j)}),Number.isNaN(j)||s[p].update(j);try{P=s[p].getResult()}catch(t){P=NaN}t.pushToMain({index:r,key:p,value:Number.isNaN(P)?NaN:a(P)})},stochastic:function(t,r,e,n,o,i){var a=i.minmax,l=i.prefix,u=i.lag,c=i.parser,s=t.verticalOhlcv,f=t.instances,y=(t.scaledGroups,14===e&&3===n&&3===o?"":"".concat(e,"_").concat(n,"_").concat(o)),p="".concat(l,"stoch_d").concat(y),h="".concat(l,"stoch_k").concat(y),v="".concat(l).concat(y);if(0===r){var d=t.len,m=t.arrayTypes;Object.assign(f,mr({},v,new lr(e,n,o))),Object.assign(s,mr(mr({},p,new Float64Array(d).fill(NaN)),h,new Float64Array(d).fill(NaN)));var b=[p,h];u>0&&t.lag(b,u);var g=u>0?b.flatMap((function(t){return[t].concat(hr(Array.from({length:u},(function(r,e){return"".concat(t,"_lag_").concat(e+1)}))))})):b;if(Array.isArray(a)){var w,S,O=null!==(S=(w=t.scaledGroups).minmax_rsi)&&void 0!==S?S:w.minmax_rsi=[];O.push.apply(O,hr(g))}var A,j=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=vr(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(g);try{for(j.s();!(A=j.n()).done;)m[A.value]="Float64Array"}catch(t){j.e(t)}finally{j.f()}}var P=s.close[r],N=s.low[r],x=s.high[r],_=null;f[v].update({close:P,low:N,high:x});try{_=f[v].getResult()}catch(t){_=null}var k=_?c(_.stochK):NaN,C=_?c(_.stochD):NaN;t.pushToMain({index:r,key:h,value:k}),t.pushToMain({index:r,key:p,value:C})},atr:function(t,r,e,n){var o=n.lag,i=n.percentage,a=n.upper,l=n.lower,u=t.verticalOhlcv,c=t.instances,s="atr_".concat(e);if(0===r){var f=t.instances,y=t.verticalOhlcv,p=t.arrayTypes,h=t.len;f[s]=new Nt(e,lt);var v=[s];i&&v.push("".concat(s,"_percentage")),null!==a&&v.push("".concat(s,"_upper")),null!==l&&v.push("".concat(s,"_lower"));for(var d=0,m=v;d<m.length;d++){var b=m[d];y[b]=new Float64Array(h).fill(NaN),p[b]="Float64Array"}o>0&&t.lag(v,o)}var g={high:u.high[r],low:u.low[r],close:u.close[r]},w=c[s];w.update(g);var S=NaN;try{S=w.getResult()}catch(t){}if(i){var O=Number.isNaN(S)?NaN:S/g.close;t.pushToMain({index:r,key:"".concat(s,"_percentage"),value:O})}if(null!==a){var A=Number.isNaN(S)?NaN:g.close+S*a;t.pushToMain({index:r,key:"".concat(s,"_upper"),value:A})}if(null!==l){var j=Number.isNaN(S)?NaN:g.close-S*l;t.pushToMain({index:r,key:"".concat(s,"_lower"),value:j})}return t.pushToMain({index:r,key:s,value:S}),!0},ema:gr,sma:gr,macd:function(t,r,e,n,o,i){var a=i.target,l=i.lag,u=i.precomputed,c=t.verticalOhlcv,s=t.instances,f=u.instanceKey;if(0===r){var y=t.inputParams,p=t.len,h=t.arrayTypes;if(!c.hasOwnProperty(a))throw new Error("Target property ".concat(a," not found in verticalOhlcv for macd."));var v,d=0,m=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Or(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Or(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(y);try{for(m.s();!(v=m.n()).done;)"macd"===v.value.key&&d++}catch(t){m.e(t)}finally{m.f()}var b=d>1?"macd_".concat(e,"_").concat(n,"_").concat(o):"macd",g=a===Ar?"".concat(b,"_diff"):"".concat(b,"_diff_").concat(a),w=a===Ar?"".concat(b,"_dea"):"".concat(b,"_dea_").concat(a),S=a===Ar?"".concat(b,"_histogram"):"".concat(b,"_histogram_").concat(a);s.hasOwnProperty("macd")||(s.macd={numberOfIndicators:d,settings:{}}),s.macd.settings[f]=new Ht(new Yt(e),new Yt(n),new Yt(o)),Object.assign(c,Sr(Sr(Sr({},g,new Float64Array(p).fill(NaN)),w,new Float64Array(p).fill(NaN)),S,new Float64Array(p).fill(NaN)));var O=[g,w,S];l>0&&t.lag(O,l);for(var A=0,j=O;A<j.length;A++)h[j[A]]="Float64Array"}var P=s.macd,N=P.numberOfIndicators,x=P.settings,_=N>1?"macd_".concat(e,"_").concat(n,"_").concat(o):"macd",k=a===Ar?"".concat(_,"_diff"):"".concat(_,"_diff_").concat(a),C=a===Ar?"".concat(_,"_dea"):"".concat(_,"_dea_").concat(a),E=a===Ar?"".concat(_,"_histogram"):"".concat(_,"_histogram_").concat(a),T=x[f],I=c[a][r];T.update(I);var M={};try{M=T.getResult()}catch(t){}return t.pushToMain({index:r,key:k,value:M?M.macd:NaN}),t.pushToMain({index:r,key:C,value:M?M.signal:NaN}),t.pushToMain({index:r,key:E,value:M?M.histogram:NaN}),!0},relativeVolume:function(t,r,e,n){var o=n.lag,i="relative_volume_".concat(e),a=t.instances,l=t.verticalOhlcv;if(0===r){var u=t.len,c=t.arrayTypes;a[i]={instance:new Z(e),prevRelativeVolumeSma:NaN},l[i]=new Float64Array(u).fill(NaN),o>0&&t.lag([i],o),c[i]="Float64Array"}var s=l.volume[r],f=a[i].instance;f.update(s);var y=NaN;try{y=f.getResult()}catch(t){}var p=a[i].prevRelativeVolumeSma,h=NaN;return Number.isNaN(y)||Number.isNaN(p)||(h=s/p),t.pushToMain({index:r,key:i,value:h}),a[i].prevRelativeVolumeSma=y,!0},donchianChannels:function(t,r,e,n,o){var i=t.verticalOhlcv,a=t.instances,l=t.len,u=t.inputParams,c=t.arrayTypes,s=t.lag,f=o.height,y=o.range,p=o.decimals,h="".concat(e,"_").concat(n);if(0===r){var v=u.filter((function(t){return"donchianChannels"===t.key})).length,d="donchian_channel",m=v>1?"".concat(d,"_").concat(h):d,b=["upper","basis","lower"].map((function(t){return"".concat(m,"_").concat(t)}));f&&b.push("".concat(m,"_height"));var g,w=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=kr(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(y);try{for(w.s();!(g=w.n()).done;){var S=g.value;if(!(S in i))throw new Error('Invalid range key "'.concat(S,'".'));b.push("".concat(m,"_range_").concat(S))}}catch(t){w.e(t)}finally{w.f()}a.donchian_channel||(a.donchian_channel={numberOfIndicators:v,settings:{}}),a.donchian_channel.numberOfIndicators=v,a.donchian_channel.settings[h]={maxDeque:[],minDeque:[]},Object.assign(i,Object.fromEntries(b.map((function(t){return[t,new Float64Array(l).fill(NaN)]})))),s>0&&t.lag(b,s),b.forEach((function(t){return c[t]="Float64Array"}))}var O=a.donchian_channel,A=O.numberOfIndicators,j=O.settings,P=A>1?"donchian_channel_".concat(h):"donchian_channel",N=j[h],x=N.maxDeque,_=N.minDeque,k=r-n,C=k-e+1,E=["upper","basis","lower"].map((function(t){return"".concat(P,"_").concat(t)}));f&&E.push("".concat(P,"_height"));var T=y.map((function(t){return"".concat(P,"_range_").concat(t)}));if(C<0||k+1>l)return[].concat(_r(E),_r(T)).forEach((function(e){return t.pushToMain({index:r,key:e,value:NaN})})),!0;var I=i.high,M=i.low,R=function(t,r,e){for(;t.length&&t[0]<C;)t.shift();for(;t.length&&e(r[t.at(-1)],r[k]);)t.pop();t.push(k)};R(x,I,(function(t,r){return t<=r})),R(_,M,(function(t,r){return t>=r}));var D=x.length&&_.length,F=D?I[x[0]]:NaN,L=D?M[_[0]]:NaN,z=D?(F+L)/2:NaN;if(t.pushToMain({index:r,key:"".concat(P,"_upper"),value:F}),t.pushToMain({index:r,key:"".concat(P,"_basis"),value:z}),t.pushToMain({index:r,key:"".concat(P,"_lower"),value:L}),f){var Y=D&&L?(F-L)/L:NaN;t.pushToMain({index:r,key:"".concat(P,"_height"),value:null===p?Y:xr(Y,p)})}for(var U=D?F-L:NaN,G=0;G<y.length;G++){var K=i[y[G]][r],V=D&&K==K&&U?(K-L)/U:NaN;t.pushToMain({index:r,key:T[G],value:null===p?V:xr(V,p)})}return!0},bollingerBands:function(t,r,e,n,o){var i,a,l,u,c,s,f=o.height,y=o.range,p=void 0===y?[]:y,h=o.target,v=o.lag,d=o.decimals,m=t.verticalOhlcv,b=t.instances,g="".concat(e,"_").concat(n),w="bollinger_bands";if(0===r){var S=t.inputParams,O=t.verticalOhlcv,A=t.len,j=t.arrayTypes;if(!(h in O))throw new Error('bollingerBands could not find target "'.concat(h,'"'));var P,N=0,x=Mr(S);try{for(x.s();!(P=x.n()).done;)"bollingerBands"===P.value.key&&N++}catch(t){x.e(t)}finally{x.f()}b.bollinger_bands||(b.bollinger_bands={numberOfIndicators:N,settings:{}}),b.bollinger_bands.settings[g]=new Et(e,n);var _="";N>1&&(_+="_".concat(g)),h!==Dr&&(_+="_".concat(h));var k=["".concat(w,"_upper"),"".concat(w,"_middle"),"".concat(w,"_lower")].map((function(t){return"".concat(t).concat(_)}));f&&k.push("".concat(w,"_height").concat(_));var C,E=Mr(p);try{for(E.s();!(C=E.n()).done;){var T=C.value;if(!(T in O))throw new Error('Invalid range item value "'.concat(T,'" property for bollingerBands.'));k.push("".concat(w,"_range_").concat(T).concat(_))}}catch(t){E.e(t)}finally{E.f()}var I=Object.fromEntries(k.map((function(t){return[t,new Float64Array(A).fill(NaN)]})));Object.assign(O,function(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?Tr(Object(e),!0).forEach((function(r){Ir(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Tr(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}({},I)),v>0&&t.lag(k,v);var M,R=Mr(k);try{for(R.s();!(M=R.n()).done;)j[M.value]="Float64Array"}catch(t){R.e(t)}finally{R.f()}}var D="";b.bollinger_bands.numberOfIndicators>1&&(D+="_".concat(g)),h!==Dr&&(D+="_".concat(h));var F=b.bollinger_bands.settings[g],L=m[h][r];F.update(L);var z={};try{z=F.getResult()}catch(t){}var Y=null!==(i=null===(a=z)||void 0===a?void 0:a.upper)&&void 0!==i?i:NaN,U=null!==(l=null===(u=z)||void 0===u?void 0:u.middle)&&void 0!==l?l:NaN,G=null!==(c=null===(s=z)||void 0===s?void 0:s.lower)&&void 0!==c?c:NaN;if(t.pushToMain({index:r,key:"".concat(w,"_upper").concat(D),value:Y}),t.pushToMain({index:r,key:"".concat(w,"_middle").concat(D),value:U}),t.pushToMain({index:r,key:"".concat(w,"_lower").concat(D),value:G}),f){var K=NaN;Number.isNaN(G)||Number.isNaN(Y)||(K=(Y-G)/G),t.pushToMain({index:r,key:"".concat(w,"_height").concat(D),value:null===d?K:xr(K,d)})}var V,H=Mr(p);try{for(H.s();!(V=H.n()).done;){var $=V.value,q=NaN,B=m[$][r];Number.isNaN(B)||Number.isNaN(G)||Number.isNaN(Y)||(q=(B-G)/(Y-G)),t.pushToMain({index:r,key:"".concat(w,"_range_").concat($).concat(D),value:null===d?q:xr(q,d)})}}catch(t){H.e(t)}finally{H.f()}return!0},volumeOscillator:function(t,r,e,n,o){var i,a,l,u=o.lag,c=t.verticalOhlcv,s=t.instances,f=c.volume[r],y="volume_oscillator_".concat(e,"_").concat(n);if(0===r){var p=t.len,h=t.arrayTypes;Object.assign(s,(i={},a=y,l={fastEMA:new Yt(e),slowEMA:new Yt(n)},(a=function(t){var r=function(t,r){if("object"!=Fr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Fr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fr(r)?r:r+""}(a))in i?Object.defineProperty(i,a,{value:l,enumerable:!0,configurable:!0,writable:!0}):i[a]=l,i)),c[y]=new Float64Array(p).fill(NaN),u>0&&t.lag([y],u),h[y]="Float64Array"}var v=s[y],d=v.fastEMA,m=v.slowEMA;d.update(f),m.update(f);var b=NaN,g=NaN;try{b=d.getResult()}catch(t){}try{g=m.getResult()}catch(t){}var w=NaN;return Number.isNaN(b)||Number.isNaN(g)||(w=100*(b-g)/g),t.pushToMain({index:r,key:y,value:w}),!0},mapCols:function(t,r,e,n,o){var i=o.lag,a=t.verticalOhlcv,l=t.len,u=t.arrayTypes;if(0===r){var c,s=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Oe(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(e);try{for(s.s();!(c=s.n()).done;){var f=c.value;if(a.hasOwnProperty(f))throw new Error('New property "'.concat(f,'" already exist in "verticalOhlcv" and can not be modified using mapCols.'));a[f]=new Array(l).fill(0),u[f]="Array"}}catch(t){s.e(t)}finally{s.f()}i>0&&t.lag(e,i)}var y,p,h=n({index:r,main:t});if(null==h)return!0;for(var v=0,d=Object.entries(h);v<d.length;v++){var m=(y=d[v],p=2,function(t){if(Array.isArray(t))return t}(y)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(y,p)||Oe(y,p)||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.")}()),b=m[0],g=m[1];t.pushToMain({index:r,key:b,value:g})}},scaler:function(t,r,e,n,o){var i=o.type,a=o.group,l=o.range,u=o.lag,c=o.precomputed,s=(o.secondaryLoop,c.groupKey),f=c.groupKeyLen,y=t.verticalOhlcv,p=t.instances,h=t.arrayTypes,v=(t.invalidValueIndex,"".concat(i,"_").concat(e));if(0===r){var d=t.len,m=t.isAlreadyComputed;if(m.has(v))throw new Error('In scaler method can not repeat params "size" and "options.type" together between indicators.');m.add(v),p.hasOwnProperty("scaler")||(p.scaler={}),p.scaler.hasOwnProperty(v)||(p.scaler[v]={windows:{}});var b,g=[],w=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=we(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(n);try{var S=function(){var r=b.value;if(!y.hasOwnProperty(r))throw new Error('Target property "'.concat(r,'" not found in verticalOhlcv'));var e="".concat(v,"_").concat(r);y[e]=new Float64Array(d).fill(NaN),h[e]="Float64Array";var n=a?s:r;if(p.scaler[v].windows[n]=[],t.scaledGroups[s]||(t.scaledGroups[s]=[]),t.scaledGroups[s].push(e),u>0){var o,i=Array.from({length:u}).map((function(t,r){return"".concat(e,"_lag_").concat(r+1)}));(o=t.scaledGroups[s]).push.apply(o,ge(i)),g.push(e)}};for(w.s();!(b=w.n()).done;)S()}catch(t){w.e(t)}finally{w.f()}u>0&&t.lag(g,u)}for(var O=p.scaler[v].windows,A=!1,j=0;j<n.length;j++){var P=n[j],N=y[P];if(void 0===N){A=!0;break}var x=N[r];if(Number.isNaN(x)||null===x){A=!0;break}var _=O[a?s:P];_.push(x),_.length>(a?e*f:e)&&_.shift()}if(!A&&r+1>=e)for(var k=function(){var e=n[C],o=y[e];if(void 0===o)return 0;var u=o[r];if(Number.isNaN(u)||null===u)return 0;var c="".concat(v,"_").concat(e),f=null,p=O[a?s:e];if("minmax"===i){var h=Math.min.apply(Math,ge(p)),d=Math.max.apply(Math,ge(p));f=Qr(u,h,d,l)}else{if("zscore"!==i)throw new Error('Unknown scaler type "'.concat(i,'"'));var m=p.reduce((function(t,r){return t+r}),0)/p.length,b=p.reduce((function(t,r){return t+Math.pow(r-m,2)}),0)/p.length,g=Math.sqrt(b);f=function(t,r,e){return 0===e?0:(t-r)/e}(u,m,g)}t.pushToMain({index:r,key:c,value:f})},C=0;C<n.length&&0!==k();C++);},crossPairs:function(t,r,e,n){var o,i=n.limit,a=n.oneHot,l=t.verticalOhlcv,u=t.verticalOhlcvTempCols,c=t.instances,s=t.len,f=t.arrayTypes,y=t.notNumberKeys,p=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return ie(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?ie(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(e);try{for(p.s();!(o=p.n()).done;){var h=o.value,v=h.fast,d=h.slow,m="".concat(v,"_x_").concat(d);if(0===r){if("number"==typeof d){var b=d.toString();u.add(b),y.add(b);var g="Int16Array";0===d||1===d?g="Uint8Array":d>=-125&&d<=125&&(g="Int8Array"),l[b]=Hr(g,s),f[b]="slowNumArrType"}c.hasOwnProperty("crossPairs")||(c.crossPairs={}),c.crossPairs[m]={run:new fe,min:1/0,max:-1/0};var w="Int16Array";i<=125&&(w="Int8Array"),l[m]=Hr(w,s),a&&(l["one_hot_".concat(m)]=Hr("Array",s),y.add("one_hot_".concat(m))),y.add(m),f[m]="crossArrType"}else if(r+1===s){if("price"!==v&&!l.hasOwnProperty(v))throw new Error('crossPairs invalid param: fast "'.concat(v,'" not found in "verticalOhlcv": ').concat(JSON.stringify(Object.keys(l))));if(!l.hasOwnProperty(d))throw new Error('crossPairs invalid param: slow "'.concat(d,'" not found in "verticalOhlcv": ').concat(JSON.stringify(Object.keys(l))))}if("price"!==v&&!l.hasOwnProperty(v))return;if(!l.hasOwnProperty(d))return;var S=c.crossPairs[m].run;if("price"===v){var O=l.close[r],A=l[d][r];S.update(r,{fast:O,slow:A,high:l.high[r],low:l.low[r]})}else{var j=l[v][r],P=l[d][r];S.update(r,{fast:j,slow:P})}var N=S.getResult(),x=Math.max(-i,Math.min(i,N));if(t.pushToMain({index:r,key:m,value:x}),a){var _=x+i,k=2*i+1;t.pushToMain({index:r,key:"one_hot_".concat(m),value:Wr(_,k)})}}}catch(t){p.e(t)}finally{p.f()}return!0},lag:function(t,r,e,n){var o=t.verticalOhlcv,i=t.len,a=t.arrayTypes;if(0===r){var l,u=$r(e);try{for(u.s();!(l=u.n()).done;){var c=l.value;if(!a.hasOwnProperty(c))throw new Error('Lag processing invoked by "'.concat(c,'" expected arrayTypes to have a "').concat(c,'" property, but it wasn’t found.'));for(var s=1;s<=n;s++){var f="".concat(c,"_lag_").concat(s);o[f]=Hr(a[c],i),a[f]=a[c]}}}catch(t){u.e(t)}finally{u.f()}}var y,p=$r(e);try{for(p.s();!(y=p.n()).done;)for(var h=y.value,v=o[h],d=1;d<=n;d++){var m="".concat(h,"_lag_").concat(d),b=r-d,g=b<0||void 0===v[b]?null:v[b];t.pushToMain({index:r,key:m,value:g})}}catch(t){p.e(t)}finally{p.f()}return!0}},Je=function(t,r){for(var e=t.length,n=new Z(r),o=new Array(e),i=0,a=0,l=0,u=0;u<e;u++)if(n.update(t[u]),n.isStable){var c=n.getResult();o[u]=c,i+=c,a+=c*c,l++}else o[u]=null;var s=i/l,f=a/l-s*s,y=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/y:null}))},Xe=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==r.length)throw new Error("Both arrays must have the same length");for(var n=Je(t,e),o=Je(r,e),i=t.length,a=[],l=0,u=0,c=0,s=0,f=0,y=0,p=-1,h=0;h<i;h++){if(null!==n[h]&&null!==o[h]){p=h;break}a.push(0)}if(-1===p)return new Array(i).fill(0);for(var v=p;v<i;v++){var d=n[v],m=o[v];if(null!==d&&null!==m)if(l+=d,u+=m,c+=d*m,s+=d*d,f+=m*m,++y<2)a.push(0);else{var b=y*c-l*u,g=Math.sqrt((y*s-l*l)*(y*f-u*u)),w=0===g?0:b/g;a.push(w)}else l=u=c=s=f=y=0,a.push(0)}return a};function We(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ze=function(t){var r,e,n=t.main,o=t.skipNull,i=void 0!==o&&o,a=t.startIndex,l=void 0===a?0:a,u=t.dateFormat,c=n.precisionMultiplier,s=n.precision,f=n.verticalOhlcv,y=n.invalidValueIndex,p=n.len,h=n.verticalOhlcvKeyNames,v=n.verticalOhlcvTempCols,d=n.notNumberKeys;if(0===h.length)return[];for(var m=i&&y>=0?y+1:0,b=Math.max(m,l),g=p-b,w=Array.from({length:g},(function(){return{}})),S=0,O=Object.entries(f);S<O.length;S++){var A=(r=O[S],e=2,function(t){if(Array.isArray(t))return t}(r)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(r,e)||function(t,r){if(t){if("string"==typeof t)return We(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?We(t,r):void 0}}(r,e)||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.")}()),j=A[0],P=A[1];if(!v.has(j))for(var N=s&&!d.has(j),x=b;x<p;x++)w[x-b][j]=N?P[x]/c:"date"===j?zr[u](P[x]):P[x]}return w};function Qe(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||function(t,r){if(t){if("string"==typeof t)return tn(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?tn(t,r):void 0}}(t,r)||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.")}()}function tn(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var rn=function(t,r){u(t,"arr","getOrderFromArray"),h(r,"methodName","getOrderFromArray");var e=["open","high","low","close","volume","date"],n=["regressor","classifier","pca"].includes(r);if(t.every((function(t){return e.includes(t)}))&&!n)return 0;for(var o=1,i=function(){var r=l[a];t.some((function(t){return t.includes(r)}))&&o++},a=0,l=["_x_","zscore_","minmax_","lag_"];a<l.length;a++)i();if(!n)return o;o=10;for(var c=function(){var r=f[s];t.some((function(t){return t.includes(r)}))&&o++},s=0,f=["prediction_","reg_","cla_","pca_"];s<f.length;s++)c();return o};function en(t){return en="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},en(t)}function nn(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function on(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?nn(Object(e),!0).forEach((function(r){an(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):nn(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function an(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=en(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=en(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==en(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function ln(t,r){if(t){if("string"==typeof t)return un(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?un(t,r):void 0}}function un(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var cn=function(t,r,e){if(2!==e)throw new Error('The default "yCallback" function in this classifier requires that "options.horizon" and "options.predictions" are set to "2".');var n=r.close[t],o=Array.from({length:e},(function(e,n){return r.close[n+1+t]}));if(o.some((function(t){return void 0===t})))return null;var i=o[0],a=o[1];return[Number(i>n),Number(a>i)]},sn={KNN:{shortName:"knn",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},FeedForwardNeuralNetworks:{shortName:"feed_forward",flatY:!1,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=t.modelArgs,i=t.uniqueLabels;o||(o={});var a=new r(o=on(on({},o),{},{activation:2===i?"logistic":"identity"}));return a.train(e,n),a},unsupervised:!1},GaussianNB:{shortName:"naive_bayes",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},MultinomialNB:{shortName:"naive_bayes",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},DecisionTreeClassifier:{shortName:"decision_tree",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},RandomForestClassifier:{shortName:"random_forest",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o}},unsupervised:!1},fn={ARIMA:{shortName:"arima",flatX:!0,flatY:!1,exportModel:function(t){return t},train:function(t){var r=t.modelClass,e=t.xRows,n=t.modelArgs;n||(n={});var o=new r(n=on(on({},n),{},{p:2,d:1,q:2,P:0,D:0,Q:0,S:0,verbose:!1}));return o.train(e),o},unsupervised:!0},SimpleLinearRegression:{shortName:"linear",flatX:!0,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},PolynomialRegression:{shortName:"polynomial",flatX:!0,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},MultivariateLinearRegression:{shortName:"multivariable",flatX:!1,flatY:!1,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},DecisionTreeRegression:{shortName:"decision_tree",flatX:!1,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},RandomForestRegression:{shortName:"random_forest",flatX:!1,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},FeedForwardNeuralNetworks:{shortName:"feed_forward",flatX:!1,flatY:!1,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=t.modelArgs;o||(o={});var i=new r(o=on(on({},o),{},{activation:"identity"}));return i.train(e,n),i},unsupervised:!1}};function yn(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function pn(t){return pn="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},pn(t)}function hn(t,r,e){return(r=Sn(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function vn(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=bn(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function dn(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||bn(t,r)||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.")}()}function mn(t){return function(t){if(Array.isArray(t))return gn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||bn(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bn(t,r){if(t){if("string"==typeof t)return gn(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?gn(t,r):void 0}}function gn(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function wn(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Sn(n.key),n)}}function Sn(t){var r=function(t,r){if("object"!=pn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=pn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pn(r)?r:r+""}var On=function(){return t=function t(r){var e=this,n=r.input,o=r.ticker,i=void 0===o?null:o,l=r.precision,s=void 0===l||l,p=r.inputParams,h=void 0===p?null:p,v=r.chunkProcess,d=void 0===v?2e3:v,m=r.ML,b=void 0===m?{}:m;if(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),u(n,"input",null!==i?"contructor ".concat(i):"constuctor"),0===n.length)throw Error("input OHLCV must not be empty: "+i);f(s,"precision","constructor"),y(d,{min:100,max:5e4,allowDecimals:!1},"chunkProcess","constructor"),c(b,"ML","constructor"),this.notNumberKeys=new Set,this.chunkProcess=d,this.input=mn(n),this.len=this.input.length,this.firstRow=this.input[0];var g=function(t){for(var r=t.firstRow,e=t.notNumberKeys,n={},o={},i=0,a=Object.entries(r);i<a.length;i++){var l=Gr(a[i],2),u=l[0],c=l[1];if("date"===u)n[u]=Ur(c),o[u]="Array",e.add(u);else if("volume"===u)n[u]=Nr(c,!0),o[u]="Int32Array",e.add(u);else if(Vr.has(u))n[u]=Nr(c,!0),o[u]="Float64Array";else{var s=Nr(c,!1);n[u]=s,o[u]="number"===s?"Float64Array":"Array",s.startsWith("number")||e.add(u)}}return{inputTypes:n,arrayTypes:o}}(this),w=g.inputTypes,S=g.arrayTypes;if(this.inputTypes=w,this.arrayTypes=S,!this.firstRow.hasOwnProperty("close"))throw Error('input OHLCV array objects require at least "close" property: '.concat(i));this.dateType=this.inputTypes.date?this.inputTypes.date:null,this.isComputed=!1,this.instances={},this.verticalOhlcv={},this.verticalOhlcvKeyNames=[],this.verticalOhlcvTempCols=new Set,this.utilities={correlation:Xe},this.invalidValueIndex=-1,this.precision=s,this.precisionMultiplier=function(t,r){if(!1===t.precision)return 1;for(var e=1,n=0,o=Object.entries(r);n<o.length;n++){var i=Qe(o[n],2),a=i[0],l=i[1];if(!1!==new Set(["open","high","low","close"]).has(a)){var u=Qe(String(l).split("."),2)[1],c=void 0===u?"":u,s=Math.max(4,c.length),f=s>1?Math.pow(10,s-1):1;f>e&&(e=f)}}return e}(this,this.firstRow),this.scaledGroups={},this.isAlreadyComputed=new Set;var O=b.classes;return void 0!==O&&c(O,"ML.classes","constructor"),this.ML={models:{},classes:O,metrics:{},featureCols:{}},this.processSecondaryLoop=!1,this.pushToMain=function(t){var r=t.index,n=t.key,o=t.value;return function(t){var r=t.index,e=t.key,n=t.value;return t.main.verticalOhlcv[e][r]=n,!0}({main:e,index:r,key:n,value:o})},null!==h?(a(h,this.len),this.inputParams=h,this.compute()):this.inputParams=[],this},r=[{key:"getDataAsCols",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var r=t.skipNull,e=void 0===r||r,n=t.dateFormat,o=void 0===n?"string":n;s(Object.keys(zr),o,"dateFormat","getDataAsCols"),c(t,"options","getDataAsCols");for(var i=this.precisionMultiplier,a=this.precision,l=this.len,u=this.invalidValueIndex,f=this.verticalOhlcv,y=this.arrayTypes,p=this.verticalOhlcvTempCols,h=this.notNumberKeys,v={},d=e?u+1:0,m=l-d,b=0,g=Object.entries(f);b<g.length;b++){var w=dn(g[b],2),S=w[0],O=w[1];if(!p.has(S)){var A=a&&!h.has(S);v[S]=Hr(y[S],m);for(var j=d;j<l;j++)v[S][j]=A?O[j]/i:"date"===S?zr[o](O[j]):O[j]}}return v}},{key:"getData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var r=t.skipNull,e=void 0===r||r,n=t.dateFormat,o=void 0===n?"string":n;return s(Object.keys(zr),o,"dateFormat","getData"),c(t,"options","getData"),Ze({main:this,skipNull:e,startIndex:0,dateFormat:o})}},{key:"getLastValues",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var r=t.dateFormat,e=void 0===r?"string":r;return s(Object.keys(zr),e,"dateFormat","getData"),Ze({skipNull:!1,main:this,startIndex:this.len-1,dateFormat:e})[0]}},{key:"compute",value:function(){return this.isComputed||(this.isComputed=!1,this.len>0&&(function(t,r){var n=r.len,o=r.inputParams,i=r.precisionMultiplier,l=r.arrayTypes,u=r.verticalOhlcv,c=r.verticalOhlcvKeyNames,s=r.inputTypes,f=r.chunkProcess,y=r.notNumberKeys,p=r.processSecondaryLoop;a(o,n);for(var h=0,v=Object.keys(s);h<v.length;h++){var d=v[h];u[d]=Hr(l[d],n)}for(var m=0;m<n;m+=f)for(var b=Math.min(m+f,n),g=m;g<b;g++){for(var w=t[g],S=0,O=Object.entries(s);S<O.length;S++){var A=He(O[S],2),j=A[0],P=A[1],N=w[j];if(Pr.hasOwnProperty(P)){var x=Pr[P](N);i>1&&!y.has(j)&&(x*=i),r.pushToMain({index:g,key:j,value:x})}else Yr.hasOwnProperty(P)?r.pushToMain({index:g,key:j,value:Yr[P](N)}):r.pushToMain({index:g,key:j,value:N})}var _,k=Ve(o);try{for(k.s();!(_=k.n()).done;)for(var C=_.value,E=C.key,T=C.params,I=C.order,M=0;M<=9;M++){if("number"!=typeof I)throw new Error("order property of ".concat(E," not found: ").concat(T));M===I&&Be[E].apply(Be,[r,g].concat(Ke(T)))}}catch(t){k.e(t)}finally{k.f()}t[g]=null;var R=Object.keys(u);e(r,g,R)||(r.invalidValueIndex=g)}(o.some((function(t){var r=t.key;return"regressor"===r||"classifier"===r||"pca"===r}))||p)&&function(t){for(var r=t.inputParams,e=t.len,n=t.invalidValueIndex+1;n<e;n++){var o,i=Ve(r);try{for(i.s();!(o=i.n()).done;)for(var a=o.value,l=a.key,u=a.params,c=a.order,s=10;s<=20;s++){if("number"!=typeof c)throw new Error("order property of ".concat(l," not found: ").concat(u));s===c&&("pca"===l&&Ee.apply(void 0,[t,n].concat(Ke(u))),"classifier"===l&&Ge.apply(void 0,[t,n].concat(Ke(u))),"regressor"===l&&De.apply(void 0,[t,n].concat(Ke(u))))}}catch(t){i.e(t)}finally{i.f()}}}(r),c.push.apply(c,Ke(Object.keys(u)))}(this.input,this),this.isComputed=!0,this.input=[],this.instances={},this.firstRow=[])),this}},{key:"crossPairs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="crossPairs";l(this),u(t,"arr",e),c(r,"options",e);var n=r.limit,o=void 0===n?125:n,i=r.oneHot,a=void 0!==i&&i;y(o,{min:2,max:this.len},"options.limit",e),f(a,"options.oneHot",e);var s,p=[],h=vn(t);try{for(h.s();!(s=h.n()).done;){var v=s.value,d=v.fast,m=void 0===d?"":d,b=v.slow,g=void 0===b?"":b;if(""===m||""===g)throw new Error("Invalid crossPairs[".concat(m,"_").concat(g,"]: Object property “fast” must be a non-null column name and “slow” must be a non-null column name or integer."));p.push(m.toString(),g.toString())}}catch(t){h.e(t)}finally{h.f()}if(this.isAlreadyComputed.has(e))throw new Error('You can only call the "'.concat(e,'" method once.'));this.isAlreadyComputed.add(e);var w=rn(p,e);return this.inputParams.push({key:e,order:w,params:[t,{limit:o,oneHot:a}]}),this}},{key:"lag",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,e="lag";l(this),u(t,"colKeys",e),y(r,{min:1,max:this.len,allowDecimals:!1},"lookback",e);var n=rn(t,e);return this.inputParams.push({key:e,order:n,params:[t,r]}),this}},{key:"relativeVolume",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="relativeVolume";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');l(this),y(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.lag,o=void 0===n?0:n;return y(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),this.inputParams.push({key:e,order:0,params:[t,{lag:o}]}),this}},{key:"atr",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="atr";l(this),y(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.lag,o=void 0===n?0:n,i=r.percentage,a=void 0!==i&&i,u=r.upper,s=void 0===u?null:u,p=r.lower,h=void 0===p?null:p;return y(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),f(a,"options.percentage","atr"),null!==s&&y(s,{min:.001,max:100,allowDecimals:!0},"options.upper","atr"),null!==h&&y(h,{min:.001,max:100,allowDecimals:!0},"options.lower","atr"),this.inputParams.push({key:e,order:0,params:[t,{lag:o,percentage:a,upper:s,lower:h}]}),this}},{key:"ema",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="ema";l(this),y(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.target,o=void 0===n?"close":n,i=r.lag,a=void 0===i?0:i;h(o,"options.target",e),y(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var u=rn([o],e);return this.inputParams.push({key:e,order:u,params:[e,t,{target:o,lag:a}]}),this}},{key:"sma",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="sma";l(this),y(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.target,o=void 0===n?"close":n,i=r.lag,a=void 0===i?0:i;h(o,"options.target",e),y(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var u=rn([o],e);return this.inputParams.push({key:e,order:u,params:[e,t,{target:o,lag:a}]}),this}},{key:"stochastic",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="stochastic",i=this.len;y(t,{min:1,max:i,allowDecimals:!1},"kPeriod",o),y(r,{min:1,max:i,allowDecimals:!1},"kSlowingPeriod",o),y(e,{min:1,max:i,allowDecimals:!1},"dPeriod",o),c(n,"options",o);var a=function(t){return t},l="",u=n.lag,s=void 0===u?0:u;y(s,{min:0,max:i,allowDecimals:!1},"options.lag",o);var h=n.minmax;return(Array.isArray(h)||"boolean"==typeof h&&!0===h)&&(Array.isArray(h)?(p(h,"options.minmax",o),a=function(t){return null!==h?Qr(t,0,100,h):t}):(f(h,"options.minmax",o),h=[0,1],a=function(t){return null!==h?Qr(t,0,100,h):t}),l="minmax_"),this.inputParams.push({key:o,order:0,params:[t,r,e,{minmax:h,prefix:l,parser:a,lag:s}]}),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="macd";l(this),y(t,{min:1,max:this.len,allowDecimals:!1},"fast",o),y(r,{min:1,max:this.len,allowDecimals:!1},"slow",o),y(e,{min:1,max:this.len,allowDecimals:!1},"signal",o),c(n,"options",o);var i=n.target,a=void 0===i?"close":i,u=n.lag,s=void 0===u?0:u;h(a,"options.target",o),y(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",o);var f={instanceKey:"".concat(t,"_").concat(r,"_").concat(e).concat("close"===a?"":"_".concat(a))},p=rn([a],o);return this.inputParams.push({key:o,order:p,params:[t,r,e,{target:a,lag:s,precomputed:f}]}),this}},{key:"bollingerBands",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="bollingerBands";l(this),y(t,{min:1,max:this.len,allowDecimals:!1},"size",n),y(r,{min:.01,max:50,allowDecimals:!0},"stdDev",n),c(e,"options",n);var o=e.target,i=void 0===o?"close":o,a=e.height,s=void 0!==a&&a,p=e.range,v=void 0===p?[]:p,d=e.lag,m=void 0===d?0:d,b=e.decimals,g=void 0===b?null:b;h(i,"options.target",n),u(v,"options.range",n),y(m,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),f(s,"options.height",n),null!==g&&y(g,{min:1,max:15,allowDecimals:!1},"decimals",n);var w=rn([i],n);return this.inputParams.push({key:n,order:w,params:[t,r,{target:i,height:s,range:v,lag:m,decimals:g}]}),this}},{key:"rsi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="rsi";l(this),y(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.target,o=void 0===n?"close":n,i=r.lag,a=void 0===i?0:i,u=r.minmax;h(o,"options.target",e),y(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var s=function(t){return t},v="";(Array.isArray(u)||"boolean"==typeof u&&!0===u)&&(Array.isArray(u)?(p(u,"options.minmax",e),s=function(t){return null!==u?Qr(t,0,100,u):t}):(f(u,"options.minmax",e),u=[0,1],s=function(t){return null!==u?Qr(t,0,100,u):t}),v="minmax_");var d=rn([o],e);return this.inputParams.push({key:e,order:d,params:[t,{target:o,lag:a,parser:s,prefix:v,minmax:u}]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="donchianChannels";l(this),y(t,{min:1,max:this.len,allowDecimals:!1},"size",n),y(r,{min:0,max:this.len,allowDecimals:!1},"offset",n),c(e,"options",n);var o=e.height,i=void 0!==o&&o,a=e.range,s=void 0===a?[]:a,p=e.lag,h=void 0===p?0:p,v=e.decimals,d=void 0===v?null:v;return u(s,"options.range",n),y(h,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),f(i,"options.height",n),null!==d&&y(d,{min:1,max:15,allowDecimals:!1},"decimals",n),this.inputParams.push({key:n,order:0,params:[t,r,{height:i,range:s,lag:h,decimals:d}]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="volumeOscillator";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');l(this),y(t,{min:1,max:this.len,allowDecimals:!1},"fastsize",n),y(r,{min:t,max:this.len,allowDecimals:!1},"slowsize",n),c(e,"options",n);var o=e.lag,i=void 0===o?0:o;return y(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),this.inputParams.push({key:n,order:0,params:[t,r,{lag:i}]}),this}},{key:"dateTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="dateTime";l(this),c(t,"options",r);var e=t.lag,n=void 0===e?0:e,o=t.oneHot,i=void 0!==o&&o;y(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),f(i,"options.oneHot",r);var a=i?"one_hot_":"",u=hn(hn(hn(hn(hn({},"".concat(a,"month"),12),"".concat(a,"day_of_the_month"),31),"".concat(a,"day_of_the_week"),7),"".concat(a,"hour"),24),"".concat(a,"minute"),60),s={prefix:a,colKeySizes:u,colKeys:Object.keys(u)};return this.inputParams.push({key:r,order:0,params:[{lag:n,oneHot:i,precompute:s}]}),this}},{key:"scaler",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"zscore",r=arguments.length>1?arguments[1]:void 0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="scaler";l(this),y(r,{min:1,max:this.len,allowDecimals:!1},"size",n),c(e,"options",n);var o=e.group,i=void 0!==o&&o,a=e.range,h=void 0===a?[0,1]:a,v=e.lag,d=void 0===v?0:v,m=e.colKeys,b=void 0===m?[]:m;u(b,"options.colKeys",n),f(i,"options.group",n),p(h,"options.range",n),s(["minmax","zscore"],t,"options.type",n);var g={groupKey:"".concat(t,"_").concat(r),groupKeyLen:b.length},w=!1,S=rn(b,n);return S>=10&&(w=!0),this.inputParams.push({key:n,order:S,params:[r,b,{type:t,group:i,range:h,lag:d,precomputed:g,secondaryLoop:w}]}),this}},{key:"classifier",value:function(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l(this);var n="classifier";y(r,{max:this.len,allowDecimals:!1},"trainingSize",n),c(e,"options",n);var o=e.retrain,i=void 0!==o&&o,a=e.trainingCols,p=void 0===a?[]:a,h=e.type,v=void 0===h?"KNN":h,d=e.lookback,m=void 0===d?0:d,b=e.findGroups,g=void 0===b?[]:b,w=e.predictions,S=void 0===w?2:w,O=e.horizon,A=void 0===O?2:O,j=e.modelArgs,P=void 0===j?void 0:j,N=e.filterCallback,x=void 0===N?function(){return!0}:N;if(void 0!==P&&("object"!==pn(P)||null===P||Array.isArray(P)))throw new TypeError('"modelArgs" must be either undefined or a plain object in '.concat(v));var _=null!==(t=e.yCallback)&&void 0!==t?t:cn;if("function"!=typeof _)throw new Error('"yCallback" must be a function in the following format:\n\n---\n\nconst yCallback = '.concat(cn.toString(),"\n\n---\n\n"));if(s(Object.keys(sn),v,"options.type",n),!this.ML.classes.hasOwnProperty(v))throw new Error('"'.concat(v,'" isn’t available because its library wasn’t imported into OHLCV_INDICATORS.ML.'));f(i,"options.retrain",n),u(p,"options.trainingCols",n),y(A,{min:1,max:this.len,allowDecimals:!1},"options.horizon",n),y(m,{max:0,allowDecimals:!1},"options.lookback",n),y(S,{min:1,allowDecimals:!1},"options.predictions",n);var k=mn(p);if(u(g,"options.findGroups","scaler")&&g.length>0){var C,E=vn(g);try{for(E.s();!(C=E.n()).done;){var T=C.value,I=T.type,M=void 0===I?"":I,R=T.size,D=T.groupName,F=void 0===D?"":D;if(!M||!R&&!F||R&&F)throw new Error('If "options.findGroups" array is set, each item must be an object that includes the "type" (mandatory) and either "size" or "groupName" (choose 1) used to locate previously scaled (minmax or zscore) groups.');k.push(M.toString(),F.toString())}}catch(t){E.e(t)}finally{E.f()}}else if(0===p.length)throw new Error('"trainingCols" array is empty in '.concat(n));var L=sn[v],z=L.shortName,Y=L.flatY,U="cla_".concat(z,"_").concat(r,"_prediction");if(this.isAlreadyComputed.has(U))throw new Error("Each classifier must have a unique pair of “type” and trainingSize.\nThis rule ensures that your output columns are labeled unambiguously.\n"+'You provided a duplicate: type="'.concat(v,'" with trainingSize=').concat(r,"."));var G={lookbackAbs:Math.abs(m)+1,flatY:Y,prefix:U};this.isAlreadyComputed.add(U);var K=rn(k,n),V=sn[v],H=this.ML.classes[v];return this.inputParams.push({key:n,order:K,params:[r,{yCallback:_,predictions:S,lookback:m,retrain:i,trainingCols:p,findGroups:g,horizon:A,type:v,modelArgs:P,precompute:G,filterCallback:x,modelConfig:V,modelClass:H}]}),this}},{key:"regressor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l(this);var e="regressor";y(t,{max:this.len,allowDecimals:!1},"trainingSize",e),c(r,"options",e);var n=r.retrain,o=void 0!==n&&n,i=r.target,a=void 0===i?"close":i,p=r.predictions,v=void 0===p?1:p,d=r.trainingCols,m=void 0===d?[]:d,b=r.type,g=void 0===b?"SimpleLinearRegression":b,w=r.lookback,S=void 0===w?0:w,O=r.findGroups,A=void 0===O?[]:O,j=r.modelArgs,P=void 0===j?void 0:j,N=r.filterCallback,x=void 0===N?function(){return!0}:N;if(s(Object.keys(fn),g,"type",e),!this.ML.classes.hasOwnProperty(g))throw new Error('"'.concat(g,'" isn’t available because its library wasn’t imported into OHLCV_INDICATORS.ML.'));f(o,"options.retrain",e),h(a,"options.target",e),y(v,{min:1,allowDecimals:!1},"predictions",e),y(S,{max:0,allowDecimals:!1},"lookback",e),u(m,"options.trainingCols",e);var _=fn[g],k=_.shortName,C=_.flatX,E=_.flatY,T="reg_".concat(k,"_").concat(t,"_").concat(a,"_prediction"),I=mn(m);if(u(A,"options.findGroups","scaler")&&A.length>0){var M,R=vn(A);try{for(R.s();!(M=R.n()).done;){var D=M.value,F=D.type,L=void 0===F?"":F,z=D.size,Y=D.groupName,U=void 0===Y?"":Y;if(!L||!z&&!U||z&&U)throw new Error('If "options.findGroups" array is set, each item must be an object that includes the "type" (mandatory) and either "size" or "groupName" (choose 1) used to locate previously scaled (minmax or zscore) groups.');I.push(L.toString(),U.toString())}}catch(t){R.e(t)}finally{R.f()}}else if(0===m.length&&!1===C)throw new Error('"trainingCols" array is empty in '.concat(e," ").concat(g));if(C){if(m.length>0)throw new Error("If regressor type is ".concat(g,' then leave "options.trainingCols" array empty.'));if(S>0)throw new Error("If regressor type is ".concat(g,' then "options.lookback" must be 0.'));if(A.length>0)throw new Error("If regressor type is ".concat(g,' then "options.findGroups" must be null.'));m.push(a)}if(this.isAlreadyComputed.has(T))throw new Error('Each regressor must have a unique "type", "trainingSize" and "target".\nThis rule ensures that your output columns are labeled unambiguously.\n'+'You provided a duplicate: type="'.concat(g,'", trainingSize=').concat(t," target=").concat(a,"."));var G={lookbackAbs:Math.abs(S)+1,flatX:C,flatY:E,prefix:T};this.isAlreadyComputed.add(T);var K=rn(I,e),V=fn[g],H=this.ML.classes[g];return this.inputParams.push({key:e,order:K,params:[t,{target:a,predictions:v,retrain:o,lookback:S,trainingCols:m,findGroups:A,type:g,modelArgs:P,precompute:G,filterCallback:x,modelConfig:V,modelClass:H}]}),this}},{key:"pca",value:function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="pca";y(r,{min:1,max:this.len},"trainingSize",n),h(t,"suffix",n),c(e,"options",n);var o=e.findGroups,i=void 0===o?[]:o,a=e.trainingCols,l=void 0===a?[]:a,p=e.lookback,v=void 0===p?0:p,d=e.filterCallback,m=void 0===d?function(){return!0}:d;u(l,"options.trainigCols",n),y(v,{min:0,max:this.len,allowDecimals:!1},"options.lookback",n),void 0!==e.modelArgs?c(e.modelArgs,"options.modelArgs",n):e.modelArgs={};var b=function(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?yn(Object(e),!0).forEach((function(r){hn(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):yn(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}({showSource:!1,storeModel:!1,isCovarianceMatrix:!1,method:"NIPALS",center:!0,scale:!1,nCompNIPALS:5,ignoreZeroVariance:!1},e.modelArgs);f(b.showSource,"options.modelArgs.showSource",n),f(b.storeModel,"options.modelArgs.storeModel",n),f(b.isCovarianceMatrix,"options.modelArgs.isCovarianceMatrix",n),f(b.center,"options.modelArgs.center",n),f(b.scale,"options.modelArgs.scale",n),f(b.ignoreZeroVariance,"options.modelArgs.ignoreZeroVariance",n),s(["SVD","NIPALS","covarianceMatrix"],b.method,"options.modelArgs.method",n),y(b.nCompNIPALS,{min:1},"options.modelArgs.nCompNIPALS",n);var g=[];if(u(i,"options.findGroups","pca")&&i.length>0){var w,S=vn(i);try{for(S.s();!(w=S.n()).done;){var O=w.value,A=O.type,j=void 0===A?"":A,P=O.size,N=O.groupName,x=void 0===N?"":N;if(!j||!P&&!x||P&&x)throw new Error('If "options.findGroups" array is set, each item must be an object that includes the "type" (mandatory) and either "size" or "groupName" (choose 1) used to locate previously scaled (minmax or zscore) groups.');g.push(j.toString(),x.toString())}}catch(t){S.e(t)}finally{S.f()}}var _=rn(g,n),k="pca_".concat(t,"_").concat(r);if(this.isAlreadyComputed.has(k))throw new Error('Each regressor must have a unique "suffix" param.\nThis rule ensures that your output columns are labeled unambiguously.\n'+'You provided a duplicate: type="'.concat(t,'".'));var C=Math.abs(v)+1;return this.isAlreadyComputed.add(k),this.inputParams.push({key:n,order:_,params:[{prefix:k,trainingSize:r,findGroups:i,trainingCols:l,lookbackAbs:C,modelArgs:b,filterCallback:m}]}),this}},{key:"exportTrainedModels",value:function(){return function(t){var r,e,n,o=t.ML,i=t.inputParams,a=o.models,l={},u=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=ln(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(i);try{for(u.s();!(r=u.n()).done;){var c=r.value,s=c.key,f=c.params;if("classifier"===s||"regressor"===s){var y=(n=2,function(t){if(Array.isArray(t))return t}(e=f)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(e,n)||ln(e,n)||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.")}()),p=(y[0],y[1]),h=p.type,v=p.predictions,d=p.precompute,m=d.flatY,b=d.prefix,g=m?v:1,w=void 0;"regressor"===s?w=fn[h].exportModel:"classifier"===s&&(w=sn[h].exportModel);for(var S=0;S<g;S++){var O="".concat(b,"_").concat(S+1);l[O]=w(a[O])}}}}catch(t){u.e(t)}finally{u.f()}return l}(this)}},{key:"mapCols",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["change"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};l(this);var n="mapCols";null==r&&(r=je),c(e,"options",n);var o=e.lag,i=void 0===o?0:o;u(t,"newCols",n),y(i,{min:0,allowDecimals:!1},"options.lag",n);var a=rn(t,n);return this.inputParams.push({key:n,order:a,params:[t,r,{lag:i}]}),this}}],r&&wn(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}()})(),OHLCV_INDICATORS=r})();