@guihz/trading-vue-editor-tes 0.0.176 → 0.0.178
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assets/{parserTccWorker-BGGjQBvd.js → parserTccWorker-Bcz7NTve.js} +56 -56
- package/lib/assets/scriptsRunWorker-Ci_BGrY5.js +69 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/label.d.ts +2 -2
- package/lib/components/editor/parseScript/buildInFuncNamespace/line.d.ts +1 -1
- package/lib/components/editor/parseScript/buildInFuncNamespace/linefill.d.ts +2 -2
- package/lib/trading-vue-editor.js +2 -2
- package/lib/trading-vue-editor.umd.cjs +1 -1
- package/package.json +1 -1
- package/lib/assets/scriptsRunWorker-C5ZII6gX.js +0 -69
@@ -1,69 +0,0 @@
|
|
1
|
-
var k2=Object.defineProperty;var U2=(Vt,Gt,Fe)=>Gt in Vt?k2(Vt,Gt,{enumerable:!0,configurable:!0,writable:!0,value:Fe}):Vt[Gt]=Fe;var R=(Vt,Gt,Fe)=>(U2(Vt,typeof Gt!="symbol"?Gt+"":Gt,Fe),Fe),Al=(Vt,Gt,Fe)=>{if(!Gt.has(Vt))throw TypeError("Cannot "+Fe)};var Hr=(Vt,Gt,Fe)=>(Al(Vt,Gt,"read from private field"),Fe?Fe.call(Vt):Gt.get(Vt)),Cl=(Vt,Gt,Fe)=>{if(Gt.has(Vt))throw TypeError("Cannot add the same private member more than once");Gt instanceof WeakSet?Gt.add(Vt):Gt.set(Vt,Fe)},ua=(Vt,Gt,Fe,Yn)=>(Al(Vt,Gt,"write to private field"),Yn?Yn.call(Vt,Fe):Gt.set(Vt,Fe),Fe);var Fl=(Vt,Gt,Fe)=>(Al(Vt,Gt,"access private method"),Fe);(function(){"use strict";var is,Ml,Ni,He;var Vt=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 Fe(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 Yn={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
|
-
*/Yn.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__",p=500,h="__lodash_placeholder__",f=1,d=2,g=4,y=1,m=2,w=1,v=2,E=4,b=8,N=16,x=32,F=64,M=128,S=256,I=512,C=30,B="...",L=800,U=16,k=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",I],["partial",x],["partialRight",F],["rearg",S]],bt="[object Arguments]",Bt="[object Array]",Et="[object AsyncFunction]",oe="[object Boolean]",Tt="[object Date]",Nt="[object DOMException]",le="[object Error]",re="[object Function]",kt="[object GeneratorFunction]",Jt="[object Map]",Ie="[object Number]",_r="[object Null]",Re="[object Object]",pn="[object Promise]",On="[object Proxy]",dn="[object RegExp]",mr="[object Set]",Tn="[object String]",$="[object Symbol]",V="[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]",De="[object Uint8ClampedArray]",ke="[object Uint16Array]",Pe="[object Uint32Array]",gr=/\b__p \+= '';/g,vr=/\b(__p \+=) '' \+/g,In=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ti=/&(?:amp|lt|gt|quot|#39);/g,vo=/[&<>"']/g,Va=RegExp(ti.source),Za=RegExp(vo.source),Ka=/<%-([\s\S]+?)%>/g,Ga=/<%([\s\S]+?)%>/g,yo=/<%=([\s\S]+?)%>/g,Ha=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ja=/^\w*$/,Xa=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ss=/[\\^$.*+?()[\]{}|]/g,Qa=RegExp(ss.source),os=/^\s+/,tu=/\s/,eu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ru=/\{\n\/\* \[wrapped with (.+)\] \*/,nu=/,? & /,iu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,su=/[()=,{}\[\]\/\s]/,ou=/\\(\\)?/g,au=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,wo=/\w*$/,uu=/^[-+]0x[0-9a-f]+$/i,lu=/^0b[01]+$/i,cu=/^\[object .+?Constructor\]$/,fu=/^0o[0-7]+$/i,hu=/^(?:0|[1-9]\d*)$/,pu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Si=/($^)/,ei=/['\n\r\u2028\u2029\\]/g,Zt="\\ud800-\\udfff",Je="\\u0300-\\u036f",du="\\ufe20-\\ufe2f",Bi="\\u20d0-\\u20ff",$n=Je+du+Bi,Do="\\u2700-\\u27bf",dh="a-z\\xdf-\\xf6\\xf8-\\xff",Rw="\\xac\\xb1\\xd7\\xf7",Pw="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",zw="\\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",_h="A-Z\\xc0-\\xd6\\xd8-\\xde",mh="\\ufe0e\\ufe0f",gh=Rw+Pw+zw+qw,_u="['’]",kw="["+Zt+"]",vh="["+gh+"]",bo="["+$n+"]",yh="\\d+",Uw="["+Do+"]",wh="["+dh+"]",Dh="[^"+Zt+gh+yh+Do+dh+_h+"]",mu="\\ud83c[\\udffb-\\udfff]",Ww="(?:"+bo+"|"+mu+")",bh="[^"+Zt+"]",gu="(?:\\ud83c[\\udde6-\\uddff]){2}",vu="[\\ud800-\\udbff][\\udc00-\\udfff]",Oi="["+_h+"]",Eh="\\u200d",xh="(?:"+wh+"|"+Dh+")",jw="(?:"+Oi+"|"+Dh+")",Ah="(?:"+_u+"(?:d|ll|m|re|s|t|ve))?",Ch="(?:"+_u+"(?:D|LL|M|RE|S|T|VE))?",Fh=Ww+"?",Mh="["+mh+"]?",Yw="(?:"+Eh+"(?:"+[bh,gu,vu].join("|")+")"+Mh+Fh+")*",Vw="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Zw="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Nh=Mh+Fh+Yw,Kw="(?:"+[Uw,gu,vu].join("|")+")"+Nh,Gw="(?:"+[bh+bo+"?",bo,gu,vu,kw].join("|")+")",Hw=RegExp(_u,"g"),Jw=RegExp(bo,"g"),yu=RegExp(mu+"(?="+mu+")|"+Gw+Nh,"g"),Xw=RegExp([Oi+"?"+wh+"+"+Ah+"(?="+[vh,Oi,"$"].join("|")+")",jw+"+"+Ch+"(?="+[vh,Oi+xh,"$"].join("|")+")",Oi+"?"+xh+"+"+Ah,Oi+"+"+Ch,Zw,Vw,yh,Kw].join("|"),"g"),Qw=RegExp("["+Eh+Zt+$n+mh+"]"),tD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,eD=["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"],rD=-1,ve={};ve[ft]=ve[ut]=ve[ht]=ve[at]=ve[Xt]=ve[ne]=ve[De]=ve[ke]=ve[Pe]=!0,ve[bt]=ve[Bt]=ve[st]=ve[oe]=ve[rt]=ve[Tt]=ve[le]=ve[re]=ve[Jt]=ve[Ie]=ve[Re]=ve[dn]=ve[mr]=ve[Tn]=ve[G]=!1;var de={};de[bt]=de[Bt]=de[st]=de[rt]=de[oe]=de[Tt]=de[ft]=de[ut]=de[ht]=de[at]=de[Xt]=de[Jt]=de[Ie]=de[Re]=de[dn]=de[mr]=de[Tn]=de[$]=de[ne]=de[De]=de[ke]=de[Pe]=!0,de[le]=de[re]=de[G]=!1;var nD={À:"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"},iD={"&":"&","<":"<",">":">",'"':""","'":"'"},sD={"&":"&","<":"<",">":">",""":'"',"'":"'"},oD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},aD=parseFloat,uD=parseInt,Sh=typeof Vt=="object"&&Vt&&Vt.Object===Object&&Vt,lD=typeof self=="object"&&self&&self.Object===Object&&self,Ze=Sh||lD||Function("return this")(),wu=t&&!t.nodeType&&t,ri=wu&&!0&&s&&!s.nodeType&&s,Bh=ri&&ri.exports===wu,Du=Bh&&Sh.process,Sr=function(){try{var j=ri&&ri.require&&ri.require("util").types;return j||Du&&Du.binding&&Du.binding("util")}catch{}}(),Oh=Sr&&Sr.isArrayBuffer,Th=Sr&&Sr.isDate,Ih=Sr&&Sr.isMap,$h=Sr&&Sr.isRegExp,Lh=Sr&&Sr.isSet,Rh=Sr&&Sr.isTypedArray;function yr(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 cD(j,J,H,gt){for(var Ot=-1,te=j==null?0:j.length;++Ot<te;){var ze=j[Ot];J(gt,ze,H(ze),j)}return gt}function Br(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt&&J(j[H],H,j)!==!1;);return j}function fD(j,J){for(var H=j==null?0:j.length;H--&&J(j[H],H,j)!==!1;);return j}function Ph(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 ze=j[H];J(ze,H,j)&&(te[Ot++]=ze)}return te}function Eo(j,J){var H=j==null?0:j.length;return!!H&&Ti(j,J,0)>-1}function bu(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 be(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 Eu(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 hD(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 pD=Au("length");function dD(j){return j.split("")}function _D(j){return j.match(iu)||[]}function zh(j,J,H){var gt;return H(j,function(Ot,te,ze){if(J(Ot,te,ze))return gt=te,!1}),gt}function xo(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 Ti(j,J,H){return J===J?FD(j,J,H):xo(j,qh,H)}function mD(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 kh(j,J){var H=j==null?0:j.length;return H?Fu(j,J)/H:Q}function Au(j){return function(J){return J==null?e:J[j]}}function Cu(j){return function(J){return j==null?e:j[J]}}function Uh(j,J,H,gt,Ot){return Ot(j,function(te,ze,he){H=gt?(gt=!1,te):J(H,te,ze,he)}),H}function gD(j,J){var H=j.length;for(j.sort(J);H--;)j[H]=j[H].value;return j}function Fu(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 Mu(j,J){for(var H=-1,gt=Array(j);++H<j;)gt[H]=J(H);return gt}function vD(j,J){return be(J,function(H){return[H,j[H]]})}function Wh(j){return j&&j.slice(0,Zh(j)+1).replace(os,"")}function wr(j){return function(J){return j(J)}}function Nu(j,J){return be(J,function(H){return j[H]})}function as(j,J){return j.has(J)}function jh(j,J){for(var H=-1,gt=j.length;++H<gt&&Ti(J,j[H],0)>-1;);return H}function Yh(j,J){for(var H=j.length;H--&&Ti(J,j[H],0)>-1;);return H}function yD(j,J){for(var H=j.length,gt=0;H--;)j[H]===J&&++gt;return gt}var wD=Cu(nD),DD=Cu(iD);function bD(j){return"\\"+oD[j]}function ED(j,J){return j==null?e:j[J]}function Ii(j){return Qw.test(j)}function xD(j){return tD.test(j)}function AD(j){for(var J,H=[];!(J=j.next()).done;)H.push(J.value);return H}function Su(j){var J=-1,H=Array(j.size);return j.forEach(function(gt,Ot){H[++J]=[Ot,gt]}),H}function Vh(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 ze=j[H];(ze===J||ze===h)&&(j[H]=h,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 CD(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=[gt,gt]}),H}function FD(j,J,H){for(var gt=H-1,Ot=j.length;++gt<Ot;)if(j[gt]===J)return gt;return-1}function MD(j,J,H){for(var gt=H+1;gt--;)if(j[gt]===J)return gt;return gt}function $i(j){return Ii(j)?SD(j):pD(j)}function Vr(j){return Ii(j)?BD(j):dD(j)}function Zh(j){for(var J=j.length;J--&&tu.test(j.charAt(J)););return J}var ND=Cu(sD);function SD(j){for(var J=yu.lastIndex=0;yu.test(j);)++J;return J}function BD(j){return j.match(yu)||[]}function OD(j){return j.match(Xw)||[]}var TD=function j(J){J=J==null?Ze:Li.defaults(Ze.Object(),J,Li.pick(Ze,eD));var H=J.Array,gt=J.Date,Ot=J.Error,te=J.Function,ze=J.Math,he=J.Object,Bu=J.RegExp,ID=J.String,Or=J.TypeError,Co=H.prototype,$D=te.prototype,Ri=he.prototype,Fo=J["__core-js_shared__"],Mo=$D.toString,ae=Ri.hasOwnProperty,LD=0,Kh=function(){var o=/[^.]+$/.exec(Fo&&Fo.keys&&Fo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),No=Ri.toString,RD=Mo.call(he),PD=Ze._,zD=Bu("^"+Mo.call(ae).replace(ss,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),So=Bh?J.Buffer:e,zn=J.Symbol,Bo=J.Uint8Array,Gh=So?So.allocUnsafe:e,Oo=Vh(he.getPrototypeOf,he),Hh=he.create,Jh=Ri.propertyIsEnumerable,To=Co.splice,Xh=zn?zn.isConcatSpreadable:e,us=zn?zn.iterator:e,ni=zn?zn.toStringTag:e,Io=function(){try{var o=ui(he,"defineProperty");return o({},"",{}),o}catch{}}(),qD=J.clearTimeout!==Ze.clearTimeout&&J.clearTimeout,kD=gt&>.now!==Ze.Date.now&>.now,UD=J.setTimeout!==Ze.setTimeout&&J.setTimeout,$o=ze.ceil,Lo=ze.floor,Ou=he.getOwnPropertySymbols,WD=So?So.isBuffer:e,Qh=J.isFinite,jD=Co.join,YD=Vh(he.keys,he),qe=ze.max,Xe=ze.min,VD=gt.now,ZD=J.parseInt,t0=ze.random,KD=Co.reverse,Tu=ui(J,"DataView"),ls=ui(J,"Map"),Iu=ui(J,"Promise"),Pi=ui(J,"Set"),cs=ui(J,"WeakMap"),fs=ui(he,"create"),Ro=cs&&new cs,zi={},GD=li(Tu),HD=li(ls),JD=li(Iu),XD=li(Pi),QD=li(cs),Po=zn?zn.prototype:e,hs=Po?Po.valueOf:e,e0=Po?Po.toString:e;function O(o){if(Ce(o)&&!It(o)&&!(o instanceof jt)){if(o instanceof Tr)return o;if(ae.call(o,"__wrapped__"))return rp(o)}return new Tr(o)}var qi=function(){function o(){}return function(u){if(!Ae(u))return{};if(Hh)return Hh(u);o.prototype=u;var _=new o;return o.prototype=e,_}}();function zo(){}function Tr(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}O.templateSettings={escape:Ka,evaluate:Ga,interpolate:yo,variable:"",imports:{_:O}},O.prototype=zo.prototype,O.prototype.constructor=O,Tr.prototype=qi(zo.prototype),Tr.prototype.constructor=Tr;function jt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ct,this.__views__=[]}function tb(){var o=new jt(this.__wrapped__);return o.__actions__=ur(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=ur(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=ur(this.__views__),o}function eb(){if(this.__filtered__){var o=new jt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function rb(){var o=this.__wrapped__.value(),u=this.__dir__,_=It(o),D=u<0,A=_?o.length:0,T=dE(0,A,this.__views__),P=T.start,q=T.end,Y=q-P,tt=D?q:P-1,et=this.__iteratees__,ot=et.length,dt=0,yt=Xe(Y,this.__takeCount__);if(!_||!D&&A==Y&&yt==Y)return A0(o,this.__actions__);var Ct=[];t:for(;Y--&&dt<yt;){tt+=u;for(var Rt=-1,Ft=o[tt];++Rt<ot;){var Ut=et[Rt],Yt=Ut.iteratee,Er=Ut.type,ir=Yt(Ft);if(Er==W)Ft=ir;else if(!ir){if(Er==k)continue t;break t}}Ct[dt++]=Ft}return Ct}jt.prototype=qi(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 nb(){this.__data__=fs?fs(null):{},this.size=0}function ib(o){var u=this.has(o)&&delete this.__data__[o];return this.size-=u?1:0,u}function sb(o){var u=this.__data__;if(fs){var _=u[o];return _===c?e:_}return ae.call(u,o)?u[o]:e}function ob(o){var u=this.__data__;return fs?u[o]!==e:ae.call(u,o)}function ab(o,u){var _=this.__data__;return this.size+=this.has(o)?0:1,_[o]=fs&&u===e?c:u,this}ii.prototype.clear=nb,ii.prototype.delete=ib,ii.prototype.get=sb,ii.prototype.has=ob,ii.prototype.set=ab;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 ub(){this.__data__=[],this.size=0}function lb(o){var u=this.__data__,_=qo(u,o);if(_<0)return!1;var D=u.length-1;return _==D?u.pop():To.call(u,_,1),--this.size,!0}function cb(o){var u=this.__data__,_=qo(u,o);return _<0?e:u[_][1]}function fb(o){return qo(this.__data__,o)>-1}function hb(o,u){var _=this.__data__,D=qo(_,o);return D<0?(++this.size,_.push([o,u])):_[D][1]=u,this}_n.prototype.clear=ub,_n.prototype.delete=lb,_n.prototype.get=cb,_n.prototype.has=fb,_n.prototype.set=hb;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 pb(){this.size=0,this.__data__={hash:new ii,map:new(ls||_n),string:new ii}}function db(o){var u=Xo(this,o).delete(o);return this.size-=u?1:0,u}function _b(o){return Xo(this,o).get(o)}function mb(o){return Xo(this,o).has(o)}function gb(o,u){var _=Xo(this,o),D=_.size;return _.set(o,u),this.size+=_.size==D?0:1,this}mn.prototype.clear=pb,mn.prototype.delete=db,mn.prototype.get=_b,mn.prototype.has=mb,mn.prototype.set=gb;function si(o){var u=-1,_=o==null?0:o.length;for(this.__data__=new mn;++u<_;)this.add(o[u])}function vb(o){return this.__data__.set(o,c),this}function yb(o){return this.__data__.has(o)}si.prototype.add=si.prototype.push=vb,si.prototype.has=yb;function Zr(o){var u=this.__data__=new _n(o);this.size=u.size}function wb(){this.__data__=new _n,this.size=0}function Db(o){var u=this.__data__,_=u.delete(o);return this.size=u.size,_}function bb(o){return this.__data__.get(o)}function Eb(o){return this.__data__.has(o)}function xb(o,u){var _=this.__data__;if(_ instanceof _n){var D=_.__data__;if(!ls||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}Zr.prototype.clear=wb,Zr.prototype.delete=Db,Zr.prototype.get=bb,Zr.prototype.has=Eb,Zr.prototype.set=xb;function r0(o,u){var _=It(o),D=!_&&ci(o),A=!_&&!D&&jn(o),T=!_&&!D&&!A&&ji(o),P=_||D||A||T,q=P?Mu(o.length,ID):[],Y=q.length;for(var tt in o)(u||ae.call(o,tt))&&!(P&&(tt=="length"||A&&(tt=="offset"||tt=="parent")||T&&(tt=="buffer"||tt=="byteLength"||tt=="byteOffset")||wn(tt,Y)))&&q.push(tt);return q}function n0(o){var u=o.length;return u?o[Yu(0,u-1)]:e}function Ab(o,u){return Qo(ur(o),oi(u,0,o.length))}function Cb(o){return Qo(ur(o))}function $u(o,u,_){(_!==e&&!Kr(o[u],_)||_===e&&!(u in o))&&gn(o,u,_)}function ps(o,u,_){var D=o[u];(!(ae.call(o,u)&&Kr(D,_))||_===e&&!(u in o))&&gn(o,u,_)}function qo(o,u){for(var _=o.length;_--;)if(Kr(o[_][0],u))return _;return-1}function Fb(o,u,_,D){return qn(o,function(A,T,P){u(D,A,_(A),P)}),D}function i0(o,u){return o&&nn(u,Ue(u),o)}function Mb(o,u){return o&&nn(u,cr(u),o)}function gn(o,u,_){u=="__proto__"&&Io?Io(o,u,{configurable:!0,enumerable:!0,value:_,writable:!0}):o[u]=_}function Lu(o,u){for(var _=-1,D=u.length,A=H(D),T=o==null;++_<D;)A[_]=T?e:ml(o,u[_]);return A}function oi(o,u,_){return o===o&&(_!==e&&(o=o<=_?o:_),u!==e&&(o=o>=u?o:u)),o}function Ir(o,u,_,D,A,T){var P,q=u&f,Y=u&d,tt=u&g;if(_&&(P=A?_(o,D,A,T):_(o)),P!==e)return P;if(!Ae(o))return o;var et=It(o);if(et){if(P=mE(o),!q)return ur(o,P)}else{var ot=Qe(o),dt=ot==re||ot==kt;if(jn(o))return M0(o,q);if(ot==Re||ot==bt||dt&&!A){if(P=Y||dt?{}:Z0(o),!q)return Y?sE(o,Mb(P,o)):iE(o,i0(P,o))}else{if(!de[ot])return A?o:{};P=gE(o,ot,q)}}T||(T=new Zr);var yt=T.get(o);if(yt)return yt;T.set(o,P),bp(o)?o.forEach(function(Ft){P.add(Ir(Ft,u,_,Ft,o,T))}):wp(o)&&o.forEach(function(Ft,Ut){P.set(Ut,Ir(Ft,u,_,Ut,o,T))});var Ct=tt?Y?rl:el:Y?cr:Ue,Rt=et?e:Ct(o);return Br(Rt||o,function(Ft,Ut){Rt&&(Ut=Ft,Ft=o[Ut]),ps(P,Ut,Ir(Ft,u,_,Ut,o,T))}),P}function Nb(o){var u=Ue(o);return function(_){return s0(_,o,u)}}function s0(o,u,_){var D=_.length;if(o==null)return!D;for(o=he(o);D--;){var A=_[D],T=u[A],P=o[A];if(P===e&&!(A in o)||!T(P))return!1}return!0}function o0(o,u,_){if(typeof o!="function")throw new Or(a);return ws(function(){o.apply(e,_)},u)}function ds(o,u,_,D){var A=-1,T=Eo,P=!0,q=o.length,Y=[],tt=u.length;if(!q)return Y;_&&(u=be(u,wr(_))),D?(T=bu,P=!1):u.length>=n&&(T=as,P=!1,u=new si(u));t:for(;++A<q;){var et=o[A],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;Y.push(et)}else T(u,ot,D)||Y.push(et)}return Y}var qn=T0(rn),a0=T0(Pu,!0);function Sb(o,u){var _=!0;return qn(o,function(D,A,T){return _=!!u(D,A,T),_}),_}function ko(o,u,_){for(var D=-1,A=o.length;++D<A;){var T=o[D],P=u(T);if(P!=null&&(q===e?P===P&&!br(P):_(P,q)))var q=P,Y=T}return Y}function Bb(o,u,_,D){var A=o.length;for(_=Lt(_),_<0&&(_=-_>A?0:A+_),D=D===e||D>A?A:Lt(D),D<0&&(D+=A),D=_>D?0:xp(D);_<D;)o[_++]=u;return o}function u0(o,u){var _=[];return qn(o,function(D,A,T){u(D,A,T)&&_.push(D)}),_}function Ke(o,u,_,D,A){var T=-1,P=o.length;for(_||(_=yE),A||(A=[]);++T<P;){var q=o[T];u>0&&_(q)?u>1?Ke(q,u-1,_,D,A):Rn(A,q):D||(A[A.length]=q)}return A}var Ru=I0(),l0=I0(!0);function rn(o,u){return o&&Ru(o,u,Ue)}function Pu(o,u){return o&&l0(o,u,Ue)}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[sn(u[_++])];return _&&_==D?o:e}function c0(o,u,_){var D=u(o);return It(o)?D:Rn(D,_(o))}function rr(o){return o==null?o===e?V:_r:ni&&ni in he(o)?pE(o):CE(o)}function zu(o,u){return o>u}function Ob(o,u){return o!=null&&ae.call(o,u)}function Tb(o,u){return o!=null&&u in he(o)}function Ib(o,u,_){return o>=Xe(u,_)&&o<qe(u,_)}function qu(o,u,_){for(var D=_?bu:Eo,A=o[0].length,T=o.length,P=T,q=H(T),Y=1/0,tt=[];P--;){var et=o[P];P&&u&&(et=be(et,wr(u))),Y=Xe(et.length,Y),q[P]=!_&&(u||A>=120&&et.length>=120)?new si(P&&et):e}et=o[0];var ot=-1,dt=q[0];t:for(;++ot<A&&tt.length<Y;){var yt=et[ot],Ct=u?u(yt):yt;if(yt=_||yt!==0?yt:0,!(dt?as(dt,Ct):D(tt,Ct,_))){for(P=T;--P;){var Rt=q[P];if(!(Rt?as(Rt,Ct):D(o[P],Ct,_)))continue t}dt&&dt.push(Ct),tt.push(yt)}}return tt}function $b(o,u,_,D){return rn(o,function(A,T,P){u(D,_(A),T,P)}),D}function _s(o,u,_){u=Un(u,o),o=J0(o,u);var D=o==null?o:o[sn(Lr(u))];return D==null?e:yr(D,o,_)}function f0(o){return Ce(o)&&rr(o)==bt}function Lb(o){return Ce(o)&&rr(o)==st}function Rb(o){return Ce(o)&&rr(o)==Tt}function ms(o,u,_,D,A){return o===u?!0:o==null||u==null||!Ce(o)&&!Ce(u)?o!==o&&u!==u:Pb(o,u,_,D,ms,A)}function Pb(o,u,_,D,A,T){var P=It(o),q=It(u),Y=P?Bt:Qe(o),tt=q?Bt:Qe(u);Y=Y==bt?Re:Y,tt=tt==bt?Re:tt;var et=Y==Re,ot=tt==Re,dt=Y==tt;if(dt&&jn(o)){if(!jn(u))return!1;P=!0,et=!1}if(dt&&!et)return T||(T=new Zr),P||ji(o)?j0(o,u,_,D,A,T):fE(o,u,Y,_,D,A,T);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 T||(T=new Zr),A(Rt,Ft,_,D,T)}}return dt?(T||(T=new Zr),hE(o,u,_,D,A,T)):!1}function zb(o){return Ce(o)&&Qe(o)==Jt}function ku(o,u,_,D){var A=_.length,T=A,P=!D;if(o==null)return!T;for(o=he(o);A--;){var q=_[A];if(P&&q[2]?q[1]!==o[q[0]]:!(q[0]in o))return!1}for(;++A<T;){q=_[A];var Y=q[0],tt=o[Y],et=q[1];if(P&&q[2]){if(tt===e&&!(Y in o))return!1}else{var ot=new Zr;if(D)var dt=D(tt,et,Y,o,u,ot);if(!(dt===e?ms(et,tt,y|m,D,ot):dt))return!1}}return!0}function h0(o){if(!Ae(o)||DE(o))return!1;var u=Dn(o)?zD:cu;return u.test(li(o))}function qb(o){return Ce(o)&&rr(o)==dn}function kb(o){return Ce(o)&&Qe(o)==mr}function Ub(o){return Ce(o)&&sa(o.length)&&!!ve[rr(o)]}function p0(o){return typeof o=="function"?o:o==null?fr:typeof o=="object"?It(o)?m0(o[0],o[1]):_0(o):$p(o)}function Uu(o){if(!ys(o))return YD(o);var u=[];for(var _ in he(o))ae.call(o,_)&&_!="constructor"&&u.push(_);return u}function Wb(o){if(!Ae(o))return AE(o);var u=ys(o),_=[];for(var D in o)D=="constructor"&&(u||!ae.call(o,D))||_.push(D);return _}function Wu(o,u){return o<u}function d0(o,u){var _=-1,D=lr(o)?H(o.length):[];return qn(o,function(A,T,P){D[++_]=u(A,T,P)}),D}function _0(o){var u=il(o);return u.length==1&&u[0][2]?G0(u[0][0],u[0][1]):function(_){return _===o||ku(_,o,u)}}function m0(o,u){return ol(o)&&K0(u)?G0(sn(o),u):function(_){var D=ml(_,o);return D===e&&D===u?gl(_,o):ms(u,D,y|m)}}function Wo(o,u,_,D,A){o!==u&&Ru(u,function(T,P){if(A||(A=new Zr),Ae(T))jb(o,u,P,_,Wo,D,A);else{var q=D?D(ul(o,P),T,P+"",o,u,A):e;q===e&&(q=T),$u(o,P,q)}},cr)}function jb(o,u,_,D,A,T,P){var q=ul(o,_),Y=ul(u,_),tt=P.get(Y);if(tt){$u(o,_,tt);return}var et=T?T(q,Y,_+"",o,u,P):e,ot=et===e;if(ot){var dt=It(Y),yt=!dt&&jn(Y),Ct=!dt&&!yt&&ji(Y);et=Y,dt||yt||Ct?It(q)?et=q:Ne(q)?et=ur(q):yt?(ot=!1,et=M0(Y,!0)):Ct?(ot=!1,et=N0(Y,!0)):et=[]:Ds(Y)||ci(Y)?(et=q,ci(q)?et=Ap(q):(!Ae(q)||Dn(q))&&(et=Z0(Y))):ot=!1}ot&&(P.set(Y,et),A(et,Y,D,T,P),P.delete(Y)),$u(o,_,et)}function g0(o,u){var _=o.length;if(_)return u+=u<0?_:0,wn(u,_)?o[u]:e}function v0(o,u,_){u.length?u=be(u,function(T){return It(T)?function(P){return ai(P,T.length===1?T[0]:T)}:T}):u=[fr];var D=-1;u=be(u,wr(At()));var A=d0(o,function(T,P,q){var Y=be(u,function(tt){return tt(T)});return{criteria:Y,index:++D,value:T}});return gD(A,function(T,P){return nE(T,P,_)})}function Yb(o,u){return y0(o,u,function(_,D){return gl(o,D)})}function y0(o,u,_){for(var D=-1,A=u.length,T={};++D<A;){var P=u[D],q=ai(o,P);_(q,P)&&gs(T,Un(P,o),q)}return T}function Vb(o){return function(u){return ai(u,o)}}function ju(o,u,_,D){var A=D?mD:Ti,T=-1,P=u.length,q=o;for(o===u&&(u=ur(u)),_&&(q=be(o,wr(_)));++T<P;)for(var Y=0,tt=u[T],et=_?_(tt):tt;(Y=A(q,et,Y,D))>-1;)q!==o&&To.call(q,Y,1),To.call(o,Y,1);return o}function w0(o,u){for(var _=o?u.length:0,D=_-1;_--;){var A=u[_];if(_==D||A!==T){var T=A;wn(A)?To.call(o,A,1):Ku(o,A)}}return o}function Yu(o,u){return o+Lo(t0()*(u-o+1))}function Zb(o,u,_,D){for(var A=-1,T=qe($o((u-o)/(_||1)),0),P=H(T);T--;)P[D?T:++A]=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 ll(H0(o,u,fr),o+"")}function Kb(o){return n0(Yi(o))}function Gb(o,u){var _=Yi(o);return Qo(_,oi(u,0,_.length))}function gs(o,u,_,D){if(!Ae(o))return o;u=Un(u,o);for(var A=-1,T=u.length,P=T-1,q=o;q!=null&&++A<T;){var Y=sn(u[A]),tt=_;if(Y==="__proto__"||Y==="constructor"||Y==="prototype")return o;if(A!=P){var et=q[Y];tt=D?D(et,Y,q):e,tt===e&&(tt=Ae(et)?et:wn(u[A+1])?[]:{})}ps(q,Y,tt),q=q[Y]}return o}var D0=Ro?function(o,u){return Ro.set(o,u),o}:fr,Hb=Io?function(o,u){return Io(o,"toString",{configurable:!0,enumerable:!1,value:yl(u),writable:!0})}:fr;function Jb(o){return Qo(Yi(o))}function $r(o,u,_){var D=-1,A=o.length;u<0&&(u=-u>A?0:A+u),_=_>A?A:_,_<0&&(_+=A),A=u>_?0:_-u>>>0,u>>>=0;for(var T=H(A);++D<A;)T[D]=o[D+u];return T}function Xb(o,u){var _;return qn(o,function(D,A,T){return _=u(D,A,T),!_}),!!_}function jo(o,u,_){var D=0,A=o==null?D:o.length;if(typeof u=="number"&&u===u&&A<=lt){for(;D<A;){var T=D+A>>>1,P=o[T];P!==null&&!br(P)&&(_?P<=u:P<u)?D=T+1:A=T}return A}return Zu(o,u,fr,_)}function Zu(o,u,_,D){var A=0,T=o==null?0:o.length;if(T===0)return 0;u=_(u);for(var P=u!==u,q=u===null,Y=br(u),tt=u===e;A<T;){var et=Lo((A+T)/2),ot=_(o[et]),dt=ot!==e,yt=ot===null,Ct=ot===ot,Rt=br(ot);if(P)var Ft=D||Ct;else tt?Ft=Ct&&(D||dt):q?Ft=Ct&&dt&&(D||!yt):Y?Ft=Ct&&dt&&!yt&&(D||!Rt):yt||Rt?Ft=!1:Ft=D?ot<=u:ot<u;Ft?A=et+1:T=et}return Xe(T,vt)}function b0(o,u){for(var _=-1,D=o.length,A=0,T=[];++_<D;){var P=o[_],q=u?u(P):P;if(!_||!Kr(q,Y)){var Y=q;T[A++]=P===0?0:P}}return T}function E0(o){return typeof o=="number"?o:br(o)?Q:+o}function Dr(o){if(typeof o=="string")return o;if(It(o))return be(o,Dr)+"";if(br(o))return e0?e0.call(o):"";var u=o+"";return u=="0"&&1/o==-K?"-0":u}function kn(o,u,_){var D=-1,A=Eo,T=o.length,P=!0,q=[],Y=q;if(_)P=!1,A=bu;else if(T>=n){var tt=u?null:lE(o);if(tt)return Ao(tt);P=!1,A=as,Y=new si}else Y=u?[]:q;t:for(;++D<T;){var et=o[D],ot=u?u(et):et;if(et=_||et!==0?et:0,P&&ot===ot){for(var dt=Y.length;dt--;)if(Y[dt]===ot)continue t;u&&Y.push(ot),q.push(et)}else A(Y,ot,_)||(Y!==q&&Y.push(ot),q.push(et))}return q}function Ku(o,u){return u=Un(u,o),o=J0(o,u),o==null||delete o[sn(Lr(u))]}function x0(o,u,_,D){return gs(o,u,_(ai(o,u)),D)}function Yo(o,u,_,D){for(var A=o.length,T=D?A:-1;(D?T--:++T<A)&&u(o[T],T,o););return _?$r(o,D?0:T,D?T+1:A):$r(o,D?T+1:0,D?A:T)}function A0(o,u){var _=o;return _ instanceof jt&&(_=_.value()),Eu(u,function(D,A){return A.func.apply(A.thisArg,Rn([D],A.args))},_)}function Gu(o,u,_){var D=o.length;if(D<2)return D?kn(o[0]):[];for(var A=-1,T=H(D);++A<D;)for(var P=o[A],q=-1;++q<D;)q!=A&&(T[A]=ds(T[A]||P,o[q],u,_));return kn(Ke(T,1),u,_)}function C0(o,u,_){for(var D=-1,A=o.length,T=u.length,P={};++D<A;){var q=D<T?u[D]:e;_(P,o[D],q)}return P}function Hu(o){return Ne(o)?o:[]}function Ju(o){return typeof o=="function"?o:fr}function Un(o,u){return It(o)?o:ol(o,u)?[o]:ep(ie(o))}var Qb=Pt;function Wn(o,u,_){var D=o.length;return _=_===e?D:_,!u&&_>=D?o:$r(o,u,_)}var F0=qD||function(o){return Ze.clearTimeout(o)};function M0(o,u){if(u)return o.slice();var _=o.length,D=Gh?Gh(_):new o.constructor(_);return o.copy(D),D}function Xu(o){var u=new o.constructor(o.byteLength);return new Bo(u).set(new Bo(o)),u}function tE(o,u){var _=u?Xu(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.byteLength)}function eE(o){var u=new o.constructor(o.source,wo.exec(o));return u.lastIndex=o.lastIndex,u}function rE(o){return hs?he(hs.call(o)):{}}function N0(o,u){var _=u?Xu(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.length)}function S0(o,u){if(o!==u){var _=o!==e,D=o===null,A=o===o,T=br(o),P=u!==e,q=u===null,Y=u===u,tt=br(u);if(!q&&!tt&&!T&&o>u||T&&P&&Y&&!q&&!tt||D&&P&&Y||!_&&Y||!A)return 1;if(!D&&!T&&!tt&&o<u||tt&&_&&A&&!D&&!T||q&&_&&A||!P&&A||!Y)return-1}return 0}function nE(o,u,_){for(var D=-1,A=o.criteria,T=u.criteria,P=A.length,q=_.length;++D<P;){var Y=S0(A[D],T[D]);if(Y){if(D>=q)return Y;var tt=_[D];return Y*(tt=="desc"?-1:1)}}return o.index-u.index}function B0(o,u,_,D){for(var A=-1,T=o.length,P=_.length,q=-1,Y=u.length,tt=qe(T-P,0),et=H(Y+tt),ot=!D;++q<Y;)et[q]=u[q];for(;++A<P;)(ot||A<T)&&(et[_[A]]=o[A]);for(;tt--;)et[q++]=o[A++];return et}function O0(o,u,_,D){for(var A=-1,T=o.length,P=-1,q=_.length,Y=-1,tt=u.length,et=qe(T-q,0),ot=H(et+tt),dt=!D;++A<et;)ot[A]=o[A];for(var yt=A;++Y<tt;)ot[yt+Y]=u[Y];for(;++P<q;)(dt||A<T)&&(ot[yt+_[P]]=o[A++]);return ot}function ur(o,u){var _=-1,D=o.length;for(u||(u=H(D));++_<D;)u[_]=o[_];return u}function nn(o,u,_,D){var A=!_;_||(_={});for(var T=-1,P=u.length;++T<P;){var q=u[T],Y=D?D(_[q],o[q],q,_,o):e;Y===e&&(Y=o[q]),A?gn(_,q,Y):ps(_,q,Y)}return _}function iE(o,u){return nn(o,sl(o),u)}function sE(o,u){return nn(o,Y0(o),u)}function Vo(o,u){return function(_,D){var A=It(_)?cD:Fb,T=u?u():{};return A(_,o,At(D,2),T)}}function ki(o){return Pt(function(u,_){var D=-1,A=_.length,T=A>1?_[A-1]:e,P=A>2?_[2]:e;for(T=o.length>3&&typeof T=="function"?(A--,T):e,P&&nr(_[0],_[1],P)&&(T=A<3?e:T,A=1),u=he(u);++D<A;){var q=_[D];q&&o(u,q,D,T)}return u})}function T0(o,u){return function(_,D){if(_==null)return _;if(!lr(_))return o(_,D);for(var A=_.length,T=u?A:-1,P=he(_);(u?T--:++T<A)&&D(P[T],T,P)!==!1;);return _}}function I0(o){return function(u,_,D){for(var A=-1,T=he(u),P=D(u),q=P.length;q--;){var Y=P[o?q:++A];if(_(T[Y],Y,T)===!1)break}return u}}function oE(o,u,_){var D=u&w,A=vs(o);function T(){var P=this&&this!==Ze&&this instanceof T?A:o;return P.apply(D?_:this,arguments)}return T}function $0(o){return function(u){u=ie(u);var _=Ii(u)?Vr(u):e,D=_?_[0]:u.charAt(0),A=_?Wn(_,1).join(""):u.slice(1);return D[o]()+A}}function Ui(o){return function(u){return Eu(Tp(Op(u).replace(Hw,"")),o,"")}}function vs(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 _=qi(o.prototype),D=o.apply(_,u);return Ae(D)?D:_}}function aE(o,u,_){var D=vs(o);function A(){for(var T=arguments.length,P=H(T),q=T,Y=Wi(A);q--;)P[q]=arguments[q];var tt=T<3&&P[0]!==Y&&P[T-1]!==Y?[]:Pn(P,Y);if(T-=tt.length,T<_)return q0(o,u,Zo,A.placeholder,e,P,tt,e,e,_-T);var et=this&&this!==Ze&&this instanceof A?D:o;return yr(et,this,P)}return A}function L0(o){return function(u,_,D){var A=he(u);if(!lr(u)){var T=At(_,3);u=Ue(u),_=function(q){return T(A[q],q,A)}}var P=o(u,_,D);return P>-1?A[T?u[P]:P]:e}}function R0(o){return yn(function(u){var _=u.length,D=_,A=Tr.prototype.thru;for(o&&u.reverse();D--;){var T=u[D];if(typeof T!="function")throw new Or(a);if(A&&!P&&Jo(T)=="wrapper")var P=new Tr([],!0)}for(D=P?D:_;++D<_;){T=u[D];var q=Jo(T),Y=q=="wrapper"?nl(T):e;Y&&al(Y[0])&&Y[1]==(M|b|x|S)&&!Y[4].length&&Y[9]==1?P=P[Jo(Y[0])].apply(P,Y[3]):P=T.length==1&&al(T)?P[q]():P.thru(T)}return function(){var tt=arguments,et=tt[0];if(P&&tt.length==1&&It(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,A,T,P,q,Y,tt){var et=u&M,ot=u&w,dt=u&v,yt=u&(b|N),Ct=u&I,Rt=dt?e:vs(o);function Ft(){for(var Ut=arguments.length,Yt=H(Ut),Er=Ut;Er--;)Yt[Er]=arguments[Er];if(yt)var ir=Wi(Ft),xr=yD(Yt,ir);if(D&&(Yt=B0(Yt,D,A,yt)),T&&(Yt=O0(Yt,T,P,yt)),Ut-=xr,yt&&Ut<tt){var Se=Pn(Yt,ir);return q0(o,u,Zo,Ft.placeholder,_,Yt,Se,q,Y,tt-Ut)}var Gr=ot?_:this,En=dt?Gr[o]:o;return Ut=Yt.length,q?Yt=FE(Yt,q):Ct&&Ut>1&&Yt.reverse(),et&&Y<Ut&&(Yt.length=Y),this&&this!==Ze&&this instanceof Ft&&(En=Rt||vs(En)),En.apply(Gr,Yt)}return Ft}function P0(o,u){return function(_,D){return $b(_,o,u(D),{})}}function Ko(o,u){return function(_,D){var A;if(_===e&&D===e)return u;if(_!==e&&(A=_),D!==e){if(A===e)return D;typeof _=="string"||typeof D=="string"?(_=Dr(_),D=Dr(D)):(_=E0(_),D=E0(D)),A=o(_,D)}return A}}function Qu(o){return yn(function(u){return u=be(u,wr(At())),Pt(function(_){var D=this;return o(u,function(A){return yr(A,D,_)})})})}function Go(o,u){u=u===e?" ":Dr(u);var _=u.length;if(_<2)return _?Vu(u,o):u;var D=Vu(u,$o(o/$i(u)));return Ii(u)?Wn(Vr(D),0,o).join(""):D.slice(0,o)}function uE(o,u,_,D){var A=u&w,T=vs(o);function P(){for(var q=-1,Y=arguments.length,tt=-1,et=D.length,ot=H(et+Y),dt=this&&this!==Ze&&this instanceof P?T:o;++tt<et;)ot[tt]=D[tt];for(;Y--;)ot[tt++]=arguments[++q];return yr(dt,A?_:this,ot)}return P}function z0(o){return function(u,_,D){return D&&typeof D!="number"&&nr(u,_,D)&&(_=D=e),u=bn(u),_===e?(_=u,u=0):_=bn(_),D=D===e?u<_?1:-1:bn(D),Zb(u,_,D,o)}}function Ho(o){return function(u,_){return typeof u=="string"&&typeof _=="string"||(u=Rr(u),_=Rr(_)),o(u,_)}}function q0(o,u,_,D,A,T,P,q,Y,tt){var et=u&b,ot=et?P:e,dt=et?e:P,yt=et?T:e,Ct=et?e:T;u|=et?x:F,u&=~(et?F:x),u&E||(u&=~(w|v));var Rt=[o,u,A,yt,ot,Ct,dt,q,Y,tt],Ft=_.apply(e,Rt);return al(o)&&X0(Ft,Rt),Ft.placeholder=D,Q0(Ft,o,u)}function tl(o){var u=ze[o];return function(_,D){if(_=Rr(_),D=D==null?0:Xe(Lt(D),292),D&&Qh(_)){var A=(ie(_)+"e").split("e"),T=u(A[0]+"e"+(+A[1]+D));return A=(ie(T)+"e").split("e"),+(A[0]+"e"+(+A[1]-D))}return u(_)}}var lE=Pi&&1/Ao(new Pi([,-0]))[1]==K?function(o){return new Pi(o)}:bl;function k0(o){return function(u){var _=Qe(u);return _==Jt?Su(u):_==mr?CD(u):vD(u,o(u))}}function vn(o,u,_,D,A,T,P,q){var Y=u&v;if(!Y&&typeof o!="function")throw new Or(a);var tt=D?D.length:0;if(tt||(u&=~(x|F),D=A=e),P=P===e?P:qe(Lt(P),0),q=q===e?q:Lt(q),tt-=A?A.length:0,u&F){var et=D,ot=A;D=A=e}var dt=Y?e:nl(o),yt=[o,u,_,D,A,et,ot,T,P,q];if(dt&&xE(yt,dt),o=yt[0],u=yt[1],_=yt[2],D=yt[3],A=yt[4],q=yt[9]=yt[9]===e?Y?0:o.length:qe(yt[9]-tt,0),!q&&u&(b|N)&&(u&=~(b|N)),!u||u==w)var Ct=oE(o,u,_);else u==b||u==N?Ct=aE(o,u,q):(u==x||u==(w|x))&&!A.length?Ct=uE(o,u,_,D):Ct=Zo.apply(e,yt);var Rt=dt?D0:X0;return Q0(Rt(Ct,yt),o,u)}function U0(o,u,_,D){return o===e||Kr(o,Ri[_])&&!ae.call(D,_)?u:o}function W0(o,u,_,D,A,T){return Ae(o)&&Ae(u)&&(T.set(u,o),Wo(o,u,e,W0,T),T.delete(u)),o}function cE(o){return Ds(o)?e:o}function j0(o,u,_,D,A,T){var P=_&y,q=o.length,Y=u.length;if(q!=Y&&!(P&&Y>q))return!1;var tt=T.get(o),et=T.get(u);if(tt&&et)return tt==u&&et==o;var ot=-1,dt=!0,yt=_&m?new si:e;for(T.set(o,u),T.set(u,o);++ot<q;){var Ct=o[ot],Rt=u[ot];if(D)var Ft=P?D(Rt,Ct,ot,u,o,T):D(Ct,Rt,ot,o,u,T);if(Ft!==e){if(Ft)continue;dt=!1;break}if(yt){if(!xu(u,function(Ut,Yt){if(!as(yt,Yt)&&(Ct===Ut||A(Ct,Ut,_,D,T)))return yt.push(Yt)})){dt=!1;break}}else if(!(Ct===Rt||A(Ct,Rt,_,D,T))){dt=!1;break}}return T.delete(o),T.delete(u),dt}function fE(o,u,_,D,A,T,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||!T(new Bo(o),new Bo(u)));case oe:case Tt:case Ie:return Kr(+o,+u);case le:return o.name==u.name&&o.message==u.message;case dn:case Tn:return o==u+"";case Jt:var q=Su;case mr:var Y=D&y;if(q||(q=Ao),o.size!=u.size&&!Y)return!1;var tt=P.get(o);if(tt)return tt==u;D|=m,P.set(o,u);var et=j0(q(o),q(u),D,A,T,P);return P.delete(o),et;case $:if(hs)return hs.call(o)==hs.call(u)}return!1}function hE(o,u,_,D,A,T){var P=_&y,q=el(o),Y=q.length,tt=el(u),et=tt.length;if(Y!=et&&!P)return!1;for(var ot=Y;ot--;){var dt=q[ot];if(!(P?dt in u:ae.call(u,dt)))return!1}var yt=T.get(o),Ct=T.get(u);if(yt&&Ct)return yt==u&&Ct==o;var Rt=!0;T.set(o,u),T.set(u,o);for(var Ft=P;++ot<Y;){dt=q[ot];var Ut=o[dt],Yt=u[dt];if(D)var Er=P?D(Yt,Ut,dt,u,o,T):D(Ut,Yt,dt,o,u,T);if(!(Er===e?Ut===Yt||A(Ut,Yt,_,D,T):Er)){Rt=!1;break}Ft||(Ft=dt=="constructor")}if(Rt&&!Ft){var ir=o.constructor,xr=u.constructor;ir!=xr&&"constructor"in o&&"constructor"in u&&!(typeof ir=="function"&&ir instanceof ir&&typeof xr=="function"&&xr instanceof xr)&&(Rt=!1)}return T.delete(o),T.delete(u),Rt}function yn(o){return ll(H0(o,e,sp),o+"")}function el(o){return c0(o,Ue,sl)}function rl(o){return c0(o,cr,Y0)}var nl=Ro?function(o){return Ro.get(o)}:bl;function Jo(o){for(var u=o.name+"",_=zi[u],D=ae.call(zi,u)?_.length:0;D--;){var A=_[D],T=A.func;if(T==null||T==o)return A.name}return u}function Wi(o){var u=ae.call(O,"placeholder")?O:o;return u.placeholder}function At(){var o=O.iteratee||wl;return o=o===wl?p0:o,arguments.length?o(arguments[0],arguments[1]):o}function Xo(o,u){var _=o.__data__;return wE(u)?_[typeof u=="string"?"string":"hash"]:_.map}function il(o){for(var u=Ue(o),_=u.length;_--;){var D=u[_],A=o[D];u[_]=[D,A,K0(A)]}return u}function ui(o,u){var _=ED(o,u);return h0(_)?_:e}function pE(o){var u=ae.call(o,ni),_=o[ni];try{o[ni]=e;var D=!0}catch{}var A=No.call(o);return D&&(u?o[ni]=_:delete o[ni]),A}var sl=Ou?function(o){return o==null?[]:(o=he(o),Ln(Ou(o),function(u){return Jh.call(o,u)}))}:El,Y0=Ou?function(o){for(var u=[];o;)Rn(u,sl(o)),o=Oo(o);return u}:El,Qe=rr;(Tu&&Qe(new Tu(new ArrayBuffer(1)))!=rt||ls&&Qe(new ls)!=Jt||Iu&&Qe(Iu.resolve())!=pn||Pi&&Qe(new Pi)!=mr||cs&&Qe(new cs)!=G)&&(Qe=function(o){var u=rr(o),_=u==Re?o.constructor:e,D=_?li(_):"";if(D)switch(D){case GD:return rt;case HD:return Jt;case JD:return pn;case XD:return mr;case QD:return G}return u});function dE(o,u,_){for(var D=-1,A=_.length;++D<A;){var T=_[D],P=T.size;switch(T.type){case"drop":o+=P;break;case"dropRight":u-=P;break;case"take":u=Xe(u,o+P);break;case"takeRight":o=qe(o,u-P);break}}return{start:o,end:u}}function _E(o){var u=o.match(ru);return u?u[1].split(nu):[]}function V0(o,u,_){u=Un(u,o);for(var D=-1,A=u.length,T=!1;++D<A;){var P=sn(u[D]);if(!(T=o!=null&&_(o,P)))break;o=o[P]}return T||++D!=A?T:(A=o==null?0:o.length,!!A&&sa(A)&&wn(P,A)&&(It(o)||ci(o)))}function mE(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 Z0(o){return typeof o.constructor=="function"&&!ys(o)?qi(Oo(o)):{}}function gE(o,u,_){var D=o.constructor;switch(u){case st:return Xu(o);case oe:case Tt:return new D(+o);case rt:return tE(o,_);case ft:case ut:case ht:case at:case Xt:case ne:case De:case ke:case Pe:return N0(o,_);case Jt:return new D;case Ie:case Tn:return new D(o);case dn:return eE(o);case mr:return new D;case $:return rE(o)}}function vE(o,u){var _=u.length;if(!_)return o;var D=_-1;return u[D]=(_>1?"& ":"")+u[D],u=u.join(_>2?", ":" "),o.replace(eu,`{
|
9
|
-
/* [wrapped with `+u+`] */
|
10
|
-
`)}function yE(o){return It(o)||ci(o)||!!(Xh&&o&&o[Xh])}function wn(o,u){var _=typeof o;return u=u??Z,!!u&&(_=="number"||_!="symbol"&&hu.test(o))&&o>-1&&o%1==0&&o<u}function nr(o,u,_){if(!Ae(_))return!1;var D=typeof u;return(D=="number"?lr(_)&&wn(u,_.length):D=="string"&&u in _)?Kr(_[u],o):!1}function ol(o,u){if(It(o))return!1;var _=typeof o;return _=="number"||_=="symbol"||_=="boolean"||o==null||br(o)?!0:Ja.test(o)||!Ha.test(o)||u!=null&&o in he(u)}function wE(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function al(o){var u=Jo(o),_=O[u];if(typeof _!="function"||!(u in jt.prototype))return!1;if(o===_)return!0;var D=nl(_);return!!D&&o===D[0]}function DE(o){return!!Kh&&Kh in o}var bE=Fo?Dn:xl;function ys(o){var u=o&&o.constructor,_=typeof u=="function"&&u.prototype||Ri;return o===_}function K0(o){return o===o&&!Ae(o)}function G0(o,u){return function(_){return _==null?!1:_[o]===u&&(u!==e||o in he(_))}}function EE(o){var u=na(o,function(D){return _.size===p&&_.clear(),D}),_=u.cache;return u}function xE(o,u){var _=o[1],D=u[1],A=_|D,T=A<(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(!(T||P))return o;D&w&&(o[2]=u[2],A|=_&w?0:E);var q=u[3];if(q){var Y=o[3];o[3]=Y?B0(Y,q,u[4]):q,o[4]=Y?Pn(o[3],h):u[4]}return q=u[5],q&&(Y=o[5],o[5]=Y?O0(Y,q,u[6]):q,o[6]=Y?Pn(o[5],h):u[6]),q=u[7],q&&(o[7]=q),D&M&&(o[8]=o[8]==null?u[8]:Xe(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=A,o}function AE(o){var u=[];if(o!=null)for(var _ in he(o))u.push(_);return u}function CE(o){return No.call(o)}function H0(o,u,_){return u=qe(u===e?o.length-1:u,0),function(){for(var D=arguments,A=-1,T=qe(D.length-u,0),P=H(T);++A<T;)P[A]=D[u+A];A=-1;for(var q=H(u+1);++A<u;)q[A]=D[A];return q[u]=_(P),yr(o,this,q)}}function J0(o,u){return u.length<2?o:ai(o,$r(u,0,-1))}function FE(o,u){for(var _=o.length,D=Xe(u.length,_),A=ur(o);D--;){var T=u[D];o[D]=wn(T,_)?A[T]:e}return o}function ul(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var X0=tp(D0),ws=UD||function(o,u){return Ze.setTimeout(o,u)},ll=tp(Hb);function Q0(o,u,_){var D=u+"";return ll(o,vE(D,ME(_E(D),_)))}function tp(o){var u=0,_=0;return function(){var D=VD(),A=U-(D-_);if(_=D,A>0){if(++u>=L)return arguments[0]}else u=0;return o.apply(e,arguments)}}function Qo(o,u){var _=-1,D=o.length,A=D-1;for(u=u===e?D:u;++_<u;){var T=Yu(_,A),P=o[T];o[T]=o[_],o[_]=P}return o.length=u,o}var ep=EE(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(Xa,function(_,D,A,T){u.push(A?T.replace(ou,"$1"):D||_)}),u});function sn(o){if(typeof o=="string"||br(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 ME(o,u){return Br(wt,function(_){var D="_."+_[0];u&_[1]&&!Eo(o,D)&&o.push(D)}),o.sort()}function rp(o){if(o instanceof jt)return o.clone();var u=new Tr(o.__wrapped__,o.__chain__);return u.__actions__=ur(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function NE(o,u,_){(_?nr(o,u,_):u===e)?u=1:u=qe(Lt(u),0);var D=o==null?0:o.length;if(!D||u<1)return[];for(var A=0,T=0,P=H($o(D/u));A<D;)P[T++]=$r(o,A,A+=u);return P}function SE(o){for(var u=-1,_=o==null?0:o.length,D=0,A=[];++u<_;){var T=o[u];T&&(A[D++]=T)}return A}function BE(){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(It(_)?ur(_):[_],Ke(u,1))}var OE=Pt(function(o,u){return Ne(o)?ds(o,Ke(u,1,Ne,!0)):[]}),TE=Pt(function(o,u){var _=Lr(u);return Ne(_)&&(_=e),Ne(o)?ds(o,Ke(u,1,Ne,!0),At(_,2)):[]}),IE=Pt(function(o,u){var _=Lr(u);return Ne(_)&&(_=e),Ne(o)?ds(o,Ke(u,1,Ne,!0),e,_):[]});function $E(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),$r(o,u<0?0:u,D)):[]}function LE(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,$r(o,0,u<0?0:u)):[]}function RE(o,u){return o&&o.length?Yo(o,At(u,3),!0,!0):[]}function PE(o,u){return o&&o.length?Yo(o,At(u,3),!0):[]}function zE(o,u,_,D){var A=o==null?0:o.length;return A?(_&&typeof _!="number"&&nr(o,u,_)&&(_=0,D=A),Bb(o,u,_,D)):[]}function np(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=_==null?0:Lt(_);return A<0&&(A=qe(D+A,0)),xo(o,At(u,3),A)}function ip(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=D-1;return _!==e&&(A=Lt(_),A=_<0?qe(D+A,0):Xe(A,D-1)),xo(o,At(u,3),A,!0)}function sp(o){var u=o==null?0:o.length;return u?Ke(o,1):[]}function qE(o){var u=o==null?0:o.length;return u?Ke(o,K):[]}function kE(o,u){var _=o==null?0:o.length;return _?(u=u===e?1:Lt(u),Ke(o,u)):[]}function UE(o){for(var u=-1,_=o==null?0:o.length,D={};++u<_;){var A=o[u];D[A[0]]=A[1]}return D}function op(o){return o&&o.length?o[0]:e}function WE(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=_==null?0:Lt(_);return A<0&&(A=qe(D+A,0)),Ti(o,u,A)}function jE(o){var u=o==null?0:o.length;return u?$r(o,0,-1):[]}var YE=Pt(function(o){var u=be(o,Hu);return u.length&&u[0]===o[0]?qu(u):[]}),VE=Pt(function(o){var u=Lr(o),_=be(o,Hu);return u===Lr(_)?u=e:_.pop(),_.length&&_[0]===o[0]?qu(_,At(u,2)):[]}),ZE=Pt(function(o){var u=Lr(o),_=be(o,Hu);return u=typeof u=="function"?u:e,u&&_.pop(),_.length&&_[0]===o[0]?qu(_,e,u):[]});function KE(o,u){return o==null?"":jD.call(o,u)}function Lr(o){var u=o==null?0:o.length;return u?o[u-1]:e}function GE(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=D;return _!==e&&(A=Lt(_),A=A<0?qe(D+A,0):Xe(A,D-1)),u===u?MD(o,u,A):xo(o,qh,A,!0)}function HE(o,u){return o&&o.length?g0(o,Lt(u)):e}var JE=Pt(ap);function ap(o,u){return o&&o.length&&u&&u.length?ju(o,u):o}function XE(o,u,_){return o&&o.length&&u&&u.length?ju(o,u,At(_,2)):o}function QE(o,u,_){return o&&o.length&&u&&u.length?ju(o,u,e,_):o}var tx=yn(function(o,u){var _=o==null?0:o.length,D=Lu(o,u);return w0(o,be(u,function(A){return wn(A,_)?+A:A}).sort(S0)),D});function ex(o,u){var _=[];if(!(o&&o.length))return _;var D=-1,A=[],T=o.length;for(u=At(u,3);++D<T;){var P=o[D];u(P,D,o)&&(_.push(P),A.push(D))}return w0(o,A),_}function cl(o){return o==null?o:KD.call(o)}function rx(o,u,_){var D=o==null?0:o.length;return D?(_&&typeof _!="number"&&nr(o,u,_)?(u=0,_=D):(u=u==null?0:Lt(u),_=_===e?D:Lt(_)),$r(o,u,_)):[]}function nx(o,u){return jo(o,u)}function ix(o,u,_){return Zu(o,u,At(_,2))}function sx(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u);if(D<_&&Kr(o[D],u))return D}return-1}function ox(o,u){return jo(o,u,!0)}function ax(o,u,_){return Zu(o,u,At(_,2),!0)}function ux(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u,!0)-1;if(Kr(o[D],u))return D}return-1}function lx(o){return o&&o.length?b0(o):[]}function cx(o,u){return o&&o.length?b0(o,At(u,2)):[]}function fx(o){var u=o==null?0:o.length;return u?$r(o,1,u):[]}function hx(o,u,_){return o&&o.length?(u=_||u===e?1:Lt(u),$r(o,0,u<0?0:u)):[]}function px(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,$r(o,u<0?0:u,D)):[]}function dx(o,u){return o&&o.length?Yo(o,At(u,3),!1,!0):[]}function _x(o,u){return o&&o.length?Yo(o,At(u,3)):[]}var mx=Pt(function(o){return kn(Ke(o,1,Ne,!0))}),gx=Pt(function(o){var u=Lr(o);return Ne(u)&&(u=e),kn(Ke(o,1,Ne,!0),At(u,2))}),vx=Pt(function(o){var u=Lr(o);return u=typeof u=="function"?u:e,kn(Ke(o,1,Ne,!0),e,u)});function yx(o){return o&&o.length?kn(o):[]}function wx(o,u){return o&&o.length?kn(o,At(u,2)):[]}function Dx(o,u){return u=typeof u=="function"?u:e,o&&o.length?kn(o,e,u):[]}function fl(o){if(!(o&&o.length))return[];var u=0;return o=Ln(o,function(_){if(Ne(_))return u=qe(_.length,u),!0}),Mu(u,function(_){return be(o,Au(_))})}function up(o,u){if(!(o&&o.length))return[];var _=fl(o);return u==null?_:be(_,function(D){return yr(u,e,D)})}var bx=Pt(function(o,u){return Ne(o)?ds(o,u):[]}),Ex=Pt(function(o){return Gu(Ln(o,Ne))}),xx=Pt(function(o){var u=Lr(o);return Ne(u)&&(u=e),Gu(Ln(o,Ne),At(u,2))}),Ax=Pt(function(o){var u=Lr(o);return u=typeof u=="function"?u:e,Gu(Ln(o,Ne),e,u)}),Cx=Pt(fl);function Fx(o,u){return C0(o||[],u||[],ps)}function Mx(o,u){return C0(o||[],u||[],gs)}var Nx=Pt(function(o){var u=o.length,_=u>1?o[u-1]:e;return _=typeof _=="function"?(o.pop(),_):e,up(o,_)});function lp(o){var u=O(o);return u.__chain__=!0,u}function Sx(o,u){return u(o),o}function ta(o,u){return u(o)}var Bx=yn(function(o){var u=o.length,_=u?o[0]:0,D=this.__wrapped__,A=function(T){return Lu(T,o)};return u>1||this.__actions__.length||!(D instanceof jt)||!wn(_)?this.thru(A):(D=D.slice(_,+_+(u?1:0)),D.__actions__.push({func:ta,args:[A],thisArg:e}),new Tr(D,this.__chain__).thru(function(T){return u&&!T.length&&T.push(e),T}))});function Ox(){return lp(this)}function Tx(){return new Tr(this.value(),this.__chain__)}function Ix(){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 $x(){return this}function Lx(o){for(var u,_=this;_ instanceof zo;){var D=rp(_);D.__index__=0,D.__values__=e,u?A.__wrapped__=D:u=D;var A=D;_=_.__wrapped__}return A.__wrapped__=o,u}function Rx(){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:[cl],thisArg:e}),new Tr(u,this.__chain__)}return this.thru(cl)}function Px(){return A0(this.__wrapped__,this.__actions__)}var zx=Vo(function(o,u,_){ae.call(o,_)?++o[_]:gn(o,_,1)});function qx(o,u,_){var D=It(o)?Ph:Sb;return _&&nr(o,u,_)&&(u=e),D(o,At(u,3))}function kx(o,u){var _=It(o)?Ln:u0;return _(o,At(u,3))}var Ux=L0(np),Wx=L0(ip);function jx(o,u){return Ke(ea(o,u),1)}function Yx(o,u){return Ke(ea(o,u),K)}function Vx(o,u,_){return _=_===e?1:Lt(_),Ke(ea(o,u),_)}function cp(o,u){var _=It(o)?Br:qn;return _(o,At(u,3))}function fp(o,u){var _=It(o)?fD:a0;return _(o,At(u,3))}var Zx=Vo(function(o,u,_){ae.call(o,_)?o[_].push(u):gn(o,_,[u])});function Kx(o,u,_,D){o=lr(o)?o:Yi(o),_=_&&!D?Lt(_):0;var A=o.length;return _<0&&(_=qe(A+_,0)),oa(o)?_<=A&&o.indexOf(u,_)>-1:!!A&&Ti(o,u,_)>-1}var Gx=Pt(function(o,u,_){var D=-1,A=typeof u=="function",T=lr(o)?H(o.length):[];return qn(o,function(P){T[++D]=A?yr(u,P,_):_s(P,u,_)}),T}),Hx=Vo(function(o,u,_){gn(o,_,u)});function ea(o,u){var _=It(o)?be:d0;return _(o,At(u,3))}function Jx(o,u,_,D){return o==null?[]:(It(u)||(u=u==null?[]:[u]),_=D?e:_,It(_)||(_=_==null?[]:[_]),v0(o,u,_))}var Xx=Vo(function(o,u,_){o[_?0:1].push(u)},function(){return[[],[]]});function Qx(o,u,_){var D=It(o)?Eu:Uh,A=arguments.length<3;return D(o,At(u,4),_,A,qn)}function tA(o,u,_){var D=It(o)?hD:Uh,A=arguments.length<3;return D(o,At(u,4),_,A,a0)}function eA(o,u){var _=It(o)?Ln:u0;return _(o,ia(At(u,3)))}function rA(o){var u=It(o)?n0:Kb;return u(o)}function nA(o,u,_){(_?nr(o,u,_):u===e)?u=1:u=Lt(u);var D=It(o)?Ab:Gb;return D(o,u)}function iA(o){var u=It(o)?Cb:Jb;return u(o)}function sA(o){if(o==null)return 0;if(lr(o))return oa(o)?$i(o):o.length;var u=Qe(o);return u==Jt||u==mr?o.size:Uu(o).length}function oA(o,u,_){var D=It(o)?xu:Xb;return _&&nr(o,u,_)&&(u=e),D(o,At(u,3))}var aA=Pt(function(o,u){if(o==null)return[];var _=u.length;return _>1&&nr(o,u[0],u[1])?u=[]:_>2&&nr(u[0],u[1],u[2])&&(u=[u[0]]),v0(o,Ke(u,1),[])}),ra=kD||function(){return Ze.Date.now()};function uA(o,u){if(typeof u!="function")throw new Or(a);return o=Lt(o),function(){if(--o<1)return u.apply(this,arguments)}}function hp(o,u,_){return u=_?e:u,u=o&&u==null?o.length:u,vn(o,M,e,e,e,e,u)}function pp(o,u){var _;if(typeof u!="function")throw new Or(a);return o=Lt(o),function(){return--o>0&&(_=u.apply(this,arguments)),o<=1&&(u=e),_}}var hl=Pt(function(o,u,_){var D=w;if(_.length){var A=Pn(_,Wi(hl));D|=x}return vn(o,D,u,_,A)}),dp=Pt(function(o,u,_){var D=w|v;if(_.length){var A=Pn(_,Wi(dp));D|=x}return vn(u,D,o,_,A)});function _p(o,u,_){u=_?e:u;var D=vn(o,b,e,e,e,e,e,u);return D.placeholder=_p.placeholder,D}function mp(o,u,_){u=_?e:u;var D=vn(o,N,e,e,e,e,e,u);return D.placeholder=mp.placeholder,D}function gp(o,u,_){var D,A,T,P,q,Y,tt=0,et=!1,ot=!1,dt=!0;if(typeof o!="function")throw new Or(a);u=Rr(u)||0,Ae(_)&&(et=!!_.leading,ot="maxWait"in _,T=ot?qe(Rr(_.maxWait)||0,u):T,dt="trailing"in _?!!_.trailing:dt);function yt(Se){var Gr=D,En=A;return D=A=e,tt=Se,P=o.apply(En,Gr),P}function Ct(Se){return tt=Se,q=ws(Ut,u),et?yt(Se):P}function Rt(Se){var Gr=Se-Y,En=Se-tt,Lp=u-Gr;return ot?Xe(Lp,T-En):Lp}function Ft(Se){var Gr=Se-Y,En=Se-tt;return Y===e||Gr>=u||Gr<0||ot&&En>=T}function Ut(){var Se=ra();if(Ft(Se))return Yt(Se);q=ws(Ut,Rt(Se))}function Yt(Se){return q=e,dt&&D?yt(Se):(D=A=e,P)}function Er(){q!==e&&F0(q),tt=0,D=Y=A=q=e}function ir(){return q===e?P:Yt(ra())}function xr(){var Se=ra(),Gr=Ft(Se);if(D=arguments,A=this,Y=Se,Gr){if(q===e)return Ct(Y);if(ot)return F0(q),q=ws(Ut,u),yt(Y)}return q===e&&(q=ws(Ut,u)),P}return xr.cancel=Er,xr.flush=ir,xr}var lA=Pt(function(o,u){return o0(o,1,u)}),cA=Pt(function(o,u,_){return o0(o,Rr(u)||0,_)});function fA(o){return vn(o,I)}function na(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new Or(a);var _=function(){var D=arguments,A=u?u.apply(this,D):D[0],T=_.cache;if(T.has(A))return T.get(A);var P=o.apply(this,D);return _.cache=T.set(A,P)||T,P};return _.cache=new(na.Cache||mn),_}na.Cache=mn;function ia(o){if(typeof o!="function")throw new Or(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 hA(o){return pp(2,o)}var pA=Qb(function(o,u){u=u.length==1&&It(u[0])?be(u[0],wr(At())):be(Ke(u,1),wr(At()));var _=u.length;return Pt(function(D){for(var A=-1,T=Xe(D.length,_);++A<T;)D[A]=u[A].call(this,D[A]);return yr(o,this,D)})}),pl=Pt(function(o,u){var _=Pn(u,Wi(pl));return vn(o,x,e,u,_)}),vp=Pt(function(o,u){var _=Pn(u,Wi(vp));return vn(o,F,e,u,_)}),dA=yn(function(o,u){return vn(o,S,e,e,e,u)});function _A(o,u){if(typeof o!="function")throw new Or(a);return u=u===e?u:Lt(u),Pt(o,u)}function mA(o,u){if(typeof o!="function")throw new Or(a);return u=u==null?0:qe(Lt(u),0),Pt(function(_){var D=_[u],A=Wn(_,0,u);return D&&Rn(A,D),yr(o,this,A)})}function gA(o,u,_){var D=!0,A=!0;if(typeof o!="function")throw new Or(a);return Ae(_)&&(D="leading"in _?!!_.leading:D,A="trailing"in _?!!_.trailing:A),gp(o,u,{leading:D,maxWait:u,trailing:A})}function vA(o){return hp(o,1)}function yA(o,u){return pl(Ju(u),o)}function wA(){if(!arguments.length)return[];var o=arguments[0];return It(o)?o:[o]}function DA(o){return Ir(o,g)}function bA(o,u){return u=typeof u=="function"?u:e,Ir(o,g,u)}function EA(o){return Ir(o,f|g)}function xA(o,u){return u=typeof u=="function"?u:e,Ir(o,f|g,u)}function AA(o,u){return u==null||s0(o,u,Ue(u))}function Kr(o,u){return o===u||o!==o&&u!==u}var CA=Ho(zu),FA=Ho(function(o,u){return o>=u}),ci=f0(function(){return arguments}())?f0:function(o){return Ce(o)&&ae.call(o,"callee")&&!Jh.call(o,"callee")},It=H.isArray,MA=Oh?wr(Oh):Lb;function lr(o){return o!=null&&sa(o.length)&&!Dn(o)}function Ne(o){return Ce(o)&&lr(o)}function NA(o){return o===!0||o===!1||Ce(o)&&rr(o)==oe}var jn=WD||xl,SA=Th?wr(Th):Rb;function BA(o){return Ce(o)&&o.nodeType===1&&!Ds(o)}function OA(o){if(o==null)return!0;if(lr(o)&&(It(o)||typeof o=="string"||typeof o.splice=="function"||jn(o)||ji(o)||ci(o)))return!o.length;var u=Qe(o);if(u==Jt||u==mr)return!o.size;if(ys(o))return!Uu(o).length;for(var _ in o)if(ae.call(o,_))return!1;return!0}function TA(o,u){return ms(o,u)}function IA(o,u,_){_=typeof _=="function"?_:e;var D=_?_(o,u):e;return D===e?ms(o,u,e,_):!!D}function dl(o){if(!Ce(o))return!1;var u=rr(o);return u==le||u==Nt||typeof o.message=="string"&&typeof o.name=="string"&&!Ds(o)}function $A(o){return typeof o=="number"&&Qh(o)}function Dn(o){if(!Ae(o))return!1;var u=rr(o);return u==re||u==kt||u==Et||u==On}function yp(o){return typeof o=="number"&&o==Lt(o)}function sa(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Z}function Ae(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function Ce(o){return o!=null&&typeof o=="object"}var wp=Ih?wr(Ih):zb;function LA(o,u){return o===u||ku(o,u,il(u))}function RA(o,u,_){return _=typeof _=="function"?_:e,ku(o,u,il(u),_)}function PA(o){return Dp(o)&&o!=+o}function zA(o){if(bE(o))throw new Ot(i);return h0(o)}function qA(o){return o===null}function kA(o){return o==null}function Dp(o){return typeof o=="number"||Ce(o)&&rr(o)==Ie}function Ds(o){if(!Ce(o)||rr(o)!=Re)return!1;var u=Oo(o);if(u===null)return!0;var _=ae.call(u,"constructor")&&u.constructor;return typeof _=="function"&&_ instanceof _&&Mo.call(_)==RD}var _l=$h?wr($h):qb;function UA(o){return yp(o)&&o>=-Z&&o<=Z}var bp=Lh?wr(Lh):kb;function oa(o){return typeof o=="string"||!It(o)&&Ce(o)&&rr(o)==Tn}function br(o){return typeof o=="symbol"||Ce(o)&&rr(o)==$}var ji=Rh?wr(Rh):Ub;function WA(o){return o===e}function jA(o){return Ce(o)&&Qe(o)==G}function YA(o){return Ce(o)&&rr(o)==nt}var VA=Ho(Wu),ZA=Ho(function(o,u){return o<=u});function Ep(o){if(!o)return[];if(lr(o))return oa(o)?Vr(o):ur(o);if(us&&o[us])return AD(o[us]());var u=Qe(o),_=u==Jt?Su:u==mr?Ao:Yi;return _(o)}function bn(o){if(!o)return o===0?o:0;if(o=Rr(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 xp(o){return o?oi(Lt(o),0,ct):0}function Rr(o){if(typeof o=="number")return o;if(br(o))return Q;if(Ae(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=Ae(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=Wh(o);var _=lu.test(o);return _||fu.test(o)?uD(o.slice(2),_?2:8):uu.test(o)?Q:+o}function Ap(o){return nn(o,cr(o))}function KA(o){return o?oi(Lt(o),-Z,Z):o===0?o:0}function ie(o){return o==null?"":Dr(o)}var GA=ki(function(o,u){if(ys(u)||lr(u)){nn(u,Ue(u),o);return}for(var _ in u)ae.call(u,_)&&ps(o,_,u[_])}),Cp=ki(function(o,u){nn(u,cr(u),o)}),aa=ki(function(o,u,_,D){nn(u,cr(u),o,D)}),HA=ki(function(o,u,_,D){nn(u,Ue(u),o,D)}),JA=yn(Lu);function XA(o,u){var _=qi(o);return u==null?_:i0(_,u)}var QA=Pt(function(o,u){o=he(o);var _=-1,D=u.length,A=D>2?u[2]:e;for(A&&nr(u[0],u[1],A)&&(D=1);++_<D;)for(var T=u[_],P=cr(T),q=-1,Y=P.length;++q<Y;){var tt=P[q],et=o[tt];(et===e||Kr(et,Ri[tt])&&!ae.call(o,tt))&&(o[tt]=T[tt])}return o}),tC=Pt(function(o){return o.push(e,W0),yr(Fp,e,o)});function eC(o,u){return zh(o,At(u,3),rn)}function rC(o,u){return zh(o,At(u,3),Pu)}function nC(o,u){return o==null?o:Ru(o,At(u,3),cr)}function iC(o,u){return o==null?o:l0(o,At(u,3),cr)}function sC(o,u){return o&&rn(o,At(u,3))}function oC(o,u){return o&&Pu(o,At(u,3))}function aC(o){return o==null?[]:Uo(o,Ue(o))}function uC(o){return o==null?[]:Uo(o,cr(o))}function ml(o,u,_){var D=o==null?e:ai(o,u);return D===e?_:D}function lC(o,u){return o!=null&&V0(o,u,Ob)}function gl(o,u){return o!=null&&V0(o,u,Tb)}var cC=P0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),o[u]=_},yl(fr)),fC=P0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),ae.call(o,u)?o[u].push(_):o[u]=[_]},At),hC=Pt(_s);function Ue(o){return lr(o)?r0(o):Uu(o)}function cr(o){return lr(o)?r0(o,!0):Wb(o)}function pC(o,u){var _={};return u=At(u,3),rn(o,function(D,A,T){gn(_,u(D,A,T),D)}),_}function dC(o,u){var _={};return u=At(u,3),rn(o,function(D,A,T){gn(_,A,u(D,A,T))}),_}var _C=ki(function(o,u,_){Wo(o,u,_)}),Fp=ki(function(o,u,_,D){Wo(o,u,_,D)}),mC=yn(function(o,u){var _={};if(o==null)return _;var D=!1;u=be(u,function(T){return T=Un(T,o),D||(D=T.length>1),T}),nn(o,rl(o),_),D&&(_=Ir(_,f|d|g,cE));for(var A=u.length;A--;)Ku(_,u[A]);return _});function gC(o,u){return Mp(o,ia(At(u)))}var vC=yn(function(o,u){return o==null?{}:Yb(o,u)});function Mp(o,u){if(o==null)return{};var _=be(rl(o),function(D){return[D]});return u=At(u),y0(o,_,function(D,A){return u(D,A[0])})}function yC(o,u,_){u=Un(u,o);var D=-1,A=u.length;for(A||(A=1,o=e);++D<A;){var T=o==null?e:o[sn(u[D])];T===e&&(D=A,T=_),o=Dn(T)?T.call(o):T}return o}function wC(o,u,_){return o==null?o:gs(o,u,_)}function DC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:gs(o,u,_,D)}var Np=k0(Ue),Sp=k0(cr);function bC(o,u,_){var D=It(o),A=D||jn(o)||ji(o);if(u=At(u,4),_==null){var T=o&&o.constructor;A?_=D?new T:[]:Ae(o)?_=Dn(T)?qi(Oo(o)):{}:_={}}return(A?Br:rn)(o,function(P,q,Y){return u(_,P,q,Y)}),_}function EC(o,u){return o==null?!0:Ku(o,u)}function xC(o,u,_){return o==null?o:x0(o,u,Ju(_))}function AC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:x0(o,u,Ju(_),D)}function Yi(o){return o==null?[]:Nu(o,Ue(o))}function CC(o){return o==null?[]:Nu(o,cr(o))}function FC(o,u,_){return _===e&&(_=u,u=e),_!==e&&(_=Rr(_),_=_===_?_:0),u!==e&&(u=Rr(u),u=u===u?u:0),oi(Rr(o),u,_)}function MC(o,u,_){return u=bn(u),_===e?(_=u,u=0):_=bn(_),o=Rr(o),Ib(o,u,_)}function NC(o,u,_){if(_&&typeof _!="boolean"&&nr(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 A=t0();return Xe(o+A*(u-o+aD("1e-"+((A+"").length-1))),u)}return Yu(o,u)}var SC=Ui(function(o,u,_){return u=u.toLowerCase(),o+(_?Bp(u):u)});function Bp(o){return vl(ie(o).toLowerCase())}function Op(o){return o=ie(o),o&&o.replace(pu,wD).replace(Jw,"")}function BC(o,u,_){o=ie(o),u=Dr(u);var D=o.length;_=_===e?D:oi(Lt(_),0,D);var A=_;return _-=u.length,_>=0&&o.slice(_,A)==u}function OC(o){return o=ie(o),o&&Za.test(o)?o.replace(vo,DD):o}function TC(o){return o=ie(o),o&&Qa.test(o)?o.replace(ss,"\\$&"):o}var IC=Ui(function(o,u,_){return o+(_?"-":"")+u.toLowerCase()}),$C=Ui(function(o,u,_){return o+(_?" ":"")+u.toLowerCase()}),LC=$0("toLowerCase");function RC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;if(!u||D>=u)return o;var A=(u-D)/2;return Go(Lo(A),_)+o+Go($o(A),_)}function PC(o,u,_){o=ie(o),u=Lt(u);var D=u?$i(o):0;return u&&D<u?o+Go(u-D,_):o}function zC(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),ZD(ie(o).replace(os,""),u||0)}function kC(o,u,_){return(_?nr(o,u,_):u===e)?u=1:u=Lt(u),Vu(ie(o),u)}function UC(){var o=arguments,u=ie(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var WC=Ui(function(o,u,_){return o+(_?"_":"")+u.toLowerCase()});function jC(o,u,_){return _&&typeof _!="number"&&nr(o,u,_)&&(u=_=e),_=_===e?ct:_>>>0,_?(o=ie(o),o&&(typeof u=="string"||u!=null&&!_l(u))&&(u=Dr(u),!u&&Ii(o))?Wn(Vr(o),0,_):o.split(u,_)):[]}var YC=Ui(function(o,u,_){return o+(_?" ":"")+vl(u)});function VC(o,u,_){return o=ie(o),_=_==null?0:oi(Lt(_),0,o.length),u=Dr(u),o.slice(_,_+u.length)==u}function ZC(o,u,_){var D=O.templateSettings;_&&nr(o,u,_)&&(u=e),o=ie(o),u=aa({},u,D,U0);var A=aa({},u.imports,D.imports,U0),T=Ue(A),P=Nu(A,T),q,Y,tt=0,et=u.interpolate||Si,ot="__p += '",dt=Bu((u.escape||Si).source+"|"+et.source+"|"+(et===yo?au:Si).source+"|"+(u.evaluate||Si).source+"|$","g"),yt="//# sourceURL="+(ae.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rD+"]")+`
|
11
|
-
`;o.replace(dt,function(Ft,Ut,Yt,Er,ir,xr){return Yt||(Yt=Er),ot+=o.slice(tt,xr).replace(ei,bD),Ut&&(q=!0,ot+=`' +
|
12
|
-
__e(`+Ut+`) +
|
13
|
-
'`),ir&&(Y=!0,ot+=`';
|
14
|
-
`+ir+`;
|
15
|
-
__p += '`),Yt&&(ot+=`' +
|
16
|
-
((__t = (`+Yt+`)) == null ? '' : __t) +
|
17
|
-
'`),tt=xr+Ft.length,Ft}),ot+=`';
|
18
|
-
`;var Ct=ae.call(u,"variable")&&u.variable;if(!Ct)ot=`with (obj) {
|
19
|
-
`+ot+`
|
20
|
-
}
|
21
|
-
`;else if(su.test(Ct))throw new Ot(l);ot=(Y?ot.replace(gr,""):ot).replace(vr,"$1").replace(In,"$1;"),ot="function("+(Ct||"obj")+`) {
|
22
|
-
`+(Ct?"":`obj || (obj = {});
|
23
|
-
`)+"var __t, __p = ''"+(q?", __e = _.escape":"")+(Y?`, __j = Array.prototype.join;
|
24
|
-
function print() { __p += __j.call(arguments, '') }
|
25
|
-
`:`;
|
26
|
-
`)+ot+`return __p
|
27
|
-
}`;var Rt=Ip(function(){return te(T,yt+"return "+ot).apply(e,P)});if(Rt.source=ot,dl(Rt))throw Rt;return Rt}function KC(o){return ie(o).toLowerCase()}function GC(o){return ie(o).toUpperCase()}function HC(o,u,_){if(o=ie(o),o&&(_||u===e))return Wh(o);if(!o||!(u=Dr(u)))return o;var D=Vr(o),A=Vr(u),T=jh(D,A),P=Yh(D,A)+1;return Wn(D,T,P).join("")}function JC(o,u,_){if(o=ie(o),o&&(_||u===e))return o.slice(0,Zh(o)+1);if(!o||!(u=Dr(u)))return o;var D=Vr(o),A=Yh(D,Vr(u))+1;return Wn(D,0,A).join("")}function XC(o,u,_){if(o=ie(o),o&&(_||u===e))return o.replace(os,"");if(!o||!(u=Dr(u)))return o;var D=Vr(o),A=jh(D,Vr(u));return Wn(D,A).join("")}function QC(o,u){var _=C,D=B;if(Ae(u)){var A="separator"in u?u.separator:A;_="length"in u?Lt(u.length):_,D="omission"in u?Dr(u.omission):D}o=ie(o);var T=o.length;if(Ii(o)){var P=Vr(o);T=P.length}if(_>=T)return o;var q=_-$i(D);if(q<1)return D;var Y=P?Wn(P,0,q).join(""):o.slice(0,q);if(A===e)return Y+D;if(P&&(q+=Y.length-q),_l(A)){if(o.slice(q).search(A)){var tt,et=Y;for(A.global||(A=Bu(A.source,ie(wo.exec(A))+"g")),A.lastIndex=0;tt=A.exec(et);)var ot=tt.index;Y=Y.slice(0,ot===e?q:ot)}}else if(o.indexOf(Dr(A),q)!=q){var dt=Y.lastIndexOf(A);dt>-1&&(Y=Y.slice(0,dt))}return Y+D}function t2(o){return o=ie(o),o&&Va.test(o)?o.replace(ti,ND):o}var e2=Ui(function(o,u,_){return o+(_?" ":"")+u.toUpperCase()}),vl=$0("toUpperCase");function Tp(o,u,_){return o=ie(o),u=_?e:u,u===e?xD(o)?OD(o):_D(o):o.match(u)||[]}var Ip=Pt(function(o,u){try{return yr(o,e,u)}catch(_){return dl(_)?_:new Ot(_)}}),r2=yn(function(o,u){return Br(u,function(_){_=sn(_),gn(o,_,hl(o[_],o))}),o});function n2(o){var u=o==null?0:o.length,_=At();return o=u?be(o,function(D){if(typeof D[1]!="function")throw new Or(a);return[_(D[0]),D[1]]}):[],Pt(function(D){for(var A=-1;++A<u;){var T=o[A];if(yr(T[0],this,D))return yr(T[1],this,D)}})}function i2(o){return Nb(Ir(o,f))}function yl(o){return function(){return o}}function s2(o,u){return o==null||o!==o?u:o}var o2=R0(),a2=R0(!0);function fr(o){return o}function wl(o){return p0(typeof o=="function"?o:Ir(o,f))}function u2(o){return _0(Ir(o,f))}function l2(o,u){return m0(o,Ir(u,f))}var c2=Pt(function(o,u){return function(_){return _s(_,o,u)}}),f2=Pt(function(o,u){return function(_){return _s(o,_,u)}});function Dl(o,u,_){var D=Ue(u),A=Uo(u,D);_==null&&!(Ae(u)&&(A.length||!D.length))&&(_=u,u=o,o=this,A=Uo(u,Ue(u)));var T=!(Ae(_)&&"chain"in _)||!!_.chain,P=Dn(o);return Br(A,function(q){var Y=u[q];o[q]=Y,P&&(o.prototype[q]=function(){var tt=this.__chain__;if(T||tt){var et=o(this.__wrapped__),ot=et.__actions__=ur(this.__actions__);return ot.push({func:Y,args:arguments,thisArg:o}),et.__chain__=tt,et}return Y.apply(o,Rn([this.value()],arguments))})}),o}function h2(){return Ze._===this&&(Ze._=PD),this}function bl(){}function p2(o){return o=Lt(o),Pt(function(u){return g0(u,o)})}var d2=Qu(be),_2=Qu(Ph),m2=Qu(xu);function $p(o){return ol(o)?Au(sn(o)):Vb(o)}function g2(o){return function(u){return o==null?e:ai(o,u)}}var v2=z0(),y2=z0(!0);function El(){return[]}function xl(){return!1}function w2(){return{}}function D2(){return""}function b2(){return!0}function E2(o,u){if(o=Lt(o),o<1||o>Z)return[];var _=ct,D=Xe(o,ct);u=At(u),o-=ct;for(var A=Mu(D,u);++_<o;)u(_);return A}function x2(o){return It(o)?be(o,sn):br(o)?[o]:ur(ep(ie(o)))}function A2(o){var u=++LD;return ie(o)+u}var C2=Ko(function(o,u){return o+u},0),F2=tl("ceil"),M2=Ko(function(o,u){return o/u},1),N2=tl("floor");function S2(o){return o&&o.length?ko(o,fr,zu):e}function B2(o,u){return o&&o.length?ko(o,At(u,2),zu):e}function O2(o){return kh(o,fr)}function T2(o,u){return kh(o,At(u,2))}function I2(o){return o&&o.length?ko(o,fr,Wu):e}function $2(o,u){return o&&o.length?ko(o,At(u,2),Wu):e}var L2=Ko(function(o,u){return o*u},1),R2=tl("round"),P2=Ko(function(o,u){return o-u},0);function z2(o){return o&&o.length?Fu(o,fr):0}function q2(o,u){return o&&o.length?Fu(o,At(u,2)):0}return O.after=uA,O.ary=hp,O.assign=GA,O.assignIn=Cp,O.assignInWith=aa,O.assignWith=HA,O.at=JA,O.before=pp,O.bind=hl,O.bindAll=r2,O.bindKey=dp,O.castArray=wA,O.chain=lp,O.chunk=NE,O.compact=SE,O.concat=BE,O.cond=n2,O.conforms=i2,O.constant=yl,O.countBy=zx,O.create=XA,O.curry=_p,O.curryRight=mp,O.debounce=gp,O.defaults=QA,O.defaultsDeep=tC,O.defer=lA,O.delay=cA,O.difference=OE,O.differenceBy=TE,O.differenceWith=IE,O.drop=$E,O.dropRight=LE,O.dropRightWhile=RE,O.dropWhile=PE,O.fill=zE,O.filter=kx,O.flatMap=jx,O.flatMapDeep=Yx,O.flatMapDepth=Vx,O.flatten=sp,O.flattenDeep=qE,O.flattenDepth=kE,O.flip=fA,O.flow=o2,O.flowRight=a2,O.fromPairs=UE,O.functions=aC,O.functionsIn=uC,O.groupBy=Zx,O.initial=jE,O.intersection=YE,O.intersectionBy=VE,O.intersectionWith=ZE,O.invert=cC,O.invertBy=fC,O.invokeMap=Gx,O.iteratee=wl,O.keyBy=Hx,O.keys=Ue,O.keysIn=cr,O.map=ea,O.mapKeys=pC,O.mapValues=dC,O.matches=u2,O.matchesProperty=l2,O.memoize=na,O.merge=_C,O.mergeWith=Fp,O.method=c2,O.methodOf=f2,O.mixin=Dl,O.negate=ia,O.nthArg=p2,O.omit=mC,O.omitBy=gC,O.once=hA,O.orderBy=Jx,O.over=d2,O.overArgs=pA,O.overEvery=_2,O.overSome=m2,O.partial=pl,O.partialRight=vp,O.partition=Xx,O.pick=vC,O.pickBy=Mp,O.property=$p,O.propertyOf=g2,O.pull=JE,O.pullAll=ap,O.pullAllBy=XE,O.pullAllWith=QE,O.pullAt=tx,O.range=v2,O.rangeRight=y2,O.rearg=dA,O.reject=eA,O.remove=ex,O.rest=_A,O.reverse=cl,O.sampleSize=nA,O.set=wC,O.setWith=DC,O.shuffle=iA,O.slice=rx,O.sortBy=aA,O.sortedUniq=lx,O.sortedUniqBy=cx,O.split=jC,O.spread=mA,O.tail=fx,O.take=hx,O.takeRight=px,O.takeRightWhile=dx,O.takeWhile=_x,O.tap=Sx,O.throttle=gA,O.thru=ta,O.toArray=Ep,O.toPairs=Np,O.toPairsIn=Sp,O.toPath=x2,O.toPlainObject=Ap,O.transform=bC,O.unary=vA,O.union=mx,O.unionBy=gx,O.unionWith=vx,O.uniq=yx,O.uniqBy=wx,O.uniqWith=Dx,O.unset=EC,O.unzip=fl,O.unzipWith=up,O.update=xC,O.updateWith=AC,O.values=Yi,O.valuesIn=CC,O.without=bx,O.words=Tp,O.wrap=yA,O.xor=Ex,O.xorBy=xx,O.xorWith=Ax,O.zip=Cx,O.zipObject=Fx,O.zipObjectDeep=Mx,O.zipWith=Nx,O.entries=Np,O.entriesIn=Sp,O.extend=Cp,O.extendWith=aa,Dl(O,O),O.add=C2,O.attempt=Ip,O.camelCase=SC,O.capitalize=Bp,O.ceil=F2,O.clamp=FC,O.clone=DA,O.cloneDeep=EA,O.cloneDeepWith=xA,O.cloneWith=bA,O.conformsTo=AA,O.deburr=Op,O.defaultTo=s2,O.divide=M2,O.endsWith=BC,O.eq=Kr,O.escape=OC,O.escapeRegExp=TC,O.every=qx,O.find=Ux,O.findIndex=np,O.findKey=eC,O.findLast=Wx,O.findLastIndex=ip,O.findLastKey=rC,O.floor=N2,O.forEach=cp,O.forEachRight=fp,O.forIn=nC,O.forInRight=iC,O.forOwn=sC,O.forOwnRight=oC,O.get=ml,O.gt=CA,O.gte=FA,O.has=lC,O.hasIn=gl,O.head=op,O.identity=fr,O.includes=Kx,O.indexOf=WE,O.inRange=MC,O.invoke=hC,O.isArguments=ci,O.isArray=It,O.isArrayBuffer=MA,O.isArrayLike=lr,O.isArrayLikeObject=Ne,O.isBoolean=NA,O.isBuffer=jn,O.isDate=SA,O.isElement=BA,O.isEmpty=OA,O.isEqual=TA,O.isEqualWith=IA,O.isError=dl,O.isFinite=$A,O.isFunction=Dn,O.isInteger=yp,O.isLength=sa,O.isMap=wp,O.isMatch=LA,O.isMatchWith=RA,O.isNaN=PA,O.isNative=zA,O.isNil=kA,O.isNull=qA,O.isNumber=Dp,O.isObject=Ae,O.isObjectLike=Ce,O.isPlainObject=Ds,O.isRegExp=_l,O.isSafeInteger=UA,O.isSet=bp,O.isString=oa,O.isSymbol=br,O.isTypedArray=ji,O.isUndefined=WA,O.isWeakMap=jA,O.isWeakSet=YA,O.join=KE,O.kebabCase=IC,O.last=Lr,O.lastIndexOf=GE,O.lowerCase=$C,O.lowerFirst=LC,O.lt=VA,O.lte=ZA,O.max=S2,O.maxBy=B2,O.mean=O2,O.meanBy=T2,O.min=I2,O.minBy=$2,O.stubArray=El,O.stubFalse=xl,O.stubObject=w2,O.stubString=D2,O.stubTrue=b2,O.multiply=L2,O.nth=HE,O.noConflict=h2,O.noop=bl,O.now=ra,O.pad=RC,O.padEnd=PC,O.padStart=zC,O.parseInt=qC,O.random=NC,O.reduce=Qx,O.reduceRight=tA,O.repeat=kC,O.replace=UC,O.result=yC,O.round=R2,O.runInContext=j,O.sample=rA,O.size=sA,O.snakeCase=WC,O.some=oA,O.sortedIndex=nx,O.sortedIndexBy=ix,O.sortedIndexOf=sx,O.sortedLastIndex=ox,O.sortedLastIndexBy=ax,O.sortedLastIndexOf=ux,O.startCase=YC,O.startsWith=VC,O.subtract=P2,O.sum=z2,O.sumBy=q2,O.template=ZC,O.times=E2,O.toFinite=bn,O.toInteger=Lt,O.toLength=xp,O.toLower=KC,O.toNumber=Rr,O.toSafeInteger=KA,O.toString=ie,O.toUpper=GC,O.trim=HC,O.trimEnd=JC,O.trimStart=XC,O.truncate=QC,O.unescape=t2,O.uniqueId=A2,O.upperCase=e2,O.upperFirst=vl,O.each=cp,O.eachRight=fp,O.first=op,Dl(O,function(){var o={};return rn(O,function(u,_){ae.call(O.prototype,_)||(o[_]=u)}),o}(),{chain:!1}),O.VERSION=r,Br(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){O[o].placeholder=O}),Br(["drop","take"],function(o,u){jt.prototype[o]=function(_){_=_===e?1:qe(Lt(_),0);var D=this.__filtered__&&!u?new jt(this):this.clone();return D.__filtered__?D.__takeCount__=Xe(_,D.__takeCount__):D.__views__.push({size:Xe(_,ct),type:o+(D.__dir__<0?"Right":"")}),D},jt.prototype[o+"Right"]=function(_){return this.reverse()[o](_).reverse()}}),Br(["filter","map","takeWhile"],function(o,u){var _=u+1,D=_==k||_==z;jt.prototype[o]=function(A){var T=this.clone();return T.__iteratees__.push({iteratee:At(A,3),type:_}),T.__filtered__=T.__filtered__||D,T}}),Br(["head","last"],function(o,u){var _="take"+(u?"Right":"");jt.prototype[o]=function(){return this[_](1).value()[0]}}),Br(["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(fr)},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 _s(_,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)},rn(jt.prototype,function(o,u){var _=/^(?:filter|find|map|reject)|While$/.test(u),D=/^(?:head|last)$/.test(u),A=O[D?"take"+(u=="last"?"Right":""):u],T=D||/^find/.test(u);A&&(O.prototype[u]=function(){var P=this.__wrapped__,q=D?[1]:arguments,Y=P instanceof jt,tt=q[0],et=Y||It(P),ot=function(Ut){var Yt=A.apply(O,Rn([Ut],q));return D&&dt?Yt[0]:Yt};et&&_&&typeof tt=="function"&&tt.length!=1&&(Y=et=!1);var dt=this.__chain__,yt=!!this.__actions__.length,Ct=T&&!dt,Rt=Y&&!yt;if(!T&&et){P=Rt?P:new jt(this);var Ft=o.apply(P,q);return Ft.__actions__.push({func:ta,args:[ot],thisArg:e}),new Tr(Ft,dt)}return Ct&&Rt?o.apply(this,q):(Ft=this.thru(ot),Ct?D?Ft.value()[0]:Ft.value():Ft)})}),Br(["pop","push","shift","sort","splice","unshift"],function(o){var u=Co[o],_=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);O.prototype[o]=function(){var A=arguments;if(D&&!this.__chain__){var T=this.value();return u.apply(It(T)?T:[],A)}return this[_](function(P){return u.apply(It(P)?P:[],A)})}}),rn(jt.prototype,function(o,u){var _=O[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=tb,jt.prototype.reverse=eb,jt.prototype.value=rb,O.prototype.at=Bx,O.prototype.chain=Ox,O.prototype.commit=Tx,O.prototype.next=Ix,O.prototype.plant=Lx,O.prototype.reverse=Rx,O.prototype.toJSON=O.prototype.valueOf=O.prototype.value=Px,O.prototype.first=O.prototype.head,us&&(O.prototype[us]=$x),O},Li=TD();ri?((ri.exports=Li)._=Li,wu._=Li):Ze._=Li}).call(Vt)}(Yn,Yn.exports);var Pr=Yn.exports;class Rp{constructor(t,e){R(this,"_defaultParams");R(this,"_UserTypeFileds");R(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Pr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Pr.cloneDeep(this._defaultParams),t),this._varipKeys)}addNewMethod(t,e){this._UserTypeFileds.prototype[t]=e}_createDynamicClass(){return class{constructor(t,e){R(this,"_varipKeys");Object.assign(this,t),this._varipKeys=e}get varipKeys(){return[...this._varipKeys]}copy(){return Pr.cloneDeep(this)}}}}var Nl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){var e=1e3,r=6e4,n=36e5,i="millisecond",a="second",l="minute",c="hour",p="day",h="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,E={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(k){var W=["th","st","nd","rd"],z=k%100;return"["+k+(W[(z-20)%10]||W[z]||W[0])+"]"}},b=function(k,W,z){var K=String(k);return!K||K.length>=W?k:""+Array(W+1-K.length).join(z)+k},N={s:b,z:function(k){var W=-k.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 k(W,z){if(W.date()<z.date())return-k(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(k){return k<0?Math.ceil(k)||0:Math.floor(k)},p:function(k){return{M:f,y:g,w:h,d:p,D:y,h:c,m:l,s:a,ms:i,Q:d}[k]||String(k||"").toLowerCase().replace(/s$/,"")},u:function(k){return k===void 0}},x="en",F={};F[x]=E;var M="$isDayjsObject",S=function(k){return k instanceof L||!(!k||!k[M])},I=function k(W,z,K){var Z;if(!W)return x;if(typeof W=="string"){var X=W.toLowerCase();F[X]&&(Z=X),z&&(F[X]=z,Z=X);var Q=W.split("-");if(!Z&&Q.length>1)return k(Q[0])}else{var ct=W.name;F[ct]=W,Z=ct}return!K&&Z&&(x=Z),Z||!K&&x},C=function(k,W){if(S(k))return k.clone();var z=typeof W=="object"?W:{};return z.date=k,z.args=arguments,new L(z)},B=N;B.l=I,B.i=S,B.w=function(k,W){return C(k,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var L=function(){function k(z){this.$L=I(z.locale,null,!0),this.parse(z),this.$x=this.$x||z.x||{},this[M]=!0}var W=k.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(B.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 B},W.isValid=function(){return this.$d.toString()!==m},W.isSame=function(z,K){var Z=C(z);return this.startOf(K)<=Z&&Z<=this.endOf(K)},W.isAfter=function(z,K){return C(z)<this.startOf(K)},W.isBefore=function(z,K){return this.endOf(K)<C(z)},W.$g=function(z,K,Z){return B.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=!!B.u(K)||K,Q=B.p(z),ct=function(Tt,Nt){var le=B.w(Z.$u?Date.UTC(Z.$y,Nt,Tt):new Date(Z.$y,Nt,Tt),Z);return X?le:le.endOf(p)},vt=function(Tt,Nt){return B.w(Z.toDate()[Tt].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 h:var Et=this.$locale().weekStart||0,oe=(lt<Et?lt+7:lt)-Et;return ct(X?bt-oe:bt+(6-oe),wt);case p: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=B.p(z),Q="set"+(this.$u?"UTC":""),ct=(Z={},Z[p]=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===p?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[B.p(z)]()},W.add=function(z,K){var Z,X=this;z=Number(z);var Q=B.p(K),ct=function(wt){var bt=C(X);return B.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===p)return ct(1);if(Q===h)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 B.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=B.z(this),ct=this.$H,vt=this.$m,lt=this.$M,wt=Z.weekdays,bt=Z.months,Bt=Z.meridiem,Et=function(Nt,le,re,kt){return Nt&&(Nt[le]||Nt(K,X))||re[le].slice(0,kt)},oe=function(Nt){return B.s(ct%12||12,Nt,"0")},Tt=Bt||function(Nt,le,re){var kt=Nt<12?"AM":"PM";return re?kt.toLowerCase():kt};return X.replace(v,function(Nt,le){return le||function(re){switch(re){case"YY":return String(K.$y).slice(-2);case"YYYY":return B.s(K.$y,4,"0");case"M":return lt+1;case"MM":return B.s(lt+1,2,"0");case"MMM":return Et(Z.monthsShort,lt,bt,3);case"MMMM":return Et(bt,lt);case"D":return K.$D;case"DD":return B.s(K.$D,2,"0");case"d":return String(K.$W);case"dd":return Et(Z.weekdaysMin,K.$W,wt,2);case"ddd":return Et(Z.weekdaysShort,K.$W,wt,3);case"dddd":return wt[K.$W];case"H":return String(ct);case"HH":return B.s(ct,2,"0");case"h":return oe(1);case"hh":return oe(2);case"a":return Tt(ct,vt,!0);case"A":return Tt(ct,vt,!1);case"m":return String(vt);case"mm":return B.s(vt,2,"0");case"s":return String(K.$s);case"ss":return B.s(K.$s,2,"0");case"SSS":return B.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=B.p(K),vt=C(z),lt=(vt.utcOffset()-this.utcOffset())*r,wt=this-vt,bt=function(){return B.m(Q,vt)};switch(ct){case g:X=bt()/12;break;case f:X=bt();break;case d:X=bt()/3;break;case h:X=(wt-lt)/6048e5;break;case p: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:B.a(X)},W.daysInMonth=function(){return this.endOf(f).$D},W.$locale=function(){return F[this.$L]},W.locale=function(z,K){if(!z)return this.$L;var Z=this.clone(),X=I(z,K,!0);return X&&(Z.$L=X),Z},W.clone=function(){return B.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()},k}(),U=L.prototype;return C.prototype=U,[["$ms",i],["$s",a],["$m",l],["$H",c],["$W",p],["$M",f],["$y",g],["$D",y]].forEach(function(k){U[k[1]]=function(W){return this.$g(W,k[0],k[1])}}),C.extend=function(k,W){return k.$i||(k(W,L,C),k.$i=!0),C},C.locale=I,C.isDayjs=S,C.unix=function(k){return C(1e3*k)},C.en=F[x],C.Ls=F,C.p={},C})})(Nl);var Pp=Nl.exports,ee=Gt(Pp),Sl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,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 p=c.parse;c.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),p.call(this,m)};var h=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 h.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(x){x===void 0&&(x="");var F=x.match(r);if(!F)return null;var M=(""+F[0]).match(n)||["-",0,0],S=M[0],I=60*+M[1]+ +M[2];return I===0?0:S==="+"?I:-I}(m),m===null))return this;var E=Math.abs(m)<=16?60*m:m,b=this;if(w)return b.$offset=E,b.$u=m===0,b;if(m!==0){var N=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(E+N,e)).$offset=E,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 E=this.local(),b=l(m).local();return y.call(E,b,w,v)}}})})(Sl);var zp=Sl.exports,Bl=Gt(zp),Ol={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,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,E){E===void 0&&(E={});var b=E.timeZoneName||"short",N=v+"|"+b,x=r[N];return x||(x=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]=x),x}(g,y);return w.formatToParts(m)},p=function(d,g){for(var y=c(d,g),m=[],w=0;w<y.length;w+=1){var v=y[w],E=v.type,b=v.value,N=e[E];N>=0&&(m[N]=parseInt(b,10))}var x=m[3],F=x===24?0:x,M=m[0]+"-"+m[1]+"-"+m[2]+" "+F+":"+m[4]+":"+m[5]+":000",S=+d;return(a.utc(M).valueOf()-(S-=S%1e3))/6e4},h=i.prototype;h.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),E=a(w,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-v,!0);if(g){var b=E.utcOffset();E=E.add(y-b,"minute")}return E.$x.$timezone=d,E},h.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=h.startOf;h.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=p(+a(),w);if(typeof d!="string")return a(d).tz(w);var E=function(F,M,S){var I=F-60*M*1e3,C=p(I,S);if(M===C)return[I,M];var B=p(I-=60*(C-M)*1e3,S);return C===B?[I,C]:[F-60*Math.min(C,B)*1e3,Math.max(C,B)]}(a.utc(d,m).valueOf(),v,w),b=E[0],N=E[1],x=a(b).utcOffset(N);return x.$x.$timezone=w,x},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(d){l=d}}})})(Ol);var qp=Ol.exports,kp=Gt(qp),Tl={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,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 p=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var h=a(this).startOf(r).add(1,r).date(p),f=a(this).endOf(e);if(h.isBefore(f))return 1}var d=a(this).startOf(r).date(p).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)}}})})(Tl);var Up=Tl.exports,Wp=Gt(Up);function We(s,t){return s.replace(/\$(\w+)/g,(e,r)=>String(t[r])||e)}function bs(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 jp(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 zr(s,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?ee(s).utcOffset(jp(t)):ee(s).tz(t)}function Jr(s){const[t,e]=bs(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 on(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}var Xr=(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))(Xr||{}),Es=(s=>(s.dividends="dividends",s.none="none",s.splits="splits",s))(Es||{}),qr=(s=>(s.freqAll="freq_all",s.freqOncePerBar="freq_once_per_bar",s.freqOncePerBarClose="freq_once_per_bar_close",s))(qr||{}),Vi=(s=>(s.gapsOff="gaps_off",s.gapsOn="gaps_on",s.lookaheadOff="lookahead_off",s.lookaheadOn="lookahead_on",s))(Vi||{}),je=(s=>(s.all="all",s.dataWindow="data_window",s.none="none",s.pane="pane",s.priceScale="price_scale",s.statusLine="status_line",s))(je||{}),kr=(s=>(s.both="both",s.left="left",s.none="none",s.right="right",s))(kr||{}),Kt=(s=>(s.inherit="inherit",s.mintick="mintick",s.percent="percent",s.price="price",s.volume="volume",s))(Kt||{}),xs=(s=>(s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(xs||{}),_e=(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))(_e||{}),$e=(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))($e||{}),an=(s=>(s.abovebar="abovebar",s.absolute="absolute",s.belowbar="belowbar",s.bottom="bottom",s.top="top",s))(an||{}),Vn=(s=>(s.ascending="ascending",s.descending="descending",s))(Vn||{}),Ar=(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))(Ar||{}),hr=(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))(hr||{}),As=(s=>(s.left="left",s.none="none",s.right="right",s))(As||{}),fi=(s=>(s.extended="extended",s.regular="regular",s))(fi||{}),sr=(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))(sr||{}),tr=(s=>(s.auto="auto",s.huge="huge",s.large="large",s.normal="normal",s.small="small",s.tiny="tiny",s))(tr||{}),Zn=(s=>(s.familyDefault="default",s.familyMonospace="monospace",s))(Zn||{}),Be=(s=>(s.cash="cash",s.fixed="fixed",s.percentOfEquity="percent_of_equity",s))(Be||{}),Cr=(s=>(s.cashPerContract="cash_per_contract",s.cashPerOrder="cash_per_order",s.percent="percent",s))(Cr||{}),me=(s=>(s.all="all",s.long="long",s.short="short",s))(me||{}),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||{}),ye=(s=>(s.bar_index="bar_index",s.bar_time="bar_time",s))(ye||{}),Ur=(s=>(s.abovebar="abovebar",s.belowbar="belowbar",s.price="price",s))(Ur||{}),Cs=(s=>(s.actual="actual",s.estimate="estimate",s.standardized="standardized",s))(Cs||{}),Kn=(s=>(s.traditional="Traditional",s.fibonacci="Fibonacci",s.woodie="Woodie",s.classic="Classic",s.dm="DM",s.camarilla="Camarilla",s))(Kn||{}),er=(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))(er||{}),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 ue={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."};Xr.SERIES,Xr.SIMPLE,Xr.INPUT,Xr.CONST,Xr.INT,Xr.FLOAT,Xr.BOOL,Xr.COLOR,Xr.STRING;const Vp=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],Zp=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],Kp=["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 Gp{constructor(t){R(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){R(this,"_arrInstance");R(this,"_errorListener");this._errorListener=r,this._arrInstance=Array.from(new Array(t||0),()=>Pr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Pr.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),Pr.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(ue.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!==Vn.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!==Vn.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(ue.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(ue.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(ue.arrLengthDiffErr,n,zt.Error);return}t=t.filter(p=>p!==void 0),e=e.filter(p=>p!==void 0);const i=t.reduce((p,h)=>p+h,0)/t.length,a=e.reduce((p,h)=>p+h,0)/e.length;let l=0;for(let p=0;p<t.length;p++)l+=(t[p]-i)*(e[p]-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(We(ue.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 Hp{constructor(t,e){R(this,"_randomNums");R(this,"_mintick");R(this,"_cacheData");R(this,"_barIndex");R(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 Pr.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(ue.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 Pr.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 Fs(){return Fs=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},Fs.apply(this,arguments)}var $l={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function pe(s){return typeof s=="number"}function Me(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 Qr(s){return typeof s=="string"}var Ee=Array.isArray;function ge(s){return s&&s.constructor.prototype.isMatrix===!0||!1}function Zi(s){return Array.isArray(s)||ge(s)}function Jp(s){return s&&s.isDenseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function Xp(s){return s&&s.isSparseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function Qp(s){return s&&s.constructor.prototype.isRange===!0||!1}function la(s){return s&&s.constructor.prototype.isIndex===!0||!1}function td(s){return typeof s=="boolean"}function ed(s){return s&&s.constructor.prototype.isResultSet===!0||!1}function rd(s){return s&&s.constructor.prototype.isHelp===!0||!1}function nd(s){return typeof s=="function"}function id(s){return s instanceof Date}function sd(s){return s instanceof RegExp}function ca(s){return!!(s&&typeof s=="object"&&s.constructor===Object&&!Ll(s)&&!Rl(s))}function od(s){return s===null}function ad(s){return s===void 0}function ud(s){return s&&s.isAccessorNode===!0&&s.constructor.prototype.isNode===!0||!1}function ld(s){return s&&s.isArrayNode===!0&&s.constructor.prototype.isNode===!0||!1}function cd(s){return s&&s.isAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function fd(s){return s&&s.isBlockNode===!0&&s.constructor.prototype.isNode===!0||!1}function hd(s){return s&&s.isConditionalNode===!0&&s.constructor.prototype.isNode===!0||!1}function pd(s){return s&&s.isConstantNode===!0&&s.constructor.prototype.isNode===!0||!1}function dd(s){return s&&s.isFunctionAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function _d(s){return s&&s.isFunctionNode===!0&&s.constructor.prototype.isNode===!0||!1}function md(s){return s&&s.isIndexNode===!0&&s.constructor.prototype.isNode===!0||!1}function gd(s){return s&&s.isNode===!0&&s.constructor.prototype.isNode===!0||!1}function vd(s){return s&&s.isObjectNode===!0&&s.constructor.prototype.isNode===!0||!1}function yd(s){return s&&s.isOperatorNode===!0&&s.constructor.prototype.isNode===!0||!1}function wd(s){return s&&s.isParenthesisNode===!0&&s.constructor.prototype.isNode===!0||!1}function Dd(s){return s&&s.isRangeNode===!0&&s.constructor.prototype.isNode===!0||!1}function bd(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 xd(s){return s&&s.constructor.prototype.isChain===!0||!1}function xn(s){var t=typeof s;return t==="object"?s===null?"null":Me(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(Me(s))return s;if(ca(s))return Ad(s,se);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(s,")"))}function Ad(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 Cd(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 Fd=["Matrix","Array"],Md=["number","BigNumber","Fraction"],pr=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)};Fs(pr,$l,{MATRIX_OPTIONS:Fd,NUMBER_OPTIONS:Md});function ql(){return!0}function Fr(){return!1}function pi(){}const kl="Argument is not a typed-function.";function Ul(){function s($){return typeof $=="object"&&$!==null&&$.constructor===Object}const t=[{name:"number",test:function($){return typeof $=="number"}},{name:"string",test:function($){return typeof $=="string"}},{name:"boolean",test:function($){return typeof $=="boolean"}},{name:"Function",test:function($){return typeof $=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function($){return $ instanceof Date}},{name:"RegExp",test:function($){return $ instanceof RegExp}},{name:"Object",test:s},{name:"null",test:function($){return $===null}},{name:"undefined",test:function($){return $===void 0}}],e={name:"any",test:ql,isAny:!0};let r,n,i=0,a={createCount:0};function l($){const V=r.get($);if(V)return V;let G='Unknown type "'+$+'"';const nt=$.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){G+='. Did you mean "'+st+'" ?';break}throw new TypeError(G)}function c($){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const G=V?l(V).index:n.length,nt=[];for(let rt=0;rt<$.length;++rt){if(!$[rt]||typeof $[rt].name!="string"||typeof $[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ft=$[rt].name;if(r.has(ft))throw new TypeError('Duplicate type name "'+ft+'"');nt.push(ft),r.set(ft,{name:ft,test:$[rt].test,isAny:$[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 p(){r=new Map,n=[],i=0,c([e],!1)}p(),c(t);function h(){let $;for($ of n)r.get($).conversionsTo=[];i=0}function f($){const V=n.filter(G=>{const nt=r.get(G);return!nt.isAny&&nt.test($)});return V.length?V:["any"]}function d($){return $&&typeof $=="function"&&"_typedFunctionData"in $}function g($,V,G){if(!d($))throw new TypeError(kl);const nt=G&&G.exact,st=Array.isArray(V)?V.join(","):V,rt=N(st),ft=w(rt);if(!nt||ft in $.signatures){const Xt=$._typedFunctionData.signatureMap.get(ft);if(Xt)return Xt}const ut=rt.length;let ht;if(nt){ht=[];let Xt;for(Xt in $.signatures)ht.push($._typedFunctionData.signatureMap.get(Xt))}else ht=$._typedFunctionData.signatures;for(let Xt=0;Xt<ut;++Xt){const ne=rt[Xt],De=[];let ke;for(ke of ht){const Pe=S(ke.params,Xt);if(!(!Pe||ne.restParam&&!Pe.restParam)){if(!Pe.hasAny){const gr=b(Pe);if(ne.types.some(vr=>!gr.has(vr.name)))continue}De.push(ke)}}if(ht=De,ht.length===0)break}let at;for(at of ht)if(at.params.length<=ut)return at;throw new TypeError("Signature not found (signature: "+($.name||"unnamed")+"("+w(rt,", ")+"))")}function y($,V,G){return g($,V,G).implementation}function m($,V){const G=l(V);if(G.test($))return $;const nt=G.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+V+" defined.");for(let st=0;st<nt.length;st++)if(l(nt[st].from).test($))return nt[st].convert($);throw new Error("Cannot convert "+$+" to "+V)}function w($){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return $.map(G=>G.name).join(V)}function v($){const V=$.indexOf("...")===0,nt=(V?$.length>3?$.slice(3):"any":$).split("|").map(ut=>l(ut.trim()));let st=!1,rt=V?"...":"";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:V}}function E($){const V=$.types.map(ft=>ft.name),G=K(V);let nt=$.hasAny,st=$.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:$.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:$.restParam}}function b($){return $.typeSet||($.typeSet=new Set,$.types.forEach(V=>$.typeSet.add(V.name))),$.typeSet}function N($){const V=[];if(typeof $!="string")throw new TypeError("Signatures must be strings");const G=$.trim();if(G==="")return V;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;V.push(rt)}return V}function x($){const V=Tt($);return V?V.restParam:!1}function F($){if(!$||$.types.length===0)return ql;if($.types.length===1)return l($.types[0].name).test;if($.types.length===2){const V=l($.types[0].name).test,G=l($.types[1].name).test;return function(st){return V(st)||G(st)}}else{const V=$.types.map(function(G){return l(G.name).test});return function(nt){for(let st=0;st<V.length;st++)if(V[st](nt))return!0;return!1}}}function M($){let V,G,nt;if(x($)){V=oe($).map(F);const st=V.length,rt=F(Tt($)),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<V.length;at++)if(!V[at](ht[at]))return!1;return ft(ht)&&ht.length>=st+1}}else return $.length===0?function(rt){return rt.length===0}:$.length===1?(G=F($[0]),function(rt){return G(rt[0])&&rt.length===1}):$.length===2?(G=F($[0]),nt=F($[1]),function(rt){return G(rt[0])&&nt(rt[1])&&rt.length===2}):(V=$.map(F),function(rt){for(let ft=0;ft<V.length;ft++)if(!V[ft](rt[ft]))return!1;return rt.length===V.length})}function S($,V){return V<$.length?$[V]:x($)?Tt($):null}function I($,V){const G=S($,V);return G?b(G):new Set}function C($){return $.conversion===null||$.conversion===void 0}function B($,V){const G=new Set;return $.forEach(nt=>{const st=I(nt.params,V);let rt;for(rt of st)G.add(rt)}),G.has("any")?["any"]:Array.from(G)}function L($,V,G){let nt,st;const rt=$||"unnamed";let ft=G,ut;for(ut=0;ut<V.length;ut++){const ne=[];if(ft.forEach(De=>{const ke=S(De.params,ut),Pe=F(ke);(ut<De.params.length||x(De.params))&&Pe(V[ut])&&ne.push(De)}),ne.length===0){if(st=B(ft,ut),st.length>0){const De=f(V[ut]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+De.join(" | ")+", index: "+ut+")"),nt.data={category:"wrongType",fn:rt,index:ut,actual:De,expected:st},nt}}else ft=ne}const ht=ft.map(function(ne){return x(ne.params)?1/0:ne.params.length});if(V.length<Math.min.apply(null,ht))return st=B(ft,ut),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+V.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:V.length,expected:st},nt;const at=Math.max.apply(null,ht);if(V.length>at)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+at+", actual: "+V.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:V.length,expectedLength:at},nt;const Xt=[];for(let ne=0;ne<V.length;++ne)Xt.push(f(V[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($){let V=n.length+1;for(let G=0;G<$.types.length;G++)C($.types[G])&&(V=Math.min(V,$.types[G].typeIndex));return V}function k($){let V=i+1;for(let G=0;G<$.types.length;G++)C($.types[G])||(V=Math.min(V,$.types[G].conversionIndex));return V}function W($,V){if($.hasAny){if(!V.hasAny)return 1}else if(V.hasAny)return-1;if($.restParam){if(!V.restParam)return 1}else if(V.restParam)return-1;if($.hasConversion){if(!V.hasConversion)return 1}else if(V.hasConversion)return-1;const G=U($)-U(V);if(G<0)return-1;if(G>0)return 1;const nt=k($)-k(V);return nt<0?-1:nt>0?1:0}function z($,V){const G=$.params,nt=V.params,st=Tt(G),rt=Tt(nt),ft=x(G),ut=x(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,De=0;for(Xt of nt)Xt.hasAny&&++ne,Xt.hasConversion&&++De;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!==De)return at-De;if(ft){if(!ut)return 1}else if(ut)return-1;const ke=(G.length-nt.length)*(ft?-1:1);if(ke!==0)return ke;const Pe=[];let gr=0;for(let In=0;In<G.length;++In){const ti=W(G[In],nt[In]);Pe.push(ti),gr+=ti}if(gr!==0)return gr;let vr;for(vr of Pe)if(vr!==0)return vr;return 0}function K($){if($.length===0)return[];const V=$.map(l);$.length>1&&V.sort((st,rt)=>st.index-rt.index);let G=V[0].conversionsTo;if($.length===1)return G;G=G.concat([]);const nt=new Set($);for(let st=1;st<V.length;++st){let rt;for(rt of V[st].conversionsTo)nt.has(rt.from)||(G.push(rt),nt.add(rt.from))}return G}function Z($,V){let G=V;if($.some(st=>st.hasConversion)){const st=x($),rt=$.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])),V.apply(this,ut)}}let nt=G;if(x($)){const st=$.length-1;nt=function(){return G.apply(this,Nt(arguments,0,st).concat([Nt(arguments,st)]))}}return nt}function X($){let V,G,nt,st;const rt=[],ft=[];switch($.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 V=rt[0],nt=ft[0],function(ht){return V(ht)?nt(ht):ht};case 2:return V=rt[0],G=rt[1],nt=ft[0],st=ft[1],function(ht){return V(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($){function V(G,nt,st){if(nt<G.length){const rt=G[nt];let ft=[];if(rt.restParam){const ut=rt.types.filter(C);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 V(G,nt+1,st.concat([ut]))})}else return[st]}return V($,0,[])}function ct($,V){const G=Math.max($.length,V.length);for(let ut=0;ut<G;ut++){const ht=I($,ut),at=I(V,ut);let Xt=!1,ne;for(ne of at)if(ht.has(ne)){Xt=!0;break}if(!Xt)return!1}const nt=$.length,st=V.length,rt=x($),ft=x(V);return rt?ft?nt===st:st>=nt:ft?nt>=st:nt===st}function vt($){return $.map(V=>Re(V)?Ie(V.referToSelf.callback):_r(V)?Jt(V.referTo.references,V.referTo.callback):V)}function lt($,V,G){const nt=[];let st;for(st of $){let rt=G[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=V[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function wt($,V,G){const nt=vt($),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(Re(ht))nt[ut]=ht.referToSelf.callback(G),nt[ut].referToSelf=ht.referToSelf,st[ut]=!0,ft=!1;else if(_r(ht)){const at=lt(ht.referTo.references,nt,V);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($){const V=/\bthis(\(|\.signatures\b)/;Object.keys($).forEach(G=>{const nt=$[G];if(V.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($,V){if(a.createCount++,Object.keys(V).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&bt(V);const G=[],nt=[],st={},rt=[];let ft;for(ft in V){if(!Object.prototype.hasOwnProperty.call(V,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 Je=nt.length;nt.push(V[ft]);const du=Zt.map(E);let Bi;for(Bi of Q(du)){const $n=w(Bi);rt.push({params:Bi,name:$n,fn:Je}),Bi.every(Do=>!Do.hasConversion)&&(st[$n]=Je)}}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&&!x(at[0].params),De=at[1]&&at[1].params.length<=2&&!x(at[1].params),ke=at[2]&&at[2].params.length<=2&&!x(at[2].params),Pe=at[3]&&at[3].params.length<=2&&!x(at[3].params),gr=at[4]&&at[4].params.length<=2&&!x(at[4].params),vr=at[5]&&at[5].params.length<=2&&!x(at[5].params),In=ne&&De&&ke&&Pe&&gr&&vr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].test=M(at[Zt].params);const ti=ne?F(at[0].params[0]):Fr,vo=De?F(at[1].params[0]):Fr,Va=ke?F(at[2].params[0]):Fr,Za=Pe?F(at[3].params[0]):Fr,Ka=gr?F(at[4].params[0]):Fr,Ga=vr?F(at[5].params[0]):Fr,yo=ne?F(at[0].params[1]):Fr,Ha=De?F(at[1].params[1]):Fr,Ja=ke?F(at[2].params[1]):Fr,Xa=Pe?F(at[3].params[1]):Fr,ss=gr?F(at[4].params[1]):Fr,Qa=vr?F(at[5].params[1]):Fr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].implementation=Z(at[Zt].params,at[Zt].fn);const os=ne?at[0].implementation:pi,tu=De?at[1].implementation:pi,eu=ke?at[2].implementation:pi,ru=Pe?at[3].implementation:pi,nu=gr?at[4].implementation:pi,iu=vr?at[5].implementation:pi,su=ne?at[0].params.length:-1,ou=De?at[1].params.length:-1,au=ke?at[2].params.length:-1,wo=Pe?at[3].params.length:-1,uu=gr?at[4].params.length:-1,lu=vr?at[5].params.length:-1,cu=In?6:0,fu=at.length,hu=at.map(Zt=>Zt.test),pu=at.map(Zt=>Zt.implementation),Si=function(){for(let Je=cu;Je<fu;Je++)if(hu[Je](arguments))return pu[Je].apply(this,arguments);return a.onMismatch($,arguments,at)};function ei(Zt,Je){return arguments.length===su&&ti(Zt)&&yo(Je)?os.apply(this,arguments):arguments.length===ou&&vo(Zt)&&Ha(Je)?tu.apply(this,arguments):arguments.length===au&&Va(Zt)&&Ja(Je)?eu.apply(this,arguments):arguments.length===wo&&Za(Zt)&&Xa(Je)?ru.apply(this,arguments):arguments.length===uu&&Ka(Zt)&&ss(Je)?nu.apply(this,arguments):arguments.length===lu&&Ga(Zt)&&Qa(Je)?iu.apply(this,arguments):Si.apply(this,arguments)}try{Object.defineProperty(ei,"name",{value:$})}catch{}return ei.signatures=st,ei._typedFunctionData={signatures:at,signatureMap:Xt},ei}function Et($,V,G){throw L($,V,G)}function oe($){return Nt($,0,$.length-1)}function Tt($){return $[$.length-1]}function Nt($,V,G){return Array.prototype.slice.call($,V,G)}function le($,V){for(let G=0;G<$.length;G++)if(V($[G]))return $[G]}function re($,V){return Array.prototype.concat.apply([],$.map(V))}function kt(){const $=oe(arguments).map(G=>w(N(G))),V=Tt(arguments);if(typeof V!="function")throw new TypeError("Callback function expected as last argument");return Jt($,V)}function Jt($,V){return{referTo:{references:$,callback:V}}}function Ie($){if(typeof $!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:$}}}function _r($){return $&&typeof $.referTo=="object"&&Array.isArray($.referTo.references)&&typeof $.referTo.callback=="function"}function Re($){return $&&typeof $.referToSelf=="object"&&typeof $.referToSelf.callback=="function"}function pn($,V){if(!$)return V;if(V&&V!==$){const G=new Error("Function names do not match (expected: "+$+", actual: "+V+")");throw G.data={actual:V,expected:$},G}return $}function On($){let V;for(const G in $)Object.prototype.hasOwnProperty.call($,G)&&(d($[G])||typeof $[G].signature=="string")&&(V=pn(V,$[G].name));return V}function dn($,V){let G;for(G in V)if(Object.prototype.hasOwnProperty.call(V,G)){if(G in $&&V[G]!==$[G]){const nt=new Error('Signature "'+G+'" is defined twice');throw nt.data={signature:G,sourceFunction:V[G],destFunction:$[G]},nt}$[G]=V[G]}}const mr=a;a=function($){const V=typeof $=="string",G=V?1:0;let nt=V?$:"";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,V||(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}V||(nt=pn(nt,ht)),dn(st,ut)}return Bt(nt||"",st)},a.create=Ul,a.createCount=mr.createCount,a.onMismatch=Et,a.throwMismatchError=Et,a.createError=L,a.clear=p,a.clearConversions=h,a.addTypes=c,a._findType=l,a.referTo=kt,a.referToSelf=Ie,a.convert=m,a.findSignature=g,a.find=y,a.isTypedFunction=d,a.warnAgainstDeprecatedThis=!0,a.addType=function($,V){let G="any";V!==!1&&r.has("Object")&&(G="Object"),a.addTypes([$],G)};function Tn($){if(!$||typeof $.from!="string"||typeof $.to!="string"||typeof $.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if($.to===$.from)throw new SyntaxError('Illegal to define conversion from "'+$.from+'" to itself.')}return a.addConversion=function($){Tn($);const V=l($.to);if(V.conversionsTo.every(function(G){return G.from!==$.from}))V.conversionsTo.push({from:$.from,convert:$.convert,index:i++});else throw new Error('There is already a conversion from "'+$.from+'" to "'+V.name+'"')},a.addConversions=function($){$.forEach(a.addConversion)},a.removeConversion=function($){Tn($);const V=l($.to),G=le(V.conversionsTo,st=>st.from===$.from);if(!G)throw new Error("Attempt to remove nonexistent conversion from "+$.from+" to "+$.to);if(G.convert!==$.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=V.conversionsTo.indexOf(G);V.conversionsTo.splice(nt,1)},a.resolve=function($,V){if(!d($))throw new TypeError(kl);const G=$._typedFunctionData.signatures;for(let nt=0;nt<G.length;++nt)if(G[nt].test(V))return G[nt];return null},a}var Wl=Ul();function we(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(!we(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(!we(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 Sd(s,r);case"exponential":return Yl(s,r);case"engineering":return Nd(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 Bd(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(pe(s))e=s;else if(Me(s))e=s.toNumber();else if(ca(s))s.precision!==void 0&&(e=Vl(s.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),s.wordSize!==void 0&&(r=Vl(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 Ms(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 Nd(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=Ms(s),r=Ns(e,t),n=r.exponent,i=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(pe(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 p=Math.abs(n-a),h=1;p>0;)h++,p--;var f=i.slice(h).join(""),d=pe(t)&&f.length||f.match(/[1-9]/)?"."+f:"",g=i.slice(0,h).join("")+d+"e"+(n>=0?"+":"")+a.toString();return r.sign+g}function Sd(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=Ms(s),r=typeof t=="number"?Ns(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 Yl(s,t){if(isNaN(s)||!isFinite(s))return String(s);var e=Ms(s),r=t?Ns(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 Bd(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=Ms(s),a=t?Ns(i,t):i;if(a.exponent<r||a.exponent>=n)return Yl(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 p=c>0?c:0;return p<l.length-1&&l.splice(p+1,0,"."),a.sign+l.join("")}function Ns(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 Od(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 Vl(s,t){if(pe(s))return s;if(Me(s))return s.toNumber();t()}function Zl(s,t){return pe(s)?s:Me(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(!we(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 Id(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 Ld(s,r);case"exponential":return Kl(s,r);case"engineering":return $d(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),p=c.e;return p>=i&&p<a?l=c.toFixed():l=Kl(s,r),l.replace(/((\.\d*?)(0+))($|e)/,function(){var h=arguments[2],f=arguments[4];return h!=="."?h+f:f})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function $d(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 Ld(s,t){return s.toFixed(t)}function Gl(s,t){return pe(s)?s:Me(s)?s.toNumber():t}function ce(s,t){var e=Rd(s,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function Rd(s,t){if(typeof s=="number")return ha(s,t);if(Me(s))return Id(s,t);if(Pd(s))return!t||t.fraction!=="decimal"?s.s*s.n+"/"+s.d:s.toString();if(Array.isArray(s))return Xl(s,t);if(Qr(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)+": "+ce(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 ce(s,t)}function Pd(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 Oe(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 xe(s,t){if(s!==void 0){if(!pe(s)||!we(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(!pe(n)||!we(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+ce(t)+")")}),(pe(s)||Me(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 p=e+1;for(n=0;n<c;n++)i=s[n],Array.isArray(i)||(i=[i],s[n]=i),_a(i,t,p,r);for(n=c;n<l;n++)i=[],s[n]=i,_a(i,t,p,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 zd(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 zd(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||Oe(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 Ss(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?Ss(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],p=0;p<c;p++){var h=n-c+p;l[p]>i[h]&&(i[h]=l[p])}for(var f=0;f<t.length;f++)Bs(t[f],i);return i}function Bs(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=Oe(s);if(hi(e,t))return s;Bs(e,t);var r=qd(e,t),n=r.length,i=[...Array(n-e.length).fill(1),...e],a=Ud(s);e.length<n&&(a=ma(a,i),e=Oe(a));for(var l=0;l<n;l++)e[l]<r[l]&&(a=kd(a,r[l],l),e=Oe(a));return a}function kd(s,t,e){return sc(...Array(t).fill(s),e)}function Ud(s){return Fs([],s)}function mt(s,t,e,r){function n(i){var a=Cd(i,t.map(Yd));return Wd(s,t,i),e(a)}return n.isFactory=!0,n.fn=s,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function Wd(s,t,e){var r=t.filter(i=>!jd(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 jd(s){return s&&s[0]==="?"}function Yd(s){return s&&s[0]==="?"?s.slice(1):s}function Vd(s,t){if(uc(s)&&ac(s,t))return s[t];throw typeof s[t]=="function"&&Gd(s,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function Zd(s,t,e){if(uc(s)&&ac(s,t))return s[t]=e,e;throw new Error('No access to property "'+t+'"')}function Kd(s,t){return t in s}function ac(s,t){return!s||typeof s!="object"?!1:Ki(Hd,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Gd(s,t){return s==null||typeof s[t]!="function"||Ki(s,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(s)?!1:Ki(Jd,t)?!0:!(t in Object.prototype||t in Function.prototype)}function uc(s){return typeof s=="object"&&s&&s.constructor===Object}var Hd={length:!0,name:!0},Jd={toString:!0,valueOf:!0,toLocaleString:!0};class Xd{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return Vd(this.wrappedObject,t)}set(t,e){return Zd(this.wrappedObject,t,e),this}has(t){return Kd(this.wrappedObject,t)}entries(){return Qd(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 Qd(s,t){return{next:()=>{var e=s.next();return e.done?e:{value:t(e.value),done:!1}}}}function t_(s){return s?s instanceof Map||s instanceof Xd||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},e_=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],r_=mt("typed",e_,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:i}=t,a=lc();return a.clear(),a.addTypes([{name:"number",test:pe},{name:"Complex",test:Ll},{name:"BigNumber",test:Me},{name:"Fraction",test:Rl},{name:"Unit",test:Pl},{name:"identifier",test:l=>Qr&&/^(?:[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:Qr},{name:"Chain",test:xd},{name:"Array",test:Ee},{name:"Matrix",test:ge},{name:"DenseMatrix",test:Jp},{name:"SparseMatrix",test:Xp},{name:"Range",test:Qp},{name:"Index",test:la},{name:"boolean",test:td},{name:"ResultSet",test:ed},{name:"Help",test:rd},{name:"function",test:nd},{name:"Date",test:id},{name:"RegExp",test:sd},{name:"null",test:od},{name:"undefined",test:ad},{name:"AccessorNode",test:ud},{name:"ArrayNode",test:ld},{name:"AssignmentNode",test:cd},{name:"BlockNode",test:fd},{name:"ConditionalNode",test:hd},{name:"ConstantNode",test:pd},{name:"FunctionNode",test:_d},{name:"FunctionAssignmentNode",test:dd},{name:"IndexNode",test:md},{name:"Node",test:gd},{name:"ObjectNode",test:vd},{name:"OperatorNode",test:yd},{name:"ParenthesisNode",test:wd},{name:"RangeNode",test:Dd},{name:"RelationalNode",test:bd},{name:"SymbolNode",test:Ed},{name:"Map",test:t_},{name:"Object",test:ca}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(e||ya(c),Od(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||Os(c),new r(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return r||Os(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||Os(c),new r(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){i||wa(c);var p=new i(c);if(p.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 p}},{from:"string",to:"number",convert:function(c){var p=Number(c);if(isNaN(p))throw new Error('Cannot convert "'+c+'" to a number');return p}},{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||Os(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||n_(),new n(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),a.onMismatch=(l,c,p)=>{var h=a.createError(l,c,p);if(["wrongType","mismatch"].includes(h.data.category)&&c.length===1&&Zi(c[0])&&p.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=h.data,f}throw h},a.onMismatch=(l,c,p)=>{var h=a.createError(l,c,p);if(["wrongType","mismatch"].includes(h.data.category)&&c.length===1&&Zi(c[0])&&p.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=h.data,f}throw h},a});function ya(s){throw new Error("Cannot convert value ".concat(s," into a BigNumber: no class 'BigNumber' provided"))}function Os(s){throw new Error("Cannot convert value ".concat(s," into a Complex number: no class 'Complex' provided"))}function n_(){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",Ts="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Is="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ba={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-_i,maxE:_i,crypto:!1},cc,ln,St=!0,$s="[DecimalError] ",Fn=$s+"Invalid argument: ",fc=$s+"Precision limit exceeded",hc=$s+"crypto unavailable",pc="[object Decimal]",Ge=Math.floor,Le=Math.pow,i_=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,s_=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,o_=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,dc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Wr=1e7,xt=7,a_=9007199254740991,u_=Ts.length-1,Ea=Is.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,p=s.s;if(!a||!l)return!c||!p?NaN:c!==p?c:a===l?0:!a^c<0?1:-1;if(!a[0]||!l[0])return a[0]?c:l[0]?-p:0;if(c!==p)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())+xt,r.rounding=1,e=l_(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,p,h=this,f=h.constructor;if(!h.isFinite()||h.isZero())return new f(h);for(St=!1,i=h.s*Le(h.s*h,1/3),!i||Math.abs(i)==1/0?(e=Ye(h.d),s=h.e,(i=(s-e.length+1)%3)&&(e+=i==1||i==-2?"0":"00"),i=Le(e,1/3),s=Ge((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=h.s):r=new f(i.toString()),a=(s=f.precision)+3;;)if(l=r,c=l.times(l).times(l),p=c.plus(h),r=fe(p.plus(h).times(l),p.plus(c),a+2,1),Ye(l.d).slice(0,a)===(e=Ye(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(h))){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(h));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-Ge(this.e/xt))*xt,s=t[s],s)for(;s%10==0;s/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(s){return fe(this,new this.constructor(s))},it.dividedToIntegerBy=it.divToInt=function(s){var t=this,e=t.constructor;return Dt(fe(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/zs(4,s)).toString()):(s=16,t="2.3283064365386962890625e-10"),i=mi(a,1,i.times(t),new a(1),!0);for(var c,p=s,h=new a(8);p--;)c=i.times(i),i=l.minus(c.times(h.minus(c.times(h))));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/zs(5,s)),n=mi(i,2,n,n,!0);for(var a,l=new i(5),c=new i(16),p=new i(20);s--;)a=n.times(n),n=n.times(l.plus(a.times(c.times(a).plus(p))))}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,fe(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()?jr(e,n,i):new e(0):new e(NaN):t.isZero()?jr(e,n+4,i).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),s=jr(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=fe(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=jr(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,p=this,h=p.constructor,f=h.precision,d=h.rounding;if(p.isFinite()){if(p.isZero())return new h(p);if(p.abs().eq(1)&&f+4<=Ea)return a=jr(h,f+4,d).times(.25),a.s=p.s,a}else{if(!p.s)return new h(NaN);if(f+4<=Ea)return a=jr(h,f+4,d).times(.5),a.s=p.s,a}for(h.precision=l=f+10,h.rounding=1,e=Math.min(28,l/xt+2|0),s=e;s;--s)p=p.div(p.times(p).plus(1).sqrt().plus(1));for(St=!1,t=Math.ceil(l/xt),r=1,c=p.times(p),a=new h(p),n=p;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,h.precision=f,h.rounding=d,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&Ge(this.e/xt)>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,p=this,h=p.constructor,f=h.precision,d=h.rounding,g=5;if(s==null)s=new h(10),t=!0;else{if(s=new h(s),e=s.d,s.s<0||!e||!e[0]||s.eq(1))return new h(NaN);t=s.eq(10)}if(e=p.d,p.s<0||!e||!e[0]||p.eq(1))return new h(e&&!e[0]?-1/0:p.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(p,l),r=t?Ps(h,l+10):Nn(s,l),c=fe(a,r,l,1),Gi(c.d,n=f,d))do if(l+=10,a=Nn(p,l),r=t?Ps(h,l+10):Nn(s,l),c=fe(a,r,l,1),!i){+Ye(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,p,h,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(p=g.d,d=s.d,l=y.precision,c=y.rounding,!p[0]||!d[0]){if(d[0])s.s=-s.s;else if(p[0])s=new y(g);else return new y(c===3?-0:0);return St?Dt(s,l,c):s}if(e=Ge(s.e/xt),h=Ge(g.e/xt),p=p.slice(),i=h-e,i){for(f=i<0,f?(t=p,i=-i,a=d.length):(t=d,e=h,a=p.length),r=Math.max(Math.ceil(l/xt),a)+2,i>r&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for(r=p.length,a=d.length,f=r<a,f&&(a=r),r=0;r<a;r++)if(p[r]!=d[r]){f=p[r]<d[r];break}i=0}for(f&&(t=p,p=d,d=t,s.s=-s.s),a=p.length,r=d.length-a;r>0;--r)p[a++]=0;for(r=d.length;r>i;){if(p[--r]<d[r]){for(n=r;n&&p[--n]===0;)p[n]=Wr-1;--p[n],p[r]+=Wr}p[r]-=d[r]}for(;p[--a]===0;)p.pop();for(;p[0]===0;p.shift())--e;return p[0]?(s.d=p,s.e=Rs(p,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=fe(e,s.abs(),0,3,1),t.s*=s.s):t=fe(e,s,0,r.modulo,1),t=t.times(s),St=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return xa(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,p,h,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(p=f.d,h=s.d,l=d.precision,c=d.rounding,!p[0]||!h[0])return h[0]||(s=new d(f)),St?Dt(s,l,c):s;if(i=Ge(f.e/xt),r=Ge(s.e/xt),p=p.slice(),n=i-r,n){for(n<0?(e=p,n=-n,a=h.length):(e=h,r=i,a=p.length),i=Math.ceil(l/xt),a=i>a?i+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=p.length,n=h.length,a-n<0&&(n=a,e=h,h=p,p=e),t=0;n;)t=(p[--n]=p[n]+h[n]+t)/Wr|0,p[n]%=Wr;for(t&&(p.unshift(t),++r),a=p.length;p[--a]==0;)p.pop();return s.d=p,s.e=Rs(p,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())+xt,r.rounding=1,e=f_(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,p=a.s,h=a.constructor;if(p!==1||!l||!l[0])return new h(!p||p<0&&(!l||l[0])?NaN:l?a:1/0);for(St=!1,p=Math.sqrt(+a),p==0||p==1/0?(t=Ye(l),(t.length+c)%2==0&&(t+="0"),p=Math.sqrt(t),c=Ge((c+1)/2)-(c<0||c%2),p==1/0?t="5e"+c:(t=p.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new h(t)):r=new h(p.toString()),e=(c=h.precision)+3;;)if(i=r,r=i.plus(fe(a,i,e+2,1)).times(.5),Ye(i.d).slice(0,e)===(t=Ye(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,h.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=fe(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,p,h=this,f=h.constructor,d=h.d,g=(s=new f(s)).d;if(s.s*=h.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=Ge(h.e/xt)+Ge(s.e/xt),c=d.length,p=g.length,c<p&&(i=d,d=g,g=i,a=c,c=p,p=a),i=[],a=c+p,r=a;r--;)i.push(0);for(r=p;--r>=0;){for(t=0,n=c+r;n>r;)l=i[n]+g[r]*d[n-r-1]+t,i[n--]=l%Wr|0,t=l/Wr|0;i[n]=(i[n]+t)%Wr|0}for(;!i[--a];)i.pop();return t?++e:i.shift(),s.d=i,s.e=Rs(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:(or(s,0,Cn),t===void 0?t=r.rounding:or(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=tn(r,!0):(or(s,0,Cn),t===void 0?t=n.rounding:or(t,0,8),r=Dt(new n(r),s+1,t),e=tn(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=tn(n):(or(s,0,Cn),t===void 0?t=i.rounding:or(t,0,8),r=Dt(new i(n),s+n.e+1,t),e=tn(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,p,h,f,d,g=this,y=g.d,m=g.constructor;if(!y)return new m(g);if(p=e=new m(1),r=c=new m(0),t=new m(r),i=t.e=_c(y)-g.e-1,a=i%xt,t.d[0]=Le(10,a<0?xt+a:a),s==null)s=i>0?t:p;else{if(l=new m(s),!l.isInt()||l.lt(p))throw Error(Fn+l);s=l.gt(t)?i>0?t:p:l}for(St=!1,l=new m(Ye(y)),h=m.precision,m.precision=i=y.length*xt*2;f=fe(l,t,0,1,1),n=e.plus(f.times(r)),n.cmp(s)!=1;)e=r,r=n,n=p,p=c.plus(f.times(n)),c=n,n=t,t=l.minus(f.times(n)),l=n;return n=fe(s.minus(e),r,0,1,1),c=c.plus(n.times(p)),e=e.plus(n.times(r)),c.s=p.s=g.s,d=fe(p,r,i,1).minus(g).abs().cmp(fe(c,e,i,1).minus(g).abs())<1?[p,r]:[c,e],m.precision=h,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:or(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=fe(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,p=+(s=new c(s));if(!l.d||!s.d||!l.d[0]||!s.d[0])return new c(Le(+l,p));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=Ge(s.e/xt),t>=s.d.length-1&&(e=p<0?-p:p)<=a_)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=Le(+l,p),t=e==0||!isFinite(e)?Ge(p*(Math.log("0."+Ye(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=xa(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(xa(s.times(Nn(l,t+e)),t),t+5,1),+Ye(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=tn(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(or(s,1,Cn),t===void 0?t=n.rounding:or(t,0,8),r=Dt(new n(r),s,t),e=tn(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):(or(s,1,Cn),t===void 0?t=r.rounding:or(t,0,8)),Dt(new r(e),s,t)},it.toString=function(){var s=this,t=s.constructor,e=tn(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=tn(s,s.e<=t.toExpNeg||s.e>=t.toExpPos);return s.isNeg()?"-"+e:e};function Ye(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=xt-r.length,e&&(i+=Mn(e)),i+=r;a=s[t],r=a+"",e=xt-r.length,e&&(i+=Mn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function or(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+=xt,n=0):(n=Math.ceil((t+1)/xt),t%=xt),i=Le(10,xt-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)==Le(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)==Le(10,t-3)-1,a}function Ls(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 l_(s,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/zs(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 fe=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 p,h,f,d,g,y,m,w,v,E,b,N,x,F,M,S,I,C,B,L,U=r.constructor,k=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?k*0:k/0);for(c?(g=1,h=r.e-n.e):(c=Wr,g=xt,h=Ge(r.e/g)-Ge(n.e/g)),B=z.length,I=W.length,v=new U(k),E=v.d=[],f=0;z[f]==(W[f]||0);f++);if(z[f]>(W[f]||0)&&h--,i==null?(F=i=U.precision,a=U.rounding):l?F=i+(r.e-n.e)+1:F=i,F<0)E.push(1),y=!0;else{if(F=F/g+2|0,f=0,B==1){for(d=0,z=z[0],F++;(f<I||d)&&F--;f++)M=d*c+(W[f]||0),E[f]=M/z|0,d=M%z|0;y=d||f<I}else{for(d=c/(z[0]+1)|0,d>1&&(z=s(z,d,c),W=s(W,d,c),B=z.length,I=W.length),S=B,b=W.slice(0,B),N=b.length;N<B;)b[N++]=0;L=z.slice(),L.unshift(0),C=z[0],z[1]>=c/2&&++C;do d=0,p=t(z,b,B,N),p<0?(x=b[0],B!=N&&(x=x*c+(b[1]||0)),d=x/C|0,d>1?(d>=c&&(d=c-1),m=s(z,d,c),w=m.length,N=b.length,p=t(m,b,w,N),p==1&&(d--,e(m,B<w?L:z,w,c))):(d==0&&(p=d=1),m=z.slice()),w=m.length,w<N&&m.unshift(0),e(b,m,N,c),p==-1&&(N=b.length,p=t(z,b,B,N),p<1&&(d++,e(b,B<N?L:z,N,c))),N=b.length):p===0&&(d++,b=[0]),E[f++]=d,p&&b[0]?b[N++]=W[S]||0:(b=[W[S]],N=1);while((S++<I||b[0]!==void 0)&&F--);y=b[0]!==void 0}E[0]||E.shift()}if(g==1)v.e=h,cc=y;else{for(f=1,d=E[0];d>=10;d/=10)f++;v.e=f+h*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,p,h,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+=xt,a=t,h=f[d=0],c=h/Le(10,n-a-1)%10|0;else if(d=Math.ceil((i+1)/xt),l=f.length,d>=l)if(r){for(;l++<=d;)f.push(0);h=c=0,n=1,i%=xt,a=i-xt+1}else break t;else{for(h=l=f[d],n=1;l>=10;l/=10)n++;i%=xt,a=i-xt+n,c=a<0?0:h/Le(10,n-a-1)%10|0}if(r=r||t<0||f[d+1]!==void 0||(a<0?h:h%Le(10,n-a-1)),p=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?h/Le(10,n-a):0:f[d-1])%10&1||e==(s.s<0?8:7)),t<1||!f[0])return f.length=0,p?(t-=s.e+1,f[0]=Le(10,(xt-t%xt)%xt),s.e=-t||0):f[0]=s.e=0,s;if(i==0?(f.length=d,l=1,d--):(f.length=d+1,l=Le(10,xt-i),f[d]=a>0?(h/Le(10,n-a)%Le(10,a)|0)*l:0),p)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]==Wr&&(f[0]=1));break}else{if(f[d]+=l,f[d]!=Wr)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 tn(s,t,e){if(!s.isFinite())return yc(s);var r,n=s.e,i=Ye(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 Rs(s,t){var e=s[0];for(t*=xt;e>=10;e/=10)t++;return t}function Ps(s,t,e){if(t>u_)throw St=!0,e&&(s.precision=e),Error(fc);return Dt(new s(Ts),t,1,!0)}function jr(s,t,e){if(t>Ea)throw Error(fc);return Dt(new s(Is),t,e,!0)}function _c(s){var t=s.length-1,e=t*xt+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/xt+4);for(St=!1;;){if(e%2&&(i=i.times(t),Dc(i.d,a)&&(n=!0)),e=Ge(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 xa(s,t){var e,r,n,i,a,l,c,p=0,h=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(Le(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(++h),l=a.plus(fe(i,e,c,1)),Ye(l.d).slice(0,c)===Ye(a.d).slice(0,c)){for(n=f;n--;)a=Dt(a.times(a),c,1);if(t==null)if(p<3&&Gi(a.d,c-r,g,p))d.precision=c+=10,e=i=l=new d(1),h=0,p++;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,p,h,f,d,g=1,y=10,m=s,w=m.d,v=m.constructor,E=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,h=b):h=t,v.precision=h+=y,e=Ye(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=Ye(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 p=Ps(v,h+2,b).times(i+""),m=Nn(new v(r+"."+e.slice(1)),h-y).plus(p),v.precision=b,t==null?Dt(m,b,E,St=!0):m;for(f=m,c=a=m=fe(m.minus(1),m.plus(1),h,1),d=Dt(m.times(m),h,1),n=3;;){if(a=Dt(a.times(d),h,1),p=c.plus(fe(a,new v(n),h,1)),Ye(p.d).slice(0,h)===Ye(c.d).slice(0,h))if(c=c.times(2),i!==0&&(c=c.plus(Ps(v,h+2,b).times(i+""))),c=fe(c,new v(g),h,1),t==null)if(Gi(c.d,h-y,E,l))v.precision=h+=y,p=a=m=fe(f.minus(1),f.plus(1),h,1),d=Dt(m.times(m),h,1),n=l=1;else return Dt(c,v.precision=b,E,St=!0);else return v.precision=b,c;c=p,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)%xt,e<0&&(r+=xt),r<n){for(r&&s.d.push(+t.slice(0,r)),n-=xt;r<n;)s.d.push(+t.slice(r,r+=xt));t=t.slice(r),r=xt-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 c_(s,t){var e,r,n,i,a,l,c,p,h;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(s_.test(t))e=16,t=t.toLowerCase();else if(i_.test(t))e=2;else if(o_.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)),p=Ls(t,e,Wr),h=p.length-1,i=h;p[i]===0;--i)p.pop();return i<0?new r(s.s*0):(s.e=Rs(p,h),s.d=p,St=!1,a&&(s=fe(s,n,l*4)),c&&(s=s.times(Math.abs(c)<54?Le(2,c):gi.pow(2,c))),St=!0,s)}function f_(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/zs(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,p=s.precision,h=Math.ceil(p/xt);for(St=!1,c=e.times(e),l=new s(r);;){if(a=fe(l.times(c),new s(t++*t++),p,1),l=n?r.plus(a):r.minus(a),r=fe(a.times(c),new s(t++*t++),p,1),a=l.plus(r),a.d[h]!==void 0){for(i=h;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=h+1,a}function zs(s,t){for(var e=s;--t;)e*=s;return e}function wc(s,t){var e,r=t.s<0,n=jr(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,p,h,f,d,g=s.constructor,y=e!==void 0;if(y?(or(e,1,Cn),r===void 0?r=g.rounding:or(r,0,8)):(e=g.precision,r=g.rounding),!s.isFinite())h=yc(s);else{for(h=tn(s),a=h.indexOf("."),y?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(h=h.replace(".",""),d=new g(1),d.e=h.length-a,d.d=Ls(tn(d),10,n),d.e=d.d.length),f=Ls(h,10,n),i=c=f.length;f[--c]==0;)f.pop();if(!f[0])h=y?"0p+0":"0";else{if(a<0?i--:(s=new g(s),s.d=f,s.e=i,s=fe(s,d,e,r,0,n),f=s.d,i=s.e,p=cc),a=f[e],l=n/2,p=p||f[e+1]!==void 0,p=r<4?(a!==void 0||p)&&(r===0||r===(s.s<0?3:2)):a>l||a===l&&(r===4||p||r===6&&f[e-1]&1||r===(s.s<0?8:7)),f.length=e,p)for(;++f[--e]>n-1;)f[e]=0,e||(++i,f.unshift(1));for(c=f.length;!f[c-1];--c);for(a=0,h="";a<c;a++)h+=Da.charAt(f[a]);if(y){if(c>1)if(t==16||t==8){for(a=t==16?4:3,--c;c%a;c++)h+="0";for(f=Ls(h,n,t),c=f.length;!f[c-1];--c);for(a=1,h="1.";a<c;a++)h+=Da.charAt(f[a])}else h=h.charAt(0)+"."+h.slice(1);h=h+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)h="0"+h;h="0."+h}else if(++i>c)for(i-=c;i--;)h+="0";else i<c&&(h=h.slice(0,i)+"."+h.slice(i))}h=(t==16?"0x":t==2?"0b":t==8?"0o":"")+h}return s.s<0?"-"+h:h}function Dc(s,t){if(s.length>t)return s.length=t,!0}function h_(s){return new this(s).abs()}function p_(s){return new this(s).acos()}function d_(s){return new this(s).acosh()}function __(s,t){return new this(s).plus(t)}function m_(s){return new this(s).asin()}function g_(s){return new this(s).asinh()}function v_(s){return new this(s).atan()}function y_(s){return new this(s).atanh()}function w_(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=jr(this,i,1).times(t.s>0?.25:.75),e.s=s.s):!t.d||s.isZero()?(e=t.s<0?jr(this,r,n):new this(0),e.s=s.s):!s.d||t.isZero()?(e=jr(this,i,1).times(.5),e.s=s.s):t.s<0?(this.precision=i,this.rounding=1,e=this.atan(fe(s,t,i,1)),t=jr(this,i,1),this.precision=r,this.rounding=n,e=s.s<0?e.minus(t):e.plus(t)):e=this.atan(fe(s,t,i,1)),e}function D_(s){return new this(s).cbrt()}function b_(s){return Dt(s=new this(s),s.e+1,2)}function E_(s,t,e){return new this(s).clamp(t,e)}function x_(s){if(!s||typeof s!="object")throw Error($s+"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(Ge(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 A_(s){return new this(s).cos()}function C_(s){return new this(s).cosh()}function bc(s){var t,e,r;function n(i){var a,l,c,p=this;if(!(p instanceof n))return new n(i);if(p.constructor=n,Ec(i)){p.s=i.s,St?!i.d||i.e>n.maxE?(p.e=NaN,p.d=null):i.e<n.minE?(p.e=0,p.d=[0]):(p.e=i.e,p.d=i.d.slice()):(p.e=i.e,p.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){p.s=1/i<0?-1:1,p.e=0,p.d=[0];return}if(i<0?(i=-i,p.s=-1):p.s=1,i===~~i&&i<1e7){for(a=0,l=i;l>=10;l/=10)a++;St?a>n.maxE?(p.e=NaN,p.d=null):a<n.minE?(p.e=0,p.d=[0]):(p.e=a,p.d=[i]):(p.e=a,p.d=[i]);return}else if(i*0!==0){i||(p.s=NaN),p.e=NaN,p.d=null;return}return Aa(p,i.toString())}else if(c!=="string")throw Error(Fn+i);return(l=i.charCodeAt(0))===45?(i=i.slice(1),p.s=-1):(l===43&&(i=i.slice(1)),p.s=1),dc.test(i)?Aa(p,i):c_(p,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=x_,n.clone=bc,n.isDecimal=Ec,n.abs=h_,n.acos=p_,n.acosh=d_,n.add=__,n.asin=m_,n.asinh=g_,n.atan=v_,n.atanh=y_,n.atan2=w_,n.cbrt=D_,n.ceil=b_,n.clamp=E_,n.cos=A_,n.cosh=C_,n.div=F_,n.exp=M_,n.floor=N_,n.hypot=S_,n.ln=B_,n.log=O_,n.log10=I_,n.log2=T_,n.max=$_,n.min=L_,n.mod=R_,n.mul=P_,n.pow=z_,n.random=q_,n.round=k_,n.sign=U_,n.sin=W_,n.sinh=j_,n.sqrt=Y_,n.sub=V_,n.sum=Z_,n.tan=K_,n.tanh=G_,n.trunc=H_,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 F_(s,t){return new this(s).div(t)}function M_(s){return new this(s).exp()}function N_(s){return Dt(s=new this(s),s.e+1,3)}function S_(){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 Ec(s){return s instanceof gi||s&&s.toStringTag===pc||!1}function B_(s){return new this(s).ln()}function O_(s,t){return new this(s).log(t)}function T_(s){return new this(s).log(2)}function I_(s){return new this(s).log(10)}function $_(){return vc(this,arguments,"lt")}function L_(){return vc(this,arguments,"gt")}function R_(s,t){return new this(s).mod(t)}function P_(s,t){return new this(s).mul(t)}function z_(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:or(s,1,Cn),r=Math.ceil(s/xt),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%=xt,r&&s&&(n=Le(10,xt-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-=xt)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<xt&&(e-=xt-r)}return a.e=e,a.d=l,a}function k_(s){return Dt(s=new this(s),s.e+1,this.rounding)}function U_(s){return s=new this(s),s.d?s.d[0]?s.s:0*s.s:s.s||NaN}function W_(s){return new this(s).sin()}function j_(s){return new this(s).sinh()}function Y_(s){return new this(s).sqrt()}function V_(s,t){return new this(s).sub(t)}function Z_(){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 K_(s){return new this(s).tan()}function G_(s){return new this(s).tanh()}function H_(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);Ts=new gi(Ts),Is=new gi(Is);var J_="BigNumber",X_=["?on","config"],Q_=mt(J_,X_,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}),xc={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 p=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 h.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 h.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 E=y[v];E===" "||E===" "||E===`
|
46
|
-
`||(E==="+"?m++:E==="-"?w++:E==="i"||E==="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(E))&&l(),y[v+1]==="i"||y[v+1]==="I"?(g.im+=parseFloat((w%2?"-":"")+E),v++):g.re+=parseFloat((w%2?"-":"")+E),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 h(f,d){if(!(this instanceof h))return new h(f,d);var g=p(f,d);this.re=g.re,this.im=g.im}h.prototype={re:0,im:0,sign:function(){var f=this.abs();return new h(this.re/f,this.im/f)},add:function(f,d){var g=new h(f,d);return this.isInfinite()&&g.isInfinite()?h.NAN:this.isInfinite()||g.isInfinite()?h.INFINITY:new h(this.re+g.re,this.im+g.im)},sub:function(f,d){var g=new h(f,d);return this.isInfinite()&&g.isInfinite()?h.NAN:this.isInfinite()||g.isInfinite()?h.INFINITY:new h(this.re-g.re,this.im-g.im)},mul:function(f,d){var g=new h(f,d);return this.isInfinite()&&g.isZero()||this.isZero()&&g.isInfinite()?h.NAN:this.isInfinite()||g.isInfinite()?h.INFINITY:g.im===0&&this.im===0?new h(this.re*g.re,0):new h(this.re*g.re-this.im*g.im,this.re*g.im+this.im*g.re)},div:function(f,d){var g=new h(f,d);if(this.isZero()&&g.isZero()||this.isInfinite()&&g.isInfinite())return h.NAN;if(this.isInfinite()||g.isZero())return h.INFINITY;if(this.isZero()||g.isInfinite())return h.ZERO;f=this.re,d=this.im;var y=g.re,m=g.im,w,v;return m===0?new h(f/y,d/y):Math.abs(y)<Math.abs(m)?(v=y/m,w=y*v+m,new h((f*v+d)/w,(d*v-f)/w)):(v=m/y,w=m*v+y,new h((f+d*v)/w,(d-f*v)/w))},pow:function(f,d){var g=new h(f,d);if(f=this.re,d=this.im,g.isZero())return h.ONE;if(g.im===0){if(d===0&&f>0)return new h(Math.pow(f,g.re),0);if(f===0)switch((g.re%4+4)%4){case 0:return new h(Math.pow(d,g.re),0);case 1:return new h(0,Math.pow(d,g.re));case 2:return new h(-Math.pow(d,g.re),0);case 3:return new h(0,-Math.pow(d,g.re))}}if(f===0&&d===0&&g.re>0&&g.im>=0)return h.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 h(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 h(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 h(y,d<0?-m:m)},exp:function(){var f=Math.exp(this.re);return this.im,new h(f*Math.cos(this.im),f*Math.sin(this.im))},expm1:function(){var f=this.re,d=this.im;return new h(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 h(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 h(Math.sin(f)*r(d),Math.cos(f)*n(d))},cos:function(){var f=this.re,d=this.im;return new h(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 h(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 h(-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 h(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 h(Math.sin(f)*r(d)/g,-Math.cos(f)*n(d)/g)},asin:function(){var f=this.re,d=this.im,g=new h(d*d-f*f+1,-2*f*d).sqrt(),y=new h(g.re-d,g.im+f).log();return new h(y.im,-y.re)},acos:function(){var f=this.re,d=this.im,g=new h(d*d-f*f+1,-2*f*d).sqrt(),y=new h(g.re-d,g.im+f).log();return new h(Math.PI/2-y.im,y.re)},atan:function(){var f=this.re,d=this.im;if(f===0){if(d===1)return new h(0,1/0);if(d===-1)return new h(0,-1/0)}var g=f*f+(1-d)*(1-d),y=new h((1-d*d-f*f)/g,-2*f/g).log();return new h(-.5*y.im,.5*y.re)},acot:function(){var f=this.re,d=this.im;if(d===0)return new h(Math.atan2(1,f),0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).atan():new h(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 h(0,1/0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).acos():new h(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 h(Math.PI/2,1/0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).asin():new h(f!==0?f/0:0,d!==0?-d/0:0).asin()},sinh:function(){var f=this.re,d=this.im;return new h(n(f)*Math.cos(d),r(f)*Math.sin(d))},cosh:function(){var f=this.re,d=this.im;return new h(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 h(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 h(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 h(-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 h(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 h((m*y-d*d)/w,(d*y+m*d)/w):new h(f!==-1?f/0:0,d!==0?d/0:0),E=v.re;return v.re=c(v.re,v.im)/2,v.im=Math.atan2(v.im,E)/2,g&&(v.im=-v.im),v},acoth:function(){var f=this.re,d=this.im;if(f===0&&d===0)return new h(0,Math.PI/2);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).atanh():new h(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 h(f!==0?Math.log(f+Math.sqrt(f*f+1)):1/0,0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).asinh():new h(f!==0?f/0:0,d!==0?-d/0:0).asinh()},asech:function(){var f=this.re,d=this.im;if(this.isZero())return h.INFINITY;var g=f*f+d*d;return g!==0?new h(f/g,-d/g).acosh():new h(f!==0?f/0:0,d!==0?-d/0:0).acosh()},inverse:function(){if(this.isZero())return h.INFINITY;if(this.isInfinite())return h.ZERO;var f=this.re,d=this.im,g=f*f+d*d;return new h(f/g,-d/g)},conjugate:function(){return new h(this.re,-this.im)},neg:function(){return new h(-this.re,-this.im)},ceil:function(f){return f=Math.pow(10,f||0),new h(Math.ceil(this.re*f)/f,Math.ceil(this.im*f)/f)},floor:function(f){return f=Math.pow(10,f||0),new h(Math.floor(this.re*f)/f,Math.floor(this.im*f)/f)},round:function(f){return f=Math.pow(10,f||0),new h(Math.round(this.re*f)/f,Math.round(this.im*f)/f)},equals:function(f,d){var g=new h(f,d);return Math.abs(g.re-this.re)<=h.EPSILON&&Math.abs(g.im-this.im)<=h.EPSILON},clone:function(){return new h(this.re,this.im)},toString:function(){var f=this.re,d=this.im,g="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(f)<h.EPSILON&&(f=0),Math.abs(d)<h.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())}},h.ZERO=new h(0,0),h.ONE=new h(1,0),h.I=new h(0,1),h.PI=new h(Math.PI,0),h.E=new h(Math.E,0),h.INFINITY=new h(1/0,1/0),h.NAN=new h(NaN,NaN),h.EPSILON=1e-15,Object.defineProperty(h,"__esModule",{value:!0}),h.default=h,h.Complex=h,s.exports=h})()})(xc);var tm=xc.exports,Ve=Gt(tm),em="Complex",rm=[],nm=mt(em,rm,()=>(Object.defineProperty(Ve,"name",{value:"Complex"}),Ve.prototype.constructor=Ve,Ve.prototype.type="Complex",Ve.prototype.isComplex=!0,Ve.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Ve.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Ve.prototype.format=function(s){var t="",e=this.im,r=this.re,n=ha(this.re,s),i=ha(this.im,s),a=pe(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},Ve.fromPolar=function(s){switch(arguments.length){case 1:{var t=arguments[0];if(typeof t=="object")return Ve(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(pe(e)){if(Pl(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),pe(r))return new Ve({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")}},Ve.prototype.valueOf=Ve.prototype.toString,Ve.fromJSON=function(s){return new Ve(s)},Ve.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},Ve),{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,E){if(isNaN(v=parseInt(v,10)))throw m();return v*E}function a(v,E){if(E===0)throw y();var b=Object.create(g.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var N=d(v,E);return b.n=v/N,b.d=E/N,b}function l(v){for(var E={},b=v,N=2,x=4;x<=b;){for(;b%N===0;)b/=N,E[N]=(E[N]||0)+1;x+=1+2*N++}return b!==v?b>1&&(E[b]=(E[b]||0)+1):E[v]=(E[v]||0)+1,E}var c=function(v,E){var b=0,N=1,x=1,F=0,M=0,S=0,I=1,C=1,B=0,L=1,U=1,k=1,W=1e7,z;if(v!=null)if(E!==void 0){if(b=v,N=E,x=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();x=b*N;break}case"number":{if(v<0&&(x=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(C=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=C);L<=W&&k<=W;)if(z=(B+U)/(L+k),v===z){L+k<=W?(b=B+U,N=L+k):k>L?(b=U,N=k):(b=B,N=L);break}else v>z?(B+=U,L+=k):(U+=B,k+=L),L>W?(b=U,N=k):(b=B,N=L);b*=C}else(isNaN(v)||isNaN(E))&&(N=b=NaN);break}case"string":{if(L=v.match(/\d+|./g),L===null)throw m();if(L[B]==="-"?(x=-1,B++):L[B]==="+"&&B++,L.length===B+1?M=i(L[B++],x):L[B+1]==="."||L[B]==="."?(L[B]!=="."&&(F=i(L[B++],x)),B++,(B+1===L.length||L[B+1]==="("&&L[B+3]===")"||L[B+1]==="'"&&L[B+3]==="'")&&(M=i(L[B],x),I=Math.pow(10,L[B].length),B++),(L[B]==="("&&L[B+2]===")"||L[B]==="'"&&L[B+2]==="'")&&(S=i(L[B+1],x),C=Math.pow(10,L[B+1].length)-1,B+=3)):L[B+1]==="/"||L[B+1]===":"?(M=i(L[B],x),I=i(L[B+2],1),B+=3):L[B+3]==="/"&&L[B+1]===" "&&(F=i(L[B],x),M=i(L[B+2],x),I=i(L[B+4],1),B+=5),L.length<=B){N=I*C,x=b=S+N*F+C*M;break}}default:throw m()}if(N===0)throw y();n.s=x<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(N)};function p(v,E,b){for(var N=1;E>0;v=v*v%b,E>>=1)E&1&&(N=N*v%b);return N}function h(v,E){for(;E%2===0;E/=2);for(;E%5===0;E/=5);if(E===1)return 0;for(var b=10%E,N=1;b!==1;N++)if(b=b*10%E,N>r)return 0;return N}function f(v,E,b){for(var N=1,x=p(10,b,E),F=0;F<300;F++){if(N===x)return F;N=N*10%E,x=x*10%E}return 0}function d(v,E){if(!v)return E;if(!E)return v;for(;;){if(v%=E,!v)return E;if(E%=v,!E)return v}}function g(v,E){if(c(v,E),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,E){return c(v,E),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,E){return c(v,E),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,E){return c(v,E),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,E){return c(v,E),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,E){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,E),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,E){return c(v,E),a(d(n.n,this.n)*d(n.d,this.d),n.d*this.d)},lcm:function(v,E){return c(v,E),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,E){if(c(v,E),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),x=1,F=1;for(var M in b)if(M!=="1"){if(M==="0"){x=0;break}if(b[M]*=n.n,b[M]%n.d===0)b[M]/=n.d;else return null;x*=Math.pow(M,b[M])}for(var M in N)if(M!=="1"){if(N[M]*=n.n,N[M]%n.d===0)N[M]/=n.d;else return null;F*=Math.pow(M,N[M])}return n.s<0?a(F,x):a(x,F)},equals:function(v,E){return c(v,E),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,E){c(v,E);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var E=this.abs(),b=E.toContinued(),N=1;N<b.length;N++){for(var x=a(b[N-1],1),F=N-2;F>=0;F--)x=x.inverse().add(b[F]);if(Math.abs(x.sub(E).valueOf())<v)return x.mul(this.s)}return this},divisible:function(v,E){return c(v,E),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var E,b="",N=this.n,x=this.d;return this.s<0&&(b+="-"),x===1?b+=N:(v&&(E=Math.floor(N/x))>0&&(b+=E,b+=" ",N%=x),b+=N,b+="/",b+=x),b},toLatex:function(v){var E,b="",N=this.n,x=this.d;return this.s<0&&(b+="-"),x===1?b+=N:(v&&(E=Math.floor(N/x))>0&&(b+=E,N%=x),b+="\\frac{",b+=N,b+="}{",b+=x,b+="}"),b},toContinued:function(){var v,E=this.n,b=this.d,N=[];if(isNaN(E)||isNaN(b))return N;do N.push(Math.floor(E/b)),v=E%b,E=b,b=v;while(E!==1);return N},toString:function(v){var E=this.n,b=this.d;if(isNaN(E)||isNaN(b))return"NaN";v=v||15;var N=h(E,b),x=f(E,b,N),F=this.s<0?"-":"";if(F+=E/b|0,E%=b,E*=10,E&&(F+="."),N){for(var M=x;M--;)F+=E/b|0,E%=b,E*=10;F+="(";for(var M=N;M--;)F+=E/b|0,E%=b,E*=10;F+=")"}else for(var M=v;E&&M--;)F+=E/b|0,E%=b,E*=10;return F}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,s.exports=g})()})(Ac);var im=Ac.exports,cn=Gt(im),sm="Fraction",om=[],am=mt(sm,om,()=>(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}),um="Matrix",lm=[],cm=mt(um,lm,()=>{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 fm="DenseMatrix",hm=["Matrix"],pm=mt(fm,hm,s=>{var{Matrix:t}=s;function e(h,f){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(f&&!Qr(f))throw new Error("Invalid datatype: "+f);if(ge(h))h.type==="DenseMatrix"?(this._data=se(h._data),this._size=se(h._size),this._datatype=f||h._datatype):(this._data=h.toArray(),this._size=h.size(),this._datatype=f||h._datatype);else if(h&&Ee(h.data)&&Ee(h.size))this._data=h.data,this._size=h.size,tc(this._data,this._size),this._datatype=f||h.datatype;else if(Ee(h))this._data=p(h),this._size=Oe(this._data),tc(this._data,this._size),this._datatype=f;else{if(h)throw new TypeError("Unsupported type of data ("+xn(h)+")");this._data=[],this._size=[0],this._datatype=f}}e.prototype=new t,e.prototype.createDenseMatrix=function(h,f){return new e(h,f)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Ss(this._data,xn)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(h,f){return new e(h,f)},e.prototype.subset=function(h,f,d){switch(arguments.length){case 1:return r(this,h);case 2:case 3:return i(this,h,f,d);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(h){if(!Ee(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Ht(h.length,this._size.length);for(var f=0;f<h.length;f++)xe(h[f],this._size[f]);for(var d=this._data,g=0,y=h.length;g<y;g++){var m=h[g];xe(m,d.length),d=d[m]}return d},e.prototype.set=function(h,f,d){if(!Ee(h))throw new TypeError("Array expected");if(h.length<this._size.length)throw new Ht(h.length,this._size.length,"<");var g,y,m,w=h.map(function(E){return E+1});c(this,w,d);var v=this._data;for(g=0,y=h.length-1;g<y;g++)m=h[g],xe(m,v.length),v=v[m];return m=h[h.length-1],xe(m,v.length),v[m]=f,this};function r(h,f){if(!la(f))throw new TypeError("Invalid index");var d=f.isScalar();if(d)return h.get(f.min());var g=f.size();if(g.length!==h._size.length)throw new Ht(g.length,h._size.length);for(var y=f.min(),m=f.max(),w=0,v=h._size.length;w<v;w++)xe(y[w],h._size[w]),xe(m[w],h._size[w]);return new e(n(h._data,f,g.length,0),h._datatype)}function n(h,f,d,g){var y=g===d-1,m=f.dimension(g);return y?m.map(function(w){return xe(w,h.length),h[w]}).valueOf():m.map(function(w){xe(w,h.length);var v=h[w];return n(v,f,d,g+1)}).valueOf()}function i(h,f,d,g){if(!f||f.isIndex!==!0)throw new TypeError("Invalid index");var y=f.size(),m=f.isScalar(),w;if(ge(d)?(w=d.size(),d=d.valueOf()):w=Oe(d),m){if(w.length!==0)throw new TypeError("Scalar expected");h.set(f.min(),d,g)}else{if(!hi(w,y))try{w.length===0?d=oc([d],y):d=oc(d,y),w=Oe(d)}catch{}if(y.length<h._size.length)throw new Ht(y.length,h._size.length,"<");if(w.length<y.length){for(var v=0,E=0;y[v]===1&&w[v]===1;)v++;for(;y[v]===1;)E++,v++;d=rc(d,y.length,E,w)}if(!hi(y,w))throw new Ht(y,w,">");var b=f.max().map(function(F){return F+1});c(h,b,g);var N=y.length,x=0;a(h._data,f,d,N,x)}return h}function a(h,f,d,g,y){var m=y===g-1,w=f.dimension(y);m?w.forEach(function(v,E){xe(v),h[v]=d[E[0]]}):w.forEach(function(v,E){xe(v),a(h[v],f,d[E[0]],g,y+1)})}e.prototype.resize=function(h,f,d){if(!Zi(h))throw new TypeError("Array or Matrix expected");var g=h.valueOf().map(m=>Array.isArray(m)&&m.length===1?m[0]:m),y=d?this.clone():this;return l(y,g,f)};function l(h,f,d){if(f.length===0){for(var g=h._data;Ee(g);)g=g[0];return g}return h._size=f.slice(0),h._data=da(h._data,h._size,d),h}e.prototype.reshape=function(h,f){var d=f?this.clone():this;d._data=ma(d._data,h);var g=d._size.reduce((y,m)=>y*m);return d._size=ga(h,g),d};function c(h,f,d){for(var g=h._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(h,g,d)}e.prototype.clone=function(){var h=new e({data:se(this._data),size:se(this._size),datatype:this._datatype});return h},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(h){var f=this,d=Cc(h),g=function w(v,E){return Ee(v)?v.map(function(b,N){return w(b,E.concat(N))}):d===1?h(v):d===2?h(v,E):h(v,E,f)},y=g(this._data,[]),m=this._datatype!==void 0?Ss(y,xn):void 0;return new e(y,m)},e.prototype.forEach=function(h){var f=this,d=function g(y,m){Ee(y)?y.forEach(function(w,v){g(w,m.concat(v))}):h(y,m,f)};d(this._data,[])},e.prototype[Symbol.iterator]=function*(){var h=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*h(this._data,[])},e.prototype.rows=function(){var h=[],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)h.push(new e([g],this._datatype));return h},e.prototype.columns=function(){var h=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 E=g.map(b=>[b[v]]);f.push(new e(E,h._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(h){return ce(this._data,h)},e.prototype.toString=function(){return ce(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(h){if(h){if(Me(h)&&(h=h.toNumber()),!pe(h)||!we(h))throw new TypeError("The parameter k must be an integer number")}else h=0;for(var f=h>0?h:0,d=h<0?-h: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(h,f,d,g){if(!Ee(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(M){if(Me(M)&&(M=M.toNumber()),!pe(M)||!we(M)||M<1)throw new Error("Size values must be positive integers");return M}),d){if(Me(d)&&(d=d.toNumber()),!pe(d)||!we(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=h[0],v=h[1],E=Math.min(w-m,v-y),b;if(Ee(f)){if(f.length!==E)throw new Error("Invalid value array length");b=function(S){return f[S]}}else if(ge(f)){var N=f.size();if(N.length!==1||N[0]!==E)throw new Error("Invalid matrix length");b=function(S){return f.get([S])}}else b=function(){return f};g||(g=Me(b(0))?b(0).mul(0):0);var x=[];if(h.length>0){x=da(x,h,g);for(var F=0;F<E;F++)x[F+m][F+y]=b(F)}return new e({data:x,size:[w,v]})},e.fromJSON=function(h){return new e(h)},e.prototype.swapRows=function(h,f){if(!pe(h)||!we(h)||!pe(f)||!we(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 xe(h,this._size[0]),xe(f,this._size[0]),e._swapRows(h,f,this._data),this},e._swapRows=function(h,f,d){var g=d[h];d[h]=d[f],d[f]=g};function p(h){return ge(h)?p(h.valueOf()):Ee(h)?h.map(p):h}return e},{isClass:!0});function dm(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 qs(s){for(var t=0;t<s.length;t++)if(Zi(s[t]))return!0;return!1}function Hi(s,t){ge(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)?Oe(s):s.size();if(t<0||t>=r.length)throw new An(t,r.length);return ge(s)?s.create(ks(s.valueOf(),t,e)):ks(s,t,e)}function ks(s,t,e){var r,n,i,a;if(t<=0)if(Array.isArray(s[0])){for(a=dm(s),n=[],r=0;r<a.length;r++)n[r]=ks(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]=ks(s[r],t-1,e);return n}}var Fc="isInteger",_m=["typed"],mm=mt(Fc,_m,s=>{var{typed:t}=s;return t(Fc,{number:we,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",Us="number, number";function Nc(s){return Math.abs(s)}Nc.signature=Mc;function Sc(s,t){return s+t}Sc.signature=Us;function Bc(s,t){return s-t}Bc.signature=Us;function Oc(s,t){return s*t}Oc.signature=Us;function Tc(s){return-s}Tc.signature=Mc;function Ic(s,t){return s*s<1&&t===1/0||s*s>1&&t===-1/0?0:Math.pow(s,t)}Ic.signature=Us;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",gm=["typed"],vm=mt(Pc,gm,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",ym=["typed"],wm=mt(zc,ym,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))})}),qc="isNaN",Dm=["typed"],bm=mt(qc,Dm,s=>{var{typed:t}=s;return t(qc,{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 Ws(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 js=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)})}}),Ys="equalScalar",xm=["typed","config"],Am=mt(Ys,xm,s=>{var{typed:t,config:e}=s,r=js({typed:t});return t(Ys,{"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)||Ws(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(Ys,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Ys,{"number, number":function(n,i){return Gn(n,i,e.epsilon)}})});var Cm="SparseMatrix",Fm=["typed","equalScalar","Matrix"],Mm=mt(Cm,Fm,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&&!Qr(w))throw new Error("Invalid datatype: "+w);if(ge(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 ("+xn(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 E=w.length,b=0,N=e,x=0;if(Qr(v)&&(N=t.find(e,[v,v])||e,x=t.convert(0,v)),E>0){var F=0;do{m._ptr.push(m._index.length);for(var M=0;M<E;M++){var S=w[M];if(Ee(S)){if(F===0&&b<S.length&&(b=S.length),F<S.length){var I=S[F];N(I,x)||(m._values.push(I),m._index.push(M))}}else F===0&&b<1&&(b=1),N(S,x)||(m._values.push(S),m._index.push(M))}F++}while(F<b)}m._ptr.push(m._index.length),m._size=[E,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 Ss(this._values,xn)},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 E=w.size();if(E.length!==m._size.length)throw new Ht(E.length,m._size.length);var b,N,x,F,M=w.min(),S=w.max();for(b=0,N=m._size.length;b<N;b++)xe(M[b],m._size[b]),xe(S[b],m._size[b]);var I=m._values,C=m._index,B=m._ptr,L=w.dimension(0),U=w.dimension(1),k=[],W=[];L.forEach(function(X,Q){W[X]=Q[0],k[X]=!0});var z=I?[]:void 0,K=[],Z=[];return U.forEach(function(X){for(Z.push(K.length),x=B[X],F=B[X+1];x<F;x++)b=C[x],k[b]===!0&&(K.push(W[b]),z&&z.push(I[x]))}),Z.push(K.length),new n({values:z,index:K,ptr:Z,size:E,datatype:m._datatype})}function c(m,w,v,E){if(!w||w.isIndex!==!0)throw new TypeError("Invalid index");var b=w.size(),N=w.isScalar(),x;if(ge(v)?(x=v.size(),v=v.toArray()):x=Oe(v),N){if(x.length!==0)throw new TypeError("Scalar expected");m.set(w.min(),v,E)}else{if(b.length!==1&&b.length!==2)throw new Ht(b.length,m._size.length,"<");if(x.length<b.length){for(var F=0,M=0;b[F]===1&&x[F]===1;)F++;for(;b[F]===1;)M++,F++;v=rc(v,b.length,M,x)}if(!hi(b,x))throw new Ht(b,x,">");if(b.length===1){var S=w.dimension(0);S.forEach(function(B,L){xe(B),m.set([B,0],v[L[0]],E)})}else{var I=w.dimension(0),C=w.dimension(1);I.forEach(function(B,L){xe(B),C.forEach(function(U,k){xe(U),m.set([B,U],v[L[0]][k[0]],E)})})}}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];xe(w,this._size[0]),xe(v,this._size[1]);var E=p(w,this._ptr[v],this._ptr[v+1],this._index);return E<this._ptr[v+1]&&this._index[E]===w?this._values[E]: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 E=m[0],b=m[1],N=this._size[0],x=this._size[1],F=e,M=0;Qr(this._datatype)&&(F=t.find(e,[this._datatype,this._datatype])||e,M=t.convert(0,this._datatype)),(E>N-1||b>x-1)&&(d(this,Math.max(E+1,N),Math.max(b+1,x),v),N=this._size[0],x=this._size[1]),xe(E,N),xe(b,x);var S=p(E,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===E?F(w,M)?h(S,b,this._values,this._index,this._ptr):this._values[S]=w:F(w,M)||f(S,E,b,w,this._values,this._index,this._ptr),this};function p(m,w,v,E){if(v-w===0)return v;for(var b=w;b<v;b++)if(E[b]===m)return b;return w}function h(m,w,v,E,b){v.splice(m,1),E.splice(m,1);for(var N=w+1;N<b.length;N++)b[N]--}function f(m,w,v,E,b,N,x){b.splice(m,0,E),N.splice(m,0,w);for(var F=v+1;F<x.length;F++)x[F]++}n.prototype.resize=function(m,w,v){if(!Zi(m))throw new TypeError("Array or Matrix expected");var E=m.valueOf().map(N=>Array.isArray(N)&&N.length===1?N[0]:N);if(E.length!==2)throw new Error("Only two dimensions matrix are supported");E.forEach(function(N){if(!pe(N)||!we(N)||N<0)throw new TypeError("Invalid size, must contain positive integers (size: "+ce(E)+")")});var b=v?this.clone():this;return d(b,E[0],E[1],w)};function d(m,w,v,E){var b=E||0,N=e,x=0;Qr(m._datatype)&&(N=t.find(e,[m._datatype,m._datatype])||e,x=t.convert(0,m._datatype),b=t.convert(b,m._datatype));var F=!N(b,x),M=m._size[0],S=m._size[1],I,C,B;if(v>S){for(C=S;C<v;C++)if(m._ptr[C]=m._values.length,F)for(I=0;I<M;I++)m._values.push(b),m._index.push(I);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(F){var L=0;for(C=0;C<S;C++){m._ptr[C]=m._ptr[C]+L,B=m._ptr[C+1]+L;var U=0;for(I=M;I<w;I++,U++)m._values.splice(B+U,0,b),m._index.splice(B+U,0,I),L++}m._ptr[S]=m._values.length}}else if(w<M){var k=0;for(C=0;C<S;C++){m._ptr[C]=m._ptr[C]-k;var W=m._ptr[C],z=m._ptr[C+1]-k;for(B=W;B<z;B++)I=m._index[B],I>w-1&&(m._values.splice(B,1),m._index.splice(B,1),k++)}m._ptr[C]=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(!pe(X)||!we(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+ce(m)+")")});var v=this._size[0]*this._size[1];m=ga(m,v);var E=m[0]*m[1];if(v!==E)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=[],x=0;x<b._ptr.length;x++)for(var F=0;F<b._ptr[x+1]-b._ptr[x];F++)N.push(x);for(var M=b._values.slice(),S=b._index.slice(),I=0;I<b._index.length;I++){var C=S[I],B=N[I],L=C*b._size[1]+B;N[I]=L%m[1],S[I]=Math.floor(L/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 k=0;k<M.length;k++){var W=S[k],z=N[k],K=M[k],Z=p(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,E=this._size[0],b=this._size[1],N=Cc(m),x=function(M,S,I){return N===1?m(M):N===2?m(M,[S,I]):m(M,[S,I],v)};return g(this,0,E-1,0,b-1,x,w)};function g(m,w,v,E,b,N,x){var F=[],M=[],S=[],I=e,C=0;Qr(m._datatype)&&(I=t.find(e,[m._datatype,m._datatype])||e,C=t.convert(0,m._datatype));for(var B=function(lt,wt,bt){lt=N(lt,wt,bt),I(lt,C)||(F.push(lt),M.push(wt))},L=E;L<=b;L++){S.push(F.length);var U=m._ptr[L],k=m._ptr[L+1];if(x)for(var W=U;W<k;W++){var z=m._index[W];z>=w&&z<=v&&B(m._values[W],z-w,L-E)}else{for(var K={},Z=U;Z<k;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;B(ct,Q-w,L-E)}}}return S.push(F.length),new n({values:F,index:M,ptr:S,size:[v-w+1,b-E+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,E=this._size[0],b=this._size[1],N=0;N<b;N++){var x=this._ptr[N],F=this._ptr[N+1];if(w)for(var M=x;M<F;M++){var S=this._index[M];m(this._values[M],[S,N],v)}else{for(var I={},C=x;C<F;C++){var B=this._index[C];I[B]=this._values[C]}for(var L=0;L<E;L++){var U=L in I?I[L]:0;m(U,[L,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],E=this._ptr[w+1],b=v;b<E;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,E,b){var N=E[0],x=E[1],F=[],M,S;for(M=0;M<N;M++)for(F[M]=[],S=0;S<x;S++)F[M][S]=0;for(S=0;S<x;S++)for(var I=v[S],C=v[S+1],B=I;B<C;B++)M=w[B],F[M][S]=m?b?se(m[B]):m[B]:1;return F}return n.prototype.format=function(m){for(var w=this._size[0],v=this._size[1],E=this.density(),b="Sparse Matrix ["+ce(w,m)+" x "+ce(v,m)+"] density: "+ce(E,m)+`
|
53
|
-
`,N=0;N<v;N++)for(var x=this._ptr[N],F=this._ptr[N+1],M=x;M<F;M++){var S=this._index[M];b+=`
|
54
|
-
(`+ce(S,m)+", "+ce(N,m)+") ==> "+(this._values?ce(this._values[M],m):"X")}return b},n.prototype.toString=function(){return ce(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(Me(m)&&(m=m.toNumber()),!pe(m)||!we(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,E=this._size[0],b=this._size[1],N=Math.min(E-v,b-w),x=[],F=[],M=[];M[0]=0;for(var S=w;S<b&&x.length<N;S++)for(var I=this._ptr[S],C=this._ptr[S+1],B=I;B<C;B++){var L=this._index[B];if(L===S-w+v){x.push(this._values[B]),F[x.length-1]=L-v;break}}return M.push(x.length),new n({values:x,index:F,ptr:M,size:[N,1]})},n.fromJSON=function(m){return new n(m)},n.diagonal=function(m,w,v,E,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(Me(X)&&(X=X.toNumber()),!pe(X)||!we(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Me(v)&&(v=v.toNumber()),!pe(v)||!we(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var N=e,x=0;Qr(b)&&(N=t.find(e,[b,b])||e,x=t.convert(0,b));var F=v>0?v:0,M=v<0?-v:0,S=m[0],I=m[1],C=Math.min(S-M,I-F),B;if(Ee(w)){if(w.length!==C)throw new Error("Invalid value array length");B=function(Q){return w[Q]}}else if(ge(w)){var L=w.size();if(L.length!==1||L[0]!==C)throw new Error("Invalid matrix length");B=function(Q){return w.get([Q])}}else B=function(){return w};for(var U=[],k=[],W=[],z=0;z<I;z++){W.push(U.length);var K=z-F;if(K>=0&&K<C){var Z=B(K);N(Z,x)||(k.push(K+M),U.push(Z))}}return W.push(U.length),new n({values:U,index:k,ptr:W,size:[S,I]})},n.prototype.swapRows=function(m,w){if(!pe(m)||!we(m)||!pe(w)||!we(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 xe(m,this._size[0]),xe(w,this._size[0]),n._swapRows(m,w,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(m,w,v,E,b){for(var N=E[m],x=E[m+1],F=N;F<x;F++)b(v[F],w[F])},n._swapRows=function(m,w,v,E,b,N){for(var x=0;x<v;x++){var F=N[x],M=N[x+1],S=p(m,F,M,b),I=p(w,F,M,b);if(S<M&&I<M&&b[S]===m&&b[I]===w){if(E){var C=E[S];E[S]=E[I],E[I]=C}continue}if(S<M&&b[S]===m&&(I>=M||b[I]!==w)){var B=E?E[S]:void 0;b.splice(I,0,w),E&&E.splice(I,0,B),b.splice(I<=S?S+1:S,1),E&&E.splice(I<=S?S+1:S,1);continue}if(I<M&&b[I]===w&&(S>=M||b[S]!==m)){var L=E?E[I]:void 0;b.splice(S,0,m),E&&E.splice(S,0,L),b.splice(S<=I?I+1:I,1),E&&E.splice(S<=I?I+1:I,1)}}},n},{isClass:!0}),Nm="number",Sm=["typed"];function Bm(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 Om(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(Nm,Sm,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=Bm(n);if(i)return Om(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}),Im="bignumber",$m=["typed","BigNumber"],Lm=mt(Im,$m,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 p=new e(2).pow(Number(a)-1);return l.gte(p)?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))})}),Rm="fraction",Pm=["typed","Fraction"],zm=mt(Rm,Pm,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))})}),kc="matrix",qm=["typed","Matrix","DenseMatrix","SparseMatrix"],km=mt(kc,qm,s=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=s;return t(kc,{"":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",Um=["typed"],Wm=mt(Uc,Um,s=>{var{typed:t}=s;return t(Uc,{number:Tc,"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",jm=["typed"],Ym=mt(Wc,jm,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",Vm=["typed"],Zm=mt(jc,Vm,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})})}),Yc="subtractScalar",Km=["typed"],Gm=mt(Yc,Km,s=>{var{typed:t}=s;return t(Yc,{"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})})}),Hm="matAlgo11xS0s",Jm=["typed","equalScalar"],Ma=mt(Hm,Jm,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a,l){var c=n._values,p=n._index,h=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,E=a;typeof d=="string"&&(m=d,w=t.find(e,[m,m]),v=t.convert(0,m),i=t.convert(i,m),E=t.find(a,[m,m]));for(var b=[],N=[],x=[],F=0;F<y;F++){x[F]=N.length;for(var M=h[F],S=h[F+1],I=M;I<S;I++){var C=p[I],B=l?E(i,c[I]):E(c[I],i);w(B,v)||(N.push(C),b.push(B))}}return x[y]=N.length,n.createSparseMatrix({values:b,index:N,ptr:x,size:[g,y],datatype:m})}}),Xm="matAlgo12xSfs",Qm=["typed","DenseMatrix"],vi=mt(Xm,Qm,s=>{var{typed:t,DenseMatrix:e}=s;return function(n,i,a,l){var c=n._values,p=n._index,h=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=[],E=[],b=[],N=0;N<y;N++){for(var x=N+1,F=h[N],M=h[N+1],S=F;S<M;S++){var I=p[S];E[I]=c[S],b[I]=x}for(var C=0;C<g;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?w(i,E[C]):w(E[C],i):v[C][N]=l?w(i,0):w(0,i)}return new e({data:v,size:[g,y],datatype:m})}}),tg="matAlgo14xDs",eg=["typed"],Na=mt(tg,eg,s=>{var{typed:t}=s;return function(n,i,a,l){var c=n._data,p=n._size,h=n._datatype,f,d=a;typeof h=="string"&&(f=h,i=t.convert(i,f),d=t.find(a,[f,f]));var g=p.length>0?e(d,0,p,p[0],c,i,l):[];return n.createDenseMatrix({data:g,size:se(p),datatype:f})};function e(r,n,i,a,l,c,p){var h=[];if(n===i.length-1)for(var f=0;f<a;f++)h[f]=p?r(c,l[f]):r(l[f],c);else for(var d=0;d<a;d++)h[d]=e(r,n+1,i,i[n+1],l[d],c,p);return h}}),rg="matAlgo02xDS0",ng=["typed","equalScalar"],ig=mt(rg,ng,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a,l){var c=n._data,p=n._size,h=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(p.length!==y.length)throw new Ht(p.length,y.length);if(p[0]!==y[0]||p[1]!==y[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+y+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var w=p[0],v=p[1],E,b=e,N=0,x=a;typeof h=="string"&&h===m&&h!=="mixed"&&(E=h,b=t.find(e,[E,E]),N=t.convert(0,E),x=t.find(a,[E,E]));for(var F=[],M=[],S=[],I=0;I<v;I++){S[I]=M.length;for(var C=g[I],B=g[I+1],L=C;L<B;L++){var U=d[L],k=l?x(f[L],c[U][I]):x(c[U][I],f[L]);b(k,N)||(M.push(U),F.push(k))}}return S[v]=M.length,i.createSparseMatrix({values:F,index:M,ptr:S,size:[w,v],datatype:h===n._datatype&&m===i._datatype?E:void 0})}}),sg="matAlgo03xDSf",og=["typed"],yi=mt(sg,og,s=>{var{typed:t}=s;return function(r,n,i,a){var l=r._data,c=r._size,p=r._datatype||r.getDataType(),h=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(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v,E=0,b=i;typeof p=="string"&&p===y&&p!=="mixed"&&(v=p,E=t.convert(0,v),b=t.find(i,[v,v]));for(var N=[],x=0;x<m;x++)N[x]=[];for(var F=[],M=[],S=0;S<w;S++){for(var I=S+1,C=d[S],B=d[S+1],L=C;L<B;L++){var U=f[L];F[U]=a?b(h[L],l[U][S]):b(l[U][S],h[L]),M[U]=I}for(var k=0;k<m;k++)M[k]===I?N[k][S]=F[k]:N[k][S]=a?b(E,l[k][S]):b(l[k][S],E)}return r.createDenseMatrix({data:N,size:[m,w],datatype:p===r._datatype&&y===n._datatype?v:void 0})}}),ag="matAlgo05xSfSf",ug=["typed","equalScalar"],Vc=mt(ag,ug,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a){var l=n._values,c=n._index,p=n._ptr,h=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(h.length!==m.length)throw new Ht(h.length,m.length);if(h[0]!==m[0]||h[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+m+")");var v=h[0],E=h[1],b,N=e,x=0,F=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],I=[],C=M?[]:void 0,B=M?[]:void 0,L=[],U=[],k,W,z,K;for(W=0;W<E;W++){I[W]=S.length;var Z=W+1;for(z=p[W],K=p[W+1];z<K;z++)k=c[z],S.push(k),L[k]=Z,C&&(C[k]=l[z]);for(z=y[W],K=y[W+1];z<K;z++)k=g[z],L[k]!==Z&&S.push(k),U[k]=Z,B&&(B[k]=d[z]);if(M)for(z=I[W];z<S.length;){k=S[z];var X=L[k],Q=U[k];if(X===Z||Q===Z){var ct=X===Z?C[k]:x,vt=Q===Z?B[k]:x,lt=F(ct,vt);N(lt,x)?S.splice(z,1):(M.push(lt),z++)}}}return I[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:I,size:[v,E],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),lg="matAlgo13xDD",cg=["typed"],fg=mt(lg,cg,s=>{var{typed:t}=s;return function(n,i,a){var l=n._data,c=n._size,p=n._datatype,h=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 p=="string"&&p===d&&(m=p,w=t.find(a,[m,m]));var v=g.length>0?e(w,0,g,g[0],l,h):[];return n.createDenseMatrix({data:v,size:g,datatype:m})};function e(r,n,i,a,l,c){var p=[];if(n===i.length-1)for(var h=0;h<a;h++)p[h]=r(l[h],c[h]);else for(var f=0;f<a;f++)p[f]=e(r,n+1,i,i[n+1],l[f],c[f]);return p}}),hg="broadcast",pg=["concat"],dg=mt(hg,pg,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),p=[],h=0;h<a;h++)p[h]=Math.max(l[h],c[h]);Bs(l,p),Bs(c,p);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]<p[g]&&(f=r(f,p[g],g)),d._size[g]<p[g]&&(d=r(d,p[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)}}),_g="matrixAlgorithmSuite",mg=["typed","matrix","concat"],Hn=mt(_g,mg,s=>{var{typed:t,matrix:e,concat:r}=s,n=fg({typed:t}),i=Na({typed:t}),a=dg({concat:r});return function(c){var p=c.elop,h=c.SD||c.DS,f;p?(f={"DenseMatrix, DenseMatrix":(m,w)=>n(...a(m,w),p),"Array, Array":(m,w)=>n(...a(e(m),e(w)),p).valueOf(),"Array, DenseMatrix":(m,w)=>n(...a(e(m),w),p),"DenseMatrix, Array":(m,w)=>n(...a(m,e(w)),p)},c.SS&&(f["SparseMatrix, SparseMatrix"]=(m,w)=>c.SS(...a(m,w),p,!1)),c.DS&&(f["DenseMatrix, SparseMatrix"]=(m,w)=>c.DS(...a(m,w),p,!1),f["Array, SparseMatrix"]=(m,w)=>c.DS(...a(e(m),w),p,!1)),h&&(f["SparseMatrix, DenseMatrix"]=(m,w)=>h(...a(w,m),p,!0),f["SparseMatrix, Array"]=(m,w)=>h(...a(e(w),m),p,!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))),h&&(f["SparseMatrix, DenseMatrix"]=t.referToSelf(m=>(w,v)=>h(...a(v,w),m,!0)),f["SparseMatrix, Array"]=t.referToSelf(m=>(w,v)=>h(...a(e(v),w),m,!0))));var d=c.scalar||"any",g=c.Ds||c.Ss;g&&(p?(f["DenseMatrix,"+d]=(m,w)=>i(m,w,p,!1),f[d+", DenseMatrix"]=(m,w)=>i(w,m,p,!0),f["Array,"+d]=(m,w)=>i(e(m),w,p,!1).valueOf(),f[d+", Array"]=(m,w)=>i(e(w),m,p,!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 p?(c.Ss&&(f["SparseMatrix,"+d]=(m,w)=>c.Ss(m,w,p,!1)),y&&(f[d+", SparseMatrix"]=(m,w)=>y(w,m,p,!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)))),p&&p.signatures&&zl(f,p.signatures),f}}),gg="matAlgo01xDSid",vg=["typed"],Zc=mt(gg,vg,s=>{var{typed:t}=s;return function(r,n,i,a){var l=r._data,c=r._size,p=r._datatype||r.getDataType(),h=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(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v=typeof p=="string"&&p!=="mixed"&&p===y?p:void 0,E=v?t.find(i,[v,v]):i,b,N,x=[];for(b=0;b<m;b++)x[b]=[];var F=[],M=[];for(N=0;N<w;N++){for(var S=N+1,I=d[N],C=d[N+1],B=I;B<C;B++)b=f[B],F[b]=a?E(h[B],l[b][N]):E(l[b][N],h[B]),M[b]=S;for(b=0;b<m;b++)M[b]===S?x[b][N]=F[b]:x[b][N]=l[b][N]}return r.createDenseMatrix({data:x,size:[m,w],datatype:p===r._datatype&&y===n._datatype?v:void 0})}}),yg="matAlgo04xSidSid",wg=["typed","equalScalar"],Dg=mt(yg,wg,s=>{var{typed:t,equalScalar:e}=s;return function(n,i,a){var l=n._values,c=n._index,p=n._ptr,h=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(h.length!==m.length)throw new Ht(h.length,m.length);if(h[0]!==m[0]||h[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+m+")");var v=h[0],E=h[1],b,N=e,x=0,F=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=t.find(e,[b,b]),x=t.convert(0,b),F=t.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],I=[],C=l&&d?[]:void 0,B=l&&d?[]:void 0,L=[],U=[],k,W,z,K,Z;for(W=0;W<E;W++){I[W]=S.length;var X=W+1;for(K=p[W],Z=p[W+1],z=K;z<Z;z++)k=c[z],S.push(k),L[k]=X,C&&(C[k]=l[z]);for(K=y[W],Z=y[W+1],z=K;z<Z;z++)if(k=g[z],L[k]===X){if(C){var Q=F(C[k],d[z]);N(Q,x)?L[k]=null:C[k]=Q}}else S.push(k),U[k]=X,B&&(B[k]=d[z]);if(C&&B)for(z=I[W];z<S.length;)k=S[z],L[k]===X?(M[z]=C[k],z++):U[k]===X?(M[z]=B[k],z++):S.splice(z,1)}return I[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:I,size:[v,E],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),bg="matAlgo10xSids",Eg=["typed","DenseMatrix"],Kc=mt(bg,Eg,s=>{var{typed:t,DenseMatrix:e}=s;return function(n,i,a,l){var c=n._values,p=n._index,h=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=[],E=[],b=[],N=0;N<y;N++){for(var x=N+1,F=h[N],M=h[N+1],S=F;S<M;S++){var I=p[S];E[I]=c[S],b[I]=x}for(var C=0;C<g;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?w(i,E[C]):w(E[C],i):v[C][N]=i}return new e({data:v,size:[g,y],datatype:m})}}),xg="multiplyScalar",Ag=["typed"],Cg=mt(xg,Ag,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",Fg=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Mg=mt(Gc,Fg,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 p(x,F){switch(x.length){case 1:switch(F.length){case 1:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;case 2:switch(F.length){case 1:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+F[0]+")");break;case 2:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function h(x,F,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return a(x,F)}function f(x,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return d(x,F)}function d(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,B=F._size,L=F._datatype||F.getDataType(),U=S[0],k=B[1],W,z=r,K=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&(W=I,z=t.find(r,[W,W]),K=t.find(n,[W,W]));for(var Z=[],X=0;X<k;X++){for(var Q=K(M[0],C[0][X]),ct=1;ct<U;ct++)Q=z(Q,K(M[ct],C[ct][X]));Z[X]=Q}return x.createDenseMatrix({data:Z,size:[k],datatype:I===x._datatype&&L===F._datatype?W:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":m,"SparseMatrix, any":E}),y=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":w,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function m(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,B=F._datatype||F.getDataType(),L=S[0],U=S[1],k,W=r,z=n;I&&B&&I===B&&typeof I=="string"&&I!=="mixed"&&(k=I,W=t.find(r,[k,k]),z=t.find(n,[k,k]));for(var K=[],Z=0;Z<L;Z++){for(var X=M[Z],Q=z(X[0],C[0]),ct=1;ct<U;ct++)Q=W(Q,z(X[ct],C[ct]));K[Z]=Q}return x.createDenseMatrix({data:K,size:[L],datatype:I===x._datatype&&B===F._datatype?k:void 0})}function w(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,B=F._size,L=F._datatype||F.getDataType(),U=S[0],k=S[1],W=B[1],z,K=r,Z=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&I!=="mixed"&&(z=I,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],C[0][vt]),wt=1;wt<k;wt++)lt=K(lt,Z(ct[wt],C[wt][vt]));X[Q][vt]=lt}}return x.createDenseMatrix({data:X,size:[U,W],datatype:I===x._datatype&&L===F._datatype?z:void 0})}function v(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._values,B=F._index,L=F._ptr,U=F._size,k=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!C)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;I&&k&&I===k&&typeof I=="string"&&I!=="mixed"&&(K=I,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=F.createSparseMatrix({values:vt,index:lt,ptr:wt,size:[W,z],datatype:I===x._datatype&&k===F._datatype?K:void 0}),Bt=0;Bt<z;Bt++){wt[Bt]=lt.length;var Et=L[Bt],oe=L[Bt+1];if(oe>Et)for(var Tt=0,Nt=0;Nt<W;Nt++){for(var le=Nt+1,re=void 0,kt=Et;kt<oe;kt++){var Jt=B[kt];Tt!==le?(re=X(M[Nt][Jt],C[kt]),Tt=le):re=Z(re,X(M[Nt][Jt],C[kt]))}Tt===le&&!Q(re,ct)&&(lt.push(Nt),vt.push(re))}}return wt[z]=lt.length,bt}function E(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var B=F._data,L=F._datatype||F.getDataType(),U=x._size[0],k=F._size[0],W=[],z=[],K=[],Z,X=r,Q=n,ct=i,vt=0;C&&L&&C===L&&typeof C=="string"&&C!=="mixed"&&(Z=C,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<k;bt++){var Bt=B[bt];if(!ct(Bt,vt))for(var Et=I[bt],oe=I[bt+1],Tt=Et;Tt<oe;Tt++){var Nt=S[Tt];wt[Nt]?lt[Nt]=X(lt[Nt],Q(Bt,M[Tt])):(wt[Nt]=!0,z.push(Nt),lt[Nt]=Q(Bt,M[Tt]))}}for(var le=z.length,re=0;re<le;re++){var kt=z[re];W[re]=lt[kt]}return K[1]=z.length,x.createSparseMatrix({values:W,index:z,ptr:K,size:[U,1],datatype:C===x._datatype&&L===F._datatype?Z:void 0})}function b(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var B=F._data,L=F._datatype||F.getDataType(),U=x._size[0],k=F._size[0],W=F._size[1],z,K=r,Z=n,X=i,Q=0;C&&L&&C===L&&typeof C=="string"&&C!=="mixed"&&(z=C,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=x.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[U,W],datatype:C===x._datatype&&L===F._datatype?z:void 0}),bt=[],Bt=[],Et=0;Et<W;Et++){lt[Et]=vt.length;for(var oe=Et+1,Tt=0;Tt<k;Tt++){var Nt=B[Tt][Et];if(!X(Nt,Q))for(var le=I[Tt],re=I[Tt+1],kt=le;kt<re;kt++){var Jt=S[kt];Bt[Jt]!==oe?(Bt[Jt]=oe,vt.push(Jt),bt[Jt]=Z(Nt,M[kt])):bt[Jt]=K(bt[Jt],Z(Nt,M[kt]))}}for(var Ie=lt[Et],_r=vt.length,Re=Ie;Re<_r;Re++){var pn=vt[Re];ct[Re]=bt[pn]}}return lt[W]=vt.length,wt}function N(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType(),B=F._values,L=F._index,U=F._ptr,k=F._datatype||F._data===void 0?F._datatype:F.getDataType(),W=x._size[0],z=F._size[1],K=M&&B,Z,X=r,Q=n;C&&k&&C===k&&typeof C=="string"&&C!=="mixed"&&(Z=C,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]));for(var ct=K?[]:void 0,vt=[],lt=[],wt=x.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[W,z],datatype:C===x._datatype&&k===F._datatype?Z:void 0}),bt=K?[]:void 0,Bt=[],Et,oe,Tt,Nt,le,re,kt,Jt,Ie=0;Ie<z;Ie++){lt[Ie]=vt.length;var _r=Ie+1;for(le=U[Ie],re=U[Ie+1],Nt=le;Nt<re;Nt++)if(Jt=L[Nt],K)for(oe=I[Jt],Tt=I[Jt+1],Et=oe;Et<Tt;Et++)kt=S[Et],Bt[kt]!==_r?(Bt[kt]=_r,vt.push(kt),bt[kt]=Q(B[Nt],M[Et])):bt[kt]=X(bt[kt],Q(B[Nt],M[Et]));else for(oe=I[Jt],Tt=I[Jt+1],Et=oe;Et<Tt;Et++)kt=S[Et],Bt[kt]!==_r&&(Bt[kt]=_r,vt.push(kt));if(K)for(var Re=lt[Ie],pn=vt.length,On=Re;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",x=>(F,M)=>{p(Oe(F),Oe(M));var S=x(e(F),e(M));return ge(S)?S.valueOf():S}),"Matrix, Matrix":function(F,M){var S=F.size(),I=M.size();return p(S,I),S.length===1?I.length===1?h(F,M,S[0]):f(F,M):I.length===1?g(F,M):y(F,M)},"Matrix, Array":t.referTo("Matrix,Matrix",x=>(F,M)=>x(F,e(M))),"Array, Matrix":t.referToSelf(x=>(F,M)=>x(e(F,M.storage()),M)),"SparseMatrix, any":function(F,M){return l(F,M,n,!1)},"DenseMatrix, any":function(F,M){return c(F,M,n,!1)},"any, SparseMatrix":function(F,M){return l(M,F,n,!0)},"any, DenseMatrix":function(F,M){return c(M,F,n,!0)},"Array, any":function(F,M){return c(e(F),M,n,!1).valueOf()},"any, Array":function(F,M){return c(e(M),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(x=>(F,M,S)=>{for(var I=x(F,M),C=0;C<S.length;C++)I=x(I,S[C]);return I})})}),Hc="subtract",Ng=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],Sg=mt(Hc,Ng,s=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:i,DenseMatrix:a,concat:l}=s,c=Zc({typed:t}),p=yi({typed:t}),h=Vc({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:h,DS:c,SD:p,Ss:d,sS:f}))}),Bg="matAlgo07xSSf",Og=["typed","DenseMatrix"],Vs=mt(Bg,Og,s=>{var{typed:t,DenseMatrix:e}=s;return function(i,a,l){var c=i._size,p=i._datatype||i._data===void 0?i._datatype:i.getDataType(),h=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==h.length)throw new Ht(c.length,h.length);if(c[0]!==h[0]||c[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+h+")");var d=c[0],g=c[1],y,m=0,w=l;typeof p=="string"&&p===f&&p!=="mixed"&&(y=p,m=t.convert(0,y),w=t.find(l,[y,y]));var v,E,b=[];for(v=0;v<d;v++)b[v]=[];var N=[],x=[],F=[],M=[];for(E=0;E<g;E++){var S=E+1;for(r(i,E,F,N,S),r(a,E,M,x,S),v=0;v<d;v++){var I=F[v]===S?N[v]:m,C=M[v]===S?x[v]:m;b[v][E]=w(I,C)}}return new e({data:b,size:[d,g],datatype:p===i._datatype&&f===a._datatype?y:void 0})};function r(n,i,a,l,c){for(var p=n._values,h=n._index,f=n._ptr,d=f[i],g=f[i+1];d<g;d++){var y=h[d];a[y]=c,l[y]=p[d]}}}),Jc="conj",Tg=["typed"],Ig=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",$g=["typed","matrix","isInteger"],Lg=mt(Xc,$g,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,p,h=!1,f=[];for(a=0;a<l;a++){var d=i[a];if(ge(d)&&(h=!0),pe(d)||Me(d)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(p=c,c=d.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>p)throw new An(c,p+1)}else{var g=se(d).valueOf(),y=Oe(g);if(f[a]=g,p=c,c=y.length-1,a>0&&c!==p)throw new Ht(p+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 h?e(m):m},"...string":function(i){return i.join("")}})}),Qc="count",Rg=["typed","size","prod"],Pg=mt(Qc,Rg,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",zg=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],qg=mt(tf,zg,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(h){return r(h)},"number | BigNumber":function(h){return c(h,h,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(h,f){return c(h,h,f)},"number | BigNumber, number | BigNumber":function(h,f){return c(h,f,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(h,f,d){return c(h,f,d)},Array:function(h){return l(h)},"Array, string":function(h,f){return l(h,f)},Matrix:function(h){return l(h.valueOf(),h.storage())},"Matrix, string":function(h,f){return l(h.valueOf(),f)}});function l(p,h){switch(p.length){case 0:return h?r(h):[];case 1:return c(p[0],p[0],h);case 2:return c(p[0],p[1],h);default:throw new Error("Vector containing two values expected")}}function c(p,h,f){var d=Me(p)||Me(h)?n:null;if(Me(p)&&(p=p.toNumber()),Me(h)&&(h=h.toNumber()),!we(p)||p<1)throw new Error("Parameters in function identity must be positive integers");if(!we(h)||h<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=[p,h];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=p<h?p:h,E=0;E<v;E++)w[E][E]=g;return w}}),ef="kron",kg=["typed","matrix","multiplyScalar"],Ug=mt(ef,kg,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(Oe(i).length===1&&(i=[i]),Oe(a).length===1&&(a=[a]),Oe(i).length>2||Oe(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(p){return a.map(function(h){return c=[],l.push(c),p.map(function(f){return h.map(function(d){return c.push(r(f,d))})})})})&&l}});function Wg(){throw new Error('No "bignumber" implementation available')}function jg(){throw new Error('No "fraction" implementation available')}function Yg(){throw new Error('No "matrix" implementation available')}var rf="reshape",Vg=["typed","isInteger","matrix"],Zg=mt(rf,Vg,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",Kg=["typed","config","?matrix"],Gg=mt(nf,Kg,s=>{var{typed:t,config:e,matrix:r}=s;return t(nf,{Matrix:function(i){return i.create(i.size())},Array:Oe,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",Hg=["typed","matrix"],Jg=mt(sf,Hg,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 p=l[0],h=l[1];if(h===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+ce(l)+")");switch(a.storage()){case"dense":c=n(a,p,h);break;case"sparse":c=i(a,p,h);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+ce(l)+")")}return c}function n(a,l,c){for(var p=a._data,h=[],f,d=0;d<c;d++){f=h[d]=[];for(var g=0;g<l;g++)f[g]=se(p[g][d])}return a.createDenseMatrix({data:h,size:[c,l],datatype:a._datatype})}function i(a,l,c){for(var p=a._values,h=a._index,f=a._ptr,d=p?[]:void 0,g=[],y=[],m=[],w=0;w<l;w++)m[w]=0;var v,E,b;for(v=0,E=h.length;v<E;v++)m[h[v]]++;for(var N=0,x=0;x<l;x++)y.push(N),N+=m[x],m[x]=y[x];for(y.push(N),b=0;b<c;b++)for(var F=f[b],M=f[b+1],S=F;S<M;S++){var I=m[h[S]]++;g[I]=b,p&&(d[I]=se(p[S]))}return a.createSparseMatrix({values:d,index:g,ptr:y,size:[c,l],datatype:a._datatype})}}),of="ctranspose",Xg=["typed","transpose","conj"],Qg=mt(of,Xg,s=>{var{typed:t,transpose:e,conj:r}=s;return t(of,{any:function(i){return r(e(i))}})}),af="mode",tv=["typed","isNaN","isNumeric"],ev=mt(af,tv,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=[],p=0,h=0;h<i.length;h++){var f=i[h];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]===p?c.push(f):l[f]>p&&(p=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: "+xn(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: "+xn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):s}var uf="prod",rv=["typed","config","multiplyScalar","numeric"],nv=mt(uf,rv,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(p){throw Sn(p,"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}}),iv="numeric",sv=["number","?bignumber","?fraction"],ov=mt(iv,sv,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):Wg,Fraction:r?a=>r(a):jg};return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",p=arguments.length>2?arguments[2]:void 0;if(p!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var h=xn(l);if(!(h in n))throw new TypeError("Cannot convert "+l+' of type "'+h+'"; 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===h?l:i[c](l)}}),lf="divideScalar",av=["typed","numeric"],uv=mt(lf,av,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",lv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],cv=mt(cf,lv,s=>{var{typed:t,config:e,identity:r,multiply:n,matrix:i,inv:a,number:l,fraction:c,Complex:p}=s;return t(cf,{"number, number":h,"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 p(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 h(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 h(g,y){if(e.predictable&&!we(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:we(y)||g>=0||e.predictable?Ic(g,y):g*g<1&&y===1/0||g*g>1&&y===-1/0?0:new p(g,0).pow(y,0)}function f(g,y){if(!we(y))throw new TypeError("For A^b, b must be an integer (value is "+y+")");var m=Oe(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(E){throw E.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+y+")"):E}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",fv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],hv=mt(ff,fv,s=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:i,concat:a}=s,l=ig({typed:t,equalScalar:r}),c=yi({typed:t}),p=Vs({typed:t,DenseMatrix:i}),h=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:p,DS:c,SD:l,Ss:h,sS:f}))}),Zs="compare",pv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],dv=mt(Zs,pv,s=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:i,Fraction:a,DenseMatrix:l,concat:c}=s,p=yi({typed:t}),h=Vc({typed:t,equalScalar:r}),f=vi({typed:t,DenseMatrix:l}),d=Hn({typed:t,matrix:n,concat:c}),g=js({typed:t});return t(Zs,_v({typed:t,config:e}),{"boolean, boolean":function(m,w){return m===w?0:m>w?1:-1},"BigNumber, BigNumber":function(m,w){return Ws(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:h,DS:p,Ss:f}))}),_v=mt(Zs,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Zs,{"number, number":function(n,i){return Gn(n,i,e.epsilon)?0:n>i?1:-1}})}),Ks="equal",mv=["typed","matrix","equalScalar","DenseMatrix","concat"],gv=mt(Ks,mv,s=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Vs({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),p=Hn({typed:t,matrix:e,concat:i});return t(Ks,vv({typed:t,equalScalar:r}),p({elop:r,SS:l,DS:a,Ss:c}))}),vv=mt(Ks,["typed","equalScalar"],s=>{var{typed:t,equalScalar:e}=s;return t(Ks,{"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)}})}),Gs="smaller",yv=["typed","config","matrix","DenseMatrix","concat"],wv=mt(Gs,yv,s=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Vs({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),p=Hn({typed:t,matrix:r,concat:i}),h=js({typed:t});return t(Gs,Dv({typed:t,config:e}),{"boolean, boolean":(f,d)=>f<d,"BigNumber, BigNumber":function(d,g){return d.lt(g)&&!Ws(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")}},h,p({SS:l,DS:a,Ss:c}))}),Dv=mt(Gs,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Gs,{"number, number":function(n,i){return n<i&&!Gn(n,i,e.epsilon)}})}),Hs="larger",bv=["typed","config","matrix","DenseMatrix","concat"],Ev=mt(Hs,bv,s=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:t}),l=Vs({typed:t,DenseMatrix:n}),c=vi({typed:t,DenseMatrix:n}),p=Hn({typed:t,matrix:r,concat:i}),h=js({typed:t});return t(Hs,xv({typed:t,config:e}),{"boolean, boolean":(f,d)=>f>d,"BigNumber, BigNumber":function(d,g){return d.gt(g)&&!Ws(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")}},h,p({SS:l,DS:a,Ss:c}))}),xv=mt(Hs,["typed","config"],s=>{var{typed:t,config:e}=s;return t(Hs,{"number, number":function(n,i){return n>i&&!Gn(n,i,e.epsilon)}})}),hf="deepEqual",Av=["typed","equal"],Cv=mt(hf,Av,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",Fv=["typed","isNumeric","isNaN","compare"],Mv=mt(pf,Fv,s=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=s,i=n,a=(p,h)=>-n(p,h);return t(pf,{"Array | Matrix, number":function(h,f){return l(h,f,i)},"Array | Matrix, number, string":function(h,f,d){if(d==="asc")return l(h,f,i);if(d==="desc")return l(h,f,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(p,h,f){if(!we(h)||h<0)throw new Error("k must be a non-negative integer");if(ge(p)){var d=p.size();if(d.length>1)throw new Error("Only one dimensional matrices supported");return c(p.valueOf(),h,f)}if(Array.isArray(p))return c(p,h,f)}function c(p,h,f){if(h>=p.length)throw new Error("k out of bounds");for(var d=0;d<p.length;d++)if(e(p[d])&&r(p[d]))return p[d];for(var g=0,y=p.length-1;g<y;){for(var m=g,w=y,v=p[Math.floor(Math.random()*(y-g+1))+g];m<w;)if(f(p[m],v)>=0){var E=p[w];p[w]=p[m],p[m]=E,--w}else++m;f(p[m],v)>0&&--m,h<=m?y=m:g=m+1}return p[h]}}),df="max",Nv=["typed","config","numeric","larger"],Sv=mt(df,Nv,s=>{var{typed:t,config:e,numeric:r,larger:n}=s;return t(df,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,p){return Fa(c,p.valueOf(),i)},"...":function(c){if(qs(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(p){throw Sn(p,"max",c)}}function a(l){var c;if(Hi(l,function(p){try{isNaN(p)&&typeof p=="number"?c=NaN:(c===void 0||n(p,c))&&(c=p)}catch(h){throw Sn(h,"max",p)}}),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",Bv=["typed","config","numeric","smaller"],Ov=mt(_f,Bv,s=>{var{typed:t,config:e,numeric:r,smaller:n}=s;return t(_f,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,p){return Fa(c,p.valueOf(),i)},"...":function(c){if(qs(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(p){throw Sn(p,"min",c)}}function a(l){var c;if(Hi(l,function(p){try{isNaN(p)&&typeof p=="number"?c=NaN:(c===void 0||n(p,c))&&(c=p)}catch(h){throw Sn(h,"min",p)}}),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"],Iv=mt(mf,Tv,s=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:i,SparseMatrix:a,concat:l}=s,c=Zc({typed:t}),p=Dg({typed:t,equalScalar:n}),h=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:p,Ss:h}))}),gf="dot",$v=["typed","addScalar","multiplyScalar","conj","size"],Lv=mt(gf,$v,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(h,f){var d=p(h),g=p(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(h,f){var d=a(h,f),g=ge(h)?h._data:h,y=ge(h)?h._datatype||h.getDataType():void 0,m=ge(f)?f._data:f,w=ge(f)?f._datatype||f.getDataType():void 0,v=p(h).length===2,E=p(f).length===2,b=e,N=r;if(y&&w&&y===w&&typeof y=="string"&&y!=="mixed"){var x=y;b=t.find(e,[x,x]),N=t.find(r,[x,x])}if(!v&&!E){for(var F=N(n(g[0]),m[0]),M=1;M<d;M++)F=b(F,N(n(g[M]),m[M]));return F}if(!v&&E){for(var S=N(n(g[0]),m[0][0]),I=1;I<d;I++)S=b(S,N(n(g[I]),m[I][0]));return S}if(v&&!E){for(var C=N(n(g[0][0]),m[0]),B=1;B<d;B++)C=b(C,N(n(g[B][0]),m[B]));return C}if(v&&E){for(var L=N(n(g[0][0]),m[0][0]),U=1;U<d;U++)L=b(L,N(n(g[U][0]),m[U][0]));return L}}function c(h,f){a(h,f);for(var d=h._index,g=h._values,y=f._index,m=f._values,w=0,v=e,E=r,b=0,N=0;b<d.length&&N<y.length;){var x=d[b],F=y[N];if(x<F){b++;continue}if(x>F){N++;continue}x===F&&(w=v(w,E(g[b],m[N])),b++,N++)}return w}function p(h){return ge(h)?h.size():i(h)}}),Rv="trace",Pv=["typed","matrix","add"],zv=mt(Rv,Pv,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: "+ce(l)+")");case 2:{var p=l[0],h=l[1];if(p===h){for(var f=0,d=0;d<p;d++)f=r(f,c[d][d]);return f}else throw new RangeError("Matrix must be square (size: "+ce(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ce(l)+")")}}function i(a){var l=a._values,c=a._index,p=a._ptr,h=a._size,f=h[0],d=h[1];if(f===d){var g=0;if(l.length>0)for(var y=0;y<d;y++)for(var m=p[y],w=p[y+1],v=m;v<w;v++){var E=c[v];if(E===y){g=r(g,l[v]);break}if(E>y)break}return g}throw new RangeError("Matrix must be square (size: "+ce(h)+")")}}),vf="det",qv=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],kv=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(h){return se(h)},"Array | Matrix":function(h){var f;switch(ge(h)?f=h.size():Array.isArray(h)?(h=e(h),f=h.size()):f=[],f.length){case 0:return se(h);case 1:if(f[0]===1)return se(h.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+ce(f)+")");case 2:{var d=f[0],g=f[1];if(d===g)return c(h.clone().valueOf(),d);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+ce(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ce(f)+")")}}});function c(p,h,f){if(h===1)return se(p[0][0]);if(h===2)return r(n(p[0][0],p[1][1]),n(p[1][0],p[0][1]));for(var d=!1,g=new Array(h).fill(0).map((M,S)=>S),y=0;y<h;y++){var m=g[y];if(a(p[m][y])){var w=void 0;for(w=y+1;w<h;w++)if(!a(p[g[w]][y])){m=g[w],g[w]=g[y],g[y]=m,d=!d;break}if(w===h)return p[m][y]}for(var v=p[m][y],E=y===0?1:p[g[y-1]][y-1],b=y+1;b<h;b++)for(var N=g[b],x=y+1;x<h;x++)p[N][x]=i(r(n(p[N][x],v),n(p[N][y],p[m][x])),E)}var F=p[g[h-1]][h-1];return d?l(F):F}}),yf="inv",Uv=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Wv=mt(yf,Uv,s=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:i,unaryMinus:a,det:l,identity:c,abs:p}=s;return t(yf,{"Array | Matrix":function(d){var g=ge(d)?d.size():Oe(d);switch(g.length){case 1:if(g[0]===1)return ge(d)?e([r(1,d.valueOf()[0])]):[r(1,d[0])];throw new RangeError("Matrix must be square (size: "+ce(g)+")");case 2:{var y=g[0],m=g[1];if(y===m)return ge(d)?e(h(d.valueOf(),y,m),d.storage()):h(d,y,m);throw new RangeError("Matrix must be square (size: "+ce(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ce(g)+")")}},any:function(d){return r(1,d)}});function h(f,d,g){var y,m,w,v,E;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 x=c(d).valueOf(),F=0;F<g;F++){var M=p(N[F][F]),S=F;for(y=F+1;y<d;)p(N[y][F])>M&&(M=p(N[y][F]),S=y),y++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");y=S,y!==F&&(E=N[F],N[F]=N[y],N[y]=E,E=x[F],x[F]=x[y],x[y]=E);var I=N[F],C=x[F];for(y=0;y<d;y++){var B=N[y],L=x[y];if(y!==F){if(B[F]!==0){for(w=r(a(B[F]),I[F]),m=F;m<g;m++)B[m]=n(B[m],i(w,I[m]));for(m=0;m<g;m++)L[m]=n(L[m],i(w,C[m]))}}else{for(w=I[F],m=F;m<g;m++)B[m]=r(B[m],w);for(m=0;m<g;m++)L[m]=r(L[m],w)}}}return x}}}),wf="pinv",jv=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],Yv=mt(wf,jv,s=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:i,dotDivide:a,dot:l,ctranspose:c,divideScalar:p,multiply:h,add:f,Complex:d}=s;return t(wf,{"Array | Matrix":function(b){var N=ge(b)?b.size():Oe(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 x=N[0],F=N[1];if(x===F)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return ge(b)?e(g(b.valueOf(),x,F),b.storage()):g(b,x,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+ce(N)+")")}},any:function(b){return i(b,0)?se(b):p(1,b)}});function g(E,b,N){var{C:x,F}=m(E,b,N),M=h(r(h(c(x),x)),c(x)),S=h(c(F),r(h(F,c(F))));return h(S,M)}function y(E,b,N){for(var x=se(E),F=0,M=0;M<b;M++){if(N<=F)return x;for(var S=M;w(x[S][F]);)if(S++,b===S&&(S=M,F++,N===F))return x;[x[S],x[M]]=[x[M],x[S]];for(var I=x[M][F],C=0;C<N;C++)x[M][C]=a(x[M][C],I);for(var B=0;B<b;B++)if(B!==M){I=x[B][F];for(var L=0;L<N;L++)x[B][L]=f(x[B][L],h(-1,h(I,x[M][L])))}F++}return x}function m(E,b,N){var x=y(E,b,N),F=E.map((S,I)=>S.filter((C,B)=>B<b&&!w(l(x[B],x[B])))),M=x.filter((S,I)=>!w(l(x[I],x[I])));return{C:F,F:M}}function w(E){return i(f(E,d(1,1)),f(0,d(1,1)))}function v(E){return n(f(E,d(1,1)),f(h(E,0),d(1,1)))}}),Vv="divide",Zv=["typed","matrix","multiply","equalScalar","divideScalar","inv"],Kv=mt(Vv,Zv,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(h,f){return r(h,a(f))},"DenseMatrix, any":function(h,f){return c(h,f,i,!1)},"SparseMatrix, any":function(h,f){return l(h,f,i,!1)},"Array, any":function(h,f){return c(e(h),f,i,!1).valueOf()},"any, Array | Matrix":function(h,f){return r(h,a(f))}},i.signatures))}),Df="sum",Gv=["typed","config","add","numeric"],Hv=mt(Df,Gv,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(qs(c))throw new TypeError("Scalar values expected in function sum");return i(c)}});function i(l){var c;return Hi(l,function(p){try{c=c===void 0?p:r(c,p)}catch(h){throw Sn(h,"sum",p)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(l,c){try{var p=Fa(l,c,r);return p}catch(h){throw Sn(h,"sum")}}}),bf="median",Jv=["typed","add","divide","compare","partitionSelect"],Xv=mt(bf,Jv,s=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:i}=s;function a(p){try{p=va(p.valueOf());var h=p.length;if(h===0)throw new Error("Cannot calculate median of an empty array");if(h%2===0){for(var f=h/2-1,d=i(p,f+1),g=p[f],y=0;y<f;++y)n(p[y],g)>0&&(g=p[y]);return c(g,d)}else{var m=i(p,(h-1)/2);return l(m)}}catch(w){throw Sn(w,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(h){return h}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(h,f){return r(e(h,f),2)}});return t(bf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(h,f){throw new Error("median(A, dim) is not yet supported")},"...":function(h){if(qs(h))throw new TypeError("Scalar values expected in function median");return a(h)}})}),Js=Q_({config:pr}),Sa=nm({}),Ba=am({}),Oa=cm({}),en=pm({Matrix:Oa}),Mt=r_({BigNumber:Js,Complex:Sa,DenseMatrix:en,Fraction:Ba}),Qv=Ym({typed:Mt}),Xs=Zm({typed:Mt}),t1=Lm({BigNumber:Js,typed:Mt}),Ef=Ig({typed:Mt}),Bn=Am({config:pr,typed:Mt}),Qs=mm({typed:Mt}),e1=wm({typed:Mt}),to=Cg({typed:Mt}),xf=Tm({typed:Mt}),Ta=Mm({Matrix:Oa,equalScalar:Bn,typed:Mt}),Af=Gm({typed:Mt}),Cf=bm({typed:Mt}),Ia=Wm({typed:Mt}),Ff=zm({Fraction:Ba,typed:Mt}),Mf=vm({typed:Mt}),Te=km({DenseMatrix:en,Matrix:Oa,SparseMatrix:Ta,typed:Mt}),Nf=ev({isNaN:Cf,isNumeric:Mf,typed:Mt}),Ji=ov({bignumber:t1,fraction:Ff,number:xf}),r1=nv({config:pr,multiplyScalar:to,numeric:Ji,typed:Mt}),n1=Zg({isInteger:Qs,matrix:Te,typed:Mt}),Sf=Gg({matrix:Te,config:pr,typed:Mt}),Bf=Jg({matrix:Te,typed:Mt}),Jn=Lg({isInteger:Qs,matrix:Te,typed:Mt}),i1=Pg({prod:r1,size:Sf,typed:Mt}),s1=Qg({conj:Ef,transpose:Bf,typed:Mt}),Xi=uv({numeric:Ji,typed:Mt}),o1=hv({DenseMatrix:en,concat:Jn,divideScalar:Xi,equalScalar:Bn,matrix:Te,typed:Mt}),Of=gv({DenseMatrix:en,concat:Jn,equalScalar:Bn,matrix:Te,typed:Mt}),Tf=qg({BigNumber:Js,DenseMatrix:en,SparseMatrix:Ta,config:pr,matrix:Te,typed:Mt}),a1=Ug({matrix:Te,multiplyScalar:to,typed:Mt}),u1=wv({DenseMatrix:en,concat:Jn,config:pr,matrix:Te,typed:Mt}),l1=Sg({DenseMatrix:en,concat:Jn,equalScalar:Bn,matrix:Te,subtractScalar:Af,typed:Mt,unaryMinus:Ia}),Qi=Iv({DenseMatrix:en,SparseMatrix:Ta,addScalar:Xs,concat:Jn,equalScalar:Bn,matrix:Te,typed:Mt}),If=dv({BigNumber:Js,DenseMatrix:en,Fraction:Ba,concat:Jn,config:pr,equalScalar:Bn,matrix:Te,typed:Mt}),c1=Cv({equal:Of,typed:Mt}),$f=Lv({addScalar:Xs,conj:Ef,multiplyScalar:to,size:Sf,typed:Mt}),f1=Ev({DenseMatrix:en,concat:Jn,config:pr,matrix:Te,typed:Mt}),$a=Ov({config:pr,numeric:Ji,smaller:u1,typed:Mt}),wi=Mg({addScalar:Xs,dot:$f,equalScalar:Bn,matrix:Te,multiplyScalar:to,typed:Mt}),h1=Mv({compare:If,isNaN:Cf,isNumeric:Mf,typed:Mt}),p1=Hv({add:Qi,config:pr,numeric:Ji,typed:Mt}),d1=zv({add:Qi,matrix:Te,typed:Mt}),Lf=kv({divideScalar:Xi,isZero:e1,matrix:Te,multiply:wi,subtractScalar:Af,typed:Mt,unaryMinus:Ia}),_1=Sv({config:pr,larger:f1,numeric:Ji,typed:Mt}),eo=Wv({abs:Qv,addScalar:Xs,det:Lf,divideScalar:Xi,identity:Tf,matrix:Te,multiply:wi,typed:Mt,unaryMinus:Ia}),m1=Yv({Complex:Sa,add:Qi,ctranspose:s1,deepEqual:c1,divideScalar:Xi,dot:$f,dotDivide:o1,equal:Of,inv:eo,matrix:Te,multiply:wi,typed:Mt}),g1=cv({Complex:Sa,config:pr,fraction:Ff,identity:Tf,inv:eo,matrix:Te,multiply:wi,number:xf,typed:Mt}),v1=Kv({divideScalar:Xi,equalScalar:Bn,inv:eo,matrix:Te,multiply:wi,typed:Mt}),Rf=Xv({add:Qi,compare:If,divide:v1,partitionSelect:h1,typed:Mt});class y1{constructor(t,e,r){R(this,"_cacheData");R(this,"_variables");R(this,"_math");R(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 p=e/n;let h=0,f=0;for(let d=0;d<=e-1;d++){const g=Math.exp(-1*Math.pow(d-c,2)/(2*Math.pow(p,2)));h+=g,f+=l[l.length-1-(e-d-1)]*g}return f/h}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=p1(...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 p=this._sum(i[i.length-1-c],-(a||0));l+=p*p}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const 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,p=0,h=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,p+=m*m,h+=w*w}return isNaN(p)||isNaN(c)||isNaN(h)?void 0:c/Math.sqrt(p*h)}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:p,TRS:h,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:p,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 E=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:(p||0)+v,TRS:(h||0)+E,count:d+1}),[void 0,void 0,void 0];{const b=c-c/t+w,N=p-p/t+v,x=h-h/t+E,F=b/x*100,M=N/x*100,S=Math.abs((F-M)/(F+M))*100;let I=S,C=[F,M,void 0];if(d+1-t<e){const B=d+1-t;I=((f||0)*(B-1)+S)/B}else I=(f*(e-1)+S)/e,C=[F,M,I];return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:b,NDMS:N,TRS:x,ADX:I,count:d+1}),C}}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,p,h)=>c>=h[l]?p: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:p}=this._variables,h=n?l.tr:c-p,f=this.ema({source:h,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:p}=this._variables,h=n?l.tr:c-p,f=this.ema({source:h,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,p=0,h=0;for(const[g,y]of a.entries())l+=g,c+=y,p+=g*y,h+=g*g;const f=(e*p-l*c)/(e*h-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,p,h)=>c<=h[l]?p: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,p=this.ema({source:c,length:n},`macd_${i}`);if(p===void 0)return[c,p,void 0];const h=c-p;return[c,p,h]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return 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[p,h]of a.entries()){const f=a[p-1];if(r<(p+.5)/l)return f===void 0||h===void 0?void 0:f+(h-f)*(r-(p-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const 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:p}=this._variables;const h=`pivot_point_levels_${n}`,{close:f,low:d,high:g,open:y,result:m}=this._cacheData[h]||{};if(!e&&(g&&d&&(p=Math.max(g,p),c=Math.min(d,c)),this._cacheDataHandle(h,{close:a,open:l,low:c,high:p,result:m}),!r))return i._value=m||[],i;const w={close:a,open:l,low:c,high:p};e===!0&&!r&&(a=f,l=y,c=d,p=g);const v=this._getPivotPointLevels(p,c,a,l,r,t);return this._cacheDataHandle(h,{...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),p=n*4+(t-4*e),h=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,h,a,f,l,d,c,g,p,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),p=n+(t-e),h=n-(t-e);return[n,i,a,l,c,p,h]}_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),p=t+2*(n-e),h=e-2*(t-n),f=p+(t-e),d=h-(t-e);return[n,i,a,l,c,p,h,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),p=n+2*(t-e),h=n-2*(t-e),f=n+3*(t-e),d=n-3*(t-e);return[n,i,a,l,c,p,h,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,p=r+1.1*(t-e)/4,h=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,p,h,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}`);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:p,data:h={}}=this._cacheData[`sar_${n}`]||{};let{result:f,maxMin:d,acceleration:g,isBelow:y}=h,m=!1;const{close:w,low:v,high:E,bar_index:b}=this._variables;return b===1&&(w>i?(y=!0,d=E,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(E,d||0),d=v,g=t):f<E&&(m=!0,y=!0,f=Math.min(v,d||0),d=E,g=t),m||(y?E>(d||0)&&(d=E,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,p))),this._cacheDataHandle(`sar_${n}`,{high:E,close:w,low:v,preLow:a,preHigh:l,data:Object.assign(h,{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:p,atr:h,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;h===void 0?v=1:p===m?v=i>g?-1:1:v=i<y?1:-1;const E=v===-1?y:g;return this._cacheDataHandle(a,{upperBand:g,lowerBand:y,superTrend:E,atr:d,close:i}),[E,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high: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}`),p=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/p}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}`);if(!a||i===void 0)return;const l=a.filter(p=>p!==void 0&&!isNaN(p)).slice(-e);if(l.length<e)return;const c=l.reduce((p,h)=>p+Math.pow(h-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:p,sumS:h=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=l=c=h=0,p=!0),!p)return r!==void 0?[]:void 0;const f=t*i+a,d=i+l,g=f/d;return c++,r!==void 0?(h=i*Math.pow(t,2)+h,this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:p,sumS:h}),this._computeBands(h,d,r,g)):(this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:p}),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){const n=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:i}=this._variables;if(n.barIndex<=i&&(n.barIndex===i?n.list[n.list.length-1]=t:n.list.push(t),n.barIndex=i,this._cacheData[r]=n),!(n.list.length<e))return n.list}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}class w1{constructor(t,e,r){R(this,"_cacheData");R(this,"_variables");R(this,"_errorListener");R(this,"_historyInputs");R(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,er.INT)}bool(t,e){return this._cacheHandle(t,e,er.BOOL)}color(t,e){return this._cacheHandle(t,e,er.COLOR)}time(t,e){return this._cacheHandle(t,e,er.TIME)}float(t,e){return this._cacheHandle(t,e,er.FLOAT)}price(t,e){return this._cacheHandle(t,e,er.PRICE)}source(t,e){return this._cacheHandle(t,e,er.SOURCE)}string(t,e){return this._cacheHandle(t,e,er.STRING)}symbol(t,e){return this._cacheHandle(t,e,er.SYMBOL)}session(t,e){return this._cacheHandle(t,e,er.SESSION)}text_area(t,e){return this._cacheHandle(t,e,er.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,er.TIMEFRAME)}enum(t,e){return this._cacheHandle(t,e,er.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(ue.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)===er.SOURCE?this._cacheData[n].options=Vp:t.options&&!t.options.includes(a)&&this._errorListener.addError(We(ue.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(je.dataWindow)||e.includes(je.statusLine)||this._errorListener.addError(We(ue.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 D1{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:p,b:h,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=p+l*(g-p),E=h+l*(y-h),b=f+l*(m-f);return`rgba(${Math.round(w)}, ${Math.round(v)}, ${Math.round(E)}, ${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 qt={};const b1=Object.prototype.toString;function ts(s){const t=b1.call(s);return t.endsWith("Array]")&&!t.includes("Big")}var E1=Object.freeze({__proto__:null,isAnyArray:ts}),x1=Fe(E1);function A1(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 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)){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=C1(s),n=A1(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 p=(c-a)/(n-r),h=0;h<s.length;h++)e[h]=(s[h]-r)*p+a;return e}var M1=Object.freeze({__proto__:null,default:F1}),N1=Fe(M1);Object.defineProperty(qt,"__esModule",{value:!0});var ar=x1,Pf=N1;const ro=" ".repeat(2),zf=" ".repeat(4);function S1(){return qf(this)}function qf(s,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:i="auto"}=t;return`${s.constructor.name} {
|
55
|
-
${ro}[
|
56
|
-
${zf}${B1(s,e,r,n,i)}
|
57
|
-
${ro}]
|
58
|
-
${ro}rows: ${s.rows}
|
59
|
-
${ro}columns: ${s.columns}
|
60
|
-
}`}function B1(s,t,e,r,n){const{rows:i,columns:a}=s,l=Math.min(i,t),c=Math.min(a,e),p=[];if(n==="auto"){n=!1;t:for(let h=0;h<l;h++)for(let f=0;f<c;f++)if(s.get(h,f)<0){n=!0;break t}}for(let h=0;h<l;h++){let f=[];for(let d=0;d<c;d++)f.push(O1(s.get(h,d),r,n));p.push(`${f.join(" ")}`)}return c!==a&&(p[p.length-1]+=` ... ${a-e} more columns`),l!==i&&p.push(`... ${i-t} more rows`),p.join(`
|
61
|
-
${zf}`)}function O1(s,t,e){return(s>=0&&e?` ${kf(s,t-1)}`:kf(s,t)).padEnd(t)}function kf(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 Mr(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 Nr(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(!ar.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(!ar.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(io("startRow",t),io("endRow",e),io("startColumn",r),io("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 no(s,t=0){let e=[];for(let r=0;r<s;r++)e.push(t);return e}function io(s,t){if(typeof t!="number")throw new TypeError(`${s} must be a number`)}function Ei(s){if(s.isEmpty())throw new Error("Empty matrix has no elements to index")}function I1(s){let t=no(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 $1(s){let t=no(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 L1(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 R1(s){let t=no(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 P1(s){let t=no(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 z1(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,p=0;for(let h=0;h<n;h++)p=s.get(a,h)-e[a],l+=p,c+=p*p;t?i.push((c-l*l/n)/(n-1)):i.push((c-l*l/n)/n)}return i}function k1(s,t,e){const r=s.rows,n=s.columns,i=[];for(let a=0;a<n;a++){let l=0,c=0,p=0;for(let h=0;h<r;h++)p=s.get(h,a)-e[a],l+=p,c+=p*p;t?i.push((c-l*l/r)/(r-1)):i.push((c-l*l/r)/r)}return i}function U1(s,t,e){const r=s.rows,n=s.columns,i=r*n;let a=0,l=0,c=0;for(let p=0;p<r;p++)for(let h=0;h<n;h++)c=s.get(p,h)-e,a+=c,l+=c*c;return t?(l-a*a/i)/(i-1):(l-a*a/i)/i}function W1(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 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[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 V1(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 Z1(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 K1(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 G1(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 H1(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 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)}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 p=0;p<t;p++)for(let h=0;h<e;h++){let f=n+Math.round(a()*l);c.set(p,h,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 p=i;p<e;p++){let h=t.get(l,p)-c*t.get(n,p);t.set(l,p,h)}}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){Mr(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){Mr(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){Mr(this,t),Mr(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){Nr(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){Nr(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){Nr(this,t),Nr(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){Mr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Nr(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(){Ei(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(){Ei(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(Mr(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){Mr(this,t),Ei(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(Mr(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){Mr(this,t),Ei(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(Nr(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){Nr(this,t),Ei(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(Nr(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){Nr(this,t),Ei(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 p=0;for(let h=0;h<r;h++)p+=this.get(c,h)*a[h];i.set(c,l,p)}}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),p=this.get(1,1),h=t.get(1,1),f=(r+p)*(n+h),d=(l+p)*n,g=r*(a-h),y=p*(c-n),m=(r+i)*h,w=(l-r)*(n+a),v=(i-p)*(c+h),E=f+y-m+v,b=g+m,N=d+y,x=f-d+g+w;return e.set(0,0,E),e.set(0,1,b),e.set(1,0,N),e.set(1,1,x),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),p=this.get(2,0),h=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),E=t.get(2,0),b=t.get(2,1),N=t.get(2,2),x=(r+n+i-a-l-h-f)*w,F=(r-a)*(-g+w),M=l*(-d+g+m-w-v-E+N),S=(-r+a+l)*(d-g+w),I=(a+l)*(-d+g),C=r*d,B=(-r+p+h)*(d-y+v),L=(-r+p)*(y-v),U=(p+h)*(-d+y),k=(r+n+i-l-c-p-h)*v,W=h*(-d+y+m-w-v-E+b),z=(-i+h+f)*(w+E-b),K=(i-f)*(w-b),Z=i*E,X=(h+f)*(-E+b),Q=(-i+l+c)*(v+E-N),ct=(i-c)*(v-N),vt=(l+c)*(-E+N),lt=n*m,wt=c*b,bt=a*y,Bt=p*g,Et=f*N,oe=C+Z+lt,Tt=x+S+I+C+z+Z+X,Nt=C+B+U+k+Z+Q+vt,le=F+M+S+C+Z+Q+ct,re=F+S+I+C+wt,kt=Z+Q+ct+vt+bt,Jt=C+B+L+W+z+K+Z,Ie=z+K+Z+X+Bt,_r=C+B+L+U+Et;return e.set(0,0,oe),e.set(0,1,Tt),e.set(0,2,Nt),e.set(1,0,le),e.set(1,1,re),e.set(1,2,kt),e.set(2,0,Jt),e.set(2,1,Ie),e.set(2,2,_r),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),p=Math.max(n,a);e=l(e,c,p),t=l(t,c,p);function h(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),E=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),x=f.subMatrix(m,f.rows-1,0,w-1),F=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),I=h($t.add(v,M),$t.add(E,S),m,w),C=h($t.add(x,M),E,m,w),B=h(v,$t.sub(N,S),m,w),L=h(M,$t.sub(F,E),m,w),U=h($t.add(v,b),S,m,w),k=h($t.sub(x,v),$t.add(E,N),m,w),W=h($t.sub(b,M),$t.add(F,S),m,w),z=$t.add(I,L);z.sub(U),z.add(W);let K=$t.add(B,U),Z=$t.add(C,L),X=$t.sub(I,C);X.add(B),X.add(k);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 h(e,t,c,p)}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 p=0;p<n;p++)for(let h=0;h<i;h++)a.set(n*l+p,i*c+h,this.get(l,c)*t.get(p,h));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 I1(this);case"column":return $1(this);case void 0:return L1(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return R1(this);case"column":return P1(this);case void 0:return z1(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(!ar.isAnyArray(n))throw new TypeError("mean must be an array");return q1(this,r,n)}case"column":{if(!ar.isAnyArray(n))throw new TypeError("mean must be an array");return k1(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return U1(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(!ar.isAnyArray(r))throw new TypeError("center must be an array");return W1(this,r),this}case"column":{if(!ar.isAnyArray(r))throw new TypeError("center must be an array");return j1(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=V1(this);else if(!ar.isAnyArray(r))throw new TypeError("scale must be an array");return Z1(this,r),this}case"column":{if(r===void 0)r=K1(this);else if(!ar.isAnyArray(r))throw new TypeError("scale must be an array");return G1(this,r),this}case void 0:{if(r===void 0)r=H1(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return J1(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return qf(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")]=S1);function Uf(s,t){return s-t}function X1(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();Cl(this,is);R(this,"data");if(Ni.isMatrix(e))Fl(this,is,Ml).call(this,e.rows,e.columns),Ni.copy(e,this);else if(Number.isInteger(e)&&e>=0)Fl(this,is,Ml).call(this,e,r);else if(ar.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(!X1(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 Mr(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),Mr(this,e,!0),r=Float64Array.from(Di(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){Nr(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),Nr(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}},is=new WeakSet,Ml=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();Cl(this,He,void 0);if(pt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ua(this,He,pt.copy(e,new pt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ua(this,He,new pt(e,e));else if(ua(this,He,new pt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Hr(this,He).size}get rows(){return Hr(this,He).rows}get columns(){return Hr(this,He).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 Hr(this,He).get(e,r)}set(e,r,n){return Hr(this,He).set(e,r,n),Hr(this,He).set(r,e,n),this}removeCross(e){return Hr(this,He).removeRow(e),Hr(this,He).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),Hr(this,He).addRow(e,n),Hr(this,He).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)}};He=new WeakMap;let Xn=go;Xn.prototype.klassType="SymmetricMatrix";class so 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 so(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}}so.prototype.klassSubType="DistanceMatrix";class fn extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class Q1 extends fn{constructor(t,e){Nr(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 ty 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 ey 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 ry 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 ny extends fn{constructor(t,e){Mr(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 iy 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 oo 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 sy 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 oy 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 dr 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 ay(s,t){if(ar.isAnyArray(s))return s[0]&&ar.isAnyArray(s[0])?new dr(s):new Wf(s,t);throw new Error("the argument is not an array")}class ao{constructor(t){t=dr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,i=new Float64Array(r),a=1,l,c,p,h,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,p=0;p<m;p++)f+=e.get(l,p)*y[p];y[l]-=f,e.set(l,c,y[l])}for(h=c,l=c+1;l<r;l++)Math.abs(y[l])>Math.abs(y[h])&&(h=l);if(h!==c){for(p=0;p<n;p++)d=e.get(h,p),e.set(h,p,e.get(c,p)),e.set(c,p,d);g=i[h],i[h]=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,p;for(p=0;p<a;p++)for(l=p+1;l<a;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(p,c)*e.get(l,p));for(p=a-1;p>=0;p--){for(c=0;c<n;c++)i.set(p,c,i.get(p,c)/e.get(p,p));for(l=0;l<p;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(p,c)*e.get(l,p))}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=dr.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,i=new Float64Array(n),a,l,c,p;for(c=0;c<n;c++){let h=0;for(a=c;a<r;a++)h=hn(h,e.get(a,c));if(h!==0){for(e.get(c,c)<0&&(h=-h),a=c;a<r;a++)e.set(a,c,e.get(a,c)/h);for(e.set(c,c,e.get(c,c)+1),l=c+1;l<n;l++){for(p=0,a=c;a<r;a++)p+=e.get(a,c)*e.get(a,l);for(p=-p/e.get(c,c),a=c;a<r;a++)e.set(a,l,e.get(a,l)+p*e.get(a,c))}}i[c]=-h}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,p,h;for(p=0;p<a;p++)for(c=0;c<n;c++){for(h=0,l=p;l<r;l++)h+=e.get(l,p)*i.get(l,c);for(h=-h/e.get(p,p),l=p;l<r;l++)i.set(l,c,i.get(l,c)+h*e.get(l,p))}for(p=a-1;p>=0;p--){for(c=0;c<n;c++)i.set(p,c,i.get(p,c)/this.Rdiag[p]);for(l=0;l<p;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(p,c)*e.get(l,p))}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 xi{constructor(t,e={}){if(t=dr.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,p=!!a,h=!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,h=!0;let C=c;c=p,p=C}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),E=new Float64Array(r),b=new Float64Array(g);for(let C=0;C<g;C++)b[C]=C;let N=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),F=Math.max(N,x);for(let C=0;C<F;C++){if(C<N){y[C]=0;for(let B=C;B<r;B++)y[C]=hn(y[C],f.get(B,C));if(y[C]!==0){f.get(C,C)<0&&(y[C]=-y[C]);for(let B=C;B<r;B++)f.set(B,C,f.get(B,C)/y[C]);f.set(C,C,f.get(C,C)+1)}y[C]=-y[C]}for(let B=C+1;B<n;B++){if(C<N&&y[C]!==0){let L=0;for(let U=C;U<r;U++)L+=f.get(U,C)*f.get(U,B);L=-L/f.get(C,C);for(let U=C;U<r;U++)f.set(U,B,f.get(U,B)+L*f.get(U,C))}v[B]=f.get(C,B)}if(c&&C<N)for(let B=C;B<r;B++)m.set(B,C,f.get(B,C));if(C<x){v[C]=0;for(let B=C+1;B<n;B++)v[C]=hn(v[C],v[B]);if(v[C]!==0){v[C+1]<0&&(v[C]=0-v[C]);for(let B=C+1;B<n;B++)v[B]/=v[C];v[C+1]+=1}if(v[C]=-v[C],C+1<r&&v[C]!==0){for(let B=C+1;B<r;B++)E[B]=0;for(let B=C+1;B<r;B++)for(let L=C+1;L<n;L++)E[B]+=v[L]*f.get(B,L);for(let B=C+1;B<n;B++){let L=-v[B]/v[C+1];for(let U=C+1;U<r;U++)f.set(U,B,f.get(U,B)+L*E[U])}}if(p)for(let B=C+1;B<n;B++)w.set(B,C,v[B])}}let M=Math.min(n,r+1);if(N<n&&(y[N]=f.get(N,N)),r<M&&(y[M-1]=0),x+1<M&&(v[x]=f.get(x,M-1)),v[M-1]=0,c){for(let C=N;C<d;C++){for(let B=0;B<r;B++)m.set(B,C,0);m.set(C,C,1)}for(let C=N-1;C>=0;C--)if(y[C]!==0){for(let B=C+1;B<d;B++){let L=0;for(let U=C;U<r;U++)L+=m.get(U,C)*m.get(U,B);L=-L/m.get(C,C);for(let U=C;U<r;U++)m.set(U,B,m.get(U,B)+L*m.get(U,C))}for(let B=C;B<r;B++)m.set(B,C,-m.get(B,C));m.set(C,C,1+m.get(C,C));for(let B=0;B<C-1;B++)m.set(B,C,0)}else{for(let B=0;B<r;B++)m.set(B,C,0);m.set(C,C,1)}}if(p)for(let C=n-1;C>=0;C--){if(C<x&&v[C]!==0)for(let B=C+1;B<n;B++){let L=0;for(let U=C+1;U<n;U++)L+=w.get(U,C)*w.get(U,B);L=-L/w.get(C+1,C);for(let U=C+1;U<n;U++)w.set(U,B,w.get(U,B)+L*w.get(U,C))}for(let B=0;B<n;B++)w.set(B,C,0);w.set(C,C,1)}let S=M-1,I=Number.EPSILON;for(;M>0;){let C,B;for(C=M-2;C>=-1&&C!==-1;C--){const L=Number.MIN_VALUE+I*Math.abs(y[C]+Math.abs(y[C+1]));if(Math.abs(v[C])<=L||Number.isNaN(v[C])){v[C]=0;break}}if(C===M-2)B=4;else{let L;for(L=M-1;L>=C&&L!==C;L--){let U=(L!==M?Math.abs(v[L]):0)+(L!==C+1?Math.abs(v[L-1]):0);if(Math.abs(y[L])<=I*U){y[L]=0;break}}L===C?B=3:L===M-1?B=1:(B=2,C=L)}switch(C++,B){case 1:{let L=v[M-2];v[M-2]=0;for(let U=M-2;U>=C;U--){let k=hn(y[U],L),W=y[U]/k,z=L/k;if(y[U]=k,U!==C&&(L=-z*v[U-1],v[U-1]=W*v[U-1]),p)for(let K=0;K<n;K++)k=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,k)}break}case 2:{let L=v[C-1];v[C-1]=0;for(let U=C;U<M;U++){let k=hn(y[U],L),W=y[U]/k,z=L/k;if(y[U]=k,L=-z*v[U],v[U]=W*v[U],c)for(let K=0;K<r;K++)k=W*m.get(K,U)+z*m.get(K,C-1),m.set(K,C-1,-z*m.get(K,U)+W*m.get(K,C-1)),m.set(K,U,k)}break}case 3:{const L=Math.max(Math.abs(y[M-1]),Math.abs(y[M-2]),Math.abs(v[M-2]),Math.abs(y[C]),Math.abs(v[C])),U=y[M-1]/L,k=y[M-2]/L,W=v[M-2]/L,z=y[C]/L,K=v[C]/L,Z=((k+U)*(k-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=C;lt<M-1;lt++){let wt=hn(ct,vt);wt===0&&(wt=Number.MIN_VALUE);let bt=ct/wt,Bt=vt/wt;if(lt!==C&&(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],p)for(let Et=0;Et<n;Et++)wt=bt*w.get(Et,lt)+Bt*w.get(Et,lt+1),w.set(Et,lt+1,-Bt*w.get(Et,lt)+bt*w.get(Et,lt+1)),w.set(Et,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&<<r-1)for(let Et=0;Et<r;Et++)wt=bt*m.get(Et,lt)+Bt*m.get(Et,lt+1),m.set(Et,lt+1,-Bt*m.get(Et,lt)+bt*m.get(Et,lt+1)),m.set(Et,lt,wt)}v[M-2]=ct;break}case 4:{if(y[C]<=0&&(y[C]=y[C]<0?-y[C]:0,p))for(let L=0;L<=S;L++)w.set(L,C,-w.get(L,C));for(;C<S&&!(y[C]>=y[C+1]);){let L=y[C];if(y[C]=y[C+1],y[C+1]=L,p&&C<n-1)for(let U=0;U<n;U++)L=w.get(U,C+1),w.set(U,C+1,w.get(U,C)),w.set(U,C,L);if(c&&C<r-1)for(let U=0;U<r;U++)L=m.get(U,C+1),m.set(U,C+1,m.get(U,C)),m.set(U,C,L);C++}M--;break}}}if(h){let C=w;w=m,m=C}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),p=l.rows,h=a.rows,f=pt.zeros(p,h);for(let d=0;d<p;d++)for(let g=0;g<h;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 h=0;h<r;h++)for(let f=0;f<n;f++)Math.abs(this.s[f])>e&&i.set(h,f,t.get(h,f)/this.s[f]);let a=this.U,l=a.rows,c=a.columns,p=new pt(r,l);for(let h=0;h<r;h++)for(let f=0;f<l;f++){let d=0;for(let g=0;g<c;g++)d+=i.get(h,g)*a.get(f,g);p.set(h,f,d)}return p}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 uy(s,t=!1){return s=dr.checkMatrix(s),t?new xi(s).inverse():jf(s,pt.eye(s.rows))}function jf(s,t,e=!1){return s=dr.checkMatrix(s),t=dr.checkMatrix(t),e?new xi(s).solve(t):s.isSquare()?new ao(s).solve(t):new za(s).solve(t)}function uo(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 oo(s,[1,2],[1,2]),a=new oo(s,[1,2],[0,2]),l=new oo(s,[1,2],[0,1]),t=s.get(0,0),e=s.get(0,1),r=s.get(0,2),t*uo(i)-e*uo(a)+r*uo(l)}else return new ao(s).determinant}else throw Error("determinant can only be calculated for a square matrix")}function ly(s,t){let e=[];for(let r=0;r<s;r++)r!==t&&e.push(r);return e}function cy(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 fy(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(ly(n,a)).transpose(),h=new xi(c).solve(l),f=pt.sub(l,c.mmul(h)).abs().max();i.setRow(a,cy(f,h,a,e,r))}return i}function hy(s,t=Number.EPSILON){if(s=pt.checkMatrix(s),s.isEmpty())return s.transpose();let e=new xi(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 py(s,t=s,e={}){s=new pt(s);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!ar.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 dy(s,t=s,e={}){s=new pt(s);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!ar.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 p=0;p<c.rows;p++)for(let h=0;h<c.columns;h++)c.set(p,h,c.get(p,h)*(1/(a[p]*l[h]))*(1/(s.rows-1)));return c}let Yf=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=dr.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,p,h,f=!1;if(r?f=!0:f=t.isSymmetric(),f){for(p=0;p<n;p++)for(h=0;h<n;h++)i.set(p,h,c.get(p,h));_y(n,l,a,i),my(n,l,a,i)}else{let d=new pt(n,n),g=new Float64Array(n);for(h=0;h<n;h++)for(p=0;p<n;p++)d.set(p,h,c.get(p,h));gy(n,d,g,i),vy(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 _y(s,t,e,r){let n,i,a,l,c,p,h,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,p=0;p<l;p++)f=f+Math.abs(e[p]);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(p=0;p<l;p++)e[p]/=f,a+=e[p]*e[p];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,p=c+1;p<=l-1;p++)i+=r.get(p,c)*e[p],t[p]+=r.get(p,c)*n;t[c]=i}for(n=0,c=0;c<l;c++)t[c]/=a,n+=t[c]*e[c];for(h=n/(a+a),c=0;c<l;c++)t[c]-=h*e[c];for(c=0;c<l;c++){for(n=e[c],i=t[c],p=c;p<=l-1;p++)r.set(p,c,r.get(p,c)-(n*t[p]+i*e[p]));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(p=0;p<=l;p++)e[p]=r.get(p,l+1)/a;for(c=0;c<=l;c++){for(i=0,p=0;p<=l;p++)i+=r.get(p,l+1)*r.get(p,c);for(p=0;p<=l;p++)r.set(p,c,r.get(p,c)-i*e[p])}}for(p=0;p<=l;p++)r.set(p,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 my(s,t,e,r){let n,i,a,l,c,p,h,f,d,g,y,m,w,v,E,b;for(a=1;a<s;a++)t[a-1]=t[a];t[s-1]=0;let N=0,x=0,F=Number.EPSILON;for(p=0;p<s;p++){for(x=Math.max(x,Math.abs(e[p])+Math.abs(t[p])),h=p;h<s&&!(Math.abs(t[h])<=F*x);)h++;if(h>p)do{for(n=e[p],f=(e[p+1]-n)/(2*t[p]),d=hn(f,1),f<0&&(d=-d),e[p]=t[p]/(f+d),e[p+1]=t[p]*(f+d),g=e[p+1],i=n-e[p],a=p+2;a<s;a++)e[a]-=i;for(N=N+i,f=e[h],y=1,m=y,w=y,v=t[p+1],E=0,b=0,a=h-1;a>=p;a--)for(w=m,m=y,b=E,n=y*t[a],i=y*f,d=hn(f,t[a]),t[a+1]=E*d,E=t[a]/d,y=f/d,f=y*e[a]-E*n,e[a+1]=i+E*(y*n+E*e[a]),c=0;c<s;c++)i=r.get(c,a+1),r.set(c,a+1,E*r.get(c,a)+y*i),r.set(c,a,y*r.get(c,a)-E*i);f=-E*b*w*v*t[p]/g,t[p]=E*f,e[p]=y*f}while(Math.abs(t[p])>F*x);e[p]=e[p]+N,t[p]=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 gy(s,t,e,r){let n=0,i=s-1,a,l,c,p,h,f,d;for(f=n+1;f<=i-1;f++){for(d=0,p=f;p<=i;p++)d=d+Math.abs(t.get(p,f-1));if(d!==0){for(c=0,p=i;p>=f;p--)e[p]=t.get(p,f-1)/d,c+=e[p]*e[p];for(l=Math.sqrt(c),e[f]>0&&(l=-l),c=c-e[f]*l,e[f]=e[f]-l,h=f;h<s;h++){for(a=0,p=i;p>=f;p--)a+=e[p]*t.get(p,h);for(a=a/c,p=f;p<=i;p++)t.set(p,h,t.get(p,h)-a*e[p])}for(p=0;p<=i;p++){for(a=0,h=i;h>=f;h--)a+=e[h]*t.get(p,h);for(a=a/c,h=f;h<=i;h++)t.set(p,h,t.get(p,h)-a*e[h])}e[f]=d*e[f],t.set(f,f-1,d*l)}}for(p=0;p<s;p++)for(h=0;h<s;h++)r.set(p,h,p===h?1:0);for(f=i-1;f>=n+1;f--)if(t.get(f,f-1)!==0){for(p=f+1;p<=i;p++)e[p]=t.get(p,f-1);for(h=f;h<=i;h++){for(l=0,p=f;p<=i;p++)l+=e[p]*r.get(p,h);for(l=l/e[f]/t.get(f,f-1),p=f;p<=i;p++)r.set(p,h,r.get(p,h)+l*e[p])}}}function vy(s,t,e,r,n){let i=s-1,a=0,l=s-1,c=Number.EPSILON,p=0,h=0,f=0,d=0,g=0,y=0,m=0,w=0,v,E,b,N,x,F,M,S,I,C,B,L,U,k,W;for(v=0;v<s;v++)for((v<a||v>l)&&(e[v]=n.get(v,v),t[v]=0),E=Math.max(v-1,0);E<s;E++)h=h+Math.abs(n.get(v,E));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=h),!(Math.abs(n.get(N,N-1))<c*y));)N--;if(N===i)n.set(i,i,n.get(i,i)+p),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)+p),n.set(i-1,i-1,n.get(i-1,i-1)+p),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,E=i-1;E<s;E++)m=n.get(i-1,E),n.set(i-1,E,d*m+f*n.get(i,E)),n.set(i,E,d*n.get(i,E)-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),I=0,M=0,N<i&&(I=n.get(i-1,i-1),M=n.get(i,i-1)*n.get(i-1,i)),w===10){for(p+=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=I=.75*y,M=-.4375*y*y}if(w===30&&(y=(I-S)/2,y=y*y+M,y>0)){for(y=Math.sqrt(y),I<S&&(y=-y),y=S-M/((I-S)/2+y),v=a;v<=i;v++)n.set(v,v,n.get(v,v)-y);p+=y,S=I=M=.964}for(w=w+1,x=i-2;x>=N&&(m=n.get(x,x),g=S-m,y=I-m,f=(g*y-M)/n.get(x+1,x)+n.get(x,x+1),d=n.get(x+1,x+1)-m-g-y,g=n.get(x+2,x+1),y=Math.abs(f)+Math.abs(d)+Math.abs(g),f=f/y,d=d/y,g=g/y,!(x===N||Math.abs(n.get(x,x-1))*(Math.abs(d)+Math.abs(g))<c*(Math.abs(f)*(Math.abs(n.get(x-1,x-1))+Math.abs(m)+Math.abs(n.get(x+1,x+1))))));)x--;for(v=x+2;v<=i;v++)n.set(v,v-2,0),v>x+2&&n.set(v,v-3,0);for(b=x;b<=i-1&&(k=b!==i-1,b!==x&&(f=n.get(b,b-1),d=n.get(b+1,b-1),g=k?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!==x?n.set(b,b-1,-y*S):N!==x&&n.set(b,b-1,-n.get(b,b-1)),f=f+y,S=f/y,I=d/y,m=g/y,d=d/f,g=g/f,E=b;E<s;E++)f=n.get(b,E)+d*n.get(b+1,E),k&&(f=f+g*n.get(b+2,E),n.set(b+2,E,n.get(b+2,E)-f*m)),n.set(b,E,n.get(b,E)-f*S),n.set(b+1,E,n.get(b+1,E)-f*I);for(v=0;v<=Math.min(i,b+3);v++)f=S*n.get(v,b)+I*n.get(v,b+1),k&&(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)+I*r.get(v,b+1),k&&(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(h!==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,E=N;E<=i;E++)g=g+n.get(v,E)*n.get(E,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*h)):(S=n.get(v,v+1),I=n.get(v+1,v),d=(e[v]-f)*(e[v]-f)+t[v]*t[v],F=(S*y-m*g)/d,n.set(v,i,F),n.set(v+1,i,Math.abs(S)>Math.abs(m)?(-g-M*F)/S:(-y-I*F)/m)),F=Math.abs(n.get(v,i)),c*F*F>1)for(E=v;E<=i;E++)n.set(E,i,n.get(E,i)/F)}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=lo(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(C=0,B=0,E=N;E<=i;E++)C=C+n.get(v,E)*n.get(E,i-1),B=B+n.get(v,E)*n.get(E,i);if(M=n.get(v,v)-f,t[v]<0)m=M,g=C,y=B;else if(N=v,t[v]===0?(W=lo(-C,-B,M,d),n.set(v,i-1,W[0]),n.set(v,i,W[1])):(S=n.get(v,v+1),I=n.get(v+1,v),L=(e[v]-f)*(e[v]-f)+t[v]*t[v]-d*d,U=(e[v]-f)*2*d,L===0&&U===0&&(L=c*h*(Math.abs(M)+Math.abs(d)+Math.abs(S)+Math.abs(I)+Math.abs(m))),W=lo(S*g-m*C+d*B,S*y-m*B-d*C,L,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,(-C-M*n.get(v,i-1)+d*n.get(v,i))/S),n.set(v+1,i,(-B-M*n.get(v,i)-d*n.get(v,i-1))/S)):(W=lo(-g-I*n.get(v,i-1),-y-I*n.get(v,i),m,d),n.set(v+1,i-1,W[0]),n.set(v+1,i,W[1]))),F=Math.max(Math.abs(n.get(v,i-1)),Math.abs(n.get(v,i))),c*F*F>1)for(E=v;E<=i;E++)n.set(E,i-1,n.get(E,i-1)/F),n.set(E,i,n.get(E,i)/F)}for(v=0;v<s;v++)if(v<a||v>l)for(E=v;E<s;E++)r.set(v,E,n.get(v,E));for(E=s-1;E>=a;E--)for(v=a;v<=l;v++){for(m=0,b=a;b<=Math.min(E,l);b++)m=m+r.get(v,b)*n.get(b,E);r.set(v,E,m)}}}function lo(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 Vf{constructor(t){if(t=dr.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 p=0;for(c=0;c<l;c++){let h=0;for(a=0;a<c;a++)h+=n.get(c,a)*n.get(l,a);h=(e.get(l,c)-h)/n.get(c,c),n.set(l,c,h),p=p+h*h}for(p=e.get(l,l)-p,i&=p>0,n.set(l,l,Math.sqrt(Math.max(p,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=dr.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=dr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:i=1e3,terminationCriteria:a=1e-10}=e;let l;if(r){if(ar.isAnyArray(r)&&typeof r[0]=="number"?r=pt.columnVector(r):r=dr.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,p,h,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()),p=t.mmul(f).div(f.transpose().mmul(f).get(0,0)),g>0&&(c=p.clone().sub(d).pow(2).sum()),d=p.clone(),r?(h=r.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0)),h=h.div(h.norm()),l=r.mmul(h).div(h.transpose().mmul(h).get(0,0))):l=p;if(r){let g=t.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0));g=g.div(g.norm());let y=t.clone().sub(p.clone().mmul(g.transpose())),m=l.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0)),w=r.clone().sub(p.clone().mulS(m.get(0,0)).mmul(h.transpose()));this.t=p,this.p=g.transpose(),this.w=f.transpose(),this.q=h,this.u=l,this.s=p.transpose().mmul(p),this.xResidual=y,this.yResidual=w,this.betas=m}else this.w=f.transpose(),this.s=p.transpose().mmul(p).sqrt(),n?this.t=p.clone().div(this.s.get(0,0)):this.t=p,this.xResidual=t.sub(p.mmul(f.transpose()))}}qt.AbstractMatrix=$t,qt.CHO=Vf,qt.CholeskyDecomposition=Vf,qt.DistanceMatrix=so,qt.EVD=Yf;var yy=qt.EigenvalueDecomposition=Yf;qt.LU=ao,qt.LuDecomposition=ao;var Kf=qt.Matrix=pt;qt.MatrixColumnSelectionView=ty,qt.MatrixColumnView=Q1,qt.MatrixFlipColumnView=ey,qt.MatrixFlipRowView=ry,qt.MatrixRowSelectionView=iy,qt.MatrixRowView=ny,qt.MatrixSelectionView=oo,qt.MatrixSubView=sy,qt.MatrixTransposeView=oy,qt.NIPALS=Zf,qt.Nipals=Zf,qt.QR=za,qt.QrDecomposition=za,qt.SVD=xi,qt.SingularValueDecomposition=xi,qt.SymmetricMatrix=Xn,qt.WrapperMatrix1D=Wf,qt.WrapperMatrix2D=dr,qt.correlation=dy,qt.covariance=py;var Gf=qt.default=pt;qt.determinant=uo,qt.inverse=uy,qt.linearDependencies=fy,qt.pseudoInverse=hy,qt.solve=jf,qt.wrap=ay;const Hf=yy,Jf=Kf;Gf.Matrix&&Gf.Matrix;class wy{constructor(t){R(this,"_errorListener");this._errorListener=t}new({rows:t,columns:e,initial_value:r}={}){return new qa(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 qa{constructor(t=0,e=0,r=void 0,n){R(this,"_matrixInstance");R(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=eo(this._matrixArray);return this._newMatrix(t)}max(){return _1(this._matrixArray)}min(){return $a(this._matrixArray)}pow({power:t}){const e=_t(t)?this._matrixArray:g1(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=l1(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=a1(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=m1(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t,order:e=Vn.ascending}={}){_t(t)&&(t=0),this._matrixInstance.sort((r,n)=>{const i=r._value[t],a=n._value[t];return e!==Vn.descending?i-a:a-i})}trace(){return d1(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(ue.matrixRehapeErr,r,zt.Error);return}const n=n1(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 i1(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 qa(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 p=i[l];i[l]=i[a],i[a]=p}const c=i[a][a];for(let p=0;p<n;p++)i[a][p]/=c;for(let p=a+1;p<r;p++){const h=i[p][a];i[p]=i[p].map((f,d)=>f-h*i[a][d]),i[p][a]=0}}for(let a=0;a<r;a++)i[a].some(l=>Number(l.toFixed(8))!==0)&&e++;return e}}class Dy{constructor(t){R(this,"_variables");R(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){if(!t)return!0;const r=Jr(t),n=Jr(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 Jr(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(Qs(i))return`${i}M`;const a=r.asWeeks();if(Qs(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 p=r.asSeconds();return p<=1?"1S":p<=5?"5S":p<=10?"10S":p<=15?"15S":p<=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=Jr(e)*1e3,a=t-n-Math.floor((t-n)/i)*i;return r?r-a:a}}class by{constructor(t,e){R(this,"_errorListener");R(this,"_intlNumberFormatter");R(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(ue.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),zr(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(","),p=((l=c[c.length-1])==null?void 0:l.replace(/[^#]/g,"").length)||0;p&&(i=i.replace(new RegExp(`\\B(?=(\\d{${p}})+(?!\\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||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){R(this,"_errorListener");this._errorListener=t}new(){return new ka(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 ka{constructor(t){R(this,"_errorListener");R(this,"_mapInstance");this._errorListener=t,this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new ka(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 xy{constructor(t){R(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){R(this,"_index");R(this,"_price");R(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 Ay{constructor(t,e){R(this,"_variables");R(this,"_errorListener");R(this,"_defaultLabel",{text:"",xloc:ye.bar_index,yloc:Ur.price,size:tr.normal,style:_e.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}`,c={...this._defaultLabel,...t,id:l,time:r,high:n,low:i};t.point&&(c.x=c.xloc===ye.bar_index?t.point.index:t.point.time,c.y=t.point.price),c.yloc===Ur.abovebar?c.y=n:c.yloc===Ur.belowbar&&(c.y=i),this._verfiyArgs(t,e);const p=new es(l,this._variables,this._errorListener);return e.startsWith("export")||this._variables.label.add(l,c,p),p}_verfiyArgs(t,e){const{xloc:r,yloc:n,style:i,size:a,textalign:l,text_font_family:c}=t,p="label.new";this._paramVerfiy(i,e,p,Object.values(_e),"style"),this._paramVerfiy(r,e,p,Object.values(ye),"xloc"),this._paramVerfiy(n,e,p,Object.values(Ur),"yloc"),this._paramVerfiy(a,e,p,Object.values(tr),"size"),this._paramVerfiy(l,e,p,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign"),this._paramVerfiy(c,e,p,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(We(ue.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}label(t,e){return t.x?t.x:new es(e,this._variables,this._errorListener)}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 es{constructor(t,e,r){R(this,"_id");R(this,"_variables");R(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}copy(t){const e=`label_${t}_${this._variables.bar_index}`,r=this._getLabel(t),n=new es(e,this._variables,this._errorListener);if(r){const i={...r,id:e};this._variables.label.add(e,i,n)}return n}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(tr),"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(ye),"xloc"))}set_yloc({yloc:t},e){const r=this._getLabel(e),{high:n,low:i}=this._variables;r&&(r.yloc=t,t===Ur.abovebar?r.y=n:t===Ur.belowbar&&(r.y=i),this._paramVerfiy(t,e,"label.set_yloc",Object.values(Ur),"yloc"))}set_color({color:t},e){const r=this._getLabel(e);r&&(r.color=t)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===ye.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(_e),"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({textcolor:t},e){const r=this._getLabel(e);r&&(r.textcolor=t)}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(We(ue.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 Cy={freq_all:qr.freqAll,freq_once_per_bar:qr.freqOncePerBar,freq_once_per_bar_close:qr.freqOncePerBarClose},Fy={gaps_off:Vi.gapsOff,gaps_on:Vi.gapsOn,lookahead_off:Vi.lookaheadOff,lookahead_on:Vi.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"},My={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Qf={all:[je.dataWindow,je.pane,je.priceScale,je.statusLine],data_window:[je.dataWindow],none:[],pane:[je.pane],price_scale:[je.priceScale],status_line:[je.statusLine]},Ny={both:kr.both,left:kr.left,none:kr.none,right:kr.right},Sy={inherit:Kt.inherit,mintick:Kt.mintick,percent:Kt.percent,price:Kt.price,volume:Kt.volume},By={style_solid:xs.styleSolid,style_dashed:xs.styleDashed,style_dotted:xs.styleDotted},Oy={style_arrowdown:_e.styleArrowdown,style_arrowup:_e.styleArrowup,style_circle:_e.styleCircle,style_cross:_e.styleCross,style_diamond:_e.styleDiamond,style_flag:_e.styleFlag,style_label_center:_e.styleLabelCenter,style_label_down:_e.styleLabelDown,style_label_left:_e.styleLabelLeft,style_label_lower_left:_e.styleLabelLowerLeft,style_label_lower_right:_e.styleLabelLowerRight,style_label_right:_e.styleLabelRight,style_label_up:_e.styleLabelUp,style_label_upper_left:_e.styleLabelUpperLeft,style_label_upper_right:_e.styleLabelUpperRight,style_none:_e.styleNone,style_square:_e.styleSquare,style_text_outline:_e.styleTextOutline,style_triangledown:_e.styleTriangledown,style_triangleup:_e.styleTriangleup,style_xcross:_e.styleXcross},Ty={style_arrow_both:$e.styleArrowBoth,style_arrow_left:$e.styleArrowLeft,style_arrow_right:$e.styleArrowRight,style_dashed:$e.styleDashed,style_dotted:$e.styleDotted,style_solid:$e.styleSolid},Iy={abovebar:an.abovebar,absolute:an.absolute,belowbar:an.belowbar,bottom:an.bottom,top:an.top},$y={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},Ly={style_area:Ar.styleArea,style_areabr:Ar.styleAreabr,style_circles:Ar.styleCircles,style_columns:Ar.styleColumns,style_cross:Ar.styleCross,style_histogram:Ar.styleHistogram,style_line:Ar.styleLine,style_linebr:Ar.styleLinebr,style_stepline:Ar.styleStepline,style_stepline_diamond:Ar.styleSteplineDiamond,style_steplinebr:Ar.styleSteplinebr},Ry={bottom_center:hr.bottomCenter,bottom_left:hr.bottomLeft,bottom_right:hr.bottomRight,middle_center:hr.middleCenter,middle_left:hr.middleLeft,middle_right:hr.middleRight,top_center:hr.topCenter,top_left:hr.topLeft,top_right:hr.topRight},Py={left:As.left,none:As.none,right:As.right},zy={arrowdown:sr.arrowdown,arrowup:sr.arrowup,circle:sr.circle,cross:sr.cross,diamond:sr.diamond,flag:sr.flag,labeldown:sr.labeldown,labelup:sr.labelup,square:sr.square,triangledown:sr.triangledown,triangleup:sr.triangleup,xcross:sr.xcross},qy={auto:tr.auto,huge:tr.huge,large:tr.large,normal:tr.normal,small:tr.small,tiny:tr.tiny},ky={cash:Be.cash,fixed:Be.fixed,percent_of_equity:Be.percentOfEquity,commission:{cash_per_contract:Cr.cashPerContract,cash_per_order:Cr.cashPerOrder,percent:Cr.percent},direction:{all:me.all,long:me.long,short:me.short},oca:{cancel:un.cancel,none:un.none,reduce:un.reduce}},Uy={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},Wy={bar_index:ye.bar_index,bar_time:ye.bar_time},jy={abovebar:Ur.abovebar,belowbar:Ur.belowbar,price:Ur.price},Yy={actual:Cs.actual,estimate:Cs.estimate,standardized:Cs.standardized};class th{constructor(){R(this,"adjustment",{dividends:Es.dividends,none:Es.none,splits:Es.splits});R(this,"alert",Cy);R(this,"barmerge",Fy);R(this,"color",Ci);R(this,"currency",Xf);R(this,"dayofweek",My);R(this,"earnings",Yy);R(this,"display",Qf);R(this,"extend",Ny);R(this,"font",{family_default:Zn.familyDefault,family_monospace:Zn.familyMonospace});R(this,"format",Sy);R(this,"hline",By);R(this,"label",Oy);R(this,"line",Ty);R(this,"location",Iy);R(this,"math",$y);R(this,"order",{ascending:Vn.ascending,descending:Vn.descending});R(this,"plot",Ly);R(this,"position",Ry);R(this,"scale",Py);R(this,"session",{extended:fi.extended,regular:fi.regular});R(this,"shape",zy);R(this,"size",qy);R(this,"splits",{denominator:"denominator",numerator:"numerator"});R(this,"strategy",ky);R(this,"text",Uy);R(this,"xloc",Wy);R(this,"yloc",jy)}updateData(){}}class Vy{constructor(t,e){R(this,"_variables");R(this,"_errorListener");R(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:ye.bar_index,line_color:Ci.blue,line_style:$e.styleSolid,line_width:1});this._variables=t,this._errorListener=e}new(t,e){var a;const r=`polyline_${e}_${this._variables.bar_index}`,n=Object.assign({},this._defaultPolyline,t,{id:r,points:(a=t.points)==null?void 0:a._value.map(l=>({time:l.time,index:l.index,price:l.price}))}),i=new eh(r,this._variables);return this._verfiyArgs(t,e),e.startsWith("export")||this._variables.polyline.add(r,n,i),i}_verfiyArgs(t,e){const{line_style:r,xloc:n}=t,i="polyline.new";this._paramVerfiy(r,e,i,Object.values($e),"line_style"),this._paramVerfiy(n,e,i,Object.values(ye),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(We(ue.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}delete({id:t}){t&&t.delete()}}class eh{constructor(t,e){R(this,"_id");R(this,"_variables");this._variables=e,this._id=t}delete(){this._variables.polyline.delete(this._id)}}class Zy{constructor(t,e){R(this,"_variables");R(this,"_errorListener");R(this,"_defaultLine",{xloc:ye.bar_index,extend:kr.none,style:$e.styleSolid});this._variables=t,this._errorListener=e}new({first_point:t,second_point:e,...r},n){const i=`line_${n}_${this._variables.bar_index}`,a={...this._defaultLine,...r,id:i};if(t&&e){const c=a.xloc===ye.bar_index?t.index:t.time,p=a.xloc===ye.bar_index?e.index:e.time;Object.assign(a,{x1:c,y1:t.price,x2:p,y2:e.price})}this._verfiyArgs(r,n);const l=new rs(i,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(i,a,l),l}_verfiyArgs(t,e){const{extend:r,xloc:n,style:i}=t,a="line.new";this._paramVerfiy(i,e,a,Object.values($e),"style"),this._paramVerfiy(r,e,a,Object.values(kr),"extend"),this._paramVerfiy(n,e,a,Object.values(ye),"xloc")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(We(ue.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}line(t,e){return t.x?t.x:new rs(e,this._variables,this._errorListener)}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 rs{constructor(t,e,r){R(this,"_variables");R(this,"_id");R(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get data(){return this._variables.line.get(this._id)}copy(t){const e=`line_${t}_${this._variables.bar_index}`,r=this._getLine(t),n=new rs(e,this._variables,this._errorListener);return r&&this._variables.line.add(e,{...r,id:e},n),n}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===ye.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(ye),"xloc"))}set_color({color:t},e){const r=this._getLine(e);r&&(r.color=t)}set_style({style:t},e){const r=this._getLine(e);r&&(r.style=t,this._paramVerfiy(t,e,"line.set_style",Object.values($e),"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(kr),"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===ye.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===ye.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(We(ue.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 Ky{constructor(t){R(this,"_variables");this._variables=t}new({line1:t,line2:e,color:r},n){const i=`linefill_${n}_${this._variables.bar_index}`,a=t==null?void 0:t.data,l=e==null?void 0:e.data;a&&(a.linefills=a.linefills||[],a.linefills.push(i)),l&&(l.linefills=l.linefills||[],l.linefills.push(i));const c=new co(this._variables,i,t,e);return n.startsWith("export")||(a||l)&&this._variables.linefill.add(i,{line1:a,line2:l,color:r,id:i},c),c}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 co{constructor(t,e,r,n){R(this,"_id");R(this,"_line1");R(this,"_line2");R(this,"_variables");this._variables=t,this._id=e,this._line1=r,this._line2=n}linefill(t,e){return t.x?t.x:new co(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({color:t}){const e=this._variables.linefill.get(this._id);e&&(e.color=t)}}class Gy{constructor(t,e){R(this,"_variables");R(this,"_errorListener");R(this,"_defaultBox",{border_color:Ci.blue,border_width:1,bgcolor:Ci.blue,xloc:ye.bar_index,extend:kr.none,style:$e.styleSolid,text:"",text_size:tr.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},e){return t===void 0?new ns(this._variables,e,this._errorListener):t}new({top_left:t,bottom_right:e,...r},n){const i=`box_${n}_${this._variables.bar_index}`,a={...this._defaultBox,...r,id:i};if(t){const{price:c,time:p,index:h}=t;a.top=c,a.left=a.xloc===ye.bar_index?h:p}if(e){const{price:c,time:p,index:h}=e;a.bottom=c,a.right=a.xloc===ye.bar_index?h:p}this._verfiyArgs(r,n);const l=new ns(this._variables,i,this._errorListener);return n.startsWith("export")||this._variables.box.add(i,a,l),l}_verfiyArgs(t,e){const{border_style:r,extend:n,xloc:i,text_size:a,text_halign:l,text_valign:c,text_wrap:p,text_font_family:h}=t,f="box.new";this._paramVerfiy(r,e,f,[$e.styleDashed,$e.styleDotted,$e.styleSolid],"border_style"),this._paramVerfiy(n,e,f,Object.values(kr),"extend"),this._paramVerfiy(i,e,f,Object.values(ye),"xloc"),this._paramVerfiy(a,e,f,Object.values(tr),"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(p,e,f,[Wt.wrapAuto,Wt.wrapNone],"text_wrap"),this._paramVerfiy(h,e,f,Object.values(Zn),"text_font_family")}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(We(ue.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 ns{constructor(t,e,r){R(this,"_id");R(this,"_variables");R(this,"_errorListener");this._variables=t,this._id=e,this._errorListener=r}copy(t){const e=`box_${t}_${this._variables.bar_index}`,r=this._getBox(),n=new ns(this._variables,e,this._errorListener);return r&&this._variables.box.add(e,{...r,id:e},n),n}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(kr),"extend"))}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t)}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(tr),"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)}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===ye.bar_index?r:i}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t)}set_border_style({style:t},e){const r=this._getBox();r&&(r.border_style=t,this._paramVerfiy(t,e,"box.set_border_style",[$e.styleDashed,$e.styleDotted,$e.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===ye.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(We(ue.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getBox(){return this._variables.box.get(this._id)}}class Hy{constructor(t,e){R(this,"_variables");R(this,"_errorListener");R(this,"_defaultTable",{position:hr.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=t,this._errorListener=e}table({x:t},e){return t||new Ua(this._variables,e,this._errorListener)}new(t,e){const r=`table_${e}_${this._variables.bar_index}`,{columns:n,rows:i}=t,a=Array.from(Array(i),()=>Array.from(Array(n),()=>{})),l={...this._defaultTable,...t,cell:a,id:r},c=new Ua(this._variables,r,this._errorListener);return this._paramVerfiy(t.position,e,"table.new",Object.values(hr),"position"),e.startsWith("export")||this._variables.table.add(r,l,c),c}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(We(ue.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 Ua{constructor(t,e,r){R(this,"_id");R(this,"_variables");R(this,"_errorListener");R(this,"_defaultCell",{column:0,row:0,text:"",text_color:Ci.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_size:tr.normal});this._variables=t,this._id=e,this._errorListener=r}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)}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 p=a[l];p&&(p[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(ue.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)}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t)}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(hr),"position"))}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(We(ue.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 Jy{constructor(t){R(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===me.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.historyOrders.length;return!(t>=e)}}class Xy{constructor(t){R(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===me.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.orders.length;return!(t>=e)}}class Qy{constructor(t,e){R(this,"_strategy");R(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(me),"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",[Be.percentOfEquity,Be.cash],"type"),e===Be.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",[Be.percentOfEquity,Be.cash],"type"),e===Be.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(We(ue.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}}let tw=class{constructor(t,e,r,n){R(this,"_variables");R(this,"_options");R(this,"_totalChangeCapital");R(this,"_historyOrder");R(this,"_orders");R(this,"_pendingOrders");R(this,"_mintick");R(this,"_funcOptions");R(this,"_pendingCloseOrders");R(this,"_errorListener");R(this,"_risk");R(this,"_opentrades");R(this,"_closedtrades");R(this,"_riskNamespace");this._variables=t,this._errorListener=n,this._options={overlay:!1,format:Kt.inherit,pyramiding:0,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Be.fixed,default_qty_value:1,initial_capital:1e6,currency:Xf.NONE,slippage:0,commission_type:Cr.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 Xy(this),this._closedtrades=new Jy(this),this._riskNamespace=new Qy(this,n)}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _orderProfit(){return this._orders.reduce((t,e)=>t+(e.profit||0),0)}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){Object.assign(this._options,t),this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),!this._options.process_orders_on_close&&this._calcLiquidate()}updateRisk(t){Object.assign(this._risk,t)}endExecution(){this._calcProfitAndLoss(),this._variables.strategy.update(),this._maxDrawdownVerify(),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:p}}=this._variables;let{preNetprofit:h=0}=this._risk;l===a&&(h=c,this._risk.preNetprofit=c,this._risk.isTemporaryBan=!1);let f=h-c;f+=this._orders.reduce((y,m)=>{const{in_price:w,direction:v,qty:E=0,commission:b=0,original_qty:N=0}=m,x=v===me.long?1:-1,F=(n-w)*E,M=(i-w)*E,S=x===1?-M:F;return y+S+E/N*b},0);let d=!1;switch(e){case Be.cash:d=t<f;break;case Be.percentOfEquity:const y=f/(p+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===me.long?i:n,"Close Position (Max intraday Loss)"),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)"),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 p=e;if(i===a){const h=l.netprofit+l.openprofit;h<n?p=0:p++,Object.assign(this._risk,{lossDays:p,totalProfit:h})}t<=p&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){var n;const{max_drawdown:t,max_drawdown_type:e,isDisabledOpen:r}=this._risk;if(!r&&t!==void 0&&e){const{max_drawdown:i,max_drawdown_percent:a}=this._variables.strategy;let l=!1;switch(e){case Be.percentOfEquity:l=a<i;break;case Be.cash:l=t<i;break}if(l){const{high:c,low:p}=this._variables,h=(n=this._orders[0])==null?void 0:n.direction;this._riskTouchOff(h===me.long?c:p,"Close Position (Max Drawdown)")}}}_riskTouchOff(t,e){this._risk.isDisabledOpen=!0,this._closeOrders(this._orders,t,e),this._pendingOrders=[]}strategy(t,e){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(Be),"default_qty_type"),this._paramVerfiy(t.commission_type,e,"strategy",Object.values(Cr),"commission_type"),Object.assign(this._options,t),this._variables.updateMaxLength(t),Object.assign(this._funcOptions,{strategy:this._options,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.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close"}):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=Be.fixed,default_qty_value:r=1,initial_capital:n}=this._options;switch(e){case Be.fixed:return r;case Be.cash:return r/t;case Be.percentOfEquity:return(n+this._orderProfit+this._totalChangeCapital)*r/100/t}}_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{high:t,low:e,close:r}=this._variables;for(const n of this._orders){const{in_price:i,qty:a=0,direction:l}=n,c=l===me.long?1:-1,p=(r-i)*c*a,h=(t-i)*a,f=(e-i)*a,d=c===1?h:-f,g=c===1?-f:h;this._calcOrderPercent(n,p,d,g)}}_calcOrderPercent(t,e,r,n){const{commission_value:i}=this._options,{close:a}=this._variables,{original_qty:l=0,qty:c=0,in_price:p,max_profit:h=0,trading_loss:f=0}=t;let{commission:d=0}=t;const g=p*c;if(i){const y=this._getCommission(a,c);e=e-y,d=d*c/l,r-=d,n+=d}r=Math.max(r,h),n=Math.min(n,f),e=e-d,Object.assign(t,{profit:e,total_profit:this._totalChangeCapital+e,total_profit_percent:e/this._options.initial_capital*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}=this._variables,{initial_capital:r,margin_long:n=0,margin_short:i=0,commission_value:a=0}=this._options,l=this._orders[0].direction===me.long?1:-1,c=l===1?e:t,p=(l===1?n:i)/100;if(p<=0)return;const[h,f,d]=this._orders.reduce((v,E)=>{let[b,N,x]=v;const{in_price:F,qty:M=0,original_qty:S=0,commission:I=0}=E,C=F*M,B=c*M;if(b+=C,N+=B,a){const L=this._getCommission(c,M);x+=L+M/S*I}return[b,N,x]},[0,0,0]),g=l*(f-h),m=r+this._totalChangeCapital+g-d-f*p;if(m>=0)return;const w=Math.trunc(m/p/c)*4;this._marginCallOrders(c,w,"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);return}for(const i of this.orders)this._processOrder(i,t,e,r,r);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders)}_orderHandle(t){const{process_orders_on_close:e,slippage:r=0}=this._options,{orders:n,isMarketPrice:i,quantities:a,close:l,price:c,activePrice:p}=this._orderArgsParse(t),h=t.direction===me.long?1:-1;if(a<=0)return;let f=a;if(i&&e){if(n.length){const m=this._processOrders(n,l,f,t.id,t.comment);if(m<=0)return;f=m}const g=l+h*r*this._mintick;if(!this._judgeCapitalEnough(f,g,h))return;this._ocaGroupVerify(f,t.oca_name,t.oca_type),this._calcCurrentOrder({...t,in_price:g,in_index:this._variables.bar_index,in_time:this._variables.time,qty:f,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,h)&&this._addPendingOrders(t,c,f,i,p)}_judgeCapitalEnough(t,e,r){if(t<=0)return!1;const{margin_long:n=0,margin_short:i=0}=this._options;if((n===0||n===100)&&r===1||i===0&&r===-1)return!0;const l=this._getCapital(r,this._options.initial_capital+this._orderProfit+this._totalChangeCapital)-this._freezeCapital;return t*e<=l}_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){let a=r;for(const l of t)if(a=this._processOrder(l,e,a,n,i),a<=0)break;return this._orders=this._orders.filter(l=>!l.isDeal),this._variables.strategy.updateOrders(this._orders),a}_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,p;const h=e===me.long?1:-1,f=n&&(n-a)*h>0,{backtest_fill_limits_assumption:d=0}=this._options;d>0&&i&&(i-=d*this._mintick*h);const g=i&&(i-a)*h<0;f&&g?(p=n,l=i):f?l=n:g?l=i:c=!0;const y=r||this._calcDefaultQty(l)||1;return{orders:this._orders.filter(w=>w.direction!==e),isMarketPrice:c,activePrice:p,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===me.long?1:-1)&&this._addPendingEntry(t,l,i,n,c)}_entryOrder(t,e,r,n){const{time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{oca_name:c,oca_type:p,direction:h,comment:f,isMarketPrice:d,id:g}=n,y=h===me.long?1:-1;if(this._closeOrders(t,e,g,f),r=this._getAvailablePositionSize(r,h),r<=0)return;e=e+l*this._mintick*y;const m={...n,in_price:e,original_qty:r,qty:r,in_index:a,in_time:i,place_order_type:"entry"};if(d){this._calcCurrentOrder(m);return}const{pendingOrders:w,orders:v}=this._getEntryOrders(h),E=w.length+v.length;E&&E>=(this._options.pyramiding||0)||!this._judgeCapitalEnough(r,e,y)||(this._ocaGroupVerify(r,c,p),this._calcCurrentOrder(m))}_getAvailablePositionSize(t,e){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==me.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,p=a.find(h=>h.id===t.id&&h.place_order_type==="entry");if(p)Object.assign(p,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:i});else if(!c||c<(this._options.pyramiding||1)){const h={...t,in_price:e,isMarketPrice:n,qty:r,active_price:i,place_order_type:"entry"};this._pendingOrders.push(h)}}_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),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(t,e,r,n){for(const i of t)this._closeOrder(i,e,r,n);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders)}_closeOrder(t,e,r,n){const{time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{in_price:c,qty:p=0,direction:h}=t,f=h===me.long?1:-1;e=e-f*l*this._mintick,t.isDeal=!0;const d=(e-c)*f*p,g={...t,out_price:e,out_id:r,out_index:a,out_time:i,out_comment:n,out_qty:p,profit:d};this._calcPercent(g),this._risk.intradayOrders+=1,this._historyOrder.push(g),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_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:p,isMarketPriceLimit:h,isMarketPriceStop:f,direction:d,id:g,out_comment:y,active_price:m,trail_offset:w=0,out_qty:v,comment_loss:E,comment_profit:b,comment_trailing:N}=a;let x=p;const F=d===me.long?1:-1;let M,S=y;if(h||f?M=e:(c&&r<=c&&n>=c&&(S=b||y,M=c),l&&r<=l&&n>=l&&(M=x?(l-x)*F>0?l:x:l,S=(x===M?N:E)||y)),M)this._processExitOnClose(a,M,{from_entry:g,comment:S,qty:v});else{let I=!1;if(m&&m<=n&&m>=r&&(x=m-w*F*this._mintick,(x-i)*F>=0&&(a.isMarketPriceStop=!0,this._options.process_orders_on_close&&(M=x)),I=!0,a.trail_stop_price=x),x)if((x-e)*F>=0&&!I)M=x;else{const C=(F===1?n:r)-w*F*this._mintick;F===1?x<e&&x>=r&&C>x&&C<i?M=x:C>x?(x=C,C>=i&&(M=C)):x<=n&&r<=x&&(M=x):x>e&&x<=n&&C<x&&C>i?M=x:C<x?(x=C,C<=i&&(M=C)):x<=n&&r<=x&&(M=x),a.trail_stop_price=x}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 r)switch(n.place_order_type){case"close":this._closeOrderHandle(n);break;case"close_all":this._closeAllOrders(n,this._variables.open);break}for(const n of this._pendingOrders){const{isCancel:i,place_order_type:a}=n;if(i)continue;let 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 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;for(const n of e)switch(n.place_order_type){case"close":this._closeOrderHandle(n,!0);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)}this._pendingCloseOrders=[]}_entryOrderHandle(t){const{open:e,low:r,high:n}=this._variables,{isMarketPrice:i,qty:a=0,in_price:l,direction:c,active_price:p}=t;if(p&&n>=p&&r<=p)return delete t.active_price,t;let h=l;if(i&&(h=e),h<=n&&h>=r){const f=this._orders.filter(d=>d.direction!==c);this._entryOrder(f,h,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:p=0,in_price:h,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=h,E=p;if(c&&(v=e),v<=n&&v>=r){const b=this._orders.filter(x=>x.direction!==f);if(b.length&&(E=this._processOrders(b,v,p,w,d),E<=0))return;const N=f===me.long?1:-1;this._ocaGroupVerify(E,g,y),this._calcCurrentOrder({...t,in_price:v+N*l*this._mintick,in_index:a,in_time:i,qty:E});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:i=100,comment:a}=t,{bar_index:l}=this._variables,c=this._orders.filter(g=>g.id===r&&g.in_index!==l&&(!g.close_qty||g.close_qty<(g.qty||0)));if(!c.length)return;let p=0;if(n?p=n:(p=c.reduce((g,y)=>g+(y.qty||0),p),p=i/100*p),p<=0)return;const{open:h,close:f}=this._variables;let d=p;for(const g of c){const{qty:y=0}=g;d<y?g.close_qty=d:(g.close_qty=y,d-=y)}this._processOrders(this._options.close_entries_rule==="ANY"?c:this._orders,e?f:h,p,`Close entry(s) order ${r}`,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:p,from_entry:h="",id:f}=t;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(i)&&this._isNaN(a)&&(this._isNaN(l)||this._isNaN(p)&&this._isNaN(c))){this._errorListener.addError(ue.strategyExitErr,e,zt.Error);return}const d={...t,place_order_type:"exit"},g=this._orders.filter(w=>(!h||h===w.id)&&!w.hasExit),y=this._pendingOrders.filter(w=>!h||h===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);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:p}=e;let h=r,f=!1;e.comment=a||i;for(const d of t){const{qty:g=0}=d,y=d.direction===me.long?1:-1;h=r?r>=g?g:r:n/100*g,d.out_qty=h,h<g&&(f=!0),Object.assign(d,{out_comment:a||i,comment_loss:l,comment_profit:c,comment_trailing:p}),!(this._stopProfit(d,y,{...e,qty:h})||this._stopLoss(d,y,{...e,qty:h})||this._trailStopLoss(d,y,{...e,qty:h}))&&(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:p}=this._variables,{in_price:h}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=h+e*i*this._mintick),t.limit=c,c&&(c-p)*e<=0&&(t.isMarketPriceLimit=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=p,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:p}=this._variables,{in_price:h}=t,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=h-e*i*this._mintick),t.stop=c,c&&(c-p)*e>=0&&(t.isMarketPriceStop=!0,r.comment=a||l,Object.assign(t,{out_comment:r.comment}),c=p,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:p}=this._variables,{in_price:h}=t,{process_orders_on_close:f}=this._options;let d;if(this._isNaN(i)?this._isNaN(a)||(d=h+a*e*this._mintick):d=i,t.trail_offset=n,d&&(d-p)*e<=0){const g=p-n*e*this._mintick;if((g-p)*e>=0&&(t.trail_stop_price=p,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)}_processExitOrders(t,e,r,n,i){let a=r,l;for(const c of t)if(l=c,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),l}_processOrder(t,e,r,n,i){const{time:a,bar_index:l}=this._variables,{slippage:c=0}=this._options,{in_price:p,qty:h=0,max_profit:f=0,trading_loss:d=0,direction:g,commission:y=0,original_qty:m=0}=t,w=g===me.long?1:-1;if(e=e-w*c*this._mintick,r<h){const v=h-r,E=(e-p)*w*r,b=f/h*r,N=d/h*r;this._calcPercent({...t,out_price:e,out_id:n,out_index:l,out_time:a,out_comment:i,profit:E,out_qty:r,max_profit:b,trading_loss:N});const x=(e-p)*w*v-y*v/m;Object.assign(t,{qty:v,profit:x,max_profit:f-b,trading_loss:d-N,total_profit:this._totalChangeCapital+x}),r=0}else{t.isDeal=!0;const v=(e-p)*w*h;this._calcPercent({...t,out_price:e,out_id:n,out_index:l,out_time:a,out_comment:i,out_qty:h,profit:v}),r-=h}return r}_calcPercent(t){const{commission_value:e}=this._options,{in_price:r,out_qty:n=0,out_price:i=0,original_qty:a=0}=t;let{profit:l=0,max_profit:c=0,trading_loss:p=0,commission:h=0}=t;c=c<0?0:c;const f=r*n;if(this._totalChangeCapital+=l,e){const d=this._getCommission(i,n);this._totalChangeCapital-=d,h=h*n/a+d,l=l-h,Object.assign(t,{commission:h,profit:l,max_profit:c})}Object.assign(t,{total_profit:this._totalChangeCapital,total_profit_percent:l/this._options.initial_capital*100,profit_percent:l/f*100,max_profit_percent:c/f*100,trading_loss_percent:p/f*100}),this._risk.intradayOrders+=1,this._historyOrder.push(t),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_getCommission(t,e){const{commission_value:r=0,commission_type:n}=this._options,i=t*e;let a=0;switch(n){case Cr.percent:a=i*r/100;break;case Cr.cashPerContract:a=e*r;break;case Cr.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;const c=r*n;if(e){const p=this._getCommission(r,n);this._totalChangeCapital-=p,l=l-p,Object.assign(t,{commission:p,profit:l,total_profit:this._totalChangeCapital})}Object.assign(t,{original_qty:n,total_profit_percent:l/this._options.initial_capital*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)}_isNaN(t){return t===void 0||isNaN(t)}_paramVerfiy(t="",e,r,n,i){t&&!n.includes(t)&&this._errorListener.addError(We(ue.paramsErr,{value:t,func:r,param:i,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}};var rh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,function(){return function(e,r,n){r.prototype.isBetween=function(i,a,l,c){var p=n(i),h=n(a),f=(c=c||"()")[0]==="(",d=c[1]===")";return(f?this.isAfter(p,l):!this.isBefore(p,l))&&(d?this.isBefore(h,l):!this.isAfter(h,l))||(f?this.isBefore(p,l):!this.isAfter(p,l))&&(d?this.isAfter(h,l):!this.isBefore(h,l))}}})})(rh);var ew=rh.exports,rw=Gt(ew),nh={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,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(I){var C,B;w[C=I,B=i.$utils().p(C),B==="date"?"day":B]=y[I]});var E=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(),x=w.hour||0,F=w.minute||0,M=w.second||0,S=w.millisecond||0;return m?new Date(Date.UTC(b,N,E,x,F,M,S)):new Date(b,N,E,x,F,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,p=i.add,h=i.subtract,f=function(d,g,y,m){m===void 0&&(m=1);var w=Object.keys(g),v=this;return w.forEach(function(E){v=d.bind(v)(g[E]*m,E)}),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)(p,d,g):p.bind(this)(d,g)},i.subtract=function(d,g){return d.constructor.name==="Object"?f.bind(this)(p,d,g,-1):h.bind(this)(d,g)}}})})(nh);var nw=nh.exports,iw=Gt(nw),ih={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(Vt,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,p=31536e6,h=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:p,months:h,days:l,hours:a,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},g=function(F){return F instanceof N},y=function(F,M,S){return new N(F,S,M.$l)},m=function(F){return r.p(F)+"s"},w=function(F){return F<0},v=function(F){return w(F)?Math.ceil(F):Math.floor(F)},E=function(F){return Math.abs(F)},b=function(F,M){return F?w(F)?{negative:!0,format:""+E(F)+M}:{negative:!1,format:""+F+M}:{negative:!1,format:""}},N=function(){function F(S,I,C){var B=this;if(this.$d={},this.$l=C,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),I)return y(S*d[m(I)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(k){B.$d[m(k)]=S[k]}),this.calMilliseconds(),this;if(typeof S=="string"){var L=S.match(f);if(L){var U=L.slice(2).map(function(k){return k!=null?Number(k):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=F.prototype;return M.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(I,C){return I+(S.$d[C]||0)*d[C]},0)},M.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/p),S%=p,this.$d.months=v(S/h),S%=h,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"),I=b(this.$d.months,"M"),C=+this.$d.days||0;this.$d.weeks&&(C+=7*this.$d.weeks);var B=b(C,"D"),L=b(this.$d.hours,"H"),U=b(this.$d.minutes,"M"),k=this.$d.seconds||0;this.$d.milliseconds&&(k+=this.$d.milliseconds/1e3,k=Math.round(1e3*k)/1e3);var W=b(k,"S"),z=S.negative||I.negative||B.negative||L.negative||U.negative||W.negative,K=L.format||U.format||W.format?"T":"",Z=(z?"-":"")+"P"+S.format+I.format+B.format+K+L.format+U.format+W.format;return Z==="P"||Z==="-P"?"P0D":Z},M.toJSON=function(){return this.toISOString()},M.format=function(S){var I=S||"YYYY-MM-DDTHH:mm:ss",C={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 I.replace(c,function(B,L){return L||String(C[B])})},M.as=function(S){return this.$ms/d[m(S)]},M.get=function(S){var I=this.$ms,C=m(S);return C==="milliseconds"?I%=1e3:I=C==="weeks"?v(I/d[C]):this.$d[C],I||0},M.add=function(S,I,C){var B;return B=I?S*d[m(I)]:g(S)?S.$ms:y(S,this).$ms,y(this.$ms+B*(C?-1:1),this)},M.subtract=function(S,I){return this.add(S,I,!0)},M.locale=function(S){var I=this.clone();return I.$l=S,I},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")},F}(),x=function(F,M,S){return F.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(F,M,S){e=S,r=S().$utils(),S.duration=function(B,L){var U=S.locale();return y(B,{$l:U},L)},S.isDuration=g;var I=M.prototype.add,C=M.prototype.subtract;M.prototype.add=function(B,L){return g(B)?x(this,B,1):I.bind(this)(B,L)},M.prototype.subtract=function(B,L){return g(B)?x(this,B,-1):C.bind(this)(B,L)}}})})(ih);var sw=ih.exports,ow=Gt(sw);ee.extend(Bl),ee.extend(rw),ee.extend(iw),ee.extend(ow);class sh{constructor(t,e,r){R(this,"array");R(this,"color");R(this,"math");R(this,"str");R(this,"map");R(this,"matrix");R(this,"timeframe");R(this,"ta");R(this,"input");R(this,"_variables");R(this,"_cacheData");R(this,"_options");R(this,"_errorListener");R(this,"_plots");R(this,"_plotshapes");R(this,"_plotbars");R(this,"_plotchars");R(this,"_plotarrows");R(this,"_plotcandles");R(this,"_alerts");R(this,"_bgColors");R(this,"_hlines");R(this,"_fills");R(this,"chart");R(this,"line");R(this,"label");R(this,"polyline");R(this,"box");R(this,"table");R(this,"linefill");R(this,"log");R(this,"runtime");R(this,"strategy");R(this,"request");R(this,"syminfo");R(this,"_count",0);var i;const n=((i=t.toString().split(".")[1])==null?void 0:i.length)||5;this._variables=e,this._errorListener=new fw,this.array=new Gp(this._errorListener),this.math=new Hp(n,this._errorListener),this.color=new D1,this.str=new by(this._errorListener,n),this.map=new Ey(this._errorListener),this.timeframe=new Dy(e),this.matrix=new wy(this._errorListener),this.ta=new y1(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 w1(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 xy(e)},this.line=new Zy(e,this._errorListener),this.label=new Ay(e,this._errorListener),this.polyline=new Vy(e,this._errorListener),this.box=new Gy(e,this._errorListener),this.table=new Hy(e,this._errorListener),this.linefill=new Ky(e),this.log=new lw(e),this.runtime=new cw(this._errorListener),this.strategy=new tw(this._variables,this._options,t,this._errorListener),this.request=new aw(this._variables,r),this.syminfo=new uw}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});const p=this._plots.size>0?[...this._plots.values()]:void 0,h=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:p,draws:m,alerts:r,colors:i,hlines:a,fills:l,logs:c,plotshapes:f,plotarrows:d,plotcandles:g,plotchars:y,plotbars:h,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()]),p=this._plotshapes.size>0?this._getDataFromBarindex(t,[...this._plotshapes.values()]):void 0,h=this._getDrawsFromBarindex(t),f=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,draws:h,alerts:e,colors:n,hlines:i,fills:a,logs:l,plotshapes:p,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}=t;this.input.update(e)}update(t){const{barIndex:e}=t;this.strategy.updateOptions(),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)?(Kp.includes(n)||Zp.includes(n))&&this._errorListener.addError(We(ue.libraryTitleIsKeywordErr,{name:n}),e,zt.Error):this._errorListener.addError(ue.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(We(ue.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"];on(t,r);const{series:n,color:i,...a}=t,{bar_index:l,time:c}=this._variables,p=`plot_${e}`,h=this._plots.get(p),f=(h==null?void 0:h.data)||[],d=n!==void 0&&isNaN(n)?void 0:n;if(f[l]={value:[c,d],itemStyle:{color:i}},this._seriesColorHandle(t,r,h),!h){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(p,{editable:!0,...a,colors:g,data:f,id:p,zIndex:this._count})}return{type:"plot",key:p}}plotbar(t,e){const r=["color"];on(t,r);const{open:n,close:i,low:a,high:l,color:c,...p}=t,{bar_index:h,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,E=l!==void 0&&isNaN(l)?void 0:l,b=[f,w,m,v,E];if(y[h]={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,...p,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(sr),"style"),this._paramVerfiy(a,r,e,Object.values(an),"location"),this._paramVerfiy(n,r,e,Object.values(tr),"size"),this._paramVerfiy(i,r,e,[Kt.percent,Kt.price,Kt.volume],"format")}plotchar(t,e){const r=["color","textcolor"];on(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:p,time:h,high:f,low:d}=this._variables,g=`plotchar_${e}`,y=this._plotchars.get(g),m=(y==null?void 0:y.data)||[],w={value:[h,n],itemStyle:{color:i,textcolor:a},low:d,high:f};m[p]=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"];on(t,r);const{series:n,colorup:i,colordown:a,...l}=t,{bar_index:c,time:p}=this._variables,h=`plotarrow_${e}`,f=this._plotarrows.get(h),d=(f==null?void 0:f.data)||[];d[c]={value:[p,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(h,{editable:!0,...l,data:d,id:h,zIndex:this._count}))}plotshape(t,e){const r=["color","textcolor"];on(t,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=t,{bar_index:p,time:h,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:h,low:f,high:d};if(m[p]=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"];on(t,r);const{wickcolor:n,bordercolor:i,color:a,close:l,open:c,low:p,high:h,...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,E=c!==void 0&&isNaN(c)?void 0:c,b=p!==void 0&&isNaN(p)?void 0:p,N=h!==void 0&&isNaN(h)?void 0:h,x=[g,E,v,b,N];w[d]={value:x,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}`;on(t,["color"]),this._verifyDisplay(t.display,"hline",e);const i=t.display&&!t.display.length?je.none:je.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,I,C,B,L,U,k,W,z,K;const r=["color","top_color","bottom_color"];on(t,r);const{color:n,top_color:i,bottom_color:a,seriesColors:l,hline1:c,hline2:p,plot1:h,plot2:f,top_value:d,bottom_value:g,...y}=t,{bar_index:m,time:w}=this._variables,v=`fill_${e}`,E=this._fills.get(v),b=(E==null?void 0:E.data)||[];this._verifyDisplay(t.display,"fill",e);const N=t.display&&!t.display.length?je.none:je.all;let x,F,M="plot";if(c&&p)x=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,F=(I=this._hlines.get(p==null?void 0:p.key))==null?void 0:I.price,M="hline";else{const Z=((C=this._plots.get(h==null?void 0:h.key))==null?void 0:C.data)||[],X=((B=this._plots.get(f==null?void 0:f.key))==null?void 0:B.data)||[];x=(U=(L=Z[m])==null?void 0:L.value)==null?void 0:U[1],F=(W=(k=X[m])==null?void 0:k.value)==null?void 0:W[1]}if(b[m]={time:w,color:n,top_color:i,bottom_color:a,plot1:x,plot2:F,top_value:d,bottom_value:g},this._seriesColorHandle(t,r,E),!E){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:p,plot1:h,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]||{},p=c.barIndex;if(this._paramVerfiy(e,r,"alert",[qr.freqAll,qr.freqOncePerBar,qr.freqOncePerBarClose]),e===qr.freqOncePerBar&&n===p){this._alerts.delete(l);return}this._cacheData[l]=c;const h={message:t,freq:e,id:l,type:"alert"};if(i){e!==qr.freqOncePerBarClose&&this._alerts.set(l,h),c.barIndex=n;return}if(!i&&e===qr.freqOncePerBarClose&&n===p&&a===n-1){this._alerts.set(l,h),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(We(ue.displayErr,{func:e,values:"[display.none, display.all]"}),r,zt.Error)}_setColors(t,e,r){on(t,["color"]);const{color:i,...a}=t;this._verifyDisplay(a.display,e,r);const l=t.display&&!t.display.length?je.none:je.all,{bar_index:c,time:p}=this._variables,h=`${e}_${r}`;this._bgColors[e]||(this._bgColors[e]=new Map);const f=this._bgColors[e].get(h),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:p},f||this._bgColors[e].set(h,{...a,display:l,colors:d,setColors:g,id:h})}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||isNaN(t))}fixnan({source:t},e){return t===void 0||isNaN(t)?this._cacheData[`fixnan_${e}`]:(this._cacheData[`fixnan_${e}`]=t,t)}nz({source:t,replacement:e}){return t!==void 0&&!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:p=0}=t;if(e)return ee(e).utc(!/GMT|UTC/.test(e)).valueOf();let h=i-1,f=n;if(h<0){const g=Math.ceil(Math.abs(h/12));h=12*g+h,f=n-g}let d=ee({year:f,month:h,day:a,hour:l,minute:c,second:p});return r&&(d=zr(d.utc(!0).valueOf(),r)),d.utc(!0).valueOf()}weekofyear({time:t,timezone:e}){return zr(t,e).week()}year({time:t,timezone:e}){return zr(t,e).year()}second({time:t,timezone:e}){return zr(t,e).second()}month({time:t,timezone:e}){return zr(t,e).month()+1}minute({time:t,timezone:e}){return zr(t,e).minute()}hour({time:t,timezone:e}){return zr(t,e).hour()}dayofweek({time:t,timezone:e}){return zr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return zr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,e),n=Jr(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=Jr(l),p=Jr(this._variables.timeframe.period);let h;if(c<=p)h=t;else{const f=`time_${e}`,d=this._cacheData[f];if(d)d.currentTime+c*1e3-d.offset<=t?(h=t,this._cacheData[f]={currentTime:t,offset:0}):h=d;else{const g=this._calcTimeOffset(t,l);this._cacheData[f]={currentTime:t,offset:g},h=t}}if(n){const{timePeriods:f,weeks:d}=this._parserSession(n,e),g=ee(t).format("YYYY-MM-DD"),y=h;h=void 0;for(const w of f){const[v,E]=w;if(ee(t).isBetween(`${g} ${v}`,`${g} ${E}`,"hour")){ee(y).isBetween(`${g} ${v}`,`${g} ${E}`,"hour")?h=y:h=ee(`${g} ${v}`).valueOf();break}}const m=this._variables.dayofweek;h&&!d.includes(m)&&(h=void 0)}return i&&(h=h&&zr(h,i).valueOf()),h&&h-a*p*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 p=parseInt(c,10);if(p<1||p>7){this._errorListener.addError(`Invalid day of week: ${c}`,e,zt.Error);return}return p});return{timePeriods:n.split(",").map(c=>{c===""||c===fi.regular?c="0930-1500":c===fi.extended&&(c="1500-1830");const p=c.split("-");return p.length!==2?(this._errorListener.addError(`Invalid time period: ${c}`,e,zt.Error),[]):[this._processTime(p[0],e),this._processTime(p[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 aw{constructor(t,e){R(this,"_variables");R(this,"_scriptId");R(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)||{},p=(l==null?void 0:l.depends)||[];if(!p.length)return`return ${l==null?void 0:l.code}`;let h=[],f=[];const d=[];if(this._getDependCodes(p,a,n,h,f,d),f.length){const m=r.length;let w=[];for(let v=m-1;v>=0;v--){const E=r[v];let b=JSON.parse(Il(E));const N=[];i!==0&&f.length&&(w.unshift("{"),i++),b=b.map(S=>{const{scope:I,code:C,varNames:B,dependSelf:L}=S;return I===2&&!N.includes(B)&&!L&&(S.code=`let ${C}`),B&&N.push(...B.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const x=[],F=[];let M=f.map(S=>({...S,isArg:!1,isPreArg:!0}));f=[],this._getDependCodes(M,b,F,h,f,x),w.unshift(...F,...x),n=w.concat(n),w=[]}}for(n.push(`return ${l==null?void 0:l.code}`);i>1;)n.push("}"),i--;n=h.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 a=self.workerStorage.get(`request_${this._scriptId}_data`),l=`${r}--${n}`;if(a!=null&&a.has(l)){const{index:c=0,periodStamp:p=Jr(this._variables.__period)*1e3}=this._cacheData.get(e)||{},h=(a.get(l)||[]).slice(c),f=this._variables.time,d=p+f;for(const[g,y]of h.entries()){const{timestamp:m,close:w,open:v,high:E,low:b,volume:N}=y;let x=m*1e3;if(x>=d){this._cacheData.set(e,{index:g,periodStamp:p});return}if(x>=f)return this._cacheData.set(e,{index:g+1,periodStamp:p}),{close:Number(w),open:Number(v),high:Number(E),low:Number(b),timestamp:m,volume:N}}this._cacheData.set(e,{index:h.length,periodStamp:p})}else{const c=self.workerStorage.get(`request_${this._scriptId}_list`);(c==null?void 0:c.get(l))||c==null||c.set(l,{id:l,calc_bars_count:i,symbol:r,timeframe:n})}}_getDependCodes(t,e,r,n,i,a){for(const l of t){if(!l.isArg){const c=e.filter(h=>{var f;return(f=h==null?void 0:h.depends)==null?void 0:f.some(d=>d.name===l.name&&d.scope===l.scope&&d.isAgainAssign)});for(const h of c){const{code:f,depends:d}=h;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 p=e.find(h=>{var f;return((f=h.varNames)==null?void 0:f.split(", ").includes(l.name))&&(!l.isPreArg||l.isPreArg&&h.methodName===l.functionName)||h.funcName===l.name});if(p){const{code:h,depends:f}=p,d=r.findIndex(g=>g===h);if(d!==-1&&r.splice(d,1),r.unshift(h),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:p,tradingvueFunc:h}=self.workerStorage.get(a)||{};return r&&(l=new oh(a),c=new th,p=new sh(this._variables.mintick||1e-5,l,this._scriptId),h=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),self.workerStorage.set(a,{builtInGather:l,buildinConstants:c,buildInFunctions:p,tradingvueFunc:h})),h(l,c,p,n||[],e)}}let uw=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 lw{constructor(t){R(this,"_logs");R(this,"_variables");R(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 p=i;a&&Array.isArray(e)&&e.length&&(p=a.replace(/{(\d+)}/g,(h,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:h})),p&&this._logs.push({message:`[${ee(l).format()}]: ${p}`,time:l,barIndex:c,type:r})}}class cw{constructor(t){R(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,zt.Error)}}class fw{constructor(){R(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Pr.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 hw{constructor(){R(this,"_isMarketOpen");R(this,"_currentBarIndex");R(this,"_totalBarIndex");R(this,"_isRealTimeBar");R(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}}class pw{constructor(t){R(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=Jr(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=Jr(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 dw{constructor(t){R(this,"_orders");R(this,"_historyOrders");R(this,"_options");R(this,"_max_contracts_held_all",0);R(this,"_max_contracts_held_long",0);R(this,"_max_contracts_held_short",0);R(this,"_max_drawdown",0);R(this,"_max_runup",0);R(this,"_max_runup_percent",0);R(this,"_max_drawdown_percent",0);R(this,"_variables");R(this,"_netprofit",0);R(this,"_eventrades",0);R(this,"_avg_trade_percent");R(this,"_closedtrades",0);R(this,"_losstrades",0);R(this,"_grossloss",0);R(this,"_grossloss_percent",0);R(this,"_grossprofit",0);R(this,"_grossprofit_percent",0);R(this,"_wintrades",0);R(this,"_opentrades_capital_held",0);R(this,"_position_avg_price",0);R(this,"_position_size",0);this._orders=[],this._historyOrders=[],this._variables=t}update(){this._calcMaxDrawdownAndMaxRunup()}_calcMaxDrawdownAndMaxRunup(){let t=0,e=0;const{high:r,low:n}=this._variables;for(const p of this._orders){const{in_price:h,qty:f=0,commission:d=0,original_qty:g=0,direction:y}=p,m=y===me.long?1:-1,w=(r-h)*f,v=(n-h)*f,E=m===1?w:-v,b=m===1?-v:w;t+=b+d*f/g,e+=E+d*f/g}const[i,a]=this._historyOrders.reduce((p,h)=>{let[f,d]=p;const{profit:g=0,commission:y=0}=h;return f+=g,d+=g-y,[f,d]},[0,0]);t-=i,e+=a;const l=t/(this.initial_capital+this.netprofit)*100;this._max_drawdown<t&&(this._max_drawdown=t),l>this._max_drawdown_percent&&(this._max_drawdown_percent=l);const c=e/(this.initial_capital+this.netprofit)*100;e>this._max_runup&&(this._max_runup=e),c>this._max_runup_percent&&(this._max_runup_percent=c)}updateOrders(t){this._orders=t,this._calcMaxContracts()}_calcMaxContracts(){const t=this._orders.length;if(!t)return;const[e,r,n,i,a,l]=this._orders.reduce(([c,p,h,f,d,g],y)=>{const{direction:m,qty:w=0,in_price:v}=y;return m===me.long?(c+=w,p+=w,g+=w):(c+=w,h+=w,g-=w),f+=w*v,d+=v,[c,p,h,f,d,g]},[0,0,0,0,0,0]);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,l,c]=this._historyOrders.reduce((p,h)=>{let[f,d,g,y,m,w]=p;const{profit:v=0,profit_percent:E=0}=h;return f+=v,d+=E,v<0?(g+=v,y+=E):(m+=v,w+=E),[f,d,g,y,m,w]},[0,0,0,0,0,0]);this._avg_trade_percent=e?n/e:void 0,this._netprofit=r,this._grossloss=i,this._grossloss_percent=a,this._grossprofit=l,this._grossprofit_percent=c,this._eventrades=this._historyOrders.filter(p=>p.profit===0).length,this._losstrades=this._historyOrders.filter(p=>(p.profit||0)<0).length,this._wintrades=this._historyOrders.filter(p=>(p.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 Math.abs(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._orders.reduce((t,e)=>{const{profit:r=0}=e;return t+r},0)}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_percent}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit_percent}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===me.long?1:-1,l=(a===1?e:r)/100;if(l<=0)return;const{close:c}=this._variables,[p,h]=this._orders.reduce((f,d)=>{let[g,y]=f;const{in_price:m,qty:w=0,original_qty:v=0}=d,E=m*w;if(g+=E,i){let b=0;switch(n){case Cr.percent:b=(E+w*c)*i/100;break;case Cr.cashPerContract:b=w*i*2;break;case Cr.cashPerOrder:b=w/v*i+i;break}y+=b}return[g,y]},[0,0]);return(p-(t+this.netprofit-h))*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}}class _w{constructor(t){R(this,"_preAccdist");R(this,"_preNvi");R(this,"_prePvi");R(this,"_preObv");R(this,"_prePvt");R(this,"_preWad");R(this,"_preVwap");R(this,"_preValue");R(this,"_currentData");R(this,"_preData");R(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,p=(l>0?t-a:l<0?t-i:0)+this._preWad;return!this.isRealTime&&(this._preWad=p),this._preValue.wad=p,p}get vwap(){var h,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=(h=self.workerStorage)==null?void 0:h.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 p=l/c;return this._preValue.vwap=p,p}_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 mw{constructor(){R(this,"_period");R(this,"_multiplier");R(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=t;const[e,r]=bs(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 gw{constructor(t){R(this,"_variables");R(this,"_bgColor");R(this,"_fgColor");R(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 vw{constructor(t){R(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(){}get tickerid(){}get timezone(){}get type(){}get volumetype(){return"n/a"}}class yw{constructor(t){R(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class ww{constructor(t){R(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}ee.extend(Wp),ee.extend(Bl),ee.extend(kp);class oh{constructor(t){R(this,"_cacheData");R(this,"_barIndex");R(this,"_isRealTimeBar");R(this,"_barstate");R(this,"_priceVariables");R(this,"_lastBarIndex");R(this,"_currentBarTime");R(this,"_lastBarTime");R(this,"_period");R(this,"_offsetTime");R(this,"_timeframe");R(this,"_ta");R(this,"_polyline");R(this,"_label");R(this,"_line");R(this,"_linefill");R(this,"_box");R(this,"_table");R(this,"_strategy");R(this,"_session");R(this,"syminfo");R(this,"chart");R(this,"earnings");R(this,"dividends");R(this,"_timeTradingday");R(this,"_mintick");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 hw,this._timeframe=new mw,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new _w(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(1),this._strategy=new dw(this),this._session=new pw(this),this.syminfo=new vw(this),this.chart=new gw(this),this.earnings=new ww(this),this.dividends=new yw(this)}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]=bs(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]=bs(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:p,lastBarTime:h,complete: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.varData=this._cacheData.varNewData,this._cacheData.varNewData={}),this._timeTradingday=d,this._currentBarTime=c*1e3,this._lastBarIndex=p,this._barIndex=e,this._lastBarTime=h*1e3,this._barstate.update(e,p,f,!1),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){const n=this.setCacheData(t,r);return n[n.length-1-e]}setCacheData(t,e){let r=this._cacheData[t]||{barIndex:-1,data:[]};return r.barIndex>this._barIndex||(r.barIndex===this._barIndex?r.data[r.data.length-1]=e:r.data.push(e),r.barIndex=this._barIndex,this._cacheData[t]=r),r.data}getTypeInstance(t,e){return new Rp(t,e)}getVarValue(t,e,r){const n=`${t}_${e}`,i=r==="var"?this._cacheData.varData[n]:this._cacheData.varipData[n];if(i)return i}setVarValue(t,e,r,n){const i=`${t}_${e}`;let a;switch(typeof r=="object"&&r&&(n="var",a=r.varipKeys),n){case"var":if(this._isRealTimeBar){const l=Pr.cloneDeep(r);if(this._cacheData.varNewData[i]=l,a&&a.length)for(const c of a)this._cacheData.varData[i][c]=l[c]}else this._cacheData.varData[i]=r;break;case"varip":this._cacheData.varipData[i]=r;break}return r}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Pr.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 es.name:case eh.name:case ns.name:case Ua.name:case rs.name:case co.name:t==null||t.delete();break}}}class Fi{constructor(t=50){R(this,"_all");R(this,"_allInstance");R(this,"_pseudoArrayAll");R(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()]}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(t,e,r){if(this._all.set(t,e),this._allInstance.set(t,r),this._all.size>this._maxLength){const n=this._all.keys().next().value;n&&this.delete(n)}}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}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 ah=Symbol("Comlink.proxy"),Dw=Symbol("Comlink.endpoint"),bw=Symbol("Comlink.releaseProxy"),Wa=Symbol("Comlink.finalizer"),fo=Symbol("Comlink.thrown"),uh=s=>typeof s=="object"&&s!==null||typeof s=="function",Ew={canHandle:s=>uh(s)&&s[ah],serialize(s){const{port1:t,port2:e}=new MessageChannel;return ja(s,t),[e,[e]]},deserialize(s){return s.start(),Fw(s)}},xw={canHandle:s=>uh(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}},lh=new Map([["proxy",Ew],["throw",xw]]);function Aw(s,t){for(const e of s)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function ja(s,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Aw(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 p;try{const h=l.slice(0,-1).reduce((d,g)=>d[g],s),f=l.reduce((d,g)=>d[g],s);switch(a){case"GET":p=f;break;case"SET":h[l.slice(-1)[0]]=Qn(n.data.value),p=!0;break;case"APPLY":p=f.apply(h,c);break;case"CONSTRUCT":{const d=new f(...c);p=Ow(d)}break;case"ENDPOINT":{const{port1:d,port2:g}=new MessageChannel;ja(s,g),p=Bw(d,[d])}break;case"RELEASE":p=void 0;break;default:return}}catch(h){p={value:h,[fo]:0}}Promise.resolve(p).catch(h=>({value:h,[fo]:0})).then(h=>{const[f,d]=mo(h);t.postMessage(Object.assign(Object.assign({},f),{id:i}),d),a==="RELEASE"&&(t.removeEventListener("message",r),ch(t),Wa in s&&typeof s[Wa]=="function"&&s[Wa]())}).catch(h=>{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 Cw(s){return s.constructor.name==="MessagePort"}function ch(s){Cw(s)&&s.close()}function Fw(s,t){return Ya(s,[],t)}function ho(s){if(s)throw new Error("Proxy has been released and is not useable")}function fh(s){return Mi(s,{type:"RELEASE"}).then(()=>{ch(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&&fh(s)});function Mw(s,t){const e=(po.get(t)||0)+1;po.set(t,e),_o&&_o.register(s,t,s)}function Nw(s){_o&&_o.unregister(s)}function Ya(s,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(i,a){if(ho(r),a===bw)return()=>{Nw(n),fh(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 Ya(s,[...t,a])},set(i,a,l){ho(r);const[c,p]=mo(l);return Mi(s,{type:"SET",path:[...t,a].map(h=>h.toString()),value:c},p).then(Qn)},apply(i,a,l){ho(r);const c=t[t.length-1];if(c===Dw)return Mi(s,{type:"ENDPOINT"}).then(Qn);if(c==="bind")return Ya(s,t.slice(0,-1));const[p,h]=hh(l);return Mi(s,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:p},h).then(Qn)},construct(i,a){ho(r);const[l,c]=hh(a);return Mi(s,{type:"CONSTRUCT",path:t.map(p=>p.toString()),argumentList:l},c).then(Qn)}});return Mw(n,s),n}function Sw(s){return Array.prototype.concat.apply([],s)}function hh(s){const t=s.map(mo);return[t.map(e=>e[0]),Sw(t.map(e=>e[1]))]}const ph=new WeakMap;function Bw(s,t){return ph.set(s,t),s}function Ow(s){return Object.assign(s,{[ah]:!0})}function mo(s){for(const[t,e]of lh)if(e.canHandle(s)){const[r,n]=e.serialize(s);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:s},ph.get(s)||[]]}function Qn(s){switch(s.type){case"HANDLER":return lh.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 Iw{constructor(){R(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 $w(s,t,e){var v;const{data:r,isPreParser:n,id:i="default",syminfo:a,interval:l,inputs:c,chart:p}=t;self.workerStorage||(self.workerStorage=new Iw);let{builtInGather:h,buildinConstants:f,buildInFunctions:d,tradingvueFunc:g}=self.workerStorage.get(i)||{},y=[];e&&(h=new oh(i),f=new th,d=new sh((a==null?void 0:a.mintick)||1e-5,h,i),g=new Function("$_var","$_const","$_func",s),self.workerStorage.set(i,{builtInGather:h,buildinConstants:f,buildInFunctions:d,tradingvueFunc:g}),self.workerStorage.set(`request_${i}`,new Map),self.workerStorage.set(`request_${i}_data`,new Map),self.workerStorage.set(`request_${i}_list`,new Map));let m=[];if(n)g(h,f,d);else if(r&&r.length){const E=r.length-1;h.updateOptions({interval:l,mintick:(a==null?void 0:a.mintick)||1e-5,chart:p}),d.updateOptions({inputs:c});try{for(const[b,N]of r.entries()){const{barindex:x}=N;!e&&(x||x===0)&&(y.push(x),h.clearDrawCache(x)),h.updateData(Object.assign(N,{barIndex:x||b,lastBarIndex:r[E].bar_index||E,lastBarTime:r[E].time})),d.update({barIndex:x||b}),g(h,f,d),d.endExecution();const F=d.errors;if(F.length&&F.some(M=>M.type===zt.Error))return{status:1,errors:F}}m=[...((v=self.workerStorage.get(`request_${i}_list`))==null?void 0:v.values())||[]],m.length&&self.workerStorage.delete(`request_${i}_list`)}catch(b){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:b==null?void 0:b.message,type:zt.Error}]}}}const w=d.errors;return w.length&&w.some(E=>E.type===zt.Error)?{status:1,errors:w}:{status:0,requestList:m,errors:w,options:{...d.options(y),id:i}}}function Lw(s){self==null||self.workerStorage.deleteStartwidthKey(s),self==null||self.workerStorage.delete(`inputs_${s}`),self==null||self.workerStorage.delete(`request_${s}`),self==null||self.workerStorage.delete(`request_${s}_data`),self==null||self.workerStorage.delete(`request_${s}_list`)}ja({runScript:$w,removeScript:Lw})})();
|