@guihz/trading-vue-editor-tes 0.0.203 → 0.0.205

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,69 +0,0 @@
1
- var U2=Object.defineProperty;var W2=(Yt,Gt,Ne)=>Gt in Yt?U2(Yt,Gt,{enumerable:!0,configurable:!0,writable:!0,value:Ne}):Yt[Gt]=Ne;var $=(Yt,Gt,Ne)=>(W2(Yt,typeof Gt!="symbol"?Gt+"":Gt,Ne),Ne),El=(Yt,Gt,Ne)=>{if(!Gt.has(Yt))throw TypeError("Cannot "+Ne)};var Jr=(Yt,Gt,Ne)=>(El(Yt,Gt,"read from private field"),Ne?Ne.call(Yt):Gt.get(Yt)),Al=(Yt,Gt,Ne)=>{if(Gt.has(Yt))throw TypeError("Cannot add the same private member more than once");Gt instanceof WeakSet?Gt.add(Yt):Gt.set(Yt,Ne)},ua=(Yt,Gt,Ne,Vn)=>(El(Yt,Gt,"write to private field"),Vn?Vn.call(Yt,Ne):Gt.set(Yt,Ne),Ne);var Cl=(Yt,Gt,Ne)=>(El(Yt,Gt,"access private method"),Ne);(function(){"use strict";var es,Fl,Ni,Xe;var Yt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Gt(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ne(s){if(s.__esModule)return s;var t=s.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(s).forEach(function(r){var n=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return s[r]}})}),e}var Vn={exports:{}};/**
2
- * @license
3
- * Lodash <https://lodash.com/>
4
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
5
- * Released under MIT license <https://lodash.com/license>
6
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8
- */Vn.exports,function(s,t){(function(){var e,r="4.17.21",n=200,i="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",h=500,p="__lodash_placeholder__",f=1,d=2,g=4,y=1,m=2,w=1,v=2,x=4,b=8,N=16,E=32,A=64,M=128,S=256,T=512,F=30,O="...",R=800,U=16,q=1,W=2,z=3,K=1/0,Z=9007199254740991,X=17976931348623157e292,Q=NaN,ct=4294967295,vt=ct-1,lt=ct>>>1,wt=[["ary",M],["bind",w],["bindKey",v],["curry",b],["curryRight",N],["flip",T],["partial",E],["partialRight",A],["rearg",S]],bt="[object Arguments]",Bt="[object Array]",xt="[object AsyncFunction]",oe="[object Boolean]",It="[object Date]",Nt="[object DOMException]",ce="[object Error]",re="[object Function]",qt="[object GeneratorFunction]",Jt="[object Map]",$e="[object Number]",vr="[object Null]",ze="[object Object]",pn="[object Promise]",On="[object Proxy]",dn="[object RegExp]",yr="[object Set]",In="[object String]",L="[object Symbol]",Y="[object Undefined]",G="[object WeakMap]",nt="[object WeakSet]",st="[object ArrayBuffer]",rt="[object DataView]",ft="[object Float32Array]",ut="[object Float64Array]",ht="[object Int8Array]",at="[object Int16Array]",Xt="[object Int32Array]",ne="[object Uint8Array]",be="[object Uint8ClampedArray]",We="[object Uint16Array]",ke="[object Uint32Array]",wr=/\b__p \+= '';/g,Dr=/\b(__p \+=) '' \+/g,Tn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ti=/&(?:amp|lt|gt|quot|#39);/g,vo=/[&<>"']/g,Va=RegExp(ti.source),Ya=RegExp(vo.source),Za=/<%-([\s\S]+?)%>/g,Ka=/<%([\s\S]+?)%>/g,yo=/<%=([\s\S]+?)%>/g,Ga=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ha=/^\w*$/,Ja=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rs=/[\\^$.*+?()[\]{}|]/g,Xa=RegExp(rs.source),ns=/^\s+/,Qa=/\s/,tu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,eu=/\{\n\/\* \[wrapped with (.+)\] \*/,ru=/,? & /,nu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,iu=/[()=,{}\[\]\/\s]/,su=/\\(\\)?/g,ou=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,wo=/\w*$/,au=/^[-+]0x[0-9a-f]+$/i,uu=/^0b[01]+$/i,lu=/^\[object .+?Constructor\]$/,cu=/^0o[0-7]+$/i,fu=/^(?:0|[1-9]\d*)$/,hu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Si=/($^)/,ei=/['\n\r\u2028\u2029\\]/g,Zt="\\ud800-\\udfff",Qe="\\u0300-\\u036f",pu="\\ufe20-\\ufe2f",Bi="\\u20d0-\\u20ff",$n=Qe+pu+Bi,Do="\\u2700-\\u27bf",_h="a-z\\xdf-\\xf6\\xf8-\\xff",Pw="\\xac\\xb1\\xd7\\xf7",zw="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",kw="\\u2000-\\u206f",qw=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",mh="A-Z\\xc0-\\xd6\\xd8-\\xde",gh="\\ufe0e\\ufe0f",vh=Pw+zw+kw+qw,du="['’]",Uw="["+Zt+"]",yh="["+vh+"]",bo="["+$n+"]",wh="\\d+",Ww="["+Do+"]",Dh="["+_h+"]",bh="[^"+Zt+vh+wh+Do+_h+mh+"]",_u="\\ud83c[\\udffb-\\udfff]",jw="(?:"+bo+"|"+_u+")",xh="[^"+Zt+"]",mu="(?:\\ud83c[\\udde6-\\uddff]){2}",gu="[\\ud800-\\udbff][\\udc00-\\udfff]",Oi="["+mh+"]",Eh="\\u200d",Ah="(?:"+Dh+"|"+bh+")",Vw="(?:"+Oi+"|"+bh+")",Ch="(?:"+du+"(?:d|ll|m|re|s|t|ve))?",Fh="(?:"+du+"(?:D|LL|M|RE|S|T|VE))?",Mh=jw+"?",Nh="["+gh+"]?",Yw="(?:"+Eh+"(?:"+[xh,mu,gu].join("|")+")"+Nh+Mh+")*",Zw="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Kw="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Sh=Nh+Mh+Yw,Gw="(?:"+[Ww,mu,gu].join("|")+")"+Sh,Hw="(?:"+[xh+bo+"?",bo,mu,gu,Uw].join("|")+")",Jw=RegExp(du,"g"),Xw=RegExp(bo,"g"),vu=RegExp(_u+"(?="+_u+")|"+Hw+Sh,"g"),Qw=RegExp([Oi+"?"+Dh+"+"+Ch+"(?="+[yh,Oi,"$"].join("|")+")",Vw+"+"+Fh+"(?="+[yh,Oi+Ah,"$"].join("|")+")",Oi+"?"+Ah+"+"+Ch,Oi+"+"+Fh,Kw,Zw,wh,Gw].join("|"),"g"),tD=RegExp("["+Eh+Zt+$n+gh+"]"),eD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,rD=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],nD=-1,ye={};ye[ft]=ye[ut]=ye[ht]=ye[at]=ye[Xt]=ye[ne]=ye[be]=ye[We]=ye[ke]=!0,ye[bt]=ye[Bt]=ye[st]=ye[oe]=ye[rt]=ye[It]=ye[ce]=ye[re]=ye[Jt]=ye[$e]=ye[ze]=ye[dn]=ye[yr]=ye[In]=ye[G]=!1;var _e={};_e[bt]=_e[Bt]=_e[st]=_e[rt]=_e[oe]=_e[It]=_e[ft]=_e[ut]=_e[ht]=_e[at]=_e[Xt]=_e[Jt]=_e[$e]=_e[ze]=_e[dn]=_e[yr]=_e[In]=_e[L]=_e[ne]=_e[be]=_e[We]=_e[ke]=!0,_e[ce]=_e[re]=_e[G]=!1;var iD={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},sD={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},oD={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},aD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},uD=parseFloat,lD=parseInt,Bh=typeof Yt=="object"&&Yt&&Yt.Object===Object&&Yt,cD=typeof self=="object"&&self&&self.Object===Object&&self,Ge=Bh||cD||Function("return this")(),yu=t&&!t.nodeType&&t,ri=yu&&!0&&s&&!s.nodeType&&s,Oh=ri&&ri.exports===yu,wu=Oh&&Bh.process,Or=function(){try{var j=ri&&ri.require&&ri.require("util").types;return j||wu&&wu.binding&&wu.binding("util")}catch{}}(),Ih=Or&&Or.isArrayBuffer,Th=Or&&Or.isDate,$h=Or&&Or.isMap,Lh=Or&&Or.isRegExp,Rh=Or&&Or.isSet,Ph=Or&&Or.isTypedArray;function br(j,J,H){switch(H.length){case 0:return j.call(J);case 1:return j.call(J,H[0]);case 2:return j.call(J,H[0],H[1]);case 3:return j.call(J,H[0],H[1],H[2])}return j.apply(J,H)}function fD(j,J,H,gt){for(var Ot=-1,te=j==null?0:j.length;++Ot<te;){var qe=j[Ot];J(gt,qe,H(qe),j)}return gt}function Ir(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt&&J(j[H],H,j)!==!1;);return j}function hD(j,J){for(var H=j==null?0:j.length;H--&&J(j[H],H,j)!==!1;);return j}function zh(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(!J(j[H],H,j))return!1;return!0}function Ln(j,J){for(var H=-1,gt=j==null?0:j.length,Ot=0,te=[];++H<gt;){var qe=j[H];J(qe,H,j)&&(te[Ot++]=qe)}return te}function xo(j,J){var H=j==null?0:j.length;return!!H&&Ii(j,J,0)>-1}function Du(j,J,H){for(var gt=-1,Ot=j==null?0:j.length;++gt<Ot;)if(H(J,j[gt]))return!0;return!1}function xe(j,J){for(var H=-1,gt=j==null?0:j.length,Ot=Array(gt);++H<gt;)Ot[H]=J(j[H],H,j);return Ot}function Rn(j,J){for(var H=-1,gt=J.length,Ot=j.length;++H<gt;)j[Ot+H]=J[H];return j}function bu(j,J,H,gt){var Ot=-1,te=j==null?0:j.length;for(gt&&te&&(H=j[++Ot]);++Ot<te;)H=J(H,j[Ot],Ot,j);return H}function pD(j,J,H,gt){var Ot=j==null?0:j.length;for(gt&&Ot&&(H=j[--Ot]);Ot--;)H=J(H,j[Ot],Ot,j);return H}function xu(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(J(j[H],H,j))return!0;return!1}var dD=Eu("length");function _D(j){return j.split("")}function mD(j){return j.match(nu)||[]}function kh(j,J,H){var gt;return H(j,function(Ot,te,qe){if(J(Ot,te,qe))return gt=te,!1}),gt}function Eo(j,J,H,gt){for(var Ot=j.length,te=H+(gt?1:-1);gt?te--:++te<Ot;)if(J(j[te],te,j))return te;return-1}function Ii(j,J,H){return J===J?MD(j,J,H):Eo(j,qh,H)}function gD(j,J,H,gt){for(var Ot=H-1,te=j.length;++Ot<te;)if(gt(j[Ot],J))return Ot;return-1}function qh(j){return j!==j}function Uh(j,J){var H=j==null?0:j.length;return H?Cu(j,J)/H:Q}function Eu(j){return function(J){return J==null?e:J[j]}}function Au(j){return function(J){return j==null?e:j[J]}}function Wh(j,J,H,gt,Ot){return Ot(j,function(te,qe,pe){H=gt?(gt=!1,te):J(H,te,qe,pe)}),H}function vD(j,J){var H=j.length;for(j.sort(J);H--;)j[H]=j[H].value;return j}function Cu(j,J){for(var H,gt=-1,Ot=j.length;++gt<Ot;){var te=J(j[gt]);te!==e&&(H=H===e?te:H+te)}return H}function Fu(j,J){for(var H=-1,gt=Array(j);++H<j;)gt[H]=J(H);return gt}function yD(j,J){return xe(J,function(H){return[H,j[H]]})}function jh(j){return j&&j.slice(0,Kh(j)+1).replace(ns,"")}function xr(j){return function(J){return j(J)}}function Mu(j,J){return xe(J,function(H){return j[H]})}function is(j,J){return j.has(J)}function Vh(j,J){for(var H=-1,gt=j.length;++H<gt&&Ii(J,j[H],0)>-1;);return H}function Yh(j,J){for(var H=j.length;H--&&Ii(J,j[H],0)>-1;);return H}function wD(j,J){for(var H=j.length,gt=0;H--;)j[H]===J&&++gt;return gt}var DD=Au(iD),bD=Au(sD);function xD(j){return"\\"+aD[j]}function ED(j,J){return j==null?e:j[J]}function Ti(j){return tD.test(j)}function AD(j){return eD.test(j)}function CD(j){for(var J,H=[];!(J=j.next()).done;)H.push(J.value);return H}function Nu(j){var J=-1,H=Array(j.size);return j.forEach(function(gt,Ot){H[++J]=[Ot,gt]}),H}function Zh(j,J){return function(H){return j(J(H))}}function Pn(j,J){for(var H=-1,gt=j.length,Ot=0,te=[];++H<gt;){var qe=j[H];(qe===J||qe===p)&&(j[H]=p,te[Ot++]=H)}return te}function Ao(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=gt}),H}function FD(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=[gt,gt]}),H}function MD(j,J,H){for(var gt=H-1,Ot=j.length;++gt<Ot;)if(j[gt]===J)return gt;return-1}function ND(j,J,H){for(var gt=H+1;gt--;)if(j[gt]===J)return gt;return gt}function $i(j){return Ti(j)?BD(j):dD(j)}function Zr(j){return Ti(j)?OD(j):_D(j)}function Kh(j){for(var J=j.length;J--&&Qa.test(j.charAt(J)););return J}var SD=Au(oD);function BD(j){for(var J=vu.lastIndex=0;vu.test(j);)++J;return J}function OD(j){return j.match(vu)||[]}function ID(j){return j.match(Qw)||[]}var TD=function j(J){J=J==null?Ge:Li.defaults(Ge.Object(),J,Li.pick(Ge,rD));var H=J.Array,gt=J.Date,Ot=J.Error,te=J.Function,qe=J.Math,pe=J.Object,Su=J.RegExp,$D=J.String,Tr=J.TypeError,Co=H.prototype,LD=te.prototype,Ri=pe.prototype,Fo=J["__core-js_shared__"],Mo=LD.toString,ae=Ri.hasOwnProperty,RD=0,Gh=function(){var o=/[^.]+$/.exec(Fo&&Fo.keys&&Fo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),No=Ri.toString,PD=Mo.call(pe),zD=Ge._,kD=Su("^"+Mo.call(ae).replace(rs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),So=Oh?J.Buffer:e,zn=J.Symbol,Bo=J.Uint8Array,Hh=So?So.allocUnsafe:e,Oo=Zh(pe.getPrototypeOf,pe),Jh=pe.create,Xh=Ri.propertyIsEnumerable,Io=Co.splice,Qh=zn?zn.isConcatSpreadable:e,ss=zn?zn.iterator:e,ni=zn?zn.toStringTag:e,To=function(){try{var o=ui(pe,"defineProperty");return o({},"",{}),o}catch{}}(),qD=J.clearTimeout!==Ge.clearTimeout&&J.clearTimeout,UD=gt&&gt.now!==Ge.Date.now&&gt.now,WD=J.setTimeout!==Ge.setTimeout&&J.setTimeout,$o=qe.ceil,Lo=qe.floor,Bu=pe.getOwnPropertySymbols,jD=So?So.isBuffer:e,t0=J.isFinite,VD=Co.join,YD=Zh(pe.keys,pe),Ue=qe.max,tr=qe.min,ZD=gt.now,KD=J.parseInt,e0=qe.random,GD=Co.reverse,Ou=ui(J,"DataView"),os=ui(J,"Map"),Iu=ui(J,"Promise"),Pi=ui(J,"Set"),as=ui(J,"WeakMap"),us=ui(pe,"create"),Ro=as&&new as,zi={},HD=li(Ou),JD=li(os),XD=li(Iu),QD=li(Pi),tb=li(as),Po=zn?zn.prototype:e,ls=Po?Po.valueOf:e,r0=Po?Po.toString:e;function B(o){if(Me(o)&&!Tt(o)&&!(o instanceof jt)){if(o instanceof $r)return o;if(ae.call(o,"__wrapped__"))return np(o)}return new $r(o)}var ki=function(){function o(){}return function(u){if(!Ce(u))return{};if(Jh)return Jh(u);o.prototype=u;var _=new o;return o.prototype=e,_}}();function zo(){}function $r(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}B.templateSettings={escape:Za,evaluate:Ka,interpolate:yo,variable:"",imports:{_:B}},B.prototype=zo.prototype,B.prototype.constructor=B,$r.prototype=ki(zo.prototype),$r.prototype.constructor=$r;function jt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ct,this.__views__=[]}function eb(){var o=new jt(this.__wrapped__);return o.__actions__=fr(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=fr(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=fr(this.__views__),o}function rb(){if(this.__filtered__){var o=new jt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function nb(){var o=this.__wrapped__.value(),u=this.__dir__,_=Tt(o),D=u<0,C=_?o.length:0,I=_x(0,C,this.__views__),P=I.start,k=I.end,V=k-P,tt=D?k:P-1,et=this.__iteratees__,ot=et.length,dt=0,yt=tr(V,this.__takeCount__);if(!_||!D&&C==V&&yt==V)return C0(o,this.__actions__);var Ct=[];t:for(;V--&&dt<yt;){tt+=u;for(var Rt=-1,Ft=o[tt];++Rt<ot;){var Ut=et[Rt],Vt=Ut.iteratee,Cr=Ut.type,ar=Vt(Ft);if(Cr==W)Ft=ar;else if(!ar){if(Cr==q)continue t;break t}}Ct[dt++]=Ft}return Ct}jt.prototype=ki(zo.prototype),jt.prototype.constructor=jt;function ii(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function ib(){this.__data__=us?us(null):{},this.size=0}function sb(o){var u=this.has(o)&&delete this.__data__[o];return this.size-=u?1:0,u}function ob(o){var u=this.__data__;if(us){var _=u[o];return _===c?e:_}return ae.call(u,o)?u[o]:e}function ab(o){var u=this.__data__;return us?u[o]!==e:ae.call(u,o)}function ub(o,u){var _=this.__data__;return this.size+=this.has(o)?0:1,_[o]=us&&u===e?c:u,this}ii.prototype.clear=ib,ii.prototype.delete=sb,ii.prototype.get=ob,ii.prototype.has=ab,ii.prototype.set=ub;function _n(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function lb(){this.__data__=[],this.size=0}function cb(o){var u=this.__data__,_=ko(u,o);if(_<0)return!1;var D=u.length-1;return _==D?u.pop():Io.call(u,_,1),--this.size,!0}function fb(o){var u=this.__data__,_=ko(u,o);return _<0?e:u[_][1]}function hb(o){return ko(this.__data__,o)>-1}function pb(o,u){var _=this.__data__,D=ko(_,o);return D<0?(++this.size,_.push([o,u])):_[D][1]=u,this}_n.prototype.clear=lb,_n.prototype.delete=cb,_n.prototype.get=fb,_n.prototype.has=hb,_n.prototype.set=pb;function mn(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function db(){this.size=0,this.__data__={hash:new ii,map:new(os||_n),string:new ii}}function _b(o){var u=Xo(this,o).delete(o);return this.size-=u?1:0,u}function mb(o){return Xo(this,o).get(o)}function gb(o){return Xo(this,o).has(o)}function vb(o,u){var _=Xo(this,o),D=_.size;return _.set(o,u),this.size+=_.size==D?0:1,this}mn.prototype.clear=db,mn.prototype.delete=_b,mn.prototype.get=mb,mn.prototype.has=gb,mn.prototype.set=vb;function si(o){var u=-1,_=o==null?0:o.length;for(this.__data__=new mn;++u<_;)this.add(o[u])}function yb(o){return this.__data__.set(o,c),this}function wb(o){return this.__data__.has(o)}si.prototype.add=si.prototype.push=yb,si.prototype.has=wb;function Kr(o){var u=this.__data__=new _n(o);this.size=u.size}function Db(){this.__data__=new _n,this.size=0}function bb(o){var u=this.__data__,_=u.delete(o);return this.size=u.size,_}function xb(o){return this.__data__.get(o)}function Eb(o){return this.__data__.has(o)}function Ab(o,u){var _=this.__data__;if(_ instanceof _n){var D=_.__data__;if(!os||D.length<n-1)return D.push([o,u]),this.size=++_.size,this;_=this.__data__=new mn(D)}return _.set(o,u),this.size=_.size,this}Kr.prototype.clear=Db,Kr.prototype.delete=bb,Kr.prototype.get=xb,Kr.prototype.has=Eb,Kr.prototype.set=Ab;function n0(o,u){var _=Tt(o),D=!_&&ci(o),C=!_&&!D&&jn(o),I=!_&&!D&&!C&&ji(o),P=_||D||C||I,k=P?Fu(o.length,$D):[],V=k.length;for(var tt in o)(u||ae.call(o,tt))&&!(P&&(tt=="length"||C&&(tt=="offset"||tt=="parent")||I&&(tt=="buffer"||tt=="byteLength"||tt=="byteOffset")||wn(tt,V)))&&k.push(tt);return k}function i0(o){var u=o.length;return u?o[ju(0,u-1)]:e}function Cb(o,u){return Qo(fr(o),oi(u,0,o.length))}function Fb(o){return Qo(fr(o))}function Tu(o,u,_){(_!==e&&!Gr(o[u],_)||_===e&&!(u in o))&&gn(o,u,_)}function cs(o,u,_){var D=o[u];(!(ae.call(o,u)&&Gr(D,_))||_===e&&!(u in o))&&gn(o,u,_)}function ko(o,u){for(var _=o.length;_--;)if(Gr(o[_][0],u))return _;return-1}function Mb(o,u,_,D){return kn(o,function(C,I,P){u(D,C,_(C),P)}),D}function s0(o,u){return o&&sn(u,je(u),o)}function Nb(o,u){return o&&sn(u,pr(u),o)}function gn(o,u,_){u=="__proto__"&&To?To(o,u,{configurable:!0,enumerable:!0,value:_,writable:!0}):o[u]=_}function $u(o,u){for(var _=-1,D=u.length,C=H(D),I=o==null;++_<D;)C[_]=I?e:_l(o,u[_]);return C}function oi(o,u,_){return o===o&&(_!==e&&(o=o<=_?o:_),u!==e&&(o=o>=u?o:u)),o}function Lr(o,u,_,D,C,I){var P,k=u&f,V=u&d,tt=u&g;if(_&&(P=C?_(o,D,C,I):_(o)),P!==e)return P;if(!Ce(o))return o;var et=Tt(o);if(et){if(P=gx(o),!k)return fr(o,P)}else{var ot=er(o),dt=ot==re||ot==qt;if(jn(o))return N0(o,k);if(ot==ze||ot==bt||dt&&!C){if(P=V||dt?{}:K0(o),!k)return V?ox(o,Nb(P,o)):sx(o,s0(P,o))}else{if(!_e[ot])return C?o:{};P=vx(o,ot,k)}}I||(I=new Kr);var yt=I.get(o);if(yt)return yt;I.set(o,P),xp(o)?o.forEach(function(Ft){P.add(Lr(Ft,u,_,Ft,o,I))}):Dp(o)&&o.forEach(function(Ft,Ut){P.set(Ut,Lr(Ft,u,_,Ut,o,I))});var Ct=tt?V?el:tl:V?pr:je,Rt=et?e:Ct(o);return Ir(Rt||o,function(Ft,Ut){Rt&&(Ut=Ft,Ft=o[Ut]),cs(P,Ut,Lr(Ft,u,_,Ut,o,I))}),P}function Sb(o){var u=je(o);return function(_){return o0(_,o,u)}}function o0(o,u,_){var D=_.length;if(o==null)return!D;for(o=pe(o);D--;){var C=_[D],I=u[C],P=o[C];if(P===e&&!(C in o)||!I(P))return!1}return!0}function a0(o,u,_){if(typeof o!="function")throw new Tr(a);return gs(function(){o.apply(e,_)},u)}function fs(o,u,_,D){var C=-1,I=xo,P=!0,k=o.length,V=[],tt=u.length;if(!k)return V;_&&(u=xe(u,xr(_))),D?(I=Du,P=!1):u.length>=n&&(I=is,P=!1,u=new si(u));t:for(;++C<k;){var et=o[C],ot=_==null?et:_(et);if(et=D||et!==0?et:0,P&&ot===ot){for(var dt=tt;dt--;)if(u[dt]===ot)continue t;V.push(et)}else I(u,ot,D)||V.push(et)}return V}var kn=T0(nn),u0=T0(Ru,!0);function Bb(o,u){var _=!0;return kn(o,function(D,C,I){return _=!!u(D,C,I),_}),_}function qo(o,u,_){for(var D=-1,C=o.length;++D<C;){var I=o[D],P=u(I);if(P!=null&&(k===e?P===P&&!Ar(P):_(P,k)))var k=P,V=I}return V}function Ob(o,u,_,D){var C=o.length;for(_=Lt(_),_<0&&(_=-_>C?0:C+_),D=D===e||D>C?C:Lt(D),D<0&&(D+=C),D=_>D?0:Ap(D);_<D;)o[_++]=u;return o}function l0(o,u){var _=[];return kn(o,function(D,C,I){u(D,C,I)&&_.push(D)}),_}function He(o,u,_,D,C){var I=-1,P=o.length;for(_||(_=wx),C||(C=[]);++I<P;){var k=o[I];u>0&&_(k)?u>1?He(k,u-1,_,D,C):Rn(C,k):D||(C[C.length]=k)}return C}var Lu=$0(),c0=$0(!0);function nn(o,u){return o&&Lu(o,u,je)}function Ru(o,u){return o&&c0(o,u,je)}function Uo(o,u){return Ln(u,function(_){return Dn(o[_])})}function ai(o,u){u=Un(u,o);for(var _=0,D=u.length;o!=null&&_<D;)o=o[on(u[_++])];return _&&_==D?o:e}function f0(o,u,_){var D=u(o);return Tt(o)?D:Rn(D,_(o))}function sr(o){return o==null?o===e?Y:vr:ni&&ni in pe(o)?dx(o):Fx(o)}function Pu(o,u){return o>u}function Ib(o,u){return o!=null&&ae.call(o,u)}function Tb(o,u){return o!=null&&u in pe(o)}function $b(o,u,_){return o>=tr(u,_)&&o<Ue(u,_)}function zu(o,u,_){for(var D=_?Du:xo,C=o[0].length,I=o.length,P=I,k=H(I),V=1/0,tt=[];P--;){var et=o[P];P&&u&&(et=xe(et,xr(u))),V=tr(et.length,V),k[P]=!_&&(u||C>=120&&et.length>=120)?new si(P&&et):e}et=o[0];var ot=-1,dt=k[0];t:for(;++ot<C&&tt.length<V;){var yt=et[ot],Ct=u?u(yt):yt;if(yt=_||yt!==0?yt:0,!(dt?is(dt,Ct):D(tt,Ct,_))){for(P=I;--P;){var Rt=k[P];if(!(Rt?is(Rt,Ct):D(o[P],Ct,_)))continue t}dt&&dt.push(Ct),tt.push(yt)}}return tt}function Lb(o,u,_,D){return nn(o,function(C,I,P){u(D,_(C),I,P)}),D}function hs(o,u,_){u=Un(u,o),o=X0(o,u);var D=o==null?o:o[on(Pr(u))];return D==null?e:br(D,o,_)}function h0(o){return Me(o)&&sr(o)==bt}function Rb(o){return Me(o)&&sr(o)==st}function Pb(o){return Me(o)&&sr(o)==It}function ps(o,u,_,D,C){return o===u?!0:o==null||u==null||!Me(o)&&!Me(u)?o!==o&&u!==u:zb(o,u,_,D,ps,C)}function zb(o,u,_,D,C,I){var P=Tt(o),k=Tt(u),V=P?Bt:er(o),tt=k?Bt:er(u);V=V==bt?ze:V,tt=tt==bt?ze:tt;var et=V==ze,ot=tt==ze,dt=V==tt;if(dt&&jn(o)){if(!jn(u))return!1;P=!0,et=!1}if(dt&&!et)return I||(I=new Kr),P||ji(o)?V0(o,u,_,D,C,I):hx(o,u,V,_,D,C,I);if(!(_&y)){var yt=et&&ae.call(o,"__wrapped__"),Ct=ot&&ae.call(u,"__wrapped__");if(yt||Ct){var Rt=yt?o.value():o,Ft=Ct?u.value():u;return I||(I=new Kr),C(Rt,Ft,_,D,I)}}return dt?(I||(I=new Kr),px(o,u,_,D,C,I)):!1}function kb(o){return Me(o)&&er(o)==Jt}function ku(o,u,_,D){var C=_.length,I=C,P=!D;if(o==null)return!I;for(o=pe(o);C--;){var k=_[C];if(P&&k[2]?k[1]!==o[k[0]]:!(k[0]in o))return!1}for(;++C<I;){k=_[C];var V=k[0],tt=o[V],et=k[1];if(P&&k[2]){if(tt===e&&!(V in o))return!1}else{var ot=new Kr;if(D)var dt=D(tt,et,V,o,u,ot);if(!(dt===e?ps(et,tt,y|m,D,ot):dt))return!1}}return!0}function p0(o){if(!Ce(o)||bx(o))return!1;var u=Dn(o)?kD:lu;return u.test(li(o))}function qb(o){return Me(o)&&sr(o)==dn}function Ub(o){return Me(o)&&er(o)==yr}function Wb(o){return Me(o)&&sa(o.length)&&!!ye[sr(o)]}function d0(o){return typeof o=="function"?o:o==null?dr:typeof o=="object"?Tt(o)?g0(o[0],o[1]):m0(o):Lp(o)}function qu(o){if(!ms(o))return YD(o);var u=[];for(var _ in pe(o))ae.call(o,_)&&_!="constructor"&&u.push(_);return u}function jb(o){if(!Ce(o))return Cx(o);var u=ms(o),_=[];for(var D in o)D=="constructor"&&(u||!ae.call(o,D))||_.push(D);return _}function Uu(o,u){return o<u}function _0(o,u){var _=-1,D=hr(o)?H(o.length):[];return kn(o,function(C,I,P){D[++_]=u(C,I,P)}),D}function m0(o){var u=nl(o);return u.length==1&&u[0][2]?H0(u[0][0],u[0][1]):function(_){return _===o||ku(_,o,u)}}function g0(o,u){return sl(o)&&G0(u)?H0(on(o),u):function(_){var D=_l(_,o);return D===e&&D===u?ml(_,o):ps(u,D,y|m)}}function Wo(o,u,_,D,C){o!==u&&Lu(u,function(I,P){if(C||(C=new Kr),Ce(I))Vb(o,u,P,_,Wo,D,C);else{var k=D?D(al(o,P),I,P+"",o,u,C):e;k===e&&(k=I),Tu(o,P,k)}},pr)}function Vb(o,u,_,D,C,I,P){var k=al(o,_),V=al(u,_),tt=P.get(V);if(tt){Tu(o,_,tt);return}var et=I?I(k,V,_+"",o,u,P):e,ot=et===e;if(ot){var dt=Tt(V),yt=!dt&&jn(V),Ct=!dt&&!yt&&ji(V);et=V,dt||yt||Ct?Tt(k)?et=k:Be(k)?et=fr(k):yt?(ot=!1,et=N0(V,!0)):Ct?(ot=!1,et=S0(V,!0)):et=[]:vs(V)||ci(V)?(et=k,ci(k)?et=Cp(k):(!Ce(k)||Dn(k))&&(et=K0(V))):ot=!1}ot&&(P.set(V,et),C(et,V,D,I,P),P.delete(V)),Tu(o,_,et)}function v0(o,u){var _=o.length;if(_)return u+=u<0?_:0,wn(u,_)?o[u]:e}function y0(o,u,_){u.length?u=xe(u,function(I){return Tt(I)?function(P){return ai(P,I.length===1?I[0]:I)}:I}):u=[dr];var D=-1;u=xe(u,xr(At()));var C=_0(o,function(I,P,k){var V=xe(u,function(tt){return tt(I)});return{criteria:V,index:++D,value:I}});return vD(C,function(I,P){return ix(I,P,_)})}function Yb(o,u){return w0(o,u,function(_,D){return ml(o,D)})}function w0(o,u,_){for(var D=-1,C=u.length,I={};++D<C;){var P=u[D],k=ai(o,P);_(k,P)&&ds(I,Un(P,o),k)}return I}function Zb(o){return function(u){return ai(u,o)}}function Wu(o,u,_,D){var C=D?gD:Ii,I=-1,P=u.length,k=o;for(o===u&&(u=fr(u)),_&&(k=xe(o,xr(_)));++I<P;)for(var V=0,tt=u[I],et=_?_(tt):tt;(V=C(k,et,V,D))>-1;)k!==o&&Io.call(k,V,1),Io.call(o,V,1);return o}function D0(o,u){for(var _=o?u.length:0,D=_-1;_--;){var C=u[_];if(_==D||C!==I){var I=C;wn(C)?Io.call(o,C,1):Zu(o,C)}}return o}function ju(o,u){return o+Lo(e0()*(u-o+1))}function Kb(o,u,_,D){for(var C=-1,I=Ue($o((u-o)/(_||1)),0),P=H(I);I--;)P[D?I:++C]=o,o+=_;return P}function Vu(o,u){var _="";if(!o||u<1||u>Z)return _;do u%2&&(_+=o),u=Lo(u/2),u&&(o+=o);while(u);return _}function Pt(o,u){return ul(J0(o,u,dr),o+"")}function Gb(o){return i0(Vi(o))}function Hb(o,u){var _=Vi(o);return Qo(_,oi(u,0,_.length))}function ds(o,u,_,D){if(!Ce(o))return o;u=Un(u,o);for(var C=-1,I=u.length,P=I-1,k=o;k!=null&&++C<I;){var V=on(u[C]),tt=_;if(V==="__proto__"||V==="constructor"||V==="prototype")return o;if(C!=P){var et=k[V];tt=D?D(et,V,k):e,tt===e&&(tt=Ce(et)?et:wn(u[C+1])?[]:{})}cs(k,V,tt),k=k[V]}return o}var b0=Ro?function(o,u){return Ro.set(o,u),o}:dr,Jb=To?function(o,u){return To(o,"toString",{configurable:!0,enumerable:!1,value:vl(u),writable:!0})}:dr;function Xb(o){return Qo(Vi(o))}function Rr(o,u,_){var D=-1,C=o.length;u<0&&(u=-u>C?0:C+u),_=_>C?C:_,_<0&&(_+=C),C=u>_?0:_-u>>>0,u>>>=0;for(var I=H(C);++D<C;)I[D]=o[D+u];return I}function Qb(o,u){var _;return kn(o,function(D,C,I){return _=u(D,C,I),!_}),!!_}function jo(o,u,_){var D=0,C=o==null?D:o.length;if(typeof u=="number"&&u===u&&C<=lt){for(;D<C;){var I=D+C>>>1,P=o[I];P!==null&&!Ar(P)&&(_?P<=u:P<u)?D=I+1:C=I}return C}return Yu(o,u,dr,_)}function Yu(o,u,_,D){var C=0,I=o==null?0:o.length;if(I===0)return 0;u=_(u);for(var P=u!==u,k=u===null,V=Ar(u),tt=u===e;C<I;){var et=Lo((C+I)/2),ot=_(o[et]),dt=ot!==e,yt=ot===null,Ct=ot===ot,Rt=Ar(ot);if(P)var Ft=D||Ct;else tt?Ft=Ct&&(D||dt):k?Ft=Ct&&dt&&(D||!yt):V?Ft=Ct&&dt&&!yt&&(D||!Rt):yt||Rt?Ft=!1:Ft=D?ot<=u:ot<u;Ft?C=et+1:I=et}return tr(I,vt)}function x0(o,u){for(var _=-1,D=o.length,C=0,I=[];++_<D;){var P=o[_],k=u?u(P):P;if(!_||!Gr(k,V)){var V=k;I[C++]=P===0?0:P}}return I}function E0(o){return typeof o=="number"?o:Ar(o)?Q:+o}function Er(o){if(typeof o=="string")return o;if(Tt(o))return xe(o,Er)+"";if(Ar(o))return r0?r0.call(o):"";var u=o+"";return u=="0"&&1/o==-K?"-0":u}function qn(o,u,_){var D=-1,C=xo,I=o.length,P=!0,k=[],V=k;if(_)P=!1,C=Du;else if(I>=n){var tt=u?null:cx(o);if(tt)return Ao(tt);P=!1,C=is,V=new si}else V=u?[]:k;t:for(;++D<I;){var et=o[D],ot=u?u(et):et;if(et=_||et!==0?et:0,P&&ot===ot){for(var dt=V.length;dt--;)if(V[dt]===ot)continue t;u&&V.push(ot),k.push(et)}else C(V,ot,_)||(V!==k&&V.push(ot),k.push(et))}return k}function Zu(o,u){return u=Un(u,o),o=X0(o,u),o==null||delete o[on(Pr(u))]}function A0(o,u,_,D){return ds(o,u,_(ai(o,u)),D)}function Vo(o,u,_,D){for(var C=o.length,I=D?C:-1;(D?I--:++I<C)&&u(o[I],I,o););return _?Rr(o,D?0:I,D?I+1:C):Rr(o,D?I+1:0,D?C:I)}function C0(o,u){var _=o;return _ instanceof jt&&(_=_.value()),bu(u,function(D,C){return C.func.apply(C.thisArg,Rn([D],C.args))},_)}function Ku(o,u,_){var D=o.length;if(D<2)return D?qn(o[0]):[];for(var C=-1,I=H(D);++C<D;)for(var P=o[C],k=-1;++k<D;)k!=C&&(I[C]=fs(I[C]||P,o[k],u,_));return qn(He(I,1),u,_)}function F0(o,u,_){for(var D=-1,C=o.length,I=u.length,P={};++D<C;){var k=D<I?u[D]:e;_(P,o[D],k)}return P}function Gu(o){return Be(o)?o:[]}function Hu(o){return typeof o=="function"?o:dr}function Un(o,u){return Tt(o)?o:sl(o,u)?[o]:rp(ie(o))}var tx=Pt;function Wn(o,u,_){var D=o.length;return _=_===e?D:_,!u&&_>=D?o:Rr(o,u,_)}var M0=qD||function(o){return Ge.clearTimeout(o)};function N0(o,u){if(u)return o.slice();var _=o.length,D=Hh?Hh(_):new o.constructor(_);return o.copy(D),D}function Ju(o){var u=new o.constructor(o.byteLength);return new Bo(u).set(new Bo(o)),u}function ex(o,u){var _=u?Ju(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.byteLength)}function rx(o){var u=new o.constructor(o.source,wo.exec(o));return u.lastIndex=o.lastIndex,u}function nx(o){return ls?pe(ls.call(o)):{}}function S0(o,u){var _=u?Ju(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.length)}function B0(o,u){if(o!==u){var _=o!==e,D=o===null,C=o===o,I=Ar(o),P=u!==e,k=u===null,V=u===u,tt=Ar(u);if(!k&&!tt&&!I&&o>u||I&&P&&V&&!k&&!tt||D&&P&&V||!_&&V||!C)return 1;if(!D&&!I&&!tt&&o<u||tt&&_&&C&&!D&&!I||k&&_&&C||!P&&C||!V)return-1}return 0}function ix(o,u,_){for(var D=-1,C=o.criteria,I=u.criteria,P=C.length,k=_.length;++D<P;){var V=B0(C[D],I[D]);if(V){if(D>=k)return V;var tt=_[D];return V*(tt=="desc"?-1:1)}}return o.index-u.index}function O0(o,u,_,D){for(var C=-1,I=o.length,P=_.length,k=-1,V=u.length,tt=Ue(I-P,0),et=H(V+tt),ot=!D;++k<V;)et[k]=u[k];for(;++C<P;)(ot||C<I)&&(et[_[C]]=o[C]);for(;tt--;)et[k++]=o[C++];return et}function I0(o,u,_,D){for(var C=-1,I=o.length,P=-1,k=_.length,V=-1,tt=u.length,et=Ue(I-k,0),ot=H(et+tt),dt=!D;++C<et;)ot[C]=o[C];for(var yt=C;++V<tt;)ot[yt+V]=u[V];for(;++P<k;)(dt||C<I)&&(ot[yt+_[P]]=o[C++]);return ot}function fr(o,u){var _=-1,D=o.length;for(u||(u=H(D));++_<D;)u[_]=o[_];return u}function sn(o,u,_,D){var C=!_;_||(_={});for(var I=-1,P=u.length;++I<P;){var k=u[I],V=D?D(_[k],o[k],k,_,o):e;V===e&&(V=o[k]),C?gn(_,k,V):cs(_,k,V)}return _}function sx(o,u){return sn(o,il(o),u)}function ox(o,u){return sn(o,Y0(o),u)}function Yo(o,u){return function(_,D){var C=Tt(_)?fD:Mb,I=u?u():{};return C(_,o,At(D,2),I)}}function qi(o){return Pt(function(u,_){var D=-1,C=_.length,I=C>1?_[C-1]:e,P=C>2?_[2]:e;for(I=o.length>3&&typeof I=="function"?(C--,I):e,P&&or(_[0],_[1],P)&&(I=C<3?e:I,C=1),u=pe(u);++D<C;){var k=_[D];k&&o(u,k,D,I)}return u})}function T0(o,u){return function(_,D){if(_==null)return _;if(!hr(_))return o(_,D);for(var C=_.length,I=u?C:-1,P=pe(_);(u?I--:++I<C)&&D(P[I],I,P)!==!1;);return _}}function $0(o){return function(u,_,D){for(var C=-1,I=pe(u),P=D(u),k=P.length;k--;){var V=P[o?k:++C];if(_(I[V],V,I)===!1)break}return u}}function ax(o,u,_){var D=u&w,C=_s(o);function I(){var P=this&&this!==Ge&&this instanceof I?C:o;return P.apply(D?_:this,arguments)}return I}function L0(o){return function(u){u=ie(u);var _=Ti(u)?Zr(u):e,D=_?_[0]:u.charAt(0),C=_?Wn(_,1).join(""):u.slice(1);return D[o]()+C}}function Ui(o){return function(u){return bu(Tp(Ip(u).replace(Jw,"")),o,"")}}function _s(o){return function(){var u=arguments;switch(u.length){case 0:return new o;case 1:return new o(u[0]);case 2:return new o(u[0],u[1]);case 3:return new o(u[0],u[1],u[2]);case 4:return new o(u[0],u[1],u[2],u[3]);case 5:return new o(u[0],u[1],u[2],u[3],u[4]);case 6:return new o(u[0],u[1],u[2],u[3],u[4],u[5]);case 7:return new o(u[0],u[1],u[2],u[3],u[4],u[5],u[6])}var _=ki(o.prototype),D=o.apply(_,u);return Ce(D)?D:_}}function ux(o,u,_){var D=_s(o);function C(){for(var I=arguments.length,P=H(I),k=I,V=Wi(C);k--;)P[k]=arguments[k];var tt=I<3&&P[0]!==V&&P[I-1]!==V?[]:Pn(P,V);if(I-=tt.length,I<_)return q0(o,u,Zo,C.placeholder,e,P,tt,e,e,_-I);var et=this&&this!==Ge&&this instanceof C?D:o;return br(et,this,P)}return C}function R0(o){return function(u,_,D){var C=pe(u);if(!hr(u)){var I=At(_,3);u=je(u),_=function(k){return I(C[k],k,C)}}var P=o(u,_,D);return P>-1?C[I?u[P]:P]:e}}function P0(o){return yn(function(u){var _=u.length,D=_,C=$r.prototype.thru;for(o&&u.reverse();D--;){var I=u[D];if(typeof I!="function")throw new Tr(a);if(C&&!P&&Jo(I)=="wrapper")var P=new $r([],!0)}for(D=P?D:_;++D<_;){I=u[D];var k=Jo(I),V=k=="wrapper"?rl(I):e;V&&ol(V[0])&&V[1]==(M|b|E|S)&&!V[4].length&&V[9]==1?P=P[Jo(V[0])].apply(P,V[3]):P=I.length==1&&ol(I)?P[k]():P.thru(I)}return function(){var tt=arguments,et=tt[0];if(P&&tt.length==1&&Tt(et))return P.plant(et).value();for(var ot=0,dt=_?u[ot].apply(this,tt):et;++ot<_;)dt=u[ot].call(this,dt);return dt}})}function Zo(o,u,_,D,C,I,P,k,V,tt){var et=u&M,ot=u&w,dt=u&v,yt=u&(b|N),Ct=u&T,Rt=dt?e:_s(o);function Ft(){for(var Ut=arguments.length,Vt=H(Ut),Cr=Ut;Cr--;)Vt[Cr]=arguments[Cr];if(yt)var ar=Wi(Ft),Fr=wD(Vt,ar);if(D&&(Vt=O0(Vt,D,C,yt)),I&&(Vt=I0(Vt,I,P,yt)),Ut-=Fr,yt&&Ut<tt){var Oe=Pn(Vt,ar);return q0(o,u,Zo,Ft.placeholder,_,Vt,Oe,k,V,tt-Ut)}var Hr=ot?_:this,xn=dt?Hr[o]:o;return Ut=Vt.length,k?Vt=Mx(Vt,k):Ct&&Ut>1&&Vt.reverse(),et&&V<Ut&&(Vt.length=V),this&&this!==Ge&&this instanceof Ft&&(xn=Rt||_s(xn)),xn.apply(Hr,Vt)}return Ft}function z0(o,u){return function(_,D){return Lb(_,o,u(D),{})}}function Ko(o,u){return function(_,D){var C;if(_===e&&D===e)return u;if(_!==e&&(C=_),D!==e){if(C===e)return D;typeof _=="string"||typeof D=="string"?(_=Er(_),D=Er(D)):(_=E0(_),D=E0(D)),C=o(_,D)}return C}}function Xu(o){return yn(function(u){return u=xe(u,xr(At())),Pt(function(_){var D=this;return o(u,function(C){return br(C,D,_)})})})}function Go(o,u){u=u===e?" ":Er(u);var _=u.length;if(_<2)return _?Vu(u,o):u;var D=Vu(u,$o(o/$i(u)));return Ti(u)?Wn(Zr(D),0,o).join(""):D.slice(0,o)}function lx(o,u,_,D){var C=u&w,I=_s(o);function P(){for(var k=-1,V=arguments.length,tt=-1,et=D.length,ot=H(et+V),dt=this&&this!==Ge&&this instanceof P?I:o;++tt<et;)ot[tt]=D[tt];for(;V--;)ot[tt++]=arguments[++k];return br(dt,C?_:this,ot)}return P}function k0(o){return function(u,_,D){return D&&typeof D!="number"&&or(u,_,D)&&(_=D=e),u=bn(u),_===e?(_=u,u=0):_=bn(_),D=D===e?u<_?1:-1:bn(D),Kb(u,_,D,o)}}function Ho(o){return function(u,_){return typeof u=="string"&&typeof _=="string"||(u=zr(u),_=zr(_)),o(u,_)}}function q0(o,u,_,D,C,I,P,k,V,tt){var et=u&b,ot=et?P:e,dt=et?e:P,yt=et?I:e,Ct=et?e:I;u|=et?E:A,u&=~(et?A:E),u&x||(u&=~(w|v));var Rt=[o,u,C,yt,ot,Ct,dt,k,V,tt],Ft=_.apply(e,Rt);return ol(o)&&Q0(Ft,Rt),Ft.placeholder=D,tp(Ft,o,u)}function Qu(o){var u=qe[o];return function(_,D){if(_=zr(_),D=D==null?0:tr(Lt(D),292),D&&t0(_)){var C=(ie(_)+"e").split("e"),I=u(C[0]+"e"+(+C[1]+D));return C=(ie(I)+"e").split("e"),+(C[0]+"e"+(+C[1]-D))}return u(_)}}var cx=Pi&&1/Ao(new Pi([,-0]))[1]==K?function(o){return new Pi(o)}:Dl;function U0(o){return function(u){var _=er(u);return _==Jt?Nu(u):_==yr?FD(u):yD(u,o(u))}}function vn(o,u,_,D,C,I,P,k){var V=u&v;if(!V&&typeof o!="function")throw new Tr(a);var tt=D?D.length:0;if(tt||(u&=~(E|A),D=C=e),P=P===e?P:Ue(Lt(P),0),k=k===e?k:Lt(k),tt-=C?C.length:0,u&A){var et=D,ot=C;D=C=e}var dt=V?e:rl(o),yt=[o,u,_,D,C,et,ot,I,P,k];if(dt&&Ax(yt,dt),o=yt[0],u=yt[1],_=yt[2],D=yt[3],C=yt[4],k=yt[9]=yt[9]===e?V?0:o.length:Ue(yt[9]-tt,0),!k&&u&(b|N)&&(u&=~(b|N)),!u||u==w)var Ct=ax(o,u,_);else u==b||u==N?Ct=ux(o,u,k):(u==E||u==(w|E))&&!C.length?Ct=lx(o,u,_,D):Ct=Zo.apply(e,yt);var Rt=dt?b0:Q0;return tp(Rt(Ct,yt),o,u)}function W0(o,u,_,D){return o===e||Gr(o,Ri[_])&&!ae.call(D,_)?u:o}function j0(o,u,_,D,C,I){return Ce(o)&&Ce(u)&&(I.set(u,o),Wo(o,u,e,j0,I),I.delete(u)),o}function fx(o){return vs(o)?e:o}function V0(o,u,_,D,C,I){var P=_&y,k=o.length,V=u.length;if(k!=V&&!(P&&V>k))return!1;var tt=I.get(o),et=I.get(u);if(tt&&et)return tt==u&&et==o;var ot=-1,dt=!0,yt=_&m?new si:e;for(I.set(o,u),I.set(u,o);++ot<k;){var Ct=o[ot],Rt=u[ot];if(D)var Ft=P?D(Rt,Ct,ot,u,o,I):D(Ct,Rt,ot,o,u,I);if(Ft!==e){if(Ft)continue;dt=!1;break}if(yt){if(!xu(u,function(Ut,Vt){if(!is(yt,Vt)&&(Ct===Ut||C(Ct,Ut,_,D,I)))return yt.push(Vt)})){dt=!1;break}}else if(!(Ct===Rt||C(Ct,Rt,_,D,I))){dt=!1;break}}return I.delete(o),I.delete(u),dt}function hx(o,u,_,D,C,I,P){switch(_){case rt:if(o.byteLength!=u.byteLength||o.byteOffset!=u.byteOffset)return!1;o=o.buffer,u=u.buffer;case st:return!(o.byteLength!=u.byteLength||!I(new Bo(o),new Bo(u)));case oe:case It:case $e:return Gr(+o,+u);case ce:return o.name==u.name&&o.message==u.message;case dn:case In:return o==u+"";case Jt:var k=Nu;case yr:var V=D&y;if(k||(k=Ao),o.size!=u.size&&!V)return!1;var tt=P.get(o);if(tt)return tt==u;D|=m,P.set(o,u);var et=V0(k(o),k(u),D,C,I,P);return P.delete(o),et;case L:if(ls)return ls.call(o)==ls.call(u)}return!1}function px(o,u,_,D,C,I){var P=_&y,k=tl(o),V=k.length,tt=tl(u),et=tt.length;if(V!=et&&!P)return!1;for(var ot=V;ot--;){var dt=k[ot];if(!(P?dt in u:ae.call(u,dt)))return!1}var yt=I.get(o),Ct=I.get(u);if(yt&&Ct)return yt==u&&Ct==o;var Rt=!0;I.set(o,u),I.set(u,o);for(var Ft=P;++ot<V;){dt=k[ot];var Ut=o[dt],Vt=u[dt];if(D)var Cr=P?D(Vt,Ut,dt,u,o,I):D(Ut,Vt,dt,o,u,I);if(!(Cr===e?Ut===Vt||C(Ut,Vt,_,D,I):Cr)){Rt=!1;break}Ft||(Ft=dt=="constructor")}if(Rt&&!Ft){var ar=o.constructor,Fr=u.constructor;ar!=Fr&&"constructor"in o&&"constructor"in u&&!(typeof ar=="function"&&ar instanceof ar&&typeof Fr=="function"&&Fr instanceof Fr)&&(Rt=!1)}return I.delete(o),I.delete(u),Rt}function yn(o){return ul(J0(o,e,op),o+"")}function tl(o){return f0(o,je,il)}function el(o){return f0(o,pr,Y0)}var rl=Ro?function(o){return Ro.get(o)}:Dl;function Jo(o){for(var u=o.name+"",_=zi[u],D=ae.call(zi,u)?_.length:0;D--;){var C=_[D],I=C.func;if(I==null||I==o)return C.name}return u}function Wi(o){var u=ae.call(B,"placeholder")?B:o;return u.placeholder}function At(){var o=B.iteratee||yl;return o=o===yl?d0:o,arguments.length?o(arguments[0],arguments[1]):o}function Xo(o,u){var _=o.__data__;return Dx(u)?_[typeof u=="string"?"string":"hash"]:_.map}function nl(o){for(var u=je(o),_=u.length;_--;){var D=u[_],C=o[D];u[_]=[D,C,G0(C)]}return u}function ui(o,u){var _=ED(o,u);return p0(_)?_:e}function dx(o){var u=ae.call(o,ni),_=o[ni];try{o[ni]=e;var D=!0}catch{}var C=No.call(o);return D&&(u?o[ni]=_:delete o[ni]),C}var il=Bu?function(o){return o==null?[]:(o=pe(o),Ln(Bu(o),function(u){return Xh.call(o,u)}))}:bl,Y0=Bu?function(o){for(var u=[];o;)Rn(u,il(o)),o=Oo(o);return u}:bl,er=sr;(Ou&&er(new Ou(new ArrayBuffer(1)))!=rt||os&&er(new os)!=Jt||Iu&&er(Iu.resolve())!=pn||Pi&&er(new Pi)!=yr||as&&er(new as)!=G)&&(er=function(o){var u=sr(o),_=u==ze?o.constructor:e,D=_?li(_):"";if(D)switch(D){case HD:return rt;case JD:return Jt;case XD:return pn;case QD:return yr;case tb:return G}return u});function _x(o,u,_){for(var D=-1,C=_.length;++D<C;){var I=_[D],P=I.size;switch(I.type){case"drop":o+=P;break;case"dropRight":u-=P;break;case"take":u=tr(u,o+P);break;case"takeRight":o=Ue(o,u-P);break}}return{start:o,end:u}}function mx(o){var u=o.match(eu);return u?u[1].split(ru):[]}function Z0(o,u,_){u=Un(u,o);for(var D=-1,C=u.length,I=!1;++D<C;){var P=on(u[D]);if(!(I=o!=null&&_(o,P)))break;o=o[P]}return I||++D!=C?I:(C=o==null?0:o.length,!!C&&sa(C)&&wn(P,C)&&(Tt(o)||ci(o)))}function gx(o){var u=o.length,_=new o.constructor(u);return u&&typeof o[0]=="string"&&ae.call(o,"index")&&(_.index=o.index,_.input=o.input),_}function K0(o){return typeof o.constructor=="function"&&!ms(o)?ki(Oo(o)):{}}function vx(o,u,_){var D=o.constructor;switch(u){case st:return Ju(o);case oe:case It:return new D(+o);case rt:return ex(o,_);case ft:case ut:case ht:case at:case Xt:case ne:case be:case We:case ke:return S0(o,_);case Jt:return new D;case $e:case In:return new D(o);case dn:return rx(o);case yr:return new D;case L:return nx(o)}}function yx(o,u){var _=u.length;if(!_)return o;var D=_-1;return u[D]=(_>1?"& ":"")+u[D],u=u.join(_>2?", ":" "),o.replace(tu,`{
9
- /* [wrapped with `+u+`] */
10
- `)}function wx(o){return Tt(o)||ci(o)||!!(Qh&&o&&o[Qh])}function wn(o,u){var _=typeof o;return u=u??Z,!!u&&(_=="number"||_!="symbol"&&fu.test(o))&&o>-1&&o%1==0&&o<u}function or(o,u,_){if(!Ce(_))return!1;var D=typeof u;return(D=="number"?hr(_)&&wn(u,_.length):D=="string"&&u in _)?Gr(_[u],o):!1}function sl(o,u){if(Tt(o))return!1;var _=typeof o;return _=="number"||_=="symbol"||_=="boolean"||o==null||Ar(o)?!0:Ha.test(o)||!Ga.test(o)||u!=null&&o in pe(u)}function Dx(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function ol(o){var u=Jo(o),_=B[u];if(typeof _!="function"||!(u in jt.prototype))return!1;if(o===_)return!0;var D=rl(_);return!!D&&o===D[0]}function bx(o){return!!Gh&&Gh in o}var xx=Fo?Dn:xl;function ms(o){var u=o&&o.constructor,_=typeof u=="function"&&u.prototype||Ri;return o===_}function G0(o){return o===o&&!Ce(o)}function H0(o,u){return function(_){return _==null?!1:_[o]===u&&(u!==e||o in pe(_))}}function Ex(o){var u=na(o,function(D){return _.size===h&&_.clear(),D}),_=u.cache;return u}function Ax(o,u){var _=o[1],D=u[1],C=_|D,I=C<(w|v|M),P=D==M&&_==b||D==M&&_==S&&o[7].length<=u[8]||D==(M|S)&&u[7].length<=u[8]&&_==b;if(!(I||P))return o;D&w&&(o[2]=u[2],C|=_&w?0:x);var k=u[3];if(k){var V=o[3];o[3]=V?O0(V,k,u[4]):k,o[4]=V?Pn(o[3],p):u[4]}return k=u[5],k&&(V=o[5],o[5]=V?I0(V,k,u[6]):k,o[6]=V?Pn(o[5],p):u[6]),k=u[7],k&&(o[7]=k),D&M&&(o[8]=o[8]==null?u[8]:tr(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=C,o}function Cx(o){var u=[];if(o!=null)for(var _ in pe(o))u.push(_);return u}function Fx(o){return No.call(o)}function J0(o,u,_){return u=Ue(u===e?o.length-1:u,0),function(){for(var D=arguments,C=-1,I=Ue(D.length-u,0),P=H(I);++C<I;)P[C]=D[u+C];C=-1;for(var k=H(u+1);++C<u;)k[C]=D[C];return k[u]=_(P),br(o,this,k)}}function X0(o,u){return u.length<2?o:ai(o,Rr(u,0,-1))}function Mx(o,u){for(var _=o.length,D=tr(u.length,_),C=fr(o);D--;){var I=u[D];o[D]=wn(I,_)?C[I]:e}return o}function al(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var Q0=ep(b0),gs=WD||function(o,u){return Ge.setTimeout(o,u)},ul=ep(Jb);function tp(o,u,_){var D=u+"";return ul(o,yx(D,Nx(mx(D),_)))}function ep(o){var u=0,_=0;return function(){var D=ZD(),C=U-(D-_);if(_=D,C>0){if(++u>=R)return arguments[0]}else u=0;return o.apply(e,arguments)}}function Qo(o,u){var _=-1,D=o.length,C=D-1;for(u=u===e?D:u;++_<u;){var I=ju(_,C),P=o[I];o[I]=o[_],o[_]=P}return o.length=u,o}var rp=Ex(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(Ja,function(_,D,C,I){u.push(C?I.replace(su,"$1"):D||_)}),u});function on(o){if(typeof o=="string"||Ar(o))return o;var u=o+"";return u=="0"&&1/o==-K?"-0":u}function li(o){if(o!=null){try{return Mo.call(o)}catch{}try{return o+""}catch{}}return""}function Nx(o,u){return Ir(wt,function(_){var D="_."+_[0];u&_[1]&&!xo(o,D)&&o.push(D)}),o.sort()}function np(o){if(o instanceof jt)return o.clone();var u=new $r(o.__wrapped__,o.__chain__);return u.__actions__=fr(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function Sx(o,u,_){(_?or(o,u,_):u===e)?u=1:u=Ue(Lt(u),0);var D=o==null?0:o.length;if(!D||u<1)return[];for(var C=0,I=0,P=H($o(D/u));C<D;)P[I++]=Rr(o,C,C+=u);return P}function Bx(o){for(var u=-1,_=o==null?0:o.length,D=0,C=[];++u<_;){var I=o[u];I&&(C[D++]=I)}return C}function Ox(){var o=arguments.length;if(!o)return[];for(var u=H(o-1),_=arguments[0],D=o;D--;)u[D-1]=arguments[D];return Rn(Tt(_)?fr(_):[_],He(u,1))}var Ix=Pt(function(o,u){return Be(o)?fs(o,He(u,1,Be,!0)):[]}),Tx=Pt(function(o,u){var _=Pr(u);return Be(_)&&(_=e),Be(o)?fs(o,He(u,1,Be,!0),At(_,2)):[]}),$x=Pt(function(o,u){var _=Pr(u);return Be(_)&&(_=e),Be(o)?fs(o,He(u,1,Be,!0),e,_):[]});function Lx(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),Rr(o,u<0?0:u,D)):[]}function Rx(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,Rr(o,0,u<0?0:u)):[]}function Px(o,u){return o&&o.length?Vo(o,At(u,3),!0,!0):[]}function zx(o,u){return o&&o.length?Vo(o,At(u,3),!0):[]}function kx(o,u,_,D){var C=o==null?0:o.length;return C?(_&&typeof _!="number"&&or(o,u,_)&&(_=0,D=C),Ob(o,u,_,D)):[]}function ip(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=_==null?0:Lt(_);return C<0&&(C=Ue(D+C,0)),Eo(o,At(u,3),C)}function sp(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=D-1;return _!==e&&(C=Lt(_),C=_<0?Ue(D+C,0):tr(C,D-1)),Eo(o,At(u,3),C,!0)}function op(o){var u=o==null?0:o.length;return u?He(o,1):[]}function qx(o){var u=o==null?0:o.length;return u?He(o,K):[]}function Ux(o,u){var _=o==null?0:o.length;return _?(u=u===e?1:Lt(u),He(o,u)):[]}function Wx(o){for(var u=-1,_=o==null?0:o.length,D={};++u<_;){var C=o[u];D[C[0]]=C[1]}return D}function ap(o){return o&&o.length?o[0]:e}function jx(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=_==null?0:Lt(_);return C<0&&(C=Ue(D+C,0)),Ii(o,u,C)}function Vx(o){var u=o==null?0:o.length;return u?Rr(o,0,-1):[]}var Yx=Pt(function(o){var u=xe(o,Gu);return u.length&&u[0]===o[0]?zu(u):[]}),Zx=Pt(function(o){var u=Pr(o),_=xe(o,Gu);return u===Pr(_)?u=e:_.pop(),_.length&&_[0]===o[0]?zu(_,At(u,2)):[]}),Kx=Pt(function(o){var u=Pr(o),_=xe(o,Gu);return u=typeof u=="function"?u:e,u&&_.pop(),_.length&&_[0]===o[0]?zu(_,e,u):[]});function Gx(o,u){return o==null?"":VD.call(o,u)}function Pr(o){var u=o==null?0:o.length;return u?o[u-1]:e}function Hx(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=D;return _!==e&&(C=Lt(_),C=C<0?Ue(D+C,0):tr(C,D-1)),u===u?ND(o,u,C):Eo(o,qh,C,!0)}function Jx(o,u){return o&&o.length?v0(o,Lt(u)):e}var Xx=Pt(up);function up(o,u){return o&&o.length&&u&&u.length?Wu(o,u):o}function Qx(o,u,_){return o&&o.length&&u&&u.length?Wu(o,u,At(_,2)):o}function tE(o,u,_){return o&&o.length&&u&&u.length?Wu(o,u,e,_):o}var eE=yn(function(o,u){var _=o==null?0:o.length,D=$u(o,u);return D0(o,xe(u,function(C){return wn(C,_)?+C:C}).sort(B0)),D});function rE(o,u){var _=[];if(!(o&&o.length))return _;var D=-1,C=[],I=o.length;for(u=At(u,3);++D<I;){var P=o[D];u(P,D,o)&&(_.push(P),C.push(D))}return D0(o,C),_}function ll(o){return o==null?o:GD.call(o)}function nE(o,u,_){var D=o==null?0:o.length;return D?(_&&typeof _!="number"&&or(o,u,_)?(u=0,_=D):(u=u==null?0:Lt(u),_=_===e?D:Lt(_)),Rr(o,u,_)):[]}function iE(o,u){return jo(o,u)}function sE(o,u,_){return Yu(o,u,At(_,2))}function oE(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u);if(D<_&&Gr(o[D],u))return D}return-1}function aE(o,u){return jo(o,u,!0)}function uE(o,u,_){return Yu(o,u,At(_,2),!0)}function lE(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u,!0)-1;if(Gr(o[D],u))return D}return-1}function cE(o){return o&&o.length?x0(o):[]}function fE(o,u){return o&&o.length?x0(o,At(u,2)):[]}function hE(o){var u=o==null?0:o.length;return u?Rr(o,1,u):[]}function pE(o,u,_){return o&&o.length?(u=_||u===e?1:Lt(u),Rr(o,0,u<0?0:u)):[]}function dE(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,Rr(o,u<0?0:u,D)):[]}function _E(o,u){return o&&o.length?Vo(o,At(u,3),!1,!0):[]}function mE(o,u){return o&&o.length?Vo(o,At(u,3)):[]}var gE=Pt(function(o){return qn(He(o,1,Be,!0))}),vE=Pt(function(o){var u=Pr(o);return Be(u)&&(u=e),qn(He(o,1,Be,!0),At(u,2))}),yE=Pt(function(o){var u=Pr(o);return u=typeof u=="function"?u:e,qn(He(o,1,Be,!0),e,u)});function wE(o){return o&&o.length?qn(o):[]}function DE(o,u){return o&&o.length?qn(o,At(u,2)):[]}function bE(o,u){return u=typeof u=="function"?u:e,o&&o.length?qn(o,e,u):[]}function cl(o){if(!(o&&o.length))return[];var u=0;return o=Ln(o,function(_){if(Be(_))return u=Ue(_.length,u),!0}),Fu(u,function(_){return xe(o,Eu(_))})}function lp(o,u){if(!(o&&o.length))return[];var _=cl(o);return u==null?_:xe(_,function(D){return br(u,e,D)})}var xE=Pt(function(o,u){return Be(o)?fs(o,u):[]}),EE=Pt(function(o){return Ku(Ln(o,Be))}),AE=Pt(function(o){var u=Pr(o);return Be(u)&&(u=e),Ku(Ln(o,Be),At(u,2))}),CE=Pt(function(o){var u=Pr(o);return u=typeof u=="function"?u:e,Ku(Ln(o,Be),e,u)}),FE=Pt(cl);function ME(o,u){return F0(o||[],u||[],cs)}function NE(o,u){return F0(o||[],u||[],ds)}var SE=Pt(function(o){var u=o.length,_=u>1?o[u-1]:e;return _=typeof _=="function"?(o.pop(),_):e,lp(o,_)});function cp(o){var u=B(o);return u.__chain__=!0,u}function BE(o,u){return u(o),o}function ta(o,u){return u(o)}var OE=yn(function(o){var u=o.length,_=u?o[0]:0,D=this.__wrapped__,C=function(I){return $u(I,o)};return u>1||this.__actions__.length||!(D instanceof jt)||!wn(_)?this.thru(C):(D=D.slice(_,+_+(u?1:0)),D.__actions__.push({func:ta,args:[C],thisArg:e}),new $r(D,this.__chain__).thru(function(I){return u&&!I.length&&I.push(e),I}))});function IE(){return cp(this)}function TE(){return new $r(this.value(),this.__chain__)}function $E(){this.__values__===e&&(this.__values__=Ep(this.value()));var o=this.__index__>=this.__values__.length,u=o?e:this.__values__[this.__index__++];return{done:o,value:u}}function LE(){return this}function RE(o){for(var u,_=this;_ instanceof zo;){var D=np(_);D.__index__=0,D.__values__=e,u?C.__wrapped__=D:u=D;var C=D;_=_.__wrapped__}return C.__wrapped__=o,u}function PE(){var o=this.__wrapped__;if(o instanceof jt){var u=o;return this.__actions__.length&&(u=new jt(this)),u=u.reverse(),u.__actions__.push({func:ta,args:[ll],thisArg:e}),new $r(u,this.__chain__)}return this.thru(ll)}function zE(){return C0(this.__wrapped__,this.__actions__)}var kE=Yo(function(o,u,_){ae.call(o,_)?++o[_]:gn(o,_,1)});function qE(o,u,_){var D=Tt(o)?zh:Bb;return _&&or(o,u,_)&&(u=e),D(o,At(u,3))}function UE(o,u){var _=Tt(o)?Ln:l0;return _(o,At(u,3))}var WE=R0(ip),jE=R0(sp);function VE(o,u){return He(ea(o,u),1)}function YE(o,u){return He(ea(o,u),K)}function ZE(o,u,_){return _=_===e?1:Lt(_),He(ea(o,u),_)}function fp(o,u){var _=Tt(o)?Ir:kn;return _(o,At(u,3))}function hp(o,u){var _=Tt(o)?hD:u0;return _(o,At(u,3))}var KE=Yo(function(o,u,_){ae.call(o,_)?o[_].push(u):gn(o,_,[u])});function GE(o,u,_,D){o=hr(o)?o:Vi(o),_=_&&!D?Lt(_):0;var C=o.length;return _<0&&(_=Ue(C+_,0)),oa(o)?_<=C&&o.indexOf(u,_)>-1:!!C&&Ii(o,u,_)>-1}var HE=Pt(function(o,u,_){var D=-1,C=typeof u=="function",I=hr(o)?H(o.length):[];return kn(o,function(P){I[++D]=C?br(u,P,_):hs(P,u,_)}),I}),JE=Yo(function(o,u,_){gn(o,_,u)});function ea(o,u){var _=Tt(o)?xe:_0;return _(o,At(u,3))}function XE(o,u,_,D){return o==null?[]:(Tt(u)||(u=u==null?[]:[u]),_=D?e:_,Tt(_)||(_=_==null?[]:[_]),y0(o,u,_))}var QE=Yo(function(o,u,_){o[_?0:1].push(u)},function(){return[[],[]]});function tA(o,u,_){var D=Tt(o)?bu:Wh,C=arguments.length<3;return D(o,At(u,4),_,C,kn)}function eA(o,u,_){var D=Tt(o)?pD:Wh,C=arguments.length<3;return D(o,At(u,4),_,C,u0)}function rA(o,u){var _=Tt(o)?Ln:l0;return _(o,ia(At(u,3)))}function nA(o){var u=Tt(o)?i0:Gb;return u(o)}function iA(o,u,_){(_?or(o,u,_):u===e)?u=1:u=Lt(u);var D=Tt(o)?Cb:Hb;return D(o,u)}function sA(o){var u=Tt(o)?Fb:Xb;return u(o)}function oA(o){if(o==null)return 0;if(hr(o))return oa(o)?$i(o):o.length;var u=er(o);return u==Jt||u==yr?o.size:qu(o).length}function aA(o,u,_){var D=Tt(o)?xu:Qb;return _&&or(o,u,_)&&(u=e),D(o,At(u,3))}var uA=Pt(function(o,u){if(o==null)return[];var _=u.length;return _>1&&or(o,u[0],u[1])?u=[]:_>2&&or(u[0],u[1],u[2])&&(u=[u[0]]),y0(o,He(u,1),[])}),ra=UD||function(){return Ge.Date.now()};function lA(o,u){if(typeof u!="function")throw new Tr(a);return o=Lt(o),function(){if(--o<1)return u.apply(this,arguments)}}function pp(o,u,_){return u=_?e:u,u=o&&u==null?o.length:u,vn(o,M,e,e,e,e,u)}function dp(o,u){var _;if(typeof u!="function")throw new Tr(a);return o=Lt(o),function(){return--o>0&&(_=u.apply(this,arguments)),o<=1&&(u=e),_}}var fl=Pt(function(o,u,_){var D=w;if(_.length){var C=Pn(_,Wi(fl));D|=E}return vn(o,D,u,_,C)}),_p=Pt(function(o,u,_){var D=w|v;if(_.length){var C=Pn(_,Wi(_p));D|=E}return vn(u,D,o,_,C)});function mp(o,u,_){u=_?e:u;var D=vn(o,b,e,e,e,e,e,u);return D.placeholder=mp.placeholder,D}function gp(o,u,_){u=_?e:u;var D=vn(o,N,e,e,e,e,e,u);return D.placeholder=gp.placeholder,D}function vp(o,u,_){var D,C,I,P,k,V,tt=0,et=!1,ot=!1,dt=!0;if(typeof o!="function")throw new Tr(a);u=zr(u)||0,Ce(_)&&(et=!!_.leading,ot="maxWait"in _,I=ot?Ue(zr(_.maxWait)||0,u):I,dt="trailing"in _?!!_.trailing:dt);function yt(Oe){var Hr=D,xn=C;return D=C=e,tt=Oe,P=o.apply(xn,Hr),P}function Ct(Oe){return tt=Oe,k=gs(Ut,u),et?yt(Oe):P}function Rt(Oe){var Hr=Oe-V,xn=Oe-tt,Rp=u-Hr;return ot?tr(Rp,I-xn):Rp}function Ft(Oe){var Hr=Oe-V,xn=Oe-tt;return V===e||Hr>=u||Hr<0||ot&&xn>=I}function Ut(){var Oe=ra();if(Ft(Oe))return Vt(Oe);k=gs(Ut,Rt(Oe))}function Vt(Oe){return k=e,dt&&D?yt(Oe):(D=C=e,P)}function Cr(){k!==e&&M0(k),tt=0,D=V=C=k=e}function ar(){return k===e?P:Vt(ra())}function Fr(){var Oe=ra(),Hr=Ft(Oe);if(D=arguments,C=this,V=Oe,Hr){if(k===e)return Ct(V);if(ot)return M0(k),k=gs(Ut,u),yt(V)}return k===e&&(k=gs(Ut,u)),P}return Fr.cancel=Cr,Fr.flush=ar,Fr}var cA=Pt(function(o,u){return a0(o,1,u)}),fA=Pt(function(o,u,_){return a0(o,zr(u)||0,_)});function hA(o){return vn(o,T)}function na(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new Tr(a);var _=function(){var D=arguments,C=u?u.apply(this,D):D[0],I=_.cache;if(I.has(C))return I.get(C);var P=o.apply(this,D);return _.cache=I.set(C,P)||I,P};return _.cache=new(na.Cache||mn),_}na.Cache=mn;function ia(o){if(typeof o!="function")throw new Tr(a);return function(){var u=arguments;switch(u.length){case 0:return!o.call(this);case 1:return!o.call(this,u[0]);case 2:return!o.call(this,u[0],u[1]);case 3:return!o.call(this,u[0],u[1],u[2])}return!o.apply(this,u)}}function pA(o){return dp(2,o)}var dA=tx(function(o,u){u=u.length==1&&Tt(u[0])?xe(u[0],xr(At())):xe(He(u,1),xr(At()));var _=u.length;return Pt(function(D){for(var C=-1,I=tr(D.length,_);++C<I;)D[C]=u[C].call(this,D[C]);return br(o,this,D)})}),hl=Pt(function(o,u){var _=Pn(u,Wi(hl));return vn(o,E,e,u,_)}),yp=Pt(function(o,u){var _=Pn(u,Wi(yp));return vn(o,A,e,u,_)}),_A=yn(function(o,u){return vn(o,S,e,e,e,u)});function mA(o,u){if(typeof o!="function")throw new Tr(a);return u=u===e?u:Lt(u),Pt(o,u)}function gA(o,u){if(typeof o!="function")throw new Tr(a);return u=u==null?0:Ue(Lt(u),0),Pt(function(_){var D=_[u],C=Wn(_,0,u);return D&&Rn(C,D),br(o,this,C)})}function vA(o,u,_){var D=!0,C=!0;if(typeof o!="function")throw new Tr(a);return Ce(_)&&(D="leading"in _?!!_.leading:D,C="trailing"in _?!!_.trailing:C),vp(o,u,{leading:D,maxWait:u,trailing:C})}function yA(o){return pp(o,1)}function wA(o,u){return hl(Hu(u),o)}function DA(){if(!arguments.length)return[];var o=arguments[0];return Tt(o)?o:[o]}function bA(o){return Lr(o,g)}function xA(o,u){return u=typeof u=="function"?u:e,Lr(o,g,u)}function EA(o){return Lr(o,f|g)}function AA(o,u){return u=typeof u=="function"?u:e,Lr(o,f|g,u)}function CA(o,u){return u==null||o0(o,u,je(u))}function Gr(o,u){return o===u||o!==o&&u!==u}var FA=Ho(Pu),MA=Ho(function(o,u){return o>=u}),ci=h0(function(){return arguments}())?h0:function(o){return Me(o)&&ae.call(o,"callee")&&!Xh.call(o,"callee")},Tt=H.isArray,NA=Ih?xr(Ih):Rb;function hr(o){return o!=null&&sa(o.length)&&!Dn(o)}function Be(o){return Me(o)&&hr(o)}function SA(o){return o===!0||o===!1||Me(o)&&sr(o)==oe}var jn=jD||xl,BA=Th?xr(Th):Pb;function OA(o){return Me(o)&&o.nodeType===1&&!vs(o)}function IA(o){if(o==null)return!0;if(hr(o)&&(Tt(o)||typeof o=="string"||typeof o.splice=="function"||jn(o)||ji(o)||ci(o)))return!o.length;var u=er(o);if(u==Jt||u==yr)return!o.size;if(ms(o))return!qu(o).length;for(var _ in o)if(ae.call(o,_))return!1;return!0}function TA(o,u){return ps(o,u)}function $A(o,u,_){_=typeof _=="function"?_:e;var D=_?_(o,u):e;return D===e?ps(o,u,e,_):!!D}function pl(o){if(!Me(o))return!1;var u=sr(o);return u==ce||u==Nt||typeof o.message=="string"&&typeof o.name=="string"&&!vs(o)}function LA(o){return typeof o=="number"&&t0(o)}function Dn(o){if(!Ce(o))return!1;var u=sr(o);return u==re||u==qt||u==xt||u==On}function wp(o){return typeof o=="number"&&o==Lt(o)}function sa(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Z}function Ce(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function Me(o){return o!=null&&typeof o=="object"}var Dp=$h?xr($h):kb;function RA(o,u){return o===u||ku(o,u,nl(u))}function PA(o,u,_){return _=typeof _=="function"?_:e,ku(o,u,nl(u),_)}function zA(o){return bp(o)&&o!=+o}function kA(o){if(xx(o))throw new Ot(i);return p0(o)}function qA(o){return o===null}function UA(o){return o==null}function bp(o){return typeof o=="number"||Me(o)&&sr(o)==$e}function vs(o){if(!Me(o)||sr(o)!=ze)return!1;var u=Oo(o);if(u===null)return!0;var _=ae.call(u,"constructor")&&u.constructor;return typeof _=="function"&&_ instanceof _&&Mo.call(_)==PD}var dl=Lh?xr(Lh):qb;function WA(o){return wp(o)&&o>=-Z&&o<=Z}var xp=Rh?xr(Rh):Ub;function oa(o){return typeof o=="string"||!Tt(o)&&Me(o)&&sr(o)==In}function Ar(o){return typeof o=="symbol"||Me(o)&&sr(o)==L}var ji=Ph?xr(Ph):Wb;function jA(o){return o===e}function VA(o){return Me(o)&&er(o)==G}function YA(o){return Me(o)&&sr(o)==nt}var ZA=Ho(Uu),KA=Ho(function(o,u){return o<=u});function Ep(o){if(!o)return[];if(hr(o))return oa(o)?Zr(o):fr(o);if(ss&&o[ss])return CD(o[ss]());var u=er(o),_=u==Jt?Nu:u==yr?Ao:Vi;return _(o)}function bn(o){if(!o)return o===0?o:0;if(o=zr(o),o===K||o===-K){var u=o<0?-1:1;return u*X}return o===o?o:0}function Lt(o){var u=bn(o),_=u%1;return u===u?_?u-_:u:0}function Ap(o){return o?oi(Lt(o),0,ct):0}function zr(o){if(typeof o=="number")return o;if(Ar(o))return Q;if(Ce(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=Ce(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=jh(o);var _=uu.test(o);return _||cu.test(o)?lD(o.slice(2),_?2:8):au.test(o)?Q:+o}function Cp(o){return sn(o,pr(o))}function GA(o){return o?oi(Lt(o),-Z,Z):o===0?o:0}function ie(o){return o==null?"":Er(o)}var HA=qi(function(o,u){if(ms(u)||hr(u)){sn(u,je(u),o);return}for(var _ in u)ae.call(u,_)&&cs(o,_,u[_])}),Fp=qi(function(o,u){sn(u,pr(u),o)}),aa=qi(function(o,u,_,D){sn(u,pr(u),o,D)}),JA=qi(function(o,u,_,D){sn(u,je(u),o,D)}),XA=yn($u);function QA(o,u){var _=ki(o);return u==null?_:s0(_,u)}var tC=Pt(function(o,u){o=pe(o);var _=-1,D=u.length,C=D>2?u[2]:e;for(C&&or(u[0],u[1],C)&&(D=1);++_<D;)for(var I=u[_],P=pr(I),k=-1,V=P.length;++k<V;){var tt=P[k],et=o[tt];(et===e||Gr(et,Ri[tt])&&!ae.call(o,tt))&&(o[tt]=I[tt])}return o}),eC=Pt(function(o){return o.push(e,j0),br(Mp,e,o)});function rC(o,u){return kh(o,At(u,3),nn)}function nC(o,u){return kh(o,At(u,3),Ru)}function iC(o,u){return o==null?o:Lu(o,At(u,3),pr)}function sC(o,u){return o==null?o:c0(o,At(u,3),pr)}function oC(o,u){return o&&nn(o,At(u,3))}function aC(o,u){return o&&Ru(o,At(u,3))}function uC(o){return o==null?[]:Uo(o,je(o))}function lC(o){return o==null?[]:Uo(o,pr(o))}function _l(o,u,_){var D=o==null?e:ai(o,u);return D===e?_:D}function cC(o,u){return o!=null&&Z0(o,u,Ib)}function ml(o,u){return o!=null&&Z0(o,u,Tb)}var fC=z0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),o[u]=_},vl(dr)),hC=z0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),ae.call(o,u)?o[u].push(_):o[u]=[_]},At),pC=Pt(hs);function je(o){return hr(o)?n0(o):qu(o)}function pr(o){return hr(o)?n0(o,!0):jb(o)}function dC(o,u){var _={};return u=At(u,3),nn(o,function(D,C,I){gn(_,u(D,C,I),D)}),_}function _C(o,u){var _={};return u=At(u,3),nn(o,function(D,C,I){gn(_,C,u(D,C,I))}),_}var mC=qi(function(o,u,_){Wo(o,u,_)}),Mp=qi(function(o,u,_,D){Wo(o,u,_,D)}),gC=yn(function(o,u){var _={};if(o==null)return _;var D=!1;u=xe(u,function(I){return I=Un(I,o),D||(D=I.length>1),I}),sn(o,el(o),_),D&&(_=Lr(_,f|d|g,fx));for(var C=u.length;C--;)Zu(_,u[C]);return _});function vC(o,u){return Np(o,ia(At(u)))}var yC=yn(function(o,u){return o==null?{}:Yb(o,u)});function Np(o,u){if(o==null)return{};var _=xe(el(o),function(D){return[D]});return u=At(u),w0(o,_,function(D,C){return u(D,C[0])})}function wC(o,u,_){u=Un(u,o);var D=-1,C=u.length;for(C||(C=1,o=e);++D<C;){var I=o==null?e:o[on(u[D])];I===e&&(D=C,I=_),o=Dn(I)?I.call(o):I}return o}function DC(o,u,_){return o==null?o:ds(o,u,_)}function bC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:ds(o,u,_,D)}var Sp=U0(je),Bp=U0(pr);function xC(o,u,_){var D=Tt(o),C=D||jn(o)||ji(o);if(u=At(u,4),_==null){var I=o&&o.constructor;C?_=D?new I:[]:Ce(o)?_=Dn(I)?ki(Oo(o)):{}:_={}}return(C?Ir:nn)(o,function(P,k,V){return u(_,P,k,V)}),_}function EC(o,u){return o==null?!0:Zu(o,u)}function AC(o,u,_){return o==null?o:A0(o,u,Hu(_))}function CC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:A0(o,u,Hu(_),D)}function Vi(o){return o==null?[]:Mu(o,je(o))}function FC(o){return o==null?[]:Mu(o,pr(o))}function MC(o,u,_){return _===e&&(_=u,u=e),_!==e&&(_=zr(_),_=_===_?_:0),u!==e&&(u=zr(u),u=u===u?u:0),oi(zr(o),u,_)}function NC(o,u,_){return u=bn(u),_===e?(_=u,u=0):_=bn(_),o=zr(o),$b(o,u,_)}function SC(o,u,_){if(_&&typeof _!="boolean"&&or(o,u,_)&&(u=_=e),_===e&&(typeof u=="boolean"?(_=u,u=e):typeof o=="boolean"&&(_=o,o=e)),o===e&&u===e?(o=0,u=1):(o=bn(o),u===e?(u=o,o=0):u=bn(u)),o>u){var D=o;o=u,u=D}if(_||o%1||u%1){var C=e0();return tr(o+C*(u-o+uD("1e-"+((C+"").length-1))),u)}return ju(o,u)}var BC=Ui(function(o,u,_){return u=u.toLowerCase(),o+(_?Op(u):u)});function Op(o){return gl(ie(o).toLowerCase())}function Ip(o){return o=ie(o),o&&o.replace(hu,DD).replace(Xw,"")}function OC(o,u,_){o=ie(o),u=Er(u);var D=o.length;_=_===e?D:oi(Lt(_),0,D);var C=_;return _-=u.length,_>=0&&o.slice(_,C)==u}function IC(o){return o=ie(o),o&&Ya.test(o)?o.replace(vo,bD):o}function TC(o){return o=ie(o),o&&Xa.test(o)?o.replace(rs,"\\$&"):o}var $C=Ui(function(o,u,_){return o+(_?"-":"")+u.toLowerCase()}),LC=Ui(function(o,u,_){return o+(_?" ":"")+u.toLowerCase()}),RC=L0("toLowerCase");function PC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;if(!u||D>=u)return o;var C=(u-D)/2;return Go(Lo(C),_)+o+Go($o(C),_)}function zC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;return u&&D<u?o+Go(u-D,_):o}function kC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;return u&&D<u?Go(u-D,_)+o:o}function qC(o,u,_){return _||u==null?u=0:u&&(u=+u),KD(ie(o).replace(ns,""),u||0)}function UC(o,u,_){return(_?or(o,u,_):u===e)?u=1:u=Lt(u),Vu(ie(o),u)}function WC(){var o=arguments,u=ie(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var jC=Ui(function(o,u,_){return o+(_?"_":"")+u.toLowerCase()});function VC(o,u,_){return _&&typeof _!="number"&&or(o,u,_)&&(u=_=e),_=_===e?ct:_>>>0,_?(o=ie(o),o&&(typeof u=="string"||u!=null&&!dl(u))&&(u=Er(u),!u&&Ti(o))?Wn(Zr(o),0,_):o.split(u,_)):[]}var YC=Ui(function(o,u,_){return o+(_?" ":"")+gl(u)});function ZC(o,u,_){return o=ie(o),_=_==null?0:oi(Lt(_),0,o.length),u=Er(u),o.slice(_,_+u.length)==u}function KC(o,u,_){var D=B.templateSettings;_&&or(o,u,_)&&(u=e),o=ie(o),u=aa({},u,D,W0);var C=aa({},u.imports,D.imports,W0),I=je(C),P=Mu(C,I),k,V,tt=0,et=u.interpolate||Si,ot="__p += '",dt=Su((u.escape||Si).source+"|"+et.source+"|"+(et===yo?ou:Si).source+"|"+(u.evaluate||Si).source+"|$","g"),yt="//# sourceURL="+(ae.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++nD+"]")+`
11
- `;o.replace(dt,function(Ft,Ut,Vt,Cr,ar,Fr){return Vt||(Vt=Cr),ot+=o.slice(tt,Fr).replace(ei,xD),Ut&&(k=!0,ot+=`' +
12
- __e(`+Ut+`) +
13
- '`),ar&&(V=!0,ot+=`';
14
- `+ar+`;
15
- __p += '`),Vt&&(ot+=`' +
16
- ((__t = (`+Vt+`)) == null ? '' : __t) +
17
- '`),tt=Fr+Ft.length,Ft}),ot+=`';
18
- `;var Ct=ae.call(u,"variable")&&u.variable;if(!Ct)ot=`with (obj) {
19
- `+ot+`
20
- }
21
- `;else if(iu.test(Ct))throw new Ot(l);ot=(V?ot.replace(wr,""):ot).replace(Dr,"$1").replace(Tn,"$1;"),ot="function("+(Ct||"obj")+`) {
22
- `+(Ct?"":`obj || (obj = {});
23
- `)+"var __t, __p = ''"+(k?", __e = _.escape":"")+(V?`, __j = Array.prototype.join;
24
- function print() { __p += __j.call(arguments, '') }
25
- `:`;
26
- `)+ot+`return __p
27
- }`;var Rt=$p(function(){return te(I,yt+"return "+ot).apply(e,P)});if(Rt.source=ot,pl(Rt))throw Rt;return Rt}function GC(o){return ie(o).toLowerCase()}function HC(o){return ie(o).toUpperCase()}function JC(o,u,_){if(o=ie(o),o&&(_||u===e))return jh(o);if(!o||!(u=Er(u)))return o;var D=Zr(o),C=Zr(u),I=Vh(D,C),P=Yh(D,C)+1;return Wn(D,I,P).join("")}function XC(o,u,_){if(o=ie(o),o&&(_||u===e))return o.slice(0,Kh(o)+1);if(!o||!(u=Er(u)))return o;var D=Zr(o),C=Yh(D,Zr(u))+1;return Wn(D,0,C).join("")}function QC(o,u,_){if(o=ie(o),o&&(_||u===e))return o.replace(ns,"");if(!o||!(u=Er(u)))return o;var D=Zr(o),C=Vh(D,Zr(u));return Wn(D,C).join("")}function t2(o,u){var _=F,D=O;if(Ce(u)){var C="separator"in u?u.separator:C;_="length"in u?Lt(u.length):_,D="omission"in u?Er(u.omission):D}o=ie(o);var I=o.length;if(Ti(o)){var P=Zr(o);I=P.length}if(_>=I)return o;var k=_-$i(D);if(k<1)return D;var V=P?Wn(P,0,k).join(""):o.slice(0,k);if(C===e)return V+D;if(P&&(k+=V.length-k),dl(C)){if(o.slice(k).search(C)){var tt,et=V;for(C.global||(C=Su(C.source,ie(wo.exec(C))+"g")),C.lastIndex=0;tt=C.exec(et);)var ot=tt.index;V=V.slice(0,ot===e?k:ot)}}else if(o.indexOf(Er(C),k)!=k){var dt=V.lastIndexOf(C);dt>-1&&(V=V.slice(0,dt))}return V+D}function e2(o){return o=ie(o),o&&Va.test(o)?o.replace(ti,SD):o}var r2=Ui(function(o,u,_){return o+(_?" ":"")+u.toUpperCase()}),gl=L0("toUpperCase");function Tp(o,u,_){return o=ie(o),u=_?e:u,u===e?AD(o)?ID(o):mD(o):o.match(u)||[]}var $p=Pt(function(o,u){try{return br(o,e,u)}catch(_){return pl(_)?_:new Ot(_)}}),n2=yn(function(o,u){return Ir(u,function(_){_=on(_),gn(o,_,fl(o[_],o))}),o});function i2(o){var u=o==null?0:o.length,_=At();return o=u?xe(o,function(D){if(typeof D[1]!="function")throw new Tr(a);return[_(D[0]),D[1]]}):[],Pt(function(D){for(var C=-1;++C<u;){var I=o[C];if(br(I[0],this,D))return br(I[1],this,D)}})}function s2(o){return Sb(Lr(o,f))}function vl(o){return function(){return o}}function o2(o,u){return o==null||o!==o?u:o}var a2=P0(),u2=P0(!0);function dr(o){return o}function yl(o){return d0(typeof o=="function"?o:Lr(o,f))}function l2(o){return m0(Lr(o,f))}function c2(o,u){return g0(o,Lr(u,f))}var f2=Pt(function(o,u){return function(_){return hs(_,o,u)}}),h2=Pt(function(o,u){return function(_){return hs(o,_,u)}});function wl(o,u,_){var D=je(u),C=Uo(u,D);_==null&&!(Ce(u)&&(C.length||!D.length))&&(_=u,u=o,o=this,C=Uo(u,je(u)));var I=!(Ce(_)&&"chain"in _)||!!_.chain,P=Dn(o);return Ir(C,function(k){var V=u[k];o[k]=V,P&&(o.prototype[k]=function(){var tt=this.__chain__;if(I||tt){var et=o(this.__wrapped__),ot=et.__actions__=fr(this.__actions__);return ot.push({func:V,args:arguments,thisArg:o}),et.__chain__=tt,et}return V.apply(o,Rn([this.value()],arguments))})}),o}function p2(){return Ge._===this&&(Ge._=zD),this}function Dl(){}function d2(o){return o=Lt(o),Pt(function(u){return v0(u,o)})}var _2=Xu(xe),m2=Xu(zh),g2=Xu(xu);function Lp(o){return sl(o)?Eu(on(o)):Zb(o)}function v2(o){return function(u){return o==null?e:ai(o,u)}}var y2=k0(),w2=k0(!0);function bl(){return[]}function xl(){return!1}function D2(){return{}}function b2(){return""}function x2(){return!0}function E2(o,u){if(o=Lt(o),o<1||o>Z)return[];var _=ct,D=tr(o,ct);u=At(u),o-=ct;for(var C=Fu(D,u);++_<o;)u(_);return C}function A2(o){return Tt(o)?xe(o,on):Ar(o)?[o]:fr(rp(ie(o)))}function C2(o){var u=++RD;return ie(o)+u}var F2=Ko(function(o,u){return o+u},0),M2=Qu("ceil"),N2=Ko(function(o,u){return o/u},1),S2=Qu("floor");function B2(o){return o&&o.length?qo(o,dr,Pu):e}function O2(o,u){return o&&o.length?qo(o,At(u,2),Pu):e}function I2(o){return Uh(o,dr)}function T2(o,u){return Uh(o,At(u,2))}function $2(o){return o&&o.length?qo(o,dr,Uu):e}function L2(o,u){return o&&o.length?qo(o,At(u,2),Uu):e}var R2=Ko(function(o,u){return o*u},1),P2=Qu("round"),z2=Ko(function(o,u){return o-u},0);function k2(o){return o&&o.length?Cu(o,dr):0}function q2(o,u){return o&&o.length?Cu(o,At(u,2)):0}return B.after=lA,B.ary=pp,B.assign=HA,B.assignIn=Fp,B.assignInWith=aa,B.assignWith=JA,B.at=XA,B.before=dp,B.bind=fl,B.bindAll=n2,B.bindKey=_p,B.castArray=DA,B.chain=cp,B.chunk=Sx,B.compact=Bx,B.concat=Ox,B.cond=i2,B.conforms=s2,B.constant=vl,B.countBy=kE,B.create=QA,B.curry=mp,B.curryRight=gp,B.debounce=vp,B.defaults=tC,B.defaultsDeep=eC,B.defer=cA,B.delay=fA,B.difference=Ix,B.differenceBy=Tx,B.differenceWith=$x,B.drop=Lx,B.dropRight=Rx,B.dropRightWhile=Px,B.dropWhile=zx,B.fill=kx,B.filter=UE,B.flatMap=VE,B.flatMapDeep=YE,B.flatMapDepth=ZE,B.flatten=op,B.flattenDeep=qx,B.flattenDepth=Ux,B.flip=hA,B.flow=a2,B.flowRight=u2,B.fromPairs=Wx,B.functions=uC,B.functionsIn=lC,B.groupBy=KE,B.initial=Vx,B.intersection=Yx,B.intersectionBy=Zx,B.intersectionWith=Kx,B.invert=fC,B.invertBy=hC,B.invokeMap=HE,B.iteratee=yl,B.keyBy=JE,B.keys=je,B.keysIn=pr,B.map=ea,B.mapKeys=dC,B.mapValues=_C,B.matches=l2,B.matchesProperty=c2,B.memoize=na,B.merge=mC,B.mergeWith=Mp,B.method=f2,B.methodOf=h2,B.mixin=wl,B.negate=ia,B.nthArg=d2,B.omit=gC,B.omitBy=vC,B.once=pA,B.orderBy=XE,B.over=_2,B.overArgs=dA,B.overEvery=m2,B.overSome=g2,B.partial=hl,B.partialRight=yp,B.partition=QE,B.pick=yC,B.pickBy=Np,B.property=Lp,B.propertyOf=v2,B.pull=Xx,B.pullAll=up,B.pullAllBy=Qx,B.pullAllWith=tE,B.pullAt=eE,B.range=y2,B.rangeRight=w2,B.rearg=_A,B.reject=rA,B.remove=rE,B.rest=mA,B.reverse=ll,B.sampleSize=iA,B.set=DC,B.setWith=bC,B.shuffle=sA,B.slice=nE,B.sortBy=uA,B.sortedUniq=cE,B.sortedUniqBy=fE,B.split=VC,B.spread=gA,B.tail=hE,B.take=pE,B.takeRight=dE,B.takeRightWhile=_E,B.takeWhile=mE,B.tap=BE,B.throttle=vA,B.thru=ta,B.toArray=Ep,B.toPairs=Sp,B.toPairsIn=Bp,B.toPath=A2,B.toPlainObject=Cp,B.transform=xC,B.unary=yA,B.union=gE,B.unionBy=vE,B.unionWith=yE,B.uniq=wE,B.uniqBy=DE,B.uniqWith=bE,B.unset=EC,B.unzip=cl,B.unzipWith=lp,B.update=AC,B.updateWith=CC,B.values=Vi,B.valuesIn=FC,B.without=xE,B.words=Tp,B.wrap=wA,B.xor=EE,B.xorBy=AE,B.xorWith=CE,B.zip=FE,B.zipObject=ME,B.zipObjectDeep=NE,B.zipWith=SE,B.entries=Sp,B.entriesIn=Bp,B.extend=Fp,B.extendWith=aa,wl(B,B),B.add=F2,B.attempt=$p,B.camelCase=BC,B.capitalize=Op,B.ceil=M2,B.clamp=MC,B.clone=bA,B.cloneDeep=EA,B.cloneDeepWith=AA,B.cloneWith=xA,B.conformsTo=CA,B.deburr=Ip,B.defaultTo=o2,B.divide=N2,B.endsWith=OC,B.eq=Gr,B.escape=IC,B.escapeRegExp=TC,B.every=qE,B.find=WE,B.findIndex=ip,B.findKey=rC,B.findLast=jE,B.findLastIndex=sp,B.findLastKey=nC,B.floor=S2,B.forEach=fp,B.forEachRight=hp,B.forIn=iC,B.forInRight=sC,B.forOwn=oC,B.forOwnRight=aC,B.get=_l,B.gt=FA,B.gte=MA,B.has=cC,B.hasIn=ml,B.head=ap,B.identity=dr,B.includes=GE,B.indexOf=jx,B.inRange=NC,B.invoke=pC,B.isArguments=ci,B.isArray=Tt,B.isArrayBuffer=NA,B.isArrayLike=hr,B.isArrayLikeObject=Be,B.isBoolean=SA,B.isBuffer=jn,B.isDate=BA,B.isElement=OA,B.isEmpty=IA,B.isEqual=TA,B.isEqualWith=$A,B.isError=pl,B.isFinite=LA,B.isFunction=Dn,B.isInteger=wp,B.isLength=sa,B.isMap=Dp,B.isMatch=RA,B.isMatchWith=PA,B.isNaN=zA,B.isNative=kA,B.isNil=UA,B.isNull=qA,B.isNumber=bp,B.isObject=Ce,B.isObjectLike=Me,B.isPlainObject=vs,B.isRegExp=dl,B.isSafeInteger=WA,B.isSet=xp,B.isString=oa,B.isSymbol=Ar,B.isTypedArray=ji,B.isUndefined=jA,B.isWeakMap=VA,B.isWeakSet=YA,B.join=Gx,B.kebabCase=$C,B.last=Pr,B.lastIndexOf=Hx,B.lowerCase=LC,B.lowerFirst=RC,B.lt=ZA,B.lte=KA,B.max=B2,B.maxBy=O2,B.mean=I2,B.meanBy=T2,B.min=$2,B.minBy=L2,B.stubArray=bl,B.stubFalse=xl,B.stubObject=D2,B.stubString=b2,B.stubTrue=x2,B.multiply=R2,B.nth=Jx,B.noConflict=p2,B.noop=Dl,B.now=ra,B.pad=PC,B.padEnd=zC,B.padStart=kC,B.parseInt=qC,B.random=SC,B.reduce=tA,B.reduceRight=eA,B.repeat=UC,B.replace=WC,B.result=wC,B.round=P2,B.runInContext=j,B.sample=nA,B.size=oA,B.snakeCase=jC,B.some=aA,B.sortedIndex=iE,B.sortedIndexBy=sE,B.sortedIndexOf=oE,B.sortedLastIndex=aE,B.sortedLastIndexBy=uE,B.sortedLastIndexOf=lE,B.startCase=YC,B.startsWith=ZC,B.subtract=z2,B.sum=k2,B.sumBy=q2,B.template=KC,B.times=E2,B.toFinite=bn,B.toInteger=Lt,B.toLength=Ap,B.toLower=GC,B.toNumber=zr,B.toSafeInteger=GA,B.toString=ie,B.toUpper=HC,B.trim=JC,B.trimEnd=XC,B.trimStart=QC,B.truncate=t2,B.unescape=e2,B.uniqueId=C2,B.upperCase=r2,B.upperFirst=gl,B.each=fp,B.eachRight=hp,B.first=ap,wl(B,function(){var o={};return nn(B,function(u,_){ae.call(B.prototype,_)||(o[_]=u)}),o}(),{chain:!1}),B.VERSION=r,Ir(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){B[o].placeholder=B}),Ir(["drop","take"],function(o,u){jt.prototype[o]=function(_){_=_===e?1:Ue(Lt(_),0);var D=this.__filtered__&&!u?new jt(this):this.clone();return D.__filtered__?D.__takeCount__=tr(_,D.__takeCount__):D.__views__.push({size:tr(_,ct),type:o+(D.__dir__<0?"Right":"")}),D},jt.prototype[o+"Right"]=function(_){return this.reverse()[o](_).reverse()}}),Ir(["filter","map","takeWhile"],function(o,u){var _=u+1,D=_==q||_==z;jt.prototype[o]=function(C){var I=this.clone();return I.__iteratees__.push({iteratee:At(C,3),type:_}),I.__filtered__=I.__filtered__||D,I}}),Ir(["head","last"],function(o,u){var _="take"+(u?"Right":"");jt.prototype[o]=function(){return this[_](1).value()[0]}}),Ir(["initial","tail"],function(o,u){var _="drop"+(u?"":"Right");jt.prototype[o]=function(){return this.__filtered__?new jt(this):this[_](1)}}),jt.prototype.compact=function(){return this.filter(dr)},jt.prototype.find=function(o){return this.filter(o).head()},jt.prototype.findLast=function(o){return this.reverse().find(o)},jt.prototype.invokeMap=Pt(function(o,u){return typeof o=="function"?new jt(this):this.map(function(_){return hs(_,o,u)})}),jt.prototype.reject=function(o){return this.filter(ia(At(o)))},jt.prototype.slice=function(o,u){o=Lt(o);var _=this;return _.__filtered__&&(o>0||u<0)?new jt(_):(o<0?_=_.takeRight(-o):o&&(_=_.drop(o)),u!==e&&(u=Lt(u),_=u<0?_.dropRight(-u):_.take(u-o)),_)},jt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},jt.prototype.toArray=function(){return this.take(ct)},nn(jt.prototype,function(o,u){var _=/^(?:filter|find|map|reject)|While$/.test(u),D=/^(?:head|last)$/.test(u),C=B[D?"take"+(u=="last"?"Right":""):u],I=D||/^find/.test(u);C&&(B.prototype[u]=function(){var P=this.__wrapped__,k=D?[1]:arguments,V=P instanceof jt,tt=k[0],et=V||Tt(P),ot=function(Ut){var Vt=C.apply(B,Rn([Ut],k));return D&&dt?Vt[0]:Vt};et&&_&&typeof tt=="function"&&tt.length!=1&&(V=et=!1);var dt=this.__chain__,yt=!!this.__actions__.length,Ct=I&&!dt,Rt=V&&!yt;if(!I&&et){P=Rt?P:new jt(this);var Ft=o.apply(P,k);return Ft.__actions__.push({func:ta,args:[ot],thisArg:e}),new $r(Ft,dt)}return Ct&&Rt?o.apply(this,k):(Ft=this.thru(ot),Ct?D?Ft.value()[0]:Ft.value():Ft)})}),Ir(["pop","push","shift","sort","splice","unshift"],function(o){var u=Co[o],_=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);B.prototype[o]=function(){var C=arguments;if(D&&!this.__chain__){var I=this.value();return u.apply(Tt(I)?I:[],C)}return this[_](function(P){return u.apply(Tt(P)?P:[],C)})}}),nn(jt.prototype,function(o,u){var _=B[u];if(_){var D=_.name+"";ae.call(zi,D)||(zi[D]=[]),zi[D].push({name:u,func:_})}}),zi[Zo(e,v).name]=[{name:"wrapper",func:e}],jt.prototype.clone=eb,jt.prototype.reverse=rb,jt.prototype.value=nb,B.prototype.at=OE,B.prototype.chain=IE,B.prototype.commit=TE,B.prototype.next=$E,B.prototype.plant=RE,B.prototype.reverse=PE,B.prototype.toJSON=B.prototype.valueOf=B.prototype.value=zE,B.prototype.first=B.prototype.head,ss&&(B.prototype[ss]=LE),B},Li=TD();ri?((ri.exports=Li)._=Li,yu._=Li):Ge._=Li}).call(Yt)}(Vn,Vn.exports);var Xr=Vn.exports;class Pp{constructor(t,e){$(this,"_defaultParams");$(this,"_UserTypeFileds");$(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Xr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Xr.cloneDeep(this._defaultParams),t),this._varipKeys)}addNewMethod(t,e){this._UserTypeFileds.prototype[t]=e}_createDynamicClass(){return class{constructor(t,e){$(this,"_varipKeys");Object.assign(this,t),this._varipKeys=e}get varipKeys(){return[...this._varipKeys]}copy(){return Xr.cloneDeep(this)}}}}var Ml={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){var e=1e3,r=6e4,n=36e5,i="millisecond",a="second",l="minute",c="hour",h="day",p="week",f="month",d="quarter",g="year",y="date",m="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|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,x={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(q){var W=["th","st","nd","rd"],z=q%100;return"["+q+(W[(z-20)%10]||W[z]||W[0])+"]"}},b=function(q,W,z){var K=String(q);return!K||K.length>=W?q:""+Array(W+1-K.length).join(z)+q},N={s:b,z:function(q){var W=-q.utcOffset(),z=Math.abs(W),K=Math.floor(z/60),Z=z%60;return(W<=0?"+":"-")+b(K,2,"0")+":"+b(Z,2,"0")},m:function q(W,z){if(W.date()<z.date())return-q(z,W);var K=12*(z.year()-W.year())+(z.month()-W.month()),Z=W.clone().add(K,f),X=z-Z<0,Q=W.clone().add(K+(X?-1:1),f);return+(-(K+(z-Z)/(X?Z-Q:Q-Z))||0)},a:function(q){return q<0?Math.ceil(q)||0:Math.floor(q)},p:function(q){return{M:f,y:g,w:p,d:h,D:y,h:c,m:l,s:a,ms:i,Q:d}[q]||String(q||"").toLowerCase().replace(/s$/,"")},u:function(q){return q===void 0}},E="en",A={};A[E]=x;var M="$isDayjsObject",S=function(q){return q instanceof R||!(!q||!q[M])},T=function q(W,z,K){var Z;if(!W)return E;if(typeof W=="string"){var X=W.toLowerCase();A[X]&&(Z=X),z&&(A[X]=z,Z=X);var Q=W.split("-");if(!Z&&Q.length>1)return q(Q[0])}else{var ct=W.name;A[ct]=W,Z=ct}return!K&&Z&&(E=Z),Z||!K&&E},F=function(q,W){if(S(q))return q.clone();var z=typeof W=="object"?W:{};return z.date=q,z.args=arguments,new R(z)},O=N;O.l=T,O.i=S,O.w=function(q,W){return F(q,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var R=function(){function q(z){this.$L=T(z.locale,null,!0),this.parse(z),this.$x=this.$x||z.x||{},this[M]=!0}var W=q.prototype;return W.parse=function(z){this.$d=function(K){var Z=K.date,X=K.utc;if(Z===null)return new Date(NaN);if(O.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var Q=Z.match(w);if(Q){var ct=Q[2]-1||0,vt=(Q[7]||"0").substring(0,3);return X?new Date(Date.UTC(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)):new Date(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)}}return new Date(Z)}(z),this.init()},W.init=function(){var z=this.$d;this.$y=z.getFullYear(),this.$M=z.getMonth(),this.$D=z.getDate(),this.$W=z.getDay(),this.$H=z.getHours(),this.$m=z.getMinutes(),this.$s=z.getSeconds(),this.$ms=z.getMilliseconds()},W.$utils=function(){return O},W.isValid=function(){return this.$d.toString()!==m},W.isSame=function(z,K){var Z=F(z);return this.startOf(K)<=Z&&Z<=this.endOf(K)},W.isAfter=function(z,K){return F(z)<this.startOf(K)},W.isBefore=function(z,K){return this.endOf(K)<F(z)},W.$g=function(z,K,Z){return O.u(z)?this[K]:this.set(Z,z)},W.unix=function(){return Math.floor(this.valueOf()/1e3)},W.valueOf=function(){return this.$d.getTime()},W.startOf=function(z,K){var Z=this,X=!!O.u(K)||K,Q=O.p(z),ct=function(It,Nt){var ce=O.w(Z.$u?Date.UTC(Z.$y,Nt,It):new Date(Z.$y,Nt,It),Z);return X?ce:ce.endOf(h)},vt=function(It,Nt){return O.w(Z.toDate()[It].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(Nt)),Z)},lt=this.$W,wt=this.$M,bt=this.$D,Bt="set"+(this.$u?"UTC":"");switch(Q){case g:return X?ct(1,0):ct(31,11);case f:return X?ct(1,wt):ct(0,wt+1);case p:var xt=this.$locale().weekStart||0,oe=(lt<xt?lt+7:lt)-xt;return ct(X?bt-oe:bt+(6-oe),wt);case h:case y:return vt(Bt+"Hours",0);case c:return vt(Bt+"Minutes",1);case l:return vt(Bt+"Seconds",2);case a:return vt(Bt+"Milliseconds",3);default:return this.clone()}},W.endOf=function(z){return this.startOf(z,!1)},W.$set=function(z,K){var Z,X=O.p(z),Q="set"+(this.$u?"UTC":""),ct=(Z={},Z[h]=Q+"Date",Z[y]=Q+"Date",Z[f]=Q+"Month",Z[g]=Q+"FullYear",Z[c]=Q+"Hours",Z[l]=Q+"Minutes",Z[a]=Q+"Seconds",Z[i]=Q+"Milliseconds",Z)[X],vt=X===h?this.$D+(K-this.$W):K;if(X===f||X===g){var lt=this.clone().set(y,1);lt.$d[ct](vt),lt.init(),this.$d=lt.set(y,Math.min(this.$D,lt.daysInMonth())).$d}else ct&&this.$d[ct](vt);return this.init(),this},W.set=function(z,K){return this.clone().$set(z,K)},W.get=function(z){return this[O.p(z)]()},W.add=function(z,K){var Z,X=this;z=Number(z);var Q=O.p(K),ct=function(wt){var bt=F(X);return O.w(bt.date(bt.date()+Math.round(wt*z)),X)};if(Q===f)return this.set(f,this.$M+z);if(Q===g)return this.set(g,this.$y+z);if(Q===h)return ct(1);if(Q===p)return ct(7);var vt=(Z={},Z[l]=r,Z[c]=n,Z[a]=e,Z)[Q]||1,lt=this.$d.getTime()+z*vt;return O.w(lt,this)},W.subtract=function(z,K){return this.add(-1*z,K)},W.format=function(z){var K=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||m;var X=z||"YYYY-MM-DDTHH:mm:ssZ",Q=O.z(this),ct=this.$H,vt=this.$m,lt=this.$M,wt=Z.weekdays,bt=Z.months,Bt=Z.meridiem,xt=function(Nt,ce,re,qt){return Nt&&(Nt[ce]||Nt(K,X))||re[ce].slice(0,qt)},oe=function(Nt){return O.s(ct%12||12,Nt,"0")},It=Bt||function(Nt,ce,re){var qt=Nt<12?"AM":"PM";return re?qt.toLowerCase():qt};return X.replace(v,function(Nt,ce){return ce||function(re){switch(re){case"YY":return String(K.$y).slice(-2);case"YYYY":return O.s(K.$y,4,"0");case"M":return lt+1;case"MM":return O.s(lt+1,2,"0");case"MMM":return xt(Z.monthsShort,lt,bt,3);case"MMMM":return xt(bt,lt);case"D":return K.$D;case"DD":return O.s(K.$D,2,"0");case"d":return String(K.$W);case"dd":return xt(Z.weekdaysMin,K.$W,wt,2);case"ddd":return xt(Z.weekdaysShort,K.$W,wt,3);case"dddd":return wt[K.$W];case"H":return String(ct);case"HH":return O.s(ct,2,"0");case"h":return oe(1);case"hh":return oe(2);case"a":return It(ct,vt,!0);case"A":return It(ct,vt,!1);case"m":return String(vt);case"mm":return O.s(vt,2,"0");case"s":return String(K.$s);case"ss":return O.s(K.$s,2,"0");case"SSS":return O.s(K.$ms,3,"0");case"Z":return Q}return null}(Nt)||Q.replace(":","")})},W.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},W.diff=function(z,K,Z){var X,Q=this,ct=O.p(K),vt=F(z),lt=(vt.utcOffset()-this.utcOffset())*r,wt=this-vt,bt=function(){return O.m(Q,vt)};switch(ct){case g:X=bt()/12;break;case f:X=bt();break;case d:X=bt()/3;break;case p:X=(wt-lt)/6048e5;break;case h:X=(wt-lt)/864e5;break;case c:X=wt/n;break;case l:X=wt/r;break;case a:X=wt/e;break;default:X=wt}return Z?X:O.a(X)},W.daysInMonth=function(){return this.endOf(f).$D},W.$locale=function(){return A[this.$L]},W.locale=function(z,K){if(!z)return this.$L;var Z=this.clone(),X=T(z,K,!0);return X&&(Z.$L=X),Z},W.clone=function(){return O.w(this.$d,this)},W.toDate=function(){return new Date(this.valueOf())},W.toJSON=function(){return this.isValid()?this.toISOString():null},W.toISOString=function(){return this.$d.toISOString()},W.toString=function(){return this.$d.toUTCString()},q}(),U=R.prototype;return F.prototype=U,[["$ms",i],["$s",a],["$m",l],["$H",c],["$W",h],["$M",f],["$y",g],["$D",y]].forEach(function(q){U[q[1]]=function(W){return this.$g(W,q[0],q[1])}}),F.extend=function(q,W){return q.$i||(q(W,R,F),q.$i=!0),F},F.locale=T,F.isDayjs=S,F.unix=function(q){return F(1e3*q)},F.en=A[E],F.Ls=A,F.p={},F})})(Ml);var zp=Ml.exports,ee=Gt(zp),Nl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(i,a,l){var c=a.prototype;l.utc=function(m){var w={date:m,utc:!0,args:arguments};return new a(w)},c.utc=function(m){var w=l(this.toDate(),{locale:this.$L,utc:!0});return m?w.add(this.utcOffset(),e):w},c.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var h=c.parse;c.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),h.call(this,m)};var p=c.init;c.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else p.call(this)};var f=c.utcOffset;c.utcOffset=function(m,w){var v=this.$utils().u;if(v(m))return this.$u?0:v(this.$offset)?f.call(this):this.$offset;if(typeof m=="string"&&(m=function(E){E===void 0&&(E="");var A=E.match(r);if(!A)return null;var M=(""+A[0]).match(n)||["-",0,0],S=M[0],T=60*+M[1]+ +M[2];return T===0?0:S==="+"?T:-T}(m),m===null))return this;var x=Math.abs(m)<=16?60*m:m,b=this;if(w)return b.$offset=x,b.$u=m===0,b;if(m!==0){var N=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(x+N,e)).$offset=x,b.$x.$localOffset=N}else b=this.utc();return b};var d=c.format;c.format=function(m){var w=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return d.call(this,w)},c.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},c.isUTC=function(){return!!this.$u},c.toISOString=function(){return this.toDate().toISOString()},c.toString=function(){return this.toDate().toUTCString()};var g=c.toDate;c.toDate=function(m){return m==="s"&&this.$offset?l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var y=c.diff;c.diff=function(m,w,v){if(m&&this.$u===m.$u)return y.call(this,m,w,v);var x=this.local(),b=l(m).local();return y.call(x,b,w,v)}}})})(Nl);var kp=Nl.exports,Sl=Gt(kp),Bl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,i,a){var l,c=function(d,g,y){y===void 0&&(y={});var m=new Date(d),w=function(v,x){x===void 0&&(x={});var b=x.timeZoneName||"short",N=v+"|"+b,E=r[N];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:v,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:b}),r[N]=E),E}(g,y);return w.formatToParts(m)},h=function(d,g){for(var y=c(d,g),m=[],w=0;w<y.length;w+=1){var v=y[w],x=v.type,b=v.value,N=e[x];N>=0&&(m[N]=parseInt(b,10))}var E=m[3],A=E===24?0:E,M=m[0]+"-"+m[1]+"-"+m[2]+" "+A+":"+m[4]+":"+m[5]+":000",S=+d;return(a.utc(M).valueOf()-(S-=S%1e3))/6e4},p=i.prototype;p.tz=function(d,g){d===void 0&&(d=l);var y=this.utcOffset(),m=this.toDate(),w=m.toLocaleString("en-US",{timeZone:d}),v=Math.round((m-new Date(w))/1e3/60),x=a(w,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-v,!0);if(g){var b=x.utcOffset();x=x.add(y-b,"minute")}return x.$x.$timezone=d,x},p.offsetName=function(d){var g=this.$x.$timezone||a.tz.guess(),y=c(this.valueOf(),g,{timeZoneName:d}).find(function(m){return m.type.toLowerCase()==="timezonename"});return y&&y.value};var f=p.startOf;p.startOf=function(d,g){if(!this.$x||!this.$x.$timezone)return f.call(this,d,g);var y=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return f.call(y,d,g).tz(this.$x.$timezone,!0)},a.tz=function(d,g,y){var m=y&&g,w=y||g||l,v=h(+a(),w);if(typeof d!="string")return a(d).tz(w);var x=function(A,M,S){var T=A-60*M*1e3,F=h(T,S);if(M===F)return[T,M];var O=h(T-=60*(F-M)*1e3,S);return F===O?[T,F]:[A-60*Math.min(F,O)*1e3,Math.max(F,O)]}(a.utc(d,m).valueOf(),v,w),b=x[0],N=x[1],E=a(b).utcOffset(N);return E.$x.$timezone=w,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(d){l=d}}})})(Bl);var qp=Bl.exports,Up=Gt(qp),Ol={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){var e="week",r="year";return function(n,i,a){var l=i.prototype;l.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var h=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var p=a(this).startOf(r).add(1,r).date(h),f=a(this).endOf(e);if(p.isBefore(f))return 1}var d=a(this).startOf(r).date(h).startOf(e).subtract(1,"millisecond"),g=this.diff(d,e,!0);return g<0?a(this).startOf("week").week():Math.ceil(g)},l.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(Ol);var Wp=Ol.exports,jp=Gt(Wp);function Ve(s,t){return s.replace(/\$(\w+)/g,(e,r)=>String(t[r])||e)}function ys(s){const t=parseInt(s)||1;let e=s.replace(/\d+/,"");return e==="m"||e==="M"?e="M":e?e=e.toLocaleLowerCase():e="m",[t,e]}function Vp(s){const t=/([+-])(\d{1,2})(\d{0,2})/,e=s.replace(/GMT|UTC/,"").match(t);if(!e)throw new Error("Invalid timezone string");const[,r,n,i]=e,a=parseInt(n,10)*60||0,l=parseInt(i,10)||0;return(r==="+"?-1:1)*(a+l)}function kr(s,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?ee(s).utcOffset(Vp(t)):ee(s).tz(t)}function Qr(s){const[t,e]=ys(s);let r=0;switch(e){case"m":r=60;break;case"s":r=1;break;case"M":r=31*24*60*60;break;case"d":r=24*60*60;break;case"w":r=7*24*60*60;break;default:r=60*60;break}return Math.round(Number(t)*r)}function _t(s){return typeof s!="number"||isNaN(s)}function me(s,t){for(const e of t)s!=null&&s.hasOwnProperty(e)&&s[e]===void 0&&(s[e]=null)}function Il(s){var t=atob(s),e=decodeURI(t);return e}function Tl(s,t){if(!String(s).includes("."))return s;const e=Math.pow(10,t);return Math.floor(s*e)/e}var Fe=(s=>(s.BOOL="bool",s.INT="int",s.FLOAT="float",s.ARRAY="array",s.BOX="box",s.CHART_POINT="chart.point",s.COLOR="color",s.CONST="const",s.LABEL="label",s.LINE="line",s.LINEFILL="linefill",s.MAP="map",s.MATRIX="matrix",s.POLYLINE="polyline",s.SERIES="series",s.SIMPLE="simple",s.STRING="string",s.TABLE="table",s.UNDETERMINED="undetermined type",s.INPUT="input",s.NA="na",s.VOID="void",s.ENUM="enum",s))(Fe||{}),ws=(s=>(s.dividends="dividends",s.none="none",s.splits="splits",s))(ws||{}),qr=(s=>(s.freqAll="freq_all",s.freqOncePerBar="freq_once_per_bar",s.freqOncePerBarClose="freq_once_per_bar_close",s))(qr||{}),Yi=(s=>(s.gapsOff="gaps_off",s.gapsOn="gaps_on",s.lookaheadOff="lookahead_off",s.lookaheadOn="lookahead_on",s))(Yi||{}),Ye=(s=>(s.all="all",s.dataWindow="data_window",s.none="none",s.pane="pane",s.priceScale="price_scale",s.statusLine="status_line",s))(Ye||{}),Ur=(s=>(s.both="both",s.left="left",s.none="none",s.right="right",s))(Ur||{}),Kt=(s=>(s.inherit="inherit",s.mintick="mintick",s.percent="percent",s.price="price",s.volume="volume",s))(Kt||{}),Ds=(s=>(s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(Ds||{}),ge=(s=>(s.styleArrowdown="style_arrowdown",s.styleArrowup="style_arrowup",s.styleCircle="style_circle",s.styleCross="style_cross",s.styleDiamond="style_diamond",s.styleFlag="style_flag",s.styleLabelCenter="style_label_center",s.styleLabelDown="style_label_down",s.styleLabelLeft="style_label_left",s.styleLabelLowerLeft="style_label_lower_left",s.styleLabelLowerRight="style_label_lower_right",s.styleLabelRight="style_label_right",s.styleLabelUp="style_label_up",s.styleLabelUpperLeft="style_label_upper_left",s.styleLabelUpperRight="style_label_upper_right",s.styleNone="style_none",s.styleSquare="style_square",s.styleTextOutline="style_text_outline",s.styleTriangledown="style_triangledown",s.styleTriangleup="style_triangleup",s.styleXcross="style_xcross",s))(ge||{}),Le=(s=>(s.styleArrowBoth="style_arrow_both",s.styleArrowLeft="style_arrow_left",s.styleArrowRight="style_arrow_right",s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(Le||{}),an=(s=>(s.abovebar="abovebar",s.absolute="absolute",s.belowbar="belowbar",s.bottom="bottom",s.top="top",s))(an||{}),Yn=(s=>(s.ascending="ascending",s.descending="descending",s))(Yn||{}),Mr=(s=>(s.styleArea="Area",s.styleAreabr="Area With Breaks",s.styleCircles="Circles",s.styleColumns="Columns",s.styleCross="Cross",s.styleHistogram="Histogram",s.styleLine="Line",s.styleLinebr="Line With Breaks",s.styleStepline="Step Line",s.styleSteplineDiamond="Step Line With Diamonds",s.styleSteplinebr="Step line with Breaks",s))(Mr||{}),_r=(s=>(s.bottomCenter="bottom_center",s.bottomLeft="bottom_left",s.bottomRight="bottom_right",s.middleCenter="middle_center",s.middleLeft="middle_left",s.middleRight="middle_right",s.topCenter="top_center",s.topLeft="top_left",s.topRight="top_right",s))(_r||{}),bs=(s=>(s.left="left",s.none="none",s.right="right",s))(bs||{}),fi=(s=>(s.extended="extended",s.regular="regular",s))(fi||{}),ur=(s=>(s.arrowdown="arrowdown",s.arrowup="arrowup",s.circle="circle",s.cross="cross",s.diamond="diamond",s.flag="flag",s.labeldown="labeldown",s.labelup="labelup",s.square="square",s.triangledown="triangledown",s.triangleup="triangleup",s.xcross="xcross",s))(ur||{}),rr=(s=>(s.auto="auto",s.huge="huge",s.large="large",s.normal="normal",s.small="small",s.tiny="tiny",s))(rr||{}),Zn=(s=>(s.familyDefault="default",s.familyMonospace="monospace",s))(Zn||{}),Re=(s=>(s.cash="cash",s.fixed="fixed",s.percentOfEquity="percent_of_equity",s))(Re||{}),nr=(s=>(s.cashPerContract="cash_per_contract",s.cashPerOrder="cash_per_order",s.percent="percent",s))(nr||{}),ue=(s=>(s.all="all",s.long="long",s.short="short",s))(ue||{}),un=(s=>(s.cancel="cancel",s.none="none",s.reduce="reduce",s))(un||{}),Wt=(s=>(s.alignBottom="align_bottom",s.alignCenter="align_center",s.alignLeft="align_left",s.alignRight="align_right",s.alignTop="align_top",s.wrapAuto="wrap_auto",s.wrapNone="wrap_none",s))(Wt||{}),we=(s=>(s.bar_index="bar_index",s.bar_time="bar_time",s))(we||{}),Wr=(s=>(s.abovebar="abovebar",s.belowbar="belowbar",s.price="price",s))(Wr||{}),xs=(s=>(s.actual="actual",s.estimate="estimate",s.standardized="standardized",s))(xs||{}),Kn=(s=>(s.traditional="Traditional",s.fibonacci="Fibonacci",s.woodie="Woodie",s.classic="Classic",s.dm="DM",s.camarilla="Camarilla",s))(Kn||{}),ir=(s=>(s.INT="int",s.BOOL="bool",s.TIME="time",s.COLOR="color",s.FLOAT="float",s.PRICE="price",s.SOURCE="source",s.STRING="string",s.SYMBOL="symbol",s.SESSION="session",s.TEXT_AREA="text_area",s.TIMEFRAME="timeframe",s.ENUM="enum",s))(ir||{}),zt=(s=>(s[s.Hint=1]="Hint",s[s.Info=2]="Info",s[s.Warning=4]="Warning",s[s.Error=8]="Error",s))(zt||{});const le={onlyInLoop:"'$text' is only allowed inside loops",invalidType:"Invalid argument 'expr$index' in 'operator SQBR' call",typeUseError:"Cannot specify a type form '$text' without also specifying the type.",notTypeKeyword:"'$text' is not a valid type keyword in variable declaration",undeclared:"Undeclared identifier '$name'",repeatVar:"'$name' is already defined",typeRepeatErr:"$keyword '$name' is already defined.",typeMismatch:"Cannot call '$operator' with argument '$index'. An argument of '$typeE' type was used but a '$typeR' is expected.",assignTypeMismatch:"Cannot assign a value of the `$typeE` type to the '$name' variable. The variable is declared with the `$typeR` type.",voidNotVar:"Void expression cannot be assigned to a variable",declareTypeErr:"Declared type '$type' is not compatible with assigned type '$valueType'",mapKeyValErr:"Cannot put <$typeA, $typeB> pairs into a map containing `$typeC` keys and `$typeD` values. The maps passed into the `$name()` function must have the same key types and value types.",inputSourceErr:"Invalid value for the '$name' parameter of the '$funcName' function. Possible values: [open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume].",buildInUseErr:"Cannot use '$name' as the default value of a type's field. The default value cannot be a function, variable or calculation.",argsLenErr:"Too many arguments passed into the `$name()` function call. Passed $lenA arguments but expected $lenB.",requiredParamErr:"No value assigned to the `$argName` parameter in $name()",argsSyntaxErr:"Syntax error after the argument for `$argName`. Arguments without their parameter name cannot be used after arguments with parameter names.",requestArgsErr:"Type $type cannot be used in $name '$argName' argument",mapKeyErr:"Incorrect `key` type `$type` in the variable. The `key` type must be one of the following: int, float, string, bool, color.",templateErr:"Incorrect number of arguments for the template: $countA expected, $countB passed.",templateNoSupportErr:"The '$name()' function does not support templates",ifOrSwitchTypeErr:"Return type of one of the '$keyword' blocks is not compatible with return type of other block(s) ($types)",argsNameErr:"The '$name' function does not have an argument with the name '$argName'",noFiledErr:"Object has no field $name",methodNotExistErr:"Could not find method or method reference '$methodName' for '$name'",tupleVarErr:"Syntax error: The quantities of tuple elements on each side of the assignment operator do not match. The right side has $indexA but the left side has $indexB.",tupleLeftVarErr:"Invalid assignment. Cannot assign a tuple to a variable '$name'.",tupleRightVarErr:"Cannot assign a variable to a tuple. The right side must be a function call or structure ('if', 'switch', 'for', 'while') returning a tuple with the same number of elements.",tempateTypeErr:"Syntax error: Only templates for arrays and matrices consist of a single type identifier enclosed in angle brackets.",qualifierErr:"'$name' is not a valid type qualifier. Possible values: 'const', 'simple', 'series'",notFindFuncErr:"Could not find function or function reference '$name'",naVarErr:"Value with NA type cannot be assigned to a variable that was defined without type keyword",notHistoryErr:"Variable '$name' doesn't have history values",defaultValueErr:"The default value cannot be a function, variable or calculation.",defaultValueTypeErr:"Default value of type $typeE can not be assigned to an argument of type $typeR",typeFieldErr:"In a type declaration, all fields without a default value must be explicitly typified.",unaryErr:"Syntax error at input '$sign'",funcArgAssignErr:"Function arguments cannot be mutable ('$name')",declaredErr:"A variable declared with the '$prefix' keyword cannot accept values of the '$type' form. Assign a '$prefix' value to this variable or remove the '$prefix' keyword from its declaration.",globalFuncErr:"Cannot use '$name' in local scope",onlyStatementErr:"Scripts must contain one declaration statement: `indicator()`, `strategy()` or `library()`, Your script has $count.",modifyGlobalVarErr:"Cannot modify global variable '$name' in function",inputDefvalErr:"Arguments of input function must be of constant type, or 'source' builtin variables.",objectIsNaErr:"Cannot access the '$name' $type of an na object. The object is 'na'.",buidinAssignErr:"Cannot assign a new value to the built-in variable '$name'.",buidinVarErr:"Cannot shadow the built-in variable `$name` because it has already been used as a built-in.",useNaErr:"Cannot use an `na` value of an unspecified type in the `$name` function.",libraryTitleErr:"Invalid argument 'title' in 'library' call. It cannot contain spaces, special characters or begin with a digit.",exportFuncArgErr:"All exported functions args should be typified",indiRunErr:"An indicator must contain at least one of the following: any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, `alertcondition()`, or any drawing (line, label, box, table, polyline).",libraryExportErr:"A library must contain at least one exported function, method, or type.",strategyRunErr:"A strategy must contain at least one of the following: any `strategy.*()` function that creates orders, any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, or any drawing (line, label, box, table, polyline).",exportUseErr:"Only libraries can contain exported $type.",funcRepeatErr:"The '$name' function has overloads with the same parameters. The type of parameters must be different in overloaded versions of functions.",importMultipleErr:"Cannot import a library more than once",importNotExitErr:"The user '$username' does not have a published library titled '$libraryName'",importNameRepeatErr:"More than one import uses the same alias: $name. Previous usage at line: $line",exportFuncHasInputErr:"The exported function '$func' depends on the '$name' input variable, which is not allowed.",libraryTitleIsKeywordErr:"Invalid argument 'title' in 'library' call. Token: '$name' can't be used as library title.",exportFuncUseGlobalVarErr:"Cannot use global variables in exported functions. Function: $func",loopRuntimeErr:"Loop takes too long to execute (> 500 ms)",paramsErr:"Invalid value '$value' for '$param' parameter of the '$func' function. Possible values: $targetVal",displayErr:"Invalid argument 'display' in '$func' call. Possible values: $values",exportFuncUseReqErr:"Cannot use `request.*()` call in exported function `$name()`",requestExprErr:"Type series $type cannot be used in $name 'expression' argument",argDefaultErr:"The default value assigned to a parameter must be either a literal value (e.g., `5`) or a built-in variable (e.g., `close`)",overloadFuncErr:"Cannot use global variables or any values qualified as 'input' in the local scopes of overloaded functions or methods. Remove any global variables or inputs from the scopes of all '$name()' overloads.",againAssignErr:"Unable to determine the object for the field assignment. Try putting the object into a separate variable before assigning values to its fields.",requestUserInLoopErr:"Cannot use `request.*()` call within loops or conditional structures.",enumVarNameErr:"Invalid enum name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumVarNameBuiltinErr:"Invalid object name: $name. Namespaces of built-ins cannot be used.",typeNameErr:"Invalid user-defined type name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumUseErr:"Cannot use the '$name' as a value. Use one of the enum's fields instead.",conditionalErr:"'$name' conditional expression must be of a bool type!",fortoErr:'The value of the "for" loop must be a number.',indicatorUseStrategyFuncErr:"You cannot use strategy $type ($name) in indicator script.",arrEmptyErr:"Array must not be empty",arrLengthDiffErr:"Arrays have different lengths",arrTypeErr:"数组类型错误,array.$name方法只能使用$type类型数组!",inputOptErr:"input's defval should be in options, but '$defval' is not in [$args]",mathRandomErr:"min must be less than max",matrixRehapeErr:"New matrix must be of same area as original matrix",strategyExitErr:"strategy.exit must have at least one of the following parameters: 'profit', 'limit', 'loss', 'stop' or one of the following pairs: 'trail_offset' and 'trail_price' / 'trail_points'. To close the position at market price, use 'strategy.close'",arrLenErr:"Invalid array length",mergeCellErr:"error: start_column > end_column or start_row > end_row"},Yp={repeatVar:"Shadowing variable '$name' which exists in parent scope. Did you want to use the ':=' operator instead of '=' ?",typeMismatch:"The `$index` parameter of the `$operator` function accepts a '$type' argument. To avoid potential unexpected results, pass a '$type' value or expression to this parameter.",moreSameArg:"More than one '$arg' arguments are supplied. Only the first one will be used.",localScopeGetHistory:"The variable '$name' is declared in local scope, which may not be executed at every update. So, obtaining its historical values may lead to unexpected results",localScopeWarning:"The function '$name' should be called on each calculation for consistency. It is recommended to extract the call from this scope",strategyCalcTickWarn:"Strategies without `calc_on_every_tick = true` only calculate on confirmed chart bars. In this case, `barstate.islast` may not initially return `true` on realtime bars, as the last bar is unconfirmed until it closes. If you need to check whether a bar is the latest before it closes, enable `calc_on_every_tick` in the `strategy()` function.",conditionWarning:"The `condition` parameter of the `$name` accepts a 'bool' argument. To avoid potential unexpected results, pass a 'bool' value or expression to this parameter.",lineWidthWarning:"Passing a value below 1 to `linewidth` will be replaced with 1 during compilation.",boolVarNumWarning:"The `$name` variable casts a numeric value to the 'bool' type. To avoid potential unexpected results, assign a 'bool' value to this variable."};Fe.SERIES,Fe.SIMPLE,Fe.INPUT,Fe.CONST,Fe.INT,Fe.FLOAT,Fe.BOOL,Fe.COLOR,Fe.STRING;const Zp=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],Kp=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],Gp=["linefill","polyline","matrix","series","simple","string","array","color","const","float","label","table","bool","line","box","int","map","continue","for","varip","var","in","export","import","method","switch","break","while","else","type","and","for","not","as","by","if","in","or","to"];class Hp{constructor(t){$(this,"_errorListener");this._errorListener=t}new({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_float({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_int({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_color({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_bool({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_string({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_line({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_box({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_table({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_linefill({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_label({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}slice({id:t,index_from:e,index_to:r}){return t==null?void 0:t.slice({index_from:e,index_to:r})}size({id:t}){return t==null?void 0:t.size()}first({id:t}){return t==null?void 0:t.first()}abs({id:t},e){return t==null?void 0:t.abs(e)}avg({id:t},e){return t==null?void 0:t.avg(e)}binary_search({id:t,val:e},r){return t==null?void 0:t.binary_search({val:e},r)}binary_search_leftmost({id:t,val:e},r){return t==null?void 0:t.binary_search_leftmost({val:e},r)}binary_search_rightmost({id:t,val:e},r){return t==null?void 0:t.binary_search_rightmost({val:e},r)}clear({id:t}){t==null||t.clear()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}covariance({id1:t,id2:e,biased:r},n){return t==null?void 0:t.covariance({id2:e,biased:r},n)}every({id:t},e){return t==null?void 0:t.every(e)}from(t,e){const r=new Qt(0,void 0,this._errorListener);return r._value=e,r}fill({id:t,value:e,index_from:r,index_to:n}){t==null||t.fill({value:e,index_from:r,index_to:n})}get({id:t,index:e}){return t==null?void 0:t.get({index:e})}includes({id:t,value:e}){return t==null?void 0:t.includes({value:e})}indexof({id:t,value:e}){return t==null?void 0:t.indexof({value:e})}insert({id:t,index:e,value:r}){t==null||t.insert({index:e,value:r})}join({id:t,separator:e},r){return t==null?void 0:t.join({separator:e},r)}last({id:t}){return t==null?void 0:t.last()}lastindexof({id:t,value:e}){return t==null?void 0:t.lastindexof({value:e})}max({id:t,nth:e},r){return t==null?void 0:t.max({nth:e},r)}median({id:t},e){return t==null?void 0:t.median(e)}min({id:t,nth:e},r){return t==null?void 0:t.min({nth:e},r)}mode({id:t},e){return t==null?void 0:t.mode(e)}percentile_linear_interpolation({id:t,percentage:e},r){return t==null?void 0:t.percentile_linear_interpolation({percentage:e},r)}percentile_nearest_rank({id:t,percentage:e},r){return t==null?void 0:t.percentile_nearest_rank({percentage:e},r)}percentrank({id:t,index:e},r){return t==null?void 0:t.percentrank({index:e},r)}pop({id:t}){return t==null?void 0:t.pop()}push({id:t,value:e}){t==null||t.push({value:e})}range({id:t},e){return t==null?void 0:t.range(e)}remove({id:t,index:e}){return t==null?void 0:t.remove({index:e})}reverse({id:t}){return t==null?void 0:t.reverse()}set({id:t,index:e,value:r}){t==null||t.set({index:e,value:r})}shift({id:t}){return t==null?void 0:t.shift()}some({id:t},e){return t==null?void 0:t.some(e)}sort({id:t,order:e},r){t==null||t.sort({order:e},r)}sort_indices({id:t,order:e},r){return t==null?void 0:t.sort_indices({order:e},r)}standardize({id:t},e){return t==null?void 0:t.standardize(e)}stdev({id:t,biased:e},r){return t==null?void 0:t.stdev({biased:e},r)}sum({id:t},e){return t==null?void 0:t.sum(e)}unshift({id:t,value:e}){t==null||t.unshift({value:e})}variance({id:t,biased:e},r){return t==null?void 0:t.variance({biased:e},r)}}class Qt{constructor(t=0,e,r){$(this,"_arrInstance");$(this,"_errorListener");this._errorListener=r,this._arrInstance=Array.from(new Array(t||0),()=>Xr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Xr.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new Qt(0,void 0,this._errorListener);return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new Qt(0,void 0,this._errorListener);return r._copyData(this._arrInstance.slice(t,e)),r}size(){return this._arrInstance.length}first(){return this._arrInstance[0]}abs(t){const e=new Qt(0,void 0,this._errorListener);this._verifySimpleType("number","abs","int/float",t);const r=this._arrInstance.map(n=>Math.abs(n));return e._copyData(r),e}avg(t){return this._verifySimpleType("number","avg","int/float",t),Xr.mean(this._arrInstance)}binary_search({val:t},e){return this._verifySimpleType("number","binary_search","int/float",e),_t(t)?-1:this._binarySearch(this._arrInstance,t)}binary_search_leftmost({val:t},e){return this._verifySimpleType("number","binary_search_leftmost","int/float",e),_t(t)?this._arrInstance.length-1:this._binarySearchLeftMost(this._arrInstance,t)}binary_search_rightmost({val:t},e){return this._verifySimpleType("number","binary_search_rightmost","int/float",e),_t(t)?this._arrInstance.length:this._binarySearchRightMost(this._arrInstance,t)}clear(){this._arrInstance=[]}concat({id2:t}){return this._arrInstance=this._arrInstance.concat(t==null?void 0:t._value),this}covariance({id2:t,biased:e},r){return this._verifySimpleType("number","covariance","int/float",r),this._verifySimpleType("number","covariance","int/float",r,t==null?void 0:t._value),this._covariance(this._arrInstance,t._value,e,r)}every(t){return this._verifySimpleType("number|boolean","every","int/float/bool",t),this._arrInstance.every(e=>!!e)}fill({value:t,index_from:e=0,index_to:r}){this._arrInstance=this._setElements(this._arrInstance,t,e,r)}get({index:t}){if(!_t(t))return this._arrInstance[t]}includes({value:t}){return this._arrInstance.includes(t)}indexof({value:t}){return this._arrInstance.indexOf(t)}insert({index:t,value:e}){_t(t)||this._arrInstance.splice(t,0,e)}join({separator:t}={},e){return this._verifySimpleType("number|string","join","int/float/string",e),this._arrInstance.join(t)}last(){return this._arrInstance[this._arrInstance.length-1]}lastindexof({value:t}){return this._arrInstance.lastIndexOf(t)}max({nth:t}={},e){return this._verifySimpleType("number","max","int/float",e),this._maxNth([...this._arrInstance],t)}median(t){return this._verifySimpleType("number","median","int/float",t),this._median([...this._arrInstance])}min({nth:t}={},e){return this._verifySimpleType("number","min","int/float",e),this._minNth([...this._arrInstance],t)}mode(t){return this._verifySimpleType("number","mode","int/float",t),this._mode([...this._arrInstance])}percentile_linear_interpolation({percentage:t},e){return this._verifySimpleType("number","percentile_linear_interpolation","int/float",e),this._percentileLinearInterpolation([...this._arrInstance],t)}percentile_nearest_rank({percentage:t=0},e){var r;if(this._arrInstance.length===0||t<0||t>100||_t(t)){(r=this._errorListener)==null||r.addError("Invalid percentile or empty array",e,zt.Error);return}return this._verifySimpleType("number","percentile_nearest_rank","int/float",e),this._getNearestRankPercentile([...this._arrInstance],t)}percentrank({index:t},e){return this._verifySimpleType("number","percentrank","int/float",e),this._getPercentileRank([...this._arrInstance],t)}pop(){return this._arrInstance.pop()}push({value:t}){this._arrInstance.push(t)}range(t){var i;if(this._arrInstance.length===0){(i=this._errorListener)==null||i.addError(le.arrEmptyErr,t,zt.Error);return}this._verifySimpleType("number","range","int/float",t);const e=Math.min(...this._arrInstance);return Math.max(...this._arrInstance)-e}remove({index:t}){if(!_t(t))return this._arrInstance.splice(t,1)[0]}reverse(){this._arrInstance.reverse()}set({index:t,value:e}){_t(t)||(this._arrInstance[t]=e)}shift(){return this._arrInstance.shift()}some(t){return this._verifySimpleType("number|boolean","some","int/float/bool",t),this._arrInstance.some(e=>!!e)}sort({order:t}={},e){this._verifySimpleType("number","sort","int/float",e),this._arrInstance.sort((r,n)=>t!==Yn.descending?r-n:n-r)}sort_indices({order:t}={},e){this._verifySimpleType("number","sort_indices","int/float",e);const r=this._arrInstance.map((i,a)=>a);r.sort((i,a)=>t!==Yn.descending?this._arrInstance[i]-this._arrInstance[a]:this._arrInstance[a]-this._arrInstance[i]);const n=new Qt(0,void 0,this._errorListener);return n._copyData(r),n}standardize(t){this._verifySimpleType("number","standardize","int/float",t);const e=new Qt(0,void 0,this._errorListener);return e._copyData(this._standardizeArray([...this._arrInstance])),e}stdev({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(le.arrEmptyErr,e,zt.Error);return}return this._verifySimpleType("number","stdev","int/float",e),this._calculateStandardDeviations([...this._arrInstance],t)}sum(t){return this._verifySimpleType("number","sum","int/float",t),this._arrInstance.reduce((r,n)=>r+(n||0),0)}unshift({value:t}){this._arrInstance.unshift(t)}variance({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(le.arrEmptyErr,e,zt.Error);return}return this._verifySimpleType("number","variance","int/float",e),this._calculateVariances([...this._arrInstance],t)}_calculateVariances(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>a+((l||0)-r)**2,0),i=n/t.length;return e?i:t.length>1?n/(t.length-1):i}_calculateStandardDeviations(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>{const c=(l||0)-r;return a+c*c},0),i=Math.sqrt(n/t.length);return e?i:t.length>1?Math.sqrt(n/(t.length-1)):i}_standardizeArray(t){const e=t.reduce((i,a)=>i+(a||0),0)/t.length,r=Math.sqrt(t.reduce((i,a)=>i+Math.pow((a||0)-e,2),0)/t.length);return t.map(i=>((i||0)-e)/r)}_getPercentileRank(t,e=0){if(_t(e))return;const r=t[e];let n=0;for(let a=0;a<t.length;a++)(t[a]<r||t[a]===r&&a!=e)&&n++;return n/(t.length-1)*100}_getNearestRankPercentile(t,e=0){const r=t.slice().sort((a,l)=>a-l),n=e/100*r.length,i=Math.ceil(n)-1;return r[i>=r.length?r.length-1:i]}_percentileLinearInterpolation(t,e=0){if(e<0||e>100||_t(e))return;t.sort(function(i,a){return i-a});const r=t.length;e/=100;const n=1/(r*2);if(e<=n)return t[0];if(e>=1-1/(r*2))return t[r-1];for(const[i,a]of t.entries()){const l=t[i-1];if(e<(i+.5)/r)return l+(a-l)*(e-(i-.5)/r)/(1/r)}}_mode(t){const e={};let r=0;const n=[];for(const i of t)e[i]=(e[i]||0)+1,r=Math.max(r,e[i]);for(const i in e)e[i]===r&&n.push(Number(i));return Math.min(...r===1?t:n)}_median(t){t.sort(function(r,n){return r-n});const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}_minNth(t,e=0){return t.sort(function(r,n){return r-n}),t[e]}_maxNth(t,e=0){return t.sort(function(r,n){return n-r}),t[e]}_setElements(t,e,r=0,n){n===void 0&&(n=t.length);for(let i=r;i<n;i++)t[i]=e;return t}_covariance(t,e,r=!0,n){var c;if(t.length!=e.length){(c=this._errorListener)==null||c.addError(le.arrLengthDiffErr,n,zt.Error);return}t=t.filter(h=>h!==void 0),e=e.filter(h=>h!==void 0);const i=t.reduce((h,p)=>h+p,0)/t.length,a=e.reduce((h,p)=>h+p,0)/e.length;let l=0;for(let h=0;h<t.length;h++)l+=(t[h]-i)*(e[h]-a);return r?l/t.length:l/(t.length-1)}_verifySimpleType(t,e,r,n,i=this._arrInstance){var l;i.filter(c=>c!==void 0).some(c=>!t.split("|").includes(typeof c))&&((l=this._errorListener)==null||l.addError(Ve(le.arrTypeErr,{name:e,type:r}),n,zt.Error))}_binarySearch(t,e){let r=0,n=t.length-1;for(;r<=n;){const i=Math.floor((r+n)/2);if(t[i]===e)return i;t[i]<e?r=i+1:n=i-1}return-1}_binarySearchLeftMost(t,e){let r=0,n=t.length-1;const i=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&i.push(a),t[a]<e?r=a+1:n=a-1}return i.length?Math.min(...i):r-1}_binarySearchRightMost(t,e){let r=0,n=t.length-1;const i=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&i.push(a),t[a]<=e?r=a+1:n=a-1}return i.length?Math.max(...i):r}}class Jp{constructor(t,e){$(this,"_randomNums");$(this,"_mintick");$(this,"_cacheData");$(this,"_barIndex");$(this,"_errorListener");this._mintick=t,this._randomNums={},this._cacheData={},this._barIndex=0,this._errorListener=e}update(t){this._barIndex=t,this._randomNums={}}abs({number:t}){if(!_t(t))return Math.abs(t)}acos({angle:t}){if(_t(t))return;const e=Math.acos(t);return isNaN(e)?void 0:e}asin({angle:t}){if(_t(t))return;const e=Math.asin(t);return isNaN(e)?void 0:e}atan({angle:t}){if(_t(t))return;const e=Math.atan(t);return isNaN(e)?void 0:e}avg(t,e){return Xr.mean(e)}ceil({number:t}){if(!_t(t))return Math.ceil(t)}floor({number:t}){if(!_t(t))return Math.floor(t)}cos({angle:t}){if(_t(t))return;const e=Math.cos(t);return isNaN(e)?void 0:e}sin({angle:t}){if(_t(t))return;const e=Math.sin(t);return isNaN(e)?void 0:e}tan({angle:t}){if(_t(t))return;const e=Math.tan(t);return isNaN(e)?void 0:e}exp({number:t}){if(!_t(t))return Math.exp(t)}log({number:t}){if(!_t(t))return Math.log(t)}log10({number:t}){if(!_t(t))return Math.log10(t)}max(t,e){return e=e.filter(r=>!_t(r)),Math.max(...e)}min(t,e){return e=e.filter(r=>!_t(r)),Math.min(...e)}pow({base:t,exponent:e}){if(!(_t(t)||_t(e)))return Math.pow(t,e)}random({min:t=0,max:e=1,seed:r},n){if(_t(t)&&(t=0),_t(e)&&(e=1),r&&this._randomNums[r])return this._randomNums[r];if(t>=e){this._errorListener.addError(le.mathRandomErr,n,zt.Error);return}let i;do i=Math.random()*(e-t)+t;while(i===t||i===e);return r&&(this._randomNums[r]=i),i}round({number:t,precision:e}){if(!_t(t))return _t(e)?Math.round(t):Number(t==null?void 0:t.toFixed(e))}round_to_mintick({number:t}){if(!_t(t))return Number(t==null?void 0:t.toFixed(this._mintick))}sign({number:t}){if(!_t(t))return t&&Math.sign(t)}sqrt({number:t}){if(!_t(t))return Math.sqrt(t)}sum({source:t,length:e=1},r){let n=this._cacheData[`sum_${r}`];n||(n=[]),n[this._barIndex]=t,this._cacheData[`sum_${r}`]=n;const i=n.filter(a=>!_t(a));if(!(i.length<e))return Xr.sum(i.slice(-e))}todegrees({radians:t}){if(!_t(t))return t*(180/Math.PI)}toradians({degrees:t}){if(!_t(t))return t*(Math.PI/180)}}function Es(){return Es=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(s[r]=e[r])}return s},Es.apply(this,arguments)}var $l={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function de(s){return typeof s=="number"}function Se(s){return!s||typeof s!="object"||typeof s.constructor!="function"?!1:s.isBigNumber===!0&&typeof s.constructor.prototype=="object"&&s.constructor.prototype.isBigNumber===!0||typeof s.constructor.isDecimal=="function"&&s.constructor.isDecimal(s)===!0}function Ll(s){return s&&typeof s=="object"&&Object.getPrototypeOf(s).isComplex===!0||!1}function Rl(s){return s&&typeof s=="object"&&Object.getPrototypeOf(s).isFraction===!0||!1}function Pl(s){return s&&s.constructor.prototype.isUnit===!0||!1}function tn(s){return typeof s=="string"}var Ee=Array.isArray;function ve(s){return s&&s.constructor.prototype.isMatrix===!0||!1}function Zi(s){return Array.isArray(s)||ve(s)}function Xp(s){return s&&s.isDenseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function Qp(s){return s&&s.isSparseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function td(s){return s&&s.constructor.prototype.isRange===!0||!1}function la(s){return s&&s.constructor.prototype.isIndex===!0||!1}function ed(s){return typeof s=="boolean"}function rd(s){return s&&s.constructor.prototype.isResultSet===!0||!1}function nd(s){return s&&s.constructor.prototype.isHelp===!0||!1}function id(s){return typeof s=="function"}function sd(s){return s instanceof Date}function od(s){return s instanceof RegExp}function ca(s){return!!(s&&typeof s=="object"&&s.constructor===Object&&!Ll(s)&&!Rl(s))}function ad(s){return s===null}function ud(s){return s===void 0}function ld(s){return s&&s.isAccessorNode===!0&&s.constructor.prototype.isNode===!0||!1}function cd(s){return s&&s.isArrayNode===!0&&s.constructor.prototype.isNode===!0||!1}function fd(s){return s&&s.isAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function hd(s){return s&&s.isBlockNode===!0&&s.constructor.prototype.isNode===!0||!1}function pd(s){return s&&s.isConditionalNode===!0&&s.constructor.prototype.isNode===!0||!1}function dd(s){return s&&s.isConstantNode===!0&&s.constructor.prototype.isNode===!0||!1}function _d(s){return s&&s.isFunctionAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function md(s){return s&&s.isFunctionNode===!0&&s.constructor.prototype.isNode===!0||!1}function gd(s){return s&&s.isIndexNode===!0&&s.constructor.prototype.isNode===!0||!1}function vd(s){return s&&s.isNode===!0&&s.constructor.prototype.isNode===!0||!1}function yd(s){return s&&s.isObjectNode===!0&&s.constructor.prototype.isNode===!0||!1}function wd(s){return s&&s.isOperatorNode===!0&&s.constructor.prototype.isNode===!0||!1}function Dd(s){return s&&s.isParenthesisNode===!0&&s.constructor.prototype.isNode===!0||!1}function bd(s){return s&&s.isRangeNode===!0&&s.constructor.prototype.isNode===!0||!1}function xd(s){return s&&s.isRelationalNode===!0&&s.constructor.prototype.isNode===!0||!1}function Ed(s){return s&&s.isSymbolNode===!0&&s.constructor.prototype.isNode===!0||!1}function Ad(s){return s&&s.constructor.prototype.isChain===!0||!1}function En(s){var t=typeof s;return t==="object"?s===null?"null":Se(s)?"BigNumber":s.constructor&&s.constructor.name?s.constructor.name:"Object":t}function se(s){var t=typeof s;if(t==="number"||t==="string"||t==="boolean"||s===null||s===void 0)return s;if(typeof s.clone=="function")return s.clone();if(Array.isArray(s))return s.map(function(e){return se(e)});if(s instanceof Date)return new Date(s.valueOf());if(Se(s))return s;if(ca(s))return Cd(s,se);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(s,")"))}function Cd(s,t){var e={};for(var r in s)Ki(s,r)&&(e[r]=t(s[r]));return e}function zl(s,t){for(var e in t)Ki(t,e)&&(s[e]=t[e]);return s}function hi(s,t){var e,r,n;if(Array.isArray(s)){if(!Array.isArray(t)||s.length!==t.length)return!1;for(r=0,n=s.length;r<n;r++)if(!hi(s[r],t[r]))return!1;return!0}else{if(typeof s=="function")return s===t;if(s instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(e in s)if(!(e in t)||!hi(s[e],t[e]))return!1;for(e in t)if(!(e in s))return!1;return!0}else return s===t}}function Ki(s,t){return s&&Object.hasOwnProperty.call(s,t)}function Fd(s,t){for(var e={},r=0;r<t.length;r++){var n=t[r],i=s[n];i!==void 0&&(e[n]=i)}return e}var Md=["Matrix","Array"],Nd=["number","BigNumber","Fraction"],mr=function(t){if(t)throw new Error(`The global config is readonly.
28
- Please create a mathjs instance if you want to change the default configuration.
29
- Example:
30
-
31
- import { create, all } from 'mathjs';
32
- const mathjs = create(all);
33
- mathjs.config({ number: 'BigNumber' });
34
- `);return Object.freeze($l)};Es(mr,$l,{MATRIX_OPTIONS:Md,NUMBER_OPTIONS:Nd});function kl(){return!0}function Nr(){return!1}function pi(){}const ql="Argument is not a typed-function.";function Ul(){function s(L){return typeof L=="object"&&L!==null&&L.constructor===Object}const t=[{name:"number",test:function(L){return typeof L=="number"}},{name:"string",test:function(L){return typeof L=="string"}},{name:"boolean",test:function(L){return typeof L=="boolean"}},{name:"Function",test:function(L){return typeof L=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(L){return L instanceof Date}},{name:"RegExp",test:function(L){return L instanceof RegExp}},{name:"Object",test:s},{name:"null",test:function(L){return L===null}},{name:"undefined",test:function(L){return L===void 0}}],e={name:"any",test:kl,isAny:!0};let r,n,i=0,a={createCount:0};function l(L){const Y=r.get(L);if(Y)return Y;let G='Unknown type "'+L+'"';const nt=L.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){G+='. Did you mean "'+st+'" ?';break}throw new TypeError(G)}function c(L){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const G=Y?l(Y).index:n.length,nt=[];for(let rt=0;rt<L.length;++rt){if(!L[rt]||typeof L[rt].name!="string"||typeof L[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ft=L[rt].name;if(r.has(ft))throw new TypeError('Duplicate type name "'+ft+'"');nt.push(ft),r.set(ft,{name:ft,test:L[rt].test,isAny:L[rt].isAny,index:G+rt,conversionsTo:[]})}const st=n.slice(G);n=n.slice(0,G).concat(nt).concat(st);for(let rt=G+nt.length;rt<n.length;++rt)r.get(n[rt]).index=rt}function h(){r=new Map,n=[],i=0,c([e],!1)}h(),c(t);function p(){let L;for(L of n)r.get(L).conversionsTo=[];i=0}function f(L){const Y=n.filter(G=>{const nt=r.get(G);return!nt.isAny&&nt.test(L)});return Y.length?Y:["any"]}function d(L){return L&&typeof L=="function"&&"_typedFunctionData"in L}function g(L,Y,G){if(!d(L))throw new TypeError(ql);const nt=G&&G.exact,st=Array.isArray(Y)?Y.join(","):Y,rt=N(st),ft=w(rt);if(!nt||ft in L.signatures){const Xt=L._typedFunctionData.signatureMap.get(ft);if(Xt)return Xt}const ut=rt.length;let ht;if(nt){ht=[];let Xt;for(Xt in L.signatures)ht.push(L._typedFunctionData.signatureMap.get(Xt))}else ht=L._typedFunctionData.signatures;for(let Xt=0;Xt<ut;++Xt){const ne=rt[Xt],be=[];let We;for(We of ht){const ke=S(We.params,Xt);if(!(!ke||ne.restParam&&!ke.restParam)){if(!ke.hasAny){const wr=b(ke);if(ne.types.some(Dr=>!wr.has(Dr.name)))continue}be.push(We)}}if(ht=be,ht.length===0)break}let at;for(at of ht)if(at.params.length<=ut)return at;throw new TypeError("Signature not found (signature: "+(L.name||"unnamed")+"("+w(rt,", ")+"))")}function y(L,Y,G){return g(L,Y,G).implementation}function m(L,Y){const G=l(Y);if(G.test(L))return L;const nt=G.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+Y+" defined.");for(let st=0;st<nt.length;st++)if(l(nt[st].from).test(L))return nt[st].convert(L);throw new Error("Cannot convert "+L+" to "+Y)}function w(L){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return L.map(G=>G.name).join(Y)}function v(L){const Y=L.indexOf("...")===0,nt=(Y?L.length>3?L.slice(3):"any":L).split("|").map(ut=>l(ut.trim()));let st=!1,rt=Y?"...":"";return{types:nt.map(function(ut){return st=ut.isAny||st,rt+=ut.name+"|",{name:ut.name,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:null,conversionIndex:-1}}),name:rt.slice(0,-1),hasAny:st,hasConversion:!1,restParam:Y}}function x(L){const Y=L.types.map(ft=>ft.name),G=K(Y);let nt=L.hasAny,st=L.name;const rt=G.map(function(ft){const ut=l(ft.from);return nt=ut.isAny||nt,st+="|"+ft.from,{name:ft.from,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:ft,conversionIndex:ft.index}});return{types:L.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:L.restParam}}function b(L){return L.typeSet||(L.typeSet=new Set,L.types.forEach(Y=>L.typeSet.add(Y.name))),L.typeSet}function N(L){const Y=[];if(typeof L!="string")throw new TypeError("Signatures must be strings");const G=L.trim();if(G==="")return Y;const nt=G.split(",");for(let st=0;st<nt.length;++st){const rt=v(nt[st].trim());if(rt.restParam&&st!==nt.length-1)throw new SyntaxError('Unexpected rest parameter "'+nt[st]+'": only allowed for the last parameter');if(rt.types.length===0)return null;Y.push(rt)}return Y}function E(L){const Y=It(L);return Y?Y.restParam:!1}function A(L){if(!L||L.types.length===0)return kl;if(L.types.length===1)return l(L.types[0].name).test;if(L.types.length===2){const Y=l(L.types[0].name).test,G=l(L.types[1].name).test;return function(st){return Y(st)||G(st)}}else{const Y=L.types.map(function(G){return l(G.name).test});return function(nt){for(let st=0;st<Y.length;st++)if(Y[st](nt))return!0;return!1}}}function M(L){let Y,G,nt;if(E(L)){Y=oe(L).map(A);const st=Y.length,rt=A(It(L)),ft=function(ut){for(let ht=st;ht<ut.length;ht++)if(!rt(ut[ht]))return!1;return!0};return function(ht){for(let at=0;at<Y.length;at++)if(!Y[at](ht[at]))return!1;return ft(ht)&&ht.length>=st+1}}else return L.length===0?function(rt){return rt.length===0}:L.length===1?(G=A(L[0]),function(rt){return G(rt[0])&&rt.length===1}):L.length===2?(G=A(L[0]),nt=A(L[1]),function(rt){return G(rt[0])&&nt(rt[1])&&rt.length===2}):(Y=L.map(A),function(rt){for(let ft=0;ft<Y.length;ft++)if(!Y[ft](rt[ft]))return!1;return rt.length===Y.length})}function S(L,Y){return Y<L.length?L[Y]:E(L)?It(L):null}function T(L,Y){const G=S(L,Y);return G?b(G):new Set}function F(L){return L.conversion===null||L.conversion===void 0}function O(L,Y){const G=new Set;return L.forEach(nt=>{const st=T(nt.params,Y);let rt;for(rt of st)G.add(rt)}),G.has("any")?["any"]:Array.from(G)}function R(L,Y,G){let nt,st;const rt=L||"unnamed";let ft=G,ut;for(ut=0;ut<Y.length;ut++){const ne=[];if(ft.forEach(be=>{const We=S(be.params,ut),ke=A(We);(ut<be.params.length||E(be.params))&&ke(Y[ut])&&ne.push(be)}),ne.length===0){if(st=O(ft,ut),st.length>0){const be=f(Y[ut]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+be.join(" | ")+", index: "+ut+")"),nt.data={category:"wrongType",fn:rt,index:ut,actual:be,expected:st},nt}}else ft=ne}const ht=ft.map(function(ne){return E(ne.params)?1/0:ne.params.length});if(Y.length<Math.min.apply(null,ht))return st=O(ft,ut),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+Y.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:Y.length,expected:st},nt;const at=Math.max.apply(null,ht);if(Y.length>at)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+at+", actual: "+Y.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:Y.length,expectedLength:at},nt;const Xt=[];for(let ne=0;ne<Y.length;++ne)Xt.push(f(Y[ne]).join("|"));return nt=new TypeError('Arguments of type "'+Xt.join(", ")+'" do not match any of the defined signatures of function '+rt+"."),nt.data={category:"mismatch",actual:Xt},nt}function U(L){let Y=n.length+1;for(let G=0;G<L.types.length;G++)F(L.types[G])&&(Y=Math.min(Y,L.types[G].typeIndex));return Y}function q(L){let Y=i+1;for(let G=0;G<L.types.length;G++)F(L.types[G])||(Y=Math.min(Y,L.types[G].conversionIndex));return Y}function W(L,Y){if(L.hasAny){if(!Y.hasAny)return 1}else if(Y.hasAny)return-1;if(L.restParam){if(!Y.restParam)return 1}else if(Y.restParam)return-1;if(L.hasConversion){if(!Y.hasConversion)return 1}else if(Y.hasConversion)return-1;const G=U(L)-U(Y);if(G<0)return-1;if(G>0)return 1;const nt=q(L)-q(Y);return nt<0?-1:nt>0?1:0}function z(L,Y){const G=L.params,nt=Y.params,st=It(G),rt=It(nt),ft=E(G),ut=E(nt);if(ft&&st.hasAny){if(!ut||!rt.hasAny)return 1}else if(ut&&rt.hasAny)return-1;let ht=0,at=0,Xt;for(Xt of G)Xt.hasAny&&++ht,Xt.hasConversion&&++at;let ne=0,be=0;for(Xt of nt)Xt.hasAny&&++ne,Xt.hasConversion&&++be;if(ht!==ne)return ht-ne;if(ft&&st.hasConversion){if(!ut||!rt.hasConversion)return 1}else if(ut&&rt.hasConversion)return-1;if(at!==be)return at-be;if(ft){if(!ut)return 1}else if(ut)return-1;const We=(G.length-nt.length)*(ft?-1:1);if(We!==0)return We;const ke=[];let wr=0;for(let Tn=0;Tn<G.length;++Tn){const ti=W(G[Tn],nt[Tn]);ke.push(ti),wr+=ti}if(wr!==0)return wr;let Dr;for(Dr of ke)if(Dr!==0)return Dr;return 0}function K(L){if(L.length===0)return[];const Y=L.map(l);L.length>1&&Y.sort((st,rt)=>st.index-rt.index);let G=Y[0].conversionsTo;if(L.length===1)return G;G=G.concat([]);const nt=new Set(L);for(let st=1;st<Y.length;++st){let rt;for(rt of Y[st].conversionsTo)nt.has(rt.from)||(G.push(rt),nt.add(rt.from))}return G}function Z(L,Y){let G=Y;if(L.some(st=>st.hasConversion)){const st=E(L),rt=L.map(X);G=function(){const ut=[],ht=st?arguments.length-1:arguments.length;for(let at=0;at<ht;at++)ut[at]=rt[at](arguments[at]);return st&&(ut[ht]=arguments[ht].map(rt[ht])),Y.apply(this,ut)}}let nt=G;if(E(L)){const st=L.length-1;nt=function(){return G.apply(this,Nt(arguments,0,st).concat([Nt(arguments,st)]))}}return nt}function X(L){let Y,G,nt,st;const rt=[],ft=[];switch(L.types.forEach(function(ut){ut.conversion&&(rt.push(l(ut.conversion.from).test),ft.push(ut.conversion.convert))}),ft.length){case 0:return function(ht){return ht};case 1:return Y=rt[0],nt=ft[0],function(ht){return Y(ht)?nt(ht):ht};case 2:return Y=rt[0],G=rt[1],nt=ft[0],st=ft[1],function(ht){return Y(ht)?nt(ht):G(ht)?st(ht):ht};default:return function(ht){for(let at=0;at<ft.length;at++)if(rt[at](ht))return ft[at](ht);return ht}}}function Q(L){function Y(G,nt,st){if(nt<G.length){const rt=G[nt];let ft=[];if(rt.restParam){const ut=rt.types.filter(F);ut.length<rt.types.length&&ft.push({types:ut,name:"..."+ut.map(ht=>ht.name).join("|"),hasAny:ut.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),ft.push(rt)}else ft=rt.types.map(function(ut){return{types:[ut],name:ut.name,hasAny:ut.isAny,hasConversion:ut.conversion,restParam:!1}});return re(ft,function(ut){return Y(G,nt+1,st.concat([ut]))})}else return[st]}return Y(L,0,[])}function ct(L,Y){const G=Math.max(L.length,Y.length);for(let ut=0;ut<G;ut++){const ht=T(L,ut),at=T(Y,ut);let Xt=!1,ne;for(ne of at)if(ht.has(ne)){Xt=!0;break}if(!Xt)return!1}const nt=L.length,st=Y.length,rt=E(L),ft=E(Y);return rt?ft?nt===st:st>=nt:ft?nt>=st:nt===st}function vt(L){return L.map(Y=>ze(Y)?$e(Y.referToSelf.callback):vr(Y)?Jt(Y.referTo.references,Y.referTo.callback):Y)}function lt(L,Y,G){const nt=[];let st;for(st of L){let rt=G[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=Y[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function wt(L,Y,G){const nt=vt(L),st=new Array(nt.length).fill(!1);let rt=!0;for(;rt;){rt=!1;let ft=!0;for(let ut=0;ut<nt.length;++ut){if(st[ut])continue;const ht=nt[ut];if(ze(ht))nt[ut]=ht.referToSelf.callback(G),nt[ut].referToSelf=ht.referToSelf,st[ut]=!0,ft=!1;else if(vr(ht)){const at=lt(ht.referTo.references,nt,Y);at?(nt[ut]=ht.referTo.callback.apply(this,at),nt[ut].referTo=ht.referTo,st[ut]=!0,ft=!1):rt=!0}}if(ft&&rt)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return nt}function bt(L){const Y=/\bthis(\(|\.signatures\b)/;Object.keys(L).forEach(G=>{const nt=L[G];if(Y.test(nt.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function Bt(L,Y){if(a.createCount++,Object.keys(Y).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&bt(Y);const G=[],nt=[],st={},rt=[];let ft;for(ft in Y){if(!Object.prototype.hasOwnProperty.call(Y,ft))continue;const Zt=N(ft);if(!Zt)continue;G.forEach(function($n){if(ct($n,Zt))throw new TypeError('Conflicting signatures "'+w($n)+'" and "'+w(Zt)+'".')}),G.push(Zt);const Qe=nt.length;nt.push(Y[ft]);const pu=Zt.map(x);let Bi;for(Bi of Q(pu)){const $n=w(Bi);rt.push({params:Bi,name:$n,fn:Qe}),Bi.every(Do=>!Do.hasConversion)&&(st[$n]=Qe)}}rt.sort(z);const ut=wt(nt,st,ei);let ht;for(ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(st[ht]=ut[st[ht]]);const at=[],Xt=new Map;for(ht of rt)Xt.has(ht.name)||(ht.fn=ut[ht.fn],at.push(ht),Xt.set(ht.name,ht));const ne=at[0]&&at[0].params.length<=2&&!E(at[0].params),be=at[1]&&at[1].params.length<=2&&!E(at[1].params),We=at[2]&&at[2].params.length<=2&&!E(at[2].params),ke=at[3]&&at[3].params.length<=2&&!E(at[3].params),wr=at[4]&&at[4].params.length<=2&&!E(at[4].params),Dr=at[5]&&at[5].params.length<=2&&!E(at[5].params),Tn=ne&&be&&We&&ke&&wr&&Dr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].test=M(at[Zt].params);const ti=ne?A(at[0].params[0]):Nr,vo=be?A(at[1].params[0]):Nr,Va=We?A(at[2].params[0]):Nr,Ya=ke?A(at[3].params[0]):Nr,Za=wr?A(at[4].params[0]):Nr,Ka=Dr?A(at[5].params[0]):Nr,yo=ne?A(at[0].params[1]):Nr,Ga=be?A(at[1].params[1]):Nr,Ha=We?A(at[2].params[1]):Nr,Ja=ke?A(at[3].params[1]):Nr,rs=wr?A(at[4].params[1]):Nr,Xa=Dr?A(at[5].params[1]):Nr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].implementation=Z(at[Zt].params,at[Zt].fn);const ns=ne?at[0].implementation:pi,Qa=be?at[1].implementation:pi,tu=We?at[2].implementation:pi,eu=ke?at[3].implementation:pi,ru=wr?at[4].implementation:pi,nu=Dr?at[5].implementation:pi,iu=ne?at[0].params.length:-1,su=be?at[1].params.length:-1,ou=We?at[2].params.length:-1,wo=ke?at[3].params.length:-1,au=wr?at[4].params.length:-1,uu=Dr?at[5].params.length:-1,lu=Tn?6:0,cu=at.length,fu=at.map(Zt=>Zt.test),hu=at.map(Zt=>Zt.implementation),Si=function(){for(let Qe=lu;Qe<cu;Qe++)if(fu[Qe](arguments))return hu[Qe].apply(this,arguments);return a.onMismatch(L,arguments,at)};function ei(Zt,Qe){return arguments.length===iu&&ti(Zt)&&yo(Qe)?ns.apply(this,arguments):arguments.length===su&&vo(Zt)&&Ga(Qe)?Qa.apply(this,arguments):arguments.length===ou&&Va(Zt)&&Ha(Qe)?tu.apply(this,arguments):arguments.length===wo&&Ya(Zt)&&Ja(Qe)?eu.apply(this,arguments):arguments.length===au&&Za(Zt)&&rs(Qe)?ru.apply(this,arguments):arguments.length===uu&&Ka(Zt)&&Xa(Qe)?nu.apply(this,arguments):Si.apply(this,arguments)}try{Object.defineProperty(ei,"name",{value:L})}catch{}return ei.signatures=st,ei._typedFunctionData={signatures:at,signatureMap:Xt},ei}function xt(L,Y,G){throw R(L,Y,G)}function oe(L){return Nt(L,0,L.length-1)}function It(L){return L[L.length-1]}function Nt(L,Y,G){return Array.prototype.slice.call(L,Y,G)}function ce(L,Y){for(let G=0;G<L.length;G++)if(Y(L[G]))return L[G]}function re(L,Y){return Array.prototype.concat.apply([],L.map(Y))}function qt(){const L=oe(arguments).map(G=>w(N(G))),Y=It(arguments);if(typeof Y!="function")throw new TypeError("Callback function expected as last argument");return Jt(L,Y)}function Jt(L,Y){return{referTo:{references:L,callback:Y}}}function $e(L){if(typeof L!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:L}}}function vr(L){return L&&typeof L.referTo=="object"&&Array.isArray(L.referTo.references)&&typeof L.referTo.callback=="function"}function ze(L){return L&&typeof L.referToSelf=="object"&&typeof L.referToSelf.callback=="function"}function pn(L,Y){if(!L)return Y;if(Y&&Y!==L){const G=new Error("Function names do not match (expected: "+L+", actual: "+Y+")");throw G.data={actual:Y,expected:L},G}return L}function On(L){let Y;for(const G in L)Object.prototype.hasOwnProperty.call(L,G)&&(d(L[G])||typeof L[G].signature=="string")&&(Y=pn(Y,L[G].name));return Y}function dn(L,Y){let G;for(G in Y)if(Object.prototype.hasOwnProperty.call(Y,G)){if(G in L&&Y[G]!==L[G]){const nt=new Error('Signature "'+G+'" is defined twice');throw nt.data={signature:G,sourceFunction:Y[G],destFunction:L[G]},nt}L[G]=Y[G]}}const yr=a;a=function(L){const Y=typeof L=="string",G=Y?1:0;let nt=Y?L:"";const st={};for(let rt=G;rt<arguments.length;++rt){const ft=arguments[rt];let ut={},ht;if(typeof ft=="function"?(ht=ft.name,typeof ft.signature=="string"?ut[ft.signature]=ft:d(ft)&&(ut=ft.signatures)):s(ft)&&(ut=ft,Y||(ht=On(ft))),Object.keys(ut).length===0){const at=new TypeError("Argument to 'typed' at index "+rt+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw at.data={index:rt,argument:ft},at}Y||(nt=pn(nt,ht)),dn(st,ut)}return Bt(nt||"",st)},a.create=Ul,a.createCount=yr.createCount,a.onMismatch=xt,a.throwMismatchError=xt,a.createError=R,a.clear=h,a.clearConversions=p,a.addTypes=c,a._findType=l,a.referTo=qt,a.referToSelf=$e,a.convert=m,a.findSignature=g,a.find=y,a.isTypedFunction=d,a.warnAgainstDeprecatedThis=!0,a.addType=function(L,Y){let G="any";Y!==!1&&r.has("Object")&&(G="Object"),a.addTypes([L],G)};function In(L){if(!L||typeof L.from!="string"||typeof L.to!="string"||typeof L.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(L.to===L.from)throw new SyntaxError('Illegal to define conversion from "'+L.from+'" to itself.')}return a.addConversion=function(L){In(L);const Y=l(L.to);if(Y.conversionsTo.every(function(G){return G.from!==L.from}))Y.conversionsTo.push({from:L.from,convert:L.convert,index:i++});else throw new Error('There is already a conversion from "'+L.from+'" to "'+Y.name+'"')},a.addConversions=function(L){L.forEach(a.addConversion)},a.removeConversion=function(L){In(L);const Y=l(L.to),G=ce(Y.conversionsTo,st=>st.from===L.from);if(!G)throw new Error("Attempt to remove nonexistent conversion from "+L.from+" to "+L.to);if(G.convert!==L.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=Y.conversionsTo.indexOf(G);Y.conversionsTo.splice(nt,1)},a.resolve=function(L,Y){if(!d(L))throw new TypeError(ql);const G=L._typedFunctionData.signatures;for(let nt=0;nt<G.length;++nt)if(G[nt].test(Y))return G[nt];return null},a}var Wl=Ul();function De(s){return typeof s=="boolean"?!0:isFinite(s)?s===Math.round(s):!1}function fa(s,t,e){var r={2:"0b",8:"0o",16:"0x"},n=r[t],i="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!De(e))throw new Error("size must be an integer");if(s>2**(e-1)-1||s<-(2**(e-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!De(s))throw new Error("Value must be an integer");s<0&&(s=s+2**e),i="i".concat(e)}var a="";return s<0&&(s=-s,a="-"),"".concat(a).concat(n).concat(s.toString(t)).concat(i)}function ha(s,t){if(typeof t=="function")return t(s);if(s===1/0)return"Infinity";if(s===-1/0)return"-Infinity";if(isNaN(s))return"NaN";var{notation:e,precision:r,wordSize:n}=jl(t);switch(e){case"fixed":return Bd(s,r);case"exponential":return Vl(s,r);case"engineering":return Sd(s,r);case"bin":return fa(s,2,n);case"oct":return fa(s,8,n);case"hex":return fa(s,16,n);case"auto":return Od(s,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],a=arguments[4];return i!=="."?i+a:a});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function jl(s){var t="auto",e,r;if(s!==void 0)if(de(s))e=s;else if(Se(s))e=s.toNumber();else if(ca(s))s.precision!==void 0&&(e=Yl(s.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),s.wordSize!==void 0&&(r=Yl(s.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),s.notation&&(t=s.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:t,precision:e,wordSize:r}}function As(s){var t=String(s).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+s);var e=t[1],r=t[2],n=parseFloat(t[4]||"0"),i=r.indexOf(".");n+=i!==-1?i-1:r.length-1;var a=r.replace(".","").replace(/^0*/,function(l){return n-=l.length,""}).replace(/0*$/,"").split("").map(function(l){return parseInt(l)});return a.length===0&&(a.push(0),n++),{sign:e,coefficients:a,exponent:n}}function Sd(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=Cs(e,t),n=r.exponent,i=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(de(t))for(;t>i.length||n-a+1>i.length;)i.push(0);else for(var l=Math.abs(n-a)-(i.length-1),c=0;c<l;c++)i.push(0);for(var h=Math.abs(n-a),p=1;h>0;)p++,h--;var f=i.slice(p).join(""),d=de(t)&&f.length||f.match(/[1-9]/)?"."+f:"",g=i.slice(0,p).join("")+d+"e"+(n>=0?"+":"")+a.toString();return r.sign+g}function Bd(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=typeof t=="number"?Cs(e,e.exponent+1+t):e,n=r.coefficients,i=r.exponent+1,a=i+(t||0);return n.length<a&&(n=n.concat(di(a-n.length))),i<0&&(n=di(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),r.sign+n.join("")}function Vl(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=As(s),r=t?Cs(e,t):e,n=r.coefficients,i=r.exponent;n.length<t&&(n=n.concat(di(t-n.length)));var a=n.shift();return r.sign+a+(n.length>0?"."+n.join(""):"")+"e"+(i>=0?"+":"")+i}function Od(s,t,e){if(isNaN(s)||!isFinite(s))return String(s);var r=Zl(e==null?void 0:e.lowerExp,-3),n=Zl(e==null?void 0:e.upperExp,5),i=As(s),a=t?Cs(i,t):i;if(a.exponent<r||a.exponent>=n)return Vl(s,t);var l=a.coefficients,c=a.exponent;l.length<t&&(l=l.concat(di(t-l.length))),l=l.concat(di(c-l.length+1+(l.length<t?t-l.length:0))),l=di(-c).concat(l);var h=c>0?c:0;return h<l.length-1&&l.splice(h+1,0,"."),a.sign+l.join("")}function Cs(s,t){for(var e={sign:s.sign,coefficients:s.coefficients,exponent:s.exponent},r=e.coefficients;t<=0;)r.unshift(0),e.exponent++,t++;if(r.length>t){var n=r.splice(t,r.length-t);if(n[0]>=5){var i=t-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),e.exponent++,i++),i--,r[i]++}}return e}function di(s){for(var t=[],e=0;e<s;e++)t.push(0);return t}function Id(s){return s.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Td=Number.EPSILON||2220446049250313e-31;function Gn(s,t,e){if(e==null)return s===t;if(s===t)return!0;if(isNaN(s)||isNaN(t))return!1;if(isFinite(s)&&isFinite(t)){var r=Math.abs(s-t);return r<=Td?!0:r<=Math.max(Math.abs(s),Math.abs(t))*e}return!1}function Yl(s,t){if(de(s))return s;if(Se(s))return s.toNumber();t()}function Zl(s,t){return de(s)?s:Se(s)?s.toNumber():t}function pa(s,t,e){var r=s.constructor,n=new r(2),i="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!De(e))throw new Error("size must be an integer");if(s.greaterThan(n.pow(e-1).sub(1))||s.lessThan(n.pow(e-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!s.isInteger())throw new Error("Value must be an integer");s.lessThan(0)&&(s=s.add(n.pow(e))),i="i".concat(e)}switch(t){case 2:return"".concat(s.toBinary()).concat(i);case 8:return"".concat(s.toOctal()).concat(i);case 16:return"".concat(s.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(t," not supported "))}}function $d(s,t){if(typeof t=="function")return t(s);if(!s.isFinite())return s.isNaN()?"NaN":s.gt(0)?"Infinity":"-Infinity";var{notation:e,precision:r,wordSize:n}=jl(t);switch(e){case"fixed":return Rd(s,r);case"exponential":return Kl(s,r);case"engineering":return Ld(s,r);case"bin":return pa(s,2,n);case"oct":return pa(s,8,n);case"hex":return pa(s,16,n);case"auto":{var i=Gl(t==null?void 0:t.lowerExp,-3),a=Gl(t==null?void 0:t.upperExp,5);if(s.isZero())return"0";var l,c=s.toSignificantDigits(r),h=c.e;return h>=i&&h<a?l=c.toFixed():l=Kl(s,r),l.replace(/((\.\d*?)(0+))($|e)/,function(){var p=arguments[2],f=arguments[4];return p!=="."?p+f:f})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Ld(s,t){var e=s.e,r=e%3===0?e:e<0?e-3-e%3:e-e%3,n=s.mul(Math.pow(10,-r)),i=n.toPrecision(t);if(i.indexOf("e")!==-1){var a=s.constructor;i=new a(i).toFixed()}return i+"e"+(e>=0?"+":"")+r.toString()}function Kl(s,t){return t!==void 0?s.toExponential(t-1):s.toExponential()}function Rd(s,t){return s.toFixed(t)}function Gl(s,t){return de(s)?s:Se(s)?s.toNumber():t}function fe(s,t){var e=Pd(s,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function Pd(s,t){if(typeof s=="number")return ha(s,t);if(Se(s))return $d(s,t);if(zd(s))return!t||t.fraction!=="decimal"?s.s*s.n+"/"+s.d:s.toString();if(Array.isArray(s))return Xl(s,t);if(tn(s))return Hl(s);if(typeof s=="function")return s.syntax?String(s.syntax):"function";if(s&&typeof s=="object"){if(typeof s.format=="function")return s.format(t);if(s&&s.toString(t)!=={}.toString())return s.toString(t);var e=Object.keys(s).map(r=>Hl(r)+": "+fe(s[r],t));return"{"+e.join(", ")+"}"}return String(s)}function Hl(s){for(var t=String(s),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in Jl?Jl[n]:n,r++}return'"'+e+'"'}var Jl={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Xl(s,t){if(Array.isArray(s)){for(var e="[",r=s.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=Xl(s[n],t);return e+="]",e}else return fe(s,t)}function zd(s){return s&&typeof s=="object"&&typeof s.s=="number"&&typeof s.n=="number"&&typeof s.d=="number"||!1}function Ht(s,t,e){if(!(this instanceof Ht))throw new SyntaxError("Constructor must be called with the new operator");this.actual=s,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(s)?"["+s.join(", ")+"]":s)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}Ht.prototype=new RangeError,Ht.prototype.constructor=RangeError,Ht.prototype.name="DimensionError",Ht.prototype.isDimensionError=!0;function An(s,t,e){if(!(this instanceof An))throw new SyntaxError("Constructor must be called with the new operator");this.index=s,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=e),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}An.prototype=new RangeError,An.prototype.constructor=RangeError,An.prototype.name="IndexError",An.prototype.isIndexError=!0;function Ie(s){for(var t=[];Array.isArray(s);)t.push(s.length),s=s[0];return t}function Ql(s,t,e){var r,n=s.length;if(n!==t[e])throw new Ht(n,t[e]);if(e<t.length-1){var i=e+1;for(r=0;r<n;r++){var a=s[r];if(!Array.isArray(a))throw new Ht(t.length-1,t.length,"<");Ql(s[r],t,i)}}else for(r=0;r<n;r++)if(Array.isArray(s[r]))throw new Ht(t.length+1,t.length,">")}function tc(s,t){var e=t.length===0;if(e){if(Array.isArray(s))throw new Ht(s.length,0)}else Ql(s,t,0)}function Ae(s,t){if(s!==void 0){if(!de(s)||!De(s))throw new TypeError("Index must be an integer (value: "+s+")");if(s<0||typeof t=="number"&&s>=t)throw new An(s,t)}}function da(s,t,e){if(!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Error("Resizing to scalar is not supported");t.forEach(function(n){if(!de(n)||!De(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+fe(t)+")")}),(de(s)||Se(s))&&(s=[s]);var r=e!==void 0?e:0;return _a(s,t,0,r),s}function _a(s,t,e,r){var n,i,a=s.length,l=t[e],c=Math.min(a,l);if(s.length=l,e<t.length-1){var h=e+1;for(n=0;n<c;n++)i=s[n],Array.isArray(i)||(i=[i],s[n]=i),_a(i,t,h,r);for(n=c;n<l;n++)i=[],s[n]=i,_a(i,t,h,r)}else{for(n=0;n<c;n++)for(;Array.isArray(s[n]);)s[n]=s[n][0];for(n=c;n<l;n++)s[n]=r}}function ma(s,t){var e=va(s),r=e.length;if(!Array.isArray(s)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Ht(0,r,"!=");t=ga(t,r);var n=ec(t);if(r!==n)throw new Ht(n,r,"!=");try{return kd(e,t)}catch(i){throw i instanceof Ht?new Ht(n,r,"!="):i}}function ga(s,t){var e=ec(s),r=s.slice(),n=-1,i=s.indexOf(n),a=s.indexOf(n,i+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var l=i>=0,c=t%e===0;if(l)if(c)r[i]=-t/e;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-e);return r}function ec(s){return s.reduce((t,e)=>t*e,1)}function kd(s,t){for(var e=s,r,n=t.length-1;n>0;n--){var i=t[n];r=[];for(var a=e.length/i,l=0;l<a;l++)r.push(e.slice(l*i,(l+1)*i));e=r}return e}function rc(s,t,e,r){var n=r||Ie(s);if(e)for(var i=0;i<e;i++)s=[s],n.unshift(1);for(s=nc(s,t,0);n.length<t;)n.push(1);return s}function nc(s,t,e){var r,n;if(Array.isArray(s)){var i=e+1;for(r=0,n=s.length;r<n;r++)s[r]=nc(s[r],t,i)}else for(var a=e;a<t;a++)s=[s];return s}function va(s){if(!Array.isArray(s))return s;var t=[];return s.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t}function Fs(s,t){for(var e,r=0,n=0;n<s.length;n++){var i=s[n],a=Array.isArray(i);if(n===0&&a&&(r=i.length),a&&i.length!==r)return;var l=a?Fs(i,t):t(i);if(e===void 0)e=l;else if(e!==l)return"mixed"}return e}function ic(s,t,e,r){if(r<e){if(s.length!==t.length)throw new Ht(s.length,t.length);for(var n=[],i=0;i<s.length;i++)n[i]=ic(s[i],t[i],e,r+1);return n}else return s.concat(t)}function sc(){var s=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(s.length===1)return s[0];if(s.length>1)return s.slice(1).reduce(function(e,r){return ic(e,r,t,0)},s[0]);throw new Error("Wrong number of arguments in function concat")}function qd(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];for(var r=t.map(d=>d.length),n=Math.max(...r),i=new Array(n).fill(null),a=0;a<t.length;a++)for(var l=t[a],c=r[a],h=0;h<c;h++){var p=n-c+h;l[h]>i[p]&&(i[p]=l[h])}for(var f=0;f<t.length;f++)Ms(t[f],i);return i}function Ms(s,t){for(var e=t.length,r=s.length,n=0;n<r;n++){var i=e-r+n;if(s[n]<t[i]&&s[n]>1||s[n]>t[i])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(s,") not possible to broadcast dimension ").concat(r," with size ").concat(s[n]," to size ").concat(t[i]))}}function oc(s,t){var e=Ie(s);if(hi(e,t))return s;Ms(e,t);var r=qd(e,t),n=r.length,i=[...Array(n-e.length).fill(1),...e],a=Wd(s);e.length<n&&(a=ma(a,i),e=Ie(a));for(var l=0;l<n;l++)e[l]<r[l]&&(a=Ud(a,r[l],l),e=Ie(a));return a}function Ud(s,t,e){return sc(...Array(t).fill(s),e)}function Wd(s){return Es([],s)}function mt(s,t,e,r){function n(i){var a=Fd(i,t.map(Yd));return jd(s,t,i),e(a)}return n.isFactory=!0,n.fn=s,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function jd(s,t,e){var r=t.filter(i=>!Vd(i)).every(i=>e[i]!==void 0);if(!r){var n=t.filter(i=>e[i]===void 0);throw new Error('Cannot create function "'.concat(s,'", ')+"some dependencies are missing: ".concat(n.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function Vd(s){return s&&s[0]==="?"}function Yd(s){return s&&s[0]==="?"?s.slice(1):s}function Zd(s,t){if(uc(s)&&ac(s,t))return s[t];throw typeof s[t]=="function"&&Hd(s,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function Kd(s,t,e){if(uc(s)&&ac(s,t))return s[t]=e,e;throw new Error('No access to property "'+t+'"')}function Gd(s,t){return t in s}function ac(s,t){return!s||typeof s!="object"?!1:Ki(Jd,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Hd(s,t){return s==null||typeof s[t]!="function"||Ki(s,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(s)?!1:Ki(Xd,t)?!0:!(t in Object.prototype||t in Function.prototype)}function uc(s){return typeof s=="object"&&s&&s.constructor===Object}var Jd={length:!0,name:!0},Xd={toString:!0,valueOf:!0,toLocaleString:!0};class Qd{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return Zd(this.wrappedObject,t)}set(t,e){return Kd(this.wrappedObject,t,e),this}has(t){return Gd(this.wrappedObject,t)}entries(){return t_(this.keys(),t=>[t,this.get(t)])}forEach(t){for(var e of this.keys())t(this.get(e),e,this)}delete(t){delete this.wrappedObject[t]}clear(){for(var t of this.keys())this.delete(t)}get size(){return Object.keys(this.wrappedObject).length}}function t_(s,t){return{next:()=>{var e=s.next();return e.done?e:{value:t(e.value),done:!1}}}}function e_(s){return s?s instanceof Map||s instanceof Qd||typeof s.set=="function"&&typeof s.get=="function"&&typeof s.keys=="function"&&typeof s.has=="function":!1}var lc=function(){return lc=Wl.create,Wl},r_=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],n_=mt("typed",r_,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:i}=t,a=lc();return a.clear(),a.addTypes([{name:"number",test:de},{name:"Complex",test:Ll},{name:"BigNumber",test:Se},{name:"Fraction",test:Rl},{name:"Unit",test:Pl},{name:"identifier",test:l=>tn&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(l)},{name:"string",test:tn},{name:"Chain",test:Ad},{name:"Array",test:Ee},{name:"Matrix",test:ve},{name:"DenseMatrix",test:Xp},{name:"SparseMatrix",test:Qp},{name:"Range",test:td},{name:"Index",test:la},{name:"boolean",test:ed},{name:"ResultSet",test:rd},{name:"Help",test:nd},{name:"function",test:id},{name:"Date",test:sd},{name:"RegExp",test:od},{name:"null",test:ad},{name:"undefined",test:ud},{name:"AccessorNode",test:ld},{name:"ArrayNode",test:cd},{name:"AssignmentNode",test:fd},{name:"BlockNode",test:hd},{name:"ConditionalNode",test:pd},{name:"ConstantNode",test:dd},{name:"FunctionNode",test:md},{name:"FunctionAssignmentNode",test:_d},{name:"IndexNode",test:gd},{name:"Node",test:vd},{name:"ObjectNode",test:yd},{name:"OperatorNode",test:wd},{name:"ParenthesisNode",test:Dd},{name:"RangeNode",test:bd},{name:"RelationalNode",test:xd},{name:"SymbolNode",test:Ed},{name:"Map",test:e_},{name:"Object",test:ca}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(e||ya(c),Id(c)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+c+"). Use function bignumber(x) to convert to BigNumber.");return new e(c)}},{from:"number",to:"Complex",convert:function(c){return r||Ns(c),new r(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return r||Ns(c),new r(c.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(c){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(c){return r||Ns(c),new r(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){i||wa(c);var h=new i(c);if(h.valueOf()!==c)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+c+"). Use function fraction(x) to convert to Fraction.");return h}},{from:"string",to:"number",convert:function(c){var h=Number(c);if(isNaN(h))throw new Error('Cannot convert "'+c+'" to a number');return h}},{from:"string",to:"BigNumber",convert:function(c){e||ya(c);try{return new e(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(c){i||wa(c);try{return new i(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){r||Ns(c);try{return new r(c)}catch{throw new Error('Cannot convert "'+c+'" to Complex')}}},{from:"boolean",to:"number",convert:function(c){return+c}},{from:"boolean",to:"BigNumber",convert:function(c){return e||ya(c),new e(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return i||wa(c),new i(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return n||i_(),new n(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),a.onMismatch=(l,c,h)=>{var p=a.createError(l,c,h);if(["wrongType","mismatch"].includes(p.data.category)&&c.length===1&&Zi(c[0])&&h.some(d=>!d.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=p.data,f}throw p},a.onMismatch=(l,c,h)=>{var p=a.createError(l,c,h);if(["wrongType","mismatch"].includes(p.data.category)&&c.length===1&&Zi(c[0])&&h.some(d=>!d.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=p.data,f}throw p},a});function ya(s){throw new Error("Cannot convert value ".concat(s," into a BigNumber: no class 'BigNumber' provided"))}function Ns(s){throw new Error("Cannot convert value ".concat(s," into a Complex number: no class 'Complex' provided"))}function i_(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function wa(s){throw new Error("Cannot convert value ".concat(s," into a Fraction, no class 'Fraction' provided."))}/*!
35
- * decimal.js v10.4.3
36
- * An arbitrary-precision Decimal type for JavaScript.
37
- * https://github.com/MikeMcl/decimal.js
38
- * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
39
- * MIT Licence
40
- */var _i=9e15,Cn=1e9,Da="0123456789abcdef",Ss="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Bs="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ba={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-_i,maxE:_i,crypto:!1},cc,ln,St=!0,Os="[DecimalError] ",Fn=Os+"Invalid argument: ",fc=Os+"Precision limit exceeded",hc=Os+"crypto unavailable",pc="[object Decimal]",Je=Math.floor,Pe=Math.pow,s_=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,o_=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,a_=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,dc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,jr=1e7,Et=7,u_=9007199254740991,l_=Ss.length-1,xa=Bs.length-1,it={toStringTag:pc};it.absoluteValue=it.abs=function(){var s=new this.constructor(this);return s.s<0&&(s.s=1),Dt(s)},it.ceil=function(){return Dt(new this.constructor(this),this.e+1,2)},it.clampedTo=it.clamp=function(s,t){var e,r=this,n=r.constructor;if(s=new n(s),t=new n(t),!s.s||!t.s)return new n(NaN);if(s.gt(t))throw Error(Fn+t);return e=r.cmp(s),e<0?s:r.cmp(t)>0?t:new n(r)},it.comparedTo=it.cmp=function(s){var t,e,r,n,i=this,a=i.d,l=(s=new i.constructor(s)).d,c=i.s,h=s.s;if(!a||!l)return!c||!h?NaN:c!==h?c:a===l?0:!a^c<0?1:-1;if(!a[0]||!l[0])return a[0]?c:l[0]?-h:0;if(c!==h)return c;if(i.e!==s.e)return i.e>s.e^c<0?1:-1;for(r=a.length,n=l.length,t=0,e=r<n?r:n;t<e;++t)if(a[t]!==l[t])return a[t]>l[t]^c<0?1:-1;return r===n?0:r>n^c<0?1:-1},it.cosine=it.cos=function(){var s,t,e=this,r=e.constructor;return e.d?e.d[0]?(s=r.precision,t=r.rounding,r.precision=s+Math.max(e.e,e.sd())+Et,r.rounding=1,e=c_(r,wc(r,e)),r.precision=s,r.rounding=t,Dt(ln==2||ln==3?e.neg():e,s,t,!0)):new r(1):new r(NaN)},it.cubeRoot=it.cbrt=function(){var s,t,e,r,n,i,a,l,c,h,p=this,f=p.constructor;if(!p.isFinite()||p.isZero())return new f(p);for(St=!1,i=p.s*Pe(p.s*p,1/3),!i||Math.abs(i)==1/0?(e=Ze(p.d),s=p.e,(i=(s-e.length+1)%3)&&(e+=i==1||i==-2?"0":"00"),i=Pe(e,1/3),s=Je((s+1)/3)-(s%3==(s<0?-1:2)),i==1/0?e="5e"+s:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+s),r=new f(e),r.s=p.s):r=new f(i.toString()),a=(s=f.precision)+3;;)if(l=r,c=l.times(l).times(l),h=c.plus(p),r=he(h.plus(p).times(l),h.plus(c),a+2,1),Ze(l.d).slice(0,a)===(e=Ze(r.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!n&&e=="4999"){if(!n&&(Dt(l,s+1,0),l.times(l).times(l).eq(p))){r=l;break}a+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Dt(r,s+1,1),t=!r.times(r).times(r).eq(p));break}return St=!0,Dt(r,s,f.rounding,t)},it.decimalPlaces=it.dp=function(){var s,t=this.d,e=NaN;if(t){if(s=t.length-1,e=(s-Je(this.e/Et))*Et,s=t[s],s)for(;s%10==0;s/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(s){return he(this,new this.constructor(s))},it.dividedToIntegerBy=it.divToInt=function(s){var t=this,e=t.constructor;return Dt(he(t,new e(s),0,1,1),e.precision,e.rounding)},it.equals=it.eq=function(s){return this.cmp(s)===0},it.floor=function(){return Dt(new this.constructor(this),this.e+1,3)},it.greaterThan=it.gt=function(s){return this.cmp(s)>0},it.greaterThanOrEqualTo=it.gte=function(s){var t=this.cmp(s);return t==1||t===0},it.hyperbolicCosine=it.cosh=function(){var s,t,e,r,n,i=this,a=i.constructor,l=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return l;e=a.precision,r=a.rounding,a.precision=e+Math.max(i.e,i.sd())+4,a.rounding=1,n=i.d.length,n<32?(s=Math.ceil(n/3),t=(1/Ls(4,s)).toString()):(s=16,t="2.3283064365386962890625e-10"),i=mi(a,1,i.times(t),new a(1),!0);for(var c,h=s,p=new a(8);h--;)c=i.times(i),i=l.minus(c.times(p.minus(c.times(p))));return Dt(i,a.precision=e,a.rounding=r,!0)},it.hyperbolicSine=it.sinh=function(){var s,t,e,r,n=this,i=n.constructor;if(!n.isFinite()||n.isZero())return new i(n);if(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+4,i.rounding=1,r=n.d.length,r<3)n=mi(i,2,n,n,!0);else{s=1.4*Math.sqrt(r),s=s>16?16:s|0,n=n.times(1/Ls(5,s)),n=mi(i,2,n,n,!0);for(var a,l=new i(5),c=new i(16),h=new i(20);s--;)a=n.times(n),n=n.times(l.plus(a.times(c.times(a).plus(h))))}return i.precision=t,i.rounding=e,Dt(n,t,e,!0)},it.hyperbolicTangent=it.tanh=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+7,r.rounding=1,he(e.sinh(),e.cosh(),r.precision=s,r.rounding=t)):new r(e.s)},it.inverseCosine=it.acos=function(){var s,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,i=e.rounding;return r!==-1?r===0?t.isNeg()?Vr(e,n,i):new e(0):new e(NaN):t.isZero()?Vr(e,n+4,i).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),s=Vr(e,n+4,i).times(.5),e.precision=n,e.rounding=i,s.minus(t))},it.inverseHyperbolicCosine=it.acosh=function(){var s,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(s=r.precision,t=r.rounding,r.precision=s+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,St=!1,e=e.times(e).minus(1).sqrt().plus(e),St=!0,r.precision=s,r.rounding=t,e.ln()):new r(e)},it.inverseHyperbolicSine=it.asinh=function(){var s,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,St=!1,e=e.times(e).plus(1).sqrt().plus(e),St=!0,r.precision=s,r.rounding=t,e.ln())},it.inverseHyperbolicTangent=it.atanh=function(){var s,t,e,r,n=this,i=n.constructor;return n.isFinite()?n.e>=0?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(s=i.precision,t=i.rounding,r=n.sd(),Math.max(r,s)<2*-n.e-1?Dt(new i(n),s,t,!0):(i.precision=e=r-n.e,n=he(n.plus(1),new i(1).minus(n),e+s,1),i.precision=s+4,i.rounding=1,n=n.ln(),i.precision=s,i.rounding=t,n.times(.5))):new i(NaN)},it.inverseSine=it.asin=function(){var s,t,e,r,n=this,i=n.constructor;return n.isZero()?new i(n):(t=n.abs().cmp(1),e=i.precision,r=i.rounding,t!==-1?t===0?(s=Vr(i,e+4,r).times(.5),s.s=n.s,s):new i(NaN):(i.precision=e+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=e,i.rounding=r,n.times(2)))},it.inverseTangent=it.atan=function(){var s,t,e,r,n,i,a,l,c,h=this,p=h.constructor,f=p.precision,d=p.rounding;if(h.isFinite()){if(h.isZero())return new p(h);if(h.abs().eq(1)&&f+4<=xa)return a=Vr(p,f+4,d).times(.25),a.s=h.s,a}else{if(!h.s)return new p(NaN);if(f+4<=xa)return a=Vr(p,f+4,d).times(.5),a.s=h.s,a}for(p.precision=l=f+10,p.rounding=1,e=Math.min(28,l/Et+2|0),s=e;s;--s)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(St=!1,t=Math.ceil(l/Et),r=1,c=h.times(h),a=new p(h),n=h;s!==-1;)if(n=n.times(c),i=a.minus(n.div(r+=2)),n=n.times(c),a=i.plus(n.div(r+=2)),a.d[t]!==void 0)for(s=t;a.d[s]===i.d[s]&&s--;);return e&&(a=a.times(2<<e-1)),St=!0,Dt(a,p.precision=f,p.rounding=d,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&Je(this.e/Et)>this.d.length-2},it.isNaN=function(){return!this.s},it.isNegative=it.isNeg=function(){return this.s<0},it.isPositive=it.isPos=function(){return this.s>0},it.isZero=function(){return!!this.d&&this.d[0]===0},it.lessThan=it.lt=function(s){return this.cmp(s)<0},it.lessThanOrEqualTo=it.lte=function(s){return this.cmp(s)<1},it.logarithm=it.log=function(s){var t,e,r,n,i,a,l,c,h=this,p=h.constructor,f=p.precision,d=p.rounding,g=5;if(s==null)s=new p(10),t=!0;else{if(s=new p(s),e=s.d,s.s<0||!e||!e[0]||s.eq(1))return new p(NaN);t=s.eq(10)}if(e=h.d,h.s<0||!e||!e[0]||h.eq(1))return new p(e&&!e[0]?-1/0:h.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)i=!0;else{for(n=e[0];n%10===0;)n/=10;i=n!==1}if(St=!1,l=f+g,a=Nn(h,l),r=t?$s(p,l+10):Nn(s,l),c=he(a,r,l,1),Gi(c.d,n=f,d))do if(l+=10,a=Nn(h,l),r=t?$s(p,l+10):Nn(s,l),c=he(a,r,l,1),!i){+Ze(c.d).slice(n+1,n+15)+1==1e14&&(c=Dt(c,f+1,0));break}while(Gi(c.d,n+=10,d));return St=!0,Dt(c,f,d)},it.minus=it.sub=function(s){var t,e,r,n,i,a,l,c,h,p,f,d,g=this,y=g.constructor;if(s=new y(s),!g.d||!s.d)return!g.s||!s.s?s=new y(NaN):g.d?s.s=-s.s:s=new y(s.d||g.s!==s.s?g:NaN),s;if(g.s!=s.s)return s.s=-s.s,g.plus(s);if(h=g.d,d=s.d,l=y.precision,c=y.rounding,!h[0]||!d[0]){if(d[0])s.s=-s.s;else if(h[0])s=new y(g);else return new y(c===3?-0:0);return St?Dt(s,l,c):s}if(e=Je(s.e/Et),p=Je(g.e/Et),h=h.slice(),i=p-e,i){for(f=i<0,f?(t=h,i=-i,a=d.length):(t=d,e=p,a=h.length),r=Math.max(Math.ceil(l/Et),a)+2,i>r&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for(r=h.length,a=d.length,f=r<a,f&&(a=r),r=0;r<a;r++)if(h[r]!=d[r]){f=h[r]<d[r];break}i=0}for(f&&(t=h,h=d,d=t,s.s=-s.s),a=h.length,r=d.length-a;r>0;--r)h[a++]=0;for(r=d.length;r>i;){if(h[--r]<d[r]){for(n=r;n&&h[--n]===0;)h[n]=jr-1;--h[n],h[r]+=jr}h[r]-=d[r]}for(;h[--a]===0;)h.pop();for(;h[0]===0;h.shift())--e;return h[0]?(s.d=h,s.e=Ts(h,e),St?Dt(s,l,c):s):new y(c===3?-0:0)},it.modulo=it.mod=function(s){var t,e=this,r=e.constructor;return s=new r(s),!e.d||!s.s||s.d&&!s.d[0]?new r(NaN):!s.d||e.d&&!e.d[0]?Dt(new r(e),r.precision,r.rounding):(St=!1,r.modulo==9?(t=he(e,s.abs(),0,3,1),t.s*=s.s):t=he(e,s,0,r.modulo,1),t=t.times(s),St=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return Ea(this)},it.naturalLogarithm=it.ln=function(){return Nn(this)},it.negated=it.neg=function(){var s=new this.constructor(this);return s.s=-s.s,Dt(s)},it.plus=it.add=function(s){var t,e,r,n,i,a,l,c,h,p,f=this,d=f.constructor;if(s=new d(s),!f.d||!s.d)return!f.s||!s.s?s=new d(NaN):f.d||(s=new d(s.d||f.s===s.s?f:NaN)),s;if(f.s!=s.s)return s.s=-s.s,f.minus(s);if(h=f.d,p=s.d,l=d.precision,c=d.rounding,!h[0]||!p[0])return p[0]||(s=new d(f)),St?Dt(s,l,c):s;if(i=Je(f.e/Et),r=Je(s.e/Et),h=h.slice(),n=i-r,n){for(n<0?(e=h,n=-n,a=p.length):(e=p,r=i,a=h.length),i=Math.ceil(l/Et),a=i>a?i+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=h.length,n=p.length,a-n<0&&(n=a,e=p,p=h,h=e),t=0;n;)t=(h[--n]=h[n]+p[n]+t)/jr|0,h[n]%=jr;for(t&&(h.unshift(t),++r),a=h.length;h[--a]==0;)h.pop();return s.d=h,s.e=Ts(h,r),St?Dt(s,l,c):s},it.precision=it.sd=function(s){var t,e=this;if(s!==void 0&&s!==!!s&&s!==1&&s!==0)throw Error(Fn+s);return e.d?(t=_c(e.d),s&&e.e+1>t&&(t=e.e+1)):t=NaN,t},it.round=function(){var s=this,t=s.constructor;return Dt(new t(s),s.e+1,t.rounding)},it.sine=it.sin=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+Math.max(e.e,e.sd())+Et,r.rounding=1,e=h_(r,wc(r,e)),r.precision=s,r.rounding=t,Dt(ln>2?e.neg():e,s,t,!0)):new r(NaN)},it.squareRoot=it.sqrt=function(){var s,t,e,r,n,i,a=this,l=a.d,c=a.e,h=a.s,p=a.constructor;if(h!==1||!l||!l[0])return new p(!h||h<0&&(!l||l[0])?NaN:l?a:1/0);for(St=!1,h=Math.sqrt(+a),h==0||h==1/0?(t=Ze(l),(t.length+c)%2==0&&(t+="0"),h=Math.sqrt(t),c=Je((c+1)/2)-(c<0||c%2),h==1/0?t="5e"+c:(t=h.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new p(t)):r=new p(h.toString()),e=(c=p.precision)+3;;)if(i=r,r=i.plus(he(a,i,e+2,1)).times(.5),Ze(i.d).slice(0,e)===(t=Ze(r.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!n&&t=="4999"){if(!n&&(Dt(i,c+1,0),i.times(i).eq(a))){r=i;break}e+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Dt(r,c+1,1),s=!r.times(r).eq(a));break}return St=!0,Dt(r,c,p.rounding,s)},it.tangent=it.tan=function(){var s,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(s=r.precision,t=r.rounding,r.precision=s+10,r.rounding=1,e=e.sin(),e.s=1,e=he(e,new r(1).minus(e.times(e)).sqrt(),s+10,0),r.precision=s,r.rounding=t,Dt(ln==2||ln==4?e.neg():e,s,t,!0)):new r(NaN)},it.times=it.mul=function(s){var t,e,r,n,i,a,l,c,h,p=this,f=p.constructor,d=p.d,g=(s=new f(s)).d;if(s.s*=p.s,!d||!d[0]||!g||!g[0])return new f(!s.s||d&&!d[0]&&!g||g&&!g[0]&&!d?NaN:!d||!g?s.s/0:s.s*0);for(e=Je(p.e/Et)+Je(s.e/Et),c=d.length,h=g.length,c<h&&(i=d,d=g,g=i,a=c,c=h,h=a),i=[],a=c+h,r=a;r--;)i.push(0);for(r=h;--r>=0;){for(t=0,n=c+r;n>r;)l=i[n]+g[r]*d[n-r-1]+t,i[n--]=l%jr|0,t=l/jr|0;i[n]=(i[n]+t)%jr|0}for(;!i[--a];)i.pop();return t?++e:i.shift(),s.d=i,s.e=Ts(i,e),St?Dt(s,f.precision,f.rounding):s},it.toBinary=function(s,t){return Ca(this,2,s,t)},it.toDecimalPlaces=it.toDP=function(s,t){var e=this,r=e.constructor;return e=new r(e),s===void 0?e:(lr(s,0,Cn),t===void 0?t=r.rounding:lr(t,0,8),Dt(e,s+e.e+1,t))},it.toExponential=function(s,t){var e,r=this,n=r.constructor;return s===void 0?e=en(r,!0):(lr(s,0,Cn),t===void 0?t=n.rounding:lr(t,0,8),r=Dt(new n(r),s+1,t),e=en(r,!0,s+1)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toFixed=function(s,t){var e,r,n=this,i=n.constructor;return s===void 0?e=en(n):(lr(s,0,Cn),t===void 0?t=i.rounding:lr(t,0,8),r=Dt(new i(n),s+n.e+1,t),e=en(r,!1,s+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},it.toFraction=function(s){var t,e,r,n,i,a,l,c,h,p,f,d,g=this,y=g.d,m=g.constructor;if(!y)return new m(g);if(h=e=new m(1),r=c=new m(0),t=new m(r),i=t.e=_c(y)-g.e-1,a=i%Et,t.d[0]=Pe(10,a<0?Et+a:a),s==null)s=i>0?t:h;else{if(l=new m(s),!l.isInt()||l.lt(h))throw Error(Fn+l);s=l.gt(t)?i>0?t:h:l}for(St=!1,l=new m(Ze(y)),p=m.precision,m.precision=i=y.length*Et*2;f=he(l,t,0,1,1),n=e.plus(f.times(r)),n.cmp(s)!=1;)e=r,r=n,n=h,h=c.plus(f.times(n)),c=n,n=t,t=l.minus(f.times(n)),l=n;return n=he(s.minus(e),r,0,1,1),c=c.plus(n.times(h)),e=e.plus(n.times(r)),c.s=h.s=g.s,d=he(h,r,i,1).minus(g).abs().cmp(he(c,e,i,1).minus(g).abs())<1?[h,r]:[c,e],m.precision=p,St=!0,d},it.toHexadecimal=it.toHex=function(s,t){return Ca(this,16,s,t)},it.toNearest=function(s,t){var e=this,r=e.constructor;if(e=new r(e),s==null){if(!e.d)return e;s=new r(1),t=r.rounding}else{if(s=new r(s),t===void 0?t=r.rounding:lr(t,0,8),!e.d)return s.s?e:s;if(!s.d)return s.s&&(s.s=e.s),s}return s.d[0]?(St=!1,e=he(e,s,0,t,1).times(s),St=!0,Dt(e)):(s.s=e.s,e=s),e},it.toNumber=function(){return+this},it.toOctal=function(s,t){return Ca(this,8,s,t)},it.toPower=it.pow=function(s){var t,e,r,n,i,a,l=this,c=l.constructor,h=+(s=new c(s));if(!l.d||!s.d||!l.d[0]||!s.d[0])return new c(Pe(+l,h));if(l=new c(l),l.eq(1))return l;if(r=c.precision,i=c.rounding,s.eq(1))return Dt(l,r,i);if(t=Je(s.e/Et),t>=s.d.length-1&&(e=h<0?-h:h)<=u_)return n=mc(c,l,e,r),s.s<0?new c(1).div(n):Dt(n,r,i);if(a=l.s,a<0){if(t<s.d.length-1)return new c(NaN);if(s.d[t]&1||(a=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=a,l}return e=Pe(+l,h),t=e==0||!isFinite(e)?Je(h*(Math.log("0."+Ze(l.d))/Math.LN10+l.e+1)):new c(e+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?a/0:0):(St=!1,c.rounding=l.s=1,e=Math.min(12,(t+"").length),n=Ea(s.times(Nn(l,r+e)),r),n.d&&(n=Dt(n,r+5,1),Gi(n.d,r,i)&&(t=r+10,n=Dt(Ea(s.times(Nn(l,t+e)),t),t+5,1),+Ze(n.d).slice(r+1,r+15)+1==1e14&&(n=Dt(n,r+1,0)))),n.s=a,St=!0,c.rounding=i,Dt(n,r,i))},it.toPrecision=function(s,t){var e,r=this,n=r.constructor;return s===void 0?e=en(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(lr(s,1,Cn),t===void 0?t=n.rounding:lr(t,0,8),r=Dt(new n(r),s,t),e=en(r,s<=r.e||r.e<=n.toExpNeg,s)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toSignificantDigits=it.toSD=function(s,t){var e=this,r=e.constructor;return s===void 0?(s=r.precision,t=r.rounding):(lr(s,1,Cn),t===void 0?t=r.rounding:lr(t,0,8)),Dt(new r(e),s,t)},it.toString=function(){var s=this,t=s.constructor,e=en(s,s.e<=t.toExpNeg||s.e>=t.toExpPos);return s.isNeg()&&!s.isZero()?"-"+e:e},it.truncated=it.trunc=function(){return Dt(new this.constructor(this),this.e+1,1)},it.valueOf=it.toJSON=function(){var s=this,t=s.constructor,e=en(s,s.e<=t.toExpNeg||s.e>=t.toExpPos);return s.isNeg()?"-"+e:e};function Ze(s){var t,e,r,n=s.length-1,i="",a=s[0];if(n>0){for(i+=a,t=1;t<n;t++)r=s[t]+"",e=Et-r.length,e&&(i+=Mn(e)),i+=r;a=s[t],r=a+"",e=Et-r.length,e&&(i+=Mn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function lr(s,t,e){if(s!==~~s||s<t||s>e)throw Error(Fn+s)}function Gi(s,t,e,r){var n,i,a,l;for(i=s[0];i>=10;i/=10)--t;return--t<0?(t+=Et,n=0):(n=Math.ceil((t+1)/Et),t%=Et),i=Pe(10,Et-t),l=s[n]%i|0,r==null?t<3?(t==0?l=l/100|0:t==1&&(l=l/10|0),a=e<4&&l==99999||e>3&&l==49999||l==5e4||l==0):a=(e<4&&l+1==i||e>3&&l+1==i/2)&&(s[n+1]/i/100|0)==Pe(10,t-2)-1||(l==i/2||l==0)&&(s[n+1]/i/100|0)==0:t<4?(t==0?l=l/1e3|0:t==1?l=l/100|0:t==2&&(l=l/10|0),a=(r||e<4)&&l==9999||!r&&e>3&&l==4999):a=((r||e<4)&&l+1==i||!r&&e>3&&l+1==i/2)&&(s[n+1]/i/1e3|0)==Pe(10,t-3)-1,a}function Is(s,t,e){for(var r,n=[0],i,a=0,l=s.length;a<l;){for(i=n.length;i--;)n[i]*=t;for(n[0]+=Da.indexOf(s.charAt(a++)),r=0;r<n.length;r++)n[r]>e-1&&(n[r+1]===void 0&&(n[r+1]=0),n[r+1]+=n[r]/e|0,n[r]%=e)}return n.reverse()}function c_(s,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/Ls(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),s.precision+=e,t=mi(s,1,t.times(n),new s(1));for(var i=e;i--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return s.precision-=e,t}var he=function(){function s(r,n,i){var a,l=0,c=r.length;for(r=r.slice();c--;)a=r[c]*n+l,r[c]=a%i|0,l=a/i|0;return l&&r.unshift(l),r}function t(r,n,i,a){var l,c;if(i!=a)c=i>a?1:-1;else for(l=c=0;l<i;l++)if(r[l]!=n[l]){c=r[l]>n[l]?1:-1;break}return c}function e(r,n,i,a){for(var l=0;i--;)r[i]-=l,l=r[i]<n[i]?1:0,r[i]=l*a+r[i]-n[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,i,a,l,c){var h,p,f,d,g,y,m,w,v,x,b,N,E,A,M,S,T,F,O,R,U=r.constructor,q=r.s==n.s?1:-1,W=r.d,z=n.d;if(!W||!W[0]||!z||!z[0])return new U(!r.s||!n.s||(W?z&&W[0]==z[0]:!z)?NaN:W&&W[0]==0||!z?q*0:q/0);for(c?(g=1,p=r.e-n.e):(c=jr,g=Et,p=Je(r.e/g)-Je(n.e/g)),O=z.length,T=W.length,v=new U(q),x=v.d=[],f=0;z[f]==(W[f]||0);f++);if(z[f]>(W[f]||0)&&p--,i==null?(A=i=U.precision,a=U.rounding):l?A=i+(r.e-n.e)+1:A=i,A<0)x.push(1),y=!0;else{if(A=A/g+2|0,f=0,O==1){for(d=0,z=z[0],A++;(f<T||d)&&A--;f++)M=d*c+(W[f]||0),x[f]=M/z|0,d=M%z|0;y=d||f<T}else{for(d=c/(z[0]+1)|0,d>1&&(z=s(z,d,c),W=s(W,d,c),O=z.length,T=W.length),S=O,b=W.slice(0,O),N=b.length;N<O;)b[N++]=0;R=z.slice(),R.unshift(0),F=z[0],z[1]>=c/2&&++F;do d=0,h=t(z,b,O,N),h<0?(E=b[0],O!=N&&(E=E*c+(b[1]||0)),d=E/F|0,d>1?(d>=c&&(d=c-1),m=s(z,d,c),w=m.length,N=b.length,h=t(m,b,w,N),h==1&&(d--,e(m,O<w?R:z,w,c))):(d==0&&(h=d=1),m=z.slice()),w=m.length,w<N&&m.unshift(0),e(b,m,N,c),h==-1&&(N=b.length,h=t(z,b,O,N),h<1&&(d++,e(b,O<N?R:z,N,c))),N=b.length):h===0&&(d++,b=[0]),x[f++]=d,h&&b[0]?b[N++]=W[S]||0:(b=[W[S]],N=1);while((S++<T||b[0]!==void 0)&&A--);y=b[0]!==void 0}x[0]||x.shift()}if(g==1)v.e=p,cc=y;else{for(f=1,d=x[0];d>=10;d/=10)f++;v.e=f+p*g-1,Dt(v,l?i+v.e+1:i,a,y)}return v}}();function Dt(s,t,e,r){var n,i,a,l,c,h,p,f,d,g=s.constructor;t:if(t!=null){if(f=s.d,!f)return s;for(n=1,l=f[0];l>=10;l/=10)n++;if(i=t-n,i<0)i+=Et,a=t,p=f[d=0],c=p/Pe(10,n-a-1)%10|0;else if(d=Math.ceil((i+1)/Et),l=f.length,d>=l)if(r){for(;l++<=d;)f.push(0);p=c=0,n=1,i%=Et,a=i-Et+1}else break t;else{for(p=l=f[d],n=1;l>=10;l/=10)n++;i%=Et,a=i-Et+n,c=a<0?0:p/Pe(10,n-a-1)%10|0}if(r=r||t<0||f[d+1]!==void 0||(a<0?p:p%Pe(10,n-a-1)),h=e<4?(c||r)&&(e==0||e==(s.s<0?3:2)):c>5||c==5&&(e==4||r||e==6&&(i>0?a>0?p/Pe(10,n-a):0:f[d-1])%10&1||e==(s.s<0?8:7)),t<1||!f[0])return f.length=0,h?(t-=s.e+1,f[0]=Pe(10,(Et-t%Et)%Et),s.e=-t||0):f[0]=s.e=0,s;if(i==0?(f.length=d,l=1,d--):(f.length=d+1,l=Pe(10,Et-i),f[d]=a>0?(p/Pe(10,n-a)%Pe(10,a)|0)*l:0),h)for(;;)if(d==0){for(i=1,a=f[0];a>=10;a/=10)i++;for(a=f[0]+=l,l=1;a>=10;a/=10)l++;i!=l&&(s.e++,f[0]==jr&&(f[0]=1));break}else{if(f[d]+=l,f[d]!=jr)break;f[d--]=0,l=1}for(i=f.length;f[--i]===0;)f.pop()}return St&&(s.e>g.maxE?(s.d=null,s.e=NaN):s.e<g.minE&&(s.e=0,s.d=[0])),s}function en(s,t,e){if(!s.isFinite())return yc(s);var r,n=s.e,i=Ze(s.d),a=i.length;return t?(e&&(r=e-a)>0?i=i.charAt(0)+"."+i.slice(1)+Mn(r):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(s.e<0?"e":"e+")+s.e):n<0?(i="0."+Mn(-n-1)+i,e&&(r=e-a)>0&&(i+=Mn(r))):n>=a?(i+=Mn(n+1-a),e&&(r=e-n-1)>0&&(i=i+"."+Mn(r))):((r=n+1)<a&&(i=i.slice(0,r)+"."+i.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(i+="."),i+=Mn(r))),i}function Ts(s,t){var e=s[0];for(t*=Et;e>=10;e/=10)t++;return t}function $s(s,t,e){if(t>l_)throw St=!0,e&&(s.precision=e),Error(fc);return Dt(new s(Ss),t,1,!0)}function Vr(s,t,e){if(t>xa)throw Error(fc);return Dt(new s(Bs),t,e,!0)}function _c(s){var t=s.length-1,e=t*Et+1;if(t=s[t],t){for(;t%10==0;t/=10)e--;for(t=s[0];t>=10;t/=10)e++}return e}function Mn(s){for(var t="";s--;)t+="0";return t}function mc(s,t,e,r){var n,i=new s(1),a=Math.ceil(r/Et+4);for(St=!1;;){if(e%2&&(i=i.times(t),Dc(i.d,a)&&(n=!0)),e=Je(e/2),e===0){e=i.d.length-1,n&&i.d[e]===0&&++i.d[e];break}t=t.times(t),Dc(t.d,a)}return St=!0,i}function gc(s){return s.d[s.d.length-1]&1}function vc(s,t,e){for(var r,n=new s(t[0]),i=0;++i<t.length;)if(r=new s(t[i]),r.s)n[e](r)&&(n=r);else{n=r;break}return n}function Ea(s,t){var e,r,n,i,a,l,c,h=0,p=0,f=0,d=s.constructor,g=d.rounding,y=d.precision;if(!s.d||!s.d[0]||s.e>17)return new d(s.d?s.d[0]?s.s<0?0:1/0:1:s.s?s.s<0?0:s:NaN);for(t==null?(St=!1,c=y):c=t,l=new d(.03125);s.e>-2;)s=s.times(l),f+=5;for(r=Math.log(Pe(2,f))/Math.LN10*2+5|0,c+=r,e=i=a=new d(1),d.precision=c;;){if(i=Dt(i.times(s),c,1),e=e.times(++p),l=a.plus(he(i,e,c,1)),Ze(l.d).slice(0,c)===Ze(a.d).slice(0,c)){for(n=f;n--;)a=Dt(a.times(a),c,1);if(t==null)if(h<3&&Gi(a.d,c-r,g,h))d.precision=c+=10,e=i=l=new d(1),p=0,h++;else return Dt(a,d.precision=y,g,St=!0);else return d.precision=y,a}a=l}}function Nn(s,t){var e,r,n,i,a,l,c,h,p,f,d,g=1,y=10,m=s,w=m.d,v=m.constructor,x=v.rounding,b=v.precision;if(m.s<0||!w||!w[0]||!m.e&&w[0]==1&&w.length==1)return new v(w&&!w[0]?-1/0:m.s!=1?NaN:w?0:m);if(t==null?(St=!1,p=b):p=t,v.precision=p+=y,e=Ze(w),r=e.charAt(0),Math.abs(i=m.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)m=m.times(s),e=Ze(m.d),r=e.charAt(0),g++;i=m.e,r>1?(m=new v("0."+e),i++):m=new v(r+"."+e.slice(1))}else return h=$s(v,p+2,b).times(i+""),m=Nn(new v(r+"."+e.slice(1)),p-y).plus(h),v.precision=b,t==null?Dt(m,b,x,St=!0):m;for(f=m,c=a=m=he(m.minus(1),m.plus(1),p,1),d=Dt(m.times(m),p,1),n=3;;){if(a=Dt(a.times(d),p,1),h=c.plus(he(a,new v(n),p,1)),Ze(h.d).slice(0,p)===Ze(c.d).slice(0,p))if(c=c.times(2),i!==0&&(c=c.plus($s(v,p+2,b).times(i+""))),c=he(c,new v(g),p,1),t==null)if(Gi(c.d,p-y,x,l))v.precision=p+=y,h=a=m=he(f.minus(1),f.plus(1),p,1),d=Dt(m.times(m),p,1),n=l=1;else return Dt(c,v.precision=b,x,St=!0);else return v.precision=b,c;c=h,n+=2}}function yc(s){return String(s.s*s.s/0)}function Aa(s,t){var e,r,n;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),r=0;t.charCodeAt(r)===48;r++);for(n=t.length;t.charCodeAt(n-1)===48;--n);if(t=t.slice(r,n),t){if(n-=r,s.e=e=e-r-1,s.d=[],r=(e+1)%Et,e<0&&(r+=Et),r<n){for(r&&s.d.push(+t.slice(0,r)),n-=Et;r<n;)s.d.push(+t.slice(r,r+=Et));t=t.slice(r),r=Et-t.length}else r-=n;for(;r--;)t+="0";s.d.push(+t),St&&(s.e>s.constructor.maxE?(s.d=null,s.e=NaN):s.e<s.constructor.minE&&(s.e=0,s.d=[0]))}else s.e=0,s.d=[0];return s}function f_(s,t){var e,r,n,i,a,l,c,h,p;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),dc.test(t))return Aa(s,t)}else if(t==="Infinity"||t==="NaN")return+t||(s.s=NaN),s.e=NaN,s.d=null,s;if(o_.test(t))e=16,t=t.toLowerCase();else if(s_.test(t))e=2;else if(a_.test(t))e=8;else throw Error(Fn+t);for(i=t.search(/p/i),i>0?(c=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),a=i>=0,r=s.constructor,a&&(t=t.replace(".",""),l=t.length,i=l-i,n=mc(r,new r(e),i,i*2)),h=Is(t,e,jr),p=h.length-1,i=p;h[i]===0;--i)h.pop();return i<0?new r(s.s*0):(s.e=Ts(h,p),s.d=h,St=!1,a&&(s=he(s,n,l*4)),c&&(s=s.times(Math.abs(c)<54?Pe(2,c):gi.pow(2,c))),St=!0,s)}function h_(s,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:mi(s,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/Ls(5,e)),t=mi(s,2,t,t);for(var n,i=new s(5),a=new s(16),l=new s(20);e--;)n=t.times(t),t=t.times(i.plus(n.times(a.times(n).minus(l))));return t}function mi(s,t,e,r,n){var i,a,l,c,h=s.precision,p=Math.ceil(h/Et);for(St=!1,c=e.times(e),l=new s(r);;){if(a=he(l.times(c),new s(t++*t++),h,1),l=n?r.plus(a):r.minus(a),r=he(a.times(c),new s(t++*t++),h,1),a=l.plus(r),a.d[p]!==void 0){for(i=p;a.d[i]===l.d[i]&&i--;);if(i==-1)break}i=l,l=r,r=a,a=i}return St=!0,a.d.length=p+1,a}function Ls(s,t){for(var e=s;--t;)e*=s;return e}function wc(s,t){var e,r=t.s<0,n=Vr(s,s.precision,1),i=n.times(.5);if(t=t.abs(),t.lte(i))return ln=r?4:1,t;if(e=t.divToInt(n),e.isZero())ln=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(i))return ln=gc(e)?r?2:3:r?4:1,t;ln=gc(e)?r?1:4:r?3:2}return t.minus(n).abs()}function Ca(s,t,e,r){var n,i,a,l,c,h,p,f,d,g=s.constructor,y=e!==void 0;if(y?(lr(e,1,Cn),r===void 0?r=g.rounding:lr(r,0,8)):(e=g.precision,r=g.rounding),!s.isFinite())p=yc(s);else{for(p=en(s),a=p.indexOf("."),y?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(p=p.replace(".",""),d=new g(1),d.e=p.length-a,d.d=Is(en(d),10,n),d.e=d.d.length),f=Is(p,10,n),i=c=f.length;f[--c]==0;)f.pop();if(!f[0])p=y?"0p+0":"0";else{if(a<0?i--:(s=new g(s),s.d=f,s.e=i,s=he(s,d,e,r,0,n),f=s.d,i=s.e,h=cc),a=f[e],l=n/2,h=h||f[e+1]!==void 0,h=r<4?(a!==void 0||h)&&(r===0||r===(s.s<0?3:2)):a>l||a===l&&(r===4||h||r===6&&f[e-1]&1||r===(s.s<0?8:7)),f.length=e,h)for(;++f[--e]>n-1;)f[e]=0,e||(++i,f.unshift(1));for(c=f.length;!f[c-1];--c);for(a=0,p="";a<c;a++)p+=Da.charAt(f[a]);if(y){if(c>1)if(t==16||t==8){for(a=t==16?4:3,--c;c%a;c++)p+="0";for(f=Is(p,n,t),c=f.length;!f[c-1];--c);for(a=1,p="1.";a<c;a++)p+=Da.charAt(f[a])}else p=p.charAt(0)+"."+p.slice(1);p=p+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)p="0"+p;p="0."+p}else if(++i>c)for(i-=c;i--;)p+="0";else i<c&&(p=p.slice(0,i)+"."+p.slice(i))}p=(t==16?"0x":t==2?"0b":t==8?"0o":"")+p}return s.s<0?"-"+p:p}function Dc(s,t){if(s.length>t)return s.length=t,!0}function p_(s){return new this(s).abs()}function d_(s){return new this(s).acos()}function __(s){return new this(s).acosh()}function m_(s,t){return new this(s).plus(t)}function g_(s){return new this(s).asin()}function v_(s){return new this(s).asinh()}function y_(s){return new this(s).atan()}function w_(s){return new this(s).atanh()}function D_(s,t){s=new this(s),t=new this(t);var e,r=this.precision,n=this.rounding,i=r+4;return!s.s||!t.s?e=new this(NaN):!s.d&&!t.d?(e=Vr(this,i,1).times(t.s>0?.25:.75),e.s=s.s):!t.d||s.isZero()?(e=t.s<0?Vr(this,r,n):new this(0),e.s=s.s):!s.d||t.isZero()?(e=Vr(this,i,1).times(.5),e.s=s.s):t.s<0?(this.precision=i,this.rounding=1,e=this.atan(he(s,t,i,1)),t=Vr(this,i,1),this.precision=r,this.rounding=n,e=s.s<0?e.minus(t):e.plus(t)):e=this.atan(he(s,t,i,1)),e}function b_(s){return new this(s).cbrt()}function x_(s){return Dt(s=new this(s),s.e+1,2)}function E_(s,t,e){return new this(s).clamp(t,e)}function A_(s){if(!s||typeof s!="object")throw Error(Os+"Object expected");var t,e,r,n=s.defaults===!0,i=["precision",1,Cn,"rounding",0,8,"toExpNeg",-_i,0,"toExpPos",0,_i,"maxE",0,_i,"minE",-_i,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(e=i[t],n&&(this[e]=ba[e]),(r=s[e])!==void 0)if(Je(r)===r&&r>=i[t+1]&&r<=i[t+2])this[e]=r;else throw Error(Fn+e+": "+r);if(e="crypto",n&&(this[e]=ba[e]),(r=s[e])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(hc);else this[e]=!1;else throw Error(Fn+e+": "+r);return this}function C_(s){return new this(s).cos()}function F_(s){return new this(s).cosh()}function bc(s){var t,e,r;function n(i){var a,l,c,h=this;if(!(h instanceof n))return new n(i);if(h.constructor=n,xc(i)){h.s=i.s,St?!i.d||i.e>n.maxE?(h.e=NaN,h.d=null):i.e<n.minE?(h.e=0,h.d=[0]):(h.e=i.e,h.d=i.d.slice()):(h.e=i.e,h.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){h.s=1/i<0?-1:1,h.e=0,h.d=[0];return}if(i<0?(i=-i,h.s=-1):h.s=1,i===~~i&&i<1e7){for(a=0,l=i;l>=10;l/=10)a++;St?a>n.maxE?(h.e=NaN,h.d=null):a<n.minE?(h.e=0,h.d=[0]):(h.e=a,h.d=[i]):(h.e=a,h.d=[i]);return}else if(i*0!==0){i||(h.s=NaN),h.e=NaN,h.d=null;return}return Aa(h,i.toString())}else if(c!=="string")throw Error(Fn+i);return(l=i.charCodeAt(0))===45?(i=i.slice(1),h.s=-1):(l===43&&(i=i.slice(1)),h.s=1),dc.test(i)?Aa(h,i):f_(h,i)}if(n.prototype=it,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=A_,n.clone=bc,n.isDecimal=xc,n.abs=p_,n.acos=d_,n.acosh=__,n.add=m_,n.asin=g_,n.asinh=v_,n.atan=y_,n.atanh=w_,n.atan2=D_,n.cbrt=b_,n.ceil=x_,n.clamp=E_,n.cos=C_,n.cosh=F_,n.div=M_,n.exp=N_,n.floor=S_,n.hypot=B_,n.ln=O_,n.log=I_,n.log10=$_,n.log2=T_,n.max=L_,n.min=R_,n.mod=P_,n.mul=z_,n.pow=k_,n.random=q_,n.round=U_,n.sign=W_,n.sin=j_,n.sinh=V_,n.sqrt=Y_,n.sub=Z_,n.sum=K_,n.tan=G_,n.tanh=H_,n.trunc=J_,s===void 0&&(s={}),s&&s.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)s.hasOwnProperty(e=r[t++])||(s[e]=this[e]);return n.config(s),n}function M_(s,t){return new this(s).div(t)}function N_(s){return new this(s).exp()}function S_(s){return Dt(s=new this(s),s.e+1,3)}function B_(){var s,t,e=new this(0);for(St=!1,s=0;s<arguments.length;)if(t=new this(arguments[s++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return St=!0,new this(1/0);e=t}return St=!0,e.sqrt()}function xc(s){return s instanceof gi||s&&s.toStringTag===pc||!1}function O_(s){return new this(s).ln()}function I_(s,t){return new this(s).log(t)}function T_(s){return new this(s).log(2)}function $_(s){return new this(s).log(10)}function L_(){return vc(this,arguments,"lt")}function R_(){return vc(this,arguments,"gt")}function P_(s,t){return new this(s).mod(t)}function z_(s,t){return new this(s).mul(t)}function k_(s,t){return new this(s).pow(t)}function q_(s){var t,e,r,n,i=0,a=new this(1),l=[];if(s===void 0?s=this.precision:lr(s,1,Cn),r=Math.ceil(s/Et),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));i<r;)n=t[i],n>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:l[i++]=n%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);i<r;)n=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(t,i):(l.push(n%1e7),i+=4);i=r/4}else throw Error(hc);else for(;i<r;)l[i++]=Math.random()*1e7|0;for(r=l[--i],s%=Et,r&&s&&(n=Pe(10,Et-s),l[i]=(r/n|0)*n);l[i]===0;i--)l.pop();if(i<0)e=0,l=[0];else{for(e=-1;l[0]===0;e-=Et)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<Et&&(e-=Et-r)}return a.e=e,a.d=l,a}function U_(s){return Dt(s=new this(s),s.e+1,this.rounding)}function W_(s){return s=new this(s),s.d?s.d[0]?s.s:0*s.s:s.s||NaN}function j_(s){return new this(s).sin()}function V_(s){return new this(s).sinh()}function Y_(s){return new this(s).sqrt()}function Z_(s,t){return new this(s).sub(t)}function K_(){var s=0,t=arguments,e=new this(t[s]);for(St=!1;e.s&&++s<t.length;)e=e.plus(t[s]);return St=!0,Dt(e,this.precision,this.rounding)}function G_(s){return new this(s).tan()}function H_(s){return new this(s).tanh()}function J_(s){return Dt(s=new this(s),s.e+1,1)}it[Symbol.for("nodejs.util.inspect.custom")]=it.toString,it[Symbol.toStringTag]="Decimal";var gi=it.constructor=bc(ba);Ss=new gi(Ss),Bs=new gi(Bs);var X_="BigNumber",Q_=["?on","config"],tm=mt(X_,Q_,s=>{var{on:t,config:e}=s,r=gi.clone({precision:e.precision,modulo:gi.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(n){return new r(n.value)},t&&t("config",function(n,i){n.precision!==i.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),Ec={exports:{}};/**
41
- * @license Complex.js v2.1.1 12/05/2020
42
- *
43
- * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
44
- * Dual licensed under the MIT or GPL Version 2 licenses.
45
- **/(function(s,t){(function(e){var r=Math.cosh||function(f){return Math.abs(f)<1e-9?1-f:(Math.exp(f)+Math.exp(-f))*.5},n=Math.sinh||function(f){return Math.abs(f)<1e-9?f:(Math.exp(f)-Math.exp(-f))*.5},i=function(f){var d=Math.PI/4;if(-d>f||f>d)return Math.cos(f)-1;var g=f*f;return g*(g*(g*(g*(g*(g*(g*(g/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},a=function(f,d){var g=Math.abs(f),y=Math.abs(d);return g<3e3&&y<3e3?Math.sqrt(g*g+y*y):(g<y?(g=y,y=f/d):y=d/f,g*Math.sqrt(1+y*y))},l=function(){throw SyntaxError("Invalid Param")};function c(f,d){var g=Math.abs(f),y=Math.abs(d);return f===0?Math.log(y):d===0?Math.log(g):g<3e3&&y<3e3?Math.log(f*f+d*d)*.5:(f=f/2,d=d/2,.5*Math.log(f*f+d*d)+Math.LN2)}var h=function(f,d){var g={re:0,im:0};if(f==null)g.re=g.im=0;else if(d!==void 0)g.re=f,g.im=d;else switch(typeof f){case"object":if("im"in f&&"re"in f)g.re=f.re,g.im=f.im;else if("abs"in f&&"arg"in f){if(!Number.isFinite(f.abs)&&Number.isFinite(f.arg))return p.INFINITY;g.re=f.abs*Math.cos(f.arg),g.im=f.abs*Math.sin(f.arg)}else if("r"in f&&"phi"in f){if(!Number.isFinite(f.r)&&Number.isFinite(f.phi))return p.INFINITY;g.re=f.r*Math.cos(f.phi),g.im=f.r*Math.sin(f.phi)}else f.length===2?(g.re=f[0],g.im=f[1]):l();break;case"string":g.im=g.re=0;var y=f.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),m=1,w=0;y===null&&l();for(var v=0;v<y.length;v++){var x=y[v];x===" "||x===" "||x===`
46
- `||(x==="+"?m++:x==="-"?w++:x==="i"||x==="I"?(m+w===0&&l(),y[v+1]!==" "&&!isNaN(y[v+1])?(g.im+=parseFloat((w%2?"-":"")+y[v+1]),v++):g.im+=parseFloat((w%2?"-":"")+"1"),m=w=0):((m+w===0||isNaN(x))&&l(),y[v+1]==="i"||y[v+1]==="I"?(g.im+=parseFloat((w%2?"-":"")+x),v++):g.re+=parseFloat((w%2?"-":"")+x),m=w=0))}m+w>0&&l();break;case"number":g.im=0,g.re=f;break;default:l()}return isNaN(g.re)||isNaN(g.im),g};function p(f,d){if(!(this instanceof p))return new p(f,d);var g=h(f,d);this.re=g.re,this.im=g.im}p.prototype={re:0,im:0,sign:function(){var f=this.abs();return new p(this.re/f,this.im/f)},add:function(f,d){var g=new p(f,d);return this.isInfinite()&&g.isInfinite()?p.NAN:this.isInfinite()||g.isInfinite()?p.INFINITY:new p(this.re+g.re,this.im+g.im)},sub:function(f,d){var g=new p(f,d);return this.isInfinite()&&g.isInfinite()?p.NAN:this.isInfinite()||g.isInfinite()?p.INFINITY:new p(this.re-g.re,this.im-g.im)},mul:function(f,d){var g=new p(f,d);return this.isInfinite()&&g.isZero()||this.isZero()&&g.isInfinite()?p.NAN:this.isInfinite()||g.isInfinite()?p.INFINITY:g.im===0&&this.im===0?new p(this.re*g.re,0):new p(this.re*g.re-this.im*g.im,this.re*g.im+this.im*g.re)},div:function(f,d){var g=new p(f,d);if(this.isZero()&&g.isZero()||this.isInfinite()&&g.isInfinite())return p.NAN;if(this.isInfinite()||g.isZero())return p.INFINITY;if(this.isZero()||g.isInfinite())return p.ZERO;f=this.re,d=this.im;var y=g.re,m=g.im,w,v;return m===0?new p(f/y,d/y):Math.abs(y)<Math.abs(m)?(v=y/m,w=y*v+m,new p((f*v+d)/w,(d*v-f)/w)):(v=m/y,w=m*v+y,new p((f+d*v)/w,(d-f*v)/w))},pow:function(f,d){var g=new p(f,d);if(f=this.re,d=this.im,g.isZero())return p.ONE;if(g.im===0){if(d===0&&f>0)return new p(Math.pow(f,g.re),0);if(f===0)switch((g.re%4+4)%4){case 0:return new p(Math.pow(d,g.re),0);case 1:return new p(0,Math.pow(d,g.re));case 2:return new p(-Math.pow(d,g.re),0);case 3:return new p(0,-Math.pow(d,g.re))}}if(f===0&&d===0&&g.re>0&&g.im>=0)return p.ZERO;var y=Math.atan2(d,f),m=c(f,d);return f=Math.exp(g.re*m-g.im*y),d=g.im*m+g.re*y,new p(f*Math.cos(d),f*Math.sin(d))},sqrt:function(){var f=this.re,d=this.im,g=this.abs(),y,m;if(f>=0){if(d===0)return new p(Math.sqrt(f),0);y=.5*Math.sqrt(2*(g+f))}else y=Math.abs(d)/Math.sqrt(2*(g-f));return f<=0?m=.5*Math.sqrt(2*(g-f)):m=Math.abs(d)/Math.sqrt(2*(g+f)),new p(y,d<0?-m:m)},exp:function(){var f=Math.exp(this.re);return this.im,new p(f*Math.cos(this.im),f*Math.sin(this.im))},expm1:function(){var f=this.re,d=this.im;return new p(Math.expm1(f)*Math.cos(d)+i(d),Math.exp(f)*Math.sin(d))},log:function(){var f=this.re,d=this.im;return new p(c(f,d),Math.atan2(d,f))},abs:function(){return a(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var f=this.re,d=this.im;return new p(Math.sin(f)*r(d),Math.cos(f)*n(d))},cos:function(){var f=this.re,d=this.im;return new p(Math.cos(f)*r(d),-Math.sin(f)*n(d))},tan:function(){var f=2*this.re,d=2*this.im,g=Math.cos(f)+r(d);return new p(Math.sin(f)/g,n(d)/g)},cot:function(){var f=2*this.re,d=2*this.im,g=Math.cos(f)-r(d);return new p(-Math.sin(f)/g,n(d)/g)},sec:function(){var f=this.re,d=this.im,g=.5*r(2*d)+.5*Math.cos(2*f);return new p(Math.cos(f)*r(d)/g,Math.sin(f)*n(d)/g)},csc:function(){var f=this.re,d=this.im,g=.5*r(2*d)-.5*Math.cos(2*f);return new p(Math.sin(f)*r(d)/g,-Math.cos(f)*n(d)/g)},asin:function(){var f=this.re,d=this.im,g=new p(d*d-f*f+1,-2*f*d).sqrt(),y=new p(g.re-d,g.im+f).log();return new p(y.im,-y.re)},acos:function(){var f=this.re,d=this.im,g=new p(d*d-f*f+1,-2*f*d).sqrt(),y=new p(g.re-d,g.im+f).log();return new p(Math.PI/2-y.im,y.re)},atan:function(){var f=this.re,d=this.im;if(f===0){if(d===1)return new p(0,1/0);if(d===-1)return new p(0,-1/0)}var g=f*f+(1-d)*(1-d),y=new p((1-d*d-f*f)/g,-2*f/g).log();return new p(-.5*y.im,.5*y.re)},acot:function(){var f=this.re,d=this.im;if(d===0)return new p(Math.atan2(1,f),0);var g=f*f+d*d;return g!==0?new p(f/g,-d/g).atan():new p(f!==0?f/0:0,d!==0?-d/0:0).atan()},asec:function(){var f=this.re,d=this.im;if(f===0&&d===0)return new p(0,1/0);var g=f*f+d*d;return g!==0?new p(f/g,-d/g).acos():new p(f!==0?f/0:0,d!==0?-d/0:0).acos()},acsc:function(){var f=this.re,d=this.im;if(f===0&&d===0)return new p(Math.PI/2,1/0);var g=f*f+d*d;return g!==0?new p(f/g,-d/g).asin():new p(f!==0?f/0:0,d!==0?-d/0:0).asin()},sinh:function(){var f=this.re,d=this.im;return new p(n(f)*Math.cos(d),r(f)*Math.sin(d))},cosh:function(){var f=this.re,d=this.im;return new p(r(f)*Math.cos(d),n(f)*Math.sin(d))},tanh:function(){var f=2*this.re,d=2*this.im,g=r(f)+Math.cos(d);return new p(n(f)/g,Math.sin(d)/g)},coth:function(){var f=2*this.re,d=2*this.im,g=r(f)-Math.cos(d);return new p(n(f)/g,-Math.sin(d)/g)},csch:function(){var f=this.re,d=this.im,g=Math.cos(2*d)-r(2*f);return new p(-2*n(f)*Math.cos(d)/g,2*r(f)*Math.sin(d)/g)},sech:function(){var f=this.re,d=this.im,g=Math.cos(2*d)+r(2*f);return new p(2*r(f)*Math.cos(d)/g,-2*n(f)*Math.sin(d)/g)},asinh:function(){var f=this.im;this.im=-this.re,this.re=f;var d=this.asin();return this.re=-this.im,this.im=f,f=d.re,d.re=-d.im,d.im=f,d},acosh:function(){var f=this.acos();if(f.im<=0){var d=f.re;f.re=-f.im,f.im=d}else{var d=f.im;f.im=-f.re,f.re=d}return f},atanh:function(){var f=this.re,d=this.im,g=f>1&&d===0,y=1-f,m=1+f,w=y*y+d*d,v=w!==0?new p((m*y-d*d)/w,(d*y+m*d)/w):new p(f!==-1?f/0:0,d!==0?d/0:0),x=v.re;return v.re=c(v.re,v.im)/2,v.im=Math.atan2(v.im,x)/2,g&&(v.im=-v.im),v},acoth:function(){var f=this.re,d=this.im;if(f===0&&d===0)return new p(0,Math.PI/2);var g=f*f+d*d;return g!==0?new p(f/g,-d/g).atanh():new p(f!==0?f/0:0,d!==0?-d/0:0).atanh()},acsch:function(){var f=this.re,d=this.im;if(d===0)return new p(f!==0?Math.log(f+Math.sqrt(f*f+1)):1/0,0);var g=f*f+d*d;return g!==0?new p(f/g,-d/g).asinh():new p(f!==0?f/0:0,d!==0?-d/0:0).asinh()},asech:function(){var f=this.re,d=this.im;if(this.isZero())return p.INFINITY;var g=f*f+d*d;return g!==0?new p(f/g,-d/g).acosh():new p(f!==0?f/0:0,d!==0?-d/0:0).acosh()},inverse:function(){if(this.isZero())return p.INFINITY;if(this.isInfinite())return p.ZERO;var f=this.re,d=this.im,g=f*f+d*d;return new p(f/g,-d/g)},conjugate:function(){return new p(this.re,-this.im)},neg:function(){return new p(-this.re,-this.im)},ceil:function(f){return f=Math.pow(10,f||0),new p(Math.ceil(this.re*f)/f,Math.ceil(this.im*f)/f)},floor:function(f){return f=Math.pow(10,f||0),new p(Math.floor(this.re*f)/f,Math.floor(this.im*f)/f)},round:function(f){return f=Math.pow(10,f||0),new p(Math.round(this.re*f)/f,Math.round(this.im*f)/f)},equals:function(f,d){var g=new p(f,d);return Math.abs(g.re-this.re)<=p.EPSILON&&Math.abs(g.im-this.im)<=p.EPSILON},clone:function(){return new p(this.re,this.im)},toString:function(){var f=this.re,d=this.im,g="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(f)<p.EPSILON&&(f=0),Math.abs(d)<p.EPSILON&&(d=0),d===0?g+f:(f!==0?(g+=f,g+=" ",d<0?(d=-d,g+="-"):g+="+",g+=" "):d<0&&(d=-d,g+="-"),d!==1&&(g+=d),g+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},p.ZERO=new p(0,0),p.ONE=new p(1,0),p.I=new p(0,1),p.PI=new p(Math.PI,0),p.E=new p(Math.E,0),p.INFINITY=new p(1/0,1/0),p.NAN=new p(NaN,NaN),p.EPSILON=1e-15,Object.defineProperty(p,"__esModule",{value:!0}),p.default=p,p.Complex=p,s.exports=p})()})(Ec);var em=Ec.exports,Ke=Gt(em),rm="Complex",nm=[],im=mt(rm,nm,()=>(Object.defineProperty(Ke,"name",{value:"Complex"}),Ke.prototype.constructor=Ke,Ke.prototype.type="Complex",Ke.prototype.isComplex=!0,Ke.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Ke.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Ke.prototype.format=function(s){var t="",e=this.im,r=this.re,n=ha(this.re,s),i=ha(this.im,s),a=de(s)?s:s?s.precision:null;if(a!==null){var l=Math.pow(10,-a);Math.abs(r/e)<l&&(r=0),Math.abs(e/r)<l&&(e=0)}return e===0?t=n:r===0?e===1?t="i":e===-1?t="-i":t=i+"i":e<0?e===-1?t=n+" - i":t=n+" - "+i.substring(1)+"i":e===1?t=n+" + i":t=n+" + "+i+"i",t},Ke.fromPolar=function(s){switch(arguments.length){case 1:{var t=arguments[0];if(typeof t=="object")return Ke(t);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var e=arguments[0],r=arguments[1];if(de(e)){if(Pl(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),de(r))return new Ke({r:e,phi:r});throw new TypeError("Phi is not a number nor an angle unit.")}else throw new TypeError("Radius r is not a number.")}default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},Ke.prototype.valueOf=Ke.prototype.toString,Ke.fromJSON=function(s){return new Ke(s)},Ke.compare=function(s,t){return s.re>t.re?1:s.re<t.re?-1:s.im>t.im?1:s.im<t.im?-1:0},Ke),{isClass:!0}),Ac={exports:{}};/**
47
- * @license Fraction.js v4.3.0 20/08/2023
48
- * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
49
- *
50
- * Copyright (c) 2023, Robert Eisele (robert@raw.org)
51
- * Dual licensed under the MIT or GPL Version 2 licenses.
52
- **/(function(s,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function i(v,x){if(isNaN(v=parseInt(v,10)))throw m();return v*x}function a(v,x){if(x===0)throw y();var b=Object.create(g.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var N=d(v,x);return b.n=v/N,b.d=x/N,b}function l(v){for(var x={},b=v,N=2,E=4;E<=b;){for(;b%N===0;)b/=N,x[N]=(x[N]||0)+1;E+=1+2*N++}return b!==v?b>1&&(x[b]=(x[b]||0)+1):x[v]=(x[v]||0)+1,x}var c=function(v,x){var b=0,N=1,E=1,A=0,M=0,S=0,T=1,F=1,O=0,R=1,U=1,q=1,W=1e7,z;if(v!=null)if(x!==void 0){if(b=v,N=x,E=b*N,b%1!==0||N%1!==0)throw w()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,N=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(N=v[1]);else throw m();E=b*N;break}case"number":{if(v<0&&(E=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(F=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=F);R<=W&&q<=W;)if(z=(O+U)/(R+q),v===z){R+q<=W?(b=O+U,N=R+q):q>R?(b=U,N=q):(b=O,N=R);break}else v>z?(O+=U,R+=q):(U+=O,q+=R),R>W?(b=U,N=q):(b=O,N=R);b*=F}else(isNaN(v)||isNaN(x))&&(N=b=NaN);break}case"string":{if(R=v.match(/\d+|./g),R===null)throw m();if(R[O]==="-"?(E=-1,O++):R[O]==="+"&&O++,R.length===O+1?M=i(R[O++],E):R[O+1]==="."||R[O]==="."?(R[O]!=="."&&(A=i(R[O++],E)),O++,(O+1===R.length||R[O+1]==="("&&R[O+3]===")"||R[O+1]==="'"&&R[O+3]==="'")&&(M=i(R[O],E),T=Math.pow(10,R[O].length),O++),(R[O]==="("&&R[O+2]===")"||R[O]==="'"&&R[O+2]==="'")&&(S=i(R[O+1],E),F=Math.pow(10,R[O+1].length)-1,O+=3)):R[O+1]==="/"||R[O+1]===":"?(M=i(R[O],E),T=i(R[O+2],1),O+=3):R[O+3]==="/"&&R[O+1]===" "&&(A=i(R[O],E),M=i(R[O+2],E),T=i(R[O+4],1),O+=5),R.length<=O){N=T*F,E=b=S+N*A+F*M;break}}default:throw m()}if(N===0)throw y();n.s=E<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(N)};function h(v,x,b){for(var N=1;x>0;v=v*v%b,x>>=1)x&1&&(N=N*v%b);return N}function p(v,x){for(;x%2===0;x/=2);for(;x%5===0;x/=5);if(x===1)return 0;for(var b=10%x,N=1;b!==1;N++)if(b=b*10%x,N>r)return 0;return N}function f(v,x,b){for(var N=1,E=h(10,b,x),A=0;A<300;A++){if(N===E)return A;N=N*10%x,E=E*10%x}return 0}function d(v,x){if(!v)return x;if(!x)return v;for(;;){if(v%=x,!v)return x;if(x%=v,!x)return v}}function g(v,x){if(c(v,x),this instanceof g)v=d(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return a(n.s*n.n,n.d)}var y=function(){return new Error("Division by Zero")},m=function(){return new Error("Invalid argument")},w=function(){return new Error("Parameters must be integer")};g.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(v,x){return c(v,x),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,x){return c(v,x),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(v,x){if(isNaN(this.n)||isNaN(this.d))return new g(NaN);if(v===void 0)return a(this.s*this.n%this.d,1);if(c(v,x),n.n===0&&this.d===0)throw y();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(v,x){return c(v,x),a(d(n.n,this.n)*d(n.d,this.d),n.d*this.d)},lcm:function(v,x){return c(v,x),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,d(n.n,this.n)*d(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,x){if(c(v,x),n.d===1)return n.s<0?a(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):a(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=l(this.n),N=l(this.d),E=1,A=1;for(var M in b)if(M!=="1"){if(M==="0"){E=0;break}if(b[M]*=n.n,b[M]%n.d===0)b[M]/=n.d;else return null;E*=Math.pow(M,b[M])}for(var M in N)if(M!=="1"){if(N[M]*=n.n,N[M]%n.d===0)N[M]/=n.d;else return null;A*=Math.pow(M,N[M])}return n.s<0?a(A,E):a(E,A)},equals:function(v,x){return c(v,x),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,x){c(v,x);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var x=this.abs(),b=x.toContinued(),N=1;N<b.length;N++){for(var E=a(b[N-1],1),A=N-2;A>=0;A--)E=E.inverse().add(b[A]);if(Math.abs(E.sub(x).valueOf())<v)return E.mul(this.s)}return this},divisible:function(v,x){return c(v,x),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var x,b="",N=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=N:(v&&(x=Math.floor(N/E))>0&&(b+=x,b+=" ",N%=E),b+=N,b+="/",b+=E),b},toLatex:function(v){var x,b="",N=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=N:(v&&(x=Math.floor(N/E))>0&&(b+=x,N%=E),b+="\\frac{",b+=N,b+="}{",b+=E,b+="}"),b},toContinued:function(){var v,x=this.n,b=this.d,N=[];if(isNaN(x)||isNaN(b))return N;do N.push(Math.floor(x/b)),v=x%b,x=b,b=v;while(x!==1);return N},toString:function(v){var x=this.n,b=this.d;if(isNaN(x)||isNaN(b))return"NaN";v=v||15;var N=p(x,b),E=f(x,b,N),A=this.s<0?"-":"";if(A+=x/b|0,x%=b,x*=10,x&&(A+="."),N){for(var M=E;M--;)A+=x/b|0,x%=b,x*=10;A+="(";for(var M=N;M--;)A+=x/b|0,x%=b,x*=10;A+=")"}else for(var M=v;x&&M--;)A+=x/b|0,x%=b,x*=10;return A}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,s.exports=g})()})(Ac);var sm=Ac.exports,cn=Gt(sm),om="Fraction",am=[],um=mt(om,am,()=>(Object.defineProperty(cn,"name",{value:"Fraction"}),cn.prototype.constructor=cn,cn.prototype.type="Fraction",cn.prototype.isFraction=!0,cn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},cn.fromJSON=function(s){return new cn(s)},cn),{isClass:!0}),lm="Matrix",cm=[],fm=mt(lm,cm,()=>{function s(){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator")}return s.prototype.type="Matrix",s.prototype.isMatrix=!0,s.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},s.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},s.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},s.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},s.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},s.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},s.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},s.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},s.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},s.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},s.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},s.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},s.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},s.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},s.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},s.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},s.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},s},{isClass:!0});function Cc(s){return Object.keys(s.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var hm="DenseMatrix",pm=["Matrix"],dm=mt(hm,pm,s=>{var{Matrix:t}=s;function e(p,f){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(f&&!tn(f))throw new Error("Invalid datatype: "+f);if(ve(p))p.type==="DenseMatrix"?(this._data=se(p._data),this._size=se(p._size),this._datatype=f||p._datatype):(this._data=p.toArray(),this._size=p.size(),this._datatype=f||p._datatype);else if(p&&Ee(p.data)&&Ee(p.size))this._data=p.data,this._size=p.size,tc(this._data,this._size),this._datatype=f||p.datatype;else if(Ee(p))this._data=h(p),this._size=Ie(this._data),tc(this._data,this._size),this._datatype=f;else{if(p)throw new TypeError("Unsupported type of data ("+En(p)+")");this._data=[],this._size=[0],this._datatype=f}}e.prototype=new t,e.prototype.createDenseMatrix=function(p,f){return new e(p,f)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Fs(this._data,En)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(p,f){return new e(p,f)},e.prototype.subset=function(p,f,d){switch(arguments.length){case 1:return r(this,p);case 2:case 3:return i(this,p,f,d);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(p){if(!Ee(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Ht(p.length,this._size.length);for(var f=0;f<p.length;f++)Ae(p[f],this._size[f]);for(var d=this._data,g=0,y=p.length;g<y;g++){var m=p[g];Ae(m,d.length),d=d[m]}return d},e.prototype.set=function(p,f,d){if(!Ee(p))throw new TypeError("Array expected");if(p.length<this._size.length)throw new Ht(p.length,this._size.length,"<");var g,y,m,w=p.map(function(x){return x+1});c(this,w,d);var v=this._data;for(g=0,y=p.length-1;g<y;g++)m=p[g],Ae(m,v.length),v=v[m];return m=p[p.length-1],Ae(m,v.length),v[m]=f,this};function r(p,f){if(!la(f))throw new TypeError("Invalid index");var d=f.isScalar();if(d)return p.get(f.min());var g=f.size();if(g.length!==p._size.length)throw new Ht(g.length,p._size.length);for(var y=f.min(),m=f.max(),w=0,v=p._size.length;w<v;w++)Ae(y[w],p._size[w]),Ae(m[w],p._size[w]);return new e(n(p._data,f,g.length,0),p._datatype)}function n(p,f,d,g){var y=g===d-1,m=f.dimension(g);return y?m.map(function(w){return Ae(w,p.length),p[w]}).valueOf():m.map(function(w){Ae(w,p.length);var v=p[w];return n(v,f,d,g+1)}).valueOf()}function i(p,f,d,g){if(!f||f.isIndex!==!0)throw new TypeError("Invalid index");var y=f.size(),m=f.isScalar(),w;if(ve(d)?(w=d.size(),d=d.valueOf()):w=Ie(d),m){if(w.length!==0)throw new TypeError("Scalar expected");p.set(f.min(),d,g)}else{if(!hi(w,y))try{w.length===0?d=oc([d],y):d=oc(d,y),w=Ie(d)}catch{}if(y.length<p._size.length)throw new Ht(y.length,p._size.length,"<");if(w.length<y.length){for(var v=0,x=0;y[v]===1&&w[v]===1;)v++;for(;y[v]===1;)x++,v++;d=rc(d,y.length,x,w)}if(!hi(y,w))throw new Ht(y,w,">");var b=f.max().map(function(A){return A+1});c(p,b,g);var N=y.length,E=0;a(p._data,f,d,N,E)}return p}function a(p,f,d,g,y){var m=y===g-1,w=f.dimension(y);m?w.forEach(function(v,x){Ae(v),p[v]=d[x[0]]}):w.forEach(function(v,x){Ae(v),a(p[v],f,d[x[0]],g,y+1)})}e.prototype.resize=function(p,f,d){if(!Zi(p))throw new TypeError("Array or Matrix expected");var g=p.valueOf().map(m=>Array.isArray(m)&&m.length===1?m[0]:m),y=d?this.clone():this;return l(y,g,f)};function l(p,f,d){if(f.length===0){for(var g=p._data;Ee(g);)g=g[0];return g}return p._size=f.slice(0),p._data=da(p._data,p._size,d),p}e.prototype.reshape=function(p,f){var d=f?this.clone():this;d._data=ma(d._data,p);var g=d._size.reduce((y,m)=>y*m);return d._size=ga(p,g),d};function c(p,f,d){for(var g=p._size.slice(0),y=!1;g.length<f.length;)g.push(0),y=!0;for(var m=0,w=f.length;m<w;m++)f[m]>g[m]&&(g[m]=f[m],y=!0);y&&l(p,g,d)}e.prototype.clone=function(){var p=new e({data:se(this._data),size:se(this._size),datatype:this._datatype});return p},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(p){var f=this,d=Cc(p),g=function w(v,x){return Ee(v)?v.map(function(b,N){return w(b,x.concat(N))}):d===1?p(v):d===2?p(v,x):p(v,x,f)},y=g(this._data,[]),m=this._datatype!==void 0?Fs(y,En):void 0;return new e(y,m)},e.prototype.forEach=function(p){var f=this,d=function g(y,m){Ee(y)?y.forEach(function(w,v){g(w,m.concat(v))}):p(y,m,f)};d(this._data,[])},e.prototype[Symbol.iterator]=function*(){var p=function*f(d,g){if(Ee(d))for(var y=0;y<d.length;y++)yield*f(d[y],g.concat(y));else yield{value:d,index:g}};yield*p(this._data,[])},e.prototype.rows=function(){var p=[],f=this.size();if(f.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var d=this._data;for(var g of d)p.push(new e([g],this._datatype));return p},e.prototype.columns=function(){var p=this,f=[],d=this.size();if(d.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var g=this._data,y=function(v){var x=g.map(b=>[b[v]]);f.push(new e(x,p._datatype))},m=0;m<d[1];m++)y(m);return f},e.prototype.toArray=function(){return se(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(p){return fe(this._data,p)},e.prototype.toString=function(){return fe(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(p){if(p){if(Se(p)&&(p=p.toNumber()),!de(p)||!De(p))throw new TypeError("The parameter k must be an integer number")}else p=0;for(var f=p>0?p:0,d=p<0?-p:0,g=this._size[0],y=this._size[1],m=Math.min(g-d,y-f),w=[],v=0;v<m;v++)w[v]=this._data[v+d][v+f];return new e({data:w,size:[m],datatype:this._datatype})},e.diagonal=function(p,f,d,g){if(!Ee(p))throw new TypeError("Array expected, size parameter");if(p.length!==2)throw new Error("Only two dimensions matrix are supported");if(p=p.map(function(M){if(Se(M)&&(M=M.toNumber()),!de(M)||!De(M)||M<1)throw new Error("Size values must be positive integers");return M}),d){if(Se(d)&&(d=d.toNumber()),!de(d)||!De(d))throw new TypeError("The parameter k must be an integer number")}else d=0;var y=d>0?d:0,m=d<0?-d:0,w=p[0],v=p[1],x=Math.min(w-m,v-y),b;if(Ee(f)){if(f.length!==x)throw new Error("Invalid value array length");b=function(S){return f[S]}}else if(ve(f)){var N=f.size();if(N.length!==1||N[0]!==x)throw new Error("Invalid matrix length");b=function(S){return f.get([S])}}else b=function(){return f};g||(g=Se(b(0))?b(0).mul(0):0);var E=[];if(p.length>0){E=da(E,p,g);for(var A=0;A<x;A++)E[A+m][A+y]=b(A)}return new e({data:E,size:[w,v]})},e.fromJSON=function(p){return new e(p)},e.prototype.swapRows=function(p,f){if(!de(p)||!De(p)||!de(f)||!De(f))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ae(p,this._size[0]),Ae(f,this._size[0]),e._swapRows(p,f,this._data),this},e._swapRows=function(p,f,d){var g=d[p];d[p]=d[f],d[f]=g};function h(p){return ve(p)?h(p.valueOf()):Ee(p)?p.map(h):p}return e},{isClass:!0});function _m(s){var t=s.length,e=s[0].length,r,n,i=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(s[r][n]);i.push(a)}return i}function Rs(s){for(var t=0;t<s.length;t++)if(Zi(s[t]))return!0;return!1}function Hi(s,t){ve(s)&&(s=s.valueOf());for(var e=0,r=s.length;e<r;e++){var n=s[e];Array.isArray(n)?Hi(n,t):t(n)}}function Yr(s,t,e){return s&&typeof s.map=="function"?s.map(function(r){return Yr(r,t)}):t(s)}function Fa(s,t,e){var r=Array.isArray(s)?Ie(s):s.size();if(t<0||t>=r.length)throw new An(t,r.length);return ve(s)?s.create(Ps(s.valueOf(),t,e)):Ps(s,t,e)}function Ps(s,t,e){var r,n,i,a;if(t<=0)if(Array.isArray(s[0])){for(a=_m(s),n=[],r=0;r<a.length;r++)n[r]=Ps(a[r],t-1,e);return n}else{for(i=s[0],r=1;r<s.length;r++)i=e(i,s[r]);return i}else{for(n=[],r=0;r<s.length;r++)n[r]=Ps(s[r],t-1,e);return n}}var Fc="isInteger",mm=["typed"],gm=mt(Fc,mm,s=>{var{typed:t}=s;return t(Fc,{number:De,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Yr(r,e))})}),Mc="number",zs="number, number";function Nc(s){return Math.abs(s)}Nc.signature=Mc;function Sc(s,t){return s+t}Sc.signature=zs;function Bc(s,t){return s-t}Bc.signature=zs;function Oc(s,t){return s*t}Oc.signature=zs;function Ic(s){return-s}Ic.signature=Mc;function Tc(s,t){return s*s<1&&t===1/0||s*s>1&&t===-1/0?0:Math.pow(s,t)}Tc.signature=zs;var $c="number";function Lc(s){return s===0}Lc.signature=$c;function Rc(s){return Number.isNaN(s)}Rc.signature=$c;var Pc="isNumeric",vm=["typed"],ym=mt(Pc,vm,s=>{var{typed:t}=s;return t(Pc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Yr(r,e))})}),zc="isZero",wm=["typed"],Dm=mt(zc,wm,s=>{var{typed:t}=s;return t(zc,{number:Lc,BigNumber:function(r){return r.isZero()},Complex:function(r){return r.re===0&&r.im===0},Fraction:function(r){return r.d===1&&r.n===0},Unit:t.referToSelf(e=>r=>t.find(e,r.valueType())(r.value)),"Array | Matrix":t.referToSelf(e=>r=>Yr(r,e))})}),kc="isNaN",bm=["typed"],xm=mt(kc,bm,s=>{var{typed:t}=s;return t(kc,{number:Rc,BigNumber:function(r){return r.isNaN()},Fraction:function(r){return!1},Complex:function(r){return r.isNaN()},Unit:function(r){return Number.isNaN(r.value)},"Array | Matrix":function(r){return Yr(r,Number.isNaN)}})});function ks(s,t,e){if(e==null)return s.eq(t);if(s.eq(t))return!0;if(s.isNaN()||t.isNaN())return!1;if(s.isFinite()&&t.isFinite()){var r=s.minus(t).abs();if(r.isZero())return!0;var n=s.constructor.max(s.abs(),t.abs());return r.lte(n.times(e))}return!1}function Em(s,t,e){return Gn(s.re,t.re,e)&&Gn(s.im,t.im,e)}var qs=mt("compareUnits",["typed"],s=>{var{typed:t}=s;return{"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)})}}),Us="equalScalar",Am=["typed","config"],Cm=mt(Us,Am,s=>{var{typed:t,config:e}=s,r=qs({typed:t});return t(Us,{"boolean, boolean":function(i,a){return i===a},"number, number":function(i,a){return Gn(i,a,e.epsilon)},"BigNumber, BigNumber":function(i,a){return i.eq(a)||ks(i,a,e.epsilon)},"Fraction, Fraction":function(i,a){return i.equals(a)},"Complex, Complex":function(i,a){return Em(i,a,e.epsilon)}},r)});mt(Us,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Us,{"number, number":function(n,i){return Gn(n,i,e.epsilon)}})});var Fm="SparseMatrix",Mm=["typed","equalScalar","Matrix"],Nm=mt(Fm,Mm,s=>{var{typed:t,equalScalar:e,Matrix:r}=s;function n(m,w){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(w&&!tn(w))throw new Error("Invalid datatype: "+w);if(ve(m))i(this,m,w);else if(m&&Ee(m.index)&&Ee(m.ptr)&&Ee(m.size))this._values=m.values,this._index=m.index,this._ptr=m.ptr,this._size=m.size,this._datatype=w||m.datatype;else if(Ee(m))a(this,m,w);else{if(m)throw new TypeError("Unsupported type of data ("+En(m)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=w}}function i(m,w,v){w.type==="SparseMatrix"?(m._values=w._values?se(w._values):void 0,m._index=se(w._index),m._ptr=se(w._ptr),m._size=se(w._size),m._datatype=v||w._datatype):a(m,w.valueOf(),v||w._datatype)}function a(m,w,v){m._values=[],m._index=[],m._ptr=[],m._datatype=v;var x=w.length,b=0,N=e,E=0;if(tn(v)&&(N=t.find(e,[v,v])||e,E=t.convert(0,v)),x>0){var A=0;do{m._ptr.push(m._index.length);for(var M=0;M<x;M++){var S=w[M];if(Ee(S)){if(A===0&&b<S.length&&(b=S.length),A<S.length){var T=S[A];N(T,E)||(m._values.push(T),m._index.push(M))}}else A===0&&b<1&&(b=1),N(S,E)||(m._values.push(S),m._index.push(M))}A++}while(A<b)}m._ptr.push(m._index.length),m._size=[x,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(m,w){return new n(m,w)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Fs(this._values,En)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(m,w){return new n(m,w)},n.prototype.density=function(){var m=this._size[0],w=this._size[1];return m!==0&&w!==0?this._index.length/(m*w):0},n.prototype.subset=function(m,w,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,m);case 2:case 3:return c(this,m,w,v);default:throw new SyntaxError("Wrong number of arguments")}};function l(m,w){if(!la(w))throw new TypeError("Invalid index");var v=w.isScalar();if(v)return m.get(w.min());var x=w.size();if(x.length!==m._size.length)throw new Ht(x.length,m._size.length);var b,N,E,A,M=w.min(),S=w.max();for(b=0,N=m._size.length;b<N;b++)Ae(M[b],m._size[b]),Ae(S[b],m._size[b]);var T=m._values,F=m._index,O=m._ptr,R=w.dimension(0),U=w.dimension(1),q=[],W=[];R.forEach(function(X,Q){W[X]=Q[0],q[X]=!0});var z=T?[]:void 0,K=[],Z=[];return U.forEach(function(X){for(Z.push(K.length),E=O[X],A=O[X+1];E<A;E++)b=F[E],q[b]===!0&&(K.push(W[b]),z&&z.push(T[E]))}),Z.push(K.length),new n({values:z,index:K,ptr:Z,size:x,datatype:m._datatype})}function c(m,w,v,x){if(!w||w.isIndex!==!0)throw new TypeError("Invalid index");var b=w.size(),N=w.isScalar(),E;if(ve(v)?(E=v.size(),v=v.toArray()):E=Ie(v),N){if(E.length!==0)throw new TypeError("Scalar expected");m.set(w.min(),v,x)}else{if(b.length!==1&&b.length!==2)throw new Ht(b.length,m._size.length,"<");if(E.length<b.length){for(var A=0,M=0;b[A]===1&&E[A]===1;)A++;for(;b[A]===1;)M++,A++;v=rc(v,b.length,M,E)}if(!hi(b,E))throw new Ht(b,E,">");if(b.length===1){var S=w.dimension(0);S.forEach(function(O,R){Ae(O),m.set([O,0],v[R[0]],x)})}else{var T=w.dimension(0),F=w.dimension(1);T.forEach(function(O,R){Ae(O),F.forEach(function(U,q){Ae(U),m.set([O,U],v[R[0]][q[0]],x)})})}}return m}n.prototype.get=function(m){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Ht(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var w=m[0],v=m[1];Ae(w,this._size[0]),Ae(v,this._size[1]);var x=h(w,this._ptr[v],this._ptr[v+1],this._index);return x<this._ptr[v+1]&&this._index[x]===w?this._values[x]:0},n.prototype.set=function(m,w,v){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Ht(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var x=m[0],b=m[1],N=this._size[0],E=this._size[1],A=e,M=0;tn(this._datatype)&&(A=t.find(e,[this._datatype,this._datatype])||e,M=t.convert(0,this._datatype)),(x>N-1||b>E-1)&&(d(this,Math.max(x+1,N),Math.max(b+1,E),v),N=this._size[0],E=this._size[1]),Ae(x,N),Ae(b,E);var S=h(x,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===x?A(w,M)?p(S,b,this._values,this._index,this._ptr):this._values[S]=w:A(w,M)||f(S,x,b,w,this._values,this._index,this._ptr),this};function h(m,w,v,x){if(v-w===0)return v;for(var b=w;b<v;b++)if(x[b]===m)return b;return w}function p(m,w,v,x,b){v.splice(m,1),x.splice(m,1);for(var N=w+1;N<b.length;N++)b[N]--}function f(m,w,v,x,b,N,E){b.splice(m,0,x),N.splice(m,0,w);for(var A=v+1;A<E.length;A++)E[A]++}n.prototype.resize=function(m,w,v){if(!Zi(m))throw new TypeError("Array or Matrix expected");var x=m.valueOf().map(N=>Array.isArray(N)&&N.length===1?N[0]:N);if(x.length!==2)throw new Error("Only two dimensions matrix are supported");x.forEach(function(N){if(!de(N)||!De(N)||N<0)throw new TypeError("Invalid size, must contain positive integers (size: "+fe(x)+")")});var b=v?this.clone():this;return d(b,x[0],x[1],w)};function d(m,w,v,x){var b=x||0,N=e,E=0;tn(m._datatype)&&(N=t.find(e,[m._datatype,m._datatype])||e,E=t.convert(0,m._datatype),b=t.convert(b,m._datatype));var A=!N(b,E),M=m._size[0],S=m._size[1],T,F,O;if(v>S){for(F=S;F<v;F++)if(m._ptr[F]=m._values.length,A)for(T=0;T<M;T++)m._values.push(b),m._index.push(T);m._ptr[v]=m._values.length}else v<S&&(m._ptr.splice(v+1,S-v),m._values.splice(m._ptr[v],m._values.length),m._index.splice(m._ptr[v],m._index.length));if(S=v,w>M){if(A){var R=0;for(F=0;F<S;F++){m._ptr[F]=m._ptr[F]+R,O=m._ptr[F+1]+R;var U=0;for(T=M;T<w;T++,U++)m._values.splice(O+U,0,b),m._index.splice(O+U,0,T),R++}m._ptr[S]=m._values.length}}else if(w<M){var q=0;for(F=0;F<S;F++){m._ptr[F]=m._ptr[F]-q;var W=m._ptr[F],z=m._ptr[F+1]-q;for(O=W;O<z;O++)T=m._index[O],T>w-1&&(m._values.splice(O,1),m._index.splice(O,1),q++)}m._ptr[F]=m._values.length}return m._size[0]=w,m._size[1]=v,m}n.prototype.reshape=function(m,w){if(!Ee(m))throw new TypeError("Array expected");if(m.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");m.forEach(function(X){if(!de(X)||!De(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+fe(m)+")")});var v=this._size[0]*this._size[1];m=ga(m,v);var x=m[0]*m[1];if(v!==x)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=w?this.clone():this;if(this._size[0]===m[0]&&this._size[1]===m[1])return b;for(var N=[],E=0;E<b._ptr.length;E++)for(var A=0;A<b._ptr[E+1]-b._ptr[E];A++)N.push(E);for(var M=b._values.slice(),S=b._index.slice(),T=0;T<b._index.length;T++){var F=S[T],O=N[T],R=F*b._size[1]+O;N[T]=R%m[1],S[T]=Math.floor(R/m[1])}b._values.length=0,b._index.length=0,b._ptr.length=m[1]+1,b._size=m.slice();for(var U=0;U<b._ptr.length;U++)b._ptr[U]=0;for(var q=0;q<M.length;q++){var W=S[q],z=N[q],K=M[q],Z=h(W,b._ptr[z],b._ptr[z+1],b._index);f(Z,W,z,K,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var m=new n({values:this._values?se(this._values):void 0,index:se(this._index),ptr:se(this._ptr),size:se(this._size),datatype:this._datatype});return m},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(m,w){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,x=this._size[0],b=this._size[1],N=Cc(m),E=function(M,S,T){return N===1?m(M):N===2?m(M,[S,T]):m(M,[S,T],v)};return g(this,0,x-1,0,b-1,E,w)};function g(m,w,v,x,b,N,E){var A=[],M=[],S=[],T=e,F=0;tn(m._datatype)&&(T=t.find(e,[m._datatype,m._datatype])||e,F=t.convert(0,m._datatype));for(var O=function(lt,wt,bt){lt=N(lt,wt,bt),T(lt,F)||(A.push(lt),M.push(wt))},R=x;R<=b;R++){S.push(A.length);var U=m._ptr[R],q=m._ptr[R+1];if(E)for(var W=U;W<q;W++){var z=m._index[W];z>=w&&z<=v&&O(m._values[W],z-w,R-x)}else{for(var K={},Z=U;Z<q;Z++){var X=m._index[Z];K[X]=m._values[Z]}for(var Q=w;Q<=v;Q++){var ct=Q in K?K[Q]:0;O(ct,Q-w,R-x)}}}return S.push(A.length),new n({values:A,index:M,ptr:S,size:[v-w+1,b-x+1]})}n.prototype.forEach=function(m,w){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,x=this._size[0],b=this._size[1],N=0;N<b;N++){var E=this._ptr[N],A=this._ptr[N+1];if(w)for(var M=E;M<A;M++){var S=this._index[M];m(this._values[M],[S,N],v)}else{for(var T={},F=E;F<A;F++){var O=this._index[F];T[O]=this._values[F]}for(var R=0;R<x;R++){var U=R in T?T[R]:0;m(U,[R,N],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var m=this._size[1],w=0;w<m;w++)for(var v=this._ptr[w],x=this._ptr[w+1],b=v;b<x;b++){var N=this._index[b];yield{value:this._values[b],index:[N,w]}}},n.prototype.toArray=function(){return y(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return y(this._values,this._index,this._ptr,this._size,!1)};function y(m,w,v,x,b){var N=x[0],E=x[1],A=[],M,S;for(M=0;M<N;M++)for(A[M]=[],S=0;S<E;S++)A[M][S]=0;for(S=0;S<E;S++)for(var T=v[S],F=v[S+1],O=T;O<F;O++)M=w[O],A[M][S]=m?b?se(m[O]):m[O]:1;return A}return n.prototype.format=function(m){for(var w=this._size[0],v=this._size[1],x=this.density(),b="Sparse Matrix ["+fe(w,m)+" x "+fe(v,m)+"] density: "+fe(x,m)+`
53
- `,N=0;N<v;N++)for(var E=this._ptr[N],A=this._ptr[N+1],M=E;M<A;M++){var S=this._index[M];b+=`
54
- (`+fe(S,m)+", "+fe(N,m)+") ==> "+(this._values?fe(this._values[M],m):"X")}return b},n.prototype.toString=function(){return fe(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(m){if(m){if(Se(m)&&(m=m.toNumber()),!de(m)||!De(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var w=m>0?m:0,v=m<0?-m:0,x=this._size[0],b=this._size[1],N=Math.min(x-v,b-w),E=[],A=[],M=[];M[0]=0;for(var S=w;S<b&&E.length<N;S++)for(var T=this._ptr[S],F=this._ptr[S+1],O=T;O<F;O++){var R=this._index[O];if(R===S-w+v){E.push(this._values[O]),A[E.length-1]=R-v;break}}return M.push(E.length),new n({values:E,index:A,ptr:M,size:[N,1]})},n.fromJSON=function(m){return new n(m)},n.diagonal=function(m,w,v,x,b){if(!Ee(m))throw new TypeError("Array expected, size parameter");if(m.length!==2)throw new Error("Only two dimensions matrix are supported");if(m=m.map(function(X){if(Se(X)&&(X=X.toNumber()),!de(X)||!De(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Se(v)&&(v=v.toNumber()),!de(v)||!De(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var N=e,E=0;tn(b)&&(N=t.find(e,[b,b])||e,E=t.convert(0,b));var A=v>0?v:0,M=v<0?-v:0,S=m[0],T=m[1],F=Math.min(S-M,T-A),O;if(Ee(w)){if(w.length!==F)throw new Error("Invalid value array length");O=function(Q){return w[Q]}}else if(ve(w)){var R=w.size();if(R.length!==1||R[0]!==F)throw new Error("Invalid matrix length");O=function(Q){return w.get([Q])}}else O=function(){return w};for(var U=[],q=[],W=[],z=0;z<T;z++){W.push(U.length);var K=z-A;if(K>=0&&K<F){var Z=O(K);N(Z,E)||(q.push(K+M),U.push(Z))}}return W.push(U.length),new n({values:U,index:q,ptr:W,size:[S,T]})},n.prototype.swapRows=function(m,w){if(!de(m)||!De(m)||!de(w)||!De(w))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ae(m,this._size[0]),Ae(w,this._size[0]),n._swapRows(m,w,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(m,w,v,x,b){for(var N=x[m],E=x[m+1],A=N;A<E;A++)b(v[A],w[A])},n._swapRows=function(m,w,v,x,b,N){for(var E=0;E<v;E++){var A=N[E],M=N[E+1],S=h(m,A,M,b),T=h(w,A,M,b);if(S<M&&T<M&&b[S]===m&&b[T]===w){if(x){var F=x[S];x[S]=x[T],x[T]=F}continue}if(S<M&&b[S]===m&&(T>=M||b[T]!==w)){var O=x?x[S]:void 0;b.splice(T,0,w),x&&x.splice(T,0,O),b.splice(T<=S?S+1:S,1),x&&x.splice(T<=S?S+1:S,1);continue}if(T<M&&b[T]===w&&(S>=M||b[S]!==m)){var R=x?x[T]:void 0;b.splice(S,0,m),x&&x.splice(S,0,R),b.splice(S<=T?T+1:T,1),x&&x.splice(S<=T?T+1:T,1)}}},n},{isClass:!0}),Sm="number",Bm=["typed"];function Om(s){var t=s.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:s,radix:e,integerPart:r,fractionalPart:n}}else return null}function Im(s){for(var t=parseInt(s.integerPart,s.radix),e=0,r=0;r<s.fractionalPart.length;r++){var n=parseInt(s.fractionalPart[r],s.radix);e+=n/Math.pow(s.radix,r+1)}var i=t+e;if(isNaN(i))throw new SyntaxError('String "'+s.input+'" is not a valid number');return i}var Tm=mt(Sm,Bm,s=>{var{typed:t}=s,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Om(n);if(i)return Im(i);var a=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(a=Number(l[2]),n=l[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":t.referToSelf(r=>n=>Yr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),$m="bignumber",Lm=["typed","BigNumber"],Rm=mt($m,Lm,s=>{var{typed:t,BigNumber:e}=s;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var a=i[2],l=e(i[1]),c=new e(2).pow(Number(a));if(l.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var h=new e(2).pow(Number(a)-1);return l.gte(h)?l.sub(c):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Yr(n,r))})}),Pm="fraction",zm=["typed","Fraction"],km=mt(Pm,zm,s=>{var{typed:t,Fraction:e}=s;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,i){return new e(n,i)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Yr(n,r))})}),qc="matrix",qm=["typed","Matrix","DenseMatrix","SparseMatrix"],Um=mt(qc,qm,s=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=s;return t(qc,{"":function(){return i([])},string:function(l){return i([],l)},"string, string":function(l,c){return i([],l,c)},Array:function(l){return i(l)},Matrix:function(l){return i(l,l.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(a,l,c){if(l==="dense"||l==="default"||l===void 0)return new r(a,c);if(l==="sparse")return new n(a,c);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),Uc="unaryMinus",Wm=["typed"],jm=mt(Uc,Wm,s=>{var{typed:t}=s;return t(Uc,{number:Ic,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf(e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n}),"Array | Matrix":t.referToSelf(e=>r=>Yr(r,e))})}),Wc="abs",Vm=["typed"],Ym=mt(Wc,Vm,s=>{var{typed:t}=s;return t(Wc,{number:Nc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Yr(r,e))})}),jc="addScalar",Zm=["typed"],Km=mt(jc,Zm,s=>{var{typed:t}=s;return t(jc,{"number, number":Sc,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var i=r.clone();return i.value=t.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),Vc="subtractScalar",Gm=["typed"],Hm=mt(Vc,Gm,s=>{var{typed:t}=s;return t(Vc,{"number, number":Bc,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var i=r.clone();return i.value=t.find(e,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),Jm="matAlgo11xS0s",Xm=["typed","equalScalar"],Ma=mt(Jm,Xm,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=e,v=0,x=a;typeof d=="string"&&(m=d,w=t.find(e,[m,m]),v=t.convert(0,m),i=t.convert(i,m),x=t.find(a,[m,m]));for(var b=[],N=[],E=[],A=0;A<y;A++){E[A]=N.length;for(var M=p[A],S=p[A+1],T=M;T<S;T++){var F=h[T],O=l?x(i,c[T]):x(c[T],i);w(O,v)||(N.push(F),b.push(O))}}return E[y]=N.length,n.createSparseMatrix({values:b,index:N,ptr:E,size:[g,y],datatype:m})}}),Qm="matAlgo12xSfs",tg=["typed","DenseMatrix"],vi=mt(Qm,tg,s=>{var{typed:t,DenseMatrix:e}=s;return function(n,i,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=a;typeof d=="string"&&(m=d,i=t.convert(i,m),w=t.find(a,[m,m]));for(var v=[],x=[],b=[],N=0;N<y;N++){for(var E=N+1,A=p[N],M=p[N+1],S=A;S<M;S++){var T=h[S];x[T]=c[S],b[T]=E}for(var F=0;F<g;F++)N===0&&(v[F]=[]),b[F]===E?v[F][N]=l?w(i,x[F]):w(x[F],i):v[F][N]=l?w(i,0):w(0,i)}return new e({data:v,size:[g,y],datatype:m})}}),eg="matAlgo14xDs",rg=["typed"],Na=mt(eg,rg,s=>{var{typed:t}=s;return function(n,i,a,l){var c=n._data,h=n._size,p=n._datatype,f,d=a;typeof p=="string"&&(f=p,i=t.convert(i,f),d=t.find(a,[f,f]));var g=h.length>0?e(d,0,h,h[0],c,i,l):[];return n.createDenseMatrix({data:g,size:se(h),datatype:f})};function e(r,n,i,a,l,c,h){var p=[];if(n===i.length-1)for(var f=0;f<a;f++)p[f]=h?r(c,l[f]):r(l[f],c);else for(var d=0;d<a;d++)p[d]=e(r,n+1,i,i[n+1],l[d],c,h);return p}}),ng="matAlgo02xDS0",ig=["typed","equalScalar"],sg=mt(ng,ig,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a,l){var c=n._data,h=n._size,p=n._datatype||n.getDataType(),f=i._values,d=i._index,g=i._ptr,y=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==y.length)throw new Ht(h.length,y.length);if(h[0]!==y[0]||h[1]!==y[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+y+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var w=h[0],v=h[1],x,b=e,N=0,E=a;typeof p=="string"&&p===m&&p!=="mixed"&&(x=p,b=t.find(e,[x,x]),N=t.convert(0,x),E=t.find(a,[x,x]));for(var A=[],M=[],S=[],T=0;T<v;T++){S[T]=M.length;for(var F=g[T],O=g[T+1],R=F;R<O;R++){var U=d[R],q=l?E(f[R],c[U][T]):E(c[U][T],f[R]);b(q,N)||(M.push(U),A.push(q))}}return S[v]=M.length,i.createSparseMatrix({values:A,index:M,ptr:S,size:[w,v],datatype:p===n._datatype&&m===i._datatype?x:void 0})}}),og="matAlgo03xDSf",ag=["typed"],yi=mt(og,ag,s=>{var{typed:t}=s;return function(r,n,i,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),p=n._values,f=n._index,d=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v,x=0,b=i;typeof h=="string"&&h===y&&h!=="mixed"&&(v=h,x=t.convert(0,v),b=t.find(i,[v,v]));for(var N=[],E=0;E<m;E++)N[E]=[];for(var A=[],M=[],S=0;S<w;S++){for(var T=S+1,F=d[S],O=d[S+1],R=F;R<O;R++){var U=f[R];A[U]=a?b(p[R],l[U][S]):b(l[U][S],p[R]),M[U]=T}for(var q=0;q<m;q++)M[q]===T?N[q][S]=A[q]:N[q][S]=a?b(x,l[q][S]):b(l[q][S],x)}return r.createDenseMatrix({data:N,size:[m,w],datatype:h===r._datatype&&y===n._datatype?v:void 0})}}),ug="matAlgo05xSfSf",lg=["typed","equalScalar"],Yc=mt(ug,lg,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a){var l=n._values,c=n._index,h=n._ptr,p=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=i._values,g=i._index,y=i._ptr,m=i._size,w=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(p.length!==m.length)throw new Ht(p.length,m.length);if(p[0]!==m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");var v=p[0],x=p[1],b,N=e,E=0,A=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),E=t.convert(0,b),A=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],T=[],F=M?[]:void 0,O=M?[]:void 0,R=[],U=[],q,W,z,K;for(W=0;W<x;W++){T[W]=S.length;var Z=W+1;for(z=h[W],K=h[W+1];z<K;z++)q=c[z],S.push(q),R[q]=Z,F&&(F[q]=l[z]);for(z=y[W],K=y[W+1];z<K;z++)q=g[z],R[q]!==Z&&S.push(q),U[q]=Z,O&&(O[q]=d[z]);if(M)for(z=T[W];z<S.length;){q=S[z];var X=R[q],Q=U[q];if(X===Z||Q===Z){var ct=X===Z?F[q]:E,vt=Q===Z?O[q]:E,lt=A(ct,vt);N(lt,E)?S.splice(z,1):(M.push(lt),z++)}}}return T[x]=S.length,n.createSparseMatrix({values:M,index:S,ptr:T,size:[v,x],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),cg="matAlgo13xDD",fg=["typed"],hg=mt(cg,fg,s=>{var{typed:t}=s;return function(n,i,a){var l=n._data,c=n._size,h=n._datatype,p=i._data,f=i._size,d=i._datatype,g=[];if(c.length!==f.length)throw new Ht(c.length,f.length);for(var y=0;y<c.length;y++){if(c[y]!==f[y])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+f+")");g[y]=c[y]}var m,w=a;typeof h=="string"&&h===d&&(m=h,w=t.find(a,[m,m]));var v=g.length>0?e(w,0,g,g[0],l,p):[];return n.createDenseMatrix({data:v,size:g,datatype:m})};function e(r,n,i,a,l,c){var h=[];if(n===i.length-1)for(var p=0;p<a;p++)h[p]=r(l[p],c[p]);else for(var f=0;f<a;f++)h[f]=e(r,n+1,i,i[n+1],l[f],c[f]);return h}}),pg="broadcast",dg=["concat"],_g=mt(pg,dg,s=>{var{concat:t}=s;return function(n,i){var a=Math.max(n._size.length,i._size.length);if(n._size.length===i._size.length&&n._size.every((y,m)=>y===i._size[m]))return[n,i];for(var l=e(n._size,a,0),c=e(i._size,a,0),h=[],p=0;p<a;p++)h[p]=Math.max(l[p],c[p]);Ms(l,h),Ms(c,h);var f=n.clone(),d=i.clone();f._size.length<a?f.reshape(e(f._size,a,1)):d._size.length<a&&d.reshape(e(d._size,a,1));for(var g=0;g<a;g++)f._size[g]<h[g]&&(f=r(f,h[g],g)),d._size[g]<h[g]&&(d=r(d,h[g],g));return[f,d]};function e(n,i,a){return[...Array(i-n.length).fill(a),...n]}function r(n,i,a){return t(...Array(i).fill(n),a)}}),mg="matrixAlgorithmSuite",gg=["typed","matrix","concat"],Hn=mt(mg,gg,s=>{var{typed:t,matrix:e,concat:r}=s,n=hg({typed:t}),i=Na({typed:t}),a=_g({concat:r});return function(c){var h=c.elop,p=c.SD||c.DS,f;h?(f={"DenseMatrix, DenseMatrix":(m,w)=>n(...a(m,w),h),"Array, Array":(m,w)=>n(...a(e(m),e(w)),h).valueOf(),"Array, DenseMatrix":(m,w)=>n(...a(e(m),w),h),"DenseMatrix, Array":(m,w)=>n(...a(m,e(w)),h)},c.SS&&(f["SparseMatrix, SparseMatrix"]=(m,w)=>c.SS(...a(m,w),h,!1)),c.DS&&(f["DenseMatrix, SparseMatrix"]=(m,w)=>c.DS(...a(m,w),h,!1),f["Array, SparseMatrix"]=(m,w)=>c.DS(...a(e(m),w),h,!1)),p&&(f["SparseMatrix, DenseMatrix"]=(m,w)=>p(...a(w,m),h,!0),f["SparseMatrix, Array"]=(m,w)=>p(...a(e(w),m),h,!0))):(f={"DenseMatrix, DenseMatrix":t.referToSelf(m=>(w,v)=>n(...a(w,v),m)),"Array, Array":t.referToSelf(m=>(w,v)=>n(...a(e(w),e(v)),m).valueOf()),"Array, DenseMatrix":t.referToSelf(m=>(w,v)=>n(...a(e(w),v),m)),"DenseMatrix, Array":t.referToSelf(m=>(w,v)=>n(...a(w,e(v)),m))},c.SS&&(f["SparseMatrix, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.SS(...a(w,v),m,!1))),c.DS&&(f["DenseMatrix, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.DS(...a(w,v),m,!1)),f["Array, SparseMatrix"]=t.referToSelf(m=>(w,v)=>c.DS(...a(e(w),v),m,!1))),p&&(f["SparseMatrix, DenseMatrix"]=t.referToSelf(m=>(w,v)=>p(...a(v,w),m,!0)),f["SparseMatrix, Array"]=t.referToSelf(m=>(w,v)=>p(...a(e(v),w),m,!0))));var d=c.scalar||"any",g=c.Ds||c.Ss;g&&(h?(f["DenseMatrix,"+d]=(m,w)=>i(m,w,h,!1),f[d+", DenseMatrix"]=(m,w)=>i(w,m,h,!0),f["Array,"+d]=(m,w)=>i(e(m),w,h,!1).valueOf(),f[d+", Array"]=(m,w)=>i(e(w),m,h,!0).valueOf()):(f["DenseMatrix,"+d]=t.referToSelf(m=>(w,v)=>i(w,v,m,!1)),f[d+", DenseMatrix"]=t.referToSelf(m=>(w,v)=>i(v,w,m,!0)),f["Array,"+d]=t.referToSelf(m=>(w,v)=>i(e(w),v,m,!1).valueOf()),f[d+", Array"]=t.referToSelf(m=>(w,v)=>i(e(v),w,m,!0).valueOf())));var y=c.sS!==void 0?c.sS:c.Ss;return h?(c.Ss&&(f["SparseMatrix,"+d]=(m,w)=>c.Ss(m,w,h,!1)),y&&(f[d+", SparseMatrix"]=(m,w)=>y(w,m,h,!0))):(c.Ss&&(f["SparseMatrix,"+d]=t.referToSelf(m=>(w,v)=>c.Ss(w,v,m,!1))),y&&(f[d+", SparseMatrix"]=t.referToSelf(m=>(w,v)=>y(v,w,m,!0)))),h&&h.signatures&&zl(f,h.signatures),f}}),vg="matAlgo01xDSid",yg=["typed"],Zc=mt(vg,yg,s=>{var{typed:t}=s;return function(r,n,i,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),p=n._values,f=n._index,d=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v=typeof h=="string"&&h!=="mixed"&&h===y?h:void 0,x=v?t.find(i,[v,v]):i,b,N,E=[];for(b=0;b<m;b++)E[b]=[];var A=[],M=[];for(N=0;N<w;N++){for(var S=N+1,T=d[N],F=d[N+1],O=T;O<F;O++)b=f[O],A[b]=a?x(p[O],l[b][N]):x(l[b][N],p[O]),M[b]=S;for(b=0;b<m;b++)M[b]===S?E[b][N]=A[b]:E[b][N]=l[b][N]}return r.createDenseMatrix({data:E,size:[m,w],datatype:h===r._datatype&&y===n._datatype?v:void 0})}}),wg="matAlgo04xSidSid",Dg=["typed","equalScalar"],bg=mt(wg,Dg,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a){var l=n._values,c=n._index,h=n._ptr,p=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=i._values,g=i._index,y=i._ptr,m=i._size,w=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(p.length!==m.length)throw new Ht(p.length,m.length);if(p[0]!==m[0]||p[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+m+")");var v=p[0],x=p[1],b,N=e,E=0,A=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),E=t.convert(0,b),A=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],T=[],F=l&&d?[]:void 0,O=l&&d?[]:void 0,R=[],U=[],q,W,z,K,Z;for(W=0;W<x;W++){T[W]=S.length;var X=W+1;for(K=h[W],Z=h[W+1],z=K;z<Z;z++)q=c[z],S.push(q),R[q]=X,F&&(F[q]=l[z]);for(K=y[W],Z=y[W+1],z=K;z<Z;z++)if(q=g[z],R[q]===X){if(F){var Q=A(F[q],d[z]);N(Q,E)?R[q]=null:F[q]=Q}}else S.push(q),U[q]=X,O&&(O[q]=d[z]);if(F&&O)for(z=T[W];z<S.length;)q=S[z],R[q]===X?(M[z]=F[q],z++):U[q]===X?(M[z]=O[q],z++):S.splice(z,1)}return T[x]=S.length,n.createSparseMatrix({values:M,index:S,ptr:T,size:[v,x],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),xg="matAlgo10xSids",Eg=["typed","DenseMatrix"],Kc=mt(xg,Eg,s=>{var{typed:t,DenseMatrix:e}=s;return function(n,i,a,l){var c=n._values,h=n._index,p=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=a;typeof d=="string"&&(m=d,i=t.convert(i,m),w=t.find(a,[m,m]));for(var v=[],x=[],b=[],N=0;N<y;N++){for(var E=N+1,A=p[N],M=p[N+1],S=A;S<M;S++){var T=h[S];x[T]=c[S],b[T]=E}for(var F=0;F<g;F++)N===0&&(v[F]=[]),b[F]===E?v[F][N]=l?w(i,x[F]):w(x[F],i):v[F][N]=i}return new e({data:v,size:[g,y],datatype:m})}}),Ag="multiplyScalar",Cg=["typed"],Fg=mt(Ag,Cg,s=>{var{typed:t}=s;return t("multiplyScalar",{"number, number":Oc,"Complex, Complex":function(r,n){return r.mul(n)},"BigNumber, BigNumber":function(r,n){return r.times(n)},"Fraction, Fraction":function(r,n){return r.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})}),Gc="multiply",Mg=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Ng=mt(Gc,Mg,s=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:i,dot:a}=s,l=Ma({typed:t,equalScalar:i}),c=Na({typed:t});function h(E,A){switch(E.length){case 1:switch(A.length){case 1:if(E[0]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(E[0]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+E[0]+") must match Matrix rows ("+A[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+A.length+" dimensions)")}break;case 2:switch(A.length){case 1:if(E[1]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+E[1]+") must match Vector length ("+A[0]+")");break;case 2:if(E[1]!==A[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+E[1]+") must match Matrix B rows ("+A[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+A.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+E.length+" dimensions)")}}function p(E,A,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return a(E,A)}function f(E,A){if(A.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return d(E,A)}function d(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._data,O=A._size,R=A._datatype||A.getDataType(),U=S[0],q=O[1],W,z=r,K=n;T&&R&&T===R&&typeof T=="string"&&T!=="mixed"&&(W=T,z=t.find(r,[W,W]),K=t.find(n,[W,W]));for(var Z=[],X=0;X<q;X++){for(var Q=K(M[0],F[0][X]),ct=1;ct<U;ct++)Q=z(Q,K(M[ct],F[ct][X]));Z[X]=Q}return E.createDenseMatrix({data:Z,size:[q],datatype:T===E._datatype&&R===A._datatype?W:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":m,"SparseMatrix, any":x}),y=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":w,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function m(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._data,O=A._datatype||A.getDataType(),R=S[0],U=S[1],q,W=r,z=n;T&&O&&T===O&&typeof T=="string"&&T!=="mixed"&&(q=T,W=t.find(r,[q,q]),z=t.find(n,[q,q]));for(var K=[],Z=0;Z<R;Z++){for(var X=M[Z],Q=z(X[0],F[0]),ct=1;ct<U;ct++)Q=W(Q,z(X[ct],F[ct]));K[Z]=Q}return E.createDenseMatrix({data:K,size:[R],datatype:T===E._datatype&&O===A._datatype?q:void 0})}function w(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._data,O=A._size,R=A._datatype||A.getDataType(),U=S[0],q=S[1],W=O[1],z,K=r,Z=n;T&&R&&T===R&&typeof T=="string"&&T!=="mixed"&&T!=="mixed"&&(z=T,K=t.find(r,[z,z]),Z=t.find(n,[z,z]));for(var X=[],Q=0;Q<U;Q++){var ct=M[Q];X[Q]=[];for(var vt=0;vt<W;vt++){for(var lt=Z(ct[0],F[0][vt]),wt=1;wt<q;wt++)lt=K(lt,Z(ct[wt],F[wt][vt]));X[Q][vt]=lt}}return E.createDenseMatrix({data:X,size:[U,W],datatype:T===E._datatype&&R===A._datatype?z:void 0})}function v(E,A){var M=E._data,S=E._size,T=E._datatype||E.getDataType(),F=A._values,O=A._index,R=A._ptr,U=A._size,q=A._datatype||A._data===void 0?A._datatype:A.getDataType();if(!F)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=S[0],z=U[1],K,Z=r,X=n,Q=i,ct=0;T&&q&&T===q&&typeof T=="string"&&T!=="mixed"&&(K=T,Z=t.find(r,[K,K]),X=t.find(n,[K,K]),Q=t.find(i,[K,K]),ct=t.convert(0,K));for(var vt=[],lt=[],wt=[],bt=A.createSparseMatrix({values:vt,index:lt,ptr:wt,size:[W,z],datatype:T===E._datatype&&q===A._datatype?K:void 0}),Bt=0;Bt<z;Bt++){wt[Bt]=lt.length;var xt=R[Bt],oe=R[Bt+1];if(oe>xt)for(var It=0,Nt=0;Nt<W;Nt++){for(var ce=Nt+1,re=void 0,qt=xt;qt<oe;qt++){var Jt=O[qt];It!==ce?(re=X(M[Nt][Jt],F[qt]),It=ce):re=Z(re,X(M[Nt][Jt],F[qt]))}It===ce&&!Q(re,ct)&&(lt.push(Nt),vt.push(re))}}return wt[z]=lt.length,bt}function x(E,A){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=A._data,R=A._datatype||A.getDataType(),U=E._size[0],q=A._size[0],W=[],z=[],K=[],Z,X=r,Q=n,ct=i,vt=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(Z=F,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]),ct=t.find(i,[Z,Z]),vt=t.convert(0,Z));var lt=[],wt=[];K[0]=0;for(var bt=0;bt<q;bt++){var Bt=O[bt];if(!ct(Bt,vt))for(var xt=T[bt],oe=T[bt+1],It=xt;It<oe;It++){var Nt=S[It];wt[Nt]?lt[Nt]=X(lt[Nt],Q(Bt,M[It])):(wt[Nt]=!0,z.push(Nt),lt[Nt]=Q(Bt,M[It]))}}for(var ce=z.length,re=0;re<ce;re++){var qt=z[re];W[re]=lt[qt]}return K[1]=z.length,E.createSparseMatrix({values:W,index:z,ptr:K,size:[U,1],datatype:F===E._datatype&&R===A._datatype?Z:void 0})}function b(E,A){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=A._data,R=A._datatype||A.getDataType(),U=E._size[0],q=A._size[0],W=A._size[1],z,K=r,Z=n,X=i,Q=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(z=F,K=t.find(r,[z,z]),Z=t.find(n,[z,z]),X=t.find(i,[z,z]),Q=t.convert(0,z));for(var ct=[],vt=[],lt=[],wt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[U,W],datatype:F===E._datatype&&R===A._datatype?z:void 0}),bt=[],Bt=[],xt=0;xt<W;xt++){lt[xt]=vt.length;for(var oe=xt+1,It=0;It<q;It++){var Nt=O[It][xt];if(!X(Nt,Q))for(var ce=T[It],re=T[It+1],qt=ce;qt<re;qt++){var Jt=S[qt];Bt[Jt]!==oe?(Bt[Jt]=oe,vt.push(Jt),bt[Jt]=Z(Nt,M[qt])):bt[Jt]=K(bt[Jt],Z(Nt,M[qt]))}}for(var $e=lt[xt],vr=vt.length,ze=$e;ze<vr;ze++){var pn=vt[ze];ct[ze]=bt[pn]}}return lt[W]=vt.length,wt}function N(E,A){var M=E._values,S=E._index,T=E._ptr,F=E._datatype||E._data===void 0?E._datatype:E.getDataType(),O=A._values,R=A._index,U=A._ptr,q=A._datatype||A._data===void 0?A._datatype:A.getDataType(),W=E._size[0],z=A._size[1],K=M&&O,Z,X=r,Q=n;F&&q&&F===q&&typeof F=="string"&&F!=="mixed"&&(Z=F,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]));for(var ct=K?[]:void 0,vt=[],lt=[],wt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[W,z],datatype:F===E._datatype&&q===A._datatype?Z:void 0}),bt=K?[]:void 0,Bt=[],xt,oe,It,Nt,ce,re,qt,Jt,$e=0;$e<z;$e++){lt[$e]=vt.length;var vr=$e+1;for(ce=U[$e],re=U[$e+1],Nt=ce;Nt<re;Nt++)if(Jt=R[Nt],K)for(oe=T[Jt],It=T[Jt+1],xt=oe;xt<It;xt++)qt=S[xt],Bt[qt]!==vr?(Bt[qt]=vr,vt.push(qt),bt[qt]=Q(O[Nt],M[xt])):bt[qt]=X(bt[qt],Q(O[Nt],M[xt]));else for(oe=T[Jt],It=T[Jt+1],xt=oe;xt<It;xt++)qt=S[xt],Bt[qt]!==vr&&(Bt[qt]=vr,vt.push(qt));if(K)for(var ze=lt[$e],pn=vt.length,On=ze;On<pn;On++){var dn=vt[On];ct[On]=bt[dn]}}return lt[z]=vt.length,wt}return t(Gc,n,{"Array, Array":t.referTo("Matrix, Matrix",E=>(A,M)=>{h(Ie(A),Ie(M));var S=E(e(A),e(M));return ve(S)?S.valueOf():S}),"Matrix, Matrix":function(A,M){var S=A.size(),T=M.size();return h(S,T),S.length===1?T.length===1?p(A,M,S[0]):f(A,M):T.length===1?g(A,M):y(A,M)},"Matrix, Array":t.referTo("Matrix,Matrix",E=>(A,M)=>E(A,e(M))),"Array, Matrix":t.referToSelf(E=>(A,M)=>E(e(A,M.storage()),M)),"SparseMatrix, any":function(A,M){return l(A,M,n,!1)},"DenseMatrix, any":function(A,M){return c(A,M,n,!1)},"any, SparseMatrix":function(A,M){return l(M,A,n,!0)},"any, DenseMatrix":function(A,M){return c(M,A,n,!0)},"Array, any":function(A,M){return c(e(A),M,n,!1).valueOf()},"any, Array":function(A,M){return c(e(M),A,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(E=>(A,M,S)=>{for(var T=E(A,M),F=0;F<S.length;F++)T=E(T,S[F]);return T})})}),Hc="subtract",Sg=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],Bg=mt(Hc,Sg,s=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:i,DenseMatrix:a,concat:l}=s,c=Zc({typed:t}),h=yi({typed:t}),p=Yc({typed:t,equalScalar:r}),f=Kc({typed:t,DenseMatrix:a}),d=vi({typed:t,DenseMatrix:a}),g=Hn({typed:t,matrix:e,concat:l});return t(Hc,{"any, any":n},g({elop:n,SS:p,DS:c,SD:h,Ss:d,sS:f}))}),Og="matAlgo07xSSf",Ig=["typed","DenseMatrix"],Ws=mt(Og,Ig,s=>{var{typed:t,DenseMatrix:e}=s;return function(i,a,l){var c=i._size,h=i._datatype||i._data===void 0?i._datatype:i.getDataType(),p=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==p.length)throw new Ht(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+p+")");var d=c[0],g=c[1],y,m=0,w=l;typeof h=="string"&&h===f&&h!=="mixed"&&(y=h,m=t.convert(0,y),w=t.find(l,[y,y]));var v,x,b=[];for(v=0;v<d;v++)b[v]=[];var N=[],E=[],A=[],M=[];for(x=0;x<g;x++){var S=x+1;for(r(i,x,A,N,S),r(a,x,M,E,S),v=0;v<d;v++){var T=A[v]===S?N[v]:m,F=M[v]===S?E[v]:m;b[v][x]=w(T,F)}}return new e({data:b,size:[d,g],datatype:h===i._datatype&&f===a._datatype?y:void 0})};function r(n,i,a,l,c){for(var h=n._values,p=n._index,f=n._ptr,d=f[i],g=f[i+1];d<g;d++){var y=p[d];a[y]=c,l[y]=h[d]}}}),Jc="conj",Tg=["typed"],$g=mt(Jc,Tg,s=>{var{typed:t}=s;return t(Jc,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Yr(r,e))})}),Xc="concat",Lg=["typed","matrix","isInteger"],Rg=mt(Xc,Lg,s=>{var{typed:t,matrix:e,isInteger:r}=s;return t(Xc,{"...Array | Matrix | number | BigNumber":function(i){var a,l=i.length,c=-1,h,p=!1,f=[];for(a=0;a<l;a++){var d=i[a];if(ve(d)&&(p=!0),de(d)||Se(d)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(h=c,c=d.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>h)throw new An(c,h+1)}else{var g=se(d).valueOf(),y=Ie(g);if(f[a]=g,h=c,c=y.length-1,a>0&&c!==h)throw new Ht(h+1,c+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var m=f.shift();f.length;)m=sc(m,f.shift(),c);return p?e(m):m},"...string":function(i){return i.join("")}})}),Qc="count",Pg=["typed","size","prod"],zg=mt(Qc,Pg,s=>{var{typed:t,size:e,prod:r}=s;return t(Qc,{string:function(i){return i.length},"Matrix | Array":function(i){return r(e(i))}})}),tf="identity",kg=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],qg=mt(tf,kg,s=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:i,SparseMatrix:a}=s;return t(tf,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(p){return r(p)},"number | BigNumber":function(p){return c(p,p,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(p,f){return c(p,p,f)},"number | BigNumber, number | BigNumber":function(p,f){return c(p,f,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(p,f,d){return c(p,f,d)},Array:function(p){return l(p)},"Array, string":function(p,f){return l(p,f)},Matrix:function(p){return l(p.valueOf(),p.storage())},"Matrix, string":function(p,f){return l(p.valueOf(),f)}});function l(h,p){switch(h.length){case 0:return p?r(p):[];case 1:return c(h[0],h[0],p);case 2:return c(h[0],h[1],p);default:throw new Error("Vector containing two values expected")}}function c(h,p,f){var d=Se(h)||Se(p)?n:null;if(Se(h)&&(h=h.toNumber()),Se(p)&&(p=p.toNumber()),!De(h)||h<1)throw new Error("Parameters in function identity must be positive integers");if(!De(p)||p<1)throw new Error("Parameters in function identity must be positive integers");var g=d?new n(1):1,y=d?new d(0):0,m=[h,p];if(f){if(f==="sparse")return a.diagonal(m,g,0,y);if(f==="dense")return i.diagonal(m,g,0,y);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var w=da([],m,y),v=h<p?h:p,x=0;x<v;x++)w[x][x]=g;return w}}),ef="kron",Ug=["typed","matrix","multiplyScalar"],Wg=mt(ef,Ug,s=>{var{typed:t,matrix:e,multiplyScalar:r}=s;return t(ef,{"Matrix, Matrix":function(a,l){return e(n(a.toArray(),l.toArray()))},"Matrix, Array":function(a,l){return e(n(a.toArray(),l))},"Array, Matrix":function(a,l){return e(n(a,l.toArray()))},"Array, Array":n});function n(i,a){if(Ie(i).length===1&&(i=[i]),Ie(a).length===1&&(a=[a]),Ie(i).length>2||Ie(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(a.length)+")");var l=[],c=[];return i.map(function(h){return a.map(function(p){return c=[],l.push(c),h.map(function(f){return p.map(function(d){return c.push(r(f,d))})})})})&&l}});function jg(){throw new Error('No "bignumber" implementation available')}function Vg(){throw new Error('No "fraction" implementation available')}function Yg(){throw new Error('No "matrix" implementation available')}var rf="reshape",Zg=["typed","isInteger","matrix"],Kg=mt(rf,Zg,s=>{var{typed:t,isInteger:e}=s;return t(rf,{"Matrix, Array":function(n,i){return n.reshape(i,!0)},"Array, Array":function(n,i){return i.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),ma(n,i)}})}),nf="size",Gg=["typed","config","?matrix"],Hg=mt(nf,Gg,s=>{var{typed:t,config:e,matrix:r}=s;return t(nf,{Matrix:function(i){return i.create(i.size())},Array:Ie,string:function(i){return e.matrix==="Array"?[i.length]:r([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return e.matrix==="Array"?[]:r?r([]):Yg()}})}),sf="transpose",Jg=["typed","matrix"],Xg=mt(sf,Jg,s=>{var{typed:t,matrix:e}=s;return t(sf,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:se});function r(a){var l=a.size(),c;switch(l.length){case 1:c=a.clone();break;case 2:{var h=l[0],p=l[1];if(p===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+fe(l)+")");switch(a.storage()){case"dense":c=n(a,h,p);break;case"sparse":c=i(a,h,p);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+fe(l)+")")}return c}function n(a,l,c){for(var h=a._data,p=[],f,d=0;d<c;d++){f=p[d]=[];for(var g=0;g<l;g++)f[g]=se(h[g][d])}return a.createDenseMatrix({data:p,size:[c,l],datatype:a._datatype})}function i(a,l,c){for(var h=a._values,p=a._index,f=a._ptr,d=h?[]:void 0,g=[],y=[],m=[],w=0;w<l;w++)m[w]=0;var v,x,b;for(v=0,x=p.length;v<x;v++)m[p[v]]++;for(var N=0,E=0;E<l;E++)y.push(N),N+=m[E],m[E]=y[E];for(y.push(N),b=0;b<c;b++)for(var A=f[b],M=f[b+1],S=A;S<M;S++){var T=m[p[S]]++;g[T]=b,h&&(d[T]=se(h[S]))}return a.createSparseMatrix({values:d,index:g,ptr:y,size:[c,l],datatype:a._datatype})}}),of="ctranspose",Qg=["typed","transpose","conj"],tv=mt(of,Qg,s=>{var{typed:t,transpose:e,conj:r}=s;return t(of,{any:function(i){return r(e(i))}})}),af="mode",ev=["typed","isNaN","isNumeric"],rv=mt(af,ev,s=>{var{typed:t,isNaN:e,isNumeric:r}=s;return t(af,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(i){i=va(i.valueOf());var a=i.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},c=[],h=0,p=0;p<i.length;p++){var f=i[p];if(r(f)&&e(f))throw new Error("Cannot calculate mode of an array containing NaN values");f in l||(l[f]=0),l[f]++,l[f]===h?c.push(f):l[f]>h&&(h=l[f],c=[f])}return c}});function Sn(s,t,e){var r;return String(s).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+En(e)+", value: "+JSON.stringify(e)+")":" (type: "+s.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(s).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+En(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):s}var uf="prod",nv=["typed","config","multiplyScalar","numeric"],iv=mt(uf,nv,s=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=s;return t(uf,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(l,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return i(l)}});function i(a){var l;if(Hi(a,function(c){try{l=l===void 0?c:r(l,c)}catch(h){throw Sn(h,"prod",c)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),sv="numeric",ov=["number","?bignumber","?fraction"],av=mt(sv,ov,s=>{var{number:t,bignumber:e,fraction:r}=s,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:a=>t(a),BigNumber:e?a=>e(a):jg,Fraction:r?a=>r(a):Vg};return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",h=arguments.length>2?arguments[2]:void 0;if(h!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var p=En(l);if(!(p in n))throw new TypeError("Cannot convert "+l+' of type "'+p+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in i))throw new TypeError("Cannot convert "+l+' to type "'+c+'"; valid output types are '+Object.keys(i).join(", "));return c===p?l:i[c](l)}}),lf="divideScalar",uv=["typed","numeric"],lv=mt(lf,uv,s=>{var{typed:t,numeric:e}=s;return t(lf,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),cf="pow",cv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],fv=mt(cf,cv,s=>{var{typed:t,config:e,identity:r,multiply:n,matrix:i,inv:a,number:l,fraction:c,Complex:h}=s;return t(cf,{"number, number":p,"Complex, Complex":function(y,m){return y.pow(m)},"BigNumber, BigNumber":function(y,m){return m.isInteger()||y>=0||e.predictable?y.pow(m):new h(y.toNumber(),0).pow(m.toNumber(),0)},"Fraction, Fraction":function(y,m){var w=y.pow(m);if(w!=null)return w;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return p(y.valueOf(),m.valueOf())},"Array, number":f,"Array, BigNumber":function(y,m){return f(y,m.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(y,m){return d(y,m.toNumber())},"Unit, number | BigNumber":function(y,m){return y.pow(m)}});function p(g,y){if(e.predictable&&!De(y)&&g<0)try{var m=c(y),w=l(m);if((y===w||Math.abs((y-w)/y)<1e-14)&&m.d%2===1)return(m.n%2===0?1:-1)*Math.pow(-g,y)}catch{}return e.predictable&&(g<-1&&y===1/0||g>-1&&g<0&&y===-1/0)?NaN:De(y)||g>=0||e.predictable?Tc(g,y):g*g<1&&y===1/0||g*g>1&&y===-1/0?0:new h(g,0).pow(y,0)}function f(g,y){if(!De(y))throw new TypeError("For A^b, b must be an integer (value is "+y+")");var m=Ie(g);if(m.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+m.length+" dimensions)");if(m[0]!==m[1])throw new Error("For A^b, A must be square (size is "+m[0]+"x"+m[1]+")");if(y<0)try{return f(a(g),-y)}catch(x){throw x.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+y+")"):x}for(var w=r(m[0]).valueOf(),v=g;y>=1;)(y&1)===1&&(w=n(v,w)),y>>=1,v=n(v,v);return w}function d(g,y){return i(f(g.valueOf(),y))}}),ff="dotDivide",hv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],pv=mt(ff,hv,s=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:i,concat:a}=s,l=sg({typed:t,equalScalar:r}),c=yi({typed:t}),h=Ws({typed:t,DenseMatrix:i}),p=Ma({typed:t,equalScalar:r}),f=vi({typed:t,DenseMatrix:i}),d=Hn({typed:t,matrix:e,concat:a});return t(ff,d({elop:n,SS:h,DS:c,SD:l,Ss:p,sS:f}))}),js="compare",dv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],_v=mt(js,dv,s=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:i,Fraction:a,DenseMatrix:l,concat:c}=s,h=yi({typed:t}),p=Yc({typed:t,equalScalar:r}),f=vi({typed:t,DenseMatrix:l}),d=Hn({typed:t,matrix:n,concat:c}),g=qs({typed:t});return t(js,mv({typed:t,config:e}),{"boolean, boolean":function(m,w){return m===w?0:m>w?1:-1},"BigNumber, BigNumber":function(m,w){return ks(m,w,e.epsilon)?new i(0):new i(m.cmp(w))},"Fraction, Fraction":function(m,w){return new a(m.compare(w))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,d({SS:p,DS:h,Ss:f}))}),mv=mt(js,["typed","config"],s=>{var{typed:t,config:e}=s;return t(js,{"number, number":function(n,i){return Gn(n,i,e.epsilon)?0:n>i?1:-1}})}),Vs="equal",gv=["typed","matrix","equalScalar","DenseMatrix","concat"],vv=mt(Vs,gv,s=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),h=Hn({typed:t,matrix:e,concat:i});return t(Vs,yv({typed:t,equalScalar:r}),h({elop:r,SS:l,DS:a,Ss:c}))}),yv=mt(Vs,["typed","equalScalar"],s=>{var{typed:t,equalScalar:e}=s;return t(Vs,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:e(n,i)}})}),Ys="smaller",wv=["typed","config","matrix","DenseMatrix","concat"],Dv=mt(Ys,wv,s=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),h=Hn({typed:t,matrix:r,concat:i}),p=qs({typed:t});return t(Ys,bv({typed:t,config:e}),{"boolean, boolean":(f,d)=>f<d,"BigNumber, BigNumber":function(d,g){return d.lt(g)&&!ks(d,g,e.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===-1,"Complex, Complex":function(d,g){throw new TypeError("No ordering relation is defined for complex numbers")}},p,h({SS:l,DS:a,Ss:c}))}),bv=mt(Ys,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Ys,{"number, number":function(n,i){return n<i&&!Gn(n,i,e.epsilon)}})}),Zs="larger",xv=["typed","config","matrix","DenseMatrix","concat"],Ev=mt(Zs,xv,s=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Ws({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),h=Hn({typed:t,matrix:r,concat:i}),p=qs({typed:t});return t(Zs,Av({typed:t,config:e}),{"boolean, boolean":(f,d)=>f>d,"BigNumber, BigNumber":function(d,g){return d.gt(g)&&!ks(d,g,e.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},p,h({SS:l,DS:a,Ss:c}))}),Av=mt(Zs,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Zs,{"number, number":function(n,i){return n>i&&!Gn(n,i,e.epsilon)}})}),hf="deepEqual",Cv=["typed","equal"],Fv=mt(hf,Cv,s=>{var{typed:t,equal:e}=s;return t(hf,{"any, any":function(i,a){return r(i.valueOf(),a.valueOf())}});function r(n,i){if(Array.isArray(n))if(Array.isArray(i)){var a=n.length;if(a!==i.length)return!1;for(var l=0;l<a;l++)if(!r(n[l],i[l]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:e(n,i)}}),pf="partitionSelect",Mv=["typed","isNumeric","isNaN","compare"],Nv=mt(pf,Mv,s=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=s,i=n,a=(h,p)=>-n(h,p);return t(pf,{"Array | Matrix, number":function(p,f){return l(p,f,i)},"Array | Matrix, number, string":function(p,f,d){if(d==="asc")return l(p,f,i);if(d==="desc")return l(p,f,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(h,p,f){if(!De(p)||p<0)throw new Error("k must be a non-negative integer");if(ve(h)){var d=h.size();if(d.length>1)throw new Error("Only one dimensional matrices supported");return c(h.valueOf(),p,f)}if(Array.isArray(h))return c(h,p,f)}function c(h,p,f){if(p>=h.length)throw new Error("k out of bounds");for(var d=0;d<h.length;d++)if(e(h[d])&&r(h[d]))return h[d];for(var g=0,y=h.length-1;g<y;){for(var m=g,w=y,v=h[Math.floor(Math.random()*(y-g+1))+g];m<w;)if(f(h[m],v)>=0){var x=h[w];h[w]=h[m],h[m]=x,--w}else++m;f(h[m],v)>0&&--m,p<=m?y=m:g=m+1}return h[p]}}),df="max",Sv=["typed","config","numeric","larger"],Bv=mt(df,Sv,s=>{var{typed:t,config:e,numeric:r,larger:n}=s;return t(df,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return Fa(c,h.valueOf(),i)},"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function i(l,c){try{return n(l,c)?l:c}catch(h){throw Sn(h,"max",c)}}function a(l){var c;if(Hi(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(p){throw Sn(p,"max",h)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),_f="min",Ov=["typed","config","numeric","smaller"],Iv=mt(_f,Ov,s=>{var{typed:t,config:e,numeric:r,smaller:n}=s;return t(_f,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return Fa(c,h.valueOf(),i)},"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function i(l,c){try{return n(l,c)?l:c}catch(h){throw Sn(h,"min",c)}}function a(l){var c;if(Hi(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(p){throw Sn(p,"min",h)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),mf="add",Tv=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],$v=mt(mf,Tv,s=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:i,SparseMatrix:a,concat:l}=s,c=Zc({typed:t}),h=bg({typed:t,equalScalar:n}),p=Kc({typed:t,DenseMatrix:i}),f=Hn({typed:t,matrix:e,concat:l});return t(mf,{"any, any":r,"any, any, ...any":t.referToSelf(d=>(g,y,m)=>{for(var w=d(g,y),v=0;v<m.length;v++)w=d(w,m[v]);return w})},f({elop:r,DS:c,SS:h,Ss:p}))}),gf="dot",Lv=["typed","addScalar","multiplyScalar","conj","size"],Rv=mt(gf,Lv,s=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:i}=s;return t(gf,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":c});function a(p,f){var d=h(p),g=h(f),y,m;if(d.length===1)y=d[0];else if(d.length===2&&d[1]===1)y=d[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+d.join(", ")+")");if(g.length===1)m=g[0];else if(g.length===2&&g[1]===1)m=g[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+g.join(", ")+")");if(y!==m)throw new RangeError("Vectors must have equal length ("+y+" != "+m+")");if(y===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return y}function l(p,f){var d=a(p,f),g=ve(p)?p._data:p,y=ve(p)?p._datatype||p.getDataType():void 0,m=ve(f)?f._data:f,w=ve(f)?f._datatype||f.getDataType():void 0,v=h(p).length===2,x=h(f).length===2,b=e,N=r;if(y&&w&&y===w&&typeof y=="string"&&y!=="mixed"){var E=y;b=t.find(e,[E,E]),N=t.find(r,[E,E])}if(!v&&!x){for(var A=N(n(g[0]),m[0]),M=1;M<d;M++)A=b(A,N(n(g[M]),m[M]));return A}if(!v&&x){for(var S=N(n(g[0]),m[0][0]),T=1;T<d;T++)S=b(S,N(n(g[T]),m[T][0]));return S}if(v&&!x){for(var F=N(n(g[0][0]),m[0]),O=1;O<d;O++)F=b(F,N(n(g[O][0]),m[O]));return F}if(v&&x){for(var R=N(n(g[0][0]),m[0][0]),U=1;U<d;U++)R=b(R,N(n(g[U][0]),m[U][0]));return R}}function c(p,f){a(p,f);for(var d=p._index,g=p._values,y=f._index,m=f._values,w=0,v=e,x=r,b=0,N=0;b<d.length&&N<y.length;){var E=d[b],A=y[N];if(E<A){b++;continue}if(E>A){N++;continue}E===A&&(w=v(w,x(g[b],m[N])),b++,N++)}return w}function h(p){return ve(p)?p.size():i(p)}}),Pv="trace",zv=["typed","matrix","add"],kv=mt(Pv,zv,s=>{var{typed:t,matrix:e,add:r}=s;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:i,DenseMatrix:n,any:se});function n(a){var l=a._size,c=a._data;switch(l.length){case 1:if(l[0]===1)return se(c[0]);throw new RangeError("Matrix must be square (size: "+fe(l)+")");case 2:{var h=l[0],p=l[1];if(h===p){for(var f=0,d=0;d<h;d++)f=r(f,c[d][d]);return f}else throw new RangeError("Matrix must be square (size: "+fe(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(l)+")")}}function i(a){var l=a._values,c=a._index,h=a._ptr,p=a._size,f=p[0],d=p[1];if(f===d){var g=0;if(l.length>0)for(var y=0;y<d;y++)for(var m=h[y],w=h[y+1],v=m;v<w;v++){var x=c[v];if(x===y){g=r(g,l[v]);break}if(x>y)break}return g}throw new RangeError("Matrix must be square (size: "+fe(p)+")")}}),vf="det",qv=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],Uv=mt(vf,qv,s=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:i,isZero:a,unaryMinus:l}=s;return t(vf,{any:function(p){return se(p)},"Array | Matrix":function(p){var f;switch(ve(p)?f=p.size():Array.isArray(p)?(p=e(p),f=p.size()):f=[],f.length){case 0:return se(p);case 1:if(f[0]===1)return se(p.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+fe(f)+")");case 2:{var d=f[0],g=f[1];if(d===g)return c(p.clone().valueOf(),d);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+fe(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(f)+")")}}});function c(h,p,f){if(p===1)return se(h[0][0]);if(p===2)return r(n(h[0][0],h[1][1]),n(h[1][0],h[0][1]));for(var d=!1,g=new Array(p).fill(0).map((M,S)=>S),y=0;y<p;y++){var m=g[y];if(a(h[m][y])){var w=void 0;for(w=y+1;w<p;w++)if(!a(h[g[w]][y])){m=g[w],g[w]=g[y],g[y]=m,d=!d;break}if(w===p)return h[m][y]}for(var v=h[m][y],x=y===0?1:h[g[y-1]][y-1],b=y+1;b<p;b++)for(var N=g[b],E=y+1;E<p;E++)h[N][E]=i(r(n(h[N][E],v),n(h[N][y],h[m][E])),x)}var A=h[g[p-1]][p-1];return d?l(A):A}}),yf="inv",Wv=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],jv=mt(yf,Wv,s=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:i,unaryMinus:a,det:l,identity:c,abs:h}=s;return t(yf,{"Array | Matrix":function(d){var g=ve(d)?d.size():Ie(d);switch(g.length){case 1:if(g[0]===1)return ve(d)?e([r(1,d.valueOf()[0])]):[r(1,d[0])];throw new RangeError("Matrix must be square (size: "+fe(g)+")");case 2:{var y=g[0],m=g[1];if(y===m)return ve(d)?e(p(d.valueOf(),y,m),d.storage()):p(d,y,m);throw new RangeError("Matrix must be square (size: "+fe(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(g)+")")}},any:function(d){return r(1,d)}});function p(f,d,g){var y,m,w,v,x;if(d===1){if(v=f[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(d===2){var b=l(f);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(f[1][1],b),r(a(f[0][1]),b)],[r(a(f[1][0]),b),r(f[0][0],b)]]}else{var N=f.concat();for(y=0;y<d;y++)N[y]=N[y].concat();for(var E=c(d).valueOf(),A=0;A<g;A++){var M=h(N[A][A]),S=A;for(y=A+1;y<d;)h(N[y][A])>M&&(M=h(N[y][A]),S=y),y++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");y=S,y!==A&&(x=N[A],N[A]=N[y],N[y]=x,x=E[A],E[A]=E[y],E[y]=x);var T=N[A],F=E[A];for(y=0;y<d;y++){var O=N[y],R=E[y];if(y!==A){if(O[A]!==0){for(w=r(a(O[A]),T[A]),m=A;m<g;m++)O[m]=n(O[m],i(w,T[m]));for(m=0;m<g;m++)R[m]=n(R[m],i(w,F[m]))}}else{for(w=T[A],m=A;m<g;m++)O[m]=r(O[m],w);for(m=0;m<g;m++)R[m]=r(R[m],w)}}}return E}}}),wf="pinv",Vv=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],Yv=mt(wf,Vv,s=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:i,dotDivide:a,dot:l,ctranspose:c,divideScalar:h,multiply:p,add:f,Complex:d}=s;return t(wf,{"Array | Matrix":function(b){var N=ve(b)?b.size():Ie(b);switch(N.length){case 1:return v(b)?c(b):N[0]===1?r(b):a(c(b),l(b,b));case 2:{if(v(b))return c(b);var E=N[0],A=N[1];if(E===A)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return ve(b)?e(g(b.valueOf(),E,A),b.storage()):g(b,E,A)}default:throw new RangeError("Matrix must be two dimensional (size: "+fe(N)+")")}},any:function(b){return i(b,0)?se(b):h(1,b)}});function g(x,b,N){var{C:E,F:A}=m(x,b,N),M=p(r(p(c(E),E)),c(E)),S=p(c(A),r(p(A,c(A))));return p(S,M)}function y(x,b,N){for(var E=se(x),A=0,M=0;M<b;M++){if(N<=A)return E;for(var S=M;w(E[S][A]);)if(S++,b===S&&(S=M,A++,N===A))return E;[E[S],E[M]]=[E[M],E[S]];for(var T=E[M][A],F=0;F<N;F++)E[M][F]=a(E[M][F],T);for(var O=0;O<b;O++)if(O!==M){T=E[O][A];for(var R=0;R<N;R++)E[O][R]=f(E[O][R],p(-1,p(T,E[M][R])))}A++}return E}function m(x,b,N){var E=y(x,b,N),A=x.map((S,T)=>S.filter((F,O)=>O<b&&!w(l(E[O],E[O])))),M=E.filter((S,T)=>!w(l(E[T],E[T])));return{C:A,F:M}}function w(x){return i(f(x,d(1,1)),f(0,d(1,1)))}function v(x){return n(f(x,d(1,1)),f(p(x,0),d(1,1)))}}),Zv="divide",Kv=["typed","matrix","multiply","equalScalar","divideScalar","inv"],Gv=mt(Zv,Kv,s=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:i,inv:a}=s,l=Ma({typed:t,equalScalar:n}),c=Na({typed:t});return t("divide",zl({"Array | Matrix, Array | Matrix":function(p,f){return r(p,a(f))},"DenseMatrix, any":function(p,f){return c(p,f,i,!1)},"SparseMatrix, any":function(p,f){return l(p,f,i,!1)},"Array, any":function(p,f){return c(e(p),f,i,!1).valueOf()},"any, Array | Matrix":function(p,f){return r(p,a(f))}},i.signatures))}),Df="sum",Hv=["typed","config","add","numeric"],Jv=mt(Df,Hv,s=>{var{typed:t,config:e,add:r,numeric:n}=s;return t(Df,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":a,"...":function(c){if(Rs(c))throw new TypeError("Scalar values expected in function sum");return i(c)}});function i(l){var c;return Hi(l,function(h){try{c=c===void 0?h:r(c,h)}catch(p){throw Sn(p,"sum",h)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(l,c){try{var h=Fa(l,c,r);return h}catch(p){throw Sn(p,"sum")}}}),bf="median",Xv=["typed","add","divide","compare","partitionSelect"],Qv=mt(bf,Xv,s=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:i}=s;function a(h){try{h=va(h.valueOf());var p=h.length;if(p===0)throw new Error("Cannot calculate median of an empty array");if(p%2===0){for(var f=p/2-1,d=i(h,f+1),g=h[f],y=0;y<f;++y)n(h[y],g)>0&&(g=h[y]);return c(g,d)}else{var m=i(h,(p-1)/2);return l(m)}}catch(w){throw Sn(w,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(p){return p}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(p,f){return r(e(p,f),2)}});return t(bf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(p,f){throw new Error("median(A, dim) is not yet supported")},"...":function(p){if(Rs(p))throw new TypeError("Scalar values expected in function median");return a(p)}})}),Ks=tm({config:mr}),Sa=im({}),Ba=um({}),Oa=fm({}),rn=dm({Matrix:Oa}),Mt=n_({BigNumber:Ks,Complex:Sa,DenseMatrix:rn,Fraction:Ba}),t1=Ym({typed:Mt}),Gs=Km({typed:Mt}),e1=Rm({BigNumber:Ks,typed:Mt}),xf=$g({typed:Mt}),Bn=Cm({config:mr,typed:Mt}),Hs=gm({typed:Mt}),r1=Dm({typed:Mt}),Js=Fg({typed:Mt}),Ef=Tm({typed:Mt}),Ia=Nm({Matrix:Oa,equalScalar:Bn,typed:Mt}),Af=Hm({typed:Mt}),Cf=xm({typed:Mt}),Ta=jm({typed:Mt}),Ff=km({Fraction:Ba,typed:Mt}),Mf=ym({typed:Mt}),Te=Um({DenseMatrix:rn,Matrix:Oa,SparseMatrix:Ia,typed:Mt}),Nf=rv({isNaN:Cf,isNumeric:Mf,typed:Mt}),Ji=av({bignumber:e1,fraction:Ff,number:Ef}),n1=iv({config:mr,multiplyScalar:Js,numeric:Ji,typed:Mt}),i1=Kg({isInteger:Hs,matrix:Te,typed:Mt}),Sf=Hg({matrix:Te,config:mr,typed:Mt}),Bf=Xg({matrix:Te,typed:Mt}),Jn=Rg({isInteger:Hs,matrix:Te,typed:Mt}),s1=zg({prod:n1,size:Sf,typed:Mt}),o1=tv({conj:xf,transpose:Bf,typed:Mt}),Xi=lv({numeric:Ji,typed:Mt}),a1=pv({DenseMatrix:rn,concat:Jn,divideScalar:Xi,equalScalar:Bn,matrix:Te,typed:Mt}),Of=vv({DenseMatrix:rn,concat:Jn,equalScalar:Bn,matrix:Te,typed:Mt}),If=qg({BigNumber:Ks,DenseMatrix:rn,SparseMatrix:Ia,config:mr,matrix:Te,typed:Mt}),u1=Wg({matrix:Te,multiplyScalar:Js,typed:Mt}),l1=Dv({DenseMatrix:rn,concat:Jn,config:mr,matrix:Te,typed:Mt}),c1=Bg({DenseMatrix:rn,concat:Jn,equalScalar:Bn,matrix:Te,subtractScalar:Af,typed:Mt,unaryMinus:Ta}),Qi=$v({DenseMatrix:rn,SparseMatrix:Ia,addScalar:Gs,concat:Jn,equalScalar:Bn,matrix:Te,typed:Mt}),Tf=_v({BigNumber:Ks,DenseMatrix:rn,Fraction:Ba,concat:Jn,config:mr,equalScalar:Bn,matrix:Te,typed:Mt}),f1=Fv({equal:Of,typed:Mt}),$f=Rv({addScalar:Gs,conj:xf,multiplyScalar:Js,size:Sf,typed:Mt}),h1=Ev({DenseMatrix:rn,concat:Jn,config:mr,matrix:Te,typed:Mt}),$a=Iv({config:mr,numeric:Ji,smaller:l1,typed:Mt}),wi=Ng({addScalar:Gs,dot:$f,equalScalar:Bn,matrix:Te,multiplyScalar:Js,typed:Mt}),p1=Nv({compare:Tf,isNaN:Cf,isNumeric:Mf,typed:Mt}),d1=Jv({add:Qi,config:mr,numeric:Ji,typed:Mt}),_1=kv({add:Qi,matrix:Te,typed:Mt}),Lf=Uv({divideScalar:Xi,isZero:r1,matrix:Te,multiply:wi,subtractScalar:Af,typed:Mt,unaryMinus:Ta}),m1=Bv({config:mr,larger:h1,numeric:Ji,typed:Mt}),Xs=jv({abs:t1,addScalar:Gs,det:Lf,divideScalar:Xi,identity:If,matrix:Te,multiply:wi,typed:Mt,unaryMinus:Ta}),g1=Yv({Complex:Sa,add:Qi,ctranspose:o1,deepEqual:f1,divideScalar:Xi,dot:$f,dotDivide:a1,equal:Of,inv:Xs,matrix:Te,multiply:wi,typed:Mt}),v1=fv({Complex:Sa,config:mr,fraction:Ff,identity:If,inv:Xs,matrix:Te,multiply:wi,number:Ef,typed:Mt}),y1=Gv({divideScalar:Xi,equalScalar:Bn,inv:Xs,matrix:Te,multiply:wi,typed:Mt}),Rf=Qv({add:Qi,compare:Tf,divide:y1,partitionSelect:p1,typed:Mt});class w1{constructor(t,e,r){$(this,"_cacheData");$(this,"_variables");$(this,"_math");$(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:i},a){if(e===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(t,e,`alma_${a}`);if(l===void 0)return;let c=r*(e-1);i&&(c=Math.floor(c));const h=e/n;let p=0,f=0;for(let d=0;d<=e-1;d++){const g=Math.exp(-1*Math.pow(d-c,2)/(2*Math.pow(h,2)));p+=g,f+=l[l.length-1-(e-d-1)]*g}return f/p}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const i=this._cacheDataList(t,e,`sma_${r}`);if(i===void 0)return;const a=i.slice(-e);return n=d1(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;this._cacheDataList(t,e,`sma_${r}`);const{sum:n}=this._cacheData[`rma_${r}`]||{},i=1/e,a=n===void 0?this.sma({source:t,length:e},r):i*t+(1-i)*(n||0);return this._cacheDataHandle(`rma_${r}`,{sum:a}),a}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:i,close:a,low:l}=this._variables,c=r===void 0?i-l:Math.max(Math.max(i-l,Math.abs(i-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:i,close:a}),this.rma({source:c,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const i=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(i===void 0)return;let l=0;for(let c=0;c<e;c++){const h=this._sum(i[i.length-1-c],-(a||0));l+=h*h}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const i=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(i===void 0||a===void 0)return[];const l=r*a;return[i,i+l,i-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const i=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(i===void 0||a===void 0)return;const l=r*a;return(i+l-(i-l))/i}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),i=this.dev({source:t,length:e},r);if(!(n===void 0||i===void 0))return(t-n)/(.015*i)}change({source:t,length:e=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const i=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return i===void 0?i:typeof t=="boolean"?i!==t:t-i}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const i=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(i===void 0||a===void 0))return 100*(i-a)/(i+a)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),i=this._math.sum({source:t,length:e},r);if(i===void 0||n===void 0)return;let a=0;for(let l=0;l<e;l++){const c=n[n.length-1-l];a+=c*(l+1)}return-a/i}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const i=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),l=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||l===void 0||i===void 0)return;let c=0,h=0,p=0;for(let d=0;d<r;d++){const[g,y]=i[i.length-1-d],m=g-a,w=y-l;c+=m*w,h+=m*m,p+=w*w}return isNaN(h)||isNaN(c)||isNaN(p)?void 0:c/Math.sqrt(h*p)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n>=i&&t<e||n<=i&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n<=i&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||i===void 0?!1:n>=i&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let i=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let l=0;l<e;l++){const c=a[a.length-1-l];i+=Math.abs(c-n)}return i/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:i,high:a,close:l,PDMS:c,NDMS:h,TRS:p,ADX:f,count:d=0}=this._cacheData[n]||{},{low:g,high:y,close:m}=this._variables;if(i===void 0||a===void 0||l===void 0)return this._cacheData[n]={low:g,high:y,close:m,PDMS:c,NDMS:h,TRS:y-g,count:1},[void 0,void 0,void 0];let w=y-a,v=i-g;w=w>v&&w>0?w:0,v=v>w&&v>0?v:0,w===v&&(w=v=0);const x=Math.max(y-g,Math.abs(y-l),Math.abs(g-l));if(d<t)return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:(c||0)+w,NDMS:(h||0)+v,TRS:(p||0)+x,count:d+1}),[void 0,void 0,void 0];{const b=c-c/t+w,N=h-h/t+v,E=p-p/t+x,A=b/E*100,M=N/E*100,S=Math.abs((A-M)/(A+M))*100;let T=S,F=[A,M,void 0];if(d+1-t<e){const O=d+1-t;T=((f||0)*(O-1)+S)/O}else T=(f*(e-1)+S)/e,F=[A,M,T];return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:b,NDMS:N,TRS:E,ADX:T,count:d+1}),F}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:i=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:t,length:e},r);if(i>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=a;return i+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:i}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:i=[]}=this._cacheData[`falling_${r}`]||{};i.push(n>t);const a=i.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:a}),a.length<e?!1:a.every(l=>l)}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,risings:i=[]}=this._cacheData[`rising_${r}`]||{};i.push(n<t);const a=i.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,risings:a}),a.length<e?!1:a.every(l=>l)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`highest_${r}`);if(i)return Math.max(...i.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`highestbars_${r}`);return i?i.slice(-e).reduce((l,c,h,p)=>c>=p[l]?h:l,0)-e+1:void 0}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let i=0,a=0;for(let l=0;l<e;l++){const c=(e-l)*e;i+=c,a+=n[n.length-1-l]*c}return a/i}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),i=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||i===void 0?void 0:this.wma({source:2*i-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},i){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},i),{ta:l,high:c,low:h}=this._variables,p=n?l.tr:c-h,f=this.ema({source:p,length:e},`range_${i}`);return[a,a+f*r,a-f*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},i){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},i),{ta:l,high:c,low:h}=this._variables,p=n?l.tr:c-h,f=this.ema({source:p,length:e},`range_${i}`);return(a+f*r-(a-f*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const i=this._cacheDataList(t,e,`dev_${n}`);if(!i)return;const a=i.slice(-e).filter(g=>g!==void 0);let l=0,c=0,h=0,p=0;for(const[g,y]of a.entries())l+=g,c+=y,h+=g*y,p+=g*g;const f=(e*h-l*c)/(e*p-l*l);return(c-f*l)/e+f*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`lowest_${r}`);if(i)return Math.min(...i.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,i=this._cacheDataList(typeof t!="number"?n:t,e,`lowestbars_${r}`);return i?i.slice(-e).reduce((l,c,h,p)=>c<=p[l]?h:l,0)-e+1:void 0}macd({source:t,fastlen:e,slowlen:r,siglen:n},i){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${i}`),l=this.ema({source:t,length:r},`ema2_${i}`);if(a===void 0||l===void 0)return[void 0,void 0,void 0];const c=a-l,h=this.ema({source:c,length:n},`macd_${i}`);if(h===void 0)return[c,h,void 0];const p=c-h;return[c,h,p]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Rf(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,i=this.change({source:t},r),a=this._math.sum({source:n*(i>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(i<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||a===void 0))return 100-100/(1+l/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return $a(Nf(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,i=this._cacheData[n]||[];if(i[this._variables.bar_index]=t,this._cacheData[n]=i,i.length<=e||t===void 0||isNaN(t))return;let a=i.length-e-1,l;for(;l===void 0&&a>=0;)l=i[a],a--;return l===void 0?l:t-l}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const i=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!i)return;const a=this._sort(i.slice(-(e+1))),l=a.length;r/=100;const c=1/(l*2);if(r<=c)return a[0];if(r>=1-1/(l*2))return a[l-1];for(const[h,p]of a.entries()){const f=a[h-1];if(r<(h+.5)/l)return f===void 0||p===void 0?void 0:f+(p-f)*(r-(h-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const i=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!i)return;const a=this._sort(i.slice(-e)),l=r/100*a.length,c=Math.ceil(l)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const i=n.slice(-(e+1)),a=t;if(a===void 0)return;let l=0;for(let c=0;c<i.length;c++)i[c]!==void 0&&(i[c]<a||i[c]===a&&c<e)&&l++;return l/(i.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const i=new Qt;let{close:a,open:l,low:c,high:h}=this._variables;const p=`pivot_point_levels_${n}`,{close:f,low:d,high:g,open:y,result:m}=this._cacheData[p]||{};if(!e&&(g&&d&&(h=Math.max(g,h),c=Math.min(d,c)),this._cacheDataHandle(p,{close:a,open:l,low:c,high:h,result:m}),!r))return i._value=m||[],i;const w={close:a,open:l,low:c,high:h};e===!0&&!r&&(a=f,l=y,c=d,h=g);const v=this._getPivotPointLevels(h,c,a,l,r,t);return this._cacheDataHandle(p,{...w,result:v}),i._value=v,i}_getPivotPointLevels(t,e,r,n,i,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Kn.traditional:return this._traditional(t,e,r);case Kn.fibonacci:return this._fibonacci(t,e,r);case Kn.woodie:return i?[]:this._woodie(t,e);case Kn.classic:return this._classic(t,e,r);case Kn.dm:return this._DM(t,e,r,n);case Kn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,i=n*2-e,a=n+(t-e),l=n*2+(t-2*e),c=n*3+(t-3*e),h=n*4+(t-4*e),p=n*2-t,f=n-(t-e),d=n*2-(2*t-e),g=n*3-(3*t-e),y=n*4-(4*t-e);return[n,i,p,a,f,l,d,c,g,h,y]}_fibonacci(t,e,r){const n=(t+e+r)/3,i=n+.382*(t-e),a=n-.382*(t-e),l=n+.618*(t-e),c=n-.618*(t-e),h=n+(t-e),p=n-(t-e);return[n,i,a,l,c,h,p]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,i=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=t+2*(n-e),p=e-2*(t-n),f=h+(t-e),d=p-(t-e);return[n,i,a,l,c,h,p,f,d]}_classic(t,e,r){const n=(t+e+r)/3,i=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=n+2*(t-e),p=n-2*(t-e),f=n+3*(t-e),d=n-3*(t-e);return[n,i,a,l,c,h,p,f,d]}_DM(t,e,r,n){let i;n===r?i=t+e+2*r:r>n?i=2*t+e+r:i=2*e+t+r;const a=i/4,l=i/2-e,c=i/2-t;return[a,l,c]}_camarilla(t,e,r){const n=(t+e+r)/3,i=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,c=r-1.1*(t-e)/6,h=r+1.1*(t-e)/4,p=r-1.1*(t-e)/4,f=r+1.1*(t-e)/2,d=r-1.1*(t-e)/2,g=t/e*r,y=r-(g-r);return[n,i,a,l,c,h,p,f,d,g,y]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const i=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!i)return;const a=i.slice(-(e+r+1)),l=a[e];return Math.max(...a)===l?l:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const i=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!i)return;const a=i.slice(-(e+r+1)),l=a[e];return Math.min(...a)===l?l:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`,!0);if(!n)return;const i=n.filter(c=>c!==void 0).slice(-e),a=Math.max(...i),l=Math.min(...i);return a-l}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),i=this.change({source:t,length:e},r);if(n)return 100*i/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},i=Math.max(t-n,0),a=Math.max(n-t,0),l=this.rma({source:i,length:e},`rma1_${r}`),c=this.rma({source:a,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||c===void 0))return 100-100/(1+l/c)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:i,low:a,high:l,preLow:c,preHigh:h,data:p={}}=this._cacheData[`sar_${n}`]||{};let{result:f,maxMin:d,acceleration:g,isBelow:y}=p,m=!1;const{close:w,low:v,high:x,bar_index:b}=this._variables;return b===1&&(w>i?(y=!0,d=x,f=a):(y=!1,d=v,f=l),m=!0,g=t),f=f+g*(d-f),y?f>v&&(m=!0,y=!1,f=Math.max(x,d||0),d=v,g=t):f<x&&(m=!0,y=!0,f=Math.min(v,d||0),d=x,g=t),m||(y?x>(d||0)&&(d=x,g=Math.min((g||0)+e,r)):v<(d||0)&&(d=v,g=Math.min((g||0)+e,r))),y?(f=Math.min(f,a),b>1&&(f=Math.min(f,c))):(f=Math.max(f,l),b>1&&(f=Math.max(f,h))),this._cacheDataHandle(`sar_${n}`,{high:x,close:w,low:v,preLow:a,preHigh:l,data:Object.assign(p,{result:f,maxMin:d,acceleration:g,isBelow:y})}),f}stoch({source:t,high:e,low:r,length:n},i){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const a=this.lowest({source:r,length:n},i),l=this.highest({source:e,length:n},i);if(!(a===void 0||l===void 0))return 100*(this._variables.close-a)/(l-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:i}=this._variables,a=`supertrend_${r}`,{upperBand:l,lowerBand:c,superTrend:h,atr:p,close:f}=this._cacheData[a]||{},d=this.atr({length:e},r);if(d===void 0)return this._cacheDataHandle(a,{close:i}),[void 0,void 0];let g=n+t*d,y=n-t*d;const m=l||0,w=c||0;y=y>w||f<w?y:w,g=g<m||f>m?g:m;let v;p===void 0?v=1:h===m?v=i>g?-1:1:v=i<y?1:-1;const x=v===-1?y:g;return this._cacheDataHandle(a,{upperBand:g,lowerBand:y,superTrend:x,atr:d,close:i}),[x,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:i}=this._variables,{close:a}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),a===void 0?t?i-n:void 0:Math.max(i-n,Math.abs(i-a),Math.abs(n-a))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const i=this.change({source:t},n);if(i===void 0)return;const a=this.ema({source:Math.abs(i),length:e},`absema1_${n}`),l=this.ema({source:i,length:e},`ema1_${n}`);if(l===void 0)return;const c=this.ema({source:l,length:r},`ema2_${n}`),h=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/h}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:i}=this._cacheData[`valuewhen_${n}`]||{};return i||(i=[]),t&&i.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:i}),i[i.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const i=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`mode_${n}`,!0);if(!a||i===void 0)return;const l=a.filter(h=>h!==void 0&&!isNaN(h)).slice(-e);if(l.length<e)return;const c=l.reduce((h,p)=>h+Math.pow(p-i,2),0);if(c!==void 0)return r||e<=1?c/e:c/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:i}=this._variables;let{sum:a=0,sumV:l=0,count:c=0,isReset:h,sumS:p=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=l=c=p=0,h=!0),!h)return r!==void 0?[]:void 0;const f=t*i+a,d=i+l,g=f/d;return c++,r!==void 0?(p=i*Math.pow(t,2)+p,this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:h,sumS:p}),this._computeBands(p,d,r,g)):(this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:h}),g)}_computeBands(t,e,r,n){let i=t/e-Math.pow(n,2);i=i<0?0:i;const a=Math.sqrt(i),l=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,l,c]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,i=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(i===void 0||a===void 0))return i/a}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:i}=this._variables;if(!(r===void 0||n===void 0))return(r-i)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let i=0;i<e-r;i++){const{currentVal:a,currentIndex:l}=n,c=t[i];if(c!==void 0){if(a!==void 0&&c<a){t.splice(i,1),t.splice(l,0,c),n={currentIndex:l+1,currentVal:a};continue}n={currentIndex:i,currentVal:c}}}}return t}_cacheDataList(t,e,r,n=!1){const i=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:a}=this._variables;if(i.barIndex<=a&&(i.barIndex===a?i.list[i.list.length-1]=t:i.list.push(t),i.barIndex=a,i.list.length>e+5&&!n&&i.list.shift(),this._cacheData[r]=i),!(i.list.length<e))return i.list}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&!this._variables._isRealTimeBar&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}class D1{constructor(t,e,r){$(this,"_cacheData");$(this,"_variables");$(this,"_errorListener");$(this,"_historyInputs");$(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){if(!(t!=null&&t.length)){self.workerStorage.delete(this._name),this._cacheData={};return}for(const e of t){const r=e.id,n=this._historyInputs[r];(!(e!=null&&e.sourceTypeName)&&(n==null?void 0:n.defval)!==e.defval||n!=null&&n.sourceTypeName&&e.sourceTypeName!==(n==null?void 0:n.sourceTypeName))&&(this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...e,isModify:!0}))}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._cacheHandle(t,e,ir.INT)}bool(t,e){return this._cacheHandle(t,e,ir.BOOL)}color(t,e){return this._cacheHandle(t,e,ir.COLOR)}time(t,e){return this._cacheHandle(t,e,ir.TIME)}float(t,e){return this._cacheHandle(t,e,ir.FLOAT)}price(t,e){return this._cacheHandle(t,e,ir.PRICE)}source(t,e){return this._cacheHandle(t,e,ir.SOURCE)}string(t,e){return this._cacheHandle(t,e,ir.STRING)}symbol(t,e){return this._cacheHandle(t,e,ir.SYMBOL)}session(t,e){return this._cacheHandle(t,e,ir.SESSION)}text_area(t,e){return this._cacheHandle(t,e,ir.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,ir.TIMEFRAME)}enum(t,e){return this._cacheHandle(t,e,ir.ENUM)}_cacheHandle(t,e,r){if(e.startsWith("export"))return t.defval;const n=`${r||"input"}_${e}`,i=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(le.inputDefvalErr,e,zt.Error),self.workerStorage.setValue(this._name,n,{...t}),i)if(!i.isModify)Object.assign(this._cacheData[n],t);else{const a=this._historyInputs[n];!(t.sourceTypeName||a!=null&&a.sourceTypeName)&&t.defval===(a==null?void 0:a.defval)||t.sourceTypeName&&(a==null?void 0:a.sourceTypeName)===t.sourceTypeName?i.sourceTypeName&&(this._cacheData[n].defval=this._variables[i.sourceTypeName]):Object.assign(this._cacheData[n],t)}else{const{defval:a,display:l}=t;this._displayVerify(e,l),t={inputType:r,...t},this._cacheData[n]=t,(r||t.inputType)===ir.SOURCE?this._cacheData[n].options=Zp:t.options&&!t.options.includes(a)&&this._errorListener.addError(Ve(le.inputOptErr,{defval:String(a),args:t.options.toString()}),e,zt.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_displayVerify(t,e){!e||!e.length||e.includes(Ye.dataWindow)||e.includes(Ye.statusLine)||this._errorListener.addError(Ve(le.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),t,zt.Error)}getInputs(){const t=Object.keys(this._cacheData),e=[];for(const r of t){const n=this._cacheData[r];n.id=r,e.push(n)}return e.sort((r,n)=>(r.index||0)-(n.index||0))}}class b1{color({x:t}){return t}new({color:t,transp:e=100}){_t(e)&&(e=100);const r=(100-e)/100,{r:n,g:i,b:a}=this._parseColor(t||"");return`rgba(${Math.round(n)}, ${Math.round(i)}, ${Math.round(a)}, ${r})`}rgb({red:t=0,green:e=0,blue:r=0,transp:n=0}){return _t(n)&&(n=0),_t(t)&&(t=0),_t(e)&&(e=0),_t(r)&&(r=0),`rgba(${t}, ${e}, ${r}, ${(100-n)/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:i}){if(_t(t)||_t(e)||_t(r)||r===e)return"rgba(0,0,0,1)";const a=(t-e)/(r-e),l=Math.min(Math.max(a,0),1),{r:c,g:h,b:p,a:f}=this._parseColor(n||"rgba(0,0,0,0)"),{r:d,g,b:y,a:m}=this._parseColor(i||"rgba(0,0,0,0)"),w=c+l*(d-c),v=h+l*(g-h),x=p+l*(y-p),b=f+l*(m-f);return`rgba(${Math.round(w)}, ${Math.round(v)}, ${Math.round(x)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,i;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:e,g:r,b:n,a:i}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var kt={};const x1=Object.prototype.toString;function ts(s){const t=x1.call(s);return t.endsWith("Array]")&&!t.includes("Big")}var E1=Object.freeze({__proto__:null,isAnyArray:ts}),A1=Ne(E1);function C1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!ts(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],l=r+1;l<i;l++)s[l]>a&&(a=s[l]);return a}function F1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!ts(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],l=r+1;l<i;l++)s[l]<a&&(a=s[l]);return a}function M1(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(ts(s)){if(s.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!ts(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(s.length);var r=F1(s),n=C1(s);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=t.min,a=i===void 0?t.autoMinMax?r:0:i,l=t.max,c=l===void 0?t.autoMinMax?n:1:l;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var h=(c-a)/(n-r),p=0;p<s.length;p++)e[p]=(s[p]-r)*h+a;return e}var N1=Object.freeze({__proto__:null,default:M1}),S1=Ne(N1);Object.defineProperty(kt,"__esModule",{value:!0});var cr=A1,Pf=S1;const Qs=" ".repeat(2),zf=" ".repeat(4);function B1(){return kf(this)}function kf(s,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:i="auto"}=t;return`${s.constructor.name} {
55
- ${Qs}[
56
- ${zf}${O1(s,e,r,n,i)}
57
- ${Qs}]
58
- ${Qs}rows: ${s.rows}
59
- ${Qs}columns: ${s.columns}
60
- }`}function O1(s,t,e,r,n){const{rows:i,columns:a}=s,l=Math.min(i,t),c=Math.min(a,e),h=[];if(n==="auto"){n=!1;t:for(let p=0;p<l;p++)for(let f=0;f<c;f++)if(s.get(p,f)<0){n=!0;break t}}for(let p=0;p<l;p++){let f=[];for(let d=0;d<c;d++)f.push(I1(s.get(p,d),r,n));h.push(`${f.join(" ")}`)}return c!==a&&(h[h.length-1]+=` ... ${a-e} more columns`),l!==i&&h.push(`... ${i-t} more rows`),h.join(`
61
- ${zf}`)}function I1(s,t,e){return(s>=0&&e?` ${qf(s,t-1)}`:qf(s,t)).padEnd(t)}function qf(s,t){let e=s.toString();if(e.length<=t)return e;let r=s.toFixed(t);if(r.length>t&&(r=s.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=s.toExponential(t);return n.length>t&&(n=s.toExponential(Math.max(0,t-(n.length-t)))),n.slice(0)}function T1(s,t){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=t.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 t(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=t.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 t(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=t.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 t(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=t.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 t(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=t.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 t(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=t.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 t(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=t.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 t(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=t.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 t(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=t.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 t(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=t.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 t(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=t.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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(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 t(r).trunc()},s.pow=function(r,n){return new t(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=t.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 Sr(s,t,e){let r=e?s.rows:s.rows-1;if(t<0||t>r)throw new RangeError("Row index out of range")}function Br(s,t,e){let r=e?s.columns:s.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function Di(s,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==s.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function bi(s,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==s.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function La(s,t){if(!cr.isAnyArray(t))throw new TypeError("row indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=s.rows)throw new RangeError("row indices are out of range")}function Ra(s,t){if(!cr.isAnyArray(t))throw new TypeError("column indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=s.columns)throw new RangeError("column indices are out of range")}function Pa(s,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(eo("startRow",t),eo("endRow",e),eo("startColumn",r),eo("endColumn",n),t>e||r>n||t<0||t>=s.rows||e<0||e>=s.rows||r<0||r>=s.columns||n<0||n>=s.columns)throw new RangeError("Submatrix indices are out of range")}function to(s,t=0){let e=[];for(let r=0;r<s;r++)e.push(t);return e}function eo(s,t){if(typeof t!="number")throw new TypeError(`${s} must be a number`)}function xi(s){if(s.isEmpty())throw new Error("Empty matrix has no elements to index")}function $1(s){let t=to(s.rows);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[e]+=s.get(e,r);return t}function L1(s){let t=to(s.columns);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[r]+=s.get(e,r);return t}function R1(s){let t=0;for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)t+=s.get(e,r);return t}function P1(s){let t=to(s.rows,1);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[e]*=s.get(e,r);return t}function z1(s){let t=to(s.columns,1);for(let e=0;e<s.rows;++e)for(let r=0;r<s.columns;++r)t[r]*=s.get(e,r);return t}function k1(s){let t=1;for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)t*=s.get(e,r);return t}function q1(s,t,e){const r=s.rows,n=s.columns,i=[];for(let a=0;a<r;a++){let l=0,c=0,h=0;for(let p=0;p<n;p++)h=s.get(a,p)-e[a],l+=h,c+=h*h;t?i.push((c-l*l/n)/(n-1)):i.push((c-l*l/n)/n)}return i}function U1(s,t,e){const r=s.rows,n=s.columns,i=[];for(let a=0;a<n;a++){let l=0,c=0,h=0;for(let p=0;p<r;p++)h=s.get(p,a)-e[a],l+=h,c+=h*h;t?i.push((c-l*l/r)/(r-1)):i.push((c-l*l/r)/r)}return i}function W1(s,t,e){const r=s.rows,n=s.columns,i=r*n;let a=0,l=0,c=0;for(let h=0;h<r;h++)for(let p=0;p<n;p++)c=s.get(h,p)-e,a+=c,l+=c*c;return t?(l-a*a/i)/(i-1):(l-a*a/i)/i}function j1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t[e])}function V1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t[r])}function Y1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)-t)}function Z1(s){const t=[];for(let e=0;e<s.rows;e++){let r=0;for(let n=0;n<s.columns;n++)r+=Math.pow(s.get(e,n),2)/(s.columns-1);t.push(Math.sqrt(r))}return t}function K1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)/t[e])}function G1(s){const t=[];for(let e=0;e<s.columns;e++){let r=0;for(let n=0;n<s.rows;n++)r+=Math.pow(s.get(n,e),2)/(s.rows-1);t.push(Math.sqrt(r))}return t}function H1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)/t[r])}function J1(s){const t=s.size-1;let e=0;for(let r=0;r<s.columns;r++)for(let n=0;n<s.rows;n++)e+=Math.pow(s.get(n,r),2)/t;return Math.sqrt(e)}function X1(s,t){for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)/t)}class $t{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let i=new pt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)i.set(a,l,r[a*e+l]);return i}static rowVector(t){let e=new pt(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new pt(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new pt(t,e)}static ones(t,e){return new pt(t,e).fill(1)}static rand(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{random:n=Math.random}=r;let i=new pt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)i.set(a,l,n());return i}static randInt(t,e,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 l=i-n,c=new pt(t,e);for(let h=0;h<t;h++)for(let p=0;p<e;p++){let f=n+Math.round(a()*l);c.set(h,p,f)}return c}static eye(t,e,r){e===void 0&&(e=t),r===void 0&&(r=1);let n=Math.min(t,e),i=this.zeros(t,e);for(let a=0;a<n;a++)i.set(a,a,r);return i}static diag(t,e,r){let n=t.length;e===void 0&&(e=n),r===void 0&&(r=e);let i=Math.min(n,e,r),a=this.zeros(e,r);for(let l=0;l<i;l++)a.set(l,l,t[l]);return a}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,i=new pt(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)i.set(a,l,Math.min(t.get(a,l),e.get(a,l)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,i=new this(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)i.set(a,l,Math.max(t.get(a,l),e.get(a,l)));return i}static checkMatrix(t){return $t.isMatrix(t)?t:new pt(t)}static isMatrix(t){return t!=null&&t.klass==="Matrix"}get size(){return this.rows*this.columns}apply(t){if(typeof t!="function")throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 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 t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(this.get(t,t)!==0)return!1;return!0}isEchelonForm(){let t=0,e=0,r=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&i===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(i=!0,r=e):(n=!1,i=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&i===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(i=!0,r=e):(n=!1,i=!0);for(let a=e+1;a<this.rows;a++)this.get(t,a)!==0&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let i=e;i<t.rows;i++)t.get(i,r)>t.get(n,r)&&(n=i);if(t.get(n,r)===0)r++;else{t.swapRows(e,n);let i=t.get(e,r);for(let a=r;a<t.columns;a++)t.set(e,a,t.get(e,a)/i);for(let a=e+1;a<t.rows;a++){let l=t.get(a,r)/t.get(e,r);t.set(a,r,0);for(let c=r+1;c<t.columns;c++)t.set(a,c,t.get(a,c)-t.get(e,c)*l)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(t.maxRow(n)===0)n--;else{let i=0,a=!1;for(;i<r&&a===!1;)t.get(n,i)===1?a=!0:i++;for(let l=0;l<n;l++){let c=t.get(l,i);for(let h=i;h<e;h++){let p=t.get(l,h)-c*t.get(n,h);t.set(l,h,p)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new pt(this.rows*e,this.columns*r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*i,this.columns*a);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Sr(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return pt.rowVector(this.getRow(t))}setRow(t,e){Sr(this,t),e=Di(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Sr(this,t),Sr(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){Br(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return pt.columnVector(this.getColumn(t))}setColumn(t,e){Br(this,t),e=bi(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Br(this,t),Br(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=Di(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=Di(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=Di(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=Di(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=bi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=bi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=bi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=bi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){Sr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Br(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=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)>e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=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)>e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(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));return e}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){xi(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=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)<e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=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)<e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(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));return e}default:throw new Error(`invalid option: ${t}`)}}minIndex(){xi(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(Sr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){Sr(this,t),xi(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(Sr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){Sr(this,t),xi(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(Br(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){Br(this,t),xi(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(Br(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){Br(this,t),xi(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){$t.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=pt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,i=new pt(e,n),a=new Float64Array(r);for(let l=0;l<n;l++){for(let c=0;c<r;c++)a[c]=t.get(c,l);for(let c=0;c<e;c++){let h=0;for(let p=0;p<r;p++)h+=this.get(c,p)*a[p];i.set(c,l,h)}}return i}strassen2x2(t){t=pt.checkMatrix(t);let e=new pt(2,2);const r=this.get(0,0),n=t.get(0,0),i=this.get(0,1),a=t.get(0,1),l=this.get(1,0),c=t.get(1,0),h=this.get(1,1),p=t.get(1,1),f=(r+h)*(n+p),d=(l+h)*n,g=r*(a-p),y=h*(c-n),m=(r+i)*p,w=(l-r)*(n+a),v=(i-h)*(c+p),x=f+y-m+v,b=g+m,N=d+y,E=f-d+g+w;return e.set(0,0,x),e.set(0,1,b),e.set(1,0,N),e.set(1,1,E),e}strassen3x3(t){t=pt.checkMatrix(t);let e=new pt(3,3);const r=this.get(0,0),n=this.get(0,1),i=this.get(0,2),a=this.get(1,0),l=this.get(1,1),c=this.get(1,2),h=this.get(2,0),p=this.get(2,1),f=this.get(2,2),d=t.get(0,0),g=t.get(0,1),y=t.get(0,2),m=t.get(1,0),w=t.get(1,1),v=t.get(1,2),x=t.get(2,0),b=t.get(2,1),N=t.get(2,2),E=(r+n+i-a-l-p-f)*w,A=(r-a)*(-g+w),M=l*(-d+g+m-w-v-x+N),S=(-r+a+l)*(d-g+w),T=(a+l)*(-d+g),F=r*d,O=(-r+h+p)*(d-y+v),R=(-r+h)*(y-v),U=(h+p)*(-d+y),q=(r+n+i-l-c-h-p)*v,W=p*(-d+y+m-w-v-x+b),z=(-i+p+f)*(w+x-b),K=(i-f)*(w-b),Z=i*x,X=(p+f)*(-x+b),Q=(-i+l+c)*(v+x-N),ct=(i-c)*(v-N),vt=(l+c)*(-x+N),lt=n*m,wt=c*b,bt=a*y,Bt=h*g,xt=f*N,oe=F+Z+lt,It=E+S+T+F+z+Z+X,Nt=F+O+U+q+Z+Q+vt,ce=A+M+S+F+Z+Q+ct,re=A+S+T+F+wt,qt=Z+Q+ct+vt+bt,Jt=F+O+R+W+z+K+Z,$e=z+K+Z+X+Bt,vr=F+O+R+U+xt;return e.set(0,0,oe),e.set(0,1,It),e.set(0,2,Nt),e.set(1,0,ce),e.set(1,1,re),e.set(1,2,qt),e.set(2,0,Jt),e.set(2,1,$e),e.set(2,2,vr),e}mmulStrassen(t){t=pt.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,i=t.rows,a=t.columns;n!==i&&console.warn(`Multiplying ${r} x ${n} and ${i} x ${a} matrix: dimensions do not match.`);function l(f,d,g){let y=f.rows,m=f.columns;if(y===d&&m===g)return f;{let w=$t.zeros(d,g);return w=w.setSubMatrix(f,0,0),w}}let c=Math.max(r,i),h=Math.max(n,a);e=l(e,c,h),t=l(t,c,h);function p(f,d,g,y){if(g<=512||y<=512)return f.mmul(d);g%2===1&&y%2===1?(f=l(f,g+1,y+1),d=l(d,g+1,y+1)):g%2===1?(f=l(f,g+1,y),d=l(d,g+1,y)):y%2===1&&(f=l(f,g,y+1),d=l(d,g,y+1));let m=parseInt(f.rows/2,10),w=parseInt(f.columns/2,10),v=f.subMatrix(0,m-1,0,w-1),x=d.subMatrix(0,m-1,0,w-1),b=f.subMatrix(0,m-1,w,f.columns-1),N=d.subMatrix(0,m-1,w,d.columns-1),E=f.subMatrix(m,f.rows-1,0,w-1),A=d.subMatrix(m,d.rows-1,0,w-1),M=f.subMatrix(m,f.rows-1,w,f.columns-1),S=d.subMatrix(m,d.rows-1,w,d.columns-1),T=p($t.add(v,M),$t.add(x,S),m,w),F=p($t.add(E,M),x,m,w),O=p(v,$t.sub(N,S),m,w),R=p(M,$t.sub(A,x),m,w),U=p($t.add(v,b),S,m,w),q=p($t.sub(E,v),$t.add(x,N),m,w),W=p($t.sub(b,M),$t.add(A,S),m,w),z=$t.add(T,R);z.sub(U),z.add(W);let K=$t.add(O,U),Z=$t.add(F,R),X=$t.sub(T,F);X.add(O),X.add(q);let Q=$t.zeros(2*z.rows,2*z.columns);return Q=Q.setSubMatrix(z,0,0),Q=Q.setSubMatrix(K,z.rows,0),Q=Q.setSubMatrix(Z,0,z.columns),Q=Q.setSubMatrix(X,z.rows,z.columns),Q.subMatrix(0,g-1,0,y-1)}return p(e,t,c,h)}scaleRows(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new pt(this.rows,this.columns);for(let i=0;i<this.rows;i++){const a=this.getRow(i);a.length>0&&Pf(a,{min:e,max:r,output:a}),n.setRow(i,a)}return n}scaleColumns(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new pt(this.rows,this.columns);for(let i=0;i<this.columns;i++){const a=this.getColumn(i);a.length&&Pf(a,{min:e,max:r,output:a}),n.setColumn(i,a)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let n=this.get(e,r),i=this.get(e,this.columns-1-r);this.set(e,r,i),this.set(e,this.columns-1-r,n)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let n=this.get(r,e),i=this.get(this.rows-1-r,e);this.set(r,e,i),this.set(this.rows-1-r,e,n)}return this}kroneckerProduct(t){t=pt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,i=t.columns,a=new pt(e*n,r*i);for(let l=0;l<e;l++)for(let c=0;c<r;c++)for(let h=0;h<n;h++)for(let p=0;p<i;p++)a.set(n*l+h,i*c+p,this.get(l,c)*t.get(h,p));return a}kroneckerSum(t){if(t=pt.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(pt.eye(r,r)),i=pt.eye(e,e).kroneckerProduct(t);return n.add(i)}transpose(){let t=new pt(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=Uf){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Uf){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){Pa(this,t,e,r,n);let i=new pt(e-t+1,n-r+1);for(let a=t;a<=e;a++)for(let l=r;l<=n;l++)i.set(a-t,l-r,this.get(a,l));return i}subMatrixRow(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new pt(t.length,r-e+1);for(let i=0;i<t.length;i++)for(let a=e;a<=r;a++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);n.set(i,a-e,this.get(t[i],a))}return n}subMatrixColumn(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new pt(r-e+1,t.length);for(let i=0;i<t.length;i++)for(let a=e;a<=r;a++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);n.set(a-e,i,this.get(a,t[i]))}return n}setSubMatrix(t,e,r){if(t=pt.checkMatrix(t),t.isEmpty())return this;let n=e+t.rows-1,i=r+t.columns-1;Pa(this,e,n,r,i);for(let a=0;a<t.rows;a++)for(let l=0;l<t.columns;l++)this.set(e+a,r+l,t.get(a,l));return this}selection(t,e){La(this,t),Ra(this,e);let r=new pt(t.length,e.length);for(let n=0;n<t.length;n++){let i=t[n];for(let a=0;a<e.length;a++){let l=e[a];r.set(n,a,this.get(i,l))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){return this.constructor.copy(this,new pt(this.rows,this.columns))}static copy(t,e){for(const[r,n,i]of t.entries())e.set(r,n,i);return e}sum(t){switch(t){case"row":return $1(this);case"column":return L1(this);case void 0:return R1(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return P1(this);case"column":return z1(this);case void 0:return k1(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":{for(let r=0;r<this.rows;r++)e[r]/=this.columns;return e}case"column":{for(let r=0;r<this.columns;r++)e[r]/=this.rows;return e}case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if(typeof r!="boolean")throw new TypeError("unbiased must be a boolean");switch(t){case"row":{if(!cr.isAnyArray(n))throw new TypeError("mean must be an array");return q1(this,r,n)}case"column":{if(!cr.isAnyArray(n))throw new TypeError("mean must be an array");return U1(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return W1(this,r,n)}default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){typeof t=="object"&&(e=t,t=void 0);const r=this.variance(t,e);if(t===void 0)return Math.sqrt(r);for(let n=0;n<r.length;n++)r[n]=Math.sqrt(r[n]);return r}center(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":{if(!cr.isAnyArray(r))throw new TypeError("center must be an array");return j1(this,r),this}case"column":{if(!cr.isAnyArray(r))throw new TypeError("center must be an array");return V1(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return Y1(this,r),this}default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":{if(r===void 0)r=Z1(this);else if(!cr.isAnyArray(r))throw new TypeError("scale must be an array");return K1(this,r),this}case"column":{if(r===void 0)r=G1(this);else if(!cr.isAnyArray(r))throw new TypeError("scale must be an array");return H1(this,r),this}case void 0:{if(r===void 0)r=J1(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return X1(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return kf(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}$t.prototype.klass="Matrix",typeof Symbol<"u"&&($t.prototype[Symbol.for("nodejs.util.inspect.custom")]=B1);function Uf(s,t){return s-t}function Q1(s){return s.every(t=>typeof t=="number")}$t.random=$t.rand,$t.randomInt=$t.randInt,$t.diagonal=$t.diag,$t.prototype.diagonal=$t.prototype.diag,$t.identity=$t.eye,$t.prototype.negate=$t.prototype.neg,$t.prototype.tensorProduct=$t.prototype.kroneckerProduct;let pt=(Ni=class extends $t{constructor(e,r){super();Al(this,es);$(this,"data");if(Ni.isMatrix(e))Cl(this,es,Fl).call(this,e.rows,e.columns),Ni.copy(e,this);else if(Number.isInteger(e)&&e>=0)Cl(this,es,Fl).call(this,e,r);else if(cr.isAnyArray(e)){const n=e;if(e=n.length,r=e?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<e;i++){if(n[i].length!==r)throw new RangeError("Inconsistent array dimensions");if(!Q1(n[i]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[i]))}this.rows=e,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(e,r,n){return this.data[e][r]=n,this}get(e,r){return this.data[e][r]}removeRow(e){return Sr(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),Sr(this,e,!0),r=Float64Array.from(Di(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){Br(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let i=0;i<e;i++)n[i]=this.data[r][i];for(let i=e+1;i<this.columns;i++)n[i-1]=this.data[r][i];this.data[r]=n}return this.columns-=1,this}addColumn(e,r){typeof r>"u"&&(r=e,e=this.columns),Br(this,e,!0),r=bi(this,r);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let a=0;for(;a<e;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}},es=new WeakSet,Fl=function(e,r){if(this.data=[],Number.isInteger(r)&&r>=0)for(let n=0;n<e;n++)this.data.push(new Float64Array(r));else throw new TypeError("nColumns must be a positive integer");this.rows=e,this.columns=r},Ni);T1($t,pt);const go=class go extends $t{constructor(e){super();Al(this,Xe,void 0);if(pt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ua(this,Xe,pt.copy(e,new pt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ua(this,Xe,new pt(e,e));else if(ua(this,Xe,new pt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Jr(this,Xe).size}get rows(){return Jr(this,Xe).rows}get columns(){return Jr(this,Xe).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return pt.isMatrix(e)&&e.klassType==="SymmetricMatrix"}static zeros(e){return new this(e)}static ones(e){return new this(e).fill(1)}clone(){const e=new go(this.diagonalSize);for(const[r,n,i]of this.upperRightEntries())e.set(r,n,i);return e}toMatrix(){return new pt(this)}get(e,r){return Jr(this,Xe).get(e,r)}set(e,r,n){return Jr(this,Xe).set(e,r,n),Jr(this,Xe).set(r,e,n),this}removeCross(e){return Jr(this,Xe).removeRow(e),Jr(this,Xe).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),Jr(this,Xe).addRow(e,n),Jr(this,Xe).addColumn(e,r),this}applyMask(e){if(e.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[n,i]of e.entries())i||r.push(n);r.reverse();for(const n of r)this.removeCross(n);return this}toCompact(){const{diagonalSize:e}=this,r=new Array(e*(e+1)/2);for(let n=0,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=e&&(n=++i);return r}static fromCompact(e){const r=e.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(e)}`);const i=new go(n);for(let a=0,l=0,c=0;c<r;c++)i.set(a,l,e[c]),++a>=n&&(a=++l);return i}*upperRightEntries(){for(let e=0,r=0;e<this.diagonalSize;void 0){const n=this.get(e,r);yield[e,r,n],++r>=this.diagonalSize&&(r=++e)}}*upperRightValues(){for(let e=0,r=0;e<this.diagonalSize;void 0)yield this.get(e,r),++r>=this.diagonalSize&&(r=++e)}};Xe=new WeakMap;let Xn=go;Xn.prototype.klassType="SymmetricMatrix";class ro extends Xn{static isDistanceMatrix(t){return Xn.isSymmetricMatrix(t)&&t.klassSubType==="DistanceMatrix"}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return e===void 0&&(e=t,t=this.diagonalSize),e=e.slice(),e[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new Xn(this)}clone(){const t=new ro(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=(t-1)*t/2,r=new Array(e);for(let n=1,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=t&&(n=++i+1);return r}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const n=new this(r);for(let i=1,a=0,l=0;l<e;l++)n.set(i,a,t[l]),++i>=r&&(i=++a+1);return n}}ro.prototype.klassSubType="DistanceMatrix";class fn extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class ty extends fn{constructor(t,e){Br(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}}class ey extends fn{constructor(t,e){Ra(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}}class ry extends fn{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}}class ny extends fn{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}}class iy extends fn{constructor(t,e){Sr(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}}class sy extends fn{constructor(t,e){La(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}}class no extends fn{constructor(t,e,r){La(t,e),Ra(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class oy extends fn{constructor(t,e,r,n,i){Pa(t,e,r,n,i),super(t,r-e+1,i-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}class ay extends fn{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}}class Wf extends $t{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class gr extends $t{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function uy(s,t){if(cr.isAnyArray(s))return s[0]&&cr.isAnyArray(s[0])?new gr(s):new Wf(s,t);throw new Error("the argument is not an array")}class io{constructor(t){t=gr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,i=new Float64Array(r),a=1,l,c,h,p,f,d,g,y,m;for(l=0;l<r;l++)i[l]=l;for(y=new Float64Array(r),c=0;c<n;c++){for(l=0;l<r;l++)y[l]=e.get(l,c);for(l=0;l<r;l++){for(m=Math.min(l,c),f=0,h=0;h<m;h++)f+=e.get(l,h)*y[h];y[l]-=f,e.set(l,c,y[l])}for(p=c,l=c+1;l<r;l++)Math.abs(y[l])>Math.abs(y[p])&&(p=l);if(p!==c){for(h=0;h<n;h++)d=e.get(p,h),e.set(p,h,e.get(c,h)),e.set(c,h,d);g=i[p],i[p]=i[c],i[c]=g,a=-a}if(c<r&&e.get(c,c)!==0)for(l=c+1;l<r;l++)e.set(l,c,e.get(l,c)/e.get(c,c))}this.LU=e,this.pivotVector=i,this.pivotSign=a}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(t.get(r,r)===0)return!0;return!1}solve(t){t=pt.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n=t.columns,i=t.subMatrixRow(this.pivotVector,0,n-1),a=e.columns,l,c,h;for(h=0;h<a;h++)for(l=h+1;l<a;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(h,c)*e.get(l,h));for(h=a-1;h>=0;h--){for(c=0;c<n;c++)i.set(h,c,i.get(h,c)/e.get(h,h));for(l=0;l<h;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(h,c)*e.get(l,h))}return i}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new pt(e,r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)i>a?n.set(i,a,t.get(i,a)):i===a?n.set(i,a,1):n.set(i,a,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new pt(e,r);for(let i=0;i<e;i++)for(let a=0;a<r;a++)i<=a?n.set(i,a,t.get(i,a)):n.set(i,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function hn(s,t){let e=0;return Math.abs(s)>Math.abs(t)?(e=t/s,Math.abs(s)*Math.sqrt(1+e*e)):t!==0?(e=s/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class za{constructor(t){t=gr.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,i=new Float64Array(n),a,l,c,h;for(c=0;c<n;c++){let p=0;for(a=c;a<r;a++)p=hn(p,e.get(a,c));if(p!==0){for(e.get(c,c)<0&&(p=-p),a=c;a<r;a++)e.set(a,c,e.get(a,c)/p);for(e.set(c,c,e.get(c,c)+1),l=c+1;l<n;l++){for(h=0,a=c;a<r;a++)h+=e.get(a,c)*e.get(a,l);for(h=-h/e.get(c,c),a=c;a<r;a++)e.set(a,l,e.get(a,l)+h*e.get(a,c))}}i[c]=-p}this.QR=e,this.Rdiag=i}solve(t){t=pt.checkMatrix(t);let e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n=t.columns,i=t.clone(),a=e.columns,l,c,h,p;for(h=0;h<a;h++)for(c=0;c<n;c++){for(p=0,l=h;l<r;l++)p+=e.get(l,h)*i.get(l,c);for(p=-p/e.get(h,h),l=h;l<r;l++)i.set(l,c,i.get(l,c)+p*e.get(l,h))}for(h=a-1;h>=0;h--){for(c=0;c<n;c++)i.set(h,c,i.get(h,c)/this.Rdiag[h]);for(l=0;l<h;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(h,c)*e.get(l,h))}return i.subMatrix(0,a-1,0,n-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(this.Rdiag[e]===0)return!1;return!0}get upperTriangularMatrix(){let t=this.QR,e=t.columns,r=new pt(e,e),n,i;for(n=0;n<e;n++)for(i=0;i<e;i++)n<i?r.set(n,i,t.get(n,i)):n===i?r.set(n,i,this.Rdiag[n]):r.set(n,i,0);return r}get orthogonalMatrix(){let t=this.QR,e=t.rows,r=t.columns,n=new pt(e,r),i,a,l,c;for(l=r-1;l>=0;l--){for(i=0;i<e;i++)n.set(i,l,0);for(n.set(l,l,1),a=l;a<r;a++)if(t.get(l,l)!==0){for(c=0,i=l;i<e;i++)c+=t.get(i,l)*n.get(i,a);for(c=-c/t.get(l,l),i=l;i<e;i++)n.set(i,a,n.get(i,a)+c*t.get(i,l))}}return n}}class Ei{constructor(t,e={}){if(t=gr.checkMatrix(t),t.isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:a=!0,autoTranspose:l=!1}=e;let c=!!i,h=!!a,p=!1,f;if(r<n)if(!l)f=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{f=t.transpose(),r=f.rows,n=f.columns,p=!0;let F=c;c=h,h=F}else f=t.clone();let d=Math.min(r,n),g=Math.min(r+1,n),y=new Float64Array(g),m=new pt(r,d),w=new pt(n,n),v=new Float64Array(n),x=new Float64Array(r),b=new Float64Array(g);for(let F=0;F<g;F++)b[F]=F;let N=Math.min(r-1,n),E=Math.max(0,Math.min(n-2,r)),A=Math.max(N,E);for(let F=0;F<A;F++){if(F<N){y[F]=0;for(let O=F;O<r;O++)y[F]=hn(y[F],f.get(O,F));if(y[F]!==0){f.get(F,F)<0&&(y[F]=-y[F]);for(let O=F;O<r;O++)f.set(O,F,f.get(O,F)/y[F]);f.set(F,F,f.get(F,F)+1)}y[F]=-y[F]}for(let O=F+1;O<n;O++){if(F<N&&y[F]!==0){let R=0;for(let U=F;U<r;U++)R+=f.get(U,F)*f.get(U,O);R=-R/f.get(F,F);for(let U=F;U<r;U++)f.set(U,O,f.get(U,O)+R*f.get(U,F))}v[O]=f.get(F,O)}if(c&&F<N)for(let O=F;O<r;O++)m.set(O,F,f.get(O,F));if(F<E){v[F]=0;for(let O=F+1;O<n;O++)v[F]=hn(v[F],v[O]);if(v[F]!==0){v[F+1]<0&&(v[F]=0-v[F]);for(let O=F+1;O<n;O++)v[O]/=v[F];v[F+1]+=1}if(v[F]=-v[F],F+1<r&&v[F]!==0){for(let O=F+1;O<r;O++)x[O]=0;for(let O=F+1;O<r;O++)for(let R=F+1;R<n;R++)x[O]+=v[R]*f.get(O,R);for(let O=F+1;O<n;O++){let R=-v[O]/v[F+1];for(let U=F+1;U<r;U++)f.set(U,O,f.get(U,O)+R*x[U])}}if(h)for(let O=F+1;O<n;O++)w.set(O,F,v[O])}}let M=Math.min(n,r+1);if(N<n&&(y[N]=f.get(N,N)),r<M&&(y[M-1]=0),E+1<M&&(v[E]=f.get(E,M-1)),v[M-1]=0,c){for(let F=N;F<d;F++){for(let O=0;O<r;O++)m.set(O,F,0);m.set(F,F,1)}for(let F=N-1;F>=0;F--)if(y[F]!==0){for(let O=F+1;O<d;O++){let R=0;for(let U=F;U<r;U++)R+=m.get(U,F)*m.get(U,O);R=-R/m.get(F,F);for(let U=F;U<r;U++)m.set(U,O,m.get(U,O)+R*m.get(U,F))}for(let O=F;O<r;O++)m.set(O,F,-m.get(O,F));m.set(F,F,1+m.get(F,F));for(let O=0;O<F-1;O++)m.set(O,F,0)}else{for(let O=0;O<r;O++)m.set(O,F,0);m.set(F,F,1)}}if(h)for(let F=n-1;F>=0;F--){if(F<E&&v[F]!==0)for(let O=F+1;O<n;O++){let R=0;for(let U=F+1;U<n;U++)R+=w.get(U,F)*w.get(U,O);R=-R/w.get(F+1,F);for(let U=F+1;U<n;U++)w.set(U,O,w.get(U,O)+R*w.get(U,F))}for(let O=0;O<n;O++)w.set(O,F,0);w.set(F,F,1)}let S=M-1,T=Number.EPSILON;for(;M>0;){let F,O;for(F=M-2;F>=-1&&F!==-1;F--){const R=Number.MIN_VALUE+T*Math.abs(y[F]+Math.abs(y[F+1]));if(Math.abs(v[F])<=R||Number.isNaN(v[F])){v[F]=0;break}}if(F===M-2)O=4;else{let R;for(R=M-1;R>=F&&R!==F;R--){let U=(R!==M?Math.abs(v[R]):0)+(R!==F+1?Math.abs(v[R-1]):0);if(Math.abs(y[R])<=T*U){y[R]=0;break}}R===F?O=3:R===M-1?O=1:(O=2,F=R)}switch(F++,O){case 1:{let R=v[M-2];v[M-2]=0;for(let U=M-2;U>=F;U--){let q=hn(y[U],R),W=y[U]/q,z=R/q;if(y[U]=q,U!==F&&(R=-z*v[U-1],v[U-1]=W*v[U-1]),h)for(let K=0;K<n;K++)q=W*w.get(K,U)+z*w.get(K,M-1),w.set(K,M-1,-z*w.get(K,U)+W*w.get(K,M-1)),w.set(K,U,q)}break}case 2:{let R=v[F-1];v[F-1]=0;for(let U=F;U<M;U++){let q=hn(y[U],R),W=y[U]/q,z=R/q;if(y[U]=q,R=-z*v[U],v[U]=W*v[U],c)for(let K=0;K<r;K++)q=W*m.get(K,U)+z*m.get(K,F-1),m.set(K,F-1,-z*m.get(K,U)+W*m.get(K,F-1)),m.set(K,U,q)}break}case 3:{const R=Math.max(Math.abs(y[M-1]),Math.abs(y[M-2]),Math.abs(v[M-2]),Math.abs(y[F]),Math.abs(v[F])),U=y[M-1]/R,q=y[M-2]/R,W=v[M-2]/R,z=y[F]/R,K=v[F]/R,Z=((q+U)*(q-U)+W*W)/2,X=U*W*(U*W);let Q=0;(Z!==0||X!==0)&&(Z<0?Q=0-Math.sqrt(Z*Z+X):Q=Math.sqrt(Z*Z+X),Q=X/(Z+Q));let ct=(z+U)*(z-U)+Q,vt=z*K;for(let lt=F;lt<M-1;lt++){let wt=hn(ct,vt);wt===0&&(wt=Number.MIN_VALUE);let bt=ct/wt,Bt=vt/wt;if(lt!==F&&(v[lt-1]=wt),ct=bt*y[lt]+Bt*v[lt],v[lt]=bt*v[lt]-Bt*y[lt],vt=Bt*y[lt+1],y[lt+1]=bt*y[lt+1],h)for(let xt=0;xt<n;xt++)wt=bt*w.get(xt,lt)+Bt*w.get(xt,lt+1),w.set(xt,lt+1,-Bt*w.get(xt,lt)+bt*w.get(xt,lt+1)),w.set(xt,lt,wt);if(wt=hn(ct,vt),wt===0&&(wt=Number.MIN_VALUE),bt=ct/wt,Bt=vt/wt,y[lt]=wt,ct=bt*v[lt]+Bt*y[lt+1],y[lt+1]=-Bt*v[lt]+bt*y[lt+1],vt=Bt*v[lt+1],v[lt+1]=bt*v[lt+1],c&&lt<r-1)for(let xt=0;xt<r;xt++)wt=bt*m.get(xt,lt)+Bt*m.get(xt,lt+1),m.set(xt,lt+1,-Bt*m.get(xt,lt)+bt*m.get(xt,lt+1)),m.set(xt,lt,wt)}v[M-2]=ct;break}case 4:{if(y[F]<=0&&(y[F]=y[F]<0?-y[F]:0,h))for(let R=0;R<=S;R++)w.set(R,F,-w.get(R,F));for(;F<S&&!(y[F]>=y[F+1]);){let R=y[F];if(y[F]=y[F+1],y[F+1]=R,h&&F<n-1)for(let U=0;U<n;U++)R=w.get(U,F+1),w.set(U,F+1,w.get(U,F)),w.set(U,F,R);if(c&&F<r-1)for(let U=0;U<r;U++)R=m.get(U,F+1),m.set(U,F+1,m.get(U,F)),m.set(U,F,R);F++}M--;break}}}if(p){let F=w;w=m,m=F}this.m=r,this.n=n,this.s=y,this.U=m,this.V=w}solve(t){let e=t,r=this.threshold,n=this.s.length,i=pt.zeros(n,n);for(let d=0;d<n;d++)Math.abs(this.s[d])<=r?i.set(d,d,0):i.set(d,d,1/this.s[d]);let a=this.U,l=this.rightSingularVectors,c=l.mmul(i),h=l.rows,p=a.rows,f=pt.zeros(h,p);for(let d=0;d<h;d++)for(let g=0;g<p;g++){let y=0;for(let m=0;m<n;m++)y+=c.get(d,m)*a.get(g,m);f.set(d,g,y)}return f.mmul(e)}solveForDiagonal(t){return this.solve(pt.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,i=new pt(r,this.s.length);for(let p=0;p<r;p++)for(let f=0;f<n;f++)Math.abs(this.s[f])>e&&i.set(p,f,t.get(p,f)/this.s[f]);let a=this.U,l=a.rows,c=a.columns,h=new pt(r,l);for(let p=0;p<r;p++)for(let f=0;f<l;f++){let d=0;for(let g=0;g<c;g++)d+=i.get(p,g)*a.get(f,g);h.set(p,f,d)}return h}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,i=r.length;n<i;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return pt.diag(this.s)}}function ly(s,t=!1){return s=gr.checkMatrix(s),t?new Ei(s).inverse():jf(s,pt.eye(s.rows))}function jf(s,t,e=!1){return s=gr.checkMatrix(s),t=gr.checkMatrix(t),e?new Ei(s).solve(t):s.isSquare()?new io(s).solve(t):new za(s).solve(t)}function so(s){if(s=pt.checkMatrix(s),s.isSquare()){if(s.columns===0)return 1;let t,e,r,n;if(s.columns===2)return t=s.get(0,0),e=s.get(0,1),r=s.get(1,0),n=s.get(1,1),t*n-e*r;if(s.columns===3){let i,a,l;return i=new no(s,[1,2],[1,2]),a=new no(s,[1,2],[0,2]),l=new no(s,[1,2],[0,1]),t=s.get(0,0),e=s.get(0,1),r=s.get(0,2),t*so(i)-e*so(a)+r*so(l)}else return new io(s).determinant}else throw Error("determinant can only be calculated for a square matrix")}function cy(s,t){let e=[];for(let r=0;r<s;r++)r!==t&&e.push(r);return e}function fy(s,t,e,r=1e-9,n=1e-9){if(s>n)return new Array(t.rows+1).fill(0);{let i=t.addRow(e,[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 hy(s,t={}){const{thresholdValue:e=1e-9,thresholdError:r=1e-9}=t;s=pt.checkMatrix(s);let n=s.rows,i=new pt(n,n);for(let a=0;a<n;a++){let l=pt.columnVector(s.getRow(a)),c=s.subMatrixRow(cy(n,a)).transpose(),p=new Ei(c).solve(l),f=pt.sub(l,c.mmul(p)).abs().max();i.setRow(a,fy(f,p,a,e,r))}return i}function py(s,t=Number.EPSILON){if(s=pt.checkMatrix(s),s.isEmpty())return s.transpose();let e=new Ei(s,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,i=e.diagonal;for(let a=0;a<i.length;a++)Math.abs(i[a])>t?i[a]=1/i[a]:i[a]=0;return n.mmul(pt.diag(i).mmul(r.transpose()))}function dy(s,t=s,e={}){s=new pt(s);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!cr.isAnyArray(t)?(e=t,t=s,r=!0):t=new pt(t),s.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=e;n&&(s=s.center("column"),r||(t=t.center("column")));const i=s.transpose().mmul(t);for(let a=0;a<i.rows;a++)for(let l=0;l<i.columns;l++)i.set(a,l,i.get(a,l)*(1/(s.rows-1)));return i}function _y(s,t=s,e={}){s=new pt(s);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!cr.isAnyArray(t)?(e=t,t=s,r=!0):t=new pt(t),s.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:i=!0}=e;n&&(s.center("column"),r||t.center("column")),i&&(s.scale("column"),r||t.scale("column"));const a=s.standardDeviation("column",{unbiased:!0}),l=r?a:t.standardDeviation("column",{unbiased:!0}),c=s.transpose().mmul(t);for(let h=0;h<c.rows;h++)for(let p=0;p<c.columns;p++)c.set(h,p,c.get(h,p)*(1/(a[h]*l[p]))*(1/(s.rows-1)));return c}let Vf=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=gr.checkMatrix(t),!t.isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n=t.columns,i=new pt(n,n),a=new Float64Array(n),l=new Float64Array(n),c=t,h,p,f=!1;if(r?f=!0:f=t.isSymmetric(),f){for(h=0;h<n;h++)for(p=0;p<n;p++)i.set(h,p,c.get(h,p));my(n,l,a,i),gy(n,l,a,i)}else{let d=new pt(n,n),g=new Float64Array(n);for(p=0;p<n;p++)for(h=0;h<n;h++)d.set(h,p,c.get(h,p));vy(n,d,g,i),yy(n,l,a,i,d)}this.n=n,this.e=l,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 t=this.n,e=this.e,r=this.d,n=new pt(t,t),i,a;for(i=0;i<t;i++){for(a=0;a<t;a++)n.set(i,a,0);n.set(i,i,r[i]),e[i]>0?n.set(i,i+1,e[i]):e[i]<0&&n.set(i,i-1,e[i])}return n}};function my(s,t,e,r){let n,i,a,l,c,h,p,f;for(c=0;c<s;c++)e[c]=r.get(s-1,c);for(l=s-1;l>0;l--){for(f=0,a=0,h=0;h<l;h++)f=f+Math.abs(e[h]);if(f===0)for(t[l]=e[l-1],c=0;c<l;c++)e[c]=r.get(l-1,c),r.set(l,c,0),r.set(c,l,0);else{for(h=0;h<l;h++)e[h]/=f,a+=e[h]*e[h];for(n=e[l-1],i=Math.sqrt(a),n>0&&(i=-i),t[l]=f*i,a=a-n*i,e[l-1]=n-i,c=0;c<l;c++)t[c]=0;for(c=0;c<l;c++){for(n=e[c],r.set(c,l,n),i=t[c]+r.get(c,c)*n,h=c+1;h<=l-1;h++)i+=r.get(h,c)*e[h],t[h]+=r.get(h,c)*n;t[c]=i}for(n=0,c=0;c<l;c++)t[c]/=a,n+=t[c]*e[c];for(p=n/(a+a),c=0;c<l;c++)t[c]-=p*e[c];for(c=0;c<l;c++){for(n=e[c],i=t[c],h=c;h<=l-1;h++)r.set(h,c,r.get(h,c)-(n*t[h]+i*e[h]));e[c]=r.get(l-1,c),r.set(l,c,0)}}e[l]=a}for(l=0;l<s-1;l++){if(r.set(s-1,l,r.get(l,l)),r.set(l,l,1),a=e[l+1],a!==0){for(h=0;h<=l;h++)e[h]=r.get(h,l+1)/a;for(c=0;c<=l;c++){for(i=0,h=0;h<=l;h++)i+=r.get(h,l+1)*r.get(h,c);for(h=0;h<=l;h++)r.set(h,c,r.get(h,c)-i*e[h])}}for(h=0;h<=l;h++)r.set(h,l+1,0)}for(c=0;c<s;c++)e[c]=r.get(s-1,c),r.set(s-1,c,0);r.set(s-1,s-1,1),t[0]=0}function gy(s,t,e,r){let n,i,a,l,c,h,p,f,d,g,y,m,w,v,x,b;for(a=1;a<s;a++)t[a-1]=t[a];t[s-1]=0;let N=0,E=0,A=Number.EPSILON;for(h=0;h<s;h++){for(E=Math.max(E,Math.abs(e[h])+Math.abs(t[h])),p=h;p<s&&!(Math.abs(t[p])<=A*E);)p++;if(p>h)do{for(n=e[h],f=(e[h+1]-n)/(2*t[h]),d=hn(f,1),f<0&&(d=-d),e[h]=t[h]/(f+d),e[h+1]=t[h]*(f+d),g=e[h+1],i=n-e[h],a=h+2;a<s;a++)e[a]-=i;for(N=N+i,f=e[p],y=1,m=y,w=y,v=t[h+1],x=0,b=0,a=p-1;a>=h;a--)for(w=m,m=y,b=x,n=y*t[a],i=y*f,d=hn(f,t[a]),t[a+1]=x*d,x=t[a]/d,y=f/d,f=y*e[a]-x*n,e[a+1]=i+x*(y*n+x*e[a]),c=0;c<s;c++)i=r.get(c,a+1),r.set(c,a+1,x*r.get(c,a)+y*i),r.set(c,a,y*r.get(c,a)-x*i);f=-x*b*w*v*t[h]/g,t[h]=x*f,e[h]=y*f}while(Math.abs(t[h])>A*E);e[h]=e[h]+N,t[h]=0}for(a=0;a<s-1;a++){for(c=a,f=e[a],l=a+1;l<s;l++)e[l]<f&&(c=l,f=e[l]);if(c!==a)for(e[c]=e[a],e[a]=f,l=0;l<s;l++)f=r.get(l,a),r.set(l,a,r.get(l,c)),r.set(l,c,f)}}function vy(s,t,e,r){let n=0,i=s-1,a,l,c,h,p,f,d;for(f=n+1;f<=i-1;f++){for(d=0,h=f;h<=i;h++)d=d+Math.abs(t.get(h,f-1));if(d!==0){for(c=0,h=i;h>=f;h--)e[h]=t.get(h,f-1)/d,c+=e[h]*e[h];for(l=Math.sqrt(c),e[f]>0&&(l=-l),c=c-e[f]*l,e[f]=e[f]-l,p=f;p<s;p++){for(a=0,h=i;h>=f;h--)a+=e[h]*t.get(h,p);for(a=a/c,h=f;h<=i;h++)t.set(h,p,t.get(h,p)-a*e[h])}for(h=0;h<=i;h++){for(a=0,p=i;p>=f;p--)a+=e[p]*t.get(h,p);for(a=a/c,p=f;p<=i;p++)t.set(h,p,t.get(h,p)-a*e[p])}e[f]=d*e[f],t.set(f,f-1,d*l)}}for(h=0;h<s;h++)for(p=0;p<s;p++)r.set(h,p,h===p?1:0);for(f=i-1;f>=n+1;f--)if(t.get(f,f-1)!==0){for(h=f+1;h<=i;h++)e[h]=t.get(h,f-1);for(p=f;p<=i;p++){for(l=0,h=f;h<=i;h++)l+=e[h]*r.get(h,p);for(l=l/e[f]/t.get(f,f-1),h=f;h<=i;h++)r.set(h,p,r.get(h,p)+l*e[h])}}}function yy(s,t,e,r,n){let i=s-1,a=0,l=s-1,c=Number.EPSILON,h=0,p=0,f=0,d=0,g=0,y=0,m=0,w=0,v,x,b,N,E,A,M,S,T,F,O,R,U,q,W;for(v=0;v<s;v++)for((v<a||v>l)&&(e[v]=n.get(v,v),t[v]=0),x=Math.max(v-1,0);x<s;x++)p=p+Math.abs(n.get(v,x));for(;i>=a;){for(N=i;N>a&&(y=Math.abs(n.get(N-1,N-1))+Math.abs(n.get(N,N)),y===0&&(y=p),!(Math.abs(n.get(N,N-1))<c*y));)N--;if(N===i)n.set(i,i,n.get(i,i)+h),e[i]=n.get(i,i),t[i]=0,i--,w=0;else if(N===i-1){if(M=n.get(i,i-1)*n.get(i-1,i),f=(n.get(i-1,i-1)-n.get(i,i))/2,d=f*f+M,m=Math.sqrt(Math.abs(d)),n.set(i,i,n.get(i,i)+h),n.set(i-1,i-1,n.get(i-1,i-1)+h),S=n.get(i,i),d>=0){for(m=f>=0?f+m:f-m,e[i-1]=S+m,e[i]=e[i-1],m!==0&&(e[i]=S-M/m),t[i-1]=0,t[i]=0,S=n.get(i,i-1),y=Math.abs(S)+Math.abs(m),f=S/y,d=m/y,g=Math.sqrt(f*f+d*d),f=f/g,d=d/g,x=i-1;x<s;x++)m=n.get(i-1,x),n.set(i-1,x,d*m+f*n.get(i,x)),n.set(i,x,d*n.get(i,x)-f*m);for(v=0;v<=i;v++)m=n.get(v,i-1),n.set(v,i-1,d*m+f*n.get(v,i)),n.set(v,i,d*n.get(v,i)-f*m);for(v=a;v<=l;v++)m=r.get(v,i-1),r.set(v,i-1,d*m+f*r.get(v,i)),r.set(v,i,d*r.get(v,i)-f*m)}else e[i-1]=S+f,e[i]=S+f,t[i-1]=m,t[i]=-m;i=i-2,w=0}else{if(S=n.get(i,i),T=0,M=0,N<i&&(T=n.get(i-1,i-1),M=n.get(i,i-1)*n.get(i-1,i)),w===10){for(h+=S,v=a;v<=i;v++)n.set(v,v,n.get(v,v)-S);y=Math.abs(n.get(i,i-1))+Math.abs(n.get(i-1,i-2)),S=T=.75*y,M=-.4375*y*y}if(w===30&&(y=(T-S)/2,y=y*y+M,y>0)){for(y=Math.sqrt(y),T<S&&(y=-y),y=S-M/((T-S)/2+y),v=a;v<=i;v++)n.set(v,v,n.get(v,v)-y);h+=y,S=T=M=.964}for(w=w+1,E=i-2;E>=N&&(m=n.get(E,E),g=S-m,y=T-m,f=(g*y-M)/n.get(E+1,E)+n.get(E,E+1),d=n.get(E+1,E+1)-m-g-y,g=n.get(E+2,E+1),y=Math.abs(f)+Math.abs(d)+Math.abs(g),f=f/y,d=d/y,g=g/y,!(E===N||Math.abs(n.get(E,E-1))*(Math.abs(d)+Math.abs(g))<c*(Math.abs(f)*(Math.abs(n.get(E-1,E-1))+Math.abs(m)+Math.abs(n.get(E+1,E+1))))));)E--;for(v=E+2;v<=i;v++)n.set(v,v-2,0),v>E+2&&n.set(v,v-3,0);for(b=E;b<=i-1&&(q=b!==i-1,b!==E&&(f=n.get(b,b-1),d=n.get(b+1,b-1),g=q?n.get(b+2,b-1):0,S=Math.abs(f)+Math.abs(d)+Math.abs(g),S!==0&&(f=f/S,d=d/S,g=g/S)),S!==0);b++)if(y=Math.sqrt(f*f+d*d+g*g),f<0&&(y=-y),y!==0){for(b!==E?n.set(b,b-1,-y*S):N!==E&&n.set(b,b-1,-n.get(b,b-1)),f=f+y,S=f/y,T=d/y,m=g/y,d=d/f,g=g/f,x=b;x<s;x++)f=n.get(b,x)+d*n.get(b+1,x),q&&(f=f+g*n.get(b+2,x),n.set(b+2,x,n.get(b+2,x)-f*m)),n.set(b,x,n.get(b,x)-f*S),n.set(b+1,x,n.get(b+1,x)-f*T);for(v=0;v<=Math.min(i,b+3);v++)f=S*n.get(v,b)+T*n.get(v,b+1),q&&(f=f+m*n.get(v,b+2),n.set(v,b+2,n.get(v,b+2)-f*g)),n.set(v,b,n.get(v,b)-f),n.set(v,b+1,n.get(v,b+1)-f*d);for(v=a;v<=l;v++)f=S*r.get(v,b)+T*r.get(v,b+1),q&&(f=f+m*r.get(v,b+2),r.set(v,b+2,r.get(v,b+2)-f*g)),r.set(v,b,r.get(v,b)-f),r.set(v,b+1,r.get(v,b+1)-f*d)}}}if(p!==0){for(i=s-1;i>=0;i--)if(f=e[i],d=t[i],d===0)for(N=i,n.set(i,i,1),v=i-1;v>=0;v--){for(M=n.get(v,v)-f,g=0,x=N;x<=i;x++)g=g+n.get(v,x)*n.get(x,i);if(t[v]<0)m=M,y=g;else if(N=v,t[v]===0?n.set(v,i,M!==0?-g/M:-g/(c*p)):(S=n.get(v,v+1),T=n.get(v+1,v),d=(e[v]-f)*(e[v]-f)+t[v]*t[v],A=(S*y-m*g)/d,n.set(v,i,A),n.set(v+1,i,Math.abs(S)>Math.abs(m)?(-g-M*A)/S:(-y-T*A)/m)),A=Math.abs(n.get(v,i)),c*A*A>1)for(x=v;x<=i;x++)n.set(x,i,n.get(x,i)/A)}else if(d<0)for(N=i-1,Math.abs(n.get(i,i-1))>Math.abs(n.get(i-1,i))?(n.set(i-1,i-1,d/n.get(i,i-1)),n.set(i-1,i,-(n.get(i,i)-f)/n.get(i,i-1))):(W=oo(0,-n.get(i-1,i),n.get(i-1,i-1)-f,d),n.set(i-1,i-1,W[0]),n.set(i-1,i,W[1])),n.set(i,i-1,0),n.set(i,i,1),v=i-2;v>=0;v--){for(F=0,O=0,x=N;x<=i;x++)F=F+n.get(v,x)*n.get(x,i-1),O=O+n.get(v,x)*n.get(x,i);if(M=n.get(v,v)-f,t[v]<0)m=M,g=F,y=O;else if(N=v,t[v]===0?(W=oo(-F,-O,M,d),n.set(v,i-1,W[0]),n.set(v,i,W[1])):(S=n.get(v,v+1),T=n.get(v+1,v),R=(e[v]-f)*(e[v]-f)+t[v]*t[v]-d*d,U=(e[v]-f)*2*d,R===0&&U===0&&(R=c*p*(Math.abs(M)+Math.abs(d)+Math.abs(S)+Math.abs(T)+Math.abs(m))),W=oo(S*g-m*F+d*O,S*y-m*O-d*F,R,U),n.set(v,i-1,W[0]),n.set(v,i,W[1]),Math.abs(S)>Math.abs(m)+Math.abs(d)?(n.set(v+1,i-1,(-F-M*n.get(v,i-1)+d*n.get(v,i))/S),n.set(v+1,i,(-O-M*n.get(v,i)-d*n.get(v,i-1))/S)):(W=oo(-g-T*n.get(v,i-1),-y-T*n.get(v,i),m,d),n.set(v+1,i-1,W[0]),n.set(v+1,i,W[1]))),A=Math.max(Math.abs(n.get(v,i-1)),Math.abs(n.get(v,i))),c*A*A>1)for(x=v;x<=i;x++)n.set(x,i-1,n.get(x,i-1)/A),n.set(x,i,n.get(x,i)/A)}for(v=0;v<s;v++)if(v<a||v>l)for(x=v;x<s;x++)r.set(v,x,n.get(v,x));for(x=s-1;x>=a;x--)for(v=a;v<=l;v++){for(m=0,b=a;b<=Math.min(x,l);b++)m=m+r.get(v,b)*n.get(b,x);r.set(v,x,m)}}}function oo(s,t,e,r){let n,i;return Math.abs(e)>Math.abs(r)?(n=r/e,i=e+n*r,[(s+n*t)/i,(t-n*s)/i]):(n=e/r,i=r+n*e,[(n*s+t)/i,(n*t-s)/i])}class Yf{constructor(t){if(t=gr.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,n=new pt(r,r),i=!0,a,l,c;for(l=0;l<r;l++){let h=0;for(c=0;c<l;c++){let p=0;for(a=0;a<c;a++)p+=n.get(c,a)*n.get(l,a);p=(e.get(l,c)-p)/n.get(c,c),n.set(l,c,p),h=h+p*p}for(h=e.get(l,l)-h,i&=h>0,n.set(l,l,Math.sqrt(Math.max(h,0))),c=l+1;c<r;c++)n.set(l,c,0)}this.L=n,this.positiveDefinite=!!i}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=gr.checkMatrix(t);let e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let n=t.columns,i=t.clone(),a,l,c;for(c=0;c<r;c++)for(l=0;l<n;l++){for(a=0;a<c;a++)i.set(c,l,i.get(c,l)-i.get(a,l)*e.get(c,a));i.set(c,l,i.get(c,l)/e.get(c,c))}for(c=r-1;c>=0;c--)for(l=0;l<n;l++){for(a=c+1;a<r;a++)i.set(c,l,i.get(c,l)-i.get(a,l)*e.get(a,c));i.set(c,l,i.get(c,l)/e.get(c,c))}return i}get lowerTriangularMatrix(){return this.L}}class Zf{constructor(t,e={}){t=gr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:i=1e3,terminationCriteria:a=1e-10}=e;let l;if(r){if(cr.isAnyArray(r)&&typeof r[0]=="number"?r=pt.columnVector(r):r=gr.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");l=r.getColumnVector(0)}else l=t.getColumnVector(0);let c=1,h,p,f,d;for(let g=0;g<i&&c>a;g++)f=t.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),f=f.div(f.norm()),h=t.mmul(f).div(f.transpose().mmul(f).get(0,0)),g>0&&(c=h.clone().sub(d).pow(2).sum()),d=h.clone(),r?(p=r.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),p=p.div(p.norm()),l=r.mmul(p).div(p.transpose().mmul(p).get(0,0))):l=h;if(r){let g=t.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0));g=g.div(g.norm());let y=t.clone().sub(h.clone().mmul(g.transpose())),m=l.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),w=r.clone().sub(h.clone().mulS(m.get(0,0)).mmul(p.transpose()));this.t=h,this.p=g.transpose(),this.w=f.transpose(),this.q=p,this.u=l,this.s=h.transpose().mmul(h),this.xResidual=y,this.yResidual=w,this.betas=m}else this.w=f.transpose(),this.s=h.transpose().mmul(h).sqrt(),n?this.t=h.clone().div(this.s.get(0,0)):this.t=h,this.xResidual=t.sub(h.mmul(f.transpose()))}}kt.AbstractMatrix=$t,kt.CHO=Yf,kt.CholeskyDecomposition=Yf,kt.DistanceMatrix=ro,kt.EVD=Vf;var wy=kt.EigenvalueDecomposition=Vf;kt.LU=io,kt.LuDecomposition=io;var Kf=kt.Matrix=pt;kt.MatrixColumnSelectionView=ey,kt.MatrixColumnView=ty,kt.MatrixFlipColumnView=ry,kt.MatrixFlipRowView=ny,kt.MatrixRowSelectionView=sy,kt.MatrixRowView=iy,kt.MatrixSelectionView=no,kt.MatrixSubView=oy,kt.MatrixTransposeView=ay,kt.NIPALS=Zf,kt.Nipals=Zf,kt.QR=za,kt.QrDecomposition=za,kt.SVD=Ei,kt.SingularValueDecomposition=Ei,kt.SymmetricMatrix=Xn,kt.WrapperMatrix1D=Wf,kt.WrapperMatrix2D=gr,kt.correlation=_y,kt.covariance=dy;var Gf=kt.default=pt;kt.determinant=so,kt.inverse=ly,kt.linearDependencies=hy,kt.pseudoInverse=py,kt.solve=jf,kt.wrap=uy;const Hf=wy,Jf=Kf;Gf.Matrix&&Gf.Matrix;class Dy{constructor(t){$(this,"_errorListener");this._errorListener=t}new({rows:t,columns:e,initial_value:r}={}){return new ka(t,e,r,this._errorListener)}avg({id:t}){return t==null?void 0:t.avg()}col({id:t,column:e}){return t==null?void 0:t.col({column:e})}det({id:t}){return t==null?void 0:t.det()}get({id:t,row:e,column:r}){return t==null?void 0:t.get({row:e,column:r})}inv({id:t}){return t==null?void 0:t.inv()}max({id:t}){return t==null?void 0:t.max()}min({id:t}){return t==null?void 0:t.min()}pow({id:t,power:e}){return t==null?void 0:t.pow({power:e})}row({id:t,row:e}){return t==null?void 0:t.row({row:e})}set({id:t,row:e,column:r,value:n}){t==null||t.set({row:e,column:r,value:n})}sum({id1:t,id2:e}){return t==null?void 0:t.sum({id2:e})}copy({id:t}){return t==null?void 0:t.copy()}diff({id1:t,id2:e}){return t==null?void 0:t.diff({id2:e})}rows({id:t}){return t==null?void 0:t.rows()}columns({id:t}){return t==null?void 0:t.columns()}fill({id:t,value:e,from_row:r,to_row:n,from_column:i,to_column:a}){t==null||t.fill({value:e,from_row:r,to_row:n,from_column:i,to_column:a})}kron({id1:t,id2:e}){return t==null?void 0:t.kron({id2:e})}mode({id:t}){return t==null?void 0:t.mode()}mult({id1:t,id2:e}){return t==null?void 0:t.mult({id2:e})}pinv({id:t}){return t==null?void 0:t.pinv()}rank({id:t}){return t==null?void 0:t.rank()}sort({id:t,column:e,order:r}){t==null||t.sort({column:e,order:r})}trace({id:t}){return t==null?void 0:t.trace()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}median({id:t}){return t==null?void 0:t.median()}add_col({id:t,column:e,array_id:r}){t==null||t.add_col({column:e,array_id:r})}add_row({id:t,row:e,array_id:r}){t==null||t.add_row({row:e,array_id:r})}is_zero({id:t}){return t==null?void 0:t.is_zero()}reshape({id:t,rows:e,columns:r},n){return t==null?void 0:t.reshape({rows:e,columns:r},n)}reverse({id:t}){t==null||t.reverse()}is_binary({id:t}){return t==null?void 0:t.is_binary()}is_square({id:t}){return t==null?void 0:t.is_square()}submatrix({id:t,from_row:e,to_row:r,from_column:n,to_column:i}){return t==null?void 0:t.submatrix({from_row:e,to_row:r,from_column:n,to_column:i})}swap_rows({id:t,row1:e,row2:r}){t==null||t.swap_rows({row1:e,row2:r})}transpose({id:t}){return t==null?void 0:t.transpose()}remove_col({id:t,column:e}){return t==null?void 0:t.remove_col({column:e})}remove_row({id:t,row:e}){return t==null?void 0:t.remove_row({row:e})}eigenvalues({id:t}){return t==null?void 0:t.eigenvalues()}is_diagonal({id:t}){return t==null?void 0:t.is_diagonal()}is_identity({id:t}){return t==null?void 0:t.is_identity()}eigenvectors({id:t}){return t==null?void 0:t.eigenvectors()}is_symmetric({id:t}){return t==null?void 0:t.is_symmetric()}swap_columns({id:t,column1:e,column2:r}){t==null||t.swap_columns({column1:e,column2:r})}is_stochastic({id:t}){return t==null?void 0:t.is_stochastic()}is_triangular({id:t}){return t==null?void 0:t.is_triangular()}elements_count({id:t}){return t==null?void 0:t.elements_count()}is_antidiagonal({id:t}){return t==null?void 0:t.is_antidiagonal()}is_antisymmetric({id:t}){return t==null?void 0:t.is_antisymmetric()}}class ka{constructor(t=0,e=0,r=void 0,n){$(this,"_matrixInstance");$(this,"_errorListener");this._matrixInstance=this._createMatrix(t,e,r),this._errorListener=n}get _matrixArray(){return this._matrixInstance.map(t=>[...t._value])}get _value(){return this._matrixInstance}set _value(t){this._matrixInstance=t}get isMatrix(){return!0}_createMatrix(t,e,r){return Array.from(new Array(t),()=>new Qt(e,r,this._errorListener))}avg(){let t=0,e=0;for(const n of this._matrixInstance)for(const i of n._value)t+=_t(i)?0:i,e+=1;return t/e}col({column:t}){const e=[],r=new Qt(0,void 0,this._errorListener);if(_t(t))return r;for(const n of this._matrixInstance)e.push(n._value[t]);return r._value=e,r}det(){return Lf(this._matrixArray)}get({row:t,column:e}){var r,n;if(!(_t(t)||_t(e)))return(n=(r=this._matrixInstance[t])==null?void 0:r._value)==null?void 0:n[e]}inv(){const t=Xs(this._matrixArray);return this._newMatrix(t)}max(){return m1(this._matrixArray)}min(){return $a(this._matrixArray)}pow({power:t}){const e=_t(t)?this._matrixArray:v1(this._matrixArray,t);return this._newMatrix(e)}row({row:t}){return _t(t)?new Qt(0,void 0,this._errorListener):this._matrixInstance[t]}set({row:t,column:e,value:r}){_t(t)||_t(e)||this._matrixInstance[t].set({index:e,value:r})}sum({id2:t}){const e=Qi(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=c1(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}rows(){return this._matrixInstance.length}columns(){return this._matrixArray.length&&this._matrixArray[0].length}fill({value:t,from_row:e,to_row:r,from_column:n,to_column:i}={}){_t(e)&&(e=0),_t(r)&&(r=this.rows()),_t(n)&&(n=0),_t(i)&&(i=this.columns());for(const[a,l]of this._matrixInstance.entries())for(const[c]of l._value.entries())a<r&&a>=e&&c>=n&&c<i&&l.set({index:c,value:t})}kron({id2:t}){const e=u1(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return $a(Nf(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=wi(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=g1(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t,order:e=Yn.ascending}={}){_t(t)&&(t=0),this._matrixInstance.sort((r,n)=>{const i=r._value[t],a=n._value[t];return e!==Yn.descending?i-a:a-i})}trace(){return _1(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return Rf(this._matrixArray)}add_col({column:t,array_id:e}={}){_t(t)&&(t=this.columns());for(const[r,n]of this._matrixInstance.entries())n.insert({index:t,value:e?e._value[r]:void 0})}add_row({row:t,array_id:e}){_t(t)&&(t=this.rows()),this._matrixInstance.splice(t,0,e||new Qt(this.columns(),void 0,this._errorListener))}is_zero(){return this._matrixArray.every(t=>t.every(e=>e===0))}reshape({rows:t=0,columns:e=0},r){if(t*e!==this.columns()*this.rows()){this._errorListener.addError(le.matrixRehapeErr,r,zt.Error);return}const n=i1(this._matrixArray,[t,e]);this._matrixInstance=n.map(i=>{const a=new Qt(0,void 0,this._errorListener);return a._value=[...i],a})}reverse(){this._matrixInstance.reverse();for(const t of this._matrixInstance)t.reverse()}is_binary(){return this._matrixArray.every(t=>t.every(e=>e===0||e===1))}is_square(){return this.rows()===this.columns()}submatrix({from_row:t,to_row:e,from_column:r,to_column:n}={}){_t(t)&&(t=0),_t(e)&&(e=this.rows()),_t(r)&&(r=0),_t(n)&&(n=this.columns());const i=this._matrixArray.splice(t,e),a=[];for(const l of i)a.push(l.splice(r,n));return this._newMatrix(a)}swap_rows({row1:t,row2:e}){if(_t(t)||_t(e))return;const r=this._matrixInstance[t],n=this._matrixInstance[e];this._matrixInstance[t]=n,this._matrixInstance[e]=r}transpose(){const t=Bf(this._matrixArray);return this._newMatrix(t)}remove_col({column:t}={}){_t(t)&&(t=this.columns());const e=[];for(const n of this._matrixInstance){const i=n._value.splice(t,1);e.push(i[0])}const r=new Qt(0,void 0,this._errorListener);return r._value=e,r}remove_row({row:t}={}){return _t(t)&&(t=this.rows()),this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new Hf(new Jf(this._matrixArray)),e=new Qt(0,void 0,this._errorListener);return e._value=t.realEigenvalues,e}is_diagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let i=0;i<e;i++)if(n!==i&&r[n][i]!==0)return!1;return!0}is_identity(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let i=0;i<e;i++)if(n!==i&&r[n][i]!==0||n===i&&r[n][i]!==1)return!1;return!0}eigenvectors(){const t=new Hf(new Jf(this._matrixArray));return this._newMatrix(t.eigenvectorMatrix.to2DArray())}is_symmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let i=n+1;i<e;i++)if(r[n][i]!==r[i][n])return!1;return!0}swap_columns({column1:t,column2:e}){if(!(_t(t)||_t(e)))for(const r of this._matrixInstance){const n=r._value[t],i=r._value[e];r.set({index:t,value:i}),r.set({index:e,value:n})}}is_stochastic(){const t=this._matrixArray;for(let e=0;e<t.length;e++){let r=0;for(let n=0;n<t[e].length;n++){if(t[e][n]<0)return!1;r+=t[e][n]}if(Math.abs(r-1)>Number.EPSILON)return!1}return!0}is_triangular(){const t=this.rows(),e=this.columns();return t!==e?!1:this._isUpperTriangular(t)||this._isLowerTriangular(t)}elements_count(){return s1(this._matrixArray)}is_antidiagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let i=0;i<t;i++)if(n+i!==t-1&&r[n][i]!==0)return!1;return!0}is_antisymmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let i=0;i<t;i++)if(n!==i&&r[n][i]!==-r[i][n])return!1;return!0}_isUpperTriangular(t){const e=this._matrixArray;for(let r=1;r<t;r++)for(let n=0;n<r;n++)if(e[r][n]!==0)return!1;return!0}_isLowerTriangular(t){const e=this._matrixArray;for(let r=0;r<t-1;r++)for(let n=r+1;n<t;n++)if(e[r][n]!==0)return!1;return!0}_newMatrix(t){const e=new ka(0,0,void 0,this._errorListener);return e._value=t.map(r=>{const n=new Qt(0,void 0,this._errorListener);return n._value=[...r],n}),e}_matrixRank(t){let e=0;const r=t.length,n=t[0].length,i=[...t].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let l=a;for(;l<r&&i[l][a]===0;)l++;if(l===r)continue;if(l!==a){const h=i[l];i[l]=i[a],i[a]=h}const c=i[a][a];for(let h=0;h<n;h++)i[a][h]/=c;for(let h=a+1;h<r;h++){const p=i[h][a];i[h]=i[h].map((f,d)=>f-p*i[a][d]),i[h][a]=0}}for(let a=0;a<r;a++)i[a].some(l=>Number(l.toFixed(8))!==0)&&e++;return e}}class by{constructor(t){$(this,"_variables");$(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){if(!t)return!0;const r=Qr(t),n=Qr(this._variables.timeframe.period);if(r<n)return!0;const i=`change_${e}`,a=this._cacheData[i],l=this._variables.time;if(a){if(a.offset){if(a.currentTime+a.offset<=l)return this._cacheData[i]={currentTime:l,offset:0},!0}else if(a.currentTime+r*1e3<=l)return this._cacheData[i]={currentTime:l,offset:0},!0}else{const c=this._calcTimeOffset(l,t);return this._cacheData[i]={currentTime:l,offset:c},!1}return!1}in_seconds({timeframe:t}={}){return Qr(t||this._variables.timeframe.period)}from_seconds({seconds:t=0}){const e=t*1e3,r=ee.duration(e);if(r.years())return"12M";const i=r.asMonths();if(Hs(i))return`${i}M`;const a=r.asWeeks();if(Hs(a))return`${a}M`;const l=r.asDays();if(l>=1)return`${Math.ceil(l)}D`;const c=r.asMinutes();if(c>=1)return`${Math.ceil(c)}`;const h=r.asSeconds();return h<=1?"1S":h<=5?"5S":h<=10?"10S":h<=15?"15S":h<=30?"30S":"1"}_calcTimeOffset(t,e){let r=0;if(e.includes("W")){const l=ee(t).day();e="1D",l!==1&&(r=(8-l)*60*60*24*1e3)}else if(e.includes("M")){const l=ee(t).date();e="1D";const c=ee(t).daysInMonth();l!==1&&(r=(c-l+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(t,e),i=Qr(e)*1e3,a=t-n-Math.floor((t-n)/i)*i;return r?r-a:a}}class xy{constructor(t,e){$(this,"_errorListener");$(this,"_intlNumberFormatter");$(this,"_precision");this._errorListener=t,this._precision=e,this._intlNumberFormatter=new Intl.NumberFormat("en",{notation:"compact"})}pos({source:t="",str:e=""}){return t==null?void 0:t.indexOf(e)}trim({source:t=""}){return t==null?void 0:t.trim()}lower({source:t=""}){return t==null?void 0:t.toLocaleLowerCase()}match({source:t="",regex:e=""}){const r=t==null?void 0:t.match(new RegExp(e));return r?r[0]:""}split({string:t="",separator:e=""}){const r=t==null?void 0:t.split(e),n=new Qt;return n._value=r||[],n}upper({source:t=""}){return t==null?void 0:t.toLocaleUpperCase()}format({formatString:t=""},e){return this._strFormat(t,e)}length({string:t=""}){return t==null?void 0:t.length}repeat({source:t="",repeat:e,separator:r=""},n){if(_t(e)){this._errorListener.addError(le.arrLenErr,n,zt.Error);return}return Array.from(new Array(e),()=>t).join(r)}replace({source:t="",target:e="",replacement:r="",occurrence:n}){_t(n)&&(n=0);let i=-1;for(let a=0;a<n+1&&(i=t.indexOf(e,i+1),i!==-1);a++);return i!==-1?t.substring(0,i)+r+t.substring(i+e.length):t}contains({source:t="",str:e=""}){return t==null?void 0:t.includes(e)}endswith({source:t="",str:e=""}){return t==null?void 0:t.endsWith(e)}tonumber({string:t=""}){if(/[^\d.]/.test(t))return;const e=parseFloat(t);return isNaN(e)?void 0:e}tostring({value:t,format:e}){if(t===void 0)return"NaN";if(typeof t=="object"){if(t.isArray)return this._arrToStr(t._value,e);if(t.isMatrix){const r=[];for(const n of t._matrixArray)r.push(this._arrToStr(n,e));return r.join(`
62
- `)}}if(typeof t=="string")return t;if(typeof t=="boolean")return String(t);if(typeof t=="number")return String(this._toStringFormat(t,e))}_arrToStr(t,e){return`[${t.map(n=>typeof n=="number"?this._toStringFormat(n,e):n).toString()}]`}substring({source:t="",begin_pos:e=0,end_pos:r}){return _t(e)&&(e=0),_t(r)&&(r=void 0),t==null?void 0:t.substring(e,r)}startswith({source:t="",str:e=""}){return t==null?void 0:t.startsWith(e)}format_time({time:t,format:e="yyyy-MM-dd'T'HH:mm:ssZ",timezone:r}){return _t(t)&&(t=0),kr(t,r).format(e)}replace_all({source:t="",target:e="",replacement:r=""}){return t==null?void 0:t.replace(new RegExp(e,"g"),r)}_toStringFormat(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case Kt.mintick:return t.toFixed(this._precision);case Kt.percent:return`${t}%`;case Kt.volume:return this._intlNumberFormatter.format(Math.round(t));default:return this._formatOthers(t,e)}}_formatOthers(t,e){var l;let[r,n]=e.split(".");e.split("%").length===2&&(t=t*100);let[i,a=""]=String(t).split(".");if(r.includes("#")){if(r.includes(",")){const c=r.split(","),h=((l=c[c.length-1])==null?void 0:l.replace(/[^#]/g,"").length)||0;h&&(i=i.replace(new RegExp(`\\B(?=(\\d{${h}})+(?!\\d))`,"g"),",")),r=c.join("")}i=r.replace(/#/,i).replace(/#/g,"")}else i=`${r}${i}`;if(n&&n.includes("#")){const c=n.split("#").length-1;a=`${a.substring(0,c)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${i}.${a}`:i}_formatNumber(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case"integer":return String(Math.round(t));case"currency":return`$${t}`;case"percent":return`${t*100}%`;default:return this._formatOthers(t,e)}}_strFormat(t,e){let r=t;for(const[n,i]of e.entries()){if(i===void 0||typeof i=="number"&&isNaN(i)){r="NaN";continue}if(typeof i=="number"){const a=`\\{\\s*${n}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,l=t.match(new RegExp(a));if(l){const c=l[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(i,c)))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(i))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),i)}return r}}class Ey{constructor(t){$(this,"_errorListener");this._errorListener=t}new(){return new qa(this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}get({id:t,key:e}){return t==null?void 0:t.get({key:e})}put({id:t,key:e,value:r}){return t==null?void 0:t.put({key:e,value:r})}keys({id:t}){return t==null?void 0:t.keys()}size({id:t}){return t==null?void 0:t.size()}clear({id:t}){t==null||t.clear()}remove({id:t,key:e}){return t==null?void 0:t.remove({key:e})}values({id:t}){return t==null?void 0:t.values()}put_all({id:t,id2:e}){t==null||t.put_all({id2:e})}contains({id:t,key:e}){return t==null?void 0:t.contains({key:e})}}class qa{constructor(t){$(this,"_errorListener");$(this,"_mapInstance");this._errorListener=t,this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new qa(this._errorListener);return e._mapInstance=new Map(t.entries()),e}copy(){return this._copyMap(this._mapInstance)}get({key:t}){return this._mapInstance.get(t)}put({key:t,value:e}){return this._mapInstance.set(t,e)}keys(){const t=new Qt(0,void 0,this._errorListener);return t._value=[...this._mapInstance.keys()],t}size(){return this._mapInstance.size}clear(){this._mapInstance.clear()}remove({key:t}){const e=this._mapInstance.get(t);return this._mapInstance.delete(t),e||void 0}values(){const t=new Qt(0,void 0,this._errorListener);return t._value=[...this._mapInstance.values()],t}put_all({id2:t}){this._mapInstance=new Map([...this._mapInstance,...t._mapInstance])}contains({key:t}){return this._mapInstance.has(t)}}class Ay{constructor(t){$(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Ai(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Ai(t,r,e)}copy({id:t}){return t==null?void 0:t.copy()}from_index({price:t,index:e}){return new Ai(t,e)}from_time({price:t,time:e}){return new Ai(t,void 0,e)}}class Ai{constructor(t,e,r){$(this,"_index");$(this,"_price");$(this,"_time");this._index=e,this._price=t,this._time=r}get index(){return this._index}get price(){return this._price}get time(){return this._time}copy(){return new Ai(this._price,this._index,this._time)}}class Cy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLabel",{text:"",xloc:we.bar_index,yloc:Wr.price,size:rr.normal,style:ge.styleLabelDown,textalign:Wt.alignCenter});this._variables=t,this._errorListener=e}new(t,e){const{time:r,high:n,low:i,bar_index:a}=this._variables,l=`label_${e}_${a}`;me(t,["color","textcolor"]);const c={...this._defaultLabel,...t,id:l,time:r,high:n,low:i,bar_index:a};t.point&&(c.x=c.xloc===we.bar_index?t.point.index:t.point.time,c.y=t.point.price),c.yloc===Wr.abovebar?c.y=n:c.yloc===Wr.belowbar&&(c.y=i),this._verfiyArgs(t,e);const h=new ao(l,this._variables,this._errorListener);return e.startsWith("export")||this._variables.label.add(l,c,h),h}_verfiyArgs(t,e){const{xloc:r,yloc:n,style:i,size:a,textalign:l,text_font_family:c}=t,h="label.new";this._paramVerfiy(i,e,h,Object.values(ge),"style"),this._paramVerfiy(r,e,h,Object.values(we),"xloc"),this._paramVerfiy(n,e,h,Object.values(Wr),"yloc"),this._paramVerfiy(a,e,h,Object.values(rr),"size"),this._paramVerfiy(l,e,h,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign"),this._paramVerfiy(c,e,h,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}label(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}get_x({id:t},e){return t==null?void 0:t.get_x(e)}get_y({id:t},e){return t==null?void 0:t.get_y(e)}set_x({id:t,...e},r){t==null||t.set_x(e,r)}set_y({id:t,...e},r){t==null||t.set_y(e,r)}delete({id:t}){t==null||t.delete()}get_text({id:t},e){return t==null?void 0:t.get_text(e)}set_xy({id:t,...e},r){t==null||t.set_xy(e,r)}set_size({id:t,...e},r){t==null||t.set_size(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}set_yloc({id:t,...e},r){t==null||t.set_yloc(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_tooltip({id:t,...e},r){t==null||t.set_tooltip(e,r)}set_point({id:t,...e},r){t==null||t.set_point(e,r)}set_text({id:t,...e},r){t==null||t.set_text(e,r)}set_textcolor({id:t,...e},r){t==null||t.set_textcolor(e,r)}set_textalign({id:t,...e},r){t==null||t.set_textalign(e,r)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class ao{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get type(){return Fe.LABEL}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get data(){return this._variables.label.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`label_${t}_${e}`,n=this._getLabel(t),i=new ao(r,this._variables,this._errorListener);if(n){const a={...n,id:r,bar_index:e};this._variables.label.add(r,a,i)}return i}get_x(t){var e;return(e=this._getLabel(t))==null?void 0:e.x}get_y(t){var e;return(e=this._getLabel(t))==null?void 0:e.y}set_x({x:t},e){const r=this._getLabel(e);r&&(r.x=t)}set_y({y:t},e){const r=this._getLabel(e);r&&(r.y=t)}delete(){this._variables.label.delete(this._id)}set_xy({x:t,y:e},r){const n=this._getLabel(r);n&&(n.x=t,n.y=e)}get_text(t){var e;return(e=this._getLabel(t))==null?void 0:e.text}set_size({size:t},e){const r=this._getLabel(e);r&&(r.size=t),this._paramVerfiy(t,e,"label.set_size",Object.values(rr),"size")}set_text({text:t},e){const r=this._getLabel(e);r&&(r.text=t)}set_xloc({x:t,xloc:e},r){const n=this._getLabel(r);n&&(n.x=t,n.xloc=e,this._paramVerfiy(e,r,"label.set_xloc",Object.values(we),"xloc"))}set_yloc({yloc:t},e){const r=this._getLabel(e),{high:n,low:i}=this._variables;r&&(r.yloc=t,t===Wr.abovebar?r.y=n:t===Wr.belowbar&&(r.y=i),this._paramVerfiy(t,e,"label.set_yloc",Object.values(Wr),"yloc"))}set_color(t,e){const r=this._getLabel(e);me(t,["color"]),r&&(r.color=t.color)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===we.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,r.y=t==null?void 0:t.price)}set_style({style:t},e){const r=this._getLabel(e);r&&(r.style=t),this._paramVerfiy(t,e,"label.set_style",Object.values(ge),"style")}set_tooltip({tooltip:t},e){const r=this._getLabel(e);r&&(r.tooltip=t)}set_textalign({textalign:t},e){const r=this._getLabel(e);r&&(r.textalign=t),this._paramVerfiy(t,e,"label.set_textalign",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign")}set_textcolor(t,e){const r=this._getLabel(e);me(t,["textcolor"]),r&&(r.textcolor=t.textcolor)}set_text_font_family({text_font_family:t},e){const r=this._getLabel(e);r&&(r.text_font_family=t),this._paramVerfiy(t,e,"label.set_text_font_family",Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const Fy={freq_all:qr.freqAll,freq_once_per_bar:qr.freqOncePerBar,freq_once_per_bar_close:qr.freqOncePerBarClose},My={gaps_off:Yi.gapsOff,gaps_on:Yi.gapsOn,lookahead_off:Yi.lookaheadOff,lookahead_on:Yi.lookaheadOn},Ci={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"},Xf={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"},Ny={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Qf={all:[Ye.dataWindow,Ye.pane,Ye.priceScale,Ye.statusLine],data_window:[Ye.dataWindow],none:[],pane:[Ye.pane],price_scale:[Ye.priceScale],status_line:[Ye.statusLine]},Sy={both:Ur.both,left:Ur.left,none:Ur.none,right:Ur.right},By={inherit:Kt.inherit,mintick:Kt.mintick,percent:Kt.percent,price:Kt.price,volume:Kt.volume},Oy={style_solid:Ds.styleSolid,style_dashed:Ds.styleDashed,style_dotted:Ds.styleDotted},Iy={style_arrowdown:ge.styleArrowdown,style_arrowup:ge.styleArrowup,style_circle:ge.styleCircle,style_cross:ge.styleCross,style_diamond:ge.styleDiamond,style_flag:ge.styleFlag,style_label_center:ge.styleLabelCenter,style_label_down:ge.styleLabelDown,style_label_left:ge.styleLabelLeft,style_label_lower_left:ge.styleLabelLowerLeft,style_label_lower_right:ge.styleLabelLowerRight,style_label_right:ge.styleLabelRight,style_label_up:ge.styleLabelUp,style_label_upper_left:ge.styleLabelUpperLeft,style_label_upper_right:ge.styleLabelUpperRight,style_none:ge.styleNone,style_square:ge.styleSquare,style_text_outline:ge.styleTextOutline,style_triangledown:ge.styleTriangledown,style_triangleup:ge.styleTriangleup,style_xcross:ge.styleXcross},Ty={style_arrow_both:Le.styleArrowBoth,style_arrow_left:Le.styleArrowLeft,style_arrow_right:Le.styleArrowRight,style_dashed:Le.styleDashed,style_dotted:Le.styleDotted,style_solid:Le.styleSolid},$y={abovebar:an.abovebar,absolute:an.absolute,belowbar:an.belowbar,bottom:an.bottom,top:an.top},Ly={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},Ry={style_area:Mr.styleArea,style_areabr:Mr.styleAreabr,style_circles:Mr.styleCircles,style_columns:Mr.styleColumns,style_cross:Mr.styleCross,style_histogram:Mr.styleHistogram,style_line:Mr.styleLine,style_linebr:Mr.styleLinebr,style_stepline:Mr.styleStepline,style_stepline_diamond:Mr.styleSteplineDiamond,style_steplinebr:Mr.styleSteplinebr},Py={bottom_center:_r.bottomCenter,bottom_left:_r.bottomLeft,bottom_right:_r.bottomRight,middle_center:_r.middleCenter,middle_left:_r.middleLeft,middle_right:_r.middleRight,top_center:_r.topCenter,top_left:_r.topLeft,top_right:_r.topRight},zy={left:bs.left,none:bs.none,right:bs.right},ky={arrowdown:ur.arrowdown,arrowup:ur.arrowup,circle:ur.circle,cross:ur.cross,diamond:ur.diamond,flag:ur.flag,labeldown:ur.labeldown,labelup:ur.labelup,square:ur.square,triangledown:ur.triangledown,triangleup:ur.triangleup,xcross:ur.xcross},qy={auto:rr.auto,huge:rr.huge,large:rr.large,normal:rr.normal,small:rr.small,tiny:rr.tiny},Uy={cash:Re.cash,fixed:Re.fixed,percent_of_equity:Re.percentOfEquity,commission:{cash_per_contract:nr.cashPerContract,cash_per_order:nr.cashPerOrder,percent:nr.percent},direction:{all:ue.all,long:ue.long,short:ue.short},oca:{cancel:un.cancel,none:un.none,reduce:un.reduce}},Wy={align_bottom:Wt.alignBottom,align_center:Wt.alignCenter,align_left:Wt.alignLeft,align_right:Wt.alignRight,align_top:Wt.alignTop,wrap_auto:Wt.wrapAuto,wrap_none:Wt.wrapNone},jy={bar_index:we.bar_index,bar_time:we.bar_time},Vy={abovebar:Wr.abovebar,belowbar:Wr.belowbar,price:Wr.price},Yy={actual:xs.actual,estimate:xs.estimate,standardized:xs.standardized};class th{constructor(){$(this,"adjustment",{dividends:ws.dividends,none:ws.none,splits:ws.splits});$(this,"alert",Fy);$(this,"barmerge",My);$(this,"color",Ci);$(this,"currency",Xf);$(this,"dayofweek",Ny);$(this,"earnings",Yy);$(this,"display",Qf);$(this,"extend",Sy);$(this,"font",{family_default:Zn.familyDefault,family_monospace:Zn.familyMonospace});$(this,"format",By);$(this,"hline",Oy);$(this,"label",Iy);$(this,"line",Ty);$(this,"location",$y);$(this,"math",Ly);$(this,"order",{ascending:Yn.ascending,descending:Yn.descending});$(this,"plot",Ry);$(this,"position",Py);$(this,"scale",zy);$(this,"session",{extended:fi.extended,regular:fi.regular});$(this,"shape",ky);$(this,"size",qy);$(this,"splits",{denominator:"denominator",numerator:"numerator"});$(this,"strategy",Uy);$(this,"text",Wy);$(this,"xloc",jy);$(this,"yloc",Vy)}updateData(){}}class Zy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:we.bar_index,line_color:Ci.blue,line_style:Le.styleSolid,line_width:1});this._variables=t,this._errorListener=e}new(t,e){var l;const{bar_index:r}=this._variables,n=`polyline_${e}_${r}`,i=Object.assign({},this._defaultPolyline,t,{id:n,bar_index:r,points:(l=t.points)==null?void 0:l._value.map(c=>({time:c.time,index:c.index,price:c.price}))});me(i,["line_color","fill_color"]);const a=new eh(n,this._variables);return this._verfiyArgs(t,e),e.startsWith("export")||this._variables.polyline.add(n,i,a),a}_verfiyArgs(t,e){const{line_style:r,xloc:n}=t,i="polyline.new";this._paramVerfiy(r,e,i,Object.values(Le),"line_style"),this._paramVerfiy(n,e,i,Object.values(we),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}delete({id:t}){t&&t.delete()}}class eh{constructor(t,e){$(this,"_id");$(this,"_variables");this._variables=e,this._id=t}get type(){return Fe.POLYLINE}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get data(){return this._variables.polyline.get(this._id)}delete(){this._variables.polyline.delete(this._id)}}class Ky{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLine",{xloc:we.bar_index,extend:Ur.none,style:Le.styleSolid});this._variables=t,this._errorListener=e}new({first_point:t,second_point:e,...r},n){const{bar_index:i}=this._variables,a=`line_${n}_${i}`;me(r,["color"]);const l={...this._defaultLine,...r,id:a,bar_index:i};if(t&&e){const h=l.xloc===we.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,p=l.xloc===we.bar_index?e==null?void 0:e.index:e==null?void 0:e.time;Object.assign(l,{x1:h,y1:t==null?void 0:t.price,x2:p,y2:e==null?void 0:e.price})}this._verfiyArgs(r,n);const c=new uo(a,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(a,l,c),c}_verfiyArgs(t,e){const{extend:r,xloc:n,style:i}=t,a="line.new";this._paramVerfiy(i,e,a,Object.values(Le),"style"),this._paramVerfiy(r,e,a,Object.values(Ur),"extend"),this._paramVerfiy(n,e,a,Object.values(we),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}line(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_x1({id:t},e){return t==null?void 0:t.get_x1(e)}get_x2({id:t},e){return t==null?void 0:t.get_x2(e)}get_y1({id:t},e){return t==null?void 0:t.get_y1(e)}get_y2({id:t},e){return t==null?void 0:t.get_y2(e)}set_x1({id:t,...e},r){t==null||t.set_x1(e,r)}set_x2({id:t,...e},r){t==null||t.set_x2(e,r)}set_y1({id:t,...e},r){t==null||t.set_y1(e,r)}set_y2({id:t,...e},r){t==null||t.set_y2(e,r)}set_xy1({id:t,...e},r){t==null||t.set_xy1(e,r)}set_xy2({id:t,...e},r){t==null||t.set_xy2(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}get_price({id:t,...e},r){return t==null?void 0:t.get_price(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_width({id:t,...e},r){t==null||t.set_width(e,r)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_first_point({id:t,...e},r){t==null||t.set_first_point(e,r)}set_second_point({id:t,...e},r){t==null||t.set_second_point(e,r)}}class uo{constructor(t,e,r){$(this,"_variables");$(this,"_id");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get type(){return Fe.LINE}get data(){return this._variables.line.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`line_${t}_${e}`,n=this._getLine(t),i=new uo(r,this._variables,this._errorListener);return n&&this._variables.line.add(r,{...n,id:r,bar_index:e},i),i}delete(){this._variables.line.delete(this._id)}get_price({x:t},e){const r=this._getLine(e);if(t===void 0)return t;if(r&&r.xloc===we.bar_index){const{x1:n,y1:i,x2:a,y2:l}=r;return n===void 0||a===void 0||i===void 0||l===void 0?void 0:(l-i)/(a-n)*(t-n)+i}}get_x1(t){var e;return(e=this._getLine(t))==null?void 0:e.x1}get_x2(t){var e;return(e=this._getLine(t))==null?void 0:e.x2}get_y1(t){var e;return(e=this._getLine(t))==null?void 0:e.y1}get_y2(t){var e;return(e=this._getLine(t))==null?void 0:e.y2}set_x1({x:t},e){const r=this._getLine(e);r&&(r.x1=t)}set_x2({x:t},e){const r=this._getLine(e);r&&(r.x2=t)}set_y1({y:t},e){const r=this._getLine(e);r&&(r.y1=t)}set_y2({y:t},e){const r=this._getLine(e);r&&(r.y2=t)}set_xy1({x:t,y:e},r){const n=this._getLine(r);n&&(n.x1=t,n.y1=e)}set_xy2({x:t,y:e},r){const n=this._getLine(r);n&&(n.x2=t,n.y2=e)}set_xloc({xloc:t,x1:e,x2:r},n){const i=this._getLine(n);i&&(i.xloc=t,i.x1=e,i.x2=r,this._paramVerfiy(t,n,"line.set_xloc",Object.values(we),"xloc"))}set_color(t,e){const r=this._getLine(e);r&&(me(t,["color"]),r.color=t.color)}set_style({style:t},e){const r=this._getLine(e);r&&(r.style=t,this._paramVerfiy(t,e,"line.set_style",Object.values(Le),"style"))}set_width({width:t},e){const r=this._getLine(e);r&&(r.width=t)}set_extend({extend:t},e){const r=this._getLine(e);r&&(r.extend=t,this._paramVerfiy(t,e,"line.set_extend",Object.values(Ur),"extend"))}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:i,price:a}=t||{},l=r.xloc===we.bar_index?n:i,c=a;l&&(r.x1=l),c&&(r.y1=c)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:i,price:a}=t||{},l=r.xloc===we.bar_index?n:i,c=a;l&&(r.x2=l),c&&(r.y2=c)}}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class Gy{constructor(t){$(this,"_variables");this._variables=t}new(t,e){const{line1:r,line2:n}=t,{bar_index:i}=this._variables,a=`linefill_${e}_${i}`,l=r==null?void 0:r.data,c=n==null?void 0:n.data;l&&(l.linefills=l.linefills||[],l.linefills.push(a)),c&&(c.linefills=c.linefills||[],c.linefills.push(a)),me(t,["color"]);const h=new lo(this._variables,a,r,n);return e.startsWith("export")||(l||c)&&this._variables.linefill.add(a,{line1:l,line2:c,color:t.color,id:a,bar_index:i},h),h}delete({id:t}){t==null||t.delete()}get_line1({id:t}){return t==null?void 0:t.get_line1()}get_line2({id:t}){return t==null?void 0:t.get_line2()}set_color({id:t,...e}){t==null||t.set_color(e)}}class lo{constructor(t,e,r,n){$(this,"_id");$(this,"_line1");$(this,"_line2");$(this,"_variables");this._variables=t,this._id=e,this._line1=r,this._line2=n}get type(){return Fe.LINEFILL}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get data(){return this._variables.linefill.get(this._id)}linefill(t,e){return t.x?t.x:new lo(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:i}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.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(t){const e=this._variables.linefill.get(this._id);e&&(me(t,["color"]),e.color=t.color)}}class Hy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultBox",{border_color:Ci.blue,border_width:1,bgcolor:Ci.blue,xloc:we.bar_index,extend:Ur.none,style:Le.styleSolid,text:"",text_size:rr.auto,text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_wrap:Wt.wrapNone});this._variables=t,this._errorListener=e}box({x:t}){return t}new({top_left:t,bottom_right:e,...r},n){const{bar_index:i}=this._variables,a=`box_${n}_${i}`,l={...this._defaultBox,...r,id:a,bar_index:i};if(me(l,["border_color","bgcolor","text_color"]),t){const{price:h,time:p,index:f}=t;l.top=h,l.left=l.xloc===we.bar_index?f:p}if(e){const{price:h,time:p,index:f}=e;l.bottom=h,l.right=l.xloc===we.bar_index?f:p}this._verfiyArgs(r,n);const c=new co(this._variables,a,this._errorListener);return n.startsWith("export")||this._variables.box.add(a,l,c),c}_verfiyArgs(t,e){const{border_style:r,extend:n,xloc:i,text_size:a,text_halign:l,text_valign:c,text_wrap:h,text_font_family:p}=t,f="box.new";this._paramVerfiy(r,e,f,[Le.styleDashed,Le.styleDotted,Le.styleSolid],"border_style"),this._paramVerfiy(n,e,f,Object.values(Ur),"extend"),this._paramVerfiy(i,e,f,Object.values(we),"xloc"),this._paramVerfiy(a,e,f,Object.values(rr),"text_size"),this._paramVerfiy(l,e,f,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"),this._paramVerfiy(c,e,f,[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"),this._paramVerfiy(h,e,f,[Wt.wrapAuto,Wt.wrapNone],"text_wrap"),this._paramVerfiy(p,e,f,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_top({id:t}){return t==null?void 0:t.get_top()}get_bottom({id:t}){return t==null?void 0:t.get_bottom()}get_left({id:t}){return t==null?void 0:t.get_left()}get_right({id:t}){return t==null?void 0:t.get_right()}set_top({id:t,...e}){t==null||t.set_top(e)}set_bottom({id:t,...e}){t==null||t.set_bottom(e)}set_left({id:t,...e}){t==null||t.set_left(e)}set_right({id:t,...e}){t==null||t.set_right(e)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_bgcolor({id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({id:t,...e}){t==null||t.set_border_color(e)}set_border_width({id:t,...e}){t==null||t.set_border_width(e)}set_border_style({id:t,...e},r){t==null||t.set_border_style(e,r)}set_lefttop({id:t,...e}){t==null||t.set_lefttop(e)}set_rightbottom({id:t,...e}){t==null||t.set_rightbottom(e)}set_text_size({id:t,...e},r){t==null||t.set_text_size(e,r)}set_text_wrap({id:t,...e},r){t==null||t.set_text_wrap(e,r)}set_text_color({id:t,...e}){t==null||t.set_text_color(e)}set_text_halign({id:t,...e},r){t==null||t.set_text_halign(e,r)}set_text_valign({id:t,...e},r){t==null||t.set_text_valign(e,r)}set_top_left_point({id:t,...e}){t==null||t.set_top_left_point(e)}set_bottom_right_point({id:t,...e}){t==null||t.set_bottom_right_point(e)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class co{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");this._variables=t,this._id=e,this._errorListener=r}get type(){return Fe.BOX}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get data(){return this._variables.box.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`box_${t}_${e}`,n=this._getBox(),i=new co(this._variables,r,this._errorListener);return n&&this._variables.box.add(r,{...n,id:r,bar_index:e},i),i}delete(){this._variables.box.delete(this._id)}get_top(){const t=this._getBox();return t&&t.top}set_top({top:t}){const e=this._getBox();e&&(e.top=t)}get_left(){const t=this._getBox();return t&&t.left}set_left({left:t}){const e=this._getBox();e&&(e.left=t)}set_text({text:t}){const e=this._getBox();e&&(e.text=t)}get_right(){const t=this._getBox();return t&&t.right}set_right({right:t}){const e=this._getBox();e&&(e.right=t)}get_bottom(){const t=this._getBox();return t&&t.bottom}set_bottom({bottom:t}){const e=this._getBox();e&&(e.bottom=t)}set_extend({extend:t},e){const r=this._getBox();r&&(r.extend=t,this._paramVerfiy(t,e,"box.set_extend",Object.values(Ur),"extend"))}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t,me(e,["bgcolor"]))}set_lefttop({left:t,top:e}){const r=this._getBox();r&&(r.left=t,r.top=e)}set_text_size({text_size:t},e){const r=this._getBox();r&&(r.text_size=t,this._paramVerfiy(t,e,"box.set_text_size",Object.values(rr),"text_size"))}set_text_wrap({text_wrap:t},e){const r=this._getBox();r&&(r.text_wrap=t,this._paramVerfiy(t,e,"box.set_text_wrap",[Wt.wrapAuto,Wt.wrapNone],"text_wrap"))}set_text_color({text_color:t}){const e=this._getBox();e&&(e.text_color=t,me(e,["text_color"]))}set_rightbottom({right:t,bottom:e}){const r=this._getBox();r&&(r.right=t,r.bottom=e)}set_text_halign({text_halign:t},e){const r=this._getBox();r&&(r.text_halign=t,this._paramVerfiy(t,e,"box.set_text_halign",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"))}set_text_valign({text_valign:t},e){const r=this._getBox();r&&(r.text_valign=t,this._paramVerfiy(t,e,"box.set_text_valign",[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"))}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:i}=t||{};e.top=n,e.left=e.xloc===we.bar_index?r:i}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t,me(e,["border_color"]))}set_border_style({style:t},e){const r=this._getBox();r&&(r.border_style=t,this._paramVerfiy(t,e,"box.set_border_style",[Le.styleDashed,Le.styleDotted,Le.styleSolid],"style"))}set_border_width({width:t}){const e=this._getBox();e&&(e.border_width=t)}set_bottom_right_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:i}=t||{};e.bottom=n,e.right=e.xloc===we.bar_index?r:i}}set_text_font_family({text_font_family:t},e){const r=this._getBox();r&&(r.text_font_family=t,this._paramVerfiy(t,e,"box.set_text_font_family",Object.values(Zn),"text_font_family"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getBox(){return this._variables.box.get(this._id)}}class Jy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultTable",{position:_r.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=t,this._errorListener=e}table({x:t}){return t}new(t,e){const{bar_index:r}=this._variables,n=`table_${e}_${r}`,{rows:i}=t;me(t,["text_color","bgcolor","border_color"]);const a=Array.from(Array(i),()=>[]),l=e.split("_"),c=l.pop(),h=l.pop(),p={...this._defaultTable,...t,cell:a,id:n,bar_index:r,line:h,col:c},f=new rh(this._variables,n,this._errorListener);return this._paramVerfiy(t.position,e,"table.new",Object.values(_r),"position"),e.startsWith("export")||this._variables.table.add(n,p,f),f}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}cell({table_id:t,...e}){t==null||t.cell(e)}cell_set_bgcolor({table_id:t,...e}){t==null||t.cell_set_bgcolor(e)}cell_set_height({table_id:t,...e}){t==null||t.cell_set_height(e)}cell_set_text({table_id:t,...e}){t==null||t.cell_set_text(e)}cell_set_text_color({table_id:t,...e}){t==null||t.cell_set_text_color(e)}cell_set_text_font_family({table_id:t,...e}){t==null||t.cell_set_text_font_family(e)}cell_set_text_halign({table_id:t,...e}){t==null||t.cell_set_text_halign(e)}cell_set_text_valign({table_id:t,...e}){t==null||t.cell_set_text_valign(e)}cell_set_text_size({table_id:t,...e}){t==null||t.cell_set_text_size(e)}cell_set_tooltip({table_id:t,...e}){t==null||t.cell_set_tooltip(e)}cell_set_width({table_id:t,...e}){t==null||t.cell_set_width(e)}clear({table_id:t,...e}){t==null||t.clear(e)}delete({table_id:t}){t==null||t.delete()}merge_cells({table_id:t,...e},r){t==null||t.merge_cells(e,r)}set_bgcolor({table_id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({table_id:t,...e}){t==null||t.set_border_color(e)}set_border_width({table_id:t,...e}){t==null||t.set_border_width(e)}set_frame_color({table_id:t,...e}){t==null||t.set_frame_color(e)}set_frame_width({table_id:t,...e}){t==null||t.set_frame_width(e)}set_position({table_id:t,...e},r){t==null||t.set_position(e,r)}}class rh{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_defaultCell",{column:0,row:0,text:"",text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_size:rr.normal});this._variables=t,this._id=e,this._errorListener=r}get type(){return Fe.TABLE}get id(){return this._id}updateId(){const t=this._id.split("_");return t.pop(),this._id=`${t.join("_")}_${this._variables.bar_index}`,this._id}get data(){return this._variables.table.get(this._id)}cell(t){const e={...this._defaultCell,...t},{column:r=0,row:n=0}=e,i=this._variables.table.get(this._id);if(i){const a=i.cell||[],l=a[n]||[];l[r]=e,a[n]=l,i.cell=a}}cell_set_bgcolor({column:t=0,row:e=0,bgcolor:r}){const n=this._getTableItem(t,e);n&&(n.bgcolor=r)}cell_set_height({column:t=0,row:e=0,height:r}){const n=this._getTableItem(t,e);n&&(n.height=r)}cell_set_text({column:t=0,row:e=0,text:r}){const n=this._getTableItem(t,e);n&&(n.text=r)}cell_set_text_color({column:t=0,row:e=0,text_color:r}){const n=this._getTableItem(t,e);n&&(n.text_color=r,me(n,["text_color"]))}cell_set_text_font_family({column:t=0,row:e=0,text_font_family:r}){const n=this._getTableItem(t,e);n&&(n.text_font_family=r)}cell_set_text_halign({column:t=0,row:e=0,text_halign:r}){const n=this._getTableItem(t,e);n&&(n.text_halign=r)}cell_set_text_valign({column:t=0,row:e=0,text_valign:r}){const n=this._getTableItem(t,e);n&&(n.text_valign=r)}cell_set_text_size({column:t=0,row:e=0,text_size:r}){const n=this._getTableItem(t,e);n&&(n.text_size=r)}cell_set_tooltip({column:t=0,row:e=0,tooltip:r}){const n=this._getTableItem(t,e);n&&(n.tooltip=r)}cell_set_width({column:t=0,row:e=0,width:r}){const n=this._getTableItem(t,e);n&&(n.width=r)}clear({start_column:t=0,start_row:e=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 l=e;l<=n;l++)for(let c=t;c<=r;c++){const h=a[l];h&&(h[c]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0},i){if(t>r||e>n){this._errorListener.addError(le.mergeCellErr,i,zt.Error);return}const a=this._variables.table.get(this._id);if(!a)return;const l=a.merge_cells||[];l.push({start_column:t,start_row:e,end_column:r,end_row:n}),a.merge_cells=l}set_bgcolor({bgcolor:t}){const e=this._variables.table.get(this._id);e&&(e.bgcolor=t,me(e,["bgcolor"]))}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t,me(e,["border_color"]))}set_border_width({border_width:t}){const e=this._variables.table.get(this._id);e&&(e.border_width=t)}set_frame_color({frame_color:t}){const e=this._variables.table.get(this._id);e&&(e.frame_color=t)}set_frame_width({frame_width:t}){const e=this._variables.table.get(this._id);e&&(e.frame_width=t)}set_position({position:t},e){const r=this._variables.table.get(this._id);r&&(r.position=t,this._paramVerfiy(t,e,"table.set_position",Object.values(_r),"position"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getTableItem(t,e){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[e][t]:void 0}}}class Xy{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){return this._verifyTradeNum(t)&&this._strategy.historyOrders[t].commission||0}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.historyOrders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_price}entry_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_time}exit_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_index}exit_comment({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_comment:""}exit_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_id:""}exit_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_price}exit_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{out_qty:e=0,direction:r}=this._strategy.historyOrders[t];return r===ue.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.historyOrders.length;return!(t>=e)}}class Qy{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,original_qty:r=0,commission:n=0}=this._strategy.orders[t];return n*e/r}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.orders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_price}entry_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,direction:r}=this._strategy.orders[t];return r===ue.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.orders.length;return!(t>=e)}}class tw{constructor(t,e){$(this,"_strategy");$(this,"_errorListener");this._strategy=t,this._errorListener=e}allow_entry_in({value:t},e){this._paramVerfiy(t,e,"strategy.risk.allow_entry_in",Object.values(ue),"value"),this._strategy.updateRisk({allow_entry_in:t})}max_cons_loss_days({count:t}){this._strategy.updateRisk({max_cons_loss_days:t})}max_drawdown({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_drawdown",[Re.percentOfEquity,Re.cash],"type"),e===Re.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_drawdown:t,max_drawdown_type:e})}max_intraday_filled_orders({count:t}){this._strategy.updateRisk({max_intraday_filled_orders:t})}max_intraday_loss({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_intraday_loss",[Re.percentOfEquity,Re.cash],"type"),e===Re.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_intraday_loss:t,max_intraday_loss_type:e})}max_position_size({contracts:t}){this._strategy.updateRisk({max_position_size:t})}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}}let ew=class{constructor(t,e,r,n,i){$(this,"_variables");$(this,"_options");$(this,"_totalChangeCapital");$(this,"_historyOrder");$(this,"_orders");$(this,"_pendingOrders");$(this,"_mintick");$(this,"_funcOptions");$(this,"_pendingCloseOrders");$(this,"_errorListener");$(this,"_risk");$(this,"_opentrades");$(this,"_closedtrades");$(this,"_riskNamespace");$(this,"_updateOptions",{});$(this,"_id");$(this,"_maxDrawdownVerifyIndex",0);this._variables=t,this._errorListener=n,this._options={overlay:!1,format:Kt.inherit,pyramiding:1,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Re.fixed,default_qty_value:1,initial_capital:1e6,currency:Xf.NONE,slippage:0,commission_type:nr.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=e,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 Qy(this),this._closedtrades=new Xy(this),this._riskNamespace=new tw(this,n),this._id=`strategy_${i}`}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _freezeCapital(){const{close:t}=this._variables;return this._orders.reduce((e,r)=>e+t*(r.qty||0),0)}get opentrades(){return this._opentrades}get closedtrades(){return this._closedtrades}get risk(){return this._riskNamespace}updateOptions(t){this._updateOptions=t||{},Object.assign(this._options,this._updateOptions)}update(){this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),this._maxDrawdownVerify(),this._variables.strategy.update(),!this._options.process_orders_on_close&&this._calcLiquidate(),this._calcProfitAndLoss()}updateRisk(t){Object.assign(this._risk,t)}endExecution(){this._maxIntradayLoss(),this._pendingCloseOrderHandle(),this._options.process_orders_on_close&&this._calcLiquidate()}_maxIntradayLoss(){var g;const{max_intraday_loss:t,max_intraday_loss_type:e,isDisabledOpen:r}=this._risk;if(t===void 0||!e||r)return;const{high:n,low:i,time_tradingday:a,time:l,strategy:{netprofit:c,initial_capital:h}}=this._variables;let{preNetprofit:p=0}=this._risk;l===a&&(p=c,this._risk.preNetprofit=c,this._risk.isTemporaryBan=!1);let f=p-c;f+=this._orders.reduce((y,m)=>{const{in_price:w,direction:v,qty:x=0,commission:b=0,original_qty:N=0}=m,E=v===ue.long?1:-1,A=(n-w)*x,M=(i-w)*x,S=E===1?M:-A;return y+S+x/N*b},0);let d=!1;switch(e){case Re.cash:d=t<f;break;case Re.percentOfEquity:const y=f/(h+c)*100;d=t<y;break}if(d){this._risk.isTemporaryBan=!0;const y=(g=this._orders[0])==null?void 0:g.direction;this._closeOrders(this._orders,y===ue.long?i:n,"Close Position (Max intraday Loss)",void 0,"close"),this._pendingOrders=[]}}_maxIntradayFilledOrdersVerify(){const{max_intraday_filled_orders:t,intradayOrders:e=0,isDisabledOpen:r}=this._risk;if(t===void 0||r)return;const{time:n,time_tradingday:i,open:a}=this._variables;n===i&&(this._risk.intradayOrders=0,this._risk.isTemporaryBan=!1),t<=e&&(this._risk.isTemporaryBan=!0,this._closeOrders(this._orders,a,"Close Position (Max number of filled orders in one day)",void 0,"close"),this._pendingOrders=[])}_maxConsLossDaysVerify(){const{max_cons_loss_days:t,lossDays:e=0,isDisabledOpen:r,totalProfit:n=0}=this._risk;if(t===void 0||r)return;const{time:i,time_tradingday:a,strategy:l,open:c}=this._variables;let h=e;if(i===a){const p=l.netprofit+l.openprofit;p<n?h=0:h++,Object.assign(this._risk,{lossDays:h,totalProfit:p})}t<=h&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){const{max_drawdown:t,max_drawdown_type:e,isDisabledOpen:r}=this._risk;if(r)return;const{bar_index:n,open:i}=this._variables;if(t!==void 0&&e&&this._maxDrawdownVerifyIndex===n){const{initial_capital:a}=this._options,c=this._orders.reduce((p,f)=>{const{in_price:d,commission:g=0,qty:y=0,original_qty:m=0,direction:w}=f,v=w===ue.long?1:-1,x=(i-d)*v*y;return p+x+g*y/m},0)+this._totalChangeCapital;let h=!1;switch(e){case Re.percentOfEquity:h=c/a*100<=-t;break;case Re.cash:h=c<=-t;break}h&&this._riskTouchOff(i,"Close Position (Max Drawdown)")}}_riskTouchOff(t,e){this._risk.isDisabledOpen=!0,this._orders.length&&this._closeOrders(this._orders,t,e,"close"),this._pendingOrders=[]}strategy(t,e){if(!this._variables.bar_index){this._paramVerfiy(t.format,e,"strategy",[Kt.inherit,Kt.price,Kt.percent,Kt.volume],"format"),this._paramVerfiy(t.default_qty_type,e,"strategy",Object.values(Re),"default_qty_type"),this._paramVerfiy(t.commission_type,e,"strategy",Object.values(nr),"commission_type");const r=self==null?void 0:self.workerStorage.get(this._id),n={...this._updateOptions};if(r)for(const i of Object.keys({...r,...t}))t[i]!==r[i]&&delete n[i];self==null||self.workerStorage.set(this._id,t),Object.assign(this._options,t,n),this._variables.updateMaxLength(t),Object.assign(this._funcOptions,{strategy:this._options,userSetStrategyConfig:n,scriptType:"strategy"})}}order(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.order",Object.values(un),"oca_type"),this._orderHandle(t))}entry(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.entry",Object.values(un),"oca_type"),this._entryHandle(t))}close(t){if(!this._orders.filter(r=>!this._options.process_orders_on_close||r.in_index!==this._variables.bar_index).length)return;const{immediately:e}=t;if(e||this._options.process_orders_on_close){const r=this._pendingCloseOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingCloseOrders.push({...t,place_order_type:"close"})}else{const r=this._pendingOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingOrders.push({...t,place_order_type:"close"})}}close_all(t){if(typeof t=="string"&&(t={}),!this._orders.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close_all"}):this._pendingOrders.push({...t,place_order_type:"close_all"})}cancel({id:t}){this._pendingOrders=this._pendingOrders.filter(e=>!(e.id===t&&e.place_order_type!=="close"))}cancel_all(){this._pendingOrders=this._pendingOrders.filter(t=>t.place_order_type==="close_all")}exit(t,e){this._exit(t,e)}convert_to_account({value:t}){return t}convert_to_symbol({value:t}){return t}default_entry_qty({fill_price:t}){return t?this._calcDefaultQty(t):0}_calcDefaultQty(t){const{default_qty_type:e=Re.fixed,default_qty_value:r=1,initial_capital:n}=this._options;let i=r;switch(e){case Re.cash:i=r/t;break;case Re.percentOfEquity:const a=this._getOrderProfit(t);i=(n+a+this._totalChangeCapital)*r/100/t;break}return Tl(i,this._getLen(t))}_getLen(t){const e=String(Math.floor(t)).length-2;return e<0?0:e}_getCapital(t,e){const{margin_long:r=0,margin_short:n=0}=this._options;return r<100&&r>0&&t===1?e=e*100/r:n<=100&&n>0&&t===-1&&(e=e*100/n),e}_calcProfitAndLoss(){const{close:t}=this._variables;for(const e of this._orders){const{in_price:r,qty:n=0,direction:i}=e,a=i===ue.long?1:-1,l=(t-r)*a*n,[c,h]=this._calcProfitAndLossHandle(r,n,a);this._calcOrderPercent(e,l,c,h)}}_calcProfitAndLossHandle(t,e,r){const{high:n,low:i}=this._variables,a=(n-t)*e,l=(i-t)*e;let c=r===1?a:-l,h=r===1?l:-a;return[c,h]}_calcOrderPercent(t,e,r,n){const{commission_value:i}=this._options,{close:a}=this._variables,{original_qty:l=0,qty:c=0,in_price:h,max_profit:p=0,trading_loss:f=0}=t;let{commission:d=0}=t,g=h*c;if(i){const y=this._getCommission(a,c);d=d*c/l,r-=d,n-=d,g+=d,e=e-y-d}r=Math.max(r,p,0),n=Math.min(n,f,0),Object.assign(t,{profit:e,total_profit:this._totalChangeCapital+e,total_profit_percent:e/(this._options.initial_capital+this._totalChangeCapital)*100,max_profit:r,trading_loss:n,profit_percent:e/g*100,max_profit_percent:r/g*100,trading_loss_percent:n/g*100})}_calcLiquidate(){if(!this._orders.length)return;const{high:t,low:e,time:r}=this._variables,{initial_capital:n,margin_long:i=0,margin_short:a=0}=this._options,l=this._orders[0].direction===ue.long?1:-1;let c=l===1?e:t;if(l===1&&i===100)return;const h=(l===1?i:a)/100;if(h<=0)return;let p=!1;const[f,d]=this._orders.reduce((w,v)=>{let[x,b]=w;const{in_price:N,qty:E=0,in_time:A}=v;A===r&&(p=!0);const M=N*E,S=c*E;return x+=M,b+=S,[x,b]},[0,0]);let g=0,y=0;const m=n+this._totalChangeCapital;if(p&&(g=m-f*h,g<0&&(c=this._orders[0].in_price,y=Math.abs(Math.trunc(g/h/c)*4),y=Math.max(y,1))),g>=0){const w=l*(d-f);if(g=m+w-d*h,g>=0)return;y=Math.abs(Math.trunc(g/h/c)*4)}y<=0||this._marginCallOrders(c,y,"Margin Call")}_marginCallOrders(t,e,r){const{close_entries_rule:n="FIFO"}=this._options;if(n==="FIFO"){this._processOrders(this._orders,t,e*this._orders.length,r,r,!0);return}for(const i of this.orders)i.position_close_type=i.place_order_type,this._processOrder(i,t,e,r,r,!0);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_orderHandle(t){const{process_orders_on_close:e,slippage:r=0}=this._options,{orders:n,isMarketPrice:i,quantities:a,close:l,price:c,activePrice:h}=this._orderArgsParse(t),p=t.direction===ue.long?1:-1;if(a<=0)return;let f=a;if(i&&e){if(n.length){const b=this._processOrders(n,l,f,t.id,t.comment,!1,"order");if(b<=0)return;f=b}const g=l+p*r*this._mintick;if(!this._judgeCapitalEnough(f,g,p))return;this._ocaGroupVerify(f,t.oca_name,t.oca_type);const{bar_index:m,time:w,high:v,low:x}=this._variables;this._calcCurrentOrder({...t,in_price:g,in_high:v,in_low:x,in_index:m,in_time:w,qty:f,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,p)&&this._addPendingOrders(t,c,f,i,h)}_judgeCapitalEnough(t,e,r){let n=this._freezeCapital;if(this._orders.some(p=>(p.direction===ue.long?1:-1)!==r)&&(n=0),t<=0)return!1;const{margin_long:i=0,margin_short:a=0}=this._options;if(i===0&&r===1||a===0&&r===-1)return!0;const l=this._getOrderProfit(e),h=this._getCapital(r,this._options.initial_capital+l+this._totalChangeCapital)-n;return t*e<=h}_getOrderProfit(t){return this._orders.reduce((e,r)=>{const{in_price:n,qty:i=0,direction:a}=r,l=a===ue.long?1:-1;return e+(t-n)*i*l},0)}_ocaGroupVerify(t,e,r){if(!e||!r||r===un.none)return!1;let n=!1;switch(r){case un.cancel:this._pendingOrders=this._pendingOrders.filter(i=>{if(i.oca_name===e)i.isCancel=!0,n=!0;else return!0});break;case un.reduce:this._pendingOrders=this._pendingOrders.filter(i=>{const{qty:a=0,oca_name:l}=i;if(e===l){const c=a-t;return n=!0,c<=0?(i.isCancel=!0,!1):(i.qty=c,!0)}else return!0});break}return n}_processOrders(t,e,r,n,i,a=!1,l){let c=r;for(const h of t)if(h.position_close_type=l||h.place_order_type,c=this._processOrder(h,e,c,n,i,a),c<=0)break;return this._orders=this._orders.filter(h=>!h.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),c}_addPendingOrders(t,e,r,n,i){const a=this._pendingOrders.find(l=>l.id===t.id&&!l.isMarketPrice);if(a)Object.assign(a,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else{const l={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"order"};this._pendingOrders.push(l)}}_orderArgsParse(t){const{direction:e,qty:r,stop:n}=t;let i=t.limit||0;const{close:a}=this._variables;let l=a,c=!1,h;const p=e===ue.long?1:-1,f=n&&(n-a)*p>0,{backtest_fill_limits_assumption:d=0}=this._options;d>0&&i&&(i-=d*this._mintick*p);const g=i&&(i-a)*p<0;f&&g?(h=n,l=i):f?l=n:g?l=i:c=!0;const y=r!==void 0?Tl(r,this._getLen(l)):this._calcDefaultQty(l);return{orders:this._orders.filter(w=>w.direction!==e),isMarketPrice:c,activePrice:h,quantities:y,close:a,price:l}}_entryHandle(t){const{process_orders_on_close:e}=this._options,{orders:r,isMarketPrice:n,quantities:i,close:a,price:l,activePrice:c}=this._orderArgsParse(t);if(i<=0)return;if(r.length&&n&&e){this._entryOrder(r,a,i,t);return}this._judgeCapitalEnough(i,a,t.direction===ue.long?1:-1)&&this._addPendingEntry(t,l,i,n,c)}_entryOrder(t,e,r,n){const{time:i,bar_index:a,high:l,low:c}=this._variables,{slippage:h=0}=this._options,{oca_name:p,oca_type:f,direction:d,comment:g,isMarketPrice:y,id:m}=n,w=d===ue.long?1:-1;if(r=this._getAvailablePositionSize(r,d),r<=0||(e=e+h*this._mintick*w,!this._judgeCapitalEnough(r,e,w)))return;this._closeOrders(t,e,m,g,"entry");const x={...n,in_price:e,qty:r,in_index:a,in_high:l,in_low:c,in_time:i,place_order_type:"entry"};if(y){this._calcCurrentOrder(x);return}const{pendingOrders:b,orders:N}=this._getEntryOrders(d),E=b.length+N.length;E&&E>=(this._options.pyramiding||1)||(this._ocaGroupVerify(r,p,f),this._calcCurrentOrder(x))}_getAvailablePositionSize(t,e){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==ue.all&&n!==e)return 0;if(r===void 0)return t;const i=this._orders.reduce((a,l)=>a+(l.qty||0),0);return i?i+t>r?0:t:t>r?t-r:0}_getEntryOrders(t){const e=this._pendingOrders.filter(n=>["entry","order"].includes(n.place_order_type)&&n.direction===t),r=this._orders.filter(n=>n.direction===t);return{pendingOrders:e,orders:r}}_addPendingEntry(t,e,r,n,i){if(r=this._getAvailablePositionSize(r,t.direction),r<=0)return;const{pendingOrders:a,orders:l}=this._getEntryOrders(t.direction),c=a.length+l.length,h=a.find(p=>p.id===t.id&&p.place_order_type==="entry");if(h)Object.assign(h,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else if(!c||c<(this._options.pyramiding||1)){const p={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"entry"};this._pendingOrders.push(p)}}_closeAllOrders(t,e){const{comment:r}=t,{bar_index:n}=this._variables,i=this._orders.filter(a=>a.in_index!==n);i.length&&(this._closeOrders(i,e,"Close position order",r,"close"),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(t,e,r,n,i){for(const a of t)a.position_close_type=i,this._closeOrder(a,e,r,n);this._orders=this._orders.filter(a=>!a.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_closeOrder(t,e,r,n){const{time:i,bar_index:a,high:l,low:c}=this._variables,{slippage:h=0}=this._options,{in_price:p,qty:f=0,direction:d}=t,g=d===ue.long?1:-1;e=e-g*h*this._mintick,t.isDeal=!0;const y=(e-p)*g*f,m={...t,out_price:e,out_id:r,out_index:a,out_high:l,out_low:c,out_time:i,out_comment:n,out_qty:f,profit:y};this._calcPercent(m)}_ordersHandle(){const t=this._orders.filter(a=>a.place_order_type==="exit"&&!a.hasExit);if(!t.length)return;const{open:e,low:r,high:n,close:i}=this._variables;for(const a of t){const{stop:l,limit:c,trail_stop_price:h,isMarketPriceLimit:p,isMarketPriceStop:f,direction:d,id:g,out_comment:y,active_price:m,trail_offset:w=0,out_qty:v,comment_loss:x,comment_profit:b,comment_trailing:N}=a;let E=h;const A=d===ue.long?1:-1;let M,S=y;if(p||f?M=e:(c&&r<=c&&n>=c&&(S=b||y,M=c),l&&r<=l&&n>=l&&(M=E?(l-E)*A>0?l:E:l,S=(E===M?N:x)||y)),M)this._processExitOnClose(a,M,{from_entry:g,comment:S,qty:v});else{let T=!1;if(m&&m<=n&&m>=r&&(E=m-w*A*this._mintick,(E-i)*A>=0&&(a.isMarketPriceStop=!0,this._options.process_orders_on_close&&(M=E)),T=!0,a.trail_stop_price=E),E)if((E-e)*A>=0&&!T)M=E;else{const F=(A===1?n:r)-w*A*this._mintick;A===1?E<e&&E>=r&&F>E&&F<i?M=E:F>E?(E=F,F>=i&&(M=F)):E<=n&&r<=E&&(M=E):E>e&&E<=n&&F<E&&F>i?M=E:F<E?(E=F,F<=i&&(M=F)):E<=n&&r<=E&&(M=E),a.trail_stop_price=E}M&&this._processExitOnClose(a,M,{from_entry:g,comment:N||y,qty:v})}}}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const t=[],e=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 this._pendingOrders){const{isCancel:i,place_order_type:a}=n;if(i)continue;let l;switch(a){case"entry":l=this._entryOrderHandle(n);break;case"order":l=this._orderOrderHandle(n);break}l&&t.push(l)}for(const n of r)switch(n.place_order_type){case"close":const i=this._closeOrderHandle(n);i&&t.push(i);break;case"close_all":this._closeAllOrders(n,this._variables.open);break}for(const n of e){const i=this._exitOrderHandle(n);i&&t.push(i)}this._pendingOrders=t}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const t=this._pendingCloseOrders.filter(n=>n.place_order_type==="exit"),e=this._pendingCloseOrders.filter(n=>["close","close_all"].includes(n.place_order_type||"")),{close:r}=this._variables;this._pendingCloseOrders=[];for(const n of e)switch(n.place_order_type){case"close":const i=this._closeOrderHandle(n,!0);i&&this._pendingCloseOrders.push(i);break;case"close_all":this._closeAllOrders(n,r);break}for(const n of t){const{from_entry:i}=n,a=this._orders.filter(l=>!i||l.id===i&&(l.isMarketPriceLimit||l.isMarketPriceStop));for(const l of a)this._processExitOnClose(l,l.limit||l.stop||l.trail_stop_price||r,n)}}_entryOrderHandle(t){const{open:e,low:r,high:n}=this._variables,{isMarketPrice:i,qty:a=0,in_price:l,direction:c,active_price:h}=t;if(h&&n>=h&&r<=h)return delete t.active_price,t;let p=l;if(i&&(p=e),p<=n&&p>=r){const f=this._orders.filter(d=>d.direction!==c);this._entryOrder(f,p,a,t)}else return t}_orderOrderHandle(t){const{open:e,low:r,high:n,time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{isMarketPrice:c,qty:h=0,in_price:p,direction:f,comment:d,oca_name:g,oca_type:y,active_price:m,id:w}=t;if(m&&n>=m&&r<=m)return delete t.active_price,t;let v=p,x=h;if(c&&(v=e),v<=n&&v>=r){const b=this._orders.filter(E=>E.direction!==f);if(b.length&&(x=this._processOrders(b,v,h,w,d,!1,"order"),x<=0))return;const N=f===ue.long?1:-1;this._ocaGroupVerify(x,g,y),this._calcCurrentOrder({...t,in_price:v+N*l*this._mintick,in_index:a,in_time:i,in_high:n,in_low:r,qty:x});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:i=100,comment:a}=t,{close_entries_rule:l="FIFO"}=this._options;let c=[];if(l==="FIFO"?c=this._orders.filter(d=>d.id===r):c=this._orders.filter(d=>d.id===r&&!d.close_qty),!c.length)return t;let h=0;if(n?h=n:(h=c.reduce((d,g)=>d+(g.qty||0),h),h=i/100*h),h<=0)return;const{open:p,close:f}=this._variables;if(l==="FIFO")this._processOrders(c,e?f:p,h,`Close entry(s) order ${r}`,a,!1,"close");else if(this._processCloseOrders(c,e?f:p,h,`Close entry(s) order ${r}`,a))return t}_processCloseOrders(t,e,r,n,i){let a=!1;for(const l of t)l.close_qty=r,(l.qty||0)>r&&(a=!0),l.position_close_type="close",this._processOrder(l,e,r,n,i);return this._orders=this._orders.filter(l=>!l.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),a}_exitOrderHandle(t){const{from_entry:e}=t,r=this._orders.filter(n=>(!e||e===n.id)&&!n.hasExit);if(!(r.length&&!this._ordersToExit(r,t)))return t}_exit(t,e){const{profit:r,loss:n,stop:i,limit:a,trail_offset:l,trail_price:c,trail_points:h,from_entry:p="",id:f}=t;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(i)&&this._isNaN(a)&&(this._isNaN(l)||this._isNaN(h)&&this._isNaN(c))){this._errorListener.addError(le.strategyExitErr,e,zt.Error);return}const d={...t,place_order_type:"exit"},g=this._orders.filter(w=>(!p||p===w.id)&&!w.hasExit),y=this._pendingOrders.filter(w=>!p||p===w.id);if(g.length){if(!this._ordersToExit(g,d))return}else if(!y.length)return;const m=this._pendingOrders.find(w=>w.id===f&&w.place_order_type==="exit");m?Object.assign(m,{...t}):this._pendingOrders.push(d)}_ordersToExit(t,e){const{qty:r,qty_percent:n=100,id:i,comment:a,comment_loss:l,comment_profit:c,comment_trailing:h}=e;let p=r,f=!1;e.comment=a||i;for(const d of t){const{qty:g=0}=d,y=d.direction===ue.long?1:-1;p=r?r>=g?g:r:n/100*g,d.out_qty=p,p<g&&(f=!0),Object.assign(d,{out_comment:a||i,comment_loss:l,comment_profit:c,comment_trailing:h}),!(this._stopProfit(d,y,{...e,qty:p})||this._stopLoss(d,y,{...e,qty:p})||this._trailStopLoss(d,y,{...e,qty:p}))&&(d.place_order_type="exit")}return f}_addExitPendingCloseOrders(t){t.place_order_type="exit";const e=this._pendingCloseOrders.find(r=>r.id===t.id);e?Object.assign(e,{...t}):this._pendingCloseOrders.push(t)}_stopProfit(t,e,r){const{limit:n,profit:i,comment_profit:a,comment:l}=r;let c=n;const{close:h}=this._variables,{in_price:p}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=p+e*i*this._mintick),t.limit=c,c!==void 0&&(c-h)*e<=0&&(t.isMarketPriceLimit=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=h,t.limit=c,f))return this._addExitPendingCloseOrders(r),!0}_stopLoss(t,e,r){const{stop:n,loss:i,comment_loss:a,comment:l}=r;let c=n;const{close:h}=this._variables,{in_price:p}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=p-e*i*this._mintick),t.stop=c,c!==void 0&&(c-h)*e>=0&&(t.isMarketPriceStop=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=h,t.stop=c,f))return this._addExitPendingCloseOrders(r),!0}_trailStopLoss(t,e,r){const{trail_offset:n,trail_price:i,trail_points:a,comment_trailing:l,comment:c}=r;if(!this._isNaN(n)){const{close:h}=this._variables,{in_price:p}=t,{process_orders_on_close:f}=this._options;let d;if(this._isNaN(i)?this._isNaN(a)||(d=p+a*e*this._mintick):d=i,t.trail_offset=n,d!==void 0&&(d-h)*e<=0){const g=h-n*e*this._mintick;if((g-h)*e>=0&&(t.trail_stop_price=h,t.isMarketPriceStop=!0,r.comment=l||c,Object.assign(t,{out_comment:r.comment}),f))return this._addExitPendingCloseOrders(r),!0;t.trail_stop_price=g}t.active_price=d}}_processExitOnClose(t,e,r){const{qty:n=0,comment:i,id:a}=r,{close_entries_rule:l="FIFO"}=this._options;if(l==="FIFO"){const c=this._processExitOrders(this._orders,e,n,a,i);c&&!c.hasExit?(c.hasExit=!0,Object.assign(t,{trail_stop_price:c.trail_stop_price,stop:c.stop,limit:c.limit,trail_offset:c.trail_offset,active_price:c.active_price})):c&&(t.hasExit=!0)}else t.hasExit=!0,this._processOrders([t],e,n,a,i,!1,"exit")}_processExitOrders(t,e,r,n,i){let a=r,l;for(const c of t)if(l=c,c.position_close_type="exit",a=this._processOrder(c,e,a,n,i),a<=0||!c.hasExit)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_processOrder(t,e,r,n,i,a=!1){const{time:l,bar_index:c,high:h,low:p}=this._variables,{slippage:f=0}=this._options,{in_price:d,qty:g=0,max_profit:y,trading_loss:m,direction:w,commission:v=0,original_qty:x=0}=t,b=w===ue.long?1:-1;if(e=e-b*f*this._mintick,r<g){const N=g-r,E=(e-d)*b*r,A=y!==void 0?y/g*r:void 0,M=m!==void 0?m/g*r:void 0,S=v*N/x;this._calcPercent({...t,out_price:e,last_commission:S,out_id:n,out_index:c,out_high:h,out_low:p,out_time:l,out_comment:i,profit:E,out_qty:r,max_profit:A,trading_loss:M});const T=(e-d)*b*N-S;Object.assign(t,{qty:N,profit:T,max_profit:y!==void 0?y-(A||0):void 0,trading_loss:m!==void 0?m-(M||0):void 0,total_profit:this._totalChangeCapital+T}),r=0}else{t.isDeal=!0;const N=(e-d)*b*g;this._calcPercent({...t,out_price:e,out_id:n,out_index:c,out_high:h,out_low:p,out_time:l,out_comment:i,out_qty:g,profit:N}),r-=g}return a&&(b===1?this._variables.strategy.marginCallLong++:this._variables.strategy.marginCallShort++),r}_calcPercent(t){const{commission_value:e,process_orders_on_close:r}=this._options,{in_price:n,out_qty:i=0,out_price:a=0,original_qty:l=0,direction:c,last_commission:h=0}=t;let{profit:p=0,max_profit:f,trading_loss:d,commission:g=0}=t,y=n*i,m=this._totalChangeCapital+this._options.initial_capital;if(this._totalChangeCapital+=p,e){const w=this._getCommission(a,i);this._totalChangeCapital-=w;let v=g*i/l;y+=v,v+=w,p=p-v,Object.assign(t,{commission:v,profit:p});const x=this._orders.reduce((b,N)=>{const{qty:E=0,original_qty:A=0,commission:M=0}=N;return b+M*E/A},0);m+=x-h}if(f===void 0||d===void 0){const w=c===ue.long?1:-1,v=this._calcProfitAndLossHandle(n,i,w);if(f=v[0],d=v[1],e){const x=g*i/l;f-=x,d-=x}f=Math.max(0,f),d=Math.min(0,d)}Object.assign(t,{max_profit:f,trading_loss:d,total_profit:this._totalChangeCapital,total_profit_percent:p/m*100,profit_percent:p/y*100,max_profit_percent:f/y*100,trading_loss_percent:d/y*100}),this._maxDrawdownVerifyIndex=this._variables.bar_index+(r?1:0),this._risk.intradayOrders+=1,this._historyOrder.push(t)}_getCommission(t,e){const{commission_value:r=0,commission_type:n}=this._options,i=t*e;let a=0;switch(n){case nr.percent:a=i*r/100;break;case nr.cashPerContract:a=e*r;break;case nr.cashPerOrder:a=r;break}return a}_calcCurrentOrder(t){const{commission_value:e}=this._options,{in_price:r,qty:n=0,max_profit:i=0,trading_loss:a=0}=t;let{profit:l=0}=t,c=r*n;const h=this._totalChangeCapital+this._options.initial_capital;if(e){const p=this._getCommission(r,n);this._totalChangeCapital-=p,l=l-p,c+=p,Object.assign(t,{commission:p,profit:l,total_profit:this._totalChangeCapital})}Object.assign(t,{original_qty:n,total_profit_percent:l/h*100,profit_percent:l/c*100,max_profit_percent:i/c*100,trading_loss_percent:a/c*100}),this._risk.intradayOrders+=1,this._orders.push(t),this._variables.strategy.updateOrders(this._orders),e&&this._variables.strategy.updateHistoryOrders(this._historyOrder)}_isNaN(t){return t===void 0||isNaN(t)}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}};var nh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){return function(e,r,n){r.prototype.isBetween=function(i,a,l,c){var h=n(i),p=n(a),f=(c=c||"()")[0]==="(",d=c[1]===")";return(f?this.isAfter(h,l):!this.isBefore(h,l))&&(d?this.isBefore(p,l):!this.isAfter(p,l))||(f?this.isBefore(h,l):!this.isAfter(h,l))&&(d?this.isAfter(p,l):!this.isBefore(p,l))}}})})(nh);var rw=nh.exports,nw=Gt(rw),ih={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){return function(e,r,n){var i=r.prototype,a=function(d){var g,y=d.date,m=d.utc,w={};if(!((g=y)===null||g instanceof Date||g instanceof Array||i.$utils().u(g)||g.constructor.name!=="Object")){if(!Object.keys(y).length)return new Date;var v=m?n.utc():n();Object.keys(y).forEach(function(T){var F,O;w[F=T,O=i.$utils().p(F),O==="date"?"day":O]=y[T]});var x=w.day||(w.year||w.month>=0?1:v.date()),b=w.year||v.year(),N=w.month>=0?w.month:w.year||w.day?0:v.month(),E=w.hour||0,A=w.minute||0,M=w.second||0,S=w.millisecond||0;return m?new Date(Date.UTC(b,N,x,E,A,M,S)):new Date(b,N,x,E,A,M,S)}return y},l=i.parse;i.parse=function(d){d.date=a.bind(this)(d),l.bind(this)(d)};var c=i.set,h=i.add,p=i.subtract,f=function(d,g,y,m){m===void 0&&(m=1);var w=Object.keys(g),v=this;return w.forEach(function(x){v=d.bind(v)(g[x]*m,x)}),v};i.set=function(d,g){return g=g===void 0?d:g,d.constructor.name==="Object"?f.bind(this)(function(y,m){return c.bind(this)(m,y)},g,d):c.bind(this)(d,g)},i.add=function(d,g){return d.constructor.name==="Object"?f.bind(this)(h,d,g):h.bind(this)(d,g)},i.subtract=function(d,g){return d.constructor.name==="Object"?f.bind(this)(h,d,g,-1):p.bind(this)(d,g)}}})})(ih);var iw=ih.exports,sw=Gt(iw),sh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Yt,function(){var e,r,n=1e3,i=6e4,a=36e5,l=864e5,c=/\[([^\]]+)]|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,h=31536e6,p=2628e6,f=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,d={years:h,months:p,days:l,hours:a,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},g=function(A){return A instanceof N},y=function(A,M,S){return new N(A,S,M.$l)},m=function(A){return r.p(A)+"s"},w=function(A){return A<0},v=function(A){return w(A)?Math.ceil(A):Math.floor(A)},x=function(A){return Math.abs(A)},b=function(A,M){return A?w(A)?{negative:!0,format:""+x(A)+M}:{negative:!1,format:""+A+M}:{negative:!1,format:""}},N=function(){function A(S,T,F){var O=this;if(this.$d={},this.$l=F,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),T)return y(S*d[m(T)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(q){O.$d[m(q)]=S[q]}),this.calMilliseconds(),this;if(typeof S=="string"){var R=S.match(f);if(R){var U=R.slice(2).map(function(q){return q!=null?Number(q):0});return this.$d.years=U[0],this.$d.months=U[1],this.$d.weeks=U[2],this.$d.days=U[3],this.$d.hours=U[4],this.$d.minutes=U[5],this.$d.seconds=U[6],this.calMilliseconds(),this}}return this}var M=A.prototype;return M.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(T,F){return T+(S.$d[F]||0)*d[F]},0)},M.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/h),S%=h,this.$d.months=v(S/p),S%=p,this.$d.days=v(S/l),S%=l,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/i),S%=i,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},M.toISOString=function(){var S=b(this.$d.years,"Y"),T=b(this.$d.months,"M"),F=+this.$d.days||0;this.$d.weeks&&(F+=7*this.$d.weeks);var O=b(F,"D"),R=b(this.$d.hours,"H"),U=b(this.$d.minutes,"M"),q=this.$d.seconds||0;this.$d.milliseconds&&(q+=this.$d.milliseconds/1e3,q=Math.round(1e3*q)/1e3);var W=b(q,"S"),z=S.negative||T.negative||O.negative||R.negative||U.negative||W.negative,K=R.format||U.format||W.format?"T":"",Z=(z?"-":"")+"P"+S.format+T.format+O.format+K+R.format+U.format+W.format;return Z==="P"||Z==="-P"?"P0D":Z},M.toJSON=function(){return this.toISOString()},M.format=function(S){var T=S||"YYYY-MM-DDTHH:mm:ss",F={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 T.replace(c,function(O,R){return R||String(F[O])})},M.as=function(S){return this.$ms/d[m(S)]},M.get=function(S){var T=this.$ms,F=m(S);return F==="milliseconds"?T%=1e3:T=F==="weeks"?v(T/d[F]):this.$d[F],T||0},M.add=function(S,T,F){var O;return O=T?S*d[m(T)]:g(S)?S.$ms:y(S,this).$ms,y(this.$ms+O*(F?-1:1),this)},M.subtract=function(S,T){return this.add(S,T,!0)},M.locale=function(S){var T=this.clone();return T.$l=S,T},M.clone=function(){return y(this.$ms,this)},M.humanize=function(S){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},M.valueOf=function(){return this.asMilliseconds()},M.milliseconds=function(){return this.get("milliseconds")},M.asMilliseconds=function(){return this.as("milliseconds")},M.seconds=function(){return this.get("seconds")},M.asSeconds=function(){return this.as("seconds")},M.minutes=function(){return this.get("minutes")},M.asMinutes=function(){return this.as("minutes")},M.hours=function(){return this.get("hours")},M.asHours=function(){return this.as("hours")},M.days=function(){return this.get("days")},M.asDays=function(){return this.as("days")},M.weeks=function(){return this.get("weeks")},M.asWeeks=function(){return this.as("weeks")},M.months=function(){return this.get("months")},M.asMonths=function(){return this.as("months")},M.years=function(){return this.get("years")},M.asYears=function(){return this.as("years")},A}(),E=function(A,M,S){return A.add(M.years()*S,"y").add(M.months()*S,"M").add(M.days()*S,"d").add(M.hours()*S,"h").add(M.minutes()*S,"m").add(M.seconds()*S,"s").add(M.milliseconds()*S,"ms")};return function(A,M,S){e=S,r=S().$utils(),S.duration=function(O,R){var U=S.locale();return y(O,{$l:U},R)},S.isDuration=g;var T=M.prototype.add,F=M.prototype.subtract;M.prototype.add=function(O,R){return g(O)?E(this,O,1):T.bind(this)(O,R)},M.prototype.subtract=function(O,R){return g(O)?E(this,O,-1):F.bind(this)(O,R)}}})})(sh);var ow=sh.exports,aw=Gt(ow);ee.extend(Sl),ee.extend(nw),ee.extend(sw),ee.extend(aw);class oh{constructor(t,e,r){$(this,"array");$(this,"color");$(this,"math");$(this,"str");$(this,"map");$(this,"matrix");$(this,"timeframe");$(this,"ta");$(this,"input");$(this,"_variables");$(this,"_cacheData");$(this,"_options");$(this,"_errorListener");$(this,"_plots");$(this,"_plotshapes");$(this,"_plotbars");$(this,"_plotchars");$(this,"_plotarrows");$(this,"_plotcandles");$(this,"_alerts");$(this,"_bgColors");$(this,"_hlines");$(this,"_fills");$(this,"chart");$(this,"line");$(this,"label");$(this,"polyline");$(this,"box");$(this,"table");$(this,"linefill");$(this,"log");$(this,"runtime");$(this,"strategy");$(this,"request");$(this,"syminfo");$(this,"_count",0);var i;const n=((i=t.toString().split(".")[1])==null?void 0:i.length)||5;this._variables=e,this._errorListener=new hw,this.array=new Hp(this._errorListener),this.math=new Jp(n,this._errorListener),this.color=new b1,this.str=new xy(this._errorListener,n),this.map=new Ey(this._errorListener),this.timeframe=new by(e),this.matrix=new Dy(this._errorListener),this.ta=new w1(e,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 D1(e,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 Ay(e)},this.line=new Ky(e,this._errorListener),this.label=new Cy(e,this._errorListener),this.polyline=new Zy(e,this._errorListener),this.box=new Hy(e,this._errorListener),this.table=new Jy(e,this._errorListener),this.linefill=new Gy(e),this.log=new cw(e),this.runtime=new fw(this._errorListener),this.strategy=new ew(this._variables,this._options,t,this._errorListener,r),this.request=new uw(this._variables,r),this.syminfo=new lw}get errors(){return this._errorListener.errors}options(t){if(t.length)return this._getDataOfBarindex(t);const e=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 v of n)i[v]=[...this._bgColors[v].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,l=this._fills.size?[...this._fills.values()]:void 0,c=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,strategySummary:this._variables.strategy.summaryData});const h=this._plots.size>0?[...this._plots.values()]:void 0,p=this._plotbars.size>0?[...this._plotbars.values()]:void 0,f=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,d=this._plotarrows.size>0?[...this._plotarrows.values()]:void 0,g=this._plotcandles.size>0?[...this._plotcandles.values()]:void 0,y=this._plotchars.size>0?[...this._plotchars.values()]:void 0,m=this._getDraws(),w=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:e,plots:h,draws:m,alerts:r,colors:i,hlines:a,fills:l,logs:c,plotshapes:f,plotarrows:d,plotcandles:g,plotchars:y,plotbars:p,isUseBgColor:w})}_getDataOfBarindex(t){const e=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 d of r)n[d]=[...this._bgColors[d].values()].map(g=>{const y=[];for(const m of t){const w=g.colors[m];w&&y.push(w)}return g.colors=y,g})}const i=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(t,[...this._fills.values()]):void 0,l=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._getDataFromBarindex(t,[...this._plots.values()]),h=this._plotshapes.size>0?this._getDataFromBarindex(t,[...this._plotshapes.values()]):void 0,p=this._getDrawsFromBarindex(t),f=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,draws:p,alerts:e,colors:n,hlines:i,fills:a,logs:l,plotshapes:h,isUseBgColor:f})}_getDataFromBarindex(t,e){return e.map(r=>{const n=[];for(const i of t){const a=r.data[i];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:i,label:a}=this._variables,l={};return t.data.length&&(l.lines=t.data),e.data.length&&(l.linefills=e.data),r.data.length&&(l.tables=r.data),n.data.length&&(l.boxes=n.data),i.data.length&&(l.polylines=i.data),a.data.length&&(l.labels=a.data),Object.keys(l).length?l:void 0}_getDrawsFromBarindex(t){const{line:e,linefill:r,table:n,box:i,polyline:a,label:l}=this._variables,c={};return e.data.length&&(c.lines=e.getValOfBarIndex(t)),r.data.length&&(c.linefills=r.getValOfBarIndex(t)),n.data.length&&(c.tables=n.getValOfBarIndex(t)),i.data.length&&(c.boxes=i.getValOfBarIndex(t)),a.data.length&&(c.polylines=a.getValOfBarIndex(t)),l.data.length&&(c.labels=l.getValOfBarIndex(t)),Object.keys(c).length?c:void 0}updateOptions(t){const{inputs:e,strategy:r}=t;this.input.update(e),r&&this.strategy.updateOptions(r)}update(t){const{barIndex:e}=t;this.strategy.update(),this.math.update(e)}endExecution(){this.strategy.endExecution()}library(t,e){if(!this._variables.bar_index){const r=/^[^\W\d\s][^\W\s]*$/,{title:n}=t;r.test(n)?(Gp.includes(n)||Kp.includes(n))&&this._errorListener.addError(Ve(le.libraryTitleIsKeywordErr,{name:n}),e,zt.Error):this._errorListener.addError(le.libraryTitleErr,e,zt.Error),this._options.scriptType="library",this._options.library=t}}indicator(t,e){if(!this._variables.bar_index){const{format:r}=t;this._paramVerfiy(r,e,"indicator",[Kt.inherit,Kt.percent,Kt.price,Kt.volume]),this._variables.updateMaxLength(t),this._options.scriptType="indicator",this._options.indicator=t}}_paramVerfiy(t="",e,r,n,i="format"){t&&!n.includes(t)&&this._errorListener.addError(Ve(le.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_lineWidthVerify(t,e){const{linewidth:r=1}=t;r<1&&(this._errorListener.addError(Yp.lineWidthWarning,e,zt.Warning),t.linewidth=1)}plot(t,e){const r=["color"];me(t,r);const{series:n,color:i,...a}=t,{bar_index:l,time:c}=this._variables,h=`plot_${e}`,p=this._plots.get(h),f=(p==null?void 0:p.data)||[],d=n!==void 0&&isNaN(n)?void 0:n;if(f[l]={value:[c,d],itemStyle:{color:i}},this._seriesColorHandle(t,r,p),!p){this._count++,this._lineWidthVerify(a,e),this._paramVerfiy(t.format,e,"plot",[Kt.percent,Kt.price,Kt.volume]);const g=i?[i]:void 0;this._plots.set(h,{editable:!0,...a,colors:g,data:f,id:h,zIndex:this._count})}return{type:"plot",key:h}}plotbar(t,e){const r=["color"];me(t,r);const{open:n,close:i,low:a,high:l,color:c,...h}=t,{bar_index:p,time:f}=this._variables,d=`plotbar_${e}`,g=this._plotbars.get(d),y=(g==null?void 0:g.data)||[],m=i!==void 0&&isNaN(i)?void 0:i,w=n!==void 0&&isNaN(n)?void 0:n,v=a!==void 0&&isNaN(a)?void 0:a,x=l!==void 0&&isNaN(l)?void 0:l,b=[f,w,m,v,x];if(y[p]={value:b,itemStyle:{color:c}},this._seriesColorHandle(t,r,g),!g){this._count++,this._paramVerfiy(t.format,e,"plotbar",[Kt.percent,Kt.price,Kt.volume]);const N=c?[c]:void 0;this._plotbars.set(d,{editable:!0,...h,colors:N,data:y,id:d,zIndex:this._count})}}_verfiyArgs(t,e,r){const{size:n,format:i,location:a,style:l}=t;this._paramVerfiy(l,r,e,Object.values(ur),"style"),this._paramVerfiy(a,r,e,Object.values(an),"location"),this._paramVerfiy(n,r,e,Object.values(rr),"size"),this._paramVerfiy(i,r,e,[Kt.percent,Kt.price,Kt.volume],"format")}plotchar(t,e){const r=["color","textcolor"];me(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:h,time:p,high:f,low:d}=this._variables,g=`plotchar_${e}`,y=this._plotchars.get(g),m=(y==null?void 0:y.data)||[],w={value:[p,n],itemStyle:{color:i,textcolor:a},low:d,high:f};m[h]=w,this._seriesColorHandle(t,r,y),y||(this._count++,this._verfiyArgs(t,"plotchar",e),this._plotchars.set(g,{editable:!0,...c,location:l,data:m,id:g,zIndex:this._count}))}plotarrow(t,e){const r=["colorup","colordown"];me(t,r);const{series:n,colorup:i,colordown:a,...l}=t,{bar_index:c,time:h}=this._variables,p=`plotarrow_${e}`,f=this._plotarrows.get(p),d=(f==null?void 0:f.data)||[];d[c]={value:[h,n!==void 0&&isNaN(n)?void 0:n],itemStyle:{colorup:i,colordown:a}},this._seriesColorHandle(t,r,f),f||(this._count++,this._paramVerfiy(t.format,e,"plotarrow",[Kt.percent,Kt.price,Kt.volume]),this._plotarrows.set(p,{editable:!0,...l,data:d,id:p,zIndex:this._count}))}plotshape(t,e){const r=["color","textcolor"];me(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:h,time:p,low:f,high:d}=this._variables,g=`plotshape_${e}`,y=this._plotshapes.get(g),m=(y==null?void 0:y.data)||[],w={value:n,color:i,textcolor:a,time:p,low:f,high:d};if(m[h]=w,this._seriesColorHandle(t,r,y),!y){this._count++;const v=i?[i]:void 0;this._verfiyArgs(t,"plotshape",e),this._plotshapes.set(g,{editable:!0,...c,data:m,location:l,id:g,colors:v,zIndex:this._count})}}plotcandle(t,e){const r=["wickcolor","bordercolor","color"];me(t,r);const{wickcolor:n,bordercolor:i,color:a,close:l,open:c,low:h,high:p,...f}=t,{bar_index:d,time:g}=this._variables,y=`plotcandle_${e}`,m=this._plotcandles.get(y),w=(m==null?void 0:m.data)||[],v=l!==void 0&&isNaN(l)?void 0:l,x=c!==void 0&&isNaN(c)?void 0:c,b=h!==void 0&&isNaN(h)?void 0:h,N=p!==void 0&&isNaN(p)?void 0:p,E=[g,x,v,b,N];w[d]={value:E,wickcolor:n,bordercolor:i,color:a},this._seriesColorHandle(t,r,m),m||(this._count++,this._paramVerfiy(t.format,e,"plotcandle",[Kt.percent,Kt.price,Kt.volume]),this._plotcandles.set(y,{editable:!0,...f,data:w,id:y,zIndex:this._count}))}hline(t,e){const r=`hline_${e}`;me(t,["color"]),this._verifyDisplay(t.display,"hline",e);const i=t.display&&!t.display.length?Ye.none:Ye.all;return this._hlines.has(r)||(this._count++,this._lineWidthVerify(t,e),this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:i,...t,zIndex:this._count})),{type:"hline",key:r}}fill(t,e){var S,T,F,O,R,U,q,W,z,K;const r=["color","top_color","bottom_color"];me(t,r);const{color:n,top_color:i,bottom_color:a,seriesColors:l,hline1:c,hline2:h,plot1:p,plot2:f,top_value:d,bottom_value:g,...y}=t,{bar_index:m,time:w}=this._variables,v=`fill_${e}`,x=this._fills.get(v),b=(x==null?void 0:x.data)||[];this._verifyDisplay(t.display,"fill",e);const N=t.display&&!t.display.length?Ye.none:Ye.all;let E,A,M="plot";if(c&&h)E=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,A=(T=this._hlines.get(h==null?void 0:h.key))==null?void 0:T.price,M="hline";else{const Z=((F=this._plots.get(p==null?void 0:p.key))==null?void 0:F.data)||[],X=((O=this._plots.get(f==null?void 0:f.key))==null?void 0:O.data)||[];E=(U=(R=Z[m])==null?void 0:R.value)==null?void 0:U[1],A=(W=(q=X[m])==null?void 0:q.value)==null?void 0:W[1]}if(b[m]={time:w,color:n,top_color:i,bottom_color:a,plot1:E,plot2:A,top_value:d,bottom_value:g},this._seriesColorHandle(t,r,x),!x){this._count++;const Z=((z=this._options.indicator)==null?void 0:z.explicit_plot_zorder)||((K=this._options.strategy)==null?void 0:K.explicit_plot_zorder),X=n?[n]:void 0,Q=i?[i]:void 0,ct=a?[a]:void 0;this._fills.set(v,{id:v,colors:X,top_colors:Q,bottom_colors:ct,display:N,data:b,type:M,editable:!0,fillgaps:!1,hline1:c,hline2:h,plot1:p,plot2:f,...y,zIndex:Z?this._count:void 0})}}alert({message:t,freq:e=qr.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:i,last_bar_index:a}=this._variables,l=`alert_${r}`,c=this._cacheData[l]||{},h=c.barIndex;if(this._paramVerfiy(e,r,"alert",[qr.freqAll,qr.freqOncePerBar,qr.freqOncePerBarClose]),e===qr.freqOncePerBar&&n===h){this._alerts.delete(l);return}this._cacheData[l]=c;const p={message:t,freq:e,id:l,type:"alert"};if(i){e!==qr.freqOncePerBarClose&&this._alerts.set(l,p),c.barIndex=n;return}if(!i&&e===qr.freqOncePerBarClose&&n===h&&a===n-1){this._alerts.set(l,p),c.barIndex=n;return}this._alerts.delete(l)}alertcondition({condition:t,message:e,title:r},n){const{_isRealTimeBar:i}=this._variables,a=`alertcondition_${n}`;i&&t?this._alerts.set(a,{message:e,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(t,e){this._setColors(t,"barcolor",e)}bgcolor(t,e){this._setColors(t,"bgcolor",e)}_verifyDisplay(t=Qf.all,e,r){t.length&&t.length<4&&this._errorListener.addError(Ve(le.displayErr,{func:e,values:"[display.none, display.all]"}),r,zt.Error)}_setColors(t,e,r){me(t,["color"]);const{color:i,...a}=t;this._verifyDisplay(a.display,e,r);const l=t.display&&!t.display.length?Ye.none:Ye.all,{bar_index:c,time:h}=this._variables,p=`${e}_${r}`;this._bgColors[e]||(this._bgColors[e]=new Map);const f=this._bgColors[e].get(p),d=(f==null?void 0:f.colors)||[],g=(f==null?void 0:f.setColors)||[];i&&!g.includes(i)&&g.push(i),d[c]={color:i,time:h},f||this._bgColors[e].set(p,{...a,display:l,colors:d,setColors:g,id:p})}max_bars_back({var:t,num:e,var_name:r}){console.log(t,e,r)}float({x:t}){return t}bool({x:t}){return t||!1}string({x:t}){return t}int({x:t}){return t&&Math.trunc(t)}na({x:t}){return!!(t===void 0||typeof t=="number"&&isNaN(t))}fixnan({source:t},e){return t===void 0||typeof t=="number"&&isNaN(t)?this._cacheData[`fixnan_${e}`]:(this._cacheData[`fixnan_${e}`]=t,t)}nz({source:t,replacement:e}){return t!==void 0&&!(typeof t=="number"&&isNaN(t))?t:e||0}time({timeframe:t="",session:e,timezone:r,bars_back:n=0},i){return this._timeHandle(this._variables.time,i,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},i){return this._variables.time_close&&this._timeHandle(this._variables.time_close,i,t,e,r,n)}timestamp(t){const{dateString:e,timezone:r,year:n,month:i,day:a,hour:l=0,minute:c=0,second:h=0}=t;if(e)return ee(e).utc(!/GMT|UTC/.test(e)).valueOf();let p=i-1,f=n;if(p<0){const g=Math.ceil(Math.abs(p/12));p=12*g+p,f=n-g}let d=ee({year:f,month:p,day:a,hour:l,minute:c,second:h});return r&&(d=kr(d.utc(!0).valueOf(),r)),d.utc(!0).valueOf()}weekofyear({time:t,timezone:e}){return kr(t,e).week()}year({time:t,timezone:e}){return kr(t,e).year()}second({time:t,timezone:e}){return kr(t,e).second()}month({time:t,timezone:e}){return kr(t,e).month()+1}minute({time:t,timezone:e}){return kr(t,e).minute()}hour({time:t,timezone:e}){return kr(t,e).hour()}dayofweek({time:t,timezone:e}){return kr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return kr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,e),n=Qr(e)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,i,a=0){const l=r||this._variables.timeframe.period,c=Qr(l),h=Qr(this._variables.timeframe.period);let p;if(c<=h)p=t;else{const f=`time_${e}`,d=this._cacheData[f];if(d)d.currentTime+c*1e3-d.offset<=t?(p=t,this._cacheData[f]={currentTime:t,offset:0}):p=d;else{const g=this._calcTimeOffset(t,l);this._cacheData[f]={currentTime:t,offset:g},p=t}}if(n){const{timePeriods:f,weeks:d}=this._parserSession(n,e),g=ee(t).format("YYYY-MM-DD"),y=p;p=void 0;for(const w of f){const[v,x]=w;if(ee(t).isBetween(`${g} ${v}`,`${g} ${x}`,"hour")){ee(y).isBetween(`${g} ${v}`,`${g} ${x}`,"hour")?p=y:p=ee(`${g} ${v}`).valueOf();break}}const m=this._variables.dayofweek;p&&!d.includes(m)&&(p=void 0)}return i&&(p=p&&kr(p,i).valueOf()),p&&p-a*h*1e3}_seriesColorHandle(t,e,r){var n;if(r&&e!=null&&e.length)for(const i of e){if((n=r.gradientColorKeys)!=null&&n.includes(i))continue;const a=t[i];if(!a)continue;const l=r[`${i}s`]||[];l.includes(a)||(l.push(a),r[`${i}s`]=l,l.length>5&&(r[`${i}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(i)))}}_parserSession(t,e){const r=t.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(c=>{const h=parseInt(c,10);if(h<1||h>7){this._errorListener.addError(`Invalid day of week: ${c}`,e,zt.Error);return}return h});return{timePeriods:n.split(",").map(c=>{c===""||c===fi.regular?c="0930-1500":c===fi.extended&&(c="1500-1830");const h=c.split("-");return h.length!==2?(this._errorListener.addError(`Invalid time period: ${c}`,e,zt.Error),[]):[this._processTime(h[0],e),this._processTime(h[1],e)]}),weeks:a}}_processTime(t,e){const r=parseInt(t.slice(0,2),10),n=parseInt(t.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",e,zt.Error);return}return`${r}:${n}`}}class uw{constructor(t,e){$(this,"_variables");$(this,"_scriptId");$(this,"_cacheData");this._variables=t,this._scriptId=e,this._cacheData=new Map}security(t,e){const r=self.workerStorage.get(`request_${this._scriptId}`),{paramsExpr:n=[]}=t,i=this._getRequestData(t,e);if(r!=null&&r.has(e)){const c=r.get(e);return this._runScripts(c,e,!1,n,i)}const a=this._parseExprCode(t),l=this._runScripts(a,e,!0,n,i);return r==null||r.set(e,a),l}_parseExprCode(t){let{expression:e,paramsExpr:r=[]}=t,n=[],i=1;e=Il(e);const a=JSON.parse(e),l=a.pop();let c=(l==null?void 0:l.memberCodes)||{},h=(l==null?void 0:l.depends)||[];if(!h.length)return`return ${l==null?void 0:l.code}`;let p=[],f=[];const d=[];if(this._getDependCodes(h,a,n,p,f,d),f.length){const m=r.length;let w=[];for(let v=m-1;v>=0;v--){const x=r[v];let b=JSON.parse(Il(x));const N=[];i!==0&&f.length&&(w.unshift("{"),i++),b=b.map(S=>{const{scope:T,code:F,varNames:O,dependSelf:R}=S;return T===2&&!N.includes(O)&&!R&&(S.code=`let ${F}`),O&&N.push(...O.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const E=[],A=[];let M=f.map(S=>({...S,isArg:!1,isPreArg:!0}));f=[],this._getDependCodes(M,b,A,p,f,E),w.unshift(...A,...E),n=w.concat(n),w=[]}}for(n.push(`return ${l==null?void 0:l.code}`);i>1;)n.push("}"),i--;n=p.concat(n),n.push(...d);let g=n.join(`
63
- `);const y=[];for(const m of Object.keys(c))g.includes(`$_var.getCacheData("${m}"`)&&y.push(c[m]);return y.length&&(g=`${y.join(`
64
- `)}
65
- ${g}`),g}_getRequestData(t,e){let{symbol:r,timeframe:n,calc_bars_count:i}=t;const{__period:a,syminfo:{ticker:l,tickerid:c},mintick:h}=this._variables;if((n===a||n==="")&&(r===l||r===c)){const{close:g,open:y,high:m,low:w,bar_index:v,last_bar_index:x,last_bar_time:b,_isRealTimeBar:N,volume:E,time:A,time_tradingday:M}=this._variables;return{barIndex:v,c:g,o:y,h:m,l:w,volume:E,lastBarIndex:x,lastBarTime:b/1e3,isrealtime:N,time_tradingday:M,time:A/1e3,interval:a,mintick:h}}const p=`${r}--${n||a}`,f=self.workerStorage.get(`request_${this._scriptId}_data`),d=self.workerStorage.get(`request_${this._scriptId}_list`);if(f!=null&&f.has(p)){d==null||d.delete(p);const{index:g=0,periodStamp:y=Qr(this._variables.__period)*1e3}=this._cacheData.get(e)||{},m=(f.get(p)||[]).slice(g),w=this._variables.time,v=y+w,x=m.length-1,b={lastBarIndex:m[x].barindex||x,lastBarTime:m[x].time,interval:a,mintick:h};for(const[N,E]of m.entries()){let{time:A,barindex:M}=E;if(A=A*1e3,A>=v){this._cacheData.set(e,{index:N,periodStamp:y});return}if(A>=w)return this._cacheData.set(e,{index:N+1,periodStamp:y}),{...E,barIndex:M||N,...b}}this._cacheData.set(e,{index:m.length,periodStamp:y})}else(d==null?void 0:d.get(p))||d==null||d.set(p,{id:p,calc_bars_count:i,symbol:r,timeframe:n||a})}_getDependCodes(t,e,r,n,i,a){for(const l of t){if(!l.isArg){const c=e.filter(p=>{var f;return(f=p==null?void 0:p.depends)==null?void 0:f.some(d=>d.name===l.name&&d.scope===l.scope&&d.isAgainAssign)});for(const p of c){const{code:f,depends:d}=p;if(!r.includes(f)&&(r.unshift(f),d!=null&&d.length)){for(const g of d)g.memberCode&&a.push(g.memberCode);this._getDependCodes(d,e,r,n,i,a)}}const h=e.find(p=>{var f;return((f=p.varNames)==null?void 0:f.split(", ").includes(l.name))&&(!l.isPreArg||l.isPreArg&&p.methodName===l.functionName)||p.funcName===l.name});if(h){const{code:p,depends:f}=h,d=r.findIndex(g=>g===p);if(d!==-1&&r.splice(d,1),r.unshift(p),f!=null&&f.length){for(const g of f)g.memberCode&&a.push(g.memberCode);this._getDependCodes(f,e,r,n,i,a)}continue}}i.some(c=>c.name===l.name)||i.push(l)}}_runScripts(t,e,r,n,i){const a=`${this._scriptId}_${e}`;let{builtInGather:l,buildinConstants:c,buildInFunctions:h,tradingvueFunc:p}=self.workerStorage.get(a)||{};const{interval:f,mintick:d,...g}=i||{};r&&(l=new ah(a),c=new th,h=new oh(this._variables.mintick||1e-5,l,this._scriptId),p=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),l.updateOptions({interval:f,mintick:d||1e-5}),self.workerStorage.set(a,{builtInGather:l,buildinConstants:c,buildInFunctions:h,tradingvueFunc:p})),l.updateData(g),h.update({barIndex:(g==null?void 0:g.barindex)||0});const y=p(l,c,h,n||[],e);return h.endExecution(),y}}let lw=class{constructor(){}prefix(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[0])||""}ticker(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[1])||""}};class cw{constructor(t){$(this,"_logs");$(this,"_variables");$(this,"_intlFormat");this._variables=t,this._logs=[],this._intlFormat=new Intl.NumberFormat("en-US")}get logs(){return this._logs}clearLogs(){this._logs=[]}info(t,e,r){this._addLog(t,e,"info",r)}error(t,e,r){this._addLog(t,e,"error",r)}warning(t,e,r){this._addLog(t,e,"warning",r)}_addLog(t,e,r,n){if(typeof e=="string"&&(n=e),n.startsWith("export"))return;const{message:i,formatString:a}=t,{time:l,bar_index:c}=this._variables;let h=i;a&&Array.isArray(e)&&e.length&&(h=a.replace(/{(\d+)}/g,(p,f)=>{let d=e[f];return typeof d=="number"&&(d=this._intlFormat.format(parseFloat(d.toFixed(3)))),typeof d=="object"&&(d.isArray?d=JSON.stringify(d._value):d=d.toString()),d!==void 0?d:p})),h&&this._logs.push({message:`[${ee(l).format()}]: ${h}`,time:l,barIndex:c,type:r})}}class fw{constructor(t){$(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,zt.Error)}}class hw{constructor(){$(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Xr.flatMap([...this._errors.values()])}addError(t,e,r,n=0){const[i,a]=e.split("_").slice(-2),l=this._errors.get(e),c={message:t,endLineNumber:Number(i),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(i),type:r};l?l.push(c):this._errors.set(e,[c])}}class pw{constructor(){$(this,"_isMarketOpen");$(this,"_currentBarIndex");$(this,"_totalBarIndex");$(this,"_isRealTimeBar");$(this,"_preBarIndex");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0}update(t,e,r,n){this._preBarIndex=this._currentBarIndex,this._currentBarIndex=t,this._totalBarIndex=e,this._isRealTimeBar=r,this._isMarketOpen=n}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1||this._currentBarIndex===this._totalBarIndex&&!this._isRealTimeBar:this._currentBarIndex===this._totalBarIndex}}class dw{constructor(t){$(this,"_variables");this._variables=t}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const t=Qr(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class _w{constructor(t){$(this,"_orders");$(this,"_historyOrders");$(this,"_options");$(this,"_max_contracts_held_all",0);$(this,"_max_contracts_held_long",0);$(this,"_max_contracts_held_short",0);$(this,"_max_drawdown",0);$(this,"_max_runup",0);$(this,"_max_runup_percent",0);$(this,"_max_drawdown_percent",0);$(this,"_variables");$(this,"_netprofit",0);$(this,"_eventrades",0);$(this,"_avg_trade_percent");$(this,"_closedtrades",0);$(this,"_losstrades",0);$(this,"_grossloss",0);$(this,"_grossloss_percent",0);$(this,"_grossprofit",0);$(this,"_grossprofit_percent",0);$(this,"_wintrades",0);$(this,"_opentrades_capital_held",0);$(this,"_position_avg_price",0);$(this,"_position_size",0);$(this,"_openprofit",0);$(this,"_preMaxNetValue",0);$(this,"_preMinNetValue",0);$(this,"marginCallLong",0);$(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=t}update(){this._calcMaxDrawdownAndMaxRunup()}_calcMaxDrawdownAndMaxRunup(){if(!this._orders.length)return;let t=0,e=0;const{high:r,low:n,close:i}=this._variables;let a=0;for(const h of this._orders){const{in_price:p,qty:f=0,commission:d=0,original_qty:g=0,direction:y,profit:m=0}=h,w=y===ue.long?1:-1,v=(r-p)*f,x=(n-p)*f,b=this._getCommission(i,f),N=d*f/g,E=w===1?v:-x,A=w===1?-x:v;a+=m+N+b,t+=A,e+=E}this._openprofit=a;const l=this.initial_capital,c=l+this._netprofit;this._preMinNetValue=this._preMinNetValue||l,this._preMaxNetValue=this._preMaxNetValue||l,t=this._preMaxNetValue-c+Math.max(t,0),e=c-this._preMinNetValue+e,this._max_drawdown<t&&(this._max_drawdown=t,this._max_drawdown_percent=t/l*100),e>this._max_runup&&(this._max_runup=e,this._max_runup_percent=e/c*100)}updateOrders(t){this._orders=t,this._calcMaxContracts()}_calcMaxContracts(){const t=this._orders.length;if(!t){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[e,r,n,i,a,l,c]=this._orders.reduce(([h,p,f,d,g,y,m],w)=>{const{direction:v,qty:x=0,in_price:b,commission:N=0}=w;return v===ue.long?(h+=x,p+=x,y+=x):(h+=x,f+=x,y-=x),d+=x*b,g+=b,m+=N,[h,p,f,d,g,y,m]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-c,this._grossloss=-c),this._position_size=l,this._position_avg_price=a/t,this._opentrades_capital_held=i,this._max_contracts_held_all=Math.max(e,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(n,this._max_contracts_held_short)}updateHistoryOrders(t){this._historyOrders=t;const e=this._historyOrders.length;this._closedtrades=e;const[r,n,i,a]=this._historyOrders.reduce((h,p)=>{let[f,d,g,y]=h;const{profit:m=0,profit_percent:w=0}=p;return f+=m,d+=w,m<0?g+=m:y+=m,[f,d,g,y]},[0,0,0,0]),l=this._orders.reduce((h,p)=>{const{commission:f=0,qty:d=0,original_qty:g=0}=p,y=f*d/g;return h+y},0);this._avg_trade_percent=e?n/e:void 0,this._netprofit=r-l;const c=this.initial_capital+this._netprofit;this._preMaxNetValue=Math.max(this._preMaxNetValue||this.initial_capital,c),this._preMinNetValue=Math.min(this._preMinNetValue||this.initial_capital,c),this._grossloss=i-l,this._grossprofit=a,this._eventrades=this._historyOrders.filter(h=>h.profit===0).length,this._losstrades=this._historyOrders.filter(h=>(h.profit||0)<0).length,this._wintrades=this._historyOrders.filter(h=>(h.profit||0)>0).length}updateStrategyOptions(t){this._options=t}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const t=this._losstrades;return t?Math.abs(this._grossloss/t):void 0}get avg_losing_trade_percent(){const t=this._losstrades;return t?Math.abs(this._grossloss_percent/t):void 0}get avg_trade(){if(this._closedtrades)return this._netprofit/this._closedtrades}get equity(){return this.initial_capital+this._netprofit+this._openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._openprofit}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const t=this._wintrades;return t?Math.abs(this._grossprofit/t):void 0}get avg_winning_trade_percent(){const t=this._wintrades;return t?Math.abs(this._grossprofit_percent/t):void 0}get initial_capital(){var t;return((t=this._options)==null?void 0:t.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss/this.initial_capital*100}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit/this.initial_capital*100}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:t,margin_long:e=0,margin_short:r=0,commission_type:n,commission_value:i=0}=this._options,a=this._orders[0].direction===ue.long?1:-1,l=(a===1?e:r)/100;if(l<=0)return;const{close:c}=this._variables,[h,p]=this._orders.reduce((f,d)=>{let[g,y]=f;const{in_price:m,qty:w=0,original_qty:v=0}=d,x=m*w;if(g+=x,i){let b=0;switch(n){case nr.percent:b=(x+w*c)*i/100;break;case nr.cashPerContract:b=w*i*2;break;case nr.cashPerOrder:b=w/v*i+i;break}y+=b}return[g,y]},[0,0]);return(h-(t+this._netprofit-p))*a/this._position_size/(1-a*l)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this._netprofit/this.initial_capital*100}get openprofit_percent(){return this._openprofit/(this.initial_capital+this._netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}get summaryData(){return{position_size:this.position_size,position_avg_price:this.position_avg_price,position_entry_name:this.position_entry_name,openprofit_percent:this.openprofit_percent,netprofit_percent:this.netprofit_percent,max_drawdown_percent:this.max_drawdown_percent,max_runup_percent:this.max_runup_percent,max_drawdown:this.max_drawdown,max_runup:this.max_runup,max_contracts_held_long:this.max_contracts_held_long,max_contracts_held_short:this.max_contracts_held_short,max_contracts_held_all:this.max_contracts_held_all,avg_winning_trade_percent:this.avg_winning_trade_percent,avg_winning_trade:this.avg_winning_trade,avg_trade_percent:this.avg_trade_percent,avg_trade:this.avg_trade,avg_losing_trade:this.avg_losing_trade,avg_losing_trade_percent:this.avg_losing_trade_percent,wintrades:this.wintrades,losstrades:this.losstrades,eventrades:this.eventrades,grossprofit:this.grossprofit,grossprofit_percent:this.grossprofit_percent,grossloss:this.grossloss,grossloss_percent:this.grossloss_percent,openprofit:this.openprofit,initial_capital:this.initial_capital,netprofit:this.netprofit,closedtrades:this.closedtrades,opentrades:this.opentrades,equity:this.equity,margin_call_long:this.marginCallLong,margin_call_short:this.marginCallShort}}_getCommission(t,e){if(!this._options)return 0;const{commission_value:r=0,commission_type:n}=this._options,i=t*e;let a=0;switch(n){case nr.percent:a=i*r/100;break;case nr.cashPerContract:a=e*r;break;case nr.cashPerOrder:a=r;break}return a}}class mw{constructor(t){$(this,"_preAccdist");$(this,"_preNvi");$(this,"_prePvi");$(this,"_preObv");$(this,"_prePvt");$(this,"_preWad");$(this,"_preVwap");$(this,"_preValue");$(this,"_currentData");$(this,"_preData");$(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=t}update(t){this._preValue={},t.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...t}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:t,low:e,high:r,volume:n}=this._currentData;if(r===e)return this._preAccdist;const i=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=i),this._preValue.accdist=i,i}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,i=(2*t-r-e)/((r-e)*n);return this._preValue.iii=i,i}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:t,low:e,high:r,volume:n,open:i}=this._currentData,a=(t-i)/(r-e)*n;return this._preValue.wvad=a,a}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const n=Math.sign(t-r)*e+this._preObv;return!this.isRealTime&&(this._preObv=n),this._preValue.obv=n,n}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:t,high:e}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const n=Math.max(e-t,Math.abs(e-r),Math.abs(t-r));return this._preValue.tr=n,n}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const n=(t-r)/r*e+this._prePvt;return!this.isRealTime&&(this._prePvt=n),this._preValue.pvt=n,n}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:t,high:e,low:r}=this._currentData,{close:n}=this._preData;if(n===void 0)return this._preWad=0,0;const i=Math.max(e,n),a=Math.min(r,n),l=t-n,h=(l>0?t-a:l<0?t-i:0)+this._preWad;return!this.isRealTime&&(this._preWad=h),this._preValue.wad=h,h}get vwap(){var p,f;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:i}=this._preVwap;if(((f=(p=self.workerStorage)==null?void 0:p.get(this._id))==null?void 0:f.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(i=!0,r=n=0),!i)return;const l=t*e+r,c=e+n;!this.isRealTime&&(this._preVwap={sum:l,sumV:c,isReset:i});const h=l/c;return this._preValue.vwap=h,h}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i<r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._preNvi=a),this._preValue.nvi=a,a}_getPvi(){const t=this._prePvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=t||1;return n&&e?a=i>r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class gw{constructor(){$(this,"_period");$(this,"_multiplier");$(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=t;const[e,r]=ys(t);this._multiplier=e,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}}class vw{constructor(t){$(this,"_variables");$(this,"_bgColor");$(this,"_fgColor");$(this,"isUseBgColor",!1);this._variables=t}updateOptions(t){t!=null&&t.bg_color&&(this._bgColor=t.bg_color,this._fgColor=this._contrastColor(t.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){return this._variables.time}get right_visible_bar_time(){return this._variables.time}_parseColor(t){let e,r,n,i;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:e,g:r,b:n,a:i}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}_contrastColor(t){const{r:e,g:r,b:n}=this._parseColor(t);return(299*e+587*r+114*n)/1e3>128?"#000000":"#ffffff"}}class yw{constructor(t){$(this,"_variables");this._variables=t}get basecurrency(){return""}get country(){}get currency(){return"CNY"}get description(){return""}get employees(){return 100}get expiration_date(){}get industry(){}get minmove(){}get mintick(){return this._variables.mintick}get pointvalue(){}get prefix(){}get pricescale(){}get recommendations_buy(){}get recommendations_buy_strong(){}get recommendations_date(){}get recommendations_hold(){}get recommendations_sell(){}get recommendations_sell_strong(){}get recommendations_total(){}get root(){return""}get sector(){}get session(){return fi.regular}get shareholders(){}get shares_outstanding_float(){}get shares_outstanding_total(){}get target_price_average(){}get target_price_date(){}get target_price_estimates(){}get target_price_high(){}get target_price_low(){}get target_price_median(){}get ticker(){return""}get tickerid(){return""}get timezone(){}get type(){}get volumetype(){return"n/a"}}class ww{constructor(t){$(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class Dw{constructor(t){$(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}ee.extend(jp),ee.extend(Sl),ee.extend(Up);class ah{constructor(t){$(this,"_cacheData");$(this,"_barIndex");$(this,"_isRealTimeBar");$(this,"_barstate");$(this,"_priceVariables");$(this,"_lastBarIndex");$(this,"_currentBarTime");$(this,"_lastBarTime");$(this,"_period");$(this,"_offsetTime");$(this,"_timeframe");$(this,"_ta");$(this,"_polyline");$(this,"_label");$(this,"_line");$(this,"_linefill");$(this,"_box");$(this,"_table");$(this,"_strategy");$(this,"_session");$(this,"syminfo");$(this,"chart");$(this,"earnings");$(this,"dividends");$(this,"_timeTradingday");$(this,"_mintick");$(this,"_cacheSpace");this._cacheData={varData:{},varNewData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new pw,this._timeframe=new gw,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new mw(t),this._polyline=new Fi,this._label=new Fi,this._line=new Fi,this._linefill=new Fi,this._box=new Fi,this._table=new Fi,this._strategy=new _w(this),this._session=new dw(this),this.syminfo=new yw(this),this.chart=new vw(this),this.earnings=new Dw(this),this.dividends=new ww(this),this._cacheSpace=new Map}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:t,open:e,high:r,low:n}=this._priceVariables;return(t+e+r+n)/4}get hl2(){const{high:t,low:e}=this._priceVariables;return(t+e)/2}get hlc3(){const{close:t,high:e,low:r}=this._priceVariables;return(t+e+r)/3}get hlcc4(){const{close:t,high:e,low:r}=this._priceVariables;return(t*2+e+r)/4}get hour(){return ee(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return ee(this._currentBarTime).minute()}get second(){return ee(this._currentBarTime).second()}get month(){return ee(this._currentBarTime).month()+1}get year(){return ee(this._currentBarTime).year()}get dayofweek(){return ee(this._currentBarTime).day()+1}get dayofmonth(){return ee(this._currentBarTime).date()}get weekofyear(){return ee(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=ys(this._period);return this._isRealTimeBar?void 0:ee(this._currentBarTime).add(t,e).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}updateMaxLength(t){const{max_lines_count:e,max_labels_count:r,max_boxes_count:n,max_polylines_count:i}=t;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),e&&this._line.setMaxLen(e),i&&this._polyline.setMaxLen(i)}getTimeTradingday(t,e){const[r,n]=ys(e),i=ee(t);return["M","w","y","d"].includes(n)?i.valueOf():(i.subtract(this._offsetTime,"h"),i.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(t){const{interval:e="1D",offsetTime:r=5,mintick:n,chart:i}=t;this._period=e,this._mintick=n,this._offsetTime=r,this._timeframe.update(e),this.chart.updateOptions(i)}updateData(t){const{barIndex:e,c:r,o:n,h:i,l:a,volume:l,time:c,lastBarIndex:h,lastBarTime:p,isrealtime:f,time_tradingday:d}=t;this._priceVariables={close:Number(r),open:Number(n),high:Number(i),low:Number(a),volume:Number(l)},this._isRealTimeBar=f,e>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varNewData={}),this._timeTradingday=d,this._currentBarTime=c*1e3,this._lastBarIndex=h,this._barIndex=e,this._lastBarTime=p*1e3,this._barstate.update(e,h,f,!0),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){const n=this.setCacheData(t,r);return(this._cacheSpace.get(t)||0)<e&&this._cacheSpace.set(t,e),n[n.length-1-e]}setCacheData(t,e){let r=this._cacheData[t]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;r.barIndex===this._barIndex?r.data[r.data.length-1]=e:r.data.push(e);const n=this._cacheSpace.get(t);return n&&r.data.length>n+5&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[t]=r,r.data}getTypeInstance(t,e){return new Pp(t,e)}verifyVarAndVarip(t,e,r){const n=`${t}_${e}`;return r==="var"&&this._cacheData.varData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varData[n]),!0):r==="varip"&&this._cacheData.varipData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varipData[n]),!0):!1}getVarValue(t,e,r){const n=`${t}_${e}`;return r==="var"?this._isRealTimeBar&&this._cacheData.varNewData.hasOwnProperty(n)?this._cacheData.varNewData[n]:this._cacheData.varData[n]:this._cacheData.varipData[n]}setVarValue(t,e,r,n){var l;const i=`${t}_${e}`;let a;switch(typeof r=="object"&&((l=r==null?void 0:r.varipKeys)!=null&&l.length)&&(n="var",a=r.varipKeys),this._chartDrawsHandle(r,this._cacheData.varData[i]||this._cacheData.varipData[i]),n){case"var":if(this._isRealTimeBar){if(this._cacheData.varNewData[i]=r,a&&a.length)for(const c of a)this._cacheData.varData[i][c]=r[c]}else this._cacheData.varData[i]=r;break;case"varip":this._cacheData.varipData[i]=r;break}return r}_upadteChartDraws(t){const e=t==null?void 0:t.id;if(e)switch(t==null?void 0:t.type){case Fe.BOX:this._setChartDraw(e,this._box);break;case Fe.LINE:this._setChartDraw(e,this._line);break;case Fe.POLYLINE:this._setChartDraw(e,this._polyline);break;case Fe.LABEL:this._setChartDraw(e,this._label);break;case Fe.LINEFILL:this._setChartDraw(e,this._linefill);break;case Fe.TABLE:this._setChartDraw(e,this._table);break}}_setChartDraw(t,e){const r=e.getInstance(t),n=e.get(t),i=(r==null?void 0:r.updateId())||t;e.delete(t),e.set(i,n,r)}_chartDrawsHandle(t,e){const r=e==null?void 0:e.id;let n=t==null?void 0:t.id;r!==n&&(n&&t.data&&(t.data.isVar=!0),r&&e.data&&(e.data.isVar=!1))}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Xr.uniq([...t,...e]):typeof t=="number"||typeof e=="number"?Number(t)+Number(e):t+e}sub(t,e){return Array.isArray(t)&&Array.isArray(e)?t.filter(r=>!e.includes(r)):Number(t)-Number(e)}againAssignParse(t,e){var n;if(e)return;const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;if(r)switch(r){case ao.name:case eh.name:case co.name:case rh.name:case uo.name:case lo.name:t==null||t.delete();break}}}class Fi{constructor(t=50){$(this,"_all");$(this,"_allInstance");$(this,"_pseudoArrayAll");$(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Qt,this._maxLength=t}setMaxLen(t){this._maxLength=t}get data(){return[...this._all.values()].slice(-this._maxLength)}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(t,e,r){if(this.set(t,e,r),this._all.size>this._maxLength){const{bar_index:n}=e;for(const[i,a]of this._all){const{isVar:l,id:c,bar_index:h}=a;if(h===n)break;if(l)continue;this.delete(c);break}}}getValOfBarIndex(t){let e=[];const r=[...this._all.keys()];for(const n of t){const i=r.filter(a=>a.endsWith(`_${n}`));for(const a of i){const l=this._all.get(a);l&&e.push(l)}}return e.length?e:void 0}set(t,e,r){this._all.set(t,e),this._allInstance.set(t,r)}get(t){return this._all.get(t)}getInstance(t){return this._allInstance.get(t)}delete(t){this._all.delete(t),this._allInstance.delete(t)}}/**
66
- * @license
67
- * Copyright 2019 Google LLC
68
- * SPDX-License-Identifier: Apache-2.0
69
- */const uh=Symbol("Comlink.proxy"),bw=Symbol("Comlink.endpoint"),xw=Symbol("Comlink.releaseProxy"),Ua=Symbol("Comlink.finalizer"),fo=Symbol("Comlink.thrown"),lh=s=>typeof s=="object"&&s!==null||typeof s=="function",Ew={canHandle:s=>lh(s)&&s[uh],serialize(s){const{port1:t,port2:e}=new MessageChannel;return Wa(s,t),[e,[e]]},deserialize(s){return s.start(),Mw(s)}},Aw={canHandle:s=>lh(s)&&fo in s,serialize({value:s}){let t;return s instanceof Error?t={isError:!0,value:{message:s.message,name:s.name,stack:s.stack}}:t={isError:!1,value:s},[t,[]]},deserialize(s){throw s.isError?Object.assign(new Error(s.value.message),s.value):s.value}},ch=new Map([["proxy",Ew],["throw",Aw]]);function Cw(s,t){for(const e of s)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function Wa(s,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Cw(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:i,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(Qn);let h;try{const p=l.slice(0,-1).reduce((d,g)=>d[g],s),f=l.reduce((d,g)=>d[g],s);switch(a){case"GET":h=f;break;case"SET":p[l.slice(-1)[0]]=Qn(n.data.value),h=!0;break;case"APPLY":h=f.apply(p,c);break;case"CONSTRUCT":{const d=new f(...c);h=Iw(d)}break;case"ENDPOINT":{const{port1:d,port2:g}=new MessageChannel;Wa(s,g),h=Ow(d,[d])}break;case"RELEASE":h=void 0;break;default:return}}catch(p){h={value:p,[fo]:0}}Promise.resolve(h).catch(p=>({value:p,[fo]:0})).then(p=>{const[f,d]=mo(p);t.postMessage(Object.assign(Object.assign({},f),{id:i}),d),a==="RELEASE"&&(t.removeEventListener("message",r),fh(t),Ua in s&&typeof s[Ua]=="function"&&s[Ua]())}).catch(p=>{const[f,d]=mo({value:new TypeError("Unserializable return value"),[fo]:0});t.postMessage(Object.assign(Object.assign({},f),{id:i}),d)})}),t.start&&t.start()}function Fw(s){return s.constructor.name==="MessagePort"}function fh(s){Fw(s)&&s.close()}function Mw(s,t){return ja(s,[],t)}function ho(s){if(s)throw new Error("Proxy has been released and is not useable")}function hh(s){return Mi(s,{type:"RELEASE"}).then(()=>{fh(s)})}const po=new WeakMap,_o="FinalizationRegistry"in globalThis&&new FinalizationRegistry(s=>{const t=(po.get(s)||0)-1;po.set(s,t),t===0&&hh(s)});function Nw(s,t){const e=(po.get(t)||0)+1;po.set(t,e),_o&&_o.register(s,t,s)}function Sw(s){_o&&_o.unregister(s)}function ja(s,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(i,a){if(ho(r),a===xw)return()=>{Sw(n),hh(s),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const l=Mi(s,{type:"GET",path:t.map(c=>c.toString())}).then(Qn);return l.then.bind(l)}return ja(s,[...t,a])},set(i,a,l){ho(r);const[c,h]=mo(l);return Mi(s,{type:"SET",path:[...t,a].map(p=>p.toString()),value:c},h).then(Qn)},apply(i,a,l){ho(r);const c=t[t.length-1];if(c===bw)return Mi(s,{type:"ENDPOINT"}).then(Qn);if(c==="bind")return ja(s,t.slice(0,-1));const[h,p]=ph(l);return Mi(s,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:h},p).then(Qn)},construct(i,a){ho(r);const[l,c]=ph(a);return Mi(s,{type:"CONSTRUCT",path:t.map(h=>h.toString()),argumentList:l},c).then(Qn)}});return Nw(n,s),n}function Bw(s){return Array.prototype.concat.apply([],s)}function ph(s){const t=s.map(mo);return[t.map(e=>e[0]),Bw(t.map(e=>e[1]))]}const dh=new WeakMap;function Ow(s,t){return dh.set(s,t),s}function Iw(s){return Object.assign(s,{[uh]:!0})}function mo(s){for(const[t,e]of ch)if(e.canHandle(s)){const[r,n]=e.serialize(s);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:s},dh.get(s)||[]]}function Qn(s){switch(s.type){case"HANDLER":return ch.get(s.name).deserialize(s.value);case"RAW":return s.value}}function Mi(s,t,e){return new Promise(r=>{const n=Tw();s.addEventListener("message",function i(a){!a.data||!a.data.id||a.data.id!==n||(s.removeEventListener("message",i),r(a.data))}),s.start&&s.start(),s.postMessage(Object.assign({id:n},t),e)})}function Tw(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class $w{constructor(){$(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}deleteStartwidthKey(t){for(const e of this._cache.keys())e.startsWith(t)&&this._cache.delete(e)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}function Lw(s,t,e){var x;const{data:r,isPreParser:n,id:i="default",syminfo:a,interval:l,inputs:c,chart:h,strategy:p}=t;self.workerStorage||(self.workerStorage=new $w);let{builtInGather:f,buildinConstants:d,buildInFunctions:g,tradingvueFunc:y}=self.workerStorage.get(i)||{},m=[];e&&(f=new ah(i),d=new th,g=new oh((a==null?void 0:a.mintick)||1e-5,f,i),y=new Function("$_var","$_const","$_func",s),self.workerStorage.set(i,{builtInGather:f,buildinConstants:d,buildInFunctions:g,tradingvueFunc:y}),self.workerStorage.set(`request_${i}`,new Map),self.workerStorage.set(`request_${i}_data`,new Map),self.workerStorage.set(`request_${i}_list`,new Map));let w=[];if(n)y(f,d,g);else if(r&&r.length){const b=r.length-1;f.updateOptions({interval:l,mintick:(a==null?void 0:a.mintick)||1e-5,chart:h}),g.updateOptions({inputs:c,strategy:p});try{for(const[N,E]of r.entries()){const{barindex:A}=E;!e&&(A||A===0)&&m.push(A),f.updateData(Object.assign(E,{barIndex:A||N,lastBarIndex:r[b].barindex||b,lastBarTime:r[b].time})),g.update({barIndex:A||N}),y(f,d,g),g.endExecution();const M=g.errors;if(M.length&&M.some(S=>S.type===zt.Error))return{status:1,errors:M}}w=[...((x=self.workerStorage.get(`request_${i}_list`))==null?void 0:x.values())||[]],w.length&&self.workerStorage.delete(`request_${i}_list`)}catch(N){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:N==null?void 0:N.message,type:zt.Error}]}}}const v=g.errors;return v.length&&v.some(b=>b.type===zt.Error)?{status:1,errors:v}:{status:0,requestList:w,errors:v,options:{...g.options(m),id:i}}}function Rw(s){self==null||self.workerStorage.deleteStartwidthKey(s),self==null||self.workerStorage.delete(`inputs_${s}`),self==null||self.workerStorage.delete(`strategy_${s}`),self==null||self.workerStorage.delete(`request_${s}`),self==null||self.workerStorage.delete(`request_${s}_data`),self==null||self.workerStorage.delete(`request_${s}_list`)}Wa({runScript:Lw,removeScript:Rw})})();