@guihz/trading-vue-editor-tes 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (21) hide show
  1. package/lib/assets/{parserTccWorker-CVfKSNrL.js → parserTccWorker-B-xIp9MW.js} +15 -15
  2. package/lib/assets/scriptsRunWorker-COxpWbV9.js +66 -0
  3. package/lib/components/editor/parseScript/buildInFuncNamespace/index.d.ts +2 -2
  4. package/lib/components/editor/parseScript/buildInFuncNamespace/strategy.d.ts +63 -3
  5. package/lib/components/editor/parseScript/buildInVarNamespace/barstate.d.ts +16 -0
  6. package/lib/components/editor/parseScript/buildInVarNamespace/index.d.ts +5 -0
  7. package/lib/components/editor/parseScript/buildInVarNamespace/session.d.ts +12 -0
  8. package/lib/components/editor/parseScript/buildInVarNamespace/strategy.d.ts +71 -0
  9. package/lib/components/editor/parseScript/buildInVarNamespace/ta.d.ts +28 -0
  10. package/lib/components/editor/parseScript/buildInVarNamespace/timeframe.d.ts +16 -0
  11. package/lib/components/editor/parseScript/constants.d.ts +2 -0
  12. package/lib/components/editor/parseScript/strategyNamespace/closedtrades.d.ts +28 -0
  13. package/lib/components/editor/parseScript/strategyNamespace/index.d.ts +4 -0
  14. package/lib/components/editor/parseScript/strategyNamespace/opentrades.d.ts +23 -0
  15. package/lib/components/editor/parseScript/strategyNamespace/risk.d.ts +20 -0
  16. package/lib/components/editor/parseScript/visitorParser.d.ts +1 -0
  17. package/lib/components/editor/utils/initEditor.d.ts +1 -0
  18. package/lib/trading-vue-editor.js +287 -272
  19. package/lib/trading-vue-editor.umd.cjs +22 -22
  20. package/package.json +1 -1
  21. package/lib/assets/scriptsRunWorker-Ce9Ua8lg.js +0 -66
@@ -1,66 +0,0 @@
1
- var b2=Object.defineProperty;var E2=(Wt,jt,De)=>jt in Wt?b2(Wt,jt,{enumerable:!0,configurable:!0,writable:!0,value:De}):Wt[jt]=De;var Z=(Wt,jt,De)=>(E2(Wt,typeof jt!="symbol"?jt+"":jt,De),De),wl=(Wt,jt,De)=>{if(!jt.has(Wt))throw TypeError("Cannot "+De)};var Lr=(Wt,jt,De)=>(wl(Wt,jt,"read from private field"),De?De.call(Wt):jt.get(Wt)),Dl=(Wt,jt,De)=>{if(jt.has(Wt))throw TypeError("Cannot add the same private member more than once");jt instanceof WeakSet?jt.add(Wt):jt.set(Wt,De)},ea=(Wt,jt,De,In)=>(wl(Wt,jt,"write to private field"),In?In.call(Wt,De):jt.set(Wt,De),De);var yl=(Wt,jt,De)=>(wl(Wt,jt,"access private method"),De);(function(){"use strict";var Xi,bl,Di,Ue;var Wt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function jt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function De(i){if(i.__esModule)return i;var t=i.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(i).forEach(function(r){var n=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return i[r]}})}),e}var In={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
- */In.exports,function(i,t){(function(){var e,r="4.17.21",n=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",f="__lodash_hash_undefined__",h=500,p="__lodash_placeholder__",c=1,m=2,v=4,w=1,g=2,y=1,_=2,E=4,b=8,N=16,A=32,C=64,M=128,S=256,$=512,F=30,I="...",R=800,U=16,q=1,k=2,P=3,K=1/0,G=9007199254740991,V=17976931348623157e292,tt=NaN,ft=4294967295,vt=ft-1,lt=ft>>>1,wt=[["ary",M],["bind",y],["bindKey",_],["curry",b],["curryRight",N],["flip",$],["partial",A],["partialRight",C],["rearg",S]],yt="[object Arguments]",St="[object Array]",bt="[object AsyncFunction]",re="[object Boolean]",It="[object Date]",Mt="[object DOMException]",ie="[object Error]",Xt="[object Function]",zt="[object GeneratorFunction]",Gt="[object Map]",Ce="[object Number]",sr="[object Null]",Me="[object Object]",Vr="[object Promise]",wn="[object Proxy]",Qr="[object RegExp]",or="[object Set]",Dn="[object String]",O="[object Symbol]",j="[object Undefined]",H="[object WeakMap]",nt="[object WeakSet]",st="[object ArrayBuffer]",rt="[object DataView]",ct="[object Float32Array]",ut="[object Float64Array]",ht="[object Int8Array]",at="[object Int16Array]",Kt="[object Int32Array]",Vt="[object Uint8Array]",pe="[object Uint8ClampedArray]",Te="[object Uint16Array]",Ne="[object Uint32Array]",ar=/\b__p \+= '';/g,ur=/\b(__p \+=) '' \+/g,yn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,jn=/&(?:amp|lt|gt|quot|#39);/g,fo=/[&<>"']/g,qa=RegExp(jn.source),Ua=RegExp(fo.source),ka=/<%-([\s\S]+?)%>/g,Wa=/<%([\s\S]+?)%>/g,co=/<%=([\s\S]+?)%>/g,Ya=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ja=/^\w*$/,Za=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Vi=/[\\^$.*+?()[\]{}|]/g,Ga=RegExp(Vi.source),Qi=/^\s+/,Ka=/\s/,Ha=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ja=/\{\n\/\* \[wrapped with (.+)\] \*/,Xa=/,? & /,Va=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Qa=/[()=,{}\[\]\/\s]/,tu=/\\(\\)?/g,eu=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ho=/\w*$/,ru=/^[-+]0x[0-9a-f]+$/i,nu=/^0b[01]+$/i,iu=/^\[object .+?Constructor\]$/,su=/^0o[0-7]+$/i,ou=/^(?:0|[1-9]\d*)$/,au=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,yi=/($^)/,Zn=/['\n\r\u2028\u2029\\]/g,Yt="\\ud800-\\udfff",ke="\\u0300-\\u036f",uu="\\ufe20-\\ufe2f",bi="\\u20d0-\\u20ff",bn=ke+uu+bi,po="\\u2700-\\u27bf",nh="a-z\\xdf-\\xf6\\xf8-\\xff",_D="\\xac\\xb1\\xd7\\xf7",wD="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",DD="\\u2000-\\u206f",yD=" \\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",ih="A-Z\\xc0-\\xd6\\xd8-\\xde",sh="\\ufe0e\\ufe0f",oh=_D+wD+DD+yD,lu="['’]",bD="["+Yt+"]",ah="["+oh+"]",mo="["+bn+"]",uh="\\d+",ED="["+po+"]",lh="["+nh+"]",fh="[^"+Yt+oh+uh+po+nh+ih+"]",fu="\\ud83c[\\udffb-\\udfff]",AD="(?:"+mo+"|"+fu+")",ch="[^"+Yt+"]",cu="(?:\\ud83c[\\udde6-\\uddff]){2}",hu="[\\ud800-\\udbff][\\udc00-\\udfff]",Ei="["+ih+"]",hh="\\u200d",ph="(?:"+lh+"|"+fh+")",xD="(?:"+Ei+"|"+fh+")",dh="(?:"+lu+"(?:d|ll|m|re|s|t|ve))?",mh="(?:"+lu+"(?:D|LL|M|RE|S|T|VE))?",gh=AD+"?",vh="["+sh+"]?",CD="(?:"+hh+"(?:"+[ch,cu,hu].join("|")+")"+vh+gh+")*",FD="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",MD="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",_h=vh+gh+CD,ND="(?:"+[ED,cu,hu].join("|")+")"+_h,SD="(?:"+[ch+mo+"?",mo,cu,hu,bD].join("|")+")",BD=RegExp(lu,"g"),ID=RegExp(mo,"g"),pu=RegExp(fu+"(?="+fu+")|"+SD+_h,"g"),TD=RegExp([Ei+"?"+lh+"+"+dh+"(?="+[ah,Ei,"$"].join("|")+")",xD+"+"+mh+"(?="+[ah,Ei+ph,"$"].join("|")+")",Ei+"?"+ph+"+"+dh,Ei+"+"+mh,MD,FD,uh,ND].join("|"),"g"),$D=RegExp("["+hh+Yt+bn+sh+"]"),OD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,RD=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],LD=-1,ce={};ce[ct]=ce[ut]=ce[ht]=ce[at]=ce[Kt]=ce[Vt]=ce[pe]=ce[Te]=ce[Ne]=!0,ce[yt]=ce[St]=ce[st]=ce[re]=ce[rt]=ce[It]=ce[ie]=ce[Xt]=ce[Gt]=ce[Ce]=ce[Me]=ce[Qr]=ce[or]=ce[Dn]=ce[H]=!1;var le={};le[yt]=le[St]=le[st]=le[rt]=le[re]=le[It]=le[ct]=le[ut]=le[ht]=le[at]=le[Kt]=le[Gt]=le[Ce]=le[Me]=le[Qr]=le[or]=le[Dn]=le[O]=le[Vt]=le[pe]=le[Te]=le[Ne]=!0,le[ie]=le[Xt]=le[H]=!1;var PD={À:"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"},zD={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},qD={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},UD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kD=parseFloat,WD=parseInt,wh=typeof Wt=="object"&&Wt&&Wt.Object===Object&&Wt,YD=typeof self=="object"&&self&&self.Object===Object&&self,Le=wh||YD||Function("return this")(),du=t&&!t.nodeType&&t,Gn=du&&!0&&i&&!i.nodeType&&i,Dh=Gn&&Gn.exports===du,mu=Dh&&wh.process,wr=function(){try{var W=Gn&&Gn.require&&Gn.require("util").types;return W||mu&&mu.binding&&mu.binding("util")}catch{}}(),yh=wr&&wr.isArrayBuffer,bh=wr&&wr.isDate,Eh=wr&&wr.isMap,Ah=wr&&wr.isRegExp,xh=wr&&wr.isSet,Ch=wr&&wr.isTypedArray;function lr(W,X,J){switch(J.length){case 0:return W.call(X);case 1:return W.call(X,J[0]);case 2:return W.call(X,J[0],J[1]);case 3:return W.call(X,J[0],J[1],J[2])}return W.apply(X,J)}function jD(W,X,J,gt){for(var Bt=-1,Ht=W==null?0:W.length;++Bt<Ht;){var Se=W[Bt];X(gt,Se,J(Se),W)}return gt}function Dr(W,X){for(var J=-1,gt=W==null?0:W.length;++J<gt&&X(W[J],J,W)!==!1;);return W}function ZD(W,X){for(var J=W==null?0:W.length;J--&&X(W[J],J,W)!==!1;);return W}function Fh(W,X){for(var J=-1,gt=W==null?0:W.length;++J<gt;)if(!X(W[J],J,W))return!1;return!0}function En(W,X){for(var J=-1,gt=W==null?0:W.length,Bt=0,Ht=[];++J<gt;){var Se=W[J];X(Se,J,W)&&(Ht[Bt++]=Se)}return Ht}function go(W,X){var J=W==null?0:W.length;return!!J&&Ai(W,X,0)>-1}function gu(W,X,J){for(var gt=-1,Bt=W==null?0:W.length;++gt<Bt;)if(J(X,W[gt]))return!0;return!1}function de(W,X){for(var J=-1,gt=W==null?0:W.length,Bt=Array(gt);++J<gt;)Bt[J]=X(W[J],J,W);return Bt}function An(W,X){for(var J=-1,gt=X.length,Bt=W.length;++J<gt;)W[Bt+J]=X[J];return W}function vu(W,X,J,gt){var Bt=-1,Ht=W==null?0:W.length;for(gt&&Ht&&(J=W[++Bt]);++Bt<Ht;)J=X(J,W[Bt],Bt,W);return J}function GD(W,X,J,gt){var Bt=W==null?0:W.length;for(gt&&Bt&&(J=W[--Bt]);Bt--;)J=X(J,W[Bt],Bt,W);return J}function _u(W,X){for(var J=-1,gt=W==null?0:W.length;++J<gt;)if(X(W[J],J,W))return!0;return!1}var KD=wu("length");function HD(W){return W.split("")}function JD(W){return W.match(Va)||[]}function Mh(W,X,J){var gt;return J(W,function(Bt,Ht,Se){if(X(Bt,Ht,Se))return gt=Ht,!1}),gt}function vo(W,X,J,gt){for(var Bt=W.length,Ht=J+(gt?1:-1);gt?Ht--:++Ht<Bt;)if(X(W[Ht],Ht,W))return Ht;return-1}function Ai(W,X,J){return X===X?uy(W,X,J):vo(W,Nh,J)}function XD(W,X,J,gt){for(var Bt=J-1,Ht=W.length;++Bt<Ht;)if(gt(W[Bt],X))return Bt;return-1}function Nh(W){return W!==W}function Sh(W,X){var J=W==null?0:W.length;return J?yu(W,X)/J:tt}function wu(W){return function(X){return X==null?e:X[W]}}function Du(W){return function(X){return W==null?e:W[X]}}function Bh(W,X,J,gt,Bt){return Bt(W,function(Ht,Se,ae){J=gt?(gt=!1,Ht):X(J,Ht,Se,ae)}),J}function VD(W,X){var J=W.length;for(W.sort(X);J--;)W[J]=W[J].value;return W}function yu(W,X){for(var J,gt=-1,Bt=W.length;++gt<Bt;){var Ht=X(W[gt]);Ht!==e&&(J=J===e?Ht:J+Ht)}return J}function bu(W,X){for(var J=-1,gt=Array(W);++J<W;)gt[J]=X(J);return gt}function QD(W,X){return de(X,function(J){return[J,W[J]]})}function Ih(W){return W&&W.slice(0,Rh(W)+1).replace(Qi,"")}function fr(W){return function(X){return W(X)}}function Eu(W,X){return de(X,function(J){return W[J]})}function ts(W,X){return W.has(X)}function Th(W,X){for(var J=-1,gt=W.length;++J<gt&&Ai(X,W[J],0)>-1;);return J}function $h(W,X){for(var J=W.length;J--&&Ai(X,W[J],0)>-1;);return J}function ty(W,X){for(var J=W.length,gt=0;J--;)W[J]===X&&++gt;return gt}var ey=Du(PD),ry=Du(zD);function ny(W){return"\\"+UD[W]}function iy(W,X){return W==null?e:W[X]}function xi(W){return $D.test(W)}function sy(W){return OD.test(W)}function oy(W){for(var X,J=[];!(X=W.next()).done;)J.push(X.value);return J}function Au(W){var X=-1,J=Array(W.size);return W.forEach(function(gt,Bt){J[++X]=[Bt,gt]}),J}function Oh(W,X){return function(J){return W(X(J))}}function xn(W,X){for(var J=-1,gt=W.length,Bt=0,Ht=[];++J<gt;){var Se=W[J];(Se===X||Se===p)&&(W[J]=p,Ht[Bt++]=J)}return Ht}function _o(W){var X=-1,J=Array(W.size);return W.forEach(function(gt){J[++X]=gt}),J}function ay(W){var X=-1,J=Array(W.size);return W.forEach(function(gt){J[++X]=[gt,gt]}),J}function uy(W,X,J){for(var gt=J-1,Bt=W.length;++gt<Bt;)if(W[gt]===X)return gt;return-1}function ly(W,X,J){for(var gt=J+1;gt--;)if(W[gt]===X)return gt;return gt}function Ci(W){return xi(W)?cy(W):KD(W)}function Tr(W){return xi(W)?hy(W):HD(W)}function Rh(W){for(var X=W.length;X--&&Ka.test(W.charAt(X)););return X}var fy=Du(qD);function cy(W){for(var X=pu.lastIndex=0;pu.test(W);)++X;return X}function hy(W){return W.match(pu)||[]}function py(W){return W.match(TD)||[]}var dy=function W(X){X=X==null?Le:Fi.defaults(Le.Object(),X,Fi.pick(Le,RD));var J=X.Array,gt=X.Date,Bt=X.Error,Ht=X.Function,Se=X.Math,ae=X.Object,xu=X.RegExp,my=X.String,yr=X.TypeError,wo=J.prototype,gy=Ht.prototype,Mi=ae.prototype,Do=X["__core-js_shared__"],yo=gy.toString,ne=Mi.hasOwnProperty,vy=0,Lh=function(){var o=/[^.]+$/.exec(Do&&Do.keys&&Do.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),bo=Mi.toString,_y=yo.call(ae),wy=Le._,Dy=xu("^"+yo.call(ne).replace(Vi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Eo=Dh?X.Buffer:e,Cn=X.Symbol,Ao=X.Uint8Array,Ph=Eo?Eo.allocUnsafe:e,xo=Oh(ae.getPrototypeOf,ae),zh=ae.create,qh=Mi.propertyIsEnumerable,Co=wo.splice,Uh=Cn?Cn.isConcatSpreadable:e,es=Cn?Cn.iterator:e,Kn=Cn?Cn.toStringTag:e,Fo=function(){try{var o=Qn(ae,"defineProperty");return o({},"",{}),o}catch{}}(),yy=X.clearTimeout!==Le.clearTimeout&&X.clearTimeout,by=gt&&gt.now!==Le.Date.now&&gt.now,Ey=X.setTimeout!==Le.setTimeout&&X.setTimeout,Mo=Se.ceil,No=Se.floor,Cu=ae.getOwnPropertySymbols,Ay=Eo?Eo.isBuffer:e,kh=X.isFinite,xy=wo.join,Cy=Oh(ae.keys,ae),Be=Se.max,We=Se.min,Fy=gt.now,My=X.parseInt,Wh=Se.random,Ny=wo.reverse,Fu=Qn(X,"DataView"),rs=Qn(X,"Map"),Mu=Qn(X,"Promise"),Ni=Qn(X,"Set"),ns=Qn(X,"WeakMap"),is=Qn(ae,"create"),So=ns&&new ns,Si={},Sy=ti(Fu),By=ti(rs),Iy=ti(Mu),Ty=ti(Ni),$y=ti(ns),Bo=Cn?Cn.prototype:e,ss=Bo?Bo.valueOf:e,Yh=Bo?Bo.toString:e;function B(o){if(we(o)&&!Tt(o)&&!(o instanceof Ut)){if(o instanceof br)return o;if(ne.call(o,"__wrapped__"))return j0(o)}return new br(o)}var Bi=function(){function o(){}return function(u){if(!_e(u))return{};if(zh)return zh(u);o.prototype=u;var d=new o;return o.prototype=e,d}}();function Io(){}function br(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}B.templateSettings={escape:ka,evaluate:Wa,interpolate:co,variable:"",imports:{_:B}},B.prototype=Io.prototype,B.prototype.constructor=B,br.prototype=Bi(Io.prototype),br.prototype.constructor=br;function Ut(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ft,this.__views__=[]}function Oy(){var o=new Ut(this.__wrapped__);return o.__actions__=Xe(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=Xe(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=Xe(this.__views__),o}function Ry(){if(this.__filtered__){var o=new Ut(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function Ly(){var o=this.__wrapped__.value(),u=this.__dir__,d=Tt(o),D=u<0,x=d?o.length:0,T=Hb(0,x,this.__views__),L=T.start,z=T.end,Y=z-L,Q=D?z:L-1,et=this.__iteratees__,ot=et.length,dt=0,_t=We(Y,this.__takeCount__);if(!d||!D&&x==Y&&_t==Y)return d0(o,this.__actions__);var xt=[];t:for(;Y--&&dt<_t;){Q+=u;for(var Rt=-1,Ct=o[Q];++Rt<ot;){var qt=et[Rt],kt=qt.iteratee,pr=qt.type,Ge=kt(Ct);if(pr==k)Ct=Ge;else if(!Ge){if(pr==q)continue t;break t}}xt[dt++]=Ct}return xt}Ut.prototype=Bi(Io.prototype),Ut.prototype.constructor=Ut;function Hn(o){var u=-1,d=o==null?0:o.length;for(this.clear();++u<d;){var D=o[u];this.set(D[0],D[1])}}function Py(){this.__data__=is?is(null):{},this.size=0}function zy(o){var u=this.has(o)&&delete this.__data__[o];return this.size-=u?1:0,u}function qy(o){var u=this.__data__;if(is){var d=u[o];return d===f?e:d}return ne.call(u,o)?u[o]:e}function Uy(o){var u=this.__data__;return is?u[o]!==e:ne.call(u,o)}function ky(o,u){var d=this.__data__;return this.size+=this.has(o)?0:1,d[o]=is&&u===e?f:u,this}Hn.prototype.clear=Py,Hn.prototype.delete=zy,Hn.prototype.get=qy,Hn.prototype.has=Uy,Hn.prototype.set=ky;function tn(o){var u=-1,d=o==null?0:o.length;for(this.clear();++u<d;){var D=o[u];this.set(D[0],D[1])}}function Wy(){this.__data__=[],this.size=0}function Yy(o){var u=this.__data__,d=To(u,o);if(d<0)return!1;var D=u.length-1;return d==D?u.pop():Co.call(u,d,1),--this.size,!0}function jy(o){var u=this.__data__,d=To(u,o);return d<0?e:u[d][1]}function Zy(o){return To(this.__data__,o)>-1}function Gy(o,u){var d=this.__data__,D=To(d,o);return D<0?(++this.size,d.push([o,u])):d[D][1]=u,this}tn.prototype.clear=Wy,tn.prototype.delete=Yy,tn.prototype.get=jy,tn.prototype.has=Zy,tn.prototype.set=Gy;function en(o){var u=-1,d=o==null?0:o.length;for(this.clear();++u<d;){var D=o[u];this.set(D[0],D[1])}}function Ky(){this.size=0,this.__data__={hash:new Hn,map:new(rs||tn),string:new Hn}}function Hy(o){var u=jo(this,o).delete(o);return this.size-=u?1:0,u}function Jy(o){return jo(this,o).get(o)}function Xy(o){return jo(this,o).has(o)}function Vy(o,u){var d=jo(this,o),D=d.size;return d.set(o,u),this.size+=d.size==D?0:1,this}en.prototype.clear=Ky,en.prototype.delete=Hy,en.prototype.get=Jy,en.prototype.has=Xy,en.prototype.set=Vy;function Jn(o){var u=-1,d=o==null?0:o.length;for(this.__data__=new en;++u<d;)this.add(o[u])}function Qy(o){return this.__data__.set(o,f),this}function tb(o){return this.__data__.has(o)}Jn.prototype.add=Jn.prototype.push=Qy,Jn.prototype.has=tb;function $r(o){var u=this.__data__=new tn(o);this.size=u.size}function eb(){this.__data__=new tn,this.size=0}function rb(o){var u=this.__data__,d=u.delete(o);return this.size=u.size,d}function nb(o){return this.__data__.get(o)}function ib(o){return this.__data__.has(o)}function sb(o,u){var d=this.__data__;if(d instanceof tn){var D=d.__data__;if(!rs||D.length<n-1)return D.push([o,u]),this.size=++d.size,this;d=this.__data__=new en(D)}return d.set(o,u),this.size=d.size,this}$r.prototype.clear=eb,$r.prototype.delete=rb,$r.prototype.get=nb,$r.prototype.has=ib,$r.prototype.set=sb;function jh(o,u){var d=Tt(o),D=!d&&ei(o),x=!d&&!D&&Bn(o),T=!d&&!D&&!x&&Oi(o),L=d||D||x||T,z=L?bu(o.length,my):[],Y=z.length;for(var Q in o)(u||ne.call(o,Q))&&!(L&&(Q=="length"||x&&(Q=="offset"||Q=="parent")||T&&(Q=="buffer"||Q=="byteLength"||Q=="byteOffset")||on(Q,Y)))&&z.push(Q);return z}function Zh(o){var u=o.length;return u?o[zu(0,u-1)]:e}function ob(o,u){return Zo(Xe(o),Xn(u,0,o.length))}function ab(o){return Zo(Xe(o))}function Nu(o,u,d){(d!==e&&!Or(o[u],d)||d===e&&!(u in o))&&rn(o,u,d)}function os(o,u,d){var D=o[u];(!(ne.call(o,u)&&Or(D,d))||d===e&&!(u in o))&&rn(o,u,d)}function To(o,u){for(var d=o.length;d--;)if(Or(o[d][0],u))return d;return-1}function ub(o,u,d,D){return Fn(o,function(x,T,L){u(D,x,d(x),L)}),D}function Gh(o,u){return o&&jr(u,$e(u),o)}function lb(o,u){return o&&jr(u,Qe(u),o)}function rn(o,u,d){u=="__proto__"&&Fo?Fo(o,u,{configurable:!0,enumerable:!0,value:d,writable:!0}):o[u]=d}function Su(o,u){for(var d=-1,D=u.length,x=J(D),T=o==null;++d<D;)x[d]=T?e:fl(o,u[d]);return x}function Xn(o,u,d){return o===o&&(d!==e&&(o=o<=d?o:d),u!==e&&(o=o>=u?o:u)),o}function Er(o,u,d,D,x,T){var L,z=u&c,Y=u&m,Q=u&v;if(d&&(L=x?d(o,D,x,T):d(o)),L!==e)return L;if(!_e(o))return o;var et=Tt(o);if(et){if(L=Xb(o),!z)return Xe(o,L)}else{var ot=Ye(o),dt=ot==Xt||ot==zt;if(Bn(o))return v0(o,z);if(ot==Me||ot==yt||dt&&!x){if(L=Y||dt?{}:R0(o),!z)return Y?qb(o,lb(L,o)):zb(o,Gh(L,o))}else{if(!le[ot])return x?o:{};L=Vb(o,ot,z)}}T||(T=new $r);var _t=T.get(o);if(_t)return _t;T.set(o,L),cp(o)?o.forEach(function(Ct){L.add(Er(Ct,u,d,Ct,o,T))}):lp(o)&&o.forEach(function(Ct,qt){L.set(qt,Er(Ct,u,d,qt,o,T))});var xt=Q?Y?Ju:Hu:Y?Qe:$e,Rt=et?e:xt(o);return Dr(Rt||o,function(Ct,qt){Rt&&(qt=Ct,Ct=o[qt]),os(L,qt,Er(Ct,u,d,qt,o,T))}),L}function fb(o){var u=$e(o);return function(d){return Kh(d,o,u)}}function Kh(o,u,d){var D=d.length;if(o==null)return!D;for(o=ae(o);D--;){var x=d[D],T=u[x],L=o[x];if(L===e&&!(x in o)||!T(L))return!1}return!0}function Hh(o,u,d){if(typeof o!="function")throw new yr(a);return ps(function(){o.apply(e,d)},u)}function as(o,u,d,D){var x=-1,T=go,L=!0,z=o.length,Y=[],Q=u.length;if(!z)return Y;d&&(u=de(u,fr(d))),D?(T=gu,L=!1):u.length>=n&&(T=ts,L=!1,u=new Jn(u));t:for(;++x<z;){var et=o[x],ot=d==null?et:d(et);if(et=D||et!==0?et:0,L&&ot===ot){for(var dt=Q;dt--;)if(u[dt]===ot)continue t;Y.push(et)}else T(u,ot,D)||Y.push(et)}return Y}var Fn=b0(Yr),Jh=b0(Iu,!0);function cb(o,u){var d=!0;return Fn(o,function(D,x,T){return d=!!u(D,x,T),d}),d}function $o(o,u,d){for(var D=-1,x=o.length;++D<x;){var T=o[D],L=u(T);if(L!=null&&(z===e?L===L&&!hr(L):d(L,z)))var z=L,Y=T}return Y}function hb(o,u,d,D){var x=o.length;for(d=Ot(d),d<0&&(d=-d>x?0:x+d),D=D===e||D>x?x:Ot(D),D<0&&(D+=x),D=d>D?0:pp(D);d<D;)o[d++]=u;return o}function Xh(o,u){var d=[];return Fn(o,function(D,x,T){u(D,x,T)&&d.push(D)}),d}function Pe(o,u,d,D,x){var T=-1,L=o.length;for(d||(d=tE),x||(x=[]);++T<L;){var z=o[T];u>0&&d(z)?u>1?Pe(z,u-1,d,D,x):An(x,z):D||(x[x.length]=z)}return x}var Bu=E0(),Vh=E0(!0);function Yr(o,u){return o&&Bu(o,u,$e)}function Iu(o,u){return o&&Vh(o,u,$e)}function Oo(o,u){return En(u,function(d){return an(o[d])})}function Vn(o,u){u=Nn(u,o);for(var d=0,D=u.length;o!=null&&d<D;)o=o[Zr(u[d++])];return d&&d==D?o:e}function Qh(o,u,d){var D=u(o);return Tt(o)?D:An(D,d(o))}function je(o){return o==null?o===e?j:sr:Kn&&Kn in ae(o)?Kb(o):aE(o)}function Tu(o,u){return o>u}function pb(o,u){return o!=null&&ne.call(o,u)}function db(o,u){return o!=null&&u in ae(o)}function mb(o,u,d){return o>=We(u,d)&&o<Be(u,d)}function $u(o,u,d){for(var D=d?gu:go,x=o[0].length,T=o.length,L=T,z=J(T),Y=1/0,Q=[];L--;){var et=o[L];L&&u&&(et=de(et,fr(u))),Y=We(et.length,Y),z[L]=!d&&(u||x>=120&&et.length>=120)?new Jn(L&&et):e}et=o[0];var ot=-1,dt=z[0];t:for(;++ot<x&&Q.length<Y;){var _t=et[ot],xt=u?u(_t):_t;if(_t=d||_t!==0?_t:0,!(dt?ts(dt,xt):D(Q,xt,d))){for(L=T;--L;){var Rt=z[L];if(!(Rt?ts(Rt,xt):D(o[L],xt,d)))continue t}dt&&dt.push(xt),Q.push(_t)}}return Q}function gb(o,u,d,D){return Yr(o,function(x,T,L){u(D,d(x),T,L)}),D}function us(o,u,d){u=Nn(u,o),o=q0(o,u);var D=o==null?o:o[Zr(xr(u))];return D==null?e:lr(D,o,d)}function t0(o){return we(o)&&je(o)==yt}function vb(o){return we(o)&&je(o)==st}function _b(o){return we(o)&&je(o)==It}function ls(o,u,d,D,x){return o===u?!0:o==null||u==null||!we(o)&&!we(u)?o!==o&&u!==u:wb(o,u,d,D,ls,x)}function wb(o,u,d,D,x,T){var L=Tt(o),z=Tt(u),Y=L?St:Ye(o),Q=z?St:Ye(u);Y=Y==yt?Me:Y,Q=Q==yt?Me:Q;var et=Y==Me,ot=Q==Me,dt=Y==Q;if(dt&&Bn(o)){if(!Bn(u))return!1;L=!0,et=!1}if(dt&&!et)return T||(T=new $r),L||Oi(o)?T0(o,u,d,D,x,T):Zb(o,u,Y,d,D,x,T);if(!(d&w)){var _t=et&&ne.call(o,"__wrapped__"),xt=ot&&ne.call(u,"__wrapped__");if(_t||xt){var Rt=_t?o.value():o,Ct=xt?u.value():u;return T||(T=new $r),x(Rt,Ct,d,D,T)}}return dt?(T||(T=new $r),Gb(o,u,d,D,x,T)):!1}function Db(o){return we(o)&&Ye(o)==Gt}function Ou(o,u,d,D){var x=d.length,T=x,L=!D;if(o==null)return!T;for(o=ae(o);x--;){var z=d[x];if(L&&z[2]?z[1]!==o[z[0]]:!(z[0]in o))return!1}for(;++x<T;){z=d[x];var Y=z[0],Q=o[Y],et=z[1];if(L&&z[2]){if(Q===e&&!(Y in o))return!1}else{var ot=new $r;if(D)var dt=D(Q,et,Y,o,u,ot);if(!(dt===e?ls(et,Q,w|g,D,ot):dt))return!1}}return!0}function e0(o){if(!_e(o)||rE(o))return!1;var u=an(o)?Dy:iu;return u.test(ti(o))}function yb(o){return we(o)&&je(o)==Qr}function bb(o){return we(o)&&Ye(o)==or}function Eb(o){return we(o)&&Vo(o.length)&&!!ce[je(o)]}function r0(o){return typeof o=="function"?o:o==null?tr:typeof o=="object"?Tt(o)?s0(o[0],o[1]):i0(o):Ap(o)}function Ru(o){if(!hs(o))return Cy(o);var u=[];for(var d in ae(o))ne.call(o,d)&&d!="constructor"&&u.push(d);return u}function Ab(o){if(!_e(o))return oE(o);var u=hs(o),d=[];for(var D in o)D=="constructor"&&(u||!ne.call(o,D))||d.push(D);return d}function Lu(o,u){return o<u}function n0(o,u){var d=-1,D=Ve(o)?J(o.length):[];return Fn(o,function(x,T,L){D[++d]=u(x,T,L)}),D}function i0(o){var u=Vu(o);return u.length==1&&u[0][2]?P0(u[0][0],u[0][1]):function(d){return d===o||Ou(d,o,u)}}function s0(o,u){return tl(o)&&L0(u)?P0(Zr(o),u):function(d){var D=fl(d,o);return D===e&&D===u?cl(d,o):ls(u,D,w|g)}}function Ro(o,u,d,D,x){o!==u&&Bu(u,function(T,L){if(x||(x=new $r),_e(T))xb(o,u,L,d,Ro,D,x);else{var z=D?D(rl(o,L),T,L+"",o,u,x):e;z===e&&(z=T),Nu(o,L,z)}},Qe)}function xb(o,u,d,D,x,T,L){var z=rl(o,d),Y=rl(u,d),Q=L.get(Y);if(Q){Nu(o,d,Q);return}var et=T?T(z,Y,d+"",o,u,L):e,ot=et===e;if(ot){var dt=Tt(Y),_t=!dt&&Bn(Y),xt=!dt&&!_t&&Oi(Y);et=Y,dt||_t||xt?Tt(z)?et=z:be(z)?et=Xe(z):_t?(ot=!1,et=v0(Y,!0)):xt?(ot=!1,et=_0(Y,!0)):et=[]:ds(Y)||ei(Y)?(et=z,ei(z)?et=dp(z):(!_e(z)||an(z))&&(et=R0(Y))):ot=!1}ot&&(L.set(Y,et),x(et,Y,D,T,L),L.delete(Y)),Nu(o,d,et)}function o0(o,u){var d=o.length;if(d)return u+=u<0?d:0,on(u,d)?o[u]:e}function a0(o,u,d){u.length?u=de(u,function(T){return Tt(T)?function(L){return Vn(L,T.length===1?T[0]:T)}:T}):u=[tr];var D=-1;u=de(u,fr(At()));var x=n0(o,function(T,L,z){var Y=de(u,function(Q){return Q(T)});return{criteria:Y,index:++D,value:T}});return VD(x,function(T,L){return Pb(T,L,d)})}function Cb(o,u){return u0(o,u,function(d,D){return cl(o,D)})}function u0(o,u,d){for(var D=-1,x=u.length,T={};++D<x;){var L=u[D],z=Vn(o,L);d(z,L)&&fs(T,Nn(L,o),z)}return T}function Fb(o){return function(u){return Vn(u,o)}}function Pu(o,u,d,D){var x=D?XD:Ai,T=-1,L=u.length,z=o;for(o===u&&(u=Xe(u)),d&&(z=de(o,fr(d)));++T<L;)for(var Y=0,Q=u[T],et=d?d(Q):Q;(Y=x(z,et,Y,D))>-1;)z!==o&&Co.call(z,Y,1),Co.call(o,Y,1);return o}function l0(o,u){for(var d=o?u.length:0,D=d-1;d--;){var x=u[d];if(d==D||x!==T){var T=x;on(x)?Co.call(o,x,1):ku(o,x)}}return o}function zu(o,u){return o+No(Wh()*(u-o+1))}function Mb(o,u,d,D){for(var x=-1,T=Be(Mo((u-o)/(d||1)),0),L=J(T);T--;)L[D?T:++x]=o,o+=d;return L}function qu(o,u){var d="";if(!o||u<1||u>G)return d;do u%2&&(d+=o),u=No(u/2),u&&(o+=o);while(u);return d}function Lt(o,u){return nl(z0(o,u,tr),o+"")}function Nb(o){return Zh(Ri(o))}function Sb(o,u){var d=Ri(o);return Zo(d,Xn(u,0,d.length))}function fs(o,u,d,D){if(!_e(o))return o;u=Nn(u,o);for(var x=-1,T=u.length,L=T-1,z=o;z!=null&&++x<T;){var Y=Zr(u[x]),Q=d;if(Y==="__proto__"||Y==="constructor"||Y==="prototype")return o;if(x!=L){var et=z[Y];Q=D?D(et,Y,z):e,Q===e&&(Q=_e(et)?et:on(u[x+1])?[]:{})}os(z,Y,Q),z=z[Y]}return o}var f0=So?function(o,u){return So.set(o,u),o}:tr,Bb=Fo?function(o,u){return Fo(o,"toString",{configurable:!0,enumerable:!1,value:pl(u),writable:!0})}:tr;function Ib(o){return Zo(Ri(o))}function Ar(o,u,d){var D=-1,x=o.length;u<0&&(u=-u>x?0:x+u),d=d>x?x:d,d<0&&(d+=x),x=u>d?0:d-u>>>0,u>>>=0;for(var T=J(x);++D<x;)T[D]=o[D+u];return T}function Tb(o,u){var d;return Fn(o,function(D,x,T){return d=u(D,x,T),!d}),!!d}function Lo(o,u,d){var D=0,x=o==null?D:o.length;if(typeof u=="number"&&u===u&&x<=lt){for(;D<x;){var T=D+x>>>1,L=o[T];L!==null&&!hr(L)&&(d?L<=u:L<u)?D=T+1:x=T}return x}return Uu(o,u,tr,d)}function Uu(o,u,d,D){var x=0,T=o==null?0:o.length;if(T===0)return 0;u=d(u);for(var L=u!==u,z=u===null,Y=hr(u),Q=u===e;x<T;){var et=No((x+T)/2),ot=d(o[et]),dt=ot!==e,_t=ot===null,xt=ot===ot,Rt=hr(ot);if(L)var Ct=D||xt;else Q?Ct=xt&&(D||dt):z?Ct=xt&&dt&&(D||!_t):Y?Ct=xt&&dt&&!_t&&(D||!Rt):_t||Rt?Ct=!1:Ct=D?ot<=u:ot<u;Ct?x=et+1:T=et}return We(T,vt)}function c0(o,u){for(var d=-1,D=o.length,x=0,T=[];++d<D;){var L=o[d],z=u?u(L):L;if(!d||!Or(z,Y)){var Y=z;T[x++]=L===0?0:L}}return T}function h0(o){return typeof o=="number"?o:hr(o)?tt:+o}function cr(o){if(typeof o=="string")return o;if(Tt(o))return de(o,cr)+"";if(hr(o))return Yh?Yh.call(o):"";var u=o+"";return u=="0"&&1/o==-K?"-0":u}function Mn(o,u,d){var D=-1,x=go,T=o.length,L=!0,z=[],Y=z;if(d)L=!1,x=gu;else if(T>=n){var Q=u?null:Yb(o);if(Q)return _o(Q);L=!1,x=ts,Y=new Jn}else Y=u?[]:z;t:for(;++D<T;){var et=o[D],ot=u?u(et):et;if(et=d||et!==0?et:0,L&&ot===ot){for(var dt=Y.length;dt--;)if(Y[dt]===ot)continue t;u&&Y.push(ot),z.push(et)}else x(Y,ot,d)||(Y!==z&&Y.push(ot),z.push(et))}return z}function ku(o,u){return u=Nn(u,o),o=q0(o,u),o==null||delete o[Zr(xr(u))]}function p0(o,u,d,D){return fs(o,u,d(Vn(o,u)),D)}function Po(o,u,d,D){for(var x=o.length,T=D?x:-1;(D?T--:++T<x)&&u(o[T],T,o););return d?Ar(o,D?0:T,D?T+1:x):Ar(o,D?T+1:0,D?x:T)}function d0(o,u){var d=o;return d instanceof Ut&&(d=d.value()),vu(u,function(D,x){return x.func.apply(x.thisArg,An([D],x.args))},d)}function Wu(o,u,d){var D=o.length;if(D<2)return D?Mn(o[0]):[];for(var x=-1,T=J(D);++x<D;)for(var L=o[x],z=-1;++z<D;)z!=x&&(T[x]=as(T[x]||L,o[z],u,d));return Mn(Pe(T,1),u,d)}function m0(o,u,d){for(var D=-1,x=o.length,T=u.length,L={};++D<x;){var z=D<T?u[D]:e;d(L,o[D],z)}return L}function Yu(o){return be(o)?o:[]}function ju(o){return typeof o=="function"?o:tr}function Nn(o,u){return Tt(o)?o:tl(o,u)?[o]:Y0(Qt(o))}var $b=Lt;function Sn(o,u,d){var D=o.length;return d=d===e?D:d,!u&&d>=D?o:Ar(o,u,d)}var g0=yy||function(o){return Le.clearTimeout(o)};function v0(o,u){if(u)return o.slice();var d=o.length,D=Ph?Ph(d):new o.constructor(d);return o.copy(D),D}function Zu(o){var u=new o.constructor(o.byteLength);return new Ao(u).set(new Ao(o)),u}function Ob(o,u){var d=u?Zu(o.buffer):o.buffer;return new o.constructor(d,o.byteOffset,o.byteLength)}function Rb(o){var u=new o.constructor(o.source,ho.exec(o));return u.lastIndex=o.lastIndex,u}function Lb(o){return ss?ae(ss.call(o)):{}}function _0(o,u){var d=u?Zu(o.buffer):o.buffer;return new o.constructor(d,o.byteOffset,o.length)}function w0(o,u){if(o!==u){var d=o!==e,D=o===null,x=o===o,T=hr(o),L=u!==e,z=u===null,Y=u===u,Q=hr(u);if(!z&&!Q&&!T&&o>u||T&&L&&Y&&!z&&!Q||D&&L&&Y||!d&&Y||!x)return 1;if(!D&&!T&&!Q&&o<u||Q&&d&&x&&!D&&!T||z&&d&&x||!L&&x||!Y)return-1}return 0}function Pb(o,u,d){for(var D=-1,x=o.criteria,T=u.criteria,L=x.length,z=d.length;++D<L;){var Y=w0(x[D],T[D]);if(Y){if(D>=z)return Y;var Q=d[D];return Y*(Q=="desc"?-1:1)}}return o.index-u.index}function D0(o,u,d,D){for(var x=-1,T=o.length,L=d.length,z=-1,Y=u.length,Q=Be(T-L,0),et=J(Y+Q),ot=!D;++z<Y;)et[z]=u[z];for(;++x<L;)(ot||x<T)&&(et[d[x]]=o[x]);for(;Q--;)et[z++]=o[x++];return et}function y0(o,u,d,D){for(var x=-1,T=o.length,L=-1,z=d.length,Y=-1,Q=u.length,et=Be(T-z,0),ot=J(et+Q),dt=!D;++x<et;)ot[x]=o[x];for(var _t=x;++Y<Q;)ot[_t+Y]=u[Y];for(;++L<z;)(dt||x<T)&&(ot[_t+d[L]]=o[x++]);return ot}function Xe(o,u){var d=-1,D=o.length;for(u||(u=J(D));++d<D;)u[d]=o[d];return u}function jr(o,u,d,D){var x=!d;d||(d={});for(var T=-1,L=u.length;++T<L;){var z=u[T],Y=D?D(d[z],o[z],z,d,o):e;Y===e&&(Y=o[z]),x?rn(d,z,Y):os(d,z,Y)}return d}function zb(o,u){return jr(o,Qu(o),u)}function qb(o,u){return jr(o,$0(o),u)}function zo(o,u){return function(d,D){var x=Tt(d)?jD:ub,T=u?u():{};return x(d,o,At(D,2),T)}}function Ii(o){return Lt(function(u,d){var D=-1,x=d.length,T=x>1?d[x-1]:e,L=x>2?d[2]:e;for(T=o.length>3&&typeof T=="function"?(x--,T):e,L&&Ze(d[0],d[1],L)&&(T=x<3?e:T,x=1),u=ae(u);++D<x;){var z=d[D];z&&o(u,z,D,T)}return u})}function b0(o,u){return function(d,D){if(d==null)return d;if(!Ve(d))return o(d,D);for(var x=d.length,T=u?x:-1,L=ae(d);(u?T--:++T<x)&&D(L[T],T,L)!==!1;);return d}}function E0(o){return function(u,d,D){for(var x=-1,T=ae(u),L=D(u),z=L.length;z--;){var Y=L[o?z:++x];if(d(T[Y],Y,T)===!1)break}return u}}function Ub(o,u,d){var D=u&y,x=cs(o);function T(){var L=this&&this!==Le&&this instanceof T?x:o;return L.apply(D?d:this,arguments)}return T}function A0(o){return function(u){u=Qt(u);var d=xi(u)?Tr(u):e,D=d?d[0]:u.charAt(0),x=d?Sn(d,1).join(""):u.slice(1);return D[o]()+x}}function Ti(o){return function(u){return vu(bp(yp(u).replace(BD,"")),o,"")}}function cs(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 d=Bi(o.prototype),D=o.apply(d,u);return _e(D)?D:d}}function kb(o,u,d){var D=cs(o);function x(){for(var T=arguments.length,L=J(T),z=T,Y=$i(x);z--;)L[z]=arguments[z];var Q=T<3&&L[0]!==Y&&L[T-1]!==Y?[]:xn(L,Y);if(T-=Q.length,T<d)return N0(o,u,qo,x.placeholder,e,L,Q,e,e,d-T);var et=this&&this!==Le&&this instanceof x?D:o;return lr(et,this,L)}return x}function x0(o){return function(u,d,D){var x=ae(u);if(!Ve(u)){var T=At(d,3);u=$e(u),d=function(z){return T(x[z],z,x)}}var L=o(u,d,D);return L>-1?x[T?u[L]:L]:e}}function C0(o){return sn(function(u){var d=u.length,D=d,x=br.prototype.thru;for(o&&u.reverse();D--;){var T=u[D];if(typeof T!="function")throw new yr(a);if(x&&!L&&Yo(T)=="wrapper")var L=new br([],!0)}for(D=L?D:d;++D<d;){T=u[D];var z=Yo(T),Y=z=="wrapper"?Xu(T):e;Y&&el(Y[0])&&Y[1]==(M|b|A|S)&&!Y[4].length&&Y[9]==1?L=L[Yo(Y[0])].apply(L,Y[3]):L=T.length==1&&el(T)?L[z]():L.thru(T)}return function(){var Q=arguments,et=Q[0];if(L&&Q.length==1&&Tt(et))return L.plant(et).value();for(var ot=0,dt=d?u[ot].apply(this,Q):et;++ot<d;)dt=u[ot].call(this,dt);return dt}})}function qo(o,u,d,D,x,T,L,z,Y,Q){var et=u&M,ot=u&y,dt=u&_,_t=u&(b|N),xt=u&$,Rt=dt?e:cs(o);function Ct(){for(var qt=arguments.length,kt=J(qt),pr=qt;pr--;)kt[pr]=arguments[pr];if(_t)var Ge=$i(Ct),dr=ty(kt,Ge);if(D&&(kt=D0(kt,D,x,_t)),T&&(kt=y0(kt,T,L,_t)),qt-=dr,_t&&qt<Q){var Ee=xn(kt,Ge);return N0(o,u,qo,Ct.placeholder,d,kt,Ee,z,Y,Q-qt)}var Rr=ot?d:this,ln=dt?Rr[o]:o;return qt=kt.length,z?kt=uE(kt,z):xt&&qt>1&&kt.reverse(),et&&Y<qt&&(kt.length=Y),this&&this!==Le&&this instanceof Ct&&(ln=Rt||cs(ln)),ln.apply(Rr,kt)}return Ct}function F0(o,u){return function(d,D){return gb(d,o,u(D),{})}}function Uo(o,u){return function(d,D){var x;if(d===e&&D===e)return u;if(d!==e&&(x=d),D!==e){if(x===e)return D;typeof d=="string"||typeof D=="string"?(d=cr(d),D=cr(D)):(d=h0(d),D=h0(D)),x=o(d,D)}return x}}function Gu(o){return sn(function(u){return u=de(u,fr(At())),Lt(function(d){var D=this;return o(u,function(x){return lr(x,D,d)})})})}function ko(o,u){u=u===e?" ":cr(u);var d=u.length;if(d<2)return d?qu(u,o):u;var D=qu(u,Mo(o/Ci(u)));return xi(u)?Sn(Tr(D),0,o).join(""):D.slice(0,o)}function Wb(o,u,d,D){var x=u&y,T=cs(o);function L(){for(var z=-1,Y=arguments.length,Q=-1,et=D.length,ot=J(et+Y),dt=this&&this!==Le&&this instanceof L?T:o;++Q<et;)ot[Q]=D[Q];for(;Y--;)ot[Q++]=arguments[++z];return lr(dt,x?d:this,ot)}return L}function M0(o){return function(u,d,D){return D&&typeof D!="number"&&Ze(u,d,D)&&(d=D=e),u=un(u),d===e?(d=u,u=0):d=un(d),D=D===e?u<d?1:-1:un(D),Mb(u,d,D,o)}}function Wo(o){return function(u,d){return typeof u=="string"&&typeof d=="string"||(u=Cr(u),d=Cr(d)),o(u,d)}}function N0(o,u,d,D,x,T,L,z,Y,Q){var et=u&b,ot=et?L:e,dt=et?e:L,_t=et?T:e,xt=et?e:T;u|=et?A:C,u&=~(et?C:A),u&E||(u&=~(y|_));var Rt=[o,u,x,_t,ot,xt,dt,z,Y,Q],Ct=d.apply(e,Rt);return el(o)&&U0(Ct,Rt),Ct.placeholder=D,k0(Ct,o,u)}function Ku(o){var u=Se[o];return function(d,D){if(d=Cr(d),D=D==null?0:We(Ot(D),292),D&&kh(d)){var x=(Qt(d)+"e").split("e"),T=u(x[0]+"e"+(+x[1]+D));return x=(Qt(T)+"e").split("e"),+(x[0]+"e"+(+x[1]-D))}return u(d)}}var Yb=Ni&&1/_o(new Ni([,-0]))[1]==K?function(o){return new Ni(o)}:gl;function S0(o){return function(u){var d=Ye(u);return d==Gt?Au(u):d==or?ay(u):QD(u,o(u))}}function nn(o,u,d,D,x,T,L,z){var Y=u&_;if(!Y&&typeof o!="function")throw new yr(a);var Q=D?D.length:0;if(Q||(u&=~(A|C),D=x=e),L=L===e?L:Be(Ot(L),0),z=z===e?z:Ot(z),Q-=x?x.length:0,u&C){var et=D,ot=x;D=x=e}var dt=Y?e:Xu(o),_t=[o,u,d,D,x,et,ot,T,L,z];if(dt&&sE(_t,dt),o=_t[0],u=_t[1],d=_t[2],D=_t[3],x=_t[4],z=_t[9]=_t[9]===e?Y?0:o.length:Be(_t[9]-Q,0),!z&&u&(b|N)&&(u&=~(b|N)),!u||u==y)var xt=Ub(o,u,d);else u==b||u==N?xt=kb(o,u,z):(u==A||u==(y|A))&&!x.length?xt=Wb(o,u,d,D):xt=qo.apply(e,_t);var Rt=dt?f0:U0;return k0(Rt(xt,_t),o,u)}function B0(o,u,d,D){return o===e||Or(o,Mi[d])&&!ne.call(D,d)?u:o}function I0(o,u,d,D,x,T){return _e(o)&&_e(u)&&(T.set(u,o),Ro(o,u,e,I0,T),T.delete(u)),o}function jb(o){return ds(o)?e:o}function T0(o,u,d,D,x,T){var L=d&w,z=o.length,Y=u.length;if(z!=Y&&!(L&&Y>z))return!1;var Q=T.get(o),et=T.get(u);if(Q&&et)return Q==u&&et==o;var ot=-1,dt=!0,_t=d&g?new Jn:e;for(T.set(o,u),T.set(u,o);++ot<z;){var xt=o[ot],Rt=u[ot];if(D)var Ct=L?D(Rt,xt,ot,u,o,T):D(xt,Rt,ot,o,u,T);if(Ct!==e){if(Ct)continue;dt=!1;break}if(_t){if(!_u(u,function(qt,kt){if(!ts(_t,kt)&&(xt===qt||x(xt,qt,d,D,T)))return _t.push(kt)})){dt=!1;break}}else if(!(xt===Rt||x(xt,Rt,d,D,T))){dt=!1;break}}return T.delete(o),T.delete(u),dt}function Zb(o,u,d,D,x,T,L){switch(d){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 Ao(o),new Ao(u)));case re:case It:case Ce:return Or(+o,+u);case ie:return o.name==u.name&&o.message==u.message;case Qr:case Dn:return o==u+"";case Gt:var z=Au;case or:var Y=D&w;if(z||(z=_o),o.size!=u.size&&!Y)return!1;var Q=L.get(o);if(Q)return Q==u;D|=g,L.set(o,u);var et=T0(z(o),z(u),D,x,T,L);return L.delete(o),et;case O:if(ss)return ss.call(o)==ss.call(u)}return!1}function Gb(o,u,d,D,x,T){var L=d&w,z=Hu(o),Y=z.length,Q=Hu(u),et=Q.length;if(Y!=et&&!L)return!1;for(var ot=Y;ot--;){var dt=z[ot];if(!(L?dt in u:ne.call(u,dt)))return!1}var _t=T.get(o),xt=T.get(u);if(_t&&xt)return _t==u&&xt==o;var Rt=!0;T.set(o,u),T.set(u,o);for(var Ct=L;++ot<Y;){dt=z[ot];var qt=o[dt],kt=u[dt];if(D)var pr=L?D(kt,qt,dt,u,o,T):D(qt,kt,dt,o,u,T);if(!(pr===e?qt===kt||x(qt,kt,d,D,T):pr)){Rt=!1;break}Ct||(Ct=dt=="constructor")}if(Rt&&!Ct){var Ge=o.constructor,dr=u.constructor;Ge!=dr&&"constructor"in o&&"constructor"in u&&!(typeof Ge=="function"&&Ge instanceof Ge&&typeof dr=="function"&&dr instanceof dr)&&(Rt=!1)}return T.delete(o),T.delete(u),Rt}function sn(o){return nl(z0(o,e,K0),o+"")}function Hu(o){return Qh(o,$e,Qu)}function Ju(o){return Qh(o,Qe,$0)}var Xu=So?function(o){return So.get(o)}:gl;function Yo(o){for(var u=o.name+"",d=Si[u],D=ne.call(Si,u)?d.length:0;D--;){var x=d[D],T=x.func;if(T==null||T==o)return x.name}return u}function $i(o){var u=ne.call(B,"placeholder")?B:o;return u.placeholder}function At(){var o=B.iteratee||dl;return o=o===dl?r0:o,arguments.length?o(arguments[0],arguments[1]):o}function jo(o,u){var d=o.__data__;return eE(u)?d[typeof u=="string"?"string":"hash"]:d.map}function Vu(o){for(var u=$e(o),d=u.length;d--;){var D=u[d],x=o[D];u[d]=[D,x,L0(x)]}return u}function Qn(o,u){var d=iy(o,u);return e0(d)?d:e}function Kb(o){var u=ne.call(o,Kn),d=o[Kn];try{o[Kn]=e;var D=!0}catch{}var x=bo.call(o);return D&&(u?o[Kn]=d:delete o[Kn]),x}var Qu=Cu?function(o){return o==null?[]:(o=ae(o),En(Cu(o),function(u){return qh.call(o,u)}))}:vl,$0=Cu?function(o){for(var u=[];o;)An(u,Qu(o)),o=xo(o);return u}:vl,Ye=je;(Fu&&Ye(new Fu(new ArrayBuffer(1)))!=rt||rs&&Ye(new rs)!=Gt||Mu&&Ye(Mu.resolve())!=Vr||Ni&&Ye(new Ni)!=or||ns&&Ye(new ns)!=H)&&(Ye=function(o){var u=je(o),d=u==Me?o.constructor:e,D=d?ti(d):"";if(D)switch(D){case Sy:return rt;case By:return Gt;case Iy:return Vr;case Ty:return or;case $y:return H}return u});function Hb(o,u,d){for(var D=-1,x=d.length;++D<x;){var T=d[D],L=T.size;switch(T.type){case"drop":o+=L;break;case"dropRight":u-=L;break;case"take":u=We(u,o+L);break;case"takeRight":o=Be(o,u-L);break}}return{start:o,end:u}}function Jb(o){var u=o.match(Ja);return u?u[1].split(Xa):[]}function O0(o,u,d){u=Nn(u,o);for(var D=-1,x=u.length,T=!1;++D<x;){var L=Zr(u[D]);if(!(T=o!=null&&d(o,L)))break;o=o[L]}return T||++D!=x?T:(x=o==null?0:o.length,!!x&&Vo(x)&&on(L,x)&&(Tt(o)||ei(o)))}function Xb(o){var u=o.length,d=new o.constructor(u);return u&&typeof o[0]=="string"&&ne.call(o,"index")&&(d.index=o.index,d.input=o.input),d}function R0(o){return typeof o.constructor=="function"&&!hs(o)?Bi(xo(o)):{}}function Vb(o,u,d){var D=o.constructor;switch(u){case st:return Zu(o);case re:case It:return new D(+o);case rt:return Ob(o,d);case ct:case ut:case ht:case at:case Kt:case Vt:case pe:case Te:case Ne:return _0(o,d);case Gt:return new D;case Ce:case Dn:return new D(o);case Qr:return Rb(o);case or:return new D;case O:return Lb(o)}}function Qb(o,u){var d=u.length;if(!d)return o;var D=d-1;return u[D]=(d>1?"& ":"")+u[D],u=u.join(d>2?", ":" "),o.replace(Ha,`{
9
- /* [wrapped with `+u+`] */
10
- `)}function tE(o){return Tt(o)||ei(o)||!!(Uh&&o&&o[Uh])}function on(o,u){var d=typeof o;return u=u??G,!!u&&(d=="number"||d!="symbol"&&ou.test(o))&&o>-1&&o%1==0&&o<u}function Ze(o,u,d){if(!_e(d))return!1;var D=typeof u;return(D=="number"?Ve(d)&&on(u,d.length):D=="string"&&u in d)?Or(d[u],o):!1}function tl(o,u){if(Tt(o))return!1;var d=typeof o;return d=="number"||d=="symbol"||d=="boolean"||o==null||hr(o)?!0:ja.test(o)||!Ya.test(o)||u!=null&&o in ae(u)}function eE(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function el(o){var u=Yo(o),d=B[u];if(typeof d!="function"||!(u in Ut.prototype))return!1;if(o===d)return!0;var D=Xu(d);return!!D&&o===D[0]}function rE(o){return!!Lh&&Lh in o}var nE=Do?an:_l;function hs(o){var u=o&&o.constructor,d=typeof u=="function"&&u.prototype||Mi;return o===d}function L0(o){return o===o&&!_e(o)}function P0(o,u){return function(d){return d==null?!1:d[o]===u&&(u!==e||o in ae(d))}}function iE(o){var u=Jo(o,function(D){return d.size===h&&d.clear(),D}),d=u.cache;return u}function sE(o,u){var d=o[1],D=u[1],x=d|D,T=x<(y|_|M),L=D==M&&d==b||D==M&&d==S&&o[7].length<=u[8]||D==(M|S)&&u[7].length<=u[8]&&d==b;if(!(T||L))return o;D&y&&(o[2]=u[2],x|=d&y?0:E);var z=u[3];if(z){var Y=o[3];o[3]=Y?D0(Y,z,u[4]):z,o[4]=Y?xn(o[3],p):u[4]}return z=u[5],z&&(Y=o[5],o[5]=Y?y0(Y,z,u[6]):z,o[6]=Y?xn(o[5],p):u[6]),z=u[7],z&&(o[7]=z),D&M&&(o[8]=o[8]==null?u[8]:We(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=x,o}function oE(o){var u=[];if(o!=null)for(var d in ae(o))u.push(d);return u}function aE(o){return bo.call(o)}function z0(o,u,d){return u=Be(u===e?o.length-1:u,0),function(){for(var D=arguments,x=-1,T=Be(D.length-u,0),L=J(T);++x<T;)L[x]=D[u+x];x=-1;for(var z=J(u+1);++x<u;)z[x]=D[x];return z[u]=d(L),lr(o,this,z)}}function q0(o,u){return u.length<2?o:Vn(o,Ar(u,0,-1))}function uE(o,u){for(var d=o.length,D=We(u.length,d),x=Xe(o);D--;){var T=u[D];o[D]=on(T,d)?x[T]:e}return o}function rl(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var U0=W0(f0),ps=Ey||function(o,u){return Le.setTimeout(o,u)},nl=W0(Bb);function k0(o,u,d){var D=u+"";return nl(o,Qb(D,lE(Jb(D),d)))}function W0(o){var u=0,d=0;return function(){var D=Fy(),x=U-(D-d);if(d=D,x>0){if(++u>=R)return arguments[0]}else u=0;return o.apply(e,arguments)}}function Zo(o,u){var d=-1,D=o.length,x=D-1;for(u=u===e?D:u;++d<u;){var T=zu(d,x),L=o[T];o[T]=o[d],o[d]=L}return o.length=u,o}var Y0=iE(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(Za,function(d,D,x,T){u.push(x?T.replace(tu,"$1"):D||d)}),u});function Zr(o){if(typeof o=="string"||hr(o))return o;var u=o+"";return u=="0"&&1/o==-K?"-0":u}function ti(o){if(o!=null){try{return yo.call(o)}catch{}try{return o+""}catch{}}return""}function lE(o,u){return Dr(wt,function(d){var D="_."+d[0];u&d[1]&&!go(o,D)&&o.push(D)}),o.sort()}function j0(o){if(o instanceof Ut)return o.clone();var u=new br(o.__wrapped__,o.__chain__);return u.__actions__=Xe(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function fE(o,u,d){(d?Ze(o,u,d):u===e)?u=1:u=Be(Ot(u),0);var D=o==null?0:o.length;if(!D||u<1)return[];for(var x=0,T=0,L=J(Mo(D/u));x<D;)L[T++]=Ar(o,x,x+=u);return L}function cE(o){for(var u=-1,d=o==null?0:o.length,D=0,x=[];++u<d;){var T=o[u];T&&(x[D++]=T)}return x}function hE(){var o=arguments.length;if(!o)return[];for(var u=J(o-1),d=arguments[0],D=o;D--;)u[D-1]=arguments[D];return An(Tt(d)?Xe(d):[d],Pe(u,1))}var pE=Lt(function(o,u){return be(o)?as(o,Pe(u,1,be,!0)):[]}),dE=Lt(function(o,u){var d=xr(u);return be(d)&&(d=e),be(o)?as(o,Pe(u,1,be,!0),At(d,2)):[]}),mE=Lt(function(o,u){var d=xr(u);return be(d)&&(d=e),be(o)?as(o,Pe(u,1,be,!0),e,d):[]});function gE(o,u,d){var D=o==null?0:o.length;return D?(u=d||u===e?1:Ot(u),Ar(o,u<0?0:u,D)):[]}function vE(o,u,d){var D=o==null?0:o.length;return D?(u=d||u===e?1:Ot(u),u=D-u,Ar(o,0,u<0?0:u)):[]}function _E(o,u){return o&&o.length?Po(o,At(u,3),!0,!0):[]}function wE(o,u){return o&&o.length?Po(o,At(u,3),!0):[]}function DE(o,u,d,D){var x=o==null?0:o.length;return x?(d&&typeof d!="number"&&Ze(o,u,d)&&(d=0,D=x),hb(o,u,d,D)):[]}function Z0(o,u,d){var D=o==null?0:o.length;if(!D)return-1;var x=d==null?0:Ot(d);return x<0&&(x=Be(D+x,0)),vo(o,At(u,3),x)}function G0(o,u,d){var D=o==null?0:o.length;if(!D)return-1;var x=D-1;return d!==e&&(x=Ot(d),x=d<0?Be(D+x,0):We(x,D-1)),vo(o,At(u,3),x,!0)}function K0(o){var u=o==null?0:o.length;return u?Pe(o,1):[]}function yE(o){var u=o==null?0:o.length;return u?Pe(o,K):[]}function bE(o,u){var d=o==null?0:o.length;return d?(u=u===e?1:Ot(u),Pe(o,u)):[]}function EE(o){for(var u=-1,d=o==null?0:o.length,D={};++u<d;){var x=o[u];D[x[0]]=x[1]}return D}function H0(o){return o&&o.length?o[0]:e}function AE(o,u,d){var D=o==null?0:o.length;if(!D)return-1;var x=d==null?0:Ot(d);return x<0&&(x=Be(D+x,0)),Ai(o,u,x)}function xE(o){var u=o==null?0:o.length;return u?Ar(o,0,-1):[]}var CE=Lt(function(o){var u=de(o,Yu);return u.length&&u[0]===o[0]?$u(u):[]}),FE=Lt(function(o){var u=xr(o),d=de(o,Yu);return u===xr(d)?u=e:d.pop(),d.length&&d[0]===o[0]?$u(d,At(u,2)):[]}),ME=Lt(function(o){var u=xr(o),d=de(o,Yu);return u=typeof u=="function"?u:e,u&&d.pop(),d.length&&d[0]===o[0]?$u(d,e,u):[]});function NE(o,u){return o==null?"":xy.call(o,u)}function xr(o){var u=o==null?0:o.length;return u?o[u-1]:e}function SE(o,u,d){var D=o==null?0:o.length;if(!D)return-1;var x=D;return d!==e&&(x=Ot(d),x=x<0?Be(D+x,0):We(x,D-1)),u===u?ly(o,u,x):vo(o,Nh,x,!0)}function BE(o,u){return o&&o.length?o0(o,Ot(u)):e}var IE=Lt(J0);function J0(o,u){return o&&o.length&&u&&u.length?Pu(o,u):o}function TE(o,u,d){return o&&o.length&&u&&u.length?Pu(o,u,At(d,2)):o}function $E(o,u,d){return o&&o.length&&u&&u.length?Pu(o,u,e,d):o}var OE=sn(function(o,u){var d=o==null?0:o.length,D=Su(o,u);return l0(o,de(u,function(x){return on(x,d)?+x:x}).sort(w0)),D});function RE(o,u){var d=[];if(!(o&&o.length))return d;var D=-1,x=[],T=o.length;for(u=At(u,3);++D<T;){var L=o[D];u(L,D,o)&&(d.push(L),x.push(D))}return l0(o,x),d}function il(o){return o==null?o:Ny.call(o)}function LE(o,u,d){var D=o==null?0:o.length;return D?(d&&typeof d!="number"&&Ze(o,u,d)?(u=0,d=D):(u=u==null?0:Ot(u),d=d===e?D:Ot(d)),Ar(o,u,d)):[]}function PE(o,u){return Lo(o,u)}function zE(o,u,d){return Uu(o,u,At(d,2))}function qE(o,u){var d=o==null?0:o.length;if(d){var D=Lo(o,u);if(D<d&&Or(o[D],u))return D}return-1}function UE(o,u){return Lo(o,u,!0)}function kE(o,u,d){return Uu(o,u,At(d,2),!0)}function WE(o,u){var d=o==null?0:o.length;if(d){var D=Lo(o,u,!0)-1;if(Or(o[D],u))return D}return-1}function YE(o){return o&&o.length?c0(o):[]}function jE(o,u){return o&&o.length?c0(o,At(u,2)):[]}function ZE(o){var u=o==null?0:o.length;return u?Ar(o,1,u):[]}function GE(o,u,d){return o&&o.length?(u=d||u===e?1:Ot(u),Ar(o,0,u<0?0:u)):[]}function KE(o,u,d){var D=o==null?0:o.length;return D?(u=d||u===e?1:Ot(u),u=D-u,Ar(o,u<0?0:u,D)):[]}function HE(o,u){return o&&o.length?Po(o,At(u,3),!1,!0):[]}function JE(o,u){return o&&o.length?Po(o,At(u,3)):[]}var XE=Lt(function(o){return Mn(Pe(o,1,be,!0))}),VE=Lt(function(o){var u=xr(o);return be(u)&&(u=e),Mn(Pe(o,1,be,!0),At(u,2))}),QE=Lt(function(o){var u=xr(o);return u=typeof u=="function"?u:e,Mn(Pe(o,1,be,!0),e,u)});function tA(o){return o&&o.length?Mn(o):[]}function eA(o,u){return o&&o.length?Mn(o,At(u,2)):[]}function rA(o,u){return u=typeof u=="function"?u:e,o&&o.length?Mn(o,e,u):[]}function sl(o){if(!(o&&o.length))return[];var u=0;return o=En(o,function(d){if(be(d))return u=Be(d.length,u),!0}),bu(u,function(d){return de(o,wu(d))})}function X0(o,u){if(!(o&&o.length))return[];var d=sl(o);return u==null?d:de(d,function(D){return lr(u,e,D)})}var nA=Lt(function(o,u){return be(o)?as(o,u):[]}),iA=Lt(function(o){return Wu(En(o,be))}),sA=Lt(function(o){var u=xr(o);return be(u)&&(u=e),Wu(En(o,be),At(u,2))}),oA=Lt(function(o){var u=xr(o);return u=typeof u=="function"?u:e,Wu(En(o,be),e,u)}),aA=Lt(sl);function uA(o,u){return m0(o||[],u||[],os)}function lA(o,u){return m0(o||[],u||[],fs)}var fA=Lt(function(o){var u=o.length,d=u>1?o[u-1]:e;return d=typeof d=="function"?(o.pop(),d):e,X0(o,d)});function V0(o){var u=B(o);return u.__chain__=!0,u}function cA(o,u){return u(o),o}function Go(o,u){return u(o)}var hA=sn(function(o){var u=o.length,d=u?o[0]:0,D=this.__wrapped__,x=function(T){return Su(T,o)};return u>1||this.__actions__.length||!(D instanceof Ut)||!on(d)?this.thru(x):(D=D.slice(d,+d+(u?1:0)),D.__actions__.push({func:Go,args:[x],thisArg:e}),new br(D,this.__chain__).thru(function(T){return u&&!T.length&&T.push(e),T}))});function pA(){return V0(this)}function dA(){return new br(this.value(),this.__chain__)}function mA(){this.__values__===e&&(this.__values__=hp(this.value()));var o=this.__index__>=this.__values__.length,u=o?e:this.__values__[this.__index__++];return{done:o,value:u}}function gA(){return this}function vA(o){for(var u,d=this;d instanceof Io;){var D=j0(d);D.__index__=0,D.__values__=e,u?x.__wrapped__=D:u=D;var x=D;d=d.__wrapped__}return x.__wrapped__=o,u}function _A(){var o=this.__wrapped__;if(o instanceof Ut){var u=o;return this.__actions__.length&&(u=new Ut(this)),u=u.reverse(),u.__actions__.push({func:Go,args:[il],thisArg:e}),new br(u,this.__chain__)}return this.thru(il)}function wA(){return d0(this.__wrapped__,this.__actions__)}var DA=zo(function(o,u,d){ne.call(o,d)?++o[d]:rn(o,d,1)});function yA(o,u,d){var D=Tt(o)?Fh:cb;return d&&Ze(o,u,d)&&(u=e),D(o,At(u,3))}function bA(o,u){var d=Tt(o)?En:Xh;return d(o,At(u,3))}var EA=x0(Z0),AA=x0(G0);function xA(o,u){return Pe(Ko(o,u),1)}function CA(o,u){return Pe(Ko(o,u),K)}function FA(o,u,d){return d=d===e?1:Ot(d),Pe(Ko(o,u),d)}function Q0(o,u){var d=Tt(o)?Dr:Fn;return d(o,At(u,3))}function tp(o,u){var d=Tt(o)?ZD:Jh;return d(o,At(u,3))}var MA=zo(function(o,u,d){ne.call(o,d)?o[d].push(u):rn(o,d,[u])});function NA(o,u,d,D){o=Ve(o)?o:Ri(o),d=d&&!D?Ot(d):0;var x=o.length;return d<0&&(d=Be(x+d,0)),Qo(o)?d<=x&&o.indexOf(u,d)>-1:!!x&&Ai(o,u,d)>-1}var SA=Lt(function(o,u,d){var D=-1,x=typeof u=="function",T=Ve(o)?J(o.length):[];return Fn(o,function(L){T[++D]=x?lr(u,L,d):us(L,u,d)}),T}),BA=zo(function(o,u,d){rn(o,d,u)});function Ko(o,u){var d=Tt(o)?de:n0;return d(o,At(u,3))}function IA(o,u,d,D){return o==null?[]:(Tt(u)||(u=u==null?[]:[u]),d=D?e:d,Tt(d)||(d=d==null?[]:[d]),a0(o,u,d))}var TA=zo(function(o,u,d){o[d?0:1].push(u)},function(){return[[],[]]});function $A(o,u,d){var D=Tt(o)?vu:Bh,x=arguments.length<3;return D(o,At(u,4),d,x,Fn)}function OA(o,u,d){var D=Tt(o)?GD:Bh,x=arguments.length<3;return D(o,At(u,4),d,x,Jh)}function RA(o,u){var d=Tt(o)?En:Xh;return d(o,Xo(At(u,3)))}function LA(o){var u=Tt(o)?Zh:Nb;return u(o)}function PA(o,u,d){(d?Ze(o,u,d):u===e)?u=1:u=Ot(u);var D=Tt(o)?ob:Sb;return D(o,u)}function zA(o){var u=Tt(o)?ab:Ib;return u(o)}function qA(o){if(o==null)return 0;if(Ve(o))return Qo(o)?Ci(o):o.length;var u=Ye(o);return u==Gt||u==or?o.size:Ru(o).length}function UA(o,u,d){var D=Tt(o)?_u:Tb;return d&&Ze(o,u,d)&&(u=e),D(o,At(u,3))}var kA=Lt(function(o,u){if(o==null)return[];var d=u.length;return d>1&&Ze(o,u[0],u[1])?u=[]:d>2&&Ze(u[0],u[1],u[2])&&(u=[u[0]]),a0(o,Pe(u,1),[])}),Ho=by||function(){return Le.Date.now()};function WA(o,u){if(typeof u!="function")throw new yr(a);return o=Ot(o),function(){if(--o<1)return u.apply(this,arguments)}}function ep(o,u,d){return u=d?e:u,u=o&&u==null?o.length:u,nn(o,M,e,e,e,e,u)}function rp(o,u){var d;if(typeof u!="function")throw new yr(a);return o=Ot(o),function(){return--o>0&&(d=u.apply(this,arguments)),o<=1&&(u=e),d}}var ol=Lt(function(o,u,d){var D=y;if(d.length){var x=xn(d,$i(ol));D|=A}return nn(o,D,u,d,x)}),np=Lt(function(o,u,d){var D=y|_;if(d.length){var x=xn(d,$i(np));D|=A}return nn(u,D,o,d,x)});function ip(o,u,d){u=d?e:u;var D=nn(o,b,e,e,e,e,e,u);return D.placeholder=ip.placeholder,D}function sp(o,u,d){u=d?e:u;var D=nn(o,N,e,e,e,e,e,u);return D.placeholder=sp.placeholder,D}function op(o,u,d){var D,x,T,L,z,Y,Q=0,et=!1,ot=!1,dt=!0;if(typeof o!="function")throw new yr(a);u=Cr(u)||0,_e(d)&&(et=!!d.leading,ot="maxWait"in d,T=ot?Be(Cr(d.maxWait)||0,u):T,dt="trailing"in d?!!d.trailing:dt);function _t(Ee){var Rr=D,ln=x;return D=x=e,Q=Ee,L=o.apply(ln,Rr),L}function xt(Ee){return Q=Ee,z=ps(qt,u),et?_t(Ee):L}function Rt(Ee){var Rr=Ee-Y,ln=Ee-Q,xp=u-Rr;return ot?We(xp,T-ln):xp}function Ct(Ee){var Rr=Ee-Y,ln=Ee-Q;return Y===e||Rr>=u||Rr<0||ot&&ln>=T}function qt(){var Ee=Ho();if(Ct(Ee))return kt(Ee);z=ps(qt,Rt(Ee))}function kt(Ee){return z=e,dt&&D?_t(Ee):(D=x=e,L)}function pr(){z!==e&&g0(z),Q=0,D=Y=x=z=e}function Ge(){return z===e?L:kt(Ho())}function dr(){var Ee=Ho(),Rr=Ct(Ee);if(D=arguments,x=this,Y=Ee,Rr){if(z===e)return xt(Y);if(ot)return g0(z),z=ps(qt,u),_t(Y)}return z===e&&(z=ps(qt,u)),L}return dr.cancel=pr,dr.flush=Ge,dr}var YA=Lt(function(o,u){return Hh(o,1,u)}),jA=Lt(function(o,u,d){return Hh(o,Cr(u)||0,d)});function ZA(o){return nn(o,$)}function Jo(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new yr(a);var d=function(){var D=arguments,x=u?u.apply(this,D):D[0],T=d.cache;if(T.has(x))return T.get(x);var L=o.apply(this,D);return d.cache=T.set(x,L)||T,L};return d.cache=new(Jo.Cache||en),d}Jo.Cache=en;function Xo(o){if(typeof o!="function")throw new yr(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 GA(o){return rp(2,o)}var KA=$b(function(o,u){u=u.length==1&&Tt(u[0])?de(u[0],fr(At())):de(Pe(u,1),fr(At()));var d=u.length;return Lt(function(D){for(var x=-1,T=We(D.length,d);++x<T;)D[x]=u[x].call(this,D[x]);return lr(o,this,D)})}),al=Lt(function(o,u){var d=xn(u,$i(al));return nn(o,A,e,u,d)}),ap=Lt(function(o,u){var d=xn(u,$i(ap));return nn(o,C,e,u,d)}),HA=sn(function(o,u){return nn(o,S,e,e,e,u)});function JA(o,u){if(typeof o!="function")throw new yr(a);return u=u===e?u:Ot(u),Lt(o,u)}function XA(o,u){if(typeof o!="function")throw new yr(a);return u=u==null?0:Be(Ot(u),0),Lt(function(d){var D=d[u],x=Sn(d,0,u);return D&&An(x,D),lr(o,this,x)})}function VA(o,u,d){var D=!0,x=!0;if(typeof o!="function")throw new yr(a);return _e(d)&&(D="leading"in d?!!d.leading:D,x="trailing"in d?!!d.trailing:x),op(o,u,{leading:D,maxWait:u,trailing:x})}function QA(o){return ep(o,1)}function tx(o,u){return al(ju(u),o)}function ex(){if(!arguments.length)return[];var o=arguments[0];return Tt(o)?o:[o]}function rx(o){return Er(o,v)}function nx(o,u){return u=typeof u=="function"?u:e,Er(o,v,u)}function ix(o){return Er(o,c|v)}function sx(o,u){return u=typeof u=="function"?u:e,Er(o,c|v,u)}function ox(o,u){return u==null||Kh(o,u,$e(u))}function Or(o,u){return o===u||o!==o&&u!==u}var ax=Wo(Tu),ux=Wo(function(o,u){return o>=u}),ei=t0(function(){return arguments}())?t0:function(o){return we(o)&&ne.call(o,"callee")&&!qh.call(o,"callee")},Tt=J.isArray,lx=yh?fr(yh):vb;function Ve(o){return o!=null&&Vo(o.length)&&!an(o)}function be(o){return we(o)&&Ve(o)}function fx(o){return o===!0||o===!1||we(o)&&je(o)==re}var Bn=Ay||_l,cx=bh?fr(bh):_b;function hx(o){return we(o)&&o.nodeType===1&&!ds(o)}function px(o){if(o==null)return!0;if(Ve(o)&&(Tt(o)||typeof o=="string"||typeof o.splice=="function"||Bn(o)||Oi(o)||ei(o)))return!o.length;var u=Ye(o);if(u==Gt||u==or)return!o.size;if(hs(o))return!Ru(o).length;for(var d in o)if(ne.call(o,d))return!1;return!0}function dx(o,u){return ls(o,u)}function mx(o,u,d){d=typeof d=="function"?d:e;var D=d?d(o,u):e;return D===e?ls(o,u,e,d):!!D}function ul(o){if(!we(o))return!1;var u=je(o);return u==ie||u==Mt||typeof o.message=="string"&&typeof o.name=="string"&&!ds(o)}function gx(o){return typeof o=="number"&&kh(o)}function an(o){if(!_e(o))return!1;var u=je(o);return u==Xt||u==zt||u==bt||u==wn}function up(o){return typeof o=="number"&&o==Ot(o)}function Vo(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=G}function _e(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function we(o){return o!=null&&typeof o=="object"}var lp=Eh?fr(Eh):Db;function vx(o,u){return o===u||Ou(o,u,Vu(u))}function _x(o,u,d){return d=typeof d=="function"?d:e,Ou(o,u,Vu(u),d)}function wx(o){return fp(o)&&o!=+o}function Dx(o){if(nE(o))throw new Bt(s);return e0(o)}function yx(o){return o===null}function bx(o){return o==null}function fp(o){return typeof o=="number"||we(o)&&je(o)==Ce}function ds(o){if(!we(o)||je(o)!=Me)return!1;var u=xo(o);if(u===null)return!0;var d=ne.call(u,"constructor")&&u.constructor;return typeof d=="function"&&d instanceof d&&yo.call(d)==_y}var ll=Ah?fr(Ah):yb;function Ex(o){return up(o)&&o>=-G&&o<=G}var cp=xh?fr(xh):bb;function Qo(o){return typeof o=="string"||!Tt(o)&&we(o)&&je(o)==Dn}function hr(o){return typeof o=="symbol"||we(o)&&je(o)==O}var Oi=Ch?fr(Ch):Eb;function Ax(o){return o===e}function xx(o){return we(o)&&Ye(o)==H}function Cx(o){return we(o)&&je(o)==nt}var Fx=Wo(Lu),Mx=Wo(function(o,u){return o<=u});function hp(o){if(!o)return[];if(Ve(o))return Qo(o)?Tr(o):Xe(o);if(es&&o[es])return oy(o[es]());var u=Ye(o),d=u==Gt?Au:u==or?_o:Ri;return d(o)}function un(o){if(!o)return o===0?o:0;if(o=Cr(o),o===K||o===-K){var u=o<0?-1:1;return u*V}return o===o?o:0}function Ot(o){var u=un(o),d=u%1;return u===u?d?u-d:u:0}function pp(o){return o?Xn(Ot(o),0,ft):0}function Cr(o){if(typeof o=="number")return o;if(hr(o))return tt;if(_e(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=_e(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=Ih(o);var d=nu.test(o);return d||su.test(o)?WD(o.slice(2),d?2:8):ru.test(o)?tt:+o}function dp(o){return jr(o,Qe(o))}function Nx(o){return o?Xn(Ot(o),-G,G):o===0?o:0}function Qt(o){return o==null?"":cr(o)}var Sx=Ii(function(o,u){if(hs(u)||Ve(u)){jr(u,$e(u),o);return}for(var d in u)ne.call(u,d)&&os(o,d,u[d])}),mp=Ii(function(o,u){jr(u,Qe(u),o)}),ta=Ii(function(o,u,d,D){jr(u,Qe(u),o,D)}),Bx=Ii(function(o,u,d,D){jr(u,$e(u),o,D)}),Ix=sn(Su);function Tx(o,u){var d=Bi(o);return u==null?d:Gh(d,u)}var $x=Lt(function(o,u){o=ae(o);var d=-1,D=u.length,x=D>2?u[2]:e;for(x&&Ze(u[0],u[1],x)&&(D=1);++d<D;)for(var T=u[d],L=Qe(T),z=-1,Y=L.length;++z<Y;){var Q=L[z],et=o[Q];(et===e||Or(et,Mi[Q])&&!ne.call(o,Q))&&(o[Q]=T[Q])}return o}),Ox=Lt(function(o){return o.push(e,I0),lr(gp,e,o)});function Rx(o,u){return Mh(o,At(u,3),Yr)}function Lx(o,u){return Mh(o,At(u,3),Iu)}function Px(o,u){return o==null?o:Bu(o,At(u,3),Qe)}function zx(o,u){return o==null?o:Vh(o,At(u,3),Qe)}function qx(o,u){return o&&Yr(o,At(u,3))}function Ux(o,u){return o&&Iu(o,At(u,3))}function kx(o){return o==null?[]:Oo(o,$e(o))}function Wx(o){return o==null?[]:Oo(o,Qe(o))}function fl(o,u,d){var D=o==null?e:Vn(o,u);return D===e?d:D}function Yx(o,u){return o!=null&&O0(o,u,pb)}function cl(o,u){return o!=null&&O0(o,u,db)}var jx=F0(function(o,u,d){u!=null&&typeof u.toString!="function"&&(u=bo.call(u)),o[u]=d},pl(tr)),Zx=F0(function(o,u,d){u!=null&&typeof u.toString!="function"&&(u=bo.call(u)),ne.call(o,u)?o[u].push(d):o[u]=[d]},At),Gx=Lt(us);function $e(o){return Ve(o)?jh(o):Ru(o)}function Qe(o){return Ve(o)?jh(o,!0):Ab(o)}function Kx(o,u){var d={};return u=At(u,3),Yr(o,function(D,x,T){rn(d,u(D,x,T),D)}),d}function Hx(o,u){var d={};return u=At(u,3),Yr(o,function(D,x,T){rn(d,x,u(D,x,T))}),d}var Jx=Ii(function(o,u,d){Ro(o,u,d)}),gp=Ii(function(o,u,d,D){Ro(o,u,d,D)}),Xx=sn(function(o,u){var d={};if(o==null)return d;var D=!1;u=de(u,function(T){return T=Nn(T,o),D||(D=T.length>1),T}),jr(o,Ju(o),d),D&&(d=Er(d,c|m|v,jb));for(var x=u.length;x--;)ku(d,u[x]);return d});function Vx(o,u){return vp(o,Xo(At(u)))}var Qx=sn(function(o,u){return o==null?{}:Cb(o,u)});function vp(o,u){if(o==null)return{};var d=de(Ju(o),function(D){return[D]});return u=At(u),u0(o,d,function(D,x){return u(D,x[0])})}function tC(o,u,d){u=Nn(u,o);var D=-1,x=u.length;for(x||(x=1,o=e);++D<x;){var T=o==null?e:o[Zr(u[D])];T===e&&(D=x,T=d),o=an(T)?T.call(o):T}return o}function eC(o,u,d){return o==null?o:fs(o,u,d)}function rC(o,u,d,D){return D=typeof D=="function"?D:e,o==null?o:fs(o,u,d,D)}var _p=S0($e),wp=S0(Qe);function nC(o,u,d){var D=Tt(o),x=D||Bn(o)||Oi(o);if(u=At(u,4),d==null){var T=o&&o.constructor;x?d=D?new T:[]:_e(o)?d=an(T)?Bi(xo(o)):{}:d={}}return(x?Dr:Yr)(o,function(L,z,Y){return u(d,L,z,Y)}),d}function iC(o,u){return o==null?!0:ku(o,u)}function sC(o,u,d){return o==null?o:p0(o,u,ju(d))}function oC(o,u,d,D){return D=typeof D=="function"?D:e,o==null?o:p0(o,u,ju(d),D)}function Ri(o){return o==null?[]:Eu(o,$e(o))}function aC(o){return o==null?[]:Eu(o,Qe(o))}function uC(o,u,d){return d===e&&(d=u,u=e),d!==e&&(d=Cr(d),d=d===d?d:0),u!==e&&(u=Cr(u),u=u===u?u:0),Xn(Cr(o),u,d)}function lC(o,u,d){return u=un(u),d===e?(d=u,u=0):d=un(d),o=Cr(o),mb(o,u,d)}function fC(o,u,d){if(d&&typeof d!="boolean"&&Ze(o,u,d)&&(u=d=e),d===e&&(typeof u=="boolean"?(d=u,u=e):typeof o=="boolean"&&(d=o,o=e)),o===e&&u===e?(o=0,u=1):(o=un(o),u===e?(u=o,o=0):u=un(u)),o>u){var D=o;o=u,u=D}if(d||o%1||u%1){var x=Wh();return We(o+x*(u-o+kD("1e-"+((x+"").length-1))),u)}return zu(o,u)}var cC=Ti(function(o,u,d){return u=u.toLowerCase(),o+(d?Dp(u):u)});function Dp(o){return hl(Qt(o).toLowerCase())}function yp(o){return o=Qt(o),o&&o.replace(au,ey).replace(ID,"")}function hC(o,u,d){o=Qt(o),u=cr(u);var D=o.length;d=d===e?D:Xn(Ot(d),0,D);var x=d;return d-=u.length,d>=0&&o.slice(d,x)==u}function pC(o){return o=Qt(o),o&&Ua.test(o)?o.replace(fo,ry):o}function dC(o){return o=Qt(o),o&&Ga.test(o)?o.replace(Vi,"\\$&"):o}var mC=Ti(function(o,u,d){return o+(d?"-":"")+u.toLowerCase()}),gC=Ti(function(o,u,d){return o+(d?" ":"")+u.toLowerCase()}),vC=A0("toLowerCase");function _C(o,u,d){o=Qt(o),u=Ot(u);var D=u?Ci(o):0;if(!u||D>=u)return o;var x=(u-D)/2;return ko(No(x),d)+o+ko(Mo(x),d)}function wC(o,u,d){o=Qt(o),u=Ot(u);var D=u?Ci(o):0;return u&&D<u?o+ko(u-D,d):o}function DC(o,u,d){o=Qt(o),u=Ot(u);var D=u?Ci(o):0;return u&&D<u?ko(u-D,d)+o:o}function yC(o,u,d){return d||u==null?u=0:u&&(u=+u),My(Qt(o).replace(Qi,""),u||0)}function bC(o,u,d){return(d?Ze(o,u,d):u===e)?u=1:u=Ot(u),qu(Qt(o),u)}function EC(){var o=arguments,u=Qt(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var AC=Ti(function(o,u,d){return o+(d?"_":"")+u.toLowerCase()});function xC(o,u,d){return d&&typeof d!="number"&&Ze(o,u,d)&&(u=d=e),d=d===e?ft:d>>>0,d?(o=Qt(o),o&&(typeof u=="string"||u!=null&&!ll(u))&&(u=cr(u),!u&&xi(o))?Sn(Tr(o),0,d):o.split(u,d)):[]}var CC=Ti(function(o,u,d){return o+(d?" ":"")+hl(u)});function FC(o,u,d){return o=Qt(o),d=d==null?0:Xn(Ot(d),0,o.length),u=cr(u),o.slice(d,d+u.length)==u}function MC(o,u,d){var D=B.templateSettings;d&&Ze(o,u,d)&&(u=e),o=Qt(o),u=ta({},u,D,B0);var x=ta({},u.imports,D.imports,B0),T=$e(x),L=Eu(x,T),z,Y,Q=0,et=u.interpolate||yi,ot="__p += '",dt=xu((u.escape||yi).source+"|"+et.source+"|"+(et===co?eu:yi).source+"|"+(u.evaluate||yi).source+"|$","g"),_t="//# sourceURL="+(ne.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++LD+"]")+`
11
- `;o.replace(dt,function(Ct,qt,kt,pr,Ge,dr){return kt||(kt=pr),ot+=o.slice(Q,dr).replace(Zn,ny),qt&&(z=!0,ot+=`' +
12
- __e(`+qt+`) +
13
- '`),Ge&&(Y=!0,ot+=`';
14
- `+Ge+`;
15
- __p += '`),kt&&(ot+=`' +
16
- ((__t = (`+kt+`)) == null ? '' : __t) +
17
- '`),Q=dr+Ct.length,Ct}),ot+=`';
18
- `;var xt=ne.call(u,"variable")&&u.variable;if(!xt)ot=`with (obj) {
19
- `+ot+`
20
- }
21
- `;else if(Qa.test(xt))throw new Bt(l);ot=(Y?ot.replace(ar,""):ot).replace(ur,"$1").replace(yn,"$1;"),ot="function("+(xt||"obj")+`) {
22
- `+(xt?"":`obj || (obj = {});
23
- `)+"var __t, __p = ''"+(z?", __e = _.escape":"")+(Y?`, __j = Array.prototype.join;
24
- function print() { __p += __j.call(arguments, '') }
25
- `:`;
26
- `)+ot+`return __p
27
- }`;var Rt=Ep(function(){return Ht(T,_t+"return "+ot).apply(e,L)});if(Rt.source=ot,ul(Rt))throw Rt;return Rt}function NC(o){return Qt(o).toLowerCase()}function SC(o){return Qt(o).toUpperCase()}function BC(o,u,d){if(o=Qt(o),o&&(d||u===e))return Ih(o);if(!o||!(u=cr(u)))return o;var D=Tr(o),x=Tr(u),T=Th(D,x),L=$h(D,x)+1;return Sn(D,T,L).join("")}function IC(o,u,d){if(o=Qt(o),o&&(d||u===e))return o.slice(0,Rh(o)+1);if(!o||!(u=cr(u)))return o;var D=Tr(o),x=$h(D,Tr(u))+1;return Sn(D,0,x).join("")}function TC(o,u,d){if(o=Qt(o),o&&(d||u===e))return o.replace(Qi,"");if(!o||!(u=cr(u)))return o;var D=Tr(o),x=Th(D,Tr(u));return Sn(D,x).join("")}function $C(o,u){var d=F,D=I;if(_e(u)){var x="separator"in u?u.separator:x;d="length"in u?Ot(u.length):d,D="omission"in u?cr(u.omission):D}o=Qt(o);var T=o.length;if(xi(o)){var L=Tr(o);T=L.length}if(d>=T)return o;var z=d-Ci(D);if(z<1)return D;var Y=L?Sn(L,0,z).join(""):o.slice(0,z);if(x===e)return Y+D;if(L&&(z+=Y.length-z),ll(x)){if(o.slice(z).search(x)){var Q,et=Y;for(x.global||(x=xu(x.source,Qt(ho.exec(x))+"g")),x.lastIndex=0;Q=x.exec(et);)var ot=Q.index;Y=Y.slice(0,ot===e?z:ot)}}else if(o.indexOf(cr(x),z)!=z){var dt=Y.lastIndexOf(x);dt>-1&&(Y=Y.slice(0,dt))}return Y+D}function OC(o){return o=Qt(o),o&&qa.test(o)?o.replace(jn,fy):o}var RC=Ti(function(o,u,d){return o+(d?" ":"")+u.toUpperCase()}),hl=A0("toUpperCase");function bp(o,u,d){return o=Qt(o),u=d?e:u,u===e?sy(o)?py(o):JD(o):o.match(u)||[]}var Ep=Lt(function(o,u){try{return lr(o,e,u)}catch(d){return ul(d)?d:new Bt(d)}}),LC=sn(function(o,u){return Dr(u,function(d){d=Zr(d),rn(o,d,ol(o[d],o))}),o});function PC(o){var u=o==null?0:o.length,d=At();return o=u?de(o,function(D){if(typeof D[1]!="function")throw new yr(a);return[d(D[0]),D[1]]}):[],Lt(function(D){for(var x=-1;++x<u;){var T=o[x];if(lr(T[0],this,D))return lr(T[1],this,D)}})}function zC(o){return fb(Er(o,c))}function pl(o){return function(){return o}}function qC(o,u){return o==null||o!==o?u:o}var UC=C0(),kC=C0(!0);function tr(o){return o}function dl(o){return r0(typeof o=="function"?o:Er(o,c))}function WC(o){return i0(Er(o,c))}function YC(o,u){return s0(o,Er(u,c))}var jC=Lt(function(o,u){return function(d){return us(d,o,u)}}),ZC=Lt(function(o,u){return function(d){return us(o,d,u)}});function ml(o,u,d){var D=$e(u),x=Oo(u,D);d==null&&!(_e(u)&&(x.length||!D.length))&&(d=u,u=o,o=this,x=Oo(u,$e(u)));var T=!(_e(d)&&"chain"in d)||!!d.chain,L=an(o);return Dr(x,function(z){var Y=u[z];o[z]=Y,L&&(o.prototype[z]=function(){var Q=this.__chain__;if(T||Q){var et=o(this.__wrapped__),ot=et.__actions__=Xe(this.__actions__);return ot.push({func:Y,args:arguments,thisArg:o}),et.__chain__=Q,et}return Y.apply(o,An([this.value()],arguments))})}),o}function GC(){return Le._===this&&(Le._=wy),this}function gl(){}function KC(o){return o=Ot(o),Lt(function(u){return o0(u,o)})}var HC=Gu(de),JC=Gu(Fh),XC=Gu(_u);function Ap(o){return tl(o)?wu(Zr(o)):Fb(o)}function VC(o){return function(u){return o==null?e:Vn(o,u)}}var QC=M0(),t2=M0(!0);function vl(){return[]}function _l(){return!1}function e2(){return{}}function r2(){return""}function n2(){return!0}function i2(o,u){if(o=Ot(o),o<1||o>G)return[];var d=ft,D=We(o,ft);u=At(u),o-=ft;for(var x=bu(D,u);++d<o;)u(d);return x}function s2(o){return Tt(o)?de(o,Zr):hr(o)?[o]:Xe(Y0(Qt(o)))}function o2(o){var u=++vy;return Qt(o)+u}var a2=Uo(function(o,u){return o+u},0),u2=Ku("ceil"),l2=Uo(function(o,u){return o/u},1),f2=Ku("floor");function c2(o){return o&&o.length?$o(o,tr,Tu):e}function h2(o,u){return o&&o.length?$o(o,At(u,2),Tu):e}function p2(o){return Sh(o,tr)}function d2(o,u){return Sh(o,At(u,2))}function m2(o){return o&&o.length?$o(o,tr,Lu):e}function g2(o,u){return o&&o.length?$o(o,At(u,2),Lu):e}var v2=Uo(function(o,u){return o*u},1),_2=Ku("round"),w2=Uo(function(o,u){return o-u},0);function D2(o){return o&&o.length?yu(o,tr):0}function y2(o,u){return o&&o.length?yu(o,At(u,2)):0}return B.after=WA,B.ary=ep,B.assign=Sx,B.assignIn=mp,B.assignInWith=ta,B.assignWith=Bx,B.at=Ix,B.before=rp,B.bind=ol,B.bindAll=LC,B.bindKey=np,B.castArray=ex,B.chain=V0,B.chunk=fE,B.compact=cE,B.concat=hE,B.cond=PC,B.conforms=zC,B.constant=pl,B.countBy=DA,B.create=Tx,B.curry=ip,B.curryRight=sp,B.debounce=op,B.defaults=$x,B.defaultsDeep=Ox,B.defer=YA,B.delay=jA,B.difference=pE,B.differenceBy=dE,B.differenceWith=mE,B.drop=gE,B.dropRight=vE,B.dropRightWhile=_E,B.dropWhile=wE,B.fill=DE,B.filter=bA,B.flatMap=xA,B.flatMapDeep=CA,B.flatMapDepth=FA,B.flatten=K0,B.flattenDeep=yE,B.flattenDepth=bE,B.flip=ZA,B.flow=UC,B.flowRight=kC,B.fromPairs=EE,B.functions=kx,B.functionsIn=Wx,B.groupBy=MA,B.initial=xE,B.intersection=CE,B.intersectionBy=FE,B.intersectionWith=ME,B.invert=jx,B.invertBy=Zx,B.invokeMap=SA,B.iteratee=dl,B.keyBy=BA,B.keys=$e,B.keysIn=Qe,B.map=Ko,B.mapKeys=Kx,B.mapValues=Hx,B.matches=WC,B.matchesProperty=YC,B.memoize=Jo,B.merge=Jx,B.mergeWith=gp,B.method=jC,B.methodOf=ZC,B.mixin=ml,B.negate=Xo,B.nthArg=KC,B.omit=Xx,B.omitBy=Vx,B.once=GA,B.orderBy=IA,B.over=HC,B.overArgs=KA,B.overEvery=JC,B.overSome=XC,B.partial=al,B.partialRight=ap,B.partition=TA,B.pick=Qx,B.pickBy=vp,B.property=Ap,B.propertyOf=VC,B.pull=IE,B.pullAll=J0,B.pullAllBy=TE,B.pullAllWith=$E,B.pullAt=OE,B.range=QC,B.rangeRight=t2,B.rearg=HA,B.reject=RA,B.remove=RE,B.rest=JA,B.reverse=il,B.sampleSize=PA,B.set=eC,B.setWith=rC,B.shuffle=zA,B.slice=LE,B.sortBy=kA,B.sortedUniq=YE,B.sortedUniqBy=jE,B.split=xC,B.spread=XA,B.tail=ZE,B.take=GE,B.takeRight=KE,B.takeRightWhile=HE,B.takeWhile=JE,B.tap=cA,B.throttle=VA,B.thru=Go,B.toArray=hp,B.toPairs=_p,B.toPairsIn=wp,B.toPath=s2,B.toPlainObject=dp,B.transform=nC,B.unary=QA,B.union=XE,B.unionBy=VE,B.unionWith=QE,B.uniq=tA,B.uniqBy=eA,B.uniqWith=rA,B.unset=iC,B.unzip=sl,B.unzipWith=X0,B.update=sC,B.updateWith=oC,B.values=Ri,B.valuesIn=aC,B.without=nA,B.words=bp,B.wrap=tx,B.xor=iA,B.xorBy=sA,B.xorWith=oA,B.zip=aA,B.zipObject=uA,B.zipObjectDeep=lA,B.zipWith=fA,B.entries=_p,B.entriesIn=wp,B.extend=mp,B.extendWith=ta,ml(B,B),B.add=a2,B.attempt=Ep,B.camelCase=cC,B.capitalize=Dp,B.ceil=u2,B.clamp=uC,B.clone=rx,B.cloneDeep=ix,B.cloneDeepWith=sx,B.cloneWith=nx,B.conformsTo=ox,B.deburr=yp,B.defaultTo=qC,B.divide=l2,B.endsWith=hC,B.eq=Or,B.escape=pC,B.escapeRegExp=dC,B.every=yA,B.find=EA,B.findIndex=Z0,B.findKey=Rx,B.findLast=AA,B.findLastIndex=G0,B.findLastKey=Lx,B.floor=f2,B.forEach=Q0,B.forEachRight=tp,B.forIn=Px,B.forInRight=zx,B.forOwn=qx,B.forOwnRight=Ux,B.get=fl,B.gt=ax,B.gte=ux,B.has=Yx,B.hasIn=cl,B.head=H0,B.identity=tr,B.includes=NA,B.indexOf=AE,B.inRange=lC,B.invoke=Gx,B.isArguments=ei,B.isArray=Tt,B.isArrayBuffer=lx,B.isArrayLike=Ve,B.isArrayLikeObject=be,B.isBoolean=fx,B.isBuffer=Bn,B.isDate=cx,B.isElement=hx,B.isEmpty=px,B.isEqual=dx,B.isEqualWith=mx,B.isError=ul,B.isFinite=gx,B.isFunction=an,B.isInteger=up,B.isLength=Vo,B.isMap=lp,B.isMatch=vx,B.isMatchWith=_x,B.isNaN=wx,B.isNative=Dx,B.isNil=bx,B.isNull=yx,B.isNumber=fp,B.isObject=_e,B.isObjectLike=we,B.isPlainObject=ds,B.isRegExp=ll,B.isSafeInteger=Ex,B.isSet=cp,B.isString=Qo,B.isSymbol=hr,B.isTypedArray=Oi,B.isUndefined=Ax,B.isWeakMap=xx,B.isWeakSet=Cx,B.join=NE,B.kebabCase=mC,B.last=xr,B.lastIndexOf=SE,B.lowerCase=gC,B.lowerFirst=vC,B.lt=Fx,B.lte=Mx,B.max=c2,B.maxBy=h2,B.mean=p2,B.meanBy=d2,B.min=m2,B.minBy=g2,B.stubArray=vl,B.stubFalse=_l,B.stubObject=e2,B.stubString=r2,B.stubTrue=n2,B.multiply=v2,B.nth=BE,B.noConflict=GC,B.noop=gl,B.now=Ho,B.pad=_C,B.padEnd=wC,B.padStart=DC,B.parseInt=yC,B.random=fC,B.reduce=$A,B.reduceRight=OA,B.repeat=bC,B.replace=EC,B.result=tC,B.round=_2,B.runInContext=W,B.sample=LA,B.size=qA,B.snakeCase=AC,B.some=UA,B.sortedIndex=PE,B.sortedIndexBy=zE,B.sortedIndexOf=qE,B.sortedLastIndex=UE,B.sortedLastIndexBy=kE,B.sortedLastIndexOf=WE,B.startCase=CC,B.startsWith=FC,B.subtract=w2,B.sum=D2,B.sumBy=y2,B.template=MC,B.times=i2,B.toFinite=un,B.toInteger=Ot,B.toLength=pp,B.toLower=NC,B.toNumber=Cr,B.toSafeInteger=Nx,B.toString=Qt,B.toUpper=SC,B.trim=BC,B.trimEnd=IC,B.trimStart=TC,B.truncate=$C,B.unescape=OC,B.uniqueId=o2,B.upperCase=RC,B.upperFirst=hl,B.each=Q0,B.eachRight=tp,B.first=H0,ml(B,function(){var o={};return Yr(B,function(u,d){ne.call(B.prototype,d)||(o[d]=u)}),o}(),{chain:!1}),B.VERSION=r,Dr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){B[o].placeholder=B}),Dr(["drop","take"],function(o,u){Ut.prototype[o]=function(d){d=d===e?1:Be(Ot(d),0);var D=this.__filtered__&&!u?new Ut(this):this.clone();return D.__filtered__?D.__takeCount__=We(d,D.__takeCount__):D.__views__.push({size:We(d,ft),type:o+(D.__dir__<0?"Right":"")}),D},Ut.prototype[o+"Right"]=function(d){return this.reverse()[o](d).reverse()}}),Dr(["filter","map","takeWhile"],function(o,u){var d=u+1,D=d==q||d==P;Ut.prototype[o]=function(x){var T=this.clone();return T.__iteratees__.push({iteratee:At(x,3),type:d}),T.__filtered__=T.__filtered__||D,T}}),Dr(["head","last"],function(o,u){var d="take"+(u?"Right":"");Ut.prototype[o]=function(){return this[d](1).value()[0]}}),Dr(["initial","tail"],function(o,u){var d="drop"+(u?"":"Right");Ut.prototype[o]=function(){return this.__filtered__?new Ut(this):this[d](1)}}),Ut.prototype.compact=function(){return this.filter(tr)},Ut.prototype.find=function(o){return this.filter(o).head()},Ut.prototype.findLast=function(o){return this.reverse().find(o)},Ut.prototype.invokeMap=Lt(function(o,u){return typeof o=="function"?new Ut(this):this.map(function(d){return us(d,o,u)})}),Ut.prototype.reject=function(o){return this.filter(Xo(At(o)))},Ut.prototype.slice=function(o,u){o=Ot(o);var d=this;return d.__filtered__&&(o>0||u<0)?new Ut(d):(o<0?d=d.takeRight(-o):o&&(d=d.drop(o)),u!==e&&(u=Ot(u),d=u<0?d.dropRight(-u):d.take(u-o)),d)},Ut.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},Ut.prototype.toArray=function(){return this.take(ft)},Yr(Ut.prototype,function(o,u){var d=/^(?:filter|find|map|reject)|While$/.test(u),D=/^(?:head|last)$/.test(u),x=B[D?"take"+(u=="last"?"Right":""):u],T=D||/^find/.test(u);x&&(B.prototype[u]=function(){var L=this.__wrapped__,z=D?[1]:arguments,Y=L instanceof Ut,Q=z[0],et=Y||Tt(L),ot=function(qt){var kt=x.apply(B,An([qt],z));return D&&dt?kt[0]:kt};et&&d&&typeof Q=="function"&&Q.length!=1&&(Y=et=!1);var dt=this.__chain__,_t=!!this.__actions__.length,xt=T&&!dt,Rt=Y&&!_t;if(!T&&et){L=Rt?L:new Ut(this);var Ct=o.apply(L,z);return Ct.__actions__.push({func:Go,args:[ot],thisArg:e}),new br(Ct,dt)}return xt&&Rt?o.apply(this,z):(Ct=this.thru(ot),xt?D?Ct.value()[0]:Ct.value():Ct)})}),Dr(["pop","push","shift","sort","splice","unshift"],function(o){var u=wo[o],d=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);B.prototype[o]=function(){var x=arguments;if(D&&!this.__chain__){var T=this.value();return u.apply(Tt(T)?T:[],x)}return this[d](function(L){return u.apply(Tt(L)?L:[],x)})}}),Yr(Ut.prototype,function(o,u){var d=B[u];if(d){var D=d.name+"";ne.call(Si,D)||(Si[D]=[]),Si[D].push({name:u,func:d})}}),Si[qo(e,_).name]=[{name:"wrapper",func:e}],Ut.prototype.clone=Oy,Ut.prototype.reverse=Ry,Ut.prototype.value=Ly,B.prototype.at=hA,B.prototype.chain=pA,B.prototype.commit=dA,B.prototype.next=mA,B.prototype.plant=vA,B.prototype.reverse=_A,B.prototype.toJSON=B.prototype.valueOf=B.prototype.value=wA,B.prototype.first=B.prototype.head,es&&(B.prototype[es]=gA),B},Fi=dy();Gn?((Gn.exports=Fi)._=Fi,du._=Fi):Le._=Fi}).call(Wt)}(In,In.exports);var Fr=In.exports;class Cp{constructor(t,e){Z(this,"_defaultParams");Z(this,"_UserTypeFileds");Z(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Fr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Fr.cloneDeep(this._defaultParams),t),this._varipKeys)}addNewMethod(t,e){this._UserTypeFileds.prototype[t]=e}_createDynamicClass(){return class{constructor(t,e){Z(this,"_varipKeys");Object.assign(this,t),this._varipKeys=e}get varipKeys(){return[...this._varipKeys]}copy(){return Fr.cloneDeep(this)}}}}var El={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,function(){var e=1e3,r=6e4,n=36e5,s="millisecond",a="second",l="minute",f="hour",h="day",p="week",c="month",m="quarter",v="year",w="date",g="Invalid Date",y=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,_=/\[([^\]]+)]|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(q){var k=["th","st","nd","rd"],P=q%100;return"["+q+(k[(P-20)%10]||k[P]||k[0])+"]"}},b=function(q,k,P){var K=String(q);return!K||K.length>=k?q:""+Array(k+1-K.length).join(P)+q},N={s:b,z:function(q){var k=-q.utcOffset(),P=Math.abs(k),K=Math.floor(P/60),G=P%60;return(k<=0?"+":"-")+b(K,2,"0")+":"+b(G,2,"0")},m:function q(k,P){if(k.date()<P.date())return-q(P,k);var K=12*(P.year()-k.year())+(P.month()-k.month()),G=k.clone().add(K,c),V=P-G<0,tt=k.clone().add(K+(V?-1:1),c);return+(-(K+(P-G)/(V?G-tt:tt-G))||0)},a:function(q){return q<0?Math.ceil(q)||0:Math.floor(q)},p:function(q){return{M:c,y:v,w:p,d:h,D:w,h:f,m:l,s:a,ms:s,Q:m}[q]||String(q||"").toLowerCase().replace(/s$/,"")},u:function(q){return q===void 0}},A="en",C={};C[A]=E;var M="$isDayjsObject",S=function(q){return q instanceof R||!(!q||!q[M])},$=function q(k,P,K){var G;if(!k)return A;if(typeof k=="string"){var V=k.toLowerCase();C[V]&&(G=V),P&&(C[V]=P,G=V);var tt=k.split("-");if(!G&&tt.length>1)return q(tt[0])}else{var ft=k.name;C[ft]=k,G=ft}return!K&&G&&(A=G),G||!K&&A},F=function(q,k){if(S(q))return q.clone();var P=typeof k=="object"?k:{};return P.date=q,P.args=arguments,new R(P)},I=N;I.l=$,I.i=S,I.w=function(q,k){return F(q,{locale:k.$L,utc:k.$u,x:k.$x,$offset:k.$offset})};var R=function(){function q(P){this.$L=$(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[M]=!0}var k=q.prototype;return k.parse=function(P){this.$d=function(K){var G=K.date,V=K.utc;if(G===null)return new Date(NaN);if(I.u(G))return new Date;if(G instanceof Date)return new Date(G);if(typeof G=="string"&&!/Z$/i.test(G)){var tt=G.match(y);if(tt){var ft=tt[2]-1||0,vt=(tt[7]||"0").substring(0,3);return V?new Date(Date.UTC(tt[1],ft,tt[3]||1,tt[4]||0,tt[5]||0,tt[6]||0,vt)):new Date(tt[1],ft,tt[3]||1,tt[4]||0,tt[5]||0,tt[6]||0,vt)}}return new Date(G)}(P),this.init()},k.init=function(){var P=this.$d;this.$y=P.getFullYear(),this.$M=P.getMonth(),this.$D=P.getDate(),this.$W=P.getDay(),this.$H=P.getHours(),this.$m=P.getMinutes(),this.$s=P.getSeconds(),this.$ms=P.getMilliseconds()},k.$utils=function(){return I},k.isValid=function(){return this.$d.toString()!==g},k.isSame=function(P,K){var G=F(P);return this.startOf(K)<=G&&G<=this.endOf(K)},k.isAfter=function(P,K){return F(P)<this.startOf(K)},k.isBefore=function(P,K){return this.endOf(K)<F(P)},k.$g=function(P,K,G){return I.u(P)?this[K]:this.set(G,P)},k.unix=function(){return Math.floor(this.valueOf()/1e3)},k.valueOf=function(){return this.$d.getTime()},k.startOf=function(P,K){var G=this,V=!!I.u(K)||K,tt=I.p(P),ft=function(It,Mt){var ie=I.w(G.$u?Date.UTC(G.$y,Mt,It):new Date(G.$y,Mt,It),G);return V?ie:ie.endOf(h)},vt=function(It,Mt){return I.w(G.toDate()[It].apply(G.toDate("s"),(V?[0,0,0,0]:[23,59,59,999]).slice(Mt)),G)},lt=this.$W,wt=this.$M,yt=this.$D,St="set"+(this.$u?"UTC":"");switch(tt){case v:return V?ft(1,0):ft(31,11);case c:return V?ft(1,wt):ft(0,wt+1);case p:var bt=this.$locale().weekStart||0,re=(lt<bt?lt+7:lt)-bt;return ft(V?yt-re:yt+(6-re),wt);case h:case w:return vt(St+"Hours",0);case f:return vt(St+"Minutes",1);case l:return vt(St+"Seconds",2);case a:return vt(St+"Milliseconds",3);default:return this.clone()}},k.endOf=function(P){return this.startOf(P,!1)},k.$set=function(P,K){var G,V=I.p(P),tt="set"+(this.$u?"UTC":""),ft=(G={},G[h]=tt+"Date",G[w]=tt+"Date",G[c]=tt+"Month",G[v]=tt+"FullYear",G[f]=tt+"Hours",G[l]=tt+"Minutes",G[a]=tt+"Seconds",G[s]=tt+"Milliseconds",G)[V],vt=V===h?this.$D+(K-this.$W):K;if(V===c||V===v){var lt=this.clone().set(w,1);lt.$d[ft](vt),lt.init(),this.$d=lt.set(w,Math.min(this.$D,lt.daysInMonth())).$d}else ft&&this.$d[ft](vt);return this.init(),this},k.set=function(P,K){return this.clone().$set(P,K)},k.get=function(P){return this[I.p(P)]()},k.add=function(P,K){var G,V=this;P=Number(P);var tt=I.p(K),ft=function(wt){var yt=F(V);return I.w(yt.date(yt.date()+Math.round(wt*P)),V)};if(tt===c)return this.set(c,this.$M+P);if(tt===v)return this.set(v,this.$y+P);if(tt===h)return ft(1);if(tt===p)return ft(7);var vt=(G={},G[l]=r,G[f]=n,G[a]=e,G)[tt]||1,lt=this.$d.getTime()+P*vt;return I.w(lt,this)},k.subtract=function(P,K){return this.add(-1*P,K)},k.format=function(P){var K=this,G=this.$locale();if(!this.isValid())return G.invalidDate||g;var V=P||"YYYY-MM-DDTHH:mm:ssZ",tt=I.z(this),ft=this.$H,vt=this.$m,lt=this.$M,wt=G.weekdays,yt=G.months,St=G.meridiem,bt=function(Mt,ie,Xt,zt){return Mt&&(Mt[ie]||Mt(K,V))||Xt[ie].slice(0,zt)},re=function(Mt){return I.s(ft%12||12,Mt,"0")},It=St||function(Mt,ie,Xt){var zt=Mt<12?"AM":"PM";return Xt?zt.toLowerCase():zt};return V.replace(_,function(Mt,ie){return ie||function(Xt){switch(Xt){case"YY":return String(K.$y).slice(-2);case"YYYY":return I.s(K.$y,4,"0");case"M":return lt+1;case"MM":return I.s(lt+1,2,"0");case"MMM":return bt(G.monthsShort,lt,yt,3);case"MMMM":return bt(yt,lt);case"D":return K.$D;case"DD":return I.s(K.$D,2,"0");case"d":return String(K.$W);case"dd":return bt(G.weekdaysMin,K.$W,wt,2);case"ddd":return bt(G.weekdaysShort,K.$W,wt,3);case"dddd":return wt[K.$W];case"H":return String(ft);case"HH":return I.s(ft,2,"0");case"h":return re(1);case"hh":return re(2);case"a":return It(ft,vt,!0);case"A":return It(ft,vt,!1);case"m":return String(vt);case"mm":return I.s(vt,2,"0");case"s":return String(K.$s);case"ss":return I.s(K.$s,2,"0");case"SSS":return I.s(K.$ms,3,"0");case"Z":return tt}return null}(Mt)||tt.replace(":","")})},k.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},k.diff=function(P,K,G){var V,tt=this,ft=I.p(K),vt=F(P),lt=(vt.utcOffset()-this.utcOffset())*r,wt=this-vt,yt=function(){return I.m(tt,vt)};switch(ft){case v:V=yt()/12;break;case c:V=yt();break;case m:V=yt()/3;break;case p:V=(wt-lt)/6048e5;break;case h:V=(wt-lt)/864e5;break;case f:V=wt/n;break;case l:V=wt/r;break;case a:V=wt/e;break;default:V=wt}return G?V:I.a(V)},k.daysInMonth=function(){return this.endOf(c).$D},k.$locale=function(){return C[this.$L]},k.locale=function(P,K){if(!P)return this.$L;var G=this.clone(),V=$(P,K,!0);return V&&(G.$L=V),G},k.clone=function(){return I.w(this.$d,this)},k.toDate=function(){return new Date(this.valueOf())},k.toJSON=function(){return this.isValid()?this.toISOString():null},k.toISOString=function(){return this.$d.toISOString()},k.toString=function(){return this.$d.toUTCString()},q}(),U=R.prototype;return F.prototype=U,[["$ms",s],["$s",a],["$m",l],["$H",f],["$W",h],["$M",c],["$y",v],["$D",w]].forEach(function(q){U[q[1]]=function(k){return this.$g(k,q[0],q[1])}}),F.extend=function(q,k){return q.$i||(q(k,R,F),q.$i=!0),F},F.locale=$,F.isDayjs=S,F.unix=function(q){return F(1e3*q)},F.en=C[A],F.Ls=C,F.p={},F})})(El);var Fp=El.exports,te=jt(Fp),Al={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(s,a,l){var f=a.prototype;l.utc=function(g){var y={date:g,utc:!0,args:arguments};return new a(y)},f.utc=function(g){var y=l(this.toDate(),{locale:this.$L,utc:!0});return g?y.add(this.utcOffset(),e):y},f.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var h=f.parse;f.parse=function(g){g.utc&&(this.$u=!0),this.$utils().u(g.$offset)||(this.$offset=g.$offset),h.call(this,g)};var p=f.init;f.init=function(){if(this.$u){var g=this.$d;this.$y=g.getUTCFullYear(),this.$M=g.getUTCMonth(),this.$D=g.getUTCDate(),this.$W=g.getUTCDay(),this.$H=g.getUTCHours(),this.$m=g.getUTCMinutes(),this.$s=g.getUTCSeconds(),this.$ms=g.getUTCMilliseconds()}else p.call(this)};var c=f.utcOffset;f.utcOffset=function(g,y){var _=this.$utils().u;if(_(g))return this.$u?0:_(this.$offset)?c.call(this):this.$offset;if(typeof g=="string"&&(g=function(A){A===void 0&&(A="");var C=A.match(r);if(!C)return null;var M=(""+C[0]).match(n)||["-",0,0],S=M[0],$=60*+M[1]+ +M[2];return $===0?0:S==="+"?$:-$}(g),g===null))return this;var E=Math.abs(g)<=16?60*g:g,b=this;if(y)return b.$offset=E,b.$u=g===0,b;if(g!==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 m=f.format;f.format=function(g){var y=g||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return m.call(this,y)},f.valueOf=function(){var g=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*g},f.isUTC=function(){return!!this.$u},f.toISOString=function(){return this.toDate().toISOString()},f.toString=function(){return this.toDate().toUTCString()};var v=f.toDate;f.toDate=function(g){return g==="s"&&this.$offset?l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():v.call(this)};var w=f.diff;f.diff=function(g,y,_){if(g&&this.$u===g.$u)return w.call(this,g,y,_);var E=this.local(),b=l(g).local();return w.call(E,b,y,_)}}})})(Al);var Mp=Al.exports,Np=jt(Mp),xl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,s,a){var l,f=function(m,v,w){w===void 0&&(w={});var g=new Date(m),y=function(_,E){E===void 0&&(E={});var b=E.timeZoneName||"short",N=_+"|"+b,A=r[N];return A||(A=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:_,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:b}),r[N]=A),A}(v,w);return y.formatToParts(g)},h=function(m,v){for(var w=f(m,v),g=[],y=0;y<w.length;y+=1){var _=w[y],E=_.type,b=_.value,N=e[E];N>=0&&(g[N]=parseInt(b,10))}var A=g[3],C=A===24?0:A,M=g[0]+"-"+g[1]+"-"+g[2]+" "+C+":"+g[4]+":"+g[5]+":000",S=+m;return(a.utc(M).valueOf()-(S-=S%1e3))/6e4},p=s.prototype;p.tz=function(m,v){m===void 0&&(m=l);var w=this.utcOffset(),g=this.toDate(),y=g.toLocaleString("en-US",{timeZone:m}),_=Math.round((g-new Date(y))/1e3/60),E=a(y,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(g.getTimezoneOffset()/15)-_,!0);if(v){var b=E.utcOffset();E=E.add(w-b,"minute")}return E.$x.$timezone=m,E},p.offsetName=function(m){var v=this.$x.$timezone||a.tz.guess(),w=f(this.valueOf(),v,{timeZoneName:m}).find(function(g){return g.type.toLowerCase()==="timezonename"});return w&&w.value};var c=p.startOf;p.startOf=function(m,v){if(!this.$x||!this.$x.$timezone)return c.call(this,m,v);var w=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return c.call(w,m,v).tz(this.$x.$timezone,!0)},a.tz=function(m,v,w){var g=w&&v,y=w||v||l,_=h(+a(),y);if(typeof m!="string")return a(m).tz(y);var E=function(C,M,S){var $=C-60*M*1e3,F=h($,S);if(M===F)return[$,M];var I=h($-=60*(F-M)*1e3,S);return F===I?[$,F]:[C-60*Math.min(F,I)*1e3,Math.max(F,I)]}(a.utc(m,g).valueOf(),_,y),b=E[0],N=E[1],A=a(b).utcOffset(N);return A.$x.$timezone=y,A},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(m){l=m}}})})(xl);var Sp=xl.exports,Bp=jt(Sp),Cl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,function(){var e="week",r="year";return function(n,s,a){var l=s.prototype;l.week=function(f){if(f===void 0&&(f=null),f!==null)return this.add(7*(f-this.week()),"day");var h=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var p=a(this).startOf(r).add(1,r).date(h),c=a(this).endOf(e);if(p.isBefore(c))return 1}var m=a(this).startOf(r).date(h).startOf(e).subtract(1,"millisecond"),v=this.diff(m,e,!0);return v<0?a(this).startOf("week").week():Math.ceil(v)},l.weeks=function(f){return f===void 0&&(f=null),this.week(f)}}})})(Cl);var Ip=Cl.exports,Tp=jt(Ip);function ms(i){const t=parseInt(i)||1;let e=i.replace(/\d+/,"");return e==="m"||e==="M"?e="M":e?e=e.toLocaleLowerCase():e="m",[t,e]}function Fl(i=10){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";const r=t.length;for(let n=0;n<i;n++)e+=t.charAt(Math.floor(Math.random()*r));return e}function $p(i){const t=/([+-])(\d{2})(\d{2})/,e=i.match(t);if(!e)throw new Error("Invalid timezone string");const[,r,n,s]=e;return(r==="+"?1:-1)*(parseInt(n,10)*60+parseInt(s,10))}function Mr(i,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?te(i).utcOffset($p(t)):te(i).tz(t)}function Tn(i){const[t,e]=ms(i);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)}var Pr=(i=>(i.BOOL="bool",i.INT="int",i.FLOAT="float",i.ARRAY="array",i.BOX="box",i.CHART_POINT="chart.point",i.COLOR="color",i.CONST="const",i.LABEL="label",i.LINE="line",i.LINEFILL="linefill",i.MAP="map",i.MATRIX="matrix",i.POLYLINE="polyline",i.SERIES="series",i.SIMPLE="simple",i.STRING="string",i.TABLE="table",i.UNDETERMINED="undetermined type",i.INPUT="input",i.NA="na",i.VOID="void",i))(Pr||{}),gs=(i=>(i.dividends="dividends",i.none="none",i.splits="splits",i))(gs||{}),fn=(i=>(i.freqAll="freq_all",i.freqOncePerBar="freq_once_per_bar",i.freqOncePerBarClose="freq_once_per_bar_close",i))(fn||{}),Li=(i=>(i.gapsOff="gaps_off",i.gapsOn="gaps_on",i.lookaheadOff="lookahead_off",i.lookaheadOn="lookahead_on",i))(Li||{}),er=(i=>(i.all="all",i.dataWindow="data_window",i.none="none",i.pane="pane",i.priceScale="price_scale",i.statusLine="status_line",i))(er||{}),$n=(i=>(i.both="both",i.left="left",i.none="none",i.right="right",i))($n||{}),On=(i=>(i.inherit="inherit",i.mintick="mintick",i.percent="percent",i.price="price",i.volume="volume",i))(On||{}),vs=(i=>(i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(vs||{}),me=(i=>(i.styleArrowdown="style_arrowdown",i.styleArrowup="style_arrowup",i.styleCircle="style_circle",i.styleCross="style_cross",i.styleDiamond="style_diamond",i.styleFlag="style_flag",i.styleLabelCenter="style_label_center",i.styleLabelDown="style_label_down",i.styleLabelLeft="style_label_left",i.styleLabelLowerLeft="style_label_lower_left",i.styleLabelLowerRight="style_label_lower_right",i.styleLabelRight="style_label_right",i.styleLabelUp="style_label_up",i.styleLabelUpperLeft="style_label_upper_left",i.styleLabelUpperRight="style_label_upper_right",i.styleNone="style_none",i.styleSquare="style_square",i.styleTextOutline="style_text_outline",i.styleTriangledown="style_triangledown",i.styleTriangleup="style_triangleup",i.styleXcross="style_xcross",i))(me||{}),zr=(i=>(i.styleArrowBoth="style_arrow_both",i.styleArrowLeft="style_arrow_left",i.styleArrowRight="style_arrow_right",i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(zr||{}),ri=(i=>(i.abovebar="abovebar",i.absolute="absolute",i.belowbar="belowbar",i.bottom="bottom",i.top="top",i))(ri||{}),Rn=(i=>(i.ascending="ascending",i.descending="descending",i))(Rn||{}),mr=(i=>(i.styleArea="Area",i.styleAreabr="Area With Breaks",i.styleCircles="Circles",i.styleColumns="Columns",i.styleCross="Cross",i.styleHistogram="Histogram",i.styleLine="Line",i.styleLinebr="Line With Breaks",i.styleStepline="Step Line",i.styleSteplineDiamond="Step Line With Diamonds",i.styleSteplinebr="Step line with Breaks",i))(mr||{}),Nr=(i=>(i.bottomCenter="bottom_center",i.bottomLeft="bottom_left",i.bottomRight="bottom_right",i.middleCenter="middle_center",i.middleLeft="middle_left",i.middleRight="middle_right",i.topCenter="top_center",i.topLeft="top_left",i.topRight="top_right",i))(Nr||{}),_s=(i=>(i.left="left",i.none="none",i.right="right",i))(_s||{}),ra=(i=>(i.extended="extended",i.regular="regular",i))(ra||{}),rr=(i=>(i.arrowdown="arrowdown",i.arrowup="arrowup",i.circle="circle",i.cross="cross",i.diamond="diamond",i.flag="flag",i.labeldown="labeldown",i.labelup="labelup",i.square="square",i.triangledown="triangledown",i.triangleup="triangleup",i.xcross="xcross",i))(rr||{}),qr=(i=>(i.auto="auto",i.huge="huge",i.large="large",i.normal="normal",i.small="small",i.tiny="tiny",i))(qr||{}),Gr=(i=>(i.cash="cash",i.fixed="fixed",i.percentOfEquity="percent_of_equity",i))(Gr||{}),Pi=(i=>(i.cashPerContract="cash_per_contract",i.cashPerOrder="cash_per_order",i.percent="percent",i))(Pi||{}),ze=(i=>(i.all="all",i.long="long",i.short="short",i))(ze||{}),Ln=(i=>(i.cancel="cancel",i.none="none",i.reduce="reduce",i))(Ln||{}),Ke=(i=>(i.alignBottom="align_bottom",i.alignCenter="align_center",i.alignLeft="align_left",i.alignRight="align_right",i.alignTop="align_top",i.wrapAuto="wrap_auto",i.wrapNone="wrap_none",i))(Ke||{}),Ie=(i=>(i.bar_index="bar_index",i.bar_time="bar_time",i))(Ie||{}),zi=(i=>(i.abovebar="abovebar",i.belowbar="belowbar",i.price="price",i))(zi||{}),ws=(i=>(i.actual="actual",i.estimate="estimate",i.standardized="standardized",i))(ws||{}),Pn=(i=>(i.traditional="Traditional",i.fibonacci="Fibonacci",i.woodie="Woodie",i.classic="Classic",i.dm="DM",i.camarilla="Camarilla",i))(Pn||{});class Op{new({size:t,initial_value:e}={}){return new Jt(t,e)}new_float({size:t,initial_value:e}={}){return new Jt(t,e)}new_int({size:t,initial_value:e}={}){return new Jt(t,e)}new_color({size:t,initial_value:e}={}){return new Jt(t,e)}new_bool({size:t,initial_value:e}={}){return new Jt(t,e)}new_string({size:t,initial_value:e}={}){return new Jt(t,e)}new_line({size:t,initial_value:e}={}){return new Jt(t,e)}new_box({size:t,initial_value:e}={}){return new Jt(t,e)}new_table({size:t,initial_value:e}={}){return new Jt(t,e)}new_linefill({size:t,initial_value:e}={}){return new Jt(t,e)}new_label({size:t,initial_value:e}={}){return new Jt(t,e)}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}){return t==null?void 0:t.abs()}avg({id:t}){return t==null?void 0:t.avg()}binary_search({id:t,val:e}){return t==null?void 0:t.binary_search({val:e})}binary_search_leftmost({id:t,val:e}){return t==null?void 0:t.binary_search_leftmost({val:e})}binary_search_rightmost({id:t,val:e}){return t==null?void 0:t.binary_search_rightmost({val:e})}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}){return t==null?void 0:t.covariance({id2:e,biased:r})}every({id:t}){return t==null?void 0:t.every()}from(t,e){const r=new Jt;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}){return t==null?void 0:t.join({separator:e})}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}){return t==null?void 0:t.max({nth:e})}median({id:t}){return t==null?void 0:t.median()}min({id:t,nth:e}){return t==null?void 0:t.min({nth:e})}mode({id:t}){return t==null?void 0:t.mode()}percentile_linear_interpolation({id:t,percentage:e}){return t==null?void 0:t.percentile_linear_interpolation({percentage:e})}percentile_nearest_rank({id:t,percentage:e}){return t==null?void 0:t.percentile_nearest_rank({percentage:e})}percentrank({id:t,index:e}){return t==null?void 0:t.percentrank({index:e})}pop({id:t}){return t==null?void 0:t.pop()}push({id:t,value:e}){t==null||t.push({value:e})}range({id:t}){return t==null?void 0:t.range()}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}){return t==null?void 0:t.some()}sort({id:t,order:e}){t==null||t.sort({order:e})}sort_indices({id:t,order:e}){return t==null?void 0:t.sort_indices({order:e})}standardize({id:t}){return t==null?void 0:t.standardize()}stdev({id:t,biased:e}){return t==null?void 0:t.stdev({biased:e})}sum({id:t}){return t==null?void 0:t.sum()}unshift({id:t,value:e}){t==null||t.unshift({value:e})}variance({id:t,biased:e}){return t==null?void 0:t.variance({biased:e})}}class Jt{constructor(t=0,e){Z(this,"_arrInstance");this._arrInstance=Array.from(new Array(t||0),()=>Fr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Fr.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new Jt;return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new Jt;return r._copyData(this._arrInstance.slice(t,e)),r}size(){return this._arrInstance.length}first(){return this._arrInstance[0]}abs(){const t=new Jt;this._verifySimpleType("number","abs","int/float");const e=this._arrInstance.map(r=>Math.abs(r));return t._copyData(e),t}avg(){return this._verifySimpleType("number","avg","int/float"),Fr.mean(this._arrInstance)}binary_search({val:t}){return this._verifySimpleType("number","binary_search","int/float"),this._binarySearch(this._arrInstance,t)}binary_search_leftmost({val:t}){return this._verifySimpleType("number","binary_search_leftmost","int/float"),this._binarySearchLeftMost(this._arrInstance,t)}binary_search_rightmost({val:t}){return this._verifySimpleType("number","binary_search_rightmost","int/float"),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}){return this._verifySimpleType("number","covariance","int/float"),this._verifySimpleType("number","covariance","int/float",t==null?void 0:t._value),this._covariance(this._arrInstance,t._value,e)}every(){return this._verifySimpleType("number|boolean","every","int/float/bool"),this._arrInstance.every(t=>!!t)}fill({value:t,index_from:e,index_to:r}){this._arrInstance=this._setElements(this._arrInstance,t,e,r)}get({index: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}){this._arrInstance.splice(t,0,e)}join({separator:t}={}){return this._verifySimpleType("number|string","join","int/float/string"),this._arrInstance.join(t)}last(){return this._arrInstance[this._arrInstance.length-1]}lastindexof({value:t}){return this._arrInstance.lastIndexOf(t)}max({nth:t}={}){return this._verifySimpleType("number","max","int/float"),this._maxNth([...this._arrInstance],t)}median(){return this._verifySimpleType("number","median","int/float"),this._median([...this._arrInstance])}min({nth:t}={}){return this._verifySimpleType("number","min","int/float"),this._minNth([...this._arrInstance],t)}mode(){return this._verifySimpleType("number","mode","int/float"),this._mode([...this._arrInstance])}percentile_linear_interpolation({percentage:t}){return this._verifySimpleType("number","percentile_linear_interpolation","int/float"),this._percentileLinearInterpolation([...this._arrInstance],t)}percentile_nearest_rank({percentage:t}){return this._verifySimpleType("number","percentile_nearest_rank","int/float"),this._getNearestRankPercentile([...this._arrInstance],t)}percentrank({index:t}){return this._verifySimpleType("number","percentrank","int/float"),this._getPercentileRank([...this._arrInstance],t)}pop(){return this._arrInstance.pop()}push({value:t}){this._arrInstance.push(t)}range(){if(this._arrInstance.length===0)throw new Error("Array must not be empty");this._verifySimpleType("number","range","int/float");const t=Math.min(...this._arrInstance);return Math.max(...this._arrInstance)-t}remove({index:t}){return this._arrInstance.splice(t,1)[0]}reverse(){this._arrInstance.reverse()}set({index:t,value:e}){this._arrInstance[t]=e}shift(){return this._arrInstance.shift()}some(){return this._verifySimpleType("number|boolean","some","int/float/bool"),this._arrInstance.some(t=>!!t)}sort({order:t}={}){this._verifySimpleType("number","sort","int/float"),this._arrInstance.sort((e,r)=>t!==Rn.descending?e-r:r-e)}sort_indices({order:t}={}){this._verifySimpleType("number","sort_indices","int/float");const e=this._arrInstance.map((n,s)=>s);e.sort((n,s)=>t!==Rn.descending?this._arrInstance[n]-this._arrInstance[s]:this._arrInstance[s]-this._arrInstance[n]);const r=new Jt;return r._copyData(e),r}standardize(){this._verifySimpleType("number","standardize","int/float");const t=new Jt;return t._copyData(this._standardizeArray([...this._arrInstance])),t}stdev({biased:t}={}){return this._verifySimpleType("number","stdev","int/float"),this._calculateStandardDeviations([...this._arrInstance],t)}sum(){return this._verifySimpleType("number","sum","int/float"),this._arrInstance.reduce((e,r)=>e+(r||0),0)}unshift({value:t}){this._arrInstance.unshift(t)}variance({biased:t}={}){return this._verifySimpleType("number","variance","int/float"),this._calculateVariances([...this._arrInstance],t)}_calculateVariances(t,e=!0){if(t.length===0)throw new Error("Array must not be empty");const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>a+((l||0)-r)**2,0),s=n/t.length;return e?s:t.length>1?n/(t.length-1):s}_calculateStandardDeviations(t,e=!0){if(t.length===0)throw new Error("Array must not be empty");const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>{const f=(l||0)-r;return a+f*f},0),s=Math.sqrt(n/t.length);return e?s:t.length>1?Math.sqrt(n/(t.length-1)):s}_standardizeArray(t){const e=t.reduce((s,a)=>s+(a||0),0)/t.length,r=Math.sqrt(t.reduce((s,a)=>s+Math.pow((a||0)-e,2),0)/t.length);return t.map(s=>((s||0)-e)/r)}_getPercentileRank(t,e=0){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){if(t.length===0||e<0||e>100)throw new Error("Invalid percentile or empty array");const r=t.slice().sort((a,l)=>a-l),n=e/100*r.length,s=Math.ceil(n)-1;return r[s>=r.length?r.length-1:s]}_percentileLinearInterpolation(t,e=0){if(e<0||e>100)return;t.sort(function(s,a){return s-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[s,a]of t.entries()){const l=t[s-1];if(e<(s+.5)/r)return l+(a-l)*(e-(s-.5)/r)/(1/r)}}_mode(t){const e={};let r=0;const n=[];for(const s of t)e[s]=(e[s]||0)+1,r=Math.max(r,e[s]);for(const s in e)e[s]===r&&n.push(Number(s));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 s=r;s<n;s++)t[s]=e;return t}_covariance(t,e,r=!0){if(t.length!=e.length)throw"Arrays have different lengths";t=t.filter(l=>l!==void 0),e=e.filter(l=>l!==void 0);const n=t.reduce((l,f)=>l+f,0)/t.length,s=e.reduce((l,f)=>l+f,0)/e.length;let a=0;for(let l=0;l<t.length;l++)a+=(t[l]-n)*(e[l]-s);return r?a/t.length:a/(t.length-1)}_verifySimpleType(t,e,r,n=this._arrInstance){if(n.filter(a=>a!==void 0).some(a=>!t.split("|").includes(typeof a)))throw Error(`数组类型错误,array.${e}方法只能使用${r}类型数组!`)}_binarySearch(t,e){let r=0,n=t.length-1;for(;r<=n;){const s=Math.floor((r+n)/2);if(t[s]===e)return s;t[s]<e?r=s+1:n=s-1}return-1}_binarySearchLeftMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<e?r=a+1:n=a-1}return s.length?Math.min(...s):r-1}_binarySearchRightMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<=e?r=a+1:n=a-1}return s.length?Math.max(...s):r}}class Rp{constructor(t){Z(this,"_randomNums");Z(this,"_mintick");Z(this,"_cacheData");Z(this,"_barIndex");this._mintick=t,this._randomNums={},this._cacheData={},this._barIndex=0}update(t){this._barIndex=t,this._randomNums={}}abs({number:t}){return Math.abs(t)}acos({angle:t}){const e=Math.acos(t);return isNaN(e)?void 0:e}asin({angle:t}){const e=Math.asin(t);return isNaN(e)?void 0:e}atan({angle:t}){const e=Math.atan(t);return isNaN(e)?void 0:e}avg(t,e){return Fr.mean(e)}ceil({number:t}){return Math.ceil(t)}floor({number:t}){return Math.floor(t)}cos({angle:t}){const e=Math.cos(t);return isNaN(e)?void 0:e}sin({angle:t}){const e=Math.sin(t);return isNaN(e)?void 0:e}tan({angle:t}){const e=Math.tan(t);return isNaN(e)?void 0:e}exp({number:t}){return Math.exp(t)}log({number:t}){return Math.log(t)}log10({number:t}){return Math.log10(t)}max(t,e){return Math.max(...e)}min(t,e){return Math.min(...e)}pow({base:t,exponent:e}){return Math.pow(t,e)}random({min:t=0,max:e=1,seed:r}){if(r&&this._randomNums[r])return this._randomNums[r];if(t>=e)throw new Error("min must be less than max");let n;do n=Math.random()*(e-t)+t;while(n===t||n===e);return r&&(this._randomNums[r]=n),n}round({number:t,precision:e}){return e?Number(t==null?void 0:t.toFixed(e)):Math.round(t)}round_to_mintick({number:t}){return Number(t==null?void 0:t.toFixed(this._mintick))}sign({number:t}){return t&&Math.sign(t)}sqrt({number: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 s=n.filter(()=>!0);if(!(s.length<e))return Fr.sum(s.slice(-e))}todegrees({radians:t}){return t*(180/Math.PI)}toradians({degrees:t}){const e=t*(Math.PI/180);return Number(e.toFixed(this._mintick))}}function Ds(){return Ds=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},Ds.apply(this,arguments)}var Ml={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function ue(i){return typeof i=="number"}function ye(i){return!i||typeof i!="object"||typeof i.constructor!="function"?!1:i.isBigNumber===!0&&typeof i.constructor.prototype=="object"&&i.constructor.prototype.isBigNumber===!0||typeof i.constructor.isDecimal=="function"&&i.constructor.isDecimal(i)===!0}function Nl(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isComplex===!0||!1}function Sl(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isFraction===!0||!1}function Bl(i){return i&&i.constructor.prototype.isUnit===!0||!1}function Ur(i){return typeof i=="string"}var ge=Array.isArray;function fe(i){return i&&i.constructor.prototype.isMatrix===!0||!1}function qi(i){return Array.isArray(i)||fe(i)}function Lp(i){return i&&i.isDenseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function Pp(i){return i&&i.isSparseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function zp(i){return i&&i.constructor.prototype.isRange===!0||!1}function na(i){return i&&i.constructor.prototype.isIndex===!0||!1}function qp(i){return typeof i=="boolean"}function Up(i){return i&&i.constructor.prototype.isResultSet===!0||!1}function kp(i){return i&&i.constructor.prototype.isHelp===!0||!1}function Wp(i){return typeof i=="function"}function Yp(i){return i instanceof Date}function jp(i){return i instanceof RegExp}function ia(i){return!!(i&&typeof i=="object"&&i.constructor===Object&&!Nl(i)&&!Sl(i))}function Zp(i){return i===null}function Gp(i){return i===void 0}function Kp(i){return i&&i.isAccessorNode===!0&&i.constructor.prototype.isNode===!0||!1}function Hp(i){return i&&i.isArrayNode===!0&&i.constructor.prototype.isNode===!0||!1}function Jp(i){return i&&i.isAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function Xp(i){return i&&i.isBlockNode===!0&&i.constructor.prototype.isNode===!0||!1}function Vp(i){return i&&i.isConditionalNode===!0&&i.constructor.prototype.isNode===!0||!1}function Qp(i){return i&&i.isConstantNode===!0&&i.constructor.prototype.isNode===!0||!1}function td(i){return i&&i.isFunctionAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function ed(i){return i&&i.isFunctionNode===!0&&i.constructor.prototype.isNode===!0||!1}function rd(i){return i&&i.isIndexNode===!0&&i.constructor.prototype.isNode===!0||!1}function nd(i){return i&&i.isNode===!0&&i.constructor.prototype.isNode===!0||!1}function id(i){return i&&i.isObjectNode===!0&&i.constructor.prototype.isNode===!0||!1}function sd(i){return i&&i.isOperatorNode===!0&&i.constructor.prototype.isNode===!0||!1}function od(i){return i&&i.isParenthesisNode===!0&&i.constructor.prototype.isNode===!0||!1}function ad(i){return i&&i.isRangeNode===!0&&i.constructor.prototype.isNode===!0||!1}function ud(i){return i&&i.isRelationalNode===!0&&i.constructor.prototype.isNode===!0||!1}function ld(i){return i&&i.isSymbolNode===!0&&i.constructor.prototype.isNode===!0||!1}function fd(i){return i&&i.constructor.prototype.isChain===!0||!1}function cn(i){var t=typeof i;return t==="object"?i===null?"null":ye(i)?"BigNumber":i.constructor&&i.constructor.name?i.constructor.name:"Object":t}function ee(i){var t=typeof i;if(t==="number"||t==="string"||t==="boolean"||i===null||i===void 0)return i;if(typeof i.clone=="function")return i.clone();if(Array.isArray(i))return i.map(function(e){return ee(e)});if(i instanceof Date)return new Date(i.valueOf());if(ye(i))return i;if(ia(i))return cd(i,ee);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(i,")"))}function cd(i,t){var e={};for(var r in i)Ui(i,r)&&(e[r]=t(i[r]));return e}function Il(i,t){for(var e in t)Ui(t,e)&&(i[e]=t[e]);return i}function ni(i,t){var e,r,n;if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(r=0,n=i.length;r<n;r++)if(!ni(i[r],t[r]))return!1;return!0}else{if(typeof i=="function")return i===t;if(i instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(e in i)if(!(e in t)||!ni(i[e],t[e]))return!1;for(e in t)if(!(e in i))return!1;return!0}else return i===t}}function Ui(i,t){return i&&Object.hasOwnProperty.call(i,t)}function hd(i,t){for(var e={},r=0;r<t.length;r++){var n=t[r],s=i[n];s!==void 0&&(e[n]=s)}return e}var pd=["Matrix","Array"],dd=["number","BigNumber","Fraction"],nr=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(Ml)};Ds(nr,Ml,{MATRIX_OPTIONS:pd,NUMBER_OPTIONS:dd});function Tl(){return!0}function gr(){return!1}function ii(){}const $l="Argument is not a typed-function.";function Ol(){function i(O){return typeof O=="object"&&O!==null&&O.constructor===Object}const t=[{name:"number",test:function(O){return typeof O=="number"}},{name:"string",test:function(O){return typeof O=="string"}},{name:"boolean",test:function(O){return typeof O=="boolean"}},{name:"Function",test:function(O){return typeof O=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(O){return O instanceof Date}},{name:"RegExp",test:function(O){return O instanceof RegExp}},{name:"Object",test:i},{name:"null",test:function(O){return O===null}},{name:"undefined",test:function(O){return O===void 0}}],e={name:"any",test:Tl,isAny:!0};let r,n,s=0,a={createCount:0};function l(O){const j=r.get(O);if(j)return j;let H='Unknown type "'+O+'"';const nt=O.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){H+='. Did you mean "'+st+'" ?';break}throw new TypeError(H)}function f(O){let j=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const H=j?l(j).index:n.length,nt=[];for(let rt=0;rt<O.length;++rt){if(!O[rt]||typeof O[rt].name!="string"||typeof O[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ct=O[rt].name;if(r.has(ct))throw new TypeError('Duplicate type name "'+ct+'"');nt.push(ct),r.set(ct,{name:ct,test:O[rt].test,isAny:O[rt].isAny,index:H+rt,conversionsTo:[]})}const st=n.slice(H);n=n.slice(0,H).concat(nt).concat(st);for(let rt=H+nt.length;rt<n.length;++rt)r.get(n[rt]).index=rt}function h(){r=new Map,n=[],s=0,f([e],!1)}h(),f(t);function p(){let O;for(O of n)r.get(O).conversionsTo=[];s=0}function c(O){const j=n.filter(H=>{const nt=r.get(H);return!nt.isAny&&nt.test(O)});return j.length?j:["any"]}function m(O){return O&&typeof O=="function"&&"_typedFunctionData"in O}function v(O,j,H){if(!m(O))throw new TypeError($l);const nt=H&&H.exact,st=Array.isArray(j)?j.join(","):j,rt=N(st),ct=y(rt);if(!nt||ct in O.signatures){const Kt=O._typedFunctionData.signatureMap.get(ct);if(Kt)return Kt}const ut=rt.length;let ht;if(nt){ht=[];let Kt;for(Kt in O.signatures)ht.push(O._typedFunctionData.signatureMap.get(Kt))}else ht=O._typedFunctionData.signatures;for(let Kt=0;Kt<ut;++Kt){const Vt=rt[Kt],pe=[];let Te;for(Te of ht){const Ne=S(Te.params,Kt);if(!(!Ne||Vt.restParam&&!Ne.restParam)){if(!Ne.hasAny){const ar=b(Ne);if(Vt.types.some(ur=>!ar.has(ur.name)))continue}pe.push(Te)}}if(ht=pe,ht.length===0)break}let at;for(at of ht)if(at.params.length<=ut)return at;throw new TypeError("Signature not found (signature: "+(O.name||"unnamed")+"("+y(rt,", ")+"))")}function w(O,j,H){return v(O,j,H).implementation}function g(O,j){const H=l(j);if(H.test(O))return O;const nt=H.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+j+" defined.");for(let st=0;st<nt.length;st++)if(l(nt[st].from).test(O))return nt[st].convert(O);throw new Error("Cannot convert "+O+" to "+j)}function y(O){let j=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return O.map(H=>H.name).join(j)}function _(O){const j=O.indexOf("...")===0,nt=(j?O.length>3?O.slice(3):"any":O).split("|").map(ut=>l(ut.trim()));let st=!1,rt=j?"...":"";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:j}}function E(O){const j=O.types.map(ct=>ct.name),H=K(j);let nt=O.hasAny,st=O.name;const rt=H.map(function(ct){const ut=l(ct.from);return nt=ut.isAny||nt,st+="|"+ct.from,{name:ct.from,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:ct,conversionIndex:ct.index}});return{types:O.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:O.restParam}}function b(O){return O.typeSet||(O.typeSet=new Set,O.types.forEach(j=>O.typeSet.add(j.name))),O.typeSet}function N(O){const j=[];if(typeof O!="string")throw new TypeError("Signatures must be strings");const H=O.trim();if(H==="")return j;const nt=H.split(",");for(let st=0;st<nt.length;++st){const rt=_(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;j.push(rt)}return j}function A(O){const j=It(O);return j?j.restParam:!1}function C(O){if(!O||O.types.length===0)return Tl;if(O.types.length===1)return l(O.types[0].name).test;if(O.types.length===2){const j=l(O.types[0].name).test,H=l(O.types[1].name).test;return function(st){return j(st)||H(st)}}else{const j=O.types.map(function(H){return l(H.name).test});return function(nt){for(let st=0;st<j.length;st++)if(j[st](nt))return!0;return!1}}}function M(O){let j,H,nt;if(A(O)){j=re(O).map(C);const st=j.length,rt=C(It(O)),ct=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<j.length;at++)if(!j[at](ht[at]))return!1;return ct(ht)&&ht.length>=st+1}}else return O.length===0?function(rt){return rt.length===0}:O.length===1?(H=C(O[0]),function(rt){return H(rt[0])&&rt.length===1}):O.length===2?(H=C(O[0]),nt=C(O[1]),function(rt){return H(rt[0])&&nt(rt[1])&&rt.length===2}):(j=O.map(C),function(rt){for(let ct=0;ct<j.length;ct++)if(!j[ct](rt[ct]))return!1;return rt.length===j.length})}function S(O,j){return j<O.length?O[j]:A(O)?It(O):null}function $(O,j){const H=S(O,j);return H?b(H):new Set}function F(O){return O.conversion===null||O.conversion===void 0}function I(O,j){const H=new Set;return O.forEach(nt=>{const st=$(nt.params,j);let rt;for(rt of st)H.add(rt)}),H.has("any")?["any"]:Array.from(H)}function R(O,j,H){let nt,st;const rt=O||"unnamed";let ct=H,ut;for(ut=0;ut<j.length;ut++){const Vt=[];if(ct.forEach(pe=>{const Te=S(pe.params,ut),Ne=C(Te);(ut<pe.params.length||A(pe.params))&&Ne(j[ut])&&Vt.push(pe)}),Vt.length===0){if(st=I(ct,ut),st.length>0){const pe=c(j[ut]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+pe.join(" | ")+", index: "+ut+")"),nt.data={category:"wrongType",fn:rt,index:ut,actual:pe,expected:st},nt}}else ct=Vt}const ht=ct.map(function(Vt){return A(Vt.params)?1/0:Vt.params.length});if(j.length<Math.min.apply(null,ht))return st=I(ct,ut),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+j.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:j.length,expected:st},nt;const at=Math.max.apply(null,ht);if(j.length>at)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+at+", actual: "+j.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:j.length,expectedLength:at},nt;const Kt=[];for(let Vt=0;Vt<j.length;++Vt)Kt.push(c(j[Vt]).join("|"));return nt=new TypeError('Arguments of type "'+Kt.join(", ")+'" do not match any of the defined signatures of function '+rt+"."),nt.data={category:"mismatch",actual:Kt},nt}function U(O){let j=n.length+1;for(let H=0;H<O.types.length;H++)F(O.types[H])&&(j=Math.min(j,O.types[H].typeIndex));return j}function q(O){let j=s+1;for(let H=0;H<O.types.length;H++)F(O.types[H])||(j=Math.min(j,O.types[H].conversionIndex));return j}function k(O,j){if(O.hasAny){if(!j.hasAny)return 1}else if(j.hasAny)return-1;if(O.restParam){if(!j.restParam)return 1}else if(j.restParam)return-1;if(O.hasConversion){if(!j.hasConversion)return 1}else if(j.hasConversion)return-1;const H=U(O)-U(j);if(H<0)return-1;if(H>0)return 1;const nt=q(O)-q(j);return nt<0?-1:nt>0?1:0}function P(O,j){const H=O.params,nt=j.params,st=It(H),rt=It(nt),ct=A(H),ut=A(nt);if(ct&&st.hasAny){if(!ut||!rt.hasAny)return 1}else if(ut&&rt.hasAny)return-1;let ht=0,at=0,Kt;for(Kt of H)Kt.hasAny&&++ht,Kt.hasConversion&&++at;let Vt=0,pe=0;for(Kt of nt)Kt.hasAny&&++Vt,Kt.hasConversion&&++pe;if(ht!==Vt)return ht-Vt;if(ct&&st.hasConversion){if(!ut||!rt.hasConversion)return 1}else if(ut&&rt.hasConversion)return-1;if(at!==pe)return at-pe;if(ct){if(!ut)return 1}else if(ut)return-1;const Te=(H.length-nt.length)*(ct?-1:1);if(Te!==0)return Te;const Ne=[];let ar=0;for(let yn=0;yn<H.length;++yn){const jn=k(H[yn],nt[yn]);Ne.push(jn),ar+=jn}if(ar!==0)return ar;let ur;for(ur of Ne)if(ur!==0)return ur;return 0}function K(O){if(O.length===0)return[];const j=O.map(l);O.length>1&&j.sort((st,rt)=>st.index-rt.index);let H=j[0].conversionsTo;if(O.length===1)return H;H=H.concat([]);const nt=new Set(O);for(let st=1;st<j.length;++st){let rt;for(rt of j[st].conversionsTo)nt.has(rt.from)||(H.push(rt),nt.add(rt.from))}return H}function G(O,j){let H=j;if(O.some(st=>st.hasConversion)){const st=A(O),rt=O.map(V);H=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])),j.apply(this,ut)}}let nt=H;if(A(O)){const st=O.length-1;nt=function(){return H.apply(this,Mt(arguments,0,st).concat([Mt(arguments,st)]))}}return nt}function V(O){let j,H,nt,st;const rt=[],ct=[];switch(O.types.forEach(function(ut){ut.conversion&&(rt.push(l(ut.conversion.from).test),ct.push(ut.conversion.convert))}),ct.length){case 0:return function(ht){return ht};case 1:return j=rt[0],nt=ct[0],function(ht){return j(ht)?nt(ht):ht};case 2:return j=rt[0],H=rt[1],nt=ct[0],st=ct[1],function(ht){return j(ht)?nt(ht):H(ht)?st(ht):ht};default:return function(ht){for(let at=0;at<ct.length;at++)if(rt[at](ht))return ct[at](ht);return ht}}}function tt(O){function j(H,nt,st){if(nt<H.length){const rt=H[nt];let ct=[];if(rt.restParam){const ut=rt.types.filter(F);ut.length<rt.types.length&&ct.push({types:ut,name:"..."+ut.map(ht=>ht.name).join("|"),hasAny:ut.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),ct.push(rt)}else ct=rt.types.map(function(ut){return{types:[ut],name:ut.name,hasAny:ut.isAny,hasConversion:ut.conversion,restParam:!1}});return Xt(ct,function(ut){return j(H,nt+1,st.concat([ut]))})}else return[st]}return j(O,0,[])}function ft(O,j){const H=Math.max(O.length,j.length);for(let ut=0;ut<H;ut++){const ht=$(O,ut),at=$(j,ut);let Kt=!1,Vt;for(Vt of at)if(ht.has(Vt)){Kt=!0;break}if(!Kt)return!1}const nt=O.length,st=j.length,rt=A(O),ct=A(j);return rt?ct?nt===st:st>=nt:ct?nt>=st:nt===st}function vt(O){return O.map(j=>Me(j)?Ce(j.referToSelf.callback):sr(j)?Gt(j.referTo.references,j.referTo.callback):j)}function lt(O,j,H){const nt=[];let st;for(st of O){let rt=H[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=j[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function wt(O,j,H){const nt=vt(O),st=new Array(nt.length).fill(!1);let rt=!0;for(;rt;){rt=!1;let ct=!0;for(let ut=0;ut<nt.length;++ut){if(st[ut])continue;const ht=nt[ut];if(Me(ht))nt[ut]=ht.referToSelf.callback(H),nt[ut].referToSelf=ht.referToSelf,st[ut]=!0,ct=!1;else if(sr(ht)){const at=lt(ht.referTo.references,nt,j);at?(nt[ut]=ht.referTo.callback.apply(this,at),nt[ut].referTo=ht.referTo,st[ut]=!0,ct=!1):rt=!0}}if(ct&&rt)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return nt}function yt(O){const j=/\bthis(\(|\.signatures\b)/;Object.keys(O).forEach(H=>{const nt=O[H];if(j.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 St(O,j){if(a.createCount++,Object.keys(j).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&yt(j);const H=[],nt=[],st={},rt=[];let ct;for(ct in j){if(!Object.prototype.hasOwnProperty.call(j,ct))continue;const Yt=N(ct);if(!Yt)continue;H.forEach(function(bn){if(ft(bn,Yt))throw new TypeError('Conflicting signatures "'+y(bn)+'" and "'+y(Yt)+'".')}),H.push(Yt);const ke=nt.length;nt.push(j[ct]);const uu=Yt.map(E);let bi;for(bi of tt(uu)){const bn=y(bi);rt.push({params:bi,name:bn,fn:ke}),bi.every(po=>!po.hasConversion)&&(st[bn]=ke)}}rt.sort(P);const ut=wt(nt,st,Zn);let ht;for(ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(st[ht]=ut[st[ht]]);const at=[],Kt=new Map;for(ht of rt)Kt.has(ht.name)||(ht.fn=ut[ht.fn],at.push(ht),Kt.set(ht.name,ht));const Vt=at[0]&&at[0].params.length<=2&&!A(at[0].params),pe=at[1]&&at[1].params.length<=2&&!A(at[1].params),Te=at[2]&&at[2].params.length<=2&&!A(at[2].params),Ne=at[3]&&at[3].params.length<=2&&!A(at[3].params),ar=at[4]&&at[4].params.length<=2&&!A(at[4].params),ur=at[5]&&at[5].params.length<=2&&!A(at[5].params),yn=Vt&&pe&&Te&&Ne&&ar&&ur;for(let Yt=0;Yt<at.length;++Yt)at[Yt].test=M(at[Yt].params);const jn=Vt?C(at[0].params[0]):gr,fo=pe?C(at[1].params[0]):gr,qa=Te?C(at[2].params[0]):gr,Ua=Ne?C(at[3].params[0]):gr,ka=ar?C(at[4].params[0]):gr,Wa=ur?C(at[5].params[0]):gr,co=Vt?C(at[0].params[1]):gr,Ya=pe?C(at[1].params[1]):gr,ja=Te?C(at[2].params[1]):gr,Za=Ne?C(at[3].params[1]):gr,Vi=ar?C(at[4].params[1]):gr,Ga=ur?C(at[5].params[1]):gr;for(let Yt=0;Yt<at.length;++Yt)at[Yt].implementation=G(at[Yt].params,at[Yt].fn);const Qi=Vt?at[0].implementation:ii,Ka=pe?at[1].implementation:ii,Ha=Te?at[2].implementation:ii,Ja=Ne?at[3].implementation:ii,Xa=ar?at[4].implementation:ii,Va=ur?at[5].implementation:ii,Qa=Vt?at[0].params.length:-1,tu=pe?at[1].params.length:-1,eu=Te?at[2].params.length:-1,ho=Ne?at[3].params.length:-1,ru=ar?at[4].params.length:-1,nu=ur?at[5].params.length:-1,iu=yn?6:0,su=at.length,ou=at.map(Yt=>Yt.test),au=at.map(Yt=>Yt.implementation),yi=function(){for(let ke=iu;ke<su;ke++)if(ou[ke](arguments))return au[ke].apply(this,arguments);return a.onMismatch(O,arguments,at)};function Zn(Yt,ke){return arguments.length===Qa&&jn(Yt)&&co(ke)?Qi.apply(this,arguments):arguments.length===tu&&fo(Yt)&&Ya(ke)?Ka.apply(this,arguments):arguments.length===eu&&qa(Yt)&&ja(ke)?Ha.apply(this,arguments):arguments.length===ho&&Ua(Yt)&&Za(ke)?Ja.apply(this,arguments):arguments.length===ru&&ka(Yt)&&Vi(ke)?Xa.apply(this,arguments):arguments.length===nu&&Wa(Yt)&&Ga(ke)?Va.apply(this,arguments):yi.apply(this,arguments)}try{Object.defineProperty(Zn,"name",{value:O})}catch{}return Zn.signatures=st,Zn._typedFunctionData={signatures:at,signatureMap:Kt},Zn}function bt(O,j,H){throw R(O,j,H)}function re(O){return Mt(O,0,O.length-1)}function It(O){return O[O.length-1]}function Mt(O,j,H){return Array.prototype.slice.call(O,j,H)}function ie(O,j){for(let H=0;H<O.length;H++)if(j(O[H]))return O[H]}function Xt(O,j){return Array.prototype.concat.apply([],O.map(j))}function zt(){const O=re(arguments).map(H=>y(N(H))),j=It(arguments);if(typeof j!="function")throw new TypeError("Callback function expected as last argument");return Gt(O,j)}function Gt(O,j){return{referTo:{references:O,callback:j}}}function Ce(O){if(typeof O!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:O}}}function sr(O){return O&&typeof O.referTo=="object"&&Array.isArray(O.referTo.references)&&typeof O.referTo.callback=="function"}function Me(O){return O&&typeof O.referToSelf=="object"&&typeof O.referToSelf.callback=="function"}function Vr(O,j){if(!O)return j;if(j&&j!==O){const H=new Error("Function names do not match (expected: "+O+", actual: "+j+")");throw H.data={actual:j,expected:O},H}return O}function wn(O){let j;for(const H in O)Object.prototype.hasOwnProperty.call(O,H)&&(m(O[H])||typeof O[H].signature=="string")&&(j=Vr(j,O[H].name));return j}function Qr(O,j){let H;for(H in j)if(Object.prototype.hasOwnProperty.call(j,H)){if(H in O&&j[H]!==O[H]){const nt=new Error('Signature "'+H+'" is defined twice');throw nt.data={signature:H,sourceFunction:j[H],destFunction:O[H]},nt}O[H]=j[H]}}const or=a;a=function(O){const j=typeof O=="string",H=j?1:0;let nt=j?O:"";const st={};for(let rt=H;rt<arguments.length;++rt){const ct=arguments[rt];let ut={},ht;if(typeof ct=="function"?(ht=ct.name,typeof ct.signature=="string"?ut[ct.signature]=ct:m(ct)&&(ut=ct.signatures)):i(ct)&&(ut=ct,j||(ht=wn(ct))),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:ct},at}j||(nt=Vr(nt,ht)),Qr(st,ut)}return St(nt||"",st)},a.create=Ol,a.createCount=or.createCount,a.onMismatch=bt,a.throwMismatchError=bt,a.createError=R,a.clear=h,a.clearConversions=p,a.addTypes=f,a._findType=l,a.referTo=zt,a.referToSelf=Ce,a.convert=g,a.findSignature=v,a.find=w,a.isTypedFunction=m,a.warnAgainstDeprecatedThis=!0,a.addType=function(O,j){let H="any";j!==!1&&r.has("Object")&&(H="Object"),a.addTypes([O],H)};function Dn(O){if(!O||typeof O.from!="string"||typeof O.to!="string"||typeof O.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(O.to===O.from)throw new SyntaxError('Illegal to define conversion from "'+O.from+'" to itself.')}return a.addConversion=function(O){Dn(O);const j=l(O.to);if(j.conversionsTo.every(function(H){return H.from!==O.from}))j.conversionsTo.push({from:O.from,convert:O.convert,index:s++});else throw new Error('There is already a conversion from "'+O.from+'" to "'+j.name+'"')},a.addConversions=function(O){O.forEach(a.addConversion)},a.removeConversion=function(O){Dn(O);const j=l(O.to),H=ie(j.conversionsTo,st=>st.from===O.from);if(!H)throw new Error("Attempt to remove nonexistent conversion from "+O.from+" to "+O.to);if(H.convert!==O.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=j.conversionsTo.indexOf(H);j.conversionsTo.splice(nt,1)},a.resolve=function(O,j){if(!m(O))throw new TypeError($l);const H=O._typedFunctionData.signatures;for(let nt=0;nt<H.length;++nt)if(H[nt].test(j))return H[nt];return null},a}var Rl=Ol();function he(i){return typeof i=="boolean"?!0:isFinite(i)?i===Math.round(i):!1}function sa(i,t,e){var r={2:"0b",8:"0o",16:"0x"},n=r[t],s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!he(e))throw new Error("size must be an integer");if(i>2**(e-1)-1||i<-(2**(e-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!he(i))throw new Error("Value must be an integer");i<0&&(i=i+2**e),s="i".concat(e)}var a="";return i<0&&(i=-i,a="-"),"".concat(a).concat(n).concat(i.toString(t)).concat(s)}function oa(i,t){if(typeof t=="function")return t(i);if(i===1/0)return"Infinity";if(i===-1/0)return"-Infinity";if(isNaN(i))return"NaN";var{notation:e,precision:r,wordSize:n}=Ll(t);switch(e){case"fixed":return gd(i,r);case"exponential":return Pl(i,r);case"engineering":return md(i,r);case"bin":return sa(i,2,n);case"oct":return sa(i,8,n);case"hex":return sa(i,16,n);case"auto":return vd(i,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],a=arguments[4];return s!=="."?s+a:a});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Ll(i){var t="auto",e,r;if(i!==void 0)if(ue(i))e=i;else if(ye(i))e=i.toNumber();else if(ia(i))i.precision!==void 0&&(e=zl(i.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),i.wordSize!==void 0&&(r=zl(i.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),i.notation&&(t=i.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:t,precision:e,wordSize:r}}function ys(i){var t=String(i).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+i);var e=t[1],r=t[2],n=parseFloat(t[4]||"0"),s=r.indexOf(".");n+=s!==-1?s-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 md(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=ys(i),r=bs(e,t),n=r.exponent,s=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(ue(t))for(;t>s.length||n-a+1>s.length;)s.push(0);else for(var l=Math.abs(n-a)-(s.length-1),f=0;f<l;f++)s.push(0);for(var h=Math.abs(n-a),p=1;h>0;)p++,h--;var c=s.slice(p).join(""),m=ue(t)&&c.length||c.match(/[1-9]/)?"."+c:"",v=s.slice(0,p).join("")+m+"e"+(n>=0?"+":"")+a.toString();return r.sign+v}function gd(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=ys(i),r=typeof t=="number"?bs(e,e.exponent+1+t):e,n=r.coefficients,s=r.exponent+1,a=s+(t||0);return n.length<a&&(n=n.concat(si(a-n.length))),s<0&&(n=si(-s+1).concat(n),s=1),s<n.length&&n.splice(s,0,s===0?"0.":"."),r.sign+n.join("")}function Pl(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=ys(i),r=t?bs(e,t):e,n=r.coefficients,s=r.exponent;n.length<t&&(n=n.concat(si(t-n.length)));var a=n.shift();return r.sign+a+(n.length>0?"."+n.join(""):"")+"e"+(s>=0?"+":"")+s}function vd(i,t,e){if(isNaN(i)||!isFinite(i))return String(i);var r=ql(e==null?void 0:e.lowerExp,-3),n=ql(e==null?void 0:e.upperExp,5),s=ys(i),a=t?bs(s,t):s;if(a.exponent<r||a.exponent>=n)return Pl(i,t);var l=a.coefficients,f=a.exponent;l.length<t&&(l=l.concat(si(t-l.length))),l=l.concat(si(f-l.length+1+(l.length<t?t-l.length:0))),l=si(-f).concat(l);var h=f>0?f:0;return h<l.length-1&&l.splice(h+1,0,"."),a.sign+l.join("")}function bs(i,t){for(var e={sign:i.sign,coefficients:i.coefficients,exponent:i.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 s=t-1;for(r[s]++;r[s]===10;)r.pop(),s===0&&(r.unshift(0),e.exponent++,s++),s--,r[s]++}}return e}function si(i){for(var t=[],e=0;e<i;e++)t.push(0);return t}function _d(i){return i.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var wd=Number.EPSILON||2220446049250313e-31;function zn(i,t,e){if(e==null)return i===t;if(i===t)return!0;if(isNaN(i)||isNaN(t))return!1;if(isFinite(i)&&isFinite(t)){var r=Math.abs(i-t);return r<=wd?!0:r<=Math.max(Math.abs(i),Math.abs(t))*e}return!1}function zl(i,t){if(ue(i))return i;if(ye(i))return i.toNumber();t()}function ql(i,t){return ue(i)?i:ye(i)?i.toNumber():t}function aa(i,t,e){var r=i.constructor,n=new r(2),s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!he(e))throw new Error("size must be an integer");if(i.greaterThan(n.pow(e-1).sub(1))||i.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(!i.isInteger())throw new Error("Value must be an integer");i.lessThan(0)&&(i=i.add(n.pow(e))),s="i".concat(e)}switch(t){case 2:return"".concat(i.toBinary()).concat(s);case 8:return"".concat(i.toOctal()).concat(s);case 16:return"".concat(i.toHexadecimal()).concat(s);default:throw new Error("Base ".concat(t," not supported "))}}function Dd(i,t){if(typeof t=="function")return t(i);if(!i.isFinite())return i.isNaN()?"NaN":i.gt(0)?"Infinity":"-Infinity";var{notation:e,precision:r,wordSize:n}=Ll(t);switch(e){case"fixed":return bd(i,r);case"exponential":return Ul(i,r);case"engineering":return yd(i,r);case"bin":return aa(i,2,n);case"oct":return aa(i,8,n);case"hex":return aa(i,16,n);case"auto":{var s=kl(t==null?void 0:t.lowerExp,-3),a=kl(t==null?void 0:t.upperExp,5);if(i.isZero())return"0";var l,f=i.toSignificantDigits(r),h=f.e;return h>=s&&h<a?l=f.toFixed():l=Ul(i,r),l.replace(/((\.\d*?)(0+))($|e)/,function(){var p=arguments[2],c=arguments[4];return p!=="."?p+c:c})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function yd(i,t){var e=i.e,r=e%3===0?e:e<0?e-3-e%3:e-e%3,n=i.mul(Math.pow(10,-r)),s=n.toPrecision(t);if(s.indexOf("e")!==-1){var a=i.constructor;s=new a(s).toFixed()}return s+"e"+(e>=0?"+":"")+r.toString()}function Ul(i,t){return t!==void 0?i.toExponential(t-1):i.toExponential()}function bd(i,t){return i.toFixed(t)}function kl(i,t){return ue(i)?i:ye(i)?i.toNumber():t}function se(i,t){var e=Ed(i,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function Ed(i,t){if(typeof i=="number")return oa(i,t);if(ye(i))return Dd(i,t);if(Ad(i))return!t||t.fraction!=="decimal"?i.s*i.n+"/"+i.d:i.toString();if(Array.isArray(i))return jl(i,t);if(Ur(i))return Wl(i);if(typeof i=="function")return i.syntax?String(i.syntax):"function";if(i&&typeof i=="object"){if(typeof i.format=="function")return i.format(t);if(i&&i.toString(t)!=={}.toString())return i.toString(t);var e=Object.keys(i).map(r=>Wl(r)+": "+se(i[r],t));return"{"+e.join(", ")+"}"}return String(i)}function Wl(i){for(var t=String(i),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in Yl?Yl[n]:n,r++}return'"'+e+'"'}var Yl={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function jl(i,t){if(Array.isArray(i)){for(var e="[",r=i.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=jl(i[n],t);return e+="]",e}else return se(i,t)}function Ad(i){return i&&typeof i=="object"&&typeof i.s=="number"&&typeof i.n=="number"&&typeof i.d=="number"||!1}function Zt(i,t,e){if(!(this instanceof Zt))throw new SyntaxError("Constructor must be called with the new operator");this.actual=i,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(i)?"["+i.join(", ")+"]":i)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}Zt.prototype=new RangeError,Zt.prototype.constructor=RangeError,Zt.prototype.name="DimensionError",Zt.prototype.isDimensionError=!0;function hn(i,t,e){if(!(this instanceof hn))throw new SyntaxError("Constructor must be called with the new operator");this.index=i,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}hn.prototype=new RangeError,hn.prototype.constructor=RangeError,hn.prototype.name="IndexError",hn.prototype.isIndexError=!0;function Ae(i){for(var t=[];Array.isArray(i);)t.push(i.length),i=i[0];return t}function Zl(i,t,e){var r,n=i.length;if(n!==t[e])throw new Zt(n,t[e]);if(e<t.length-1){var s=e+1;for(r=0;r<n;r++){var a=i[r];if(!Array.isArray(a))throw new Zt(t.length-1,t.length,"<");Zl(i[r],t,s)}}else for(r=0;r<n;r++)if(Array.isArray(i[r]))throw new Zt(t.length+1,t.length,">")}function Gl(i,t){var e=t.length===0;if(e){if(Array.isArray(i))throw new Zt(i.length,0)}else Zl(i,t,0)}function ve(i,t){if(i!==void 0){if(!ue(i)||!he(i))throw new TypeError("Index must be an integer (value: "+i+")");if(i<0||typeof t=="number"&&i>=t)throw new hn(i,t)}}function ua(i,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(!ue(n)||!he(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+se(t)+")")}),(ue(i)||ye(i))&&(i=[i]);var r=e!==void 0?e:0;return la(i,t,0,r),i}function la(i,t,e,r){var n,s,a=i.length,l=t[e],f=Math.min(a,l);if(i.length=l,e<t.length-1){var h=e+1;for(n=0;n<f;n++)s=i[n],Array.isArray(s)||(s=[s],i[n]=s),la(s,t,h,r);for(n=f;n<l;n++)s=[],i[n]=s,la(s,t,h,r)}else{for(n=0;n<f;n++)for(;Array.isArray(i[n]);)i[n]=i[n][0];for(n=f;n<l;n++)i[n]=r}}function fa(i,t){var e=ha(i),r=e.length;if(!Array.isArray(i)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Zt(0,r,"!=");t=ca(t,r);var n=Kl(t);if(r!==n)throw new Zt(n,r,"!=");try{return xd(e,t)}catch(s){throw s instanceof Zt?new Zt(n,r,"!="):s}}function ca(i,t){var e=Kl(i),r=i.slice(),n=-1,s=i.indexOf(n),a=i.indexOf(n,s+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var l=s>=0,f=t%e===0;if(l)if(f)r[s]=-t/e;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-e);return r}function Kl(i){return i.reduce((t,e)=>t*e,1)}function xd(i,t){for(var e=i,r,n=t.length-1;n>0;n--){var s=t[n];r=[];for(var a=e.length/s,l=0;l<a;l++)r.push(e.slice(l*s,(l+1)*s));e=r}return e}function Hl(i,t,e,r){var n=r||Ae(i);if(e)for(var s=0;s<e;s++)i=[i],n.unshift(1);for(i=Jl(i,t,0);n.length<t;)n.push(1);return i}function Jl(i,t,e){var r,n;if(Array.isArray(i)){var s=e+1;for(r=0,n=i.length;r<n;r++)i[r]=Jl(i[r],t,s)}else for(var a=e;a<t;a++)i=[i];return i}function ha(i){if(!Array.isArray(i))return i;var t=[];return i.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t}function Es(i,t){for(var e,r=0,n=0;n<i.length;n++){var s=i[n],a=Array.isArray(s);if(n===0&&a&&(r=s.length),a&&s.length!==r)return;var l=a?Es(s,t):t(s);if(e===void 0)e=l;else if(e!==l)return"mixed"}return e}function Xl(i,t,e,r){if(r<e){if(i.length!==t.length)throw new Zt(i.length,t.length);for(var n=[],s=0;s<i.length;s++)n[s]=Xl(i[s],t[s],e,r+1);return n}else return i.concat(t)}function Vl(){var i=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(i.length===1)return i[0];if(i.length>1)return i.slice(1).reduce(function(e,r){return Xl(e,r,t,0)},i[0]);throw new Error("Wrong number of arguments in function concat")}function Cd(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];for(var r=t.map(m=>m.length),n=Math.max(...r),s=new Array(n).fill(null),a=0;a<t.length;a++)for(var l=t[a],f=r[a],h=0;h<f;h++){var p=n-f+h;l[h]>s[p]&&(s[p]=l[h])}for(var c=0;c<t.length;c++)As(t[c],s);return s}function As(i,t){for(var e=t.length,r=i.length,n=0;n<r;n++){var s=e-r+n;if(i[n]<t[s]&&i[n]>1||i[n]>t[s])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(i,") not possible to broadcast dimension ").concat(r," with size ").concat(i[n]," to size ").concat(t[s]))}}function Ql(i,t){var e=Ae(i);if(ni(e,t))return i;As(e,t);var r=Cd(e,t),n=r.length,s=[...Array(n-e.length).fill(1),...e],a=Md(i);e.length<n&&(a=fa(a,s),e=Ae(a));for(var l=0;l<n;l++)e[l]<r[l]&&(a=Fd(a,r[l],l),e=Ae(a));return a}function Fd(i,t,e){return Vl(...Array(t).fill(i),e)}function Md(i){return Ds([],i)}function mt(i,t,e,r){function n(s){var a=hd(s,t.map(Bd));return Nd(i,t,s),e(a)}return n.isFactory=!0,n.fn=i,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function Nd(i,t,e){var r=t.filter(s=>!Sd(s)).every(s=>e[s]!==void 0);if(!r){var n=t.filter(s=>e[s]===void 0);throw new Error('Cannot create function "'.concat(i,'", ')+"some dependencies are missing: ".concat(n.map(s=>'"'.concat(s,'"')).join(", "),"."))}}function Sd(i){return i&&i[0]==="?"}function Bd(i){return i&&i[0]==="?"?i.slice(1):i}function Id(i,t){if(ef(i)&&tf(i,t))return i[t];throw typeof i[t]=="function"&&Od(i,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function Td(i,t,e){if(ef(i)&&tf(i,t))return i[t]=e,e;throw new Error('No access to property "'+t+'"')}function $d(i,t){return t in i}function tf(i,t){return!i||typeof i!="object"?!1:Ui(Rd,t)?!0:!(t in Object.prototype||t in Function.prototype)}function Od(i,t){return i==null||typeof i[t]!="function"||Ui(i,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(i)?!1:Ui(Ld,t)?!0:!(t in Object.prototype||t in Function.prototype)}function ef(i){return typeof i=="object"&&i&&i.constructor===Object}var Rd={length:!0,name:!0},Ld={toString:!0,valueOf:!0,toLocaleString:!0};class Pd{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return Id(this.wrappedObject,t)}set(t,e){return Td(this.wrappedObject,t,e),this}has(t){return $d(this.wrappedObject,t)}entries(){return zd(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 zd(i,t){return{next:()=>{var e=i.next();return e.done?e:{value:t(e.value),done:!1}}}}function qd(i){return i?i instanceof Map||i instanceof Pd||typeof i.set=="function"&&typeof i.get=="function"&&typeof i.keys=="function"&&typeof i.has=="function":!1}var rf=function(){return rf=Rl.create,Rl},Ud=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],kd=mt("typed",Ud,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:s}=t,a=rf();return a.clear(),a.addTypes([{name:"number",test:ue},{name:"Complex",test:Nl},{name:"BigNumber",test:ye},{name:"Fraction",test:Sl},{name:"Unit",test:Bl},{name:"identifier",test:l=>Ur&&/^(?:[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:Ur},{name:"Chain",test:fd},{name:"Array",test:ge},{name:"Matrix",test:fe},{name:"DenseMatrix",test:Lp},{name:"SparseMatrix",test:Pp},{name:"Range",test:zp},{name:"Index",test:na},{name:"boolean",test:qp},{name:"ResultSet",test:Up},{name:"Help",test:kp},{name:"function",test:Wp},{name:"Date",test:Yp},{name:"RegExp",test:jp},{name:"null",test:Zp},{name:"undefined",test:Gp},{name:"AccessorNode",test:Kp},{name:"ArrayNode",test:Hp},{name:"AssignmentNode",test:Jp},{name:"BlockNode",test:Xp},{name:"ConditionalNode",test:Vp},{name:"ConstantNode",test:Qp},{name:"FunctionNode",test:ed},{name:"FunctionAssignmentNode",test:td},{name:"IndexNode",test:rd},{name:"Node",test:nd},{name:"ObjectNode",test:id},{name:"OperatorNode",test:sd},{name:"ParenthesisNode",test:od},{name:"RangeNode",test:ad},{name:"RelationalNode",test:ud},{name:"SymbolNode",test:ld},{name:"Map",test:qd},{name:"Object",test:ia}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(f){if(e||pa(f),_d(f)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+f+"). Use function bignumber(x) to convert to BigNumber.");return new e(f)}},{from:"number",to:"Complex",convert:function(f){return r||xs(f),new r(f,0)}},{from:"BigNumber",to:"Complex",convert:function(f){return r||xs(f),new r(f.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(f){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(f){return r||xs(f),new r(f.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(f){s||da(f);var h=new s(f);if(h.valueOf()!==f)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+f+"). Use function fraction(x) to convert to Fraction.");return h}},{from:"string",to:"number",convert:function(f){var h=Number(f);if(isNaN(h))throw new Error('Cannot convert "'+f+'" to a number');return h}},{from:"string",to:"BigNumber",convert:function(f){e||pa(f);try{return new e(f)}catch{throw new Error('Cannot convert "'+f+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(f){s||da(f);try{return new s(f)}catch{throw new Error('Cannot convert "'+f+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(f){r||xs(f);try{return new r(f)}catch{throw new Error('Cannot convert "'+f+'" to Complex')}}},{from:"boolean",to:"number",convert:function(f){return+f}},{from:"boolean",to:"BigNumber",convert:function(f){return e||pa(f),new e(+f)}},{from:"boolean",to:"Fraction",convert:function(f){return s||da(f),new s(+f)}},{from:"boolean",to:"string",convert:function(f){return String(f)}},{from:"Array",to:"Matrix",convert:function(f){return n||Wd(),new n(f)}},{from:"Matrix",to:"Array",convert:function(f){return f.valueOf()}}]),a.onMismatch=(l,f,h)=>{var p=a.createError(l,f,h);if(["wrongType","mismatch"].includes(p.data.category)&&f.length===1&&qi(f[0])&&h.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw c.data=p.data,c}throw p},a.onMismatch=(l,f,h)=>{var p=a.createError(l,f,h);if(["wrongType","mismatch"].includes(p.data.category)&&f.length===1&&qi(f[0])&&h.some(m=>!m.params.includes(","))){var c=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw c.data=p.data,c}throw p},a});function pa(i){throw new Error("Cannot convert value ".concat(i," into a BigNumber: no class 'BigNumber' provided"))}function xs(i){throw new Error("Cannot convert value ".concat(i," into a Complex number: no class 'Complex' provided"))}function Wd(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function da(i){throw new Error("Cannot convert value ".concat(i," 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 oi=9e15,pn=1e9,ma="0123456789abcdef",Cs="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Fs="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ga={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-oi,maxE:oi,crypto:!1},nf,Kr,Nt=!0,Ms="[DecimalError] ",dn=Ms+"Invalid argument: ",sf=Ms+"Precision limit exceeded",of=Ms+"crypto unavailable",af="[object Decimal]",qe=Math.floor,Fe=Math.pow,Yd=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,jd=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Zd=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,uf=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Sr=1e7,Et=7,Gd=9007199254740991,Kd=Cs.length-1,va=Fs.length-1,it={toStringTag:af};it.absoluteValue=it.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),Dt(i)},it.ceil=function(){return Dt(new this.constructor(this),this.e+1,2)},it.clampedTo=it.clamp=function(i,t){var e,r=this,n=r.constructor;if(i=new n(i),t=new n(t),!i.s||!t.s)return new n(NaN);if(i.gt(t))throw Error(dn+t);return e=r.cmp(i),e<0?i:r.cmp(t)>0?t:new n(r)},it.comparedTo=it.cmp=function(i){var t,e,r,n,s=this,a=s.d,l=(i=new s.constructor(i)).d,f=s.s,h=i.s;if(!a||!l)return!f||!h?NaN:f!==h?f:a===l?0:!a^f<0?1:-1;if(!a[0]||!l[0])return a[0]?f:l[0]?-h:0;if(f!==h)return f;if(s.e!==i.e)return s.e>i.e^f<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]^f<0?1:-1;return r===n?0:r>n^f<0?1:-1},it.cosine=it.cos=function(){var i,t,e=this,r=e.constructor;return e.d?e.d[0]?(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=Hd(r,df(r,e)),r.precision=i,r.rounding=t,Dt(Kr==2||Kr==3?e.neg():e,i,t,!0)):new r(1):new r(NaN)},it.cubeRoot=it.cbrt=function(){var i,t,e,r,n,s,a,l,f,h,p=this,c=p.constructor;if(!p.isFinite()||p.isZero())return new c(p);for(Nt=!1,s=p.s*Fe(p.s*p,1/3),!s||Math.abs(s)==1/0?(e=Oe(p.d),i=p.e,(s=(i-e.length+1)%3)&&(e+=s==1||s==-2?"0":"00"),s=Fe(e,1/3),i=qe((i+1)/3)-(i%3==(i<0?-1:2)),s==1/0?e="5e"+i:(e=s.toExponential(),e=e.slice(0,e.indexOf("e")+1)+i),r=new c(e),r.s=p.s):r=new c(s.toString()),a=(i=c.precision)+3;;)if(l=r,f=l.times(l).times(l),h=f.plus(p),r=oe(h.plus(p).times(l),h.plus(f),a+2,1),Oe(l.d).slice(0,a)===(e=Oe(r.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!n&&e=="4999"){if(!n&&(Dt(l,i+1,0),l.times(l).times(l).eq(p))){r=l;break}a+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Dt(r,i+1,1),t=!r.times(r).times(r).eq(p));break}return Nt=!0,Dt(r,i,c.rounding,t)},it.decimalPlaces=it.dp=function(){var i,t=this.d,e=NaN;if(t){if(i=t.length-1,e=(i-qe(this.e/Et))*Et,i=t[i],i)for(;i%10==0;i/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(i){return oe(this,new this.constructor(i))},it.dividedToIntegerBy=it.divToInt=function(i){var t=this,e=t.constructor;return Dt(oe(t,new e(i),0,1,1),e.precision,e.rounding)},it.equals=it.eq=function(i){return this.cmp(i)===0},it.floor=function(){return Dt(new this.constructor(this),this.e+1,3)},it.greaterThan=it.gt=function(i){return this.cmp(i)>0},it.greaterThanOrEqualTo=it.gte=function(i){var t=this.cmp(i);return t==1||t===0},it.hyperbolicCosine=it.cosh=function(){var i,t,e,r,n,s=this,a=s.constructor,l=new a(1);if(!s.isFinite())return new a(s.s?1/0:NaN);if(s.isZero())return l;e=a.precision,r=a.rounding,a.precision=e+Math.max(s.e,s.sd())+4,a.rounding=1,n=s.d.length,n<32?(i=Math.ceil(n/3),t=(1/Is(4,i)).toString()):(i=16,t="2.3283064365386962890625e-10"),s=ai(a,1,s.times(t),new a(1),!0);for(var f,h=i,p=new a(8);h--;)f=s.times(s),s=l.minus(f.times(p.minus(f.times(p))));return Dt(s,a.precision=e,a.rounding=r,!0)},it.hyperbolicSine=it.sinh=function(){var i,t,e,r,n=this,s=n.constructor;if(!n.isFinite()||n.isZero())return new s(n);if(t=s.precision,e=s.rounding,s.precision=t+Math.max(n.e,n.sd())+4,s.rounding=1,r=n.d.length,r<3)n=ai(s,2,n,n,!0);else{i=1.4*Math.sqrt(r),i=i>16?16:i|0,n=n.times(1/Is(5,i)),n=ai(s,2,n,n,!0);for(var a,l=new s(5),f=new s(16),h=new s(20);i--;)a=n.times(n),n=n.times(l.plus(a.times(f.times(a).plus(h))))}return s.precision=t,s.rounding=e,Dt(n,t,e,!0)},it.hyperbolicTangent=it.tanh=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+7,r.rounding=1,oe(e.sinh(),e.cosh(),r.precision=i,r.rounding=t)):new r(e.s)},it.inverseCosine=it.acos=function(){var i,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,s=e.rounding;return r!==-1?r===0?t.isNeg()?Br(e,n,s):new e(0):new e(NaN):t.isZero()?Br(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),i=Br(e,n+4,s).times(.5),e.precision=n,e.rounding=s,i.minus(t))},it.inverseHyperbolicCosine=it.acosh=function(){var i,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(i=r.precision,t=r.rounding,r.precision=i+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,Nt=!1,e=e.times(e).minus(1).sqrt().plus(e),Nt=!0,r.precision=i,r.rounding=t,e.ln()):new r(e)},it.inverseHyperbolicSine=it.asinh=function(){var i,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,Nt=!1,e=e.times(e).plus(1).sqrt().plus(e),Nt=!0,r.precision=i,r.rounding=t,e.ln())},it.inverseHyperbolicTangent=it.atanh=function(){var i,t,e,r,n=this,s=n.constructor;return n.isFinite()?n.e>=0?new s(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(i=s.precision,t=s.rounding,r=n.sd(),Math.max(r,i)<2*-n.e-1?Dt(new s(n),i,t,!0):(s.precision=e=r-n.e,n=oe(n.plus(1),new s(1).minus(n),e+i,1),s.precision=i+4,s.rounding=1,n=n.ln(),s.precision=i,s.rounding=t,n.times(.5))):new s(NaN)},it.inverseSine=it.asin=function(){var i,t,e,r,n=this,s=n.constructor;return n.isZero()?new s(n):(t=n.abs().cmp(1),e=s.precision,r=s.rounding,t!==-1?t===0?(i=Br(s,e+4,r).times(.5),i.s=n.s,i):new s(NaN):(s.precision=e+6,s.rounding=1,n=n.div(new s(1).minus(n.times(n)).sqrt().plus(1)).atan(),s.precision=e,s.rounding=r,n.times(2)))},it.inverseTangent=it.atan=function(){var i,t,e,r,n,s,a,l,f,h=this,p=h.constructor,c=p.precision,m=p.rounding;if(h.isFinite()){if(h.isZero())return new p(h);if(h.abs().eq(1)&&c+4<=va)return a=Br(p,c+4,m).times(.25),a.s=h.s,a}else{if(!h.s)return new p(NaN);if(c+4<=va)return a=Br(p,c+4,m).times(.5),a.s=h.s,a}for(p.precision=l=c+10,p.rounding=1,e=Math.min(28,l/Et+2|0),i=e;i;--i)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(Nt=!1,t=Math.ceil(l/Et),r=1,f=h.times(h),a=new p(h),n=h;i!==-1;)if(n=n.times(f),s=a.minus(n.div(r+=2)),n=n.times(f),a=s.plus(n.div(r+=2)),a.d[t]!==void 0)for(i=t;a.d[i]===s.d[i]&&i--;);return e&&(a=a.times(2<<e-1)),Nt=!0,Dt(a,p.precision=c,p.rounding=m,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&qe(this.e/Et)>this.d.length-2},it.isNaN=function(){return!this.s},it.isNegative=it.isNeg=function(){return this.s<0},it.isPositive=it.isPos=function(){return this.s>0},it.isZero=function(){return!!this.d&&this.d[0]===0},it.lessThan=it.lt=function(i){return this.cmp(i)<0},it.lessThanOrEqualTo=it.lte=function(i){return this.cmp(i)<1},it.logarithm=it.log=function(i){var t,e,r,n,s,a,l,f,h=this,p=h.constructor,c=p.precision,m=p.rounding,v=5;if(i==null)i=new p(10),t=!0;else{if(i=new p(i),e=i.d,i.s<0||!e||!e[0]||i.eq(1))return new p(NaN);t=i.eq(10)}if(e=h.d,h.s<0||!e||!e[0]||h.eq(1))return new p(e&&!e[0]?-1/0:h.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)s=!0;else{for(n=e[0];n%10===0;)n/=10;s=n!==1}if(Nt=!1,l=c+v,a=gn(h,l),r=t?Bs(p,l+10):gn(i,l),f=oe(a,r,l,1),ki(f.d,n=c,m))do if(l+=10,a=gn(h,l),r=t?Bs(p,l+10):gn(i,l),f=oe(a,r,l,1),!s){+Oe(f.d).slice(n+1,n+15)+1==1e14&&(f=Dt(f,c+1,0));break}while(ki(f.d,n+=10,m));return Nt=!0,Dt(f,c,m)},it.minus=it.sub=function(i){var t,e,r,n,s,a,l,f,h,p,c,m,v=this,w=v.constructor;if(i=new w(i),!v.d||!i.d)return!v.s||!i.s?i=new w(NaN):v.d?i.s=-i.s:i=new w(i.d||v.s!==i.s?v:NaN),i;if(v.s!=i.s)return i.s=-i.s,v.plus(i);if(h=v.d,m=i.d,l=w.precision,f=w.rounding,!h[0]||!m[0]){if(m[0])i.s=-i.s;else if(h[0])i=new w(v);else return new w(f===3?-0:0);return Nt?Dt(i,l,f):i}if(e=qe(i.e/Et),p=qe(v.e/Et),h=h.slice(),s=p-e,s){for(c=s<0,c?(t=h,s=-s,a=m.length):(t=m,e=p,a=h.length),r=Math.max(Math.ceil(l/Et),a)+2,s>r&&(s=r,t.length=1),t.reverse(),r=s;r--;)t.push(0);t.reverse()}else{for(r=h.length,a=m.length,c=r<a,c&&(a=r),r=0;r<a;r++)if(h[r]!=m[r]){c=h[r]<m[r];break}s=0}for(c&&(t=h,h=m,m=t,i.s=-i.s),a=h.length,r=m.length-a;r>0;--r)h[a++]=0;for(r=m.length;r>s;){if(h[--r]<m[r]){for(n=r;n&&h[--n]===0;)h[n]=Sr-1;--h[n],h[r]+=Sr}h[r]-=m[r]}for(;h[--a]===0;)h.pop();for(;h[0]===0;h.shift())--e;return h[0]?(i.d=h,i.e=Ss(h,e),Nt?Dt(i,l,f):i):new w(f===3?-0:0)},it.modulo=it.mod=function(i){var t,e=this,r=e.constructor;return i=new r(i),!e.d||!i.s||i.d&&!i.d[0]?new r(NaN):!i.d||e.d&&!e.d[0]?Dt(new r(e),r.precision,r.rounding):(Nt=!1,r.modulo==9?(t=oe(e,i.abs(),0,3,1),t.s*=i.s):t=oe(e,i,0,r.modulo,1),t=t.times(i),Nt=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return _a(this)},it.naturalLogarithm=it.ln=function(){return gn(this)},it.negated=it.neg=function(){var i=new this.constructor(this);return i.s=-i.s,Dt(i)},it.plus=it.add=function(i){var t,e,r,n,s,a,l,f,h,p,c=this,m=c.constructor;if(i=new m(i),!c.d||!i.d)return!c.s||!i.s?i=new m(NaN):c.d||(i=new m(i.d||c.s===i.s?c:NaN)),i;if(c.s!=i.s)return i.s=-i.s,c.minus(i);if(h=c.d,p=i.d,l=m.precision,f=m.rounding,!h[0]||!p[0])return p[0]||(i=new m(c)),Nt?Dt(i,l,f):i;if(s=qe(c.e/Et),r=qe(i.e/Et),h=h.slice(),n=s-r,n){for(n<0?(e=h,n=-n,a=p.length):(e=p,r=s,a=h.length),s=Math.ceil(l/Et),a=s>a?s+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=h.length,n=p.length,a-n<0&&(n=a,e=p,p=h,h=e),t=0;n;)t=(h[--n]=h[n]+p[n]+t)/Sr|0,h[n]%=Sr;for(t&&(h.unshift(t),++r),a=h.length;h[--a]==0;)h.pop();return i.d=h,i.e=Ss(h,r),Nt?Dt(i,l,f):i},it.precision=it.sd=function(i){var t,e=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(dn+i);return e.d?(t=lf(e.d),i&&e.e+1>t&&(t=e.e+1)):t=NaN,t},it.round=function(){var i=this,t=i.constructor;return Dt(new t(i),i.e+1,t.rounding)},it.sine=it.sin=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=Xd(r,df(r,e)),r.precision=i,r.rounding=t,Dt(Kr>2?e.neg():e,i,t,!0)):new r(NaN)},it.squareRoot=it.sqrt=function(){var i,t,e,r,n,s,a=this,l=a.d,f=a.e,h=a.s,p=a.constructor;if(h!==1||!l||!l[0])return new p(!h||h<0&&(!l||l[0])?NaN:l?a:1/0);for(Nt=!1,h=Math.sqrt(+a),h==0||h==1/0?(t=Oe(l),(t.length+f)%2==0&&(t+="0"),h=Math.sqrt(t),f=qe((f+1)/2)-(f<0||f%2),h==1/0?t="5e"+f:(t=h.toExponential(),t=t.slice(0,t.indexOf("e")+1)+f),r=new p(t)):r=new p(h.toString()),e=(f=p.precision)+3;;)if(s=r,r=s.plus(oe(a,s,e+2,1)).times(.5),Oe(s.d).slice(0,e)===(t=Oe(r.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!n&&t=="4999"){if(!n&&(Dt(s,f+1,0),s.times(s).eq(a))){r=s;break}e+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Dt(r,f+1,1),i=!r.times(r).eq(a));break}return Nt=!0,Dt(r,f,p.rounding,i)},it.tangent=it.tan=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+10,r.rounding=1,e=e.sin(),e.s=1,e=oe(e,new r(1).minus(e.times(e)).sqrt(),i+10,0),r.precision=i,r.rounding=t,Dt(Kr==2||Kr==4?e.neg():e,i,t,!0)):new r(NaN)},it.times=it.mul=function(i){var t,e,r,n,s,a,l,f,h,p=this,c=p.constructor,m=p.d,v=(i=new c(i)).d;if(i.s*=p.s,!m||!m[0]||!v||!v[0])return new c(!i.s||m&&!m[0]&&!v||v&&!v[0]&&!m?NaN:!m||!v?i.s/0:i.s*0);for(e=qe(p.e/Et)+qe(i.e/Et),f=m.length,h=v.length,f<h&&(s=m,m=v,v=s,a=f,f=h,h=a),s=[],a=f+h,r=a;r--;)s.push(0);for(r=h;--r>=0;){for(t=0,n=f+r;n>r;)l=s[n]+v[r]*m[n-r-1]+t,s[n--]=l%Sr|0,t=l/Sr|0;s[n]=(s[n]+t)%Sr|0}for(;!s[--a];)s.pop();return t?++e:s.shift(),i.d=s,i.e=Ss(s,e),Nt?Dt(i,c.precision,c.rounding):i},it.toBinary=function(i,t){return Da(this,2,i,t)},it.toDecimalPlaces=it.toDP=function(i,t){var e=this,r=e.constructor;return e=new r(e),i===void 0?e:(He(i,0,pn),t===void 0?t=r.rounding:He(t,0,8),Dt(e,i+e.e+1,t))},it.toExponential=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=kr(r,!0):(He(i,0,pn),t===void 0?t=n.rounding:He(t,0,8),r=Dt(new n(r),i+1,t),e=kr(r,!0,i+1)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toFixed=function(i,t){var e,r,n=this,s=n.constructor;return i===void 0?e=kr(n):(He(i,0,pn),t===void 0?t=s.rounding:He(t,0,8),r=Dt(new s(n),i+n.e+1,t),e=kr(r,!1,i+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},it.toFraction=function(i){var t,e,r,n,s,a,l,f,h,p,c,m,v=this,w=v.d,g=v.constructor;if(!w)return new g(v);if(h=e=new g(1),r=f=new g(0),t=new g(r),s=t.e=lf(w)-v.e-1,a=s%Et,t.d[0]=Fe(10,a<0?Et+a:a),i==null)i=s>0?t:h;else{if(l=new g(i),!l.isInt()||l.lt(h))throw Error(dn+l);i=l.gt(t)?s>0?t:h:l}for(Nt=!1,l=new g(Oe(w)),p=g.precision,g.precision=s=w.length*Et*2;c=oe(l,t,0,1,1),n=e.plus(c.times(r)),n.cmp(i)!=1;)e=r,r=n,n=h,h=f.plus(c.times(n)),f=n,n=t,t=l.minus(c.times(n)),l=n;return n=oe(i.minus(e),r,0,1,1),f=f.plus(n.times(h)),e=e.plus(n.times(r)),f.s=h.s=v.s,m=oe(h,r,s,1).minus(v).abs().cmp(oe(f,e,s,1).minus(v).abs())<1?[h,r]:[f,e],g.precision=p,Nt=!0,m},it.toHexadecimal=it.toHex=function(i,t){return Da(this,16,i,t)},it.toNearest=function(i,t){var e=this,r=e.constructor;if(e=new r(e),i==null){if(!e.d)return e;i=new r(1),t=r.rounding}else{if(i=new r(i),t===void 0?t=r.rounding:He(t,0,8),!e.d)return i.s?e:i;if(!i.d)return i.s&&(i.s=e.s),i}return i.d[0]?(Nt=!1,e=oe(e,i,0,t,1).times(i),Nt=!0,Dt(e)):(i.s=e.s,e=i),e},it.toNumber=function(){return+this},it.toOctal=function(i,t){return Da(this,8,i,t)},it.toPower=it.pow=function(i){var t,e,r,n,s,a,l=this,f=l.constructor,h=+(i=new f(i));if(!l.d||!i.d||!l.d[0]||!i.d[0])return new f(Fe(+l,h));if(l=new f(l),l.eq(1))return l;if(r=f.precision,s=f.rounding,i.eq(1))return Dt(l,r,s);if(t=qe(i.e/Et),t>=i.d.length-1&&(e=h<0?-h:h)<=Gd)return n=ff(f,l,e,r),i.s<0?new f(1).div(n):Dt(n,r,s);if(a=l.s,a<0){if(t<i.d.length-1)return new f(NaN);if(i.d[t]&1||(a=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=a,l}return e=Fe(+l,h),t=e==0||!isFinite(e)?qe(h*(Math.log("0."+Oe(l.d))/Math.LN10+l.e+1)):new f(e+"").e,t>f.maxE+1||t<f.minE-1?new f(t>0?a/0:0):(Nt=!1,f.rounding=l.s=1,e=Math.min(12,(t+"").length),n=_a(i.times(gn(l,r+e)),r),n.d&&(n=Dt(n,r+5,1),ki(n.d,r,s)&&(t=r+10,n=Dt(_a(i.times(gn(l,t+e)),t),t+5,1),+Oe(n.d).slice(r+1,r+15)+1==1e14&&(n=Dt(n,r+1,0)))),n.s=a,Nt=!0,f.rounding=s,Dt(n,r,s))},it.toPrecision=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=kr(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(He(i,1,pn),t===void 0?t=n.rounding:He(t,0,8),r=Dt(new n(r),i,t),e=kr(r,i<=r.e||r.e<=n.toExpNeg,i)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toSignificantDigits=it.toSD=function(i,t){var e=this,r=e.constructor;return i===void 0?(i=r.precision,t=r.rounding):(He(i,1,pn),t===void 0?t=r.rounding:He(t,0,8)),Dt(new r(e),i,t)},it.toString=function(){var i=this,t=i.constructor,e=kr(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()&&!i.isZero()?"-"+e:e},it.truncated=it.trunc=function(){return Dt(new this.constructor(this),this.e+1,1)},it.valueOf=it.toJSON=function(){var i=this,t=i.constructor,e=kr(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()?"-"+e:e};function Oe(i){var t,e,r,n=i.length-1,s="",a=i[0];if(n>0){for(s+=a,t=1;t<n;t++)r=i[t]+"",e=Et-r.length,e&&(s+=mn(e)),s+=r;a=i[t],r=a+"",e=Et-r.length,e&&(s+=mn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}function He(i,t,e){if(i!==~~i||i<t||i>e)throw Error(dn+i)}function ki(i,t,e,r){var n,s,a,l;for(s=i[0];s>=10;s/=10)--t;return--t<0?(t+=Et,n=0):(n=Math.ceil((t+1)/Et),t%=Et),s=Fe(10,Et-t),l=i[n]%s|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==s||e>3&&l+1==s/2)&&(i[n+1]/s/100|0)==Fe(10,t-2)-1||(l==s/2||l==0)&&(i[n+1]/s/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==s||!r&&e>3&&l+1==s/2)&&(i[n+1]/s/1e3|0)==Fe(10,t-3)-1,a}function Ns(i,t,e){for(var r,n=[0],s,a=0,l=i.length;a<l;){for(s=n.length;s--;)n[s]*=t;for(n[0]+=ma.indexOf(i.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 Hd(i,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/Is(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i.precision+=e,t=ai(i,1,t.times(n),new i(1));for(var s=e;s--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return i.precision-=e,t}var oe=function(){function i(r,n,s){var a,l=0,f=r.length;for(r=r.slice();f--;)a=r[f]*n+l,r[f]=a%s|0,l=a/s|0;return l&&r.unshift(l),r}function t(r,n,s,a){var l,f;if(s!=a)f=s>a?1:-1;else for(l=f=0;l<s;l++)if(r[l]!=n[l]){f=r[l]>n[l]?1:-1;break}return f}function e(r,n,s,a){for(var l=0;s--;)r[s]-=l,l=r[s]<n[s]?1:0,r[s]=l*a+r[s]-n[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,s,a,l,f){var h,p,c,m,v,w,g,y,_,E,b,N,A,C,M,S,$,F,I,R,U=r.constructor,q=r.s==n.s?1:-1,k=r.d,P=n.d;if(!k||!k[0]||!P||!P[0])return new U(!r.s||!n.s||(k?P&&k[0]==P[0]:!P)?NaN:k&&k[0]==0||!P?q*0:q/0);for(f?(v=1,p=r.e-n.e):(f=Sr,v=Et,p=qe(r.e/v)-qe(n.e/v)),I=P.length,$=k.length,_=new U(q),E=_.d=[],c=0;P[c]==(k[c]||0);c++);if(P[c]>(k[c]||0)&&p--,s==null?(C=s=U.precision,a=U.rounding):l?C=s+(r.e-n.e)+1:C=s,C<0)E.push(1),w=!0;else{if(C=C/v+2|0,c=0,I==1){for(m=0,P=P[0],C++;(c<$||m)&&C--;c++)M=m*f+(k[c]||0),E[c]=M/P|0,m=M%P|0;w=m||c<$}else{for(m=f/(P[0]+1)|0,m>1&&(P=i(P,m,f),k=i(k,m,f),I=P.length,$=k.length),S=I,b=k.slice(0,I),N=b.length;N<I;)b[N++]=0;R=P.slice(),R.unshift(0),F=P[0],P[1]>=f/2&&++F;do m=0,h=t(P,b,I,N),h<0?(A=b[0],I!=N&&(A=A*f+(b[1]||0)),m=A/F|0,m>1?(m>=f&&(m=f-1),g=i(P,m,f),y=g.length,N=b.length,h=t(g,b,y,N),h==1&&(m--,e(g,I<y?R:P,y,f))):(m==0&&(h=m=1),g=P.slice()),y=g.length,y<N&&g.unshift(0),e(b,g,N,f),h==-1&&(N=b.length,h=t(P,b,I,N),h<1&&(m++,e(b,I<N?R:P,N,f))),N=b.length):h===0&&(m++,b=[0]),E[c++]=m,h&&b[0]?b[N++]=k[S]||0:(b=[k[S]],N=1);while((S++<$||b[0]!==void 0)&&C--);w=b[0]!==void 0}E[0]||E.shift()}if(v==1)_.e=p,nf=w;else{for(c=1,m=E[0];m>=10;m/=10)c++;_.e=c+p*v-1,Dt(_,l?s+_.e+1:s,a,w)}return _}}();function Dt(i,t,e,r){var n,s,a,l,f,h,p,c,m,v=i.constructor;t:if(t!=null){if(c=i.d,!c)return i;for(n=1,l=c[0];l>=10;l/=10)n++;if(s=t-n,s<0)s+=Et,a=t,p=c[m=0],f=p/Fe(10,n-a-1)%10|0;else if(m=Math.ceil((s+1)/Et),l=c.length,m>=l)if(r){for(;l++<=m;)c.push(0);p=f=0,n=1,s%=Et,a=s-Et+1}else break t;else{for(p=l=c[m],n=1;l>=10;l/=10)n++;s%=Et,a=s-Et+n,f=a<0?0:p/Fe(10,n-a-1)%10|0}if(r=r||t<0||c[m+1]!==void 0||(a<0?p:p%Fe(10,n-a-1)),h=e<4?(f||r)&&(e==0||e==(i.s<0?3:2)):f>5||f==5&&(e==4||r||e==6&&(s>0?a>0?p/Fe(10,n-a):0:c[m-1])%10&1||e==(i.s<0?8:7)),t<1||!c[0])return c.length=0,h?(t-=i.e+1,c[0]=Fe(10,(Et-t%Et)%Et),i.e=-t||0):c[0]=i.e=0,i;if(s==0?(c.length=m,l=1,m--):(c.length=m+1,l=Fe(10,Et-s),c[m]=a>0?(p/Fe(10,n-a)%Fe(10,a)|0)*l:0),h)for(;;)if(m==0){for(s=1,a=c[0];a>=10;a/=10)s++;for(a=c[0]+=l,l=1;a>=10;a/=10)l++;s!=l&&(i.e++,c[0]==Sr&&(c[0]=1));break}else{if(c[m]+=l,c[m]!=Sr)break;c[m--]=0,l=1}for(s=c.length;c[--s]===0;)c.pop()}return Nt&&(i.e>v.maxE?(i.d=null,i.e=NaN):i.e<v.minE&&(i.e=0,i.d=[0])),i}function kr(i,t,e){if(!i.isFinite())return pf(i);var r,n=i.e,s=Oe(i.d),a=s.length;return t?(e&&(r=e-a)>0?s=s.charAt(0)+"."+s.slice(1)+mn(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i.e<0?"e":"e+")+i.e):n<0?(s="0."+mn(-n-1)+s,e&&(r=e-a)>0&&(s+=mn(r))):n>=a?(s+=mn(n+1-a),e&&(r=e-n-1)>0&&(s=s+"."+mn(r))):((r=n+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(s+="."),s+=mn(r))),s}function Ss(i,t){var e=i[0];for(t*=Et;e>=10;e/=10)t++;return t}function Bs(i,t,e){if(t>Kd)throw Nt=!0,e&&(i.precision=e),Error(sf);return Dt(new i(Cs),t,1,!0)}function Br(i,t,e){if(t>va)throw Error(sf);return Dt(new i(Fs),t,e,!0)}function lf(i){var t=i.length-1,e=t*Et+1;if(t=i[t],t){for(;t%10==0;t/=10)e--;for(t=i[0];t>=10;t/=10)e++}return e}function mn(i){for(var t="";i--;)t+="0";return t}function ff(i,t,e,r){var n,s=new i(1),a=Math.ceil(r/Et+4);for(Nt=!1;;){if(e%2&&(s=s.times(t),mf(s.d,a)&&(n=!0)),e=qe(e/2),e===0){e=s.d.length-1,n&&s.d[e]===0&&++s.d[e];break}t=t.times(t),mf(t.d,a)}return Nt=!0,s}function cf(i){return i.d[i.d.length-1]&1}function hf(i,t,e){for(var r,n=new i(t[0]),s=0;++s<t.length;)if(r=new i(t[s]),r.s)n[e](r)&&(n=r);else{n=r;break}return n}function _a(i,t){var e,r,n,s,a,l,f,h=0,p=0,c=0,m=i.constructor,v=m.rounding,w=m.precision;if(!i.d||!i.d[0]||i.e>17)return new m(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:NaN);for(t==null?(Nt=!1,f=w):f=t,l=new m(.03125);i.e>-2;)i=i.times(l),c+=5;for(r=Math.log(Fe(2,c))/Math.LN10*2+5|0,f+=r,e=s=a=new m(1),m.precision=f;;){if(s=Dt(s.times(i),f,1),e=e.times(++p),l=a.plus(oe(s,e,f,1)),Oe(l.d).slice(0,f)===Oe(a.d).slice(0,f)){for(n=c;n--;)a=Dt(a.times(a),f,1);if(t==null)if(h<3&&ki(a.d,f-r,v,h))m.precision=f+=10,e=s=l=new m(1),p=0,h++;else return Dt(a,m.precision=w,v,Nt=!0);else return m.precision=w,a}a=l}}function gn(i,t){var e,r,n,s,a,l,f,h,p,c,m,v=1,w=10,g=i,y=g.d,_=g.constructor,E=_.rounding,b=_.precision;if(g.s<0||!y||!y[0]||!g.e&&y[0]==1&&y.length==1)return new _(y&&!y[0]?-1/0:g.s!=1?NaN:y?0:g);if(t==null?(Nt=!1,p=b):p=t,_.precision=p+=w,e=Oe(y),r=e.charAt(0),Math.abs(s=g.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)g=g.times(i),e=Oe(g.d),r=e.charAt(0),v++;s=g.e,r>1?(g=new _("0."+e),s++):g=new _(r+"."+e.slice(1))}else return h=Bs(_,p+2,b).times(s+""),g=gn(new _(r+"."+e.slice(1)),p-w).plus(h),_.precision=b,t==null?Dt(g,b,E,Nt=!0):g;for(c=g,f=a=g=oe(g.minus(1),g.plus(1),p,1),m=Dt(g.times(g),p,1),n=3;;){if(a=Dt(a.times(m),p,1),h=f.plus(oe(a,new _(n),p,1)),Oe(h.d).slice(0,p)===Oe(f.d).slice(0,p))if(f=f.times(2),s!==0&&(f=f.plus(Bs(_,p+2,b).times(s+""))),f=oe(f,new _(v),p,1),t==null)if(ki(f.d,p-w,E,l))_.precision=p+=w,h=a=g=oe(c.minus(1),c.plus(1),p,1),m=Dt(g.times(g),p,1),n=l=1;else return Dt(f,_.precision=b,E,Nt=!0);else return _.precision=b,f;f=h,n+=2}}function pf(i){return String(i.s*i.s/0)}function wa(i,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,i.e=e=e-r-1,i.d=[],r=(e+1)%Et,e<0&&(r+=Et),r<n){for(r&&i.d.push(+t.slice(0,r)),n-=Et;r<n;)i.d.push(+t.slice(r,r+=Et));t=t.slice(r),r=Et-t.length}else r-=n;for(;r--;)t+="0";i.d.push(+t),Nt&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function Jd(i,t){var e,r,n,s,a,l,f,h,p;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),uf.test(t))return wa(i,t)}else if(t==="Infinity"||t==="NaN")return+t||(i.s=NaN),i.e=NaN,i.d=null,i;if(jd.test(t))e=16,t=t.toLowerCase();else if(Yd.test(t))e=2;else if(Zd.test(t))e=8;else throw Error(dn+t);for(s=t.search(/p/i),s>0?(f=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),a=s>=0,r=i.constructor,a&&(t=t.replace(".",""),l=t.length,s=l-s,n=ff(r,new r(e),s,s*2)),h=Ns(t,e,Sr),p=h.length-1,s=p;h[s]===0;--s)h.pop();return s<0?new r(i.s*0):(i.e=Ss(h,p),i.d=h,Nt=!1,a&&(i=oe(i,n,l*4)),f&&(i=i.times(Math.abs(f)<54?Fe(2,f):ui.pow(2,f))),Nt=!0,i)}function Xd(i,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:ai(i,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/Is(5,e)),t=ai(i,2,t,t);for(var n,s=new i(5),a=new i(16),l=new i(20);e--;)n=t.times(t),t=t.times(s.plus(n.times(a.times(n).minus(l))));return t}function ai(i,t,e,r,n){var s,a,l,f,h=i.precision,p=Math.ceil(h/Et);for(Nt=!1,f=e.times(e),l=new i(r);;){if(a=oe(l.times(f),new i(t++*t++),h,1),l=n?r.plus(a):r.minus(a),r=oe(a.times(f),new i(t++*t++),h,1),a=l.plus(r),a.d[p]!==void 0){for(s=p;a.d[s]===l.d[s]&&s--;);if(s==-1)break}s=l,l=r,r=a,a=s}return Nt=!0,a.d.length=p+1,a}function Is(i,t){for(var e=i;--t;)e*=i;return e}function df(i,t){var e,r=t.s<0,n=Br(i,i.precision,1),s=n.times(.5);if(t=t.abs(),t.lte(s))return Kr=r?4:1,t;if(e=t.divToInt(n),e.isZero())Kr=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(s))return Kr=cf(e)?r?2:3:r?4:1,t;Kr=cf(e)?r?1:4:r?3:2}return t.minus(n).abs()}function Da(i,t,e,r){var n,s,a,l,f,h,p,c,m,v=i.constructor,w=e!==void 0;if(w?(He(e,1,pn),r===void 0?r=v.rounding:He(r,0,8)):(e=v.precision,r=v.rounding),!i.isFinite())p=pf(i);else{for(p=kr(i),a=p.indexOf("."),w?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(p=p.replace(".",""),m=new v(1),m.e=p.length-a,m.d=Ns(kr(m),10,n),m.e=m.d.length),c=Ns(p,10,n),s=f=c.length;c[--f]==0;)c.pop();if(!c[0])p=w?"0p+0":"0";else{if(a<0?s--:(i=new v(i),i.d=c,i.e=s,i=oe(i,m,e,r,0,n),c=i.d,s=i.e,h=nf),a=c[e],l=n/2,h=h||c[e+1]!==void 0,h=r<4?(a!==void 0||h)&&(r===0||r===(i.s<0?3:2)):a>l||a===l&&(r===4||h||r===6&&c[e-1]&1||r===(i.s<0?8:7)),c.length=e,h)for(;++c[--e]>n-1;)c[e]=0,e||(++s,c.unshift(1));for(f=c.length;!c[f-1];--f);for(a=0,p="";a<f;a++)p+=ma.charAt(c[a]);if(w){if(f>1)if(t==16||t==8){for(a=t==16?4:3,--f;f%a;f++)p+="0";for(c=Ns(p,n,t),f=c.length;!c[f-1];--f);for(a=1,p="1.";a<f;a++)p+=ma.charAt(c[a])}else p=p.charAt(0)+"."+p.slice(1);p=p+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)p="0"+p;p="0."+p}else if(++s>f)for(s-=f;s--;)p+="0";else s<f&&(p=p.slice(0,s)+"."+p.slice(s))}p=(t==16?"0x":t==2?"0b":t==8?"0o":"")+p}return i.s<0?"-"+p:p}function mf(i,t){if(i.length>t)return i.length=t,!0}function Vd(i){return new this(i).abs()}function Qd(i){return new this(i).acos()}function tm(i){return new this(i).acosh()}function em(i,t){return new this(i).plus(t)}function rm(i){return new this(i).asin()}function nm(i){return new this(i).asinh()}function im(i){return new this(i).atan()}function sm(i){return new this(i).atanh()}function om(i,t){i=new this(i),t=new this(t);var e,r=this.precision,n=this.rounding,s=r+4;return!i.s||!t.s?e=new this(NaN):!i.d&&!t.d?(e=Br(this,s,1).times(t.s>0?.25:.75),e.s=i.s):!t.d||i.isZero()?(e=t.s<0?Br(this,r,n):new this(0),e.s=i.s):!i.d||t.isZero()?(e=Br(this,s,1).times(.5),e.s=i.s):t.s<0?(this.precision=s,this.rounding=1,e=this.atan(oe(i,t,s,1)),t=Br(this,s,1),this.precision=r,this.rounding=n,e=i.s<0?e.minus(t):e.plus(t)):e=this.atan(oe(i,t,s,1)),e}function am(i){return new this(i).cbrt()}function um(i){return Dt(i=new this(i),i.e+1,2)}function lm(i,t,e){return new this(i).clamp(t,e)}function fm(i){if(!i||typeof i!="object")throw Error(Ms+"Object expected");var t,e,r,n=i.defaults===!0,s=["precision",1,pn,"rounding",0,8,"toExpNeg",-oi,0,"toExpPos",0,oi,"maxE",0,oi,"minE",-oi,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(e=s[t],n&&(this[e]=ga[e]),(r=i[e])!==void 0)if(qe(r)===r&&r>=s[t+1]&&r<=s[t+2])this[e]=r;else throw Error(dn+e+": "+r);if(e="crypto",n&&(this[e]=ga[e]),(r=i[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(of);else this[e]=!1;else throw Error(dn+e+": "+r);return this}function cm(i){return new this(i).cos()}function hm(i){return new this(i).cosh()}function gf(i){var t,e,r;function n(s){var a,l,f,h=this;if(!(h instanceof n))return new n(s);if(h.constructor=n,vf(s)){h.s=s.s,Nt?!s.d||s.e>n.maxE?(h.e=NaN,h.d=null):s.e<n.minE?(h.e=0,h.d=[0]):(h.e=s.e,h.d=s.d.slice()):(h.e=s.e,h.d=s.d?s.d.slice():s.d);return}if(f=typeof s,f==="number"){if(s===0){h.s=1/s<0?-1:1,h.e=0,h.d=[0];return}if(s<0?(s=-s,h.s=-1):h.s=1,s===~~s&&s<1e7){for(a=0,l=s;l>=10;l/=10)a++;Nt?a>n.maxE?(h.e=NaN,h.d=null):a<n.minE?(h.e=0,h.d=[0]):(h.e=a,h.d=[s]):(h.e=a,h.d=[s]);return}else if(s*0!==0){s||(h.s=NaN),h.e=NaN,h.d=null;return}return wa(h,s.toString())}else if(f!=="string")throw Error(dn+s);return(l=s.charCodeAt(0))===45?(s=s.slice(1),h.s=-1):(l===43&&(s=s.slice(1)),h.s=1),uf.test(s)?wa(h,s):Jd(h,s)}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=fm,n.clone=gf,n.isDecimal=vf,n.abs=Vd,n.acos=Qd,n.acosh=tm,n.add=em,n.asin=rm,n.asinh=nm,n.atan=im,n.atanh=sm,n.atan2=om,n.cbrt=am,n.ceil=um,n.clamp=lm,n.cos=cm,n.cosh=hm,n.div=pm,n.exp=dm,n.floor=mm,n.hypot=gm,n.ln=vm,n.log=_m,n.log10=Dm,n.log2=wm,n.max=ym,n.min=bm,n.mod=Em,n.mul=Am,n.pow=xm,n.random=Cm,n.round=Fm,n.sign=Mm,n.sin=Nm,n.sinh=Sm,n.sqrt=Bm,n.sub=Im,n.sum=Tm,n.tan=$m,n.tanh=Om,n.trunc=Rm,i===void 0&&(i={}),i&&i.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)i.hasOwnProperty(e=r[t++])||(i[e]=this[e]);return n.config(i),n}function pm(i,t){return new this(i).div(t)}function dm(i){return new this(i).exp()}function mm(i){return Dt(i=new this(i),i.e+1,3)}function gm(){var i,t,e=new this(0);for(Nt=!1,i=0;i<arguments.length;)if(t=new this(arguments[i++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return Nt=!0,new this(1/0);e=t}return Nt=!0,e.sqrt()}function vf(i){return i instanceof ui||i&&i.toStringTag===af||!1}function vm(i){return new this(i).ln()}function _m(i,t){return new this(i).log(t)}function wm(i){return new this(i).log(2)}function Dm(i){return new this(i).log(10)}function ym(){return hf(this,arguments,"lt")}function bm(){return hf(this,arguments,"gt")}function Em(i,t){return new this(i).mod(t)}function Am(i,t){return new this(i).mul(t)}function xm(i,t){return new this(i).pow(t)}function Cm(i){var t,e,r,n,s=0,a=new this(1),l=[];if(i===void 0?i=this.precision:He(i,1,pn),r=Math.ceil(i/Et),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));s<r;)n=t[s],n>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:l[s++]=n%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);s<r;)n=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(t,s):(l.push(n%1e7),s+=4);s=r/4}else throw Error(of);else for(;s<r;)l[s++]=Math.random()*1e7|0;for(r=l[--s],i%=Et,r&&i&&(n=Fe(10,Et-i),l[s]=(r/n|0)*n);l[s]===0;s--)l.pop();if(s<0)e=0,l=[0];else{for(e=-1;l[0]===0;e-=Et)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<Et&&(e-=Et-r)}return a.e=e,a.d=l,a}function Fm(i){return Dt(i=new this(i),i.e+1,this.rounding)}function Mm(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Nm(i){return new this(i).sin()}function Sm(i){return new this(i).sinh()}function Bm(i){return new this(i).sqrt()}function Im(i,t){return new this(i).sub(t)}function Tm(){var i=0,t=arguments,e=new this(t[i]);for(Nt=!1;e.s&&++i<t.length;)e=e.plus(t[i]);return Nt=!0,Dt(e,this.precision,this.rounding)}function $m(i){return new this(i).tan()}function Om(i){return new this(i).tanh()}function Rm(i){return Dt(i=new this(i),i.e+1,1)}it[Symbol.for("nodejs.util.inspect.custom")]=it.toString,it[Symbol.toStringTag]="Decimal";var ui=it.constructor=gf(ga);Cs=new ui(Cs),Fs=new ui(Fs);var Lm="BigNumber",Pm=["?on","config"],zm=mt(Lm,Pm,i=>{var{on:t,config:e}=i,r=ui.clone({precision:e.precision,modulo:ui.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,s){n.precision!==s.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),_f={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(i,t){(function(e){var r=Math.cosh||function(c){return Math.abs(c)<1e-9?1-c:(Math.exp(c)+Math.exp(-c))*.5},n=Math.sinh||function(c){return Math.abs(c)<1e-9?c:(Math.exp(c)-Math.exp(-c))*.5},s=function(c){var m=Math.PI/4;if(-m>c||c>m)return Math.cos(c)-1;var v=c*c;return v*(v*(v*(v*(v*(v*(v*(v/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},a=function(c,m){var v=Math.abs(c),w=Math.abs(m);return v<3e3&&w<3e3?Math.sqrt(v*v+w*w):(v<w?(v=w,w=c/m):w=m/c,v*Math.sqrt(1+w*w))},l=function(){throw SyntaxError("Invalid Param")};function f(c,m){var v=Math.abs(c),w=Math.abs(m);return c===0?Math.log(w):m===0?Math.log(v):v<3e3&&w<3e3?Math.log(c*c+m*m)*.5:(c=c/2,m=m/2,.5*Math.log(c*c+m*m)+Math.LN2)}var h=function(c,m){var v={re:0,im:0};if(c==null)v.re=v.im=0;else if(m!==void 0)v.re=c,v.im=m;else switch(typeof c){case"object":if("im"in c&&"re"in c)v.re=c.re,v.im=c.im;else if("abs"in c&&"arg"in c){if(!Number.isFinite(c.abs)&&Number.isFinite(c.arg))return p.INFINITY;v.re=c.abs*Math.cos(c.arg),v.im=c.abs*Math.sin(c.arg)}else if("r"in c&&"phi"in c){if(!Number.isFinite(c.r)&&Number.isFinite(c.phi))return p.INFINITY;v.re=c.r*Math.cos(c.phi),v.im=c.r*Math.sin(c.phi)}else c.length===2?(v.re=c[0],v.im=c[1]):l();break;case"string":v.im=v.re=0;var w=c.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),g=1,y=0;w===null&&l();for(var _=0;_<w.length;_++){var E=w[_];E===" "||E===" "||E===`
46
- `||(E==="+"?g++:E==="-"?y++:E==="i"||E==="I"?(g+y===0&&l(),w[_+1]!==" "&&!isNaN(w[_+1])?(v.im+=parseFloat((y%2?"-":"")+w[_+1]),_++):v.im+=parseFloat((y%2?"-":"")+"1"),g=y=0):((g+y===0||isNaN(E))&&l(),w[_+1]==="i"||w[_+1]==="I"?(v.im+=parseFloat((y%2?"-":"")+E),_++):v.re+=parseFloat((y%2?"-":"")+E),g=y=0))}g+y>0&&l();break;case"number":v.im=0,v.re=c;break;default:l()}return isNaN(v.re)||isNaN(v.im),v};function p(c,m){if(!(this instanceof p))return new p(c,m);var v=h(c,m);this.re=v.re,this.im=v.im}p.prototype={re:0,im:0,sign:function(){var c=this.abs();return new p(this.re/c,this.im/c)},add:function(c,m){var v=new p(c,m);return this.isInfinite()&&v.isInfinite()?p.NAN:this.isInfinite()||v.isInfinite()?p.INFINITY:new p(this.re+v.re,this.im+v.im)},sub:function(c,m){var v=new p(c,m);return this.isInfinite()&&v.isInfinite()?p.NAN:this.isInfinite()||v.isInfinite()?p.INFINITY:new p(this.re-v.re,this.im-v.im)},mul:function(c,m){var v=new p(c,m);return this.isInfinite()&&v.isZero()||this.isZero()&&v.isInfinite()?p.NAN:this.isInfinite()||v.isInfinite()?p.INFINITY:v.im===0&&this.im===0?new p(this.re*v.re,0):new p(this.re*v.re-this.im*v.im,this.re*v.im+this.im*v.re)},div:function(c,m){var v=new p(c,m);if(this.isZero()&&v.isZero()||this.isInfinite()&&v.isInfinite())return p.NAN;if(this.isInfinite()||v.isZero())return p.INFINITY;if(this.isZero()||v.isInfinite())return p.ZERO;c=this.re,m=this.im;var w=v.re,g=v.im,y,_;return g===0?new p(c/w,m/w):Math.abs(w)<Math.abs(g)?(_=w/g,y=w*_+g,new p((c*_+m)/y,(m*_-c)/y)):(_=g/w,y=g*_+w,new p((c+m*_)/y,(m-c*_)/y))},pow:function(c,m){var v=new p(c,m);if(c=this.re,m=this.im,v.isZero())return p.ONE;if(v.im===0){if(m===0&&c>0)return new p(Math.pow(c,v.re),0);if(c===0)switch((v.re%4+4)%4){case 0:return new p(Math.pow(m,v.re),0);case 1:return new p(0,Math.pow(m,v.re));case 2:return new p(-Math.pow(m,v.re),0);case 3:return new p(0,-Math.pow(m,v.re))}}if(c===0&&m===0&&v.re>0&&v.im>=0)return p.ZERO;var w=Math.atan2(m,c),g=f(c,m);return c=Math.exp(v.re*g-v.im*w),m=v.im*g+v.re*w,new p(c*Math.cos(m),c*Math.sin(m))},sqrt:function(){var c=this.re,m=this.im,v=this.abs(),w,g;if(c>=0){if(m===0)return new p(Math.sqrt(c),0);w=.5*Math.sqrt(2*(v+c))}else w=Math.abs(m)/Math.sqrt(2*(v-c));return c<=0?g=.5*Math.sqrt(2*(v-c)):g=Math.abs(m)/Math.sqrt(2*(v+c)),new p(w,m<0?-g:g)},exp:function(){var c=Math.exp(this.re);return this.im,new p(c*Math.cos(this.im),c*Math.sin(this.im))},expm1:function(){var c=this.re,m=this.im;return new p(Math.expm1(c)*Math.cos(m)+s(m),Math.exp(c)*Math.sin(m))},log:function(){var c=this.re,m=this.im;return new p(f(c,m),Math.atan2(m,c))},abs:function(){return a(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var c=this.re,m=this.im;return new p(Math.sin(c)*r(m),Math.cos(c)*n(m))},cos:function(){var c=this.re,m=this.im;return new p(Math.cos(c)*r(m),-Math.sin(c)*n(m))},tan:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)+r(m);return new p(Math.sin(c)/v,n(m)/v)},cot:function(){var c=2*this.re,m=2*this.im,v=Math.cos(c)-r(m);return new p(-Math.sin(c)/v,n(m)/v)},sec:function(){var c=this.re,m=this.im,v=.5*r(2*m)+.5*Math.cos(2*c);return new p(Math.cos(c)*r(m)/v,Math.sin(c)*n(m)/v)},csc:function(){var c=this.re,m=this.im,v=.5*r(2*m)-.5*Math.cos(2*c);return new p(Math.sin(c)*r(m)/v,-Math.cos(c)*n(m)/v)},asin:function(){var c=this.re,m=this.im,v=new p(m*m-c*c+1,-2*c*m).sqrt(),w=new p(v.re-m,v.im+c).log();return new p(w.im,-w.re)},acos:function(){var c=this.re,m=this.im,v=new p(m*m-c*c+1,-2*c*m).sqrt(),w=new p(v.re-m,v.im+c).log();return new p(Math.PI/2-w.im,w.re)},atan:function(){var c=this.re,m=this.im;if(c===0){if(m===1)return new p(0,1/0);if(m===-1)return new p(0,-1/0)}var v=c*c+(1-m)*(1-m),w=new p((1-m*m-c*c)/v,-2*c/v).log();return new p(-.5*w.im,.5*w.re)},acot:function(){var c=this.re,m=this.im;if(m===0)return new p(Math.atan2(1,c),0);var v=c*c+m*m;return v!==0?new p(c/v,-m/v).atan():new p(c!==0?c/0:0,m!==0?-m/0:0).atan()},asec:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new p(0,1/0);var v=c*c+m*m;return v!==0?new p(c/v,-m/v).acos():new p(c!==0?c/0:0,m!==0?-m/0:0).acos()},acsc:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new p(Math.PI/2,1/0);var v=c*c+m*m;return v!==0?new p(c/v,-m/v).asin():new p(c!==0?c/0:0,m!==0?-m/0:0).asin()},sinh:function(){var c=this.re,m=this.im;return new p(n(c)*Math.cos(m),r(c)*Math.sin(m))},cosh:function(){var c=this.re,m=this.im;return new p(r(c)*Math.cos(m),n(c)*Math.sin(m))},tanh:function(){var c=2*this.re,m=2*this.im,v=r(c)+Math.cos(m);return new p(n(c)/v,Math.sin(m)/v)},coth:function(){var c=2*this.re,m=2*this.im,v=r(c)-Math.cos(m);return new p(n(c)/v,-Math.sin(m)/v)},csch:function(){var c=this.re,m=this.im,v=Math.cos(2*m)-r(2*c);return new p(-2*n(c)*Math.cos(m)/v,2*r(c)*Math.sin(m)/v)},sech:function(){var c=this.re,m=this.im,v=Math.cos(2*m)+r(2*c);return new p(2*r(c)*Math.cos(m)/v,-2*n(c)*Math.sin(m)/v)},asinh:function(){var c=this.im;this.im=-this.re,this.re=c;var m=this.asin();return this.re=-this.im,this.im=c,c=m.re,m.re=-m.im,m.im=c,m},acosh:function(){var c=this.acos();if(c.im<=0){var m=c.re;c.re=-c.im,c.im=m}else{var m=c.im;c.im=-c.re,c.re=m}return c},atanh:function(){var c=this.re,m=this.im,v=c>1&&m===0,w=1-c,g=1+c,y=w*w+m*m,_=y!==0?new p((g*w-m*m)/y,(m*w+g*m)/y):new p(c!==-1?c/0:0,m!==0?m/0:0),E=_.re;return _.re=f(_.re,_.im)/2,_.im=Math.atan2(_.im,E)/2,v&&(_.im=-_.im),_},acoth:function(){var c=this.re,m=this.im;if(c===0&&m===0)return new p(0,Math.PI/2);var v=c*c+m*m;return v!==0?new p(c/v,-m/v).atanh():new p(c!==0?c/0:0,m!==0?-m/0:0).atanh()},acsch:function(){var c=this.re,m=this.im;if(m===0)return new p(c!==0?Math.log(c+Math.sqrt(c*c+1)):1/0,0);var v=c*c+m*m;return v!==0?new p(c/v,-m/v).asinh():new p(c!==0?c/0:0,m!==0?-m/0:0).asinh()},asech:function(){var c=this.re,m=this.im;if(this.isZero())return p.INFINITY;var v=c*c+m*m;return v!==0?new p(c/v,-m/v).acosh():new p(c!==0?c/0:0,m!==0?-m/0:0).acosh()},inverse:function(){if(this.isZero())return p.INFINITY;if(this.isInfinite())return p.ZERO;var c=this.re,m=this.im,v=c*c+m*m;return new p(c/v,-m/v)},conjugate:function(){return new p(this.re,-this.im)},neg:function(){return new p(-this.re,-this.im)},ceil:function(c){return c=Math.pow(10,c||0),new p(Math.ceil(this.re*c)/c,Math.ceil(this.im*c)/c)},floor:function(c){return c=Math.pow(10,c||0),new p(Math.floor(this.re*c)/c,Math.floor(this.im*c)/c)},round:function(c){return c=Math.pow(10,c||0),new p(Math.round(this.re*c)/c,Math.round(this.im*c)/c)},equals:function(c,m){var v=new p(c,m);return Math.abs(v.re-this.re)<=p.EPSILON&&Math.abs(v.im-this.im)<=p.EPSILON},clone:function(){return new p(this.re,this.im)},toString:function(){var c=this.re,m=this.im,v="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(c)<p.EPSILON&&(c=0),Math.abs(m)<p.EPSILON&&(m=0),m===0?v+c:(c!==0?(v+=c,v+=" ",m<0?(m=-m,v+="-"):v+="+",v+=" "):m<0&&(m=-m,v+="-"),m!==1&&(v+=m),v+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},p.ZERO=new p(0,0),p.ONE=new p(1,0),p.I=new p(0,1),p.PI=new p(Math.PI,0),p.E=new p(Math.E,0),p.INFINITY=new p(1/0,1/0),p.NAN=new p(NaN,NaN),p.EPSILON=1e-15,Object.defineProperty(p,"__esModule",{value:!0}),p.default=p,p.Complex=p,i.exports=p})()})(_f);var qm=_f.exports,Re=jt(qm),Um="Complex",km=[],Wm=mt(Um,km,()=>(Object.defineProperty(Re,"name",{value:"Complex"}),Re.prototype.constructor=Re,Re.prototype.type="Complex",Re.prototype.isComplex=!0,Re.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Re.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Re.prototype.format=function(i){var t="",e=this.im,r=this.re,n=oa(this.re,i),s=oa(this.im,i),a=ue(i)?i:i?i.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=s+"i":e<0?e===-1?t=n+" - i":t=n+" - "+s.substring(1)+"i":e===1?t=n+" + i":t=n+" + "+s+"i",t},Re.fromPolar=function(i){switch(arguments.length){case 1:{var t=arguments[0];if(typeof t=="object")return Re(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(ue(e)){if(Bl(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),ue(r))return new Re({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")}},Re.prototype.valueOf=Re.prototype.toString,Re.fromJSON=function(i){return new Re(i)},Re.compare=function(i,t){return i.re>t.re?1:i.re<t.re?-1:i.im>t.im?1:i.im<t.im?-1:0},Re),{isClass:!0}),wf={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(i,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function s(_,E){if(isNaN(_=parseInt(_,10)))throw g();return _*E}function a(_,E){if(E===0)throw w();var b=Object.create(v.prototype);b.s=_<0?-1:1,_=_<0?-_:_;var N=m(_,E);return b.n=_/N,b.d=E/N,b}function l(_){for(var E={},b=_,N=2,A=4;A<=b;){for(;b%N===0;)b/=N,E[N]=(E[N]||0)+1;A+=1+2*N++}return b!==_?b>1&&(E[b]=(E[b]||0)+1):E[_]=(E[_]||0)+1,E}var f=function(_,E){var b=0,N=1,A=1,C=0,M=0,S=0,$=1,F=1,I=0,R=1,U=1,q=1,k=1e7,P;if(_!=null)if(E!==void 0){if(b=_,N=E,A=b*N,b%1!==0||N%1!==0)throw y()}else switch(typeof _){case"object":{if("d"in _&&"n"in _)b=_.n,N=_.d,"s"in _&&(b*=_.s);else if(0 in _)b=_[0],1 in _&&(N=_[1]);else throw g();A=b*N;break}case"number":{if(_<0&&(A=_,_=-_),_%1===0)b=_;else if(_>0){for(_>=1&&(F=Math.pow(10,Math.floor(1+Math.log(_)/Math.LN10)),_/=F);R<=k&&q<=k;)if(P=(I+U)/(R+q),_===P){R+q<=k?(b=I+U,N=R+q):q>R?(b=U,N=q):(b=I,N=R);break}else _>P?(I+=U,R+=q):(U+=I,q+=R),R>k?(b=U,N=q):(b=I,N=R);b*=F}else(isNaN(_)||isNaN(E))&&(N=b=NaN);break}case"string":{if(R=_.match(/\d+|./g),R===null)throw g();if(R[I]==="-"?(A=-1,I++):R[I]==="+"&&I++,R.length===I+1?M=s(R[I++],A):R[I+1]==="."||R[I]==="."?(R[I]!=="."&&(C=s(R[I++],A)),I++,(I+1===R.length||R[I+1]==="("&&R[I+3]===")"||R[I+1]==="'"&&R[I+3]==="'")&&(M=s(R[I],A),$=Math.pow(10,R[I].length),I++),(R[I]==="("&&R[I+2]===")"||R[I]==="'"&&R[I+2]==="'")&&(S=s(R[I+1],A),F=Math.pow(10,R[I+1].length)-1,I+=3)):R[I+1]==="/"||R[I+1]===":"?(M=s(R[I],A),$=s(R[I+2],1),I+=3):R[I+3]==="/"&&R[I+1]===" "&&(C=s(R[I],A),M=s(R[I+2],A),$=s(R[I+4],1),I+=5),R.length<=I){N=$*F,A=b=S+N*C+F*M;break}}default:throw g()}if(N===0)throw w();n.s=A<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(N)};function h(_,E,b){for(var N=1;E>0;_=_*_%b,E>>=1)E&1&&(N=N*_%b);return N}function p(_,E){for(;E%2===0;E/=2);for(;E%5===0;E/=5);if(E===1)return 0;for(var b=10%E,N=1;b!==1;N++)if(b=b*10%E,N>r)return 0;return N}function c(_,E,b){for(var N=1,A=h(10,b,E),C=0;C<300;C++){if(N===A)return C;N=N*10%E,A=A*10%E}return 0}function m(_,E){if(!_)return E;if(!E)return _;for(;;){if(_%=E,!_)return E;if(E%=_,!E)return _}}function v(_,E){if(f(_,E),this instanceof v)_=m(n.d,n.n),this.s=n.s,this.n=n.n/_,this.d=n.d/_;else return a(n.s*n.n,n.d)}var w=function(){return new Error("Division by Zero")},g=function(){return new Error("Invalid argument")},y=function(){return new Error("Parameters must be integer")};v.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(_,E){return f(_,E),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(_,E){return f(_,E),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(_,E){return f(_,E),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(_,E){return f(_,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(_,E){if(isNaN(this.n)||isNaN(this.d))return new v(NaN);if(_===void 0)return a(this.s*this.n%this.d,1);if(f(_,E),n.n===0&&this.d===0)throw w();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(_,E){return f(_,E),a(m(n.n,this.n)*m(n.d,this.d),n.d*this.d)},lcm:function(_,E){return f(_,E),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,m(n.n,this.n)*m(n.d,this.d))},ceil:function(_){return _=Math.pow(10,_||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):a(Math.ceil(_*this.s*this.n/this.d),_)},floor:function(_){return _=Math.pow(10,_||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):a(Math.floor(_*this.s*this.n/this.d),_)},round:function(_){return _=Math.pow(10,_||0),isNaN(this.n)||isNaN(this.d)?new v(NaN):a(Math.round(_*this.s*this.n/this.d),_)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(_,E){if(f(_,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),A=1,C=1;for(var M in b)if(M!=="1"){if(M==="0"){A=0;break}if(b[M]*=n.n,b[M]%n.d===0)b[M]/=n.d;else return null;A*=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;C*=Math.pow(M,N[M])}return n.s<0?a(C,A):a(A,C)},equals:function(_,E){return f(_,E),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(_,E){f(_,E);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(_){if(isNaN(this.n)||isNaN(this.d))return this;_=_||.001;for(var E=this.abs(),b=E.toContinued(),N=1;N<b.length;N++){for(var A=a(b[N-1],1),C=N-2;C>=0;C--)A=A.inverse().add(b[C]);if(Math.abs(A.sub(E).valueOf())<_)return A.mul(this.s)}return this},divisible:function(_,E){return f(_,E),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(_){var E,b="",N=this.n,A=this.d;return this.s<0&&(b+="-"),A===1?b+=N:(_&&(E=Math.floor(N/A))>0&&(b+=E,b+=" ",N%=A),b+=N,b+="/",b+=A),b},toLatex:function(_){var E,b="",N=this.n,A=this.d;return this.s<0&&(b+="-"),A===1?b+=N:(_&&(E=Math.floor(N/A))>0&&(b+=E,N%=A),b+="\\frac{",b+=N,b+="}{",b+=A,b+="}"),b},toContinued:function(){var _,E=this.n,b=this.d,N=[];if(isNaN(E)||isNaN(b))return N;do N.push(Math.floor(E/b)),_=E%b,E=b,b=_;while(E!==1);return N},toString:function(_){var E=this.n,b=this.d;if(isNaN(E)||isNaN(b))return"NaN";_=_||15;var N=p(E,b),A=c(E,b,N),C=this.s<0?"-":"";if(C+=E/b|0,E%=b,E*=10,E&&(C+="."),N){for(var M=A;M--;)C+=E/b|0,E%=b,E*=10;C+="(";for(var M=N;M--;)C+=E/b|0,E%=b,E*=10;C+=")"}else for(var M=_;E&&M--;)C+=E/b|0,E%=b,E*=10;return C}},Object.defineProperty(v,"__esModule",{value:!0}),v.default=v,v.Fraction=v,i.exports=v})()})(wf);var Ym=wf.exports,Hr=jt(Ym),jm="Fraction",Zm=[],Gm=mt(jm,Zm,()=>(Object.defineProperty(Hr,"name",{value:"Fraction"}),Hr.prototype.constructor=Hr,Hr.prototype.type="Fraction",Hr.prototype.isFraction=!0,Hr.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},Hr.fromJSON=function(i){return new Hr(i)},Hr),{isClass:!0}),Km="Matrix",Hm=[],Jm=mt(Km,Hm,()=>{function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.prototype.type="Matrix",i.prototype.isMatrix=!0,i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},i.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i},{isClass:!0});function Df(i){return Object.keys(i.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var Xm="DenseMatrix",Vm=["Matrix"],Qm=mt(Xm,Vm,i=>{var{Matrix:t}=i;function e(p,c){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(c&&!Ur(c))throw new Error("Invalid datatype: "+c);if(fe(p))p.type==="DenseMatrix"?(this._data=ee(p._data),this._size=ee(p._size),this._datatype=c||p._datatype):(this._data=p.toArray(),this._size=p.size(),this._datatype=c||p._datatype);else if(p&&ge(p.data)&&ge(p.size))this._data=p.data,this._size=p.size,Gl(this._data,this._size),this._datatype=c||p.datatype;else if(ge(p))this._data=h(p),this._size=Ae(this._data),Gl(this._data,this._size),this._datatype=c;else{if(p)throw new TypeError("Unsupported type of data ("+cn(p)+")");this._data=[],this._size=[0],this._datatype=c}}e.prototype=new t,e.prototype.createDenseMatrix=function(p,c){return new e(p,c)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Es(this._data,cn)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(p,c){return new e(p,c)},e.prototype.subset=function(p,c,m){switch(arguments.length){case 1:return r(this,p);case 2:case 3:return s(this,p,c,m);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(p){if(!ge(p))throw new TypeError("Array expected");if(p.length!==this._size.length)throw new Zt(p.length,this._size.length);for(var c=0;c<p.length;c++)ve(p[c],this._size[c]);for(var m=this._data,v=0,w=p.length;v<w;v++){var g=p[v];ve(g,m.length),m=m[g]}return m},e.prototype.set=function(p,c,m){if(!ge(p))throw new TypeError("Array expected");if(p.length<this._size.length)throw new Zt(p.length,this._size.length,"<");var v,w,g,y=p.map(function(E){return E+1});f(this,y,m);var _=this._data;for(v=0,w=p.length-1;v<w;v++)g=p[v],ve(g,_.length),_=_[g];return g=p[p.length-1],ve(g,_.length),_[g]=c,this};function r(p,c){if(!na(c))throw new TypeError("Invalid index");var m=c.isScalar();if(m)return p.get(c.min());var v=c.size();if(v.length!==p._size.length)throw new Zt(v.length,p._size.length);for(var w=c.min(),g=c.max(),y=0,_=p._size.length;y<_;y++)ve(w[y],p._size[y]),ve(g[y],p._size[y]);return new e(n(p._data,c,v.length,0),p._datatype)}function n(p,c,m,v){var w=v===m-1,g=c.dimension(v);return w?g.map(function(y){return ve(y,p.length),p[y]}).valueOf():g.map(function(y){ve(y,p.length);var _=p[y];return n(_,c,m,v+1)}).valueOf()}function s(p,c,m,v){if(!c||c.isIndex!==!0)throw new TypeError("Invalid index");var w=c.size(),g=c.isScalar(),y;if(fe(m)?(y=m.size(),m=m.valueOf()):y=Ae(m),g){if(y.length!==0)throw new TypeError("Scalar expected");p.set(c.min(),m,v)}else{if(!ni(y,w))try{y.length===0?m=Ql([m],w):m=Ql(m,w),y=Ae(m)}catch{}if(w.length<p._size.length)throw new Zt(w.length,p._size.length,"<");if(y.length<w.length){for(var _=0,E=0;w[_]===1&&y[_]===1;)_++;for(;w[_]===1;)E++,_++;m=Hl(m,w.length,E,y)}if(!ni(w,y))throw new Zt(w,y,">");var b=c.max().map(function(C){return C+1});f(p,b,v);var N=w.length,A=0;a(p._data,c,m,N,A)}return p}function a(p,c,m,v,w){var g=w===v-1,y=c.dimension(w);g?y.forEach(function(_,E){ve(_),p[_]=m[E[0]]}):y.forEach(function(_,E){ve(_),a(p[_],c,m[E[0]],v,w+1)})}e.prototype.resize=function(p,c,m){if(!qi(p))throw new TypeError("Array or Matrix expected");var v=p.valueOf().map(g=>Array.isArray(g)&&g.length===1?g[0]:g),w=m?this.clone():this;return l(w,v,c)};function l(p,c,m){if(c.length===0){for(var v=p._data;ge(v);)v=v[0];return v}return p._size=c.slice(0),p._data=ua(p._data,p._size,m),p}e.prototype.reshape=function(p,c){var m=c?this.clone():this;m._data=fa(m._data,p);var v=m._size.reduce((w,g)=>w*g);return m._size=ca(p,v),m};function f(p,c,m){for(var v=p._size.slice(0),w=!1;v.length<c.length;)v.push(0),w=!0;for(var g=0,y=c.length;g<y;g++)c[g]>v[g]&&(v[g]=c[g],w=!0);w&&l(p,v,m)}e.prototype.clone=function(){var p=new e({data:ee(this._data),size:ee(this._size),datatype:this._datatype});return p},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(p){var c=this,m=Df(p),v=function y(_,E){return ge(_)?_.map(function(b,N){return y(b,E.concat(N))}):m===1?p(_):m===2?p(_,E):p(_,E,c)},w=v(this._data,[]),g=this._datatype!==void 0?Es(w,cn):void 0;return new e(w,g)},e.prototype.forEach=function(p){var c=this,m=function v(w,g){ge(w)?w.forEach(function(y,_){v(y,g.concat(_))}):p(w,g,c)};m(this._data,[])},e.prototype[Symbol.iterator]=function*(){var p=function*c(m,v){if(ge(m))for(var w=0;w<m.length;w++)yield*c(m[w],v.concat(w));else yield{value:m,index:v}};yield*p(this._data,[])},e.prototype.rows=function(){var p=[],c=this.size();if(c.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var m=this._data;for(var v of m)p.push(new e([v],this._datatype));return p},e.prototype.columns=function(){var p=this,c=[],m=this.size();if(m.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var v=this._data,w=function(_){var E=v.map(b=>[b[_]]);c.push(new e(E,p._datatype))},g=0;g<m[1];g++)w(g);return c},e.prototype.toArray=function(){return ee(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(p){return se(this._data,p)},e.prototype.toString=function(){return se(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(p){if(p){if(ye(p)&&(p=p.toNumber()),!ue(p)||!he(p))throw new TypeError("The parameter k must be an integer number")}else p=0;for(var c=p>0?p:0,m=p<0?-p:0,v=this._size[0],w=this._size[1],g=Math.min(v-m,w-c),y=[],_=0;_<g;_++)y[_]=this._data[_+m][_+c];return new e({data:y,size:[g],datatype:this._datatype})},e.diagonal=function(p,c,m,v){if(!ge(p))throw new TypeError("Array expected, size parameter");if(p.length!==2)throw new Error("Only two dimensions matrix are supported");if(p=p.map(function(M){if(ye(M)&&(M=M.toNumber()),!ue(M)||!he(M)||M<1)throw new Error("Size values must be positive integers");return M}),m){if(ye(m)&&(m=m.toNumber()),!ue(m)||!he(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var w=m>0?m:0,g=m<0?-m:0,y=p[0],_=p[1],E=Math.min(y-g,_-w),b;if(ge(c)){if(c.length!==E)throw new Error("Invalid value array length");b=function(S){return c[S]}}else if(fe(c)){var N=c.size();if(N.length!==1||N[0]!==E)throw new Error("Invalid matrix length");b=function(S){return c.get([S])}}else b=function(){return c};v||(v=ye(b(0))?b(0).mul(0):0);var A=[];if(p.length>0){A=ua(A,p,v);for(var C=0;C<E;C++)A[C+g][C+w]=b(C)}return new e({data:A,size:[y,_]})},e.fromJSON=function(p){return new e(p)},e.prototype.swapRows=function(p,c){if(!ue(p)||!he(p)||!ue(c)||!he(c))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return ve(p,this._size[0]),ve(c,this._size[0]),e._swapRows(p,c,this._data),this},e._swapRows=function(p,c,m){var v=m[p];m[p]=m[c],m[c]=v};function h(p){return fe(p)?h(p.valueOf()):ge(p)?p.map(h):p}return e},{isClass:!0});function tg(i){var t=i.length,e=i[0].length,r,n,s=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(i[r][n]);s.push(a)}return s}function Ts(i){for(var t=0;t<i.length;t++)if(qi(i[t]))return!0;return!1}function Wi(i,t){fe(i)&&(i=i.valueOf());for(var e=0,r=i.length;e<r;e++){var n=i[e];Array.isArray(n)?Wi(n,t):t(n)}}function Ir(i,t,e){return i&&typeof i.map=="function"?i.map(function(r){return Ir(r,t)}):t(i)}function ya(i,t,e){var r=Array.isArray(i)?Ae(i):i.size();if(t<0||t>=r.length)throw new hn(t,r.length);return fe(i)?i.create($s(i.valueOf(),t,e)):$s(i,t,e)}function $s(i,t,e){var r,n,s,a;if(t<=0)if(Array.isArray(i[0])){for(a=tg(i),n=[],r=0;r<a.length;r++)n[r]=$s(a[r],t-1,e);return n}else{for(s=i[0],r=1;r<i.length;r++)s=e(s,i[r]);return s}else{for(n=[],r=0;r<i.length;r++)n[r]=$s(i[r],t-1,e);return n}}var yf="isInteger",eg=["typed"],rg=mt(yf,eg,i=>{var{typed:t}=i;return t(yf,{number:he,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),bf="number",Os="number, number";function Ef(i){return Math.abs(i)}Ef.signature=bf;function Af(i,t){return i+t}Af.signature=Os;function xf(i,t){return i-t}xf.signature=Os;function Cf(i,t){return i*t}Cf.signature=Os;function Ff(i){return-i}Ff.signature=bf;function Mf(i,t){return i*i<1&&t===1/0||i*i>1&&t===-1/0?0:Math.pow(i,t)}Mf.signature=Os;var Nf="number";function Sf(i){return i===0}Sf.signature=Nf;function Bf(i){return Number.isNaN(i)}Bf.signature=Nf;var If="isNumeric",ng=["typed"],ig=mt(If,ng,i=>{var{typed:t}=i;return t(If,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),Tf="isZero",sg=["typed"],og=mt(Tf,sg,i=>{var{typed:t}=i;return t(Tf,{number:Sf,BigNumber:function(r){return r.isZero()},Complex:function(r){return r.re===0&&r.im===0},Fraction:function(r){return r.d===1&&r.n===0},Unit:t.referToSelf(e=>r=>t.find(e,r.valueType())(r.value)),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),$f="isNaN",ag=["typed"],ug=mt($f,ag,i=>{var{typed:t}=i;return t($f,{number:Bf,BigNumber:function(r){return r.isNaN()},Fraction:function(r){return!1},Complex:function(r){return r.isNaN()},Unit:function(r){return Number.isNaN(r.value)},"Array | Matrix":function(r){return Ir(r,Number.isNaN)}})});function Rs(i,t,e){if(e==null)return i.eq(t);if(i.eq(t))return!0;if(i.isNaN()||t.isNaN())return!1;if(i.isFinite()&&t.isFinite()){var r=i.minus(t).abs();if(r.isZero())return!0;var n=i.constructor.max(i.abs(),t.abs());return r.lte(n.times(e))}return!1}function lg(i,t,e){return zn(i.re,t.re,e)&&zn(i.im,t.im,e)}var Ls=mt("compareUnits",["typed"],i=>{var{typed:t}=i;return{"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)})}}),Ps="equalScalar",fg=["typed","config"],cg=mt(Ps,fg,i=>{var{typed:t,config:e}=i,r=Ls({typed:t});return t(Ps,{"boolean, boolean":function(s,a){return s===a},"number, number":function(s,a){return zn(s,a,e.epsilon)},"BigNumber, BigNumber":function(s,a){return s.eq(a)||Rs(s,a,e.epsilon)},"Fraction, Fraction":function(s,a){return s.equals(a)},"Complex, Complex":function(s,a){return lg(s,a,e.epsilon)}},r)});mt(Ps,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Ps,{"number, number":function(n,s){return zn(n,s,e.epsilon)}})});var hg="SparseMatrix",pg=["typed","equalScalar","Matrix"],dg=mt(hg,pg,i=>{var{typed:t,equalScalar:e,Matrix:r}=i;function n(g,y){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!Ur(y))throw new Error("Invalid datatype: "+y);if(fe(g))s(this,g,y);else if(g&&ge(g.index)&&ge(g.ptr)&&ge(g.size))this._values=g.values,this._index=g.index,this._ptr=g.ptr,this._size=g.size,this._datatype=y||g.datatype;else if(ge(g))a(this,g,y);else{if(g)throw new TypeError("Unsupported type of data ("+cn(g)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function s(g,y,_){y.type==="SparseMatrix"?(g._values=y._values?ee(y._values):void 0,g._index=ee(y._index),g._ptr=ee(y._ptr),g._size=ee(y._size),g._datatype=_||y._datatype):a(g,y.valueOf(),_||y._datatype)}function a(g,y,_){g._values=[],g._index=[],g._ptr=[],g._datatype=_;var E=y.length,b=0,N=e,A=0;if(Ur(_)&&(N=t.find(e,[_,_])||e,A=t.convert(0,_)),E>0){var C=0;do{g._ptr.push(g._index.length);for(var M=0;M<E;M++){var S=y[M];if(ge(S)){if(C===0&&b<S.length&&(b=S.length),C<S.length){var $=S[C];N($,A)||(g._values.push($),g._index.push(M))}}else C===0&&b<1&&(b=1),N(S,A)||(g._values.push(S),g._index.push(M))}C++}while(C<b)}g._ptr.push(g._index.length),g._size=[E,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(g,y){return new n(g,y)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Es(this._values,cn)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(g,y){return new n(g,y)},n.prototype.density=function(){var g=this._size[0],y=this._size[1];return g!==0&&y!==0?this._index.length/(g*y):0},n.prototype.subset=function(g,y,_){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,g);case 2:case 3:return f(this,g,y,_);default:throw new SyntaxError("Wrong number of arguments")}};function l(g,y){if(!na(y))throw new TypeError("Invalid index");var _=y.isScalar();if(_)return g.get(y.min());var E=y.size();if(E.length!==g._size.length)throw new Zt(E.length,g._size.length);var b,N,A,C,M=y.min(),S=y.max();for(b=0,N=g._size.length;b<N;b++)ve(M[b],g._size[b]),ve(S[b],g._size[b]);var $=g._values,F=g._index,I=g._ptr,R=y.dimension(0),U=y.dimension(1),q=[],k=[];R.forEach(function(V,tt){k[V]=tt[0],q[V]=!0});var P=$?[]:void 0,K=[],G=[];return U.forEach(function(V){for(G.push(K.length),A=I[V],C=I[V+1];A<C;A++)b=F[A],q[b]===!0&&(K.push(k[b]),P&&P.push($[A]))}),G.push(K.length),new n({values:P,index:K,ptr:G,size:E,datatype:g._datatype})}function f(g,y,_,E){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var b=y.size(),N=y.isScalar(),A;if(fe(_)?(A=_.size(),_=_.toArray()):A=Ae(_),N){if(A.length!==0)throw new TypeError("Scalar expected");g.set(y.min(),_,E)}else{if(b.length!==1&&b.length!==2)throw new Zt(b.length,g._size.length,"<");if(A.length<b.length){for(var C=0,M=0;b[C]===1&&A[C]===1;)C++;for(;b[C]===1;)M++,C++;_=Hl(_,b.length,M,A)}if(!ni(b,A))throw new Zt(b,A,">");if(b.length===1){var S=y.dimension(0);S.forEach(function(I,R){ve(I),g.set([I,0],_[R[0]],E)})}else{var $=y.dimension(0),F=y.dimension(1);$.forEach(function(I,R){ve(I),F.forEach(function(U,q){ve(U),g.set([I,U],_[R[0]][q[0]],E)})})}}return g}n.prototype.get=function(g){if(!ge(g))throw new TypeError("Array expected");if(g.length!==this._size.length)throw new Zt(g.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=g[0],_=g[1];ve(y,this._size[0]),ve(_,this._size[1]);var E=h(y,this._ptr[_],this._ptr[_+1],this._index);return E<this._ptr[_+1]&&this._index[E]===y?this._values[E]:0},n.prototype.set=function(g,y,_){if(!ge(g))throw new TypeError("Array expected");if(g.length!==this._size.length)throw new Zt(g.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var E=g[0],b=g[1],N=this._size[0],A=this._size[1],C=e,M=0;Ur(this._datatype)&&(C=t.find(e,[this._datatype,this._datatype])||e,M=t.convert(0,this._datatype)),(E>N-1||b>A-1)&&(m(this,Math.max(E+1,N),Math.max(b+1,A),_),N=this._size[0],A=this._size[1]),ve(E,N),ve(b,A);var S=h(E,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===E?C(y,M)?p(S,b,this._values,this._index,this._ptr):this._values[S]=y:C(y,M)||c(S,E,b,y,this._values,this._index,this._ptr),this};function h(g,y,_,E){if(_-y===0)return _;for(var b=y;b<_;b++)if(E[b]===g)return b;return y}function p(g,y,_,E,b){_.splice(g,1),E.splice(g,1);for(var N=y+1;N<b.length;N++)b[N]--}function c(g,y,_,E,b,N,A){b.splice(g,0,E),N.splice(g,0,y);for(var C=_+1;C<A.length;C++)A[C]++}n.prototype.resize=function(g,y,_){if(!qi(g))throw new TypeError("Array or Matrix expected");var E=g.valueOf().map(N=>Array.isArray(N)&&N.length===1?N[0]:N);if(E.length!==2)throw new Error("Only two dimensions matrix are supported");E.forEach(function(N){if(!ue(N)||!he(N)||N<0)throw new TypeError("Invalid size, must contain positive integers (size: "+se(E)+")")});var b=_?this.clone():this;return m(b,E[0],E[1],y)};function m(g,y,_,E){var b=E||0,N=e,A=0;Ur(g._datatype)&&(N=t.find(e,[g._datatype,g._datatype])||e,A=t.convert(0,g._datatype),b=t.convert(b,g._datatype));var C=!N(b,A),M=g._size[0],S=g._size[1],$,F,I;if(_>S){for(F=S;F<_;F++)if(g._ptr[F]=g._values.length,C)for($=0;$<M;$++)g._values.push(b),g._index.push($);g._ptr[_]=g._values.length}else _<S&&(g._ptr.splice(_+1,S-_),g._values.splice(g._ptr[_],g._values.length),g._index.splice(g._ptr[_],g._index.length));if(S=_,y>M){if(C){var R=0;for(F=0;F<S;F++){g._ptr[F]=g._ptr[F]+R,I=g._ptr[F+1]+R;var U=0;for($=M;$<y;$++,U++)g._values.splice(I+U,0,b),g._index.splice(I+U,0,$),R++}g._ptr[S]=g._values.length}}else if(y<M){var q=0;for(F=0;F<S;F++){g._ptr[F]=g._ptr[F]-q;var k=g._ptr[F],P=g._ptr[F+1]-q;for(I=k;I<P;I++)$=g._index[I],$>y-1&&(g._values.splice(I,1),g._index.splice(I,1),q++)}g._ptr[F]=g._values.length}return g._size[0]=y,g._size[1]=_,g}n.prototype.reshape=function(g,y){if(!ge(g))throw new TypeError("Array expected");if(g.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");g.forEach(function(V){if(!ue(V)||!he(V)||V<=-2||V===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+se(g)+")")});var _=this._size[0]*this._size[1];g=ca(g,_);var E=g[0]*g[1];if(_!==E)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=y?this.clone():this;if(this._size[0]===g[0]&&this._size[1]===g[1])return b;for(var N=[],A=0;A<b._ptr.length;A++)for(var C=0;C<b._ptr[A+1]-b._ptr[A];C++)N.push(A);for(var M=b._values.slice(),S=b._index.slice(),$=0;$<b._index.length;$++){var F=S[$],I=N[$],R=F*b._size[1]+I;N[$]=R%g[1],S[$]=Math.floor(R/g[1])}b._values.length=0,b._index.length=0,b._ptr.length=g[1]+1,b._size=g.slice();for(var U=0;U<b._ptr.length;U++)b._ptr[U]=0;for(var q=0;q<M.length;q++){var k=S[q],P=N[q],K=M[q],G=h(k,b._ptr[P],b._ptr[P+1],b._index);c(G,k,P,K,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var g=new n({values:this._values?ee(this._values):void 0,index:ee(this._index),ptr:ee(this._ptr),size:ee(this._size),datatype:this._datatype});return g},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(g,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var _=this,E=this._size[0],b=this._size[1],N=Df(g),A=function(M,S,$){return N===1?g(M):N===2?g(M,[S,$]):g(M,[S,$],_)};return v(this,0,E-1,0,b-1,A,y)};function v(g,y,_,E,b,N,A){var C=[],M=[],S=[],$=e,F=0;Ur(g._datatype)&&($=t.find(e,[g._datatype,g._datatype])||e,F=t.convert(0,g._datatype));for(var I=function(lt,wt,yt){lt=N(lt,wt,yt),$(lt,F)||(C.push(lt),M.push(wt))},R=E;R<=b;R++){S.push(C.length);var U=g._ptr[R],q=g._ptr[R+1];if(A)for(var k=U;k<q;k++){var P=g._index[k];P>=y&&P<=_&&I(g._values[k],P-y,R-E)}else{for(var K={},G=U;G<q;G++){var V=g._index[G];K[V]=g._values[G]}for(var tt=y;tt<=_;tt++){var ft=tt in K?K[tt]:0;I(ft,tt-y,R-E)}}}return S.push(C.length),new n({values:C,index:M,ptr:S,size:[_-y+1,b-E+1]})}n.prototype.forEach=function(g,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var _=this,E=this._size[0],b=this._size[1],N=0;N<b;N++){var A=this._ptr[N],C=this._ptr[N+1];if(y)for(var M=A;M<C;M++){var S=this._index[M];g(this._values[M],[S,N],_)}else{for(var $={},F=A;F<C;F++){var I=this._index[F];$[I]=this._values[F]}for(var R=0;R<E;R++){var U=R in $?$[R]:0;g(U,[R,N],_)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var g=this._size[1],y=0;y<g;y++)for(var _=this._ptr[y],E=this._ptr[y+1],b=_;b<E;b++){var N=this._index[b];yield{value:this._values[b],index:[N,y]}}},n.prototype.toArray=function(){return w(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return w(this._values,this._index,this._ptr,this._size,!1)};function w(g,y,_,E,b){var N=E[0],A=E[1],C=[],M,S;for(M=0;M<N;M++)for(C[M]=[],S=0;S<A;S++)C[M][S]=0;for(S=0;S<A;S++)for(var $=_[S],F=_[S+1],I=$;I<F;I++)M=y[I],C[M][S]=g?b?ee(g[I]):g[I]:1;return C}return n.prototype.format=function(g){for(var y=this._size[0],_=this._size[1],E=this.density(),b="Sparse Matrix ["+se(y,g)+" x "+se(_,g)+"] density: "+se(E,g)+`
53
- `,N=0;N<_;N++)for(var A=this._ptr[N],C=this._ptr[N+1],M=A;M<C;M++){var S=this._index[M];b+=`
54
- (`+se(S,g)+", "+se(N,g)+") ==> "+(this._values?se(this._values[M],g):"X")}return b},n.prototype.toString=function(){return se(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(g){if(g){if(ye(g)&&(g=g.toNumber()),!ue(g)||!he(g))throw new TypeError("The parameter k must be an integer number")}else g=0;var y=g>0?g:0,_=g<0?-g:0,E=this._size[0],b=this._size[1],N=Math.min(E-_,b-y),A=[],C=[],M=[];M[0]=0;for(var S=y;S<b&&A.length<N;S++)for(var $=this._ptr[S],F=this._ptr[S+1],I=$;I<F;I++){var R=this._index[I];if(R===S-y+_){A.push(this._values[I]),C[A.length-1]=R-_;break}}return M.push(A.length),new n({values:A,index:C,ptr:M,size:[N,1]})},n.fromJSON=function(g){return new n(g)},n.diagonal=function(g,y,_,E,b){if(!ge(g))throw new TypeError("Array expected, size parameter");if(g.length!==2)throw new Error("Only two dimensions matrix are supported");if(g=g.map(function(V){if(ye(V)&&(V=V.toNumber()),!ue(V)||!he(V)||V<1)throw new Error("Size values must be positive integers");return V}),_){if(ye(_)&&(_=_.toNumber()),!ue(_)||!he(_))throw new TypeError("The parameter k must be an integer number")}else _=0;var N=e,A=0;Ur(b)&&(N=t.find(e,[b,b])||e,A=t.convert(0,b));var C=_>0?_:0,M=_<0?-_:0,S=g[0],$=g[1],F=Math.min(S-M,$-C),I;if(ge(y)){if(y.length!==F)throw new Error("Invalid value array length");I=function(tt){return y[tt]}}else if(fe(y)){var R=y.size();if(R.length!==1||R[0]!==F)throw new Error("Invalid matrix length");I=function(tt){return y.get([tt])}}else I=function(){return y};for(var U=[],q=[],k=[],P=0;P<$;P++){k.push(U.length);var K=P-C;if(K>=0&&K<F){var G=I(K);N(G,A)||(q.push(K+M),U.push(G))}}return k.push(U.length),new n({values:U,index:q,ptr:k,size:[S,$]})},n.prototype.swapRows=function(g,y){if(!ue(g)||!he(g)||!ue(y)||!he(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return ve(g,this._size[0]),ve(y,this._size[0]),n._swapRows(g,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(g,y,_,E,b){for(var N=E[g],A=E[g+1],C=N;C<A;C++)b(_[C],y[C])},n._swapRows=function(g,y,_,E,b,N){for(var A=0;A<_;A++){var C=N[A],M=N[A+1],S=h(g,C,M,b),$=h(y,C,M,b);if(S<M&&$<M&&b[S]===g&&b[$]===y){if(E){var F=E[S];E[S]=E[$],E[$]=F}continue}if(S<M&&b[S]===g&&($>=M||b[$]!==y)){var I=E?E[S]:void 0;b.splice($,0,y),E&&E.splice($,0,I),b.splice($<=S?S+1:S,1),E&&E.splice($<=S?S+1:S,1);continue}if($<M&&b[$]===y&&(S>=M||b[S]!==g)){var R=E?E[$]:void 0;b.splice(S,0,g),E&&E.splice(S,0,R),b.splice(S<=$?$+1:$,1),E&&E.splice(S<=$?$+1:$,1)}}},n},{isClass:!0}),mg="number",gg=["typed"];function vg(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function _g(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var wg=mt(mg,gg,i=>{var{typed:t}=i,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var s=vg(n);if(s)return _g(s);var a=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(a=Number(l[2]),n=l[1]);var f=Number(n);if(isNaN(f))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(f>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));f>=2**(a-1)&&(f=f-2**a)}return f},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),null:function(n){return 0},"Unit, string | Unit":function(n,s){return n.toNumber(s)},"Array | Matrix":t.referToSelf(r=>n=>Ir(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),Dg="bignumber",yg=["typed","BigNumber"],bg=mt(Dg,yg,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var a=s[2],l=e(s[1]),f=new e(2).pow(Number(a));if(l.gt(f.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var h=new e(2).pow(Number(a)-1);return l.gte(h)?l.sub(f):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Ir(n,r))})}),Eg="fraction",Ag=["typed","Fraction"],xg=mt(Eg,Ag,i=>{var{typed:t,Fraction:e}=i;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,s){return new e(n,s)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Ir(n,r))})}),Of="matrix",Cg=["typed","Matrix","DenseMatrix","SparseMatrix"],Fg=mt(Of,Cg,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t(Of,{"":function(){return s([])},string:function(l){return s([],l)},"string, string":function(l,f){return s([],l,f)},Array:function(l){return s(l)},Matrix:function(l){return s(l,l.storage())},"Array | Matrix, string":s,"Array | Matrix, string, string":s});function s(a,l,f){if(l==="dense"||l==="default"||l===void 0)return new r(a,f);if(l==="sparse")return new n(a,f);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),Rf="unaryMinus",Mg=["typed"],Ng=mt(Rf,Mg,i=>{var{typed:t}=i;return t(Rf,{number:Ff,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf(e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n}),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),Lf="abs",Sg=["typed"],Bg=mt(Lf,Sg,i=>{var{typed:t}=i;return t(Lf,{number:Ef,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),Pf="addScalar",Ig=["typed"],Tg=mt(Pf,Ig,i=>{var{typed:t}=i;return t(Pf,{"number, number":Af,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),zf="subtractScalar",$g=["typed"],Og=mt(zf,$g,i=>{var{typed:t}=i;return t(zf,{"number, number":xf,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),Rg="matAlgo11xS0s",Lg=["typed","equalScalar"],ba=mt(Rg,Lg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,l){var f=n._values,h=n._index,p=n._ptr,c=n._size,m=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],w=c[1],g,y=e,_=0,E=a;typeof m=="string"&&(g=m,y=t.find(e,[g,g]),_=t.convert(0,g),s=t.convert(s,g),E=t.find(a,[g,g]));for(var b=[],N=[],A=[],C=0;C<w;C++){A[C]=N.length;for(var M=p[C],S=p[C+1],$=M;$<S;$++){var F=h[$],I=l?E(s,f[$]):E(f[$],s);y(I,_)||(N.push(F),b.push(I))}}return A[w]=N.length,n.createSparseMatrix({values:b,index:N,ptr:A,size:[v,w],datatype:g})}}),Pg="matAlgo12xSfs",zg=["typed","DenseMatrix"],li=mt(Pg,zg,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,l){var f=n._values,h=n._index,p=n._ptr,c=n._size,m=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],w=c[1],g,y=a;typeof m=="string"&&(g=m,s=t.convert(s,g),y=t.find(a,[g,g]));for(var _=[],E=[],b=[],N=0;N<w;N++){for(var A=N+1,C=p[N],M=p[N+1],S=C;S<M;S++){var $=h[S];E[$]=f[S],b[$]=A}for(var F=0;F<v;F++)N===0&&(_[F]=[]),b[F]===A?_[F][N]=l?y(s,E[F]):y(E[F],s):_[F][N]=l?y(s,0):y(0,s)}return new e({data:_,size:[v,w],datatype:g})}}),qg="matAlgo14xDs",Ug=["typed"],Ea=mt(qg,Ug,i=>{var{typed:t}=i;return function(n,s,a,l){var f=n._data,h=n._size,p=n._datatype,c,m=a;typeof p=="string"&&(c=p,s=t.convert(s,c),m=t.find(a,[c,c]));var v=h.length>0?e(m,0,h,h[0],f,s,l):[];return n.createDenseMatrix({data:v,size:ee(h),datatype:c})};function e(r,n,s,a,l,f,h){var p=[];if(n===s.length-1)for(var c=0;c<a;c++)p[c]=h?r(f,l[c]):r(l[c],f);else for(var m=0;m<a;m++)p[m]=e(r,n+1,s,s[n+1],l[m],f,h);return p}}),kg="matAlgo02xDS0",Wg=["typed","equalScalar"],Yg=mt(kg,Wg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,l){var f=n._data,h=n._size,p=n._datatype||n.getDataType(),c=s._values,m=s._index,v=s._ptr,w=s._size,g=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==w.length)throw new Zt(h.length,w.length);if(h[0]!==w[0]||h[1]!==w[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+w+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=h[0],_=h[1],E,b=e,N=0,A=a;typeof p=="string"&&p===g&&p!=="mixed"&&(E=p,b=t.find(e,[E,E]),N=t.convert(0,E),A=t.find(a,[E,E]));for(var C=[],M=[],S=[],$=0;$<_;$++){S[$]=M.length;for(var F=v[$],I=v[$+1],R=F;R<I;R++){var U=m[R],q=l?A(c[R],f[U][$]):A(f[U][$],c[R]);b(q,N)||(M.push(U),C.push(q))}}return S[_]=M.length,s.createSparseMatrix({values:C,index:M,ptr:S,size:[y,_],datatype:p===n._datatype&&g===s._datatype?E:void 0})}}),jg="matAlgo03xDSf",Zg=["typed"],fi=mt(jg,Zg,i=>{var{typed:t}=i;return function(r,n,s,a){var l=r._data,f=r._size,h=r._datatype||r.getDataType(),p=n._values,c=n._index,m=n._ptr,v=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(f.length!==v.length)throw new Zt(f.length,v.length);if(f[0]!==v[0]||f[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+v+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=f[0],y=f[1],_,E=0,b=s;typeof h=="string"&&h===w&&h!=="mixed"&&(_=h,E=t.convert(0,_),b=t.find(s,[_,_]));for(var N=[],A=0;A<g;A++)N[A]=[];for(var C=[],M=[],S=0;S<y;S++){for(var $=S+1,F=m[S],I=m[S+1],R=F;R<I;R++){var U=c[R];C[U]=a?b(p[R],l[U][S]):b(l[U][S],p[R]),M[U]=$}for(var q=0;q<g;q++)M[q]===$?N[q][S]=C[q]:N[q][S]=a?b(E,l[q][S]):b(l[q][S],E)}return r.createDenseMatrix({data:N,size:[g,y],datatype:h===r._datatype&&w===n._datatype?_:void 0})}}),Gg="matAlgo05xSfSf",Kg=["typed","equalScalar"],qf=mt(Gg,Kg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var l=n._values,f=n._index,h=n._ptr,p=n._size,c=n._datatype||n._data===void 0?n._datatype:n.getDataType(),m=s._values,v=s._index,w=s._ptr,g=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(p.length!==g.length)throw new Zt(p.length,g.length);if(p[0]!==g[0]||p[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+g+")");var _=p[0],E=p[1],b,N=e,A=0,C=a;typeof c=="string"&&c===y&&c!=="mixed"&&(b=c,N=t.find(e,[b,b]),A=t.convert(0,b),C=t.find(a,[b,b]));var M=l&&m?[]:void 0,S=[],$=[],F=M?[]:void 0,I=M?[]:void 0,R=[],U=[],q,k,P,K;for(k=0;k<E;k++){$[k]=S.length;var G=k+1;for(P=h[k],K=h[k+1];P<K;P++)q=f[P],S.push(q),R[q]=G,F&&(F[q]=l[P]);for(P=w[k],K=w[k+1];P<K;P++)q=v[P],R[q]!==G&&S.push(q),U[q]=G,I&&(I[q]=m[P]);if(M)for(P=$[k];P<S.length;){q=S[P];var V=R[q],tt=U[q];if(V===G||tt===G){var ft=V===G?F[q]:A,vt=tt===G?I[q]:A,lt=C(ft,vt);N(lt,A)?S.splice(P,1):(M.push(lt),P++)}}}return $[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:$,size:[_,E],datatype:c===n._datatype&&y===s._datatype?b:void 0})}}),Hg="matAlgo13xDD",Jg=["typed"],Xg=mt(Hg,Jg,i=>{var{typed:t}=i;return function(n,s,a){var l=n._data,f=n._size,h=n._datatype,p=s._data,c=s._size,m=s._datatype,v=[];if(f.length!==c.length)throw new Zt(f.length,c.length);for(var w=0;w<f.length;w++){if(f[w]!==c[w])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+c+")");v[w]=f[w]}var g,y=a;typeof h=="string"&&h===m&&(g=h,y=t.find(a,[g,g]));var _=v.length>0?e(y,0,v,v[0],l,p):[];return n.createDenseMatrix({data:_,size:v,datatype:g})};function e(r,n,s,a,l,f){var h=[];if(n===s.length-1)for(var p=0;p<a;p++)h[p]=r(l[p],f[p]);else for(var c=0;c<a;c++)h[c]=e(r,n+1,s,s[n+1],l[c],f[c]);return h}}),Vg="broadcast",Qg=["concat"],tv=mt(Vg,Qg,i=>{var{concat:t}=i;return function(n,s){var a=Math.max(n._size.length,s._size.length);if(n._size.length===s._size.length&&n._size.every((w,g)=>w===s._size[g]))return[n,s];for(var l=e(n._size,a,0),f=e(s._size,a,0),h=[],p=0;p<a;p++)h[p]=Math.max(l[p],f[p]);As(l,h),As(f,h);var c=n.clone(),m=s.clone();c._size.length<a?c.reshape(e(c._size,a,1)):m._size.length<a&&m.reshape(e(m._size,a,1));for(var v=0;v<a;v++)c._size[v]<h[v]&&(c=r(c,h[v],v)),m._size[v]<h[v]&&(m=r(m,h[v],v));return[c,m]};function e(n,s,a){return[...Array(s-n.length).fill(a),...n]}function r(n,s,a){return t(...Array(s).fill(n),a)}}),ev="matrixAlgorithmSuite",rv=["typed","matrix","concat"],qn=mt(ev,rv,i=>{var{typed:t,matrix:e,concat:r}=i,n=Xg({typed:t}),s=Ea({typed:t}),a=tv({concat:r});return function(f){var h=f.elop,p=f.SD||f.DS,c;h?(c={"DenseMatrix, DenseMatrix":(g,y)=>n(...a(g,y),h),"Array, Array":(g,y)=>n(...a(e(g),e(y)),h).valueOf(),"Array, DenseMatrix":(g,y)=>n(...a(e(g),y),h),"DenseMatrix, Array":(g,y)=>n(...a(g,e(y)),h)},f.SS&&(c["SparseMatrix, SparseMatrix"]=(g,y)=>f.SS(...a(g,y),h,!1)),f.DS&&(c["DenseMatrix, SparseMatrix"]=(g,y)=>f.DS(...a(g,y),h,!1),c["Array, SparseMatrix"]=(g,y)=>f.DS(...a(e(g),y),h,!1)),p&&(c["SparseMatrix, DenseMatrix"]=(g,y)=>p(...a(y,g),h,!0),c["SparseMatrix, Array"]=(g,y)=>p(...a(e(y),g),h,!0))):(c={"DenseMatrix, DenseMatrix":t.referToSelf(g=>(y,_)=>n(...a(y,_),g)),"Array, Array":t.referToSelf(g=>(y,_)=>n(...a(e(y),e(_)),g).valueOf()),"Array, DenseMatrix":t.referToSelf(g=>(y,_)=>n(...a(e(y),_),g)),"DenseMatrix, Array":t.referToSelf(g=>(y,_)=>n(...a(y,e(_)),g))},f.SS&&(c["SparseMatrix, SparseMatrix"]=t.referToSelf(g=>(y,_)=>f.SS(...a(y,_),g,!1))),f.DS&&(c["DenseMatrix, SparseMatrix"]=t.referToSelf(g=>(y,_)=>f.DS(...a(y,_),g,!1)),c["Array, SparseMatrix"]=t.referToSelf(g=>(y,_)=>f.DS(...a(e(y),_),g,!1))),p&&(c["SparseMatrix, DenseMatrix"]=t.referToSelf(g=>(y,_)=>p(...a(_,y),g,!0)),c["SparseMatrix, Array"]=t.referToSelf(g=>(y,_)=>p(...a(e(_),y),g,!0))));var m=f.scalar||"any",v=f.Ds||f.Ss;v&&(h?(c["DenseMatrix,"+m]=(g,y)=>s(g,y,h,!1),c[m+", DenseMatrix"]=(g,y)=>s(y,g,h,!0),c["Array,"+m]=(g,y)=>s(e(g),y,h,!1).valueOf(),c[m+", Array"]=(g,y)=>s(e(y),g,h,!0).valueOf()):(c["DenseMatrix,"+m]=t.referToSelf(g=>(y,_)=>s(y,_,g,!1)),c[m+", DenseMatrix"]=t.referToSelf(g=>(y,_)=>s(_,y,g,!0)),c["Array,"+m]=t.referToSelf(g=>(y,_)=>s(e(y),_,g,!1).valueOf()),c[m+", Array"]=t.referToSelf(g=>(y,_)=>s(e(_),y,g,!0).valueOf())));var w=f.sS!==void 0?f.sS:f.Ss;return h?(f.Ss&&(c["SparseMatrix,"+m]=(g,y)=>f.Ss(g,y,h,!1)),w&&(c[m+", SparseMatrix"]=(g,y)=>w(y,g,h,!0))):(f.Ss&&(c["SparseMatrix,"+m]=t.referToSelf(g=>(y,_)=>f.Ss(y,_,g,!1))),w&&(c[m+", SparseMatrix"]=t.referToSelf(g=>(y,_)=>w(_,y,g,!0)))),h&&h.signatures&&Il(c,h.signatures),c}}),nv="matAlgo01xDSid",iv=["typed"],Uf=mt(nv,iv,i=>{var{typed:t}=i;return function(r,n,s,a){var l=r._data,f=r._size,h=r._datatype||r.getDataType(),p=n._values,c=n._index,m=n._ptr,v=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(f.length!==v.length)throw new Zt(f.length,v.length);if(f[0]!==v[0]||f[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+v+")");if(!p)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g=f[0],y=f[1],_=typeof h=="string"&&h!=="mixed"&&h===w?h:void 0,E=_?t.find(s,[_,_]):s,b,N,A=[];for(b=0;b<g;b++)A[b]=[];var C=[],M=[];for(N=0;N<y;N++){for(var S=N+1,$=m[N],F=m[N+1],I=$;I<F;I++)b=c[I],C[b]=a?E(p[I],l[b][N]):E(l[b][N],p[I]),M[b]=S;for(b=0;b<g;b++)M[b]===S?A[b][N]=C[b]:A[b][N]=l[b][N]}return r.createDenseMatrix({data:A,size:[g,y],datatype:h===r._datatype&&w===n._datatype?_:void 0})}}),sv="matAlgo04xSidSid",ov=["typed","equalScalar"],av=mt(sv,ov,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var l=n._values,f=n._index,h=n._ptr,p=n._size,c=n._datatype||n._data===void 0?n._datatype:n.getDataType(),m=s._values,v=s._index,w=s._ptr,g=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(p.length!==g.length)throw new Zt(p.length,g.length);if(p[0]!==g[0]||p[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+g+")");var _=p[0],E=p[1],b,N=e,A=0,C=a;typeof c=="string"&&c===y&&c!=="mixed"&&(b=c,N=t.find(e,[b,b]),A=t.convert(0,b),C=t.find(a,[b,b]));var M=l&&m?[]:void 0,S=[],$=[],F=l&&m?[]:void 0,I=l&&m?[]:void 0,R=[],U=[],q,k,P,K,G;for(k=0;k<E;k++){$[k]=S.length;var V=k+1;for(K=h[k],G=h[k+1],P=K;P<G;P++)q=f[P],S.push(q),R[q]=V,F&&(F[q]=l[P]);for(K=w[k],G=w[k+1],P=K;P<G;P++)if(q=v[P],R[q]===V){if(F){var tt=C(F[q],m[P]);N(tt,A)?R[q]=null:F[q]=tt}}else S.push(q),U[q]=V,I&&(I[q]=m[P]);if(F&&I)for(P=$[k];P<S.length;)q=S[P],R[q]===V?(M[P]=F[q],P++):U[q]===V?(M[P]=I[q],P++):S.splice(P,1)}return $[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:$,size:[_,E],datatype:c===n._datatype&&y===s._datatype?b:void 0})}}),uv="matAlgo10xSids",lv=["typed","DenseMatrix"],kf=mt(uv,lv,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,l){var f=n._values,h=n._index,p=n._ptr,c=n._size,m=n._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var v=c[0],w=c[1],g,y=a;typeof m=="string"&&(g=m,s=t.convert(s,g),y=t.find(a,[g,g]));for(var _=[],E=[],b=[],N=0;N<w;N++){for(var A=N+1,C=p[N],M=p[N+1],S=C;S<M;S++){var $=h[S];E[$]=f[S],b[$]=A}for(var F=0;F<v;F++)N===0&&(_[F]=[]),b[F]===A?_[F][N]=l?y(s,E[F]):y(E[F],s):_[F][N]=s}return new e({data:_,size:[v,w],datatype:g})}}),fv="multiplyScalar",cv=["typed"],hv=mt(fv,cv,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":Cf,"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)})}),Wf="multiply",pv=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],dv=mt(Wf,pv,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:a}=i,l=ba({typed:t,equalScalar:s}),f=Ea({typed:t});function h(A,C){switch(A.length){case 1:switch(C.length){case 1:if(A[0]!==C[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(A[0]!==C[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+A[0]+") must match Matrix rows ("+C[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+C.length+" dimensions)")}break;case 2:switch(C.length){case 1:if(A[1]!==C[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+A[1]+") must match Vector length ("+C[0]+")");break;case 2:if(A[1]!==C[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+A[1]+") must match Matrix B rows ("+C[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+C.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+A.length+" dimensions)")}}function p(A,C,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return a(A,C)}function c(A,C){if(C.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return m(A,C)}function m(A,C){var M=A._data,S=A._size,$=A._datatype||A.getDataType(),F=C._data,I=C._size,R=C._datatype||C.getDataType(),U=S[0],q=I[1],k,P=r,K=n;$&&R&&$===R&&typeof $=="string"&&$!=="mixed"&&(k=$,P=t.find(r,[k,k]),K=t.find(n,[k,k]));for(var G=[],V=0;V<q;V++){for(var tt=K(M[0],F[0][V]),ft=1;ft<U;ft++)tt=P(tt,K(M[ft],F[ft][V]));G[V]=tt}return A.createDenseMatrix({data:G,size:[q],datatype:$===A._datatype&&R===C._datatype?k:void 0})}var v=t("_multiplyMatrixVector",{"DenseMatrix, any":g,"SparseMatrix, any":E}),w=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":_,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function g(A,C){var M=A._data,S=A._size,$=A._datatype||A.getDataType(),F=C._data,I=C._datatype||C.getDataType(),R=S[0],U=S[1],q,k=r,P=n;$&&I&&$===I&&typeof $=="string"&&$!=="mixed"&&(q=$,k=t.find(r,[q,q]),P=t.find(n,[q,q]));for(var K=[],G=0;G<R;G++){for(var V=M[G],tt=P(V[0],F[0]),ft=1;ft<U;ft++)tt=k(tt,P(V[ft],F[ft]));K[G]=tt}return A.createDenseMatrix({data:K,size:[R],datatype:$===A._datatype&&I===C._datatype?q:void 0})}function y(A,C){var M=A._data,S=A._size,$=A._datatype||A.getDataType(),F=C._data,I=C._size,R=C._datatype||C.getDataType(),U=S[0],q=S[1],k=I[1],P,K=r,G=n;$&&R&&$===R&&typeof $=="string"&&$!=="mixed"&&$!=="mixed"&&(P=$,K=t.find(r,[P,P]),G=t.find(n,[P,P]));for(var V=[],tt=0;tt<U;tt++){var ft=M[tt];V[tt]=[];for(var vt=0;vt<k;vt++){for(var lt=G(ft[0],F[0][vt]),wt=1;wt<q;wt++)lt=K(lt,G(ft[wt],F[wt][vt]));V[tt][vt]=lt}}return A.createDenseMatrix({data:V,size:[U,k],datatype:$===A._datatype&&R===C._datatype?P:void 0})}function _(A,C){var M=A._data,S=A._size,$=A._datatype||A.getDataType(),F=C._values,I=C._index,R=C._ptr,U=C._size,q=C._datatype||C._data===void 0?C._datatype:C.getDataType();if(!F)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var k=S[0],P=U[1],K,G=r,V=n,tt=s,ft=0;$&&q&&$===q&&typeof $=="string"&&$!=="mixed"&&(K=$,G=t.find(r,[K,K]),V=t.find(n,[K,K]),tt=t.find(s,[K,K]),ft=t.convert(0,K));for(var vt=[],lt=[],wt=[],yt=C.createSparseMatrix({values:vt,index:lt,ptr:wt,size:[k,P],datatype:$===A._datatype&&q===C._datatype?K:void 0}),St=0;St<P;St++){wt[St]=lt.length;var bt=R[St],re=R[St+1];if(re>bt)for(var It=0,Mt=0;Mt<k;Mt++){for(var ie=Mt+1,Xt=void 0,zt=bt;zt<re;zt++){var Gt=I[zt];It!==ie?(Xt=V(M[Mt][Gt],F[zt]),It=ie):Xt=G(Xt,V(M[Mt][Gt],F[zt]))}It===ie&&!tt(Xt,ft)&&(lt.push(Mt),vt.push(Xt))}}return wt[P]=lt.length,yt}function E(A,C){var M=A._values,S=A._index,$=A._ptr,F=A._datatype||A._data===void 0?A._datatype:A.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var I=C._data,R=C._datatype||C.getDataType(),U=A._size[0],q=C._size[0],k=[],P=[],K=[],G,V=r,tt=n,ft=s,vt=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(G=F,V=t.find(r,[G,G]),tt=t.find(n,[G,G]),ft=t.find(s,[G,G]),vt=t.convert(0,G));var lt=[],wt=[];K[0]=0;for(var yt=0;yt<q;yt++){var St=I[yt];if(!ft(St,vt))for(var bt=$[yt],re=$[yt+1],It=bt;It<re;It++){var Mt=S[It];wt[Mt]?lt[Mt]=V(lt[Mt],tt(St,M[It])):(wt[Mt]=!0,P.push(Mt),lt[Mt]=tt(St,M[It]))}}for(var ie=P.length,Xt=0;Xt<ie;Xt++){var zt=P[Xt];k[Xt]=lt[zt]}return K[1]=P.length,A.createSparseMatrix({values:k,index:P,ptr:K,size:[U,1],datatype:F===A._datatype&&R===C._datatype?G:void 0})}function b(A,C){var M=A._values,S=A._index,$=A._ptr,F=A._datatype||A._data===void 0?A._datatype:A.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var I=C._data,R=C._datatype||C.getDataType(),U=A._size[0],q=C._size[0],k=C._size[1],P,K=r,G=n,V=s,tt=0;F&&R&&F===R&&typeof F=="string"&&F!=="mixed"&&(P=F,K=t.find(r,[P,P]),G=t.find(n,[P,P]),V=t.find(s,[P,P]),tt=t.convert(0,P));for(var ft=[],vt=[],lt=[],wt=A.createSparseMatrix({values:ft,index:vt,ptr:lt,size:[U,k],datatype:F===A._datatype&&R===C._datatype?P:void 0}),yt=[],St=[],bt=0;bt<k;bt++){lt[bt]=vt.length;for(var re=bt+1,It=0;It<q;It++){var Mt=I[It][bt];if(!V(Mt,tt))for(var ie=$[It],Xt=$[It+1],zt=ie;zt<Xt;zt++){var Gt=S[zt];St[Gt]!==re?(St[Gt]=re,vt.push(Gt),yt[Gt]=G(Mt,M[zt])):yt[Gt]=K(yt[Gt],G(Mt,M[zt]))}}for(var Ce=lt[bt],sr=vt.length,Me=Ce;Me<sr;Me++){var Vr=vt[Me];ft[Me]=yt[Vr]}}return lt[k]=vt.length,wt}function N(A,C){var M=A._values,S=A._index,$=A._ptr,F=A._datatype||A._data===void 0?A._datatype:A.getDataType(),I=C._values,R=C._index,U=C._ptr,q=C._datatype||C._data===void 0?C._datatype:C.getDataType(),k=A._size[0],P=C._size[1],K=M&&I,G,V=r,tt=n;F&&q&&F===q&&typeof F=="string"&&F!=="mixed"&&(G=F,V=t.find(r,[G,G]),tt=t.find(n,[G,G]));for(var ft=K?[]:void 0,vt=[],lt=[],wt=A.createSparseMatrix({values:ft,index:vt,ptr:lt,size:[k,P],datatype:F===A._datatype&&q===C._datatype?G:void 0}),yt=K?[]:void 0,St=[],bt,re,It,Mt,ie,Xt,zt,Gt,Ce=0;Ce<P;Ce++){lt[Ce]=vt.length;var sr=Ce+1;for(ie=U[Ce],Xt=U[Ce+1],Mt=ie;Mt<Xt;Mt++)if(Gt=R[Mt],K)for(re=$[Gt],It=$[Gt+1],bt=re;bt<It;bt++)zt=S[bt],St[zt]!==sr?(St[zt]=sr,vt.push(zt),yt[zt]=tt(I[Mt],M[bt])):yt[zt]=V(yt[zt],tt(I[Mt],M[bt]));else for(re=$[Gt],It=$[Gt+1],bt=re;bt<It;bt++)zt=S[bt],St[zt]!==sr&&(St[zt]=sr,vt.push(zt));if(K)for(var Me=lt[Ce],Vr=vt.length,wn=Me;wn<Vr;wn++){var Qr=vt[wn];ft[wn]=yt[Qr]}}return lt[P]=vt.length,wt}return t(Wf,n,{"Array, Array":t.referTo("Matrix, Matrix",A=>(C,M)=>{h(Ae(C),Ae(M));var S=A(e(C),e(M));return fe(S)?S.valueOf():S}),"Matrix, Matrix":function(C,M){var S=C.size(),$=M.size();return h(S,$),S.length===1?$.length===1?p(C,M,S[0]):c(C,M):$.length===1?v(C,M):w(C,M)},"Matrix, Array":t.referTo("Matrix,Matrix",A=>(C,M)=>A(C,e(M))),"Array, Matrix":t.referToSelf(A=>(C,M)=>A(e(C,M.storage()),M)),"SparseMatrix, any":function(C,M){return l(C,M,n,!1)},"DenseMatrix, any":function(C,M){return f(C,M,n,!1)},"any, SparseMatrix":function(C,M){return l(M,C,n,!0)},"any, DenseMatrix":function(C,M){return f(M,C,n,!0)},"Array, any":function(C,M){return f(e(C),M,n,!1).valueOf()},"any, Array":function(C,M){return f(e(M),C,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(A=>(C,M,S)=>{for(var $=A(C,M),F=0;F<S.length;F++)$=A($,S[F]);return $})})}),Yf="subtract",mv=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],gv=mt(Yf,mv,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:a,concat:l}=i,f=Uf({typed:t}),h=fi({typed:t}),p=qf({typed:t,equalScalar:r}),c=kf({typed:t,DenseMatrix:a}),m=li({typed:t,DenseMatrix:a}),v=qn({typed:t,matrix:e,concat:l});return t(Yf,{"any, any":n},v({elop:n,SS:p,DS:f,SD:h,Ss:m,sS:c}))}),vv="matAlgo07xSSf",_v=["typed","DenseMatrix"],zs=mt(vv,_v,i=>{var{typed:t,DenseMatrix:e}=i;return function(s,a,l){var f=s._size,h=s._datatype||s._data===void 0?s._datatype:s.getDataType(),p=a._size,c=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(f.length!==p.length)throw new Zt(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");var m=f[0],v=f[1],w,g=0,y=l;typeof h=="string"&&h===c&&h!=="mixed"&&(w=h,g=t.convert(0,w),y=t.find(l,[w,w]));var _,E,b=[];for(_=0;_<m;_++)b[_]=[];var N=[],A=[],C=[],M=[];for(E=0;E<v;E++){var S=E+1;for(r(s,E,C,N,S),r(a,E,M,A,S),_=0;_<m;_++){var $=C[_]===S?N[_]:g,F=M[_]===S?A[_]:g;b[_][E]=y($,F)}}return new e({data:b,size:[m,v],datatype:h===s._datatype&&c===a._datatype?w:void 0})};function r(n,s,a,l,f){for(var h=n._values,p=n._index,c=n._ptr,m=c[s],v=c[s+1];m<v;m++){var w=p[m];a[w]=f,l[w]=h[m]}}}),jf="conj",wv=["typed"],Dv=mt(jf,wv,i=>{var{typed:t}=i;return t(jf,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Ir(r,e))})}),Zf="concat",yv=["typed","matrix","isInteger"],bv=mt(Zf,yv,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(Zf,{"...Array | Matrix | number | BigNumber":function(s){var a,l=s.length,f=-1,h,p=!1,c=[];for(a=0;a<l;a++){var m=s[a];if(fe(m)&&(p=!0),ue(m)||ye(m)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(h=f,f=m.valueOf(),!r(f))throw new TypeError("Integer number expected for dimension");if(f<0||a>0&&f>h)throw new hn(f,h+1)}else{var v=ee(m).valueOf(),w=Ae(v);if(c[a]=v,h=f,f=w.length-1,a>0&&f!==h)throw new Zt(h+1,f+1)}}if(c.length===0)throw new SyntaxError("At least one matrix expected");for(var g=c.shift();c.length;)g=Vl(g,c.shift(),f);return p?e(g):g},"...string":function(s){return s.join("")}})}),Gf="count",Ev=["typed","size","prod"],Av=mt(Gf,Ev,i=>{var{typed:t,size:e,prod:r}=i;return t(Gf,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),Kf="identity",xv=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Cv=mt(Kf,xv,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:a}=i;return t(Kf,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(p){return r(p)},"number | BigNumber":function(p){return f(p,p,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(p,c){return f(p,p,c)},"number | BigNumber, number | BigNumber":function(p,c){return f(p,c,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(p,c,m){return f(p,c,m)},Array:function(p){return l(p)},"Array, string":function(p,c){return l(p,c)},Matrix:function(p){return l(p.valueOf(),p.storage())},"Matrix, string":function(p,c){return l(p.valueOf(),c)}});function l(h,p){switch(h.length){case 0:return p?r(p):[];case 1:return f(h[0],h[0],p);case 2:return f(h[0],h[1],p);default:throw new Error("Vector containing two values expected")}}function f(h,p,c){var m=ye(h)||ye(p)?n:null;if(ye(h)&&(h=h.toNumber()),ye(p)&&(p=p.toNumber()),!he(h)||h<1)throw new Error("Parameters in function identity must be positive integers");if(!he(p)||p<1)throw new Error("Parameters in function identity must be positive integers");var v=m?new n(1):1,w=m?new m(0):0,g=[h,p];if(c){if(c==="sparse")return a.diagonal(g,v,0,w);if(c==="dense")return s.diagonal(g,v,0,w);throw new TypeError('Unknown matrix type "'.concat(c,'"'))}for(var y=ua([],g,w),_=h<p?h:p,E=0;E<_;E++)y[E][E]=v;return y}}),Hf="kron",Fv=["typed","matrix","multiplyScalar"],Mv=mt(Hf,Fv,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(Hf,{"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(s,a){if(Ae(s).length===1&&(s=[s]),Ae(a).length===1&&(a=[a]),Ae(s).length>2||Ae(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(s.length)+", y = "+JSON.stringify(a.length)+")");var l=[],f=[];return s.map(function(h){return a.map(function(p){return f=[],l.push(f),h.map(function(c){return p.map(function(m){return f.push(r(c,m))})})})})&&l}});function Nv(){throw new Error('No "bignumber" implementation available')}function Sv(){throw new Error('No "fraction" implementation available')}function Bv(){throw new Error('No "matrix" implementation available')}var Jf="reshape",Iv=["typed","isInteger","matrix"],Tv=mt(Jf,Iv,i=>{var{typed:t,isInteger:e}=i;return t(Jf,{"Matrix, Array":function(n,s){return n.reshape(s,!0)},"Array, Array":function(n,s){return s.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),fa(n,s)}})}),Xf="size",$v=["typed","config","?matrix"],Ov=mt(Xf,$v,i=>{var{typed:t,config:e,matrix:r}=i;return t(Xf,{Matrix:function(s){return s.create(s.size())},Array:Ae,string:function(s){return e.matrix==="Array"?[s.length]:r([s.length])},"number | Complex | BigNumber | Unit | boolean | null":function(s){return e.matrix==="Array"?[]:r?r([]):Bv()}})}),Vf="transpose",Rv=["typed","matrix"],Lv=mt(Vf,Rv,i=>{var{typed:t,matrix:e}=i;return t(Vf,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:ee});function r(a){var l=a.size(),f;switch(l.length){case 1:f=a.clone();break;case 2:{var h=l[0],p=l[1];if(p===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+se(l)+")");switch(a.storage()){case"dense":f=n(a,h,p);break;case"sparse":f=s(a,h,p);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+se(l)+")")}return f}function n(a,l,f){for(var h=a._data,p=[],c,m=0;m<f;m++){c=p[m]=[];for(var v=0;v<l;v++)c[v]=ee(h[v][m])}return a.createDenseMatrix({data:p,size:[f,l],datatype:a._datatype})}function s(a,l,f){for(var h=a._values,p=a._index,c=a._ptr,m=h?[]:void 0,v=[],w=[],g=[],y=0;y<l;y++)g[y]=0;var _,E,b;for(_=0,E=p.length;_<E;_++)g[p[_]]++;for(var N=0,A=0;A<l;A++)w.push(N),N+=g[A],g[A]=w[A];for(w.push(N),b=0;b<f;b++)for(var C=c[b],M=c[b+1],S=C;S<M;S++){var $=g[p[S]]++;v[$]=b,h&&(m[$]=ee(h[S]))}return a.createSparseMatrix({values:m,index:v,ptr:w,size:[f,l],datatype:a._datatype})}}),Qf="ctranspose",Pv=["typed","transpose","conj"],zv=mt(Qf,Pv,i=>{var{typed:t,transpose:e,conj:r}=i;return t(Qf,{any:function(s){return r(e(s))}})}),tc="mode",qv=["typed","isNaN","isNumeric"],Uv=mt(tc,qv,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(tc,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(s){s=ha(s.valueOf());var a=s.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},f=[],h=0,p=0;p<s.length;p++){var c=s[p];if(r(c)&&e(c))throw new Error("Cannot calculate mode of an array containing NaN values");c in l||(l[c]=0),l[c]++,l[c]===h?f.push(c):l[c]>h&&(h=l[c],f=[c])}return f}});function vn(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+cn(e)+", value: "+JSON.stringify(e)+")":" (type: "+i.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(i).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+cn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var ec="prod",kv=["typed","config","multiplyScalar","numeric"],Wv=mt(ec,kv,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(ec,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,f){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return s(l)}});function s(a){var l;if(Wi(a,function(f){try{l=l===void 0?f:r(l,f)}catch(h){throw vn(h,"prod",f)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),Yv="numeric",jv=["number","?bignumber","?fraction"],Zv=mt(Yv,jv,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:a=>t(a),BigNumber:e?a=>e(a):Nv,Fraction:r?a=>r(a):Sv};return function(l){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",h=arguments.length>2?arguments[2]:void 0;if(h!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var p=cn(l);if(!(p in n))throw new TypeError("Cannot convert "+l+' of type "'+p+'"; valid input types are '+Object.keys(n).join(", "));if(!(f in s))throw new TypeError("Cannot convert "+l+' to type "'+f+'"; valid output types are '+Object.keys(s).join(", "));return f===p?l:s[f](l)}}),rc="divideScalar",Gv=["typed","numeric"],Kv=mt(rc,Gv,i=>{var{typed:t,numeric:e}=i;return t(rc,{"number, number":function(n,s){return n/s},"Complex, Complex":function(n,s){return n.div(s)},"BigNumber, BigNumber":function(n,s){return n.div(s)},"Fraction, Fraction":function(n,s){return n.div(s)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),nc="pow",Hv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Jv=mt(nc,Hv,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:a,number:l,fraction:f,Complex:h}=i;return t(nc,{"number, number":p,"Complex, Complex":function(w,g){return w.pow(g)},"BigNumber, BigNumber":function(w,g){return g.isInteger()||w>=0||e.predictable?w.pow(g):new h(w.toNumber(),0).pow(g.toNumber(),0)},"Fraction, Fraction":function(w,g){var y=w.pow(g);if(y!=null)return y;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return p(w.valueOf(),g.valueOf())},"Array, number":c,"Array, BigNumber":function(w,g){return c(w,g.toNumber())},"Matrix, number":m,"Matrix, BigNumber":function(w,g){return m(w,g.toNumber())},"Unit, number | BigNumber":function(w,g){return w.pow(g)}});function p(v,w){if(e.predictable&&!he(w)&&v<0)try{var g=f(w),y=l(g);if((w===y||Math.abs((w-y)/w)<1e-14)&&g.d%2===1)return(g.n%2===0?1:-1)*Math.pow(-v,w)}catch{}return e.predictable&&(v<-1&&w===1/0||v>-1&&v<0&&w===-1/0)?NaN:he(w)||v>=0||e.predictable?Mf(v,w):v*v<1&&w===1/0||v*v>1&&w===-1/0?0:new h(v,0).pow(w,0)}function c(v,w){if(!he(w))throw new TypeError("For A^b, b must be an integer (value is "+w+")");var g=Ae(v);if(g.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+g.length+" dimensions)");if(g[0]!==g[1])throw new Error("For A^b, A must be square (size is "+g[0]+"x"+g[1]+")");if(w<0)try{return c(a(v),-w)}catch(E){throw E.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+w+")"):E}for(var y=r(g[0]).valueOf(),_=v;w>=1;)(w&1)===1&&(y=n(_,y)),w>>=1,_=n(_,_);return y}function m(v,w){return s(c(v.valueOf(),w))}}),ic="dotDivide",Xv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],Vv=mt(ic,Xv,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:a}=i,l=Yg({typed:t,equalScalar:r}),f=fi({typed:t}),h=zs({typed:t,DenseMatrix:s}),p=ba({typed:t,equalScalar:r}),c=li({typed:t,DenseMatrix:s}),m=qn({typed:t,matrix:e,concat:a});return t(ic,m({elop:n,SS:h,DS:f,SD:l,Ss:p,sS:c}))}),qs="compare",Qv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],t_=mt(qs,Qv,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:a,DenseMatrix:l,concat:f}=i,h=fi({typed:t}),p=qf({typed:t,equalScalar:r}),c=li({typed:t,DenseMatrix:l}),m=qn({typed:t,matrix:n,concat:f}),v=Ls({typed:t});return t(qs,e_({typed:t,config:e}),{"boolean, boolean":function(g,y){return g===y?0:g>y?1:-1},"BigNumber, BigNumber":function(g,y){return Rs(g,y,e.epsilon)?new s(0):new s(g.cmp(y))},"Fraction, Fraction":function(g,y){return new a(g.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},v,m({SS:p,DS:h,Ss:c}))}),e_=mt(qs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(qs,{"number, number":function(n,s){return zn(n,s,e.epsilon)?0:n>s?1:-1}})}),Us="equal",r_=["typed","matrix","equalScalar","DenseMatrix","concat"],n_=mt(Us,r_,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,a=fi({typed:t}),l=zs({typed:t,DenseMatrix:n}),f=li({typed:t,DenseMatrix:n}),h=qn({typed:t,matrix:e,concat:s});return t(Us,i_({typed:t,equalScalar:r}),h({elop:r,SS:l,DS:a,Ss:f}))}),i_=mt(Us,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(Us,{"any, any":function(n,s){return n===null?s===null:s===null?n===null:n===void 0?s===void 0:s===void 0?n===void 0:e(n,s)}})}),ks="smaller",s_=["typed","config","matrix","DenseMatrix","concat"],o_=mt(ks,s_,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=fi({typed:t}),l=zs({typed:t,DenseMatrix:n}),f=li({typed:t,DenseMatrix:n}),h=qn({typed:t,matrix:r,concat:s}),p=Ls({typed:t});return t(ks,a_({typed:t,config:e}),{"boolean, boolean":(c,m)=>c<m,"BigNumber, BigNumber":function(m,v){return m.lt(v)&&!Rs(m,v,e.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===-1,"Complex, Complex":function(m,v){throw new TypeError("No ordering relation is defined for complex numbers")}},p,h({SS:l,DS:a,Ss:f}))}),a_=mt(ks,["typed","config"],i=>{var{typed:t,config:e}=i;return t(ks,{"number, number":function(n,s){return n<s&&!zn(n,s,e.epsilon)}})}),Ws="larger",u_=["typed","config","matrix","DenseMatrix","concat"],l_=mt(Ws,u_,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=fi({typed:t}),l=zs({typed:t,DenseMatrix:n}),f=li({typed:t,DenseMatrix:n}),h=qn({typed:t,matrix:r,concat:s}),p=Ls({typed:t});return t(Ws,f_({typed:t,config:e}),{"boolean, boolean":(c,m)=>c>m,"BigNumber, BigNumber":function(m,v){return m.gt(v)&&!Rs(m,v,e.epsilon)},"Fraction, Fraction":(c,m)=>c.compare(m)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},p,h({SS:l,DS:a,Ss:f}))}),f_=mt(Ws,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Ws,{"number, number":function(n,s){return n>s&&!zn(n,s,e.epsilon)}})}),sc="deepEqual",c_=["typed","equal"],h_=mt(sc,c_,i=>{var{typed:t,equal:e}=i;return t(sc,{"any, any":function(s,a){return r(s.valueOf(),a.valueOf())}});function r(n,s){if(Array.isArray(n))if(Array.isArray(s)){var a=n.length;if(a!==s.length)return!1;for(var l=0;l<a;l++)if(!r(n[l],s[l]))return!1;return!0}else return!1;else return Array.isArray(s)?!1:e(n,s)}}),oc="partitionSelect",p_=["typed","isNumeric","isNaN","compare"],d_=mt(oc,p_,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,a=(h,p)=>-n(h,p);return t(oc,{"Array | Matrix, number":function(p,c){return l(p,c,s)},"Array | Matrix, number, string":function(p,c,m){if(m==="asc")return l(p,c,s);if(m==="desc")return l(p,c,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(h,p,c){if(!he(p)||p<0)throw new Error("k must be a non-negative integer");if(fe(h)){var m=h.size();if(m.length>1)throw new Error("Only one dimensional matrices supported");return f(h.valueOf(),p,c)}if(Array.isArray(h))return f(h,p,c)}function f(h,p,c){if(p>=h.length)throw new Error("k out of bounds");for(var m=0;m<h.length;m++)if(e(h[m])&&r(h[m]))return h[m];for(var v=0,w=h.length-1;v<w;){for(var g=v,y=w,_=h[Math.floor(Math.random()*(w-v+1))+v];g<y;)if(c(h[g],_)>=0){var E=h[y];h[y]=h[g],h[g]=E,--y}else++g;c(h[g],_)>0&&--g,p<=g?w=g:v=g+1}return h[p]}}),ac="max",m_=["typed","config","numeric","larger"],g_=mt(ac,m_,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(ac,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(f,h){return ya(f,h.valueOf(),s)},"...":function(f){if(Ts(f))throw new TypeError("Scalar values expected in function max");return a(f)}});function s(l,f){try{return n(l,f)?l:f}catch(h){throw vn(h,"max",f)}}function a(l){var f;if(Wi(l,function(h){try{isNaN(h)&&typeof h=="number"?f=NaN:(f===void 0||n(h,f))&&(f=h)}catch(p){throw vn(p,"max",h)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=r(f,e.number)),f}}),uc="min",v_=["typed","config","numeric","smaller"],__=mt(uc,v_,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(uc,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(f,h){return ya(f,h.valueOf(),s)},"...":function(f){if(Ts(f))throw new TypeError("Scalar values expected in function min");return a(f)}});function s(l,f){try{return n(l,f)?l:f}catch(h){throw vn(h,"min",f)}}function a(l){var f;if(Wi(l,function(h){try{isNaN(h)&&typeof h=="number"?f=NaN:(f===void 0||n(h,f))&&(f=h)}catch(p){throw vn(p,"min",h)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=r(f,e.number)),f}}),lc="add",w_=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],D_=mt(lc,w_,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:a,concat:l}=i,f=Uf({typed:t}),h=av({typed:t,equalScalar:n}),p=kf({typed:t,DenseMatrix:s}),c=qn({typed:t,matrix:e,concat:l});return t(lc,{"any, any":r,"any, any, ...any":t.referToSelf(m=>(v,w,g)=>{for(var y=m(v,w),_=0;_<g.length;_++)y=m(y,g[_]);return y})},c({elop:r,DS:f,SS:h,Ss:p}))}),fc="dot",y_=["typed","addScalar","multiplyScalar","conj","size"],b_=mt(fc,y_,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(fc,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":f});function a(p,c){var m=h(p),v=h(c),w,g;if(m.length===1)w=m[0];else if(m.length===2&&m[1]===1)w=m[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+m.join(", ")+")");if(v.length===1)g=v[0];else if(v.length===2&&v[1]===1)g=v[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+v.join(", ")+")");if(w!==g)throw new RangeError("Vectors must have equal length ("+w+" != "+g+")");if(w===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return w}function l(p,c){var m=a(p,c),v=fe(p)?p._data:p,w=fe(p)?p._datatype||p.getDataType():void 0,g=fe(c)?c._data:c,y=fe(c)?c._datatype||c.getDataType():void 0,_=h(p).length===2,E=h(c).length===2,b=e,N=r;if(w&&y&&w===y&&typeof w=="string"&&w!=="mixed"){var A=w;b=t.find(e,[A,A]),N=t.find(r,[A,A])}if(!_&&!E){for(var C=N(n(v[0]),g[0]),M=1;M<m;M++)C=b(C,N(n(v[M]),g[M]));return C}if(!_&&E){for(var S=N(n(v[0]),g[0][0]),$=1;$<m;$++)S=b(S,N(n(v[$]),g[$][0]));return S}if(_&&!E){for(var F=N(n(v[0][0]),g[0]),I=1;I<m;I++)F=b(F,N(n(v[I][0]),g[I]));return F}if(_&&E){for(var R=N(n(v[0][0]),g[0][0]),U=1;U<m;U++)R=b(R,N(n(v[U][0]),g[U][0]));return R}}function f(p,c){a(p,c);for(var m=p._index,v=p._values,w=c._index,g=c._values,y=0,_=e,E=r,b=0,N=0;b<m.length&&N<w.length;){var A=m[b],C=w[N];if(A<C){b++;continue}if(A>C){N++;continue}A===C&&(y=_(y,E(v[b],g[N])),b++,N++)}return y}function h(p){return fe(p)?p.size():s(p)}}),E_="trace",A_=["typed","matrix","add"],x_=mt(E_,A_,i=>{var{typed:t,matrix:e,add:r}=i;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:s,DenseMatrix:n,any:ee});function n(a){var l=a._size,f=a._data;switch(l.length){case 1:if(l[0]===1)return ee(f[0]);throw new RangeError("Matrix must be square (size: "+se(l)+")");case 2:{var h=l[0],p=l[1];if(h===p){for(var c=0,m=0;m<h;m++)c=r(c,f[m][m]);return c}else throw new RangeError("Matrix must be square (size: "+se(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(l)+")")}}function s(a){var l=a._values,f=a._index,h=a._ptr,p=a._size,c=p[0],m=p[1];if(c===m){var v=0;if(l.length>0)for(var w=0;w<m;w++)for(var g=h[w],y=h[w+1],_=g;_<y;_++){var E=f[_];if(E===w){v=r(v,l[_]);break}if(E>w)break}return v}throw new RangeError("Matrix must be square (size: "+se(p)+")")}}),cc="det",C_=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],F_=mt(cc,C_,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:a,unaryMinus:l}=i;return t(cc,{any:function(p){return ee(p)},"Array | Matrix":function(p){var c;switch(fe(p)?c=p.size():Array.isArray(p)?(p=e(p),c=p.size()):c=[],c.length){case 0:return ee(p);case 1:if(c[0]===1)return ee(p.valueOf()[0]);if(c[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+se(c)+")");case 2:{var m=c[0],v=c[1];if(m===v)return f(p.clone().valueOf(),m);if(v===0)return 1;throw new RangeError("Matrix must be square (size: "+se(c)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(c)+")")}}});function f(h,p,c){if(p===1)return ee(h[0][0]);if(p===2)return r(n(h[0][0],h[1][1]),n(h[1][0],h[0][1]));for(var m=!1,v=new Array(p).fill(0).map((M,S)=>S),w=0;w<p;w++){var g=v[w];if(a(h[g][w])){var y=void 0;for(y=w+1;y<p;y++)if(!a(h[v[y]][w])){g=v[y],v[y]=v[w],v[w]=g,m=!m;break}if(y===p)return h[g][w]}for(var _=h[g][w],E=w===0?1:h[v[w-1]][w-1],b=w+1;b<p;b++)for(var N=v[b],A=w+1;A<p;A++)h[N][A]=s(r(n(h[N][A],_),n(h[N][w],h[g][A])),E)}var C=h[v[p-1]][p-1];return m?l(C):C}}),hc="inv",M_=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],N_=mt(hc,M_,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:a,det:l,identity:f,abs:h}=i;return t(hc,{"Array | Matrix":function(m){var v=fe(m)?m.size():Ae(m);switch(v.length){case 1:if(v[0]===1)return fe(m)?e([r(1,m.valueOf()[0])]):[r(1,m[0])];throw new RangeError("Matrix must be square (size: "+se(v)+")");case 2:{var w=v[0],g=v[1];if(w===g)return fe(m)?e(p(m.valueOf(),w,g),m.storage()):p(m,w,g);throw new RangeError("Matrix must be square (size: "+se(v)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+se(v)+")")}},any:function(m){return r(1,m)}});function p(c,m,v){var w,g,y,_,E;if(m===1){if(_=c[0][0],_===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,_)]]}else if(m===2){var b=l(c);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(c[1][1],b),r(a(c[0][1]),b)],[r(a(c[1][0]),b),r(c[0][0],b)]]}else{var N=c.concat();for(w=0;w<m;w++)N[w]=N[w].concat();for(var A=f(m).valueOf(),C=0;C<v;C++){var M=h(N[C][C]),S=C;for(w=C+1;w<m;)h(N[w][C])>M&&(M=h(N[w][C]),S=w),w++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");w=S,w!==C&&(E=N[C],N[C]=N[w],N[w]=E,E=A[C],A[C]=A[w],A[w]=E);var $=N[C],F=A[C];for(w=0;w<m;w++){var I=N[w],R=A[w];if(w!==C){if(I[C]!==0){for(y=r(a(I[C]),$[C]),g=C;g<v;g++)I[g]=n(I[g],s(y,$[g]));for(g=0;g<v;g++)R[g]=n(R[g],s(y,F[g]))}}else{for(y=$[C],g=C;g<v;g++)I[g]=r(I[g],y);for(g=0;g<v;g++)R[g]=r(R[g],y)}}}return A}}}),pc="pinv",S_=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],B_=mt(pc,S_,i=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:s,dotDivide:a,dot:l,ctranspose:f,divideScalar:h,multiply:p,add:c,Complex:m}=i;return t(pc,{"Array | Matrix":function(b){var N=fe(b)?b.size():Ae(b);switch(N.length){case 1:return _(b)?f(b):N[0]===1?r(b):a(f(b),l(b,b));case 2:{if(_(b))return f(b);var A=N[0],C=N[1];if(A===C)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return fe(b)?e(v(b.valueOf(),A,C),b.storage()):v(b,A,C)}default:throw new RangeError("Matrix must be two dimensional (size: "+se(N)+")")}},any:function(b){return s(b,0)?ee(b):h(1,b)}});function v(E,b,N){var{C:A,F:C}=g(E,b,N),M=p(r(p(f(A),A)),f(A)),S=p(f(C),r(p(C,f(C))));return p(S,M)}function w(E,b,N){for(var A=ee(E),C=0,M=0;M<b;M++){if(N<=C)return A;for(var S=M;y(A[S][C]);)if(S++,b===S&&(S=M,C++,N===C))return A;[A[S],A[M]]=[A[M],A[S]];for(var $=A[M][C],F=0;F<N;F++)A[M][F]=a(A[M][F],$);for(var I=0;I<b;I++)if(I!==M){$=A[I][C];for(var R=0;R<N;R++)A[I][R]=c(A[I][R],p(-1,p($,A[M][R])))}C++}return A}function g(E,b,N){var A=w(E,b,N),C=E.map((S,$)=>S.filter((F,I)=>I<b&&!y(l(A[I],A[I])))),M=A.filter((S,$)=>!y(l(A[$],A[$])));return{C,F:M}}function y(E){return s(c(E,m(1,1)),c(0,m(1,1)))}function _(E){return n(c(E,m(1,1)),c(p(E,0),m(1,1)))}}),I_="divide",T_=["typed","matrix","multiply","equalScalar","divideScalar","inv"],$_=mt(I_,T_,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:a}=i,l=ba({typed:t,equalScalar:n}),f=Ea({typed:t});return t("divide",Il({"Array | Matrix, Array | Matrix":function(p,c){return r(p,a(c))},"DenseMatrix, any":function(p,c){return f(p,c,s,!1)},"SparseMatrix, any":function(p,c){return l(p,c,s,!1)},"Array, any":function(p,c){return f(e(p),c,s,!1).valueOf()},"any, Array | Matrix":function(p,c){return r(p,a(c))}},s.signatures))}),dc="sum",O_=["typed","config","add","numeric"],R_=mt(dc,O_,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(dc,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":a,"...":function(f){if(Ts(f))throw new TypeError("Scalar values expected in function sum");return s(f)}});function s(l){var f;return Wi(l,function(h){try{f=f===void 0?h:r(f,h)}catch(p){throw vn(p,"sum",h)}}),f===void 0&&(f=n(0,e.number)),typeof f=="string"&&(f=n(f,e.number)),f}function a(l,f){try{var h=ya(l,f,r);return h}catch(p){throw vn(p,"sum")}}}),mc="median",L_=["typed","add","divide","compare","partitionSelect"],P_=mt(mc,L_,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function a(h){try{h=ha(h.valueOf());var p=h.length;if(p===0)throw new Error("Cannot calculate median of an empty array");if(p%2===0){for(var c=p/2-1,m=s(h,c+1),v=h[c],w=0;w<c;++w)n(h[w],v)>0&&(v=h[w]);return f(v,m)}else{var g=s(h,(p-1)/2);return l(g)}}catch(y){throw vn(y,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(p){return p}}),f=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(p,c){return r(e(p,c),2)}});return t(mc,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(p,c){throw new Error("median(A, dim) is not yet supported")},"...":function(p){if(Ts(p))throw new TypeError("Scalar values expected in function median");return a(p)}})}),Ys=zm({config:nr}),Aa=Wm({}),xa=Gm({}),Ca=Jm({}),Wr=Qm({Matrix:Ca}),Ft=kd({BigNumber:Ys,Complex:Aa,DenseMatrix:Wr,Fraction:xa}),z_=Bg({typed:Ft}),js=Tg({typed:Ft}),q_=bg({BigNumber:Ys,typed:Ft}),gc=Dv({typed:Ft}),_n=cg({config:nr,typed:Ft}),Zs=rg({typed:Ft}),U_=og({typed:Ft}),Gs=hv({typed:Ft}),vc=wg({typed:Ft}),Fa=dg({Matrix:Ca,equalScalar:_n,typed:Ft}),_c=Og({typed:Ft}),wc=ug({typed:Ft}),Ma=Ng({typed:Ft}),Dc=xg({Fraction:xa,typed:Ft}),yc=ig({typed:Ft}),xe=Fg({DenseMatrix:Wr,Matrix:Ca,SparseMatrix:Fa,typed:Ft}),bc=Uv({isNaN:wc,isNumeric:yc,typed:Ft}),Yi=Zv({bignumber:q_,fraction:Dc,number:vc}),k_=Wv({config:nr,multiplyScalar:Gs,numeric:Yi,typed:Ft}),W_=Tv({isInteger:Zs,matrix:xe,typed:Ft}),Ec=Ov({matrix:xe,config:nr,typed:Ft}),Ac=Lv({matrix:xe,typed:Ft}),Un=bv({isInteger:Zs,matrix:xe,typed:Ft}),Y_=Av({prod:k_,size:Ec,typed:Ft}),j_=zv({conj:gc,transpose:Ac,typed:Ft}),ji=Kv({numeric:Yi,typed:Ft}),Z_=Vv({DenseMatrix:Wr,concat:Un,divideScalar:ji,equalScalar:_n,matrix:xe,typed:Ft}),xc=n_({DenseMatrix:Wr,concat:Un,equalScalar:_n,matrix:xe,typed:Ft}),Cc=Cv({BigNumber:Ys,DenseMatrix:Wr,SparseMatrix:Fa,config:nr,matrix:xe,typed:Ft}),G_=Mv({matrix:xe,multiplyScalar:Gs,typed:Ft}),K_=o_({DenseMatrix:Wr,concat:Un,config:nr,matrix:xe,typed:Ft}),H_=gv({DenseMatrix:Wr,concat:Un,equalScalar:_n,matrix:xe,subtractScalar:_c,typed:Ft,unaryMinus:Ma}),Zi=D_({DenseMatrix:Wr,SparseMatrix:Fa,addScalar:js,concat:Un,equalScalar:_n,matrix:xe,typed:Ft}),Fc=t_({BigNumber:Ys,DenseMatrix:Wr,Fraction:xa,concat:Un,config:nr,equalScalar:_n,matrix:xe,typed:Ft}),J_=h_({equal:xc,typed:Ft}),Mc=b_({addScalar:js,conj:gc,multiplyScalar:Gs,size:Ec,typed:Ft}),X_=l_({DenseMatrix:Wr,concat:Un,config:nr,matrix:xe,typed:Ft}),Na=__({config:nr,numeric:Yi,smaller:K_,typed:Ft}),ci=dv({addScalar:js,dot:Mc,equalScalar:_n,matrix:xe,multiplyScalar:Gs,typed:Ft}),V_=d_({compare:Fc,isNaN:wc,isNumeric:yc,typed:Ft}),Q_=R_({add:Zi,config:nr,numeric:Yi,typed:Ft}),t1=x_({add:Zi,matrix:xe,typed:Ft}),Nc=F_({divideScalar:ji,isZero:U_,matrix:xe,multiply:ci,subtractScalar:_c,typed:Ft,unaryMinus:Ma}),e1=g_({config:nr,larger:X_,numeric:Yi,typed:Ft}),Ks=N_({abs:z_,addScalar:js,det:Nc,divideScalar:ji,identity:Cc,matrix:xe,multiply:ci,typed:Ft,unaryMinus:Ma}),r1=B_({Complex:Aa,add:Zi,ctranspose:j_,deepEqual:J_,divideScalar:ji,dot:Mc,dotDivide:Z_,equal:xc,inv:Ks,matrix:xe,multiply:ci,typed:Ft}),n1=Jv({Complex:Aa,config:nr,fraction:Dc,identity:Cc,inv:Ks,matrix:xe,multiply:ci,number:vc,typed:Ft}),i1=$_({divideScalar:ji,equalScalar:_n,inv:Ks,matrix:xe,multiply:ci,typed:Ft}),Sc=P_({add:Zi,compare:Fc,divide:i1,partitionSelect:V_,typed:Ft});class s1{constructor(t,e,r){Z(this,"_cacheData");Z(this,"_variables");Z(this,"_math");Z(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},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 f=r*(e-1);s&&(f=Math.floor(f));const h=e/n;let p=0,c=0;for(let m=0;m<=e-1;m++){const v=Math.exp(-1*Math.pow(m-f,2)/(2*Math.pow(h,2)));p+=v,c+=l[l.length-1-(e-m-1)]*v}return c/p}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const a=s.slice(-e);return n=Q_(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const n=this._cacheData[`sma_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`sma_${r}`]=n;const{sum:s}=this._cacheData[`rma_${r}`]||{},a=1/e,l=s===void 0?this.sma({source:t,length:e},r):a*t+(1-a)*(s||0);return this._cacheDataHandle(`rma_${r}`,{sum:l}),l}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:s,close:a,low:l}=this._variables,f=r===void 0?s-l:Math.max(Math.max(s-l,Math.abs(s-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:s,close:a}),this.rma({source:f,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(s===void 0)return;let l=0;for(let f=0;f<e;f++){const h=this._sum(s[s.length-1-f],-(a||0));l+=h*h}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return[];const l=r*a;return[s,s+l,s-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return;const l=r*a;return(s+l-(s-l))/s}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=t,this._cacheData[`change_${r}`]=n;const s=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return s===void 0?s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||a===void 0))return 100*(s-a)/(s+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}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let a=0;for(let l=0;l<e;l++){const f=n[n.length-1-l];a+=f*(l+1)}return-a/s}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),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||s===void 0)return;let f=0,h=0,p=0;for(let m=0;m<r;m++){const[v,w]=s[s.length-1-m],g=v-a,y=w-l;f+=g*y,h+=g*g,p+=y*y}return isNaN(h)||isNaN(f)||isNaN(p)?void 0:f/Math.sqrt(h*p)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e||n<=s&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n<=s&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let s=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let l=0;l<e;l++){const f=a[a.length-1-l];s+=Math.abs(f-n)}return s/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:s,high:a,close:l,PDMS:f,NDMS:h,TRS:p,ADX:c,count:m=0}=this._cacheData[n]||{},{low:v,high:w,close:g}=this._variables;if(s===void 0||a===void 0||l===void 0)return this._cacheData[n]={low:v,high:w,close:g,PDMS:f,NDMS:h,TRS:w-v,count:1},[void 0,void 0,void 0];let y=w-a,_=s-v;y=y>_&&y>0?y:0,_=_>y&&_>0?_:0,y===_&&(y=_=0);const E=Math.max(w-v,Math.abs(w-l),Math.abs(v-l));if(m<t)return this._cacheDataHandle(n,{low:v,high:w,close:g,PDMS:(f||0)+y,NDMS:(h||0)+_,TRS:(p||0)+E,count:m+1}),[void 0,void 0,void 0];{const b=f-f/t+y,N=h-h/t+_,A=p-p/t+E,C=b/A*100,M=N/A*100,S=Math.abs((C-M)/(C+M))*100;let $=S,F=[C,M,void 0];if(m+1-t<e){const I=m+1-t;$=((c||0)*(I-1)+S)/I}else $=(c*(e-1)+S)/e,F=[C,M,$];return this._cacheDataHandle(n,{low:v,high:w,close:g,PDMS:b,NDMS:N,TRS:A,ADX:$,count:m+1}),F}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:s=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:t,length:e},r);if(s>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=a;return s+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:s}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:s=[]}=this._cacheData[`falling_${r}`]||{};s.push(n>t);const a=s.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:s=[]}=this._cacheData[`rising_${r}`]||{};s.push(n<t);const a=s.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 n=this._cacheData[`highest_${r}`]||[],{high:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`highest_${r}`]=n;const l=n.filter(()=>!0);if(!(l.length<e))return Math.max(...l.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`highestbars_${r}`]||[],{high:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`highestbars_${r}`]=n;const l=n.filter(()=>!0);return l.length<e?void 0:l.slice(-e).reduce((h,p,c,m)=>p>=m[h]?c:h,0)-e+1}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,a=0;for(let l=0;l<e;l++){const f=(e-l)*e;s+=f,a+=n[n.length-1-l]*f}return a/s}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},s),{ta:l,high:f,low:h}=this._variables,p=n?l.tr:f-h,c=this.ema({source:p,length:e},`range_${s}`);return[a,a+c*r,a-c*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},s),{ta:l,high:f,low:h}=this._variables,p=n?l.tr:f-h,c=this.ema({source:p,length:e},`range_${s}`);return(a+c*r-(a-c*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const s=this._cacheDataList(t,e,`dev_${n}`);if(!s)return;const a=s.slice(-e).filter(v=>v!==void 0);let l=0,f=0,h=0,p=0;for(const[v,w]of a.entries())l+=v,f+=w,h+=v*w,p+=v*v;const c=(e*h-l*f)/(e*p-l*l);return(f-c*l)/e+c*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowest_${r}`]||[],{low:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`lowest_${r}`]=n;const l=n.filter(()=>!0);if(!(l.length<e))return Math.min(...l.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const n=this._cacheData[`lowestbars_${r}`]||[],{low:s,bar_index:a}=this._variables;typeof t!="number"?n[a]=s:n[a]=t,this._cacheData[`lowestbars_${r}`]=n;const l=n.filter(()=>!0);return l.length<e?void 0:l.slice(-e).reduce((h,p,c,m)=>p<=m[h]?c:h,0)-e+1}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${s}`),l=this.ema({source:t,length:r},`ema2_${s}`);if(a===void 0||l===void 0)return[void 0,void 0,void 0];const f=a-l,h=this.ema({source:f,length:n},`macd_${s}`);if(h===void 0)return[f,h,void 0];const p=f-h;return[f,h,p]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Sc(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),a=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(s<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||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 Na(bc(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,s=this._cacheData[n]||[];if(s[this._variables.bar_index]=t,this._cacheData[n]=s,s.length<=e||t===void 0||isNaN(t))return;let a=s.length-e-1,l;for(;l===void 0&&a>=0;)l=s[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 s=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!s)return;const a=this._sort(s.slice(-(e+1))),l=a.length;r/=100;const f=1/(l*2);if(r<=f)return a[0];if(r>=1-1/(l*2))return a[l-1];for(const[h,p]of a.entries()){const c=a[h-1];if(r<(h+.5)/l)return c===void 0||p===void 0?void 0:c+(p-c)*(r-(h-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const a=this._sort(s.slice(-e)),l=r/100*a.length,f=Math.ceil(l)-1;return a[f>=a.length?a.length-1:f]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const s=n.slice(-(e+1)),a=t;if(a===void 0)return;let l=0;for(let f=0;f<s.length;f++)s[f]!==void 0&&(s[f]<a||s[f]===a&&f<e)&&l++;return l/(s.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const s=new Jt;let{close:a,open:l,low:f,high:h}=this._variables;const p=`pivot_point_levels_${n}`,{close:c,low:m,high:v,open:w,result:g}=this._cacheData[p]||{};if(!e&&(v&&m&&(h=Math.max(v,h),f=Math.min(m,f)),this._cacheDataHandle(p,{close:a,open:l,low:f,high:h,result:g}),!r))return s._value=g||[],s;const y={close:a,open:l,low:f,high:h};e===!0&&!r&&(a=c,l=w,f=m,h=v);const _=this._getPivotPointLevels(h,f,a,l,r,t);return this._cacheDataHandle(p,{...y,result:_}),s._value=_,s}_getPivotPointLevels(t,e,r,n,s,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Pn.traditional:return this._traditional(t,e,r);case Pn.fibonacci:return this._fibonacci(t,e,r);case Pn.woodie:return s?[]:this._woodie(t,e);case Pn.classic:return this._classic(t,e,r);case Pn.dm:return this._DM(t,e,r,n);case Pn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,s=n*2-e,a=n+(t-e),l=n*2+(t-2*e),f=n*3+(t-3*e),h=n*4+(t-4*e),p=n*2-t,c=n-(t-e),m=n*2-(2*t-e),v=n*3-(3*t-e),w=n*4-(4*t-e);return[n,s,p,a,c,l,m,f,v,h,w]}_fibonacci(t,e,r){const n=(t+e+r)/3,s=n+.382*(t-e),a=n-.382*(t-e),l=n+.618*(t-e),f=n-.618*(t-e),h=n+(t-e),p=n-(t-e);return[n,s,a,l,f,h,p]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,s=2*n-e,a=2*n-t,l=n+(t-e),f=n-(t-e),h=t+2*(n-e),p=e-2*(t-n),c=h+(t-e),m=p-(t-e);return[n,s,a,l,f,h,p,c,m]}_classic(t,e,r){const n=(t+e+r)/3,s=2*n-e,a=2*n-t,l=n+(t-e),f=n-(t-e),h=n+2*(t-e),p=n-2*(t-e),c=n+3*(t-e),m=n-3*(t-e);return[n,s,a,l,f,h,p,c,m]}_DM(t,e,r,n){let s;n===r?s=t+e+2*r:r>n?s=2*t+e+r:s=2*e+t+r;const a=s/4,l=s/2-e,f=s/2-t;return[a,l,f]}_camarilla(t,e,r){const n=(t+e+r)/3,s=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,f=r-1.1*(t-e)/6,h=r+1.1*(t-e)/4,p=r-1.1*(t-e)/4,c=r+1.1*(t-e)/2,m=r-1.1*(t-e)/2,v=t/e*r,w=r-(v-r);return[n,s,a,l,f,h,p,c,m,v,w]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!s)return;const a=s.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 s=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!s)return;const a=s.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 s=n.filter(f=>f!==void 0).slice(-e),a=Math.max(...s),l=Math.min(...s);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}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},s=Math.max(t-n,0),a=Math.max(n-t,0),l=this.rma({source:s,length:e},`rma1_${r}`),f=this.rma({source:a,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||f===void 0))return 100-100/(1+l/f)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:s,low:a,high:l,preLow:f,preHigh:h,data:p={}}=this._cacheData[`sar_${n}`]||{};let{result:c,maxMin:m,acceleration:v,isBelow:w}=p,g=!1;const{close:y,low:_,high:E,bar_index:b}=this._variables;return b===1&&(y>s?(w=!0,m=E,c=a):(w=!1,m=_,c=l),g=!0,v=t),c=c+v*(m-c),w?c>_&&(g=!0,w=!1,c=Math.max(E,m||0),m=_,v=t):c<E&&(g=!0,w=!0,c=Math.min(_,m||0),m=E,v=t),g||(w?E>(m||0)&&(m=E,v=Math.min((v||0)+e,r)):_<(m||0)&&(m=_,v=Math.min((v||0)+e,r))),w?(c=Math.min(c,a),b>1&&(c=Math.min(c,f))):(c=Math.max(c,l),b>1&&(c=Math.max(c,h))),this._cacheDataHandle(`sar_${n}`,{high:E,close:y,low:_,preLow:a,preHigh:l,data:Object.assign(p,{result:c,maxMin:m,acceleration:v,isBelow:w})}),c}stoch({source:t,high:e,low:r,length:n},s){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const a=this.lowest({source:r,length:n},s),l=this.highest({source:e,length:n},s);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:s}=this._variables,a=`supertrend_${r}`,{upperBand:l,lowerBand:f,superTrend:h,atr:p,close:c}=this._cacheData[a]||{},m=this.atr({length:e},r);if(m===void 0)return this._cacheDataHandle(a,{close:s}),[void 0,void 0];let v=n+t*m,w=n-t*m;const g=l||0,y=f||0;w=w>y||c<y?w:y,v=v<g||c>g?v:g;let _;p===void 0?_=1:h===g?_=s>v?-1:1:_=s<w?1:-1;const E=_===-1?w:v;return this._cacheDataHandle(a,{upperBand:v,lowerBand:w,superTrend:E,atr:m,close:s}),[E,_]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:s}=this._variables,{close:a}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),a===void 0?t?s-n:void 0:Math.max(s-n,Math.abs(s-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 s=this.change({source:t},n);if(s===void 0)return;const a=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),l=this.ema({source:s,length:e},`ema1_${n}`);if(l===void 0)return;const f=this.ema({source:l,length:r},`ema2_${n}`),h=this.ema({source:a,length:e},`absema2_${n}`);if(f!==void 0)return f/h}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:s}=this._cacheData[`valuewhen_${n}`]||{};return s||(s=[]),t&&s.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:s}),s[s.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const s=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`mode_${n}`);if(!a||s===void 0)return;const l=a.filter(h=>h!==void 0&&!isNaN(h)).slice(-e);if(l.length<e)return;const f=l.reduce((h,p)=>h+Math.pow(p-s,2),0);if(f!==void 0)return r||e<=1?f/e:f/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:s}=this._variables;let{sum:a=0,sumV:l=0,count:f=0,isReset:h,sumS:p=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=l=f=p=0,h=!0),!h)return r!==void 0?[]:void 0;const c=t*s+a,m=s+l,v=c/m;return f++,r!==void 0?(p=s*Math.pow(t,2)+p,this._cacheDataHandle(`vwap_${n}`,{sum:c,sumV:m,count:f,isReset:h,sumS:p}),this._computeBands(p,m,r,v)):(this._cacheDataHandle(`vwap_${n}`,{sum:c,sumV:m,count:f,isReset:h}),v)}_computeBands(t,e,r,n){let s=t/e-Math.pow(n,2);s=s<0?0:s;const a=Math.sqrt(s),l=a!==void 0&&!isNaN(a)?n+r*a:void 0,f=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,l,f]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||a===void 0))return s/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:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:a,currentIndex:l}=n,f=t[s];if(f!==void 0){if(a!==void 0&&f<a){t.splice(s,1),t.splice(l,0,f),n={currentIndex:l+1,currentVal:a};continue}n={currentIndex:s,currentVal:f}}}}return t}_cacheDataList(t,e,r){const n=this._cacheData[r]||[];n[this._variables.bar_index]=t,this._cacheData[r]=n;const s=n.filter(()=>!0);if(!(s.length<e))return s}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}const o1={onlyInLoop:"'$text' is only allowed inside loops",invalidType:"Invalid argument 'expr$index' in 'operator SQBR' call",typeUseError:"Cannot specify a type form '$text' without also specifying the type.",notTypeKeyword:"'$text' is not a valid type keyword in variable declaration",undeclared:"Undeclared identifier '$name'",repeatVar:"'$name' is already defined",typeMismatch:"Cannot call '$operator' with argument '$index'. An argument of '$typeE' type was used but a '$typeR' is expected.",assignTypeMismatch:"Cannot assign a value of the `$typeE` type to the '$name' variable. The variable is declared with the `$typeR` type.",voidNotVar:"Void expression cannot be assigned to a variable",declareTypeErr:"Declared type '$type' is not compatible with assigned type '$valueType'",mapKeyValErr:"Cannot put <$typeA, $typeB> pairs into a map containing `$typeC` keys and `$typeD` values. The maps passed into the `$name()` function must have the same key types and value types.",inputSourceErr:"Invalid value for the '$name' parameter of the '$funcName' function. Possible values: [open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume].",buildInUseErr:"Cannot use '$name' as the default value of a type's field. The default value cannot be a function, variable or calculation.",argsLenErr:"Too many arguments passed into the `$name()` function call. Passed $lenA arguments but expected $lenB.",requiredParamErr:"No value assigned to the `$argName` parameter in $name()",argsSyntaxErr:"Syntax error after the argument for `$argName`. Arguments without their parameter name cannot be used after arguments with parameter names.",requestArgsErr:"Type $type cannot be used in $name '$argName' argument",mapKeyErr:"Incorrect `key` type `$type` in the variable. The `key` type must be one of the following: int, float, string, bool, color.",templateErr:"Incorrect number of arguments for the template: $countA expected, $countB passed.",templateNoSupportErr:"The '$name()' function does not support templates",ifOrSwitchTypeErr:"Return type of one of the '$keyword' blocks is not compatible with return type of other block(s) ($types)",argsNameErr:"The '$name' function does not have an argument with the name '$argName'",noFiledErr:"Object has no field $name",methodNotExistErr:"Could not find method or method reference '$methodName' for '$name'",tupleVarErr:"Syntax error: The quantities of tuple elements on each side of the assignment operator do not match. The right side has $indexA but the left side has $indexB.",tupleLeftVarErr:"Invalid assignment. Cannot assign a tuple to a variable '$name'.",tupleRightVarErr:"Cannot assign a variable to a tuple. The right side must be a function call or structure ('if', 'switch', 'for', 'while') returning a tuple with the same number of elements.",tempateTypeErr:"Syntax error: Only templates for arrays and matrices consist of a single type identifier enclosed in angle brackets.",qualifierErr:"'$name' is not a valid type qualifier. Possible values: 'const', 'simple', 'series'",notFindFuncErr:"Could not find function or function reference '$name'",naVarErr:"Value with NA type cannot be assigned to a variable that was defined without type keyword",notHistoryErr:"Variable '$name' doesn't have history values",defaultValueErr:"The default value cannot be a function, variable or calculation.",defaultValueTypeErr:"Default value of type $typeE can not be assigned to an argument of type $typeR",unaryErr:"Syntax error at input '$sign'",funcArgAssignErr:"Function arguments cannot be mutable ('$name')",declaredErr:"A variable declared with the '$prefix' keyword cannot accept values of the '$type' form. Assign a '$prefix' value to this variable or remove the '$prefix' keyword from its declaration.",globalFuncErr:"Cannot use '$name' in local scope",onlyStatementErr:"Scripts must contain one declaration statement: `indicator()`, `strategy()` or `library()`, Your script has $count.",modifyGlobalVarErr:"Cannot modify global variable '$name' in function",inputDefvalErr:"Arguments of input function must be of constant type, or 'source' builtin variables.",objectIsNaErr:"Cannot access the '$name' $type of an undefined object. The object is 'na'."};Pr.SERIES,Pr.SIMPLE,Pr.INPUT,Pr.CONST,Pr.INT,Pr.FLOAT,Pr.BOOL,Pr.COLOR,Pr.STRING;const a1=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"];var hi=(i=>(i[i.Hint=1]="Hint",i[i.Info=2]="Info",i[i.Warning=4]="Warning",i[i.Error=8]="Error",i))(hi||{});class u1{constructor(t,e){Z(this,"_cacheData");Z(this,"_variables");Z(this,"_errorListener");Z(this,"_count");Z(this,"_historyInputs");Z(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._count=-1,this._name=`inputs_${Fl()}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){for(const e of t){const r=e.id;if(!this._cacheData[r])return;Object.assign(this._cacheData[r],{...e,isModify:!0}),self.workerStorage.updateValue(this._name,`in_${e.index}`,{modifyDefval:e.sourceTypeName||e.defval})}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._cacheHandle(t,e,"int")}bool(t,e){return this._cacheHandle(t,e,"bool")}color(t,e){return this._cacheHandle(t,e,"color")}time(t,e){return this._cacheHandle(t,e,"time")}float(t,e){return this._cacheHandle(t,e,"float")}price(t,e){return this._cacheHandle(t,e,"price")}source(t,e){return this._cacheHandle(t,e,"source")}string(t,e){return this._cacheHandle(t,e,"string")}symbol(t,e){return this._cacheHandle(t,e,"symbol")}session(t,e){return this._cacheHandle(t,e,"session")}text_area(t,e){return this._cacheHandle(t,e,"text_area")}timeframe(t,e){return this._cacheHandle(t,e,"timeframe")}_cacheHandle(t,e,r){const n=`${r||"input"}_${e}`,s=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(o1.inputDefvalErr,e,hi.Error),s)s.isModify?s.sourceTypeName&&(this._cacheData[n].defval=this._variables[s.sourceTypeName]):Object.assign(this._cacheData[n],t);else{const{defval:a,display:l}=t;this._displayVerify(e,l),this._count++,t={inputType:r,...t,index:this._count},this._cacheData[n]=t,this._judgeHistoryInputs(t),(r||t.inputType)==="source"?this._cacheData[n].options=a1:t.options&&!t.options.includes(a)&&this._errorListener.addError(`input's defval should be in options, but '${a}' is not in [${t.options.toString()}]`,e,hi.Error)}return this._cacheData[n].defval}_judgeHistoryInputs(t){const{defval:e,sourceTypeName:r,index:n}=t;let s=r||e;const a=`in_${n}`,l=this._historyInputs[a];if(!l)self.workerStorage.setValue(this._name,a,{defval:s});else{const{defval:f,modifyDefval:h}=l;f===s?s=h||s:self.workerStorage.setValue(this._name,a,{defval:s})}r?t.sourceTypeName=s:t.defval=s}_displayVerify(t,e){!e||!e.length||e.includes(er.dataWindow)||e.includes(er.statusLine)||this._errorListener.addError("Invalid argument 'display' in 'input' call. Possible values: [display.none, display.data_window, display.status_line, display.all]",t,hi.Error)}getInputs(){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}_getGroups(t){const e=[];for(const[r,n]of t)e.push({name:r,inputs:n});return e}}class l1{color({x:t}){return t}new({color:t,transp:e=100}){const{r,g:n,b:s}=this._parseColor(t);return`rgba(${Math.round(r)}, ${Math.round(n)}, ${Math.round(s)}, ${e/100})`}rgb({red:t,green:e,blue:r,transp:n=0}){return`rgba(${t}, ${e}, ${r}, ${n/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:s}){const a=(t-e)/(r-e),l=Math.min(Math.max(a,0),1),{r:f,g:h,b:p,a:c}=this._parseColor(n),{r:m,g:v,b:w,a:g}=this._parseColor(s),y=f+l*(m-f),_=h+l*(v-h),E=p+l*(w-p),b=c+l*(g-c);return`rgba(${Math.round(y)}, ${Math.round(_)}, ${Math.round(E)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=(255-parseInt(a,16))/255:s=1}else{const a=this._parserRgbColor(t);e=a[0],r=a[1],n=a[2],s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var Pt={};const f1=Object.prototype.toString;function Gi(i){const t=f1.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var c1=Object.freeze({__proto__:null,isAnyArray:Gi}),h1=De(c1);function p1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Gi(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],l=r+1;l<s;l++)i[l]>a&&(a=i[l]);return a}function d1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Gi(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],l=r+1;l<s;l++)i[l]<a&&(a=i[l]);return a}function m1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Gi(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!Gi(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=d1(i),n=p1(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,a=s===void 0?t.autoMinMax?r:0:s,l=t.max,f=l===void 0?t.autoMinMax?n:1:l;if(a>=f)throw new RangeError("min option must be smaller than max option");for(var h=(f-a)/(n-r),p=0;p<i.length;p++)e[p]=(i[p]-r)*h+a;return e}var g1=Object.freeze({__proto__:null,default:m1}),v1=De(g1);Object.defineProperty(Pt,"__esModule",{value:!0});var Je=h1,Bc=v1;const Hs=" ".repeat(2),Ic=" ".repeat(4);function _1(){return Tc(this)}function Tc(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
55
- ${Hs}[
56
- ${Ic}${w1(i,e,r,n,s)}
57
- ${Hs}]
58
- ${Hs}rows: ${i.rows}
59
- ${Hs}columns: ${i.columns}
60
- }`}function w1(i,t,e,r,n){const{rows:s,columns:a}=i,l=Math.min(s,t),f=Math.min(a,e),h=[];if(n==="auto"){n=!1;t:for(let p=0;p<l;p++)for(let c=0;c<f;c++)if(i.get(p,c)<0){n=!0;break t}}for(let p=0;p<l;p++){let c=[];for(let m=0;m<f;m++)c.push(D1(i.get(p,m),r,n));h.push(`${c.join(" ")}`)}return f!==a&&(h[h.length-1]+=` ... ${a-e} more columns`),l!==s&&h.push(`... ${s-t} more rows`),h.join(`
61
- ${Ic}`)}function D1(i,t,e){return(i>=0&&e?` ${$c(i,t-1)}`:$c(i,t)).padEnd(t)}function $c(i,t){let e=i.toString();if(e.length<=t)return e;let r=i.toFixed(t);if(r.length>t&&(r=i.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=i.toExponential(t);return n.length>t&&(n=i.toExponential(Math.max(0,t-(n.length-t)))),n.slice(0)}function y1(i,t){i.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},i.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r.get(n,s));return this},i.add=function(r,n){return new t(r).add(n)},i.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},i.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r.get(n,s));return this},i.sub=function(r,n){return new t(r).sub(n)},i.prototype.subtract=i.prototype.sub,i.prototype.subtractS=i.prototype.subS,i.prototype.subtractM=i.prototype.subM,i.subtract=i.sub,i.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},i.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r.get(n,s));return this},i.mul=function(r,n){return new t(r).mul(n)},i.prototype.multiply=i.prototype.mul,i.prototype.multiplyS=i.prototype.mulS,i.prototype.multiplyM=i.prototype.mulM,i.multiply=i.mul,i.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},i.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r.get(n,s));return this},i.div=function(r,n){return new t(r).div(n)},i.prototype.divide=i.prototype.div,i.prototype.divideS=i.prototype.divS,i.prototype.divideM=i.prototype.divM,i.divide=i.div,i.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},i.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r.get(n,s));return this},i.mod=function(r,n){return new t(r).mod(n)},i.prototype.modulus=i.prototype.mod,i.prototype.modulusS=i.prototype.modS,i.prototype.modulusM=i.prototype.modM,i.modulus=i.mod,i.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},i.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r.get(n,s));return this},i.and=function(r,n){return new t(r).and(n)},i.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},i.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r.get(n,s));return this},i.or=function(r,n){return new t(r).or(n)},i.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},i.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r.get(n,s));return this},i.xor=function(r,n){return new t(r).xor(n)},i.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},i.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r.get(n,s));return this},i.leftShift=function(r,n){return new t(r).leftShift(n)},i.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},i.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r.get(n,s));return this},i.signPropagatingRightShift=function(r,n){return new t(r).signPropagatingRightShift(n)},i.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},i.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r);return this},i.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 s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r.get(n,s));return this},i.rightShift=function(r,n){return new t(r).rightShift(n)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.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},i.not=function(r){return new t(r).not()},i.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},i.abs=function(r){return new t(r).abs()},i.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},i.acos=function(r){return new t(r).acos()},i.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},i.acosh=function(r){return new t(r).acosh()},i.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},i.asin=function(r){return new t(r).asin()},i.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},i.asinh=function(r){return new t(r).asinh()},i.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},i.atan=function(r){return new t(r).atan()},i.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},i.atanh=function(r){return new t(r).atanh()},i.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},i.cbrt=function(r){return new t(r).cbrt()},i.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},i.ceil=function(r){return new t(r).ceil()},i.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},i.clz32=function(r){return new t(r).clz32()},i.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},i.cos=function(r){return new t(r).cos()},i.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},i.cosh=function(r){return new t(r).cosh()},i.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},i.exp=function(r){return new t(r).exp()},i.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},i.expm1=function(r){return new t(r).expm1()},i.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},i.floor=function(r){return new t(r).floor()},i.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},i.fround=function(r){return new t(r).fround()},i.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},i.log=function(r){return new t(r).log()},i.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},i.log1p=function(r){return new t(r).log1p()},i.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},i.log10=function(r){return new t(r).log10()},i.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},i.log2=function(r){return new t(r).log2()},i.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},i.round=function(r){return new t(r).round()},i.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},i.sign=function(r){return new t(r).sign()},i.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},i.sin=function(r){return new t(r).sin()},i.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},i.sinh=function(r){return new t(r).sinh()},i.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},i.sqrt=function(r){return new t(r).sqrt()},i.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},i.tan=function(r){return new t(r).tan()},i.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},i.tanh=function(r){return new t(r).tanh()},i.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},i.trunc=function(r){return new t(r).trunc()},i.pow=function(r,n){return new t(r).pow(n)},i.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},i.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r));return this},i.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 s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r.get(n,s)));return this}}function vr(i,t,e){let r=e?i.rows:i.rows-1;if(t<0||t>r)throw new RangeError("Row index out of range")}function _r(i,t,e){let r=e?i.columns:i.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function pi(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function di(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function Sa(i,t){if(!Je.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]>=i.rows)throw new RangeError("row indices are out of range")}function Ba(i,t){if(!Je.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]>=i.columns)throw new RangeError("column indices are out of range")}function Ia(i,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(Xs("startRow",t),Xs("endRow",e),Xs("startColumn",r),Xs("endColumn",n),t>e||r>n||t<0||t>=i.rows||e<0||e>=i.rows||r<0||r>=i.columns||n<0||n>=i.columns)throw new RangeError("Submatrix indices are out of range")}function Js(i,t=0){let e=[];for(let r=0;r<i;r++)e.push(t);return e}function Xs(i,t){if(typeof t!="number")throw new TypeError(`${i} must be a number`)}function mi(i){if(i.isEmpty())throw new Error("Empty matrix has no elements to index")}function b1(i){let t=Js(i.rows);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]+=i.get(e,r);return t}function E1(i){let t=Js(i.columns);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]+=i.get(e,r);return t}function A1(i){let t=0;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t+=i.get(e,r);return t}function x1(i){let t=Js(i.rows,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]*=i.get(e,r);return t}function C1(i){let t=Js(i.columns,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]*=i.get(e,r);return t}function F1(i){let t=1;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t*=i.get(e,r);return t}function M1(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<r;a++){let l=0,f=0,h=0;for(let p=0;p<n;p++)h=i.get(a,p)-e[a],l+=h,f+=h*h;t?s.push((f-l*l/n)/(n-1)):s.push((f-l*l/n)/n)}return s}function N1(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<n;a++){let l=0,f=0,h=0;for(let p=0;p<r;p++)h=i.get(p,a)-e[a],l+=h,f+=h*h;t?s.push((f-l*l/r)/(r-1)):s.push((f-l*l/r)/r)}return s}function S1(i,t,e){const r=i.rows,n=i.columns,s=r*n;let a=0,l=0,f=0;for(let h=0;h<r;h++)for(let p=0;p<n;p++)f=i.get(h,p)-e,a+=f,l+=f*f;return t?(l-a*a/s)/(s-1):(l-a*a/s)/s}function B1(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[e])}function I1(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[r])}function T1(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t)}function $1(i){const t=[];for(let e=0;e<i.rows;e++){let r=0;for(let n=0;n<i.columns;n++)r+=Math.pow(i.get(e,n),2)/(i.columns-1);t.push(Math.sqrt(r))}return t}function O1(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[e])}function R1(i){const t=[];for(let e=0;e<i.columns;e++){let r=0;for(let n=0;n<i.rows;n++)r+=Math.pow(i.get(n,e),2)/(i.rows-1);t.push(Math.sqrt(r))}return t}function L1(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[r])}function P1(i){const t=i.size-1;let e=0;for(let r=0;r<i.columns;r++)for(let n=0;n<i.rows;n++)e+=Math.pow(i.get(n,r),2)/t;return Math.sqrt(e)}function z1(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.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 s=new pt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)s.set(a,l,r[a*e+l]);return s}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 s=new pt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)s.set(a,l,n());return s}static randInt(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:s=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(s))throw new TypeError("max must be an integer");if(n>=s)throw new RangeError("min must be smaller than max");let l=s-n,f=new pt(t,e);for(let h=0;h<t;h++)for(let p=0;p<e;p++){let c=n+Math.round(a()*l);f.set(h,p,c)}return f}static eye(t,e,r){e===void 0&&(e=t),r===void 0&&(r=1);let n=Math.min(t,e),s=this.zeros(t,e);for(let a=0;a<n;a++)s.set(a,a,r);return s}static diag(t,e,r){let n=t.length;e===void 0&&(e=n),r===void 0&&(r=e);let s=Math.min(n,e,r),a=this.zeros(e,r);for(let l=0;l<s;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,s=new pt(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)s.set(a,l,Math.min(t.get(a,l),e.get(a,l)));return s}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new this(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)s.set(a,l,Math.max(t.get(a,l),e.get(a,l)));return s}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,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!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 s=e;s<t.rows;s++)t.get(s,r)>t.get(n,r)&&(n=s);if(t.get(n,r)===0)r++;else{t.swapRows(e,n);let s=t.get(e,r);for(let a=r;a<t.columns;a++)t.set(e,a,t.get(e,a)/s);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 f=r+1;f<t.columns;f++)t.set(a,f,t.get(a,f)-t.get(e,f)*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 s=0,a=!1;for(;s<r&&a===!1;)t.get(n,s)===1?a=!0:s++;for(let l=0;l<n;l++){let f=t.get(l,s);for(let h=s;h<e;h++){let p=t.get(l,h)-f*t.get(n,h);t.set(l,h,p)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new pt(this.rows*e,this.columns*r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*s,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){vr(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){vr(this,t),e=pi(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){vr(this,t),vr(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){_r(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){_r(this,t),e=di(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){_r(this,t),_r(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=pi(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=pi(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=pi(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=pi(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=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[e]);return this}subColumnVector(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[e]);return this}mulColumnVector(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[e]);return this}divColumnVector(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[e]);return this}mulRow(t,e){vr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){_r(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(){mi(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(){mi(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(vr(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){vr(this,t),mi(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(vr(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){vr(this,t),mi(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(_r(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){_r(this,t),mi(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(_r(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){_r(this,t),mi(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,s=new pt(e,n),a=new Float64Array(r);for(let l=0;l<n;l++){for(let f=0;f<r;f++)a[f]=t.get(f,l);for(let f=0;f<e;f++){let h=0;for(let p=0;p<r;p++)h+=this.get(f,p)*a[p];s.set(f,l,h)}}return s}strassen2x2(t){t=pt.checkMatrix(t);let e=new pt(2,2);const r=this.get(0,0),n=t.get(0,0),s=this.get(0,1),a=t.get(0,1),l=this.get(1,0),f=t.get(1,0),h=this.get(1,1),p=t.get(1,1),c=(r+h)*(n+p),m=(l+h)*n,v=r*(a-p),w=h*(f-n),g=(r+s)*p,y=(l-r)*(n+a),_=(s-h)*(f+p),E=c+w-g+_,b=v+g,N=m+w,A=c-m+v+y;return e.set(0,0,E),e.set(0,1,b),e.set(1,0,N),e.set(1,1,A),e}strassen3x3(t){t=pt.checkMatrix(t);let e=new pt(3,3);const r=this.get(0,0),n=this.get(0,1),s=this.get(0,2),a=this.get(1,0),l=this.get(1,1),f=this.get(1,2),h=this.get(2,0),p=this.get(2,1),c=this.get(2,2),m=t.get(0,0),v=t.get(0,1),w=t.get(0,2),g=t.get(1,0),y=t.get(1,1),_=t.get(1,2),E=t.get(2,0),b=t.get(2,1),N=t.get(2,2),A=(r+n+s-a-l-p-c)*y,C=(r-a)*(-v+y),M=l*(-m+v+g-y-_-E+N),S=(-r+a+l)*(m-v+y),$=(a+l)*(-m+v),F=r*m,I=(-r+h+p)*(m-w+_),R=(-r+h)*(w-_),U=(h+p)*(-m+w),q=(r+n+s-l-f-h-p)*_,k=p*(-m+w+g-y-_-E+b),P=(-s+p+c)*(y+E-b),K=(s-c)*(y-b),G=s*E,V=(p+c)*(-E+b),tt=(-s+l+f)*(_+E-N),ft=(s-f)*(_-N),vt=(l+f)*(-E+N),lt=n*g,wt=f*b,yt=a*w,St=h*v,bt=c*N,re=F+G+lt,It=A+S+$+F+P+G+V,Mt=F+I+U+q+G+tt+vt,ie=C+M+S+F+G+tt+ft,Xt=C+S+$+F+wt,zt=G+tt+ft+vt+yt,Gt=F+I+R+k+P+K+G,Ce=P+K+G+V+St,sr=F+I+R+U+bt;return e.set(0,0,re),e.set(0,1,It),e.set(0,2,Mt),e.set(1,0,ie),e.set(1,1,Xt),e.set(1,2,zt),e.set(2,0,Gt),e.set(2,1,Ce),e.set(2,2,sr),e}mmulStrassen(t){t=pt.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,s=t.rows,a=t.columns;n!==s&&console.warn(`Multiplying ${r} x ${n} and ${s} x ${a} matrix: dimensions do not match.`);function l(c,m,v){let w=c.rows,g=c.columns;if(w===m&&g===v)return c;{let y=$t.zeros(m,v);return y=y.setSubMatrix(c,0,0),y}}let f=Math.max(r,s),h=Math.max(n,a);e=l(e,f,h),t=l(t,f,h);function p(c,m,v,w){if(v<=512||w<=512)return c.mmul(m);v%2===1&&w%2===1?(c=l(c,v+1,w+1),m=l(m,v+1,w+1)):v%2===1?(c=l(c,v+1,w),m=l(m,v+1,w)):w%2===1&&(c=l(c,v,w+1),m=l(m,v,w+1));let g=parseInt(c.rows/2,10),y=parseInt(c.columns/2,10),_=c.subMatrix(0,g-1,0,y-1),E=m.subMatrix(0,g-1,0,y-1),b=c.subMatrix(0,g-1,y,c.columns-1),N=m.subMatrix(0,g-1,y,m.columns-1),A=c.subMatrix(g,c.rows-1,0,y-1),C=m.subMatrix(g,m.rows-1,0,y-1),M=c.subMatrix(g,c.rows-1,y,c.columns-1),S=m.subMatrix(g,m.rows-1,y,m.columns-1),$=p($t.add(_,M),$t.add(E,S),g,y),F=p($t.add(A,M),E,g,y),I=p(_,$t.sub(N,S),g,y),R=p(M,$t.sub(C,E),g,y),U=p($t.add(_,b),S,g,y),q=p($t.sub(A,_),$t.add(E,N),g,y),k=p($t.sub(b,M),$t.add(C,S),g,y),P=$t.add($,R);P.sub(U),P.add(k);let K=$t.add(I,U),G=$t.add(F,R),V=$t.sub($,F);V.add(I),V.add(q);let tt=$t.zeros(2*P.rows,2*P.columns);return tt=tt.setSubMatrix(P,0,0),tt=tt.setSubMatrix(K,P.rows,0),tt=tt.setSubMatrix(G,0,P.columns),tt=tt.setSubMatrix(V,P.rows,P.columns),tt.subMatrix(0,v-1,0,w-1)}return p(e,t,f,h)}scaleRows(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new pt(this.rows,this.columns);for(let s=0;s<this.rows;s++){const a=this.getRow(s);a.length>0&&Bc(a,{min:e,max:r,output:a}),n.setRow(s,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 s=0;s<this.columns;s++){const a=this.getColumn(s);a.length&&Bc(a,{min:e,max:r,output:a}),n.setColumn(s,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),s=this.get(e,this.columns-1-r);this.set(e,r,s),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),s=this.get(this.rows-1-r,e);this.set(r,e,s),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,s=t.columns,a=new pt(e*n,r*s);for(let l=0;l<e;l++)for(let f=0;f<r;f++)for(let h=0;h<n;h++)for(let p=0;p<s;p++)a.set(n*l+h,s*f+p,this.get(l,f)*t.get(h,p));return a}kroneckerSum(t){if(t=pt.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(pt.eye(r,r)),s=pt.eye(e,e).kroneckerProduct(t);return n.add(s)}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=Oc){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Oc){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){Ia(this,t,e,r,n);let s=new pt(e-t+1,n-r+1);for(let a=t;a<=e;a++)for(let l=r;l<=n;l++)s.set(a-t,l-r,this.get(a,l));return s}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 s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.rows)throw new RangeError(`Row index out of range: ${t[s]}`);n.set(s,a-e,this.get(t[s],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 s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.columns)throw new RangeError(`Column index out of range: ${t[s]}`);n.set(a-e,s,this.get(a,t[s]))}return n}setSubMatrix(t,e,r){if(t=pt.checkMatrix(t),t.isEmpty())return this;let n=e+t.rows-1,s=r+t.columns-1;Ia(this,e,n,r,s);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){Sa(this,t),Ba(this,e);let r=new pt(t.length,e.length);for(let n=0;n<t.length;n++){let s=t[n];for(let a=0;a<e.length;a++){let l=e[a];r.set(n,a,this.get(s,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,s]of t.entries())e.set(r,n,s);return e}sum(t){switch(t){case"row":return b1(this);case"column":return E1(this);case void 0:return A1(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return x1(this);case"column":return C1(this);case void 0:return F1(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(!Je.isAnyArray(n))throw new TypeError("mean must be an array");return M1(this,r,n)}case"column":{if(!Je.isAnyArray(n))throw new TypeError("mean must be an array");return N1(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return S1(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(!Je.isAnyArray(r))throw new TypeError("center must be an array");return B1(this,r),this}case"column":{if(!Je.isAnyArray(r))throw new TypeError("center must be an array");return I1(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return T1(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=$1(this);else if(!Je.isAnyArray(r))throw new TypeError("scale must be an array");return O1(this,r),this}case"column":{if(r===void 0)r=R1(this);else if(!Je.isAnyArray(r))throw new TypeError("scale must be an array");return L1(this,r),this}case void 0:{if(r===void 0)r=P1(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return z1(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return Tc(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")]=_1);function Oc(i,t){return i-t}function q1(i){return i.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=(Di=class extends $t{constructor(e,r){super();Dl(this,Xi);Z(this,"data");if(Di.isMatrix(e))yl(this,Xi,bl).call(this,e.rows,e.columns),Di.copy(e,this);else if(Number.isInteger(e)&&e>=0)yl(this,Xi,bl).call(this,e,r);else if(Je.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 s=0;s<e;s++){if(n[s].length!==r)throw new RangeError("Inconsistent array dimensions");if(!q1(n[s]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[s]))}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 vr(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),vr(this,e,!0),r=Float64Array.from(pi(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){_r(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let s=0;s<e;s++)n[s]=this.data[r][s];for(let s=e+1;s<this.columns;s++)n[s-1]=this.data[r][s];this.data[r]=n}return this.columns-=1,this}addColumn(e,r){typeof r>"u"&&(r=e,e=this.columns),_r(this,e,!0),r=di(this,r);for(let n=0;n<this.rows;n++){const s=new Float64Array(this.columns+1);let a=0;for(;a<e;a++)s[a]=this.data[n][a];for(s[a++]=r[n];a<this.columns+1;a++)s[a]=this.data[n][a-1];this.data[n]=s}return this.columns+=1,this}},Xi=new WeakSet,bl=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},Di);y1($t,pt);const lo=class lo extends $t{constructor(e){super();Dl(this,Ue,void 0);if(pt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ea(this,Ue,pt.copy(e,new pt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ea(this,Ue,new pt(e,e));else if(ea(this,Ue,new pt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Lr(this,Ue).size}get rows(){return Lr(this,Ue).rows}get columns(){return Lr(this,Ue).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 lo(this.diagonalSize);for(const[r,n,s]of this.upperRightEntries())e.set(r,n,s);return e}toMatrix(){return new pt(this)}get(e,r){return Lr(this,Ue).get(e,r)}set(e,r,n){return Lr(this,Ue).set(e,r,n),Lr(this,Ue).set(r,e,n),this}removeCross(e){return Lr(this,Ue).removeRow(e),Lr(this,Ue).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),Lr(this,Ue).addRow(e,n),Lr(this,Ue).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,s]of e.entries())s||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,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=e&&(n=++s);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 s=new lo(n);for(let a=0,l=0,f=0;f<r;f++)s.set(a,l,e[f]),++a>=n&&(a=++l);return s}*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)}};Ue=new WeakMap;let kn=lo;kn.prototype.klassType="SymmetricMatrix";class Vs extends kn{static isDistanceMatrix(t){return kn.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 kn(this)}clone(){const t=new Vs(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,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=t&&(n=++s+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 s=1,a=0,l=0;l<e;l++)n.set(s,a,t[l]),++s>=r&&(s=++a+1);return n}}Vs.prototype.klassSubType="DistanceMatrix";class Jr extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class U1 extends Jr{constructor(t,e){_r(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 k1 extends Jr{constructor(t,e){Ba(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 W1 extends Jr{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 Y1 extends Jr{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 j1 extends Jr{constructor(t,e){vr(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 Z1 extends Jr{constructor(t,e){Sa(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 Qs extends Jr{constructor(t,e,r){Sa(t,e),Ba(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 G1 extends Jr{constructor(t,e,r,n,s){Ia(t,e,r,n,s),super(t,r-e+1,s-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 K1 extends Jr{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 Rc 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 ir 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 H1(i,t){if(Je.isAnyArray(i))return i[0]&&Je.isAnyArray(i[0])?new ir(i):new Rc(i,t);throw new Error("the argument is not an array")}class to{constructor(t){t=ir.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,s=new Float64Array(r),a=1,l,f,h,p,c,m,v,w,g;for(l=0;l<r;l++)s[l]=l;for(w=new Float64Array(r),f=0;f<n;f++){for(l=0;l<r;l++)w[l]=e.get(l,f);for(l=0;l<r;l++){for(g=Math.min(l,f),c=0,h=0;h<g;h++)c+=e.get(l,h)*w[h];w[l]-=c,e.set(l,f,w[l])}for(p=f,l=f+1;l<r;l++)Math.abs(w[l])>Math.abs(w[p])&&(p=l);if(p!==f){for(h=0;h<n;h++)m=e.get(p,h),e.set(p,h,e.get(f,h)),e.set(f,h,m);v=s[p],s[p]=s[f],s[f]=v,a=-a}if(f<r&&e.get(f,f)!==0)for(l=f+1;l<r;l++)e.set(l,f,e.get(l,f)/e.get(f,f))}this.LU=e,this.pivotVector=s,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,s=t.subMatrixRow(this.pivotVector,0,n-1),a=e.columns,l,f,h;for(h=0;h<a;h++)for(l=h+1;l<a;l++)for(f=0;f<n;f++)s.set(l,f,s.get(l,f)-s.get(h,f)*e.get(l,h));for(h=a-1;h>=0;h--){for(f=0;f<n;f++)s.set(h,f,s.get(h,f)/e.get(h,h));for(l=0;l<h;l++)for(f=0;f<n;f++)s.set(l,f,s.get(l,f)-s.get(h,f)*e.get(l,h))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new pt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s>a?n.set(s,a,t.get(s,a)):s===a?n.set(s,a,1):n.set(s,a,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new pt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s<=a?n.set(s,a,t.get(s,a)):n.set(s,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Xr(i,t){let e=0;return Math.abs(i)>Math.abs(t)?(e=t/i,Math.abs(i)*Math.sqrt(1+e*e)):t!==0?(e=i/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class Ta{constructor(t){t=ir.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,s=new Float64Array(n),a,l,f,h;for(f=0;f<n;f++){let p=0;for(a=f;a<r;a++)p=Xr(p,e.get(a,f));if(p!==0){for(e.get(f,f)<0&&(p=-p),a=f;a<r;a++)e.set(a,f,e.get(a,f)/p);for(e.set(f,f,e.get(f,f)+1),l=f+1;l<n;l++){for(h=0,a=f;a<r;a++)h+=e.get(a,f)*e.get(a,l);for(h=-h/e.get(f,f),a=f;a<r;a++)e.set(a,l,e.get(a,l)+h*e.get(a,f))}}s[f]=-p}this.QR=e,this.Rdiag=s}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,s=t.clone(),a=e.columns,l,f,h,p;for(h=0;h<a;h++)for(f=0;f<n;f++){for(p=0,l=h;l<r;l++)p+=e.get(l,h)*s.get(l,f);for(p=-p/e.get(h,h),l=h;l<r;l++)s.set(l,f,s.get(l,f)+p*e.get(l,h))}for(h=a-1;h>=0;h--){for(f=0;f<n;f++)s.set(h,f,s.get(h,f)/this.Rdiag[h]);for(l=0;l<h;l++)for(f=0;f<n;f++)s.set(l,f,s.get(l,f)-s.get(h,f)*e.get(l,h))}return s.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,s;for(n=0;n<e;n++)for(s=0;s<e;s++)n<s?r.set(n,s,t.get(n,s)):n===s?r.set(n,s,this.Rdiag[n]):r.set(n,s,0);return r}get orthogonalMatrix(){let t=this.QR,e=t.rows,r=t.columns,n=new pt(e,r),s,a,l,f;for(l=r-1;l>=0;l--){for(s=0;s<e;s++)n.set(s,l,0);for(n.set(l,l,1),a=l;a<r;a++)if(t.get(l,l)!==0){for(f=0,s=l;s<e;s++)f+=t.get(s,l)*n.get(s,a);for(f=-f/t.get(l,l),s=l;s<e;s++)n.set(s,a,n.get(s,a)+f*t.get(s,l))}}return n}}class gi{constructor(t,e={}){if(t=ir.checkMatrix(t),t.isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:s=!0,computeRightSingularVectors:a=!0,autoTranspose:l=!1}=e;let f=!!s,h=!!a,p=!1,c;if(r<n)if(!l)c=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{c=t.transpose(),r=c.rows,n=c.columns,p=!0;let F=f;f=h,h=F}else c=t.clone();let m=Math.min(r,n),v=Math.min(r+1,n),w=new Float64Array(v),g=new pt(r,m),y=new pt(n,n),_=new Float64Array(n),E=new Float64Array(r),b=new Float64Array(v);for(let F=0;F<v;F++)b[F]=F;let N=Math.min(r-1,n),A=Math.max(0,Math.min(n-2,r)),C=Math.max(N,A);for(let F=0;F<C;F++){if(F<N){w[F]=0;for(let I=F;I<r;I++)w[F]=Xr(w[F],c.get(I,F));if(w[F]!==0){c.get(F,F)<0&&(w[F]=-w[F]);for(let I=F;I<r;I++)c.set(I,F,c.get(I,F)/w[F]);c.set(F,F,c.get(F,F)+1)}w[F]=-w[F]}for(let I=F+1;I<n;I++){if(F<N&&w[F]!==0){let R=0;for(let U=F;U<r;U++)R+=c.get(U,F)*c.get(U,I);R=-R/c.get(F,F);for(let U=F;U<r;U++)c.set(U,I,c.get(U,I)+R*c.get(U,F))}_[I]=c.get(F,I)}if(f&&F<N)for(let I=F;I<r;I++)g.set(I,F,c.get(I,F));if(F<A){_[F]=0;for(let I=F+1;I<n;I++)_[F]=Xr(_[F],_[I]);if(_[F]!==0){_[F+1]<0&&(_[F]=0-_[F]);for(let I=F+1;I<n;I++)_[I]/=_[F];_[F+1]+=1}if(_[F]=-_[F],F+1<r&&_[F]!==0){for(let I=F+1;I<r;I++)E[I]=0;for(let I=F+1;I<r;I++)for(let R=F+1;R<n;R++)E[I]+=_[R]*c.get(I,R);for(let I=F+1;I<n;I++){let R=-_[I]/_[F+1];for(let U=F+1;U<r;U++)c.set(U,I,c.get(U,I)+R*E[U])}}if(h)for(let I=F+1;I<n;I++)y.set(I,F,_[I])}}let M=Math.min(n,r+1);if(N<n&&(w[N]=c.get(N,N)),r<M&&(w[M-1]=0),A+1<M&&(_[A]=c.get(A,M-1)),_[M-1]=0,f){for(let F=N;F<m;F++){for(let I=0;I<r;I++)g.set(I,F,0);g.set(F,F,1)}for(let F=N-1;F>=0;F--)if(w[F]!==0){for(let I=F+1;I<m;I++){let R=0;for(let U=F;U<r;U++)R+=g.get(U,F)*g.get(U,I);R=-R/g.get(F,F);for(let U=F;U<r;U++)g.set(U,I,g.get(U,I)+R*g.get(U,F))}for(let I=F;I<r;I++)g.set(I,F,-g.get(I,F));g.set(F,F,1+g.get(F,F));for(let I=0;I<F-1;I++)g.set(I,F,0)}else{for(let I=0;I<r;I++)g.set(I,F,0);g.set(F,F,1)}}if(h)for(let F=n-1;F>=0;F--){if(F<A&&_[F]!==0)for(let I=F+1;I<n;I++){let R=0;for(let U=F+1;U<n;U++)R+=y.get(U,F)*y.get(U,I);R=-R/y.get(F+1,F);for(let U=F+1;U<n;U++)y.set(U,I,y.get(U,I)+R*y.get(U,F))}for(let I=0;I<n;I++)y.set(I,F,0);y.set(F,F,1)}let S=M-1,$=Number.EPSILON;for(;M>0;){let F,I;for(F=M-2;F>=-1&&F!==-1;F--){const R=Number.MIN_VALUE+$*Math.abs(w[F]+Math.abs(w[F+1]));if(Math.abs(_[F])<=R||Number.isNaN(_[F])){_[F]=0;break}}if(F===M-2)I=4;else{let R;for(R=M-1;R>=F&&R!==F;R--){let U=(R!==M?Math.abs(_[R]):0)+(R!==F+1?Math.abs(_[R-1]):0);if(Math.abs(w[R])<=$*U){w[R]=0;break}}R===F?I=3:R===M-1?I=1:(I=2,F=R)}switch(F++,I){case 1:{let R=_[M-2];_[M-2]=0;for(let U=M-2;U>=F;U--){let q=Xr(w[U],R),k=w[U]/q,P=R/q;if(w[U]=q,U!==F&&(R=-P*_[U-1],_[U-1]=k*_[U-1]),h)for(let K=0;K<n;K++)q=k*y.get(K,U)+P*y.get(K,M-1),y.set(K,M-1,-P*y.get(K,U)+k*y.get(K,M-1)),y.set(K,U,q)}break}case 2:{let R=_[F-1];_[F-1]=0;for(let U=F;U<M;U++){let q=Xr(w[U],R),k=w[U]/q,P=R/q;if(w[U]=q,R=-P*_[U],_[U]=k*_[U],f)for(let K=0;K<r;K++)q=k*g.get(K,U)+P*g.get(K,F-1),g.set(K,F-1,-P*g.get(K,U)+k*g.get(K,F-1)),g.set(K,U,q)}break}case 3:{const R=Math.max(Math.abs(w[M-1]),Math.abs(w[M-2]),Math.abs(_[M-2]),Math.abs(w[F]),Math.abs(_[F])),U=w[M-1]/R,q=w[M-2]/R,k=_[M-2]/R,P=w[F]/R,K=_[F]/R,G=((q+U)*(q-U)+k*k)/2,V=U*k*(U*k);let tt=0;(G!==0||V!==0)&&(G<0?tt=0-Math.sqrt(G*G+V):tt=Math.sqrt(G*G+V),tt=V/(G+tt));let ft=(P+U)*(P-U)+tt,vt=P*K;for(let lt=F;lt<M-1;lt++){let wt=Xr(ft,vt);wt===0&&(wt=Number.MIN_VALUE);let yt=ft/wt,St=vt/wt;if(lt!==F&&(_[lt-1]=wt),ft=yt*w[lt]+St*_[lt],_[lt]=yt*_[lt]-St*w[lt],vt=St*w[lt+1],w[lt+1]=yt*w[lt+1],h)for(let bt=0;bt<n;bt++)wt=yt*y.get(bt,lt)+St*y.get(bt,lt+1),y.set(bt,lt+1,-St*y.get(bt,lt)+yt*y.get(bt,lt+1)),y.set(bt,lt,wt);if(wt=Xr(ft,vt),wt===0&&(wt=Number.MIN_VALUE),yt=ft/wt,St=vt/wt,w[lt]=wt,ft=yt*_[lt]+St*w[lt+1],w[lt+1]=-St*_[lt]+yt*w[lt+1],vt=St*_[lt+1],_[lt+1]=yt*_[lt+1],f&&lt<r-1)for(let bt=0;bt<r;bt++)wt=yt*g.get(bt,lt)+St*g.get(bt,lt+1),g.set(bt,lt+1,-St*g.get(bt,lt)+yt*g.get(bt,lt+1)),g.set(bt,lt,wt)}_[M-2]=ft;break}case 4:{if(w[F]<=0&&(w[F]=w[F]<0?-w[F]:0,h))for(let R=0;R<=S;R++)y.set(R,F,-y.get(R,F));for(;F<S&&!(w[F]>=w[F+1]);){let R=w[F];if(w[F]=w[F+1],w[F+1]=R,h&&F<n-1)for(let U=0;U<n;U++)R=y.get(U,F+1),y.set(U,F+1,y.get(U,F)),y.set(U,F,R);if(f&&F<r-1)for(let U=0;U<r;U++)R=g.get(U,F+1),g.set(U,F+1,g.get(U,F)),g.set(U,F,R);F++}M--;break}}}if(p){let F=y;y=g,g=F}this.m=r,this.n=n,this.s=w,this.U=g,this.V=y}solve(t){let e=t,r=this.threshold,n=this.s.length,s=pt.zeros(n,n);for(let m=0;m<n;m++)Math.abs(this.s[m])<=r?s.set(m,m,0):s.set(m,m,1/this.s[m]);let a=this.U,l=this.rightSingularVectors,f=l.mmul(s),h=l.rows,p=a.rows,c=pt.zeros(h,p);for(let m=0;m<h;m++)for(let v=0;v<p;v++){let w=0;for(let g=0;g<n;g++)w+=f.get(m,g)*a.get(v,g);c.set(m,v,w)}return c.mmul(e)}solveForDiagonal(t){return this.solve(pt.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,s=new pt(r,this.s.length);for(let p=0;p<r;p++)for(let c=0;c<n;c++)Math.abs(this.s[c])>e&&s.set(p,c,t.get(p,c)/this.s[c]);let a=this.U,l=a.rows,f=a.columns,h=new pt(r,l);for(let p=0;p<r;p++)for(let c=0;c<l;c++){let m=0;for(let v=0;v<f;v++)m+=s.get(p,v)*a.get(c,v);h.set(p,c,m)}return h}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,s=r.length;n<s;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 J1(i,t=!1){return i=ir.checkMatrix(i),t?new gi(i).inverse():Lc(i,pt.eye(i.rows))}function Lc(i,t,e=!1){return i=ir.checkMatrix(i),t=ir.checkMatrix(t),e?new gi(i).solve(t):i.isSquare()?new to(i).solve(t):new Ta(i).solve(t)}function eo(i){if(i=pt.checkMatrix(i),i.isSquare()){if(i.columns===0)return 1;let t,e,r,n;if(i.columns===2)return t=i.get(0,0),e=i.get(0,1),r=i.get(1,0),n=i.get(1,1),t*n-e*r;if(i.columns===3){let s,a,l;return s=new Qs(i,[1,2],[1,2]),a=new Qs(i,[1,2],[0,2]),l=new Qs(i,[1,2],[0,1]),t=i.get(0,0),e=i.get(0,1),r=i.get(0,2),t*eo(s)-e*eo(a)+r*eo(l)}else return new to(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function X1(i,t){let e=[];for(let r=0;r<i;r++)r!==t&&e.push(r);return e}function V1(i,t,e,r=1e-9,n=1e-9){if(i>n)return new Array(t.rows+1).fill(0);{let s=t.addRow(e,[0]);for(let a=0;a<s.rows;a++)Math.abs(s.get(a,0))<r&&s.set(a,0,0);return s.to1DArray()}}function Q1(i,t={}){const{thresholdValue:e=1e-9,thresholdError:r=1e-9}=t;i=pt.checkMatrix(i);let n=i.rows,s=new pt(n,n);for(let a=0;a<n;a++){let l=pt.columnVector(i.getRow(a)),f=i.subMatrixRow(X1(n,a)).transpose(),p=new gi(f).solve(l),c=pt.sub(l,f.mmul(p)).abs().max();s.setRow(a,V1(c,p,a,e,r))}return s}function tw(i,t=Number.EPSILON){if(i=pt.checkMatrix(i),i.isEmpty())return i.transpose();let e=new gi(i,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,s=e.diagonal;for(let a=0;a<s.length;a++)Math.abs(s[a])>t?s[a]=1/s[a]:s[a]=0;return n.mmul(pt.diag(s).mmul(r.transpose()))}function ew(i,t=i,e={}){i=new pt(i);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!Je.isAnyArray(t)?(e=t,t=i,r=!0):t=new pt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=e;n&&(i=i.center("column"),r||(t=t.center("column")));const s=i.transpose().mmul(t);for(let a=0;a<s.rows;a++)for(let l=0;l<s.columns;l++)s.set(a,l,s.get(a,l)*(1/(i.rows-1)));return s}function rw(i,t=i,e={}){i=new pt(i);let r=!1;if(typeof t=="object"&&!pt.isMatrix(t)&&!Je.isAnyArray(t)?(e=t,t=i,r=!0):t=new pt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:s=!0}=e;n&&(i.center("column"),r||t.center("column")),s&&(i.scale("column"),r||t.scale("column"));const a=i.standardDeviation("column",{unbiased:!0}),l=r?a:t.standardDeviation("column",{unbiased:!0}),f=i.transpose().mmul(t);for(let h=0;h<f.rows;h++)for(let p=0;p<f.columns;p++)f.set(h,p,f.get(h,p)*(1/(a[h]*l[p]))*(1/(i.rows-1)));return f}let Pc=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=ir.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,s=new pt(n,n),a=new Float64Array(n),l=new Float64Array(n),f=t,h,p,c=!1;if(r?c=!0:c=t.isSymmetric(),c){for(h=0;h<n;h++)for(p=0;p<n;p++)s.set(h,p,f.get(h,p));nw(n,l,a,s),iw(n,l,a,s)}else{let m=new pt(n,n),v=new Float64Array(n);for(p=0;p<n;p++)for(h=0;h<n;h++)m.set(h,p,f.get(h,p));sw(n,m,v,s),ow(n,l,a,s,m)}this.n=n,this.e=l,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t=this.n,e=this.e,r=this.d,n=new pt(t,t),s,a;for(s=0;s<t;s++){for(a=0;a<t;a++)n.set(s,a,0);n.set(s,s,r[s]),e[s]>0?n.set(s,s+1,e[s]):e[s]<0&&n.set(s,s-1,e[s])}return n}};function nw(i,t,e,r){let n,s,a,l,f,h,p,c;for(f=0;f<i;f++)e[f]=r.get(i-1,f);for(l=i-1;l>0;l--){for(c=0,a=0,h=0;h<l;h++)c=c+Math.abs(e[h]);if(c===0)for(t[l]=e[l-1],f=0;f<l;f++)e[f]=r.get(l-1,f),r.set(l,f,0),r.set(f,l,0);else{for(h=0;h<l;h++)e[h]/=c,a+=e[h]*e[h];for(n=e[l-1],s=Math.sqrt(a),n>0&&(s=-s),t[l]=c*s,a=a-n*s,e[l-1]=n-s,f=0;f<l;f++)t[f]=0;for(f=0;f<l;f++){for(n=e[f],r.set(f,l,n),s=t[f]+r.get(f,f)*n,h=f+1;h<=l-1;h++)s+=r.get(h,f)*e[h],t[h]+=r.get(h,f)*n;t[f]=s}for(n=0,f=0;f<l;f++)t[f]/=a,n+=t[f]*e[f];for(p=n/(a+a),f=0;f<l;f++)t[f]-=p*e[f];for(f=0;f<l;f++){for(n=e[f],s=t[f],h=f;h<=l-1;h++)r.set(h,f,r.get(h,f)-(n*t[h]+s*e[h]));e[f]=r.get(l-1,f),r.set(l,f,0)}}e[l]=a}for(l=0;l<i-1;l++){if(r.set(i-1,l,r.get(l,l)),r.set(l,l,1),a=e[l+1],a!==0){for(h=0;h<=l;h++)e[h]=r.get(h,l+1)/a;for(f=0;f<=l;f++){for(s=0,h=0;h<=l;h++)s+=r.get(h,l+1)*r.get(h,f);for(h=0;h<=l;h++)r.set(h,f,r.get(h,f)-s*e[h])}}for(h=0;h<=l;h++)r.set(h,l+1,0)}for(f=0;f<i;f++)e[f]=r.get(i-1,f),r.set(i-1,f,0);r.set(i-1,i-1,1),t[0]=0}function iw(i,t,e,r){let n,s,a,l,f,h,p,c,m,v,w,g,y,_,E,b;for(a=1;a<i;a++)t[a-1]=t[a];t[i-1]=0;let N=0,A=0,C=Number.EPSILON;for(h=0;h<i;h++){for(A=Math.max(A,Math.abs(e[h])+Math.abs(t[h])),p=h;p<i&&!(Math.abs(t[p])<=C*A);)p++;if(p>h)do{for(n=e[h],c=(e[h+1]-n)/(2*t[h]),m=Xr(c,1),c<0&&(m=-m),e[h]=t[h]/(c+m),e[h+1]=t[h]*(c+m),v=e[h+1],s=n-e[h],a=h+2;a<i;a++)e[a]-=s;for(N=N+s,c=e[p],w=1,g=w,y=w,_=t[h+1],E=0,b=0,a=p-1;a>=h;a--)for(y=g,g=w,b=E,n=w*t[a],s=w*c,m=Xr(c,t[a]),t[a+1]=E*m,E=t[a]/m,w=c/m,c=w*e[a]-E*n,e[a+1]=s+E*(w*n+E*e[a]),f=0;f<i;f++)s=r.get(f,a+1),r.set(f,a+1,E*r.get(f,a)+w*s),r.set(f,a,w*r.get(f,a)-E*s);c=-E*b*y*_*t[h]/v,t[h]=E*c,e[h]=w*c}while(Math.abs(t[h])>C*A);e[h]=e[h]+N,t[h]=0}for(a=0;a<i-1;a++){for(f=a,c=e[a],l=a+1;l<i;l++)e[l]<c&&(f=l,c=e[l]);if(f!==a)for(e[f]=e[a],e[a]=c,l=0;l<i;l++)c=r.get(l,a),r.set(l,a,r.get(l,f)),r.set(l,f,c)}}function sw(i,t,e,r){let n=0,s=i-1,a,l,f,h,p,c,m;for(c=n+1;c<=s-1;c++){for(m=0,h=c;h<=s;h++)m=m+Math.abs(t.get(h,c-1));if(m!==0){for(f=0,h=s;h>=c;h--)e[h]=t.get(h,c-1)/m,f+=e[h]*e[h];for(l=Math.sqrt(f),e[c]>0&&(l=-l),f=f-e[c]*l,e[c]=e[c]-l,p=c;p<i;p++){for(a=0,h=s;h>=c;h--)a+=e[h]*t.get(h,p);for(a=a/f,h=c;h<=s;h++)t.set(h,p,t.get(h,p)-a*e[h])}for(h=0;h<=s;h++){for(a=0,p=s;p>=c;p--)a+=e[p]*t.get(h,p);for(a=a/f,p=c;p<=s;p++)t.set(h,p,t.get(h,p)-a*e[p])}e[c]=m*e[c],t.set(c,c-1,m*l)}}for(h=0;h<i;h++)for(p=0;p<i;p++)r.set(h,p,h===p?1:0);for(c=s-1;c>=n+1;c--)if(t.get(c,c-1)!==0){for(h=c+1;h<=s;h++)e[h]=t.get(h,c-1);for(p=c;p<=s;p++){for(l=0,h=c;h<=s;h++)l+=e[h]*r.get(h,p);for(l=l/e[c]/t.get(c,c-1),h=c;h<=s;h++)r.set(h,p,r.get(h,p)+l*e[h])}}}function ow(i,t,e,r,n){let s=i-1,a=0,l=i-1,f=Number.EPSILON,h=0,p=0,c=0,m=0,v=0,w=0,g=0,y=0,_,E,b,N,A,C,M,S,$,F,I,R,U,q,k;for(_=0;_<i;_++)for((_<a||_>l)&&(e[_]=n.get(_,_),t[_]=0),E=Math.max(_-1,0);E<i;E++)p=p+Math.abs(n.get(_,E));for(;s>=a;){for(N=s;N>a&&(w=Math.abs(n.get(N-1,N-1))+Math.abs(n.get(N,N)),w===0&&(w=p),!(Math.abs(n.get(N,N-1))<f*w));)N--;if(N===s)n.set(s,s,n.get(s,s)+h),e[s]=n.get(s,s),t[s]=0,s--,y=0;else if(N===s-1){if(M=n.get(s,s-1)*n.get(s-1,s),c=(n.get(s-1,s-1)-n.get(s,s))/2,m=c*c+M,g=Math.sqrt(Math.abs(m)),n.set(s,s,n.get(s,s)+h),n.set(s-1,s-1,n.get(s-1,s-1)+h),S=n.get(s,s),m>=0){for(g=c>=0?c+g:c-g,e[s-1]=S+g,e[s]=e[s-1],g!==0&&(e[s]=S-M/g),t[s-1]=0,t[s]=0,S=n.get(s,s-1),w=Math.abs(S)+Math.abs(g),c=S/w,m=g/w,v=Math.sqrt(c*c+m*m),c=c/v,m=m/v,E=s-1;E<i;E++)g=n.get(s-1,E),n.set(s-1,E,m*g+c*n.get(s,E)),n.set(s,E,m*n.get(s,E)-c*g);for(_=0;_<=s;_++)g=n.get(_,s-1),n.set(_,s-1,m*g+c*n.get(_,s)),n.set(_,s,m*n.get(_,s)-c*g);for(_=a;_<=l;_++)g=r.get(_,s-1),r.set(_,s-1,m*g+c*r.get(_,s)),r.set(_,s,m*r.get(_,s)-c*g)}else e[s-1]=S+c,e[s]=S+c,t[s-1]=g,t[s]=-g;s=s-2,y=0}else{if(S=n.get(s,s),$=0,M=0,N<s&&($=n.get(s-1,s-1),M=n.get(s,s-1)*n.get(s-1,s)),y===10){for(h+=S,_=a;_<=s;_++)n.set(_,_,n.get(_,_)-S);w=Math.abs(n.get(s,s-1))+Math.abs(n.get(s-1,s-2)),S=$=.75*w,M=-.4375*w*w}if(y===30&&(w=($-S)/2,w=w*w+M,w>0)){for(w=Math.sqrt(w),$<S&&(w=-w),w=S-M/(($-S)/2+w),_=a;_<=s;_++)n.set(_,_,n.get(_,_)-w);h+=w,S=$=M=.964}for(y=y+1,A=s-2;A>=N&&(g=n.get(A,A),v=S-g,w=$-g,c=(v*w-M)/n.get(A+1,A)+n.get(A,A+1),m=n.get(A+1,A+1)-g-v-w,v=n.get(A+2,A+1),w=Math.abs(c)+Math.abs(m)+Math.abs(v),c=c/w,m=m/w,v=v/w,!(A===N||Math.abs(n.get(A,A-1))*(Math.abs(m)+Math.abs(v))<f*(Math.abs(c)*(Math.abs(n.get(A-1,A-1))+Math.abs(g)+Math.abs(n.get(A+1,A+1))))));)A--;for(_=A+2;_<=s;_++)n.set(_,_-2,0),_>A+2&&n.set(_,_-3,0);for(b=A;b<=s-1&&(q=b!==s-1,b!==A&&(c=n.get(b,b-1),m=n.get(b+1,b-1),v=q?n.get(b+2,b-1):0,S=Math.abs(c)+Math.abs(m)+Math.abs(v),S!==0&&(c=c/S,m=m/S,v=v/S)),S!==0);b++)if(w=Math.sqrt(c*c+m*m+v*v),c<0&&(w=-w),w!==0){for(b!==A?n.set(b,b-1,-w*S):N!==A&&n.set(b,b-1,-n.get(b,b-1)),c=c+w,S=c/w,$=m/w,g=v/w,m=m/c,v=v/c,E=b;E<i;E++)c=n.get(b,E)+m*n.get(b+1,E),q&&(c=c+v*n.get(b+2,E),n.set(b+2,E,n.get(b+2,E)-c*g)),n.set(b,E,n.get(b,E)-c*S),n.set(b+1,E,n.get(b+1,E)-c*$);for(_=0;_<=Math.min(s,b+3);_++)c=S*n.get(_,b)+$*n.get(_,b+1),q&&(c=c+g*n.get(_,b+2),n.set(_,b+2,n.get(_,b+2)-c*v)),n.set(_,b,n.get(_,b)-c),n.set(_,b+1,n.get(_,b+1)-c*m);for(_=a;_<=l;_++)c=S*r.get(_,b)+$*r.get(_,b+1),q&&(c=c+g*r.get(_,b+2),r.set(_,b+2,r.get(_,b+2)-c*v)),r.set(_,b,r.get(_,b)-c),r.set(_,b+1,r.get(_,b+1)-c*m)}}}if(p!==0){for(s=i-1;s>=0;s--)if(c=e[s],m=t[s],m===0)for(N=s,n.set(s,s,1),_=s-1;_>=0;_--){for(M=n.get(_,_)-c,v=0,E=N;E<=s;E++)v=v+n.get(_,E)*n.get(E,s);if(t[_]<0)g=M,w=v;else if(N=_,t[_]===0?n.set(_,s,M!==0?-v/M:-v/(f*p)):(S=n.get(_,_+1),$=n.get(_+1,_),m=(e[_]-c)*(e[_]-c)+t[_]*t[_],C=(S*w-g*v)/m,n.set(_,s,C),n.set(_+1,s,Math.abs(S)>Math.abs(g)?(-v-M*C)/S:(-w-$*C)/g)),C=Math.abs(n.get(_,s)),f*C*C>1)for(E=_;E<=s;E++)n.set(E,s,n.get(E,s)/C)}else if(m<0)for(N=s-1,Math.abs(n.get(s,s-1))>Math.abs(n.get(s-1,s))?(n.set(s-1,s-1,m/n.get(s,s-1)),n.set(s-1,s,-(n.get(s,s)-c)/n.get(s,s-1))):(k=ro(0,-n.get(s-1,s),n.get(s-1,s-1)-c,m),n.set(s-1,s-1,k[0]),n.set(s-1,s,k[1])),n.set(s,s-1,0),n.set(s,s,1),_=s-2;_>=0;_--){for(F=0,I=0,E=N;E<=s;E++)F=F+n.get(_,E)*n.get(E,s-1),I=I+n.get(_,E)*n.get(E,s);if(M=n.get(_,_)-c,t[_]<0)g=M,v=F,w=I;else if(N=_,t[_]===0?(k=ro(-F,-I,M,m),n.set(_,s-1,k[0]),n.set(_,s,k[1])):(S=n.get(_,_+1),$=n.get(_+1,_),R=(e[_]-c)*(e[_]-c)+t[_]*t[_]-m*m,U=(e[_]-c)*2*m,R===0&&U===0&&(R=f*p*(Math.abs(M)+Math.abs(m)+Math.abs(S)+Math.abs($)+Math.abs(g))),k=ro(S*v-g*F+m*I,S*w-g*I-m*F,R,U),n.set(_,s-1,k[0]),n.set(_,s,k[1]),Math.abs(S)>Math.abs(g)+Math.abs(m)?(n.set(_+1,s-1,(-F-M*n.get(_,s-1)+m*n.get(_,s))/S),n.set(_+1,s,(-I-M*n.get(_,s)-m*n.get(_,s-1))/S)):(k=ro(-v-$*n.get(_,s-1),-w-$*n.get(_,s),g,m),n.set(_+1,s-1,k[0]),n.set(_+1,s,k[1]))),C=Math.max(Math.abs(n.get(_,s-1)),Math.abs(n.get(_,s))),f*C*C>1)for(E=_;E<=s;E++)n.set(E,s-1,n.get(E,s-1)/C),n.set(E,s,n.get(E,s)/C)}for(_=0;_<i;_++)if(_<a||_>l)for(E=_;E<i;E++)r.set(_,E,n.get(_,E));for(E=i-1;E>=a;E--)for(_=a;_<=l;_++){for(g=0,b=a;b<=Math.min(E,l);b++)g=g+r.get(_,b)*n.get(b,E);r.set(_,E,g)}}}function ro(i,t,e,r){let n,s;return Math.abs(e)>Math.abs(r)?(n=r/e,s=e+n*r,[(i+n*t)/s,(t-n*i)/s]):(n=e/r,s=r+n*e,[(n*i+t)/s,(n*t-i)/s])}class zc{constructor(t){if(t=ir.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,n=new pt(r,r),s=!0,a,l,f;for(l=0;l<r;l++){let h=0;for(f=0;f<l;f++){let p=0;for(a=0;a<f;a++)p+=n.get(f,a)*n.get(l,a);p=(e.get(l,f)-p)/n.get(f,f),n.set(l,f,p),h=h+p*p}for(h=e.get(l,l)-h,s&=h>0,n.set(l,l,Math.sqrt(Math.max(h,0))),f=l+1;f<r;f++)n.set(l,f,0)}this.L=n,this.positiveDefinite=!!s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=ir.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,s=t.clone(),a,l,f;for(f=0;f<r;f++)for(l=0;l<n;l++){for(a=0;a<f;a++)s.set(f,l,s.get(f,l)-s.get(a,l)*e.get(f,a));s.set(f,l,s.get(f,l)/e.get(f,f))}for(f=r-1;f>=0;f--)for(l=0;l<n;l++){for(a=f+1;a<r;a++)s.set(f,l,s.get(f,l)-s.get(a,l)*e.get(a,f));s.set(f,l,s.get(f,l)/e.get(f,f))}return s}get lowerTriangularMatrix(){return this.L}}class qc{constructor(t,e={}){t=ir.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:s=1e3,terminationCriteria:a=1e-10}=e;let l;if(r){if(Je.isAnyArray(r)&&typeof r[0]=="number"?r=pt.columnVector(r):r=ir.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 f=1,h,p,c,m;for(let v=0;v<s&&f>a;v++)c=t.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),c=c.div(c.norm()),h=t.mmul(c).div(c.transpose().mmul(c).get(0,0)),v>0&&(f=h.clone().sub(m).pow(2).sum()),m=h.clone(),r?(p=r.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),p=p.div(p.norm()),l=r.mmul(p).div(p.transpose().mmul(p).get(0,0))):l=h;if(r){let v=t.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0));v=v.div(v.norm());let w=t.clone().sub(h.clone().mmul(v.transpose())),g=l.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),y=r.clone().sub(h.clone().mulS(g.get(0,0)).mmul(p.transpose()));this.t=h,this.p=v.transpose(),this.w=c.transpose(),this.q=p,this.u=l,this.s=h.transpose().mmul(h),this.xResidual=w,this.yResidual=y,this.betas=g}else this.w=c.transpose(),this.s=h.transpose().mmul(h).sqrt(),n?this.t=h.clone().div(this.s.get(0,0)):this.t=h,this.xResidual=t.sub(h.mmul(c.transpose()))}}Pt.AbstractMatrix=$t,Pt.CHO=zc,Pt.CholeskyDecomposition=zc,Pt.DistanceMatrix=Vs,Pt.EVD=Pc;var aw=Pt.EigenvalueDecomposition=Pc;Pt.LU=to,Pt.LuDecomposition=to;var Uc=Pt.Matrix=pt;Pt.MatrixColumnSelectionView=k1,Pt.MatrixColumnView=U1,Pt.MatrixFlipColumnView=W1,Pt.MatrixFlipRowView=Y1,Pt.MatrixRowSelectionView=Z1,Pt.MatrixRowView=j1,Pt.MatrixSelectionView=Qs,Pt.MatrixSubView=G1,Pt.MatrixTransposeView=K1,Pt.NIPALS=qc,Pt.Nipals=qc,Pt.QR=Ta,Pt.QrDecomposition=Ta,Pt.SVD=gi,Pt.SingularValueDecomposition=gi,Pt.SymmetricMatrix=kn,Pt.WrapperMatrix1D=Rc,Pt.WrapperMatrix2D=ir,Pt.correlation=rw,Pt.covariance=ew;var kc=Pt.default=pt;Pt.determinant=eo,Pt.inverse=J1,Pt.linearDependencies=Q1,Pt.pseudoInverse=tw,Pt.solve=Lc,Pt.wrap=H1;const Wc=aw,Yc=Uc;kc.Matrix&&kc.Matrix;class uw{new({rows:t,columns:e,initial_value:r}={}){return new $a(t,e,r)}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:s,to_column:a}){t==null||t.fill({value:e,from_row:r,to_row:n,from_column:s,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}){return t==null?void 0:t.reshape({rows:e,columns:r})}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:s}){return t==null?void 0:t.submatrix({from_row:e,to_row:r,from_column:n,to_column:s})}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 $a{constructor(t=0,e=0,r=void 0){Z(this,"_matrixInstance");this._matrixInstance=this._createMatrix(t,e,r)}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 Jt(e,r))}avg(){let t=0,e=0;for(const n of this._matrixInstance)for(const s of n._value)t+=s,e+=1;return t/e}col({column:t=0}){const e=[];for(const n of this._matrixInstance)e.push(n._value[t]);const r=new Jt;return r._value=e,r}det(){return Nc(this._matrixArray)}get({row:t=0,column:e=0}){var r,n;return(n=(r=this._matrixInstance[t])==null?void 0:r._value)==null?void 0:n[e]}inv(){const t=Ks(this._matrixArray);return this._newMatrix(t)}max(){return e1(this._matrixArray)}min(){return Na(this._matrixArray)}pow({power:t}){const e=n1(this._matrixArray,t);return this._newMatrix(e)}row({row:t=0}){return this._matrixInstance[t]}set({row:t,column:e,value:r}){this._matrixInstance[t].set({index:e,value:r})}sum({id2:t}){const e=Zi(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=H_(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=0,to_row:r=this.rows(),from_column:n=0,to_column:s=this.columns()}={}){for(const[a,l]of this._matrixInstance.entries())for(const[f]of l._value.entries())a<r&&a>=e&&f>=n&&f<s&&l.set({index:f,value:t})}kron({id2:t}){const e=G_(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return Na(bc(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=ci(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=r1(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t=0,order:e=Rn.ascending}={}){this._matrixInstance.sort((r,n)=>{const s=r._value[t],a=n._value[t];return e!==Rn.descending?s-a:a-s})}trace(){return t1(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return Sc(this._matrixArray)}add_col({column:t=this.columns(),array_id:e}={}){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}){this._matrixInstance.splice(t||this.rows(),0,e||new Jt(this.columns()))}is_zero(){return this._matrixArray.every(t=>t.every(e=>e===0))}reshape({rows:t,columns:e}){const r=W_(this._matrixArray,[t,e]);this._matrixInstance=r.map(n=>{const s=new Jt;return s._value=[...n],s})}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=0,to_row:e=this.rows(),from_column:r=0,to_column:n=this.columns()}={}){const s=this._matrixArray.splice(t,e),a=[];for(const l of s)a.push(l.splice(r,n));return this._newMatrix(a)}swap_rows({row1:t,row2:e}){const r=this._matrixInstance[t],n=this._matrixInstance[e];this._matrixInstance[t]=n,this._matrixInstance[e]=r}transpose(){const t=Ac(this._matrixArray);return this._newMatrix(t)}remove_col({column:t=this.columns()}={}){const e=[];for(const n of this._matrixInstance){const s=n._value.splice(t,1);e.push(s[0])}const r=new Jt;return r._value=e,r}remove_row({row:t=this.rows()}={}){return this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new Wc(new Yc(this._matrixArray)),e=new Jt;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 s=0;s<e;s++)if(n!==s&&r[n][s]!==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 s=0;s<e;s++)if(n!==s&&r[n][s]!==0||n===s&&r[n][s]!==1)return!1;return!0}eigenvectors(){const t=new Wc(new Yc(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 s=n+1;s<e;s++)if(r[n][s]!==r[s][n])return!1;return!0}swap_columns({column1:t,column2:e}){for(const r of this._matrixInstance){const n=r._value[t],s=r._value[e];r.set({index:t,value:s}),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 Y_(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 s=0;s<t;s++)if(n+s!==t-1&&r[n][s]!==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 s=0;s<t;s++)if(n!==s&&r[n][s]!==-r[s][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 $a;return e._value=t.map(r=>{const n=new Jt;return n._value=[...r],n}),e}_matrixRank(t){let e=0;const r=t.length,n=t[0].length,s=[...t].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let l=a;for(;l<r&&s[l][a]===0;)l++;if(l===r)continue;if(l!==a){const h=s[l];s[l]=s[a],s[a]=h}const f=s[a][a];for(let h=0;h<n;h++)s[a][h]/=f;for(let h=a+1;h<r;h++){const p=s[h][a];s[h]=s[h].map((c,m)=>c-p*s[a][m]),s[h][a]=0}}for(let a=0;a<r;a++)s[a].some(l=>Number(l.toFixed(8))!==0)&&e++;return e}}class lw{constructor(t){Z(this,"_variables");Z(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){const r=Tn(t),n=Tn(this._variables.timeframe.period);if(r<n)return!0;const s=`change_${e}`,a=this._cacheData[s],l=this._variables.time;if(a){if(a.offset){if(a.currentTime+a.offset<=l)return this._cacheData[s]={currentTime:l,offset:0},!0}else if(a.currentTime+r*1e3<=l)return this._cacheData[s]={currentTime:l,offset:0},!0}else{const f=this._calcTimeOffset(l,t);return this._cacheData[s]={currentTime:l,offset:f},!1}return!1}in_seconds({timeframe:t}={}){return Tn(t||this._variables.timeframe.period)}from_seconds({seconds:t=0}){const e=t*1e3,r=te.duration(e);if(r.years())return"12M";const s=r.asMonths();if(Zs(s))return`${s}M`;const a=r.asWeeks();if(Zs(a))return`${a}M`;const l=r.asDays();if(l>=1)return`${Math.ceil(l)}D`;const f=r.asMinutes();if(f>=1)return`${Math.ceil(f)}`;const h=r.asSeconds();return h<=1?"1S":h<=5?"5S":h<=10?"10S":h<=15?"15S":h<=30?"30S":"1"}_calcTimeOffset(t,e){let r=0;if(e.includes("W")){const l=te(t).day();e="1D",l!==1&&(r=(8-l)*60*60*24*1e3)}else if(e.includes("M")){const l=te(t).date();e="1D";const f=te(t).daysInMonth();l!==1&&(r=(f-l+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(t,e),s=Tn(e)*1e3,a=t-n-Math.floor((t-n)/s)*s;return r?r-a:a}}class fw{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 Jt;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=0,separator:r=""}){return Array.from(new Array(e),()=>t).join(r)}replace({source:t,target:e,replacement:r,occurrence:n=0}){let s=-1;for(let a=0;a<n+1&&(s=t.indexOf(e,s+1),s!==-1);a++);return s!==-1?t.substring(0,s)+r+t.substring(s+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 this._formatNumber(t,e)}_arrToStr(t,e){return`[${t.map(n=>typeof n=="number"?this._formatNumber(n,e):n).toString()}]`}substring({source:t,begin_pos:e=0,end_pos:r}){return 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 Mr(t,r).format(e)}replace_all({source:t,target:e,replacement:r}){return t==null?void 0:t.replace(new RegExp(e,"g"),r)}_formatNumber(t,e){if(!e)return t;switch(e){case"integer":return String(Math.round(t));case"currency":return`$${t}`;case"percent":return`${t*100}%`;default:const r=e.split(".")[1],n=r?r.length:0;return parseFloat(t.toFixed(n))}}_strFormat(t,e){let r=t;return e.forEach((n,s)=>{if(typeof n=="number"){const a=`\\{\\s*${s}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,l=t.match(new RegExp(a));if(l){const f=l[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(n,f)))}else r=r.replace(new RegExp(`\\{${s}\\}`,"g"),String(n))}else r=r.replace(new RegExp(`\\{${s}\\}`,"g"),n)}),r}}class cw{new(){return new Oa}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 Oa{constructor(){Z(this,"_mapInstance");this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new Oa;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 Jt;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 Jt;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 hw{constructor(t){Z(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Wn(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Wn(t,r,e)}copy({id:t}){const{price:e,time:r,index:n}=t||{};return new Wn(e,n,r)}from_index({price:t,index:e}){return new Wn(t,e)}from_time({price:t,time:e}){return new Wn(t,void 0,e)}}class Wn{constructor(t,e,r){Z(this,"_index");Z(this,"_price");Z(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 Wn(this._price,this._index,this._time)}}class pw{constructor(t){Z(this,"_variables");Z(this,"_defaultLabel",{text:"",xloc:Ie.bar_index,yloc:zi.price,size:qr.normal,style:me.styleLabelDown,textalign:Ke.alignCenter});this._variables=t}new(t,e){const r=`label_${e}`,n={...this._defaultLabel,...t,id:r};t.point&&(n.x=n.xloc===Ie.bar_index?t.point.index:t.point.time,n.y=t.point.price);const s=new Ki(r,this._variables);return this._variables.label.add(r,n,s),s}label(t,e){return t.x?t.x:new Ki(e,this._variables)}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 Ki{constructor(t,e){Z(this,"_id");Z(this,"_variables");this._id=t,this._variables=e}copy(t){const e=`label_${t}`,r=this._getLabel(t),n=new Ki(e,this._variables);return r&&this._variables.label.add(e,{...r,id:e},n),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)}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)}set_yloc({yloc:t},e){const r=this._getLabel(e);r&&(r.yloc=t)}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===Ie.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)}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)}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)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const dw={freq_all:fn.freqAll,freq_once_per_bar:fn.freqOncePerBar,freq_once_per_bar_close:fn.freqOncePerBarClose},mw={gaps_off:Li.gapsOff,gaps_on:Li.gapsOn,lookahead_off:Li.lookaheadOff,lookahead_on:Li.lookaheadOn},vi={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"},jc={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"},gw={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},vw={all:[er.dataWindow,er.pane,er.priceScale,er.statusLine],data_window:[er.dataWindow],none:[],pane:[er.pane],price_scale:[er.priceScale],status_line:[er.statusLine]},_w={both:$n.both,left:$n.left,none:$n.none,right:$n.right},ww={inherit:On.inherit,mintick:On.mintick,percent:On.percent,price:On.price,volume:On.volume},Dw={style_solid:vs.styleSolid,style_dashed:vs.styleDashed,style_dotted:vs.styleDotted},yw={style_arrowdown:me.styleArrowdown,style_arrowup:me.styleArrowup,style_circle:me.styleCircle,style_cross:me.styleCross,style_diamond:me.styleDiamond,style_flag:me.styleFlag,style_label_center:me.styleLabelCenter,style_label_down:me.styleLabelDown,style_label_left:me.styleLabelLeft,style_label_lower_left:me.styleLabelLowerLeft,style_label_lower_right:me.styleLabelLowerRight,style_label_right:me.styleLabelRight,style_label_up:me.styleLabelUp,style_label_upper_left:me.styleLabelUpperLeft,style_label_upper_right:me.styleLabelUpperRight,style_none:me.styleNone,style_square:me.styleSquare,style_text_outline:me.styleTextOutline,style_triangledown:me.styleTriangledown,style_triangleup:me.styleTriangleup,style_xcross:me.styleXcross},bw={style_arrow_both:zr.styleArrowBoth,style_arrow_left:zr.styleArrowLeft,style_arrow_right:zr.styleArrowRight,style_dashed:zr.styleDashed,style_dotted:zr.styleDotted,style_solid:zr.styleSolid},Ew={abovebar:ri.abovebar,absolute:ri.absolute,belowbar:ri.belowbar,bottom:ri.bottom,top:ri.top},Aw={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},xw={style_area:mr.styleArea,style_areabr:mr.styleAreabr,style_circles:mr.styleCircles,style_columns:mr.styleColumns,style_cross:mr.styleCross,style_histogram:mr.styleHistogram,style_line:mr.styleLine,style_linebr:mr.styleLinebr,style_stepline:mr.styleStepline,style_stepline_diamond:mr.styleSteplineDiamond,style_steplinebr:mr.styleSteplinebr},Cw={bottom_center:Nr.bottomCenter,bottom_left:Nr.bottomLeft,bottom_right:Nr.bottomRight,middle_center:Nr.middleCenter,middle_left:Nr.middleLeft,middle_right:Nr.middleRight,top_center:Nr.topCenter,top_left:Nr.topLeft,top_right:Nr.topRight},Fw={left:_s.left,none:_s.none,right:_s.right},Mw={arrowdown:rr.arrowdown,arrowup:rr.arrowup,circle:rr.circle,cross:rr.cross,diamond:rr.diamond,flag:rr.flag,labeldown:rr.labeldown,labelup:rr.labelup,square:rr.square,triangledown:rr.triangledown,triangleup:rr.triangleup,xcross:rr.xcross},Nw={auto:qr.auto,huge:qr.huge,large:qr.large,normal:qr.normal,small:qr.small,tiny:qr.tiny},Sw={cash:Gr.cash,fixed:Gr.fixed,percent_of_equity:Gr.percentOfEquity,commission:{cash_per_contract:Pi.cashPerContract,cash_per_order:Pi.cashPerOrder,percent:Pi.percent},direction:{all:ze.all,long:ze.long,short:ze.short},oca:{cancel:Ln.cancel,none:Ln.none,reduce:Ln.reduce}},Bw={align_bottom:Ke.alignBottom,align_center:Ke.alignCenter,align_left:Ke.alignLeft,align_right:Ke.alignRight,align_top:Ke.alignTop,wrap_auto:Ke.wrapAuto,wrap_none:Ke.wrapNone},Iw={bar_index:Ie.bar_index,bar_time:Ie.bar_time},Tw={abovebar:zi.abovebar,belowbar:zi.belowbar,price:zi.price},$w={actual:ws.actual,estimate:ws.estimate,standardized:ws.standardized};class Ow{constructor(){Z(this,"adjustment",{dividends:gs.dividends,none:gs.none,splits:gs.splits});Z(this,"alert",dw);Z(this,"barmerge",mw);Z(this,"color",vi);Z(this,"currency",jc);Z(this,"dayofweek",gw);Z(this,"earnings",$w);Z(this,"display",vw);Z(this,"extend",_w);Z(this,"font",{family_default:"SimSun",family_monospace:"Monospace"});Z(this,"format",ww);Z(this,"hline",Dw);Z(this,"label",yw);Z(this,"line",bw);Z(this,"location",Ew);Z(this,"math",Aw);Z(this,"order",{ascending:Rn.ascending,descending:Rn.descending});Z(this,"plot",xw);Z(this,"position",Cw);Z(this,"scale",Fw);Z(this,"session",{extended:ra.extended,regular:ra.regular});Z(this,"shape",Mw);Z(this,"size",Nw);Z(this,"splits",{denominator:"denominator",numerator:"numerator"});Z(this,"strategy",Sw);Z(this,"text",Bw);Z(this,"xloc",Iw);Z(this,"yloc",Tw)}updateData(){}}class Rw{constructor(t){Z(this,"_variables");Z(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:Ie.bar_index,line_color:vi.blue,line_style:zr.styleSolid,line_width:1});this._variables=t}new(t,e){const r=`polyline_${e}`,n=Object.assign({},this._defaultPolyline,t,{id:r}),s=new Zc(r,this._variables);return this._variables.polyline.add(r,n,s),s}delete({id:t}){t&&t.delete()}}class Zc{constructor(t,e){Z(this,"_id");Z(this,"_variables");this._variables=e,this._id=t}delete(){this._variables.polyline.delete(this._id)}}class Lw{constructor(t){Z(this,"_variables");Z(this,"_defaultLine",{xloc:Ie.bar_index,extend:$n.none,style:zr.styleSolid});this._variables=t}new({first_point:t,second_point:e,...r},n){const s=`line_${n}`,a={...this._defaultLine,...r,id:s};if(t&&e){const f=a.xloc===Ie.bar_index?t.index:t.time,h=a.xloc===Ie.bar_index?e.index:e.time;Object.assign(a,{x1:f,y1:t.price,x2:h,y2:e.price})}const l=new Hi(s,this._variables);return this._variables.line.add(s,a,l),l}line(t,e){return t.x?t.x:new Hi(e,this._variables)}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 Hi{constructor(t,e){Z(this,"_variables");Z(this,"_id");this._id=t,this._variables=e}get data(){return this._variables.line.get(this._id)}copy(t){const e=`line_${t}`,r=this._getLine(t),n=new Hi(e,this._variables);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===Ie.bar_index){const{x1:n,y1:s,x2:a,y2:l}=r;return n===void 0||a===void 0||s===void 0||l===void 0?void 0:(l-s)/(a-n)*(t-n)+s}}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 s=this._getLine(n);s&&(s.xloc=t,s.x1=e,s.x2=r)}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)}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)}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},l=r.xloc===Ie.bar_index?n:s,f=a;l&&(r.x1=l),f&&(r.y1=f)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},l=r.xloc===Ie.bar_index?n:s,f=a;l&&(r.x2=l),f&&(r.y2=f)}}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class Pw{constructor(t){Z(this,"_variables");this._variables=t}new({line1:t,line2:e,color:r},n){const s=`linefill_${n}`,a=t==null?void 0:t.data,l=e==null?void 0:e.data;a&&(a.linefills=a.linefills||[],a.linefills.push(s)),l&&(l.linefills=l.linefills||[],l.linefills.push(s));const f=new no(this._variables,s,t,e);return(a||l)&&this._variables.linefill.add(s,{line1:a,line2:l,color:r,id:s},f),f}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 no{constructor(t,e,r,n){Z(this,"_id");Z(this,"_line1");Z(this,"_line2");Z(this,"_variables");this._variables=t,this._id=e,this._line1=r,this._line2=n}linefill(t,e){return t.x?t.x:new no(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:s}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.filter(a=>a!==this._id)),s&&(s.linefills=(r=s.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 zw{constructor(t){Z(this,"_variables");Z(this,"_defaultBox",{border_color:vi.blue,border_width:1,bgcolor:vi.blue,xloc:Ie.bar_index,extend:$n.none,style:zr.styleSolid,text:"",text_size:qr.auto,text_color:vi.black,text_halign:Ke.alignCenter,text_valign:Ke.alignCenter,text_wrap:Ke.wrapNone});this._variables=t}box({x:t},e){return t===void 0?new Ji(this._variables,e):t}new({top_left:t,bottom_right:e,...r},n){const s=`box_${n}`,a={...this._defaultBox,...r,id:s};if(t){const{price:f,time:h,index:p}=t;a.top=f,a.left=a.xloc===Ie.bar_index?p:h}if(e){const{price:f,time:h,index:p}=e;a.bottom=f,a.right=a.xloc===Ie.bar_index?p:h}const l=new Ji(this._variables,s);return this._variables.box.add(s,a,l),l}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}){t==null||t.set_extend(e)}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}){t==null||t.set_border_style(e)}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}){t==null||t.set_text_size(e)}set_text_wrap({id:t,...e}){t==null||t.set_text_wrap(e)}set_text_color({id:t,...e}){t==null||t.set_text_color(e)}set_text_halign({id:t,...e}){t==null||t.set_text_halign(e)}set_text_valign({id:t,...e}){t==null||t.set_text_valign(e)}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}){t==null||t.set_text_font_family(e)}}class Ji{constructor(t,e){Z(this,"_id");Z(this,"_variables");this._variables=t,this._id=e}copy(t){const e=`box_${t}`,r=this._getBox(),n=new Ji(this._variables,e);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}){const e=this._getBox();e&&(e.extend=t)}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}){const e=this._getBox();e&&(e.text_size=t)}set_text_wrap({text_wrap:t}){const e=this._getBox();e&&(e.text_wrap=t)}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}){const e=this._getBox();e&&(e.text_halign=t)}set_text_valign({text_valign:t}){const e=this._getBox();e&&(e.text_valign=t)}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.top=n,e.left=e.xloc===Ie.bar_index?r:s}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t)}set_border_style({style:t}){const e=this._getBox();e&&(e.border_style=t)}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:s}=t||{};e.bottom=n,e.right=e.xloc===Ie.bar_index?r:s}}set_text_font_family({text_font_family:t}){const e=this._getBox();e&&(e.text_font_family=t)}_getBox(){return this._variables.box.get(this._id)}}class qw{constructor(t){Z(this,"_variables");Z(this,"_defaultTable",{position:Nr.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=t}table({x:t},e){return t||new Ra(this._variables,e)}new(t,e){const r=`table_${e}`,n={...this._defaultTable,...t,cell:[],id:r},s=new Ra(this._variables,r);return this._variables.table.add(r,n,s),s}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}){t==null||t.set_position(e)}}class Ra{constructor(t,e){Z(this,"_id");Z(this,"_variables");Z(this,"_defaultCell",{column:0,row:0,text:"",text_color:vi.black,text_halign:Ke.alignCenter,text_valign:Ke.alignCenter,text_size:qr.normal});this._variables=t,this._id=e}cell(t){const e={...this._defaultCell,...t},{column:r=0,row:n=0}=e,s=this._variables.table.get(this._id);if(s){const a=s.cell||[],l=a[n]||[];l[r]=e,a[n]=l,s.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 s=this._variables.table.get(this._id);if(s){const a=s.cell;if(a)for(let l=e;l<=n;l++)for(let f=t;f<=r;f++){const h=a[l];h&&(h[f]=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},s){if(t>r||e>n){console.log(`error ${s}: start_column > end_column or start_row > end_row`);return}const a=this._getTableItem(t,e);if(!a)return;this.clear({start_column:t,start_row:e,end_column:r,end_row:n});const l=this._variables.table.get(this._id);l.cell[e][t]={...a,isMerge:!0,merge_columns:r-t+1,merge_rows:n-e+1}}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}){const e=this._variables.table.get(this._id);e&&(e.position=t)}_getTableItem(t,e){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[e][t]:void 0}}}let Uw=class{constructor(t,e,r=.001){Z(this,"_variables");Z(this,"_options");Z(this,"_totalChangeCapital");Z(this,"_historyOrder");Z(this,"_orders");Z(this,"_pendingOrders");Z(this,"_mintick");Z(this,"_funcOptions");this._variables=t,this._options={overlay:!1,format:On.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:Gr.fixed,default_qty_value:1,initial_capital:1e6,currency:jc.NONE,slippage:0,commission_type:Pi.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._mintick=r,this._variables.strategy.updateOrders(this._orders)}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)}updateOptions(t){Object.assign(this._options,t),this._pendingOrderHandle(),this._ordersHandle(),this._calcLiquidate(),this._calcProfitAndLoss()}strategy(t){this._options={...t},Object.assign(this._funcOptions,{strategy:this._options,scriptType:"strategy"})}order(t){this._orderHandle(t)}entry(t){this._entryHandle(t)}close(t){const{immediately:e}=t;e||this._options.process_orders_on_close?this._closeOrderHandle(t,!0):this._pendingOrders.push({...t,place_order_type:"close"})}close_all(t){const{immediately:e}=t;e||this._options.process_orders_on_close?this._closeAllOrders(t,this._variables.close):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){this._exit(t)}_calcDefaultQty(t,e){const{default_qty_type:r=Gr.fixed,default_qty_value:n=1,initial_capital:s}=this._options;switch(r){case Gr.fixed:return n;case Gr.cash:return n/t;case Gr.percentOfEquity:return this._getCapital(e,s+this._orderProfit+this._totalChangeCapital)*n/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:s,qty:a=0,max_profit:l=0,trading_loss:f=0,direction:h}=n,p=h===ze.long?1:-1,c=(r-s)*p*a,m=(t-s)*a,v=(e-s)*a;let w=p===1?m:-v;w=Math.max(w,l);let g=p===1?v:-m;g=Math.min(g,f),Object.assign(n,{profit:c,max_profit:w,trading_loss:g,total_profit:this._totalChangeCapital+c})}}_calcLiquidate(){if(!this._orders.length)return;const{high:t,low:e}=this._variables,{initial_capital:r,margin_long:n=0,margin_short:s=0}=this._options,a=this._orders[0].direction===ze.long?1:-1,l=a===1?e:t,f=(a===1?n:s)/100;if(f<=0)return;const[h,p]=this._orders.reduce((g,y)=>{let[_,E]=g;const{in_price:b,qty:N=0}=y;return _+=b*N,E+=l*N,[_,E]},[0,0]),c=a*(p-h),v=r+this._totalChangeCapital+c-p*f;if(v>=0)return;const w=Math.trunc(v/f/l)*4;this._processOrders(this._orders,l,Math.abs(w),"Margin Call")}_orderHandle(t){const{process_orders_on_close:e,slippage:r=0}=this._options,{orders:n,isMarketPrice:s,quantities:a,close:l,price:f,activePrice:h}=this._orderArgsParse(t),p=t.direction===ze.long?1:-1;if(a<=0)return;let c=a;if(s&&e){if(n.length){const g=this._processOrders(n,l,c,t.comment);if(g<=0)return;c=g}const v=l+p*r*this._mintick;if(!this._judgeCapitalEnough(c,v,p))return;this._ocaGroupVerify(c,t.oca_name,t.oca_type),this._orders.push({...t,in_price:v,in_time:this._variables.time,total_profit:this._totalChangeCapital,qty:c,place_order_type:"order"});return}this._judgeCapitalEnough(a,f,p)&&this._addPendingOrders(t,f,c,s,h)}_judgeCapitalEnough(t,e,r){if(t<=0)return!1;const{margin_long:n=0,margin_short:s=0}=this._options;if((n===0||n===100)&&r===1||s===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===Ln.none)return!1;let n=!1;switch(r){case Ln.cancel:this._pendingOrders=this._pendingOrders.filter(s=>{if(s.oca_name===e)s.isCancel=!0,n=!0;else return!0});break;case Ln.reduce:this._pendingOrders=this._pendingOrders.filter(s=>{const{qty:a=0,oca_name:l}=s;if(e===l){const f=a-t;return n=!0,f<=0?(s.isCancel=!0,!1):(s.qty=f,!0)}else return!0});break}return n}_processOrders(t,e,r,n){let s=r;for(const a of t)if(s=this._processOrder(a,e,s,n),s<=0)break;return this._orders=this._orders.filter(a=>!a.isDeal),this._variables.strategy.updateOrders(this._orders),s}_addPendingOrders(t,e,r,n,s){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:s});else{const l={...t,in_price:e,isMarketPrice:n,qty:r,active_price:s,place_order_type:"order"};this._pendingOrders.push(l)}}_orderArgsParse(t){const{direction:e,qty:r,stop:n}=t;let s=t.limit||0;const{close:a}=this._variables;let l=a,f=!1,h;const p=e===ze.long?1:-1,c=n&&(n-a)*p>0,{backtest_fill_limits_assumption:m=0}=this._options;m>0&&s&&(s-=m*this._mintick*p);const v=s&&(s-a)*p<0;c&&v?(h=n,l=s):c?l=n:v?l=s:f=!0;const w=r||this._calcDefaultQty(l,p)||1;return{orders:this._orders.filter(y=>y.direction!==e),isMarketPrice:f,activePrice:h,quantities:w,close:a,price:l}}_entryHandle(t){const{process_orders_on_close:e}=this._options,{orders:r,isMarketPrice:n,quantities:s,close:a,price:l,activePrice:f}=this._orderArgsParse(t);if(s<=0)return;if(r.length&&n&&e){this._entryOrder(r,a,s,t);return}this._judgeCapitalEnough(s,a,t.direction===ze.long?1:-1)&&this._addPendingEntry(t,l,s,n,f)}_entryOrder(t,e,r,n){const{time:s}=this._variables,{slippage:a=0}=this._options,{oca_name:l,oca_type:f,direction:h,comment:p,isMarketPrice:c}=n,m=h===ze.long?1:-1;if(this._closeOrders(t,e,p),c){this._orders.push({...n,in_price:e,qty:r,in_time:s,place_order_type:"entry",total_profit:this._totalChangeCapital});return}const{pendingOrders:v,orders:w}=this._getEntryOrders(h),g=v.length+w.length;g&&g>=(this._options.pyramiding||0)||(e=e+a*this._mintick*m,!this._judgeCapitalEnough(r,e,m))||(this._ocaGroupVerify(r,l,f),this._orders.push({...n,in_price:e,qty:r,in_time:s,place_order_type:"entry",total_profit:this._totalChangeCapital}))}_getEntryOrders(t){const e=this._pendingOrders.filter(n=>n.place_order_type==="entry"&&n.direction===t),r=this._orders.filter(n=>n.place_order_type==="entry"&&n.direction===t);return{pendingOrders:e,orders:r}}_addPendingEntry(t,e,r,n,s){const{pendingOrders:a,orders:l}=this._getEntryOrders(t.direction),f=a.length+l.length,h=a.find(p=>p.id===t.id);if(h)Object.assign(h,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:s});else if(!f||f<(this._options.pyramiding||1)){const p={...t,in_price:e,isMarketPrice:n,qty:r,active_price:s,place_order_type:"entry"};this._pendingOrders.push(p)}}_closeAllOrders(t,e){const{comment:r}=t;this._closeOrders(this._orders,e,r),this._orders=[],this._variables.strategy.updateOrders(this._orders)}_closeOrders(t,e,r){for(const n of t)this._closeOrder(n,e,r);this._orders=this._orders.filter(n=>!n.isDeal),this._variables.strategy.updateOrders(this._orders)}_closeOrder(t,e,r){const{time:n}=this._variables,{slippage:s=0}=this._options,{in_price:a,qty:l=0,direction:f}=t,h=f===ze.long?1:-1;e=e-h*s*this._mintick,t.isDeal=!0;const p=(e-a)*h*l;this._totalChangeCapital+=p,this._historyOrder.push({...t,out_price:e,out_time:n,out_comment:r,profit:p,total_profit:this._totalChangeCapital})}_ordersHandle(){if(!this._orders.length)return;const t=this._orders.filter(a=>a.place_order_type==="exit"&&!a.hasExit),{open:e,low:r,high:n,close:s}=this._variables;for(const a of t){const{stop:l,limit:f,trail_stop_price:h,isMarketPriceLimit:p,isMarketPriceStop:c,direction:m,id:v,comment:w,qty:g,active_price:y,trail_offset:_=0,out_qty:E}=a;let b=h;const N=m===ze.long?1:-1;let A;if(p||c?A=e:(f&&r<=f&&n>=f&&(A=f),l&&r<=l&&n>=l&&(A=b?(l-b)*N>0?l:b:l)),A)this._processExitOnClose(a,A,{from_entry:v,comment:w,qty:E});else{if(b)if((b-e)*N>=0)A=b;else{const C=(N===1?n:r)-_*N*this._mintick;N===1?b<e&&b>=r&&C>b&&C<s?A=b:C>b?(b=C,C>=s&&(A=C)):b<=n&&r<=b&&(A=b):b>e&&b<=n&&C<b&&C>s?A=b:C<b?(b=C,C<=s&&(A=C)):b<=n&&r<=b&&(A=b),a.trail_stop_price=b}else y&&y<=n&&y>=r&&(b=y-_*N*this._mintick,(b-s)*N>=0&&(a.isMarketPriceStop=!0,this._options.process_orders_on_close&&(A=b)),a.trail_stop_price=b);A&&this._processExitOnClose(a,A,{from_entry:v,comment:w,qty:g})}}}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const t=[],e=this._pendingOrders.filter(r=>r.place_order_type==="exit");for(const r of this._pendingOrders){const{isCancel:n,place_order_type:s}=r;if(n)continue;let a;switch(s){case"entry":a=this._entryOrderHandle(r);break;case"order":a=this._orderOrderHandle(r);break;case"close":this._closeOrderHandle(r);break;case"close_all":this._closeAllOrders(r,this._variables.open);break}a&&t.push(a)}for(const r of e){const n=this._exitOrderHandle(r);n&&t.push(n)}this._pendingOrders=t}_entryOrderHandle(t){const{open:e,low:r,high:n}=this._variables,{isMarketPrice:s,qty:a=0,in_price:l,direction:f,active_price:h}=t;if(h&&n>=h&&r<=h)return delete t.active_price,t;let p=l;if(s&&(p=e),p<=n&&p>=r){const c=this._orders.filter(m=>m.direction!==f);this._entryOrder(c,p,a,t)}else return t}_orderOrderHandle(t){const{open:e,low:r,high:n,time:s}=this._variables,{slippage:a=0}=this._options,{isMarketPrice:l,qty:f=0,in_price:h,direction:p,comment:c,oca_name:m,oca_type:v,active_price:w}=t;if(w&&n>=w&&r<=w)return delete t.active_price,t;let g=h,y=f;if(l&&(g=e),g<=n&&g>=r){const _=this._orders.filter(b=>b.direction!==p);if(_.length&&(y=this._processOrders(_,g,f,c),y<=0))return;const E=p===ze.long?1:-1;this._ocaGroupVerify(y,m,v),this._orders.push({...t,in_price:g+E*a*this._mintick,in_time:s,total_profit:this._totalChangeCapital,qty:y});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:s=100,comment:a}=t,l=this._orders.filter(m=>m.id===r&&(!m.close_qty||m.close_qty<(m.qty||0)));if(!l.length)return;let f=0;if(n?f=n:(f=l.reduce((m,v)=>m+(v.qty||0),f),f=s/100*f),f<=0)return;const{open:h,close:p}=this._variables;let c=f;for(const m of l){const{qty:v=0}=m;c<v?m.close_qty=c:(m.close_qty=v,c-=v)}this._processOrders(this._options.close_entries_rule==="ANY"?l:this._orders,e?p:h,f,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){const{profit:e,loss:r,stop:n,limit:s,trail_offset:a,trail_price:l,trail_points:f,from_entry:h="",id:p}=t;if(this._isNaN(e)&&this._isNaN(r)&&this._isNaN(n)&&this._isNaN(s)&&this._isNaN(a)&&(this._isNaN(f)||this._isNaN(l))){console.log("error");return}const c={...t,place_order_type:"exit"},m=this._orders.filter(g=>(!h||h===g.id)&&!g.hasExit),v=this._pendingOrders.filter(g=>!h||h===g.id);if(m.length){if(!this._ordersToExit(m,c))return}else if(!v.length)return;const w=this._pendingOrders.find(g=>g.id===p);w?Object.assign(w,{...t}):this._pendingOrders.push(c)}_ordersToExit(t,e){const{qty:r,qty_percent:n=100}=e;let s=r,a=!1;for(const l of t){const{qty:f=0}=l,h=l.direction===ze.long?1:-1;s=r?r>=f?f:r:n*f,l.out_qty=s,s<f&&(a=!0),!(this._stopProfit(l,h,{...e,qty:s})||this._stopLoss(l,h,{...e,qty:s})||this._trailStopLoss(l,h,{...e,qty:s}))&&(l.place_order_type="exit")}return a}_stopProfit(t,e,r){const{limit:n,profit:s}=r;let a=n;const{close:l}=this._variables,{in_price:f}=t,{process_orders_on_close:h}=this._options;if(!this._isNaN(s)&&this._isNaN(n)&&(a=f+e*s*this._mintick),t.limit=a,a&&(a-l)*e<=0&&(t.isMarketPriceLimit=!0,a=l,h))return this._processExitOnClose(t,a,r),!0}_stopLoss(t,e,r){const{stop:n,loss:s}=r;let a=n;const{close:l}=this._variables,{in_price:f}=t,{process_orders_on_close:h}=this._options;if(!this._isNaN(s)&&this._isNaN(n)&&(a=f-e*s*this._mintick),t.stop=a,a&&(a-l)*e>=0&&(t.isMarketPriceStop=!0,a=l,h))return this._processExitOnClose(t,a,r),!0}_trailStopLoss(t,e,r){const{trail_offset:n,trail_price:s,trail_points:a}=r;if(!this._isNaN(n)){const{close:l}=this._variables,{in_price:f}=t,{process_orders_on_close:h}=this._options;let p;if(this._isNaN(s)?this._isNaN(a)||(p=f+a*e*this._mintick):p=s,t.trail_offset=n,p&&(p-l)*e<=0){const c=l-n*e*this._mintick;if((c-l)*e>=0&&(t.isMarketPriceStop=!0,h))return this._processExitOnClose(t,l,r),!0;t.trail_stop_price=c}t.active_price=p}}_processExitOnClose(t,e,r){const{qty:n=0,comment:s,id:a}=r,{close_entries_rule:l="FIFO"}=this._options;if(l==="FIFO"){const f=this._processExitOrders(this._orders,e,n,s||a);f&&!f.hasExit?(f.hasExit=!0,Object.assign(t,{trail_stop_price:f.trail_stop_price,stop:f.stop,limit:f.limit,trail_offset:f.trail_offset,active_price:f.active_price})):f&&(t.hasExit=!0)}else t.hasExit=!0,this._processOrders([t],e,n,s||a)}_processExitOrders(t,e,r,n){let s=r,a;for(const l of t)if(a=l,s=this._processOrder(l,e,s,n),s<=0||!l.hasExit)break;return this._orders=this._orders.filter(l=>!l.isDeal),this._variables.strategy.updateOrders(this._orders),a}_processOrder(t,e,r,n){const{time:s}=this._variables,{slippage:a=0}=this._options,{in_price:l,qty:f=0,max_profit:h=0,trading_loss:p=0,direction:c}=t,m=c===ze.long?1:-1;if(e=e-m*a*this._mintick,r<f){const v=f-r,w=(e-l)*m*r;this._totalChangeCapital+=w;const g=h/f*r,y=p/f*r;this._historyOrder.push({...t,out_price:e,out_time:s,out_comment:n,profit:w,qty:r,total_profit:this._totalChangeCapital,max_profit:g,trading_loss:y}),Object.assign(t,{qty:v,max_profit:h-g,trading_loss:p-y}),r=0}else{t.isDeal=!0;const v=(e-l)*m*f;this._totalChangeCapital+=v,this._historyOrder.push({...t,out_price:e,out_time:s,out_comment:n,profit:v,total_profit:this._totalChangeCapital}),r-=f}return r}_isNaN(t){return t===void 0||isNaN(t)}};class kw{constructor(t){Z(this,"_logs");Z(this,"_variables");this._variables=t,this._logs=[]}get logs(){return this._logs}clearLogs(){this._logs=[]}info(t,e){this._addLog(t,e,"info")}error(t,e){this._addLog(t,e,"error")}warning(t,e){this._addLog(t,e,"warning")}_addLog(t,e,r){const{message:n,formatString:s}=t,{time:a,bar_index:l,precision:f}=this._variables;let h=n;s&&Array.isArray(e)&&e.length&&(h=s.replace(/{(\d+)}/g,(p,c)=>{let m=e[c];return typeof m=="number"&&(m=parseFloat(m.toFixed(f))),m!==void 0?String(m):p})),h&&this._logs.push({message:`${te(a).format()}: ${h}`,time:a,barIndex:l,type:r})}}class Ww{constructor(t){Z(this,"_errorListener");this._errorListener=t}error({message:t},e){this._errorListener.addError(t,e,hi.Error)}}class Yw{constructor(){Z(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Fr.flatMap([...this._errors.values()])}addError(t,e,r){const[n,s]=e.split("_").slice(-2),a=this._errors.get(e),l={message:t,endLineNumber:Number(n),startColumn:Number(s),endColumn:Number(s),startLineNumber:Number(n),type:r};a?a.push(l):this._errors.set(e,[l])}}te.extend(Tp),te.extend(Np),te.extend(Bp);class jw{constructor(){Z(this,"_cacheData");Z(this,"_barIndex");Z(this,"_isRealTimeBar");Z(this,"_barstate");Z(this,"_priceVariables");Z(this,"_lastBarIndex");Z(this,"_currentBarTime");Z(this,"_lastBarTime");Z(this,"_period");Z(this,"_offsetTime");Z(this,"_timeframe");Z(this,"_ta");Z(this,"_polyline");Z(this,"_label");Z(this,"_line");Z(this,"_linefill");Z(this,"_box");Z(this,"_table");Z(this,"_strategy");Z(this,"_precision");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 Zw,this._timeframe=new Gw,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new Kw,this._polyline=new _i,this._label=new _i,this._line=new _i,this._linefill=new _i,this._box=new _i,this._table=new _i,this._strategy=new Hw,this._precision=4}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 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 te(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return te(this._currentBarTime).minute()}get second(){return te(this._currentBarTime).second()}get month(){return te(this._currentBarTime).month()+1}get year(){return te(this._currentBarTime).year()}get dayofweek(){return te(this._currentBarTime).day()+1}get dayofmonth(){return te(this._currentBarTime).date()}get weekofyear(){return te(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=ms(this._period);return this._isRealTimeBar?void 0:te(this._currentBarTime).add(t,e).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get precision(){return this._precision}getTimeTradingday(t,e){const[r,n]=ms(e),s=te(t).add(r,n);return["M","w","y"].includes(n)?s.subtract(1,"d").valueOf():s.startOf("d").add(this._offsetTime,"h").valueOf()}updateData(t){const{barIndex:e,c:r,o:n,h:s,l:a,volume:l,lastBarIndex:f,time:h,lastBarTime:p,period:c="1D",offsetTime:m=5,precision:v=4}=t;this._priceVariables={close:Number(r),open:Number(n),high:Number(s),low:Number(a),volume:Number(l)},e>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varData=this._cacheData.varNewData,this._cacheData.varNewData={}),this._precision=v,this._currentBarTime=h*1e3,this._lastBarIndex=f,this._barIndex=e,this._lastBarTime=p*1e3,this._period=c,this._offsetTime=m,this._timeframe.update(c),this._barstate.update(e,f,!1,!1),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){let n=this._cacheData[t]||[];n[this._barIndex]=r,n=n.filter(()=>!0);const s=n[n.length-1-e];return this._cacheData[t]=n,s}setCacheData(t,e){const r=this._cacheData[t]||[];r[this._barIndex]=e,this._cacheData[t]=r}getTypeInstance(t,e){return new Cp(t,e)}getVarValue(t,e,r){const n=`${t}_${e}`,s=r==="var"?this._cacheData.varData[n]:this._cacheData.varipData[n];if(s)return s}setVarValue(t,e,r,n){const s=`${t}_${e}`;let a;switch(typeof r=="object"&&r&&(n="var",a=r.varipKeys),n){case"var":if(this._isRealTimeBar){const l=Fr.cloneDeep(r);if(this._cacheData.varNewData[s]=l,a&&a.length)for(const f of a)this._cacheData.varData[s][f]=l[f]}else this._cacheData.varData[s]=r;break;case"varip":this._cacheData.varipData[s]=r;break}return r}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Fr.uniq([...t,...e]):Number(t)+Number(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 Ki.name:case Zc.name:case Ji.name:case Ra.name:case Hi.name:case no.name:t==null||t.delete();break}}}class _i{constructor(t=50){Z(this,"_all");Z(this,"_allInstance");Z(this,"_pseudoArrayAll");Z(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Jt,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){this._all.set(t,e),this._allInstance.set(t,r);const n=[...this._all.keys()];if(n.length>this._maxLength){const s=n.shift();s&&this.delete(s)}}get(t){return this._all.get(t)}getInstance(t){return this._allInstance.get(t)}delete(t){this._all.delete(t),this._allInstance.delete(t)}}class Zw{constructor(){Z(this,"_isMarketOpen");Z(this,"_currentBarIndex");Z(this,"_totalBarIndex");Z(this,"_isRealTimeBar");Z(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 Gw{constructor(){Z(this,"_period");Z(this,"_multiplier");Z(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=t;const[e,r]=ms(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 Kw{constructor(){Z(this,"_preAccdist");Z(this,"_preNvi");Z(this,"_prePvi");Z(this,"_preObv");Z(this,"_prePvt");Z(this,"_preWad");Z(this,"_preVwap");Z(this,"_preValue");Z(this,"_currentData");Z(this,"_preData");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={}}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 s=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=s),this._preValue.accdist=s,s}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,s=(2*t-r-e)/((r-e)*n);return this._preValue.iii=s,s}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:s}=this._currentData,a=(t-s)/(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 s=Math.max(e,n),a=Math.min(r,n),l=t-n,h=(l>0?t-a:l<0?t-s:0)+this._preWad;return!this.isRealTime&&(this._preWad=h),this._preValue.wad=h,h}get vwap(){if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:s}=this._preVwap;if(self.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin")&&(s=!0,r=n=0),!s)return;const l=t*e+r,f=e+n;!this.isRealTime&&(this._preVwap={sum:l,sumV:f,isReset:s});const h=l/f;return this._preValue.vwap=h,h}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const l=t||1;return n&&e?a=s<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:s}=this._currentData;let a=1;const l=t||1;return n&&e?a=s>r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class Hw{constructor(){Z(this,"_orders");Z(this,"_historyOrders");this._orders=[],this._historyOrders=[]}updateOrders(t){this._orders=t}updateHistoryOrders(t){this._historyOrders=t}get long(){return"long"}get short(){return"short"}get position_size(){return this._orders.reduce((t,e)=>{const r=e.direction===ze.long?1:-1;return t+(e.qty||0)*r},0)}}var Gc={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,function(){return function(e,r,n){r.prototype.isBetween=function(s,a,l,f){var h=n(s),p=n(a),c=(f=f||"()")[0]==="(",m=f[1]===")";return(c?this.isAfter(h,l):!this.isBefore(h,l))&&(m?this.isBefore(p,l):!this.isAfter(p,l))||(c?this.isBefore(h,l):!this.isAfter(h,l))&&(m?this.isAfter(p,l):!this.isBefore(p,l))}}})})(Gc);var Jw=Gc.exports,Xw=jt(Jw),Kc={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,function(){return function(e,r,n){var s=r.prototype,a=function(m){var v,w=m.date,g=m.utc,y={};if(!((v=w)===null||v instanceof Date||v instanceof Array||s.$utils().u(v)||v.constructor.name!=="Object")){if(!Object.keys(w).length)return new Date;var _=g?n.utc():n();Object.keys(w).forEach(function($){var F,I;y[F=$,I=s.$utils().p(F),I==="date"?"day":I]=w[$]});var E=y.day||(y.year||y.month>=0?1:_.date()),b=y.year||_.year(),N=y.month>=0?y.month:y.year||y.day?0:_.month(),A=y.hour||0,C=y.minute||0,M=y.second||0,S=y.millisecond||0;return g?new Date(Date.UTC(b,N,E,A,C,M,S)):new Date(b,N,E,A,C,M,S)}return w},l=s.parse;s.parse=function(m){m.date=a.bind(this)(m),l.bind(this)(m)};var f=s.set,h=s.add,p=s.subtract,c=function(m,v,w,g){g===void 0&&(g=1);var y=Object.keys(v),_=this;return y.forEach(function(E){_=m.bind(_)(v[E]*g,E)}),_};s.set=function(m,v){return v=v===void 0?m:v,m.constructor.name==="Object"?c.bind(this)(function(w,g){return f.bind(this)(g,w)},v,m):f.bind(this)(m,v)},s.add=function(m,v){return m.constructor.name==="Object"?c.bind(this)(h,m,v):h.bind(this)(m,v)},s.subtract=function(m,v){return m.constructor.name==="Object"?c.bind(this)(h,m,v,-1):p.bind(this)(m,v)}}})})(Kc);var Vw=Kc.exports,Qw=jt(Vw),Hc={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Wt,function(){var e,r,n=1e3,s=6e4,a=36e5,l=864e5,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,h=31536e6,p=2628e6,c=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,m={years:h,months:p,days:l,hours:a,minutes:s,seconds:n,milliseconds:1,weeks:6048e5},v=function(C){return C instanceof N},w=function(C,M,S){return new N(C,S,M.$l)},g=function(C){return r.p(C)+"s"},y=function(C){return C<0},_=function(C){return y(C)?Math.ceil(C):Math.floor(C)},E=function(C){return Math.abs(C)},b=function(C,M){return C?y(C)?{negative:!0,format:""+E(C)+M}:{negative:!1,format:""+C+M}:{negative:!1,format:""}},N=function(){function C(S,$,F){var I=this;if(this.$d={},this.$l=F,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),$)return w(S*m[g($)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(q){I.$d[g(q)]=S[q]}),this.calMilliseconds(),this;if(typeof S=="string"){var R=S.match(c);if(R){var U=R.slice(2).map(function(q){return q!=null?Number(q):0});return this.$d.years=U[0],this.$d.months=U[1],this.$d.weeks=U[2],this.$d.days=U[3],this.$d.hours=U[4],this.$d.minutes=U[5],this.$d.seconds=U[6],this.calMilliseconds(),this}}return this}var M=C.prototype;return M.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function($,F){return $+(S.$d[F]||0)*m[F]},0)},M.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=_(S/h),S%=h,this.$d.months=_(S/p),S%=p,this.$d.days=_(S/l),S%=l,this.$d.hours=_(S/a),S%=a,this.$d.minutes=_(S/s),S%=s,this.$d.seconds=_(S/n),S%=n,this.$d.milliseconds=S},M.toISOString=function(){var S=b(this.$d.years,"Y"),$=b(this.$d.months,"M"),F=+this.$d.days||0;this.$d.weeks&&(F+=7*this.$d.weeks);var I=b(F,"D"),R=b(this.$d.hours,"H"),U=b(this.$d.minutes,"M"),q=this.$d.seconds||0;this.$d.milliseconds&&(q+=this.$d.milliseconds/1e3,q=Math.round(1e3*q)/1e3);var k=b(q,"S"),P=S.negative||$.negative||I.negative||R.negative||U.negative||k.negative,K=R.format||U.format||k.format?"T":"",G=(P?"-":"")+"P"+S.format+$.format+I.format+K+R.format+U.format+k.format;return G==="P"||G==="-P"?"P0D":G},M.toJSON=function(){return this.toISOString()},M.format=function(S){var $=S||"YYYY-MM-DDTHH:mm:ss",F={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return $.replace(f,function(I,R){return R||String(F[I])})},M.as=function(S){return this.$ms/m[g(S)]},M.get=function(S){var $=this.$ms,F=g(S);return F==="milliseconds"?$%=1e3:$=F==="weeks"?_($/m[F]):this.$d[F],$||0},M.add=function(S,$,F){var I;return I=$?S*m[g($)]:v(S)?S.$ms:w(S,this).$ms,w(this.$ms+I*(F?-1:1),this)},M.subtract=function(S,$){return this.add(S,$,!0)},M.locale=function(S){var $=this.clone();return $.$l=S,$},M.clone=function(){return w(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")},C}(),A=function(C,M,S){return C.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(C,M,S){e=S,r=S().$utils(),S.duration=function(I,R){var U=S.locale();return w(I,{$l:U},R)},S.isDuration=v;var $=M.prototype.add,F=M.prototype.subtract;M.prototype.add=function(I,R){return v(I)?A(this,I,1):$.bind(this)(I,R)},M.prototype.subtract=function(I,R){return v(I)?A(this,I,-1):F.bind(this)(I,R)}}})})(Hc);var tD=Hc.exports,eD=jt(tD);te.extend(Xw),te.extend(Qw),te.extend(eD);class rD{constructor(t,e){Z(this,"array");Z(this,"color");Z(this,"math");Z(this,"str");Z(this,"map");Z(this,"matrix");Z(this,"timeframe");Z(this,"ta");Z(this,"input");Z(this,"_variables");Z(this,"_cacheData");Z(this,"_options");Z(this,"_errorListener");Z(this,"_plots");Z(this,"_alerts");Z(this,"_bgColors");Z(this,"_hlines");Z(this,"_fills");Z(this,"chart");Z(this,"line");Z(this,"label");Z(this,"polyline");Z(this,"box");Z(this,"table");Z(this,"linefill");Z(this,"log");Z(this,"runtime");Z(this,"strategy");this._variables=e,this.array=new Op,this.math=new Rp(t),this.color=new l1,this.str=new fw,this.map=new cw,this.timeframe=new lw(e),this.matrix=new uw,this.ta=new s1(e,this.math,this.timeframe),this._cacheData={},this._options={id:Fl(10)},this._bgColors={},this._alerts=new Map,this._hlines=new Map,this._fills=new Map,this._errorListener=new Yw,this.input=new u1(e,this._errorListener),this._plots=new Map,this.chart={point:new hw(e)},this.line=new Lw(e),this.label=new pw(e),this.polyline=new Rw(e),this.box=new zw(e),this.table=new qw(e),this.linefill=new Pw(e),this.log=new kw(e),this.runtime=new Ww(this._errorListener),this.strategy=new Uw(this._variables,this._options,t)}get errors(){return this._errorListener.errors}get options(){const t=this.input.getInputs(),e=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const r=Object.keys(this._bgColors).length?{...this._bgColors}:void 0,n=this._hlines.size?[...this._hlines.values()]:void 0,s=this._fills.size?[...this._fills.values()]:void 0,a=this.log.logs.length?this.log.logs:void 0;return this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders}),Object.assign(this._options,{inputs:t,plots:[...this._plots.values()],draws:this._getDraws(),alerts:e,colors:r,hlines:n,fills:s,logs:a})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:s,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),s.data.length&&(l.polylines=s.data),a.data.length&&(l.labels=a.data),Object.keys(l).length?l:void 0}update(t){const{barIndex:e,inputs:r}=t;r&&r.length&&this.input.update(r),this.strategy.updateOptions(),this.math.update(e)}indicator(t){this._variables.bar_index||(this._options.scriptType="indicator",this._options.indicator=t)}plot(t,e){const{series:r,color:n,seriesColors:s,...a}=t,{bar_index:l}=this._variables,f=`plot_${e}`,h=this._plots.get(f),p=(h==null?void 0:h.data)||[],c=r!==void 0&&isNaN(r)?void 0:r;if(p[l]=c,s!=null&&s.length&&(this._seriesColorHandle(t,f),p[l]={value:c,itemStyle:{color:n}}),!h){const m=n?[n]:void 0;this._plots.set(f,{editable:!0,...a,colors:m,data:p,id:f})}return{type:"plot",key:f}}plotbar(t,e){const{open:r,close:n,low:s,high:a,color:l,seriesColors:f,...h}=t,{bar_index:p}=this._variables,c=`plotbar_${e}`,m=this._plots.get(c),v=(m==null?void 0:m.data)||[],w=n!==void 0&&isNaN(n)?void 0:n,g=r!==void 0&&isNaN(r)?void 0:r,y=s!==void 0&&isNaN(s)?void 0:s,_=a!==void 0&&isNaN(a)?void 0:a,E=[g,w,y,_];if(v[p]=E,f!=null&&f.length&&(this._seriesColorHandle(t,c),v[p]={value:E,itemStyle:{color:l}}),!m){const b=l?[l]:void 0;this._plots.set(c,{editable:!0,...h,colors:b,data:v,id:c})}}plotchar(t,e){const{series:r,color:n,textcolor:s,...a}=t,{bar_index:l}=this._variables,f=`plotchar_${e}`,h=this._plots.get(f),p=(h==null?void 0:h.data)||[];p[l]={value:r,color:n,textcolor:s},h||this._plots.set(f,{editable:!0,...a,data:p,id:f})}plotarrow(t,e){const{series:r,colorup:n,colordown:s,...a}=t,{bar_index:l}=this._variables,f=`plotarrow_${e}`,h=this._plots.get(f),p=(h==null?void 0:h.data)||[];p[l]={value:r!==void 0&&isNaN(r)?void 0:r,colorup:n,colordown:s},h||this._plots.set(f,{editable:!0,...a,data:p,id:f})}plotshape(t,e){const{series:r,color:n,textcolor:s,...a}=t,{bar_index:l}=this._variables,f=`plotshape_${e}`,h=this._plots.get(f),p=(h==null?void 0:h.data)||[];p[l]={value:r,color:n,textcolor:s},h||this._plots.set(f,{editable:!0,...a,data:p,id:f})}plotcandle(t,e){const{wickcolor:r,bordercolor:n,color:s,close:a,open:l,low:f,high:h,...p}=t,{bar_index:c}=this._variables,m=`plotcandle_${e}`,v=this._plots.get(m),w=(v==null?void 0:v.data)||[],g=a!==void 0&&isNaN(a)?void 0:a,y=l!==void 0&&isNaN(l)?void 0:l,_=f!==void 0&&isNaN(f)?void 0:f,E=h!==void 0&&isNaN(h)?void 0:h,b=[y,g,_,E];w[c]={value:b,wickcolor:r,bordercolor:n,color:s},v||this._plots.set(m,{editable:!0,...p,data:w,id:m})}hline(t,e){const r=`hline_${e}`;return this._hlines.set(r,{linewidth:1,editable:!0,display:er.all,...t}),{type:"hline",key:r}}fill(t,e){const r=`fill_${e}`;this._fills.set(r,{display:er.all,editable:!0,fillgaps:!1,...t})}alert({message:t,freq:e=fn.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:s,last_bar_index:a}=this._variables,l=`alert_${r}`,f=this._cacheData[l].barIndex;if(e===fn.freqOncePerBar&&n===f){this._alerts.delete(l);return}const h={message:t,freq:e,id:l,type:"alert"};if(s){e!==fn.freqOncePerBarClose&&this._alerts.set(l,h),this._cacheData[l].barIndex=n;return}if(!s&&e===fn.freqOncePerBarClose&&n===f&&a===n-1){this._alerts.set(l,h),this._cacheData[l].barIndex=n;return}this._alerts.delete(l)}alertcondition({condition:t,message:e,title:r},n){const{_isRealTimeBar:s}=this._variables,a=`alertcondition_${n}`;s&&t?this._alerts.set(a,{message:e,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(t){this._setColors(t,"barcolor")}bgcolor(t){this._setColors(t,"bgcolor")}_setColors(t,e){var l,f;const{color:r,...n}=t,{bar_index:s}=this._variables,a=((l=this._bgColors[e])==null?void 0:l.colors)||[];if(!a[s]){const h=((f=this._bgColors[e])==null?void 0:f.setColors)||[];h.includes(r)||h.push(r),a[s]=r,this._bgColors[e]={...n,colors:a,setColors: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}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},s){return this._timeHandle(this._variables.time,s,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._variables.time_close&&this._timeHandle(this._variables.time_close,s,t,e,r,n)}timestamp({dateString:t,timezone:e,year:r,month:n,day:s,hour:a=0,minute:l=0,second:f=0}){if(t)return te(t).valueOf();let h=te({year:r,month:n,day:s,hour:a,minute:l,second:f});return e&&(h=Mr(h.valueOf(),e)),h.valueOf()}weekofyear({time:t,timezone:e}){return Mr(t,e).week()}year({time:t,timezone:e}){return Mr(t,e).year()}second({time:t,timezone:e}){return Mr(t,e).second()}month({time:t,timezone:e}){return Mr(t,e).month()+1}minute({time:t,timezone:e}){return Mr(t,e).minute()}hour({time:t,timezone:e}){return Mr(t,e).hour()}dayofweek({time:t,timezone:e}){return Mr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return Mr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,e),n=Tn(e)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,s,a=0){const l=r||this._variables.timeframe.period,f=Tn(l),h=Tn(this._variables.timeframe.period);let p;if(f<=h)p=t;else{const c=`time_${e}`,m=this._cacheData[c];if(m)m.currentTime+f*1e3-m.offset<=t?(p=t,this._cacheData[c]={currentTime:t,offset:0}):p=m;else{const v=this._calcTimeOffset(t,l);this._cacheData[c]={currentTime:t,offset:v},p=t}}if(n){const{timePeriods:c,weeks:m}=this._parserSession(n),v=te(t).format("YYYY-MM-DD"),w=p;p=void 0;for(const y of c){const[_,E]=y;if(te(t).isBetween(`${v} ${_}`,`${v} ${E}`,"hour")){te(w).isBetween(`${v} ${_}`,`${v} ${E}`,"hour")?p=w:p=te(`${v} ${_}`).valueOf();break}}const g=this._variables.dayofweek;p&&!m.includes(g)&&(p=void 0)}return s&&(p=p&&Mr(p,s).valueOf()),p&&p-a*h*1e3}_seriesColorHandle(t,e){var s,a;const{seriesColors:r}=t,n=this._plots.get(e);if(n&&r!=null&&r.length)for(const l of r){if((s=n.gradientColorKeys)!=null&&s.includes(l))continue;const f=t[l],h=n[`${l}s`]||[];h.includes(f)||(h.push(f),n[`${l}s`]=h,h.length>5&&(n[`${l}s`]=[],(a=n.gradientColorKeys)==null||a.push(l)))}}_parserSession(t){const e=t.split(":"),r=e[0],s=(e[1]||"1234567").split("").map(l=>{const f=parseInt(l,10);if(f<1||f>7)throw new Error(`Invalid day of week: ${l}`);return f});return{timePeriods:r.split(",").map(l=>{const f=l.split("-");if(f.length!==2)throw new Error(`Invalid time period: ${l}`);return[this._processTime(f[0]),this._processTime(f[1])]}),weeks:s}}_processTime(t){const e=parseInt(t.slice(0,2),10),r=parseInt(t.slice(2),10);if(!(e>=0&&e<=23)&&r>=0&&r<=59)throw new Error("Invalid time: Time must be within 00:00 to 23:59");return`${e}:${r}`}}/**
63
- * @license
64
- * Copyright 2019 Google LLC
65
- * SPDX-License-Identifier: Apache-2.0
66
- */const Jc=Symbol("Comlink.proxy"),nD=Symbol("Comlink.endpoint"),iD=Symbol("Comlink.releaseProxy"),La=Symbol("Comlink.finalizer"),io=Symbol("Comlink.thrown"),Xc=i=>typeof i=="object"&&i!==null||typeof i=="function",sD={canHandle:i=>Xc(i)&&i[Jc],serialize(i){const{port1:t,port2:e}=new MessageChannel;return Pa(i,t),[e,[e]]},deserialize(i){return i.start(),lD(i)}},oD={canHandle:i=>Xc(i)&&io in i,serialize({value:i}){let t;return i instanceof Error?t={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:t={isError:!1,value:i},[t,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},Vc=new Map([["proxy",sD],["throw",oD]]);function aD(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function Pa(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!aD(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:a,path:l}=Object.assign({path:[]},n.data),f=(n.data.argumentList||[]).map(Yn);let h;try{const p=l.slice(0,-1).reduce((m,v)=>m[v],i),c=l.reduce((m,v)=>m[v],i);switch(a){case"GET":h=c;break;case"SET":p[l.slice(-1)[0]]=Yn(n.data.value),h=!0;break;case"APPLY":h=c.apply(p,f);break;case"CONSTRUCT":{const m=new c(...f);h=dD(m)}break;case"ENDPOINT":{const{port1:m,port2:v}=new MessageChannel;Pa(i,v),h=pD(m,[m])}break;case"RELEASE":h=void 0;break;default:return}}catch(p){h={value:p,[io]:0}}Promise.resolve(h).catch(p=>({value:p,[io]:0})).then(p=>{const[c,m]=uo(p);t.postMessage(Object.assign(Object.assign({},c),{id:s}),m),a==="RELEASE"&&(t.removeEventListener("message",r),Qc(t),La in i&&typeof i[La]=="function"&&i[La]())}).catch(p=>{const[c,m]=uo({value:new TypeError("Unserializable return value"),[io]:0});t.postMessage(Object.assign(Object.assign({},c),{id:s}),m)})}),t.start&&t.start()}function uD(i){return i.constructor.name==="MessagePort"}function Qc(i){uD(i)&&i.close()}function lD(i,t){return za(i,[],t)}function so(i){if(i)throw new Error("Proxy has been released and is not useable")}function th(i){return wi(i,{type:"RELEASE"}).then(()=>{Qc(i)})}const oo=new WeakMap,ao="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(oo.get(i)||0)-1;oo.set(i,t),t===0&&th(i)});function fD(i,t){const e=(oo.get(t)||0)+1;oo.set(t,e),ao&&ao.register(i,t,i)}function cD(i){ao&&ao.unregister(i)}function za(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(so(r),a===iD)return()=>{cD(n),th(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const l=wi(i,{type:"GET",path:t.map(f=>f.toString())}).then(Yn);return l.then.bind(l)}return za(i,[...t,a])},set(s,a,l){so(r);const[f,h]=uo(l);return wi(i,{type:"SET",path:[...t,a].map(p=>p.toString()),value:f},h).then(Yn)},apply(s,a,l){so(r);const f=t[t.length-1];if(f===nD)return wi(i,{type:"ENDPOINT"}).then(Yn);if(f==="bind")return za(i,t.slice(0,-1));const[h,p]=eh(l);return wi(i,{type:"APPLY",path:t.map(c=>c.toString()),argumentList:h},p).then(Yn)},construct(s,a){so(r);const[l,f]=eh(a);return wi(i,{type:"CONSTRUCT",path:t.map(h=>h.toString()),argumentList:l},f).then(Yn)}});return fD(n,i),n}function hD(i){return Array.prototype.concat.apply([],i)}function eh(i){const t=i.map(uo);return[t.map(e=>e[0]),hD(t.map(e=>e[1]))]}const rh=new WeakMap;function pD(i,t){return rh.set(i,t),i}function dD(i){return Object.assign(i,{[Jc]:!0})}function uo(i){for(const[t,e]of Vc)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},rh.get(i)||[]]}function Yn(i){switch(i.type){case"HANDLER":return Vc.get(i.name).deserialize(i.value);case"RAW":return i.value}}function wi(i,t,e){return new Promise(r=>{const n=mD();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",s),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},t),e)})}function mD(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class gD{constructor(){Z(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)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}function vD(i,t,e){const{data:r,isPreParser:n}=t;if(self.workerStorage||(self.workerStorage=new gD),e&&(self.builtInGather=new jw,self.buildinConstants=new Ow,self.buildInFunctions=new rD(4,self.builtInGather),self.tradingvueFunc=new Function("$_var","$_const","$_func",i)),n)self.tradingvueFunc(self.builtInGather,self.buildinConstants,self.buildInFunctions);else if(r&&r.length){const a=r.length;for(const[l,f]of r.entries())self.builtInGather.updateData(Object.assign(f,{barIndex:l,lastBarIndex:a-1,lastBarTime:r[a-1].time})),self.buildInFunctions.update({barIndex:l}),self.tradingvueFunc(self.builtInGather,self.buildinConstants,self.buildInFunctions)}const s=self.buildInFunctions.errors;return s.length&&s.some(a=>a.type===hi.Error)?{status:1,errors:s}:{status:0,options:self.buildInFunctions.options}}Pa(vD)})();