@guihz/trading-vue-editor-tes 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -51,7 +51,7 @@ Example:
51
51
  * Dual licensed under the MIT or GPL Version 2 licenses.
52
52
  **/(function(i,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function s(v,E){if(isNaN(v=parseInt(v,10)))throw g();return v*E}function u(v,E){if(E===0)throw w();var b=Object.create(_.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var N=m(v,E);return b.n=v/N,b.d=E/N,b}function l(v){for(var E={},b=v,N=2,x=4;x<=b;){for(;b%N===0;)b/=N,E[N]=(E[N]||0)+1;x+=1+2*N++}return b!==v?b>1&&(E[b]=(E[b]||0)+1):E[v]=(E[v]||0)+1,E}var f=function(v,E){var b=0,N=1,x=1,F=0,M=0,S=0,$=1,C=1,I=0,R=1,U=1,q=1,k=1e7,P;if(v!=null)if(E!==void 0){if(b=v,N=E,x=b*N,b%1!==0||N%1!==0)throw y()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,N=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(N=v[1]);else throw g();x=b*N;break}case"number":{if(v<0&&(x=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(C=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=C);R<=k&&q<=k;)if(P=(I+U)/(R+q),v===P){R+q<=k?(b=I+U,N=R+q):q>R?(b=U,N=q):(b=I,N=R);break}else v>P?(I+=U,R+=q):(U+=I,q+=R),R>k?(b=U,N=q):(b=I,N=R);b*=C}else(isNaN(v)||isNaN(E))&&(N=b=NaN);break}case"string":{if(R=v.match(/\d+|./g),R===null)throw g();if(R[I]==="-"?(x=-1,I++):R[I]==="+"&&I++,R.length===I+1?M=s(R[I++],x):R[I+1]==="."||R[I]==="."?(R[I]!=="."&&(F=s(R[I++],x)),I++,(I+1===R.length||R[I+1]==="("&&R[I+3]===")"||R[I+1]==="'"&&R[I+3]==="'")&&(M=s(R[I],x),$=Math.pow(10,R[I].length),I++),(R[I]==="("&&R[I+2]===")"||R[I]==="'"&&R[I+2]==="'")&&(S=s(R[I+1],x),C=Math.pow(10,R[I+1].length)-1,I+=3)):R[I+1]==="/"||R[I+1]===":"?(M=s(R[I],x),$=s(R[I+2],1),I+=3):R[I+3]==="/"&&R[I+1]===" "&&(F=s(R[I],x),M=s(R[I+2],x),$=s(R[I+4],1),I+=5),R.length<=I){N=$*C,x=b=S+N*F+C*M;break}}default:throw g()}if(N===0)throw w();n.s=x<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(N)};function p(v,E,b){for(var N=1;E>0;v=v*v%b,E>>=1)E&1&&(N=N*v%b);return N}function h(v,E){for(;E%2===0;E/=2);for(;E%5===0;E/=5);if(E===1)return 0;for(var b=10%E,N=1;b!==1;N++)if(b=b*10%E,N>r)return 0;return N}function c(v,E,b){for(var N=1,x=p(10,b,E),F=0;F<300;F++){if(N===x)return F;N=N*10%E,x=x*10%E}return 0}function m(v,E){if(!v)return E;if(!E)return v;for(;;){if(v%=E,!v)return E;if(E%=v,!E)return v}}function _(v,E){if(f(v,E),this instanceof _)v=m(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return u(n.s*n.n,n.d)}var w=function(){return new Error("Division by Zero")},g=function(){return new Error("Invalid argument")},y=function(){return new Error("Parameters must be integer")};_.prototype={s:1,n:0,d:1,abs:function(){return u(this.n,this.d)},neg:function(){return u(-this.s*this.n,this.d)},add:function(v,E){return f(v,E),u(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,E){return f(v,E),u(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,E){return f(v,E),u(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,E){return f(v,E),u(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return u(this.s*this.n,this.d)},mod:function(v,E){if(isNaN(this.n)||isNaN(this.d))return new _(NaN);if(v===void 0)return u(this.s*this.n%this.d,1);if(f(v,E),n.n===0&&this.d===0)throw w();return u(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(v,E){return f(v,E),u(m(n.n,this.n)*m(n.d,this.d),n.d*this.d)},lcm:function(v,E){return f(v,E),n.n===0&&this.n===0?u(0,1):u(n.n*this.n,m(n.n,this.n)*m(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new _(NaN):u(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new _(NaN):u(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new _(NaN):u(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return u(this.s*this.d,this.n)},pow:function(v,E){if(f(v,E),n.d===1)return n.s<0?u(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):u(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=l(this.n),N=l(this.d),x=1,F=1;for(var M in b)if(M!=="1"){if(M==="0"){x=0;break}if(b[M]*=n.n,b[M]%n.d===0)b[M]/=n.d;else return null;x*=Math.pow(M,b[M])}for(var M in N)if(M!=="1"){if(N[M]*=n.n,N[M]%n.d===0)N[M]/=n.d;else return null;F*=Math.pow(M,N[M])}return n.s<0?u(F,x):u(x,F)},equals:function(v,E){return f(v,E),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,E){f(v,E);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var E=this.abs(),b=E.toContinued(),N=1;N<b.length;N++){for(var x=u(b[N-1],1),F=N-2;F>=0;F--)x=x.inverse().add(b[F]);if(Math.abs(x.sub(E).valueOf())<v)return x.mul(this.s)}return this},divisible:function(v,E){return f(v,E),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var E,b="",N=this.n,x=this.d;return this.s<0&&(b+="-"),x===1?b+=N:(v&&(E=Math.floor(N/x))>0&&(b+=E,b+=" ",N%=x),b+=N,b+="/",b+=x),b},toLatex:function(v){var E,b="",N=this.n,x=this.d;return this.s<0&&(b+="-"),x===1?b+=N:(v&&(E=Math.floor(N/x))>0&&(b+=E,N%=x),b+="\\frac{",b+=N,b+="}{",b+=x,b+="}"),b},toContinued:function(){var v,E=this.n,b=this.d,N=[];if(isNaN(E)||isNaN(b))return N;do N.push(Math.floor(E/b)),v=E%b,E=b,b=v;while(E!==1);return N},toString:function(v){var E=this.n,b=this.d;if(isNaN(E)||isNaN(b))return"NaN";v=v||15;var N=h(E,b),x=c(E,b,N),F=this.s<0?"-":"";if(F+=E/b|0,E%=b,E*=10,E&&(F+="."),N){for(var M=x;M--;)F+=E/b|0,E%=b,E*=10;F+="(";for(var M=N;M--;)F+=E/b|0,E%=b,E*=10;F+=")"}else for(var M=v;E&&M--;)F+=E/b|0,E%=b,E*=10;return F}},Object.defineProperty(_,"__esModule",{value:!0}),_.default=_,_.Fraction=_,i.exports=_})()})(_f);var Ym=_f.exports,Hr=jt(Ym),jm="Fraction",Zm=[],Gm=mt(jm,Zm,()=>(Object.defineProperty(Hr,"name",{value:"Fraction"}),Hr.prototype.constructor=Hr,Hr.prototype.type="Fraction",Hr.prototype.isFraction=!0,Hr.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Hr.fromJSON=function(i){return new Hr(i)},Hr),{isClass:!0}),Km="Matrix",Hm=[],Jm=mt(Km,Hm,()=>{function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.prototype.type="Matrix",i.prototype.isMatrix=!0,i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},i.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i},{isClass:!0});function wf(i){return Object.keys(i.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var Xm="DenseMatrix",Vm=["Matrix"],Qm=mt(Xm,Vm,i=>{var{Matrix:t}=i;function e(h,c){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(c&&!Ur(c))throw new Error("Invalid datatype: "+c);if(fe(h))h.type==="DenseMatrix"?(this._data=te(h._data),this._size=te(h._size),this._datatype=c||h._datatype):(this._data=h.toArray(),this._size=h.size(),this._datatype=c||h._datatype);else if(h&&ge(h.data)&&ge(h.size))this._data=h.data,this._size=h.size,Zl(this._data,this._size),this._datatype=c||h.datatype;else if(ge(h))this._data=p(h),this._size=Ae(this._data),Zl(this._data,this._size),this._datatype=c;else{if(h)throw new TypeError("Unsupported type of data ("+cn(h)+")");this._data=[],this._size=[0],this._datatype=c}}e.prototype=new t,e.prototype.createDenseMatrix=function(h,c){return new e(h,c)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Es(this._data,cn)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(h,c){return new e(h,c)},e.prototype.subset=function(h,c,m){switch(arguments.length){case 1:return r(this,h);case 2:case 3:return s(this,h,c,m);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(h){if(!ge(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Zt(h.length,this._size.length);for(var c=0;c<h.length;c++)ve(h[c],this._size[c]);for(var m=this._data,_=0,w=h.length;_<w;_++){var g=h[_];ve(g,m.length),m=m[g]}return m},e.prototype.set=function(h,c,m){if(!ge(h))throw new TypeError("Array expected");if(h.length<this._size.length)throw new Zt(h.length,this._size.length,"<");var _,w,g,y=h.map(function(E){return E+1});f(this,y,m);var v=this._data;for(_=0,w=h.length-1;_<w;_++)g=h[_],ve(g,v.length),v=v[g];return g=h[h.length-1],ve(g,v.length),v[g]=c,this};function r(h,c){if(!na(c))throw new TypeError("Invalid index");var m=c.isScalar();if(m)return h.get(c.min());var _=c.size();if(_.length!==h._size.length)throw new Zt(_.length,h._size.length);for(var w=c.min(),g=c.max(),y=0,v=h._size.length;y<v;y++)ve(w[y],h._size[y]),ve(g[y],h._size[y]);return new e(n(h._data,c,_.length,0),h._datatype)}function n(h,c,m,_){var w=_===m-1,g=c.dimension(_);return w?g.map(function(y){return ve(y,h.length),h[y]}).valueOf():g.map(function(y){ve(y,h.length);var v=h[y];return n(v,c,m,_+1)}).valueOf()}function s(h,c,m,_){if(!c||c.isIndex!==!0)throw new TypeError("Invalid index");var w=c.size(),g=c.isScalar(),y;if(fe(m)?(y=m.size(),m=m.valueOf()):y=Ae(m),g){if(y.length!==0)throw new TypeError("Scalar expected");h.set(c.min(),m,_)}else{if(!ni(y,w))try{y.length===0?m=Vl([m],w):m=Vl(m,w),y=Ae(m)}catch{}if(w.length<h._size.length)throw new Zt(w.length,h._size.length,"<");if(y.length<w.length){for(var v=0,E=0;w[v]===1&&y[v]===1;)v++;for(;w[v]===1;)E++,v++;m=Kl(m,w.length,E,y)}if(!ni(w,y))throw new Zt(w,y,">");var b=c.max().map(function(F){return F+1});f(h,b,_);var N=w.length,x=0;u(h._data,c,m,N,x)}return h}function u(h,c,m,_,w){var g=w===_-1,y=c.dimension(w);g?y.forEach(function(v,E){ve(v),h[v]=m[E[0]]}):y.forEach(function(v,E){ve(v),u(h[v],c,m[E[0]],_,w+1)})}e.prototype.resize=function(h,c,m){if(!qi(h))throw new TypeError("Array or Matrix expected");var _=h.valueOf().map(g=>Array.isArray(g)&&g.length===1?g[0]:g),w=m?this.clone():this;return l(w,_,c)};function l(h,c,m){if(c.length===0){for(var _=h._data;ge(_);)_=_[0];return _}return h._size=c.slice(0),h._data=ua(h._data,h._size,m),h}e.prototype.reshape=function(h,c){var m=c?this.clone():this;m._data=fa(m._data,h);var _=m._size.reduce((w,g)=>w*g);return m._size=ca(h,_),m};function f(h,c,m){for(var _=h._size.slice(0),w=!1;_.length<c.length;)_.push(0),w=!0;for(var g=0,y=c.length;g<y;g++)c[g]>_[g]&&(_[g]=c[g],w=!0);w&&l(h,_,m)}e.prototype.clone=function(){var h=new e({data:te(this._data),size:te(this._size),datatype:this._datatype});return h},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(h){var c=this,m=wf(h),_=function y(v,E){return ge(v)?v.map(function(b,N){return y(b,E.concat(N))}):m===1?h(v):m===2?h(v,E):h(v,E,c)},w=_(this._data,[]),g=this._datatype!==void 0?Es(w,cn):void 0;return new e(w,g)},e.prototype.forEach=function(h){var c=this,m=function _(w,g){ge(w)?w.forEach(function(y,v){_(y,g.concat(v))}):h(w,g,c)};m(this._data,[])},e.prototype[Symbol.iterator]=function*(){var h=function*c(m,_){if(ge(m))for(var w=0;w<m.length;w++)yield*c(m[w],_.concat(w));else yield{value:m,index:_}};yield*h(this._data,[])},e.prototype.rows=function(){var h=[],c=this.size();if(c.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var m=this._data;for(var _ of m)h.push(new e([_],this._datatype));return h},e.prototype.columns=function(){var h=this,c=[],m=this.size();if(m.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var _=this._data,w=function(v){var E=_.map(b=>[b[v]]);c.push(new e(E,h._datatype))},g=0;g<m[1];g++)w(g);return c},e.prototype.toArray=function(){return te(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(h){return se(this._data,h)},e.prototype.toString=function(){return se(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(h){if(h){if(ye(h)&&(h=h.toNumber()),!ue(h)||!he(h))throw new TypeError("The parameter k must be an integer number")}else h=0;for(var c=h>0?h:0,m=h<0?-h:0,_=this._size[0],w=this._size[1],g=Math.min(_-m,w-c),y=[],v=0;v<g;v++)y[v]=this._data[v+m][v+c];return new e({data:y,size:[g],datatype:this._datatype})},e.diagonal=function(h,c,m,_){if(!ge(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(M){if(ye(M)&&(M=M.toNumber()),!ue(M)||!he(M)||M<1)throw new Error("Size values must be positive integers");return M}),m){if(ye(m)&&(m=m.toNumber()),!ue(m)||!he(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var w=m>0?m:0,g=m<0?-m:0,y=h[0],v=h[1],E=Math.min(y-g,v-w),b;if(ge(c)){if(c.length!==E)throw new Error("Invalid value array length");b=function(S){return c[S]}}else if(fe(c)){var N=c.size();if(N.length!==1||N[0]!==E)throw new Error("Invalid matrix length");b=function(S){return c.get([S])}}else b=function(){return c};_||(_=ye(b(0))?b(0).mul(0):0);var x=[];if(h.length>0){x=ua(x,h,_);for(var F=0;F<E;F++)x[F+g][F+w]=b(F)}return new e({data:x,size:[y,v]})},e.fromJSON=function(h){return new e(h)},e.prototype.swapRows=function(h,c){if(!ue(h)||!he(h)||!ue(c)||!he(c))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return ve(h,this._size[0]),ve(c,this._size[0]),e._swapRows(h,c,this._data),this},e._swapRows=function(h,c,m){var _=m[h];m[h]=m[c],m[c]=_};function p(h){return fe(h)?p(h.valueOf()):ge(h)?h.map(p):h}return e},{isClass:!0});function tg(i){var t=i.length,e=i[0].length,r,n,s=[];for(n=0;n<e;n++){var u=[];for(r=0;r<t;r++)u.push(i[r][n]);s.push(u)}return s}function Ts(i){for(var t=0;t<i.length;t++)if(qi(i[t]))return!0;return!1}function Wi(i,t){fe(i)&&(i=i.valueOf());for(var e=0,r=i.length;e<r;e++){var n=i[e];Array.isArray(n)?Wi(n,t):t(n)}}function Ir(i,t,e){return i&&typeof i.map=="function"?i.map(function(r){return Ir(r,t)}):t(i)}function ya(i,t,e){var r=Array.isArray(i)?Ae(i):i.size();if(t<0||t>=r.length)throw new hn(t,r.length);return fe(i)?i.create($s(i.valueOf(),t,e)):$s(i,t,e)}function $s(i,t,e){var r,n,s,u;if(t<=0)if(Array.isArray(i[0])){for(u=tg(i),n=[],r=0;r<u.length;r++)n[r]=$s(u[r],t-1,e);return n}else{for(s=i[0],r=1;r<i.length;r++)s=e(s,i[r]);return s}else{for(n=[],r=0;r<i.length;r++)n[r]=$s(i[r],t-1,e);return n}}var Df="isInteger",eg=["typed"],rg=mt(Df,eg,i=>{var{typed:t}=i;return t(Df,{number:he,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),yf="number",Os="number, number";function bf(i){return Math.abs(i)}bf.signature=yf;function Ef(i,t){return i+t}Ef.signature=Os;function Af(i,t){return i-t}Af.signature=Os;function xf(i,t){return i*t}xf.signature=Os;function Cf(i){return-i}Cf.signature=yf;function Ff(i,t){return i*i<1&&t===1/0||i*i>1&&t===-1/0?0:Math.pow(i,t)}Ff.signature=Os;var Mf="number";function Nf(i){return i===0}Nf.signature=Mf;function Sf(i){return Number.isNaN(i)}Sf.signature=Mf;var Bf="isNumeric",ng=["typed"],ig=mt(Bf,ng,i=>{var{typed:t}=i;return t(Bf,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),If="isZero",sg=["typed"],og=mt(If,sg,i=>{var{typed:t}=i;return t(If,{number:Nf,BigNumber:function(r){return r.isZero()},Complex:function(r){return r.re===0&&r.im===0},Fraction:function(r){return r.d===1&&r.n===0},Unit:t.referToSelf(e=>r=>t.find(e,r.valueType())(r.value)),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),Tf="isNaN",ag=["typed"],ug=mt(Tf,ag,i=>{var{typed:t}=i;return t(Tf,{number:Sf,BigNumber:function(r){return r.isNaN()},Fraction:function(r){return!1},Complex:function(r){return r.isNaN()},Unit:function(r){return Number.isNaN(r.value)},"Array | Matrix":function(r){return Ir(r,Number.isNaN)}})});function Rs(i,t,e){if(e==null)return i.eq(t);if(i.eq(t))return!0;if(i.isNaN()||t.isNaN())return!1;if(i.isFinite()&&t.isFinite()){var r=i.minus(t).abs();if(r.isZero())return!0;var n=i.constructor.max(i.abs(),t.abs());return r.lte(n.times(e))}return!1}function lg(i,t,e){return zn(i.re,t.re,e)&&zn(i.im,t.im,e)}var Ls=mt("compareUnits",["typed"],i=>{var{typed:t}=i;return{"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)})}}),Ps="equalScalar",fg=["typed","config"],cg=mt(Ps,fg,i=>{var{typed:t,config:e}=i,r=Ls({typed:t});return t(Ps,{"boolean, boolean":function(s,u){return s===u},"number, number":function(s,u){return zn(s,u,e.epsilon)},"BigNumber, BigNumber":function(s,u){return s.eq(u)||Rs(s,u,e.epsilon)},"Fraction, Fraction":function(s,u){return s.equals(u)},"Complex, Complex":function(s,u){return lg(s,u,e.epsilon)}},r)});mt(Ps,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Ps,{"number, number":function(n,s){return zn(n,s,e.epsilon)}})});var hg="SparseMatrix",pg=["typed","equalScalar","Matrix"],dg=mt(hg,pg,i=>{var{typed:t,equalScalar:e,Matrix:r}=i;function n(g,y){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!Ur(y))throw new Error("Invalid datatype: "+y);if(fe(g))s(this,g,y);else if(g&&ge(g.index)&&ge(g.ptr)&&ge(g.size))this._values=g.values,this._index=g.index,this._ptr=g.ptr,this._size=g.size,this._datatype=y||g.datatype;else if(ge(g))u(this,g,y);else{if(g)throw new TypeError("Unsupported type of data ("+cn(g)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function s(g,y,v){y.type==="SparseMatrix"?(g._values=y._values?te(y._values):void 0,g._index=te(y._index),g._ptr=te(y._ptr),g._size=te(y._size),g._datatype=v||y._datatype):u(g,y.valueOf(),v||y._datatype)}function u(g,y,v){g._values=[],g._index=[],g._ptr=[],g._datatype=v;var E=y.length,b=0,N=e,x=0;if(Ur(v)&&(N=t.find(e,[v,v])||e,x=t.convert(0,v)),E>0){var F=0;do{g._ptr.push(g._index.length);for(var M=0;M<E;M++){var S=y[M];if(ge(S)){if(F===0&&b<S.length&&(b=S.length),F<S.length){var $=S[F];N($,x)||(g._values.push($),g._index.push(M))}}else F===0&&b<1&&(b=1),N(S,x)||(g._values.push(S),g._index.push(M))}F++}while(F<b)}g._ptr.push(g._index.length),g._size=[E,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(g,y){return new n(g,y)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Es(this._values,cn)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(g,y){return new n(g,y)},n.prototype.density=function(){var g=this._size[0],y=this._size[1];return g!==0&&y!==0?this._index.length/(g*y):0},n.prototype.subset=function(g,y,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,g);case 2:case 3:return f(this,g,y,v);default:throw new SyntaxError("Wrong number of arguments")}};function l(g,y){if(!na(y))throw new TypeError("Invalid index");var v=y.isScalar();if(v)return g.get(y.min());var E=y.size();if(E.length!==g._size.length)throw new Zt(E.length,g._size.length);var b,N,x,F,M=y.min(),S=y.max();for(b=0,N=g._size.length;b<N;b++)ve(M[b],g._size[b]),ve(S[b],g._size[b]);var $=g._values,C=g._index,I=g._ptr,R=y.dimension(0),U=y.dimension(1),q=[],k=[];R.forEach(function(V,tt){k[V]=tt[0],q[V]=!0});var P=$?[]:void 0,K=[],G=[];return U.forEach(function(V){for(G.push(K.length),x=I[V],F=I[V+1];x<F;x++)b=C[x],q[b]===!0&&(K.push(k[b]),P&&P.push($[x]))}),G.push(K.length),new n({values:P,index:K,ptr:G,size:E,datatype:g._datatype})}function f(g,y,v,E){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var b=y.size(),N=y.isScalar(),x;if(fe(v)?(x=v.size(),v=v.toArray()):x=Ae(v),N){if(x.length!==0)throw new TypeError("Scalar expected");g.set(y.min(),v,E)}else{if(b.length!==1&&b.length!==2)throw new Zt(b.length,g._size.length,"<");if(x.length<b.length){for(var F=0,M=0;b[F]===1&&x[F]===1;)F++;for(;b[F]===1;)M++,F++;v=Kl(v,b.length,M,x)}if(!ni(b,x))throw new Zt(b,x,">");if(b.length===1){var S=y.dimension(0);S.forEach(function(I,R){ve(I),g.set([I,0],v[R[0]],E)})}else{var $=y.dimension(0),C=y.dimension(1);$.forEach(function(I,R){ve(I),C.forEach(function(U,q){ve(U),g.set([I,U],v[R[0]][q[0]],E)})})}}return g}n.prototype.get=function(g){if(!ge(g))throw new TypeError("Array expected");if(g.length!==this._size.length)throw new Zt(g.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=g[0],v=g[1];ve(y,this._size[0]),ve(v,this._size[1]);var E=p(y,this._ptr[v],this._ptr[v+1],this._index);return E<this._ptr[v+1]&&this._index[E]===y?this._values[E]:0},n.prototype.set=function(g,y,v){if(!ge(g))throw new TypeError("Array expected");if(g.length!==this._size.length)throw new Zt(g.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var E=g[0],b=g[1],N=this._size[0],x=this._size[1],F=e,M=0;Ur(this._datatype)&&(F=t.find(e,[this._datatype,this._datatype])||e,M=t.convert(0,this._datatype)),(E>N-1||b>x-1)&&(m(this,Math.max(E+1,N),Math.max(b+1,x),v),N=this._size[0],x=this._size[1]),ve(E,N),ve(b,x);var S=p(E,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===E?F(y,M)?h(S,b,this._values,this._index,this._ptr):this._values[S]=y:F(y,M)||c(S,E,b,y,this._values,this._index,this._ptr),this};function p(g,y,v,E){if(v-y===0)return v;for(var b=y;b<v;b++)if(E[b]===g)return b;return y}function h(g,y,v,E,b){v.splice(g,1),E.splice(g,1);for(var N=y+1;N<b.length;N++)b[N]--}function c(g,y,v,E,b,N,x){b.splice(g,0,E),N.splice(g,0,y);for(var F=v+1;F<x.length;F++)x[F]++}n.prototype.resize=function(g,y,v){if(!qi(g))throw new TypeError("Array or Matrix expected");var E=g.valueOf().map(N=>Array.isArray(N)&&N.length===1?N[0]:N);if(E.length!==2)throw new Error("Only two dimensions matrix are supported");E.forEach(function(N){if(!ue(N)||!he(N)||N<0)throw new TypeError("Invalid size, must contain positive integers (size: "+se(E)+")")});var b=v?this.clone():this;return m(b,E[0],E[1],y)};function m(g,y,v,E){var b=E||0,N=e,x=0;Ur(g._datatype)&&(N=t.find(e,[g._datatype,g._datatype])||e,x=t.convert(0,g._datatype),b=t.convert(b,g._datatype));var F=!N(b,x),M=g._size[0],S=g._size[1],$,C,I;if(v>S){for(C=S;C<v;C++)if(g._ptr[C]=g._values.length,F)for($=0;$<M;$++)g._values.push(b),g._index.push($);g._ptr[v]=g._values.length}else v<S&&(g._ptr.splice(v+1,S-v),g._values.splice(g._ptr[v],g._values.length),g._index.splice(g._ptr[v],g._index.length));if(S=v,y>M){if(F){var R=0;for(C=0;C<S;C++){g._ptr[C]=g._ptr[C]+R,I=g._ptr[C+1]+R;var U=0;for($=M;$<y;$++,U++)g._values.splice(I+U,0,b),g._index.splice(I+U,0,$),R++}g._ptr[S]=g._values.length}}else if(y<M){var q=0;for(C=0;C<S;C++){g._ptr[C]=g._ptr[C]-q;var k=g._ptr[C],P=g._ptr[C+1]-q;for(I=k;I<P;I++)$=g._index[I],$>y-1&&(g._values.splice(I,1),g._index.splice(I,1),q++)}g._ptr[C]=g._values.length}return g._size[0]=y,g._size[1]=v,g}n.prototype.reshape=function(g,y){if(!ge(g))throw new TypeError("Array expected");if(g.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");g.forEach(function(V){if(!ue(V)||!he(V)||V<=-2||V===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+se(g)+")")});var v=this._size[0]*this._size[1];g=ca(g,v);var E=g[0]*g[1];if(v!==E)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=y?this.clone():this;if(this._size[0]===g[0]&&this._size[1]===g[1])return b;for(var N=[],x=0;x<b._ptr.length;x++)for(var F=0;F<b._ptr[x+1]-b._ptr[x];F++)N.push(x);for(var M=b._values.slice(),S=b._index.slice(),$=0;$<b._index.length;$++){var C=S[$],I=N[$],R=C*b._size[1]+I;N[$]=R%g[1],S[$]=Math.floor(R/g[1])}b._values.length=0,b._index.length=0,b._ptr.length=g[1]+1,b._size=g.slice();for(var U=0;U<b._ptr.length;U++)b._ptr[U]=0;for(var q=0;q<M.length;q++){var k=S[q],P=N[q],K=M[q],G=p(k,b._ptr[P],b._ptr[P+1],b._index);c(G,k,P,K,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var g=new n({values:this._values?te(this._values):void 0,index:te(this._index),ptr:te(this._ptr),size:te(this._size),datatype:this._datatype});return g},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(g,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,E=this._size[0],b=this._size[1],N=wf(g),x=function(M,S,$){return N===1?g(M):N===2?g(M,[S,$]):g(M,[S,$],v)};return _(this,0,E-1,0,b-1,x,y)};function _(g,y,v,E,b,N,x){var F=[],M=[],S=[],$=e,C=0;Ur(g._datatype)&&($=t.find(e,[g._datatype,g._datatype])||e,C=t.convert(0,g._datatype));for(var I=function(lt,wt,yt){lt=N(lt,wt,yt),$(lt,C)||(F.push(lt),M.push(wt))},R=E;R<=b;R++){S.push(F.length);var U=g._ptr[R],q=g._ptr[R+1];if(x)for(var k=U;k<q;k++){var P=g._index[k];P>=y&&P<=v&&I(g._values[k],P-y,R-E)}else{for(var K={},G=U;G<q;G++){var V=g._index[G];K[V]=g._values[G]}for(var tt=y;tt<=v;tt++){var ft=tt in K?K[tt]:0;I(ft,tt-y,R-E)}}}return S.push(F.length),new n({values:F,index:M,ptr:S,size:[v-y+1,b-E+1]})}n.prototype.forEach=function(g,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,E=this._size[0],b=this._size[1],N=0;N<b;N++){var x=this._ptr[N],F=this._ptr[N+1];if(y)for(var M=x;M<F;M++){var S=this._index[M];g(this._values[M],[S,N],v)}else{for(var $={},C=x;C<F;C++){var I=this._index[C];$[I]=this._values[C]}for(var R=0;R<E;R++){var U=R in $?$[R]:0;g(U,[R,N],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var g=this._size[1],y=0;y<g;y++)for(var v=this._ptr[y],E=this._ptr[y+1],b=v;b<E;b++){var N=this._index[b];yield{value:this._values[b],index:[N,y]}}},n.prototype.toArray=function(){return w(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return w(this._values,this._index,this._ptr,this._size,!1)};function w(g,y,v,E,b){var N=E[0],x=E[1],F=[],M,S;for(M=0;M<N;M++)for(F[M]=[],S=0;S<x;S++)F[M][S]=0;for(S=0;S<x;S++)for(var $=v[S],C=v[S+1],I=$;I<C;I++)M=y[I],F[M][S]=g?b?te(g[I]):g[I]:1;return F}return n.prototype.format=function(g){for(var y=this._size[0],v=this._size[1],E=this.density(),b="Sparse Matrix ["+se(y,g)+" x "+se(v,g)+"] density: "+se(E,g)+`
53
53
  `,N=0;N<v;N++)for(var x=this._ptr[N],F=this._ptr[N+1],M=x;M<F;M++){var S=this._index[M];b+=`
54
- (`+se(S,g)+", "+se(N,g)+") ==> "+(this._values?se(this._values[M],g):"X")}return b},n.prototype.toString=function(){return se(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(g){if(g){if(ye(g)&&(g=g.toNumber()),!ue(g)||!he(g))throw new TypeError("The parameter k must be an integer number")}else g=0;var y=g>0?g:0,v=g<0?-g:0,E=this._size[0],b=this._size[1],N=Math.min(E-v,b-y),x=[],F=[],M=[];M[0]=0;for(var S=y;S<b&&x.length<N;S++)for(var $=this._ptr[S],C=this._ptr[S+1],I=$;I<C;I++){var R=this._index[I];if(R===S-y+v){x.push(this._values[I]),F[x.length-1]=R-v;break}}return M.push(x.length),new n({values:x,index:F,ptr:M,size:[N,1]})},n.fromJSON=function(g){return new n(g)},n.diagonal=function(g,y,v,E,b){if(!ge(g))throw new TypeError("Array expected, size parameter");if(g.length!==2)throw new Error("Only two dimensions matrix are supported");if(g=g.map(function(V){if(ye(V)&&(V=V.toNumber()),!ue(V)||!he(V)||V<1)throw new Error("Size values must be positive integers");return V}),v){if(ye(v)&&(v=v.toNumber()),!ue(v)||!he(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var N=e,x=0;Ur(b)&&(N=t.find(e,[b,b])||e,x=t.convert(0,b));var F=v>0?v:0,M=v<0?-v:0,S=g[0],$=g[1],C=Math.min(S-M,$-F),I;if(ge(y)){if(y.length!==C)throw new Error("Invalid value array length");I=function(tt){return y[tt]}}else if(fe(y)){var R=y.size();if(R.length!==1||R[0]!==C)throw new Error("Invalid matrix length");I=function(tt){return y.get([tt])}}else I=function(){return y};for(var U=[],q=[],k=[],P=0;P<$;P++){k.push(U.length);var K=P-F;if(K>=0&&K<C){var G=I(K);N(G,x)||(q.push(K+M),U.push(G))}}return k.push(U.length),new n({values:U,index:q,ptr:k,size:[S,$]})},n.prototype.swapRows=function(g,y){if(!ue(g)||!he(g)||!ue(y)||!he(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return ve(g,this._size[0]),ve(y,this._size[0]),n._swapRows(g,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(g,y,v,E,b){for(var N=E[g],x=E[g+1],F=N;F<x;F++)b(v[F],y[F])},n._swapRows=function(g,y,v,E,b,N){for(var x=0;x<v;x++){var F=N[x],M=N[x+1],S=p(g,F,M,b),$=p(y,F,M,b);if(S<M&&$<M&&b[S]===g&&b[$]===y){if(E){var C=E[S];E[S]=E[$],E[$]=C}continue}if(S<M&&b[S]===g&&($>=M||b[$]!==y)){var I=E?E[S]:void 0;b.splice($,0,y),E&&E.splice($,0,I),b.splice($<=S?S+1:S,1),E&&E.splice($<=S?S+1:S,1);continue}if($<M&&b[$]===y&&(S>=M||b[S]!==g)){var R=E?E[$]:void 0;b.splice(S,0,g),E&&E.splice(S,0,R),b.splice(S<=$?$+1:$,1),E&&E.splice(S<=$?$+1:$,1)}}},n},{isClass:!0}),mg="number",gg=["typed"];function vg(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function _g(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var wg=mt(mg,gg,i=>{var{typed:t}=i,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var s=vg(n);if(s)return _g(s);var u=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(u=Number(l[2]),n=l[1]);var f=Number(n);if(isNaN(f))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(f>2**u-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));f>=2**(u-1)&&(f=f-2**u)}return f},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),null:function(n){return 0},"Unit, string | Unit":function(n,s){return n.toNumber(s)},"Array | Matrix":t.referToSelf(r=>n=>Ir(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),Dg="bignumber",yg=["typed","BigNumber"],bg=mt(Dg,yg,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var u=s[2],l=e(s[1]),f=new e(2).pow(Number(u));if(l.gt(f.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var p=new e(2).pow(Number(u)-1);return l.gte(p)?l.sub(f):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Ir(n,r))})}),Eg="fraction",Ag=["typed","Fraction"],xg=mt(Eg,Ag,i=>{var{typed:t,Fraction:e}=i;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,s){return new e(n,s)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Ir(n,r))})}),$f="matrix",Cg=["typed","Matrix","DenseMatrix","SparseMatrix"],Fg=mt($f,Cg,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t($f,{"":function(){return s([])},string:function(l){return s([],l)},"string, string":function(l,f){return s([],l,f)},Array:function(l){return s(l)},Matrix:function(l){return s(l,l.storage())},"Array | Matrix, string":s,"Array | Matrix, string, string":s});function s(u,l,f){if(l==="dense"||l==="default"||l===void 0)return new r(u,f);if(l==="sparse")return new n(u,f);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),Of="unaryMinus",Mg=["typed"],Ng=mt(Of,Mg,i=>{var{typed:t}=i;return t(Of,{number:Cf,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf(e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n}),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),Rf="abs",Sg=["typed"],Bg=mt(Rf,Sg,i=>{var{typed:t}=i;return t(Rf,{number:bf,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),Lf="addScalar",Ig=["typed"],Tg=mt(Lf,Ig,i=>{var{typed:t}=i;return t(Lf,{"number, number":Ef,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),Pf="subtractScalar",$g=["typed"],Og=mt(Pf,$g,i=>{var{typed:t}=i;return t(Pf,{"number, number":Af,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),Rg="matAlgo11xS0s",Lg=["typed","equalScalar"],ba=mt(Rg,Lg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,u,l){var f=n._values,p=n._index,h=n._ptr,c=n._size,m=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var _=c[0],w=c[1],g,y=e,v=0,E=u;typeof m=="string"&&(g=m,y=t.find(e,[g,g]),v=t.convert(0,g),s=t.convert(s,g),E=t.find(u,[g,g]));for(var b=[],N=[],x=[],F=0;F<w;F++){x[F]=N.length;for(var M=h[F],S=h[F+1],$=M;$<S;$++){var C=p[$],I=l?E(s,f[$]):E(f[$],s);y(I,v)||(N.push(C),b.push(I))}}return x[w]=N.length,n.createSparseMatrix({values:b,index:N,ptr:x,size:[_,w],datatype:g})}}),Pg="matAlgo12xSfs",zg=["typed","DenseMatrix"],li=mt(Pg,zg,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,u,l){var f=n._values,p=n._index,h=n._ptr,c=n._size,m=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var _=c[0],w=c[1],g,y=u;typeof m=="string"&&(g=m,s=t.convert(s,g),y=t.find(u,[g,g]));for(var v=[],E=[],b=[],N=0;N<w;N++){for(var x=N+1,F=h[N],M=h[N+1],S=F;S<M;S++){var $=p[S];E[$]=f[S],b[$]=x}for(var C=0;C<_;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?y(s,E[C]):y(E[C],s):v[C][N]=l?y(s,0):y(0,s)}return new e({data:v,size:[_,w],datatype:g})}}),qg="matAlgo14xDs",Ug=["typed"],Ea=mt(qg,Ug,i=>{var{typed:t}=i;return function(n,s,u,l){var f=n._data,p=n._size,h=n._datatype,c,m=u;typeof h=="string"&&(c=h,s=t.convert(s,c),m=t.find(u,[c,c]));var _=p.length>0?e(m,0,p,p[0],f,s,l):[];return n.createDenseMatrix({data:_,size:te(p),datatype:c})};function e(r,n,s,u,l,f,p){var h=[];if(n===s.length-1)for(var c=0;c<u;c++)h[c]=p?r(f,l[c]):r(l[c],f);else for(var m=0;m<u;m++)h[m]=e(r,n+1,s,s[n+1],l[m],f,p);return h}}),kg="matAlgo02xDS0",Wg=["typed","equalScalar"],Yg=mt(kg,Wg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,u,l){var f=n._data,p=n._size,h=n._datatype||n.getDataType(),c=s._values,m=s._index,_=s._ptr,w=s._size,g=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(p.length!==w.length)throw new Zt(p.length,w.length);if(p[0]!==w[0]||p[1]!==w[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+w+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=p[0],v=p[1],E,b=e,N=0,x=u;typeof h=="string"&&h===g&&h!=="mixed"&&(E=h,b=t.find(e,[E,E]),N=t.convert(0,E),x=t.find(u,[E,E]));for(var F=[],M=[],S=[],$=0;$<v;$++){S[$]=M.length;for(var C=_[$],I=_[$+1],R=C;R<I;R++){var U=m[R],q=l?x(c[R],f[U][$]):x(f[U][$],c[R]);b(q,N)||(M.push(U),F.push(q))}}return S[v]=M.length,s.createSparseMatrix({values:F,index:M,ptr:S,size:[y,v],datatype:h===n._datatype&&g===s._datatype?E:void 0})}}),jg="matAlgo03xDSf",Zg=["typed"],fi=mt(jg,Zg,i=>{var{typed:t}=i;return function(r,n,s,u){var l=r._data,f=r._size,p=r._datatype||r.getDataType(),h=n._values,c=n._index,m=n._ptr,_=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(f.length!==_.length)throw new Zt(f.length,_.length);if(f[0]!==_[0]||f[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+_+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=f[0],y=f[1],v,E=0,b=s;typeof p=="string"&&p===w&&p!=="mixed"&&(v=p,E=t.convert(0,v),b=t.find(s,[v,v]));for(var N=[],x=0;x<g;x++)N[x]=[];for(var F=[],M=[],S=0;S<y;S++){for(var $=S+1,C=m[S],I=m[S+1],R=C;R<I;R++){var U=c[R];F[U]=u?b(h[R],l[U][S]):b(l[U][S],h[R]),M[U]=$}for(var q=0;q<g;q++)M[q]===$?N[q][S]=F[q]:N[q][S]=u?b(E,l[q][S]):b(l[q][S],E)}return r.createDenseMatrix({data:N,size:[g,y],datatype:p===r._datatype&&w===n._datatype?v:void 0})}}),Gg="matAlgo05xSfSf",Kg=["typed","equalScalar"],zf=mt(Gg,Kg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,u){var l=n._values,f=n._index,p=n._ptr,h=n._size,c=n._datatype||n._data===void 0?n._datatype:n.getDataType(),m=s._values,_=s._index,w=s._ptr,g=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==g.length)throw new Zt(h.length,g.length);if(h[0]!==g[0]||h[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+g+")");var v=h[0],E=h[1],b,N=e,x=0,F=u;typeof c=="string"&&c===y&&c!=="mixed"&&(b=c,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(u,[b,b]));var M=l&&m?[]:void 0,S=[],$=[],C=M?[]:void 0,I=M?[]:void 0,R=[],U=[],q,k,P,K;for(k=0;k<E;k++){$[k]=S.length;var G=k+1;for(P=p[k],K=p[k+1];P<K;P++)q=f[P],S.push(q),R[q]=G,C&&(C[q]=l[P]);for(P=w[k],K=w[k+1];P<K;P++)q=_[P],R[q]!==G&&S.push(q),U[q]=G,I&&(I[q]=m[P]);if(M)for(P=$[k];P<S.length;){q=S[P];var V=R[q],tt=U[q];if(V===G||tt===G){var ft=V===G?C[q]:x,vt=tt===G?I[q]:x,lt=F(ft,vt);N(lt,x)?S.splice(P,1):(M.push(lt),P++)}}}return $[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:$,size:[v,E],datatype:c===n._datatype&&y===s._datatype?b:void 0})}}),Hg="matAlgo13xDD",Jg=["typed"],Xg=mt(Hg,Jg,i=>{var{typed:t}=i;return function(n,s,u){var l=n._data,f=n._size,p=n._datatype,h=s._data,c=s._size,m=s._datatype,_=[];if(f.length!==c.length)throw new Zt(f.length,c.length);for(var w=0;w<f.length;w++){if(f[w]!==c[w])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+c+")");_[w]=f[w]}var g,y=u;typeof p=="string"&&p===m&&(g=p,y=t.find(u,[g,g]));var v=_.length>0?e(y,0,_,_[0],l,h):[];return n.createDenseMatrix({data:v,size:_,datatype:g})};function e(r,n,s,u,l,f){var p=[];if(n===s.length-1)for(var h=0;h<u;h++)p[h]=r(l[h],f[h]);else for(var c=0;c<u;c++)p[c]=e(r,n+1,s,s[n+1],l[c],f[c]);return p}}),Vg="broadcast",Qg=["concat"],tv=mt(Vg,Qg,i=>{var{concat:t}=i;return function(n,s){var u=Math.max(n._size.length,s._size.length);if(n._size.length===s._size.length&&n._size.every((w,g)=>w===s._size[g]))return[n,s];for(var l=e(n._size,u,0),f=e(s._size,u,0),p=[],h=0;h<u;h++)p[h]=Math.max(l[h],f[h]);As(l,p),As(f,p);var c=n.clone(),m=s.clone();c._size.length<u?c.reshape(e(c._size,u,1)):m._size.length<u&&m.reshape(e(m._size,u,1));for(var _=0;_<u;_++)c._size[_]<p[_]&&(c=r(c,p[_],_)),m._size[_]<p[_]&&(m=r(m,p[_],_));return[c,m]};function e(n,s,u){return[...Array(s-n.length).fill(u),...n]}function r(n,s,u){return t(...Array(s).fill(n),u)}}),ev="matrixAlgorithmSuite",rv=["typed","matrix","concat"],qn=mt(ev,rv,i=>{var{typed:t,matrix:e,concat:r}=i,n=Xg({typed:t}),s=Ea({typed:t}),u=tv({concat:r});return function(f){var p=f.elop,h=f.SD||f.DS,c;p?(c={"DenseMatrix, DenseMatrix":(g,y)=>n(...u(g,y),p),"Array, Array":(g,y)=>n(...u(e(g),e(y)),p).valueOf(),"Array, DenseMatrix":(g,y)=>n(...u(e(g),y),p),"DenseMatrix, Array":(g,y)=>n(...u(g,e(y)),p)},f.SS&&(c["SparseMatrix, SparseMatrix"]=(g,y)=>f.SS(...u(g,y),p,!1)),f.DS&&(c["DenseMatrix, SparseMatrix"]=(g,y)=>f.DS(...u(g,y),p,!1),c["Array, SparseMatrix"]=(g,y)=>f.DS(...u(e(g),y),p,!1)),h&&(c["SparseMatrix, DenseMatrix"]=(g,y)=>h(...u(y,g),p,!0),c["SparseMatrix, Array"]=(g,y)=>h(...u(e(y),g),p,!0))):(c={"DenseMatrix, DenseMatrix":t.referToSelf(g=>(y,v)=>n(...u(y,v),g)),"Array, Array":t.referToSelf(g=>(y,v)=>n(...u(e(y),e(v)),g).valueOf()),"Array, DenseMatrix":t.referToSelf(g=>(y,v)=>n(...u(e(y),v),g)),"DenseMatrix, Array":t.referToSelf(g=>(y,v)=>n(...u(y,e(v)),g))},f.SS&&(c["SparseMatrix, SparseMatrix"]=t.referToSelf(g=>(y,v)=>f.SS(...u(y,v),g,!1))),f.DS&&(c["DenseMatrix, SparseMatrix"]=t.referToSelf(g=>(y,v)=>f.DS(...u(y,v),g,!1)),c["Array, SparseMatrix"]=t.referToSelf(g=>(y,v)=>f.DS(...u(e(y),v),g,!1))),h&&(c["SparseMatrix, DenseMatrix"]=t.referToSelf(g=>(y,v)=>h(...u(v,y),g,!0)),c["SparseMatrix, Array"]=t.referToSelf(g=>(y,v)=>h(...u(e(v),y),g,!0))));var m=f.scalar||"any",_=f.Ds||f.Ss;_&&(p?(c["DenseMatrix,"+m]=(g,y)=>s(g,y,p,!1),c[m+", DenseMatrix"]=(g,y)=>s(y,g,p,!0),c["Array,"+m]=(g,y)=>s(e(g),y,p,!1).valueOf(),c[m+", Array"]=(g,y)=>s(e(y),g,p,!0).valueOf()):(c["DenseMatrix,"+m]=t.referToSelf(g=>(y,v)=>s(y,v,g,!1)),c[m+", DenseMatrix"]=t.referToSelf(g=>(y,v)=>s(v,y,g,!0)),c["Array,"+m]=t.referToSelf(g=>(y,v)=>s(e(y),v,g,!1).valueOf()),c[m+", Array"]=t.referToSelf(g=>(y,v)=>s(e(v),y,g,!0).valueOf())));var w=f.sS!==void 0?f.sS:f.Ss;return p?(f.Ss&&(c["SparseMatrix,"+m]=(g,y)=>f.Ss(g,y,p,!1)),w&&(c[m+", SparseMatrix"]=(g,y)=>w(y,g,p,!0))):(f.Ss&&(c["SparseMatrix,"+m]=t.referToSelf(g=>(y,v)=>f.Ss(y,v,g,!1))),w&&(c[m+", SparseMatrix"]=t.referToSelf(g=>(y,v)=>w(v,y,g,!0)))),p&&p.signatures&&Bl(c,p.signatures),c}}),nv="matAlgo01xDSid",iv=["typed"],qf=mt(nv,iv,i=>{var{typed:t}=i;return function(r,n,s,u){var l=r._data,f=r._size,p=r._datatype||r.getDataType(),h=n._values,c=n._index,m=n._ptr,_=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(f.length!==_.length)throw new Zt(f.length,_.length);if(f[0]!==_[0]||f[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+_+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=f[0],y=f[1],v=typeof p=="string"&&p!=="mixed"&&p===w?p:void 0,E=v?t.find(s,[v,v]):s,b,N,x=[];for(b=0;b<g;b++)x[b]=[];var F=[],M=[];for(N=0;N<y;N++){for(var S=N+1,$=m[N],C=m[N+1],I=$;I<C;I++)b=c[I],F[b]=u?E(h[I],l[b][N]):E(l[b][N],h[I]),M[b]=S;for(b=0;b<g;b++)M[b]===S?x[b][N]=F[b]:x[b][N]=l[b][N]}return r.createDenseMatrix({data:x,size:[g,y],datatype:p===r._datatype&&w===n._datatype?v:void 0})}}),sv="matAlgo04xSidSid",ov=["typed","equalScalar"],av=mt(sv,ov,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,u){var l=n._values,f=n._index,p=n._ptr,h=n._size,c=n._datatype||n._data===void 0?n._datatype:n.getDataType(),m=s._values,_=s._index,w=s._ptr,g=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==g.length)throw new Zt(h.length,g.length);if(h[0]!==g[0]||h[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+g+")");var v=h[0],E=h[1],b,N=e,x=0,F=u;typeof c=="string"&&c===y&&c!=="mixed"&&(b=c,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(u,[b,b]));var M=l&&m?[]:void 0,S=[],$=[],C=l&&m?[]:void 0,I=l&&m?[]:void 0,R=[],U=[],q,k,P,K,G;for(k=0;k<E;k++){$[k]=S.length;var V=k+1;for(K=p[k],G=p[k+1],P=K;P<G;P++)q=f[P],S.push(q),R[q]=V,C&&(C[q]=l[P]);for(K=w[k],G=w[k+1],P=K;P<G;P++)if(q=_[P],R[q]===V){if(C){var tt=F(C[q],m[P]);N(tt,x)?R[q]=null:C[q]=tt}}else S.push(q),U[q]=V,I&&(I[q]=m[P]);if(C&&I)for(P=$[k];P<S.length;)q=S[P],R[q]===V?(M[P]=C[q],P++):U[q]===V?(M[P]=I[q],P++):S.splice(P,1)}return $[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:$,size:[v,E],datatype:c===n._datatype&&y===s._datatype?b:void 0})}}),uv="matAlgo10xSids",lv=["typed","DenseMatrix"],Uf=mt(uv,lv,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,u,l){var f=n._values,p=n._index,h=n._ptr,c=n._size,m=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var _=c[0],w=c[1],g,y=u;typeof m=="string"&&(g=m,s=t.convert(s,g),y=t.find(u,[g,g]));for(var v=[],E=[],b=[],N=0;N<w;N++){for(var x=N+1,F=h[N],M=h[N+1],S=F;S<M;S++){var $=p[S];E[$]=f[S],b[$]=x}for(var C=0;C<_;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?y(s,E[C]):y(E[C],s):v[C][N]=s}return new e({data:v,size:[_,w],datatype:g})}}),fv="multiplyScalar",cv=["typed"],hv=mt(fv,cv,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":xf,"Complex, Complex":function(r,n){return r.mul(n)},"BigNumber, BigNumber":function(r,n){return r.times(n)},"Fraction, Fraction":function(r,n){return r.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})}),kf="multiply",pv=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],dv=mt(kf,pv,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:u}=i,l=ba({typed:t,equalScalar:s}),f=Ea({typed:t});function p(x,F){switch(x.length){case 1:switch(F.length){case 1:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;case 2:switch(F.length){case 1:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+F[0]+")");break;case 2:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function h(x,F,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return u(x,F)}function c(x,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(x,F)}function m(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._data,I=F._size,R=F._datatype||F.getDataType(),U=S[0],q=I[1],k,P=r,K=n;$&&R&&$===R&&typeof $=="string"&&$!=="mixed"&&(k=$,P=t.find(r,[k,k]),K=t.find(n,[k,k]));for(var G=[],V=0;V<q;V++){for(var tt=K(M[0],C[0][V]),ft=1;ft<U;ft++)tt=P(tt,K(M[ft],C[ft][V]));G[V]=tt}return x.createDenseMatrix({data:G,size:[q],datatype:$===x._datatype&&R===F._datatype?k:void 0})}var _=t("_multiplyMatrixVector",{"DenseMatrix, any":g,"SparseMatrix, any":E}),w=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function g(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._data,I=F._datatype||F.getDataType(),R=S[0],U=S[1],q,k=r,P=n;$&&I&&$===I&&typeof $=="string"&&$!=="mixed"&&(q=$,k=t.find(r,[q,q]),P=t.find(n,[q,q]));for(var K=[],G=0;G<R;G++){for(var V=M[G],tt=P(V[0],C[0]),ft=1;ft<U;ft++)tt=k(tt,P(V[ft],C[ft]));K[G]=tt}return x.createDenseMatrix({data:K,size:[R],datatype:$===x._datatype&&I===F._datatype?q:void 0})}function y(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._data,I=F._size,R=F._datatype||F.getDataType(),U=S[0],q=S[1],k=I[1],P,K=r,G=n;$&&R&&$===R&&typeof $=="string"&&$!=="mixed"&&$!=="mixed"&&(P=$,K=t.find(r,[P,P]),G=t.find(n,[P,P]));for(var V=[],tt=0;tt<U;tt++){var ft=M[tt];V[tt]=[];for(var vt=0;vt<k;vt++){for(var lt=G(ft[0],C[0][vt]),wt=1;wt<q;wt++)lt=K(lt,G(ft[wt],C[wt][vt]));V[tt][vt]=lt}}return x.createDenseMatrix({data:V,size:[U,k],datatype:$===x._datatype&&R===F._datatype?P:void 0})}function v(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._values,I=F._index,R=F._ptr,U=F._size,q=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!C)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var k=S[0],P=U[1],K,G=r,V=n,tt=s,ft=0;$&&q&&$===q&&typeof $=="string"&&$!=="mixed"&&(K=$,G=t.find(r,[K,K]),V=t.find(n,[K,K]),tt=t.find(s,[K,K]),ft=t.convert(0,K));for(var vt=[],lt=[],wt=[],yt=F.createSparseMatrix({values:vt,index:lt,ptr:wt,size:[k,P],datatype:$===x._datatype&&q===F._datatype?K:void 0}),St=0;St<P;St++){wt[St]=lt.length;var bt=R[St],ee=R[St+1];if(ee>bt)for(var It=0,Mt=0;Mt<k;Mt++){for(var ie=Mt+1,Xt=void 0,zt=bt;zt<ee;zt++){var Gt=I[zt];It!==ie?(Xt=V(M[Mt][Gt],C[zt]),It=ie):Xt=G(Xt,V(M[Mt][Gt],C[zt]))}It===ie&&!tt(Xt,ft)&&(lt.push(Mt),vt.push(Xt))}}return wt[P]=lt.length,yt}function E(x,F){var M=x._values,S=x._index,$=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var I=F._data,R=F._datatype||F.getDataType(),U=x._size[0],q=F._size[0],k=[],P=[],K=[],G,V=r,tt=n,ft=s,vt=0;C&&R&&C===R&&typeof C=="string"&&C!=="mixed"&&(G=C,V=t.find(r,[G,G]),tt=t.find(n,[G,G]),ft=t.find(s,[G,G]),vt=t.convert(0,G));var lt=[],wt=[];K[0]=0;for(var yt=0;yt<q;yt++){var St=I[yt];if(!ft(St,vt))for(var bt=$[yt],ee=$[yt+1],It=bt;It<ee;It++){var Mt=S[It];wt[Mt]?lt[Mt]=V(lt[Mt],tt(St,M[It])):(wt[Mt]=!0,P.push(Mt),lt[Mt]=tt(St,M[It]))}}for(var ie=P.length,Xt=0;Xt<ie;Xt++){var zt=P[Xt];k[Xt]=lt[zt]}return K[1]=P.length,x.createSparseMatrix({values:k,index:P,ptr:K,size:[U,1],datatype:C===x._datatype&&R===F._datatype?G:void 0})}function b(x,F){var M=x._values,S=x._index,$=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var I=F._data,R=F._datatype||F.getDataType(),U=x._size[0],q=F._size[0],k=F._size[1],P,K=r,G=n,V=s,tt=0;C&&R&&C===R&&typeof C=="string"&&C!=="mixed"&&(P=C,K=t.find(r,[P,P]),G=t.find(n,[P,P]),V=t.find(s,[P,P]),tt=t.convert(0,P));for(var ft=[],vt=[],lt=[],wt=x.createSparseMatrix({values:ft,index:vt,ptr:lt,size:[U,k],datatype:C===x._datatype&&R===F._datatype?P:void 0}),yt=[],St=[],bt=0;bt<k;bt++){lt[bt]=vt.length;for(var ee=bt+1,It=0;It<q;It++){var Mt=I[It][bt];if(!V(Mt,tt))for(var ie=$[It],Xt=$[It+1],zt=ie;zt<Xt;zt++){var Gt=S[zt];St[Gt]!==ee?(St[Gt]=ee,vt.push(Gt),yt[Gt]=G(Mt,M[zt])):yt[Gt]=K(yt[Gt],G(Mt,M[zt]))}}for(var Ce=lt[bt],sr=vt.length,Me=Ce;Me<sr;Me++){var Vr=vt[Me];ft[Me]=yt[Vr]}}return lt[k]=vt.length,wt}function N(x,F){var M=x._values,S=x._index,$=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType(),I=F._values,R=F._index,U=F._ptr,q=F._datatype||F._data===void 0?F._datatype:F.getDataType(),k=x._size[0],P=F._size[1],K=M&&I,G,V=r,tt=n;C&&q&&C===q&&typeof C=="string"&&C!=="mixed"&&(G=C,V=t.find(r,[G,G]),tt=t.find(n,[G,G]));for(var ft=K?[]:void 0,vt=[],lt=[],wt=x.createSparseMatrix({values:ft,index:vt,ptr:lt,size:[k,P],datatype:C===x._datatype&&q===F._datatype?G:void 0}),yt=K?[]:void 0,St=[],bt,ee,It,Mt,ie,Xt,zt,Gt,Ce=0;Ce<P;Ce++){lt[Ce]=vt.length;var sr=Ce+1;for(ie=U[Ce],Xt=U[Ce+1],Mt=ie;Mt<Xt;Mt++)if(Gt=R[Mt],K)for(ee=$[Gt],It=$[Gt+1],bt=ee;bt<It;bt++)zt=S[bt],St[zt]!==sr?(St[zt]=sr,vt.push(zt),yt[zt]=tt(I[Mt],M[bt])):yt[zt]=V(yt[zt],tt(I[Mt],M[bt]));else for(ee=$[Gt],It=$[Gt+1],bt=ee;bt<It;bt++)zt=S[bt],St[zt]!==sr&&(St[zt]=sr,vt.push(zt));if(K)for(var Me=lt[Ce],Vr=vt.length,wn=Me;wn<Vr;wn++){var Qr=vt[wn];ft[wn]=yt[Qr]}}return lt[P]=vt.length,wt}return t(kf,n,{"Array, Array":t.referTo("Matrix, Matrix",x=>(F,M)=>{p(Ae(F),Ae(M));var S=x(e(F),e(M));return fe(S)?S.valueOf():S}),"Matrix, Matrix":function(F,M){var S=F.size(),$=M.size();return p(S,$),S.length===1?$.length===1?h(F,M,S[0]):c(F,M):$.length===1?_(F,M):w(F,M)},"Matrix, Array":t.referTo("Matrix,Matrix",x=>(F,M)=>x(F,e(M))),"Array, Matrix":t.referToSelf(x=>(F,M)=>x(e(F,M.storage()),M)),"SparseMatrix, any":function(F,M){return l(F,M,n,!1)},"DenseMatrix, any":function(F,M){return f(F,M,n,!1)},"any, SparseMatrix":function(F,M){return l(M,F,n,!0)},"any, DenseMatrix":function(F,M){return f(M,F,n,!0)},"Array, any":function(F,M){return f(e(F),M,n,!1).valueOf()},"any, Array":function(F,M){return f(e(M),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(x=>(F,M,S)=>{for(var $=x(F,M),C=0;C<S.length;C++)$=x($,S[C]);return $})})}),Wf="subtract",mv=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],gv=mt(Wf,mv,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:u,concat:l}=i,f=qf({typed:t}),p=fi({typed:t}),h=zf({typed:t,equalScalar:r}),c=Uf({typed:t,DenseMatrix:u}),m=li({typed:t,DenseMatrix:u}),_=qn({typed:t,matrix:e,concat:l});return t(Wf,{"any, any":n},_({elop:n,SS:h,DS:f,SD:p,Ss:m,sS:c}))}),vv="matAlgo07xSSf",_v=["typed","DenseMatrix"],zs=mt(vv,_v,i=>{var{typed:t,DenseMatrix:e}=i;return function(s,u,l){var f=s._size,p=s._datatype||s._data===void 0?s._datatype:s.getDataType(),h=u._size,c=u._datatype||u._data===void 0?u._datatype:u.getDataType();if(f.length!==h.length)throw new Zt(f.length,h.length);if(f[0]!==h[0]||f[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+h+")");var m=f[0],_=f[1],w,g=0,y=l;typeof p=="string"&&p===c&&p!=="mixed"&&(w=p,g=t.convert(0,w),y=t.find(l,[w,w]));var v,E,b=[];for(v=0;v<m;v++)b[v]=[];var N=[],x=[],F=[],M=[];for(E=0;E<_;E++){var S=E+1;for(r(s,E,F,N,S),r(u,E,M,x,S),v=0;v<m;v++){var $=F[v]===S?N[v]:g,C=M[v]===S?x[v]:g;b[v][E]=y($,C)}}return new e({data:b,size:[m,_],datatype:p===s._datatype&&c===u._datatype?w:void 0})};function r(n,s,u,l,f){for(var p=n._values,h=n._index,c=n._ptr,m=c[s],_=c[s+1];m<_;m++){var w=h[m];u[w]=f,l[w]=p[m]}}}),Yf="conj",wv=["typed"],Dv=mt(Yf,wv,i=>{var{typed:t}=i;return t(Yf,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),jf="concat",yv=["typed","matrix","isInteger"],bv=mt(jf,yv,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(jf,{"...Array | Matrix | number | BigNumber":function(s){var u,l=s.length,f=-1,p,h=!1,c=[];for(u=0;u<l;u++){var m=s[u];if(fe(m)&&(h=!0),ue(m)||ye(m)){if(u!==l-1)throw new Error("Dimension must be specified as last argument");if(p=f,f=m.valueOf(),!r(f))throw new TypeError("Integer number expected for dimension");if(f<0||u>0&&f>p)throw new hn(f,p+1)}else{var _=te(m).valueOf(),w=Ae(_);if(c[u]=_,p=f,f=w.length-1,u>0&&f!==p)throw new Zt(p+1,f+1)}}if(c.length===0)throw new SyntaxError("At least one matrix expected");for(var g=c.shift();c.length;)g=Xl(g,c.shift(),f);return h?e(g):g},"...string":function(s){return s.join("")}})}),Zf="count",Ev=["typed","size","prod"],Av=mt(Zf,Ev,i=>{var{typed:t,size:e,prod:r}=i;return t(Zf,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),Gf="identity",xv=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Cv=mt(Gf,xv,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:u}=i;return t(Gf,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(h){return r(h)},"number | BigNumber":function(h){return f(h,h,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(h,c){return f(h,h,c)},"number | BigNumber, number | BigNumber":function(h,c){return f(h,c,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(h,c,m){return f(h,c,m)},Array:function(h){return l(h)},"Array, string":function(h,c){return l(h,c)},Matrix:function(h){return l(h.valueOf(),h.storage())},"Matrix, string":function(h,c){return l(h.valueOf(),c)}});function l(p,h){switch(p.length){case 0:return h?r(h):[];case 1:return f(p[0],p[0],h);case 2:return f(p[0],p[1],h);default:throw new Error("Vector containing two values expected")}}function f(p,h,c){var m=ye(p)||ye(h)?n:null;if(ye(p)&&(p=p.toNumber()),ye(h)&&(h=h.toNumber()),!he(p)||p<1)throw new Error("Parameters in function identity must be positive integers");if(!he(h)||h<1)throw new Error("Parameters in function identity must be positive integers");var _=m?new n(1):1,w=m?new m(0):0,g=[p,h];if(c){if(c==="sparse")return u.diagonal(g,_,0,w);if(c==="dense")return s.diagonal(g,_,0,w);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var y=ua([],g,w),v=p<h?p:h,E=0;E<v;E++)y[E][E]=_;return y}}),Kf="kron",Fv=["typed","matrix","multiplyScalar"],Mv=mt(Kf,Fv,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(Kf,{"Matrix, Matrix":function(u,l){return e(n(u.toArray(),l.toArray()))},"Matrix, Array":function(u,l){return e(n(u.toArray(),l))},"Array, Matrix":function(u,l){return e(n(u,l.toArray()))},"Array, Array":n});function n(s,u){if(Ae(s).length===1&&(s=[s]),Ae(u).length===1&&(u=[u]),Ae(s).length>2||Ae(u).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(s.length)+", y = "+JSON.stringify(u.length)+")");var l=[],f=[];return s.map(function(p){return u.map(function(h){return f=[],l.push(f),p.map(function(c){return h.map(function(m){return f.push(r(c,m))})})})})&&l}});function Nv(){throw new Error('No "bignumber" implementation available')}function Sv(){throw new Error('No "fraction" implementation available')}function Bv(){throw new Error('No "matrix" implementation available')}var Hf="reshape",Iv=["typed","isInteger","matrix"],Tv=mt(Hf,Iv,i=>{var{typed:t,isInteger:e}=i;return t(Hf,{"Matrix, Array":function(n,s){return n.reshape(s,!0)},"Array, Array":function(n,s){return s.forEach(function(u){if(!e(u))throw new TypeError("Invalid size for dimension: "+u)}),fa(n,s)}})}),Jf="size",$v=["typed","config","?matrix"],Ov=mt(Jf,$v,i=>{var{typed:t,config:e,matrix:r}=i;return t(Jf,{Matrix:function(s){return s.create(s.size())},Array:Ae,string:function(s){return e.matrix==="Array"?[s.length]:r([s.length])},"number | Complex | BigNumber | Unit | boolean | null":function(s){return e.matrix==="Array"?[]:r?r([]):Bv()}})}),Xf="transpose",Rv=["typed","matrix"],Lv=mt(Xf,Rv,i=>{var{typed:t,matrix:e}=i;return t(Xf,{Array:u=>r(e(u)).valueOf(),Matrix:r,any:te});function r(u){var l=u.size(),f;switch(l.length){case 1:f=u.clone();break;case 2:{var p=l[0],h=l[1];if(h===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+se(l)+")");switch(u.storage()){case"dense":f=n(u,p,h);break;case"sparse":f=s(u,p,h);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+se(l)+")")}return f}function n(u,l,f){for(var p=u._data,h=[],c,m=0;m<f;m++){c=h[m]=[];for(var _=0;_<l;_++)c[_]=te(p[_][m])}return u.createDenseMatrix({data:h,size:[f,l],datatype:u._datatype})}function s(u,l,f){for(var p=u._values,h=u._index,c=u._ptr,m=p?[]:void 0,_=[],w=[],g=[],y=0;y<l;y++)g[y]=0;var v,E,b;for(v=0,E=h.length;v<E;v++)g[h[v]]++;for(var N=0,x=0;x<l;x++)w.push(N),N+=g[x],g[x]=w[x];for(w.push(N),b=0;b<f;b++)for(var F=c[b],M=c[b+1],S=F;S<M;S++){var $=g[h[S]]++;_[$]=b,p&&(m[$]=te(p[S]))}return u.createSparseMatrix({values:m,index:_,ptr:w,size:[f,l],datatype:u._datatype})}}),Vf="ctranspose",Pv=["typed","transpose","conj"],zv=mt(Vf,Pv,i=>{var{typed:t,transpose:e,conj:r}=i;return t(Vf,{any:function(s){return r(e(s))}})}),Qf="mode",qv=["typed","isNaN","isNumeric"],Uv=mt(Qf,qv,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(Qf,{"Array | Matrix":n,"...":function(u){return n(u)}});function n(s){s=ha(s.valueOf());var u=s.length;if(u===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},f=[],p=0,h=0;h<s.length;h++){var c=s[h];if(r(c)&&e(c))throw new Error("Cannot calculate mode of an array containing NaN values");c in l||(l[c]=0),l[c]++,l[c]===p?f.push(c):l[c]>p&&(p=l[c],f=[c])}return f}});function vn(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+cn(e)+", value: "+JSON.stringify(e)+")":" (type: "+i.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(i).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+cn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var tc="prod",kv=["typed","config","multiplyScalar","numeric"],Wv=mt(tc,kv,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(tc,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,f){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return s(l)}});function s(u){var l;if(Wi(u,function(f){try{l=l===void 0?f:r(l,f)}catch(p){throw vn(p,"prod",f)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),Yv="numeric",jv=["number","?bignumber","?fraction"],Zv=mt(Yv,jv,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:u=>t(u),BigNumber:e?u=>e(u):Nv,Fraction:r?u=>r(u):Sv};return function(l){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",p=arguments.length>2?arguments[2]:void 0;if(p!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var h=cn(l);if(!(h in n))throw new TypeError("Cannot convert "+l+' of type "'+h+'"; valid input types are '+Object.keys(n).join(", "));if(!(f in s))throw new TypeError("Cannot convert "+l+' to type "'+f+'"; valid output types are '+Object.keys(s).join(", "));return f===h?l:s[f](l)}}),ec="divideScalar",Gv=["typed","numeric"],Kv=mt(ec,Gv,i=>{var{typed:t,numeric:e}=i;return t(ec,{"number, number":function(n,s){return n/s},"Complex, Complex":function(n,s){return n.div(s)},"BigNumber, BigNumber":function(n,s){return n.div(s)},"Fraction, Fraction":function(n,s){return n.div(s)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),rc="pow",Hv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Jv=mt(rc,Hv,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:u,number:l,fraction:f,Complex:p}=i;return t(rc,{"number, number":h,"Complex, Complex":function(w,g){return w.pow(g)},"BigNumber, BigNumber":function(w,g){return g.isInteger()||w>=0||e.predictable?w.pow(g):new p(w.toNumber(),0).pow(g.toNumber(),0)},"Fraction, Fraction":function(w,g){var y=w.pow(g);if(y!=null)return y;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return h(w.valueOf(),g.valueOf())},"Array, number":c,"Array, BigNumber":function(w,g){return c(w,g.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(w,g){return m(w,g.toNumber())},"Unit, number | BigNumber":function(w,g){return w.pow(g)}});function h(_,w){if(e.predictable&&!he(w)&&_<0)try{var g=f(w),y=l(g);if((w===y||Math.abs((w-y)/w)<1e-14)&&g.d%2===1)return(g.n%2===0?1:-1)*Math.pow(-_,w)}catch{}return e.predictable&&(_<-1&&w===1/0||_>-1&&_<0&&w===-1/0)?NaN:he(w)||_>=0||e.predictable?Ff(_,w):_*_<1&&w===1/0||_*_>1&&w===-1/0?0:new p(_,0).pow(w,0)}function c(_,w){if(!he(w))throw new TypeError("For A^b, b must be an integer (value is "+w+")");var g=Ae(_);if(g.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+g.length+" dimensions)");if(g[0]!==g[1])throw new Error("For A^b, A must be square (size is "+g[0]+"x"+g[1]+")");if(w<0)try{return c(u(_),-w)}catch(E){throw E.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+w+")"):E}for(var y=r(g[0]).valueOf(),v=_;w>=1;)(w&1)===1&&(y=n(v,y)),w>>=1,v=n(v,v);return y}function m(_,w){return s(c(_.valueOf(),w))}}),nc="dotDivide",Xv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],Vv=mt(nc,Xv,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:u}=i,l=Yg({typed:t,equalScalar:r}),f=fi({typed:t}),p=zs({typed:t,DenseMatrix:s}),h=ba({typed:t,equalScalar:r}),c=li({typed:t,DenseMatrix:s}),m=qn({typed:t,matrix:e,concat:u});return t(nc,m({elop:n,SS:p,DS:f,SD:l,Ss:h,sS:c}))}),qs="compare",Qv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],t_=mt(qs,Qv,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:u,DenseMatrix:l,concat:f}=i,p=fi({typed:t}),h=zf({typed:t,equalScalar:r}),c=li({typed:t,DenseMatrix:l}),m=qn({typed:t,matrix:n,concat:f}),_=Ls({typed:t});return t(qs,e_({typed:t,config:e}),{"boolean, boolean":function(g,y){return g===y?0:g>y?1:-1},"BigNumber, BigNumber":function(g,y){return Rs(g,y,e.epsilon)?new s(0):new s(g.cmp(y))},"Fraction, Fraction":function(g,y){return new u(g.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},_,m({SS:h,DS:p,Ss:c}))}),e_=mt(qs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(qs,{"number, number":function(n,s){return zn(n,s,e.epsilon)?0:n>s?1:-1}})}),Us="equal",r_=["typed","matrix","equalScalar","DenseMatrix","concat"],n_=mt(Us,r_,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,u=fi({typed:t}),l=zs({typed:t,DenseMatrix:n}),f=li({typed:t,DenseMatrix:n}),p=qn({typed:t,matrix:e,concat:s});return t(Us,i_({typed:t,equalScalar:r}),p({elop:r,SS:l,DS:u,Ss:f}))}),i_=mt(Us,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(Us,{"any, any":function(n,s){return n===null?s===null:s===null?n===null:n===void 0?s===void 0:s===void 0?n===void 0:e(n,s)}})}),ks="smaller",s_=["typed","config","matrix","DenseMatrix","concat"],o_=mt(ks,s_,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,u=fi({typed:t}),l=zs({typed:t,DenseMatrix:n}),f=li({typed:t,DenseMatrix:n}),p=qn({typed:t,matrix:r,concat:s}),h=Ls({typed:t});return t(ks,a_({typed:t,config:e}),{"boolean, boolean":(c,m)=>c<m,"BigNumber, BigNumber":function(m,_){return m.lt(_)&&!Rs(m,_,e.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===-1,"Complex, Complex":function(m,_){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:l,DS:u,Ss:f}))}),a_=mt(ks,["typed","config"],i=>{var{typed:t,config:e}=i;return t(ks,{"number, number":function(n,s){return n<s&&!zn(n,s,e.epsilon)}})}),Ws="larger",u_=["typed","config","matrix","DenseMatrix","concat"],l_=mt(Ws,u_,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,u=fi({typed:t}),l=zs({typed:t,DenseMatrix:n}),f=li({typed:t,DenseMatrix:n}),p=qn({typed:t,matrix:r,concat:s}),h=Ls({typed:t});return t(Ws,f_({typed:t,config:e}),{"boolean, boolean":(c,m)=>c>m,"BigNumber, BigNumber":function(m,_){return m.gt(_)&&!Rs(m,_,e.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:l,DS:u,Ss:f}))}),f_=mt(Ws,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Ws,{"number, number":function(n,s){return n>s&&!zn(n,s,e.epsilon)}})}),ic="deepEqual",c_=["typed","equal"],h_=mt(ic,c_,i=>{var{typed:t,equal:e}=i;return t(ic,{"any, any":function(s,u){return r(s.valueOf(),u.valueOf())}});function r(n,s){if(Array.isArray(n))if(Array.isArray(s)){var u=n.length;if(u!==s.length)return!1;for(var l=0;l<u;l++)if(!r(n[l],s[l]))return!1;return!0}else return!1;else return Array.isArray(s)?!1:e(n,s)}}),sc="partitionSelect",p_=["typed","isNumeric","isNaN","compare"],d_=mt(sc,p_,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,u=(p,h)=>-n(p,h);return t(sc,{"Array | Matrix, number":function(h,c){return l(h,c,s)},"Array | Matrix, number, string":function(h,c,m){if(m==="asc")return l(h,c,s);if(m==="desc")return l(h,c,u);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(p,h,c){if(!he(h)||h<0)throw new Error("k must be a non-negative integer");if(fe(p)){var m=p.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return f(p.valueOf(),h,c)}if(Array.isArray(p))return f(p,h,c)}function f(p,h,c){if(h>=p.length)throw new Error("k out of bounds");for(var m=0;m<p.length;m++)if(e(p[m])&&r(p[m]))return p[m];for(var _=0,w=p.length-1;_<w;){for(var g=_,y=w,v=p[Math.floor(Math.random()*(w-_+1))+_];g<y;)if(c(p[g],v)>=0){var E=p[y];p[y]=p[g],p[g]=E,--y}else++g;c(p[g],v)>0&&--g,h<=g?w=g:_=g+1}return p[h]}}),oc="max",m_=["typed","config","numeric","larger"],g_=mt(oc,m_,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(oc,{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(f,p){return ya(f,p.valueOf(),s)},"...":function(f){if(Ts(f))throw new TypeError("Scalar values expected in function max");return u(f)}});function s(l,f){try{return n(l,f)?l:f}catch(p){throw vn(p,"max",f)}}function u(l){var f;if(Wi(l,function(p){try{isNaN(p)&&typeof p=="number"?f=NaN:(f===void 0||n(p,f))&&(f=p)}catch(h){throw vn(h,"max",p)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=r(f,e.number)),f}}),ac="min",v_=["typed","config","numeric","smaller"],__=mt(ac,v_,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(ac,{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(f,p){return ya(f,p.valueOf(),s)},"...":function(f){if(Ts(f))throw new TypeError("Scalar values expected in function min");return u(f)}});function s(l,f){try{return n(l,f)?l:f}catch(p){throw vn(p,"min",f)}}function u(l){var f;if(Wi(l,function(p){try{isNaN(p)&&typeof p=="number"?f=NaN:(f===void 0||n(p,f))&&(f=p)}catch(h){throw vn(h,"min",p)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=r(f,e.number)),f}}),uc="add",w_=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],D_=mt(uc,w_,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:u,concat:l}=i,f=qf({typed:t}),p=av({typed:t,equalScalar:n}),h=Uf({typed:t,DenseMatrix:s}),c=qn({typed:t,matrix:e,concat:l});return t(uc,{"any, any":r,"any, any, ...any":t.referToSelf(m=>(_,w,g)=>{for(var y=m(_,w),v=0;v<g.length;v++)y=m(y,g[v]);return y})},c({elop:r,DS:f,SS:p,Ss:h}))}),lc="dot",y_=["typed","addScalar","multiplyScalar","conj","size"],b_=mt(lc,y_,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(lc,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":f});function u(h,c){var m=p(h),_=p(c),w,g;if(m.length===1)w=m[0];else if(m.length===2&&m[1]===1)w=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(_.length===1)g=_[0];else if(_.length===2&&_[1]===1)g=_[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+_.join(", ")+")");if(w!==g)throw new RangeError("Vectors must have equal length ("+w+" != "+g+")");if(w===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return w}function l(h,c){var m=u(h,c),_=fe(h)?h._data:h,w=fe(h)?h._datatype||h.getDataType():void 0,g=fe(c)?c._data:c,y=fe(c)?c._datatype||c.getDataType():void 0,v=p(h).length===2,E=p(c).length===2,b=e,N=r;if(w&&y&&w===y&&typeof w=="string"&&w!=="mixed"){var x=w;b=t.find(e,[x,x]),N=t.find(r,[x,x])}if(!v&&!E){for(var F=N(n(_[0]),g[0]),M=1;M<m;M++)F=b(F,N(n(_[M]),g[M]));return F}if(!v&&E){for(var S=N(n(_[0]),g[0][0]),$=1;$<m;$++)S=b(S,N(n(_[$]),g[$][0]));return S}if(v&&!E){for(var C=N(n(_[0][0]),g[0]),I=1;I<m;I++)C=b(C,N(n(_[I][0]),g[I]));return C}if(v&&E){for(var R=N(n(_[0][0]),g[0][0]),U=1;U<m;U++)R=b(R,N(n(_[U][0]),g[U][0]));return R}}function f(h,c){u(h,c);for(var m=h._index,_=h._values,w=c._index,g=c._values,y=0,v=e,E=r,b=0,N=0;b<m.length&&N<w.length;){var x=m[b],F=w[N];if(x<F){b++;continue}if(x>F){N++;continue}x===F&&(y=v(y,E(_[b],g[N])),b++,N++)}return y}function p(h){return fe(h)?h.size():s(h)}}),E_="trace",A_=["typed","matrix","add"],x_=mt(E_,A_,i=>{var{typed:t,matrix:e,add:r}=i;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:s,DenseMatrix:n,any:te});function n(u){var l=u._size,f=u._data;switch(l.length){case 1:if(l[0]===1)return te(f[0]);throw new RangeError("Matrix must be square (size: "+se(l)+")");case 2:{var p=l[0],h=l[1];if(p===h){for(var c=0,m=0;m<p;m++)c=r(c,f[m][m]);return c}else throw new RangeError("Matrix must be square (size: "+se(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(l)+")")}}function s(u){var l=u._values,f=u._index,p=u._ptr,h=u._size,c=h[0],m=h[1];if(c===m){var _=0;if(l.length>0)for(var w=0;w<m;w++)for(var g=p[w],y=p[w+1],v=g;v<y;v++){var E=f[v];if(E===w){_=r(_,l[v]);break}if(E>w)break}return _}throw new RangeError("Matrix must be square (size: "+se(h)+")")}}),fc="det",C_=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],F_=mt(fc,C_,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:u,unaryMinus:l}=i;return t(fc,{any:function(h){return te(h)},"Array | Matrix":function(h){var c;switch(fe(h)?c=h.size():Array.isArray(h)?(h=e(h),c=h.size()):c=[],c.length){case 0:return te(h);case 1:if(c[0]===1)return te(h.valueOf()[0]);if(c[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+se(c)+")");case 2:{var m=c[0],_=c[1];if(m===_)return f(h.clone().valueOf(),m);if(_===0)return 1;throw new RangeError("Matrix must be square (size: "+se(c)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(c)+")")}}});function f(p,h,c){if(h===1)return te(p[0][0]);if(h===2)return r(n(p[0][0],p[1][1]),n(p[1][0],p[0][1]));for(var m=!1,_=new Array(h).fill(0).map((M,S)=>S),w=0;w<h;w++){var g=_[w];if(u(p[g][w])){var y=void 0;for(y=w+1;y<h;y++)if(!u(p[_[y]][w])){g=_[y],_[y]=_[w],_[w]=g,m=!m;break}if(y===h)return p[g][w]}for(var v=p[g][w],E=w===0?1:p[_[w-1]][w-1],b=w+1;b<h;b++)for(var N=_[b],x=w+1;x<h;x++)p[N][x]=s(r(n(p[N][x],v),n(p[N][w],p[g][x])),E)}var F=p[_[h-1]][h-1];return m?l(F):F}}),cc="inv",M_=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],N_=mt(cc,M_,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:u,det:l,identity:f,abs:p}=i;return t(cc,{"Array | Matrix":function(m){var _=fe(m)?m.size():Ae(m);switch(_.length){case 1:if(_[0]===1)return fe(m)?e([r(1,m.valueOf()[0])]):[r(1,m[0])];throw new RangeError("Matrix must be square (size: "+se(_)+")");case 2:{var w=_[0],g=_[1];if(w===g)return fe(m)?e(h(m.valueOf(),w,g),m.storage()):h(m,w,g);throw new RangeError("Matrix must be square (size: "+se(_)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(_)+")")}},any:function(m){return r(1,m)}});function h(c,m,_){var w,g,y,v,E;if(m===1){if(v=c[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(m===2){var b=l(c);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(c[1][1],b),r(u(c[0][1]),b)],[r(u(c[1][0]),b),r(c[0][0],b)]]}else{var N=c.concat();for(w=0;w<m;w++)N[w]=N[w].concat();for(var x=f(m).valueOf(),F=0;F<_;F++){var M=p(N[F][F]),S=F;for(w=F+1;w<m;)p(N[w][F])>M&&(M=p(N[w][F]),S=w),w++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");w=S,w!==F&&(E=N[F],N[F]=N[w],N[w]=E,E=x[F],x[F]=x[w],x[w]=E);var $=N[F],C=x[F];for(w=0;w<m;w++){var I=N[w],R=x[w];if(w!==F){if(I[F]!==0){for(y=r(u(I[F]),$[F]),g=F;g<_;g++)I[g]=n(I[g],s(y,$[g]));for(g=0;g<_;g++)R[g]=n(R[g],s(y,C[g]))}}else{for(y=$[F],g=F;g<_;g++)I[g]=r(I[g],y);for(g=0;g<_;g++)R[g]=r(R[g],y)}}}return x}}}),hc="pinv",S_=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],B_=mt(hc,S_,i=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:s,dotDivide:u,dot:l,ctranspose:f,divideScalar:p,multiply:h,add:c,Complex:m}=i;return t(hc,{"Array | Matrix":function(b){var N=fe(b)?b.size():Ae(b);switch(N.length){case 1:return v(b)?f(b):N[0]===1?r(b):u(f(b),l(b,b));case 2:{if(v(b))return f(b);var x=N[0],F=N[1];if(x===F)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return fe(b)?e(_(b.valueOf(),x,F),b.storage()):_(b,x,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+se(N)+")")}},any:function(b){return s(b,0)?te(b):p(1,b)}});function _(E,b,N){var{C:x,F}=g(E,b,N),M=h(r(h(f(x),x)),f(x)),S=h(f(F),r(h(F,f(F))));return h(S,M)}function w(E,b,N){for(var x=te(E),F=0,M=0;M<b;M++){if(N<=F)return x;for(var S=M;y(x[S][F]);)if(S++,b===S&&(S=M,F++,N===F))return x;[x[S],x[M]]=[x[M],x[S]];for(var $=x[M][F],C=0;C<N;C++)x[M][C]=u(x[M][C],$);for(var I=0;I<b;I++)if(I!==M){$=x[I][F];for(var R=0;R<N;R++)x[I][R]=c(x[I][R],h(-1,h($,x[M][R])))}F++}return x}function g(E,b,N){var x=w(E,b,N),F=E.map((S,$)=>S.filter((C,I)=>I<b&&!y(l(x[I],x[I])))),M=x.filter((S,$)=>!y(l(x[$],x[$])));return{C:F,F:M}}function y(E){return s(c(E,m(1,1)),c(0,m(1,1)))}function v(E){return n(c(E,m(1,1)),c(h(E,0),m(1,1)))}}),I_="divide",T_=["typed","matrix","multiply","equalScalar","divideScalar","inv"],$_=mt(I_,T_,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:u}=i,l=ba({typed:t,equalScalar:n}),f=Ea({typed:t});return t("divide",Bl({"Array | Matrix, Array | Matrix":function(h,c){return r(h,u(c))},"DenseMatrix, any":function(h,c){return f(h,c,s,!1)},"SparseMatrix, any":function(h,c){return l(h,c,s,!1)},"Array, any":function(h,c){return f(e(h),c,s,!1).valueOf()},"any, Array | Matrix":function(h,c){return r(h,u(c))}},s.signatures))}),pc="sum",O_=["typed","config","add","numeric"],R_=mt(pc,O_,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(pc,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":u,"...":function(f){if(Ts(f))throw new TypeError("Scalar values expected in function sum");return s(f)}});function s(l){var f;return Wi(l,function(p){try{f=f===void 0?p:r(f,p)}catch(h){throw vn(h,"sum",p)}}),f===void 0&&(f=n(0,e.number)),typeof f=="string"&&(f=n(f,e.number)),f}function u(l,f){try{var p=ya(l,f,r);return p}catch(h){throw vn(h,"sum")}}}),dc="median",L_=["typed","add","divide","compare","partitionSelect"],P_=mt(dc,L_,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function u(p){try{p=ha(p.valueOf());var h=p.length;if(h===0)throw new Error("Cannot calculate median of an empty array");if(h%2===0){for(var c=h/2-1,m=s(p,c+1),_=p[c],w=0;w<c;++w)n(p[w],_)>0&&(_=p[w]);return f(_,m)}else{var g=s(p,(h-1)/2);return l(g)}}catch(y){throw vn(y,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(h){return h}}),f=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(h,c){return r(e(h,c),2)}});return t(dc,{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(h,c){throw new Error("median(A, dim) is not yet supported")},"...":function(h){if(Ts(h))throw new TypeError("Scalar values expected in function median");return u(h)}})}),Ys=zm({config:nr}),Aa=Wm({}),xa=Gm({}),Ca=Jm({}),Wr=Qm({Matrix:Ca}),Ft=kd({BigNumber:Ys,Complex:Aa,DenseMatrix:Wr,Fraction:xa}),z_=Bg({typed:Ft}),js=Tg({typed:Ft}),q_=bg({BigNumber:Ys,typed:Ft}),mc=Dv({typed:Ft}),_n=cg({config:nr,typed:Ft}),Zs=rg({typed:Ft}),U_=og({typed:Ft}),Gs=hv({typed:Ft}),gc=wg({typed:Ft}),Fa=dg({Matrix:Ca,equalScalar:_n,typed:Ft}),vc=Og({typed:Ft}),_c=ug({typed:Ft}),Ma=Ng({typed:Ft}),wc=xg({Fraction:xa,typed:Ft}),Dc=ig({typed:Ft}),xe=Fg({DenseMatrix:Wr,Matrix:Ca,SparseMatrix:Fa,typed:Ft}),yc=Uv({isNaN:_c,isNumeric:Dc,typed:Ft}),Yi=Zv({bignumber:q_,fraction:wc,number:gc}),k_=Wv({config:nr,multiplyScalar:Gs,numeric:Yi,typed:Ft}),W_=Tv({isInteger:Zs,matrix:xe,typed:Ft}),bc=Ov({matrix:xe,config:nr,typed:Ft}),Ec=Lv({matrix:xe,typed:Ft}),Un=bv({isInteger:Zs,matrix:xe,typed:Ft}),Y_=Av({prod:k_,size:bc,typed:Ft}),j_=zv({conj:mc,transpose:Ec,typed:Ft}),ji=Kv({numeric:Yi,typed:Ft}),Z_=Vv({DenseMatrix:Wr,concat:Un,divideScalar:ji,equalScalar:_n,matrix:xe,typed:Ft}),Ac=n_({DenseMatrix:Wr,concat:Un,equalScalar:_n,matrix:xe,typed:Ft}),xc=Cv({BigNumber:Ys,DenseMatrix:Wr,SparseMatrix:Fa,config:nr,matrix:xe,typed:Ft}),G_=Mv({matrix:xe,multiplyScalar:Gs,typed:Ft}),K_=o_({DenseMatrix:Wr,concat:Un,config:nr,matrix:xe,typed:Ft}),H_=gv({DenseMatrix:Wr,concat:Un,equalScalar:_n,matrix:xe,subtractScalar:vc,typed:Ft,unaryMinus:Ma}),Zi=D_({DenseMatrix:Wr,SparseMatrix:Fa,addScalar:js,concat:Un,equalScalar:_n,matrix:xe,typed:Ft}),Cc=t_({BigNumber:Ys,DenseMatrix:Wr,Fraction:xa,concat:Un,config:nr,equalScalar:_n,matrix:xe,typed:Ft}),J_=h_({equal:Ac,typed:Ft}),Fc=b_({addScalar:js,conj:mc,multiplyScalar:Gs,size:bc,typed:Ft}),X_=l_({DenseMatrix:Wr,concat:Un,config:nr,matrix:xe,typed:Ft}),Na=__({config:nr,numeric:Yi,smaller:K_,typed:Ft}),ci=dv({addScalar:js,dot:Fc,equalScalar:_n,matrix:xe,multiplyScalar:Gs,typed:Ft}),V_=d_({compare:Cc,isNaN:_c,isNumeric:Dc,typed:Ft}),Q_=R_({add:Zi,config:nr,numeric:Yi,typed:Ft}),t1=x_({add:Zi,matrix:xe,typed:Ft}),Mc=F_({divideScalar:ji,isZero:U_,matrix:xe,multiply:ci,subtractScalar:vc,typed:Ft,unaryMinus:Ma}),e1=g_({config:nr,larger:X_,numeric:Yi,typed:Ft}),Ks=N_({abs:z_,addScalar:js,det:Mc,divideScalar:ji,identity:xc,matrix:xe,multiply:ci,typed:Ft,unaryMinus:Ma}),r1=B_({Complex:Aa,add:Zi,ctranspose:j_,deepEqual:J_,divideScalar:ji,dot:Fc,dotDivide:Z_,equal:Ac,inv:Ks,matrix:xe,multiply:ci,typed:Ft}),n1=Jv({Complex:Aa,config:nr,fraction:wc,identity:xc,inv:Ks,matrix:xe,multiply:ci,number:gc,typed:Ft}),i1=$_({divideScalar:ji,equalScalar:_n,inv:Ks,matrix:xe,multiply:ci,typed:Ft}),Nc=P_({add:Zi,compare:Cc,divide:i1,partitionSelect:V_,typed:Ft});class s1{constructor(t,e,r){Z(this,"_cacheData");Z(this,"_variables");Z(this,"_math");Z(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},u){if(e===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(t,e,`alma_${u}`);if(l===void 0)return;let f=r*(e-1);s&&(f=Math.floor(f));const p=e/n;let h=0,c=0;for(let m=0;m<=e-1;m++){const _=Math.exp(-1*Math.pow(m-f,2)/(2*Math.pow(p,2)));h+=_,c+=l[l.length-1-(e-m-1)]*_}return c/h}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const u=s.slice(-e);return n=Q_(...u)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const n=this._cacheData[`sma_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`sma_${r}`]=n;const{sum:s}=this._cacheData[`rma_${r}`]||{},u=1/e,l=s===void 0?this.sma({source:t,length:e},r):u*t+(1-u)*(s||0);return this._cacheDataHandle(`rma_${r}`,{sum:l}),l}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:s,close:u,low:l}=this._variables,f=r===void 0?s-l:Math.max(Math.max(s-l,Math.abs(s-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:s,close:u}),this.rma({source:f,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),u=this.sma({source:t,length:e},n);if(s===void 0)return;let l=0;for(let f=0;f<e;f++){const p=this._sum(s[s.length-1-f],-(u||0));l+=p*p}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),u=this.stdev({source:t,length:e},n);if(s===void 0||u===void 0)return[];const l=r*u;return[s,s+l,s-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),u=this.stdev({source:t,length:e},n);if(s===void 0||u===void 0)return;const l=r*u;return(s+l-(s-l))/s}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const s=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return s===void 0?s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),u=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||u===void 0))return 100*(s-u)/(s+u)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let u=0;for(let l=0;l<e;l++){const f=n[n.length-1-l];u+=f*(l+1)}return-u/s}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),u=this.sma({source:t,length:r},`sma1_${n}`),l=this.sma({source:e,length:r},`sma2_${n}`);if(u===void 0||l===void 0||s===void 0)return;let f=0,p=0,h=0;for(let m=0;m<r;m++){const[_,w]=s[s.length-1-m],g=_-u,y=w-l;f+=g*y,p+=g*g,h+=y*y}return isNaN(p)||isNaN(f)||isNaN(h)?void 0:f/Math.sqrt(p*h)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e||n<=s&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n<=s&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let s=0;const u=this._cacheDataList(t,e,`dev_${r}`);if(!(!u||n===void 0)){for(let l=0;l<e;l++){const f=u[u.length-1-l];s+=Math.abs(f-n)}return s/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:s,high:u,close:l,PDMS:f,NDMS:p,TRS:h,ADX:c,count:m=0}=this._cacheData[n]||{},{low:_,high:w,close:g}=this._variables;if(s===void 0||u===void 0||l===void 0)return this._cacheData[n]={low:_,high:w,close:g,PDMS:f,NDMS:p,TRS:w-_,count:1},[void 0,void 0,void 0];let y=w-u,v=s-_;y=y>v&&y>0?y:0,v=v>y&&v>0?v:0,y===v&&(y=v=0);const E=Math.max(w-_,Math.abs(w-l),Math.abs(_-l));if(m<t)return this._cacheDataHandle(n,{low:_,high:w,close:g,PDMS:(f||0)+y,NDMS:(p||0)+v,TRS:(h||0)+E,count:m+1}),[void 0,void 0,void 0];{const b=f-f/t+y,N=p-p/t+v,x=h-h/t+E,F=b/x*100,M=N/x*100,S=Math.abs((F-M)/(F+M))*100;let $=S,C=[F,M,void 0];if(m+1-t<e){const I=m+1-t;$=((c||0)*(I-1)+S)/I}else $=(c*(e-1)+S)/e,C=[F,M,$];return this._cacheDataHandle(n,{low:_,high:w,close:g,PDMS:b,NDMS:N,TRS:x,ADX:$,count:m+1}),C}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:s=1}=this._cacheData[`ema_${r}`]||{};const u=this.sma({source:t,length:e},r);if(s>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=u;return s+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:s}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:s=[]}=this._cacheData[`falling_${r}`]||{};s.push(n>t);const u=s.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:u}),u.length<e?!1:u.every(l=>l)}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,risings:s=[]}=this._cacheData[`rising_${r}`]||{};s.push(n<t);const u=s.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,risings:u}),u.length<e?!1:u.every(l=>l)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highest_${r}`]||[],{high:s,bar_index:u}=this._variables;typeof t!="number"?n[u]=s:n[u]=t,this._cacheData[`highest_${r}`]=n;const l=n.filter(()=>!0);if(!(l.length<e))return Math.max(...l.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highestbars_${r}`]||[],{high:s,bar_index:u}=this._variables;typeof t!="number"?n[u]=s:n[u]=t,this._cacheData[`highestbars_${r}`]=n;const l=n.filter(()=>!0);return l.length<e?void 0:l.slice(-e).reduce((p,h,c,m)=>h>=m[p]?c:p,0)-e+1}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,u=0;for(let l=0;l<e;l++){const f=(e-l)*e;s+=f,u+=n[n.length-1-l]*f}return u/s}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const u=this.ema({source:t,length:e},s),{ta:l,high:f,low:p}=this._variables,h=n?l.tr:f-p,c=this.ema({source:h,length:e},`range_${s}`);return[u,u+c*r,u-c*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const u=this.ema({source:t,length:e},s),{ta:l,high:f,low:p}=this._variables,h=n?l.tr:f-p,c=this.ema({source:h,length:e},`range_${s}`);return(u+c*r-(u-c*r))/u}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const s=this._cacheDataList(t,e,`dev_${n}`);if(!s)return;const u=s.slice(-e).filter(_=>_!==void 0);let l=0,f=0,p=0,h=0;for(const[_,w]of u.entries())l+=_,f+=w,p+=_*w,h+=_*_;const c=(e*p-l*f)/(e*h-l*l);return(f-c*l)/e+c*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowest_${r}`]||[],{low:s,bar_index:u}=this._variables;typeof t!="number"?n[u]=s:n[u]=t,this._cacheData[`lowest_${r}`]=n;const l=n.filter(()=>!0);if(!(l.length<e))return Math.min(...l.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowestbars_${r}`]||[],{low:s,bar_index:u}=this._variables;typeof t!="number"?n[u]=s:n[u]=t,this._cacheData[`lowestbars_${r}`]=n;const l=n.filter(()=>!0);return l.length<e?void 0:l.slice(-e).reduce((p,h,c,m)=>h<=m[p]?c:p,0)-e+1}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const u=this.ema({source:t,length:e},`ema1_${s}`),l=this.ema({source:t,length:r},`ema2_${s}`);if(u===void 0||l===void 0)return[void 0,void 0,void 0];const f=u-l,p=this.ema({source:f,length:n},`macd_${s}`);if(p===void 0)return[f,p,void 0];const h=f-p;return[f,p,h]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Nc(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),u=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(s<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||u===void 0))return 100-100/(1+l/u)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return Na(yc(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,s=this._cacheData[n]||[];if(s[this._variables.bar_index]=t,this._cacheData[n]=s,s.length<=e||t===void 0||isNaN(t))return;let u=s.length-e-1,l;for(;l===void 0&&u>=0;)l=s[u],u--;return l===void 0?l:t-l}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!s)return;const u=this._sort(s.slice(-(e+1))),l=u.length;r/=100;const f=1/(l*2);if(r<=f)return u[0];if(r>=1-1/(l*2))return u[l-1];for(const[p,h]of u.entries()){const c=u[p-1];if(r<(p+.5)/l)return c===void 0||h===void 0?void 0:c+(h-c)*(r-(p-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const u=this._sort(s.slice(-e)),l=r/100*u.length,f=Math.ceil(l)-1;return u[f>=u.length?u.length-1:f]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const s=n.slice(-(e+1)),u=t;if(u===void 0)return;let l=0;for(let f=0;f<s.length;f++)s[f]!==void 0&&(s[f]<u||s[f]===u&&f<e)&&l++;return l/(s.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const s=new Jt;let{close:u,open:l,low:f,high:p}=this._variables;const h=`pivot_point_levels_${n}`,{close:c,low:m,high:_,open:w,result:g}=this._cacheData[h]||{};if(!e&&(_&&m&&(p=Math.max(_,p),f=Math.min(m,f)),this._cacheDataHandle(h,{close:u,open:l,low:f,high:p,result:g}),!r))return s._value=g||[],s;const y={close:u,open:l,low:f,high:p};e===!0&&!r&&(u=c,l=w,f=m,p=_);const v=this._getPivotPointLevels(p,f,u,l,r,t);return this._cacheDataHandle(h,{...y,result:v}),s._value=v,s}_getPivotPointLevels(t,e,r,n,s,u){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(u){case Pn.traditional:return this._traditional(t,e,r);case Pn.fibonacci:return this._fibonacci(t,e,r);case Pn.woodie:return s?[]:this._woodie(t,e);case Pn.classic:return this._classic(t,e,r);case Pn.dm:return this._DM(t,e,r,n);case Pn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,s=n*2-e,u=n+(t-e),l=n*2+(t-2*e),f=n*3+(t-3*e),p=n*4+(t-4*e),h=n*2-t,c=n-(t-e),m=n*2-(2*t-e),_=n*3-(3*t-e),w=n*4-(4*t-e);return[n,s,h,u,c,l,m,f,_,p,w]}_fibonacci(t,e,r){const n=(t+e+r)/3,s=n+.382*(t-e),u=n-.382*(t-e),l=n+.618*(t-e),f=n-.618*(t-e),p=n+(t-e),h=n-(t-e);return[n,s,u,l,f,p,h]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,s=2*n-e,u=2*n-t,l=n+(t-e),f=n-(t-e),p=t+2*(n-e),h=e-2*(t-n),c=p+(t-e),m=h-(t-e);return[n,s,u,l,f,p,h,c,m]}_classic(t,e,r){const n=(t+e+r)/3,s=2*n-e,u=2*n-t,l=n+(t-e),f=n-(t-e),p=n+2*(t-e),h=n-2*(t-e),c=n+3*(t-e),m=n-3*(t-e);return[n,s,u,l,f,p,h,c,m]}_DM(t,e,r,n){let s;n===r?s=t+e+2*r:r>n?s=2*t+e+r:s=2*e+t+r;const u=s/4,l=s/2-e,f=s/2-t;return[u,l,f]}_camarilla(t,e,r){const n=(t+e+r)/3,s=r+1.1*(t-e)/12,u=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,f=r-1.1*(t-e)/6,p=r+1.1*(t-e)/4,h=r-1.1*(t-e)/4,c=r+1.1*(t-e)/2,m=r-1.1*(t-e)/2,_=t/e*r,w=r-(_-r);return[n,s,u,l,f,p,h,c,m,_,w]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!s)return;const u=s.slice(-(e+r+1)),l=u[e];return Math.max(...u)===l?l:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!s)return;const u=s.slice(-(e+r+1)),l=u[e];return Math.min(...u)===l?l:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`);if(!n)return;const s=n.filter(f=>f!==void 0).slice(-e),u=Math.max(...s),l=Math.min(...s);return u-l}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},s=Math.max(t-n,0),u=Math.max(n-t,0),l=this.rma({source:s,length:e},`rma1_${r}`),f=this.rma({source:u,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||f===void 0))return 100-100/(1+l/f)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:s,low:u,high:l,preLow:f,preHigh:p,data:h={}}=this._cacheData[`sar_${n}`]||{};let{result:c,maxMin:m,acceleration:_,isBelow:w}=h,g=!1;const{close:y,low:v,high:E,bar_index:b}=this._variables;return b===1&&(y>s?(w=!0,m=E,c=u):(w=!1,m=v,c=l),g=!0,_=t),c=c+_*(m-c),w?c>v&&(g=!0,w=!1,c=Math.max(E,m||0),m=v,_=t):c<E&&(g=!0,w=!0,c=Math.min(v,m||0),m=E,_=t),g||(w?E>(m||0)&&(m=E,_=Math.min((_||0)+e,r)):v<(m||0)&&(m=v,_=Math.min((_||0)+e,r))),w?(c=Math.min(c,u),b>1&&(c=Math.min(c,f))):(c=Math.max(c,l),b>1&&(c=Math.max(c,p))),this._cacheDataHandle(`sar_${n}`,{high:E,close:y,low:v,preLow:u,preHigh:l,data:Object.assign(h,{result:c,maxMin:m,acceleration:_,isBelow:w})}),c}stoch({source:t,high:e,low:r,length:n},s){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const u=this.lowest({source:r,length:n},s),l=this.highest({source:e,length:n},s);if(!(u===void 0||l===void 0))return 100*(this._variables.close-u)/(l-u)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:s}=this._variables,u=`supertrend_${r}`,{upperBand:l,lowerBand:f,superTrend:p,atr:h,close:c}=this._cacheData[u]||{},m=this.atr({length:e},r);if(m===void 0)return this._cacheDataHandle(u,{close:s}),[void 0,void 0];let _=n+t*m,w=n-t*m;const g=l||0,y=f||0;w=w>y||c<y?w:y,_=_<g||c>g?_:g;let v;h===void 0?v=1:p===g?v=s>_?-1:1:v=s<w?1:-1;const E=v===-1?w:_;return this._cacheDataHandle(u,{upperBand:_,lowerBand:w,superTrend:E,atr:m,close:s}),[E,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:s}=this._variables,{close:u}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),u===void 0?t?s-n:void 0:Math.max(s-n,Math.abs(s-u),Math.abs(n-u))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.change({source:t},n);if(s===void 0)return;const u=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),l=this.ema({source:s,length:e},`ema1_${n}`);if(l===void 0)return;const f=this.ema({source:l,length:r},`ema2_${n}`),p=this.ema({source:u,length:e},`absema2_${n}`);if(f!==void 0)return f/p}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:s}=this._cacheData[`valuewhen_${n}`]||{};return s||(s=[]),t&&s.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:s}),s[s.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const s=this.sma({source:t,length:e},n);if(s===void 0)return;const u=t-s,l=this._math.sum({source:u*u,length:e},n);if(l!==void 0)return r||e<=1?l/e:l/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:s}=this._variables;let{sum:u=0,sumV:l=0,count:f=0,isReset:p,sumS:h=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(u=l=f=h=0,p=!0),!p)return r!==void 0?[]:void 0;const c=t*s+u,m=s+l,_=c/m;return f++,r!==void 0?(h=s*Math.pow(t,2)+h,this._cacheDataHandle(`vwap_${n}`,{sum:c,sumV:m,count:f,isReset:p,sumS:h}),this._computeBands(h,m,r,_)):(this._cacheDataHandle(`vwap_${n}`,{sum:c,sumV:m,count:f,isReset:p}),_)}_computeBands(t,e,r,n){let s=t/e-Math.pow(n,2);s=s<0?0:s;const u=Math.sqrt(s),l=u!==void 0&&!isNaN(u)?n+r*u:void 0,f=u!==void 0&&!isNaN(u)?n-r*u:void 0;return[n,l,f]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),u=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||u===void 0))return s/u}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:u,currentIndex:l}=n,f=t[s];if(f!==void 0){if(u!==void 0&&f<u){t.splice(s,1),t.splice(l,0,f),n={currentIndex:l+1,currentVal:u};continue}n={currentIndex:s,currentVal:f}}}}return t}_cacheDataList(t,e,r){const n=this._cacheData[r]||[];n[this._variables.bar_index]=t,this._cacheData[r]=n;const s=n.filter(()=>!0);if(!(s.length<e))return s}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}const o1={onlyInLoop:"'$text' is only allowed inside loops",invalidType:"Invalid argument 'expr$index' in 'operator SQBR' call",typeUseError:"Cannot specify a type form '$text' without also specifying the type.",notTypeKeyword:"'$text' is not a valid type keyword in variable declaration",undeclared:"Undeclared identifier '$name'",repeatVar:"'$name' is already defined",typeMismatch:"Cannot call '$operator' with argument '$index'. An argument of '$typeE' type was used but a '$typeR' is expected.",assignTypeMismatch:"Cannot assign a value of the `$typeE` type to the '$name' variable. The variable is declared with the `$typeR` type.",voidNotVar:"Void expression cannot be assigned to a variable",declareTypeErr:"Declared type '$type' is not compatible with assigned type '$valueType'",mapKeyValErr:"Cannot put <$typeA, $typeB> pairs into a map containing `$typeC` keys and `$typeD` values. The maps passed into the `$name()` function must have the same key types and value types.",inputSourceErr:"Invalid value for the '$name' parameter of the '$funcName' function. Possible values: [open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume].",buildInUseErr:"Cannot use '$name' as the default value of a type's field. The default value cannot be a function, variable or calculation.",argsLenErr:"Too many arguments passed into the `$name()` function call. Passed $lenA arguments but expected $lenB.",requiredParamErr:"No value assigned to the `$argName` parameter in $name()",argsSyntaxErr:"Syntax error after the argument for `$argName`. Arguments without their parameter name cannot be used after arguments with parameter names.",requestArgsErr:"Type $type cannot be used in $name '$argName' argument",mapKeyErr:"Incorrect `key` type `$type` in the variable. The `key` type must be one of the following: int, float, string, bool, color.",templateErr:"Incorrect number of arguments for the template: $countA expected, $countB passed.",templateNoSupportErr:"The '$name()' function does not support templates",ifOrSwitchTypeErr:"Return type of one of the '$keyword' blocks is not compatible with return type of other block(s) ($types)",argsNameErr:"The '$name' function does not have an argument with the name '$argName'",noFiledErr:"Object has no field $name",methodNotExistErr:"Could not find method or method reference '$methodName' for '$name'",tupleVarErr:"Syntax error: The quantities of tuple elements on each side of the assignment operator do not match. The right side has $indexA but the left side has $indexB.",tupleLeftVarErr:"Invalid assignment. Cannot assign a tuple to a variable '$name'.",tupleRightVarErr:"Cannot assign a variable to a tuple. The right side must be a function call or structure ('if', 'switch', 'for', 'while') returning a tuple with the same number of elements.",tempateTypeErr:"Syntax error: Only templates for arrays and matrices consist of a single type identifier enclosed in angle brackets.",qualifierErr:"'$name' is not a valid type qualifier. Possible values: 'const', 'simple', 'series'",notFindFuncErr:"Could not find function or function reference '$name'",naVarErr:"Value with NA type cannot be assigned to a variable that was defined without type keyword",notHistoryErr:"Variable '$name' doesn't have history values",defaultValueErr:"The default value cannot be a function, variable or calculation.",defaultValueTypeErr:"Default value of type $typeE can not be assigned to an argument of type $typeR",unaryErr:"Syntax error at input '$sign'",funcArgAssignErr:"Function arguments cannot be mutable ('$name')",declaredErr:"A variable declared with the '$prefix' keyword cannot accept values of the '$type' form. Assign a '$prefix' value to this variable or remove the '$prefix' keyword from its declaration.",globalFuncErr:"Cannot use '$name' in local scope",onlyStatementErr:"Scripts must contain one declaration statement: `indicator()`, `strategy()` or `library()`, Your script has $count.",modifyGlobalVarErr:"Cannot modify global variable '$name' in function",inputDefvalErr:"Arguments of input function must be of constant type, or 'source' builtin variables.",objectIsNaErr:"Cannot access the '$name' $type of an undefined object. The object is 'na'."};Pr.SERIES,Pr.SIMPLE,Pr.INPUT,Pr.CONST,Pr.INT,Pr.FLOAT,Pr.BOOL,Pr.COLOR,Pr.STRING;const a1=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"];var hi=(i=>(i[i.Hint=1]="Hint",i[i.Info=2]="Info",i[i.Warning=4]="Warning",i[i.Error=8]="Error",i))(hi||{});class u1{constructor(t,e){Z(this,"_cacheData");Z(this,"_variables");Z(this,"_errorListener");Z(this,"_count");Z(this,"_historyInputs");Z(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._count=-1,this._name=`inputs_${Tp()}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){for(const e of t){const r=e.id;if(!this._cacheData[r])return;Object.assign(this._cacheData[r],{...e,isModify:!0}),self.workerStorage.updateValue(this._name,`in_${e.index}`,{modifyDefval:e.sourceTypeName||e.defval})}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._cacheHandle(t,e,"int")}bool(t,e){return this._cacheHandle(t,e,"bool")}color(t,e){return this._cacheHandle(t,e,"color")}time(t,e){return this._cacheHandle(t,e,"time")}float(t,e){return this._cacheHandle(t,e,"float")}price(t,e){return this._cacheHandle(t,e,"price")}source(t,e){return this._cacheHandle(t,e,"source")}string(t,e){return this._cacheHandle(t,e,"string")}symbol(t,e){return this._cacheHandle(t,e,"symbol")}session(t,e){return this._cacheHandle(t,e,"session")}text_area(t,e){return this._cacheHandle(t,e,"text_area")}timeframe(t,e){return this._cacheHandle(t,e,"timeframe")}_cacheHandle(t,e,r){const n=`${r||"input"}_${e}`,s=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(o1.inputDefvalErr,e,hi.Error),s)s.isModify?s.sourceTypeName&&(this._cacheData[n].defval=this._variables[s.sourceTypeName]):Object.assign(this._cacheData[n],t);else{const{defval:u,display:l}=t;this._displayVerify(e,l),this._count++,t={inputType:r,...t,index:this._count},this._cacheData[n]=t,this._judgeHistoryInputs(t),(r||t.inputType)==="source"?this._cacheData[n].options=a1:t.options&&!t.options.includes(u)&&this._errorListener.addError(`input's defval should be in options, but '${u}' is not in [${t.options.toString()}]`,e,hi.Error)}return this._cacheData[n].defval}_judgeHistoryInputs(t){const{defval:e,sourceTypeName:r,index:n}=t;let s=r||e;const u=`in_${n}`,l=this._historyInputs[u];if(!l)self.workerStorage.setValue(this._name,u,{defval:s});else{const{defval:f,modifyDefval:p}=l;f===s?s=p||s:self.workerStorage.setValue(this._name,u,{defval:s})}r?t.sourceTypeName=s:t.defval=s}_displayVerify(t,e){!e||!e.length||e.includes(er.dataWindow)||e.includes(er.statusLine)||this._errorListener.addError("Invalid argument 'display' in 'input' call. Possible values: [display.none, display.data_window, display.status_line, display.all]",t,hi.Error)}getInputs(){var n;const t=Object.keys(this._cacheData),e=new Map,r=[];for(const s of t){const u=this._cacheData[s];u.id=s;const{group:l}=u;l?e.has(l)?(n=e.get(l))==null||n.push(u):e.set(l,[u]):r.push(u)}return[...this._getGroups(e),{inputs:r}]}_getGroups(t){const e=[];for(const[r,n]of t)e.push({name:r,inputs:n});return e}}class l1{color({x:t}){return t}new({color:t,transp:e=100}){const{r,g:n,b:s}=this._parseColor(t);return`rgba(${Math.round(r)}, ${Math.round(n)}, ${Math.round(s)}, ${e/100})`}rgb({red:t,green:e,blue:r,transp:n=0}){return`rgba(${t}, ${e}, ${r}, ${n/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:s}){const u=(t-e)/(r-e),l=Math.min(Math.max(u,0),1),{r:f,g:p,b:h,a:c}=this._parseColor(n),{r:m,g:_,b:w,a:g}=this._parseColor(s),y=f+l*(m-f),v=p+l*(_-p),E=h+l*(w-h),b=c+l*(g-c);return`rgba(${Math.round(y)}, ${Math.round(v)}, ${Math.round(E)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const u=t.substring(7);u?s=(255-parseInt(u,16))/255:s=1}else{const u=this._parserRgbColor(t);e=u[0],r=u[1],n=u[2],s=u[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var Pt={};const f1=Object.prototype.toString;function Gi(i){const t=f1.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var c1=Object.freeze({__proto__:null,isAnyArray:Gi}),h1=De(c1);function p1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Gi(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var u=i[r],l=r+1;l<s;l++)i[l]>u&&(u=i[l]);return u}function d1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Gi(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var u=i[r],l=r+1;l<s;l++)i[l]<u&&(u=i[l]);return u}function m1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Gi(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!Gi(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=d1(i),n=p1(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,u=s===void 0?t.autoMinMax?r:0:s,l=t.max,f=l===void 0?t.autoMinMax?n:1:l;if(u>=f)throw new RangeError("min option must be smaller than max option");for(var p=(f-u)/(n-r),h=0;h<i.length;h++)e[h]=(i[h]-r)*p+u;return e}var g1=Object.freeze({__proto__:null,default:m1}),v1=De(g1);Object.defineProperty(Pt,"__esModule",{value:!0});var Je=h1,Sc=v1;const Hs=" ".repeat(2),Bc=" ".repeat(4);function _1(){return Ic(this)}function Ic(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
54
+ (`+se(S,g)+", "+se(N,g)+") ==> "+(this._values?se(this._values[M],g):"X")}return b},n.prototype.toString=function(){return se(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(g){if(g){if(ye(g)&&(g=g.toNumber()),!ue(g)||!he(g))throw new TypeError("The parameter k must be an integer number")}else g=0;var y=g>0?g:0,v=g<0?-g:0,E=this._size[0],b=this._size[1],N=Math.min(E-v,b-y),x=[],F=[],M=[];M[0]=0;for(var S=y;S<b&&x.length<N;S++)for(var $=this._ptr[S],C=this._ptr[S+1],I=$;I<C;I++){var R=this._index[I];if(R===S-y+v){x.push(this._values[I]),F[x.length-1]=R-v;break}}return M.push(x.length),new n({values:x,index:F,ptr:M,size:[N,1]})},n.fromJSON=function(g){return new n(g)},n.diagonal=function(g,y,v,E,b){if(!ge(g))throw new TypeError("Array expected, size parameter");if(g.length!==2)throw new Error("Only two dimensions matrix are supported");if(g=g.map(function(V){if(ye(V)&&(V=V.toNumber()),!ue(V)||!he(V)||V<1)throw new Error("Size values must be positive integers");return V}),v){if(ye(v)&&(v=v.toNumber()),!ue(v)||!he(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var N=e,x=0;Ur(b)&&(N=t.find(e,[b,b])||e,x=t.convert(0,b));var F=v>0?v:0,M=v<0?-v:0,S=g[0],$=g[1],C=Math.min(S-M,$-F),I;if(ge(y)){if(y.length!==C)throw new Error("Invalid value array length");I=function(tt){return y[tt]}}else if(fe(y)){var R=y.size();if(R.length!==1||R[0]!==C)throw new Error("Invalid matrix length");I=function(tt){return y.get([tt])}}else I=function(){return y};for(var U=[],q=[],k=[],P=0;P<$;P++){k.push(U.length);var K=P-F;if(K>=0&&K<C){var G=I(K);N(G,x)||(q.push(K+M),U.push(G))}}return k.push(U.length),new n({values:U,index:q,ptr:k,size:[S,$]})},n.prototype.swapRows=function(g,y){if(!ue(g)||!he(g)||!ue(y)||!he(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return ve(g,this._size[0]),ve(y,this._size[0]),n._swapRows(g,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(g,y,v,E,b){for(var N=E[g],x=E[g+1],F=N;F<x;F++)b(v[F],y[F])},n._swapRows=function(g,y,v,E,b,N){for(var x=0;x<v;x++){var F=N[x],M=N[x+1],S=p(g,F,M,b),$=p(y,F,M,b);if(S<M&&$<M&&b[S]===g&&b[$]===y){if(E){var C=E[S];E[S]=E[$],E[$]=C}continue}if(S<M&&b[S]===g&&($>=M||b[$]!==y)){var I=E?E[S]:void 0;b.splice($,0,y),E&&E.splice($,0,I),b.splice($<=S?S+1:S,1),E&&E.splice($<=S?S+1:S,1);continue}if($<M&&b[$]===y&&(S>=M||b[S]!==g)){var R=E?E[$]:void 0;b.splice(S,0,g),E&&E.splice(S,0,R),b.splice(S<=$?$+1:$,1),E&&E.splice(S<=$?$+1:$,1)}}},n},{isClass:!0}),mg="number",gg=["typed"];function vg(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function _g(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var wg=mt(mg,gg,i=>{var{typed:t}=i,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var s=vg(n);if(s)return _g(s);var u=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(u=Number(l[2]),n=l[1]);var f=Number(n);if(isNaN(f))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(f>2**u-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));f>=2**(u-1)&&(f=f-2**u)}return f},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),null:function(n){return 0},"Unit, string | Unit":function(n,s){return n.toNumber(s)},"Array | Matrix":t.referToSelf(r=>n=>Ir(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),Dg="bignumber",yg=["typed","BigNumber"],bg=mt(Dg,yg,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var u=s[2],l=e(s[1]),f=new e(2).pow(Number(u));if(l.gt(f.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var p=new e(2).pow(Number(u)-1);return l.gte(p)?l.sub(f):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Ir(n,r))})}),Eg="fraction",Ag=["typed","Fraction"],xg=mt(Eg,Ag,i=>{var{typed:t,Fraction:e}=i;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,s){return new e(n,s)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Ir(n,r))})}),$f="matrix",Cg=["typed","Matrix","DenseMatrix","SparseMatrix"],Fg=mt($f,Cg,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t($f,{"":function(){return s([])},string:function(l){return s([],l)},"string, string":function(l,f){return s([],l,f)},Array:function(l){return s(l)},Matrix:function(l){return s(l,l.storage())},"Array | Matrix, string":s,"Array | Matrix, string, string":s});function s(u,l,f){if(l==="dense"||l==="default"||l===void 0)return new r(u,f);if(l==="sparse")return new n(u,f);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),Of="unaryMinus",Mg=["typed"],Ng=mt(Of,Mg,i=>{var{typed:t}=i;return t(Of,{number:Cf,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf(e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n}),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),Rf="abs",Sg=["typed"],Bg=mt(Rf,Sg,i=>{var{typed:t}=i;return t(Rf,{number:bf,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),Lf="addScalar",Ig=["typed"],Tg=mt(Lf,Ig,i=>{var{typed:t}=i;return t(Lf,{"number, number":Ef,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),Pf="subtractScalar",$g=["typed"],Og=mt(Pf,$g,i=>{var{typed:t}=i;return t(Pf,{"number, number":Af,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),Rg="matAlgo11xS0s",Lg=["typed","equalScalar"],ba=mt(Rg,Lg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,u,l){var f=n._values,p=n._index,h=n._ptr,c=n._size,m=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var _=c[0],w=c[1],g,y=e,v=0,E=u;typeof m=="string"&&(g=m,y=t.find(e,[g,g]),v=t.convert(0,g),s=t.convert(s,g),E=t.find(u,[g,g]));for(var b=[],N=[],x=[],F=0;F<w;F++){x[F]=N.length;for(var M=h[F],S=h[F+1],$=M;$<S;$++){var C=p[$],I=l?E(s,f[$]):E(f[$],s);y(I,v)||(N.push(C),b.push(I))}}return x[w]=N.length,n.createSparseMatrix({values:b,index:N,ptr:x,size:[_,w],datatype:g})}}),Pg="matAlgo12xSfs",zg=["typed","DenseMatrix"],li=mt(Pg,zg,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,u,l){var f=n._values,p=n._index,h=n._ptr,c=n._size,m=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var _=c[0],w=c[1],g,y=u;typeof m=="string"&&(g=m,s=t.convert(s,g),y=t.find(u,[g,g]));for(var v=[],E=[],b=[],N=0;N<w;N++){for(var x=N+1,F=h[N],M=h[N+1],S=F;S<M;S++){var $=p[S];E[$]=f[S],b[$]=x}for(var C=0;C<_;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?y(s,E[C]):y(E[C],s):v[C][N]=l?y(s,0):y(0,s)}return new e({data:v,size:[_,w],datatype:g})}}),qg="matAlgo14xDs",Ug=["typed"],Ea=mt(qg,Ug,i=>{var{typed:t}=i;return function(n,s,u,l){var f=n._data,p=n._size,h=n._datatype,c,m=u;typeof h=="string"&&(c=h,s=t.convert(s,c),m=t.find(u,[c,c]));var _=p.length>0?e(m,0,p,p[0],f,s,l):[];return n.createDenseMatrix({data:_,size:te(p),datatype:c})};function e(r,n,s,u,l,f,p){var h=[];if(n===s.length-1)for(var c=0;c<u;c++)h[c]=p?r(f,l[c]):r(l[c],f);else for(var m=0;m<u;m++)h[m]=e(r,n+1,s,s[n+1],l[m],f,p);return h}}),kg="matAlgo02xDS0",Wg=["typed","equalScalar"],Yg=mt(kg,Wg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,u,l){var f=n._data,p=n._size,h=n._datatype||n.getDataType(),c=s._values,m=s._index,_=s._ptr,w=s._size,g=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(p.length!==w.length)throw new Zt(p.length,w.length);if(p[0]!==w[0]||p[1]!==w[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+w+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=p[0],v=p[1],E,b=e,N=0,x=u;typeof h=="string"&&h===g&&h!=="mixed"&&(E=h,b=t.find(e,[E,E]),N=t.convert(0,E),x=t.find(u,[E,E]));for(var F=[],M=[],S=[],$=0;$<v;$++){S[$]=M.length;for(var C=_[$],I=_[$+1],R=C;R<I;R++){var U=m[R],q=l?x(c[R],f[U][$]):x(f[U][$],c[R]);b(q,N)||(M.push(U),F.push(q))}}return S[v]=M.length,s.createSparseMatrix({values:F,index:M,ptr:S,size:[y,v],datatype:h===n._datatype&&g===s._datatype?E:void 0})}}),jg="matAlgo03xDSf",Zg=["typed"],fi=mt(jg,Zg,i=>{var{typed:t}=i;return function(r,n,s,u){var l=r._data,f=r._size,p=r._datatype||r.getDataType(),h=n._values,c=n._index,m=n._ptr,_=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(f.length!==_.length)throw new Zt(f.length,_.length);if(f[0]!==_[0]||f[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+_+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=f[0],y=f[1],v,E=0,b=s;typeof p=="string"&&p===w&&p!=="mixed"&&(v=p,E=t.convert(0,v),b=t.find(s,[v,v]));for(var N=[],x=0;x<g;x++)N[x]=[];for(var F=[],M=[],S=0;S<y;S++){for(var $=S+1,C=m[S],I=m[S+1],R=C;R<I;R++){var U=c[R];F[U]=u?b(h[R],l[U][S]):b(l[U][S],h[R]),M[U]=$}for(var q=0;q<g;q++)M[q]===$?N[q][S]=F[q]:N[q][S]=u?b(E,l[q][S]):b(l[q][S],E)}return r.createDenseMatrix({data:N,size:[g,y],datatype:p===r._datatype&&w===n._datatype?v:void 0})}}),Gg="matAlgo05xSfSf",Kg=["typed","equalScalar"],zf=mt(Gg,Kg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,u){var l=n._values,f=n._index,p=n._ptr,h=n._size,c=n._datatype||n._data===void 0?n._datatype:n.getDataType(),m=s._values,_=s._index,w=s._ptr,g=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==g.length)throw new Zt(h.length,g.length);if(h[0]!==g[0]||h[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+g+")");var v=h[0],E=h[1],b,N=e,x=0,F=u;typeof c=="string"&&c===y&&c!=="mixed"&&(b=c,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(u,[b,b]));var M=l&&m?[]:void 0,S=[],$=[],C=M?[]:void 0,I=M?[]:void 0,R=[],U=[],q,k,P,K;for(k=0;k<E;k++){$[k]=S.length;var G=k+1;for(P=p[k],K=p[k+1];P<K;P++)q=f[P],S.push(q),R[q]=G,C&&(C[q]=l[P]);for(P=w[k],K=w[k+1];P<K;P++)q=_[P],R[q]!==G&&S.push(q),U[q]=G,I&&(I[q]=m[P]);if(M)for(P=$[k];P<S.length;){q=S[P];var V=R[q],tt=U[q];if(V===G||tt===G){var ft=V===G?C[q]:x,vt=tt===G?I[q]:x,lt=F(ft,vt);N(lt,x)?S.splice(P,1):(M.push(lt),P++)}}}return $[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:$,size:[v,E],datatype:c===n._datatype&&y===s._datatype?b:void 0})}}),Hg="matAlgo13xDD",Jg=["typed"],Xg=mt(Hg,Jg,i=>{var{typed:t}=i;return function(n,s,u){var l=n._data,f=n._size,p=n._datatype,h=s._data,c=s._size,m=s._datatype,_=[];if(f.length!==c.length)throw new Zt(f.length,c.length);for(var w=0;w<f.length;w++){if(f[w]!==c[w])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+c+")");_[w]=f[w]}var g,y=u;typeof p=="string"&&p===m&&(g=p,y=t.find(u,[g,g]));var v=_.length>0?e(y,0,_,_[0],l,h):[];return n.createDenseMatrix({data:v,size:_,datatype:g})};function e(r,n,s,u,l,f){var p=[];if(n===s.length-1)for(var h=0;h<u;h++)p[h]=r(l[h],f[h]);else for(var c=0;c<u;c++)p[c]=e(r,n+1,s,s[n+1],l[c],f[c]);return p}}),Vg="broadcast",Qg=["concat"],tv=mt(Vg,Qg,i=>{var{concat:t}=i;return function(n,s){var u=Math.max(n._size.length,s._size.length);if(n._size.length===s._size.length&&n._size.every((w,g)=>w===s._size[g]))return[n,s];for(var l=e(n._size,u,0),f=e(s._size,u,0),p=[],h=0;h<u;h++)p[h]=Math.max(l[h],f[h]);As(l,p),As(f,p);var c=n.clone(),m=s.clone();c._size.length<u?c.reshape(e(c._size,u,1)):m._size.length<u&&m.reshape(e(m._size,u,1));for(var _=0;_<u;_++)c._size[_]<p[_]&&(c=r(c,p[_],_)),m._size[_]<p[_]&&(m=r(m,p[_],_));return[c,m]};function e(n,s,u){return[...Array(s-n.length).fill(u),...n]}function r(n,s,u){return t(...Array(s).fill(n),u)}}),ev="matrixAlgorithmSuite",rv=["typed","matrix","concat"],qn=mt(ev,rv,i=>{var{typed:t,matrix:e,concat:r}=i,n=Xg({typed:t}),s=Ea({typed:t}),u=tv({concat:r});return function(f){var p=f.elop,h=f.SD||f.DS,c;p?(c={"DenseMatrix, DenseMatrix":(g,y)=>n(...u(g,y),p),"Array, Array":(g,y)=>n(...u(e(g),e(y)),p).valueOf(),"Array, DenseMatrix":(g,y)=>n(...u(e(g),y),p),"DenseMatrix, Array":(g,y)=>n(...u(g,e(y)),p)},f.SS&&(c["SparseMatrix, SparseMatrix"]=(g,y)=>f.SS(...u(g,y),p,!1)),f.DS&&(c["DenseMatrix, SparseMatrix"]=(g,y)=>f.DS(...u(g,y),p,!1),c["Array, SparseMatrix"]=(g,y)=>f.DS(...u(e(g),y),p,!1)),h&&(c["SparseMatrix, DenseMatrix"]=(g,y)=>h(...u(y,g),p,!0),c["SparseMatrix, Array"]=(g,y)=>h(...u(e(y),g),p,!0))):(c={"DenseMatrix, DenseMatrix":t.referToSelf(g=>(y,v)=>n(...u(y,v),g)),"Array, Array":t.referToSelf(g=>(y,v)=>n(...u(e(y),e(v)),g).valueOf()),"Array, DenseMatrix":t.referToSelf(g=>(y,v)=>n(...u(e(y),v),g)),"DenseMatrix, Array":t.referToSelf(g=>(y,v)=>n(...u(y,e(v)),g))},f.SS&&(c["SparseMatrix, SparseMatrix"]=t.referToSelf(g=>(y,v)=>f.SS(...u(y,v),g,!1))),f.DS&&(c["DenseMatrix, SparseMatrix"]=t.referToSelf(g=>(y,v)=>f.DS(...u(y,v),g,!1)),c["Array, SparseMatrix"]=t.referToSelf(g=>(y,v)=>f.DS(...u(e(y),v),g,!1))),h&&(c["SparseMatrix, DenseMatrix"]=t.referToSelf(g=>(y,v)=>h(...u(v,y),g,!0)),c["SparseMatrix, Array"]=t.referToSelf(g=>(y,v)=>h(...u(e(v),y),g,!0))));var m=f.scalar||"any",_=f.Ds||f.Ss;_&&(p?(c["DenseMatrix,"+m]=(g,y)=>s(g,y,p,!1),c[m+", DenseMatrix"]=(g,y)=>s(y,g,p,!0),c["Array,"+m]=(g,y)=>s(e(g),y,p,!1).valueOf(),c[m+", Array"]=(g,y)=>s(e(y),g,p,!0).valueOf()):(c["DenseMatrix,"+m]=t.referToSelf(g=>(y,v)=>s(y,v,g,!1)),c[m+", DenseMatrix"]=t.referToSelf(g=>(y,v)=>s(v,y,g,!0)),c["Array,"+m]=t.referToSelf(g=>(y,v)=>s(e(y),v,g,!1).valueOf()),c[m+", Array"]=t.referToSelf(g=>(y,v)=>s(e(v),y,g,!0).valueOf())));var w=f.sS!==void 0?f.sS:f.Ss;return p?(f.Ss&&(c["SparseMatrix,"+m]=(g,y)=>f.Ss(g,y,p,!1)),w&&(c[m+", SparseMatrix"]=(g,y)=>w(y,g,p,!0))):(f.Ss&&(c["SparseMatrix,"+m]=t.referToSelf(g=>(y,v)=>f.Ss(y,v,g,!1))),w&&(c[m+", SparseMatrix"]=t.referToSelf(g=>(y,v)=>w(v,y,g,!0)))),p&&p.signatures&&Bl(c,p.signatures),c}}),nv="matAlgo01xDSid",iv=["typed"],qf=mt(nv,iv,i=>{var{typed:t}=i;return function(r,n,s,u){var l=r._data,f=r._size,p=r._datatype||r.getDataType(),h=n._values,c=n._index,m=n._ptr,_=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(f.length!==_.length)throw new Zt(f.length,_.length);if(f[0]!==_[0]||f[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+_+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=f[0],y=f[1],v=typeof p=="string"&&p!=="mixed"&&p===w?p:void 0,E=v?t.find(s,[v,v]):s,b,N,x=[];for(b=0;b<g;b++)x[b]=[];var F=[],M=[];for(N=0;N<y;N++){for(var S=N+1,$=m[N],C=m[N+1],I=$;I<C;I++)b=c[I],F[b]=u?E(h[I],l[b][N]):E(l[b][N],h[I]),M[b]=S;for(b=0;b<g;b++)M[b]===S?x[b][N]=F[b]:x[b][N]=l[b][N]}return r.createDenseMatrix({data:x,size:[g,y],datatype:p===r._datatype&&w===n._datatype?v:void 0})}}),sv="matAlgo04xSidSid",ov=["typed","equalScalar"],av=mt(sv,ov,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,u){var l=n._values,f=n._index,p=n._ptr,h=n._size,c=n._datatype||n._data===void 0?n._datatype:n.getDataType(),m=s._values,_=s._index,w=s._ptr,g=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==g.length)throw new Zt(h.length,g.length);if(h[0]!==g[0]||h[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+g+")");var v=h[0],E=h[1],b,N=e,x=0,F=u;typeof c=="string"&&c===y&&c!=="mixed"&&(b=c,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(u,[b,b]));var M=l&&m?[]:void 0,S=[],$=[],C=l&&m?[]:void 0,I=l&&m?[]:void 0,R=[],U=[],q,k,P,K,G;for(k=0;k<E;k++){$[k]=S.length;var V=k+1;for(K=p[k],G=p[k+1],P=K;P<G;P++)q=f[P],S.push(q),R[q]=V,C&&(C[q]=l[P]);for(K=w[k],G=w[k+1],P=K;P<G;P++)if(q=_[P],R[q]===V){if(C){var tt=F(C[q],m[P]);N(tt,x)?R[q]=null:C[q]=tt}}else S.push(q),U[q]=V,I&&(I[q]=m[P]);if(C&&I)for(P=$[k];P<S.length;)q=S[P],R[q]===V?(M[P]=C[q],P++):U[q]===V?(M[P]=I[q],P++):S.splice(P,1)}return $[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:$,size:[v,E],datatype:c===n._datatype&&y===s._datatype?b:void 0})}}),uv="matAlgo10xSids",lv=["typed","DenseMatrix"],Uf=mt(uv,lv,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,u,l){var f=n._values,p=n._index,h=n._ptr,c=n._size,m=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var _=c[0],w=c[1],g,y=u;typeof m=="string"&&(g=m,s=t.convert(s,g),y=t.find(u,[g,g]));for(var v=[],E=[],b=[],N=0;N<w;N++){for(var x=N+1,F=h[N],M=h[N+1],S=F;S<M;S++){var $=p[S];E[$]=f[S],b[$]=x}for(var C=0;C<_;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?y(s,E[C]):y(E[C],s):v[C][N]=s}return new e({data:v,size:[_,w],datatype:g})}}),fv="multiplyScalar",cv=["typed"],hv=mt(fv,cv,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":xf,"Complex, Complex":function(r,n){return r.mul(n)},"BigNumber, BigNumber":function(r,n){return r.times(n)},"Fraction, Fraction":function(r,n){return r.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})}),kf="multiply",pv=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],dv=mt(kf,pv,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:u}=i,l=ba({typed:t,equalScalar:s}),f=Ea({typed:t});function p(x,F){switch(x.length){case 1:switch(F.length){case 1:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;case 2:switch(F.length){case 1:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+F[0]+")");break;case 2:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function h(x,F,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return u(x,F)}function c(x,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(x,F)}function m(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._data,I=F._size,R=F._datatype||F.getDataType(),U=S[0],q=I[1],k,P=r,K=n;$&&R&&$===R&&typeof $=="string"&&$!=="mixed"&&(k=$,P=t.find(r,[k,k]),K=t.find(n,[k,k]));for(var G=[],V=0;V<q;V++){for(var tt=K(M[0],C[0][V]),ft=1;ft<U;ft++)tt=P(tt,K(M[ft],C[ft][V]));G[V]=tt}return x.createDenseMatrix({data:G,size:[q],datatype:$===x._datatype&&R===F._datatype?k:void 0})}var _=t("_multiplyMatrixVector",{"DenseMatrix, any":g,"SparseMatrix, any":E}),w=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function g(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._data,I=F._datatype||F.getDataType(),R=S[0],U=S[1],q,k=r,P=n;$&&I&&$===I&&typeof $=="string"&&$!=="mixed"&&(q=$,k=t.find(r,[q,q]),P=t.find(n,[q,q]));for(var K=[],G=0;G<R;G++){for(var V=M[G],tt=P(V[0],C[0]),ft=1;ft<U;ft++)tt=k(tt,P(V[ft],C[ft]));K[G]=tt}return x.createDenseMatrix({data:K,size:[R],datatype:$===x._datatype&&I===F._datatype?q:void 0})}function y(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._data,I=F._size,R=F._datatype||F.getDataType(),U=S[0],q=S[1],k=I[1],P,K=r,G=n;$&&R&&$===R&&typeof $=="string"&&$!=="mixed"&&$!=="mixed"&&(P=$,K=t.find(r,[P,P]),G=t.find(n,[P,P]));for(var V=[],tt=0;tt<U;tt++){var ft=M[tt];V[tt]=[];for(var vt=0;vt<k;vt++){for(var lt=G(ft[0],C[0][vt]),wt=1;wt<q;wt++)lt=K(lt,G(ft[wt],C[wt][vt]));V[tt][vt]=lt}}return x.createDenseMatrix({data:V,size:[U,k],datatype:$===x._datatype&&R===F._datatype?P:void 0})}function v(x,F){var M=x._data,S=x._size,$=x._datatype||x.getDataType(),C=F._values,I=F._index,R=F._ptr,U=F._size,q=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!C)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var k=S[0],P=U[1],K,G=r,V=n,tt=s,ft=0;$&&q&&$===q&&typeof $=="string"&&$!=="mixed"&&(K=$,G=t.find(r,[K,K]),V=t.find(n,[K,K]),tt=t.find(s,[K,K]),ft=t.convert(0,K));for(var vt=[],lt=[],wt=[],yt=F.createSparseMatrix({values:vt,index:lt,ptr:wt,size:[k,P],datatype:$===x._datatype&&q===F._datatype?K:void 0}),St=0;St<P;St++){wt[St]=lt.length;var bt=R[St],ee=R[St+1];if(ee>bt)for(var It=0,Mt=0;Mt<k;Mt++){for(var ie=Mt+1,Xt=void 0,zt=bt;zt<ee;zt++){var Gt=I[zt];It!==ie?(Xt=V(M[Mt][Gt],C[zt]),It=ie):Xt=G(Xt,V(M[Mt][Gt],C[zt]))}It===ie&&!tt(Xt,ft)&&(lt.push(Mt),vt.push(Xt))}}return wt[P]=lt.length,yt}function E(x,F){var M=x._values,S=x._index,$=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var I=F._data,R=F._datatype||F.getDataType(),U=x._size[0],q=F._size[0],k=[],P=[],K=[],G,V=r,tt=n,ft=s,vt=0;C&&R&&C===R&&typeof C=="string"&&C!=="mixed"&&(G=C,V=t.find(r,[G,G]),tt=t.find(n,[G,G]),ft=t.find(s,[G,G]),vt=t.convert(0,G));var lt=[],wt=[];K[0]=0;for(var yt=0;yt<q;yt++){var St=I[yt];if(!ft(St,vt))for(var bt=$[yt],ee=$[yt+1],It=bt;It<ee;It++){var Mt=S[It];wt[Mt]?lt[Mt]=V(lt[Mt],tt(St,M[It])):(wt[Mt]=!0,P.push(Mt),lt[Mt]=tt(St,M[It]))}}for(var ie=P.length,Xt=0;Xt<ie;Xt++){var zt=P[Xt];k[Xt]=lt[zt]}return K[1]=P.length,x.createSparseMatrix({values:k,index:P,ptr:K,size:[U,1],datatype:C===x._datatype&&R===F._datatype?G:void 0})}function b(x,F){var M=x._values,S=x._index,$=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var I=F._data,R=F._datatype||F.getDataType(),U=x._size[0],q=F._size[0],k=F._size[1],P,K=r,G=n,V=s,tt=0;C&&R&&C===R&&typeof C=="string"&&C!=="mixed"&&(P=C,K=t.find(r,[P,P]),G=t.find(n,[P,P]),V=t.find(s,[P,P]),tt=t.convert(0,P));for(var ft=[],vt=[],lt=[],wt=x.createSparseMatrix({values:ft,index:vt,ptr:lt,size:[U,k],datatype:C===x._datatype&&R===F._datatype?P:void 0}),yt=[],St=[],bt=0;bt<k;bt++){lt[bt]=vt.length;for(var ee=bt+1,It=0;It<q;It++){var Mt=I[It][bt];if(!V(Mt,tt))for(var ie=$[It],Xt=$[It+1],zt=ie;zt<Xt;zt++){var Gt=S[zt];St[Gt]!==ee?(St[Gt]=ee,vt.push(Gt),yt[Gt]=G(Mt,M[zt])):yt[Gt]=K(yt[Gt],G(Mt,M[zt]))}}for(var Ce=lt[bt],sr=vt.length,Me=Ce;Me<sr;Me++){var Vr=vt[Me];ft[Me]=yt[Vr]}}return lt[k]=vt.length,wt}function N(x,F){var M=x._values,S=x._index,$=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType(),I=F._values,R=F._index,U=F._ptr,q=F._datatype||F._data===void 0?F._datatype:F.getDataType(),k=x._size[0],P=F._size[1],K=M&&I,G,V=r,tt=n;C&&q&&C===q&&typeof C=="string"&&C!=="mixed"&&(G=C,V=t.find(r,[G,G]),tt=t.find(n,[G,G]));for(var ft=K?[]:void 0,vt=[],lt=[],wt=x.createSparseMatrix({values:ft,index:vt,ptr:lt,size:[k,P],datatype:C===x._datatype&&q===F._datatype?G:void 0}),yt=K?[]:void 0,St=[],bt,ee,It,Mt,ie,Xt,zt,Gt,Ce=0;Ce<P;Ce++){lt[Ce]=vt.length;var sr=Ce+1;for(ie=U[Ce],Xt=U[Ce+1],Mt=ie;Mt<Xt;Mt++)if(Gt=R[Mt],K)for(ee=$[Gt],It=$[Gt+1],bt=ee;bt<It;bt++)zt=S[bt],St[zt]!==sr?(St[zt]=sr,vt.push(zt),yt[zt]=tt(I[Mt],M[bt])):yt[zt]=V(yt[zt],tt(I[Mt],M[bt]));else for(ee=$[Gt],It=$[Gt+1],bt=ee;bt<It;bt++)zt=S[bt],St[zt]!==sr&&(St[zt]=sr,vt.push(zt));if(K)for(var Me=lt[Ce],Vr=vt.length,wn=Me;wn<Vr;wn++){var Qr=vt[wn];ft[wn]=yt[Qr]}}return lt[P]=vt.length,wt}return t(kf,n,{"Array, Array":t.referTo("Matrix, Matrix",x=>(F,M)=>{p(Ae(F),Ae(M));var S=x(e(F),e(M));return fe(S)?S.valueOf():S}),"Matrix, Matrix":function(F,M){var S=F.size(),$=M.size();return p(S,$),S.length===1?$.length===1?h(F,M,S[0]):c(F,M):$.length===1?_(F,M):w(F,M)},"Matrix, Array":t.referTo("Matrix,Matrix",x=>(F,M)=>x(F,e(M))),"Array, Matrix":t.referToSelf(x=>(F,M)=>x(e(F,M.storage()),M)),"SparseMatrix, any":function(F,M){return l(F,M,n,!1)},"DenseMatrix, any":function(F,M){return f(F,M,n,!1)},"any, SparseMatrix":function(F,M){return l(M,F,n,!0)},"any, DenseMatrix":function(F,M){return f(M,F,n,!0)},"Array, any":function(F,M){return f(e(F),M,n,!1).valueOf()},"any, Array":function(F,M){return f(e(M),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(x=>(F,M,S)=>{for(var $=x(F,M),C=0;C<S.length;C++)$=x($,S[C]);return $})})}),Wf="subtract",mv=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],gv=mt(Wf,mv,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:u,concat:l}=i,f=qf({typed:t}),p=fi({typed:t}),h=zf({typed:t,equalScalar:r}),c=Uf({typed:t,DenseMatrix:u}),m=li({typed:t,DenseMatrix:u}),_=qn({typed:t,matrix:e,concat:l});return t(Wf,{"any, any":n},_({elop:n,SS:h,DS:f,SD:p,Ss:m,sS:c}))}),vv="matAlgo07xSSf",_v=["typed","DenseMatrix"],zs=mt(vv,_v,i=>{var{typed:t,DenseMatrix:e}=i;return function(s,u,l){var f=s._size,p=s._datatype||s._data===void 0?s._datatype:s.getDataType(),h=u._size,c=u._datatype||u._data===void 0?u._datatype:u.getDataType();if(f.length!==h.length)throw new Zt(f.length,h.length);if(f[0]!==h[0]||f[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+h+")");var m=f[0],_=f[1],w,g=0,y=l;typeof p=="string"&&p===c&&p!=="mixed"&&(w=p,g=t.convert(0,w),y=t.find(l,[w,w]));var v,E,b=[];for(v=0;v<m;v++)b[v]=[];var N=[],x=[],F=[],M=[];for(E=0;E<_;E++){var S=E+1;for(r(s,E,F,N,S),r(u,E,M,x,S),v=0;v<m;v++){var $=F[v]===S?N[v]:g,C=M[v]===S?x[v]:g;b[v][E]=y($,C)}}return new e({data:b,size:[m,_],datatype:p===s._datatype&&c===u._datatype?w:void 0})};function r(n,s,u,l,f){for(var p=n._values,h=n._index,c=n._ptr,m=c[s],_=c[s+1];m<_;m++){var w=h[m];u[w]=f,l[w]=p[m]}}}),Yf="conj",wv=["typed"],Dv=mt(Yf,wv,i=>{var{typed:t}=i;return t(Yf,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),jf="concat",yv=["typed","matrix","isInteger"],bv=mt(jf,yv,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(jf,{"...Array | Matrix | number | BigNumber":function(s){var u,l=s.length,f=-1,p,h=!1,c=[];for(u=0;u<l;u++){var m=s[u];if(fe(m)&&(h=!0),ue(m)||ye(m)){if(u!==l-1)throw new Error("Dimension must be specified as last argument");if(p=f,f=m.valueOf(),!r(f))throw new TypeError("Integer number expected for dimension");if(f<0||u>0&&f>p)throw new hn(f,p+1)}else{var _=te(m).valueOf(),w=Ae(_);if(c[u]=_,p=f,f=w.length-1,u>0&&f!==p)throw new Zt(p+1,f+1)}}if(c.length===0)throw new SyntaxError("At least one matrix expected");for(var g=c.shift();c.length;)g=Xl(g,c.shift(),f);return h?e(g):g},"...string":function(s){return s.join("")}})}),Zf="count",Ev=["typed","size","prod"],Av=mt(Zf,Ev,i=>{var{typed:t,size:e,prod:r}=i;return t(Zf,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),Gf="identity",xv=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Cv=mt(Gf,xv,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:u}=i;return t(Gf,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(h){return r(h)},"number | BigNumber":function(h){return f(h,h,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(h,c){return f(h,h,c)},"number | BigNumber, number | BigNumber":function(h,c){return f(h,c,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(h,c,m){return f(h,c,m)},Array:function(h){return l(h)},"Array, string":function(h,c){return l(h,c)},Matrix:function(h){return l(h.valueOf(),h.storage())},"Matrix, string":function(h,c){return l(h.valueOf(),c)}});function l(p,h){switch(p.length){case 0:return h?r(h):[];case 1:return f(p[0],p[0],h);case 2:return f(p[0],p[1],h);default:throw new Error("Vector containing two values expected")}}function f(p,h,c){var m=ye(p)||ye(h)?n:null;if(ye(p)&&(p=p.toNumber()),ye(h)&&(h=h.toNumber()),!he(p)||p<1)throw new Error("Parameters in function identity must be positive integers");if(!he(h)||h<1)throw new Error("Parameters in function identity must be positive integers");var _=m?new n(1):1,w=m?new m(0):0,g=[p,h];if(c){if(c==="sparse")return u.diagonal(g,_,0,w);if(c==="dense")return s.diagonal(g,_,0,w);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var y=ua([],g,w),v=p<h?p:h,E=0;E<v;E++)y[E][E]=_;return y}}),Kf="kron",Fv=["typed","matrix","multiplyScalar"],Mv=mt(Kf,Fv,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(Kf,{"Matrix, Matrix":function(u,l){return e(n(u.toArray(),l.toArray()))},"Matrix, Array":function(u,l){return e(n(u.toArray(),l))},"Array, Matrix":function(u,l){return e(n(u,l.toArray()))},"Array, Array":n});function n(s,u){if(Ae(s).length===1&&(s=[s]),Ae(u).length===1&&(u=[u]),Ae(s).length>2||Ae(u).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(s.length)+", y = "+JSON.stringify(u.length)+")");var l=[],f=[];return s.map(function(p){return u.map(function(h){return f=[],l.push(f),p.map(function(c){return h.map(function(m){return f.push(r(c,m))})})})})&&l}});function Nv(){throw new Error('No "bignumber" implementation available')}function Sv(){throw new Error('No "fraction" implementation available')}function Bv(){throw new Error('No "matrix" implementation available')}var Hf="reshape",Iv=["typed","isInteger","matrix"],Tv=mt(Hf,Iv,i=>{var{typed:t,isInteger:e}=i;return t(Hf,{"Matrix, Array":function(n,s){return n.reshape(s,!0)},"Array, Array":function(n,s){return s.forEach(function(u){if(!e(u))throw new TypeError("Invalid size for dimension: "+u)}),fa(n,s)}})}),Jf="size",$v=["typed","config","?matrix"],Ov=mt(Jf,$v,i=>{var{typed:t,config:e,matrix:r}=i;return t(Jf,{Matrix:function(s){return s.create(s.size())},Array:Ae,string:function(s){return e.matrix==="Array"?[s.length]:r([s.length])},"number | Complex | BigNumber | Unit | boolean | null":function(s){return e.matrix==="Array"?[]:r?r([]):Bv()}})}),Xf="transpose",Rv=["typed","matrix"],Lv=mt(Xf,Rv,i=>{var{typed:t,matrix:e}=i;return t(Xf,{Array:u=>r(e(u)).valueOf(),Matrix:r,any:te});function r(u){var l=u.size(),f;switch(l.length){case 1:f=u.clone();break;case 2:{var p=l[0],h=l[1];if(h===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+se(l)+")");switch(u.storage()){case"dense":f=n(u,p,h);break;case"sparse":f=s(u,p,h);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+se(l)+")")}return f}function n(u,l,f){for(var p=u._data,h=[],c,m=0;m<f;m++){c=h[m]=[];for(var _=0;_<l;_++)c[_]=te(p[_][m])}return u.createDenseMatrix({data:h,size:[f,l],datatype:u._datatype})}function s(u,l,f){for(var p=u._values,h=u._index,c=u._ptr,m=p?[]:void 0,_=[],w=[],g=[],y=0;y<l;y++)g[y]=0;var v,E,b;for(v=0,E=h.length;v<E;v++)g[h[v]]++;for(var N=0,x=0;x<l;x++)w.push(N),N+=g[x],g[x]=w[x];for(w.push(N),b=0;b<f;b++)for(var F=c[b],M=c[b+1],S=F;S<M;S++){var $=g[h[S]]++;_[$]=b,p&&(m[$]=te(p[S]))}return u.createSparseMatrix({values:m,index:_,ptr:w,size:[f,l],datatype:u._datatype})}}),Vf="ctranspose",Pv=["typed","transpose","conj"],zv=mt(Vf,Pv,i=>{var{typed:t,transpose:e,conj:r}=i;return t(Vf,{any:function(s){return r(e(s))}})}),Qf="mode",qv=["typed","isNaN","isNumeric"],Uv=mt(Qf,qv,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(Qf,{"Array | Matrix":n,"...":function(u){return n(u)}});function n(s){s=ha(s.valueOf());var u=s.length;if(u===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},f=[],p=0,h=0;h<s.length;h++){var c=s[h];if(r(c)&&e(c))throw new Error("Cannot calculate mode of an array containing NaN values");c in l||(l[c]=0),l[c]++,l[c]===p?f.push(c):l[c]>p&&(p=l[c],f=[c])}return f}});function vn(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+cn(e)+", value: "+JSON.stringify(e)+")":" (type: "+i.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(i).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+cn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var tc="prod",kv=["typed","config","multiplyScalar","numeric"],Wv=mt(tc,kv,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(tc,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,f){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return s(l)}});function s(u){var l;if(Wi(u,function(f){try{l=l===void 0?f:r(l,f)}catch(p){throw vn(p,"prod",f)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),Yv="numeric",jv=["number","?bignumber","?fraction"],Zv=mt(Yv,jv,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:u=>t(u),BigNumber:e?u=>e(u):Nv,Fraction:r?u=>r(u):Sv};return function(l){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",p=arguments.length>2?arguments[2]:void 0;if(p!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var h=cn(l);if(!(h in n))throw new TypeError("Cannot convert "+l+' of type "'+h+'"; valid input types are '+Object.keys(n).join(", "));if(!(f in s))throw new TypeError("Cannot convert "+l+' to type "'+f+'"; valid output types are '+Object.keys(s).join(", "));return f===h?l:s[f](l)}}),ec="divideScalar",Gv=["typed","numeric"],Kv=mt(ec,Gv,i=>{var{typed:t,numeric:e}=i;return t(ec,{"number, number":function(n,s){return n/s},"Complex, Complex":function(n,s){return n.div(s)},"BigNumber, BigNumber":function(n,s){return n.div(s)},"Fraction, Fraction":function(n,s){return n.div(s)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),rc="pow",Hv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Jv=mt(rc,Hv,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:u,number:l,fraction:f,Complex:p}=i;return t(rc,{"number, number":h,"Complex, Complex":function(w,g){return w.pow(g)},"BigNumber, BigNumber":function(w,g){return g.isInteger()||w>=0||e.predictable?w.pow(g):new p(w.toNumber(),0).pow(g.toNumber(),0)},"Fraction, Fraction":function(w,g){var y=w.pow(g);if(y!=null)return y;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return h(w.valueOf(),g.valueOf())},"Array, number":c,"Array, BigNumber":function(w,g){return c(w,g.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(w,g){return m(w,g.toNumber())},"Unit, number | BigNumber":function(w,g){return w.pow(g)}});function h(_,w){if(e.predictable&&!he(w)&&_<0)try{var g=f(w),y=l(g);if((w===y||Math.abs((w-y)/w)<1e-14)&&g.d%2===1)return(g.n%2===0?1:-1)*Math.pow(-_,w)}catch{}return e.predictable&&(_<-1&&w===1/0||_>-1&&_<0&&w===-1/0)?NaN:he(w)||_>=0||e.predictable?Ff(_,w):_*_<1&&w===1/0||_*_>1&&w===-1/0?0:new p(_,0).pow(w,0)}function c(_,w){if(!he(w))throw new TypeError("For A^b, b must be an integer (value is "+w+")");var g=Ae(_);if(g.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+g.length+" dimensions)");if(g[0]!==g[1])throw new Error("For A^b, A must be square (size is "+g[0]+"x"+g[1]+")");if(w<0)try{return c(u(_),-w)}catch(E){throw E.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+w+")"):E}for(var y=r(g[0]).valueOf(),v=_;w>=1;)(w&1)===1&&(y=n(v,y)),w>>=1,v=n(v,v);return y}function m(_,w){return s(c(_.valueOf(),w))}}),nc="dotDivide",Xv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],Vv=mt(nc,Xv,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:u}=i,l=Yg({typed:t,equalScalar:r}),f=fi({typed:t}),p=zs({typed:t,DenseMatrix:s}),h=ba({typed:t,equalScalar:r}),c=li({typed:t,DenseMatrix:s}),m=qn({typed:t,matrix:e,concat:u});return t(nc,m({elop:n,SS:p,DS:f,SD:l,Ss:h,sS:c}))}),qs="compare",Qv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],t_=mt(qs,Qv,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:u,DenseMatrix:l,concat:f}=i,p=fi({typed:t}),h=zf({typed:t,equalScalar:r}),c=li({typed:t,DenseMatrix:l}),m=qn({typed:t,matrix:n,concat:f}),_=Ls({typed:t});return t(qs,e_({typed:t,config:e}),{"boolean, boolean":function(g,y){return g===y?0:g>y?1:-1},"BigNumber, BigNumber":function(g,y){return Rs(g,y,e.epsilon)?new s(0):new s(g.cmp(y))},"Fraction, Fraction":function(g,y){return new u(g.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},_,m({SS:h,DS:p,Ss:c}))}),e_=mt(qs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(qs,{"number, number":function(n,s){return zn(n,s,e.epsilon)?0:n>s?1:-1}})}),Us="equal",r_=["typed","matrix","equalScalar","DenseMatrix","concat"],n_=mt(Us,r_,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,u=fi({typed:t}),l=zs({typed:t,DenseMatrix:n}),f=li({typed:t,DenseMatrix:n}),p=qn({typed:t,matrix:e,concat:s});return t(Us,i_({typed:t,equalScalar:r}),p({elop:r,SS:l,DS:u,Ss:f}))}),i_=mt(Us,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(Us,{"any, any":function(n,s){return n===null?s===null:s===null?n===null:n===void 0?s===void 0:s===void 0?n===void 0:e(n,s)}})}),ks="smaller",s_=["typed","config","matrix","DenseMatrix","concat"],o_=mt(ks,s_,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,u=fi({typed:t}),l=zs({typed:t,DenseMatrix:n}),f=li({typed:t,DenseMatrix:n}),p=qn({typed:t,matrix:r,concat:s}),h=Ls({typed:t});return t(ks,a_({typed:t,config:e}),{"boolean, boolean":(c,m)=>c<m,"BigNumber, BigNumber":function(m,_){return m.lt(_)&&!Rs(m,_,e.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===-1,"Complex, Complex":function(m,_){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:l,DS:u,Ss:f}))}),a_=mt(ks,["typed","config"],i=>{var{typed:t,config:e}=i;return t(ks,{"number, number":function(n,s){return n<s&&!zn(n,s,e.epsilon)}})}),Ws="larger",u_=["typed","config","matrix","DenseMatrix","concat"],l_=mt(Ws,u_,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,u=fi({typed:t}),l=zs({typed:t,DenseMatrix:n}),f=li({typed:t,DenseMatrix:n}),p=qn({typed:t,matrix:r,concat:s}),h=Ls({typed:t});return t(Ws,f_({typed:t,config:e}),{"boolean, boolean":(c,m)=>c>m,"BigNumber, BigNumber":function(m,_){return m.gt(_)&&!Rs(m,_,e.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:l,DS:u,Ss:f}))}),f_=mt(Ws,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Ws,{"number, number":function(n,s){return n>s&&!zn(n,s,e.epsilon)}})}),ic="deepEqual",c_=["typed","equal"],h_=mt(ic,c_,i=>{var{typed:t,equal:e}=i;return t(ic,{"any, any":function(s,u){return r(s.valueOf(),u.valueOf())}});function r(n,s){if(Array.isArray(n))if(Array.isArray(s)){var u=n.length;if(u!==s.length)return!1;for(var l=0;l<u;l++)if(!r(n[l],s[l]))return!1;return!0}else return!1;else return Array.isArray(s)?!1:e(n,s)}}),sc="partitionSelect",p_=["typed","isNumeric","isNaN","compare"],d_=mt(sc,p_,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,u=(p,h)=>-n(p,h);return t(sc,{"Array | Matrix, number":function(h,c){return l(h,c,s)},"Array | Matrix, number, string":function(h,c,m){if(m==="asc")return l(h,c,s);if(m==="desc")return l(h,c,u);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(p,h,c){if(!he(h)||h<0)throw new Error("k must be a non-negative integer");if(fe(p)){var m=p.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return f(p.valueOf(),h,c)}if(Array.isArray(p))return f(p,h,c)}function f(p,h,c){if(h>=p.length)throw new Error("k out of bounds");for(var m=0;m<p.length;m++)if(e(p[m])&&r(p[m]))return p[m];for(var _=0,w=p.length-1;_<w;){for(var g=_,y=w,v=p[Math.floor(Math.random()*(w-_+1))+_];g<y;)if(c(p[g],v)>=0){var E=p[y];p[y]=p[g],p[g]=E,--y}else++g;c(p[g],v)>0&&--g,h<=g?w=g:_=g+1}return p[h]}}),oc="max",m_=["typed","config","numeric","larger"],g_=mt(oc,m_,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(oc,{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(f,p){return ya(f,p.valueOf(),s)},"...":function(f){if(Ts(f))throw new TypeError("Scalar values expected in function max");return u(f)}});function s(l,f){try{return n(l,f)?l:f}catch(p){throw vn(p,"max",f)}}function u(l){var f;if(Wi(l,function(p){try{isNaN(p)&&typeof p=="number"?f=NaN:(f===void 0||n(p,f))&&(f=p)}catch(h){throw vn(h,"max",p)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=r(f,e.number)),f}}),ac="min",v_=["typed","config","numeric","smaller"],__=mt(ac,v_,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(ac,{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(f,p){return ya(f,p.valueOf(),s)},"...":function(f){if(Ts(f))throw new TypeError("Scalar values expected in function min");return u(f)}});function s(l,f){try{return n(l,f)?l:f}catch(p){throw vn(p,"min",f)}}function u(l){var f;if(Wi(l,function(p){try{isNaN(p)&&typeof p=="number"?f=NaN:(f===void 0||n(p,f))&&(f=p)}catch(h){throw vn(h,"min",p)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=r(f,e.number)),f}}),uc="add",w_=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],D_=mt(uc,w_,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:u,concat:l}=i,f=qf({typed:t}),p=av({typed:t,equalScalar:n}),h=Uf({typed:t,DenseMatrix:s}),c=qn({typed:t,matrix:e,concat:l});return t(uc,{"any, any":r,"any, any, ...any":t.referToSelf(m=>(_,w,g)=>{for(var y=m(_,w),v=0;v<g.length;v++)y=m(y,g[v]);return y})},c({elop:r,DS:f,SS:p,Ss:h}))}),lc="dot",y_=["typed","addScalar","multiplyScalar","conj","size"],b_=mt(lc,y_,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(lc,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":f});function u(h,c){var m=p(h),_=p(c),w,g;if(m.length===1)w=m[0];else if(m.length===2&&m[1]===1)w=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(_.length===1)g=_[0];else if(_.length===2&&_[1]===1)g=_[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+_.join(", ")+")");if(w!==g)throw new RangeError("Vectors must have equal length ("+w+" != "+g+")");if(w===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return w}function l(h,c){var m=u(h,c),_=fe(h)?h._data:h,w=fe(h)?h._datatype||h.getDataType():void 0,g=fe(c)?c._data:c,y=fe(c)?c._datatype||c.getDataType():void 0,v=p(h).length===2,E=p(c).length===2,b=e,N=r;if(w&&y&&w===y&&typeof w=="string"&&w!=="mixed"){var x=w;b=t.find(e,[x,x]),N=t.find(r,[x,x])}if(!v&&!E){for(var F=N(n(_[0]),g[0]),M=1;M<m;M++)F=b(F,N(n(_[M]),g[M]));return F}if(!v&&E){for(var S=N(n(_[0]),g[0][0]),$=1;$<m;$++)S=b(S,N(n(_[$]),g[$][0]));return S}if(v&&!E){for(var C=N(n(_[0][0]),g[0]),I=1;I<m;I++)C=b(C,N(n(_[I][0]),g[I]));return C}if(v&&E){for(var R=N(n(_[0][0]),g[0][0]),U=1;U<m;U++)R=b(R,N(n(_[U][0]),g[U][0]));return R}}function f(h,c){u(h,c);for(var m=h._index,_=h._values,w=c._index,g=c._values,y=0,v=e,E=r,b=0,N=0;b<m.length&&N<w.length;){var x=m[b],F=w[N];if(x<F){b++;continue}if(x>F){N++;continue}x===F&&(y=v(y,E(_[b],g[N])),b++,N++)}return y}function p(h){return fe(h)?h.size():s(h)}}),E_="trace",A_=["typed","matrix","add"],x_=mt(E_,A_,i=>{var{typed:t,matrix:e,add:r}=i;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:s,DenseMatrix:n,any:te});function n(u){var l=u._size,f=u._data;switch(l.length){case 1:if(l[0]===1)return te(f[0]);throw new RangeError("Matrix must be square (size: "+se(l)+")");case 2:{var p=l[0],h=l[1];if(p===h){for(var c=0,m=0;m<p;m++)c=r(c,f[m][m]);return c}else throw new RangeError("Matrix must be square (size: "+se(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(l)+")")}}function s(u){var l=u._values,f=u._index,p=u._ptr,h=u._size,c=h[0],m=h[1];if(c===m){var _=0;if(l.length>0)for(var w=0;w<m;w++)for(var g=p[w],y=p[w+1],v=g;v<y;v++){var E=f[v];if(E===w){_=r(_,l[v]);break}if(E>w)break}return _}throw new RangeError("Matrix must be square (size: "+se(h)+")")}}),fc="det",C_=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],F_=mt(fc,C_,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:u,unaryMinus:l}=i;return t(fc,{any:function(h){return te(h)},"Array | Matrix":function(h){var c;switch(fe(h)?c=h.size():Array.isArray(h)?(h=e(h),c=h.size()):c=[],c.length){case 0:return te(h);case 1:if(c[0]===1)return te(h.valueOf()[0]);if(c[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+se(c)+")");case 2:{var m=c[0],_=c[1];if(m===_)return f(h.clone().valueOf(),m);if(_===0)return 1;throw new RangeError("Matrix must be square (size: "+se(c)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(c)+")")}}});function f(p,h,c){if(h===1)return te(p[0][0]);if(h===2)return r(n(p[0][0],p[1][1]),n(p[1][0],p[0][1]));for(var m=!1,_=new Array(h).fill(0).map((M,S)=>S),w=0;w<h;w++){var g=_[w];if(u(p[g][w])){var y=void 0;for(y=w+1;y<h;y++)if(!u(p[_[y]][w])){g=_[y],_[y]=_[w],_[w]=g,m=!m;break}if(y===h)return p[g][w]}for(var v=p[g][w],E=w===0?1:p[_[w-1]][w-1],b=w+1;b<h;b++)for(var N=_[b],x=w+1;x<h;x++)p[N][x]=s(r(n(p[N][x],v),n(p[N][w],p[g][x])),E)}var F=p[_[h-1]][h-1];return m?l(F):F}}),cc="inv",M_=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],N_=mt(cc,M_,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:u,det:l,identity:f,abs:p}=i;return t(cc,{"Array | Matrix":function(m){var _=fe(m)?m.size():Ae(m);switch(_.length){case 1:if(_[0]===1)return fe(m)?e([r(1,m.valueOf()[0])]):[r(1,m[0])];throw new RangeError("Matrix must be square (size: "+se(_)+")");case 2:{var w=_[0],g=_[1];if(w===g)return fe(m)?e(h(m.valueOf(),w,g),m.storage()):h(m,w,g);throw new RangeError("Matrix must be square (size: "+se(_)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(_)+")")}},any:function(m){return r(1,m)}});function h(c,m,_){var w,g,y,v,E;if(m===1){if(v=c[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(m===2){var b=l(c);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(c[1][1],b),r(u(c[0][1]),b)],[r(u(c[1][0]),b),r(c[0][0],b)]]}else{var N=c.concat();for(w=0;w<m;w++)N[w]=N[w].concat();for(var x=f(m).valueOf(),F=0;F<_;F++){var M=p(N[F][F]),S=F;for(w=F+1;w<m;)p(N[w][F])>M&&(M=p(N[w][F]),S=w),w++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");w=S,w!==F&&(E=N[F],N[F]=N[w],N[w]=E,E=x[F],x[F]=x[w],x[w]=E);var $=N[F],C=x[F];for(w=0;w<m;w++){var I=N[w],R=x[w];if(w!==F){if(I[F]!==0){for(y=r(u(I[F]),$[F]),g=F;g<_;g++)I[g]=n(I[g],s(y,$[g]));for(g=0;g<_;g++)R[g]=n(R[g],s(y,C[g]))}}else{for(y=$[F],g=F;g<_;g++)I[g]=r(I[g],y);for(g=0;g<_;g++)R[g]=r(R[g],y)}}}return x}}}),hc="pinv",S_=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],B_=mt(hc,S_,i=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:s,dotDivide:u,dot:l,ctranspose:f,divideScalar:p,multiply:h,add:c,Complex:m}=i;return t(hc,{"Array | Matrix":function(b){var N=fe(b)?b.size():Ae(b);switch(N.length){case 1:return v(b)?f(b):N[0]===1?r(b):u(f(b),l(b,b));case 2:{if(v(b))return f(b);var x=N[0],F=N[1];if(x===F)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return fe(b)?e(_(b.valueOf(),x,F),b.storage()):_(b,x,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+se(N)+")")}},any:function(b){return s(b,0)?te(b):p(1,b)}});function _(E,b,N){var{C:x,F}=g(E,b,N),M=h(r(h(f(x),x)),f(x)),S=h(f(F),r(h(F,f(F))));return h(S,M)}function w(E,b,N){for(var x=te(E),F=0,M=0;M<b;M++){if(N<=F)return x;for(var S=M;y(x[S][F]);)if(S++,b===S&&(S=M,F++,N===F))return x;[x[S],x[M]]=[x[M],x[S]];for(var $=x[M][F],C=0;C<N;C++)x[M][C]=u(x[M][C],$);for(var I=0;I<b;I++)if(I!==M){$=x[I][F];for(var R=0;R<N;R++)x[I][R]=c(x[I][R],h(-1,h($,x[M][R])))}F++}return x}function g(E,b,N){var x=w(E,b,N),F=E.map((S,$)=>S.filter((C,I)=>I<b&&!y(l(x[I],x[I])))),M=x.filter((S,$)=>!y(l(x[$],x[$])));return{C:F,F:M}}function y(E){return s(c(E,m(1,1)),c(0,m(1,1)))}function v(E){return n(c(E,m(1,1)),c(h(E,0),m(1,1)))}}),I_="divide",T_=["typed","matrix","multiply","equalScalar","divideScalar","inv"],$_=mt(I_,T_,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:u}=i,l=ba({typed:t,equalScalar:n}),f=Ea({typed:t});return t("divide",Bl({"Array | Matrix, Array | Matrix":function(h,c){return r(h,u(c))},"DenseMatrix, any":function(h,c){return f(h,c,s,!1)},"SparseMatrix, any":function(h,c){return l(h,c,s,!1)},"Array, any":function(h,c){return f(e(h),c,s,!1).valueOf()},"any, Array | Matrix":function(h,c){return r(h,u(c))}},s.signatures))}),pc="sum",O_=["typed","config","add","numeric"],R_=mt(pc,O_,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(pc,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":u,"...":function(f){if(Ts(f))throw new TypeError("Scalar values expected in function sum");return s(f)}});function s(l){var f;return Wi(l,function(p){try{f=f===void 0?p:r(f,p)}catch(h){throw vn(h,"sum",p)}}),f===void 0&&(f=n(0,e.number)),typeof f=="string"&&(f=n(f,e.number)),f}function u(l,f){try{var p=ya(l,f,r);return p}catch(h){throw vn(h,"sum")}}}),dc="median",L_=["typed","add","divide","compare","partitionSelect"],P_=mt(dc,L_,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function u(p){try{p=ha(p.valueOf());var h=p.length;if(h===0)throw new Error("Cannot calculate median of an empty array");if(h%2===0){for(var c=h/2-1,m=s(p,c+1),_=p[c],w=0;w<c;++w)n(p[w],_)>0&&(_=p[w]);return f(_,m)}else{var g=s(p,(h-1)/2);return l(g)}}catch(y){throw vn(y,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(h){return h}}),f=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(h,c){return r(e(h,c),2)}});return t(dc,{"Array | Matrix":u,"Array | Matrix, number | BigNumber":function(h,c){throw new Error("median(A, dim) is not yet supported")},"...":function(h){if(Ts(h))throw new TypeError("Scalar values expected in function median");return u(h)}})}),Ys=zm({config:nr}),Aa=Wm({}),xa=Gm({}),Ca=Jm({}),Wr=Qm({Matrix:Ca}),Ft=kd({BigNumber:Ys,Complex:Aa,DenseMatrix:Wr,Fraction:xa}),z_=Bg({typed:Ft}),js=Tg({typed:Ft}),q_=bg({BigNumber:Ys,typed:Ft}),mc=Dv({typed:Ft}),_n=cg({config:nr,typed:Ft}),Zs=rg({typed:Ft}),U_=og({typed:Ft}),Gs=hv({typed:Ft}),gc=wg({typed:Ft}),Fa=dg({Matrix:Ca,equalScalar:_n,typed:Ft}),vc=Og({typed:Ft}),_c=ug({typed:Ft}),Ma=Ng({typed:Ft}),wc=xg({Fraction:xa,typed:Ft}),Dc=ig({typed:Ft}),xe=Fg({DenseMatrix:Wr,Matrix:Ca,SparseMatrix:Fa,typed:Ft}),yc=Uv({isNaN:_c,isNumeric:Dc,typed:Ft}),Yi=Zv({bignumber:q_,fraction:wc,number:gc}),k_=Wv({config:nr,multiplyScalar:Gs,numeric:Yi,typed:Ft}),W_=Tv({isInteger:Zs,matrix:xe,typed:Ft}),bc=Ov({matrix:xe,config:nr,typed:Ft}),Ec=Lv({matrix:xe,typed:Ft}),Un=bv({isInteger:Zs,matrix:xe,typed:Ft}),Y_=Av({prod:k_,size:bc,typed:Ft}),j_=zv({conj:mc,transpose:Ec,typed:Ft}),ji=Kv({numeric:Yi,typed:Ft}),Z_=Vv({DenseMatrix:Wr,concat:Un,divideScalar:ji,equalScalar:_n,matrix:xe,typed:Ft}),Ac=n_({DenseMatrix:Wr,concat:Un,equalScalar:_n,matrix:xe,typed:Ft}),xc=Cv({BigNumber:Ys,DenseMatrix:Wr,SparseMatrix:Fa,config:nr,matrix:xe,typed:Ft}),G_=Mv({matrix:xe,multiplyScalar:Gs,typed:Ft}),K_=o_({DenseMatrix:Wr,concat:Un,config:nr,matrix:xe,typed:Ft}),H_=gv({DenseMatrix:Wr,concat:Un,equalScalar:_n,matrix:xe,subtractScalar:vc,typed:Ft,unaryMinus:Ma}),Zi=D_({DenseMatrix:Wr,SparseMatrix:Fa,addScalar:js,concat:Un,equalScalar:_n,matrix:xe,typed:Ft}),Cc=t_({BigNumber:Ys,DenseMatrix:Wr,Fraction:xa,concat:Un,config:nr,equalScalar:_n,matrix:xe,typed:Ft}),J_=h_({equal:Ac,typed:Ft}),Fc=b_({addScalar:js,conj:mc,multiplyScalar:Gs,size:bc,typed:Ft}),X_=l_({DenseMatrix:Wr,concat:Un,config:nr,matrix:xe,typed:Ft}),Na=__({config:nr,numeric:Yi,smaller:K_,typed:Ft}),ci=dv({addScalar:js,dot:Fc,equalScalar:_n,matrix:xe,multiplyScalar:Gs,typed:Ft}),V_=d_({compare:Cc,isNaN:_c,isNumeric:Dc,typed:Ft}),Q_=R_({add:Zi,config:nr,numeric:Yi,typed:Ft}),t1=x_({add:Zi,matrix:xe,typed:Ft}),Mc=F_({divideScalar:ji,isZero:U_,matrix:xe,multiply:ci,subtractScalar:vc,typed:Ft,unaryMinus:Ma}),e1=g_({config:nr,larger:X_,numeric:Yi,typed:Ft}),Ks=N_({abs:z_,addScalar:js,det:Mc,divideScalar:ji,identity:xc,matrix:xe,multiply:ci,typed:Ft,unaryMinus:Ma}),r1=B_({Complex:Aa,add:Zi,ctranspose:j_,deepEqual:J_,divideScalar:ji,dot:Fc,dotDivide:Z_,equal:Ac,inv:Ks,matrix:xe,multiply:ci,typed:Ft}),n1=Jv({Complex:Aa,config:nr,fraction:wc,identity:xc,inv:Ks,matrix:xe,multiply:ci,number:gc,typed:Ft}),i1=$_({divideScalar:ji,equalScalar:_n,inv:Ks,matrix:xe,multiply:ci,typed:Ft}),Nc=P_({add:Zi,compare:Cc,divide:i1,partitionSelect:V_,typed:Ft});class s1{constructor(t,e,r){Z(this,"_cacheData");Z(this,"_variables");Z(this,"_math");Z(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},u){if(e===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(t,e,`alma_${u}`);if(l===void 0)return;let f=r*(e-1);s&&(f=Math.floor(f));const p=e/n;let h=0,c=0;for(let m=0;m<=e-1;m++){const _=Math.exp(-1*Math.pow(m-f,2)/(2*Math.pow(p,2)));h+=_,c+=l[l.length-1-(e-m-1)]*_}return c/h}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const u=s.slice(-e);return n=Q_(...u)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const n=this._cacheData[`sma_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`sma_${r}`]=n;const{sum:s}=this._cacheData[`rma_${r}`]||{},u=1/e,l=s===void 0?this.sma({source:t,length:e},r):u*t+(1-u)*(s||0);return this._cacheDataHandle(`rma_${r}`,{sum:l}),l}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:s,close:u,low:l}=this._variables,f=r===void 0?s-l:Math.max(Math.max(s-l,Math.abs(s-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:s,close:u}),this.rma({source:f,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),u=this.sma({source:t,length:e},n);if(s===void 0)return;let l=0;for(let f=0;f<e;f++){const p=this._sum(s[s.length-1-f],-(u||0));l+=p*p}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),u=this.stdev({source:t,length:e},n);if(s===void 0||u===void 0)return[];const l=r*u;return[s,s+l,s-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),u=this.stdev({source:t,length:e},n);if(s===void 0||u===void 0)return;const l=r*u;return(s+l-(s-l))/s}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const s=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return s===void 0?s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),u=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||u===void 0))return 100*(s-u)/(s+u)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let u=0;for(let l=0;l<e;l++){const f=n[n.length-1-l];u+=f*(l+1)}return-u/s}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),u=this.sma({source:t,length:r},`sma1_${n}`),l=this.sma({source:e,length:r},`sma2_${n}`);if(u===void 0||l===void 0||s===void 0)return;let f=0,p=0,h=0;for(let m=0;m<r;m++){const[_,w]=s[s.length-1-m],g=_-u,y=w-l;f+=g*y,p+=g*g,h+=y*y}return isNaN(p)||isNaN(f)||isNaN(h)?void 0:f/Math.sqrt(p*h)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e||n<=s&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n<=s&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let s=0;const u=this._cacheDataList(t,e,`dev_${r}`);if(!(!u||n===void 0)){for(let l=0;l<e;l++){const f=u[u.length-1-l];s+=Math.abs(f-n)}return s/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:s,high:u,close:l,PDMS:f,NDMS:p,TRS:h,ADX:c,count:m=0}=this._cacheData[n]||{},{low:_,high:w,close:g}=this._variables;if(s===void 0||u===void 0||l===void 0)return this._cacheData[n]={low:_,high:w,close:g,PDMS:f,NDMS:p,TRS:w-_,count:1},[void 0,void 0,void 0];let y=w-u,v=s-_;y=y>v&&y>0?y:0,v=v>y&&v>0?v:0,y===v&&(y=v=0);const E=Math.max(w-_,Math.abs(w-l),Math.abs(_-l));if(m<t)return this._cacheDataHandle(n,{low:_,high:w,close:g,PDMS:(f||0)+y,NDMS:(p||0)+v,TRS:(h||0)+E,count:m+1}),[void 0,void 0,void 0];{const b=f-f/t+y,N=p-p/t+v,x=h-h/t+E,F=b/x*100,M=N/x*100,S=Math.abs((F-M)/(F+M))*100;let $=S,C=[F,M,void 0];if(m+1-t<e){const I=m+1-t;$=((c||0)*(I-1)+S)/I}else $=(c*(e-1)+S)/e,C=[F,M,$];return this._cacheDataHandle(n,{low:_,high:w,close:g,PDMS:b,NDMS:N,TRS:x,ADX:$,count:m+1}),C}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:s=1}=this._cacheData[`ema_${r}`]||{};const u=this.sma({source:t,length:e},r);if(s>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=u;return s+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:s}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:s=[]}=this._cacheData[`falling_${r}`]||{};s.push(n>t);const u=s.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:u}),u.length<e?!1:u.every(l=>l)}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,risings:s=[]}=this._cacheData[`rising_${r}`]||{};s.push(n<t);const u=s.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,risings:u}),u.length<e?!1:u.every(l=>l)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highest_${r}`]||[],{high:s,bar_index:u}=this._variables;typeof t!="number"?n[u]=s:n[u]=t,this._cacheData[`highest_${r}`]=n;const l=n.filter(()=>!0);if(!(l.length<e))return Math.max(...l.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highestbars_${r}`]||[],{high:s,bar_index:u}=this._variables;typeof t!="number"?n[u]=s:n[u]=t,this._cacheData[`highestbars_${r}`]=n;const l=n.filter(()=>!0);return l.length<e?void 0:l.slice(-e).reduce((p,h,c,m)=>h>=m[p]?c:p,0)-e+1}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,u=0;for(let l=0;l<e;l++){const f=(e-l)*e;s+=f,u+=n[n.length-1-l]*f}return u/s}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const u=this.ema({source:t,length:e},s),{ta:l,high:f,low:p}=this._variables,h=n?l.tr:f-p,c=this.ema({source:h,length:e},`range_${s}`);return[u,u+c*r,u-c*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const u=this.ema({source:t,length:e},s),{ta:l,high:f,low:p}=this._variables,h=n?l.tr:f-p,c=this.ema({source:h,length:e},`range_${s}`);return(u+c*r-(u-c*r))/u}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const s=this._cacheDataList(t,e,`dev_${n}`);if(!s)return;const u=s.slice(-e).filter(_=>_!==void 0);let l=0,f=0,p=0,h=0;for(const[_,w]of u.entries())l+=_,f+=w,p+=_*w,h+=_*_;const c=(e*p-l*f)/(e*h-l*l);return(f-c*l)/e+c*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowest_${r}`]||[],{low:s,bar_index:u}=this._variables;typeof t!="number"?n[u]=s:n[u]=t,this._cacheData[`lowest_${r}`]=n;const l=n.filter(()=>!0);if(!(l.length<e))return Math.min(...l.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowestbars_${r}`]||[],{low:s,bar_index:u}=this._variables;typeof t!="number"?n[u]=s:n[u]=t,this._cacheData[`lowestbars_${r}`]=n;const l=n.filter(()=>!0);return l.length<e?void 0:l.slice(-e).reduce((p,h,c,m)=>h<=m[p]?c:p,0)-e+1}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const u=this.ema({source:t,length:e},`ema1_${s}`),l=this.ema({source:t,length:r},`ema2_${s}`);if(u===void 0||l===void 0)return[void 0,void 0,void 0];const f=u-l,p=this.ema({source:f,length:n},`macd_${s}`);if(p===void 0)return[f,p,void 0];const h=f-p;return[f,p,h]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Nc(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),u=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(s<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||u===void 0))return 100-100/(1+l/u)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return Na(yc(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,s=this._cacheData[n]||[];if(s[this._variables.bar_index]=t,this._cacheData[n]=s,s.length<=e||t===void 0||isNaN(t))return;let u=s.length-e-1,l;for(;l===void 0&&u>=0;)l=s[u],u--;return l===void 0?l:t-l}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!s)return;const u=this._sort(s.slice(-(e+1))),l=u.length;r/=100;const f=1/(l*2);if(r<=f)return u[0];if(r>=1-1/(l*2))return u[l-1];for(const[p,h]of u.entries()){const c=u[p-1];if(r<(p+.5)/l)return c===void 0||h===void 0?void 0:c+(h-c)*(r-(p-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const u=this._sort(s.slice(-e)),l=r/100*u.length,f=Math.ceil(l)-1;return u[f>=u.length?u.length-1:f]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const s=n.slice(-(e+1)),u=t;if(u===void 0)return;let l=0;for(let f=0;f<s.length;f++)s[f]!==void 0&&(s[f]<u||s[f]===u&&f<e)&&l++;return l/(s.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const s=new Jt;let{close:u,open:l,low:f,high:p}=this._variables;const h=`pivot_point_levels_${n}`,{close:c,low:m,high:_,open:w,result:g}=this._cacheData[h]||{};if(!e&&(_&&m&&(p=Math.max(_,p),f=Math.min(m,f)),this._cacheDataHandle(h,{close:u,open:l,low:f,high:p,result:g}),!r))return s._value=g||[],s;const y={close:u,open:l,low:f,high:p};e===!0&&!r&&(u=c,l=w,f=m,p=_);const v=this._getPivotPointLevels(p,f,u,l,r,t);return this._cacheDataHandle(h,{...y,result:v}),s._value=v,s}_getPivotPointLevels(t,e,r,n,s,u){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(u){case Pn.traditional:return this._traditional(t,e,r);case Pn.fibonacci:return this._fibonacci(t,e,r);case Pn.woodie:return s?[]:this._woodie(t,e);case Pn.classic:return this._classic(t,e,r);case Pn.dm:return this._DM(t,e,r,n);case Pn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,s=n*2-e,u=n+(t-e),l=n*2+(t-2*e),f=n*3+(t-3*e),p=n*4+(t-4*e),h=n*2-t,c=n-(t-e),m=n*2-(2*t-e),_=n*3-(3*t-e),w=n*4-(4*t-e);return[n,s,h,u,c,l,m,f,_,p,w]}_fibonacci(t,e,r){const n=(t+e+r)/3,s=n+.382*(t-e),u=n-.382*(t-e),l=n+.618*(t-e),f=n-.618*(t-e),p=n+(t-e),h=n-(t-e);return[n,s,u,l,f,p,h]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,s=2*n-e,u=2*n-t,l=n+(t-e),f=n-(t-e),p=t+2*(n-e),h=e-2*(t-n),c=p+(t-e),m=h-(t-e);return[n,s,u,l,f,p,h,c,m]}_classic(t,e,r){const n=(t+e+r)/3,s=2*n-e,u=2*n-t,l=n+(t-e),f=n-(t-e),p=n+2*(t-e),h=n-2*(t-e),c=n+3*(t-e),m=n-3*(t-e);return[n,s,u,l,f,p,h,c,m]}_DM(t,e,r,n){let s;n===r?s=t+e+2*r:r>n?s=2*t+e+r:s=2*e+t+r;const u=s/4,l=s/2-e,f=s/2-t;return[u,l,f]}_camarilla(t,e,r){const n=(t+e+r)/3,s=r+1.1*(t-e)/12,u=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,f=r-1.1*(t-e)/6,p=r+1.1*(t-e)/4,h=r-1.1*(t-e)/4,c=r+1.1*(t-e)/2,m=r-1.1*(t-e)/2,_=t/e*r,w=r-(_-r);return[n,s,u,l,f,p,h,c,m,_,w]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!s)return;const u=s.slice(-(e+r+1)),l=u[e];return Math.max(...u)===l?l:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!s)return;const u=s.slice(-(e+r+1)),l=u[e];return Math.min(...u)===l?l:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`);if(!n)return;const s=n.filter(f=>f!==void 0).slice(-e),u=Math.max(...s),l=Math.min(...s);return u-l}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},s=Math.max(t-n,0),u=Math.max(n-t,0),l=this.rma({source:s,length:e},`rma1_${r}`),f=this.rma({source:u,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||f===void 0))return 100-100/(1+l/f)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:s,low:u,high:l,preLow:f,preHigh:p,data:h={}}=this._cacheData[`sar_${n}`]||{};let{result:c,maxMin:m,acceleration:_,isBelow:w}=h,g=!1;const{close:y,low:v,high:E,bar_index:b}=this._variables;return b===1&&(y>s?(w=!0,m=E,c=u):(w=!1,m=v,c=l),g=!0,_=t),c=c+_*(m-c),w?c>v&&(g=!0,w=!1,c=Math.max(E,m||0),m=v,_=t):c<E&&(g=!0,w=!0,c=Math.min(v,m||0),m=E,_=t),g||(w?E>(m||0)&&(m=E,_=Math.min((_||0)+e,r)):v<(m||0)&&(m=v,_=Math.min((_||0)+e,r))),w?(c=Math.min(c,u),b>1&&(c=Math.min(c,f))):(c=Math.max(c,l),b>1&&(c=Math.max(c,p))),this._cacheDataHandle(`sar_${n}`,{high:E,close:y,low:v,preLow:u,preHigh:l,data:Object.assign(h,{result:c,maxMin:m,acceleration:_,isBelow:w})}),c}stoch({source:t,high:e,low:r,length:n},s){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const u=this.lowest({source:r,length:n},s),l=this.highest({source:e,length:n},s);if(!(u===void 0||l===void 0))return 100*(this._variables.close-u)/(l-u)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:s}=this._variables,u=`supertrend_${r}`,{upperBand:l,lowerBand:f,superTrend:p,atr:h,close:c}=this._cacheData[u]||{},m=this.atr({length:e},r);if(m===void 0)return this._cacheDataHandle(u,{close:s}),[void 0,void 0];let _=n+t*m,w=n-t*m;const g=l||0,y=f||0;w=w>y||c<y?w:y,_=_<g||c>g?_:g;let v;h===void 0?v=1:p===g?v=s>_?-1:1:v=s<w?1:-1;const E=v===-1?w:_;return this._cacheDataHandle(u,{upperBand:_,lowerBand:w,superTrend:E,atr:m,close:s}),[E,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:s}=this._variables,{close:u}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),u===void 0?t?s-n:void 0:Math.max(s-n,Math.abs(s-u),Math.abs(n-u))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.change({source:t},n);if(s===void 0)return;const u=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),l=this.ema({source:s,length:e},`ema1_${n}`);if(l===void 0)return;const f=this.ema({source:l,length:r},`ema2_${n}`),p=this.ema({source:u,length:e},`absema2_${n}`);if(f!==void 0)return f/p}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:s}=this._cacheData[`valuewhen_${n}`]||{};return s||(s=[]),t&&s.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:s}),s[s.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const s=this.sma({source:t,length:e},n),u=this._cacheDataList(t,e,`mode_${n}`);if(!u||s===void 0)return;const l=u.filter(p=>p!==void 0&&!isNaN(p)).slice(-e);if(l.length<e)return;const f=l.reduce((p,h)=>p+Math.pow(h-s,2),0);if(f!==void 0)return r||e<=1?f/e:f/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:s}=this._variables;let{sum:u=0,sumV:l=0,count:f=0,isReset:p,sumS:h=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(u=l=f=h=0,p=!0),!p)return r!==void 0?[]:void 0;const c=t*s+u,m=s+l,_=c/m;return f++,r!==void 0?(h=s*Math.pow(t,2)+h,this._cacheDataHandle(`vwap_${n}`,{sum:c,sumV:m,count:f,isReset:p,sumS:h}),this._computeBands(h,m,r,_)):(this._cacheDataHandle(`vwap_${n}`,{sum:c,sumV:m,count:f,isReset:p}),_)}_computeBands(t,e,r,n){let s=t/e-Math.pow(n,2);s=s<0?0:s;const u=Math.sqrt(s),l=u!==void 0&&!isNaN(u)?n+r*u:void 0,f=u!==void 0&&!isNaN(u)?n-r*u:void 0;return[n,l,f]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),u=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||u===void 0))return s/u}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:u,currentIndex:l}=n,f=t[s];if(f!==void 0){if(u!==void 0&&f<u){t.splice(s,1),t.splice(l,0,f),n={currentIndex:l+1,currentVal:u};continue}n={currentIndex:s,currentVal:f}}}}return t}_cacheDataList(t,e,r){const n=this._cacheData[r]||[];n[this._variables.bar_index]=t,this._cacheData[r]=n;const s=n.filter(()=>!0);if(!(s.length<e))return s}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}const o1={onlyInLoop:"'$text' is only allowed inside loops",invalidType:"Invalid argument 'expr$index' in 'operator SQBR' call",typeUseError:"Cannot specify a type form '$text' without also specifying the type.",notTypeKeyword:"'$text' is not a valid type keyword in variable declaration",undeclared:"Undeclared identifier '$name'",repeatVar:"'$name' is already defined",typeMismatch:"Cannot call '$operator' with argument '$index'. An argument of '$typeE' type was used but a '$typeR' is expected.",assignTypeMismatch:"Cannot assign a value of the `$typeE` type to the '$name' variable. The variable is declared with the `$typeR` type.",voidNotVar:"Void expression cannot be assigned to a variable",declareTypeErr:"Declared type '$type' is not compatible with assigned type '$valueType'",mapKeyValErr:"Cannot put <$typeA, $typeB> pairs into a map containing `$typeC` keys and `$typeD` values. The maps passed into the `$name()` function must have the same key types and value types.",inputSourceErr:"Invalid value for the '$name' parameter of the '$funcName' function. Possible values: [open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume].",buildInUseErr:"Cannot use '$name' as the default value of a type's field. The default value cannot be a function, variable or calculation.",argsLenErr:"Too many arguments passed into the `$name()` function call. Passed $lenA arguments but expected $lenB.",requiredParamErr:"No value assigned to the `$argName` parameter in $name()",argsSyntaxErr:"Syntax error after the argument for `$argName`. Arguments without their parameter name cannot be used after arguments with parameter names.",requestArgsErr:"Type $type cannot be used in $name '$argName' argument",mapKeyErr:"Incorrect `key` type `$type` in the variable. The `key` type must be one of the following: int, float, string, bool, color.",templateErr:"Incorrect number of arguments for the template: $countA expected, $countB passed.",templateNoSupportErr:"The '$name()' function does not support templates",ifOrSwitchTypeErr:"Return type of one of the '$keyword' blocks is not compatible with return type of other block(s) ($types)",argsNameErr:"The '$name' function does not have an argument with the name '$argName'",noFiledErr:"Object has no field $name",methodNotExistErr:"Could not find method or method reference '$methodName' for '$name'",tupleVarErr:"Syntax error: The quantities of tuple elements on each side of the assignment operator do not match. The right side has $indexA but the left side has $indexB.",tupleLeftVarErr:"Invalid assignment. Cannot assign a tuple to a variable '$name'.",tupleRightVarErr:"Cannot assign a variable to a tuple. The right side must be a function call or structure ('if', 'switch', 'for', 'while') returning a tuple with the same number of elements.",tempateTypeErr:"Syntax error: Only templates for arrays and matrices consist of a single type identifier enclosed in angle brackets.",qualifierErr:"'$name' is not a valid type qualifier. Possible values: 'const', 'simple', 'series'",notFindFuncErr:"Could not find function or function reference '$name'",naVarErr:"Value with NA type cannot be assigned to a variable that was defined without type keyword",notHistoryErr:"Variable '$name' doesn't have history values",defaultValueErr:"The default value cannot be a function, variable or calculation.",defaultValueTypeErr:"Default value of type $typeE can not be assigned to an argument of type $typeR",unaryErr:"Syntax error at input '$sign'",funcArgAssignErr:"Function arguments cannot be mutable ('$name')",declaredErr:"A variable declared with the '$prefix' keyword cannot accept values of the '$type' form. Assign a '$prefix' value to this variable or remove the '$prefix' keyword from its declaration.",globalFuncErr:"Cannot use '$name' in local scope",onlyStatementErr:"Scripts must contain one declaration statement: `indicator()`, `strategy()` or `library()`, Your script has $count.",modifyGlobalVarErr:"Cannot modify global variable '$name' in function",inputDefvalErr:"Arguments of input function must be of constant type, or 'source' builtin variables.",objectIsNaErr:"Cannot access the '$name' $type of an undefined object. The object is 'na'."};Pr.SERIES,Pr.SIMPLE,Pr.INPUT,Pr.CONST,Pr.INT,Pr.FLOAT,Pr.BOOL,Pr.COLOR,Pr.STRING;const a1=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"];var hi=(i=>(i[i.Hint=1]="Hint",i[i.Info=2]="Info",i[i.Warning=4]="Warning",i[i.Error=8]="Error",i))(hi||{});class u1{constructor(t,e){Z(this,"_cacheData");Z(this,"_variables");Z(this,"_errorListener");Z(this,"_count");Z(this,"_historyInputs");Z(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._count=-1,this._name=`inputs_${Tp()}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){for(const e of t){const r=e.id;if(!this._cacheData[r])return;Object.assign(this._cacheData[r],{...e,isModify:!0}),self.workerStorage.updateValue(this._name,`in_${e.index}`,{modifyDefval:e.sourceTypeName||e.defval})}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._cacheHandle(t,e,"int")}bool(t,e){return this._cacheHandle(t,e,"bool")}color(t,e){return this._cacheHandle(t,e,"color")}time(t,e){return this._cacheHandle(t,e,"time")}float(t,e){return this._cacheHandle(t,e,"float")}price(t,e){return this._cacheHandle(t,e,"price")}source(t,e){return this._cacheHandle(t,e,"source")}string(t,e){return this._cacheHandle(t,e,"string")}symbol(t,e){return this._cacheHandle(t,e,"symbol")}session(t,e){return this._cacheHandle(t,e,"session")}text_area(t,e){return this._cacheHandle(t,e,"text_area")}timeframe(t,e){return this._cacheHandle(t,e,"timeframe")}_cacheHandle(t,e,r){const n=`${r||"input"}_${e}`,s=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(o1.inputDefvalErr,e,hi.Error),s)s.isModify?s.sourceTypeName&&(this._cacheData[n].defval=this._variables[s.sourceTypeName]):Object.assign(this._cacheData[n],t);else{const{defval:u,display:l}=t;this._displayVerify(e,l),this._count++,t={inputType:r,...t,index:this._count},this._cacheData[n]=t,this._judgeHistoryInputs(t),(r||t.inputType)==="source"?this._cacheData[n].options=a1:t.options&&!t.options.includes(u)&&this._errorListener.addError(`input's defval should be in options, but '${u}' is not in [${t.options.toString()}]`,e,hi.Error)}return this._cacheData[n].defval}_judgeHistoryInputs(t){const{defval:e,sourceTypeName:r,index:n}=t;let s=r||e;const u=`in_${n}`,l=this._historyInputs[u];if(!l)self.workerStorage.setValue(this._name,u,{defval:s});else{const{defval:f,modifyDefval:p}=l;f===s?s=p||s:self.workerStorage.setValue(this._name,u,{defval:s})}r?t.sourceTypeName=s:t.defval=s}_displayVerify(t,e){!e||!e.length||e.includes(er.dataWindow)||e.includes(er.statusLine)||this._errorListener.addError("Invalid argument 'display' in 'input' call. Possible values: [display.none, display.data_window, display.status_line, display.all]",t,hi.Error)}getInputs(){var n;const t=Object.keys(this._cacheData),e=new Map,r=[];for(const s of t){const u=this._cacheData[s];u.id=s;const{group:l}=u;l?e.has(l)?(n=e.get(l))==null||n.push(u):e.set(l,[u]):r.push(u)}return[...this._getGroups(e),{inputs:r}]}_getGroups(t){const e=[];for(const[r,n]of t)e.push({name:r,inputs:n});return e}}class l1{color({x:t}){return t}new({color:t,transp:e=100}){const{r,g:n,b:s}=this._parseColor(t);return`rgba(${Math.round(r)}, ${Math.round(n)}, ${Math.round(s)}, ${e/100})`}rgb({red:t,green:e,blue:r,transp:n=0}){return`rgba(${t}, ${e}, ${r}, ${n/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:s}){const u=(t-e)/(r-e),l=Math.min(Math.max(u,0),1),{r:f,g:p,b:h,a:c}=this._parseColor(n),{r:m,g:_,b:w,a:g}=this._parseColor(s),y=f+l*(m-f),v=p+l*(_-p),E=h+l*(w-h),b=c+l*(g-c);return`rgba(${Math.round(y)}, ${Math.round(v)}, ${Math.round(E)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const u=t.substring(7);u?s=(255-parseInt(u,16))/255:s=1}else{const u=this._parserRgbColor(t);e=u[0],r=u[1],n=u[2],s=u[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var Pt={};const f1=Object.prototype.toString;function Gi(i){const t=f1.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var c1=Object.freeze({__proto__:null,isAnyArray:Gi}),h1=De(c1);function p1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Gi(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var u=i[r],l=r+1;l<s;l++)i[l]>u&&(u=i[l]);return u}function d1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Gi(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var u=i[r],l=r+1;l<s;l++)i[l]<u&&(u=i[l]);return u}function m1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Gi(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!Gi(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=d1(i),n=p1(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,u=s===void 0?t.autoMinMax?r:0:s,l=t.max,f=l===void 0?t.autoMinMax?n:1:l;if(u>=f)throw new RangeError("min option must be smaller than max option");for(var p=(f-u)/(n-r),h=0;h<i.length;h++)e[h]=(i[h]-r)*p+u;return e}var g1=Object.freeze({__proto__:null,default:m1}),v1=De(g1);Object.defineProperty(Pt,"__esModule",{value:!0});var Je=h1,Sc=v1;const Hs=" ".repeat(2),Bc=" ".repeat(4);function _1(){return Ic(this)}function Ic(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
55
55
  ${Hs}[
56
56
  ${Bc}${w1(i,e,r,n,s)}
57
57
  ${Hs}]
@@ -65026,7 +65026,7 @@ function Jr(s, i, a) {
65026
65026
  function Tb() {
65027
65027
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
65028
65028
  }
65029
- const pu = new Worker(new URL("" + new URL("assets/scriptsRunWorker-R-fsPWzS.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
65029
+ const pu = new Worker(new URL("" + new URL("assets/scriptsRunWorker-vL9x1NCe.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
65030
65030
  pu.onerror = (s) => {
65031
65031
  console.error(s);
65032
65032
  };