@guihz/trading-vue-editor-tes 0.0.144 → 0.0.145

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,7 +59,7 @@ ${yo}rows: ${s.rows}
59
59
  ${yo}columns: ${s.columns}
60
60
  }`}function oy(s,e,t,r,n){const{rows:i,columns:a}=s,u=Math.min(i,e),f=Math.min(a,t),c=[];if(n==="auto"){n=!1;e:for(let h=0;h<u;h++)for(let d=0;d<f;d++)if(s.get(h,d)<0){n=!0;break e}}for(let h=0;h<u;h++){let d=[];for(let p=0;p<f;p++)d.push(ay(s.get(h,p),r,n));c.push(`${d.join(" ")}`)}return f!==a&&(c[c.length-1]+=` ... ${a-t} more columns`),u!==i&&c.push(`... ${i-e} more rows`),c.join(`
61
61
  ${Bf}`)}function ay(s,e,t){return(s>=0&&t?` ${Nf(s,e-1)}`:Nf(s,e)).padEnd(e)}function Nf(s,e){let t=s.toString();if(t.length<=e)return t;let r=s.toFixed(e);if(r.length>e&&(r=s.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=s.toExponential(e);return n.length>e&&(n=s.toExponential(Math.max(0,e-(n.length-e)))),n.slice(0)}function uy(s,e){s.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},s.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)+r);return this},s.prototype.addM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)+r.get(n,i));return this},s.add=function(r,n){return new e(r).add(n)},s.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},s.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)-r);return this},s.prototype.subM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)-r.get(n,i));return this},s.sub=function(r,n){return new e(r).sub(n)},s.prototype.subtract=s.prototype.sub,s.prototype.subtractS=s.prototype.subS,s.prototype.subtractM=s.prototype.subM,s.subtract=s.sub,s.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},s.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)*r);return this},s.prototype.mulM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)*r.get(n,i));return this},s.mul=function(r,n){return new e(r).mul(n)},s.prototype.multiply=s.prototype.mul,s.prototype.multiplyS=s.prototype.mulS,s.prototype.multiplyM=s.prototype.mulM,s.multiply=s.mul,s.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},s.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)/r);return this},s.prototype.divM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)/r.get(n,i));return this},s.div=function(r,n){return new e(r).div(n)},s.prototype.divide=s.prototype.div,s.prototype.divideS=s.prototype.divS,s.prototype.divideM=s.prototype.divM,s.divide=s.div,s.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},s.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)%r);return this},s.prototype.modM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)%r.get(n,i));return this},s.mod=function(r,n){return new e(r).mod(n)},s.prototype.modulus=s.prototype.mod,s.prototype.modulusS=s.prototype.modS,s.prototype.modulusM=s.prototype.modM,s.modulus=s.mod,s.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},s.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)&r);return this},s.prototype.andM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)&r.get(n,i));return this},s.and=function(r,n){return new e(r).and(n)},s.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},s.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)|r);return this},s.prototype.orM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)|r.get(n,i));return this},s.or=function(r,n){return new e(r).or(n)},s.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},s.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)^r);return this},s.prototype.xorM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)^r.get(n,i));return this},s.xor=function(r,n){return new e(r).xor(n)},s.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},s.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)<<r);return this},s.prototype.leftShiftM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)<<r.get(n,i));return this},s.leftShift=function(r,n){return new e(r).leftShift(n)},s.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},s.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>r);return this},s.prototype.signPropagatingRightShiftM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>r.get(n,i));return this},s.signPropagatingRightShift=function(r,n){return new e(r).signPropagatingRightShift(n)},s.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},s.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>>r);return this},s.prototype.rightShiftM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>>r.get(n,i));return this},s.rightShift=function(r,n){return new e(r).rightShift(n)},s.prototype.zeroFillRightShift=s.prototype.rightShift,s.prototype.zeroFillRightShiftS=s.prototype.rightShiftS,s.prototype.zeroFillRightShiftM=s.prototype.rightShiftM,s.zeroFillRightShift=s.rightShift,s.prototype.not=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,~this.get(r,n));return this},s.not=function(r){return new e(r).not()},s.prototype.abs=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.abs(this.get(r,n)));return this},s.abs=function(r){return new e(r).abs()},s.prototype.acos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acos(this.get(r,n)));return this},s.acos=function(r){return new e(r).acos()},s.prototype.acosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acosh(this.get(r,n)));return this},s.acosh=function(r){return new e(r).acosh()},s.prototype.asin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asin(this.get(r,n)));return this},s.asin=function(r){return new e(r).asin()},s.prototype.asinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asinh(this.get(r,n)));return this},s.asinh=function(r){return new e(r).asinh()},s.prototype.atan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atan(this.get(r,n)));return this},s.atan=function(r){return new e(r).atan()},s.prototype.atanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atanh(this.get(r,n)));return this},s.atanh=function(r){return new e(r).atanh()},s.prototype.cbrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cbrt(this.get(r,n)));return this},s.cbrt=function(r){return new e(r).cbrt()},s.prototype.ceil=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.ceil(this.get(r,n)));return this},s.ceil=function(r){return new e(r).ceil()},s.prototype.clz32=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.clz32(this.get(r,n)));return this},s.clz32=function(r){return new e(r).clz32()},s.prototype.cos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cos(this.get(r,n)));return this},s.cos=function(r){return new e(r).cos()},s.prototype.cosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cosh(this.get(r,n)));return this},s.cosh=function(r){return new e(r).cosh()},s.prototype.exp=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.exp(this.get(r,n)));return this},s.exp=function(r){return new e(r).exp()},s.prototype.expm1=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.expm1(this.get(r,n)));return this},s.expm1=function(r){return new e(r).expm1()},s.prototype.floor=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.floor(this.get(r,n)));return this},s.floor=function(r){return new e(r).floor()},s.prototype.fround=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.fround(this.get(r,n)));return this},s.fround=function(r){return new e(r).fround()},s.prototype.log=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log(this.get(r,n)));return this},s.log=function(r){return new e(r).log()},s.prototype.log1p=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log1p(this.get(r,n)));return this},s.log1p=function(r){return new e(r).log1p()},s.prototype.log10=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log10(this.get(r,n)));return this},s.log10=function(r){return new e(r).log10()},s.prototype.log2=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log2(this.get(r,n)));return this},s.log2=function(r){return new e(r).log2()},s.prototype.round=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.round(this.get(r,n)));return this},s.round=function(r){return new e(r).round()},s.prototype.sign=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sign(this.get(r,n)));return this},s.sign=function(r){return new e(r).sign()},s.prototype.sin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sin(this.get(r,n)));return this},s.sin=function(r){return new e(r).sin()},s.prototype.sinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sinh(this.get(r,n)));return this},s.sinh=function(r){return new e(r).sinh()},s.prototype.sqrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sqrt(this.get(r,n)));return this},s.sqrt=function(r){return new e(r).sqrt()},s.prototype.tan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tan(this.get(r,n)));return this},s.tan=function(r){return new e(r).tan()},s.prototype.tanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tanh(this.get(r,n)));return this},s.tanh=function(r){return new e(r).tanh()},s.prototype.trunc=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.trunc(this.get(r,n)));return this},s.trunc=function(r){return new e(r).trunc()},s.pow=function(r,n){return new e(r).pow(n)},s.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},s.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,Math.pow(this.get(n,i),r));return this},s.prototype.powM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,Math.pow(this.get(n,i),r.get(n,i)));return this}}function $r(s,e,t){let r=t?s.rows:s.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function Lr(s,e,t){let r=t?s.columns:s.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function Ni(s,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==s.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function Si(s,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==s.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function Ja(s,e){if(!gr.isAnyArray(e))throw new TypeError("row indices must be an array");for(let t=0;t<e.length;t++)if(e[t]<0||e[t]>=s.rows)throw new RangeError("row indices are out of range")}function eu(s,e){if(!gr.isAnyArray(e))throw new TypeError("column indices must be an array");for(let t=0;t<e.length;t++)if(e[t]<0||e[t]>=s.columns)throw new RangeError("column indices are out of range")}function tu(s,e,t,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(wo("startRow",e),wo("endRow",t),wo("startColumn",r),wo("endColumn",n),e>t||r>n||e<0||e>=s.rows||t<0||t>=s.rows||r<0||r>=s.columns||n<0||n>=s.columns)throw new RangeError("Submatrix indices are out of range")}function Do(s,e=0){let t=[];for(let r=0;r<s;r++)t.push(e);return t}function wo(s,e){if(typeof e!="number")throw new TypeError(`${s} must be a number`)}function Oi(s){if(s.isEmpty())throw new Error("Empty matrix has no elements to index")}function ly(s){let e=Do(s.rows);for(let t=0;t<s.rows;++t)for(let r=0;r<s.columns;++r)e[t]+=s.get(t,r);return e}function cy(s){let e=Do(s.columns);for(let t=0;t<s.rows;++t)for(let r=0;r<s.columns;++r)e[r]+=s.get(t,r);return e}function fy(s){let e=0;for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)e+=s.get(t,r);return e}function hy(s){let e=Do(s.rows,1);for(let t=0;t<s.rows;++t)for(let r=0;r<s.columns;++r)e[t]*=s.get(t,r);return e}function dy(s){let e=Do(s.columns,1);for(let t=0;t<s.rows;++t)for(let r=0;r<s.columns;++r)e[r]*=s.get(t,r);return e}function py(s){let e=1;for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)e*=s.get(t,r);return e}function _y(s,e,t){const r=s.rows,n=s.columns,i=[];for(let a=0;a<r;a++){let u=0,f=0,c=0;for(let h=0;h<n;h++)c=s.get(a,h)-t[a],u+=c,f+=c*c;e?i.push((f-u*u/n)/(n-1)):i.push((f-u*u/n)/n)}return i}function vy(s,e,t){const r=s.rows,n=s.columns,i=[];for(let a=0;a<n;a++){let u=0,f=0,c=0;for(let h=0;h<r;h++)c=s.get(h,a)-t[a],u+=c,f+=c*c;e?i.push((f-u*u/r)/(r-1)):i.push((f-u*u/r)/r)}return i}function gy(s,e,t){const r=s.rows,n=s.columns,i=r*n;let a=0,u=0,f=0;for(let c=0;c<r;c++)for(let h=0;h<n;h++)f=s.get(c,h)-t,a+=f,u+=f*f;return e?(u-a*a/i)/(i-1):(u-a*a/i)/i}function my(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)-e[t])}function xy(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)-e[r])}function yy(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)-e)}function Dy(s){const e=[];for(let t=0;t<s.rows;t++){let r=0;for(let n=0;n<s.columns;n++)r+=Math.pow(s.get(t,n),2)/(s.columns-1);e.push(Math.sqrt(r))}return e}function wy(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)/e[t])}function by(s){const e=[];for(let t=0;t<s.columns;t++){let r=0;for(let n=0;n<s.rows;n++)r+=Math.pow(s.get(n,t),2)/(s.rows-1);e.push(Math.sqrt(r))}return e}function Ey(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)/e[r])}function Cy(s){const e=s.size-1;let t=0;for(let r=0;r<s.columns;r++)for(let n=0;n<s.rows;n++)t+=Math.pow(s.get(n,r),2)/e;return Math.sqrt(t)}function Ay(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)/e)}class ke{static from1DArray(e,t,r){if(e*t!==r.length)throw new RangeError("data length does not match given dimensions");let i=new ve(e,t);for(let a=0;a<e;a++)for(let u=0;u<t;u++)i.set(a,u,r[a*t+u]);return i}static rowVector(e){let t=new ve(1,e.length);for(let r=0;r<e.length;r++)t.set(0,r,e[r]);return t}static columnVector(e){let t=new ve(e.length,1);for(let r=0;r<e.length;r++)t.set(r,0,e[r]);return t}static zeros(e,t){return new ve(e,t)}static ones(e,t){return new ve(e,t).fill(1)}static rand(e,t,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{random:n=Math.random}=r;let i=new ve(e,t);for(let a=0;a<e;a++)for(let u=0;u<t;u++)i.set(a,u,n());return i}static randInt(e,t,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:i=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(n>=i)throw new RangeError("min must be smaller than max");let u=i-n,f=new ve(e,t);for(let c=0;c<e;c++)for(let h=0;h<t;h++){let d=n+Math.round(a()*u);f.set(c,h,d)}return f}static eye(e,t,r){t===void 0&&(t=e),r===void 0&&(r=1);let n=Math.min(e,t),i=this.zeros(e,t);for(let a=0;a<n;a++)i.set(a,a,r);return i}static diag(e,t,r){let n=e.length;t===void 0&&(t=n),r===void 0&&(r=t);let i=Math.min(n,t,r),a=this.zeros(t,r);for(let u=0;u<i;u++)a.set(u,u,e[u]);return a}static min(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let r=e.rows,n=e.columns,i=new ve(r,n);for(let a=0;a<r;a++)for(let u=0;u<n;u++)i.set(a,u,Math.min(e.get(a,u),t.get(a,u)));return i}static max(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let r=e.rows,n=e.columns,i=new this(r,n);for(let a=0;a<r;a++)for(let u=0;u<n;u++)i.set(a,u,Math.max(e.get(a,u),t.get(a,u)));return i}static checkMatrix(e){return ke.isMatrix(e)?e:new ve(e)}static isMatrix(e){return e!=null&&e.klass==="Matrix"}get size(){return this.rows*this.columns}apply(e){if(typeof e!="function")throw new TypeError("callback must be a function");for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.call(this,t,r);return this}to1DArray(){let e=[];for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}to2DArray(){let e=[];for(let t=0;t<this.rows;t++){e.push([]);for(let r=0;r<this.columns;r++)e[t].push(this.get(t,r))}return e}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let e=0;e<this.rows;e++)for(let t=0;t<=e;t++)if(this.get(e,t)!==this.get(t,e))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let e=0;e<this.rows;e++)if(this.get(e,e)!==0)return!1;return!0}isEchelonForm(){let e=0,t=0,r=-1,n=!0,i=!1;for(;e<this.rows&&n;){for(t=0,i=!1;t<this.columns&&i===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>r?(i=!0,r=t):(n=!1,i=!0);e++}return n}isReducedEchelonForm(){let e=0,t=0,r=-1,n=!0,i=!1;for(;e<this.rows&&n;){for(t=0,i=!1;t<this.columns&&i===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>r?(i=!0,r=t):(n=!1,i=!0);for(let a=t+1;a<this.rows;a++)this.get(e,a)!==0&&(n=!1);e++}return n}echelonForm(){let e=this.clone(),t=0,r=0;for(;t<e.rows&&r<e.columns;){let n=t;for(let i=t;i<e.rows;i++)e.get(i,r)>e.get(n,r)&&(n=i);if(e.get(n,r)===0)r++;else{e.swapRows(t,n);let i=e.get(t,r);for(let a=r;a<e.columns;a++)e.set(t,a,e.get(t,a)/i);for(let a=t+1;a<e.rows;a++){let u=e.get(a,r)/e.get(t,r);e.set(a,r,0);for(let f=r+1;f<e.columns;f++)e.set(a,f,e.get(a,f)-e.get(t,f)*u)}t++,r++}}return e}reducedEchelonForm(){let e=this.echelonForm(),t=e.columns,r=e.rows,n=r-1;for(;n>=0;)if(e.maxRow(n)===0)n--;else{let i=0,a=!1;for(;i<r&&a===!1;)e.get(n,i)===1?a=!0:i++;for(let u=0;u<n;u++){let f=e.get(u,i);for(let c=i;c<t;c++){let h=e.get(u,c)-f*e.get(n,c);e.set(u,c,h)}}n--}return e}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{rows:t=1,columns:r=1}=e;if(!Number.isInteger(t)||t<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new ve(this.rows*t,this.columns*r);for(let i=0;i<t;i++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*i,this.columns*a);return n}fill(e){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,e);return this}neg(){return this.mulS(-1)}getRow(e){$r(this,e);let t=[];for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}getRowVector(e){return ve.rowVector(this.getRow(e))}setRow(e,t){$r(this,e),t=Ni(this,t);for(let r=0;r<this.columns;r++)this.set(e,r,t[r]);return this}swapRows(e,t){$r(this,e),$r(this,t);for(let r=0;r<this.columns;r++){let n=this.get(e,r);this.set(e,r,this.get(t,r)),this.set(t,r,n)}return this}getColumn(e){Lr(this,e);let t=[];for(let r=0;r<this.rows;r++)t.push(this.get(r,e));return t}getColumnVector(e){return ve.columnVector(this.getColumn(e))}setColumn(e,t){Lr(this,e),t=Si(this,t);for(let r=0;r<this.rows;r++)this.set(r,e,t[r]);return this}swapColumns(e,t){Lr(this,e),Lr(this,t);for(let r=0;r<this.rows;r++){let n=this.get(r,e);this.set(r,e,this.get(r,t)),this.set(r,t,n)}return this}addRowVector(e){e=Ni(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)+e[r]);return this}subRowVector(e){e=Ni(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)-e[r]);return this}mulRowVector(e){e=Ni(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e[r]);return this}divRowVector(e){e=Ni(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)/e[r]);return this}addColumnVector(e){e=Si(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)+e[t]);return this}subColumnVector(e){e=Si(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)-e[t]);return this}mulColumnVector(e){e=Si(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e[t]);return this}divColumnVector(e){e=Si(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)/e[t]);return this}mulRow(e,t){$r(this,e);for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this}mulColumn(e,t){Lr(this,e);for(let r=0;r<this.rows;r++)this.set(r,e,this.get(r,e)*t);return this}max(e){if(this.isEmpty())return NaN;switch(e){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t[r]&&(t[r]=this.get(r,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t[n]&&(t[n]=this.get(r,n));return t}case void 0:{let t=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n));return t}default:throw new Error(`invalid option: ${e}`)}}maxIndex(){Oi(this);let e=this.get(0,0),t=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e&&(e=this.get(r,n),t[0]=r,t[1]=n);return t}min(e){if(this.isEmpty())return NaN;switch(e){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t[r]&&(t[r]=this.get(r,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t[n]&&(t[n]=this.get(r,n));return t}case void 0:{let t=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n));return t}default:throw new Error(`invalid option: ${e}`)}}minIndex(){Oi(this);let e=this.get(0,0),t=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e&&(e=this.get(r,n),t[0]=r,t[1]=n);return t}maxRow(e){if($r(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let r=1;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}maxRowIndex(e){$r(this,e),Oi(this);let t=this.get(e,0),r=[e,0];for(let n=1;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n),r[1]=n);return r}minRow(e){if($r(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let r=1;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}minRowIndex(e){$r(this,e),Oi(this);let t=this.get(e,0),r=[e,0];for(let n=1;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n),r[1]=n);return r}maxColumn(e){if(Lr(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let r=1;r<this.rows;r++)this.get(r,e)>t&&(t=this.get(r,e));return t}maxColumnIndex(e){Lr(this,e),Oi(this);let t=this.get(0,e),r=[0,e];for(let n=1;n<this.rows;n++)this.get(n,e)>t&&(t=this.get(n,e),r[0]=n);return r}minColumn(e){if(Lr(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let r=1;r<this.rows;r++)this.get(r,e)<t&&(t=this.get(r,e));return t}minColumnIndex(e){Lr(this,e),Oi(this);let t=this.get(0,e),r=[0,e];for(let n=1;n<this.rows;n++)this.get(n,e)<t&&(t=this.get(n,e),r[0]=n);return r}diag(){let e=Math.min(this.rows,this.columns),t=[];for(let r=0;r<e;r++)t.push(this.get(r,r));return t}norm(e="frobenius"){switch(e){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${e}`)}}cumulativeSum(){let e=0;for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r),this.set(t,r,e);return this}dot(e){ke.isMatrix(e)&&(e=e.to1DArray());let t=this.to1DArray();if(t.length!==e.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<t.length;n++)r+=t[n]*e[n];return r}mmul(e){e=ve.checkMatrix(e);let t=this.rows,r=this.columns,n=e.columns,i=new ve(t,n),a=new Float64Array(r);for(let u=0;u<n;u++){for(let f=0;f<r;f++)a[f]=e.get(f,u);for(let f=0;f<t;f++){let c=0;for(let h=0;h<r;h++)c+=this.get(f,h)*a[h];i.set(f,u,c)}}return i}strassen2x2(e){e=ve.checkMatrix(e);let t=new ve(2,2);const r=this.get(0,0),n=e.get(0,0),i=this.get(0,1),a=e.get(0,1),u=this.get(1,0),f=e.get(1,0),c=this.get(1,1),h=e.get(1,1),d=(r+c)*(n+h),p=(u+c)*n,v=r*(a-h),x=c*(f-n),_=(r+i)*h,y=(u-r)*(n+a),m=(i-c)*(f+h),w=d+x-_+m,D=v+_,C=p+x,b=d-p+v+y;return t.set(0,0,w),t.set(0,1,D),t.set(1,0,C),t.set(1,1,b),t}strassen3x3(e){e=ve.checkMatrix(e);let t=new ve(3,3);const r=this.get(0,0),n=this.get(0,1),i=this.get(0,2),a=this.get(1,0),u=this.get(1,1),f=this.get(1,2),c=this.get(2,0),h=this.get(2,1),d=this.get(2,2),p=e.get(0,0),v=e.get(0,1),x=e.get(0,2),_=e.get(1,0),y=e.get(1,1),m=e.get(1,2),w=e.get(2,0),D=e.get(2,1),C=e.get(2,2),b=(r+n+i-a-u-h-d)*y,F=(r-a)*(-v+y),B=u*(-p+v+_-y-m-w+C),M=(-r+a+u)*(p-v+y),O=(a+u)*(-p+v),A=r*p,N=(-r+c+h)*(p-x+m),I=(-r+c)*(x-m),L=(c+h)*(-p+x),k=(r+n+i-u-f-c-h)*m,z=h*(-p+x+_-y-m-w+D),R=(-i+h+d)*(y+w-D),V=(i-d)*(y-D),H=i*w,ee=(h+d)*(-w+D),te=(-i+u+f)*(m+w-C),j=(i-f)*(m-C),X=(u+f)*(-w+C),Y=n*_,Q=f*D,pe=a*x,De=c*v,we=d*C,be=A+H+Y,Oe=b+M+O+A+R+H+ee,Fe=A+N+L+k+H+te+X,nt=F+B+M+A+H+te+j,Ye=F+M+O+A+Q,Ie=H+te+j+X+pe,Le=A+N+I+z+R+V+H,yt=R+V+H+ee+De,Wt=A+N+I+L+we;return t.set(0,0,be),t.set(0,1,Oe),t.set(0,2,Fe),t.set(1,0,nt),t.set(1,1,Ye),t.set(1,2,Ie),t.set(2,0,Le),t.set(2,1,yt),t.set(2,2,Wt),t}mmulStrassen(e){e=ve.checkMatrix(e);let t=this.clone(),r=t.rows,n=t.columns,i=e.rows,a=e.columns;n!==i&&console.warn(`Multiplying ${r} x ${n} and ${i} x ${a} matrix: dimensions do not match.`);function u(d,p,v){let x=d.rows,_=d.columns;if(x===p&&_===v)return d;{let y=ke.zeros(p,v);return y=y.setSubMatrix(d,0,0),y}}let f=Math.max(r,i),c=Math.max(n,a);t=u(t,f,c),e=u(e,f,c);function h(d,p,v,x){if(v<=512||x<=512)return d.mmul(p);v%2===1&&x%2===1?(d=u(d,v+1,x+1),p=u(p,v+1,x+1)):v%2===1?(d=u(d,v+1,x),p=u(p,v+1,x)):x%2===1&&(d=u(d,v,x+1),p=u(p,v,x+1));let _=parseInt(d.rows/2,10),y=parseInt(d.columns/2,10),m=d.subMatrix(0,_-1,0,y-1),w=p.subMatrix(0,_-1,0,y-1),D=d.subMatrix(0,_-1,y,d.columns-1),C=p.subMatrix(0,_-1,y,p.columns-1),b=d.subMatrix(_,d.rows-1,0,y-1),F=p.subMatrix(_,p.rows-1,0,y-1),B=d.subMatrix(_,d.rows-1,y,d.columns-1),M=p.subMatrix(_,p.rows-1,y,p.columns-1),O=h(ke.add(m,B),ke.add(w,M),_,y),A=h(ke.add(b,B),w,_,y),N=h(m,ke.sub(C,M),_,y),I=h(B,ke.sub(F,w),_,y),L=h(ke.add(m,D),M,_,y),k=h(ke.sub(b,m),ke.add(w,C),_,y),z=h(ke.sub(D,B),ke.add(F,M),_,y),R=ke.add(O,I);R.sub(L),R.add(z);let V=ke.add(N,L),H=ke.add(A,I),ee=ke.sub(O,A);ee.add(N),ee.add(k);let te=ke.zeros(2*R.rows,2*R.columns);return te=te.setSubMatrix(R,0,0),te=te.setSubMatrix(V,R.rows,0),te=te.setSubMatrix(H,0,R.columns),te=te.setSubMatrix(ee,R.rows,R.columns),te.subMatrix(0,v-1,0,x-1)}return h(t,e,f,c)}scaleRows(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(t>=r)throw new RangeError("min must be smaller than max");let n=new ve(this.rows,this.columns);for(let i=0;i<this.rows;i++){const a=this.getRow(i);a.length>0&&Ff(a,{min:t,max:r,output:a}),n.setRow(i,a)}return n}scaleColumns(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(t>=r)throw new RangeError("min must be smaller than max");let n=new ve(this.rows,this.columns);for(let i=0;i<this.columns;i++){const a=this.getColumn(i);a.length&&Ff(a,{min:t,max:r,output:a}),n.setColumn(i,a)}return n}flipRows(){const e=Math.ceil(this.columns/2);for(let t=0;t<this.rows;t++)for(let r=0;r<e;r++){let n=this.get(t,r),i=this.get(t,this.columns-1-r);this.set(t,r,i),this.set(t,this.columns-1-r,n)}return this}flipColumns(){const e=Math.ceil(this.rows/2);for(let t=0;t<this.columns;t++)for(let r=0;r<e;r++){let n=this.get(r,t),i=this.get(this.rows-1-r,t);this.set(r,t,i),this.set(this.rows-1-r,t,n)}return this}kroneckerProduct(e){e=ve.checkMatrix(e);let t=this.rows,r=this.columns,n=e.rows,i=e.columns,a=new ve(t*n,r*i);for(let u=0;u<t;u++)for(let f=0;f<r;f++)for(let c=0;c<n;c++)for(let h=0;h<i;h++)a.set(n*u+c,i*f+h,this.get(u,f)*e.get(c,h));return a}kroneckerSum(e){if(e=ve.checkMatrix(e),!this.isSquare()||!e.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let t=this.rows,r=e.rows,n=this.kroneckerProduct(ve.eye(r,r)),i=ve.eye(t,t).kroneckerProduct(e);return n.add(i)}transpose(){let e=new ve(this.columns,this.rows);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.set(r,t,this.get(t,r));return e}sortRows(e=Sf){for(let t=0;t<this.rows;t++)this.setRow(t,this.getRow(t).sort(e));return this}sortColumns(e=Sf){for(let t=0;t<this.columns;t++)this.setColumn(t,this.getColumn(t).sort(e));return this}subMatrix(e,t,r,n){tu(this,e,t,r,n);let i=new ve(t-e+1,n-r+1);for(let a=e;a<=t;a++)for(let u=r;u<=n;u++)i.set(a-e,u-r,this.get(a,u));return i}subMatrixRow(e,t,r){if(t===void 0&&(t=0),r===void 0&&(r=this.columns-1),t>r||t<0||t>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new ve(e.length,r-t+1);for(let i=0;i<e.length;i++)for(let a=t;a<=r;a++){if(e[i]<0||e[i]>=this.rows)throw new RangeError(`Row index out of range: ${e[i]}`);n.set(i,a-t,this.get(e[i],a))}return n}subMatrixColumn(e,t,r){if(t===void 0&&(t=0),r===void 0&&(r=this.rows-1),t>r||t<0||t>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new ve(r-t+1,e.length);for(let i=0;i<e.length;i++)for(let a=t;a<=r;a++){if(e[i]<0||e[i]>=this.columns)throw new RangeError(`Column index out of range: ${e[i]}`);n.set(a-t,i,this.get(a,e[i]))}return n}setSubMatrix(e,t,r){if(e=ve.checkMatrix(e),e.isEmpty())return this;let n=t+e.rows-1,i=r+e.columns-1;tu(this,t,n,r,i);for(let a=0;a<e.rows;a++)for(let u=0;u<e.columns;u++)this.set(t+a,r+u,e.get(a,u));return this}selection(e,t){Ja(this,e),eu(this,t);let r=new ve(e.length,t.length);for(let n=0;n<e.length;n++){let i=e[n];for(let a=0;a<t.length;a++){let u=t[a];r.set(n,a,this.get(i,u))}}return r}trace(){let e=Math.min(this.rows,this.columns),t=0;for(let r=0;r<e;r++)t+=this.get(r,r);return t}clone(){return this.constructor.copy(this,new ve(this.rows,this.columns))}static copy(e,t){for(const[r,n,i]of e.entries())t.set(r,n,i);return t}sum(e){switch(e){case"row":return ly(this);case"column":return cy(this);case void 0:return fy(this);default:throw new Error(`invalid option: ${e}`)}}product(e){switch(e){case"row":return hy(this);case"column":return dy(this);case void 0:return py(this);default:throw new Error(`invalid option: ${e}`)}}mean(e){const t=this.sum(e);switch(e){case"row":{for(let r=0;r<this.rows;r++)t[r]/=this.columns;return t}case"column":{for(let r=0;r<this.columns;r++)t[r]/=this.rows;return t}case void 0:return t/this.size;default:throw new Error(`invalid option: ${e}`)}}variance(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(e)}=t;if(typeof r!="boolean")throw new TypeError("unbiased must be a boolean");switch(e){case"row":{if(!gr.isAnyArray(n))throw new TypeError("mean must be an array");return _y(this,r,n)}case"column":{if(!gr.isAnyArray(n))throw new TypeError("mean must be an array");return vy(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return gy(this,r,n)}default:throw new Error(`invalid option: ${e}`)}}standardDeviation(e,t){typeof e=="object"&&(t=e,e=void 0);const r=this.variance(e,t);if(e===void 0)return Math.sqrt(r);for(let n=0;n<r.length;n++)r[n]=Math.sqrt(r[n]);return r}center(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");const{center:r=this.mean(e)}=t;switch(e){case"row":{if(!gr.isAnyArray(r))throw new TypeError("center must be an array");return my(this,r),this}case"column":{if(!gr.isAnyArray(r))throw new TypeError("center must be an array");return xy(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return yy(this,r),this}default:throw new Error(`invalid option: ${e}`)}}scale(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");let r=t.scale;switch(e){case"row":{if(r===void 0)r=Dy(this);else if(!gr.isAnyArray(r))throw new TypeError("scale must be an array");return wy(this,r),this}case"column":{if(r===void 0)r=by(this);else if(!gr.isAnyArray(r))throw new TypeError("scale must be an array");return Ey(this,r),this}case void 0:{if(r===void 0)r=Cy(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return Ay(this,r),this}default:throw new Error(`invalid option: ${e}`)}}toString(e){return Mf(this,e)}[Symbol.iterator](){return this.entries()}*entries(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield[e,t,this.get(e,t)]}*values(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield this.get(e,t)}}ke.prototype.klass="Matrix",typeof Symbol<"u"&&(ke.prototype[Symbol.for("nodejs.util.inspect.custom")]=sy);function Sf(s,e){return s-e}function Fy(s){return s.every(e=>typeof e=="number")}ke.random=ke.rand,ke.randomInt=ke.randInt,ke.diagonal=ke.diag,ke.prototype.diagonal=ke.prototype.diag,ke.identity=ke.eye,ke.prototype.negate=ke.prototype.neg,ke.prototype.tensorProduct=ke.prototype.kroneckerProduct;let ve=(Pi=class extends ke{constructor(t,r){super();vl(this,gs);q(this,"data");if(Pi.isMatrix(t))gl(this,gs,ml).call(this,t.rows,t.columns),Pi.copy(t,this);else if(Number.isInteger(t)&&t>=0)gl(this,gs,ml).call(this,t,r);else if(gr.isAnyArray(t)){const n=t;if(t=n.length,r=t?n[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let i=0;i<t;i++){if(n[i].length!==r)throw new RangeError("Inconsistent array dimensions");if(!Fy(n[i]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[i]))}this.rows=t,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(t,r,n){return this.data[t][r]=n,this}get(t,r){return this.data[t][r]}removeRow(t){return $r(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,r){return r===void 0&&(r=t,t=this.rows),$r(this,t,!0),r=Float64Array.from(Ni(this,r)),this.data.splice(t,0,r),this.rows+=1,this}removeColumn(t){Lr(this,t);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let i=0;i<t;i++)n[i]=this.data[r][i];for(let i=t+1;i<this.columns;i++)n[i-1]=this.data[r][i];this.data[r]=n}return this.columns-=1,this}addColumn(t,r){typeof r>"u"&&(r=t,t=this.columns),Lr(this,t,!0),r=Si(this,r);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let a=0;for(;a<t;a++)i[a]=this.data[n][a];for(i[a++]=r[n];a<this.columns+1;a++)i[a]=this.data[n][a-1];this.data[n]=i}return this.columns+=1,this}},gs=new WeakSet,ml=function(t,r){if(this.data=[],Number.isInteger(r)&&r>=0)for(let n=0;n<t;n++)this.data.push(new Float64Array(r));else throw new TypeError("nColumns must be a positive integer");this.rows=t,this.columns=r},Pi);uy(ke,ve);const Lo=class Lo extends ke{constructor(t){super();vl(this,rr,void 0);if(ve.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");Ca(this,rr,ve.copy(t,new ve(t.rows,t.rows)))}else if(Number.isInteger(t)&&t>=0)Ca(this,rr,new ve(t,t));else if(Ca(this,rr,new ve(t)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return on(this,rr).size}get rows(){return on(this,rr).rows}get columns(){return on(this,rr).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return ve.isMatrix(t)&&t.klassType==="SymmetricMatrix"}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}clone(){const t=new Lo(this.diagonalSize);for(const[r,n,i]of this.upperRightEntries())t.set(r,n,i);return t}toMatrix(){return new ve(this)}get(t,r){return on(this,rr).get(t,r)}set(t,r,n){return on(this,rr).set(t,r,n),on(this,rr).set(r,t,n),this}removeCross(t){return on(this,rr).removeRow(t),on(this,rr).removeColumn(t),this}addCross(t,r){r===void 0&&(r=t,t=this.diagonalSize);const n=r.slice();return n.splice(t,1),on(this,rr).addRow(t,n),on(this,rr).addColumn(t,r),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[n,i]of t.entries())i||r.push(n);r.reverse();for(const n of r)this.removeCross(n);return this}toCompact(){const{diagonalSize:t}=this,r=new Array(t*(t+1)/2);for(let n=0,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=t&&(n=++i);return r}static fromCompact(t){const r=t.length,n=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const i=new Lo(n);for(let a=0,u=0,f=0;f<r;f++)i.set(a,u,t[f]),++a>=n&&(a=++u);return i}*upperRightEntries(){for(let t=0,r=0;t<this.diagonalSize;void 0){const n=this.get(t,r);yield[t,r,n],++r>=this.diagonalSize&&(r=++t)}}*upperRightValues(){for(let t=0,r=0;t<this.diagonalSize;void 0)yield this.get(t,r),++r>=this.diagonalSize&&(r=++t)}};rr=new WeakMap;let si=Lo;si.prototype.klassType="SymmetricMatrix";class bo extends si{static isDistanceMatrix(e){return si.isSymmetricMatrix(e)&&e.klassSubType==="DistanceMatrix"}constructor(e){if(super(e),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(e,t,r){return e===t&&(r=0),super.set(e,t,r)}addCross(e,t){return t===void 0&&(t=e,e=this.diagonalSize),t=t.slice(),t[e]=0,super.addCross(e,t)}toSymmetricMatrix(){return new si(this)}clone(){const e=new bo(this.diagonalSize);for(const[t,r,n]of this.upperRightEntries())t!==r&&e.set(t,r,n);return e}toCompact(){const{diagonalSize:e}=this,t=(e-1)*e/2,r=new Array(t);for(let n=1,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=e&&(n=++i+1);return r}static fromCompact(e){const t=e.length,r=(Math.sqrt(8*t+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(e)}`);const n=new this(r);for(let i=1,a=0,u=0;u<t;u++)n.set(i,a,e[u]),++i>=r&&(i=++a+1);return n}}bo.prototype.klassSubType="DistanceMatrix";class yn extends ke{constructor(e,t,r){super(),this.matrix=e,this.rows=t,this.columns=r}}class By extends yn{constructor(e,t){Lr(e,t),super(e,e.rows,1),this.column=t}set(e,t,r){return this.matrix.set(e,this.column,r),this}get(e){return this.matrix.get(e,this.column)}}class My extends yn{constructor(e,t){eu(e,t),super(e,e.rows,t.length),this.columnIndices=t}set(e,t,r){return this.matrix.set(e,this.columnIndices[t],r),this}get(e,t){return this.matrix.get(e,this.columnIndices[t])}}class Ny extends yn{constructor(e){super(e,e.rows,e.columns)}set(e,t,r){return this.matrix.set(e,this.columns-t-1,r),this}get(e,t){return this.matrix.get(e,this.columns-t-1)}}class Sy extends yn{constructor(e){super(e,e.rows,e.columns)}set(e,t,r){return this.matrix.set(this.rows-e-1,t,r),this}get(e,t){return this.matrix.get(this.rows-e-1,t)}}class Oy extends yn{constructor(e,t){$r(e,t),super(e,1,e.columns),this.row=t}set(e,t,r){return this.matrix.set(this.row,t,r),this}get(e,t){return this.matrix.get(this.row,t)}}class Iy extends yn{constructor(e,t){Ja(e,t),super(e,t.length,e.columns),this.rowIndices=t}set(e,t,r){return this.matrix.set(this.rowIndices[e],t,r),this}get(e,t){return this.matrix.get(this.rowIndices[e],t)}}class Eo extends yn{constructor(e,t,r){Ja(e,t),eu(e,r),super(e,t.length,r.length),this.rowIndices=t,this.columnIndices=r}set(e,t,r){return this.matrix.set(this.rowIndices[e],this.columnIndices[t],r),this}get(e,t){return this.matrix.get(this.rowIndices[e],this.columnIndices[t])}}class Ty extends yn{constructor(e,t,r,n,i){tu(e,t,r,n,i),super(e,r-t+1,i-n+1),this.startRow=t,this.startColumn=n}set(e,t,r){return this.matrix.set(this.startRow+e,this.startColumn+t,r),this}get(e,t){return this.matrix.get(this.startRow+e,this.startColumn+t)}}class $y extends yn{constructor(e){super(e,e.columns,e.rows)}set(e,t,r){return this.matrix.set(t,e,r),this}get(e,t){return this.matrix.get(t,e)}}class Of extends ke{constructor(e,t={}){const{rows:r=1}=t;if(e.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=e.length/r,this.data=e}set(e,t,r){let n=this._calculateIndex(e,t);return this.data[n]=r,this}get(e,t){let r=this._calculateIndex(e,t);return this.data[r]}_calculateIndex(e,t){return e*this.columns+t}}class Cr extends ke{constructor(e){super(),this.data=e,this.rows=e.length,this.columns=e[0].length}set(e,t,r){return this.data[e][t]=r,this}get(e,t){return this.data[e][t]}}function Ly(s,e){if(gr.isAnyArray(s))return s[0]&&gr.isAnyArray(s[0])?new Cr(s):new Of(s,e);throw new Error("the argument is not an array")}class Co{constructor(e){e=Cr.checkMatrix(e);let t=e.clone(),r=t.rows,n=t.columns,i=new Float64Array(r),a=1,u,f,c,h,d,p,v,x,_;for(u=0;u<r;u++)i[u]=u;for(x=new Float64Array(r),f=0;f<n;f++){for(u=0;u<r;u++)x[u]=t.get(u,f);for(u=0;u<r;u++){for(_=Math.min(u,f),d=0,c=0;c<_;c++)d+=t.get(u,c)*x[c];x[u]-=d,t.set(u,f,x[u])}for(h=f,u=f+1;u<r;u++)Math.abs(x[u])>Math.abs(x[h])&&(h=u);if(h!==f){for(c=0;c<n;c++)p=t.get(h,c),t.set(h,c,t.get(f,c)),t.set(f,c,p);v=i[h],i[h]=i[f],i[f]=v,a=-a}if(f<r&&t.get(f,f)!==0)for(u=f+1;u<r;u++)t.set(u,f,t.get(u,f)/t.get(f,f))}this.LU=t,this.pivotVector=i,this.pivotSign=a}isSingular(){let e=this.LU,t=e.columns;for(let r=0;r<t;r++)if(e.get(r,r)===0)return!0;return!1}solve(e){e=ve.checkMatrix(e);let t=this.LU;if(t.rows!==e.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n=e.columns,i=e.subMatrixRow(this.pivotVector,0,n-1),a=t.columns,u,f,c;for(c=0;c<a;c++)for(u=c+1;u<a;u++)for(f=0;f<n;f++)i.set(u,f,i.get(u,f)-i.get(c,f)*t.get(u,c));for(c=a-1;c>=0;c--){for(f=0;f<n;f++)i.set(c,f,i.get(c,f)/t.get(c,c));for(u=0;u<c;u++)for(f=0;f<n;f++)i.set(u,f,i.get(u,f)-i.get(c,f)*t.get(u,c))}return i}get determinant(){let e=this.LU;if(!e.isSquare())throw new Error("Matrix must be square");let t=this.pivotSign,r=e.columns;for(let n=0;n<r;n++)t*=e.get(n,n);return t}get lowerTriangularMatrix(){let e=this.LU,t=e.rows,r=e.columns,n=new ve(t,r);for(let i=0;i<t;i++)for(let a=0;a<r;a++)i>a?n.set(i,a,e.get(i,a)):i===a?n.set(i,a,1):n.set(i,a,0);return n}get upperTriangularMatrix(){let e=this.LU,t=e.rows,r=e.columns,n=new ve(t,r);for(let i=0;i<t;i++)for(let a=0;a<r;a++)i<=a?n.set(i,a,e.get(i,a)):n.set(i,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Dn(s,e){let t=0;return Math.abs(s)>Math.abs(e)?(t=e/s,Math.abs(s)*Math.sqrt(1+t*t)):e!==0?(t=s/e,Math.abs(e)*Math.sqrt(1+t*t)):0}class ru{constructor(e){e=Cr.checkMatrix(e);let t=e.clone(),r=e.rows,n=e.columns,i=new Float64Array(n),a,u,f,c;for(f=0;f<n;f++){let h=0;for(a=f;a<r;a++)h=Dn(h,t.get(a,f));if(h!==0){for(t.get(f,f)<0&&(h=-h),a=f;a<r;a++)t.set(a,f,t.get(a,f)/h);for(t.set(f,f,t.get(f,f)+1),u=f+1;u<n;u++){for(c=0,a=f;a<r;a++)c+=t.get(a,f)*t.get(a,u);for(c=-c/t.get(f,f),a=f;a<r;a++)t.set(a,u,t.get(a,u)+c*t.get(a,f))}}i[f]=-h}this.QR=t,this.Rdiag=i}solve(e){e=ve.checkMatrix(e);let t=this.QR,r=t.rows;if(e.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n=e.columns,i=e.clone(),a=t.columns,u,f,c,h;for(c=0;c<a;c++)for(f=0;f<n;f++){for(h=0,u=c;u<r;u++)h+=t.get(u,c)*i.get(u,f);for(h=-h/t.get(c,c),u=c;u<r;u++)i.set(u,f,i.get(u,f)+h*t.get(u,c))}for(c=a-1;c>=0;c--){for(f=0;f<n;f++)i.set(c,f,i.get(c,f)/this.Rdiag[c]);for(u=0;u<c;u++)for(f=0;f<n;f++)i.set(u,f,i.get(u,f)-i.get(c,f)*t.get(u,c))}return i.subMatrix(0,a-1,0,n-1)}isFullRank(){let e=this.QR.columns;for(let t=0;t<e;t++)if(this.Rdiag[t]===0)return!1;return!0}get upperTriangularMatrix(){let e=this.QR,t=e.columns,r=new ve(t,t),n,i;for(n=0;n<t;n++)for(i=0;i<t;i++)n<i?r.set(n,i,e.get(n,i)):n===i?r.set(n,i,this.Rdiag[n]):r.set(n,i,0);return r}get orthogonalMatrix(){let e=this.QR,t=e.rows,r=e.columns,n=new ve(t,r),i,a,u,f;for(u=r-1;u>=0;u--){for(i=0;i<t;i++)n.set(i,u,0);for(n.set(u,u,1),a=u;a<r;a++)if(e.get(u,u)!==0){for(f=0,i=u;i<t;i++)f+=e.get(i,u)*n.get(i,a);for(f=-f/e.get(u,u),i=u;i<t;i++)n.set(i,a,n.get(i,a)+f*e.get(i,u))}}return n}}class Ii{constructor(e,t={}){if(e=Cr.checkMatrix(e),e.isEmpty())throw new Error("Matrix must be non-empty");let r=e.rows,n=e.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:a=!0,autoTranspose:u=!1}=t;let f=!!i,c=!!a,h=!1,d;if(r<n)if(!u)d=e.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{d=e.transpose(),r=d.rows,n=d.columns,h=!0;let A=f;f=c,c=A}else d=e.clone();let p=Math.min(r,n),v=Math.min(r+1,n),x=new Float64Array(v),_=new ve(r,p),y=new ve(n,n),m=new Float64Array(n),w=new Float64Array(r),D=new Float64Array(v);for(let A=0;A<v;A++)D[A]=A;let C=Math.min(r-1,n),b=Math.max(0,Math.min(n-2,r)),F=Math.max(C,b);for(let A=0;A<F;A++){if(A<C){x[A]=0;for(let N=A;N<r;N++)x[A]=Dn(x[A],d.get(N,A));if(x[A]!==0){d.get(A,A)<0&&(x[A]=-x[A]);for(let N=A;N<r;N++)d.set(N,A,d.get(N,A)/x[A]);d.set(A,A,d.get(A,A)+1)}x[A]=-x[A]}for(let N=A+1;N<n;N++){if(A<C&&x[A]!==0){let I=0;for(let L=A;L<r;L++)I+=d.get(L,A)*d.get(L,N);I=-I/d.get(A,A);for(let L=A;L<r;L++)d.set(L,N,d.get(L,N)+I*d.get(L,A))}m[N]=d.get(A,N)}if(f&&A<C)for(let N=A;N<r;N++)_.set(N,A,d.get(N,A));if(A<b){m[A]=0;for(let N=A+1;N<n;N++)m[A]=Dn(m[A],m[N]);if(m[A]!==0){m[A+1]<0&&(m[A]=0-m[A]);for(let N=A+1;N<n;N++)m[N]/=m[A];m[A+1]+=1}if(m[A]=-m[A],A+1<r&&m[A]!==0){for(let N=A+1;N<r;N++)w[N]=0;for(let N=A+1;N<r;N++)for(let I=A+1;I<n;I++)w[N]+=m[I]*d.get(N,I);for(let N=A+1;N<n;N++){let I=-m[N]/m[A+1];for(let L=A+1;L<r;L++)d.set(L,N,d.get(L,N)+I*w[L])}}if(c)for(let N=A+1;N<n;N++)y.set(N,A,m[N])}}let B=Math.min(n,r+1);if(C<n&&(x[C]=d.get(C,C)),r<B&&(x[B-1]=0),b+1<B&&(m[b]=d.get(b,B-1)),m[B-1]=0,f){for(let A=C;A<p;A++){for(let N=0;N<r;N++)_.set(N,A,0);_.set(A,A,1)}for(let A=C-1;A>=0;A--)if(x[A]!==0){for(let N=A+1;N<p;N++){let I=0;for(let L=A;L<r;L++)I+=_.get(L,A)*_.get(L,N);I=-I/_.get(A,A);for(let L=A;L<r;L++)_.set(L,N,_.get(L,N)+I*_.get(L,A))}for(let N=A;N<r;N++)_.set(N,A,-_.get(N,A));_.set(A,A,1+_.get(A,A));for(let N=0;N<A-1;N++)_.set(N,A,0)}else{for(let N=0;N<r;N++)_.set(N,A,0);_.set(A,A,1)}}if(c)for(let A=n-1;A>=0;A--){if(A<b&&m[A]!==0)for(let N=A+1;N<n;N++){let I=0;for(let L=A+1;L<n;L++)I+=y.get(L,A)*y.get(L,N);I=-I/y.get(A+1,A);for(let L=A+1;L<n;L++)y.set(L,N,y.get(L,N)+I*y.get(L,A))}for(let N=0;N<n;N++)y.set(N,A,0);y.set(A,A,1)}let M=B-1,O=Number.EPSILON;for(;B>0;){let A,N;for(A=B-2;A>=-1&&A!==-1;A--){const I=Number.MIN_VALUE+O*Math.abs(x[A]+Math.abs(x[A+1]));if(Math.abs(m[A])<=I||Number.isNaN(m[A])){m[A]=0;break}}if(A===B-2)N=4;else{let I;for(I=B-1;I>=A&&I!==A;I--){let L=(I!==B?Math.abs(m[I]):0)+(I!==A+1?Math.abs(m[I-1]):0);if(Math.abs(x[I])<=O*L){x[I]=0;break}}I===A?N=3:I===B-1?N=1:(N=2,A=I)}switch(A++,N){case 1:{let I=m[B-2];m[B-2]=0;for(let L=B-2;L>=A;L--){let k=Dn(x[L],I),z=x[L]/k,R=I/k;if(x[L]=k,L!==A&&(I=-R*m[L-1],m[L-1]=z*m[L-1]),c)for(let V=0;V<n;V++)k=z*y.get(V,L)+R*y.get(V,B-1),y.set(V,B-1,-R*y.get(V,L)+z*y.get(V,B-1)),y.set(V,L,k)}break}case 2:{let I=m[A-1];m[A-1]=0;for(let L=A;L<B;L++){let k=Dn(x[L],I),z=x[L]/k,R=I/k;if(x[L]=k,I=-R*m[L],m[L]=z*m[L],f)for(let V=0;V<r;V++)k=z*_.get(V,L)+R*_.get(V,A-1),_.set(V,A-1,-R*_.get(V,L)+z*_.get(V,A-1)),_.set(V,L,k)}break}case 3:{const I=Math.max(Math.abs(x[B-1]),Math.abs(x[B-2]),Math.abs(m[B-2]),Math.abs(x[A]),Math.abs(m[A])),L=x[B-1]/I,k=x[B-2]/I,z=m[B-2]/I,R=x[A]/I,V=m[A]/I,H=((k+L)*(k-L)+z*z)/2,ee=L*z*(L*z);let te=0;(H!==0||ee!==0)&&(H<0?te=0-Math.sqrt(H*H+ee):te=Math.sqrt(H*H+ee),te=ee/(H+te));let j=(R+L)*(R-L)+te,X=R*V;for(let Y=A;Y<B-1;Y++){let Q=Dn(j,X);Q===0&&(Q=Number.MIN_VALUE);let pe=j/Q,De=X/Q;if(Y!==A&&(m[Y-1]=Q),j=pe*x[Y]+De*m[Y],m[Y]=pe*m[Y]-De*x[Y],X=De*x[Y+1],x[Y+1]=pe*x[Y+1],c)for(let we=0;we<n;we++)Q=pe*y.get(we,Y)+De*y.get(we,Y+1),y.set(we,Y+1,-De*y.get(we,Y)+pe*y.get(we,Y+1)),y.set(we,Y,Q);if(Q=Dn(j,X),Q===0&&(Q=Number.MIN_VALUE),pe=j/Q,De=X/Q,x[Y]=Q,j=pe*m[Y]+De*x[Y+1],x[Y+1]=-De*m[Y]+pe*x[Y+1],X=De*m[Y+1],m[Y+1]=pe*m[Y+1],f&&Y<r-1)for(let we=0;we<r;we++)Q=pe*_.get(we,Y)+De*_.get(we,Y+1),_.set(we,Y+1,-De*_.get(we,Y)+pe*_.get(we,Y+1)),_.set(we,Y,Q)}m[B-2]=j;break}case 4:{if(x[A]<=0&&(x[A]=x[A]<0?-x[A]:0,c))for(let I=0;I<=M;I++)y.set(I,A,-y.get(I,A));for(;A<M&&!(x[A]>=x[A+1]);){let I=x[A];if(x[A]=x[A+1],x[A+1]=I,c&&A<n-1)for(let L=0;L<n;L++)I=y.get(L,A+1),y.set(L,A+1,y.get(L,A)),y.set(L,A,I);if(f&&A<r-1)for(let L=0;L<r;L++)I=_.get(L,A+1),_.set(L,A+1,_.get(L,A)),_.set(L,A,I);A++}B--;break}}}if(h){let A=y;y=_,_=A}this.m=r,this.n=n,this.s=x,this.U=_,this.V=y}solve(e){let t=e,r=this.threshold,n=this.s.length,i=ve.zeros(n,n);for(let p=0;p<n;p++)Math.abs(this.s[p])<=r?i.set(p,p,0):i.set(p,p,1/this.s[p]);let a=this.U,u=this.rightSingularVectors,f=u.mmul(i),c=u.rows,h=a.rows,d=ve.zeros(c,h);for(let p=0;p<c;p++)for(let v=0;v<h;v++){let x=0;for(let _=0;_<n;_++)x+=f.get(p,_)*a.get(v,_);d.set(p,v,x)}return d.mmul(t)}solveForDiagonal(e){return this.solve(ve.diag(e))}inverse(){let e=this.V,t=this.threshold,r=e.rows,n=e.columns,i=new ve(r,this.s.length);for(let h=0;h<r;h++)for(let d=0;d<n;d++)Math.abs(this.s[d])>t&&i.set(h,d,e.get(h,d)/this.s[d]);let a=this.U,u=a.rows,f=a.columns,c=new ve(r,u);for(let h=0;h<r;h++)for(let d=0;d<u;d++){let p=0;for(let v=0;v<f;v++)p+=i.get(h,v)*a.get(d,v);c.set(h,d,p)}return c}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let e=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,t=0,r=this.s;for(let n=0,i=r.length;n<i;n++)r[n]>e&&t++;return t}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return ve.diag(this.s)}}function Ry(s,e=!1){return s=Cr.checkMatrix(s),e?new Ii(s).inverse():If(s,ve.eye(s.rows))}function If(s,e,t=!1){return s=Cr.checkMatrix(s),e=Cr.checkMatrix(e),t?new Ii(s).solve(e):s.isSquare()?new Co(s).solve(e):new ru(s).solve(e)}function Ao(s){if(s=ve.checkMatrix(s),s.isSquare()){if(s.columns===0)return 1;let e,t,r,n;if(s.columns===2)return e=s.get(0,0),t=s.get(0,1),r=s.get(1,0),n=s.get(1,1),e*n-t*r;if(s.columns===3){let i,a,u;return i=new Eo(s,[1,2],[1,2]),a=new Eo(s,[1,2],[0,2]),u=new Eo(s,[1,2],[0,1]),e=s.get(0,0),t=s.get(0,1),r=s.get(0,2),e*Ao(i)-t*Ao(a)+r*Ao(u)}else return new Co(s).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Py(s,e){let t=[];for(let r=0;r<s;r++)r!==e&&t.push(r);return t}function ky(s,e,t,r=1e-9,n=1e-9){if(s>n)return new Array(e.rows+1).fill(0);{let i=e.addRow(t,[0]);for(let a=0;a<i.rows;a++)Math.abs(i.get(a,0))<r&&i.set(a,0,0);return i.to1DArray()}}function zy(s,e={}){const{thresholdValue:t=1e-9,thresholdError:r=1e-9}=e;s=ve.checkMatrix(s);let n=s.rows,i=new ve(n,n);for(let a=0;a<n;a++){let u=ve.columnVector(s.getRow(a)),f=s.subMatrixRow(Py(n,a)).transpose(),h=new Ii(f).solve(u),d=ve.sub(u,f.mmul(h)).abs().max();i.setRow(a,ky(d,h,a,t,r))}return i}function qy(s,e=Number.EPSILON){if(s=ve.checkMatrix(s),s.isEmpty())return s.transpose();let t=new Ii(s,{autoTranspose:!0}),r=t.leftSingularVectors,n=t.rightSingularVectors,i=t.diagonal;for(let a=0;a<i.length;a++)Math.abs(i[a])>e?i[a]=1/i[a]:i[a]=0;return n.mmul(ve.diag(i).mmul(r.transpose()))}function Uy(s,e=s,t={}){s=new ve(s);let r=!1;if(typeof e=="object"&&!ve.isMatrix(e)&&!gr.isAnyArray(e)?(t=e,e=s,r=!0):e=new ve(e),s.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=t;n&&(s=s.center("column"),r||(e=e.center("column")));const i=s.transpose().mmul(e);for(let a=0;a<i.rows;a++)for(let u=0;u<i.columns;u++)i.set(a,u,i.get(a,u)*(1/(s.rows-1)));return i}function Wy(s,e=s,t={}){s=new ve(s);let r=!1;if(typeof e=="object"&&!ve.isMatrix(e)&&!gr.isAnyArray(e)?(t=e,e=s,r=!0):e=new ve(e),s.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:i=!0}=t;n&&(s.center("column"),r||e.center("column")),i&&(s.scale("column"),r||e.scale("column"));const a=s.standardDeviation("column",{unbiased:!0}),u=r?a:e.standardDeviation("column",{unbiased:!0}),f=s.transpose().mmul(e);for(let c=0;c<f.rows;c++)for(let h=0;h<f.columns;h++)f.set(c,h,f.get(c,h)*(1/(a[c]*u[h]))*(1/(s.rows-1)));return f}let Tf=class{constructor(e,t={}){const{assumeSymmetric:r=!1}=t;if(e=Cr.checkMatrix(e),!e.isSquare())throw new Error("Matrix is not a square matrix");if(e.isEmpty())throw new Error("Matrix must be non-empty");let n=e.columns,i=new ve(n,n),a=new Float64Array(n),u=new Float64Array(n),f=e,c,h,d=!1;if(r?d=!0:d=e.isSymmetric(),d){for(c=0;c<n;c++)for(h=0;h<n;h++)i.set(c,h,f.get(c,h));Hy(n,u,a,i),jy(n,u,a,i)}else{let p=new ve(n,n),v=new Float64Array(n);for(h=0;h<n;h++)for(c=0;c<n;c++)p.set(c,h,f.get(c,h));Yy(n,p,v,i),Ky(n,u,a,i,p)}this.n=n,this.e=u,this.d=a,this.V=i}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let e=this.n,t=this.e,r=this.d,n=new ve(e,e),i,a;for(i=0;i<e;i++){for(a=0;a<e;a++)n.set(i,a,0);n.set(i,i,r[i]),t[i]>0?n.set(i,i+1,t[i]):t[i]<0&&n.set(i,i-1,t[i])}return n}};function Hy(s,e,t,r){let n,i,a,u,f,c,h,d;for(f=0;f<s;f++)t[f]=r.get(s-1,f);for(u=s-1;u>0;u--){for(d=0,a=0,c=0;c<u;c++)d=d+Math.abs(t[c]);if(d===0)for(e[u]=t[u-1],f=0;f<u;f++)t[f]=r.get(u-1,f),r.set(u,f,0),r.set(f,u,0);else{for(c=0;c<u;c++)t[c]/=d,a+=t[c]*t[c];for(n=t[u-1],i=Math.sqrt(a),n>0&&(i=-i),e[u]=d*i,a=a-n*i,t[u-1]=n-i,f=0;f<u;f++)e[f]=0;for(f=0;f<u;f++){for(n=t[f],r.set(f,u,n),i=e[f]+r.get(f,f)*n,c=f+1;c<=u-1;c++)i+=r.get(c,f)*t[c],e[c]+=r.get(c,f)*n;e[f]=i}for(n=0,f=0;f<u;f++)e[f]/=a,n+=e[f]*t[f];for(h=n/(a+a),f=0;f<u;f++)e[f]-=h*t[f];for(f=0;f<u;f++){for(n=t[f],i=e[f],c=f;c<=u-1;c++)r.set(c,f,r.get(c,f)-(n*e[c]+i*t[c]));t[f]=r.get(u-1,f),r.set(u,f,0)}}t[u]=a}for(u=0;u<s-1;u++){if(r.set(s-1,u,r.get(u,u)),r.set(u,u,1),a=t[u+1],a!==0){for(c=0;c<=u;c++)t[c]=r.get(c,u+1)/a;for(f=0;f<=u;f++){for(i=0,c=0;c<=u;c++)i+=r.get(c,u+1)*r.get(c,f);for(c=0;c<=u;c++)r.set(c,f,r.get(c,f)-i*t[c])}}for(c=0;c<=u;c++)r.set(c,u+1,0)}for(f=0;f<s;f++)t[f]=r.get(s-1,f),r.set(s-1,f,0);r.set(s-1,s-1,1),e[0]=0}function jy(s,e,t,r){let n,i,a,u,f,c,h,d,p,v,x,_,y,m,w,D;for(a=1;a<s;a++)e[a-1]=e[a];e[s-1]=0;let C=0,b=0,F=Number.EPSILON;for(c=0;c<s;c++){for(b=Math.max(b,Math.abs(t[c])+Math.abs(e[c])),h=c;h<s&&!(Math.abs(e[h])<=F*b);)h++;if(h>c)do{for(n=t[c],d=(t[c+1]-n)/(2*e[c]),p=Dn(d,1),d<0&&(p=-p),t[c]=e[c]/(d+p),t[c+1]=e[c]*(d+p),v=t[c+1],i=n-t[c],a=c+2;a<s;a++)t[a]-=i;for(C=C+i,d=t[h],x=1,_=x,y=x,m=e[c+1],w=0,D=0,a=h-1;a>=c;a--)for(y=_,_=x,D=w,n=x*e[a],i=x*d,p=Dn(d,e[a]),e[a+1]=w*p,w=e[a]/p,x=d/p,d=x*t[a]-w*n,t[a+1]=i+w*(x*n+w*t[a]),f=0;f<s;f++)i=r.get(f,a+1),r.set(f,a+1,w*r.get(f,a)+x*i),r.set(f,a,x*r.get(f,a)-w*i);d=-w*D*y*m*e[c]/v,e[c]=w*d,t[c]=x*d}while(Math.abs(e[c])>F*b);t[c]=t[c]+C,e[c]=0}for(a=0;a<s-1;a++){for(f=a,d=t[a],u=a+1;u<s;u++)t[u]<d&&(f=u,d=t[u]);if(f!==a)for(t[f]=t[a],t[a]=d,u=0;u<s;u++)d=r.get(u,a),r.set(u,a,r.get(u,f)),r.set(u,f,d)}}function Yy(s,e,t,r){let n=0,i=s-1,a,u,f,c,h,d,p;for(d=n+1;d<=i-1;d++){for(p=0,c=d;c<=i;c++)p=p+Math.abs(e.get(c,d-1));if(p!==0){for(f=0,c=i;c>=d;c--)t[c]=e.get(c,d-1)/p,f+=t[c]*t[c];for(u=Math.sqrt(f),t[d]>0&&(u=-u),f=f-t[d]*u,t[d]=t[d]-u,h=d;h<s;h++){for(a=0,c=i;c>=d;c--)a+=t[c]*e.get(c,h);for(a=a/f,c=d;c<=i;c++)e.set(c,h,e.get(c,h)-a*t[c])}for(c=0;c<=i;c++){for(a=0,h=i;h>=d;h--)a+=t[h]*e.get(c,h);for(a=a/f,h=d;h<=i;h++)e.set(c,h,e.get(c,h)-a*t[h])}t[d]=p*t[d],e.set(d,d-1,p*u)}}for(c=0;c<s;c++)for(h=0;h<s;h++)r.set(c,h,c===h?1:0);for(d=i-1;d>=n+1;d--)if(e.get(d,d-1)!==0){for(c=d+1;c<=i;c++)t[c]=e.get(c,d-1);for(h=d;h<=i;h++){for(u=0,c=d;c<=i;c++)u+=t[c]*r.get(c,h);for(u=u/t[d]/e.get(d,d-1),c=d;c<=i;c++)r.set(c,h,r.get(c,h)+u*t[c])}}}function Ky(s,e,t,r,n){let i=s-1,a=0,u=s-1,f=Number.EPSILON,c=0,h=0,d=0,p=0,v=0,x=0,_=0,y=0,m,w,D,C,b,F,B,M,O,A,N,I,L,k,z;for(m=0;m<s;m++)for((m<a||m>u)&&(t[m]=n.get(m,m),e[m]=0),w=Math.max(m-1,0);w<s;w++)h=h+Math.abs(n.get(m,w));for(;i>=a;){for(C=i;C>a&&(x=Math.abs(n.get(C-1,C-1))+Math.abs(n.get(C,C)),x===0&&(x=h),!(Math.abs(n.get(C,C-1))<f*x));)C--;if(C===i)n.set(i,i,n.get(i,i)+c),t[i]=n.get(i,i),e[i]=0,i--,y=0;else if(C===i-1){if(B=n.get(i,i-1)*n.get(i-1,i),d=(n.get(i-1,i-1)-n.get(i,i))/2,p=d*d+B,_=Math.sqrt(Math.abs(p)),n.set(i,i,n.get(i,i)+c),n.set(i-1,i-1,n.get(i-1,i-1)+c),M=n.get(i,i),p>=0){for(_=d>=0?d+_:d-_,t[i-1]=M+_,t[i]=t[i-1],_!==0&&(t[i]=M-B/_),e[i-1]=0,e[i]=0,M=n.get(i,i-1),x=Math.abs(M)+Math.abs(_),d=M/x,p=_/x,v=Math.sqrt(d*d+p*p),d=d/v,p=p/v,w=i-1;w<s;w++)_=n.get(i-1,w),n.set(i-1,w,p*_+d*n.get(i,w)),n.set(i,w,p*n.get(i,w)-d*_);for(m=0;m<=i;m++)_=n.get(m,i-1),n.set(m,i-1,p*_+d*n.get(m,i)),n.set(m,i,p*n.get(m,i)-d*_);for(m=a;m<=u;m++)_=r.get(m,i-1),r.set(m,i-1,p*_+d*r.get(m,i)),r.set(m,i,p*r.get(m,i)-d*_)}else t[i-1]=M+d,t[i]=M+d,e[i-1]=_,e[i]=-_;i=i-2,y=0}else{if(M=n.get(i,i),O=0,B=0,C<i&&(O=n.get(i-1,i-1),B=n.get(i,i-1)*n.get(i-1,i)),y===10){for(c+=M,m=a;m<=i;m++)n.set(m,m,n.get(m,m)-M);x=Math.abs(n.get(i,i-1))+Math.abs(n.get(i-1,i-2)),M=O=.75*x,B=-.4375*x*x}if(y===30&&(x=(O-M)/2,x=x*x+B,x>0)){for(x=Math.sqrt(x),O<M&&(x=-x),x=M-B/((O-M)/2+x),m=a;m<=i;m++)n.set(m,m,n.get(m,m)-x);c+=x,M=O=B=.964}for(y=y+1,b=i-2;b>=C&&(_=n.get(b,b),v=M-_,x=O-_,d=(v*x-B)/n.get(b+1,b)+n.get(b,b+1),p=n.get(b+1,b+1)-_-v-x,v=n.get(b+2,b+1),x=Math.abs(d)+Math.abs(p)+Math.abs(v),d=d/x,p=p/x,v=v/x,!(b===C||Math.abs(n.get(b,b-1))*(Math.abs(p)+Math.abs(v))<f*(Math.abs(d)*(Math.abs(n.get(b-1,b-1))+Math.abs(_)+Math.abs(n.get(b+1,b+1))))));)b--;for(m=b+2;m<=i;m++)n.set(m,m-2,0),m>b+2&&n.set(m,m-3,0);for(D=b;D<=i-1&&(k=D!==i-1,D!==b&&(d=n.get(D,D-1),p=n.get(D+1,D-1),v=k?n.get(D+2,D-1):0,M=Math.abs(d)+Math.abs(p)+Math.abs(v),M!==0&&(d=d/M,p=p/M,v=v/M)),M!==0);D++)if(x=Math.sqrt(d*d+p*p+v*v),d<0&&(x=-x),x!==0){for(D!==b?n.set(D,D-1,-x*M):C!==b&&n.set(D,D-1,-n.get(D,D-1)),d=d+x,M=d/x,O=p/x,_=v/x,p=p/d,v=v/d,w=D;w<s;w++)d=n.get(D,w)+p*n.get(D+1,w),k&&(d=d+v*n.get(D+2,w),n.set(D+2,w,n.get(D+2,w)-d*_)),n.set(D,w,n.get(D,w)-d*M),n.set(D+1,w,n.get(D+1,w)-d*O);for(m=0;m<=Math.min(i,D+3);m++)d=M*n.get(m,D)+O*n.get(m,D+1),k&&(d=d+_*n.get(m,D+2),n.set(m,D+2,n.get(m,D+2)-d*v)),n.set(m,D,n.get(m,D)-d),n.set(m,D+1,n.get(m,D+1)-d*p);for(m=a;m<=u;m++)d=M*r.get(m,D)+O*r.get(m,D+1),k&&(d=d+_*r.get(m,D+2),r.set(m,D+2,r.get(m,D+2)-d*v)),r.set(m,D,r.get(m,D)-d),r.set(m,D+1,r.get(m,D+1)-d*p)}}}if(h!==0){for(i=s-1;i>=0;i--)if(d=t[i],p=e[i],p===0)for(C=i,n.set(i,i,1),m=i-1;m>=0;m--){for(B=n.get(m,m)-d,v=0,w=C;w<=i;w++)v=v+n.get(m,w)*n.get(w,i);if(e[m]<0)_=B,x=v;else if(C=m,e[m]===0?n.set(m,i,B!==0?-v/B:-v/(f*h)):(M=n.get(m,m+1),O=n.get(m+1,m),p=(t[m]-d)*(t[m]-d)+e[m]*e[m],F=(M*x-_*v)/p,n.set(m,i,F),n.set(m+1,i,Math.abs(M)>Math.abs(_)?(-v-B*F)/M:(-x-O*F)/_)),F=Math.abs(n.get(m,i)),f*F*F>1)for(w=m;w<=i;w++)n.set(w,i,n.get(w,i)/F)}else if(p<0)for(C=i-1,Math.abs(n.get(i,i-1))>Math.abs(n.get(i-1,i))?(n.set(i-1,i-1,p/n.get(i,i-1)),n.set(i-1,i,-(n.get(i,i)-d)/n.get(i,i-1))):(z=Fo(0,-n.get(i-1,i),n.get(i-1,i-1)-d,p),n.set(i-1,i-1,z[0]),n.set(i-1,i,z[1])),n.set(i,i-1,0),n.set(i,i,1),m=i-2;m>=0;m--){for(A=0,N=0,w=C;w<=i;w++)A=A+n.get(m,w)*n.get(w,i-1),N=N+n.get(m,w)*n.get(w,i);if(B=n.get(m,m)-d,e[m]<0)_=B,v=A,x=N;else if(C=m,e[m]===0?(z=Fo(-A,-N,B,p),n.set(m,i-1,z[0]),n.set(m,i,z[1])):(M=n.get(m,m+1),O=n.get(m+1,m),I=(t[m]-d)*(t[m]-d)+e[m]*e[m]-p*p,L=(t[m]-d)*2*p,I===0&&L===0&&(I=f*h*(Math.abs(B)+Math.abs(p)+Math.abs(M)+Math.abs(O)+Math.abs(_))),z=Fo(M*v-_*A+p*N,M*x-_*N-p*A,I,L),n.set(m,i-1,z[0]),n.set(m,i,z[1]),Math.abs(M)>Math.abs(_)+Math.abs(p)?(n.set(m+1,i-1,(-A-B*n.get(m,i-1)+p*n.get(m,i))/M),n.set(m+1,i,(-N-B*n.get(m,i)-p*n.get(m,i-1))/M)):(z=Fo(-v-O*n.get(m,i-1),-x-O*n.get(m,i),_,p),n.set(m+1,i-1,z[0]),n.set(m+1,i,z[1]))),F=Math.max(Math.abs(n.get(m,i-1)),Math.abs(n.get(m,i))),f*F*F>1)for(w=m;w<=i;w++)n.set(w,i-1,n.get(w,i-1)/F),n.set(w,i,n.get(w,i)/F)}for(m=0;m<s;m++)if(m<a||m>u)for(w=m;w<s;w++)r.set(m,w,n.get(m,w));for(w=s-1;w>=a;w--)for(m=a;m<=u;m++){for(_=0,D=a;D<=Math.min(w,u);D++)_=_+r.get(m,D)*n.get(D,w);r.set(m,w,_)}}}function Fo(s,e,t,r){let n,i;return Math.abs(t)>Math.abs(r)?(n=r/t,i=t+n*r,[(s+n*e)/i,(e-n*s)/i]):(n=t/r,i=r+n*t,[(n*s+e)/i,(n*e-s)/i])}class $f{constructor(e){if(e=Cr.checkMatrix(e),!e.isSymmetric())throw new Error("Matrix is not symmetric");let t=e,r=t.rows,n=new ve(r,r),i=!0,a,u,f;for(u=0;u<r;u++){let c=0;for(f=0;f<u;f++){let h=0;for(a=0;a<f;a++)h+=n.get(f,a)*n.get(u,a);h=(t.get(u,f)-h)/n.get(f,f),n.set(u,f,h),c=c+h*h}for(c=t.get(u,u)-c,i&=c>0,n.set(u,u,Math.sqrt(Math.max(c,0))),f=u+1;f<r;f++)n.set(u,f,0)}this.L=n,this.positiveDefinite=!!i}isPositiveDefinite(){return this.positiveDefinite}solve(e){e=Cr.checkMatrix(e);let t=this.L,r=t.rows;if(e.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let n=e.columns,i=e.clone(),a,u,f;for(f=0;f<r;f++)for(u=0;u<n;u++){for(a=0;a<f;a++)i.set(f,u,i.get(f,u)-i.get(a,u)*t.get(f,a));i.set(f,u,i.get(f,u)/t.get(f,f))}for(f=r-1;f>=0;f--)for(u=0;u<n;u++){for(a=f+1;a<r;a++)i.set(f,u,i.get(f,u)-i.get(a,u)*t.get(a,f));i.set(f,u,i.get(f,u)/t.get(f,f))}return i}get lowerTriangularMatrix(){return this.L}}class Lf{constructor(e,t={}){e=Cr.checkMatrix(e);let{Y:r}=t;const{scaleScores:n=!1,maxIterations:i=1e3,terminationCriteria:a=1e-10}=t;let u;if(r){if(gr.isAnyArray(r)&&typeof r[0]=="number"?r=ve.columnVector(r):r=Cr.checkMatrix(r),r.rows!==e.rows)throw new Error("Y should have the same number of rows as X");u=r.getColumnVector(0)}else u=e.getColumnVector(0);let f=1,c,h,d,p;for(let v=0;v<i&&f>a;v++)d=e.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),d=d.div(d.norm()),c=e.mmul(d).div(d.transpose().mmul(d).get(0,0)),v>0&&(f=c.clone().sub(p).pow(2).sum()),p=c.clone(),r?(h=r.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0)),h=h.div(h.norm()),u=r.mmul(h).div(h.transpose().mmul(h).get(0,0))):u=c;if(r){let v=e.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0));v=v.div(v.norm());let x=e.clone().sub(c.clone().mmul(v.transpose())),_=u.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0)),y=r.clone().sub(c.clone().mulS(_.get(0,0)).mmul(h.transpose()));this.t=c,this.p=v.transpose(),this.w=d.transpose(),this.q=h,this.u=u,this.s=c.transpose().mmul(c),this.xResidual=x,this.yResidual=y,this.betas=_}else this.w=d.transpose(),this.s=c.transpose().mmul(c).sqrt(),n?this.t=c.clone().div(this.s.get(0,0)):this.t=c,this.xResidual=e.sub(c.mmul(d.transpose()))}}We.AbstractMatrix=ke,We.CHO=$f,We.CholeskyDecomposition=$f,We.DistanceMatrix=bo,We.EVD=Tf;var Zy=We.EigenvalueDecomposition=Tf;We.LU=Co,We.LuDecomposition=Co;var Rf=We.Matrix=ve;We.MatrixColumnSelectionView=My,We.MatrixColumnView=By,We.MatrixFlipColumnView=Ny,We.MatrixFlipRowView=Sy,We.MatrixRowSelectionView=Iy,We.MatrixRowView=Oy,We.MatrixSelectionView=Eo,We.MatrixSubView=Ty,We.MatrixTransposeView=$y,We.NIPALS=Lf,We.Nipals=Lf,We.QR=ru,We.QrDecomposition=ru,We.SVD=Ii,We.SingularValueDecomposition=Ii,We.SymmetricMatrix=si,We.WrapperMatrix1D=Of,We.WrapperMatrix2D=Cr,We.correlation=Wy,We.covariance=Uy;var Pf=We.default=ve;We.determinant=Ao,We.inverse=Ry,We.linearDependencies=zy,We.pseudoInverse=qy,We.solve=If,We.wrap=Ly;const kf=Zy,zf=Rf;Pf.Matrix&&Pf.Matrix;class Vy{constructor(e){q(this,"_errorListener");this._errorListener=e}new({rows:e,columns:t,initial_value:r}={}){return new nu(e,t,r,this._errorListener)}avg({id:e}){return e==null?void 0:e.avg()}col({id:e,column:t}){return e==null?void 0:e.col({column:t})}det({id:e}){return e==null?void 0:e.det()}get({id:e,row:t,column:r}){return e==null?void 0:e.get({row:t,column:r})}inv({id:e}){return e==null?void 0:e.inv()}max({id:e}){return e==null?void 0:e.max()}min({id:e}){return e==null?void 0:e.min()}pow({id:e,power:t}){return e==null?void 0:e.pow({power:t})}row({id:e,row:t}){return e==null?void 0:e.row({row:t})}set({id:e,row:t,column:r,value:n}){e==null||e.set({row:t,column:r,value:n})}sum({id1:e,id2:t}){return e==null?void 0:e.sum({id2:t})}copy({id:e}){return e==null?void 0:e.copy()}diff({id1:e,id2:t}){return e==null?void 0:e.diff({id2:t})}rows({id:e}){return e==null?void 0:e.rows()}columns({id:e}){return e==null?void 0:e.columns()}fill({id:e,value:t,from_row:r,to_row:n,from_column:i,to_column:a}){e==null||e.fill({value:t,from_row:r,to_row:n,from_column:i,to_column:a})}kron({id1:e,id2:t}){return e==null?void 0:e.kron({id2:t})}mode({id:e}){return e==null?void 0:e.mode()}mult({id1:e,id2:t}){return e==null?void 0:e.mult({id2:t})}pinv({id:e}){return e==null?void 0:e.pinv()}rank({id:e}){return e==null?void 0:e.rank()}sort({id:e,column:t,order:r}){e==null||e.sort({column:t,order:r})}trace({id:e}){return e==null?void 0:e.trace()}concat({id1:e,id2:t}){return e==null?void 0:e.concat({id2:t})}median({id:e}){return e==null?void 0:e.median()}add_col({id:e,column:t,array_id:r}){e==null||e.add_col({column:t,array_id:r})}add_row({id:e,row:t,array_id:r}){e==null||e.add_row({row:t,array_id:r})}is_zero({id:e}){return e==null?void 0:e.is_zero()}reshape({id:e,rows:t,columns:r},n){return e==null?void 0:e.reshape({rows:t,columns:r},n)}reverse({id:e}){e==null||e.reverse()}is_binary({id:e}){return e==null?void 0:e.is_binary()}is_square({id:e}){return e==null?void 0:e.is_square()}submatrix({id:e,from_row:t,to_row:r,from_column:n,to_column:i}){return e==null?void 0:e.submatrix({from_row:t,to_row:r,from_column:n,to_column:i})}swap_rows({id:e,row1:t,row2:r}){e==null||e.swap_rows({row1:t,row2:r})}transpose({id:e}){return e==null?void 0:e.transpose()}remove_col({id:e,column:t}){return e==null?void 0:e.remove_col({column:t})}remove_row({id:e,row:t}){return e==null?void 0:e.remove_row({row:t})}eigenvalues({id:e}){return e==null?void 0:e.eigenvalues()}is_diagonal({id:e}){return e==null?void 0:e.is_diagonal()}is_identity({id:e}){return e==null?void 0:e.is_identity()}eigenvectors({id:e}){return e==null?void 0:e.eigenvectors()}is_symmetric({id:e}){return e==null?void 0:e.is_symmetric()}swap_columns({id:e,column1:t,column2:r}){e==null||e.swap_columns({column1:t,column2:r})}is_stochastic({id:e}){return e==null?void 0:e.is_stochastic()}is_triangular({id:e}){return e==null?void 0:e.is_triangular()}elements_count({id:e}){return e==null?void 0:e.elements_count()}is_antidiagonal({id:e}){return e==null?void 0:e.is_antidiagonal()}is_antisymmetric({id:e}){return e==null?void 0:e.is_antisymmetric()}}class nu{constructor(e=0,t=0,r=void 0,n){q(this,"_matrixInstance");q(this,"_errorListener");this._matrixInstance=this._createMatrix(e,t,r),this._errorListener=n}get _matrixArray(){return this._matrixInstance.map(e=>[...e._value])}get _value(){return this._matrixInstance}set _value(e){this._matrixInstance=e}get isMatrix(){return!0}_createMatrix(e,t,r){return Array.from(new Array(e),()=>new it(t,r,this._errorListener))}avg(){let e=0,t=0;for(const n of this._matrixInstance)for(const i of n._value)e+=me(i)?0:i,t+=1;return e/t}col({column:e}){const t=[],r=new it(0,void 0,this._errorListener);if(me(e))return r;for(const n of this._matrixInstance)t.push(n._value[e]);return r._value=t,r}det(){return Cf(this._matrixArray)}get({row:e,column:t}){var r,n;if(!(me(e)||me(t)))return(n=(r=this._matrixInstance[e])==null?void 0:r._value)==null?void 0:n[t]}inv(){const e=xo(this._matrixArray);return this._newMatrix(e)}max(){return Hx(this._matrixArray)}min(){return Qa(this._matrixArray)}pow({power:e}){const t=me(e)?this._matrixArray:Yx(this._matrixArray,e);return this._newMatrix(t)}row({row:e}){return me(e)?new it(0,void 0,this._errorListener):this._matrixInstance[e]}set({row:e,column:t,value:r}){me(e)||me(t)||this._matrixInstance[e].set({index:t,value:r})}sum({id2:e}){const t=hs(this._matrixArray,typeof e=="number"?e:e._matrixArray);return this._newMatrix(t)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:e}){const t=Px(this._matrixArray,typeof e=="number"?e:e._matrixArray);return this._newMatrix(t)}rows(){return this._matrixInstance.length}columns(){return this._matrixArray.length&&this._matrixArray[0].length}fill({value:e,from_row:t,to_row:r,from_column:n,to_column:i}={}){me(t)&&(t=0),me(r)&&(r=this.rows()),me(n)&&(n=0),me(i)&&(i=this.columns());for(const[a,u]of this._matrixInstance.entries())for(const[f]of u._value.entries())a<r&&a>=t&&f>=n&&f<i&&u.set({index:f,value:e})}kron({id2:e}){const t=Lx(this._matrixArray,e._matrixArray);return this._newMatrix(t)}mode(){return Qa(mf(this._matrixArray))}mult({id2:e}){const t=typeof e=="number"?e:e._matrixArray?e._matrixArray:e._value,r=Mi(this._matrixArray,t);return this._newMatrix(r)}pinv(){const e=jx(this._matrixArray);return this._newMatrix(e)}rank(){return this._matrixRank(this._matrixArray)}sort({column:e,order:t=Jn.ascending}={}){me(e)&&(e=0),this._matrixInstance.sort((r,n)=>{const i=r._value[e],a=n._value[e];return t!==Jn.descending?i-a:a-i})}trace(){return Wx(this._matrixArray)}concat({id2:e}){for(const t of e._value)this._matrixInstance.push(t);return this}median(){return Af(this._matrixArray)}add_col({column:e,array_id:t}={}){me(e)&&(e=this.columns());for(const[r,n]of this._matrixInstance.entries())n.insert({index:e,value:t?t._value[r]:void 0})}add_row({row:e,array_id:t}){me(e)&&(e=this.rows()),this._matrixInstance.splice(e,0,t||new it(this.columns(),void 0,this._errorListener))}is_zero(){return this._matrixArray.every(e=>e.every(t=>t===0))}reshape({rows:e=0,columns:t=0},r){if(e*t!==this.columns()*this.rows()){this._errorListener.addError(ct.matrixRehapeErr,r,Ze.Error);return}const n=Ox(this._matrixArray,[e,t]);this._matrixInstance=n.map(i=>{const a=new it(0,void 0,this._errorListener);return a._value=[...i],a})}reverse(){this._matrixInstance.reverse();for(const e of this._matrixInstance)e.reverse()}is_binary(){return this._matrixArray.every(e=>e.every(t=>t===0||t===1))}is_square(){return this.rows()===this.columns()}submatrix({from_row:e,to_row:t,from_column:r,to_column:n}={}){me(e)&&(e=0),me(t)&&(t=this.rows()),me(r)&&(r=0),me(n)&&(n=this.columns());const i=this._matrixArray.splice(e,t),a=[];for(const u of i)a.push(u.splice(r,n));return this._newMatrix(a)}swap_rows({row1:e,row2:t}){if(me(e)||me(t))return;const r=this._matrixInstance[e],n=this._matrixInstance[t];this._matrixInstance[e]=n,this._matrixInstance[t]=r}transpose(){const e=yf(this._matrixArray);return this._newMatrix(e)}remove_col({column:e}={}){me(e)&&(e=this.columns());const t=[];for(const n of this._matrixInstance){const i=n._value.splice(e,1);t.push(i[0])}const r=new it(0,void 0,this._errorListener);return r._value=t,r}remove_row({row:e}={}){return me(e)&&(e=this.rows()),this._matrixInstance.splice(e,1)[0]}eigenvalues(){const e=new kf(new zf(this._matrixArray)),t=new it(0,void 0,this._errorListener);return t._value=e.realEigenvalues,t}is_diagonal(){const e=this.rows(),t=this.columns();if(e!==t)return!1;const r=this._matrixArray;for(let n=0;n<e;n++)for(let i=0;i<t;i++)if(n!==i&&r[n][i]!==0)return!1;return!0}is_identity(){const e=this.rows(),t=this.columns();if(e!==t)return!1;const r=this._matrixArray;for(let n=0;n<e;n++)for(let i=0;i<t;i++)if(n!==i&&r[n][i]!==0||n===i&&r[n][i]!==1)return!1;return!0}eigenvectors(){const e=new kf(new zf(this._matrixArray));return this._newMatrix(e.eigenvectorMatrix.to2DArray())}is_symmetric(){const e=this.rows(),t=this.columns();if(e!==t)return!1;const r=this._matrixArray;for(let n=0;n<e;n++)for(let i=n+1;i<t;i++)if(r[n][i]!==r[i][n])return!1;return!0}swap_columns({column1:e,column2:t}){if(!(me(e)||me(t)))for(const r of this._matrixInstance){const n=r._value[e],i=r._value[t];r.set({index:e,value:i}),r.set({index:t,value:n})}}is_stochastic(){const e=this._matrixArray;for(let t=0;t<e.length;t++){let r=0;for(let n=0;n<e[t].length;n++){if(e[t][n]<0)return!1;r+=e[t][n]}if(Math.abs(r-1)>Number.EPSILON)return!1}return!0}is_triangular(){const e=this.rows(),t=this.columns();return e!==t?!1:this._isUpperTriangular(e)||this._isLowerTriangular(e)}elements_count(){return Ix(this._matrixArray)}is_antidiagonal(){const e=this.rows(),t=this.columns();if(e!==t)return!1;const r=this._matrixArray;for(let n=0;n<e;n++)for(let i=0;i<e;i++)if(n+i!==e-1&&r[n][i]!==0)return!1;return!0}is_antisymmetric(){const e=this.rows(),t=this.columns();if(e!==t)return!1;const r=this._matrixArray;for(let n=0;n<e;n++)for(let i=0;i<e;i++)if(n!==i&&r[n][i]!==-r[i][n])return!1;return!0}_isUpperTriangular(e){const t=this._matrixArray;for(let r=1;r<e;r++)for(let n=0;n<r;n++)if(t[r][n]!==0)return!1;return!0}_isLowerTriangular(e){const t=this._matrixArray;for(let r=0;r<e-1;r++)for(let n=r+1;n<e;n++)if(t[r][n]!==0)return!1;return!0}_newMatrix(e){const t=new nu(0,0,void 0,this._errorListener);return t._value=e.map(r=>{const n=new it(0,void 0,this._errorListener);return n._value=[...r],n}),t}_matrixRank(e){let t=0;const r=e.length,n=e[0].length,i=[...e].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let u=a;for(;u<r&&i[u][a]===0;)u++;if(u===r)continue;if(u!==a){const c=i[u];i[u]=i[a],i[a]=c}const f=i[a][a];for(let c=0;c<n;c++)i[a][c]/=f;for(let c=a+1;c<r;c++){const h=i[c][a];i[c]=i[c].map((d,p)=>d-h*i[a][p]),i[c][a]=0}}for(let a=0;a<r;a++)i[a].some(u=>Number(u.toFixed(8))!==0)&&t++;return t}}class Gy{constructor(e){q(this,"_variables");q(this,"_cacheData");this._variables=e,this._cacheData={}}change({timeframe:e},t){if(!e)return!0;const r=pn(e),n=pn(this._variables.timeframe.period);if(r<n)return!0;const i=`change_${t}`,a=this._cacheData[i],u=this._variables.time;if(a){if(a.offset){if(a.currentTime+a.offset<=u)return this._cacheData[i]={currentTime:u,offset:0},!0}else if(a.currentTime+r*1e3<=u)return this._cacheData[i]={currentTime:u,offset:0},!0}else{const f=this._calcTimeOffset(u,e);return this._cacheData[i]={currentTime:u,offset:f},!1}return!1}in_seconds({timeframe:e}={}){return pn(e||this._variables.timeframe.period)}from_seconds({seconds:e=0}){const t=e*1e3,r=ot.duration(t);if(r.years())return"12M";const i=r.asMonths();if(go(i))return`${i}M`;const a=r.asWeeks();if(go(a))return`${a}M`;const u=r.asDays();if(u>=1)return`${Math.ceil(u)}D`;const f=r.asMinutes();if(f>=1)return`${Math.ceil(f)}`;const c=r.asSeconds();return c<=1?"1S":c<=5?"5S":c<=10?"10S":c<=15?"15S":c<=30?"30S":"1"}_calcTimeOffset(e,t){let r=0;if(t.includes("W")){const u=ot(e).day();t="1D",u!==1&&(r=(8-u)*60*60*24*1e3)}else if(t.includes("M")){const u=ot(e).date();t="1D";const f=ot(e).daysInMonth();u!==1&&(r=(f-u+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(e,t),i=pn(t)*1e3,a=e-n-Math.floor((e-n)/i)*i;return r?r-a:a}}class Xy{constructor(e,t){q(this,"_errorListener");q(this,"_intlNumberFormatter");q(this,"_precision");this._errorListener=e,this._precision=t,this._intlNumberFormatter=new Intl.NumberFormat("en",{notation:"compact"})}pos({source:e="",str:t=""}){return e==null?void 0:e.indexOf(t)}trim({source:e=""}){return e==null?void 0:e.trim()}lower({source:e=""}){return e==null?void 0:e.toLocaleLowerCase()}match({source:e="",regex:t=""}){const r=e==null?void 0:e.match(new RegExp(t));return r?r[0]:""}split({string:e="",separator:t=""}){const r=e==null?void 0:e.split(t),n=new it;return n._value=r||[],n}upper({source:e=""}){return e==null?void 0:e.toLocaleUpperCase()}format({formatString:e=""},t){return this._strFormat(e,t)}length({string:e=""}){return e==null?void 0:e.length}repeat({source:e="",repeat:t,separator:r=""},n){if(me(t)){this._errorListener.addError(ct.arrLenErr,n,Ze.Error);return}return Array.from(new Array(t),()=>e).join(r)}replace({source:e="",target:t="",replacement:r="",occurrence:n}){me(n)&&(n=0);let i=-1;for(let a=0;a<n+1&&(i=e.indexOf(t,i+1),i!==-1);a++);return i!==-1?e.substring(0,i)+r+e.substring(i+t.length):e}contains({source:e="",str:t=""}){return e==null?void 0:e.includes(t)}endswith({source:e="",str:t=""}){return e==null?void 0:e.endsWith(t)}tonumber({string:e=""}){if(/[^\d.]/.test(e))return;const t=parseFloat(e);return isNaN(t)?void 0:t}tostring({value:e,format:t}){if(e===void 0)return"NaN";if(typeof e=="object"){if(e.isArray)return this._arrToStr(e._value,t);if(e.isMatrix){const r=[];for(const n of e._matrixArray)r.push(this._arrToStr(n,t));return r.join(`
62
- `)}}if(typeof e=="string")return e;if(typeof e=="boolean")return String(e);if(typeof e=="number")return String(this._toStringFormat(e,t))}_arrToStr(e,t){return`[${e.map(n=>typeof n=="number"?this._toStringFormat(n,t):n).toString()}]`}substring({source:e="",begin_pos:t=0,end_pos:r}){return me(t)&&(t=0),me(r)&&(r=void 0),e==null?void 0:e.substring(t,r)}startswith({source:e="",str:t=""}){return e==null?void 0:e.startsWith(t)}format_time({time:e,format:t="yyyy-MM-dd'T'HH:mm:ssZ",timezone:r}){return me(e)&&(e=0),Kr(e,r).format(t)}replace_all({source:e="",target:t="",replacement:r=""}){return e==null?void 0:e.replace(new RegExp(t,"g"),r)}_toStringFormat(e,t){if(!t)return e;switch(t){case Je.mintick:return e.toFixed(this._precision);case Je.price:return`${e}%`;case Je.volume:return this._intlNumberFormatter.format(Math.round(e));default:const[r,n]=t.split(".");let[i,a=""]=String(e).split(".");if(r.includes("#")?i=r.replace(/#/,i).replace(/#/g,""):i=`${r}${i}`,n&&n.includes("#")){const u=n.split("#").length-1;a=`${a.substring(0,u)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${i}.${a}`:i}}_formatNumber(e,t){if(!t)return e;switch(t){case"integer":return String(Math.round(e));case"currency":return`$${e}`;case"percent":return`${e*100}%`;default:const r=t.split(".")[1],n=r?r.length:0;return parseFloat(e.toFixed(n))}}_strFormat(e,t){let r=e;return t.forEach((n,i)=>{if(typeof n=="number"){const a=`\\{\\s*${i}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,u=e.match(new RegExp(a));if(u){const f=u[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(n,f)))}else r=r.replace(new RegExp(`\\{${i}\\}`,"g"),String(n))}else r=r.replace(new RegExp(`\\{${i}\\}`,"g"),n)}),r}}class Qy{constructor(e){q(this,"_errorListener");this._errorListener=e}new(){return new iu(this._errorListener)}copy({id:e}){return e==null?void 0:e.copy()}get({id:e,key:t}){return e==null?void 0:e.get({key:t})}put({id:e,key:t,value:r}){return e==null?void 0:e.put({key:t,value:r})}keys({id:e}){return e==null?void 0:e.keys()}size({id:e}){return e==null?void 0:e.size()}clear({id:e}){e==null||e.clear()}remove({id:e,key:t}){return e==null?void 0:e.remove({key:t})}values({id:e}){return e==null?void 0:e.values()}put_all({id:e,id2:t}){e==null||e.put_all({id2:t})}contains({id:e,key:t}){return e==null?void 0:e.contains({key:t})}}class iu{constructor(e){q(this,"_errorListener");q(this,"_mapInstance");this._errorListener=e,this._mapInstance=new Map}get isMap(){return!0}_copyMap(e){const t=new iu(this._errorListener);return t._mapInstance=new Map(e.entries()),t}copy(){return this._copyMap(this._mapInstance)}get({key:e}){return this._mapInstance.get(e)}put({key:e,value:t}){return this._mapInstance.set(e,t)}keys(){const e=new it(0,void 0,this._errorListener);return e._value=[...this._mapInstance.keys()],e}size(){return this._mapInstance.size}clear(){this._mapInstance.clear()}remove({key:e}){const t=this._mapInstance.get(e);return this._mapInstance.delete(e),t||void 0}values(){const e=new it(0,void 0,this._errorListener);return e._value=[...this._mapInstance.values()],e}put_all({id2:e}){this._mapInstance=new Map([...this._mapInstance,...e._mapInstance])}contains({key:e}){return this._mapInstance.has(e)}}class Jy{constructor(e){q(this,"_variables");this._variables=e}new({price:e,time:t,index:r}){return new Ti(e,r,t)}now({price:e}){const{time:t,bar_index:r}=this._variables;return new Ti(e,r,t)}copy({id:e}){return e==null?void 0:e.copy()}from_index({price:e,index:t}){return new Ti(e,t)}from_time({price:e,time:t}){return new Ti(e,void 0,t)}}class Ti{constructor(e,t,r){q(this,"_index");q(this,"_price");q(this,"_time");this._index=t,this._price=e,this._time=r}get index(){return this._index}get price(){return this._price}get time(){return this._time}copy(){return new Ti(this._price,this._index,this._time)}}class eD{constructor(e,t){q(this,"_variables");q(this,"_errorListener");q(this,"_defaultLabel",{text:"",xloc:bt.bar_index,yloc:Gr.price,size:ar.normal,style:gt.styleLabelDown,textalign:je.alignCenter});this._variables=e,this._errorListener=t}new(e,t){const{time:r,high:n,low:i,bar_index:a}=this._variables,u=`label_${t}_${a}`,f={...this._defaultLabel,...e,id:u,time:r};e.point&&(f.x=f.xloc===bt.bar_index?e.point.index:e.point.time,f.y=e.point.price),f.yloc===Gr.abovebar?f.y=n:f.yloc===Gr.belowbar&&(f.y=i),this._verfiyArgs(e,t);const c=new ps(u,this._variables,this._errorListener);return t.startsWith("export")||this._variables.label.add(u,f,c),c}_verfiyArgs(e,t){const{xloc:r,yloc:n,style:i,size:a,textalign:u,text_font_family:f}=e,c="label.new";this._paramVerfiy(i,t,c,Object.values(gt),"style"),this._paramVerfiy(r,t,c,Object.values(bt),"xloc"),this._paramVerfiy(n,t,c,Object.values(Gr),"yloc"),this._paramVerfiy(a,t,c,Object.values(ar),"size"),this._paramVerfiy(u,t,c,[je.alignLeft,je.alignCenter,je.alignRight],"textalign"),this._paramVerfiy(f,t,c,Object.values(ei),"text_font_family")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}label(e,t){return e.x?e.x:new ps(t,this._variables,this._errorListener)}copy({id:e},t){return e==null?void 0:e.copy(t)}get_x({id:e},t){return e==null?void 0:e.get_x(t)}get_y({id:e},t){return e==null?void 0:e.get_y(t)}set_x({id:e,...t},r){e==null||e.set_x(t,r)}set_y({id:e,...t},r){e==null||e.set_y(t,r)}delete({id:e}){e==null||e.delete()}get_text({id:e},t){return e==null?void 0:e.get_text(t)}set_xy({id:e,...t},r){e==null||e.set_xy(t,r)}set_size({id:e,...t},r){e==null||e.set_size(t,r)}set_xloc({id:e,...t},r){e==null||e.set_xloc(t,r)}set_yloc({id:e,...t},r){e==null||e.set_yloc(t,r)}set_style({id:e,...t},r){e==null||e.set_style(t,r)}set_color({id:e,...t},r){e==null||e.set_color(t,r)}set_tooltip({id:e,...t},r){e==null||e.set_tooltip(t,r)}set_point({id:e,...t},r){e==null||e.set_point(t,r)}set_text({id:e,...t},r){e==null||e.set_text(t,r)}set_textcolor({id:e,...t},r){e==null||e.set_textcolor(t,r)}set_textalign({id:e,...t},r){e==null||e.set_textalign(t,r)}set_text_font_family({id:e,...t},r){e==null||e.set_text_font_family(t,r)}}class ps{constructor(e,t,r){q(this,"_id");q(this,"_variables");q(this,"_errorListener");this._id=e,this._variables=t,this._errorListener=r}copy(e){const t=`label_${e}_${this._variables.bar_index}`,r=this._getLabel(e),n=new ps(t,this._variables,this._errorListener);if(r){const i={...r,id:t};this._variables.label.add(t,i,n)}return n}get_x(e){var t;return(t=this._getLabel(e))==null?void 0:t.x}get_y(e){var t;return(t=this._getLabel(e))==null?void 0:t.y}set_x({x:e},t){const r=this._getLabel(t);r&&(r.x=e)}set_y({y:e},t){const r=this._getLabel(t);r&&(r.y=e)}delete(){this._variables.label.delete(this._id)}set_xy({x:e,y:t},r){const n=this._getLabel(r);n&&(n.x=e,n.y=t)}get_text(e){var t;return(t=this._getLabel(e))==null?void 0:t.text}set_size({size:e},t){const r=this._getLabel(t);r&&(r.size=e),this._paramVerfiy(e,t,"label.set_size",Object.values(ar),"size")}set_text({text:e},t){const r=this._getLabel(t);r&&(r.text=e)}set_xloc({x:e,xloc:t},r){const n=this._getLabel(r);n&&(n.x=e,n.xloc=t,this._paramVerfiy(t,r,"label.set_xloc",Object.values(bt),"xloc"))}set_yloc({yloc:e},t){const r=this._getLabel(t),{high:n,low:i}=this._variables;r&&(r.yloc=e,e===Gr.abovebar?r.y=n:e===Gr.belowbar&&(r.y=i),this._paramVerfiy(e,t,"label.set_yloc",Object.values(Gr),"yloc"))}set_color({color:e},t){const r=this._getLabel(t);r&&(r.color=e)}set_point({point:e},t){const r=this._getLabel(t);r&&(r.x=r.xloc===bt.bar_index?e==null?void 0:e.index:e==null?void 0:e.time,r.y=e==null?void 0:e.price)}set_style({style:e},t){const r=this._getLabel(t);r&&(r.style=e),this._paramVerfiy(e,t,"label.set_style",Object.values(gt),"style")}set_tooltip({tooltip:e},t){const r=this._getLabel(t);r&&(r.tooltip=e)}set_textalign({textalign:e},t){const r=this._getLabel(t);r&&(r.textalign=e),this._paramVerfiy(e,t,"label.set_textalign",[je.alignLeft,je.alignCenter,je.alignRight],"textalign")}set_textcolor({textcolor:e},t){const r=this._getLabel(t);r&&(r.textcolor=e)}set_text_font_family({text_font_family:e},t){const r=this._getLabel(t);r&&(r.text_font_family=e),this._paramVerfiy(e,t,"label.set_text_font_family",Object.values(ei),"text_font_family")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}_getLabel(e){const t=this._variables.label.get(this._id);return t||console.log(`错误${e}: label 不存在`),t}}const tD={freq_all:Zr.freqAll,freq_once_per_bar:Zr.freqOncePerBar,freq_once_per_bar_close:Zr.freqOncePerBarClose},rD={gaps_off:ss.gapsOff,gaps_on:ss.gapsOn,lookahead_off:ss.lookaheadOff,lookahead_on:ss.lookaheadOn},$i={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#FF5252",silver:"#B2B5BE",teal:"#00897B",white:"#FFFFFF",yellow:"#FFEB3B"},qf={AUD:"AUD",BTC:"BTC",CAD:"CAD",CHF:"CHF",ETH:"ETH",EUR:"EUR",GBP:"GBP",HKD:"HKD",INR:"INR",JPY:"JPY",KRW:"KRW",MYR:"MYR",NOK:"NOK",NONE:"NONE",NZD:"NZD",RUB:"RUB",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",USDT:"USDT",ZAR:"ZAR"},nD={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Uf={all:[Vt.dataWindow,Vt.pane,Vt.priceScale,Vt.statusLine],data_window:[Vt.dataWindow],none:[],pane:[Vt.pane],price_scale:[Vt.priceScale],status_line:[Vt.statusLine]},iD={both:Vr.both,left:Vr.left,none:Vr.none,right:Vr.right},sD={inherit:Je.inherit,mintick:Je.mintick,percent:Je.percent,price:Je.price,volume:Je.volume},oD={style_solid:qs.styleSolid,style_dashed:qs.styleDashed,style_dotted:qs.styleDotted},aD={style_arrowdown:gt.styleArrowdown,style_arrowup:gt.styleArrowup,style_circle:gt.styleCircle,style_cross:gt.styleCross,style_diamond:gt.styleDiamond,style_flag:gt.styleFlag,style_label_center:gt.styleLabelCenter,style_label_down:gt.styleLabelDown,style_label_left:gt.styleLabelLeft,style_label_lower_left:gt.styleLabelLowerLeft,style_label_lower_right:gt.styleLabelLowerRight,style_label_right:gt.styleLabelRight,style_label_up:gt.styleLabelUp,style_label_upper_left:gt.styleLabelUpperLeft,style_label_upper_right:gt.styleLabelUpperRight,style_none:gt.styleNone,style_square:gt.styleSquare,style_text_outline:gt.styleTextOutline,style_triangledown:gt.styleTriangledown,style_triangleup:gt.styleTriangleup,style_xcross:gt.styleXcross},uD={style_arrow_both:qt.styleArrowBoth,style_arrow_left:qt.styleArrowLeft,style_arrow_right:qt.styleArrowRight,style_dashed:qt.styleDashed,style_dotted:qt.styleDotted,style_solid:qt.styleSolid},lD={abovebar:vn.abovebar,absolute:vn.absolute,belowbar:vn.belowbar,bottom:vn.bottom,top:vn.top},cD={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},fD={style_area:Or.styleArea,style_areabr:Or.styleAreabr,style_circles:Or.styleCircles,style_columns:Or.styleColumns,style_cross:Or.styleCross,style_histogram:Or.styleHistogram,style_line:Or.styleLine,style_linebr:Or.styleLinebr,style_stepline:Or.styleStepline,style_stepline_diamond:Or.styleSteplineDiamond,style_steplinebr:Or.styleSteplinebr},hD={bottom_center:br.bottomCenter,bottom_left:br.bottomLeft,bottom_right:br.bottomRight,middle_center:br.middleCenter,middle_left:br.middleLeft,middle_right:br.middleRight,top_center:br.topCenter,top_left:br.topLeft,top_right:br.topRight},dD={left:Us.left,none:Us.none,right:Us.right},pD={arrowdown:_r.arrowdown,arrowup:_r.arrowup,circle:_r.circle,cross:_r.cross,diamond:_r.diamond,flag:_r.flag,labeldown:_r.labeldown,labelup:_r.labelup,square:_r.square,triangledown:_r.triangledown,triangleup:_r.triangleup,xcross:_r.xcross},_D={auto:ar.auto,huge:ar.huge,large:ar.large,normal:ar.normal,small:ar.small,tiny:ar.tiny},vD={cash:Rt.cash,fixed:Rt.fixed,percent_of_equity:Rt.percentOfEquity,commission:{cash_per_contract:Ir.cashPerContract,cash_per_order:Ir.cashPerOrder,percent:Ir.percent},direction:{all:mt.all,long:mt.long,short:mt.short},oca:{cancel:gn.cancel,none:gn.none,reduce:gn.reduce}},gD={align_bottom:je.alignBottom,align_center:je.alignCenter,align_left:je.alignLeft,align_right:je.alignRight,align_top:je.alignTop,wrap_auto:je.wrapAuto,wrap_none:je.wrapNone},mD={bar_index:bt.bar_index,bar_time:bt.bar_time},xD={abovebar:Gr.abovebar,belowbar:Gr.belowbar,price:Gr.price},yD={actual:Ws.actual,estimate:Ws.estimate,standardized:Ws.standardized};class Wf{constructor(){q(this,"adjustment",{dividends:zs.dividends,none:zs.none,splits:zs.splits});q(this,"alert",tD);q(this,"barmerge",rD);q(this,"color",$i);q(this,"currency",qf);q(this,"dayofweek",nD);q(this,"earnings",yD);q(this,"display",Uf);q(this,"extend",iD);q(this,"font",{family_default:ei.familyDefault,family_monospace:ei.familyMonospace});q(this,"format",sD);q(this,"hline",oD);q(this,"label",aD);q(this,"line",uD);q(this,"location",lD);q(this,"math",cD);q(this,"order",{ascending:Jn.ascending,descending:Jn.descending});q(this,"plot",fD);q(this,"position",hD);q(this,"scale",dD);q(this,"session",{extended:yi.extended,regular:yi.regular});q(this,"shape",pD);q(this,"size",_D);q(this,"splits",{denominator:"denominator",numerator:"numerator"});q(this,"strategy",vD);q(this,"text",gD);q(this,"xloc",mD);q(this,"yloc",xD)}updateData(){}}class DD{constructor(e,t){q(this,"_variables");q(this,"_errorListener");q(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:bt.bar_index,line_color:$i.blue,line_style:qt.styleSolid,line_width:1});this._variables=e,this._errorListener=t}new(e,t){var a;const r=`polyline_${t}_${this._variables.bar_index}`,n=Object.assign({},this._defaultPolyline,e,{id:r,points:(a=e.points)==null?void 0:a._value.map(u=>({time:u.time,index:u.index,price:u.price}))}),i=new Hf(r,this._variables);return this._verfiyArgs(e,t),t.startsWith("export")||this._variables.polyline.add(r,n,i),i}_verfiyArgs(e,t){const{line_style:r,xloc:n}=e,i="polyline.new";this._paramVerfiy(r,t,i,Object.values(qt),"line_style"),this._paramVerfiy(n,t,i,Object.values(bt),"xloc")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}delete({id:e}){e&&e.delete()}}class Hf{constructor(e,t){q(this,"_id");q(this,"_variables");this._variables=t,this._id=e}delete(){this._variables.polyline.delete(this._id)}}class wD{constructor(e,t){q(this,"_variables");q(this,"_errorListener");q(this,"_defaultLine",{xloc:bt.bar_index,extend:Vr.none,style:qt.styleSolid});this._variables=e,this._errorListener=t}new({first_point:e,second_point:t,...r},n){const i=`line_${n}_${this._variables.bar_index}`,a={...this._defaultLine,...r,id:i};if(e&&t){const f=a.xloc===bt.bar_index?e.index:e.time,c=a.xloc===bt.bar_index?t.index:t.time;Object.assign(a,{x1:f,y1:e.price,x2:c,y2:t.price})}this._verfiyArgs(r,n);const u=new _s(i,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(i,a,u),u}_verfiyArgs(e,t){const{extend:r,xloc:n,style:i}=e,a="line.new";this._paramVerfiy(i,t,a,Object.values(qt),"style"),this._paramVerfiy(r,t,a,Object.values(Vr),"extend"),this._paramVerfiy(n,t,a,Object.values(bt),"xloc")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}line(e,t){return e.x?e.x:new _s(t,this._variables,this._errorListener)}copy({id:e},t){return e==null?void 0:e.copy(t)}delete({id:e}){e==null||e.delete()}get_x1({id:e},t){return e==null?void 0:e.get_x1(t)}get_x2({id:e},t){return e==null?void 0:e.get_x2(t)}get_y1({id:e},t){return e==null?void 0:e.get_y1(t)}get_y2({id:e},t){return e==null?void 0:e.get_y2(t)}set_x1({id:e,...t},r){e==null||e.set_x1(t,r)}set_x2({id:e,...t},r){e==null||e.set_x2(t,r)}set_y1({id:e,...t},r){e==null||e.set_y1(t,r)}set_y2({id:e,...t},r){e==null||e.set_y2(t,r)}set_xy1({id:e,...t},r){e==null||e.set_xy1(t,r)}set_xy2({id:e,...t},r){e==null||e.set_xy2(t,r)}set_xloc({id:e,...t},r){e==null||e.set_xloc(t,r)}get_price({id:e,...t},r){return e==null?void 0:e.get_price(t,r)}set_color({id:e,...t},r){e==null||e.set_color(t,r)}set_style({id:e,...t},r){e==null||e.set_style(t,r)}set_width({id:e,...t},r){e==null||e.set_width(t,r)}set_extend({id:e,...t},r){e==null||e.set_extend(t,r)}set_first_point({id:e,...t},r){e==null||e.set_first_point(t,r)}set_second_point({id:e,...t},r){e==null||e.set_second_point(t,r)}}class _s{constructor(e,t,r){q(this,"_variables");q(this,"_id");q(this,"_errorListener");this._id=e,this._variables=t,this._errorListener=r}get data(){return this._variables.line.get(this._id)}copy(e){const t=`line_${e}_${this._variables.bar_index}`,r=this._getLine(e),n=new _s(t,this._variables,this._errorListener);return r&&this._variables.line.add(t,{...r,id:t},n),n}delete(){this._variables.line.delete(this._id)}get_price({x:e},t){const r=this._getLine(t);if(e===void 0)return e;if(r&&r.xloc===bt.bar_index){const{x1:n,y1:i,x2:a,y2:u}=r;return n===void 0||a===void 0||i===void 0||u===void 0?void 0:(u-i)/(a-n)*(e-n)+i}}get_x1(e){var t;return(t=this._getLine(e))==null?void 0:t.x1}get_x2(e){var t;return(t=this._getLine(e))==null?void 0:t.x2}get_y1(e){var t;return(t=this._getLine(e))==null?void 0:t.y1}get_y2(e){var t;return(t=this._getLine(e))==null?void 0:t.y2}set_x1({x:e},t){const r=this._getLine(t);r&&(r.x1=e)}set_x2({x:e},t){const r=this._getLine(t);r&&(r.x2=e)}set_y1({y:e},t){const r=this._getLine(t);r&&(r.y1=e)}set_y2({y:e},t){const r=this._getLine(t);r&&(r.y2=e)}set_xy1({x:e,y:t},r){const n=this._getLine(r);n&&(n.x1=e,n.y1=t)}set_xy2({x:e,y:t},r){const n=this._getLine(r);n&&(n.x2=e,n.y2=t)}set_xloc({xloc:e,x1:t,x2:r},n){const i=this._getLine(n);i&&(i.xloc=e,i.x1=t,i.x2=r,this._paramVerfiy(e,n,"line.set_xloc",Object.values(bt),"xloc"))}set_color({color:e},t){const r=this._getLine(t);r&&(r.color=e)}set_style({style:e},t){const r=this._getLine(t);r&&(r.style=e,this._paramVerfiy(e,t,"line.set_style",Object.values(qt),"style"))}set_width({width:e},t){const r=this._getLine(t);r&&(r.width=e)}set_extend({extend:e},t){const r=this._getLine(t);r&&(r.extend=e,this._paramVerfiy(e,t,"line.set_extend",Object.values(Vr),"extend"))}set_first_point({point:e},t){const r=this._getLine(t);if(r){const{index:n,time:i,price:a}=e||{},u=r.xloc===bt.bar_index?n:i,f=a;u&&(r.x1=u),f&&(r.y1=f)}}set_second_point({point:e},t){const r=this._getLine(t);if(r){const{index:n,time:i,price:a}=e||{},u=r.xloc===bt.bar_index?n:i,f=a;u&&(r.x2=u),f&&(r.y2=f)}}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}_getLine(e){const t=this._variables.line.get(this._id);return t||console.log(`${e}: line 不存在`),t}}class bD{constructor(e){q(this,"_variables");this._variables=e}new({line1:e,line2:t,color:r},n){const i=`linefill_${n}_${this._variables.bar_index}`,a=e==null?void 0:e.data,u=t==null?void 0:t.data;a&&(a.linefills=a.linefills||[],a.linefills.push(i)),u&&(u.linefills=u.linefills||[],u.linefills.push(i));const f=new Bo(this._variables,i,e,t);return n.startsWith("export")||(a||u)&&this._variables.linefill.add(i,{line1:a,line2:u,color:r,id:i},f),f}delete({id:e}){e==null||e.delete()}get_line1({id:e}){return e==null?void 0:e.get_line1()}get_line2({id:e}){return e==null?void 0:e.get_line2()}set_color({id:e,...t}){e==null||e.set_color(t)}}class Bo{constructor(e,t,r,n){q(this,"_id");q(this,"_line1");q(this,"_line2");q(this,"_variables");this._variables=e,this._id=t,this._line1=r,this._line2=n}linefill(e,t){return e.x?e.x:new Bo(this._variables,t)}delete(){var t,r;const e=this._variables.linefill.get(this._id);if(e){const{line1:n,line2:i}=e;n&&(n.linefills=(t=n.linefills)==null?void 0:t.filter(a=>a!==this._id)),i&&(i.linefills=(r=i.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id)}get_line1(){return this._line1}get_line2(){return this._line2}set_color({color:e}){const t=this._variables.linefill.get(this._id);t&&(t.color=e)}}class ED{constructor(e,t){q(this,"_variables");q(this,"_errorListener");q(this,"_defaultBox",{border_color:$i.blue,border_width:1,bgcolor:$i.blue,xloc:bt.bar_index,extend:Vr.none,style:qt.styleSolid,text:"",text_size:ar.auto,text_color:$i.black,text_halign:je.alignCenter,text_valign:je.alignCenter,text_wrap:je.wrapNone});this._variables=e,this._errorListener=t}box({x:e},t){return e===void 0?new vs(this._variables,t,this._errorListener):e}new({top_left:e,bottom_right:t,...r},n){const i=`box_${n}_${this._variables.bar_index}`,a={...this._defaultBox,...r,id:i};if(e){const{price:f,time:c,index:h}=e;a.top=f,a.left=a.xloc===bt.bar_index?h:c}if(t){const{price:f,time:c,index:h}=t;a.bottom=f,a.right=a.xloc===bt.bar_index?h:c}this._verfiyArgs(r,n);const u=new vs(this._variables,i,this._errorListener);return n.startsWith("export")||this._variables.box.add(i,a,u),u}_verfiyArgs(e,t){const{border_style:r,extend:n,xloc:i,text_size:a,text_halign:u,text_valign:f,text_wrap:c,text_font_family:h}=e,d="box.new";this._paramVerfiy(r,t,d,[qt.styleDashed,qt.styleDotted,qt.styleSolid],"border_style"),this._paramVerfiy(n,t,d,Object.values(Vr),"extend"),this._paramVerfiy(i,t,d,Object.values(bt),"xloc"),this._paramVerfiy(a,t,d,Object.values(ar),"text_size"),this._paramVerfiy(u,t,d,[je.alignLeft,je.alignCenter,je.alignRight],"text_halign"),this._paramVerfiy(f,t,d,[je.alignBottom,je.alignCenter,je.alignTop],"text_valign"),this._paramVerfiy(c,t,d,[je.wrapAuto,je.wrapNone],"text_wrap"),this._paramVerfiy(h,t,d,Object.values(ei),"text_font_family")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}copy({id:e},t){return e==null?void 0:e.copy(t)}delete({id:e}){e==null||e.delete()}get_top({id:e}){return e==null?void 0:e.get_top()}get_bottom({id:e}){return e==null?void 0:e.get_bottom()}get_left({id:e}){return e==null?void 0:e.get_left()}get_right({id:e}){return e==null?void 0:e.get_right()}set_top({id:e,...t}){e==null||e.set_top(t)}set_bottom({id:e,...t}){e==null||e.set_bottom(t)}set_left({id:e,...t}){e==null||e.set_left(t)}set_right({id:e,...t}){e==null||e.set_right(t)}set_extend({id:e,...t},r){e==null||e.set_extend(t,r)}set_bgcolor({id:e,...t}){e==null||e.set_bgcolor(t)}set_border_color({id:e,...t}){e==null||e.set_border_color(t)}set_border_width({id:e,...t}){e==null||e.set_border_width(t)}set_border_style({id:e,...t},r){e==null||e.set_border_style(t,r)}set_lefttop({id:e,...t}){e==null||e.set_lefttop(t)}set_rightbottom({id:e,...t}){e==null||e.set_rightbottom(t)}set_text_size({id:e,...t},r){e==null||e.set_text_size(t,r)}set_text_wrap({id:e,...t},r){e==null||e.set_text_wrap(t,r)}set_text_color({id:e,...t}){e==null||e.set_text_color(t)}set_text_halign({id:e,...t},r){e==null||e.set_text_halign(t,r)}set_text_valign({id:e,...t},r){e==null||e.set_text_valign(t,r)}set_top_left_point({id:e,...t}){e==null||e.set_top_left_point(t)}set_bottom_right_point({id:e,...t}){e==null||e.set_bottom_right_point(t)}set_text_font_family({id:e,...t},r){e==null||e.set_text_font_family(t,r)}}class vs{constructor(e,t,r){q(this,"_id");q(this,"_variables");q(this,"_errorListener");this._variables=e,this._id=t,this._errorListener=r}copy(e){const t=`box_${e}_${this._variables.bar_index}`,r=this._getBox(),n=new vs(this._variables,t,this._errorListener);return r&&this._variables.box.add(t,{...r,id:t},n),n}delete(){this._variables.box.delete(this._id)}get_top(){const e=this._getBox();return e&&e.top}set_top({top:e}){const t=this._getBox();t&&(t.top=e)}get_left(){const e=this._getBox();return e&&e.left}set_left({left:e}){const t=this._getBox();t&&(t.left=e)}set_text({text:e}){const t=this._getBox();t&&(t.text=e)}get_right(){const e=this._getBox();return e&&e.right}set_right({right:e}){const t=this._getBox();t&&(t.right=e)}get_bottom(){const e=this._getBox();return e&&e.bottom}set_bottom({bottom:e}){const t=this._getBox();t&&(t.bottom=e)}set_extend({extend:e},t){const r=this._getBox();r&&(r.extend=e,this._paramVerfiy(e,t,"box.set_extend",Object.values(Vr),"extend"))}set_bgcolor({color:e}){const t=this._getBox();t&&(t.bgcolor=e)}set_lefttop({left:e,top:t}){const r=this._getBox();r&&(r.left=e,r.top=t)}set_text_size({text_size:e},t){const r=this._getBox();r&&(r.text_size=e,this._paramVerfiy(e,t,"box.set_text_size",Object.values(ar),"text_size"))}set_text_wrap({text_wrap:e},t){const r=this._getBox();r&&(r.text_wrap=e,this._paramVerfiy(e,t,"box.set_text_wrap",[je.wrapAuto,je.wrapNone],"text_wrap"))}set_text_color({text_color:e}){const t=this._getBox();t&&(t.text_color=e)}set_rightbottom({right:e,bottom:t}){const r=this._getBox();r&&(r.right=e,r.bottom=t)}set_text_halign({text_halign:e},t){const r=this._getBox();r&&(r.text_halign=e,this._paramVerfiy(e,t,"box.set_text_halign",[je.alignLeft,je.alignCenter,je.alignRight],"text_halign"))}set_text_valign({text_valign:e},t){const r=this._getBox();r&&(r.text_valign=e,this._paramVerfiy(e,t,"box.set_text_valign",[je.alignBottom,je.alignCenter,je.alignTop],"text_valign"))}set_top_left_point({point:e}){const t=this._getBox();if(t){const{index:r,price:n,time:i}=e||{};t.top=n,t.left=t.xloc===bt.bar_index?r:i}}set_border_color({color:e}){const t=this._getBox();t&&(t.border_color=e)}set_border_style({style:e},t){const r=this._getBox();r&&(r.border_style=e,this._paramVerfiy(e,t,"box.set_border_style",[qt.styleDashed,qt.styleDotted,qt.styleSolid],"style"))}set_border_width({width:e}){const t=this._getBox();t&&(t.border_width=e)}set_bottom_right_point({point:e}){const t=this._getBox();if(t){const{index:r,price:n,time:i}=e||{};t.bottom=n,t.right=t.xloc===bt.bar_index?r:i}}set_text_font_family({text_font_family:e},t){const r=this._getBox();r&&(r.text_font_family=e,this._paramVerfiy(e,t,"box.set_text_font_family",Object.values(ei),"text_font_family"))}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}_getBox(){return this._variables.box.get(this._id)}}class CD{constructor(e,t){q(this,"_variables");q(this,"_errorListener");q(this,"_defaultTable",{position:br.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=e,this._errorListener=t}table({x:e},t){return e||new su(this._variables,t,this._errorListener)}new(e,t){const r=`table_${t}_${this._variables.bar_index}`,n={...this._defaultTable,...e,cell:[],id:r},i=new su(this._variables,r,this._errorListener);return this._paramVerfiy(e.position,t,"table.new",Object.values(br),"position"),t.startsWith("export")||this._variables.table.add(r,n,i),i}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}cell({table_id:e,...t}){e==null||e.cell(t)}cell_set_bgcolor({table_id:e,...t}){e==null||e.cell_set_bgcolor(t)}cell_set_height({table_id:e,...t}){e==null||e.cell_set_height(t)}cell_set_text({table_id:e,...t}){e==null||e.cell_set_text(t)}cell_set_text_color({table_id:e,...t}){e==null||e.cell_set_text_color(t)}cell_set_text_font_family({table_id:e,...t}){e==null||e.cell_set_text_font_family(t)}cell_set_text_halign({table_id:e,...t}){e==null||e.cell_set_text_halign(t)}cell_set_text_valign({table_id:e,...t}){e==null||e.cell_set_text_valign(t)}cell_set_text_size({table_id:e,...t}){e==null||e.cell_set_text_size(t)}cell_set_tooltip({table_id:e,...t}){e==null||e.cell_set_tooltip(t)}cell_set_width({table_id:e,...t}){e==null||e.cell_set_width(t)}clear({table_id:e,...t}){e==null||e.clear(t)}delete({table_id:e}){e==null||e.delete()}merge_cells({table_id:e,...t},r){e==null||e.merge_cells(t,r)}set_bgcolor({table_id:e,...t}){e==null||e.set_bgcolor(t)}set_border_color({table_id:e,...t}){e==null||e.set_border_color(t)}set_border_width({table_id:e,...t}){e==null||e.set_border_width(t)}set_frame_color({table_id:e,...t}){e==null||e.set_frame_color(t)}set_frame_width({table_id:e,...t}){e==null||e.set_frame_width(t)}set_position({table_id:e,...t},r){e==null||e.set_position(t,r)}}class su{constructor(e,t,r){q(this,"_id");q(this,"_variables");q(this,"_errorListener");q(this,"_defaultCell",{column:0,row:0,text:"",text_color:$i.black,text_halign:je.alignCenter,text_valign:je.alignCenter,text_size:ar.normal});this._variables=e,this._id=t,this._errorListener=r}cell(e){const t={...this._defaultCell,...e},{column:r=0,row:n=0}=t,i=this._variables.table.get(this._id);if(i){const a=i.cell||[],u=a[n]||[];u[r]=t,a[n]=u,i.cell=a}}cell_set_bgcolor({column:e=0,row:t=0,bgcolor:r}){const n=this._getTableItem(e,t);n&&(n.bgcolor=r)}cell_set_height({column:e=0,row:t=0,height:r}){const n=this._getTableItem(e,t);n&&(n.height=r)}cell_set_text({column:e=0,row:t=0,text:r}){const n=this._getTableItem(e,t);n&&(n.text=r)}cell_set_text_color({column:e=0,row:t=0,text_color:r}){const n=this._getTableItem(e,t);n&&(n.text_color=r)}cell_set_text_font_family({column:e=0,row:t=0,text_font_family:r}){const n=this._getTableItem(e,t);n&&(n.text_font_family=r)}cell_set_text_halign({column:e=0,row:t=0,text_halign:r}){const n=this._getTableItem(e,t);n&&(n.text_halign=r)}cell_set_text_valign({column:e=0,row:t=0,text_valign:r}){const n=this._getTableItem(e,t);n&&(n.text_valign=r)}cell_set_text_size({column:e=0,row:t=0,text_size:r}){const n=this._getTableItem(e,t);n&&(n.text_size=r)}cell_set_tooltip({column:e=0,row:t=0,tooltip:r}){const n=this._getTableItem(e,t);n&&(n.tooltip=r)}cell_set_width({column:e=0,row:t=0,width:r}){const n=this._getTableItem(e,t);n&&(n.width=r)}clear({start_column:e=0,start_row:t=0,end_column:r=0,end_row:n=0}){const i=this._variables.table.get(this._id);if(i){const a=i.cell;if(a)for(let u=t;u<=n;u++)for(let f=e;f<=r;f++){const c=a[u];c&&(c[f]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:e=0,start_row:t=0,end_column:r=0,end_row:n=0},i){if(e>r||t>n){console.log(`error ${i}: start_column > end_column or start_row > end_row`);return}const a=this._getTableItem(e,t);if(!a)return;this.clear({start_column:e,start_row:t,end_column:r,end_row:n});const u=this._variables.table.get(this._id);u.cell[t][e]={...a,isMerge:!0,merge_columns:r-e+1,merge_rows:n-t+1}}set_bgcolor({bgcolor:e}){const t=this._variables.table.get(this._id);t&&(t.bgcolor=e)}set_border_color({border_color:e}){const t=this._variables.table.get(this._id);t&&(t.border_color=e)}set_border_width({border_width:e}){const t=this._variables.table.get(this._id);t&&(t.border_width=e)}set_frame_color({frame_color:e}){const t=this._variables.table.get(this._id);t&&(t.frame_color=e)}set_frame_width({frame_width:e}){const t=this._variables.table.get(this._id);t&&(t.frame_width=e)}set_position({position:e},t){const r=this._variables.table.get(this._id);r&&(r.position=e,this._paramVerfiy(e,t,"table.set_position",Object.values(br),"position"))}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}_getTableItem(e,t){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[t][e]:void 0}}}class AD{constructor(e){q(this,"_strategy");this._strategy=e}commission({trade_num:e}){return this._verifyTradeNum(e)&&this._strategy.historyOrders[e].commission||0}entry_bar_index({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].in_index}entry_comment({trade_num:e}){if(!this._verifyTradeNum(e))return"";const{comment:t,id:r}=this._strategy.historyOrders[e];return t||r}entry_id({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].id:""}entry_price({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].in_price}entry_time({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].in_time}exit_bar_index({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].out_index}exit_comment({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].out_comment:""}exit_id({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].out_id:""}exit_price({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].out_price}exit_time({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].out_time}max_drawdown({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].trading_loss:0}max_drawdown_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].trading_loss_percent:0}max_runup({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].max_profit:0}max_runup_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].max_profit_percent:0}profit({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].profit:0}profit_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].profit_percent:0}size({trade_num:e}){if(!this._verifyTradeNum(e))return 0;const{out_qty:t=0,direction:r}=this._strategy.historyOrders[e];return r===mt.long?t:-t}_verifyTradeNum(e){if(typeof e!="number"||e<0)return!1;const t=this._strategy.historyOrders.length;return!(e>=t)}}class FD{constructor(e){q(this,"_strategy");this._strategy=e}commission({trade_num:e}){if(!this._verifyTradeNum(e))return 0;const{qty:t=0,original_qty:r=0,commission:n=0}=this._strategy.orders[e];return n*t/r}entry_bar_index({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.orders[e].in_index}entry_comment({trade_num:e}){if(!this._verifyTradeNum(e))return"";const{comment:t,id:r}=this._strategy.orders[e];return t||r}entry_id({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].id:""}entry_price({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.orders[e].in_price}entry_time({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.orders[e].in_time}max_drawdown({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].trading_loss:0}max_drawdown_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].trading_loss_percent:0}max_runup({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].max_profit:0}max_runup_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].max_profit_percent:0}profit({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].profit:0}profit_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].profit_percent:0}size({trade_num:e}){if(!this._verifyTradeNum(e))return 0;const{qty:t=0,direction:r}=this._strategy.orders[e];return r===mt.long?t:-t}_verifyTradeNum(e){if(typeof e!="number"||e<0)return!1;const t=this._strategy.orders.length;return!(e>=t)}}class BD{constructor(e,t){q(this,"_strategy");q(this,"_errorListener");this._strategy=e,this._errorListener=t}allow_entry_in({value:e},t){this._paramVerfiy(e,t,"strategy.risk.allow_entry_in",Object.values(mt),"value"),this._strategy.updateRisk({allow_entry_in:e})}max_cons_loss_days({count:e}){this._strategy.updateRisk({max_cons_loss_days:e})}max_drawdown({value:e,type:t},r){this._paramVerfiy(t,r,"strategy.risk.max_drawdown",[Rt.percentOfEquity,Rt.cash],"type"),t===Rt.percentOfEquity&&(e=e>100?100:e),this._strategy.updateRisk({max_drawdown:e,max_drawdown_type:t})}max_intraday_filled_orders({count:e}){this._strategy.updateRisk({max_intraday_filled_orders:e})}max_intraday_loss({value:e,type:t},r){this._paramVerfiy(t,r,"strategy.risk.max_intraday_loss",[Rt.percentOfEquity,Rt.cash],"type"),t===Rt.percentOfEquity&&(e=e>100?100:e),this._strategy.updateRisk({max_intraday_loss:e,max_intraday_loss_type:t})}max_position_size({contracts:e}){this._strategy.updateRisk({max_position_size:e})}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}}let MD=class{constructor(e,t,r,n){q(this,"_variables");q(this,"_options");q(this,"_totalChangeCapital");q(this,"_historyOrder");q(this,"_orders");q(this,"_pendingOrders");q(this,"_mintick");q(this,"_funcOptions");q(this,"_pendingCloseOrders");q(this,"_errorListener");q(this,"_risk");q(this,"_opentrades");q(this,"_closedtrades");q(this,"_riskNamespace");this._variables=e,this._errorListener=n,this._options={overlay:!1,format:Je.inherit,pyramiding:0,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Rt.fixed,default_qty_value:1,initial_capital:1e6,currency:qf.NONE,slippage:0,commission_type:Ir.percent,commission_value:0,process_orders_on_close:!1,close_entries_rule:"FIFO",margin_long:0,margin_short:0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,max_polylines_count:50},this._funcOptions=t,this._totalChangeCapital=0,this._orders=[],this._pendingOrders=[],this._historyOrder=[],this._pendingCloseOrders=[],this._mintick=r,this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),this._variables.strategy.updateStrategyOptions(this._options),this._risk={intradayOrders:0},this._opentrades=new FD(this),this._closedtrades=new AD(this),this._riskNamespace=new BD(this,n)}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _orderProfit(){return this._orders.reduce((e,t)=>e+(t.profit||0),0)}get _freezeCapital(){const{close:e}=this._variables;return this._orders.reduce((t,r)=>t+e*(r.qty||0),0)}get opentrades(){return this._opentrades}get closedtrades(){return this._closedtrades}get risk(){return this._riskNamespace}updateOptions(e){Object.assign(this._options,e),this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),!this._options.process_orders_on_close&&this._calcLiquidate()}updateRisk(e){Object.assign(this._risk,e)}endExecution(){this._calcProfitAndLoss(),this._variables.strategy.update(),this._maxDrawdownVerify(),this._maxIntradayLoss(),this._pendingCloseOrderHandle(),this._options.process_orders_on_close&&this._calcLiquidate()}_maxIntradayLoss(){var v;const{max_intraday_loss:e,max_intraday_loss_type:t,isDisabledOpen:r}=this._risk;if(e===void 0||!t||r)return;const{high:n,low:i,time_tradingday:a,time:u,strategy:{netprofit:f,initial_capital:c}}=this._variables;let{preNetprofit:h=0}=this._risk;u===a&&(h=f,this._risk.preNetprofit=f,this._risk.isTemporaryBan=!1);let d=h-f;d+=this._orders.reduce((x,_)=>{const{in_price:y,direction:m,qty:w=0,commission:D=0,original_qty:C=0}=_,b=m===mt.long?1:-1,F=(n-y)*w,B=(i-y)*w,M=b===1?-B:F;return x+M+w/C*D},0);let p=!1;switch(t){case Rt.cash:p=e<d;break;case Rt.percentOfEquity:const x=d/(c+f)*100;p=e<x;break}if(p){this._risk.isTemporaryBan=!0;const x=(v=this._orders[0])==null?void 0:v.direction;this._closeOrders(this._orders,x===mt.long?i:n,"Close Position (Max intraday Loss)"),this._pendingOrders=[]}}_maxIntradayFilledOrdersVerify(){const{max_intraday_filled_orders:e,intradayOrders:t=0,isDisabledOpen:r}=this._risk;if(e===void 0||r)return;const{time:n,time_tradingday:i,open:a}=this._variables;n===i&&(this._risk.intradayOrders=0,this._risk.isTemporaryBan=!1),e<=t&&(this._risk.isTemporaryBan=!0,this._closeOrders(this._orders,a,"Close Position (Max number of filled orders in one day)"),this._pendingOrders=[])}_maxConsLossDaysVerify(){const{max_cons_loss_days:e,lossDays:t=0,isDisabledOpen:r,totalProfit:n=0}=this._risk;if(e===void 0||r)return;const{time:i,time_tradingday:a,strategy:u,open:f}=this._variables;let c=t;if(i===a){const h=u.netprofit+u.openprofit;h<n?c=0:c++,Object.assign(this._risk,{lossDays:c,totalProfit:h})}e<=c&&this._riskTouchOff(f,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){var n;const{max_drawdown:e,max_drawdown_type:t,isDisabledOpen:r}=this._risk;if(!r&&e!==void 0&&t){const{max_drawdown:i,max_drawdown_percent:a}=this._variables.strategy;let u=!1;switch(t){case Rt.percentOfEquity:u=a<i;break;case Rt.cash:u=e<i;break}if(u){const{high:f,low:c}=this._variables,h=(n=this._orders[0])==null?void 0:n.direction;this._riskTouchOff(h===mt.long?f:c,"Close Position (Max Drawdown)")}}}_riskTouchOff(e,t){this._risk.isDisabledOpen=!0,this._closeOrders(this._orders,e,t),this._pendingOrders=[]}strategy(e,t){this._variables.bar_index||(this._paramVerfiy(e.format,t,"strategy",[Je.inherit,Je.price,Je.percent,Je.volume],"format"),this._paramVerfiy(e.default_qty_type,t,"strategy",Object.values(Rt),"default_qty_type"),this._paramVerfiy(e.commission_type,t,"strategy",Object.values(Ir),"commission_type"),this._options={...e},this._variables.updateMaxLength(e),Object.assign(this._funcOptions,{strategy:this._options,scriptType:"strategy"}))}order(e,t){this._risk.isDisabledOpen||(this._paramVerfiy(e.oca_type,t,"strategy.order",Object.values(gn),"oca_type"),this._orderHandle(e))}entry(e,t){this._risk.isDisabledOpen||(this._paramVerfiy(e.oca_type,t,"strategy.entry",Object.values(gn),"oca_type"),this._entryHandle(e))}close(e){if(!this._orders.length)return;const{immediately:t}=e;t||this._options.process_orders_on_close?this._pendingCloseOrders.push({...e,place_order_type:"close"}):this._pendingOrders.push({...e,place_order_type:"close"})}close_all(e){if(typeof e=="string"&&(e={}),!this._orders.length)return;const{immediately:t}=e;t||this._options.process_orders_on_close?this._pendingCloseOrders.push({...e,place_order_type:"close_all"}):this._pendingOrders.push({...e,place_order_type:"close_all"})}cancel({id:e}){this._pendingOrders=this._pendingOrders.filter(t=>!(t.id===e&&t.place_order_type!=="close"))}cancel_all(){this._pendingOrders=this._pendingOrders.filter(e=>e.place_order_type==="close_all")}exit(e,t){this._exit(e,t)}convert_to_account({value:e}){return e}convert_to_symbol({value:e}){return e}default_entry_qty({fill_price:e}){return e?this._calcDefaultQty(e):0}_calcDefaultQty(e){const{default_qty_type:t=Rt.fixed,default_qty_value:r=1,initial_capital:n}=this._options;switch(t){case Rt.fixed:return r;case Rt.cash:return r/e;case Rt.percentOfEquity:return(n+this._orderProfit+this._totalChangeCapital)*r/100/e}}_getCapital(e,t){const{margin_long:r=0,margin_short:n=0}=this._options;return r<100&&r>0&&e===1?t=t*100/r:n<=100&&n>0&&e===-1&&(t=t*100/n),t}_calcProfitAndLoss(){const{high:e,low:t,close:r}=this._variables;for(const n of this._orders){const{in_price:i,qty:a=0,direction:u}=n,f=u===mt.long?1:-1,c=(r-i)*f*a,h=(e-i)*a,d=(t-i)*a,p=f===1?h:-d,v=f===1?-d:h;this._calcOrderPercent(n,c,p,v)}}_calcOrderPercent(e,t,r,n){const{commission_value:i}=this._options,{close:a}=this._variables,{original_qty:u=0,qty:f=0,in_price:c,max_profit:h=0,trading_loss:d=0}=e;let{commission:p=0}=e;const v=c*f;if(i){const x=this._getCommission(a,f);t=t-x,p=p*f/u,r-=p,n+=p}r=Math.max(r,h),n=Math.min(n,d),Object.assign(e,{profit:t-p,total_profit:this._totalChangeCapital+t,max_profit:r,trading_loss:n,profit_percent:t/v*100,max_profit_percent:r/v*100,trading_loss_percent:n/v*100})}_calcLiquidate(){if(!this._orders.length)return;const{high:e,low:t}=this._variables,{initial_capital:r,margin_long:n=0,margin_short:i=0,commission_value:a=0}=this._options,u=this._orders[0].direction===mt.long?1:-1,f=u===1?t:e,c=(u===1?n:i)/100;if(c<=0)return;const[h,d,p]=this._orders.reduce((m,w)=>{let[D,C,b]=m;const{in_price:F,qty:B=0,original_qty:M=0,commission:O=0}=w,A=F*B,N=f*B;if(D+=A,C+=N,a){const I=this._getCommission(f,B);b+=I+B/M*O}return[D,C,b]},[0,0,0]),v=u*(d-h),_=r+this._totalChangeCapital+v-p-d*c;if(_>=0)return;const y=Math.trunc(_/c/f)*4;this._marginCallOrders(f,y,"Margin Call")}_marginCallOrders(e,t,r){const{close_entries_rule:n="FIFO"}=this._options;if(n==="FIFO"){this._processOrders(this._orders,e,t*this._orders.length,r,r);return}for(const i of this.orders)this._processOrder(i,e,t,r,r);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders)}_orderHandle(e){const{process_orders_on_close:t,slippage:r=0}=this._options,{orders:n,isMarketPrice:i,quantities:a,close:u,price:f,activePrice:c}=this._orderArgsParse(e),h=e.direction===mt.long?1:-1;if(a<=0)return;let d=a;if(i&&t){if(n.length){const _=this._processOrders(n,u,d,e.id,e.comment);if(_<=0)return;d=_}const v=u+h*r*this._mintick;if(!this._judgeCapitalEnough(d,v,h))return;this._ocaGroupVerify(d,e.oca_name,e.oca_type),this._calcCurrentOrder({...e,in_price:v,in_index:this._variables.bar_index,in_time:this._variables.time,qty:d,place_order_type:"order"});return}this._judgeCapitalEnough(a,f,h)&&this._addPendingOrders(e,f,d,i,c)}_judgeCapitalEnough(e,t,r){if(e<=0)return!1;const{margin_long:n=0,margin_short:i=0}=this._options;if((n===0||n===100)&&r===1||i===0&&r===-1)return!0;const u=this._getCapital(r,this._options.initial_capital+this._orderProfit+this._totalChangeCapital)-this._freezeCapital;return e*t<=u}_ocaGroupVerify(e,t,r){if(!t||!r||r===gn.none)return!1;let n=!1;switch(r){case gn.cancel:this._pendingOrders=this._pendingOrders.filter(i=>{if(i.oca_name===t)i.isCancel=!0,n=!0;else return!0});break;case gn.reduce:this._pendingOrders=this._pendingOrders.filter(i=>{const{qty:a=0,oca_name:u}=i;if(t===u){const f=a-e;return n=!0,f<=0?(i.isCancel=!0,!1):(i.qty=f,!0)}else return!0});break}return n}_processOrders(e,t,r,n,i){let a=r;for(const u of e)if(a=this._processOrder(u,t,a,n,i),a<=0)break;return this._orders=this._orders.filter(u=>!u.isDeal),this._variables.strategy.updateOrders(this._orders),a}_addPendingOrders(e,t,r,n,i){const a=this._pendingOrders.find(u=>u.id===e.id&&!u.isMarketPrice);if(a)Object.assign(a,{...e,in_price:t,isMarketPrice:n,qty:r,active_price:i});else{const u={...e,in_price:t,isMarketPrice:n,qty:r,active_price:i,place_order_type:"order"};this._pendingOrders.push(u)}}_orderArgsParse(e){const{direction:t,qty:r,stop:n}=e;let i=e.limit||0;const{close:a}=this._variables;let u=a,f=!1,c;const h=t===mt.long?1:-1,d=n&&(n-a)*h>0,{backtest_fill_limits_assumption:p=0}=this._options;p>0&&i&&(i-=p*this._mintick*h);const v=i&&(i-a)*h<0;d&&v?(c=n,u=i):d?u=n:v?u=i:f=!0;const x=r||this._calcDefaultQty(u)||1;return{orders:this._orders.filter(y=>y.direction!==t),isMarketPrice:f,activePrice:c,quantities:x,close:a,price:u}}_entryHandle(e){const{process_orders_on_close:t}=this._options,{orders:r,isMarketPrice:n,quantities:i,close:a,price:u,activePrice:f}=this._orderArgsParse(e);if(i<=0)return;if(r.length&&n&&t){this._entryOrder(r,a,i,e);return}this._judgeCapitalEnough(i,a,e.direction===mt.long?1:-1)&&this._addPendingEntry(e,u,i,n,f)}_entryOrder(e,t,r,n){const{time:i,bar_index:a}=this._variables,{slippage:u=0}=this._options,{oca_name:f,oca_type:c,direction:h,comment:d,isMarketPrice:p,id:v}=n,x=h===mt.long?1:-1;if(this._closeOrders(e,t,v,d),r=this._getAvailablePositionSize(r,h),r<=0)return;t=t+u*this._mintick*x;const _={...n,in_price:t,original_qty:r,qty:r,in_index:a,in_time:i,place_order_type:"entry"};if(p){this._calcCurrentOrder(_);return}const{pendingOrders:y,orders:m}=this._getEntryOrders(h),w=y.length+m.length;w&&w>=(this._options.pyramiding||0)||!this._judgeCapitalEnough(r,t,x)||(this._ocaGroupVerify(r,f,c),this._calcCurrentOrder(_))}_getAvailablePositionSize(e,t){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==mt.all&&n!==t)return 0;if(r===void 0)return e;const i=this._orders.reduce((a,u)=>a+(u.qty||0),0);return i?i+e>r?0:e:e>r?e-r:0}_getEntryOrders(e){const t=this._pendingOrders.filter(n=>["entry","order"].includes(n.place_order_type)&&n.direction===e),r=this._orders.filter(n=>n.direction===e);return{pendingOrders:t,orders:r}}_addPendingEntry(e,t,r,n,i){if(r=this._getAvailablePositionSize(r,e.direction),r<=0)return;const{pendingOrders:a,orders:u}=this._getEntryOrders(e.direction),f=a.length+u.length,c=a.find(h=>h.id===e.id&&h.place_order_type==="entry");if(c)Object.assign(c,{...e,in_price:t,isMarketPrice:n,qty:r,active_price:i});else if(!f||f<(this._options.pyramiding||1)){const h={...e,in_price:t,isMarketPrice:n,qty:r,active_price:i,place_order_type:"entry"};this._pendingOrders.push(h)}}_closeAllOrders(e,t){const{comment:r}=e,{bar_index:n}=this._variables,i=this._orders.filter(a=>a.in_index!==n);i.length&&(this._closeOrders(i,t,"Close position order",r),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(e,t,r,n){for(const i of e)this._closeOrder(i,t,r,n);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders)}_closeOrder(e,t,r,n){const{time:i,bar_index:a}=this._variables,{slippage:u=0}=this._options,{in_price:f,qty:c=0,direction:h}=e,d=h===mt.long?1:-1;t=t-d*u*this._mintick,e.isDeal=!0;const p=(t-f)*d*c,v={...e,out_price:t,out_id:r,out_index:a,out_time:i,out_comment:n,out_qty:c,profit:p};this._calcPercent(v),this._risk.intradayOrders+=1,this._historyOrder.push(v),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_ordersHandle(){const e=this._orders.filter(a=>a.place_order_type==="exit"&&!a.hasExit);if(!e.length)return;const{open:t,low:r,high:n,close:i}=this._variables;for(const a of e){const{stop:u,limit:f,trail_stop_price:c,isMarketPriceLimit:h,isMarketPriceStop:d,direction:p,id:v,out_comment:x,active_price:_,trail_offset:y=0,out_qty:m,comment_loss:w,comment_profit:D,comment_trailing:C}=a;let b=c;const F=p===mt.long?1:-1;let B,M=x;if(h||d?B=t:(f&&r<=f&&n>=f&&(M=D||x,B=f),u&&r<=u&&n>=u&&(B=b?(u-b)*F>0?u:b:u,M=(b===B?C:w)||x)),B)this._processExitOnClose(a,B,{from_entry:v,comment:M,qty:m});else{let O=!1;if(_&&_<=n&&_>=r&&(b=_-y*F*this._mintick,(b-i)*F>=0&&(a.isMarketPriceStop=!0,this._options.process_orders_on_close&&(B=b)),O=!0,a.trail_stop_price=b),b)if((b-t)*F>=0&&!O)B=b;else{const A=(F===1?n:r)-y*F*this._mintick;F===1?b<t&&b>=r&&A>b&&A<i?B=b:A>b?(b=A,A>=i&&(B=A)):b<=n&&r<=b&&(B=b):b>t&&b<=n&&A<b&&A>i?B=b:A<b?(b=A,A<=i&&(B=A)):b<=n&&r<=b&&(B=b),a.trail_stop_price=b}B&&this._processExitOnClose(a,B,{from_entry:v,comment:C||x,qty:m})}}}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const e=[],t=this._pendingOrders.filter(n=>n.place_order_type==="exit"),r=this._pendingOrders.filter(n=>["close","close_all"].includes(n.place_order_type||""));for(const n of r)switch(n.place_order_type){case"close":this._closeOrderHandle(n);break;case"close_all":this._closeAllOrders(n,this._variables.open);break}for(const n of this._pendingOrders){const{isCancel:i,place_order_type:a}=n;if(i)continue;let u;switch(a){case"entry":u=this._entryOrderHandle(n);break;case"order":u=this._orderOrderHandle(n);break}u&&e.push(u)}for(const n of t){const i=this._exitOrderHandle(n);i&&e.push(i)}this._pendingOrders=e}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const e=this._pendingCloseOrders.filter(n=>n.place_order_type==="exit"),t=this._pendingCloseOrders.filter(n=>["close","close_all"].includes(n.place_order_type||"")),{close:r}=this._variables;for(const n of t)switch(n.place_order_type){case"close":this._closeOrderHandle(n,!0);break;case"close_all":this._closeAllOrders(n,r);break}for(const n of e){const{from_entry:i}=n,a=this._orders.filter(u=>!i||u.id===i&&(u.isMarketPriceLimit||u.isMarketPriceStop));for(const u of a)this._processExitOnClose(u,u.limit||u.stop||u.trail_stop_price||r,n)}this._pendingCloseOrders=[]}_entryOrderHandle(e){const{open:t,low:r,high:n}=this._variables,{isMarketPrice:i,qty:a=0,in_price:u,direction:f,active_price:c}=e;if(c&&n>=c&&r<=c)return delete e.active_price,e;let h=u;if(i&&(h=t),h<=n&&h>=r){const d=this._orders.filter(p=>p.direction!==f);this._entryOrder(d,h,a,e)}else return e}_orderOrderHandle(e){const{open:t,low:r,high:n,time:i,bar_index:a}=this._variables,{slippage:u=0}=this._options,{isMarketPrice:f,qty:c=0,in_price:h,direction:d,comment:p,oca_name:v,oca_type:x,active_price:_,id:y}=e;if(_&&n>=_&&r<=_)return delete e.active_price,e;let m=h,w=c;if(f&&(m=t),m<=n&&m>=r){const D=this._orders.filter(b=>b.direction!==d);if(D.length&&(w=this._processOrders(D,m,c,y,p),w<=0))return;const C=d===mt.long?1:-1;this._ocaGroupVerify(w,v,x),this._calcCurrentOrder({...e,in_price:m+C*u*this._mintick,in_index:a,in_time:i,qty:w});return}else return e}_closeOrderHandle(e,t){const{id:r,qty:n,qty_percent:i=100,comment:a}=e,{bar_index:u}=this._variables,f=this._orders.filter(v=>v.id===r&&v.in_index!==u&&(!v.close_qty||v.close_qty<(v.qty||0)));if(!f.length)return;let c=0;if(n?c=n:(c=f.reduce((v,x)=>v+(x.qty||0),c),c=i/100*c),c<=0)return;const{open:h,close:d}=this._variables;let p=c;for(const v of f){const{qty:x=0}=v;p<x?v.close_qty=p:(v.close_qty=x,p-=x)}this._processOrders(this._options.close_entries_rule==="ANY"?f:this._orders,t?d:h,c,`Close entry(s) order ${r}`,a)}_exitOrderHandle(e){const{from_entry:t}=e,r=this._orders.filter(n=>(!t||t===n.id)&&!n.hasExit);if(!(r.length&&!this._ordersToExit(r,e)))return e}_exit(e,t){const{profit:r,loss:n,stop:i,limit:a,trail_offset:u,trail_price:f,trail_points:c,from_entry:h="",id:d}=e;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(i)&&this._isNaN(a)&&(this._isNaN(u)||this._isNaN(c)&&this._isNaN(f))){this._errorListener.addError(ct.strategyExitErr,t,Ze.Error);return}const p={...e,place_order_type:"exit"},v=this._orders.filter(y=>(!h||h===y.id)&&!y.hasExit),x=this._pendingOrders.filter(y=>!h||h===y.id);if(v.length){if(!this._ordersToExit(v,p))return}else if(!x.length)return;const _=this._pendingOrders.find(y=>y.id===d);_?Object.assign(_,{...e}):this._pendingOrders.push(p)}_ordersToExit(e,t){const{qty:r,qty_percent:n=100,id:i,comment:a,comment_loss:u,comment_profit:f,comment_trailing:c}=t;let h=r,d=!1;t.comment=a||i;for(const p of e){const{qty:v=0}=p,x=p.direction===mt.long?1:-1;h=r?r>=v?v:r:n/100*v,p.out_qty=h,h<v&&(d=!0),Object.assign(p,{out_comment:a||i,comment_loss:u,comment_profit:f,comment_trailing:c}),!(this._stopProfit(p,x,{...t,qty:h})||this._stopLoss(p,x,{...t,qty:h})||this._trailStopLoss(p,x,{...t,qty:h}))&&(p.place_order_type="exit")}return d}_addExitPendingCloseOrders(e){e.place_order_type="exit";const t=this._pendingCloseOrders.find(r=>r.id===e.id);t?Object.assign(t,{...e}):this._pendingCloseOrders.push(e)}_stopProfit(e,t,r){const{limit:n,profit:i,comment_profit:a,comment:u}=r;let f=n;const{close:c}=this._variables,{in_price:h}=e,{process_orders_on_close:d}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(f=h+t*i*this._mintick),e.limit=f,f&&(f-c)*t<=0&&(e.isMarketPriceLimit=!0,r.comment=a||u,Object.assign(e,{out_comment:r.comment}),f=c,d))return this._addExitPendingCloseOrders(r),!0}_stopLoss(e,t,r){const{stop:n,loss:i,comment_loss:a,comment:u}=r;let f=n;const{close:c}=this._variables,{in_price:h}=e,{process_orders_on_close:d}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(f=h-t*i*this._mintick),e.stop=f,f&&(f-c)*t>=0&&(e.isMarketPriceStop=!0,r.comment=a||u,Object.assign(e,{out_comment:r.comment}),f=c,d))return this._addExitPendingCloseOrders(r),!0}_trailStopLoss(e,t,r){const{trail_offset:n,trail_price:i,trail_points:a,comment_trailing:u,comment:f}=r;if(!this._isNaN(n)){const{close:c}=this._variables,{in_price:h}=e,{process_orders_on_close:d}=this._options;let p;if(this._isNaN(i)?this._isNaN(a)||(p=h+a*t*this._mintick):p=i,e.trail_offset=n,p&&(p-c)*t<=0){const v=c-n*t*this._mintick;if((v-c)*t>=0&&(e.trail_stop_price=c,e.isMarketPriceStop=!0,r.comment=u||f,Object.assign(e,{out_comment:r.comment}),d))return this._addExitPendingCloseOrders(r),!0;e.trail_stop_price=v}e.active_price=p}}_processExitOnClose(e,t,r){const{qty:n=0,comment:i,id:a}=r,{close_entries_rule:u="FIFO"}=this._options;if(u==="FIFO"){const f=this._processExitOrders(this._orders,t,n,a,i);f&&!f.hasExit?(f.hasExit=!0,Object.assign(e,{trail_stop_price:f.trail_stop_price,stop:f.stop,limit:f.limit,trail_offset:f.trail_offset,active_price:f.active_price})):f&&(e.hasExit=!0)}else e.hasExit=!0,this._processOrders([e],t,n,a,i)}_processExitOrders(e,t,r,n,i){let a=r,u;for(const f of e)if(u=f,a=this._processOrder(f,t,a,n,i),a<=0||!f.hasExit)break;return this._orders=this._orders.filter(f=>!f.isDeal),this._variables.strategy.updateOrders(this._orders),u}_processOrder(e,t,r,n,i){const{time:a,bar_index:u}=this._variables,{slippage:f=0}=this._options,{in_price:c,qty:h=0,max_profit:d=0,trading_loss:p=0,direction:v,commission:x=0,original_qty:_=0}=e,y=v===mt.long?1:-1;if(t=t-y*f*this._mintick,r<h){const m=h-r,w=(t-c)*y*r,D=d/h*r,C=p/h*r;this._calcPercent({...e,out_price:t,out_id:n,out_index:u,out_time:a,out_comment:i,profit:w,out_qty:r,max_profit:D,trading_loss:C});const b=(t-c)*y*m-x*m/_;Object.assign(e,{qty:m,profit:b,max_profit:d-D,trading_loss:p-C,total_profit:this._totalChangeCapital+b}),r=0}else{e.isDeal=!0;const m=(t-c)*y*h;this._calcPercent({...e,out_price:t,out_id:n,out_index:u,out_time:a,out_comment:i,out_qty:h,profit:m}),r-=h}return r}_calcPercent(e){const{commission_value:t}=this._options,{in_price:r,out_qty:n=0,out_price:i=0,original_qty:a=0}=e;let{profit:u=0,max_profit:f=0,trading_loss:c=0,commission:h=0}=e;f=f<0?0:f;const d=r*n;if(this._totalChangeCapital+=u,t){const p=this._getCommission(i,n);this._totalChangeCapital-=p,h=h*n/a+p,u=u-h,Object.assign(e,{commission:h,profit:u,max_profit:f})}Object.assign(e,{total_profit:this._totalChangeCapital,profit_percent:u/d*100,max_profit_percent:f/d*100,trading_loss_percent:c/d*100}),this._risk.intradayOrders+=1,this._historyOrder.push(e),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_getCommission(e,t){const{commission_value:r=0,commission_type:n}=this._options,i=e*t;let a=0;switch(n){case Ir.percent:a=i*r/100;break;case Ir.cashPerContract:a=t*r;break;case Ir.cashPerOrder:a=r;break}return a}_calcCurrentOrder(e){const{commission_value:t}=this._options,{in_price:r,qty:n=0,max_profit:i=0,trading_loss:a=0}=e;let{profit:u=0}=e;const f=r*n;if(t){const c=this._getCommission(r,n);this._totalChangeCapital-=c,u=u-c,Object.assign(e,{commission:c,profit:u,total_profit:this._totalChangeCapital})}Object.assign(e,{original_qty:n,profit_percent:u/f*100,max_profit_percent:i/f*100,trading_loss_percent:a/f*100}),this._risk.intradayOrders+=1,this._orders.push(e),this._variables.strategy.updateOrders(this._orders)}_isNaN(e){return e===void 0||isNaN(e)}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}};var jf={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(ye,function(){return function(t,r,n){r.prototype.isBetween=function(i,a,u,f){var c=n(i),h=n(a),d=(f=f||"()")[0]==="(",p=f[1]===")";return(d?this.isAfter(c,u):!this.isBefore(c,u))&&(p?this.isBefore(h,u):!this.isAfter(h,u))||(d?this.isBefore(c,u):!this.isAfter(c,u))&&(p?this.isAfter(h,u):!this.isBefore(h,u))}}})})(jf);var ND=jf.exports,SD=tt(ND),Yf={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(ye,function(){return function(t,r,n){var i=r.prototype,a=function(p){var v,x=p.date,_=p.utc,y={};if(!((v=x)===null||v instanceof Date||v instanceof Array||i.$utils().u(v)||v.constructor.name!=="Object")){if(!Object.keys(x).length)return new Date;var m=_?n.utc():n();Object.keys(x).forEach(function(O){var A,N;y[A=O,N=i.$utils().p(A),N==="date"?"day":N]=x[O]});var w=y.day||(y.year||y.month>=0?1:m.date()),D=y.year||m.year(),C=y.month>=0?y.month:y.year||y.day?0:m.month(),b=y.hour||0,F=y.minute||0,B=y.second||0,M=y.millisecond||0;return _?new Date(Date.UTC(D,C,w,b,F,B,M)):new Date(D,C,w,b,F,B,M)}return x},u=i.parse;i.parse=function(p){p.date=a.bind(this)(p),u.bind(this)(p)};var f=i.set,c=i.add,h=i.subtract,d=function(p,v,x,_){_===void 0&&(_=1);var y=Object.keys(v),m=this;return y.forEach(function(w){m=p.bind(m)(v[w]*_,w)}),m};i.set=function(p,v){return v=v===void 0?p:v,p.constructor.name==="Object"?d.bind(this)(function(x,_){return f.bind(this)(_,x)},v,p):f.bind(this)(p,v)},i.add=function(p,v){return p.constructor.name==="Object"?d.bind(this)(c,p,v):c.bind(this)(p,v)},i.subtract=function(p,v){return p.constructor.name==="Object"?d.bind(this)(c,p,v,-1):h.bind(this)(p,v)}}})})(Yf);var OD=Yf.exports,ID=tt(OD),Kf={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(ye,function(){var t,r,n=1e3,i=6e4,a=36e5,u=864e5,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,c=31536e6,h=2628e6,d=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,p={years:c,months:h,days:u,hours:a,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},v=function(F){return F instanceof C},x=function(F,B,M){return new C(F,M,B.$l)},_=function(F){return r.p(F)+"s"},y=function(F){return F<0},m=function(F){return y(F)?Math.ceil(F):Math.floor(F)},w=function(F){return Math.abs(F)},D=function(F,B){return F?y(F)?{negative:!0,format:""+w(F)+B}:{negative:!1,format:""+F+B}:{negative:!1,format:""}},C=function(){function F(M,O,A){var N=this;if(this.$d={},this.$l=A,M===void 0&&(this.$ms=0,this.parseFromMilliseconds()),O)return x(M*p[_(O)],this);if(typeof M=="number")return this.$ms=M,this.parseFromMilliseconds(),this;if(typeof M=="object")return Object.keys(M).forEach(function(k){N.$d[_(k)]=M[k]}),this.calMilliseconds(),this;if(typeof M=="string"){var I=M.match(d);if(I){var L=I.slice(2).map(function(k){return k!=null?Number(k):0});return this.$d.years=L[0],this.$d.months=L[1],this.$d.weeks=L[2],this.$d.days=L[3],this.$d.hours=L[4],this.$d.minutes=L[5],this.$d.seconds=L[6],this.calMilliseconds(),this}}return this}var B=F.prototype;return B.calMilliseconds=function(){var M=this;this.$ms=Object.keys(this.$d).reduce(function(O,A){return O+(M.$d[A]||0)*p[A]},0)},B.parseFromMilliseconds=function(){var M=this.$ms;this.$d.years=m(M/c),M%=c,this.$d.months=m(M/h),M%=h,this.$d.days=m(M/u),M%=u,this.$d.hours=m(M/a),M%=a,this.$d.minutes=m(M/i),M%=i,this.$d.seconds=m(M/n),M%=n,this.$d.milliseconds=M},B.toISOString=function(){var M=D(this.$d.years,"Y"),O=D(this.$d.months,"M"),A=+this.$d.days||0;this.$d.weeks&&(A+=7*this.$d.weeks);var N=D(A,"D"),I=D(this.$d.hours,"H"),L=D(this.$d.minutes,"M"),k=this.$d.seconds||0;this.$d.milliseconds&&(k+=this.$d.milliseconds/1e3,k=Math.round(1e3*k)/1e3);var z=D(k,"S"),R=M.negative||O.negative||N.negative||I.negative||L.negative||z.negative,V=I.format||L.format||z.format?"T":"",H=(R?"-":"")+"P"+M.format+O.format+N.format+V+I.format+L.format+z.format;return H==="P"||H==="-P"?"P0D":H},B.toJSON=function(){return this.toISOString()},B.format=function(M){var O=M||"YYYY-MM-DDTHH:mm:ss",A={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return O.replace(f,function(N,I){return I||String(A[N])})},B.as=function(M){return this.$ms/p[_(M)]},B.get=function(M){var O=this.$ms,A=_(M);return A==="milliseconds"?O%=1e3:O=A==="weeks"?m(O/p[A]):this.$d[A],O||0},B.add=function(M,O,A){var N;return N=O?M*p[_(O)]:v(M)?M.$ms:x(M,this).$ms,x(this.$ms+N*(A?-1:1),this)},B.subtract=function(M,O){return this.add(M,O,!0)},B.locale=function(M){var O=this.clone();return O.$l=M,O},B.clone=function(){return x(this.$ms,this)},B.humanize=function(M){return t().add(this.$ms,"ms").locale(this.$l).fromNow(!M)},B.valueOf=function(){return this.asMilliseconds()},B.milliseconds=function(){return this.get("milliseconds")},B.asMilliseconds=function(){return this.as("milliseconds")},B.seconds=function(){return this.get("seconds")},B.asSeconds=function(){return this.as("seconds")},B.minutes=function(){return this.get("minutes")},B.asMinutes=function(){return this.as("minutes")},B.hours=function(){return this.get("hours")},B.asHours=function(){return this.as("hours")},B.days=function(){return this.get("days")},B.asDays=function(){return this.as("days")},B.weeks=function(){return this.get("weeks")},B.asWeeks=function(){return this.as("weeks")},B.months=function(){return this.get("months")},B.asMonths=function(){return this.as("months")},B.years=function(){return this.get("years")},B.asYears=function(){return this.as("years")},F}(),b=function(F,B,M){return F.add(B.years()*M,"y").add(B.months()*M,"M").add(B.days()*M,"d").add(B.hours()*M,"h").add(B.minutes()*M,"m").add(B.seconds()*M,"s").add(B.milliseconds()*M,"ms")};return function(F,B,M){t=M,r=M().$utils(),M.duration=function(N,I){var L=M.locale();return x(N,{$l:L},I)},M.isDuration=v;var O=B.prototype.add,A=B.prototype.subtract;B.prototype.add=function(N,I){return v(N)?b(this,N,1):O.bind(this)(N,I)},B.prototype.subtract=function(N,I){return v(N)?b(this,N,-1):A.bind(this)(N,I)}}})})(Kf);var TD=Kf.exports,$D=tt(TD);ot.extend(Dl),ot.extend(SD),ot.extend(ID),ot.extend($D);class Zf{constructor(e,t,r){q(this,"array");q(this,"color");q(this,"math");q(this,"str");q(this,"map");q(this,"matrix");q(this,"timeframe");q(this,"ta");q(this,"input");q(this,"_variables");q(this,"_cacheData");q(this,"_options");q(this,"_errorListener");q(this,"_plots");q(this,"_plotshapes");q(this,"_plotbars");q(this,"_plotchars");q(this,"_plotarrows");q(this,"_plotcandles");q(this,"_alerts");q(this,"_bgColors");q(this,"_hlines");q(this,"_fills");q(this,"chart");q(this,"line");q(this,"label");q(this,"polyline");q(this,"box");q(this,"table");q(this,"linefill");q(this,"log");q(this,"runtime");q(this,"strategy");q(this,"request");q(this,"syminfo");q(this,"_count",0);var i;const n=((i=e.toString().split(".")[1])==null?void 0:i.length)||4;this._variables=t,this._errorListener=new hw,this.array=new D1(this._errorListener),this.math=new w1(n,this._errorListener),this.color=new Gx,this.str=new Xy(this._errorListener,n),this.map=new Qy(this._errorListener),this.timeframe=new Gy(t),this.matrix=new Vy(this._errorListener),this.ta=new Zx(t,this.math,this.timeframe),this._cacheData={},this._options={},this._bgColors={},this._alerts=new Map,this._hlines=new Map,this._fills=new Map,this.input=new Vx(t,this._errorListener,r),this._plots=new Map,this._plotshapes=new Map,this._plotbars=new Map,this._plotcandles=new Map,this._plotchars=new Map,this._plotarrows=new Map,this.chart={point:new Jy(t)},this.line=new wD(t,this._errorListener),this.label=new eD(t,this._errorListener),this.polyline=new DD(t,this._errorListener),this.box=new ED(t,this._errorListener),this.table=new CD(t,this._errorListener),this.linefill=new bD(t),this.log=new cw(t),this.runtime=new fw(this._errorListener),this.strategy=new MD(this._variables,this._options,e,this._errorListener),this.request=new uw(this._variables,r),this.syminfo=new lw}get errors(){return this._errorListener.errors}options(e){if(e.length)return this._getDataOfBarindex(e);const t=this.input.getInputs(),r=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const n=Object.keys(this._bgColors);let i;if(n.length){i={};for(const m of n)i[m]=[...this._bgColors[m].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,u=this._fills.size?[...this._fills.values()]:void 0,f=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const c=this._plots.size>0?[...this._plots.values()]:void 0,h=this._plotbars.size>0?[...this._plotbars.values()]:void 0,d=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,p=this._plotarrows.size>0?[...this._plotarrows.values()]:void 0,v=this._plotcandles.size>0?[...this._plotcandles.values()]:void 0,x=this._plotchars.size>0?[...this._plotchars.values()]:void 0,_=this._getDraws(),y=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:t,plots:c,draws:_,alerts:r,colors:i,hlines:a,fills:u,logs:f,plotshapes:d,plotarrows:p,plotcandles:v,plotchars:x,plotbars:h,isUseBgColor:y})}_getDataOfBarindex(e){const t=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const r=Object.keys(this._bgColors);let n;if(r.length){n={};for(const p of r)n[p]=[...this._bgColors[p].values()].map(v=>{const x=[];for(const _ of e){const y=v.colors[_];y&&x.push(y)}return v.colors=x,v})}const i=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(e,[...this._fills.values()]):void 0,u=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const f=this._getDataFromBarindex(e,[...this._plots.values()]),c=this._plotshapes.size>0?this._getDataFromBarindex(e,[...this._plotshapes.values()]):void 0,h=this._getDrawsFromBarindex(e),d=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:f,draws:h,alerts:t,colors:n,hlines:i,fills:a,logs:u,plotshapes:c,isUseBgColor:d})}_getDataFromBarindex(e,t){return t.map(r=>{const n=[];for(const i of e){const a=r.data[i];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:e,linefill:t,table:r,box:n,polyline:i,label:a}=this._variables,u={};return e.data.length&&(u.lines=e.data),t.data.length&&(u.linefills=t.data),r.data.length&&(u.tables=r.data),n.data.length&&(u.boxes=n.data),i.data.length&&(u.polylines=i.data),a.data.length&&(u.labels=a.data),Object.keys(u).length?u:void 0}_getDrawsFromBarindex(e){const{line:t,linefill:r,table:n,box:i,polyline:a,label:u}=this._variables,f={};return t.data.length&&(f.lines=t.getValOfBarIndex(e)),r.data.length&&(f.linefills=r.getValOfBarIndex(e)),n.data.length&&(f.tables=n.getValOfBarIndex(e)),i.data.length&&(f.boxes=i.getValOfBarIndex(e)),a.data.length&&(f.polylines=a.getValOfBarIndex(e)),u.data.length&&(f.labels=u.getValOfBarIndex(e)),Object.keys(f).length?f:void 0}updateOptions(e){const{inputs:t}=e;t&&t.length&&this.input.update(t)}update(e){const{barIndex:t}=e;this.strategy.updateOptions(),this.math.update(t)}endExecution(){this.strategy.endExecution()}library(e,t){if(!this._variables.bar_index){const r=/^[^\W\d\s][^\W\s]*$/,{title:n}=e;r.test(n)?(y1.includes(n)||x1.includes(n))&&this._errorListener.addError(Zt(ct.libraryTitleIsKeywordErr,{name:n}),t,Ze.Error):this._errorListener.addError(ct.libraryTitleErr,t,Ze.Error),this._options.scriptType="library",this._options.library=e}}indicator(e,t){if(!this._variables.bar_index){const{format:r}=e;this._paramVerfiy(r,t,"indicator",[Je.inherit,Je.percent,Je.price,Je.volume]),this._variables.updateMaxLength(e),this._options.scriptType="indicator",this._options.indicator=e}}_paramVerfiy(e="",t,r,n,i="format"){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}plot(e,t){const r=["color"];_n(e,r);const{series:n,color:i,...a}=e,{bar_index:u,time:f}=this._variables,c=`plot_${t}`,h=this._plots.get(c),d=(h==null?void 0:h.data)||[],p=n!==void 0&&isNaN(n)?void 0:n;if(d[u]={value:[f,p],itemStyle:{color:i}},this._seriesColorHandle(e,r,h),!h){this._count++,this._paramVerfiy(e.format,t,"plot",[Je.percent,Je.price,Je.volume]);const v=i?[i]:void 0;this._plots.set(c,{editable:!0,...a,colors:v,data:d,id:c,zIndex:this._count})}return{type:"plot",key:c}}plotbar(e,t){const r=["color"];_n(e,r);const{open:n,close:i,low:a,high:u,color:f,...c}=e,{bar_index:h,time:d}=this._variables,p=`plotbar_${t}`,v=this._plotbars.get(p),x=(v==null?void 0:v.data)||[],_=i!==void 0&&isNaN(i)?void 0:i,y=n!==void 0&&isNaN(n)?void 0:n,m=a!==void 0&&isNaN(a)?void 0:a,w=u!==void 0&&isNaN(u)?void 0:u,D=[d,y,_,m,w];if(x[h]={value:D,itemStyle:{color:f}},this._seriesColorHandle(e,r,v),!v){this._count++,this._paramVerfiy(e.format,t,"plotbar",[Je.percent,Je.price,Je.volume]);const C=f?[f]:void 0;this._plotbars.set(p,{editable:!0,...c,colors:C,data:x,id:p,zIndex:this._count})}}_verfiyArgs(e,t,r){const{size:n,format:i,location:a,style:u}=e;this._paramVerfiy(u,r,t,Object.values(_r),"style"),this._paramVerfiy(a,r,t,Object.values(vn),"location"),this._paramVerfiy(n,r,t,Object.values(ar),"size"),this._paramVerfiy(i,r,t,[Je.percent,Je.price,Je.volume],"format")}plotchar(e,t){const r=["color","textcolor"];_n(e,r);const{series:n,color:i,textcolor:a,location:u=vn.abovebar,...f}=e,{bar_index:c,time:h,high:d,low:p}=this._variables,v=`plotchar_${t}`,x=this._plotchars.get(v),_=(x==null?void 0:x.data)||[],y={value:[h,n],itemStyle:{color:i,textcolor:a},low:p,high:d};_[c]=y,this._seriesColorHandle(e,r,x),x||(this._count++,this._verfiyArgs(e,"plotchar",t),this._plotchars.set(v,{editable:!0,...f,location:u,data:_,id:v,zIndex:this._count}))}plotarrow(e,t){const r=["colorup","colordown"];_n(e,r);const{series:n,colorup:i,colordown:a,...u}=e,{bar_index:f,time:c}=this._variables,h=`plotarrow_${t}`,d=this._plotarrows.get(h),p=(d==null?void 0:d.data)||[];p[f]={value:[c,n!==void 0&&isNaN(n)?void 0:n],itemStyle:{colorup:i,colordown:a}},this._seriesColorHandle(e,r,d),d||(this._count++,this._paramVerfiy(e.format,t,"plotarrow",[Je.percent,Je.price,Je.volume]),this._plotarrows.set(h,{editable:!0,...u,data:p,id:h,zIndex:this._count}))}plotshape(e,t){const r=["color","textcolor"];_n(e,r);const{series:n,color:i,textcolor:a,location:u=vn.abovebar,...f}=e,{bar_index:c,time:h,low:d,high:p}=this._variables,v=`plotshape_${t}`,x=this._plotshapes.get(v),_=(x==null?void 0:x.data)||[],y={value:n,color:i,textcolor:a,time:h,low:d,high:p};if(_[c]=y,this._seriesColorHandle(e,r,x),!x){this._count++;const m=i?[i]:void 0;this._verfiyArgs(e,"plotshape",t),this._plotshapes.set(v,{editable:!0,...f,data:_,location:u,id:v,colors:m,zIndex:this._count})}}plotcandle(e,t){const r=["wickcolor","bordercolor","color"];_n(e,r);const{wickcolor:n,bordercolor:i,color:a,close:u,open:f,low:c,high:h,...d}=e,{bar_index:p,time:v}=this._variables,x=`plotcandle_${t}`,_=this._plotcandles.get(x),y=(_==null?void 0:_.data)||[],m=u!==void 0&&isNaN(u)?void 0:u,w=f!==void 0&&isNaN(f)?void 0:f,D=c!==void 0&&isNaN(c)?void 0:c,C=h!==void 0&&isNaN(h)?void 0:h,b=[v,w,m,D,C];y[p]={value:b,wickcolor:n,bordercolor:i,color:a},this._seriesColorHandle(e,r,_),_||(this._count++,this._paramVerfiy(e.format,t,"plotcandle",[Je.percent,Je.price,Je.volume]),this._plotcandles.set(x,{editable:!0,...d,data:y,id:x,zIndex:this._count}))}hline(e,t){const r=`hline_${t}`;_n(e,["color"]),this._verifyDisplay(e.display,"hline",t);const i=e.display&&!e.display.length?Vt.none:Vt.all;return this._hlines.has(r)||(this._count++,this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:i,...e,zIndex:this._count})),{type:"hline",key:r}}fill(e,t){var F,B,M,O,A,N,I,L,k,z;const r=["color","top_color","bottom_color"];_n(e,r);const{color:n,top_color:i,bottom_color:a,seriesColors:u,hline1:f,hline2:c,plot1:h,plot2:d,...p}=e,{bar_index:v,time:x}=this._variables,_=`fill_${t}`,y=this._fills.get(_),m=(y==null?void 0:y.data)||[];this._verifyDisplay(e.display,"fill",t);const w=e.display&&!e.display.length?Vt.none:Vt.all;let D,C,b="plot";if(f&&c)D=(F=this._hlines.get(f==null?void 0:f.key))==null?void 0:F.price,C=(B=this._hlines.get(c==null?void 0:c.key))==null?void 0:B.price,b="hline";else{const R=((M=this._plots.get(h==null?void 0:h.key))==null?void 0:M.data)||[],V=((O=this._plots.get(d==null?void 0:d.key))==null?void 0:O.data)||[];D=(N=(A=R[v])==null?void 0:A.value)==null?void 0:N[1],C=(L=(I=V[v])==null?void 0:I.value)==null?void 0:L[1]}if(m[v]={time:x,color:n,top_color:i,bottom_color:a,plot1:D,plot2:C},this._seriesColorHandle(e,r,y),!y){this._count++;const R=((k=this._options.indicator)==null?void 0:k.explicit_plot_zorder)||((z=this._options.strategy)==null?void 0:z.explicit_plot_zorder),V=n?[n]:void 0,H=i?[i]:void 0,ee=a?[a]:void 0;this._fills.set(_,{id:_,colors:V,top_colors:H,bottom_colors:ee,display:w,data:m,type:b,editable:!0,fillgaps:!1,hline1:f,hline2:c,plot1:h,plot2:d,...p,zIndex:R?this._count:void 0})}}alert({message:e,freq:t=Zr.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:i,last_bar_index:a}=this._variables,u=`alert_${r}`,f=this._cacheData[u]||{},c=f.barIndex;if(this._paramVerfiy(t,r,"alert",[Zr.freqAll,Zr.freqOncePerBar,Zr.freqOncePerBarClose]),t===Zr.freqOncePerBar&&n===c){this._alerts.delete(u);return}this._cacheData[u]=f;const h={message:e,freq:t,id:u,type:"alert"};if(i){t!==Zr.freqOncePerBarClose&&this._alerts.set(u,h),f.barIndex=n;return}if(!i&&t===Zr.freqOncePerBarClose&&n===c&&a===n-1){this._alerts.set(u,h),f.barIndex=n;return}this._alerts.delete(u)}alertcondition({condition:e,message:t,title:r},n){const{_isRealTimeBar:i}=this._variables,a=`alertcondition_${n}`;i&&e?this._alerts.set(a,{message:t,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(e,t){this._setColors(e,"barcolor",t)}bgcolor(e,t){this._setColors(e,"bgcolor",t)}_verifyDisplay(e=Uf.all,t,r){e.length&&e.length<4&&this._errorListener.addError(Zt(ct.displayErr,{func:t,values:"[display.none, display.all]"}),r,Ze.Error)}_setColors(e,t,r){_n(e,["color"]);const{color:i,...a}=e;this._verifyDisplay(a.display,t,r);const u=e.display&&!e.display.length?Vt.none:Vt.all,{bar_index:f,time:c}=this._variables,h=`${t}_${r}`;this._bgColors[t]||(this._bgColors[t]=new Map);const d=this._bgColors[t].get(h),p=(d==null?void 0:d.colors)||[],v=(d==null?void 0:d.setColors)||[];i&&!v.includes(i)&&v.push(i),p[f]={color:i,time:c},d||this._bgColors[t].set(h,{...a,display:u,colors:p,setColors:v,id:h})}max_bars_back({var:e,num:t,var_name:r}){console.log(e,t,r)}float({x:e}){return e}bool({x:e}){return e||!1}string({x:e}){return e}int({x:e}){return e&&Math.trunc(e)}na({x:e}){return!!(e===void 0||isNaN(e))}fixnan({source:e},t){return e===void 0||isNaN(e)?this._cacheData[`fixnan_${t}`]:(this._cacheData[`fixnan_${t}`]=e,e)}nz({source:e,replacement:t}){return e!==void 0&&!isNaN(e)?e:t||0}time({timeframe:e="",session:t,timezone:r,bars_back:n=0},i){return this._timeHandle(this._variables.time,i,e,t,r,n)}time_close({timeframe:e="",session:t,timezone:r,bars_back:n=0},i){return this._variables.time_close&&this._timeHandle(this._variables.time_close,i,e,t,r,n)}timestamp(e){const{dateString:t,timezone:r,year:n,month:i,day:a,hour:u=0,minute:f=0,second:c=0}=e;if(t)return ot(t).utc(!/GMT|UTC/.test(t)).valueOf();let h=i-1,d=n;if(h<0){const v=Math.ceil(Math.abs(h/12));h=12*v+h,d=n-v}let p=ot({year:d,month:h,day:a,hour:u,minute:f,second:c});return r&&(p=Kr(p.utc(!0).valueOf(),r)),p.utc(!0).valueOf()}weekofyear({time:e,timezone:t}){return Kr(e,t).week()}year({time:e,timezone:t}){return Kr(e,t).year()}second({time:e,timezone:t}){return Kr(e,t).second()}month({time:e,timezone:t}){return Kr(e,t).month()+1}minute({time:e,timezone:t}){return Kr(e,t).minute()}hour({time:e,timezone:t}){return Kr(e,t).hour()}dayofweek({time:e,timezone:t}){return Kr(e,t).day()+1}dayofmonth({time:e,timezone:t}){return Kr(e,t).date()}_calcTimeOffset(e,t){const r=this._variables.getTimeTradingday(e,t),n=pn(t)*1e3;return e-r-Math.floor((e-r)/n)*n}_timeHandle(e,t,r="",n,i,a=0){const u=r||this._variables.timeframe.period,f=pn(u),c=pn(this._variables.timeframe.period);let h;if(f<=c)h=e;else{const d=`time_${t}`,p=this._cacheData[d];if(p)p.currentTime+f*1e3-p.offset<=e?(h=e,this._cacheData[d]={currentTime:e,offset:0}):h=p;else{const v=this._calcTimeOffset(e,u);this._cacheData[d]={currentTime:e,offset:v},h=e}}if(n){const{timePeriods:d,weeks:p}=this._parserSession(n,t),v=ot(e).format("YYYY-MM-DD"),x=h;h=void 0;for(const y of d){const[m,w]=y;if(ot(e).isBetween(`${v} ${m}`,`${v} ${w}`,"hour")){ot(x).isBetween(`${v} ${m}`,`${v} ${w}`,"hour")?h=x:h=ot(`${v} ${m}`).valueOf();break}}const _=this._variables.dayofweek;h&&!p.includes(_)&&(h=void 0)}return i&&(h=h&&Kr(h,i).valueOf()),h&&h-a*c*1e3}_seriesColorHandle(e,t,r){var n;if(r&&t!=null&&t.length)for(const i of t){if((n=r.gradientColorKeys)!=null&&n.includes(i))continue;const a=e[i];if(!a)continue;const u=r[`${i}s`]||[];u.includes(a)||(u.push(a),r[`${i}s`]=u,u.length>5&&(r[`${i}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(i)))}}_parserSession(e,t){const r=e.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(f=>{const c=parseInt(f,10);if(c<1||c>7){this._errorListener.addError(`Invalid day of week: ${f}`,t,Ze.Error);return}return c});return{timePeriods:n.split(",").map(f=>{f===""||f===yi.regular?f="0930-1500":f===yi.extended&&(f="1500-1830");const c=f.split("-");return c.length!==2?(this._errorListener.addError(`Invalid time period: ${f}`,t,Ze.Error),[]):[this._processTime(c[0],t),this._processTime(c[1],t)]}),weeks:a}}_processTime(e,t){const r=parseInt(e.slice(0,2),10),n=parseInt(e.slice(2),10);if(!(r>=0&&r<=23)&&n>=0&&n<=59){this._errorListener.addError("Invalid time: Time must be within 00:00 to 23:59",t,Ze.Error);return}return`${r}:${n}`}}var Vf={exports:{}};function LD(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ou={exports:{}},Gf;function Ve(){return Gf||(Gf=1,function(s,e){(function(t,r){s.exports=r()})(ye,function(){var t=t||function(r,n){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof ye<"u"&&ye.crypto&&(i=ye.crypto),!i&&typeof LD=="function")try{i=Fx}catch{}var a=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},u=Object.create||function(){function w(){}return function(D){var C;return w.prototype=D,C=new w,w.prototype=null,C}}(),f={},c=f.lib={},h=c.Base=function(){return{extend:function(w){var D=u(this);return w&&D.mixIn(w),(!D.hasOwnProperty("init")||this.init===D.init)&&(D.init=function(){D.$super.init.apply(this,arguments)}),D.init.prototype=D,D.$super=this,D},create:function(){var w=this.extend();return w.init.apply(w,arguments),w},init:function(){},mixIn:function(w){for(var D in w)w.hasOwnProperty(D)&&(this[D]=w[D]);w.hasOwnProperty("toString")&&(this.toString=w.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=c.WordArray=h.extend({init:function(w,D){w=this.words=w||[],D!=n?this.sigBytes=D:this.sigBytes=w.length*4},toString:function(w){return(w||v).stringify(this)},concat:function(w){var D=this.words,C=w.words,b=this.sigBytes,F=w.sigBytes;if(this.clamp(),b%4)for(var B=0;B<F;B++){var M=C[B>>>2]>>>24-B%4*8&255;D[b+B>>>2]|=M<<24-(b+B)%4*8}else for(var O=0;O<F;O+=4)D[b+O>>>2]=C[O>>>2];return this.sigBytes+=F,this},clamp:function(){var w=this.words,D=this.sigBytes;w[D>>>2]&=4294967295<<32-D%4*8,w.length=r.ceil(D/4)},clone:function(){var w=h.clone.call(this);return w.words=this.words.slice(0),w},random:function(w){for(var D=[],C=0;C<w;C+=4)D.push(a());return new d.init(D,w)}}),p=f.enc={},v=p.Hex={stringify:function(w){for(var D=w.words,C=w.sigBytes,b=[],F=0;F<C;F++){var B=D[F>>>2]>>>24-F%4*8&255;b.push((B>>>4).toString(16)),b.push((B&15).toString(16))}return b.join("")},parse:function(w){for(var D=w.length,C=[],b=0;b<D;b+=2)C[b>>>3]|=parseInt(w.substr(b,2),16)<<24-b%8*4;return new d.init(C,D/2)}},x=p.Latin1={stringify:function(w){for(var D=w.words,C=w.sigBytes,b=[],F=0;F<C;F++){var B=D[F>>>2]>>>24-F%4*8&255;b.push(String.fromCharCode(B))}return b.join("")},parse:function(w){for(var D=w.length,C=[],b=0;b<D;b++)C[b>>>2]|=(w.charCodeAt(b)&255)<<24-b%4*8;return new d.init(C,D)}},_=p.Utf8={stringify:function(w){try{return decodeURIComponent(escape(x.stringify(w)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(w){return x.parse(unescape(encodeURIComponent(w)))}},y=c.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(w){typeof w=="string"&&(w=_.parse(w)),this._data.concat(w),this._nDataBytes+=w.sigBytes},_process:function(w){var D,C=this._data,b=C.words,F=C.sigBytes,B=this.blockSize,M=B*4,O=F/M;w?O=r.ceil(O):O=r.max((O|0)-this._minBufferSize,0);var A=O*B,N=r.min(A*4,F);if(A){for(var I=0;I<A;I+=B)this._doProcessBlock(b,I);D=b.splice(0,A),C.sigBytes-=N}return new d.init(D,N)},clone:function(){var w=h.clone.call(this);return w._data=this._data.clone(),w},_minBufferSize:0});c.Hasher=y.extend({cfg:h.extend(),init:function(w){this.cfg=this.cfg.extend(w),this.reset()},reset:function(){y.reset.call(this),this._doReset()},update:function(w){return this._append(w),this._process(),this},finalize:function(w){w&&this._append(w);var D=this._doFinalize();return D},blockSize:16,_createHelper:function(w){return function(D,C){return new w.init(C).finalize(D)}},_createHmacHelper:function(w){return function(D,C){return new m.HMAC.init(w,C).finalize(D)}}});var m=f.algo={};return f}(Math);return t})}(ou)),ou.exports}var au={exports:{}},Xf;function Mo(){return Xf||(Xf=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(r){var n=t,i=n.lib,a=i.Base,u=i.WordArray,f=n.x64={};f.Word=a.extend({init:function(c,h){this.high=c,this.low=h}}),f.WordArray=a.extend({init:function(c,h){c=this.words=c||[],h!=r?this.sigBytes=h:this.sigBytes=c.length*8},toX32:function(){for(var c=this.words,h=c.length,d=[],p=0;p<h;p++){var v=c[p];d.push(v.high),d.push(v.low)}return u.create(d,this.sigBytes)},clone:function(){for(var c=a.clone.call(this),h=c.words=this.words.slice(0),d=h.length,p=0;p<d;p++)h[p]=h[p].clone();return c}})}(),t})}(au)),au.exports}var uu={exports:{}},Qf;function RD(){return Qf||(Qf=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(){if(typeof ArrayBuffer=="function"){var r=t,n=r.lib,i=n.WordArray,a=i.init,u=i.init=function(f){if(f instanceof ArrayBuffer&&(f=new Uint8Array(f)),(f instanceof Int8Array||typeof Uint8ClampedArray<"u"&&f instanceof Uint8ClampedArray||f instanceof Int16Array||f instanceof Uint16Array||f instanceof Int32Array||f instanceof Uint32Array||f instanceof Float32Array||f instanceof Float64Array)&&(f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength)),f instanceof Uint8Array){for(var c=f.byteLength,h=[],d=0;d<c;d++)h[d>>>2]|=f[d]<<24-d%4*8;a.call(this,h,c)}else a.apply(this,arguments)};u.prototype=i}}(),t.lib.WordArray})}(uu)),uu.exports}var lu={exports:{}},Jf;function PD(){return Jf||(Jf=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.WordArray,a=r.enc;a.Utf16=a.Utf16BE={stringify:function(f){for(var c=f.words,h=f.sigBytes,d=[],p=0;p<h;p+=2){var v=c[p>>>2]>>>16-p%4*8&65535;d.push(String.fromCharCode(v))}return d.join("")},parse:function(f){for(var c=f.length,h=[],d=0;d<c;d++)h[d>>>1]|=f.charCodeAt(d)<<16-d%2*16;return i.create(h,c*2)}},a.Utf16LE={stringify:function(f){for(var c=f.words,h=f.sigBytes,d=[],p=0;p<h;p+=2){var v=u(c[p>>>2]>>>16-p%4*8&65535);d.push(String.fromCharCode(v))}return d.join("")},parse:function(f){for(var c=f.length,h=[],d=0;d<c;d++)h[d>>>1]|=u(f.charCodeAt(d)<<16-d%2*16);return i.create(h,c*2)}};function u(f){return f<<8&4278255360|f>>>8&16711935}}(),t.enc.Utf16})}(lu)),lu.exports}var cu={exports:{}},eh;function oi(){return eh||(eh=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.WordArray,a=r.enc;a.Base64={stringify:function(f){var c=f.words,h=f.sigBytes,d=this._map;f.clamp();for(var p=[],v=0;v<h;v+=3)for(var x=c[v>>>2]>>>24-v%4*8&255,_=c[v+1>>>2]>>>24-(v+1)%4*8&255,y=c[v+2>>>2]>>>24-(v+2)%4*8&255,m=x<<16|_<<8|y,w=0;w<4&&v+w*.75<h;w++)p.push(d.charAt(m>>>6*(3-w)&63));var D=d.charAt(64);if(D)for(;p.length%4;)p.push(D);return p.join("")},parse:function(f){var c=f.length,h=this._map,d=this._reverseMap;if(!d){d=this._reverseMap=[];for(var p=0;p<h.length;p++)d[h.charCodeAt(p)]=p}var v=h.charAt(64);if(v){var x=f.indexOf(v);x!==-1&&(c=x)}return u(f,c,d)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function u(f,c,h){for(var d=[],p=0,v=0;v<c;v++)if(v%4){var x=h[f.charCodeAt(v-1)]<<v%4*2,_=h[f.charCodeAt(v)]>>>6-v%4*2,y=x|_;d[p>>>2]|=y<<24-p%4*8,p++}return i.create(d,p)}}(),t.enc.Base64})}(cu)),cu.exports}var fu={exports:{}},th;function kD(){return th||(th=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.WordArray,a=r.enc;a.Base64url={stringify:function(f,c){c===void 0&&(c=!0);var h=f.words,d=f.sigBytes,p=c?this._safe_map:this._map;f.clamp();for(var v=[],x=0;x<d;x+=3)for(var _=h[x>>>2]>>>24-x%4*8&255,y=h[x+1>>>2]>>>24-(x+1)%4*8&255,m=h[x+2>>>2]>>>24-(x+2)%4*8&255,w=_<<16|y<<8|m,D=0;D<4&&x+D*.75<d;D++)v.push(p.charAt(w>>>6*(3-D)&63));var C=p.charAt(64);if(C)for(;v.length%4;)v.push(C);return v.join("")},parse:function(f,c){c===void 0&&(c=!0);var h=f.length,d=c?this._safe_map:this._map,p=this._reverseMap;if(!p){p=this._reverseMap=[];for(var v=0;v<d.length;v++)p[d.charCodeAt(v)]=v}var x=d.charAt(64);if(x){var _=f.indexOf(x);_!==-1&&(h=_)}return u(f,h,p)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function u(f,c,h){for(var d=[],p=0,v=0;v<c;v++)if(v%4){var x=h[f.charCodeAt(v-1)]<<v%4*2,_=h[f.charCodeAt(v)]>>>6-v%4*2,y=x|_;d[p>>>2]|=y<<24-p%4*8,p++}return i.create(d,p)}}(),t.enc.Base64url})}(fu)),fu.exports}var hu={exports:{}},rh;function ai(){return rh||(rh=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(r){var n=t,i=n.lib,a=i.WordArray,u=i.Hasher,f=n.algo,c=[];(function(){for(var _=0;_<64;_++)c[_]=r.abs(r.sin(_+1))*4294967296|0})();var h=f.MD5=u.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(_,y){for(var m=0;m<16;m++){var w=y+m,D=_[w];_[w]=(D<<8|D>>>24)&16711935|(D<<24|D>>>8)&4278255360}var C=this._hash.words,b=_[y+0],F=_[y+1],B=_[y+2],M=_[y+3],O=_[y+4],A=_[y+5],N=_[y+6],I=_[y+7],L=_[y+8],k=_[y+9],z=_[y+10],R=_[y+11],V=_[y+12],H=_[y+13],ee=_[y+14],te=_[y+15],j=C[0],X=C[1],Y=C[2],Q=C[3];j=d(j,X,Y,Q,b,7,c[0]),Q=d(Q,j,X,Y,F,12,c[1]),Y=d(Y,Q,j,X,B,17,c[2]),X=d(X,Y,Q,j,M,22,c[3]),j=d(j,X,Y,Q,O,7,c[4]),Q=d(Q,j,X,Y,A,12,c[5]),Y=d(Y,Q,j,X,N,17,c[6]),X=d(X,Y,Q,j,I,22,c[7]),j=d(j,X,Y,Q,L,7,c[8]),Q=d(Q,j,X,Y,k,12,c[9]),Y=d(Y,Q,j,X,z,17,c[10]),X=d(X,Y,Q,j,R,22,c[11]),j=d(j,X,Y,Q,V,7,c[12]),Q=d(Q,j,X,Y,H,12,c[13]),Y=d(Y,Q,j,X,ee,17,c[14]),X=d(X,Y,Q,j,te,22,c[15]),j=p(j,X,Y,Q,F,5,c[16]),Q=p(Q,j,X,Y,N,9,c[17]),Y=p(Y,Q,j,X,R,14,c[18]),X=p(X,Y,Q,j,b,20,c[19]),j=p(j,X,Y,Q,A,5,c[20]),Q=p(Q,j,X,Y,z,9,c[21]),Y=p(Y,Q,j,X,te,14,c[22]),X=p(X,Y,Q,j,O,20,c[23]),j=p(j,X,Y,Q,k,5,c[24]),Q=p(Q,j,X,Y,ee,9,c[25]),Y=p(Y,Q,j,X,M,14,c[26]),X=p(X,Y,Q,j,L,20,c[27]),j=p(j,X,Y,Q,H,5,c[28]),Q=p(Q,j,X,Y,B,9,c[29]),Y=p(Y,Q,j,X,I,14,c[30]),X=p(X,Y,Q,j,V,20,c[31]),j=v(j,X,Y,Q,A,4,c[32]),Q=v(Q,j,X,Y,L,11,c[33]),Y=v(Y,Q,j,X,R,16,c[34]),X=v(X,Y,Q,j,ee,23,c[35]),j=v(j,X,Y,Q,F,4,c[36]),Q=v(Q,j,X,Y,O,11,c[37]),Y=v(Y,Q,j,X,I,16,c[38]),X=v(X,Y,Q,j,z,23,c[39]),j=v(j,X,Y,Q,H,4,c[40]),Q=v(Q,j,X,Y,b,11,c[41]),Y=v(Y,Q,j,X,M,16,c[42]),X=v(X,Y,Q,j,N,23,c[43]),j=v(j,X,Y,Q,k,4,c[44]),Q=v(Q,j,X,Y,V,11,c[45]),Y=v(Y,Q,j,X,te,16,c[46]),X=v(X,Y,Q,j,B,23,c[47]),j=x(j,X,Y,Q,b,6,c[48]),Q=x(Q,j,X,Y,I,10,c[49]),Y=x(Y,Q,j,X,ee,15,c[50]),X=x(X,Y,Q,j,A,21,c[51]),j=x(j,X,Y,Q,V,6,c[52]),Q=x(Q,j,X,Y,M,10,c[53]),Y=x(Y,Q,j,X,z,15,c[54]),X=x(X,Y,Q,j,F,21,c[55]),j=x(j,X,Y,Q,L,6,c[56]),Q=x(Q,j,X,Y,te,10,c[57]),Y=x(Y,Q,j,X,N,15,c[58]),X=x(X,Y,Q,j,H,21,c[59]),j=x(j,X,Y,Q,O,6,c[60]),Q=x(Q,j,X,Y,R,10,c[61]),Y=x(Y,Q,j,X,B,15,c[62]),X=x(X,Y,Q,j,k,21,c[63]),C[0]=C[0]+j|0,C[1]=C[1]+X|0,C[2]=C[2]+Y|0,C[3]=C[3]+Q|0},_doFinalize:function(){var _=this._data,y=_.words,m=this._nDataBytes*8,w=_.sigBytes*8;y[w>>>5]|=128<<24-w%32;var D=r.floor(m/4294967296),C=m;y[(w+64>>>9<<4)+15]=(D<<8|D>>>24)&16711935|(D<<24|D>>>8)&4278255360,y[(w+64>>>9<<4)+14]=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360,_.sigBytes=(y.length+1)*4,this._process();for(var b=this._hash,F=b.words,B=0;B<4;B++){var M=F[B];F[B]=(M<<8|M>>>24)&16711935|(M<<24|M>>>8)&4278255360}return b},clone:function(){var _=u.clone.call(this);return _._hash=this._hash.clone(),_}});function d(_,y,m,w,D,C,b){var F=_+(y&m|~y&w)+D+b;return(F<<C|F>>>32-C)+y}function p(_,y,m,w,D,C,b){var F=_+(y&w|m&~w)+D+b;return(F<<C|F>>>32-C)+y}function v(_,y,m,w,D,C,b){var F=_+(y^m^w)+D+b;return(F<<C|F>>>32-C)+y}function x(_,y,m,w,D,C,b){var F=_+(m^(y|~w))+D+b;return(F<<C|F>>>32-C)+y}n.MD5=u._createHelper(h),n.HmacMD5=u._createHmacHelper(h)}(Math),t.MD5})}(hu)),hu.exports}var du={exports:{}},nh;function ih(){return nh||(nh=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.WordArray,a=n.Hasher,u=r.algo,f=[],c=u.SHA1=a.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(h,d){for(var p=this._hash.words,v=p[0],x=p[1],_=p[2],y=p[3],m=p[4],w=0;w<80;w++){if(w<16)f[w]=h[d+w]|0;else{var D=f[w-3]^f[w-8]^f[w-14]^f[w-16];f[w]=D<<1|D>>>31}var C=(v<<5|v>>>27)+m+f[w];w<20?C+=(x&_|~x&y)+1518500249:w<40?C+=(x^_^y)+1859775393:w<60?C+=(x&_|x&y|_&y)-1894007588:C+=(x^_^y)-899497514,m=y,y=_,_=x<<30|x>>>2,x=v,v=C}p[0]=p[0]+v|0,p[1]=p[1]+x|0,p[2]=p[2]+_|0,p[3]=p[3]+y|0,p[4]=p[4]+m|0},_doFinalize:function(){var h=this._data,d=h.words,p=this._nDataBytes*8,v=h.sigBytes*8;return d[v>>>5]|=128<<24-v%32,d[(v+64>>>9<<4)+14]=Math.floor(p/4294967296),d[(v+64>>>9<<4)+15]=p,h.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var h=a.clone.call(this);return h._hash=this._hash.clone(),h}});r.SHA1=a._createHelper(c),r.HmacSHA1=a._createHmacHelper(c)}(),t.SHA1})}(du)),du.exports}var pu={exports:{}},sh;function _u(){return sh||(sh=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(r){var n=t,i=n.lib,a=i.WordArray,u=i.Hasher,f=n.algo,c=[],h=[];(function(){function v(m){for(var w=r.sqrt(m),D=2;D<=w;D++)if(!(m%D))return!1;return!0}function x(m){return(m-(m|0))*4294967296|0}for(var _=2,y=0;y<64;)v(_)&&(y<8&&(c[y]=x(r.pow(_,1/2))),h[y]=x(r.pow(_,1/3)),y++),_++})();var d=[],p=f.SHA256=u.extend({_doReset:function(){this._hash=new a.init(c.slice(0))},_doProcessBlock:function(v,x){for(var _=this._hash.words,y=_[0],m=_[1],w=_[2],D=_[3],C=_[4],b=_[5],F=_[6],B=_[7],M=0;M<64;M++){if(M<16)d[M]=v[x+M]|0;else{var O=d[M-15],A=(O<<25|O>>>7)^(O<<14|O>>>18)^O>>>3,N=d[M-2],I=(N<<15|N>>>17)^(N<<13|N>>>19)^N>>>10;d[M]=A+d[M-7]+I+d[M-16]}var L=C&b^~C&F,k=y&m^y&w^m&w,z=(y<<30|y>>>2)^(y<<19|y>>>13)^(y<<10|y>>>22),R=(C<<26|C>>>6)^(C<<21|C>>>11)^(C<<7|C>>>25),V=B+R+L+h[M]+d[M],H=z+k;B=F,F=b,b=C,C=D+V|0,D=w,w=m,m=y,y=V+H|0}_[0]=_[0]+y|0,_[1]=_[1]+m|0,_[2]=_[2]+w|0,_[3]=_[3]+D|0,_[4]=_[4]+C|0,_[5]=_[5]+b|0,_[6]=_[6]+F|0,_[7]=_[7]+B|0},_doFinalize:function(){var v=this._data,x=v.words,_=this._nDataBytes*8,y=v.sigBytes*8;return x[y>>>5]|=128<<24-y%32,x[(y+64>>>9<<4)+14]=r.floor(_/4294967296),x[(y+64>>>9<<4)+15]=_,v.sigBytes=x.length*4,this._process(),this._hash},clone:function(){var v=u.clone.call(this);return v._hash=this._hash.clone(),v}});n.SHA256=u._createHelper(p),n.HmacSHA256=u._createHmacHelper(p)}(Math),t.SHA256})}(pu)),pu.exports}var vu={exports:{}},oh;function zD(){return oh||(oh=1,function(s,e){(function(t,r,n){s.exports=r(Ve(),_u())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.WordArray,a=r.algo,u=a.SHA256,f=a.SHA224=u.extend({_doReset:function(){this._hash=new i.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var c=u._doFinalize.call(this);return c.sigBytes-=4,c}});r.SHA224=u._createHelper(f),r.HmacSHA224=u._createHmacHelper(f)}(),t.SHA224})}(vu)),vu.exports}var gu={exports:{}},ah;function uh(){return ah||(ah=1,function(s,e){(function(t,r,n){s.exports=r(Ve(),Mo())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.Hasher,a=r.x64,u=a.Word,f=a.WordArray,c=r.algo;function h(){return u.create.apply(u,arguments)}var d=[h(1116352408,3609767458),h(1899447441,602891725),h(3049323471,3964484399),h(3921009573,2173295548),h(961987163,4081628472),h(1508970993,3053834265),h(2453635748,2937671579),h(2870763221,3664609560),h(3624381080,2734883394),h(310598401,1164996542),h(607225278,1323610764),h(1426881987,3590304994),h(1925078388,4068182383),h(2162078206,991336113),h(2614888103,633803317),h(3248222580,3479774868),h(3835390401,2666613458),h(4022224774,944711139),h(264347078,2341262773),h(604807628,2007800933),h(770255983,1495990901),h(1249150122,1856431235),h(1555081692,3175218132),h(1996064986,2198950837),h(2554220882,3999719339),h(2821834349,766784016),h(2952996808,2566594879),h(3210313671,3203337956),h(3336571891,1034457026),h(3584528711,2466948901),h(113926993,3758326383),h(338241895,168717936),h(666307205,1188179964),h(773529912,1546045734),h(1294757372,1522805485),h(1396182291,2643833823),h(1695183700,2343527390),h(1986661051,1014477480),h(2177026350,1206759142),h(2456956037,344077627),h(2730485921,1290863460),h(2820302411,3158454273),h(3259730800,3505952657),h(3345764771,106217008),h(3516065817,3606008344),h(3600352804,1432725776),h(4094571909,1467031594),h(275423344,851169720),h(430227734,3100823752),h(506948616,1363258195),h(659060556,3750685593),h(883997877,3785050280),h(958139571,3318307427),h(1322822218,3812723403),h(1537002063,2003034995),h(1747873779,3602036899),h(1955562222,1575990012),h(2024104815,1125592928),h(2227730452,2716904306),h(2361852424,442776044),h(2428436474,593698344),h(2756734187,3733110249),h(3204031479,2999351573),h(3329325298,3815920427),h(3391569614,3928383900),h(3515267271,566280711),h(3940187606,3454069534),h(4118630271,4000239992),h(116418474,1914138554),h(174292421,2731055270),h(289380356,3203993006),h(460393269,320620315),h(685471733,587496836),h(852142971,1086792851),h(1017036298,365543100),h(1126000580,2618297676),h(1288033470,3409855158),h(1501505948,4234509866),h(1607167915,987167468),h(1816402316,1246189591)],p=[];(function(){for(var x=0;x<80;x++)p[x]=h()})();var v=c.SHA512=i.extend({_doReset:function(){this._hash=new f.init([new u.init(1779033703,4089235720),new u.init(3144134277,2227873595),new u.init(1013904242,4271175723),new u.init(2773480762,1595750129),new u.init(1359893119,2917565137),new u.init(2600822924,725511199),new u.init(528734635,4215389547),new u.init(1541459225,327033209)])},_doProcessBlock:function(x,_){for(var y=this._hash.words,m=y[0],w=y[1],D=y[2],C=y[3],b=y[4],F=y[5],B=y[6],M=y[7],O=m.high,A=m.low,N=w.high,I=w.low,L=D.high,k=D.low,z=C.high,R=C.low,V=b.high,H=b.low,ee=F.high,te=F.low,j=B.high,X=B.low,Y=M.high,Q=M.low,pe=O,De=A,we=N,be=I,Oe=L,Fe=k,nt=z,Ye=R,Ie=V,Le=H,yt=ee,Wt=te,Ct=j,lr=X,Rr=Y,cr=Q,Dt=0;Dt<80;Dt++){var It,P,Z=p[Dt];if(Dt<16)P=Z.high=x[_+Dt*2]|0,It=Z.low=x[_+Dt*2+1]|0;else{var J=p[Dt-15],ie=J.high,ue=J.low,se=(ie>>>1|ue<<31)^(ie>>>8|ue<<24)^ie>>>7,_e=(ue>>>1|ie<<31)^(ue>>>8|ie<<24)^(ue>>>7|ie<<25),he=p[Dt-2],de=he.high,fe=he.low,Xe=(de>>>19|fe<<13)^(de<<3|fe>>>29)^de>>>6,et=(fe>>>19|de<<13)^(fe<<3|de>>>29)^(fe>>>6|de<<26),dt=p[Dt-7],zt=dt.high,Tt=dt.low,nr=p[Dt-16],fr=nr.high,en=nr.low;It=_e+Tt,P=se+zt+(It>>>0<_e>>>0?1:0),It=It+et,P=P+Xe+(It>>>0<et>>>0?1:0),It=It+en,P=P+fr+(It>>>0<en>>>0?1:0),Z.high=P,Z.low=It}var wn=Ie&yt^~Ie&Ct,li=Le&Wt^~Le&lr,ms=pe&we^pe&Oe^we&Oe,xs=De&be^De&Fe^be&Fe,ys=(pe>>>28|De<<4)^(pe<<30|De>>>2)^(pe<<25|De>>>7),ki=(De>>>28|pe<<4)^(De<<30|pe>>>2)^(De<<25|pe>>>7),zi=(Ie>>>14|Le<<18)^(Ie>>>18|Le<<14)^(Ie<<23|Le>>>9),Ds=(Le>>>14|Ie<<18)^(Le>>>18|Ie<<14)^(Le<<23|Ie>>>9),qi=d[Dt],ws=qi.high,qn=qi.low,Qt=cr+Ds,mr=Rr+zi+(Qt>>>0<cr>>>0?1:0),Qt=Qt+li,mr=mr+wn+(Qt>>>0<li>>>0?1:0),Qt=Qt+qn,mr=mr+ws+(Qt>>>0<qn>>>0?1:0),Qt=Qt+It,mr=mr+P+(Qt>>>0<It>>>0?1:0),Ui=ki+xs,bs=ys+ms+(Ui>>>0<ki>>>0?1:0);Rr=Ct,cr=lr,Ct=yt,lr=Wt,yt=Ie,Wt=Le,Le=Ye+Qt|0,Ie=nt+mr+(Le>>>0<Ye>>>0?1:0)|0,nt=Oe,Ye=Fe,Oe=we,Fe=be,we=pe,be=De,De=Qt+Ui|0,pe=mr+bs+(De>>>0<Qt>>>0?1:0)|0}A=m.low=A+De,m.high=O+pe+(A>>>0<De>>>0?1:0),I=w.low=I+be,w.high=N+we+(I>>>0<be>>>0?1:0),k=D.low=k+Fe,D.high=L+Oe+(k>>>0<Fe>>>0?1:0),R=C.low=R+Ye,C.high=z+nt+(R>>>0<Ye>>>0?1:0),H=b.low=H+Le,b.high=V+Ie+(H>>>0<Le>>>0?1:0),te=F.low=te+Wt,F.high=ee+yt+(te>>>0<Wt>>>0?1:0),X=B.low=X+lr,B.high=j+Ct+(X>>>0<lr>>>0?1:0),Q=M.low=Q+cr,M.high=Y+Rr+(Q>>>0<cr>>>0?1:0)},_doFinalize:function(){var x=this._data,_=x.words,y=this._nDataBytes*8,m=x.sigBytes*8;_[m>>>5]|=128<<24-m%32,_[(m+128>>>10<<5)+30]=Math.floor(y/4294967296),_[(m+128>>>10<<5)+31]=y,x.sigBytes=_.length*4,this._process();var w=this._hash.toX32();return w},clone:function(){var x=i.clone.call(this);return x._hash=this._hash.clone(),x},blockSize:1024/32});r.SHA512=i._createHelper(v),r.HmacSHA512=i._createHmacHelper(v)}(),t.SHA512})}(gu)),gu.exports}var mu={exports:{}},lh;function qD(){return lh||(lh=1,function(s,e){(function(t,r,n){s.exports=r(Ve(),Mo(),uh())})(ye,function(t){return function(){var r=t,n=r.x64,i=n.Word,a=n.WordArray,u=r.algo,f=u.SHA512,c=u.SHA384=f.extend({_doReset:function(){this._hash=new a.init([new i.init(3418070365,3238371032),new i.init(1654270250,914150663),new i.init(2438529370,812702999),new i.init(355462360,4144912697),new i.init(1731405415,4290775857),new i.init(2394180231,1750603025),new i.init(3675008525,1694076839),new i.init(1203062813,3204075428)])},_doFinalize:function(){var h=f._doFinalize.call(this);return h.sigBytes-=16,h}});r.SHA384=f._createHelper(c),r.HmacSHA384=f._createHmacHelper(c)}(),t.SHA384})}(mu)),mu.exports}var xu={exports:{}},ch;function UD(){return ch||(ch=1,function(s,e){(function(t,r,n){s.exports=r(Ve(),Mo())})(ye,function(t){return function(r){var n=t,i=n.lib,a=i.WordArray,u=i.Hasher,f=n.x64,c=f.Word,h=n.algo,d=[],p=[],v=[];(function(){for(var y=1,m=0,w=0;w<24;w++){d[y+5*m]=(w+1)*(w+2)/2%64;var D=m%5,C=(2*y+3*m)%5;y=D,m=C}for(var y=0;y<5;y++)for(var m=0;m<5;m++)p[y+5*m]=m+(2*y+3*m)%5*5;for(var b=1,F=0;F<24;F++){for(var B=0,M=0,O=0;O<7;O++){if(b&1){var A=(1<<O)-1;A<32?M^=1<<A:B^=1<<A-32}b&128?b=b<<1^113:b<<=1}v[F]=c.create(B,M)}})();var x=[];(function(){for(var y=0;y<25;y++)x[y]=c.create()})();var _=h.SHA3=u.extend({cfg:u.cfg.extend({outputLength:512}),_doReset:function(){for(var y=this._state=[],m=0;m<25;m++)y[m]=new c.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(y,m){for(var w=this._state,D=this.blockSize/2,C=0;C<D;C++){var b=y[m+2*C],F=y[m+2*C+1];b=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360,F=(F<<8|F>>>24)&16711935|(F<<24|F>>>8)&4278255360;var B=w[C];B.high^=F,B.low^=b}for(var M=0;M<24;M++){for(var O=0;O<5;O++){for(var A=0,N=0,I=0;I<5;I++){var B=w[O+5*I];A^=B.high,N^=B.low}var L=x[O];L.high=A,L.low=N}for(var O=0;O<5;O++)for(var k=x[(O+4)%5],z=x[(O+1)%5],R=z.high,V=z.low,A=k.high^(R<<1|V>>>31),N=k.low^(V<<1|R>>>31),I=0;I<5;I++){var B=w[O+5*I];B.high^=A,B.low^=N}for(var H=1;H<25;H++){var A,N,B=w[H],ee=B.high,te=B.low,j=d[H];j<32?(A=ee<<j|te>>>32-j,N=te<<j|ee>>>32-j):(A=te<<j-32|ee>>>64-j,N=ee<<j-32|te>>>64-j);var X=x[p[H]];X.high=A,X.low=N}var Y=x[0],Q=w[0];Y.high=Q.high,Y.low=Q.low;for(var O=0;O<5;O++)for(var I=0;I<5;I++){var H=O+5*I,B=w[H],pe=x[H],De=x[(O+1)%5+5*I],we=x[(O+2)%5+5*I];B.high=pe.high^~De.high&we.high,B.low=pe.low^~De.low&we.low}var B=w[0],be=v[M];B.high^=be.high,B.low^=be.low}},_doFinalize:function(){var y=this._data,m=y.words;this._nDataBytes*8;var w=y.sigBytes*8,D=this.blockSize*32;m[w>>>5]|=1<<24-w%32,m[(r.ceil((w+1)/D)*D>>>5)-1]|=128,y.sigBytes=m.length*4,this._process();for(var C=this._state,b=this.cfg.outputLength/8,F=b/8,B=[],M=0;M<F;M++){var O=C[M],A=O.high,N=O.low;A=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,N=(N<<8|N>>>24)&16711935|(N<<24|N>>>8)&4278255360,B.push(N),B.push(A)}return new a.init(B,b)},clone:function(){for(var y=u.clone.call(this),m=y._state=this._state.slice(0),w=0;w<25;w++)m[w]=m[w].clone();return y}});n.SHA3=u._createHelper(_),n.HmacSHA3=u._createHmacHelper(_)}(Math),t.SHA3})}(xu)),xu.exports}var yu={exports:{}},fh;function WD(){return fh||(fh=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){/** @preserve
62
+ `)}}if(typeof e=="string")return e;if(typeof e=="boolean")return String(e);if(typeof e=="number")return String(this._toStringFormat(e,t))}_arrToStr(e,t){return`[${e.map(n=>typeof n=="number"?this._toStringFormat(n,t):n).toString()}]`}substring({source:e="",begin_pos:t=0,end_pos:r}){return me(t)&&(t=0),me(r)&&(r=void 0),e==null?void 0:e.substring(t,r)}startswith({source:e="",str:t=""}){return e==null?void 0:e.startsWith(t)}format_time({time:e,format:t="yyyy-MM-dd'T'HH:mm:ssZ",timezone:r}){return me(e)&&(e=0),Kr(e,r).format(t)}replace_all({source:e="",target:t="",replacement:r=""}){return e==null?void 0:e.replace(new RegExp(t,"g"),r)}_toStringFormat(e,t){if(!t)return e;switch(t){case Je.mintick:return e.toFixed(this._precision);case Je.price:return`${e}%`;case Je.volume:return this._intlNumberFormatter.format(Math.round(e));default:const[r,n]=t.split(".");let[i,a=""]=String(e).split(".");if(r.includes("#")?i=r.replace(/#/,i).replace(/#/g,""):i=`${r}${i}`,n&&n.includes("#")){const u=n.split("#").length-1;a=`${a.substring(0,u)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${i}.${a}`:i}}_formatNumber(e,t){if(!t)return e;switch(t){case"integer":return String(Math.round(e));case"currency":return`$${e}`;case"percent":return`${e*100}%`;default:const r=t.split(".")[1],n=r?r.length:0;return parseFloat(e.toFixed(n))}}_strFormat(e,t){let r=e;return t.forEach((n,i)=>{if(typeof n=="number"){const a=`\\{\\s*${i}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,u=e.match(new RegExp(a));if(u){const f=u[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(n,f)))}else r=r.replace(new RegExp(`\\{${i}\\}`,"g"),String(n))}else r=r.replace(new RegExp(`\\{${i}\\}`,"g"),n)}),r}}class Qy{constructor(e){q(this,"_errorListener");this._errorListener=e}new(){return new iu(this._errorListener)}copy({id:e}){return e==null?void 0:e.copy()}get({id:e,key:t}){return e==null?void 0:e.get({key:t})}put({id:e,key:t,value:r}){return e==null?void 0:e.put({key:t,value:r})}keys({id:e}){return e==null?void 0:e.keys()}size({id:e}){return e==null?void 0:e.size()}clear({id:e}){e==null||e.clear()}remove({id:e,key:t}){return e==null?void 0:e.remove({key:t})}values({id:e}){return e==null?void 0:e.values()}put_all({id:e,id2:t}){e==null||e.put_all({id2:t})}contains({id:e,key:t}){return e==null?void 0:e.contains({key:t})}}class iu{constructor(e){q(this,"_errorListener");q(this,"_mapInstance");this._errorListener=e,this._mapInstance=new Map}get isMap(){return!0}_copyMap(e){const t=new iu(this._errorListener);return t._mapInstance=new Map(e.entries()),t}copy(){return this._copyMap(this._mapInstance)}get({key:e}){return this._mapInstance.get(e)}put({key:e,value:t}){return this._mapInstance.set(e,t)}keys(){const e=new it(0,void 0,this._errorListener);return e._value=[...this._mapInstance.keys()],e}size(){return this._mapInstance.size}clear(){this._mapInstance.clear()}remove({key:e}){const t=this._mapInstance.get(e);return this._mapInstance.delete(e),t||void 0}values(){const e=new it(0,void 0,this._errorListener);return e._value=[...this._mapInstance.values()],e}put_all({id2:e}){this._mapInstance=new Map([...this._mapInstance,...e._mapInstance])}contains({key:e}){return this._mapInstance.has(e)}}class Jy{constructor(e){q(this,"_variables");this._variables=e}new({price:e,time:t,index:r}){return new Ti(e,r,t)}now({price:e}){const{time:t,bar_index:r}=this._variables;return new Ti(e,r,t)}copy({id:e}){return e==null?void 0:e.copy()}from_index({price:e,index:t}){return new Ti(e,t)}from_time({price:e,time:t}){return new Ti(e,void 0,t)}}class Ti{constructor(e,t,r){q(this,"_index");q(this,"_price");q(this,"_time");this._index=t,this._price=e,this._time=r}get index(){return this._index}get price(){return this._price}get time(){return this._time}copy(){return new Ti(this._price,this._index,this._time)}}class eD{constructor(e,t){q(this,"_variables");q(this,"_errorListener");q(this,"_defaultLabel",{text:"",xloc:bt.bar_index,yloc:Gr.price,size:ar.normal,style:gt.styleLabelDown,textalign:je.alignCenter});this._variables=e,this._errorListener=t}new(e,t){const{time:r,high:n,low:i,bar_index:a}=this._variables,u=`label_${t}_${a}`,f={...this._defaultLabel,...e,id:u,time:r,high:n,low:i};e.point&&(f.x=f.xloc===bt.bar_index?e.point.index:e.point.time,f.y=e.point.price),f.yloc===Gr.abovebar?f.y=n:f.yloc===Gr.belowbar&&(f.y=i),this._verfiyArgs(e,t);const c=new ps(u,this._variables,this._errorListener);return t.startsWith("export")||this._variables.label.add(u,f,c),c}_verfiyArgs(e,t){const{xloc:r,yloc:n,style:i,size:a,textalign:u,text_font_family:f}=e,c="label.new";this._paramVerfiy(i,t,c,Object.values(gt),"style"),this._paramVerfiy(r,t,c,Object.values(bt),"xloc"),this._paramVerfiy(n,t,c,Object.values(Gr),"yloc"),this._paramVerfiy(a,t,c,Object.values(ar),"size"),this._paramVerfiy(u,t,c,[je.alignLeft,je.alignCenter,je.alignRight],"textalign"),this._paramVerfiy(f,t,c,Object.values(ei),"text_font_family")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}label(e,t){return e.x?e.x:new ps(t,this._variables,this._errorListener)}copy({id:e},t){return e==null?void 0:e.copy(t)}get_x({id:e},t){return e==null?void 0:e.get_x(t)}get_y({id:e},t){return e==null?void 0:e.get_y(t)}set_x({id:e,...t},r){e==null||e.set_x(t,r)}set_y({id:e,...t},r){e==null||e.set_y(t,r)}delete({id:e}){e==null||e.delete()}get_text({id:e},t){return e==null?void 0:e.get_text(t)}set_xy({id:e,...t},r){e==null||e.set_xy(t,r)}set_size({id:e,...t},r){e==null||e.set_size(t,r)}set_xloc({id:e,...t},r){e==null||e.set_xloc(t,r)}set_yloc({id:e,...t},r){e==null||e.set_yloc(t,r)}set_style({id:e,...t},r){e==null||e.set_style(t,r)}set_color({id:e,...t},r){e==null||e.set_color(t,r)}set_tooltip({id:e,...t},r){e==null||e.set_tooltip(t,r)}set_point({id:e,...t},r){e==null||e.set_point(t,r)}set_text({id:e,...t},r){e==null||e.set_text(t,r)}set_textcolor({id:e,...t},r){e==null||e.set_textcolor(t,r)}set_textalign({id:e,...t},r){e==null||e.set_textalign(t,r)}set_text_font_family({id:e,...t},r){e==null||e.set_text_font_family(t,r)}}class ps{constructor(e,t,r){q(this,"_id");q(this,"_variables");q(this,"_errorListener");this._id=e,this._variables=t,this._errorListener=r}copy(e){const t=`label_${e}_${this._variables.bar_index}`,r=this._getLabel(e),n=new ps(t,this._variables,this._errorListener);if(r){const i={...r,id:t};this._variables.label.add(t,i,n)}return n}get_x(e){var t;return(t=this._getLabel(e))==null?void 0:t.x}get_y(e){var t;return(t=this._getLabel(e))==null?void 0:t.y}set_x({x:e},t){const r=this._getLabel(t);r&&(r.x=e)}set_y({y:e},t){const r=this._getLabel(t);r&&(r.y=e)}delete(){this._variables.label.delete(this._id)}set_xy({x:e,y:t},r){const n=this._getLabel(r);n&&(n.x=e,n.y=t)}get_text(e){var t;return(t=this._getLabel(e))==null?void 0:t.text}set_size({size:e},t){const r=this._getLabel(t);r&&(r.size=e),this._paramVerfiy(e,t,"label.set_size",Object.values(ar),"size")}set_text({text:e},t){const r=this._getLabel(t);r&&(r.text=e)}set_xloc({x:e,xloc:t},r){const n=this._getLabel(r);n&&(n.x=e,n.xloc=t,this._paramVerfiy(t,r,"label.set_xloc",Object.values(bt),"xloc"))}set_yloc({yloc:e},t){const r=this._getLabel(t),{high:n,low:i}=this._variables;r&&(r.yloc=e,e===Gr.abovebar?r.y=n:e===Gr.belowbar&&(r.y=i),this._paramVerfiy(e,t,"label.set_yloc",Object.values(Gr),"yloc"))}set_color({color:e},t){const r=this._getLabel(t);r&&(r.color=e)}set_point({point:e},t){const r=this._getLabel(t);r&&(r.x=r.xloc===bt.bar_index?e==null?void 0:e.index:e==null?void 0:e.time,r.y=e==null?void 0:e.price)}set_style({style:e},t){const r=this._getLabel(t);r&&(r.style=e),this._paramVerfiy(e,t,"label.set_style",Object.values(gt),"style")}set_tooltip({tooltip:e},t){const r=this._getLabel(t);r&&(r.tooltip=e)}set_textalign({textalign:e},t){const r=this._getLabel(t);r&&(r.textalign=e),this._paramVerfiy(e,t,"label.set_textalign",[je.alignLeft,je.alignCenter,je.alignRight],"textalign")}set_textcolor({textcolor:e},t){const r=this._getLabel(t);r&&(r.textcolor=e)}set_text_font_family({text_font_family:e},t){const r=this._getLabel(t);r&&(r.text_font_family=e),this._paramVerfiy(e,t,"label.set_text_font_family",Object.values(ei),"text_font_family")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}_getLabel(e){const t=this._variables.label.get(this._id);return t||console.log(`错误${e}: label 不存在`),t}}const tD={freq_all:Zr.freqAll,freq_once_per_bar:Zr.freqOncePerBar,freq_once_per_bar_close:Zr.freqOncePerBarClose},rD={gaps_off:ss.gapsOff,gaps_on:ss.gapsOn,lookahead_off:ss.lookaheadOff,lookahead_on:ss.lookaheadOn},$i={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#FF5252",silver:"#B2B5BE",teal:"#00897B",white:"#FFFFFF",yellow:"#FFEB3B"},qf={AUD:"AUD",BTC:"BTC",CAD:"CAD",CHF:"CHF",ETH:"ETH",EUR:"EUR",GBP:"GBP",HKD:"HKD",INR:"INR",JPY:"JPY",KRW:"KRW",MYR:"MYR",NOK:"NOK",NONE:"NONE",NZD:"NZD",RUB:"RUB",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",USDT:"USDT",ZAR:"ZAR"},nD={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Uf={all:[Vt.dataWindow,Vt.pane,Vt.priceScale,Vt.statusLine],data_window:[Vt.dataWindow],none:[],pane:[Vt.pane],price_scale:[Vt.priceScale],status_line:[Vt.statusLine]},iD={both:Vr.both,left:Vr.left,none:Vr.none,right:Vr.right},sD={inherit:Je.inherit,mintick:Je.mintick,percent:Je.percent,price:Je.price,volume:Je.volume},oD={style_solid:qs.styleSolid,style_dashed:qs.styleDashed,style_dotted:qs.styleDotted},aD={style_arrowdown:gt.styleArrowdown,style_arrowup:gt.styleArrowup,style_circle:gt.styleCircle,style_cross:gt.styleCross,style_diamond:gt.styleDiamond,style_flag:gt.styleFlag,style_label_center:gt.styleLabelCenter,style_label_down:gt.styleLabelDown,style_label_left:gt.styleLabelLeft,style_label_lower_left:gt.styleLabelLowerLeft,style_label_lower_right:gt.styleLabelLowerRight,style_label_right:gt.styleLabelRight,style_label_up:gt.styleLabelUp,style_label_upper_left:gt.styleLabelUpperLeft,style_label_upper_right:gt.styleLabelUpperRight,style_none:gt.styleNone,style_square:gt.styleSquare,style_text_outline:gt.styleTextOutline,style_triangledown:gt.styleTriangledown,style_triangleup:gt.styleTriangleup,style_xcross:gt.styleXcross},uD={style_arrow_both:qt.styleArrowBoth,style_arrow_left:qt.styleArrowLeft,style_arrow_right:qt.styleArrowRight,style_dashed:qt.styleDashed,style_dotted:qt.styleDotted,style_solid:qt.styleSolid},lD={abovebar:vn.abovebar,absolute:vn.absolute,belowbar:vn.belowbar,bottom:vn.bottom,top:vn.top},cD={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},fD={style_area:Or.styleArea,style_areabr:Or.styleAreabr,style_circles:Or.styleCircles,style_columns:Or.styleColumns,style_cross:Or.styleCross,style_histogram:Or.styleHistogram,style_line:Or.styleLine,style_linebr:Or.styleLinebr,style_stepline:Or.styleStepline,style_stepline_diamond:Or.styleSteplineDiamond,style_steplinebr:Or.styleSteplinebr},hD={bottom_center:br.bottomCenter,bottom_left:br.bottomLeft,bottom_right:br.bottomRight,middle_center:br.middleCenter,middle_left:br.middleLeft,middle_right:br.middleRight,top_center:br.topCenter,top_left:br.topLeft,top_right:br.topRight},dD={left:Us.left,none:Us.none,right:Us.right},pD={arrowdown:_r.arrowdown,arrowup:_r.arrowup,circle:_r.circle,cross:_r.cross,diamond:_r.diamond,flag:_r.flag,labeldown:_r.labeldown,labelup:_r.labelup,square:_r.square,triangledown:_r.triangledown,triangleup:_r.triangleup,xcross:_r.xcross},_D={auto:ar.auto,huge:ar.huge,large:ar.large,normal:ar.normal,small:ar.small,tiny:ar.tiny},vD={cash:Rt.cash,fixed:Rt.fixed,percent_of_equity:Rt.percentOfEquity,commission:{cash_per_contract:Ir.cashPerContract,cash_per_order:Ir.cashPerOrder,percent:Ir.percent},direction:{all:mt.all,long:mt.long,short:mt.short},oca:{cancel:gn.cancel,none:gn.none,reduce:gn.reduce}},gD={align_bottom:je.alignBottom,align_center:je.alignCenter,align_left:je.alignLeft,align_right:je.alignRight,align_top:je.alignTop,wrap_auto:je.wrapAuto,wrap_none:je.wrapNone},mD={bar_index:bt.bar_index,bar_time:bt.bar_time},xD={abovebar:Gr.abovebar,belowbar:Gr.belowbar,price:Gr.price},yD={actual:Ws.actual,estimate:Ws.estimate,standardized:Ws.standardized};class Wf{constructor(){q(this,"adjustment",{dividends:zs.dividends,none:zs.none,splits:zs.splits});q(this,"alert",tD);q(this,"barmerge",rD);q(this,"color",$i);q(this,"currency",qf);q(this,"dayofweek",nD);q(this,"earnings",yD);q(this,"display",Uf);q(this,"extend",iD);q(this,"font",{family_default:ei.familyDefault,family_monospace:ei.familyMonospace});q(this,"format",sD);q(this,"hline",oD);q(this,"label",aD);q(this,"line",uD);q(this,"location",lD);q(this,"math",cD);q(this,"order",{ascending:Jn.ascending,descending:Jn.descending});q(this,"plot",fD);q(this,"position",hD);q(this,"scale",dD);q(this,"session",{extended:yi.extended,regular:yi.regular});q(this,"shape",pD);q(this,"size",_D);q(this,"splits",{denominator:"denominator",numerator:"numerator"});q(this,"strategy",vD);q(this,"text",gD);q(this,"xloc",mD);q(this,"yloc",xD)}updateData(){}}class DD{constructor(e,t){q(this,"_variables");q(this,"_errorListener");q(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:bt.bar_index,line_color:$i.blue,line_style:qt.styleSolid,line_width:1});this._variables=e,this._errorListener=t}new(e,t){var a;const r=`polyline_${t}_${this._variables.bar_index}`,n=Object.assign({},this._defaultPolyline,e,{id:r,points:(a=e.points)==null?void 0:a._value.map(u=>({time:u.time,index:u.index,price:u.price}))}),i=new Hf(r,this._variables);return this._verfiyArgs(e,t),t.startsWith("export")||this._variables.polyline.add(r,n,i),i}_verfiyArgs(e,t){const{line_style:r,xloc:n}=e,i="polyline.new";this._paramVerfiy(r,t,i,Object.values(qt),"line_style"),this._paramVerfiy(n,t,i,Object.values(bt),"xloc")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}delete({id:e}){e&&e.delete()}}class Hf{constructor(e,t){q(this,"_id");q(this,"_variables");this._variables=t,this._id=e}delete(){this._variables.polyline.delete(this._id)}}class wD{constructor(e,t){q(this,"_variables");q(this,"_errorListener");q(this,"_defaultLine",{xloc:bt.bar_index,extend:Vr.none,style:qt.styleSolid});this._variables=e,this._errorListener=t}new({first_point:e,second_point:t,...r},n){const i=`line_${n}_${this._variables.bar_index}`,a={...this._defaultLine,...r,id:i};if(e&&t){const f=a.xloc===bt.bar_index?e.index:e.time,c=a.xloc===bt.bar_index?t.index:t.time;Object.assign(a,{x1:f,y1:e.price,x2:c,y2:t.price})}this._verfiyArgs(r,n);const u=new _s(i,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(i,a,u),u}_verfiyArgs(e,t){const{extend:r,xloc:n,style:i}=e,a="line.new";this._paramVerfiy(i,t,a,Object.values(qt),"style"),this._paramVerfiy(r,t,a,Object.values(Vr),"extend"),this._paramVerfiy(n,t,a,Object.values(bt),"xloc")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}line(e,t){return e.x?e.x:new _s(t,this._variables,this._errorListener)}copy({id:e},t){return e==null?void 0:e.copy(t)}delete({id:e}){e==null||e.delete()}get_x1({id:e},t){return e==null?void 0:e.get_x1(t)}get_x2({id:e},t){return e==null?void 0:e.get_x2(t)}get_y1({id:e},t){return e==null?void 0:e.get_y1(t)}get_y2({id:e},t){return e==null?void 0:e.get_y2(t)}set_x1({id:e,...t},r){e==null||e.set_x1(t,r)}set_x2({id:e,...t},r){e==null||e.set_x2(t,r)}set_y1({id:e,...t},r){e==null||e.set_y1(t,r)}set_y2({id:e,...t},r){e==null||e.set_y2(t,r)}set_xy1({id:e,...t},r){e==null||e.set_xy1(t,r)}set_xy2({id:e,...t},r){e==null||e.set_xy2(t,r)}set_xloc({id:e,...t},r){e==null||e.set_xloc(t,r)}get_price({id:e,...t},r){return e==null?void 0:e.get_price(t,r)}set_color({id:e,...t},r){e==null||e.set_color(t,r)}set_style({id:e,...t},r){e==null||e.set_style(t,r)}set_width({id:e,...t},r){e==null||e.set_width(t,r)}set_extend({id:e,...t},r){e==null||e.set_extend(t,r)}set_first_point({id:e,...t},r){e==null||e.set_first_point(t,r)}set_second_point({id:e,...t},r){e==null||e.set_second_point(t,r)}}class _s{constructor(e,t,r){q(this,"_variables");q(this,"_id");q(this,"_errorListener");this._id=e,this._variables=t,this._errorListener=r}get data(){return this._variables.line.get(this._id)}copy(e){const t=`line_${e}_${this._variables.bar_index}`,r=this._getLine(e),n=new _s(t,this._variables,this._errorListener);return r&&this._variables.line.add(t,{...r,id:t},n),n}delete(){this._variables.line.delete(this._id)}get_price({x:e},t){const r=this._getLine(t);if(e===void 0)return e;if(r&&r.xloc===bt.bar_index){const{x1:n,y1:i,x2:a,y2:u}=r;return n===void 0||a===void 0||i===void 0||u===void 0?void 0:(u-i)/(a-n)*(e-n)+i}}get_x1(e){var t;return(t=this._getLine(e))==null?void 0:t.x1}get_x2(e){var t;return(t=this._getLine(e))==null?void 0:t.x2}get_y1(e){var t;return(t=this._getLine(e))==null?void 0:t.y1}get_y2(e){var t;return(t=this._getLine(e))==null?void 0:t.y2}set_x1({x:e},t){const r=this._getLine(t);r&&(r.x1=e)}set_x2({x:e},t){const r=this._getLine(t);r&&(r.x2=e)}set_y1({y:e},t){const r=this._getLine(t);r&&(r.y1=e)}set_y2({y:e},t){const r=this._getLine(t);r&&(r.y2=e)}set_xy1({x:e,y:t},r){const n=this._getLine(r);n&&(n.x1=e,n.y1=t)}set_xy2({x:e,y:t},r){const n=this._getLine(r);n&&(n.x2=e,n.y2=t)}set_xloc({xloc:e,x1:t,x2:r},n){const i=this._getLine(n);i&&(i.xloc=e,i.x1=t,i.x2=r,this._paramVerfiy(e,n,"line.set_xloc",Object.values(bt),"xloc"))}set_color({color:e},t){const r=this._getLine(t);r&&(r.color=e)}set_style({style:e},t){const r=this._getLine(t);r&&(r.style=e,this._paramVerfiy(e,t,"line.set_style",Object.values(qt),"style"))}set_width({width:e},t){const r=this._getLine(t);r&&(r.width=e)}set_extend({extend:e},t){const r=this._getLine(t);r&&(r.extend=e,this._paramVerfiy(e,t,"line.set_extend",Object.values(Vr),"extend"))}set_first_point({point:e},t){const r=this._getLine(t);if(r){const{index:n,time:i,price:a}=e||{},u=r.xloc===bt.bar_index?n:i,f=a;u&&(r.x1=u),f&&(r.y1=f)}}set_second_point({point:e},t){const r=this._getLine(t);if(r){const{index:n,time:i,price:a}=e||{},u=r.xloc===bt.bar_index?n:i,f=a;u&&(r.x2=u),f&&(r.y2=f)}}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}_getLine(e){const t=this._variables.line.get(this._id);return t||console.log(`${e}: line 不存在`),t}}class bD{constructor(e){q(this,"_variables");this._variables=e}new({line1:e,line2:t,color:r},n){const i=`linefill_${n}_${this._variables.bar_index}`,a=e==null?void 0:e.data,u=t==null?void 0:t.data;a&&(a.linefills=a.linefills||[],a.linefills.push(i)),u&&(u.linefills=u.linefills||[],u.linefills.push(i));const f=new Bo(this._variables,i,e,t);return n.startsWith("export")||(a||u)&&this._variables.linefill.add(i,{line1:a,line2:u,color:r,id:i},f),f}delete({id:e}){e==null||e.delete()}get_line1({id:e}){return e==null?void 0:e.get_line1()}get_line2({id:e}){return e==null?void 0:e.get_line2()}set_color({id:e,...t}){e==null||e.set_color(t)}}class Bo{constructor(e,t,r,n){q(this,"_id");q(this,"_line1");q(this,"_line2");q(this,"_variables");this._variables=e,this._id=t,this._line1=r,this._line2=n}linefill(e,t){return e.x?e.x:new Bo(this._variables,t)}delete(){var t,r;const e=this._variables.linefill.get(this._id);if(e){const{line1:n,line2:i}=e;n&&(n.linefills=(t=n.linefills)==null?void 0:t.filter(a=>a!==this._id)),i&&(i.linefills=(r=i.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id)}get_line1(){return this._line1}get_line2(){return this._line2}set_color({color:e}){const t=this._variables.linefill.get(this._id);t&&(t.color=e)}}class ED{constructor(e,t){q(this,"_variables");q(this,"_errorListener");q(this,"_defaultBox",{border_color:$i.blue,border_width:1,bgcolor:$i.blue,xloc:bt.bar_index,extend:Vr.none,style:qt.styleSolid,text:"",text_size:ar.auto,text_color:$i.black,text_halign:je.alignCenter,text_valign:je.alignCenter,text_wrap:je.wrapNone});this._variables=e,this._errorListener=t}box({x:e},t){return e===void 0?new vs(this._variables,t,this._errorListener):e}new({top_left:e,bottom_right:t,...r},n){const i=`box_${n}_${this._variables.bar_index}`,a={...this._defaultBox,...r,id:i};if(e){const{price:f,time:c,index:h}=e;a.top=f,a.left=a.xloc===bt.bar_index?h:c}if(t){const{price:f,time:c,index:h}=t;a.bottom=f,a.right=a.xloc===bt.bar_index?h:c}this._verfiyArgs(r,n);const u=new vs(this._variables,i,this._errorListener);return n.startsWith("export")||this._variables.box.add(i,a,u),u}_verfiyArgs(e,t){const{border_style:r,extend:n,xloc:i,text_size:a,text_halign:u,text_valign:f,text_wrap:c,text_font_family:h}=e,d="box.new";this._paramVerfiy(r,t,d,[qt.styleDashed,qt.styleDotted,qt.styleSolid],"border_style"),this._paramVerfiy(n,t,d,Object.values(Vr),"extend"),this._paramVerfiy(i,t,d,Object.values(bt),"xloc"),this._paramVerfiy(a,t,d,Object.values(ar),"text_size"),this._paramVerfiy(u,t,d,[je.alignLeft,je.alignCenter,je.alignRight],"text_halign"),this._paramVerfiy(f,t,d,[je.alignBottom,je.alignCenter,je.alignTop],"text_valign"),this._paramVerfiy(c,t,d,[je.wrapAuto,je.wrapNone],"text_wrap"),this._paramVerfiy(h,t,d,Object.values(ei),"text_font_family")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}copy({id:e},t){return e==null?void 0:e.copy(t)}delete({id:e}){e==null||e.delete()}get_top({id:e}){return e==null?void 0:e.get_top()}get_bottom({id:e}){return e==null?void 0:e.get_bottom()}get_left({id:e}){return e==null?void 0:e.get_left()}get_right({id:e}){return e==null?void 0:e.get_right()}set_top({id:e,...t}){e==null||e.set_top(t)}set_bottom({id:e,...t}){e==null||e.set_bottom(t)}set_left({id:e,...t}){e==null||e.set_left(t)}set_right({id:e,...t}){e==null||e.set_right(t)}set_extend({id:e,...t},r){e==null||e.set_extend(t,r)}set_bgcolor({id:e,...t}){e==null||e.set_bgcolor(t)}set_border_color({id:e,...t}){e==null||e.set_border_color(t)}set_border_width({id:e,...t}){e==null||e.set_border_width(t)}set_border_style({id:e,...t},r){e==null||e.set_border_style(t,r)}set_lefttop({id:e,...t}){e==null||e.set_lefttop(t)}set_rightbottom({id:e,...t}){e==null||e.set_rightbottom(t)}set_text_size({id:e,...t},r){e==null||e.set_text_size(t,r)}set_text_wrap({id:e,...t},r){e==null||e.set_text_wrap(t,r)}set_text_color({id:e,...t}){e==null||e.set_text_color(t)}set_text_halign({id:e,...t},r){e==null||e.set_text_halign(t,r)}set_text_valign({id:e,...t},r){e==null||e.set_text_valign(t,r)}set_top_left_point({id:e,...t}){e==null||e.set_top_left_point(t)}set_bottom_right_point({id:e,...t}){e==null||e.set_bottom_right_point(t)}set_text_font_family({id:e,...t},r){e==null||e.set_text_font_family(t,r)}}class vs{constructor(e,t,r){q(this,"_id");q(this,"_variables");q(this,"_errorListener");this._variables=e,this._id=t,this._errorListener=r}copy(e){const t=`box_${e}_${this._variables.bar_index}`,r=this._getBox(),n=new vs(this._variables,t,this._errorListener);return r&&this._variables.box.add(t,{...r,id:t},n),n}delete(){this._variables.box.delete(this._id)}get_top(){const e=this._getBox();return e&&e.top}set_top({top:e}){const t=this._getBox();t&&(t.top=e)}get_left(){const e=this._getBox();return e&&e.left}set_left({left:e}){const t=this._getBox();t&&(t.left=e)}set_text({text:e}){const t=this._getBox();t&&(t.text=e)}get_right(){const e=this._getBox();return e&&e.right}set_right({right:e}){const t=this._getBox();t&&(t.right=e)}get_bottom(){const e=this._getBox();return e&&e.bottom}set_bottom({bottom:e}){const t=this._getBox();t&&(t.bottom=e)}set_extend({extend:e},t){const r=this._getBox();r&&(r.extend=e,this._paramVerfiy(e,t,"box.set_extend",Object.values(Vr),"extend"))}set_bgcolor({color:e}){const t=this._getBox();t&&(t.bgcolor=e)}set_lefttop({left:e,top:t}){const r=this._getBox();r&&(r.left=e,r.top=t)}set_text_size({text_size:e},t){const r=this._getBox();r&&(r.text_size=e,this._paramVerfiy(e,t,"box.set_text_size",Object.values(ar),"text_size"))}set_text_wrap({text_wrap:e},t){const r=this._getBox();r&&(r.text_wrap=e,this._paramVerfiy(e,t,"box.set_text_wrap",[je.wrapAuto,je.wrapNone],"text_wrap"))}set_text_color({text_color:e}){const t=this._getBox();t&&(t.text_color=e)}set_rightbottom({right:e,bottom:t}){const r=this._getBox();r&&(r.right=e,r.bottom=t)}set_text_halign({text_halign:e},t){const r=this._getBox();r&&(r.text_halign=e,this._paramVerfiy(e,t,"box.set_text_halign",[je.alignLeft,je.alignCenter,je.alignRight],"text_halign"))}set_text_valign({text_valign:e},t){const r=this._getBox();r&&(r.text_valign=e,this._paramVerfiy(e,t,"box.set_text_valign",[je.alignBottom,je.alignCenter,je.alignTop],"text_valign"))}set_top_left_point({point:e}){const t=this._getBox();if(t){const{index:r,price:n,time:i}=e||{};t.top=n,t.left=t.xloc===bt.bar_index?r:i}}set_border_color({color:e}){const t=this._getBox();t&&(t.border_color=e)}set_border_style({style:e},t){const r=this._getBox();r&&(r.border_style=e,this._paramVerfiy(e,t,"box.set_border_style",[qt.styleDashed,qt.styleDotted,qt.styleSolid],"style"))}set_border_width({width:e}){const t=this._getBox();t&&(t.border_width=e)}set_bottom_right_point({point:e}){const t=this._getBox();if(t){const{index:r,price:n,time:i}=e||{};t.bottom=n,t.right=t.xloc===bt.bar_index?r:i}}set_text_font_family({text_font_family:e},t){const r=this._getBox();r&&(r.text_font_family=e,this._paramVerfiy(e,t,"box.set_text_font_family",Object.values(ei),"text_font_family"))}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}_getBox(){return this._variables.box.get(this._id)}}class CD{constructor(e,t){q(this,"_variables");q(this,"_errorListener");q(this,"_defaultTable",{position:br.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=e,this._errorListener=t}table({x:e},t){return e||new su(this._variables,t,this._errorListener)}new(e,t){const r=`table_${t}_${this._variables.bar_index}`,n={...this._defaultTable,...e,cell:[],id:r},i=new su(this._variables,r,this._errorListener);return this._paramVerfiy(e.position,t,"table.new",Object.values(br),"position"),t.startsWith("export")||this._variables.table.add(r,n,i),i}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}cell({table_id:e,...t}){e==null||e.cell(t)}cell_set_bgcolor({table_id:e,...t}){e==null||e.cell_set_bgcolor(t)}cell_set_height({table_id:e,...t}){e==null||e.cell_set_height(t)}cell_set_text({table_id:e,...t}){e==null||e.cell_set_text(t)}cell_set_text_color({table_id:e,...t}){e==null||e.cell_set_text_color(t)}cell_set_text_font_family({table_id:e,...t}){e==null||e.cell_set_text_font_family(t)}cell_set_text_halign({table_id:e,...t}){e==null||e.cell_set_text_halign(t)}cell_set_text_valign({table_id:e,...t}){e==null||e.cell_set_text_valign(t)}cell_set_text_size({table_id:e,...t}){e==null||e.cell_set_text_size(t)}cell_set_tooltip({table_id:e,...t}){e==null||e.cell_set_tooltip(t)}cell_set_width({table_id:e,...t}){e==null||e.cell_set_width(t)}clear({table_id:e,...t}){e==null||e.clear(t)}delete({table_id:e}){e==null||e.delete()}merge_cells({table_id:e,...t},r){e==null||e.merge_cells(t,r)}set_bgcolor({table_id:e,...t}){e==null||e.set_bgcolor(t)}set_border_color({table_id:e,...t}){e==null||e.set_border_color(t)}set_border_width({table_id:e,...t}){e==null||e.set_border_width(t)}set_frame_color({table_id:e,...t}){e==null||e.set_frame_color(t)}set_frame_width({table_id:e,...t}){e==null||e.set_frame_width(t)}set_position({table_id:e,...t},r){e==null||e.set_position(t,r)}}class su{constructor(e,t,r){q(this,"_id");q(this,"_variables");q(this,"_errorListener");q(this,"_defaultCell",{column:0,row:0,text:"",text_color:$i.black,text_halign:je.alignCenter,text_valign:je.alignCenter,text_size:ar.normal});this._variables=e,this._id=t,this._errorListener=r}cell(e){const t={...this._defaultCell,...e},{column:r=0,row:n=0}=t,i=this._variables.table.get(this._id);if(i){const a=i.cell||[],u=a[n]||[];u[r]=t,a[n]=u,i.cell=a}}cell_set_bgcolor({column:e=0,row:t=0,bgcolor:r}){const n=this._getTableItem(e,t);n&&(n.bgcolor=r)}cell_set_height({column:e=0,row:t=0,height:r}){const n=this._getTableItem(e,t);n&&(n.height=r)}cell_set_text({column:e=0,row:t=0,text:r}){const n=this._getTableItem(e,t);n&&(n.text=r)}cell_set_text_color({column:e=0,row:t=0,text_color:r}){const n=this._getTableItem(e,t);n&&(n.text_color=r)}cell_set_text_font_family({column:e=0,row:t=0,text_font_family:r}){const n=this._getTableItem(e,t);n&&(n.text_font_family=r)}cell_set_text_halign({column:e=0,row:t=0,text_halign:r}){const n=this._getTableItem(e,t);n&&(n.text_halign=r)}cell_set_text_valign({column:e=0,row:t=0,text_valign:r}){const n=this._getTableItem(e,t);n&&(n.text_valign=r)}cell_set_text_size({column:e=0,row:t=0,text_size:r}){const n=this._getTableItem(e,t);n&&(n.text_size=r)}cell_set_tooltip({column:e=0,row:t=0,tooltip:r}){const n=this._getTableItem(e,t);n&&(n.tooltip=r)}cell_set_width({column:e=0,row:t=0,width:r}){const n=this._getTableItem(e,t);n&&(n.width=r)}clear({start_column:e=0,start_row:t=0,end_column:r=0,end_row:n=0}){const i=this._variables.table.get(this._id);if(i){const a=i.cell;if(a)for(let u=t;u<=n;u++)for(let f=e;f<=r;f++){const c=a[u];c&&(c[f]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:e=0,start_row:t=0,end_column:r=0,end_row:n=0},i){if(e>r||t>n){console.log(`error ${i}: start_column > end_column or start_row > end_row`);return}const a=this._getTableItem(e,t);if(!a)return;this.clear({start_column:e,start_row:t,end_column:r,end_row:n});const u=this._variables.table.get(this._id);u.cell[t][e]={...a,isMerge:!0,merge_columns:r-e+1,merge_rows:n-t+1}}set_bgcolor({bgcolor:e}){const t=this._variables.table.get(this._id);t&&(t.bgcolor=e)}set_border_color({border_color:e}){const t=this._variables.table.get(this._id);t&&(t.border_color=e)}set_border_width({border_width:e}){const t=this._variables.table.get(this._id);t&&(t.border_width=e)}set_frame_color({frame_color:e}){const t=this._variables.table.get(this._id);t&&(t.frame_color=e)}set_frame_width({frame_width:e}){const t=this._variables.table.get(this._id);t&&(t.frame_width=e)}set_position({position:e},t){const r=this._variables.table.get(this._id);r&&(r.position=e,this._paramVerfiy(e,t,"table.set_position",Object.values(br),"position"))}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}_getTableItem(e,t){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[t][e]:void 0}}}class AD{constructor(e){q(this,"_strategy");this._strategy=e}commission({trade_num:e}){return this._verifyTradeNum(e)&&this._strategy.historyOrders[e].commission||0}entry_bar_index({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].in_index}entry_comment({trade_num:e}){if(!this._verifyTradeNum(e))return"";const{comment:t,id:r}=this._strategy.historyOrders[e];return t||r}entry_id({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].id:""}entry_price({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].in_price}entry_time({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].in_time}exit_bar_index({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].out_index}exit_comment({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].out_comment:""}exit_id({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].out_id:""}exit_price({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].out_price}exit_time({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].out_time}max_drawdown({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].trading_loss:0}max_drawdown_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].trading_loss_percent:0}max_runup({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].max_profit:0}max_runup_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].max_profit_percent:0}profit({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].profit:0}profit_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].profit_percent:0}size({trade_num:e}){if(!this._verifyTradeNum(e))return 0;const{out_qty:t=0,direction:r}=this._strategy.historyOrders[e];return r===mt.long?t:-t}_verifyTradeNum(e){if(typeof e!="number"||e<0)return!1;const t=this._strategy.historyOrders.length;return!(e>=t)}}class FD{constructor(e){q(this,"_strategy");this._strategy=e}commission({trade_num:e}){if(!this._verifyTradeNum(e))return 0;const{qty:t=0,original_qty:r=0,commission:n=0}=this._strategy.orders[e];return n*t/r}entry_bar_index({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.orders[e].in_index}entry_comment({trade_num:e}){if(!this._verifyTradeNum(e))return"";const{comment:t,id:r}=this._strategy.orders[e];return t||r}entry_id({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].id:""}entry_price({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.orders[e].in_price}entry_time({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.orders[e].in_time}max_drawdown({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].trading_loss:0}max_drawdown_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].trading_loss_percent:0}max_runup({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].max_profit:0}max_runup_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].max_profit_percent:0}profit({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].profit:0}profit_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].profit_percent:0}size({trade_num:e}){if(!this._verifyTradeNum(e))return 0;const{qty:t=0,direction:r}=this._strategy.orders[e];return r===mt.long?t:-t}_verifyTradeNum(e){if(typeof e!="number"||e<0)return!1;const t=this._strategy.orders.length;return!(e>=t)}}class BD{constructor(e,t){q(this,"_strategy");q(this,"_errorListener");this._strategy=e,this._errorListener=t}allow_entry_in({value:e},t){this._paramVerfiy(e,t,"strategy.risk.allow_entry_in",Object.values(mt),"value"),this._strategy.updateRisk({allow_entry_in:e})}max_cons_loss_days({count:e}){this._strategy.updateRisk({max_cons_loss_days:e})}max_drawdown({value:e,type:t},r){this._paramVerfiy(t,r,"strategy.risk.max_drawdown",[Rt.percentOfEquity,Rt.cash],"type"),t===Rt.percentOfEquity&&(e=e>100?100:e),this._strategy.updateRisk({max_drawdown:e,max_drawdown_type:t})}max_intraday_filled_orders({count:e}){this._strategy.updateRisk({max_intraday_filled_orders:e})}max_intraday_loss({value:e,type:t},r){this._paramVerfiy(t,r,"strategy.risk.max_intraday_loss",[Rt.percentOfEquity,Rt.cash],"type"),t===Rt.percentOfEquity&&(e=e>100?100:e),this._strategy.updateRisk({max_intraday_loss:e,max_intraday_loss_type:t})}max_position_size({contracts:e}){this._strategy.updateRisk({max_position_size:e})}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}}let MD=class{constructor(e,t,r,n){q(this,"_variables");q(this,"_options");q(this,"_totalChangeCapital");q(this,"_historyOrder");q(this,"_orders");q(this,"_pendingOrders");q(this,"_mintick");q(this,"_funcOptions");q(this,"_pendingCloseOrders");q(this,"_errorListener");q(this,"_risk");q(this,"_opentrades");q(this,"_closedtrades");q(this,"_riskNamespace");this._variables=e,this._errorListener=n,this._options={overlay:!1,format:Je.inherit,pyramiding:0,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Rt.fixed,default_qty_value:1,initial_capital:1e6,currency:qf.NONE,slippage:0,commission_type:Ir.percent,commission_value:0,process_orders_on_close:!1,close_entries_rule:"FIFO",margin_long:0,margin_short:0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,max_polylines_count:50},this._funcOptions=t,this._totalChangeCapital=0,this._orders=[],this._pendingOrders=[],this._historyOrder=[],this._pendingCloseOrders=[],this._mintick=r,this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),this._variables.strategy.updateStrategyOptions(this._options),this._risk={intradayOrders:0},this._opentrades=new FD(this),this._closedtrades=new AD(this),this._riskNamespace=new BD(this,n)}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _orderProfit(){return this._orders.reduce((e,t)=>e+(t.profit||0),0)}get _freezeCapital(){const{close:e}=this._variables;return this._orders.reduce((t,r)=>t+e*(r.qty||0),0)}get opentrades(){return this._opentrades}get closedtrades(){return this._closedtrades}get risk(){return this._riskNamespace}updateOptions(e){Object.assign(this._options,e),this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),!this._options.process_orders_on_close&&this._calcLiquidate()}updateRisk(e){Object.assign(this._risk,e)}endExecution(){this._calcProfitAndLoss(),this._variables.strategy.update(),this._maxDrawdownVerify(),this._maxIntradayLoss(),this._pendingCloseOrderHandle(),this._options.process_orders_on_close&&this._calcLiquidate()}_maxIntradayLoss(){var v;const{max_intraday_loss:e,max_intraday_loss_type:t,isDisabledOpen:r}=this._risk;if(e===void 0||!t||r)return;const{high:n,low:i,time_tradingday:a,time:u,strategy:{netprofit:f,initial_capital:c}}=this._variables;let{preNetprofit:h=0}=this._risk;u===a&&(h=f,this._risk.preNetprofit=f,this._risk.isTemporaryBan=!1);let d=h-f;d+=this._orders.reduce((x,_)=>{const{in_price:y,direction:m,qty:w=0,commission:D=0,original_qty:C=0}=_,b=m===mt.long?1:-1,F=(n-y)*w,B=(i-y)*w,M=b===1?-B:F;return x+M+w/C*D},0);let p=!1;switch(t){case Rt.cash:p=e<d;break;case Rt.percentOfEquity:const x=d/(c+f)*100;p=e<x;break}if(p){this._risk.isTemporaryBan=!0;const x=(v=this._orders[0])==null?void 0:v.direction;this._closeOrders(this._orders,x===mt.long?i:n,"Close Position (Max intraday Loss)"),this._pendingOrders=[]}}_maxIntradayFilledOrdersVerify(){const{max_intraday_filled_orders:e,intradayOrders:t=0,isDisabledOpen:r}=this._risk;if(e===void 0||r)return;const{time:n,time_tradingday:i,open:a}=this._variables;n===i&&(this._risk.intradayOrders=0,this._risk.isTemporaryBan=!1),e<=t&&(this._risk.isTemporaryBan=!0,this._closeOrders(this._orders,a,"Close Position (Max number of filled orders in one day)"),this._pendingOrders=[])}_maxConsLossDaysVerify(){const{max_cons_loss_days:e,lossDays:t=0,isDisabledOpen:r,totalProfit:n=0}=this._risk;if(e===void 0||r)return;const{time:i,time_tradingday:a,strategy:u,open:f}=this._variables;let c=t;if(i===a){const h=u.netprofit+u.openprofit;h<n?c=0:c++,Object.assign(this._risk,{lossDays:c,totalProfit:h})}e<=c&&this._riskTouchOff(f,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){var n;const{max_drawdown:e,max_drawdown_type:t,isDisabledOpen:r}=this._risk;if(!r&&e!==void 0&&t){const{max_drawdown:i,max_drawdown_percent:a}=this._variables.strategy;let u=!1;switch(t){case Rt.percentOfEquity:u=a<i;break;case Rt.cash:u=e<i;break}if(u){const{high:f,low:c}=this._variables,h=(n=this._orders[0])==null?void 0:n.direction;this._riskTouchOff(h===mt.long?f:c,"Close Position (Max Drawdown)")}}}_riskTouchOff(e,t){this._risk.isDisabledOpen=!0,this._closeOrders(this._orders,e,t),this._pendingOrders=[]}strategy(e,t){this._variables.bar_index||(this._paramVerfiy(e.format,t,"strategy",[Je.inherit,Je.price,Je.percent,Je.volume],"format"),this._paramVerfiy(e.default_qty_type,t,"strategy",Object.values(Rt),"default_qty_type"),this._paramVerfiy(e.commission_type,t,"strategy",Object.values(Ir),"commission_type"),this._options={...e},this._variables.updateMaxLength(e),Object.assign(this._funcOptions,{strategy:this._options,scriptType:"strategy"}))}order(e,t){this._risk.isDisabledOpen||(this._paramVerfiy(e.oca_type,t,"strategy.order",Object.values(gn),"oca_type"),this._orderHandle(e))}entry(e,t){this._risk.isDisabledOpen||(this._paramVerfiy(e.oca_type,t,"strategy.entry",Object.values(gn),"oca_type"),this._entryHandle(e))}close(e){if(!this._orders.length)return;const{immediately:t}=e;t||this._options.process_orders_on_close?this._pendingCloseOrders.push({...e,place_order_type:"close"}):this._pendingOrders.push({...e,place_order_type:"close"})}close_all(e){if(typeof e=="string"&&(e={}),!this._orders.length)return;const{immediately:t}=e;t||this._options.process_orders_on_close?this._pendingCloseOrders.push({...e,place_order_type:"close_all"}):this._pendingOrders.push({...e,place_order_type:"close_all"})}cancel({id:e}){this._pendingOrders=this._pendingOrders.filter(t=>!(t.id===e&&t.place_order_type!=="close"))}cancel_all(){this._pendingOrders=this._pendingOrders.filter(e=>e.place_order_type==="close_all")}exit(e,t){this._exit(e,t)}convert_to_account({value:e}){return e}convert_to_symbol({value:e}){return e}default_entry_qty({fill_price:e}){return e?this._calcDefaultQty(e):0}_calcDefaultQty(e){const{default_qty_type:t=Rt.fixed,default_qty_value:r=1,initial_capital:n}=this._options;switch(t){case Rt.fixed:return r;case Rt.cash:return r/e;case Rt.percentOfEquity:return(n+this._orderProfit+this._totalChangeCapital)*r/100/e}}_getCapital(e,t){const{margin_long:r=0,margin_short:n=0}=this._options;return r<100&&r>0&&e===1?t=t*100/r:n<=100&&n>0&&e===-1&&(t=t*100/n),t}_calcProfitAndLoss(){const{high:e,low:t,close:r}=this._variables;for(const n of this._orders){const{in_price:i,qty:a=0,direction:u}=n,f=u===mt.long?1:-1,c=(r-i)*f*a,h=(e-i)*a,d=(t-i)*a,p=f===1?h:-d,v=f===1?-d:h;this._calcOrderPercent(n,c,p,v)}}_calcOrderPercent(e,t,r,n){const{commission_value:i}=this._options,{close:a}=this._variables,{original_qty:u=0,qty:f=0,in_price:c,max_profit:h=0,trading_loss:d=0}=e;let{commission:p=0}=e;const v=c*f;if(i){const x=this._getCommission(a,f);t=t-x,p=p*f/u,r-=p,n+=p}r=Math.max(r,h),n=Math.min(n,d),Object.assign(e,{profit:t-p,total_profit:this._totalChangeCapital+t,max_profit:r,trading_loss:n,profit_percent:t/v*100,max_profit_percent:r/v*100,trading_loss_percent:n/v*100})}_calcLiquidate(){if(!this._orders.length)return;const{high:e,low:t}=this._variables,{initial_capital:r,margin_long:n=0,margin_short:i=0,commission_value:a=0}=this._options,u=this._orders[0].direction===mt.long?1:-1,f=u===1?t:e,c=(u===1?n:i)/100;if(c<=0)return;const[h,d,p]=this._orders.reduce((m,w)=>{let[D,C,b]=m;const{in_price:F,qty:B=0,original_qty:M=0,commission:O=0}=w,A=F*B,N=f*B;if(D+=A,C+=N,a){const I=this._getCommission(f,B);b+=I+B/M*O}return[D,C,b]},[0,0,0]),v=u*(d-h),_=r+this._totalChangeCapital+v-p-d*c;if(_>=0)return;const y=Math.trunc(_/c/f)*4;this._marginCallOrders(f,y,"Margin Call")}_marginCallOrders(e,t,r){const{close_entries_rule:n="FIFO"}=this._options;if(n==="FIFO"){this._processOrders(this._orders,e,t*this._orders.length,r,r);return}for(const i of this.orders)this._processOrder(i,e,t,r,r);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders)}_orderHandle(e){const{process_orders_on_close:t,slippage:r=0}=this._options,{orders:n,isMarketPrice:i,quantities:a,close:u,price:f,activePrice:c}=this._orderArgsParse(e),h=e.direction===mt.long?1:-1;if(a<=0)return;let d=a;if(i&&t){if(n.length){const _=this._processOrders(n,u,d,e.id,e.comment);if(_<=0)return;d=_}const v=u+h*r*this._mintick;if(!this._judgeCapitalEnough(d,v,h))return;this._ocaGroupVerify(d,e.oca_name,e.oca_type),this._calcCurrentOrder({...e,in_price:v,in_index:this._variables.bar_index,in_time:this._variables.time,qty:d,place_order_type:"order"});return}this._judgeCapitalEnough(a,f,h)&&this._addPendingOrders(e,f,d,i,c)}_judgeCapitalEnough(e,t,r){if(e<=0)return!1;const{margin_long:n=0,margin_short:i=0}=this._options;if((n===0||n===100)&&r===1||i===0&&r===-1)return!0;const u=this._getCapital(r,this._options.initial_capital+this._orderProfit+this._totalChangeCapital)-this._freezeCapital;return e*t<=u}_ocaGroupVerify(e,t,r){if(!t||!r||r===gn.none)return!1;let n=!1;switch(r){case gn.cancel:this._pendingOrders=this._pendingOrders.filter(i=>{if(i.oca_name===t)i.isCancel=!0,n=!0;else return!0});break;case gn.reduce:this._pendingOrders=this._pendingOrders.filter(i=>{const{qty:a=0,oca_name:u}=i;if(t===u){const f=a-e;return n=!0,f<=0?(i.isCancel=!0,!1):(i.qty=f,!0)}else return!0});break}return n}_processOrders(e,t,r,n,i){let a=r;for(const u of e)if(a=this._processOrder(u,t,a,n,i),a<=0)break;return this._orders=this._orders.filter(u=>!u.isDeal),this._variables.strategy.updateOrders(this._orders),a}_addPendingOrders(e,t,r,n,i){const a=this._pendingOrders.find(u=>u.id===e.id&&!u.isMarketPrice);if(a)Object.assign(a,{...e,in_price:t,isMarketPrice:n,qty:r,active_price:i});else{const u={...e,in_price:t,isMarketPrice:n,qty:r,active_price:i,place_order_type:"order"};this._pendingOrders.push(u)}}_orderArgsParse(e){const{direction:t,qty:r,stop:n}=e;let i=e.limit||0;const{close:a}=this._variables;let u=a,f=!1,c;const h=t===mt.long?1:-1,d=n&&(n-a)*h>0,{backtest_fill_limits_assumption:p=0}=this._options;p>0&&i&&(i-=p*this._mintick*h);const v=i&&(i-a)*h<0;d&&v?(c=n,u=i):d?u=n:v?u=i:f=!0;const x=r||this._calcDefaultQty(u)||1;return{orders:this._orders.filter(y=>y.direction!==t),isMarketPrice:f,activePrice:c,quantities:x,close:a,price:u}}_entryHandle(e){const{process_orders_on_close:t}=this._options,{orders:r,isMarketPrice:n,quantities:i,close:a,price:u,activePrice:f}=this._orderArgsParse(e);if(i<=0)return;if(r.length&&n&&t){this._entryOrder(r,a,i,e);return}this._judgeCapitalEnough(i,a,e.direction===mt.long?1:-1)&&this._addPendingEntry(e,u,i,n,f)}_entryOrder(e,t,r,n){const{time:i,bar_index:a}=this._variables,{slippage:u=0}=this._options,{oca_name:f,oca_type:c,direction:h,comment:d,isMarketPrice:p,id:v}=n,x=h===mt.long?1:-1;if(this._closeOrders(e,t,v,d),r=this._getAvailablePositionSize(r,h),r<=0)return;t=t+u*this._mintick*x;const _={...n,in_price:t,original_qty:r,qty:r,in_index:a,in_time:i,place_order_type:"entry"};if(p){this._calcCurrentOrder(_);return}const{pendingOrders:y,orders:m}=this._getEntryOrders(h),w=y.length+m.length;w&&w>=(this._options.pyramiding||0)||!this._judgeCapitalEnough(r,t,x)||(this._ocaGroupVerify(r,f,c),this._calcCurrentOrder(_))}_getAvailablePositionSize(e,t){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==mt.all&&n!==t)return 0;if(r===void 0)return e;const i=this._orders.reduce((a,u)=>a+(u.qty||0),0);return i?i+e>r?0:e:e>r?e-r:0}_getEntryOrders(e){const t=this._pendingOrders.filter(n=>["entry","order"].includes(n.place_order_type)&&n.direction===e),r=this._orders.filter(n=>n.direction===e);return{pendingOrders:t,orders:r}}_addPendingEntry(e,t,r,n,i){if(r=this._getAvailablePositionSize(r,e.direction),r<=0)return;const{pendingOrders:a,orders:u}=this._getEntryOrders(e.direction),f=a.length+u.length,c=a.find(h=>h.id===e.id&&h.place_order_type==="entry");if(c)Object.assign(c,{...e,in_price:t,isMarketPrice:n,qty:r,active_price:i});else if(!f||f<(this._options.pyramiding||1)){const h={...e,in_price:t,isMarketPrice:n,qty:r,active_price:i,place_order_type:"entry"};this._pendingOrders.push(h)}}_closeAllOrders(e,t){const{comment:r}=e,{bar_index:n}=this._variables,i=this._orders.filter(a=>a.in_index!==n);i.length&&(this._closeOrders(i,t,"Close position order",r),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(e,t,r,n){for(const i of e)this._closeOrder(i,t,r,n);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders)}_closeOrder(e,t,r,n){const{time:i,bar_index:a}=this._variables,{slippage:u=0}=this._options,{in_price:f,qty:c=0,direction:h}=e,d=h===mt.long?1:-1;t=t-d*u*this._mintick,e.isDeal=!0;const p=(t-f)*d*c,v={...e,out_price:t,out_id:r,out_index:a,out_time:i,out_comment:n,out_qty:c,profit:p};this._calcPercent(v),this._risk.intradayOrders+=1,this._historyOrder.push(v),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_ordersHandle(){const e=this._orders.filter(a=>a.place_order_type==="exit"&&!a.hasExit);if(!e.length)return;const{open:t,low:r,high:n,close:i}=this._variables;for(const a of e){const{stop:u,limit:f,trail_stop_price:c,isMarketPriceLimit:h,isMarketPriceStop:d,direction:p,id:v,out_comment:x,active_price:_,trail_offset:y=0,out_qty:m,comment_loss:w,comment_profit:D,comment_trailing:C}=a;let b=c;const F=p===mt.long?1:-1;let B,M=x;if(h||d?B=t:(f&&r<=f&&n>=f&&(M=D||x,B=f),u&&r<=u&&n>=u&&(B=b?(u-b)*F>0?u:b:u,M=(b===B?C:w)||x)),B)this._processExitOnClose(a,B,{from_entry:v,comment:M,qty:m});else{let O=!1;if(_&&_<=n&&_>=r&&(b=_-y*F*this._mintick,(b-i)*F>=0&&(a.isMarketPriceStop=!0,this._options.process_orders_on_close&&(B=b)),O=!0,a.trail_stop_price=b),b)if((b-t)*F>=0&&!O)B=b;else{const A=(F===1?n:r)-y*F*this._mintick;F===1?b<t&&b>=r&&A>b&&A<i?B=b:A>b?(b=A,A>=i&&(B=A)):b<=n&&r<=b&&(B=b):b>t&&b<=n&&A<b&&A>i?B=b:A<b?(b=A,A<=i&&(B=A)):b<=n&&r<=b&&(B=b),a.trail_stop_price=b}B&&this._processExitOnClose(a,B,{from_entry:v,comment:C||x,qty:m})}}}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const e=[],t=this._pendingOrders.filter(n=>n.place_order_type==="exit"),r=this._pendingOrders.filter(n=>["close","close_all"].includes(n.place_order_type||""));for(const n of r)switch(n.place_order_type){case"close":this._closeOrderHandle(n);break;case"close_all":this._closeAllOrders(n,this._variables.open);break}for(const n of this._pendingOrders){const{isCancel:i,place_order_type:a}=n;if(i)continue;let u;switch(a){case"entry":u=this._entryOrderHandle(n);break;case"order":u=this._orderOrderHandle(n);break}u&&e.push(u)}for(const n of t){const i=this._exitOrderHandle(n);i&&e.push(i)}this._pendingOrders=e}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const e=this._pendingCloseOrders.filter(n=>n.place_order_type==="exit"),t=this._pendingCloseOrders.filter(n=>["close","close_all"].includes(n.place_order_type||"")),{close:r}=this._variables;for(const n of t)switch(n.place_order_type){case"close":this._closeOrderHandle(n,!0);break;case"close_all":this._closeAllOrders(n,r);break}for(const n of e){const{from_entry:i}=n,a=this._orders.filter(u=>!i||u.id===i&&(u.isMarketPriceLimit||u.isMarketPriceStop));for(const u of a)this._processExitOnClose(u,u.limit||u.stop||u.trail_stop_price||r,n)}this._pendingCloseOrders=[]}_entryOrderHandle(e){const{open:t,low:r,high:n}=this._variables,{isMarketPrice:i,qty:a=0,in_price:u,direction:f,active_price:c}=e;if(c&&n>=c&&r<=c)return delete e.active_price,e;let h=u;if(i&&(h=t),h<=n&&h>=r){const d=this._orders.filter(p=>p.direction!==f);this._entryOrder(d,h,a,e)}else return e}_orderOrderHandle(e){const{open:t,low:r,high:n,time:i,bar_index:a}=this._variables,{slippage:u=0}=this._options,{isMarketPrice:f,qty:c=0,in_price:h,direction:d,comment:p,oca_name:v,oca_type:x,active_price:_,id:y}=e;if(_&&n>=_&&r<=_)return delete e.active_price,e;let m=h,w=c;if(f&&(m=t),m<=n&&m>=r){const D=this._orders.filter(b=>b.direction!==d);if(D.length&&(w=this._processOrders(D,m,c,y,p),w<=0))return;const C=d===mt.long?1:-1;this._ocaGroupVerify(w,v,x),this._calcCurrentOrder({...e,in_price:m+C*u*this._mintick,in_index:a,in_time:i,qty:w});return}else return e}_closeOrderHandle(e,t){const{id:r,qty:n,qty_percent:i=100,comment:a}=e,{bar_index:u}=this._variables,f=this._orders.filter(v=>v.id===r&&v.in_index!==u&&(!v.close_qty||v.close_qty<(v.qty||0)));if(!f.length)return;let c=0;if(n?c=n:(c=f.reduce((v,x)=>v+(x.qty||0),c),c=i/100*c),c<=0)return;const{open:h,close:d}=this._variables;let p=c;for(const v of f){const{qty:x=0}=v;p<x?v.close_qty=p:(v.close_qty=x,p-=x)}this._processOrders(this._options.close_entries_rule==="ANY"?f:this._orders,t?d:h,c,`Close entry(s) order ${r}`,a)}_exitOrderHandle(e){const{from_entry:t}=e,r=this._orders.filter(n=>(!t||t===n.id)&&!n.hasExit);if(!(r.length&&!this._ordersToExit(r,e)))return e}_exit(e,t){const{profit:r,loss:n,stop:i,limit:a,trail_offset:u,trail_price:f,trail_points:c,from_entry:h="",id:d}=e;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(i)&&this._isNaN(a)&&(this._isNaN(u)||this._isNaN(c)&&this._isNaN(f))){this._errorListener.addError(ct.strategyExitErr,t,Ze.Error);return}const p={...e,place_order_type:"exit"},v=this._orders.filter(y=>(!h||h===y.id)&&!y.hasExit),x=this._pendingOrders.filter(y=>!h||h===y.id);if(v.length){if(!this._ordersToExit(v,p))return}else if(!x.length)return;const _=this._pendingOrders.find(y=>y.id===d);_?Object.assign(_,{...e}):this._pendingOrders.push(p)}_ordersToExit(e,t){const{qty:r,qty_percent:n=100,id:i,comment:a,comment_loss:u,comment_profit:f,comment_trailing:c}=t;let h=r,d=!1;t.comment=a||i;for(const p of e){const{qty:v=0}=p,x=p.direction===mt.long?1:-1;h=r?r>=v?v:r:n/100*v,p.out_qty=h,h<v&&(d=!0),Object.assign(p,{out_comment:a||i,comment_loss:u,comment_profit:f,comment_trailing:c}),!(this._stopProfit(p,x,{...t,qty:h})||this._stopLoss(p,x,{...t,qty:h})||this._trailStopLoss(p,x,{...t,qty:h}))&&(p.place_order_type="exit")}return d}_addExitPendingCloseOrders(e){e.place_order_type="exit";const t=this._pendingCloseOrders.find(r=>r.id===e.id);t?Object.assign(t,{...e}):this._pendingCloseOrders.push(e)}_stopProfit(e,t,r){const{limit:n,profit:i,comment_profit:a,comment:u}=r;let f=n;const{close:c}=this._variables,{in_price:h}=e,{process_orders_on_close:d}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(f=h+t*i*this._mintick),e.limit=f,f&&(f-c)*t<=0&&(e.isMarketPriceLimit=!0,r.comment=a||u,Object.assign(e,{out_comment:r.comment}),f=c,d))return this._addExitPendingCloseOrders(r),!0}_stopLoss(e,t,r){const{stop:n,loss:i,comment_loss:a,comment:u}=r;let f=n;const{close:c}=this._variables,{in_price:h}=e,{process_orders_on_close:d}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(f=h-t*i*this._mintick),e.stop=f,f&&(f-c)*t>=0&&(e.isMarketPriceStop=!0,r.comment=a||u,Object.assign(e,{out_comment:r.comment}),f=c,d))return this._addExitPendingCloseOrders(r),!0}_trailStopLoss(e,t,r){const{trail_offset:n,trail_price:i,trail_points:a,comment_trailing:u,comment:f}=r;if(!this._isNaN(n)){const{close:c}=this._variables,{in_price:h}=e,{process_orders_on_close:d}=this._options;let p;if(this._isNaN(i)?this._isNaN(a)||(p=h+a*t*this._mintick):p=i,e.trail_offset=n,p&&(p-c)*t<=0){const v=c-n*t*this._mintick;if((v-c)*t>=0&&(e.trail_stop_price=c,e.isMarketPriceStop=!0,r.comment=u||f,Object.assign(e,{out_comment:r.comment}),d))return this._addExitPendingCloseOrders(r),!0;e.trail_stop_price=v}e.active_price=p}}_processExitOnClose(e,t,r){const{qty:n=0,comment:i,id:a}=r,{close_entries_rule:u="FIFO"}=this._options;if(u==="FIFO"){const f=this._processExitOrders(this._orders,t,n,a,i);f&&!f.hasExit?(f.hasExit=!0,Object.assign(e,{trail_stop_price:f.trail_stop_price,stop:f.stop,limit:f.limit,trail_offset:f.trail_offset,active_price:f.active_price})):f&&(e.hasExit=!0)}else e.hasExit=!0,this._processOrders([e],t,n,a,i)}_processExitOrders(e,t,r,n,i){let a=r,u;for(const f of e)if(u=f,a=this._processOrder(f,t,a,n,i),a<=0||!f.hasExit)break;return this._orders=this._orders.filter(f=>!f.isDeal),this._variables.strategy.updateOrders(this._orders),u}_processOrder(e,t,r,n,i){const{time:a,bar_index:u}=this._variables,{slippage:f=0}=this._options,{in_price:c,qty:h=0,max_profit:d=0,trading_loss:p=0,direction:v,commission:x=0,original_qty:_=0}=e,y=v===mt.long?1:-1;if(t=t-y*f*this._mintick,r<h){const m=h-r,w=(t-c)*y*r,D=d/h*r,C=p/h*r;this._calcPercent({...e,out_price:t,out_id:n,out_index:u,out_time:a,out_comment:i,profit:w,out_qty:r,max_profit:D,trading_loss:C});const b=(t-c)*y*m-x*m/_;Object.assign(e,{qty:m,profit:b,max_profit:d-D,trading_loss:p-C,total_profit:this._totalChangeCapital+b}),r=0}else{e.isDeal=!0;const m=(t-c)*y*h;this._calcPercent({...e,out_price:t,out_id:n,out_index:u,out_time:a,out_comment:i,out_qty:h,profit:m}),r-=h}return r}_calcPercent(e){const{commission_value:t}=this._options,{in_price:r,out_qty:n=0,out_price:i=0,original_qty:a=0}=e;let{profit:u=0,max_profit:f=0,trading_loss:c=0,commission:h=0}=e;f=f<0?0:f;const d=r*n;if(this._totalChangeCapital+=u,t){const p=this._getCommission(i,n);this._totalChangeCapital-=p,h=h*n/a+p,u=u-h,Object.assign(e,{commission:h,profit:u,max_profit:f})}Object.assign(e,{total_profit:this._totalChangeCapital,profit_percent:u/d*100,max_profit_percent:f/d*100,trading_loss_percent:c/d*100}),this._risk.intradayOrders+=1,this._historyOrder.push(e),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_getCommission(e,t){const{commission_value:r=0,commission_type:n}=this._options,i=e*t;let a=0;switch(n){case Ir.percent:a=i*r/100;break;case Ir.cashPerContract:a=t*r;break;case Ir.cashPerOrder:a=r;break}return a}_calcCurrentOrder(e){const{commission_value:t}=this._options,{in_price:r,qty:n=0,max_profit:i=0,trading_loss:a=0}=e;let{profit:u=0}=e;const f=r*n;if(t){const c=this._getCommission(r,n);this._totalChangeCapital-=c,u=u-c,Object.assign(e,{commission:c,profit:u,total_profit:this._totalChangeCapital})}Object.assign(e,{original_qty:n,profit_percent:u/f*100,max_profit_percent:i/f*100,trading_loss_percent:a/f*100}),this._risk.intradayOrders+=1,this._orders.push(e),this._variables.strategy.updateOrders(this._orders)}_isNaN(e){return e===void 0||isNaN(e)}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}};var jf={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(ye,function(){return function(t,r,n){r.prototype.isBetween=function(i,a,u,f){var c=n(i),h=n(a),d=(f=f||"()")[0]==="(",p=f[1]===")";return(d?this.isAfter(c,u):!this.isBefore(c,u))&&(p?this.isBefore(h,u):!this.isAfter(h,u))||(d?this.isBefore(c,u):!this.isAfter(c,u))&&(p?this.isAfter(h,u):!this.isBefore(h,u))}}})})(jf);var ND=jf.exports,SD=tt(ND),Yf={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(ye,function(){return function(t,r,n){var i=r.prototype,a=function(p){var v,x=p.date,_=p.utc,y={};if(!((v=x)===null||v instanceof Date||v instanceof Array||i.$utils().u(v)||v.constructor.name!=="Object")){if(!Object.keys(x).length)return new Date;var m=_?n.utc():n();Object.keys(x).forEach(function(O){var A,N;y[A=O,N=i.$utils().p(A),N==="date"?"day":N]=x[O]});var w=y.day||(y.year||y.month>=0?1:m.date()),D=y.year||m.year(),C=y.month>=0?y.month:y.year||y.day?0:m.month(),b=y.hour||0,F=y.minute||0,B=y.second||0,M=y.millisecond||0;return _?new Date(Date.UTC(D,C,w,b,F,B,M)):new Date(D,C,w,b,F,B,M)}return x},u=i.parse;i.parse=function(p){p.date=a.bind(this)(p),u.bind(this)(p)};var f=i.set,c=i.add,h=i.subtract,d=function(p,v,x,_){_===void 0&&(_=1);var y=Object.keys(v),m=this;return y.forEach(function(w){m=p.bind(m)(v[w]*_,w)}),m};i.set=function(p,v){return v=v===void 0?p:v,p.constructor.name==="Object"?d.bind(this)(function(x,_){return f.bind(this)(_,x)},v,p):f.bind(this)(p,v)},i.add=function(p,v){return p.constructor.name==="Object"?d.bind(this)(c,p,v):c.bind(this)(p,v)},i.subtract=function(p,v){return p.constructor.name==="Object"?d.bind(this)(c,p,v,-1):h.bind(this)(p,v)}}})})(Yf);var OD=Yf.exports,ID=tt(OD),Kf={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(ye,function(){var t,r,n=1e3,i=6e4,a=36e5,u=864e5,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,c=31536e6,h=2628e6,d=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,p={years:c,months:h,days:u,hours:a,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},v=function(F){return F instanceof C},x=function(F,B,M){return new C(F,M,B.$l)},_=function(F){return r.p(F)+"s"},y=function(F){return F<0},m=function(F){return y(F)?Math.ceil(F):Math.floor(F)},w=function(F){return Math.abs(F)},D=function(F,B){return F?y(F)?{negative:!0,format:""+w(F)+B}:{negative:!1,format:""+F+B}:{negative:!1,format:""}},C=function(){function F(M,O,A){var N=this;if(this.$d={},this.$l=A,M===void 0&&(this.$ms=0,this.parseFromMilliseconds()),O)return x(M*p[_(O)],this);if(typeof M=="number")return this.$ms=M,this.parseFromMilliseconds(),this;if(typeof M=="object")return Object.keys(M).forEach(function(k){N.$d[_(k)]=M[k]}),this.calMilliseconds(),this;if(typeof M=="string"){var I=M.match(d);if(I){var L=I.slice(2).map(function(k){return k!=null?Number(k):0});return this.$d.years=L[0],this.$d.months=L[1],this.$d.weeks=L[2],this.$d.days=L[3],this.$d.hours=L[4],this.$d.minutes=L[5],this.$d.seconds=L[6],this.calMilliseconds(),this}}return this}var B=F.prototype;return B.calMilliseconds=function(){var M=this;this.$ms=Object.keys(this.$d).reduce(function(O,A){return O+(M.$d[A]||0)*p[A]},0)},B.parseFromMilliseconds=function(){var M=this.$ms;this.$d.years=m(M/c),M%=c,this.$d.months=m(M/h),M%=h,this.$d.days=m(M/u),M%=u,this.$d.hours=m(M/a),M%=a,this.$d.minutes=m(M/i),M%=i,this.$d.seconds=m(M/n),M%=n,this.$d.milliseconds=M},B.toISOString=function(){var M=D(this.$d.years,"Y"),O=D(this.$d.months,"M"),A=+this.$d.days||0;this.$d.weeks&&(A+=7*this.$d.weeks);var N=D(A,"D"),I=D(this.$d.hours,"H"),L=D(this.$d.minutes,"M"),k=this.$d.seconds||0;this.$d.milliseconds&&(k+=this.$d.milliseconds/1e3,k=Math.round(1e3*k)/1e3);var z=D(k,"S"),R=M.negative||O.negative||N.negative||I.negative||L.negative||z.negative,V=I.format||L.format||z.format?"T":"",H=(R?"-":"")+"P"+M.format+O.format+N.format+V+I.format+L.format+z.format;return H==="P"||H==="-P"?"P0D":H},B.toJSON=function(){return this.toISOString()},B.format=function(M){var O=M||"YYYY-MM-DDTHH:mm:ss",A={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return O.replace(f,function(N,I){return I||String(A[N])})},B.as=function(M){return this.$ms/p[_(M)]},B.get=function(M){var O=this.$ms,A=_(M);return A==="milliseconds"?O%=1e3:O=A==="weeks"?m(O/p[A]):this.$d[A],O||0},B.add=function(M,O,A){var N;return N=O?M*p[_(O)]:v(M)?M.$ms:x(M,this).$ms,x(this.$ms+N*(A?-1:1),this)},B.subtract=function(M,O){return this.add(M,O,!0)},B.locale=function(M){var O=this.clone();return O.$l=M,O},B.clone=function(){return x(this.$ms,this)},B.humanize=function(M){return t().add(this.$ms,"ms").locale(this.$l).fromNow(!M)},B.valueOf=function(){return this.asMilliseconds()},B.milliseconds=function(){return this.get("milliseconds")},B.asMilliseconds=function(){return this.as("milliseconds")},B.seconds=function(){return this.get("seconds")},B.asSeconds=function(){return this.as("seconds")},B.minutes=function(){return this.get("minutes")},B.asMinutes=function(){return this.as("minutes")},B.hours=function(){return this.get("hours")},B.asHours=function(){return this.as("hours")},B.days=function(){return this.get("days")},B.asDays=function(){return this.as("days")},B.weeks=function(){return this.get("weeks")},B.asWeeks=function(){return this.as("weeks")},B.months=function(){return this.get("months")},B.asMonths=function(){return this.as("months")},B.years=function(){return this.get("years")},B.asYears=function(){return this.as("years")},F}(),b=function(F,B,M){return F.add(B.years()*M,"y").add(B.months()*M,"M").add(B.days()*M,"d").add(B.hours()*M,"h").add(B.minutes()*M,"m").add(B.seconds()*M,"s").add(B.milliseconds()*M,"ms")};return function(F,B,M){t=M,r=M().$utils(),M.duration=function(N,I){var L=M.locale();return x(N,{$l:L},I)},M.isDuration=v;var O=B.prototype.add,A=B.prototype.subtract;B.prototype.add=function(N,I){return v(N)?b(this,N,1):O.bind(this)(N,I)},B.prototype.subtract=function(N,I){return v(N)?b(this,N,-1):A.bind(this)(N,I)}}})})(Kf);var TD=Kf.exports,$D=tt(TD);ot.extend(Dl),ot.extend(SD),ot.extend(ID),ot.extend($D);class Zf{constructor(e,t,r){q(this,"array");q(this,"color");q(this,"math");q(this,"str");q(this,"map");q(this,"matrix");q(this,"timeframe");q(this,"ta");q(this,"input");q(this,"_variables");q(this,"_cacheData");q(this,"_options");q(this,"_errorListener");q(this,"_plots");q(this,"_plotshapes");q(this,"_plotbars");q(this,"_plotchars");q(this,"_plotarrows");q(this,"_plotcandles");q(this,"_alerts");q(this,"_bgColors");q(this,"_hlines");q(this,"_fills");q(this,"chart");q(this,"line");q(this,"label");q(this,"polyline");q(this,"box");q(this,"table");q(this,"linefill");q(this,"log");q(this,"runtime");q(this,"strategy");q(this,"request");q(this,"syminfo");q(this,"_count",0);var i;const n=((i=e.toString().split(".")[1])==null?void 0:i.length)||4;this._variables=t,this._errorListener=new hw,this.array=new D1(this._errorListener),this.math=new w1(n,this._errorListener),this.color=new Gx,this.str=new Xy(this._errorListener,n),this.map=new Qy(this._errorListener),this.timeframe=new Gy(t),this.matrix=new Vy(this._errorListener),this.ta=new Zx(t,this.math,this.timeframe),this._cacheData={},this._options={},this._bgColors={},this._alerts=new Map,this._hlines=new Map,this._fills=new Map,this.input=new Vx(t,this._errorListener,r),this._plots=new Map,this._plotshapes=new Map,this._plotbars=new Map,this._plotcandles=new Map,this._plotchars=new Map,this._plotarrows=new Map,this.chart={point:new Jy(t)},this.line=new wD(t,this._errorListener),this.label=new eD(t,this._errorListener),this.polyline=new DD(t,this._errorListener),this.box=new ED(t,this._errorListener),this.table=new CD(t,this._errorListener),this.linefill=new bD(t),this.log=new cw(t),this.runtime=new fw(this._errorListener),this.strategy=new MD(this._variables,this._options,e,this._errorListener),this.request=new uw(this._variables,r),this.syminfo=new lw}get errors(){return this._errorListener.errors}options(e){if(e.length)return this._getDataOfBarindex(e);const t=this.input.getInputs(),r=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const n=Object.keys(this._bgColors);let i;if(n.length){i={};for(const m of n)i[m]=[...this._bgColors[m].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,u=this._fills.size?[...this._fills.values()]:void 0,f=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const c=this._plots.size>0?[...this._plots.values()]:void 0,h=this._plotbars.size>0?[...this._plotbars.values()]:void 0,d=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,p=this._plotarrows.size>0?[...this._plotarrows.values()]:void 0,v=this._plotcandles.size>0?[...this._plotcandles.values()]:void 0,x=this._plotchars.size>0?[...this._plotchars.values()]:void 0,_=this._getDraws(),y=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:t,plots:c,draws:_,alerts:r,colors:i,hlines:a,fills:u,logs:f,plotshapes:d,plotarrows:p,plotcandles:v,plotchars:x,plotbars:h,isUseBgColor:y})}_getDataOfBarindex(e){const t=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const r=Object.keys(this._bgColors);let n;if(r.length){n={};for(const p of r)n[p]=[...this._bgColors[p].values()].map(v=>{const x=[];for(const _ of e){const y=v.colors[_];y&&x.push(y)}return v.colors=x,v})}const i=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(e,[...this._fills.values()]):void 0,u=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const f=this._getDataFromBarindex(e,[...this._plots.values()]),c=this._plotshapes.size>0?this._getDataFromBarindex(e,[...this._plotshapes.values()]):void 0,h=this._getDrawsFromBarindex(e),d=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:f,draws:h,alerts:t,colors:n,hlines:i,fills:a,logs:u,plotshapes:c,isUseBgColor:d})}_getDataFromBarindex(e,t){return t.map(r=>{const n=[];for(const i of e){const a=r.data[i];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:e,linefill:t,table:r,box:n,polyline:i,label:a}=this._variables,u={};return e.data.length&&(u.lines=e.data),t.data.length&&(u.linefills=t.data),r.data.length&&(u.tables=r.data),n.data.length&&(u.boxes=n.data),i.data.length&&(u.polylines=i.data),a.data.length&&(u.labels=a.data),Object.keys(u).length?u:void 0}_getDrawsFromBarindex(e){const{line:t,linefill:r,table:n,box:i,polyline:a,label:u}=this._variables,f={};return t.data.length&&(f.lines=t.getValOfBarIndex(e)),r.data.length&&(f.linefills=r.getValOfBarIndex(e)),n.data.length&&(f.tables=n.getValOfBarIndex(e)),i.data.length&&(f.boxes=i.getValOfBarIndex(e)),a.data.length&&(f.polylines=a.getValOfBarIndex(e)),u.data.length&&(f.labels=u.getValOfBarIndex(e)),Object.keys(f).length?f:void 0}updateOptions(e){const{inputs:t}=e;t&&t.length&&this.input.update(t)}update(e){const{barIndex:t}=e;this.strategy.updateOptions(),this.math.update(t)}endExecution(){this.strategy.endExecution()}library(e,t){if(!this._variables.bar_index){const r=/^[^\W\d\s][^\W\s]*$/,{title:n}=e;r.test(n)?(y1.includes(n)||x1.includes(n))&&this._errorListener.addError(Zt(ct.libraryTitleIsKeywordErr,{name:n}),t,Ze.Error):this._errorListener.addError(ct.libraryTitleErr,t,Ze.Error),this._options.scriptType="library",this._options.library=e}}indicator(e,t){if(!this._variables.bar_index){const{format:r}=e;this._paramVerfiy(r,t,"indicator",[Je.inherit,Je.percent,Je.price,Je.volume]),this._variables.updateMaxLength(e),this._options.scriptType="indicator",this._options.indicator=e}}_paramVerfiy(e="",t,r,n,i="format"){e&&!n.includes(e)&&this._errorListener.addError(Zt(ct.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,Ze.Error)}plot(e,t){const r=["color"];_n(e,r);const{series:n,color:i,...a}=e,{bar_index:u,time:f}=this._variables,c=`plot_${t}`,h=this._plots.get(c),d=(h==null?void 0:h.data)||[],p=n!==void 0&&isNaN(n)?void 0:n;if(d[u]={value:[f,p],itemStyle:{color:i}},this._seriesColorHandle(e,r,h),!h){this._count++,this._paramVerfiy(e.format,t,"plot",[Je.percent,Je.price,Je.volume]);const v=i?[i]:void 0;this._plots.set(c,{editable:!0,...a,colors:v,data:d,id:c,zIndex:this._count})}return{type:"plot",key:c}}plotbar(e,t){const r=["color"];_n(e,r);const{open:n,close:i,low:a,high:u,color:f,...c}=e,{bar_index:h,time:d}=this._variables,p=`plotbar_${t}`,v=this._plotbars.get(p),x=(v==null?void 0:v.data)||[],_=i!==void 0&&isNaN(i)?void 0:i,y=n!==void 0&&isNaN(n)?void 0:n,m=a!==void 0&&isNaN(a)?void 0:a,w=u!==void 0&&isNaN(u)?void 0:u,D=[d,y,_,m,w];if(x[h]={value:D,itemStyle:{color:f}},this._seriesColorHandle(e,r,v),!v){this._count++,this._paramVerfiy(e.format,t,"plotbar",[Je.percent,Je.price,Je.volume]);const C=f?[f]:void 0;this._plotbars.set(p,{editable:!0,...c,colors:C,data:x,id:p,zIndex:this._count})}}_verfiyArgs(e,t,r){const{size:n,format:i,location:a,style:u}=e;this._paramVerfiy(u,r,t,Object.values(_r),"style"),this._paramVerfiy(a,r,t,Object.values(vn),"location"),this._paramVerfiy(n,r,t,Object.values(ar),"size"),this._paramVerfiy(i,r,t,[Je.percent,Je.price,Je.volume],"format")}plotchar(e,t){const r=["color","textcolor"];_n(e,r);const{series:n,color:i,textcolor:a,location:u=vn.abovebar,...f}=e,{bar_index:c,time:h,high:d,low:p}=this._variables,v=`plotchar_${t}`,x=this._plotchars.get(v),_=(x==null?void 0:x.data)||[],y={value:[h,n],itemStyle:{color:i,textcolor:a},low:p,high:d};_[c]=y,this._seriesColorHandle(e,r,x),x||(this._count++,this._verfiyArgs(e,"plotchar",t),this._plotchars.set(v,{editable:!0,...f,location:u,data:_,id:v,zIndex:this._count}))}plotarrow(e,t){const r=["colorup","colordown"];_n(e,r);const{series:n,colorup:i,colordown:a,...u}=e,{bar_index:f,time:c}=this._variables,h=`plotarrow_${t}`,d=this._plotarrows.get(h),p=(d==null?void 0:d.data)||[];p[f]={value:[c,n!==void 0&&isNaN(n)?void 0:n],itemStyle:{colorup:i,colordown:a}},this._seriesColorHandle(e,r,d),d||(this._count++,this._paramVerfiy(e.format,t,"plotarrow",[Je.percent,Je.price,Je.volume]),this._plotarrows.set(h,{editable:!0,...u,data:p,id:h,zIndex:this._count}))}plotshape(e,t){const r=["color","textcolor"];_n(e,r);const{series:n,color:i,textcolor:a,location:u=vn.abovebar,...f}=e,{bar_index:c,time:h,low:d,high:p}=this._variables,v=`plotshape_${t}`,x=this._plotshapes.get(v),_=(x==null?void 0:x.data)||[],y={value:n,color:i,textcolor:a,time:h,low:d,high:p};if(_[c]=y,this._seriesColorHandle(e,r,x),!x){this._count++;const m=i?[i]:void 0;this._verfiyArgs(e,"plotshape",t),this._plotshapes.set(v,{editable:!0,...f,data:_,location:u,id:v,colors:m,zIndex:this._count})}}plotcandle(e,t){const r=["wickcolor","bordercolor","color"];_n(e,r);const{wickcolor:n,bordercolor:i,color:a,close:u,open:f,low:c,high:h,...d}=e,{bar_index:p,time:v}=this._variables,x=`plotcandle_${t}`,_=this._plotcandles.get(x),y=(_==null?void 0:_.data)||[],m=u!==void 0&&isNaN(u)?void 0:u,w=f!==void 0&&isNaN(f)?void 0:f,D=c!==void 0&&isNaN(c)?void 0:c,C=h!==void 0&&isNaN(h)?void 0:h,b=[v,w,m,D,C];y[p]={value:b,wickcolor:n,bordercolor:i,color:a},this._seriesColorHandle(e,r,_),_||(this._count++,this._paramVerfiy(e.format,t,"plotcandle",[Je.percent,Je.price,Je.volume]),this._plotcandles.set(x,{editable:!0,...d,data:y,id:x,zIndex:this._count}))}hline(e,t){const r=`hline_${t}`;_n(e,["color"]),this._verifyDisplay(e.display,"hline",t);const i=e.display&&!e.display.length?Vt.none:Vt.all;return this._hlines.has(r)||(this._count++,this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:i,...e,zIndex:this._count})),{type:"hline",key:r}}fill(e,t){var F,B,M,O,A,N,I,L,k,z;const r=["color","top_color","bottom_color"];_n(e,r);const{color:n,top_color:i,bottom_color:a,seriesColors:u,hline1:f,hline2:c,plot1:h,plot2:d,...p}=e,{bar_index:v,time:x}=this._variables,_=`fill_${t}`,y=this._fills.get(_),m=(y==null?void 0:y.data)||[];this._verifyDisplay(e.display,"fill",t);const w=e.display&&!e.display.length?Vt.none:Vt.all;let D,C,b="plot";if(f&&c)D=(F=this._hlines.get(f==null?void 0:f.key))==null?void 0:F.price,C=(B=this._hlines.get(c==null?void 0:c.key))==null?void 0:B.price,b="hline";else{const R=((M=this._plots.get(h==null?void 0:h.key))==null?void 0:M.data)||[],V=((O=this._plots.get(d==null?void 0:d.key))==null?void 0:O.data)||[];D=(N=(A=R[v])==null?void 0:A.value)==null?void 0:N[1],C=(L=(I=V[v])==null?void 0:I.value)==null?void 0:L[1]}if(m[v]={time:x,color:n,top_color:i,bottom_color:a,plot1:D,plot2:C},this._seriesColorHandle(e,r,y),!y){this._count++;const R=((k=this._options.indicator)==null?void 0:k.explicit_plot_zorder)||((z=this._options.strategy)==null?void 0:z.explicit_plot_zorder),V=n?[n]:void 0,H=i?[i]:void 0,ee=a?[a]:void 0;this._fills.set(_,{id:_,colors:V,top_colors:H,bottom_colors:ee,display:w,data:m,type:b,editable:!0,fillgaps:!1,hline1:f,hline2:c,plot1:h,plot2:d,...p,zIndex:R?this._count:void 0})}}alert({message:e,freq:t=Zr.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:i,last_bar_index:a}=this._variables,u=`alert_${r}`,f=this._cacheData[u]||{},c=f.barIndex;if(this._paramVerfiy(t,r,"alert",[Zr.freqAll,Zr.freqOncePerBar,Zr.freqOncePerBarClose]),t===Zr.freqOncePerBar&&n===c){this._alerts.delete(u);return}this._cacheData[u]=f;const h={message:e,freq:t,id:u,type:"alert"};if(i){t!==Zr.freqOncePerBarClose&&this._alerts.set(u,h),f.barIndex=n;return}if(!i&&t===Zr.freqOncePerBarClose&&n===c&&a===n-1){this._alerts.set(u,h),f.barIndex=n;return}this._alerts.delete(u)}alertcondition({condition:e,message:t,title:r},n){const{_isRealTimeBar:i}=this._variables,a=`alertcondition_${n}`;i&&e?this._alerts.set(a,{message:t,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(e,t){this._setColors(e,"barcolor",t)}bgcolor(e,t){this._setColors(e,"bgcolor",t)}_verifyDisplay(e=Uf.all,t,r){e.length&&e.length<4&&this._errorListener.addError(Zt(ct.displayErr,{func:t,values:"[display.none, display.all]"}),r,Ze.Error)}_setColors(e,t,r){_n(e,["color"]);const{color:i,...a}=e;this._verifyDisplay(a.display,t,r);const u=e.display&&!e.display.length?Vt.none:Vt.all,{bar_index:f,time:c}=this._variables,h=`${t}_${r}`;this._bgColors[t]||(this._bgColors[t]=new Map);const d=this._bgColors[t].get(h),p=(d==null?void 0:d.colors)||[],v=(d==null?void 0:d.setColors)||[];i&&!v.includes(i)&&v.push(i),p[f]={color:i,time:c},d||this._bgColors[t].set(h,{...a,display:u,colors:p,setColors:v,id:h})}max_bars_back({var:e,num:t,var_name:r}){console.log(e,t,r)}float({x:e}){return e}bool({x:e}){return e||!1}string({x:e}){return e}int({x:e}){return e&&Math.trunc(e)}na({x:e}){return!!(e===void 0||isNaN(e))}fixnan({source:e},t){return e===void 0||isNaN(e)?this._cacheData[`fixnan_${t}`]:(this._cacheData[`fixnan_${t}`]=e,e)}nz({source:e,replacement:t}){return e!==void 0&&!isNaN(e)?e:t||0}time({timeframe:e="",session:t,timezone:r,bars_back:n=0},i){return this._timeHandle(this._variables.time,i,e,t,r,n)}time_close({timeframe:e="",session:t,timezone:r,bars_back:n=0},i){return this._variables.time_close&&this._timeHandle(this._variables.time_close,i,e,t,r,n)}timestamp(e){const{dateString:t,timezone:r,year:n,month:i,day:a,hour:u=0,minute:f=0,second:c=0}=e;if(t)return ot(t).utc(!/GMT|UTC/.test(t)).valueOf();let h=i-1,d=n;if(h<0){const v=Math.ceil(Math.abs(h/12));h=12*v+h,d=n-v}let p=ot({year:d,month:h,day:a,hour:u,minute:f,second:c});return r&&(p=Kr(p.utc(!0).valueOf(),r)),p.utc(!0).valueOf()}weekofyear({time:e,timezone:t}){return Kr(e,t).week()}year({time:e,timezone:t}){return Kr(e,t).year()}second({time:e,timezone:t}){return Kr(e,t).second()}month({time:e,timezone:t}){return Kr(e,t).month()+1}minute({time:e,timezone:t}){return Kr(e,t).minute()}hour({time:e,timezone:t}){return Kr(e,t).hour()}dayofweek({time:e,timezone:t}){return Kr(e,t).day()+1}dayofmonth({time:e,timezone:t}){return Kr(e,t).date()}_calcTimeOffset(e,t){const r=this._variables.getTimeTradingday(e,t),n=pn(t)*1e3;return e-r-Math.floor((e-r)/n)*n}_timeHandle(e,t,r="",n,i,a=0){const u=r||this._variables.timeframe.period,f=pn(u),c=pn(this._variables.timeframe.period);let h;if(f<=c)h=e;else{const d=`time_${t}`,p=this._cacheData[d];if(p)p.currentTime+f*1e3-p.offset<=e?(h=e,this._cacheData[d]={currentTime:e,offset:0}):h=p;else{const v=this._calcTimeOffset(e,u);this._cacheData[d]={currentTime:e,offset:v},h=e}}if(n){const{timePeriods:d,weeks:p}=this._parserSession(n,t),v=ot(e).format("YYYY-MM-DD"),x=h;h=void 0;for(const y of d){const[m,w]=y;if(ot(e).isBetween(`${v} ${m}`,`${v} ${w}`,"hour")){ot(x).isBetween(`${v} ${m}`,`${v} ${w}`,"hour")?h=x:h=ot(`${v} ${m}`).valueOf();break}}const _=this._variables.dayofweek;h&&!p.includes(_)&&(h=void 0)}return i&&(h=h&&Kr(h,i).valueOf()),h&&h-a*c*1e3}_seriesColorHandle(e,t,r){var n;if(r&&t!=null&&t.length)for(const i of t){if((n=r.gradientColorKeys)!=null&&n.includes(i))continue;const a=e[i];if(!a)continue;const u=r[`${i}s`]||[];u.includes(a)||(u.push(a),r[`${i}s`]=u,u.length>5&&(r[`${i}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(i)))}}_parserSession(e,t){const r=e.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(f=>{const c=parseInt(f,10);if(c<1||c>7){this._errorListener.addError(`Invalid day of week: ${f}`,t,Ze.Error);return}return c});return{timePeriods:n.split(",").map(f=>{f===""||f===yi.regular?f="0930-1500":f===yi.extended&&(f="1500-1830");const c=f.split("-");return c.length!==2?(this._errorListener.addError(`Invalid time period: ${f}`,t,Ze.Error),[]):[this._processTime(c[0],t),this._processTime(c[1],t)]}),weeks:a}}_processTime(e,t){const r=parseInt(e.slice(0,2),10),n=parseInt(e.slice(2),10);if(!(r>=0&&r<=23)&&n>=0&&n<=59){this._errorListener.addError("Invalid time: Time must be within 00:00 to 23:59",t,Ze.Error);return}return`${r}:${n}`}}var Vf={exports:{}};function LD(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ou={exports:{}},Gf;function Ve(){return Gf||(Gf=1,function(s,e){(function(t,r){s.exports=r()})(ye,function(){var t=t||function(r,n){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof ye<"u"&&ye.crypto&&(i=ye.crypto),!i&&typeof LD=="function")try{i=Fx}catch{}var a=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},u=Object.create||function(){function w(){}return function(D){var C;return w.prototype=D,C=new w,w.prototype=null,C}}(),f={},c=f.lib={},h=c.Base=function(){return{extend:function(w){var D=u(this);return w&&D.mixIn(w),(!D.hasOwnProperty("init")||this.init===D.init)&&(D.init=function(){D.$super.init.apply(this,arguments)}),D.init.prototype=D,D.$super=this,D},create:function(){var w=this.extend();return w.init.apply(w,arguments),w},init:function(){},mixIn:function(w){for(var D in w)w.hasOwnProperty(D)&&(this[D]=w[D]);w.hasOwnProperty("toString")&&(this.toString=w.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=c.WordArray=h.extend({init:function(w,D){w=this.words=w||[],D!=n?this.sigBytes=D:this.sigBytes=w.length*4},toString:function(w){return(w||v).stringify(this)},concat:function(w){var D=this.words,C=w.words,b=this.sigBytes,F=w.sigBytes;if(this.clamp(),b%4)for(var B=0;B<F;B++){var M=C[B>>>2]>>>24-B%4*8&255;D[b+B>>>2]|=M<<24-(b+B)%4*8}else for(var O=0;O<F;O+=4)D[b+O>>>2]=C[O>>>2];return this.sigBytes+=F,this},clamp:function(){var w=this.words,D=this.sigBytes;w[D>>>2]&=4294967295<<32-D%4*8,w.length=r.ceil(D/4)},clone:function(){var w=h.clone.call(this);return w.words=this.words.slice(0),w},random:function(w){for(var D=[],C=0;C<w;C+=4)D.push(a());return new d.init(D,w)}}),p=f.enc={},v=p.Hex={stringify:function(w){for(var D=w.words,C=w.sigBytes,b=[],F=0;F<C;F++){var B=D[F>>>2]>>>24-F%4*8&255;b.push((B>>>4).toString(16)),b.push((B&15).toString(16))}return b.join("")},parse:function(w){for(var D=w.length,C=[],b=0;b<D;b+=2)C[b>>>3]|=parseInt(w.substr(b,2),16)<<24-b%8*4;return new d.init(C,D/2)}},x=p.Latin1={stringify:function(w){for(var D=w.words,C=w.sigBytes,b=[],F=0;F<C;F++){var B=D[F>>>2]>>>24-F%4*8&255;b.push(String.fromCharCode(B))}return b.join("")},parse:function(w){for(var D=w.length,C=[],b=0;b<D;b++)C[b>>>2]|=(w.charCodeAt(b)&255)<<24-b%4*8;return new d.init(C,D)}},_=p.Utf8={stringify:function(w){try{return decodeURIComponent(escape(x.stringify(w)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(w){return x.parse(unescape(encodeURIComponent(w)))}},y=c.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(w){typeof w=="string"&&(w=_.parse(w)),this._data.concat(w),this._nDataBytes+=w.sigBytes},_process:function(w){var D,C=this._data,b=C.words,F=C.sigBytes,B=this.blockSize,M=B*4,O=F/M;w?O=r.ceil(O):O=r.max((O|0)-this._minBufferSize,0);var A=O*B,N=r.min(A*4,F);if(A){for(var I=0;I<A;I+=B)this._doProcessBlock(b,I);D=b.splice(0,A),C.sigBytes-=N}return new d.init(D,N)},clone:function(){var w=h.clone.call(this);return w._data=this._data.clone(),w},_minBufferSize:0});c.Hasher=y.extend({cfg:h.extend(),init:function(w){this.cfg=this.cfg.extend(w),this.reset()},reset:function(){y.reset.call(this),this._doReset()},update:function(w){return this._append(w),this._process(),this},finalize:function(w){w&&this._append(w);var D=this._doFinalize();return D},blockSize:16,_createHelper:function(w){return function(D,C){return new w.init(C).finalize(D)}},_createHmacHelper:function(w){return function(D,C){return new m.HMAC.init(w,C).finalize(D)}}});var m=f.algo={};return f}(Math);return t})}(ou)),ou.exports}var au={exports:{}},Xf;function Mo(){return Xf||(Xf=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(r){var n=t,i=n.lib,a=i.Base,u=i.WordArray,f=n.x64={};f.Word=a.extend({init:function(c,h){this.high=c,this.low=h}}),f.WordArray=a.extend({init:function(c,h){c=this.words=c||[],h!=r?this.sigBytes=h:this.sigBytes=c.length*8},toX32:function(){for(var c=this.words,h=c.length,d=[],p=0;p<h;p++){var v=c[p];d.push(v.high),d.push(v.low)}return u.create(d,this.sigBytes)},clone:function(){for(var c=a.clone.call(this),h=c.words=this.words.slice(0),d=h.length,p=0;p<d;p++)h[p]=h[p].clone();return c}})}(),t})}(au)),au.exports}var uu={exports:{}},Qf;function RD(){return Qf||(Qf=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(){if(typeof ArrayBuffer=="function"){var r=t,n=r.lib,i=n.WordArray,a=i.init,u=i.init=function(f){if(f instanceof ArrayBuffer&&(f=new Uint8Array(f)),(f instanceof Int8Array||typeof Uint8ClampedArray<"u"&&f instanceof Uint8ClampedArray||f instanceof Int16Array||f instanceof Uint16Array||f instanceof Int32Array||f instanceof Uint32Array||f instanceof Float32Array||f instanceof Float64Array)&&(f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength)),f instanceof Uint8Array){for(var c=f.byteLength,h=[],d=0;d<c;d++)h[d>>>2]|=f[d]<<24-d%4*8;a.call(this,h,c)}else a.apply(this,arguments)};u.prototype=i}}(),t.lib.WordArray})}(uu)),uu.exports}var lu={exports:{}},Jf;function PD(){return Jf||(Jf=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.WordArray,a=r.enc;a.Utf16=a.Utf16BE={stringify:function(f){for(var c=f.words,h=f.sigBytes,d=[],p=0;p<h;p+=2){var v=c[p>>>2]>>>16-p%4*8&65535;d.push(String.fromCharCode(v))}return d.join("")},parse:function(f){for(var c=f.length,h=[],d=0;d<c;d++)h[d>>>1]|=f.charCodeAt(d)<<16-d%2*16;return i.create(h,c*2)}},a.Utf16LE={stringify:function(f){for(var c=f.words,h=f.sigBytes,d=[],p=0;p<h;p+=2){var v=u(c[p>>>2]>>>16-p%4*8&65535);d.push(String.fromCharCode(v))}return d.join("")},parse:function(f){for(var c=f.length,h=[],d=0;d<c;d++)h[d>>>1]|=u(f.charCodeAt(d)<<16-d%2*16);return i.create(h,c*2)}};function u(f){return f<<8&4278255360|f>>>8&16711935}}(),t.enc.Utf16})}(lu)),lu.exports}var cu={exports:{}},eh;function oi(){return eh||(eh=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.WordArray,a=r.enc;a.Base64={stringify:function(f){var c=f.words,h=f.sigBytes,d=this._map;f.clamp();for(var p=[],v=0;v<h;v+=3)for(var x=c[v>>>2]>>>24-v%4*8&255,_=c[v+1>>>2]>>>24-(v+1)%4*8&255,y=c[v+2>>>2]>>>24-(v+2)%4*8&255,m=x<<16|_<<8|y,w=0;w<4&&v+w*.75<h;w++)p.push(d.charAt(m>>>6*(3-w)&63));var D=d.charAt(64);if(D)for(;p.length%4;)p.push(D);return p.join("")},parse:function(f){var c=f.length,h=this._map,d=this._reverseMap;if(!d){d=this._reverseMap=[];for(var p=0;p<h.length;p++)d[h.charCodeAt(p)]=p}var v=h.charAt(64);if(v){var x=f.indexOf(v);x!==-1&&(c=x)}return u(f,c,d)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function u(f,c,h){for(var d=[],p=0,v=0;v<c;v++)if(v%4){var x=h[f.charCodeAt(v-1)]<<v%4*2,_=h[f.charCodeAt(v)]>>>6-v%4*2,y=x|_;d[p>>>2]|=y<<24-p%4*8,p++}return i.create(d,p)}}(),t.enc.Base64})}(cu)),cu.exports}var fu={exports:{}},th;function kD(){return th||(th=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.WordArray,a=r.enc;a.Base64url={stringify:function(f,c){c===void 0&&(c=!0);var h=f.words,d=f.sigBytes,p=c?this._safe_map:this._map;f.clamp();for(var v=[],x=0;x<d;x+=3)for(var _=h[x>>>2]>>>24-x%4*8&255,y=h[x+1>>>2]>>>24-(x+1)%4*8&255,m=h[x+2>>>2]>>>24-(x+2)%4*8&255,w=_<<16|y<<8|m,D=0;D<4&&x+D*.75<d;D++)v.push(p.charAt(w>>>6*(3-D)&63));var C=p.charAt(64);if(C)for(;v.length%4;)v.push(C);return v.join("")},parse:function(f,c){c===void 0&&(c=!0);var h=f.length,d=c?this._safe_map:this._map,p=this._reverseMap;if(!p){p=this._reverseMap=[];for(var v=0;v<d.length;v++)p[d.charCodeAt(v)]=v}var x=d.charAt(64);if(x){var _=f.indexOf(x);_!==-1&&(h=_)}return u(f,h,p)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function u(f,c,h){for(var d=[],p=0,v=0;v<c;v++)if(v%4){var x=h[f.charCodeAt(v-1)]<<v%4*2,_=h[f.charCodeAt(v)]>>>6-v%4*2,y=x|_;d[p>>>2]|=y<<24-p%4*8,p++}return i.create(d,p)}}(),t.enc.Base64url})}(fu)),fu.exports}var hu={exports:{}},rh;function ai(){return rh||(rh=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(r){var n=t,i=n.lib,a=i.WordArray,u=i.Hasher,f=n.algo,c=[];(function(){for(var _=0;_<64;_++)c[_]=r.abs(r.sin(_+1))*4294967296|0})();var h=f.MD5=u.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(_,y){for(var m=0;m<16;m++){var w=y+m,D=_[w];_[w]=(D<<8|D>>>24)&16711935|(D<<24|D>>>8)&4278255360}var C=this._hash.words,b=_[y+0],F=_[y+1],B=_[y+2],M=_[y+3],O=_[y+4],A=_[y+5],N=_[y+6],I=_[y+7],L=_[y+8],k=_[y+9],z=_[y+10],R=_[y+11],V=_[y+12],H=_[y+13],ee=_[y+14],te=_[y+15],j=C[0],X=C[1],Y=C[2],Q=C[3];j=d(j,X,Y,Q,b,7,c[0]),Q=d(Q,j,X,Y,F,12,c[1]),Y=d(Y,Q,j,X,B,17,c[2]),X=d(X,Y,Q,j,M,22,c[3]),j=d(j,X,Y,Q,O,7,c[4]),Q=d(Q,j,X,Y,A,12,c[5]),Y=d(Y,Q,j,X,N,17,c[6]),X=d(X,Y,Q,j,I,22,c[7]),j=d(j,X,Y,Q,L,7,c[8]),Q=d(Q,j,X,Y,k,12,c[9]),Y=d(Y,Q,j,X,z,17,c[10]),X=d(X,Y,Q,j,R,22,c[11]),j=d(j,X,Y,Q,V,7,c[12]),Q=d(Q,j,X,Y,H,12,c[13]),Y=d(Y,Q,j,X,ee,17,c[14]),X=d(X,Y,Q,j,te,22,c[15]),j=p(j,X,Y,Q,F,5,c[16]),Q=p(Q,j,X,Y,N,9,c[17]),Y=p(Y,Q,j,X,R,14,c[18]),X=p(X,Y,Q,j,b,20,c[19]),j=p(j,X,Y,Q,A,5,c[20]),Q=p(Q,j,X,Y,z,9,c[21]),Y=p(Y,Q,j,X,te,14,c[22]),X=p(X,Y,Q,j,O,20,c[23]),j=p(j,X,Y,Q,k,5,c[24]),Q=p(Q,j,X,Y,ee,9,c[25]),Y=p(Y,Q,j,X,M,14,c[26]),X=p(X,Y,Q,j,L,20,c[27]),j=p(j,X,Y,Q,H,5,c[28]),Q=p(Q,j,X,Y,B,9,c[29]),Y=p(Y,Q,j,X,I,14,c[30]),X=p(X,Y,Q,j,V,20,c[31]),j=v(j,X,Y,Q,A,4,c[32]),Q=v(Q,j,X,Y,L,11,c[33]),Y=v(Y,Q,j,X,R,16,c[34]),X=v(X,Y,Q,j,ee,23,c[35]),j=v(j,X,Y,Q,F,4,c[36]),Q=v(Q,j,X,Y,O,11,c[37]),Y=v(Y,Q,j,X,I,16,c[38]),X=v(X,Y,Q,j,z,23,c[39]),j=v(j,X,Y,Q,H,4,c[40]),Q=v(Q,j,X,Y,b,11,c[41]),Y=v(Y,Q,j,X,M,16,c[42]),X=v(X,Y,Q,j,N,23,c[43]),j=v(j,X,Y,Q,k,4,c[44]),Q=v(Q,j,X,Y,V,11,c[45]),Y=v(Y,Q,j,X,te,16,c[46]),X=v(X,Y,Q,j,B,23,c[47]),j=x(j,X,Y,Q,b,6,c[48]),Q=x(Q,j,X,Y,I,10,c[49]),Y=x(Y,Q,j,X,ee,15,c[50]),X=x(X,Y,Q,j,A,21,c[51]),j=x(j,X,Y,Q,V,6,c[52]),Q=x(Q,j,X,Y,M,10,c[53]),Y=x(Y,Q,j,X,z,15,c[54]),X=x(X,Y,Q,j,F,21,c[55]),j=x(j,X,Y,Q,L,6,c[56]),Q=x(Q,j,X,Y,te,10,c[57]),Y=x(Y,Q,j,X,N,15,c[58]),X=x(X,Y,Q,j,H,21,c[59]),j=x(j,X,Y,Q,O,6,c[60]),Q=x(Q,j,X,Y,R,10,c[61]),Y=x(Y,Q,j,X,B,15,c[62]),X=x(X,Y,Q,j,k,21,c[63]),C[0]=C[0]+j|0,C[1]=C[1]+X|0,C[2]=C[2]+Y|0,C[3]=C[3]+Q|0},_doFinalize:function(){var _=this._data,y=_.words,m=this._nDataBytes*8,w=_.sigBytes*8;y[w>>>5]|=128<<24-w%32;var D=r.floor(m/4294967296),C=m;y[(w+64>>>9<<4)+15]=(D<<8|D>>>24)&16711935|(D<<24|D>>>8)&4278255360,y[(w+64>>>9<<4)+14]=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360,_.sigBytes=(y.length+1)*4,this._process();for(var b=this._hash,F=b.words,B=0;B<4;B++){var M=F[B];F[B]=(M<<8|M>>>24)&16711935|(M<<24|M>>>8)&4278255360}return b},clone:function(){var _=u.clone.call(this);return _._hash=this._hash.clone(),_}});function d(_,y,m,w,D,C,b){var F=_+(y&m|~y&w)+D+b;return(F<<C|F>>>32-C)+y}function p(_,y,m,w,D,C,b){var F=_+(y&w|m&~w)+D+b;return(F<<C|F>>>32-C)+y}function v(_,y,m,w,D,C,b){var F=_+(y^m^w)+D+b;return(F<<C|F>>>32-C)+y}function x(_,y,m,w,D,C,b){var F=_+(m^(y|~w))+D+b;return(F<<C|F>>>32-C)+y}n.MD5=u._createHelper(h),n.HmacMD5=u._createHmacHelper(h)}(Math),t.MD5})}(hu)),hu.exports}var du={exports:{}},nh;function ih(){return nh||(nh=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.WordArray,a=n.Hasher,u=r.algo,f=[],c=u.SHA1=a.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(h,d){for(var p=this._hash.words,v=p[0],x=p[1],_=p[2],y=p[3],m=p[4],w=0;w<80;w++){if(w<16)f[w]=h[d+w]|0;else{var D=f[w-3]^f[w-8]^f[w-14]^f[w-16];f[w]=D<<1|D>>>31}var C=(v<<5|v>>>27)+m+f[w];w<20?C+=(x&_|~x&y)+1518500249:w<40?C+=(x^_^y)+1859775393:w<60?C+=(x&_|x&y|_&y)-1894007588:C+=(x^_^y)-899497514,m=y,y=_,_=x<<30|x>>>2,x=v,v=C}p[0]=p[0]+v|0,p[1]=p[1]+x|0,p[2]=p[2]+_|0,p[3]=p[3]+y|0,p[4]=p[4]+m|0},_doFinalize:function(){var h=this._data,d=h.words,p=this._nDataBytes*8,v=h.sigBytes*8;return d[v>>>5]|=128<<24-v%32,d[(v+64>>>9<<4)+14]=Math.floor(p/4294967296),d[(v+64>>>9<<4)+15]=p,h.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var h=a.clone.call(this);return h._hash=this._hash.clone(),h}});r.SHA1=a._createHelper(c),r.HmacSHA1=a._createHmacHelper(c)}(),t.SHA1})}(du)),du.exports}var pu={exports:{}},sh;function _u(){return sh||(sh=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){return function(r){var n=t,i=n.lib,a=i.WordArray,u=i.Hasher,f=n.algo,c=[],h=[];(function(){function v(m){for(var w=r.sqrt(m),D=2;D<=w;D++)if(!(m%D))return!1;return!0}function x(m){return(m-(m|0))*4294967296|0}for(var _=2,y=0;y<64;)v(_)&&(y<8&&(c[y]=x(r.pow(_,1/2))),h[y]=x(r.pow(_,1/3)),y++),_++})();var d=[],p=f.SHA256=u.extend({_doReset:function(){this._hash=new a.init(c.slice(0))},_doProcessBlock:function(v,x){for(var _=this._hash.words,y=_[0],m=_[1],w=_[2],D=_[3],C=_[4],b=_[5],F=_[6],B=_[7],M=0;M<64;M++){if(M<16)d[M]=v[x+M]|0;else{var O=d[M-15],A=(O<<25|O>>>7)^(O<<14|O>>>18)^O>>>3,N=d[M-2],I=(N<<15|N>>>17)^(N<<13|N>>>19)^N>>>10;d[M]=A+d[M-7]+I+d[M-16]}var L=C&b^~C&F,k=y&m^y&w^m&w,z=(y<<30|y>>>2)^(y<<19|y>>>13)^(y<<10|y>>>22),R=(C<<26|C>>>6)^(C<<21|C>>>11)^(C<<7|C>>>25),V=B+R+L+h[M]+d[M],H=z+k;B=F,F=b,b=C,C=D+V|0,D=w,w=m,m=y,y=V+H|0}_[0]=_[0]+y|0,_[1]=_[1]+m|0,_[2]=_[2]+w|0,_[3]=_[3]+D|0,_[4]=_[4]+C|0,_[5]=_[5]+b|0,_[6]=_[6]+F|0,_[7]=_[7]+B|0},_doFinalize:function(){var v=this._data,x=v.words,_=this._nDataBytes*8,y=v.sigBytes*8;return x[y>>>5]|=128<<24-y%32,x[(y+64>>>9<<4)+14]=r.floor(_/4294967296),x[(y+64>>>9<<4)+15]=_,v.sigBytes=x.length*4,this._process(),this._hash},clone:function(){var v=u.clone.call(this);return v._hash=this._hash.clone(),v}});n.SHA256=u._createHelper(p),n.HmacSHA256=u._createHmacHelper(p)}(Math),t.SHA256})}(pu)),pu.exports}var vu={exports:{}},oh;function zD(){return oh||(oh=1,function(s,e){(function(t,r,n){s.exports=r(Ve(),_u())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.WordArray,a=r.algo,u=a.SHA256,f=a.SHA224=u.extend({_doReset:function(){this._hash=new i.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var c=u._doFinalize.call(this);return c.sigBytes-=4,c}});r.SHA224=u._createHelper(f),r.HmacSHA224=u._createHmacHelper(f)}(),t.SHA224})}(vu)),vu.exports}var gu={exports:{}},ah;function uh(){return ah||(ah=1,function(s,e){(function(t,r,n){s.exports=r(Ve(),Mo())})(ye,function(t){return function(){var r=t,n=r.lib,i=n.Hasher,a=r.x64,u=a.Word,f=a.WordArray,c=r.algo;function h(){return u.create.apply(u,arguments)}var d=[h(1116352408,3609767458),h(1899447441,602891725),h(3049323471,3964484399),h(3921009573,2173295548),h(961987163,4081628472),h(1508970993,3053834265),h(2453635748,2937671579),h(2870763221,3664609560),h(3624381080,2734883394),h(310598401,1164996542),h(607225278,1323610764),h(1426881987,3590304994),h(1925078388,4068182383),h(2162078206,991336113),h(2614888103,633803317),h(3248222580,3479774868),h(3835390401,2666613458),h(4022224774,944711139),h(264347078,2341262773),h(604807628,2007800933),h(770255983,1495990901),h(1249150122,1856431235),h(1555081692,3175218132),h(1996064986,2198950837),h(2554220882,3999719339),h(2821834349,766784016),h(2952996808,2566594879),h(3210313671,3203337956),h(3336571891,1034457026),h(3584528711,2466948901),h(113926993,3758326383),h(338241895,168717936),h(666307205,1188179964),h(773529912,1546045734),h(1294757372,1522805485),h(1396182291,2643833823),h(1695183700,2343527390),h(1986661051,1014477480),h(2177026350,1206759142),h(2456956037,344077627),h(2730485921,1290863460),h(2820302411,3158454273),h(3259730800,3505952657),h(3345764771,106217008),h(3516065817,3606008344),h(3600352804,1432725776),h(4094571909,1467031594),h(275423344,851169720),h(430227734,3100823752),h(506948616,1363258195),h(659060556,3750685593),h(883997877,3785050280),h(958139571,3318307427),h(1322822218,3812723403),h(1537002063,2003034995),h(1747873779,3602036899),h(1955562222,1575990012),h(2024104815,1125592928),h(2227730452,2716904306),h(2361852424,442776044),h(2428436474,593698344),h(2756734187,3733110249),h(3204031479,2999351573),h(3329325298,3815920427),h(3391569614,3928383900),h(3515267271,566280711),h(3940187606,3454069534),h(4118630271,4000239992),h(116418474,1914138554),h(174292421,2731055270),h(289380356,3203993006),h(460393269,320620315),h(685471733,587496836),h(852142971,1086792851),h(1017036298,365543100),h(1126000580,2618297676),h(1288033470,3409855158),h(1501505948,4234509866),h(1607167915,987167468),h(1816402316,1246189591)],p=[];(function(){for(var x=0;x<80;x++)p[x]=h()})();var v=c.SHA512=i.extend({_doReset:function(){this._hash=new f.init([new u.init(1779033703,4089235720),new u.init(3144134277,2227873595),new u.init(1013904242,4271175723),new u.init(2773480762,1595750129),new u.init(1359893119,2917565137),new u.init(2600822924,725511199),new u.init(528734635,4215389547),new u.init(1541459225,327033209)])},_doProcessBlock:function(x,_){for(var y=this._hash.words,m=y[0],w=y[1],D=y[2],C=y[3],b=y[4],F=y[5],B=y[6],M=y[7],O=m.high,A=m.low,N=w.high,I=w.low,L=D.high,k=D.low,z=C.high,R=C.low,V=b.high,H=b.low,ee=F.high,te=F.low,j=B.high,X=B.low,Y=M.high,Q=M.low,pe=O,De=A,we=N,be=I,Oe=L,Fe=k,nt=z,Ye=R,Ie=V,Le=H,yt=ee,Wt=te,Ct=j,lr=X,Rr=Y,cr=Q,Dt=0;Dt<80;Dt++){var It,P,Z=p[Dt];if(Dt<16)P=Z.high=x[_+Dt*2]|0,It=Z.low=x[_+Dt*2+1]|0;else{var J=p[Dt-15],ie=J.high,ue=J.low,se=(ie>>>1|ue<<31)^(ie>>>8|ue<<24)^ie>>>7,_e=(ue>>>1|ie<<31)^(ue>>>8|ie<<24)^(ue>>>7|ie<<25),he=p[Dt-2],de=he.high,fe=he.low,Xe=(de>>>19|fe<<13)^(de<<3|fe>>>29)^de>>>6,et=(fe>>>19|de<<13)^(fe<<3|de>>>29)^(fe>>>6|de<<26),dt=p[Dt-7],zt=dt.high,Tt=dt.low,nr=p[Dt-16],fr=nr.high,en=nr.low;It=_e+Tt,P=se+zt+(It>>>0<_e>>>0?1:0),It=It+et,P=P+Xe+(It>>>0<et>>>0?1:0),It=It+en,P=P+fr+(It>>>0<en>>>0?1:0),Z.high=P,Z.low=It}var wn=Ie&yt^~Ie&Ct,li=Le&Wt^~Le&lr,ms=pe&we^pe&Oe^we&Oe,xs=De&be^De&Fe^be&Fe,ys=(pe>>>28|De<<4)^(pe<<30|De>>>2)^(pe<<25|De>>>7),ki=(De>>>28|pe<<4)^(De<<30|pe>>>2)^(De<<25|pe>>>7),zi=(Ie>>>14|Le<<18)^(Ie>>>18|Le<<14)^(Ie<<23|Le>>>9),Ds=(Le>>>14|Ie<<18)^(Le>>>18|Ie<<14)^(Le<<23|Ie>>>9),qi=d[Dt],ws=qi.high,qn=qi.low,Qt=cr+Ds,mr=Rr+zi+(Qt>>>0<cr>>>0?1:0),Qt=Qt+li,mr=mr+wn+(Qt>>>0<li>>>0?1:0),Qt=Qt+qn,mr=mr+ws+(Qt>>>0<qn>>>0?1:0),Qt=Qt+It,mr=mr+P+(Qt>>>0<It>>>0?1:0),Ui=ki+xs,bs=ys+ms+(Ui>>>0<ki>>>0?1:0);Rr=Ct,cr=lr,Ct=yt,lr=Wt,yt=Ie,Wt=Le,Le=Ye+Qt|0,Ie=nt+mr+(Le>>>0<Ye>>>0?1:0)|0,nt=Oe,Ye=Fe,Oe=we,Fe=be,we=pe,be=De,De=Qt+Ui|0,pe=mr+bs+(De>>>0<Qt>>>0?1:0)|0}A=m.low=A+De,m.high=O+pe+(A>>>0<De>>>0?1:0),I=w.low=I+be,w.high=N+we+(I>>>0<be>>>0?1:0),k=D.low=k+Fe,D.high=L+Oe+(k>>>0<Fe>>>0?1:0),R=C.low=R+Ye,C.high=z+nt+(R>>>0<Ye>>>0?1:0),H=b.low=H+Le,b.high=V+Ie+(H>>>0<Le>>>0?1:0),te=F.low=te+Wt,F.high=ee+yt+(te>>>0<Wt>>>0?1:0),X=B.low=X+lr,B.high=j+Ct+(X>>>0<lr>>>0?1:0),Q=M.low=Q+cr,M.high=Y+Rr+(Q>>>0<cr>>>0?1:0)},_doFinalize:function(){var x=this._data,_=x.words,y=this._nDataBytes*8,m=x.sigBytes*8;_[m>>>5]|=128<<24-m%32,_[(m+128>>>10<<5)+30]=Math.floor(y/4294967296),_[(m+128>>>10<<5)+31]=y,x.sigBytes=_.length*4,this._process();var w=this._hash.toX32();return w},clone:function(){var x=i.clone.call(this);return x._hash=this._hash.clone(),x},blockSize:1024/32});r.SHA512=i._createHelper(v),r.HmacSHA512=i._createHmacHelper(v)}(),t.SHA512})}(gu)),gu.exports}var mu={exports:{}},lh;function qD(){return lh||(lh=1,function(s,e){(function(t,r,n){s.exports=r(Ve(),Mo(),uh())})(ye,function(t){return function(){var r=t,n=r.x64,i=n.Word,a=n.WordArray,u=r.algo,f=u.SHA512,c=u.SHA384=f.extend({_doReset:function(){this._hash=new a.init([new i.init(3418070365,3238371032),new i.init(1654270250,914150663),new i.init(2438529370,812702999),new i.init(355462360,4144912697),new i.init(1731405415,4290775857),new i.init(2394180231,1750603025),new i.init(3675008525,1694076839),new i.init(1203062813,3204075428)])},_doFinalize:function(){var h=f._doFinalize.call(this);return h.sigBytes-=16,h}});r.SHA384=f._createHelper(c),r.HmacSHA384=f._createHmacHelper(c)}(),t.SHA384})}(mu)),mu.exports}var xu={exports:{}},ch;function UD(){return ch||(ch=1,function(s,e){(function(t,r,n){s.exports=r(Ve(),Mo())})(ye,function(t){return function(r){var n=t,i=n.lib,a=i.WordArray,u=i.Hasher,f=n.x64,c=f.Word,h=n.algo,d=[],p=[],v=[];(function(){for(var y=1,m=0,w=0;w<24;w++){d[y+5*m]=(w+1)*(w+2)/2%64;var D=m%5,C=(2*y+3*m)%5;y=D,m=C}for(var y=0;y<5;y++)for(var m=0;m<5;m++)p[y+5*m]=m+(2*y+3*m)%5*5;for(var b=1,F=0;F<24;F++){for(var B=0,M=0,O=0;O<7;O++){if(b&1){var A=(1<<O)-1;A<32?M^=1<<A:B^=1<<A-32}b&128?b=b<<1^113:b<<=1}v[F]=c.create(B,M)}})();var x=[];(function(){for(var y=0;y<25;y++)x[y]=c.create()})();var _=h.SHA3=u.extend({cfg:u.cfg.extend({outputLength:512}),_doReset:function(){for(var y=this._state=[],m=0;m<25;m++)y[m]=new c.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(y,m){for(var w=this._state,D=this.blockSize/2,C=0;C<D;C++){var b=y[m+2*C],F=y[m+2*C+1];b=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360,F=(F<<8|F>>>24)&16711935|(F<<24|F>>>8)&4278255360;var B=w[C];B.high^=F,B.low^=b}for(var M=0;M<24;M++){for(var O=0;O<5;O++){for(var A=0,N=0,I=0;I<5;I++){var B=w[O+5*I];A^=B.high,N^=B.low}var L=x[O];L.high=A,L.low=N}for(var O=0;O<5;O++)for(var k=x[(O+4)%5],z=x[(O+1)%5],R=z.high,V=z.low,A=k.high^(R<<1|V>>>31),N=k.low^(V<<1|R>>>31),I=0;I<5;I++){var B=w[O+5*I];B.high^=A,B.low^=N}for(var H=1;H<25;H++){var A,N,B=w[H],ee=B.high,te=B.low,j=d[H];j<32?(A=ee<<j|te>>>32-j,N=te<<j|ee>>>32-j):(A=te<<j-32|ee>>>64-j,N=ee<<j-32|te>>>64-j);var X=x[p[H]];X.high=A,X.low=N}var Y=x[0],Q=w[0];Y.high=Q.high,Y.low=Q.low;for(var O=0;O<5;O++)for(var I=0;I<5;I++){var H=O+5*I,B=w[H],pe=x[H],De=x[(O+1)%5+5*I],we=x[(O+2)%5+5*I];B.high=pe.high^~De.high&we.high,B.low=pe.low^~De.low&we.low}var B=w[0],be=v[M];B.high^=be.high,B.low^=be.low}},_doFinalize:function(){var y=this._data,m=y.words;this._nDataBytes*8;var w=y.sigBytes*8,D=this.blockSize*32;m[w>>>5]|=1<<24-w%32,m[(r.ceil((w+1)/D)*D>>>5)-1]|=128,y.sigBytes=m.length*4,this._process();for(var C=this._state,b=this.cfg.outputLength/8,F=b/8,B=[],M=0;M<F;M++){var O=C[M],A=O.high,N=O.low;A=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,N=(N<<8|N>>>24)&16711935|(N<<24|N>>>8)&4278255360,B.push(N),B.push(A)}return new a.init(B,b)},clone:function(){for(var y=u.clone.call(this),m=y._state=this._state.slice(0),w=0;w<25;w++)m[w]=m[w].clone();return y}});n.SHA3=u._createHelper(_),n.HmacSHA3=u._createHmacHelper(_)}(Math),t.SHA3})}(xu)),xu.exports}var yu={exports:{}},fh;function WD(){return fh||(fh=1,function(s,e){(function(t,r){s.exports=r(Ve())})(ye,function(t){/** @preserve
63
63
  (c) 2012 by Cédric Mesnil. All rights reserved.
64
64
 
65
65
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -67556,7 +67556,7 @@ function nr(a, n, r) {
67556
67556
  function oh() {
67557
67557
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
67558
67558
  }
67559
- const Fp = new Worker(new URL("" + new URL("assets/scriptsRunWorker-gOaiI2Kb.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
67559
+ const Fp = new Worker(new URL("" + new URL("assets/scriptsRunWorker-C9KtHX5_.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
67560
67560
  Fp.onerror = (a) => {
67561
67561
  console.error(a);
67562
67562
  };
@@ -141,7 +141,7 @@ function print() { __p += __j.call(arguments, '') }
141
141
  * @license
142
142
  * Copyright 2019 Google LLC
143
143
  * SPDX-License-Identifier: Apache-2.0
144
- */const _o=Symbol("Comlink.proxy"),sm=Symbol("Comlink.endpoint"),am=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),fo=a=>typeof a=="object"&&a!==null||typeof a=="function",nm={canHandle:a=>fo(a)&&a[_o],serialize(a){const{port1:n,port2:s}=new MessageChannel;return bo(a,n),[s,[s]]},deserialize(a){return a.start(),_n(a)}},im={canHandle:a=>fo(a)&&Ys in a,serialize({value:a}){let n;return a instanceof Error?n={isError:!0,value:{message:a.message,name:a.name,stack:a.stack}}:n={isError:!1,value:a},[n,[]]},deserialize(a){throw a.isError?Object.assign(new Error(a.value.message),a.value):a.value}},go=new Map([["proxy",nm],["throw",im]]);function om(a,n){for(const s of a)if(n===s||s==="*"||s instanceof RegExp&&s.test(n))return!0;return!1}function bo(a,n=globalThis,s=["*"]){n.addEventListener("message",function o(c){if(!c||!c.data)return;if(!om(s,c.origin)){console.warn(`Invalid origin '${c.origin}' for comlink proxy`);return}const{id:l,type:m,path:_}=Object.assign({path:[]},c.data),f=(c.data.argumentList||[]).map(br);let b;try{const h=_.slice(0,-1).reduce((O,K)=>O[K],a),T=_.reduce((O,K)=>O[K],a);switch(m){case"GET":b=T;break;case"SET":h[_.slice(-1)[0]]=br(c.data.value),b=!0;break;case"APPLY":b=T.apply(h,f);break;case"CONSTRUCT":{const O=new T(...f);b=gn(O)}break;case"ENDPOINT":{const{port1:O,port2:K}=new MessageChannel;bo(a,K),b=mm(O,[O])}break;case"RELEASE":b=void 0;break;default:return}}catch(h){b={value:h,[Ys]:0}}Promise.resolve(b).catch(h=>({value:h,[Ys]:0})).then(h=>{const[T,O]=ea(h);n.postMessage(Object.assign(Object.assign({},T),{id:l}),O),m==="RELEASE"&&(n.removeEventListener("message",o),xo(n),yn in a&&typeof a[yn]=="function"&&a[yn]())}).catch(h=>{const[T,O]=ea({value:new TypeError("Unserializable return value"),[Ys]:0});n.postMessage(Object.assign(Object.assign({},T),{id:l}),O)})}),n.start&&n.start()}function lm(a){return a.constructor.name==="MessagePort"}function xo(a){lm(a)&&a.close()}function _n(a,n){return fn(a,[],n)}function Qs(a){if(a)throw new Error("Proxy has been released and is not useable")}function ho(a){return Lr(a,{type:"RELEASE"}).then(()=>{xo(a)})}const Zs=new WeakMap,Js="FinalizationRegistry"in globalThis&&new FinalizationRegistry(a=>{const n=(Zs.get(a)||0)-1;Zs.set(a,n),n===0&&ho(a)});function cm(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function pm(a){Js&&Js.unregister(a)}function fn(a,n=[],s=function(){}){let o=!1;const c=new Proxy(s,{get(l,m){if(Qs(o),m===am)return()=>{pm(c),ho(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>c};const _=Lr(a,{type:"GET",path:n.map(f=>f.toString())}).then(br);return _.then.bind(_)}return fn(a,[...n,m])},set(l,m,_){Qs(o);const[f,b]=ea(_);return Lr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:f},b).then(br)},apply(l,m,_){Qs(o);const f=n[n.length-1];if(f===sm)return Lr(a,{type:"ENDPOINT"}).then(br);if(f==="bind")return fn(a,n.slice(0,-1));const[b,h]=wo(_);return Lr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(br)},construct(l,m){Qs(o);const[_,f]=wo(m);return Lr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:_},f).then(br)}});return cm(c,a),c}function dm(a){return Array.prototype.concat.apply([],a)}function wo(a){const n=a.map(ea);return[n.map(s=>s[0]),dm(n.map(s=>s[1]))]}const vo=new WeakMap;function mm(a,n){return vo.set(a,n),a}function gn(a){return Object.assign(a,{[_o]:!0})}function ea(a){for(const[n,s]of go)if(s.canHandle(a)){const[o,c]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},c]}return[{type:"RAW",value:a},vo.get(a)||[]]}function br(a){switch(a.type){case"HANDLER":return go.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Lr(a,n,s){return new Promise(o=>{const c=um();a.addEventListener("message",function l(m){!m.data||!m.data.id||m.data.id!==c||(a.removeEventListener("message",l),o(m.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:c},n),s)})}function um(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const To=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-gOaiI2Kb.js").href:new URL("assets/scriptsRunWorker-gOaiI2Kb.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});To.onerror=a=>{console.error(a)};async function Do(a){return await Gs.setInlayHints(a)}const ko=_n(To),Io=_n(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-CILIfaWz.js").href:new URL("assets/parserTccWorker-CILIfaWz.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function Ao(a,n=!1){const{functions:s,types:o,constants:c,variables:l,methods:m}=ct;return await Io.parseTcc(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function ym(a,n){const{functions:s,types:o,constants:c,variables:l,methods:m}=ct;return await Io.parseLibraryCode(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function qo(a,n,s=!0){return await ko.runScript(a,n,s)}async function _m(a){return await ko.removeScript(a)}function fm(a){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/editor.worker-CT5Cb1wO.js").href:new URL("assets/editor.worker-CT5Cb1wO.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),{name:a==null?void 0:a.name})}self.MonacoEnvironment={getWorker(){return new fm({name:"Editor Worker"})}},sn.config({paths:{vs:"https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.45.0/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});let Co={};const gm=(a,n)=>{const{height:s,width:o,theme:c,options:l,hasDiff:m,readOnly:_,defaultValue:f,onChange:b,onLinkOpen:h,onDeclareConfigChange:T,onCursorPositionChange:O,onActionTrigger:K,onEditorDidMount:F}=a,N=R.useRef(null),H=R.useRef(null);R.useImperativeHandle(n,()=>({setOriginalScript(S){var U;(U=N.current)==null||U.setOriginalScript(S)},setScript(S){var U;(U=N.current)==null||U.setValue(S)},gotoLine(){var S;(S=N.current)==null||S.gotoLine()},getEditorLayout(){var S;return(S=N.current)==null?void 0:S.getEditorLayout()},setPosition(S,U){var te;(te=N.current)==null||te.setPosition({column:S,lineNumber:U})},setModelMarkers(S){var U;(U=N.current)==null||U.setModelMarkers(S)},focus(){var S;(S=N.current)==null||S.focus()}})),R.useEffect(()=>{var S,U;m?(U=N.current)==null||U.addDiffDecorations():(S=N.current)==null||S.removeDiffDecorations()},[m]),R.useEffect(()=>{var S;(S=N.current)==null||S.updateActionTrigger(K)},[K]),R.useEffect(()=>{var S;h&&((S=N.current)==null||S.addLinkOpenFunc(h))},[h]);function V(S,U){var fe,le;St.initBuiltinsTrees(),Gs.setEditor(S),N.current=new rm(S,U,K),h&&((fe=N.current)==null||fe.addLinkOpenFunc(h)),m&&((le=N.current)==null||le.addDiffDecorations()),qd(S),requestAnimationFrame(P);const te=S.getValue();N.current.onChangeCursorPosition(O),b&&b(te),!_&&G(te),F&&F()}const G=R.useCallback(async S=>{var $e;const U=Date.now(),{errors:te,functions:fe,methods:le,types:ht,variables:Et,overloadsFuncs:Ue,imports:Ke,preParserCode:Y,enums:be}=await Ao(S),Ee=new Map(Object.entries(fe)),Me=new Map(Object.entries(le)),pt=new Map(Object.entries(ht)),wt=new Map(Object.entries(Et)),re=new Map(Object.entries(Ke)),xe=new Map(Object.entries(be));gr.setUserDefined({functions:Ee,methods:Me,types:pt,variables:wt,imports:re,enums:xe},Ue),St.setUserDefind(Ee,pt,wt,Me,xe);const Re=te.map(je=>({...je,severity:je.type||Ie.MarkerSeverity.Error}));if(_)return;try{if(!te.length&&Y){const je=await qo(Y,{isPreParser:!0});io.isEqual(je,Co)||(Co=je,T&&T(je))}}catch(je){console.log(je),te.push({message:je.message,startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0})}($e=N.current)==null||$e.setModelMarkers(Re);const Nt=Date.now();console.log((Nt-U)/1e3)},[T,_]),B=R.useMemo(()=>io.debounce(G,1500),[G]);function k(S){var U;if(_){G(S||"");return}Gs.clearInlayHints(),(U=N.current)==null||U.setModelMarkers([]),S!==void 0&&(b&&b(S),B(S))}const P=R.useCallback(()=>{var U,te;const S=(U=H.current)==null?void 0:U.getBoundingClientRect();(te=N.current)==null||te.setEditorLayout((S==null?void 0:S.height)||0,S==null?void 0:S.width)},[]);return R.useEffect(()=>{const S=()=>{window.requestAnimationFrame(P)},U=new ResizeObserver(S);return H.current&&U.observe(H.current),()=>{H.current&&U.unobserve(H.current),U.disconnect()}},[]),L.jsx("div",{ref:H,children:L.jsx(gd,{height:s,width:o||"100%",defaultLanguage:Se,defaultValue:f||`indicator("我的脚本")
144
+ */const _o=Symbol("Comlink.proxy"),sm=Symbol("Comlink.endpoint"),am=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),fo=a=>typeof a=="object"&&a!==null||typeof a=="function",nm={canHandle:a=>fo(a)&&a[_o],serialize(a){const{port1:n,port2:s}=new MessageChannel;return bo(a,n),[s,[s]]},deserialize(a){return a.start(),_n(a)}},im={canHandle:a=>fo(a)&&Ys in a,serialize({value:a}){let n;return a instanceof Error?n={isError:!0,value:{message:a.message,name:a.name,stack:a.stack}}:n={isError:!1,value:a},[n,[]]},deserialize(a){throw a.isError?Object.assign(new Error(a.value.message),a.value):a.value}},go=new Map([["proxy",nm],["throw",im]]);function om(a,n){for(const s of a)if(n===s||s==="*"||s instanceof RegExp&&s.test(n))return!0;return!1}function bo(a,n=globalThis,s=["*"]){n.addEventListener("message",function o(c){if(!c||!c.data)return;if(!om(s,c.origin)){console.warn(`Invalid origin '${c.origin}' for comlink proxy`);return}const{id:l,type:m,path:_}=Object.assign({path:[]},c.data),f=(c.data.argumentList||[]).map(br);let b;try{const h=_.slice(0,-1).reduce((O,K)=>O[K],a),T=_.reduce((O,K)=>O[K],a);switch(m){case"GET":b=T;break;case"SET":h[_.slice(-1)[0]]=br(c.data.value),b=!0;break;case"APPLY":b=T.apply(h,f);break;case"CONSTRUCT":{const O=new T(...f);b=gn(O)}break;case"ENDPOINT":{const{port1:O,port2:K}=new MessageChannel;bo(a,K),b=mm(O,[O])}break;case"RELEASE":b=void 0;break;default:return}}catch(h){b={value:h,[Ys]:0}}Promise.resolve(b).catch(h=>({value:h,[Ys]:0})).then(h=>{const[T,O]=ea(h);n.postMessage(Object.assign(Object.assign({},T),{id:l}),O),m==="RELEASE"&&(n.removeEventListener("message",o),xo(n),yn in a&&typeof a[yn]=="function"&&a[yn]())}).catch(h=>{const[T,O]=ea({value:new TypeError("Unserializable return value"),[Ys]:0});n.postMessage(Object.assign(Object.assign({},T),{id:l}),O)})}),n.start&&n.start()}function lm(a){return a.constructor.name==="MessagePort"}function xo(a){lm(a)&&a.close()}function _n(a,n){return fn(a,[],n)}function Qs(a){if(a)throw new Error("Proxy has been released and is not useable")}function ho(a){return Lr(a,{type:"RELEASE"}).then(()=>{xo(a)})}const Zs=new WeakMap,Js="FinalizationRegistry"in globalThis&&new FinalizationRegistry(a=>{const n=(Zs.get(a)||0)-1;Zs.set(a,n),n===0&&ho(a)});function cm(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function pm(a){Js&&Js.unregister(a)}function fn(a,n=[],s=function(){}){let o=!1;const c=new Proxy(s,{get(l,m){if(Qs(o),m===am)return()=>{pm(c),ho(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>c};const _=Lr(a,{type:"GET",path:n.map(f=>f.toString())}).then(br);return _.then.bind(_)}return fn(a,[...n,m])},set(l,m,_){Qs(o);const[f,b]=ea(_);return Lr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:f},b).then(br)},apply(l,m,_){Qs(o);const f=n[n.length-1];if(f===sm)return Lr(a,{type:"ENDPOINT"}).then(br);if(f==="bind")return fn(a,n.slice(0,-1));const[b,h]=wo(_);return Lr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(br)},construct(l,m){Qs(o);const[_,f]=wo(m);return Lr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:_},f).then(br)}});return cm(c,a),c}function dm(a){return Array.prototype.concat.apply([],a)}function wo(a){const n=a.map(ea);return[n.map(s=>s[0]),dm(n.map(s=>s[1]))]}const vo=new WeakMap;function mm(a,n){return vo.set(a,n),a}function gn(a){return Object.assign(a,{[_o]:!0})}function ea(a){for(const[n,s]of go)if(s.canHandle(a)){const[o,c]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},c]}return[{type:"RAW",value:a},vo.get(a)||[]]}function br(a){switch(a.type){case"HANDLER":return go.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Lr(a,n,s){return new Promise(o=>{const c=um();a.addEventListener("message",function l(m){!m.data||!m.data.id||m.data.id!==c||(a.removeEventListener("message",l),o(m.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:c},n),s)})}function um(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const To=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-C9KtHX5_.js").href:new URL("assets/scriptsRunWorker-C9KtHX5_.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});To.onerror=a=>{console.error(a)};async function Do(a){return await Gs.setInlayHints(a)}const ko=_n(To),Io=_n(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-CILIfaWz.js").href:new URL("assets/parserTccWorker-CILIfaWz.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function Ao(a,n=!1){const{functions:s,types:o,constants:c,variables:l,methods:m}=ct;return await Io.parseTcc(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function ym(a,n){const{functions:s,types:o,constants:c,variables:l,methods:m}=ct;return await Io.parseLibraryCode(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function qo(a,n,s=!0){return await ko.runScript(a,n,s)}async function _m(a){return await ko.removeScript(a)}function fm(a){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/editor.worker-CT5Cb1wO.js").href:new URL("assets/editor.worker-CT5Cb1wO.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),{name:a==null?void 0:a.name})}self.MonacoEnvironment={getWorker(){return new fm({name:"Editor Worker"})}},sn.config({paths:{vs:"https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.45.0/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});let Co={};const gm=(a,n)=>{const{height:s,width:o,theme:c,options:l,hasDiff:m,readOnly:_,defaultValue:f,onChange:b,onLinkOpen:h,onDeclareConfigChange:T,onCursorPositionChange:O,onActionTrigger:K,onEditorDidMount:F}=a,N=R.useRef(null),H=R.useRef(null);R.useImperativeHandle(n,()=>({setOriginalScript(S){var U;(U=N.current)==null||U.setOriginalScript(S)},setScript(S){var U;(U=N.current)==null||U.setValue(S)},gotoLine(){var S;(S=N.current)==null||S.gotoLine()},getEditorLayout(){var S;return(S=N.current)==null?void 0:S.getEditorLayout()},setPosition(S,U){var te;(te=N.current)==null||te.setPosition({column:S,lineNumber:U})},setModelMarkers(S){var U;(U=N.current)==null||U.setModelMarkers(S)},focus(){var S;(S=N.current)==null||S.focus()}})),R.useEffect(()=>{var S,U;m?(U=N.current)==null||U.addDiffDecorations():(S=N.current)==null||S.removeDiffDecorations()},[m]),R.useEffect(()=>{var S;(S=N.current)==null||S.updateActionTrigger(K)},[K]),R.useEffect(()=>{var S;h&&((S=N.current)==null||S.addLinkOpenFunc(h))},[h]);function V(S,U){var fe,le;St.initBuiltinsTrees(),Gs.setEditor(S),N.current=new rm(S,U,K),h&&((fe=N.current)==null||fe.addLinkOpenFunc(h)),m&&((le=N.current)==null||le.addDiffDecorations()),qd(S),requestAnimationFrame(P);const te=S.getValue();N.current.onChangeCursorPosition(O),b&&b(te),!_&&G(te),F&&F()}const G=R.useCallback(async S=>{var $e;const U=Date.now(),{errors:te,functions:fe,methods:le,types:ht,variables:Et,overloadsFuncs:Ue,imports:Ke,preParserCode:Y,enums:be}=await Ao(S),Ee=new Map(Object.entries(fe)),Me=new Map(Object.entries(le)),pt=new Map(Object.entries(ht)),wt=new Map(Object.entries(Et)),re=new Map(Object.entries(Ke)),xe=new Map(Object.entries(be));gr.setUserDefined({functions:Ee,methods:Me,types:pt,variables:wt,imports:re,enums:xe},Ue),St.setUserDefind(Ee,pt,wt,Me,xe);const Re=te.map(je=>({...je,severity:je.type||Ie.MarkerSeverity.Error}));if(_)return;try{if(!te.length&&Y){const je=await qo(Y,{isPreParser:!0});io.isEqual(je,Co)||(Co=je,T&&T(je))}}catch(je){console.log(je),te.push({message:je.message,startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0})}($e=N.current)==null||$e.setModelMarkers(Re);const Nt=Date.now();console.log((Nt-U)/1e3)},[T,_]),B=R.useMemo(()=>io.debounce(G,1500),[G]);function k(S){var U;if(_){G(S||"");return}Gs.clearInlayHints(),(U=N.current)==null||U.setModelMarkers([]),S!==void 0&&(b&&b(S),B(S))}const P=R.useCallback(()=>{var U,te;const S=(U=H.current)==null?void 0:U.getBoundingClientRect();(te=N.current)==null||te.setEditorLayout((S==null?void 0:S.height)||0,S==null?void 0:S.width)},[]);return R.useEffect(()=>{const S=()=>{window.requestAnimationFrame(P)},U=new ResizeObserver(S);return H.current&&U.observe(H.current),()=>{H.current&&U.unobserve(H.current),U.disconnect()}},[]),L.jsx("div",{ref:H,children:L.jsx(gd,{height:s,width:o||"100%",defaultLanguage:Se,defaultValue:f||`indicator("我的脚本")
145
145
  plot(close)
146
146
  `,theme:c||"vs-dark",className:`tvue-script ${c||"vs-dark"}`,options:{colorDecorators:!0,useShadowDOM:!1,matchOnWordStartOnly:!0,automaticLayout:!1,suggest:{filterGraceful:!0},fontSize:13,..._?Pd:{},readOnlyMessage:{value:"该脚本是只读的。它无法被编辑。"},...l},onMount:V,onChange:k})})},bm=R.forwardRef(gm),xm=a=>{const{theme:n,modified:s,original:o,height:c,width:l,renderSideBySide:m=!0}=a,_=R.useCallback((f,b)=>{b.languages.register({id:Se}),b.editor.defineTheme("vs-dark",cn),b.editor.defineTheme("vs",ln),b.languages.setMonarchTokensProvider(Se,Nr),b.languages.setLanguageConfiguration(Se,on)},[]);return L.jsx(md,{height:c||"90vh",width:l||"100%",theme:n||"vs-dark",options:{readOnly:!0,renderSideBySide:m,scrollBeyondLastLine:!1},language:Se,modified:s,original:o,onMount:_})};A.VMarkerSeverity=void 0,function(a){a[a.Hint=1]="Hint",a[a.Info=2]="Info",a[a.Warning=4]="Warning",a[a.Error=8]="Error"}(A.VMarkerSeverity||(A.VMarkerSeverity={}));var ta={},hm=function(){var a=document.getSelection();if(!a.rangeCount)return function(){};for(var n=document.activeElement,s=[],o=0;o<a.rangeCount;o++)s.push(a.getRangeAt(o));switch(n.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":n.blur();break;default:n=null;break}return a.removeAllRanges(),function(){a.type==="Caret"&&a.removeAllRanges(),a.rangeCount||s.forEach(function(c){a.addRange(c)}),n&&n.focus()}},wm=hm,zo={"text/plain":"Text","text/html":"Url",default:"Text"},vm="Copy to clipboard: #{key}, Enter";function Tm(a){var n=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return a.replace(/#{\s*key\s*}/g,n)}function Dm(a,n){var s,o,c,l,m,_,f=!1;n||(n={}),s=n.debug||!1;try{c=wm(),l=document.createRange(),m=document.getSelection(),_=document.createElement("span"),_.textContent=a,_.ariaHidden="true",_.style.all="unset",_.style.position="fixed",_.style.top=0,_.style.clip="rect(0, 0, 0, 0)",_.style.whiteSpace="pre",_.style.webkitUserSelect="text",_.style.MozUserSelect="text",_.style.msUserSelect="text",_.style.userSelect="text",_.addEventListener("copy",function(h){if(h.stopPropagation(),n.format)if(h.preventDefault(),typeof h.clipboardData>"u"){s&&console.warn("unable to use e.clipboardData"),s&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var T=zo[n.format]||zo.default;window.clipboardData.setData(T,a)}else h.clipboardData.clearData(),h.clipboardData.setData(n.format,a);n.onCopy&&(h.preventDefault(),n.onCopy(h.clipboardData))}),document.body.appendChild(_),l.selectNodeContents(_),m.addRange(l);var b=document.execCommand("copy");if(!b)throw new Error("copy command was unsuccessful");f=!0}catch(h){s&&console.error("unable to copy using execCommand: ",h),s&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(n.format||"text",a),n.onCopy&&n.onCopy(window.clipboardData),f=!0}catch(T){s&&console.error("unable to copy using clipboardData: ",T),s&&console.error("falling back to prompt"),o=Tm("message"in n?n.message:vm),window.prompt(o,a)}}finally{m&&(typeof m.removeRange=="function"?m.removeRange(l):m.removeAllRanges()),_&&document.body.removeChild(_),c()}return f}var km=Dm;function bn(a){"@babel/helpers - typeof";return bn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},bn(a)}Object.defineProperty(ta,"__esModule",{value:!0}),ta.CopyToClipboard=void 0;var ra=So(R),Im=So(km),Am=["text","onCopy","options","children"];function So(a){return a&&a.__esModule?a:{default:a}}function Eo(a,n){var s=Object.keys(a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(a);n&&(o=o.filter(function(c){return Object.getOwnPropertyDescriptor(a,c).enumerable})),s.push.apply(s,o)}return s}function No(a){for(var n=1;n<arguments.length;n++){var s=arguments[n]!=null?arguments[n]:{};n%2?Eo(Object(s),!0).forEach(function(o){hn(a,o,s[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(s)):Eo(Object(s)).forEach(function(o){Object.defineProperty(a,o,Object.getOwnPropertyDescriptor(s,o))})}return a}function qm(a,n){if(a==null)return{};var s=Cm(a,n),o,c;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(a);for(c=0;c<l.length;c++)o=l[c],!(n.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(a,o)&&(s[o]=a[o])}return s}function Cm(a,n){if(a==null)return{};var s={},o=Object.keys(a),c,l;for(l=0;l<o.length;l++)c=o[l],!(n.indexOf(c)>=0)&&(s[c]=a[c]);return s}function zm(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function Lo(a,n){for(var s=0;s<n.length;s++){var o=n[s];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(a,o.key,o)}}function Sm(a,n,s){return n&&Lo(a.prototype,n),s&&Lo(a,s),Object.defineProperty(a,"prototype",{writable:!1}),a}function Em(a,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(n&&n.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),n&&xn(a,n)}function xn(a,n){return xn=Object.setPrototypeOf||function(o,c){return o.__proto__=c,o},xn(a,n)}function Nm(a){var n=Mm();return function(){var o=sa(a),c;if(n){var l=sa(this).constructor;c=Reflect.construct(o,arguments,l)}else c=o.apply(this,arguments);return Lm(this,c)}}function Lm(a,n){if(n&&(bn(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Mo(a)}function Mo(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function Mm(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function sa(a){return sa=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},sa(a)}function hn(a,n,s){return n in a?Object.defineProperty(a,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[n]=s,a}var Po=function(a){Em(s,a);var n=Nm(s);function s(){var o;zm(this,s);for(var c=arguments.length,l=new Array(c),m=0;m<c;m++)l[m]=arguments[m];return o=n.call.apply(n,[this].concat(l)),hn(Mo(o),"onClick",function(_){var f=o.props,b=f.text,h=f.onCopy,T=f.children,O=f.options,K=ra.default.Children.only(T),F=(0,Im.default)(b,O);h&&h(b,F),K&&K.props&&typeof K.props.onClick=="function"&&K.props.onClick(_)}),o}return Sm(s,[{key:"render",value:function(){var c=this.props;c.text,c.onCopy,c.options;var l=c.children,m=qm(c,Am),_=ra.default.Children.only(l);return ra.default.cloneElement(_,No(No({},m),{},{onClick:this.onClick}))}}]),s}(ra.default.PureComponent);ta.CopyToClipboard=Po,hn(Po,"defaultProps",{onCopy:void 0,options:void 0});var Pm=ta,wn=Pm.CopyToClipboard;wn.CopyToClipboard=wn;var Om=wn;const vn=cp(Om);async function Rm(a,n=0){const s=a[n];if(!s)return;const{name:o,args:c,type:l,desc:m,examples:_,remarks:f,seeAlso:b,syntax:h,detailedDesc:T,fields:O,returns:K}=s,F={name:o};if(a.length>1&&(F.overloads=`${a.length} overloads`),l&&(F.type=l),c&&(F.name=`${o}()`,F.args=c.map(N=>{const{name:H,desc:V,displayType:G}=N;return{label:`${H} (${G})`,desc:V&&xr(V)}})),m&&(F.desc=m.map(N=>xr(N))),_&&(F.originalExample=_.join(`
147
147
  `),F.examples=await Ie.editor.colorize(F.originalExample,Se,{tabSize:4})),T){F.detailedDesc=[];for(const N of T){const{desc:H,examples:V}=N;let G=H.map(P=>xr(P)),B,k;V&&(k=V.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guihz/trading-vue-editor-tes",
3
- "version": "0.0.144",
3
+ "version": "0.0.145",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib"