@guihz/trading-vue-editor-tes 0.0.176 → 0.0.178
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assets/{parserTccWorker-BGGjQBvd.js → parserTccWorker-Bcz7NTve.js} +56 -56
- package/lib/assets/scriptsRunWorker-Ci_BGrY5.js +69 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/label.d.ts +2 -2
- package/lib/components/editor/parseScript/buildInFuncNamespace/line.d.ts +1 -1
- package/lib/components/editor/parseScript/buildInFuncNamespace/linefill.d.ts +2 -2
- package/lib/trading-vue-editor.js +2 -2
- package/lib/trading-vue-editor.umd.cjs +1 -1
- package/package.json +1 -1
- package/lib/assets/scriptsRunWorker-C5ZII6gX.js +0 -69
@@ -0,0 +1,69 @@
|
|
1
|
+
var k2=Object.defineProperty;var U2=(Ve,Ge,Mt)=>Ge in Ve?k2(Ve,Ge,{enumerable:!0,configurable:!0,writable:!0,value:Mt}):Ve[Ge]=Mt;var R=(Ve,Ge,Mt)=>(U2(Ve,typeof Ge!="symbol"?Ge+"":Ge,Mt),Mt),Al=(Ve,Ge,Mt)=>{if(!Ge.has(Ve))throw TypeError("Cannot "+Mt)};var Jr=(Ve,Ge,Mt)=>(Al(Ve,Ge,"read from private field"),Mt?Mt.call(Ve):Ge.get(Ve)),Cl=(Ve,Ge,Mt)=>{if(Ge.has(Ve))throw TypeError("Cannot add the same private member more than once");Ge instanceof WeakSet?Ge.add(Ve):Ge.set(Ve,Mt)},ua=(Ve,Ge,Mt,Yn)=>(Al(Ve,Ge,"write to private field"),Yn?Yn.call(Ve,Mt):Ge.set(Ve,Mt),Mt);var Fl=(Ve,Ge,Mt)=>(Al(Ve,Ge,"access private method"),Mt);(function(){"use strict";var is,Ml,Ni,Jt;var Ve=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ge(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Mt(s){if(s.__esModule)return s;var e=s.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(r){var n=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return s[r]}})}),t}var Yn={exports:{}};/**
|
2
|
+
* @license
|
3
|
+
* Lodash <https://lodash.com/>
|
4
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
5
|
+
* Released under MIT license <https://lodash.com/license>
|
6
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
7
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
8
|
+
*/Yn.exports,function(s,e){(function(){var t,r="4.17.21",n=200,i="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",p=500,h="__lodash_placeholder__",f=1,d=2,g=4,y=1,m=2,w=1,v=2,E=4,b=8,N=16,x=32,F=64,M=128,S=256,I=512,C=30,B="...",L=800,U=16,k=1,W=2,z=3,K=1/0,Z=9007199254740991,X=17976931348623157e292,Q=NaN,ce=4294967295,ve=ce-1,le=ce>>>1,we=[["ary",M],["bind",w],["bindKey",v],["curry",b],["curryRight",N],["flip",I],["partial",x],["partialRight",F],["rearg",S]],be="[object Arguments]",Be="[object Array]",Ee="[object AsyncFunction]",ot="[object Boolean]",Te="[object Date]",Ne="[object DOMException]",lt="[object Error]",rt="[object Function]",ke="[object GeneratorFunction]",Je="[object Map]",$t="[object Number]",mr="[object Null]",Pt="[object Object]",pn="[object Promise]",On="[object Proxy]",dn="[object RegExp]",gr="[object Set]",Tn="[object String]",$="[object Symbol]",V="[object Undefined]",G="[object WeakMap]",ne="[object WeakSet]",se="[object ArrayBuffer]",re="[object DataView]",fe="[object Float32Array]",ue="[object Float64Array]",he="[object Int8Array]",ae="[object Int16Array]",Xe="[object Int32Array]",nt="[object Uint8Array]",bt="[object Uint8ClampedArray]",Ut="[object Uint16Array]",zt="[object Uint32Array]",vr=/\b__p \+= '';/g,yr=/\b(__p \+=) '' \+/g,In=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ei=/&(?:amp|lt|gt|quot|#39);/g,vo=/[&<>"']/g,Va=RegExp(ei.source),Za=RegExp(vo.source),Ka=/<%-([\s\S]+?)%>/g,Ga=/<%([\s\S]+?)%>/g,yo=/<%=([\s\S]+?)%>/g,Ha=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ja=/^\w*$/,Xa=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ss=/[\\^$.*+?()[\]{}|]/g,Qa=RegExp(ss.source),os=/^\s+/,eu=/\s/,tu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ru=/\{\n\/\* \[wrapped with (.+)\] \*/,nu=/,? & /,iu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,su=/[()=,{}\[\]\/\s]/,ou=/\\(\\)?/g,au=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,wo=/\w*$/,uu=/^[-+]0x[0-9a-f]+$/i,lu=/^0b[01]+$/i,cu=/^\[object .+?Constructor\]$/,fu=/^0o[0-7]+$/i,hu=/^(?:0|[1-9]\d*)$/,pu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Si=/($^)/,ti=/['\n\r\u2028\u2029\\]/g,Ze="\\ud800-\\udfff",Xt="\\u0300-\\u036f",du="\\ufe20-\\ufe2f",Bi="\\u20d0-\\u20ff",$n=Xt+du+Bi,Do="\\u2700-\\u27bf",dh="a-z\\xdf-\\xf6\\xf8-\\xff",Rw="\\xac\\xb1\\xd7\\xf7",Pw="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",zw="\\u2000-\\u206f",qw=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",_h="A-Z\\xc0-\\xd6\\xd8-\\xde",mh="\\ufe0e\\ufe0f",gh=Rw+Pw+zw+qw,_u="['’]",kw="["+Ze+"]",vh="["+gh+"]",bo="["+$n+"]",yh="\\d+",Uw="["+Do+"]",wh="["+dh+"]",Dh="[^"+Ze+gh+yh+Do+dh+_h+"]",mu="\\ud83c[\\udffb-\\udfff]",Ww="(?:"+bo+"|"+mu+")",bh="[^"+Ze+"]",gu="(?:\\ud83c[\\udde6-\\uddff]){2}",vu="[\\ud800-\\udbff][\\udc00-\\udfff]",Oi="["+_h+"]",Eh="\\u200d",xh="(?:"+wh+"|"+Dh+")",jw="(?:"+Oi+"|"+Dh+")",Ah="(?:"+_u+"(?:d|ll|m|re|s|t|ve))?",Ch="(?:"+_u+"(?:D|LL|M|RE|S|T|VE))?",Fh=Ww+"?",Mh="["+mh+"]?",Yw="(?:"+Eh+"(?:"+[bh,gu,vu].join("|")+")"+Mh+Fh+")*",Vw="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Zw="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Nh=Mh+Fh+Yw,Kw="(?:"+[Uw,gu,vu].join("|")+")"+Nh,Gw="(?:"+[bh+bo+"?",bo,gu,vu,kw].join("|")+")",Hw=RegExp(_u,"g"),Jw=RegExp(bo,"g"),yu=RegExp(mu+"(?="+mu+")|"+Gw+Nh,"g"),Xw=RegExp([Oi+"?"+wh+"+"+Ah+"(?="+[vh,Oi,"$"].join("|")+")",jw+"+"+Ch+"(?="+[vh,Oi+xh,"$"].join("|")+")",Oi+"?"+xh+"+"+Ah,Oi+"+"+Ch,Zw,Vw,yh,Kw].join("|"),"g"),Qw=RegExp("["+Eh+Ze+$n+mh+"]"),eD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,tD=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],rD=-1,yt={};yt[fe]=yt[ue]=yt[he]=yt[ae]=yt[Xe]=yt[nt]=yt[bt]=yt[Ut]=yt[zt]=!0,yt[be]=yt[Be]=yt[se]=yt[ot]=yt[re]=yt[Te]=yt[lt]=yt[rt]=yt[Je]=yt[$t]=yt[Pt]=yt[dn]=yt[gr]=yt[Tn]=yt[G]=!1;var dt={};dt[be]=dt[Be]=dt[se]=dt[re]=dt[ot]=dt[Te]=dt[fe]=dt[ue]=dt[he]=dt[ae]=dt[Xe]=dt[Je]=dt[$t]=dt[Pt]=dt[dn]=dt[gr]=dt[Tn]=dt[$]=dt[nt]=dt[bt]=dt[Ut]=dt[zt]=!0,dt[lt]=dt[rt]=dt[G]=!1;var nD={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},iD={"&":"&","<":"<",">":">",'"':""","'":"'"},sD={"&":"&","<":"<",">":">",""":'"',"'":"'"},oD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},aD=parseFloat,uD=parseInt,Sh=typeof Ve=="object"&&Ve&&Ve.Object===Object&&Ve,lD=typeof self=="object"&&self&&self.Object===Object&&self,Kt=Sh||lD||Function("return this")(),wu=e&&!e.nodeType&&e,ri=wu&&!0&&s&&!s.nodeType&&s,Bh=ri&&ri.exports===wu,Du=Bh&&Sh.process,Br=function(){try{var j=ri&&ri.require&&ri.require("util").types;return j||Du&&Du.binding&&Du.binding("util")}catch{}}(),Oh=Br&&Br.isArrayBuffer,Th=Br&&Br.isDate,Ih=Br&&Br.isMap,$h=Br&&Br.isRegExp,Lh=Br&&Br.isSet,Rh=Br&&Br.isTypedArray;function wr(j,J,H){switch(H.length){case 0:return j.call(J);case 1:return j.call(J,H[0]);case 2:return j.call(J,H[0],H[1]);case 3:return j.call(J,H[0],H[1],H[2])}return j.apply(J,H)}function cD(j,J,H,ge){for(var Oe=-1,et=j==null?0:j.length;++Oe<et;){var qt=j[Oe];J(ge,qt,H(qt),j)}return ge}function Or(j,J){for(var H=-1,ge=j==null?0:j.length;++H<ge&&J(j[H],H,j)!==!1;);return j}function fD(j,J){for(var H=j==null?0:j.length;H--&&J(j[H],H,j)!==!1;);return j}function Ph(j,J){for(var H=-1,ge=j==null?0:j.length;++H<ge;)if(!J(j[H],H,j))return!1;return!0}function Ln(j,J){for(var H=-1,ge=j==null?0:j.length,Oe=0,et=[];++H<ge;){var qt=j[H];J(qt,H,j)&&(et[Oe++]=qt)}return et}function Eo(j,J){var H=j==null?0:j.length;return!!H&&Ti(j,J,0)>-1}function bu(j,J,H){for(var ge=-1,Oe=j==null?0:j.length;++ge<Oe;)if(H(J,j[ge]))return!0;return!1}function Et(j,J){for(var H=-1,ge=j==null?0:j.length,Oe=Array(ge);++H<ge;)Oe[H]=J(j[H],H,j);return Oe}function Rn(j,J){for(var H=-1,ge=J.length,Oe=j.length;++H<ge;)j[Oe+H]=J[H];return j}function Eu(j,J,H,ge){var Oe=-1,et=j==null?0:j.length;for(ge&&et&&(H=j[++Oe]);++Oe<et;)H=J(H,j[Oe],Oe,j);return H}function hD(j,J,H,ge){var Oe=j==null?0:j.length;for(ge&&Oe&&(H=j[--Oe]);Oe--;)H=J(H,j[Oe],Oe,j);return H}function xu(j,J){for(var H=-1,ge=j==null?0:j.length;++H<ge;)if(J(j[H],H,j))return!0;return!1}var pD=Au("length");function dD(j){return j.split("")}function _D(j){return j.match(iu)||[]}function zh(j,J,H){var ge;return H(j,function(Oe,et,qt){if(J(Oe,et,qt))return ge=et,!1}),ge}function xo(j,J,H,ge){for(var Oe=j.length,et=H+(ge?1:-1);ge?et--:++et<Oe;)if(J(j[et],et,j))return et;return-1}function Ti(j,J,H){return J===J?FD(j,J,H):xo(j,qh,H)}function mD(j,J,H,ge){for(var Oe=H-1,et=j.length;++Oe<et;)if(ge(j[Oe],J))return Oe;return-1}function qh(j){return j!==j}function kh(j,J){var H=j==null?0:j.length;return H?Fu(j,J)/H:Q}function Au(j){return function(J){return J==null?t:J[j]}}function Cu(j){return function(J){return j==null?t:j[J]}}function Uh(j,J,H,ge,Oe){return Oe(j,function(et,qt,ht){H=ge?(ge=!1,et):J(H,et,qt,ht)}),H}function gD(j,J){var H=j.length;for(j.sort(J);H--;)j[H]=j[H].value;return j}function Fu(j,J){for(var H,ge=-1,Oe=j.length;++ge<Oe;){var et=J(j[ge]);et!==t&&(H=H===t?et:H+et)}return H}function Mu(j,J){for(var H=-1,ge=Array(j);++H<j;)ge[H]=J(H);return ge}function vD(j,J){return Et(J,function(H){return[H,j[H]]})}function Wh(j){return j&&j.slice(0,Zh(j)+1).replace(os,"")}function Dr(j){return function(J){return j(J)}}function Nu(j,J){return Et(J,function(H){return j[H]})}function as(j,J){return j.has(J)}function jh(j,J){for(var H=-1,ge=j.length;++H<ge&&Ti(J,j[H],0)>-1;);return H}function Yh(j,J){for(var H=j.length;H--&&Ti(J,j[H],0)>-1;);return H}function yD(j,J){for(var H=j.length,ge=0;H--;)j[H]===J&&++ge;return ge}var wD=Cu(nD),DD=Cu(iD);function bD(j){return"\\"+oD[j]}function ED(j,J){return j==null?t:j[J]}function Ii(j){return Qw.test(j)}function xD(j){return eD.test(j)}function AD(j){for(var J,H=[];!(J=j.next()).done;)H.push(J.value);return H}function Su(j){var J=-1,H=Array(j.size);return j.forEach(function(ge,Oe){H[++J]=[Oe,ge]}),H}function Vh(j,J){return function(H){return j(J(H))}}function Pn(j,J){for(var H=-1,ge=j.length,Oe=0,et=[];++H<ge;){var qt=j[H];(qt===J||qt===h)&&(j[H]=h,et[Oe++]=H)}return et}function Ao(j){var J=-1,H=Array(j.size);return j.forEach(function(ge){H[++J]=ge}),H}function CD(j){var J=-1,H=Array(j.size);return j.forEach(function(ge){H[++J]=[ge,ge]}),H}function FD(j,J,H){for(var ge=H-1,Oe=j.length;++ge<Oe;)if(j[ge]===J)return ge;return-1}function MD(j,J,H){for(var ge=H+1;ge--;)if(j[ge]===J)return ge;return ge}function $i(j){return Ii(j)?SD(j):pD(j)}function Zr(j){return Ii(j)?BD(j):dD(j)}function Zh(j){for(var J=j.length;J--&&eu.test(j.charAt(J)););return J}var ND=Cu(sD);function SD(j){for(var J=yu.lastIndex=0;yu.test(j);)++J;return J}function BD(j){return j.match(yu)||[]}function OD(j){return j.match(Xw)||[]}var TD=function j(J){J=J==null?Kt:Li.defaults(Kt.Object(),J,Li.pick(Kt,tD));var H=J.Array,ge=J.Date,Oe=J.Error,et=J.Function,qt=J.Math,ht=J.Object,Bu=J.RegExp,ID=J.String,Tr=J.TypeError,Co=H.prototype,$D=et.prototype,Ri=ht.prototype,Fo=J["__core-js_shared__"],Mo=$D.toString,at=Ri.hasOwnProperty,LD=0,Kh=function(){var o=/[^.]+$/.exec(Fo&&Fo.keys&&Fo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),No=Ri.toString,RD=Mo.call(ht),PD=Kt._,zD=Bu("^"+Mo.call(at).replace(ss,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),So=Bh?J.Buffer:t,zn=J.Symbol,Bo=J.Uint8Array,Gh=So?So.allocUnsafe:t,Oo=Vh(ht.getPrototypeOf,ht),Hh=ht.create,Jh=Ri.propertyIsEnumerable,To=Co.splice,Xh=zn?zn.isConcatSpreadable:t,us=zn?zn.iterator:t,ni=zn?zn.toStringTag:t,Io=function(){try{var o=ui(ht,"defineProperty");return o({},"",{}),o}catch{}}(),qD=J.clearTimeout!==Kt.clearTimeout&&J.clearTimeout,kD=ge&&ge.now!==Kt.Date.now&&ge.now,UD=J.setTimeout!==Kt.setTimeout&&J.setTimeout,$o=qt.ceil,Lo=qt.floor,Ou=ht.getOwnPropertySymbols,WD=So?So.isBuffer:t,Qh=J.isFinite,jD=Co.join,YD=Vh(ht.keys,ht),kt=qt.max,Qt=qt.min,VD=ge.now,ZD=J.parseInt,e0=qt.random,KD=Co.reverse,Tu=ui(J,"DataView"),ls=ui(J,"Map"),Iu=ui(J,"Promise"),Pi=ui(J,"Set"),cs=ui(J,"WeakMap"),fs=ui(ht,"create"),Ro=cs&&new cs,zi={},GD=li(Tu),HD=li(ls),JD=li(Iu),XD=li(Pi),QD=li(cs),Po=zn?zn.prototype:t,hs=Po?Po.valueOf:t,t0=Po?Po.toString:t;function O(o){if(Ft(o)&&!Ie(o)&&!(o instanceof je)){if(o instanceof Ir)return o;if(at.call(o,"__wrapped__"))return rp(o)}return new Ir(o)}var qi=function(){function o(){}return function(u){if(!Ct(u))return{};if(Hh)return Hh(u);o.prototype=u;var _=new o;return o.prototype=t,_}}();function zo(){}function Ir(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=t}O.templateSettings={escape:Ka,evaluate:Ga,interpolate:yo,variable:"",imports:{_:O}},O.prototype=zo.prototype,O.prototype.constructor=O,Ir.prototype=qi(zo.prototype),Ir.prototype.constructor=Ir;function je(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ce,this.__views__=[]}function eb(){var o=new je(this.__wrapped__);return o.__actions__=lr(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=lr(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=lr(this.__views__),o}function tb(){if(this.__filtered__){var o=new je(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function rb(){var o=this.__wrapped__.value(),u=this.__dir__,_=Ie(o),D=u<0,A=_?o.length:0,T=dE(0,A,this.__views__),P=T.start,q=T.end,Y=q-P,ee=D?q:P-1,te=this.__iteratees__,oe=te.length,de=0,ye=Qt(Y,this.__takeCount__);if(!_||!D&&A==Y&&ye==Y)return A0(o,this.__actions__);var Ce=[];e:for(;Y--&&de<ye;){ee+=u;for(var Re=-1,Fe=o[ee];++Re<oe;){var Ue=te[Re],Ye=Ue.iteratee,xr=Ue.type,sr=Ye(Fe);if(xr==W)Fe=sr;else if(!sr){if(xr==k)continue e;break e}}Ce[de++]=Fe}return Ce}je.prototype=qi(zo.prototype),je.prototype.constructor=je;function ii(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function nb(){this.__data__=fs?fs(null):{},this.size=0}function ib(o){var u=this.has(o)&&delete this.__data__[o];return this.size-=u?1:0,u}function sb(o){var u=this.__data__;if(fs){var _=u[o];return _===c?t:_}return at.call(u,o)?u[o]:t}function ob(o){var u=this.__data__;return fs?u[o]!==t:at.call(u,o)}function ab(o,u){var _=this.__data__;return this.size+=this.has(o)?0:1,_[o]=fs&&u===t?c:u,this}ii.prototype.clear=nb,ii.prototype.delete=ib,ii.prototype.get=sb,ii.prototype.has=ob,ii.prototype.set=ab;function _n(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function ub(){this.__data__=[],this.size=0}function lb(o){var u=this.__data__,_=qo(u,o);if(_<0)return!1;var D=u.length-1;return _==D?u.pop():To.call(u,_,1),--this.size,!0}function cb(o){var u=this.__data__,_=qo(u,o);return _<0?t:u[_][1]}function fb(o){return qo(this.__data__,o)>-1}function hb(o,u){var _=this.__data__,D=qo(_,o);return D<0?(++this.size,_.push([o,u])):_[D][1]=u,this}_n.prototype.clear=ub,_n.prototype.delete=lb,_n.prototype.get=cb,_n.prototype.has=fb,_n.prototype.set=hb;function mn(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function pb(){this.size=0,this.__data__={hash:new ii,map:new(ls||_n),string:new ii}}function db(o){var u=Xo(this,o).delete(o);return this.size-=u?1:0,u}function _b(o){return Xo(this,o).get(o)}function mb(o){return Xo(this,o).has(o)}function gb(o,u){var _=Xo(this,o),D=_.size;return _.set(o,u),this.size+=_.size==D?0:1,this}mn.prototype.clear=pb,mn.prototype.delete=db,mn.prototype.get=_b,mn.prototype.has=mb,mn.prototype.set=gb;function si(o){var u=-1,_=o==null?0:o.length;for(this.__data__=new mn;++u<_;)this.add(o[u])}function vb(o){return this.__data__.set(o,c),this}function yb(o){return this.__data__.has(o)}si.prototype.add=si.prototype.push=vb,si.prototype.has=yb;function Kr(o){var u=this.__data__=new _n(o);this.size=u.size}function wb(){this.__data__=new _n,this.size=0}function Db(o){var u=this.__data__,_=u.delete(o);return this.size=u.size,_}function bb(o){return this.__data__.get(o)}function Eb(o){return this.__data__.has(o)}function xb(o,u){var _=this.__data__;if(_ instanceof _n){var D=_.__data__;if(!ls||D.length<n-1)return D.push([o,u]),this.size=++_.size,this;_=this.__data__=new mn(D)}return _.set(o,u),this.size=_.size,this}Kr.prototype.clear=wb,Kr.prototype.delete=Db,Kr.prototype.get=bb,Kr.prototype.has=Eb,Kr.prototype.set=xb;function r0(o,u){var _=Ie(o),D=!_&&ci(o),A=!_&&!D&&jn(o),T=!_&&!D&&!A&&ji(o),P=_||D||A||T,q=P?Mu(o.length,ID):[],Y=q.length;for(var ee in o)(u||at.call(o,ee))&&!(P&&(ee=="length"||A&&(ee=="offset"||ee=="parent")||T&&(ee=="buffer"||ee=="byteLength"||ee=="byteOffset")||wn(ee,Y)))&&q.push(ee);return q}function n0(o){var u=o.length;return u?o[Yu(0,u-1)]:t}function Ab(o,u){return Qo(lr(o),oi(u,0,o.length))}function Cb(o){return Qo(lr(o))}function $u(o,u,_){(_!==t&&!Gr(o[u],_)||_===t&&!(u in o))&&gn(o,u,_)}function ps(o,u,_){var D=o[u];(!(at.call(o,u)&&Gr(D,_))||_===t&&!(u in o))&&gn(o,u,_)}function qo(o,u){for(var _=o.length;_--;)if(Gr(o[_][0],u))return _;return-1}function Fb(o,u,_,D){return qn(o,function(A,T,P){u(D,A,_(A),P)}),D}function i0(o,u){return o&&sn(u,Wt(u),o)}function Mb(o,u){return o&&sn(u,fr(u),o)}function gn(o,u,_){u=="__proto__"&&Io?Io(o,u,{configurable:!0,enumerable:!0,value:_,writable:!0}):o[u]=_}function Lu(o,u){for(var _=-1,D=u.length,A=H(D),T=o==null;++_<D;)A[_]=T?t:ml(o,u[_]);return A}function oi(o,u,_){return o===o&&(_!==t&&(o=o<=_?o:_),u!==t&&(o=o>=u?o:u)),o}function $r(o,u,_,D,A,T){var P,q=u&f,Y=u&d,ee=u&g;if(_&&(P=A?_(o,D,A,T):_(o)),P!==t)return P;if(!Ct(o))return o;var te=Ie(o);if(te){if(P=mE(o),!q)return lr(o,P)}else{var oe=er(o),de=oe==rt||oe==ke;if(jn(o))return M0(o,q);if(oe==Pt||oe==be||de&&!A){if(P=Y||de?{}:Z0(o),!q)return Y?sE(o,Mb(P,o)):iE(o,i0(P,o))}else{if(!dt[oe])return A?o:{};P=gE(o,oe,q)}}T||(T=new Kr);var ye=T.get(o);if(ye)return ye;T.set(o,P),bp(o)?o.forEach(function(Fe){P.add($r(Fe,u,_,Fe,o,T))}):wp(o)&&o.forEach(function(Fe,Ue){P.set(Ue,$r(Fe,u,_,Ue,o,T))});var Ce=ee?Y?rl:tl:Y?fr:Wt,Re=te?t:Ce(o);return Or(Re||o,function(Fe,Ue){Re&&(Ue=Fe,Fe=o[Ue]),ps(P,Ue,$r(Fe,u,_,Ue,o,T))}),P}function Nb(o){var u=Wt(o);return function(_){return s0(_,o,u)}}function s0(o,u,_){var D=_.length;if(o==null)return!D;for(o=ht(o);D--;){var A=_[D],T=u[A],P=o[A];if(P===t&&!(A in o)||!T(P))return!1}return!0}function o0(o,u,_){if(typeof o!="function")throw new Tr(a);return ws(function(){o.apply(t,_)},u)}function ds(o,u,_,D){var A=-1,T=Eo,P=!0,q=o.length,Y=[],ee=u.length;if(!q)return Y;_&&(u=Et(u,Dr(_))),D?(T=bu,P=!1):u.length>=n&&(T=as,P=!1,u=new si(u));e:for(;++A<q;){var te=o[A],oe=_==null?te:_(te);if(te=D||te!==0?te:0,P&&oe===oe){for(var de=ee;de--;)if(u[de]===oe)continue e;Y.push(te)}else T(u,oe,D)||Y.push(te)}return Y}var qn=T0(nn),a0=T0(Pu,!0);function Sb(o,u){var _=!0;return qn(o,function(D,A,T){return _=!!u(D,A,T),_}),_}function ko(o,u,_){for(var D=-1,A=o.length;++D<A;){var T=o[D],P=u(T);if(P!=null&&(q===t?P===P&&!Er(P):_(P,q)))var q=P,Y=T}return Y}function Bb(o,u,_,D){var A=o.length;for(_=Le(_),_<0&&(_=-_>A?0:A+_),D=D===t||D>A?A:Le(D),D<0&&(D+=A),D=_>D?0:xp(D);_<D;)o[_++]=u;return o}function u0(o,u){var _=[];return qn(o,function(D,A,T){u(D,A,T)&&_.push(D)}),_}function Gt(o,u,_,D,A){var T=-1,P=o.length;for(_||(_=yE),A||(A=[]);++T<P;){var q=o[T];u>0&&_(q)?u>1?Gt(q,u-1,_,D,A):Rn(A,q):D||(A[A.length]=q)}return A}var Ru=I0(),l0=I0(!0);function nn(o,u){return o&&Ru(o,u,Wt)}function Pu(o,u){return o&&l0(o,u,Wt)}function Uo(o,u){return Ln(u,function(_){return Dn(o[_])})}function ai(o,u){u=Un(u,o);for(var _=0,D=u.length;o!=null&&_<D;)o=o[on(u[_++])];return _&&_==D?o:t}function c0(o,u,_){var D=u(o);return Ie(o)?D:Rn(D,_(o))}function nr(o){return o==null?o===t?V:mr:ni&&ni in ht(o)?pE(o):CE(o)}function zu(o,u){return o>u}function Ob(o,u){return o!=null&&at.call(o,u)}function Tb(o,u){return o!=null&&u in ht(o)}function Ib(o,u,_){return o>=Qt(u,_)&&o<kt(u,_)}function qu(o,u,_){for(var D=_?bu:Eo,A=o[0].length,T=o.length,P=T,q=H(T),Y=1/0,ee=[];P--;){var te=o[P];P&&u&&(te=Et(te,Dr(u))),Y=Qt(te.length,Y),q[P]=!_&&(u||A>=120&&te.length>=120)?new si(P&&te):t}te=o[0];var oe=-1,de=q[0];e:for(;++oe<A&&ee.length<Y;){var ye=te[oe],Ce=u?u(ye):ye;if(ye=_||ye!==0?ye:0,!(de?as(de,Ce):D(ee,Ce,_))){for(P=T;--P;){var Re=q[P];if(!(Re?as(Re,Ce):D(o[P],Ce,_)))continue e}de&&de.push(Ce),ee.push(ye)}}return ee}function $b(o,u,_,D){return nn(o,function(A,T,P){u(D,_(A),T,P)}),D}function _s(o,u,_){u=Un(u,o),o=J0(o,u);var D=o==null?o:o[on(Rr(u))];return D==null?t:wr(D,o,_)}function f0(o){return Ft(o)&&nr(o)==be}function Lb(o){return Ft(o)&&nr(o)==se}function Rb(o){return Ft(o)&&nr(o)==Te}function ms(o,u,_,D,A){return o===u?!0:o==null||u==null||!Ft(o)&&!Ft(u)?o!==o&&u!==u:Pb(o,u,_,D,ms,A)}function Pb(o,u,_,D,A,T){var P=Ie(o),q=Ie(u),Y=P?Be:er(o),ee=q?Be:er(u);Y=Y==be?Pt:Y,ee=ee==be?Pt:ee;var te=Y==Pt,oe=ee==Pt,de=Y==ee;if(de&&jn(o)){if(!jn(u))return!1;P=!0,te=!1}if(de&&!te)return T||(T=new Kr),P||ji(o)?j0(o,u,_,D,A,T):fE(o,u,Y,_,D,A,T);if(!(_&y)){var ye=te&&at.call(o,"__wrapped__"),Ce=oe&&at.call(u,"__wrapped__");if(ye||Ce){var Re=ye?o.value():o,Fe=Ce?u.value():u;return T||(T=new Kr),A(Re,Fe,_,D,T)}}return de?(T||(T=new Kr),hE(o,u,_,D,A,T)):!1}function zb(o){return Ft(o)&&er(o)==Je}function ku(o,u,_,D){var A=_.length,T=A,P=!D;if(o==null)return!T;for(o=ht(o);A--;){var q=_[A];if(P&&q[2]?q[1]!==o[q[0]]:!(q[0]in o))return!1}for(;++A<T;){q=_[A];var Y=q[0],ee=o[Y],te=q[1];if(P&&q[2]){if(ee===t&&!(Y in o))return!1}else{var oe=new Kr;if(D)var de=D(ee,te,Y,o,u,oe);if(!(de===t?ms(te,ee,y|m,D,oe):de))return!1}}return!0}function h0(o){if(!Ct(o)||DE(o))return!1;var u=Dn(o)?zD:cu;return u.test(li(o))}function qb(o){return Ft(o)&&nr(o)==dn}function kb(o){return Ft(o)&&er(o)==gr}function Ub(o){return Ft(o)&&sa(o.length)&&!!yt[nr(o)]}function p0(o){return typeof o=="function"?o:o==null?hr:typeof o=="object"?Ie(o)?m0(o[0],o[1]):_0(o):$p(o)}function Uu(o){if(!ys(o))return YD(o);var u=[];for(var _ in ht(o))at.call(o,_)&&_!="constructor"&&u.push(_);return u}function Wb(o){if(!Ct(o))return AE(o);var u=ys(o),_=[];for(var D in o)D=="constructor"&&(u||!at.call(o,D))||_.push(D);return _}function Wu(o,u){return o<u}function d0(o,u){var _=-1,D=cr(o)?H(o.length):[];return qn(o,function(A,T,P){D[++_]=u(A,T,P)}),D}function _0(o){var u=il(o);return u.length==1&&u[0][2]?G0(u[0][0],u[0][1]):function(_){return _===o||ku(_,o,u)}}function m0(o,u){return ol(o)&&K0(u)?G0(on(o),u):function(_){var D=ml(_,o);return D===t&&D===u?gl(_,o):ms(u,D,y|m)}}function Wo(o,u,_,D,A){o!==u&&Ru(u,function(T,P){if(A||(A=new Kr),Ct(T))jb(o,u,P,_,Wo,D,A);else{var q=D?D(ul(o,P),T,P+"",o,u,A):t;q===t&&(q=T),$u(o,P,q)}},fr)}function jb(o,u,_,D,A,T,P){var q=ul(o,_),Y=ul(u,_),ee=P.get(Y);if(ee){$u(o,_,ee);return}var te=T?T(q,Y,_+"",o,u,P):t,oe=te===t;if(oe){var de=Ie(Y),ye=!de&&jn(Y),Ce=!de&&!ye&&ji(Y);te=Y,de||ye||Ce?Ie(q)?te=q:St(q)?te=lr(q):ye?(oe=!1,te=M0(Y,!0)):Ce?(oe=!1,te=N0(Y,!0)):te=[]:Ds(Y)||ci(Y)?(te=q,ci(q)?te=Ap(q):(!Ct(q)||Dn(q))&&(te=Z0(Y))):oe=!1}oe&&(P.set(Y,te),A(te,Y,D,T,P),P.delete(Y)),$u(o,_,te)}function g0(o,u){var _=o.length;if(_)return u+=u<0?_:0,wn(u,_)?o[u]:t}function v0(o,u,_){u.length?u=Et(u,function(T){return Ie(T)?function(P){return ai(P,T.length===1?T[0]:T)}:T}):u=[hr];var D=-1;u=Et(u,Dr(Ae()));var A=d0(o,function(T,P,q){var Y=Et(u,function(ee){return ee(T)});return{criteria:Y,index:++D,value:T}});return gD(A,function(T,P){return nE(T,P,_)})}function Yb(o,u){return y0(o,u,function(_,D){return gl(o,D)})}function y0(o,u,_){for(var D=-1,A=u.length,T={};++D<A;){var P=u[D],q=ai(o,P);_(q,P)&&gs(T,Un(P,o),q)}return T}function Vb(o){return function(u){return ai(u,o)}}function ju(o,u,_,D){var A=D?mD:Ti,T=-1,P=u.length,q=o;for(o===u&&(u=lr(u)),_&&(q=Et(o,Dr(_)));++T<P;)for(var Y=0,ee=u[T],te=_?_(ee):ee;(Y=A(q,te,Y,D))>-1;)q!==o&&To.call(q,Y,1),To.call(o,Y,1);return o}function w0(o,u){for(var _=o?u.length:0,D=_-1;_--;){var A=u[_];if(_==D||A!==T){var T=A;wn(A)?To.call(o,A,1):Ku(o,A)}}return o}function Yu(o,u){return o+Lo(e0()*(u-o+1))}function Zb(o,u,_,D){for(var A=-1,T=kt($o((u-o)/(_||1)),0),P=H(T);T--;)P[D?T:++A]=o,o+=_;return P}function Vu(o,u){var _="";if(!o||u<1||u>Z)return _;do u%2&&(_+=o),u=Lo(u/2),u&&(o+=o);while(u);return _}function Pe(o,u){return ll(H0(o,u,hr),o+"")}function Kb(o){return n0(Yi(o))}function Gb(o,u){var _=Yi(o);return Qo(_,oi(u,0,_.length))}function gs(o,u,_,D){if(!Ct(o))return o;u=Un(u,o);for(var A=-1,T=u.length,P=T-1,q=o;q!=null&&++A<T;){var Y=on(u[A]),ee=_;if(Y==="__proto__"||Y==="constructor"||Y==="prototype")return o;if(A!=P){var te=q[Y];ee=D?D(te,Y,q):t,ee===t&&(ee=Ct(te)?te:wn(u[A+1])?[]:{})}ps(q,Y,ee),q=q[Y]}return o}var D0=Ro?function(o,u){return Ro.set(o,u),o}:hr,Hb=Io?function(o,u){return Io(o,"toString",{configurable:!0,enumerable:!1,value:yl(u),writable:!0})}:hr;function Jb(o){return Qo(Yi(o))}function Lr(o,u,_){var D=-1,A=o.length;u<0&&(u=-u>A?0:A+u),_=_>A?A:_,_<0&&(_+=A),A=u>_?0:_-u>>>0,u>>>=0;for(var T=H(A);++D<A;)T[D]=o[D+u];return T}function Xb(o,u){var _;return qn(o,function(D,A,T){return _=u(D,A,T),!_}),!!_}function jo(o,u,_){var D=0,A=o==null?D:o.length;if(typeof u=="number"&&u===u&&A<=le){for(;D<A;){var T=D+A>>>1,P=o[T];P!==null&&!Er(P)&&(_?P<=u:P<u)?D=T+1:A=T}return A}return Zu(o,u,hr,_)}function Zu(o,u,_,D){var A=0,T=o==null?0:o.length;if(T===0)return 0;u=_(u);for(var P=u!==u,q=u===null,Y=Er(u),ee=u===t;A<T;){var te=Lo((A+T)/2),oe=_(o[te]),de=oe!==t,ye=oe===null,Ce=oe===oe,Re=Er(oe);if(P)var Fe=D||Ce;else ee?Fe=Ce&&(D||de):q?Fe=Ce&&de&&(D||!ye):Y?Fe=Ce&&de&&!ye&&(D||!Re):ye||Re?Fe=!1:Fe=D?oe<=u:oe<u;Fe?A=te+1:T=te}return Qt(T,ve)}function b0(o,u){for(var _=-1,D=o.length,A=0,T=[];++_<D;){var P=o[_],q=u?u(P):P;if(!_||!Gr(q,Y)){var Y=q;T[A++]=P===0?0:P}}return T}function E0(o){return typeof o=="number"?o:Er(o)?Q:+o}function br(o){if(typeof o=="string")return o;if(Ie(o))return Et(o,br)+"";if(Er(o))return t0?t0.call(o):"";var u=o+"";return u=="0"&&1/o==-K?"-0":u}function kn(o,u,_){var D=-1,A=Eo,T=o.length,P=!0,q=[],Y=q;if(_)P=!1,A=bu;else if(T>=n){var ee=u?null:lE(o);if(ee)return Ao(ee);P=!1,A=as,Y=new si}else Y=u?[]:q;e:for(;++D<T;){var te=o[D],oe=u?u(te):te;if(te=_||te!==0?te:0,P&&oe===oe){for(var de=Y.length;de--;)if(Y[de]===oe)continue e;u&&Y.push(oe),q.push(te)}else A(Y,oe,_)||(Y!==q&&Y.push(oe),q.push(te))}return q}function Ku(o,u){return u=Un(u,o),o=J0(o,u),o==null||delete o[on(Rr(u))]}function x0(o,u,_,D){return gs(o,u,_(ai(o,u)),D)}function Yo(o,u,_,D){for(var A=o.length,T=D?A:-1;(D?T--:++T<A)&&u(o[T],T,o););return _?Lr(o,D?0:T,D?T+1:A):Lr(o,D?T+1:0,D?A:T)}function A0(o,u){var _=o;return _ instanceof je&&(_=_.value()),Eu(u,function(D,A){return A.func.apply(A.thisArg,Rn([D],A.args))},_)}function Gu(o,u,_){var D=o.length;if(D<2)return D?kn(o[0]):[];for(var A=-1,T=H(D);++A<D;)for(var P=o[A],q=-1;++q<D;)q!=A&&(T[A]=ds(T[A]||P,o[q],u,_));return kn(Gt(T,1),u,_)}function C0(o,u,_){for(var D=-1,A=o.length,T=u.length,P={};++D<A;){var q=D<T?u[D]:t;_(P,o[D],q)}return P}function Hu(o){return St(o)?o:[]}function Ju(o){return typeof o=="function"?o:hr}function Un(o,u){return Ie(o)?o:ol(o,u)?[o]:tp(it(o))}var Qb=Pe;function Wn(o,u,_){var D=o.length;return _=_===t?D:_,!u&&_>=D?o:Lr(o,u,_)}var F0=qD||function(o){return Kt.clearTimeout(o)};function M0(o,u){if(u)return o.slice();var _=o.length,D=Gh?Gh(_):new o.constructor(_);return o.copy(D),D}function Xu(o){var u=new o.constructor(o.byteLength);return new Bo(u).set(new Bo(o)),u}function eE(o,u){var _=u?Xu(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.byteLength)}function tE(o){var u=new o.constructor(o.source,wo.exec(o));return u.lastIndex=o.lastIndex,u}function rE(o){return hs?ht(hs.call(o)):{}}function N0(o,u){var _=u?Xu(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.length)}function S0(o,u){if(o!==u){var _=o!==t,D=o===null,A=o===o,T=Er(o),P=u!==t,q=u===null,Y=u===u,ee=Er(u);if(!q&&!ee&&!T&&o>u||T&&P&&Y&&!q&&!ee||D&&P&&Y||!_&&Y||!A)return 1;if(!D&&!T&&!ee&&o<u||ee&&_&&A&&!D&&!T||q&&_&&A||!P&&A||!Y)return-1}return 0}function nE(o,u,_){for(var D=-1,A=o.criteria,T=u.criteria,P=A.length,q=_.length;++D<P;){var Y=S0(A[D],T[D]);if(Y){if(D>=q)return Y;var ee=_[D];return Y*(ee=="desc"?-1:1)}}return o.index-u.index}function B0(o,u,_,D){for(var A=-1,T=o.length,P=_.length,q=-1,Y=u.length,ee=kt(T-P,0),te=H(Y+ee),oe=!D;++q<Y;)te[q]=u[q];for(;++A<P;)(oe||A<T)&&(te[_[A]]=o[A]);for(;ee--;)te[q++]=o[A++];return te}function O0(o,u,_,D){for(var A=-1,T=o.length,P=-1,q=_.length,Y=-1,ee=u.length,te=kt(T-q,0),oe=H(te+ee),de=!D;++A<te;)oe[A]=o[A];for(var ye=A;++Y<ee;)oe[ye+Y]=u[Y];for(;++P<q;)(de||A<T)&&(oe[ye+_[P]]=o[A++]);return oe}function lr(o,u){var _=-1,D=o.length;for(u||(u=H(D));++_<D;)u[_]=o[_];return u}function sn(o,u,_,D){var A=!_;_||(_={});for(var T=-1,P=u.length;++T<P;){var q=u[T],Y=D?D(_[q],o[q],q,_,o):t;Y===t&&(Y=o[q]),A?gn(_,q,Y):ps(_,q,Y)}return _}function iE(o,u){return sn(o,sl(o),u)}function sE(o,u){return sn(o,Y0(o),u)}function Vo(o,u){return function(_,D){var A=Ie(_)?cD:Fb,T=u?u():{};return A(_,o,Ae(D,2),T)}}function ki(o){return Pe(function(u,_){var D=-1,A=_.length,T=A>1?_[A-1]:t,P=A>2?_[2]:t;for(T=o.length>3&&typeof T=="function"?(A--,T):t,P&&ir(_[0],_[1],P)&&(T=A<3?t:T,A=1),u=ht(u);++D<A;){var q=_[D];q&&o(u,q,D,T)}return u})}function T0(o,u){return function(_,D){if(_==null)return _;if(!cr(_))return o(_,D);for(var A=_.length,T=u?A:-1,P=ht(_);(u?T--:++T<A)&&D(P[T],T,P)!==!1;);return _}}function I0(o){return function(u,_,D){for(var A=-1,T=ht(u),P=D(u),q=P.length;q--;){var Y=P[o?q:++A];if(_(T[Y],Y,T)===!1)break}return u}}function oE(o,u,_){var D=u&w,A=vs(o);function T(){var P=this&&this!==Kt&&this instanceof T?A:o;return P.apply(D?_:this,arguments)}return T}function $0(o){return function(u){u=it(u);var _=Ii(u)?Zr(u):t,D=_?_[0]:u.charAt(0),A=_?Wn(_,1).join(""):u.slice(1);return D[o]()+A}}function Ui(o){return function(u){return Eu(Tp(Op(u).replace(Hw,"")),o,"")}}function vs(o){return function(){var u=arguments;switch(u.length){case 0:return new o;case 1:return new o(u[0]);case 2:return new o(u[0],u[1]);case 3:return new o(u[0],u[1],u[2]);case 4:return new o(u[0],u[1],u[2],u[3]);case 5:return new o(u[0],u[1],u[2],u[3],u[4]);case 6:return new o(u[0],u[1],u[2],u[3],u[4],u[5]);case 7:return new o(u[0],u[1],u[2],u[3],u[4],u[5],u[6])}var _=qi(o.prototype),D=o.apply(_,u);return Ct(D)?D:_}}function aE(o,u,_){var D=vs(o);function A(){for(var T=arguments.length,P=H(T),q=T,Y=Wi(A);q--;)P[q]=arguments[q];var ee=T<3&&P[0]!==Y&&P[T-1]!==Y?[]:Pn(P,Y);if(T-=ee.length,T<_)return q0(o,u,Zo,A.placeholder,t,P,ee,t,t,_-T);var te=this&&this!==Kt&&this instanceof A?D:o;return wr(te,this,P)}return A}function L0(o){return function(u,_,D){var A=ht(u);if(!cr(u)){var T=Ae(_,3);u=Wt(u),_=function(q){return T(A[q],q,A)}}var P=o(u,_,D);return P>-1?A[T?u[P]:P]:t}}function R0(o){return yn(function(u){var _=u.length,D=_,A=Ir.prototype.thru;for(o&&u.reverse();D--;){var T=u[D];if(typeof T!="function")throw new Tr(a);if(A&&!P&&Jo(T)=="wrapper")var P=new Ir([],!0)}for(D=P?D:_;++D<_;){T=u[D];var q=Jo(T),Y=q=="wrapper"?nl(T):t;Y&&al(Y[0])&&Y[1]==(M|b|x|S)&&!Y[4].length&&Y[9]==1?P=P[Jo(Y[0])].apply(P,Y[3]):P=T.length==1&&al(T)?P[q]():P.thru(T)}return function(){var ee=arguments,te=ee[0];if(P&&ee.length==1&&Ie(te))return P.plant(te).value();for(var oe=0,de=_?u[oe].apply(this,ee):te;++oe<_;)de=u[oe].call(this,de);return de}})}function Zo(o,u,_,D,A,T,P,q,Y,ee){var te=u&M,oe=u&w,de=u&v,ye=u&(b|N),Ce=u&I,Re=de?t:vs(o);function Fe(){for(var Ue=arguments.length,Ye=H(Ue),xr=Ue;xr--;)Ye[xr]=arguments[xr];if(ye)var sr=Wi(Fe),Ar=yD(Ye,sr);if(D&&(Ye=B0(Ye,D,A,ye)),T&&(Ye=O0(Ye,T,P,ye)),Ue-=Ar,ye&&Ue<ee){var Bt=Pn(Ye,sr);return q0(o,u,Zo,Fe.placeholder,_,Ye,Bt,q,Y,ee-Ue)}var Hr=oe?_:this,En=de?Hr[o]:o;return Ue=Ye.length,q?Ye=FE(Ye,q):Ce&&Ue>1&&Ye.reverse(),te&&Y<Ue&&(Ye.length=Y),this&&this!==Kt&&this instanceof Fe&&(En=Re||vs(En)),En.apply(Hr,Ye)}return Fe}function P0(o,u){return function(_,D){return $b(_,o,u(D),{})}}function Ko(o,u){return function(_,D){var A;if(_===t&&D===t)return u;if(_!==t&&(A=_),D!==t){if(A===t)return D;typeof _=="string"||typeof D=="string"?(_=br(_),D=br(D)):(_=E0(_),D=E0(D)),A=o(_,D)}return A}}function Qu(o){return yn(function(u){return u=Et(u,Dr(Ae())),Pe(function(_){var D=this;return o(u,function(A){return wr(A,D,_)})})})}function Go(o,u){u=u===t?" ":br(u);var _=u.length;if(_<2)return _?Vu(u,o):u;var D=Vu(u,$o(o/$i(u)));return Ii(u)?Wn(Zr(D),0,o).join(""):D.slice(0,o)}function uE(o,u,_,D){var A=u&w,T=vs(o);function P(){for(var q=-1,Y=arguments.length,ee=-1,te=D.length,oe=H(te+Y),de=this&&this!==Kt&&this instanceof P?T:o;++ee<te;)oe[ee]=D[ee];for(;Y--;)oe[ee++]=arguments[++q];return wr(de,A?_:this,oe)}return P}function z0(o){return function(u,_,D){return D&&typeof D!="number"&&ir(u,_,D)&&(_=D=t),u=bn(u),_===t?(_=u,u=0):_=bn(_),D=D===t?u<_?1:-1:bn(D),Zb(u,_,D,o)}}function Ho(o){return function(u,_){return typeof u=="string"&&typeof _=="string"||(u=Pr(u),_=Pr(_)),o(u,_)}}function q0(o,u,_,D,A,T,P,q,Y,ee){var te=u&b,oe=te?P:t,de=te?t:P,ye=te?T:t,Ce=te?t:T;u|=te?x:F,u&=~(te?F:x),u&E||(u&=~(w|v));var Re=[o,u,A,ye,oe,Ce,de,q,Y,ee],Fe=_.apply(t,Re);return al(o)&&X0(Fe,Re),Fe.placeholder=D,Q0(Fe,o,u)}function el(o){var u=qt[o];return function(_,D){if(_=Pr(_),D=D==null?0:Qt(Le(D),292),D&&Qh(_)){var A=(it(_)+"e").split("e"),T=u(A[0]+"e"+(+A[1]+D));return A=(it(T)+"e").split("e"),+(A[0]+"e"+(+A[1]-D))}return u(_)}}var lE=Pi&&1/Ao(new Pi([,-0]))[1]==K?function(o){return new Pi(o)}:bl;function k0(o){return function(u){var _=er(u);return _==Je?Su(u):_==gr?CD(u):vD(u,o(u))}}function vn(o,u,_,D,A,T,P,q){var Y=u&v;if(!Y&&typeof o!="function")throw new Tr(a);var ee=D?D.length:0;if(ee||(u&=~(x|F),D=A=t),P=P===t?P:kt(Le(P),0),q=q===t?q:Le(q),ee-=A?A.length:0,u&F){var te=D,oe=A;D=A=t}var de=Y?t:nl(o),ye=[o,u,_,D,A,te,oe,T,P,q];if(de&&xE(ye,de),o=ye[0],u=ye[1],_=ye[2],D=ye[3],A=ye[4],q=ye[9]=ye[9]===t?Y?0:o.length:kt(ye[9]-ee,0),!q&&u&(b|N)&&(u&=~(b|N)),!u||u==w)var Ce=oE(o,u,_);else u==b||u==N?Ce=aE(o,u,q):(u==x||u==(w|x))&&!A.length?Ce=uE(o,u,_,D):Ce=Zo.apply(t,ye);var Re=de?D0:X0;return Q0(Re(Ce,ye),o,u)}function U0(o,u,_,D){return o===t||Gr(o,Ri[_])&&!at.call(D,_)?u:o}function W0(o,u,_,D,A,T){return Ct(o)&&Ct(u)&&(T.set(u,o),Wo(o,u,t,W0,T),T.delete(u)),o}function cE(o){return Ds(o)?t:o}function j0(o,u,_,D,A,T){var P=_&y,q=o.length,Y=u.length;if(q!=Y&&!(P&&Y>q))return!1;var ee=T.get(o),te=T.get(u);if(ee&&te)return ee==u&&te==o;var oe=-1,de=!0,ye=_&m?new si:t;for(T.set(o,u),T.set(u,o);++oe<q;){var Ce=o[oe],Re=u[oe];if(D)var Fe=P?D(Re,Ce,oe,u,o,T):D(Ce,Re,oe,o,u,T);if(Fe!==t){if(Fe)continue;de=!1;break}if(ye){if(!xu(u,function(Ue,Ye){if(!as(ye,Ye)&&(Ce===Ue||A(Ce,Ue,_,D,T)))return ye.push(Ye)})){de=!1;break}}else if(!(Ce===Re||A(Ce,Re,_,D,T))){de=!1;break}}return T.delete(o),T.delete(u),de}function fE(o,u,_,D,A,T,P){switch(_){case re:if(o.byteLength!=u.byteLength||o.byteOffset!=u.byteOffset)return!1;o=o.buffer,u=u.buffer;case se:return!(o.byteLength!=u.byteLength||!T(new Bo(o),new Bo(u)));case ot:case Te:case $t:return Gr(+o,+u);case lt:return o.name==u.name&&o.message==u.message;case dn:case Tn:return o==u+"";case Je:var q=Su;case gr:var Y=D&y;if(q||(q=Ao),o.size!=u.size&&!Y)return!1;var ee=P.get(o);if(ee)return ee==u;D|=m,P.set(o,u);var te=j0(q(o),q(u),D,A,T,P);return P.delete(o),te;case $:if(hs)return hs.call(o)==hs.call(u)}return!1}function hE(o,u,_,D,A,T){var P=_&y,q=tl(o),Y=q.length,ee=tl(u),te=ee.length;if(Y!=te&&!P)return!1;for(var oe=Y;oe--;){var de=q[oe];if(!(P?de in u:at.call(u,de)))return!1}var ye=T.get(o),Ce=T.get(u);if(ye&&Ce)return ye==u&&Ce==o;var Re=!0;T.set(o,u),T.set(u,o);for(var Fe=P;++oe<Y;){de=q[oe];var Ue=o[de],Ye=u[de];if(D)var xr=P?D(Ye,Ue,de,u,o,T):D(Ue,Ye,de,o,u,T);if(!(xr===t?Ue===Ye||A(Ue,Ye,_,D,T):xr)){Re=!1;break}Fe||(Fe=de=="constructor")}if(Re&&!Fe){var sr=o.constructor,Ar=u.constructor;sr!=Ar&&"constructor"in o&&"constructor"in u&&!(typeof sr=="function"&&sr instanceof sr&&typeof Ar=="function"&&Ar instanceof Ar)&&(Re=!1)}return T.delete(o),T.delete(u),Re}function yn(o){return ll(H0(o,t,sp),o+"")}function tl(o){return c0(o,Wt,sl)}function rl(o){return c0(o,fr,Y0)}var nl=Ro?function(o){return Ro.get(o)}:bl;function Jo(o){for(var u=o.name+"",_=zi[u],D=at.call(zi,u)?_.length:0;D--;){var A=_[D],T=A.func;if(T==null||T==o)return A.name}return u}function Wi(o){var u=at.call(O,"placeholder")?O:o;return u.placeholder}function Ae(){var o=O.iteratee||wl;return o=o===wl?p0:o,arguments.length?o(arguments[0],arguments[1]):o}function Xo(o,u){var _=o.__data__;return wE(u)?_[typeof u=="string"?"string":"hash"]:_.map}function il(o){for(var u=Wt(o),_=u.length;_--;){var D=u[_],A=o[D];u[_]=[D,A,K0(A)]}return u}function ui(o,u){var _=ED(o,u);return h0(_)?_:t}function pE(o){var u=at.call(o,ni),_=o[ni];try{o[ni]=t;var D=!0}catch{}var A=No.call(o);return D&&(u?o[ni]=_:delete o[ni]),A}var sl=Ou?function(o){return o==null?[]:(o=ht(o),Ln(Ou(o),function(u){return Jh.call(o,u)}))}:El,Y0=Ou?function(o){for(var u=[];o;)Rn(u,sl(o)),o=Oo(o);return u}:El,er=nr;(Tu&&er(new Tu(new ArrayBuffer(1)))!=re||ls&&er(new ls)!=Je||Iu&&er(Iu.resolve())!=pn||Pi&&er(new Pi)!=gr||cs&&er(new cs)!=G)&&(er=function(o){var u=nr(o),_=u==Pt?o.constructor:t,D=_?li(_):"";if(D)switch(D){case GD:return re;case HD:return Je;case JD:return pn;case XD:return gr;case QD:return G}return u});function dE(o,u,_){for(var D=-1,A=_.length;++D<A;){var T=_[D],P=T.size;switch(T.type){case"drop":o+=P;break;case"dropRight":u-=P;break;case"take":u=Qt(u,o+P);break;case"takeRight":o=kt(o,u-P);break}}return{start:o,end:u}}function _E(o){var u=o.match(ru);return u?u[1].split(nu):[]}function V0(o,u,_){u=Un(u,o);for(var D=-1,A=u.length,T=!1;++D<A;){var P=on(u[D]);if(!(T=o!=null&&_(o,P)))break;o=o[P]}return T||++D!=A?T:(A=o==null?0:o.length,!!A&&sa(A)&&wn(P,A)&&(Ie(o)||ci(o)))}function mE(o){var u=o.length,_=new o.constructor(u);return u&&typeof o[0]=="string"&&at.call(o,"index")&&(_.index=o.index,_.input=o.input),_}function Z0(o){return typeof o.constructor=="function"&&!ys(o)?qi(Oo(o)):{}}function gE(o,u,_){var D=o.constructor;switch(u){case se:return Xu(o);case ot:case Te:return new D(+o);case re:return eE(o,_);case fe:case ue:case he:case ae:case Xe:case nt:case bt:case Ut:case zt:return N0(o,_);case Je:return new D;case $t:case Tn:return new D(o);case dn:return tE(o);case gr:return new D;case $:return rE(o)}}function vE(o,u){var _=u.length;if(!_)return o;var D=_-1;return u[D]=(_>1?"& ":"")+u[D],u=u.join(_>2?", ":" "),o.replace(tu,`{
|
9
|
+
/* [wrapped with `+u+`] */
|
10
|
+
`)}function yE(o){return Ie(o)||ci(o)||!!(Xh&&o&&o[Xh])}function wn(o,u){var _=typeof o;return u=u??Z,!!u&&(_=="number"||_!="symbol"&&hu.test(o))&&o>-1&&o%1==0&&o<u}function ir(o,u,_){if(!Ct(_))return!1;var D=typeof u;return(D=="number"?cr(_)&&wn(u,_.length):D=="string"&&u in _)?Gr(_[u],o):!1}function ol(o,u){if(Ie(o))return!1;var _=typeof o;return _=="number"||_=="symbol"||_=="boolean"||o==null||Er(o)?!0:Ja.test(o)||!Ha.test(o)||u!=null&&o in ht(u)}function wE(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function al(o){var u=Jo(o),_=O[u];if(typeof _!="function"||!(u in je.prototype))return!1;if(o===_)return!0;var D=nl(_);return!!D&&o===D[0]}function DE(o){return!!Kh&&Kh in o}var bE=Fo?Dn:xl;function ys(o){var u=o&&o.constructor,_=typeof u=="function"&&u.prototype||Ri;return o===_}function K0(o){return o===o&&!Ct(o)}function G0(o,u){return function(_){return _==null?!1:_[o]===u&&(u!==t||o in ht(_))}}function EE(o){var u=na(o,function(D){return _.size===p&&_.clear(),D}),_=u.cache;return u}function xE(o,u){var _=o[1],D=u[1],A=_|D,T=A<(w|v|M),P=D==M&&_==b||D==M&&_==S&&o[7].length<=u[8]||D==(M|S)&&u[7].length<=u[8]&&_==b;if(!(T||P))return o;D&w&&(o[2]=u[2],A|=_&w?0:E);var q=u[3];if(q){var Y=o[3];o[3]=Y?B0(Y,q,u[4]):q,o[4]=Y?Pn(o[3],h):u[4]}return q=u[5],q&&(Y=o[5],o[5]=Y?O0(Y,q,u[6]):q,o[6]=Y?Pn(o[5],h):u[6]),q=u[7],q&&(o[7]=q),D&M&&(o[8]=o[8]==null?u[8]:Qt(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=A,o}function AE(o){var u=[];if(o!=null)for(var _ in ht(o))u.push(_);return u}function CE(o){return No.call(o)}function H0(o,u,_){return u=kt(u===t?o.length-1:u,0),function(){for(var D=arguments,A=-1,T=kt(D.length-u,0),P=H(T);++A<T;)P[A]=D[u+A];A=-1;for(var q=H(u+1);++A<u;)q[A]=D[A];return q[u]=_(P),wr(o,this,q)}}function J0(o,u){return u.length<2?o:ai(o,Lr(u,0,-1))}function FE(o,u){for(var _=o.length,D=Qt(u.length,_),A=lr(o);D--;){var T=u[D];o[D]=wn(T,_)?A[T]:t}return o}function ul(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var X0=ep(D0),ws=UD||function(o,u){return Kt.setTimeout(o,u)},ll=ep(Hb);function Q0(o,u,_){var D=u+"";return ll(o,vE(D,ME(_E(D),_)))}function ep(o){var u=0,_=0;return function(){var D=VD(),A=U-(D-_);if(_=D,A>0){if(++u>=L)return arguments[0]}else u=0;return o.apply(t,arguments)}}function Qo(o,u){var _=-1,D=o.length,A=D-1;for(u=u===t?D:u;++_<u;){var T=Yu(_,A),P=o[T];o[T]=o[_],o[_]=P}return o.length=u,o}var tp=EE(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(Xa,function(_,D,A,T){u.push(A?T.replace(ou,"$1"):D||_)}),u});function on(o){if(typeof o=="string"||Er(o))return o;var u=o+"";return u=="0"&&1/o==-K?"-0":u}function li(o){if(o!=null){try{return Mo.call(o)}catch{}try{return o+""}catch{}}return""}function ME(o,u){return Or(we,function(_){var D="_."+_[0];u&_[1]&&!Eo(o,D)&&o.push(D)}),o.sort()}function rp(o){if(o instanceof je)return o.clone();var u=new Ir(o.__wrapped__,o.__chain__);return u.__actions__=lr(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function NE(o,u,_){(_?ir(o,u,_):u===t)?u=1:u=kt(Le(u),0);var D=o==null?0:o.length;if(!D||u<1)return[];for(var A=0,T=0,P=H($o(D/u));A<D;)P[T++]=Lr(o,A,A+=u);return P}function SE(o){for(var u=-1,_=o==null?0:o.length,D=0,A=[];++u<_;){var T=o[u];T&&(A[D++]=T)}return A}function BE(){var o=arguments.length;if(!o)return[];for(var u=H(o-1),_=arguments[0],D=o;D--;)u[D-1]=arguments[D];return Rn(Ie(_)?lr(_):[_],Gt(u,1))}var OE=Pe(function(o,u){return St(o)?ds(o,Gt(u,1,St,!0)):[]}),TE=Pe(function(o,u){var _=Rr(u);return St(_)&&(_=t),St(o)?ds(o,Gt(u,1,St,!0),Ae(_,2)):[]}),IE=Pe(function(o,u){var _=Rr(u);return St(_)&&(_=t),St(o)?ds(o,Gt(u,1,St,!0),t,_):[]});function $E(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===t?1:Le(u),Lr(o,u<0?0:u,D)):[]}function LE(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===t?1:Le(u),u=D-u,Lr(o,0,u<0?0:u)):[]}function RE(o,u){return o&&o.length?Yo(o,Ae(u,3),!0,!0):[]}function PE(o,u){return o&&o.length?Yo(o,Ae(u,3),!0):[]}function zE(o,u,_,D){var A=o==null?0:o.length;return A?(_&&typeof _!="number"&&ir(o,u,_)&&(_=0,D=A),Bb(o,u,_,D)):[]}function np(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=_==null?0:Le(_);return A<0&&(A=kt(D+A,0)),xo(o,Ae(u,3),A)}function ip(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=D-1;return _!==t&&(A=Le(_),A=_<0?kt(D+A,0):Qt(A,D-1)),xo(o,Ae(u,3),A,!0)}function sp(o){var u=o==null?0:o.length;return u?Gt(o,1):[]}function qE(o){var u=o==null?0:o.length;return u?Gt(o,K):[]}function kE(o,u){var _=o==null?0:o.length;return _?(u=u===t?1:Le(u),Gt(o,u)):[]}function UE(o){for(var u=-1,_=o==null?0:o.length,D={};++u<_;){var A=o[u];D[A[0]]=A[1]}return D}function op(o){return o&&o.length?o[0]:t}function WE(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=_==null?0:Le(_);return A<0&&(A=kt(D+A,0)),Ti(o,u,A)}function jE(o){var u=o==null?0:o.length;return u?Lr(o,0,-1):[]}var YE=Pe(function(o){var u=Et(o,Hu);return u.length&&u[0]===o[0]?qu(u):[]}),VE=Pe(function(o){var u=Rr(o),_=Et(o,Hu);return u===Rr(_)?u=t:_.pop(),_.length&&_[0]===o[0]?qu(_,Ae(u,2)):[]}),ZE=Pe(function(o){var u=Rr(o),_=Et(o,Hu);return u=typeof u=="function"?u:t,u&&_.pop(),_.length&&_[0]===o[0]?qu(_,t,u):[]});function KE(o,u){return o==null?"":jD.call(o,u)}function Rr(o){var u=o==null?0:o.length;return u?o[u-1]:t}function GE(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var A=D;return _!==t&&(A=Le(_),A=A<0?kt(D+A,0):Qt(A,D-1)),u===u?MD(o,u,A):xo(o,qh,A,!0)}function HE(o,u){return o&&o.length?g0(o,Le(u)):t}var JE=Pe(ap);function ap(o,u){return o&&o.length&&u&&u.length?ju(o,u):o}function XE(o,u,_){return o&&o.length&&u&&u.length?ju(o,u,Ae(_,2)):o}function QE(o,u,_){return o&&o.length&&u&&u.length?ju(o,u,t,_):o}var ex=yn(function(o,u){var _=o==null?0:o.length,D=Lu(o,u);return w0(o,Et(u,function(A){return wn(A,_)?+A:A}).sort(S0)),D});function tx(o,u){var _=[];if(!(o&&o.length))return _;var D=-1,A=[],T=o.length;for(u=Ae(u,3);++D<T;){var P=o[D];u(P,D,o)&&(_.push(P),A.push(D))}return w0(o,A),_}function cl(o){return o==null?o:KD.call(o)}function rx(o,u,_){var D=o==null?0:o.length;return D?(_&&typeof _!="number"&&ir(o,u,_)?(u=0,_=D):(u=u==null?0:Le(u),_=_===t?D:Le(_)),Lr(o,u,_)):[]}function nx(o,u){return jo(o,u)}function ix(o,u,_){return Zu(o,u,Ae(_,2))}function sx(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u);if(D<_&&Gr(o[D],u))return D}return-1}function ox(o,u){return jo(o,u,!0)}function ax(o,u,_){return Zu(o,u,Ae(_,2),!0)}function ux(o,u){var _=o==null?0:o.length;if(_){var D=jo(o,u,!0)-1;if(Gr(o[D],u))return D}return-1}function lx(o){return o&&o.length?b0(o):[]}function cx(o,u){return o&&o.length?b0(o,Ae(u,2)):[]}function fx(o){var u=o==null?0:o.length;return u?Lr(o,1,u):[]}function hx(o,u,_){return o&&o.length?(u=_||u===t?1:Le(u),Lr(o,0,u<0?0:u)):[]}function px(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===t?1:Le(u),u=D-u,Lr(o,u<0?0:u,D)):[]}function dx(o,u){return o&&o.length?Yo(o,Ae(u,3),!1,!0):[]}function _x(o,u){return o&&o.length?Yo(o,Ae(u,3)):[]}var mx=Pe(function(o){return kn(Gt(o,1,St,!0))}),gx=Pe(function(o){var u=Rr(o);return St(u)&&(u=t),kn(Gt(o,1,St,!0),Ae(u,2))}),vx=Pe(function(o){var u=Rr(o);return u=typeof u=="function"?u:t,kn(Gt(o,1,St,!0),t,u)});function yx(o){return o&&o.length?kn(o):[]}function wx(o,u){return o&&o.length?kn(o,Ae(u,2)):[]}function Dx(o,u){return u=typeof u=="function"?u:t,o&&o.length?kn(o,t,u):[]}function fl(o){if(!(o&&o.length))return[];var u=0;return o=Ln(o,function(_){if(St(_))return u=kt(_.length,u),!0}),Mu(u,function(_){return Et(o,Au(_))})}function up(o,u){if(!(o&&o.length))return[];var _=fl(o);return u==null?_:Et(_,function(D){return wr(u,t,D)})}var bx=Pe(function(o,u){return St(o)?ds(o,u):[]}),Ex=Pe(function(o){return Gu(Ln(o,St))}),xx=Pe(function(o){var u=Rr(o);return St(u)&&(u=t),Gu(Ln(o,St),Ae(u,2))}),Ax=Pe(function(o){var u=Rr(o);return u=typeof u=="function"?u:t,Gu(Ln(o,St),t,u)}),Cx=Pe(fl);function Fx(o,u){return C0(o||[],u||[],ps)}function Mx(o,u){return C0(o||[],u||[],gs)}var Nx=Pe(function(o){var u=o.length,_=u>1?o[u-1]:t;return _=typeof _=="function"?(o.pop(),_):t,up(o,_)});function lp(o){var u=O(o);return u.__chain__=!0,u}function Sx(o,u){return u(o),o}function ea(o,u){return u(o)}var Bx=yn(function(o){var u=o.length,_=u?o[0]:0,D=this.__wrapped__,A=function(T){return Lu(T,o)};return u>1||this.__actions__.length||!(D instanceof je)||!wn(_)?this.thru(A):(D=D.slice(_,+_+(u?1:0)),D.__actions__.push({func:ea,args:[A],thisArg:t}),new Ir(D,this.__chain__).thru(function(T){return u&&!T.length&&T.push(t),T}))});function Ox(){return lp(this)}function Tx(){return new Ir(this.value(),this.__chain__)}function Ix(){this.__values__===t&&(this.__values__=Ep(this.value()));var o=this.__index__>=this.__values__.length,u=o?t:this.__values__[this.__index__++];return{done:o,value:u}}function $x(){return this}function Lx(o){for(var u,_=this;_ instanceof zo;){var D=rp(_);D.__index__=0,D.__values__=t,u?A.__wrapped__=D:u=D;var A=D;_=_.__wrapped__}return A.__wrapped__=o,u}function Rx(){var o=this.__wrapped__;if(o instanceof je){var u=o;return this.__actions__.length&&(u=new je(this)),u=u.reverse(),u.__actions__.push({func:ea,args:[cl],thisArg:t}),new Ir(u,this.__chain__)}return this.thru(cl)}function Px(){return A0(this.__wrapped__,this.__actions__)}var zx=Vo(function(o,u,_){at.call(o,_)?++o[_]:gn(o,_,1)});function qx(o,u,_){var D=Ie(o)?Ph:Sb;return _&&ir(o,u,_)&&(u=t),D(o,Ae(u,3))}function kx(o,u){var _=Ie(o)?Ln:u0;return _(o,Ae(u,3))}var Ux=L0(np),Wx=L0(ip);function jx(o,u){return Gt(ta(o,u),1)}function Yx(o,u){return Gt(ta(o,u),K)}function Vx(o,u,_){return _=_===t?1:Le(_),Gt(ta(o,u),_)}function cp(o,u){var _=Ie(o)?Or:qn;return _(o,Ae(u,3))}function fp(o,u){var _=Ie(o)?fD:a0;return _(o,Ae(u,3))}var Zx=Vo(function(o,u,_){at.call(o,_)?o[_].push(u):gn(o,_,[u])});function Kx(o,u,_,D){o=cr(o)?o:Yi(o),_=_&&!D?Le(_):0;var A=o.length;return _<0&&(_=kt(A+_,0)),oa(o)?_<=A&&o.indexOf(u,_)>-1:!!A&&Ti(o,u,_)>-1}var Gx=Pe(function(o,u,_){var D=-1,A=typeof u=="function",T=cr(o)?H(o.length):[];return qn(o,function(P){T[++D]=A?wr(u,P,_):_s(P,u,_)}),T}),Hx=Vo(function(o,u,_){gn(o,_,u)});function ta(o,u){var _=Ie(o)?Et:d0;return _(o,Ae(u,3))}function Jx(o,u,_,D){return o==null?[]:(Ie(u)||(u=u==null?[]:[u]),_=D?t:_,Ie(_)||(_=_==null?[]:[_]),v0(o,u,_))}var Xx=Vo(function(o,u,_){o[_?0:1].push(u)},function(){return[[],[]]});function Qx(o,u,_){var D=Ie(o)?Eu:Uh,A=arguments.length<3;return D(o,Ae(u,4),_,A,qn)}function eA(o,u,_){var D=Ie(o)?hD:Uh,A=arguments.length<3;return D(o,Ae(u,4),_,A,a0)}function tA(o,u){var _=Ie(o)?Ln:u0;return _(o,ia(Ae(u,3)))}function rA(o){var u=Ie(o)?n0:Kb;return u(o)}function nA(o,u,_){(_?ir(o,u,_):u===t)?u=1:u=Le(u);var D=Ie(o)?Ab:Gb;return D(o,u)}function iA(o){var u=Ie(o)?Cb:Jb;return u(o)}function sA(o){if(o==null)return 0;if(cr(o))return oa(o)?$i(o):o.length;var u=er(o);return u==Je||u==gr?o.size:Uu(o).length}function oA(o,u,_){var D=Ie(o)?xu:Xb;return _&&ir(o,u,_)&&(u=t),D(o,Ae(u,3))}var aA=Pe(function(o,u){if(o==null)return[];var _=u.length;return _>1&&ir(o,u[0],u[1])?u=[]:_>2&&ir(u[0],u[1],u[2])&&(u=[u[0]]),v0(o,Gt(u,1),[])}),ra=kD||function(){return Kt.Date.now()};function uA(o,u){if(typeof u!="function")throw new Tr(a);return o=Le(o),function(){if(--o<1)return u.apply(this,arguments)}}function hp(o,u,_){return u=_?t:u,u=o&&u==null?o.length:u,vn(o,M,t,t,t,t,u)}function pp(o,u){var _;if(typeof u!="function")throw new Tr(a);return o=Le(o),function(){return--o>0&&(_=u.apply(this,arguments)),o<=1&&(u=t),_}}var hl=Pe(function(o,u,_){var D=w;if(_.length){var A=Pn(_,Wi(hl));D|=x}return vn(o,D,u,_,A)}),dp=Pe(function(o,u,_){var D=w|v;if(_.length){var A=Pn(_,Wi(dp));D|=x}return vn(u,D,o,_,A)});function _p(o,u,_){u=_?t:u;var D=vn(o,b,t,t,t,t,t,u);return D.placeholder=_p.placeholder,D}function mp(o,u,_){u=_?t:u;var D=vn(o,N,t,t,t,t,t,u);return D.placeholder=mp.placeholder,D}function gp(o,u,_){var D,A,T,P,q,Y,ee=0,te=!1,oe=!1,de=!0;if(typeof o!="function")throw new Tr(a);u=Pr(u)||0,Ct(_)&&(te=!!_.leading,oe="maxWait"in _,T=oe?kt(Pr(_.maxWait)||0,u):T,de="trailing"in _?!!_.trailing:de);function ye(Bt){var Hr=D,En=A;return D=A=t,ee=Bt,P=o.apply(En,Hr),P}function Ce(Bt){return ee=Bt,q=ws(Ue,u),te?ye(Bt):P}function Re(Bt){var Hr=Bt-Y,En=Bt-ee,Lp=u-Hr;return oe?Qt(Lp,T-En):Lp}function Fe(Bt){var Hr=Bt-Y,En=Bt-ee;return Y===t||Hr>=u||Hr<0||oe&&En>=T}function Ue(){var Bt=ra();if(Fe(Bt))return Ye(Bt);q=ws(Ue,Re(Bt))}function Ye(Bt){return q=t,de&&D?ye(Bt):(D=A=t,P)}function xr(){q!==t&&F0(q),ee=0,D=Y=A=q=t}function sr(){return q===t?P:Ye(ra())}function Ar(){var Bt=ra(),Hr=Fe(Bt);if(D=arguments,A=this,Y=Bt,Hr){if(q===t)return Ce(Y);if(oe)return F0(q),q=ws(Ue,u),ye(Y)}return q===t&&(q=ws(Ue,u)),P}return Ar.cancel=xr,Ar.flush=sr,Ar}var lA=Pe(function(o,u){return o0(o,1,u)}),cA=Pe(function(o,u,_){return o0(o,Pr(u)||0,_)});function fA(o){return vn(o,I)}function na(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new Tr(a);var _=function(){var D=arguments,A=u?u.apply(this,D):D[0],T=_.cache;if(T.has(A))return T.get(A);var P=o.apply(this,D);return _.cache=T.set(A,P)||T,P};return _.cache=new(na.Cache||mn),_}na.Cache=mn;function ia(o){if(typeof o!="function")throw new Tr(a);return function(){var u=arguments;switch(u.length){case 0:return!o.call(this);case 1:return!o.call(this,u[0]);case 2:return!o.call(this,u[0],u[1]);case 3:return!o.call(this,u[0],u[1],u[2])}return!o.apply(this,u)}}function hA(o){return pp(2,o)}var pA=Qb(function(o,u){u=u.length==1&&Ie(u[0])?Et(u[0],Dr(Ae())):Et(Gt(u,1),Dr(Ae()));var _=u.length;return Pe(function(D){for(var A=-1,T=Qt(D.length,_);++A<T;)D[A]=u[A].call(this,D[A]);return wr(o,this,D)})}),pl=Pe(function(o,u){var _=Pn(u,Wi(pl));return vn(o,x,t,u,_)}),vp=Pe(function(o,u){var _=Pn(u,Wi(vp));return vn(o,F,t,u,_)}),dA=yn(function(o,u){return vn(o,S,t,t,t,u)});function _A(o,u){if(typeof o!="function")throw new Tr(a);return u=u===t?u:Le(u),Pe(o,u)}function mA(o,u){if(typeof o!="function")throw new Tr(a);return u=u==null?0:kt(Le(u),0),Pe(function(_){var D=_[u],A=Wn(_,0,u);return D&&Rn(A,D),wr(o,this,A)})}function gA(o,u,_){var D=!0,A=!0;if(typeof o!="function")throw new Tr(a);return Ct(_)&&(D="leading"in _?!!_.leading:D,A="trailing"in _?!!_.trailing:A),gp(o,u,{leading:D,maxWait:u,trailing:A})}function vA(o){return hp(o,1)}function yA(o,u){return pl(Ju(u),o)}function wA(){if(!arguments.length)return[];var o=arguments[0];return Ie(o)?o:[o]}function DA(o){return $r(o,g)}function bA(o,u){return u=typeof u=="function"?u:t,$r(o,g,u)}function EA(o){return $r(o,f|g)}function xA(o,u){return u=typeof u=="function"?u:t,$r(o,f|g,u)}function AA(o,u){return u==null||s0(o,u,Wt(u))}function Gr(o,u){return o===u||o!==o&&u!==u}var CA=Ho(zu),FA=Ho(function(o,u){return o>=u}),ci=f0(function(){return arguments}())?f0:function(o){return Ft(o)&&at.call(o,"callee")&&!Jh.call(o,"callee")},Ie=H.isArray,MA=Oh?Dr(Oh):Lb;function cr(o){return o!=null&&sa(o.length)&&!Dn(o)}function St(o){return Ft(o)&&cr(o)}function NA(o){return o===!0||o===!1||Ft(o)&&nr(o)==ot}var jn=WD||xl,SA=Th?Dr(Th):Rb;function BA(o){return Ft(o)&&o.nodeType===1&&!Ds(o)}function OA(o){if(o==null)return!0;if(cr(o)&&(Ie(o)||typeof o=="string"||typeof o.splice=="function"||jn(o)||ji(o)||ci(o)))return!o.length;var u=er(o);if(u==Je||u==gr)return!o.size;if(ys(o))return!Uu(o).length;for(var _ in o)if(at.call(o,_))return!1;return!0}function TA(o,u){return ms(o,u)}function IA(o,u,_){_=typeof _=="function"?_:t;var D=_?_(o,u):t;return D===t?ms(o,u,t,_):!!D}function dl(o){if(!Ft(o))return!1;var u=nr(o);return u==lt||u==Ne||typeof o.message=="string"&&typeof o.name=="string"&&!Ds(o)}function $A(o){return typeof o=="number"&&Qh(o)}function Dn(o){if(!Ct(o))return!1;var u=nr(o);return u==rt||u==ke||u==Ee||u==On}function yp(o){return typeof o=="number"&&o==Le(o)}function sa(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Z}function Ct(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function Ft(o){return o!=null&&typeof o=="object"}var wp=Ih?Dr(Ih):zb;function LA(o,u){return o===u||ku(o,u,il(u))}function RA(o,u,_){return _=typeof _=="function"?_:t,ku(o,u,il(u),_)}function PA(o){return Dp(o)&&o!=+o}function zA(o){if(bE(o))throw new Oe(i);return h0(o)}function qA(o){return o===null}function kA(o){return o==null}function Dp(o){return typeof o=="number"||Ft(o)&&nr(o)==$t}function Ds(o){if(!Ft(o)||nr(o)!=Pt)return!1;var u=Oo(o);if(u===null)return!0;var _=at.call(u,"constructor")&&u.constructor;return typeof _=="function"&&_ instanceof _&&Mo.call(_)==RD}var _l=$h?Dr($h):qb;function UA(o){return yp(o)&&o>=-Z&&o<=Z}var bp=Lh?Dr(Lh):kb;function oa(o){return typeof o=="string"||!Ie(o)&&Ft(o)&&nr(o)==Tn}function Er(o){return typeof o=="symbol"||Ft(o)&&nr(o)==$}var ji=Rh?Dr(Rh):Ub;function WA(o){return o===t}function jA(o){return Ft(o)&&er(o)==G}function YA(o){return Ft(o)&&nr(o)==ne}var VA=Ho(Wu),ZA=Ho(function(o,u){return o<=u});function Ep(o){if(!o)return[];if(cr(o))return oa(o)?Zr(o):lr(o);if(us&&o[us])return AD(o[us]());var u=er(o),_=u==Je?Su:u==gr?Ao:Yi;return _(o)}function bn(o){if(!o)return o===0?o:0;if(o=Pr(o),o===K||o===-K){var u=o<0?-1:1;return u*X}return o===o?o:0}function Le(o){var u=bn(o),_=u%1;return u===u?_?u-_:u:0}function xp(o){return o?oi(Le(o),0,ce):0}function Pr(o){if(typeof o=="number")return o;if(Er(o))return Q;if(Ct(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=Ct(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=Wh(o);var _=lu.test(o);return _||fu.test(o)?uD(o.slice(2),_?2:8):uu.test(o)?Q:+o}function Ap(o){return sn(o,fr(o))}function KA(o){return o?oi(Le(o),-Z,Z):o===0?o:0}function it(o){return o==null?"":br(o)}var GA=ki(function(o,u){if(ys(u)||cr(u)){sn(u,Wt(u),o);return}for(var _ in u)at.call(u,_)&&ps(o,_,u[_])}),Cp=ki(function(o,u){sn(u,fr(u),o)}),aa=ki(function(o,u,_,D){sn(u,fr(u),o,D)}),HA=ki(function(o,u,_,D){sn(u,Wt(u),o,D)}),JA=yn(Lu);function XA(o,u){var _=qi(o);return u==null?_:i0(_,u)}var QA=Pe(function(o,u){o=ht(o);var _=-1,D=u.length,A=D>2?u[2]:t;for(A&&ir(u[0],u[1],A)&&(D=1);++_<D;)for(var T=u[_],P=fr(T),q=-1,Y=P.length;++q<Y;){var ee=P[q],te=o[ee];(te===t||Gr(te,Ri[ee])&&!at.call(o,ee))&&(o[ee]=T[ee])}return o}),eC=Pe(function(o){return o.push(t,W0),wr(Fp,t,o)});function tC(o,u){return zh(o,Ae(u,3),nn)}function rC(o,u){return zh(o,Ae(u,3),Pu)}function nC(o,u){return o==null?o:Ru(o,Ae(u,3),fr)}function iC(o,u){return o==null?o:l0(o,Ae(u,3),fr)}function sC(o,u){return o&&nn(o,Ae(u,3))}function oC(o,u){return o&&Pu(o,Ae(u,3))}function aC(o){return o==null?[]:Uo(o,Wt(o))}function uC(o){return o==null?[]:Uo(o,fr(o))}function ml(o,u,_){var D=o==null?t:ai(o,u);return D===t?_:D}function lC(o,u){return o!=null&&V0(o,u,Ob)}function gl(o,u){return o!=null&&V0(o,u,Tb)}var cC=P0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),o[u]=_},yl(hr)),fC=P0(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=No.call(u)),at.call(o,u)?o[u].push(_):o[u]=[_]},Ae),hC=Pe(_s);function Wt(o){return cr(o)?r0(o):Uu(o)}function fr(o){return cr(o)?r0(o,!0):Wb(o)}function pC(o,u){var _={};return u=Ae(u,3),nn(o,function(D,A,T){gn(_,u(D,A,T),D)}),_}function dC(o,u){var _={};return u=Ae(u,3),nn(o,function(D,A,T){gn(_,A,u(D,A,T))}),_}var _C=ki(function(o,u,_){Wo(o,u,_)}),Fp=ki(function(o,u,_,D){Wo(o,u,_,D)}),mC=yn(function(o,u){var _={};if(o==null)return _;var D=!1;u=Et(u,function(T){return T=Un(T,o),D||(D=T.length>1),T}),sn(o,rl(o),_),D&&(_=$r(_,f|d|g,cE));for(var A=u.length;A--;)Ku(_,u[A]);return _});function gC(o,u){return Mp(o,ia(Ae(u)))}var vC=yn(function(o,u){return o==null?{}:Yb(o,u)});function Mp(o,u){if(o==null)return{};var _=Et(rl(o),function(D){return[D]});return u=Ae(u),y0(o,_,function(D,A){return u(D,A[0])})}function yC(o,u,_){u=Un(u,o);var D=-1,A=u.length;for(A||(A=1,o=t);++D<A;){var T=o==null?t:o[on(u[D])];T===t&&(D=A,T=_),o=Dn(T)?T.call(o):T}return o}function wC(o,u,_){return o==null?o:gs(o,u,_)}function DC(o,u,_,D){return D=typeof D=="function"?D:t,o==null?o:gs(o,u,_,D)}var Np=k0(Wt),Sp=k0(fr);function bC(o,u,_){var D=Ie(o),A=D||jn(o)||ji(o);if(u=Ae(u,4),_==null){var T=o&&o.constructor;A?_=D?new T:[]:Ct(o)?_=Dn(T)?qi(Oo(o)):{}:_={}}return(A?Or:nn)(o,function(P,q,Y){return u(_,P,q,Y)}),_}function EC(o,u){return o==null?!0:Ku(o,u)}function xC(o,u,_){return o==null?o:x0(o,u,Ju(_))}function AC(o,u,_,D){return D=typeof D=="function"?D:t,o==null?o:x0(o,u,Ju(_),D)}function Yi(o){return o==null?[]:Nu(o,Wt(o))}function CC(o){return o==null?[]:Nu(o,fr(o))}function FC(o,u,_){return _===t&&(_=u,u=t),_!==t&&(_=Pr(_),_=_===_?_:0),u!==t&&(u=Pr(u),u=u===u?u:0),oi(Pr(o),u,_)}function MC(o,u,_){return u=bn(u),_===t?(_=u,u=0):_=bn(_),o=Pr(o),Ib(o,u,_)}function NC(o,u,_){if(_&&typeof _!="boolean"&&ir(o,u,_)&&(u=_=t),_===t&&(typeof u=="boolean"?(_=u,u=t):typeof o=="boolean"&&(_=o,o=t)),o===t&&u===t?(o=0,u=1):(o=bn(o),u===t?(u=o,o=0):u=bn(u)),o>u){var D=o;o=u,u=D}if(_||o%1||u%1){var A=e0();return Qt(o+A*(u-o+aD("1e-"+((A+"").length-1))),u)}return Yu(o,u)}var SC=Ui(function(o,u,_){return u=u.toLowerCase(),o+(_?Bp(u):u)});function Bp(o){return vl(it(o).toLowerCase())}function Op(o){return o=it(o),o&&o.replace(pu,wD).replace(Jw,"")}function BC(o,u,_){o=it(o),u=br(u);var D=o.length;_=_===t?D:oi(Le(_),0,D);var A=_;return _-=u.length,_>=0&&o.slice(_,A)==u}function OC(o){return o=it(o),o&&Za.test(o)?o.replace(vo,DD):o}function TC(o){return o=it(o),o&&Qa.test(o)?o.replace(ss,"\\$&"):o}var IC=Ui(function(o,u,_){return o+(_?"-":"")+u.toLowerCase()}),$C=Ui(function(o,u,_){return o+(_?" ":"")+u.toLowerCase()}),LC=$0("toLowerCase");function RC(o,u,_){o=it(o),u=Le(u);var D=u?$i(o):0;if(!u||D>=u)return o;var A=(u-D)/2;return Go(Lo(A),_)+o+Go($o(A),_)}function PC(o,u,_){o=it(o),u=Le(u);var D=u?$i(o):0;return u&&D<u?o+Go(u-D,_):o}function zC(o,u,_){o=it(o),u=Le(u);var D=u?$i(o):0;return u&&D<u?Go(u-D,_)+o:o}function qC(o,u,_){return _||u==null?u=0:u&&(u=+u),ZD(it(o).replace(os,""),u||0)}function kC(o,u,_){return(_?ir(o,u,_):u===t)?u=1:u=Le(u),Vu(it(o),u)}function UC(){var o=arguments,u=it(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var WC=Ui(function(o,u,_){return o+(_?"_":"")+u.toLowerCase()});function jC(o,u,_){return _&&typeof _!="number"&&ir(o,u,_)&&(u=_=t),_=_===t?ce:_>>>0,_?(o=it(o),o&&(typeof u=="string"||u!=null&&!_l(u))&&(u=br(u),!u&&Ii(o))?Wn(Zr(o),0,_):o.split(u,_)):[]}var YC=Ui(function(o,u,_){return o+(_?" ":"")+vl(u)});function VC(o,u,_){return o=it(o),_=_==null?0:oi(Le(_),0,o.length),u=br(u),o.slice(_,_+u.length)==u}function ZC(o,u,_){var D=O.templateSettings;_&&ir(o,u,_)&&(u=t),o=it(o),u=aa({},u,D,U0);var A=aa({},u.imports,D.imports,U0),T=Wt(A),P=Nu(A,T),q,Y,ee=0,te=u.interpolate||Si,oe="__p += '",de=Bu((u.escape||Si).source+"|"+te.source+"|"+(te===yo?au:Si).source+"|"+(u.evaluate||Si).source+"|$","g"),ye="//# sourceURL="+(at.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rD+"]")+`
|
11
|
+
`;o.replace(de,function(Fe,Ue,Ye,xr,sr,Ar){return Ye||(Ye=xr),oe+=o.slice(ee,Ar).replace(ti,bD),Ue&&(q=!0,oe+=`' +
|
12
|
+
__e(`+Ue+`) +
|
13
|
+
'`),sr&&(Y=!0,oe+=`';
|
14
|
+
`+sr+`;
|
15
|
+
__p += '`),Ye&&(oe+=`' +
|
16
|
+
((__t = (`+Ye+`)) == null ? '' : __t) +
|
17
|
+
'`),ee=Ar+Fe.length,Fe}),oe+=`';
|
18
|
+
`;var Ce=at.call(u,"variable")&&u.variable;if(!Ce)oe=`with (obj) {
|
19
|
+
`+oe+`
|
20
|
+
}
|
21
|
+
`;else if(su.test(Ce))throw new Oe(l);oe=(Y?oe.replace(vr,""):oe).replace(yr,"$1").replace(In,"$1;"),oe="function("+(Ce||"obj")+`) {
|
22
|
+
`+(Ce?"":`obj || (obj = {});
|
23
|
+
`)+"var __t, __p = ''"+(q?", __e = _.escape":"")+(Y?`, __j = Array.prototype.join;
|
24
|
+
function print() { __p += __j.call(arguments, '') }
|
25
|
+
`:`;
|
26
|
+
`)+oe+`return __p
|
27
|
+
}`;var Re=Ip(function(){return et(T,ye+"return "+oe).apply(t,P)});if(Re.source=oe,dl(Re))throw Re;return Re}function KC(o){return it(o).toLowerCase()}function GC(o){return it(o).toUpperCase()}function HC(o,u,_){if(o=it(o),o&&(_||u===t))return Wh(o);if(!o||!(u=br(u)))return o;var D=Zr(o),A=Zr(u),T=jh(D,A),P=Yh(D,A)+1;return Wn(D,T,P).join("")}function JC(o,u,_){if(o=it(o),o&&(_||u===t))return o.slice(0,Zh(o)+1);if(!o||!(u=br(u)))return o;var D=Zr(o),A=Yh(D,Zr(u))+1;return Wn(D,0,A).join("")}function XC(o,u,_){if(o=it(o),o&&(_||u===t))return o.replace(os,"");if(!o||!(u=br(u)))return o;var D=Zr(o),A=jh(D,Zr(u));return Wn(D,A).join("")}function QC(o,u){var _=C,D=B;if(Ct(u)){var A="separator"in u?u.separator:A;_="length"in u?Le(u.length):_,D="omission"in u?br(u.omission):D}o=it(o);var T=o.length;if(Ii(o)){var P=Zr(o);T=P.length}if(_>=T)return o;var q=_-$i(D);if(q<1)return D;var Y=P?Wn(P,0,q).join(""):o.slice(0,q);if(A===t)return Y+D;if(P&&(q+=Y.length-q),_l(A)){if(o.slice(q).search(A)){var ee,te=Y;for(A.global||(A=Bu(A.source,it(wo.exec(A))+"g")),A.lastIndex=0;ee=A.exec(te);)var oe=ee.index;Y=Y.slice(0,oe===t?q:oe)}}else if(o.indexOf(br(A),q)!=q){var de=Y.lastIndexOf(A);de>-1&&(Y=Y.slice(0,de))}return Y+D}function e2(o){return o=it(o),o&&Va.test(o)?o.replace(ei,ND):o}var t2=Ui(function(o,u,_){return o+(_?" ":"")+u.toUpperCase()}),vl=$0("toUpperCase");function Tp(o,u,_){return o=it(o),u=_?t:u,u===t?xD(o)?OD(o):_D(o):o.match(u)||[]}var Ip=Pe(function(o,u){try{return wr(o,t,u)}catch(_){return dl(_)?_:new Oe(_)}}),r2=yn(function(o,u){return Or(u,function(_){_=on(_),gn(o,_,hl(o[_],o))}),o});function n2(o){var u=o==null?0:o.length,_=Ae();return o=u?Et(o,function(D){if(typeof D[1]!="function")throw new Tr(a);return[_(D[0]),D[1]]}):[],Pe(function(D){for(var A=-1;++A<u;){var T=o[A];if(wr(T[0],this,D))return wr(T[1],this,D)}})}function i2(o){return Nb($r(o,f))}function yl(o){return function(){return o}}function s2(o,u){return o==null||o!==o?u:o}var o2=R0(),a2=R0(!0);function hr(o){return o}function wl(o){return p0(typeof o=="function"?o:$r(o,f))}function u2(o){return _0($r(o,f))}function l2(o,u){return m0(o,$r(u,f))}var c2=Pe(function(o,u){return function(_){return _s(_,o,u)}}),f2=Pe(function(o,u){return function(_){return _s(o,_,u)}});function Dl(o,u,_){var D=Wt(u),A=Uo(u,D);_==null&&!(Ct(u)&&(A.length||!D.length))&&(_=u,u=o,o=this,A=Uo(u,Wt(u)));var T=!(Ct(_)&&"chain"in _)||!!_.chain,P=Dn(o);return Or(A,function(q){var Y=u[q];o[q]=Y,P&&(o.prototype[q]=function(){var ee=this.__chain__;if(T||ee){var te=o(this.__wrapped__),oe=te.__actions__=lr(this.__actions__);return oe.push({func:Y,args:arguments,thisArg:o}),te.__chain__=ee,te}return Y.apply(o,Rn([this.value()],arguments))})}),o}function h2(){return Kt._===this&&(Kt._=PD),this}function bl(){}function p2(o){return o=Le(o),Pe(function(u){return g0(u,o)})}var d2=Qu(Et),_2=Qu(Ph),m2=Qu(xu);function $p(o){return ol(o)?Au(on(o)):Vb(o)}function g2(o){return function(u){return o==null?t:ai(o,u)}}var v2=z0(),y2=z0(!0);function El(){return[]}function xl(){return!1}function w2(){return{}}function D2(){return""}function b2(){return!0}function E2(o,u){if(o=Le(o),o<1||o>Z)return[];var _=ce,D=Qt(o,ce);u=Ae(u),o-=ce;for(var A=Mu(D,u);++_<o;)u(_);return A}function x2(o){return Ie(o)?Et(o,on):Er(o)?[o]:lr(tp(it(o)))}function A2(o){var u=++LD;return it(o)+u}var C2=Ko(function(o,u){return o+u},0),F2=el("ceil"),M2=Ko(function(o,u){return o/u},1),N2=el("floor");function S2(o){return o&&o.length?ko(o,hr,zu):t}function B2(o,u){return o&&o.length?ko(o,Ae(u,2),zu):t}function O2(o){return kh(o,hr)}function T2(o,u){return kh(o,Ae(u,2))}function I2(o){return o&&o.length?ko(o,hr,Wu):t}function $2(o,u){return o&&o.length?ko(o,Ae(u,2),Wu):t}var L2=Ko(function(o,u){return o*u},1),R2=el("round"),P2=Ko(function(o,u){return o-u},0);function z2(o){return o&&o.length?Fu(o,hr):0}function q2(o,u){return o&&o.length?Fu(o,Ae(u,2)):0}return O.after=uA,O.ary=hp,O.assign=GA,O.assignIn=Cp,O.assignInWith=aa,O.assignWith=HA,O.at=JA,O.before=pp,O.bind=hl,O.bindAll=r2,O.bindKey=dp,O.castArray=wA,O.chain=lp,O.chunk=NE,O.compact=SE,O.concat=BE,O.cond=n2,O.conforms=i2,O.constant=yl,O.countBy=zx,O.create=XA,O.curry=_p,O.curryRight=mp,O.debounce=gp,O.defaults=QA,O.defaultsDeep=eC,O.defer=lA,O.delay=cA,O.difference=OE,O.differenceBy=TE,O.differenceWith=IE,O.drop=$E,O.dropRight=LE,O.dropRightWhile=RE,O.dropWhile=PE,O.fill=zE,O.filter=kx,O.flatMap=jx,O.flatMapDeep=Yx,O.flatMapDepth=Vx,O.flatten=sp,O.flattenDeep=qE,O.flattenDepth=kE,O.flip=fA,O.flow=o2,O.flowRight=a2,O.fromPairs=UE,O.functions=aC,O.functionsIn=uC,O.groupBy=Zx,O.initial=jE,O.intersection=YE,O.intersectionBy=VE,O.intersectionWith=ZE,O.invert=cC,O.invertBy=fC,O.invokeMap=Gx,O.iteratee=wl,O.keyBy=Hx,O.keys=Wt,O.keysIn=fr,O.map=ta,O.mapKeys=pC,O.mapValues=dC,O.matches=u2,O.matchesProperty=l2,O.memoize=na,O.merge=_C,O.mergeWith=Fp,O.method=c2,O.methodOf=f2,O.mixin=Dl,O.negate=ia,O.nthArg=p2,O.omit=mC,O.omitBy=gC,O.once=hA,O.orderBy=Jx,O.over=d2,O.overArgs=pA,O.overEvery=_2,O.overSome=m2,O.partial=pl,O.partialRight=vp,O.partition=Xx,O.pick=vC,O.pickBy=Mp,O.property=$p,O.propertyOf=g2,O.pull=JE,O.pullAll=ap,O.pullAllBy=XE,O.pullAllWith=QE,O.pullAt=ex,O.range=v2,O.rangeRight=y2,O.rearg=dA,O.reject=tA,O.remove=tx,O.rest=_A,O.reverse=cl,O.sampleSize=nA,O.set=wC,O.setWith=DC,O.shuffle=iA,O.slice=rx,O.sortBy=aA,O.sortedUniq=lx,O.sortedUniqBy=cx,O.split=jC,O.spread=mA,O.tail=fx,O.take=hx,O.takeRight=px,O.takeRightWhile=dx,O.takeWhile=_x,O.tap=Sx,O.throttle=gA,O.thru=ea,O.toArray=Ep,O.toPairs=Np,O.toPairsIn=Sp,O.toPath=x2,O.toPlainObject=Ap,O.transform=bC,O.unary=vA,O.union=mx,O.unionBy=gx,O.unionWith=vx,O.uniq=yx,O.uniqBy=wx,O.uniqWith=Dx,O.unset=EC,O.unzip=fl,O.unzipWith=up,O.update=xC,O.updateWith=AC,O.values=Yi,O.valuesIn=CC,O.without=bx,O.words=Tp,O.wrap=yA,O.xor=Ex,O.xorBy=xx,O.xorWith=Ax,O.zip=Cx,O.zipObject=Fx,O.zipObjectDeep=Mx,O.zipWith=Nx,O.entries=Np,O.entriesIn=Sp,O.extend=Cp,O.extendWith=aa,Dl(O,O),O.add=C2,O.attempt=Ip,O.camelCase=SC,O.capitalize=Bp,O.ceil=F2,O.clamp=FC,O.clone=DA,O.cloneDeep=EA,O.cloneDeepWith=xA,O.cloneWith=bA,O.conformsTo=AA,O.deburr=Op,O.defaultTo=s2,O.divide=M2,O.endsWith=BC,O.eq=Gr,O.escape=OC,O.escapeRegExp=TC,O.every=qx,O.find=Ux,O.findIndex=np,O.findKey=tC,O.findLast=Wx,O.findLastIndex=ip,O.findLastKey=rC,O.floor=N2,O.forEach=cp,O.forEachRight=fp,O.forIn=nC,O.forInRight=iC,O.forOwn=sC,O.forOwnRight=oC,O.get=ml,O.gt=CA,O.gte=FA,O.has=lC,O.hasIn=gl,O.head=op,O.identity=hr,O.includes=Kx,O.indexOf=WE,O.inRange=MC,O.invoke=hC,O.isArguments=ci,O.isArray=Ie,O.isArrayBuffer=MA,O.isArrayLike=cr,O.isArrayLikeObject=St,O.isBoolean=NA,O.isBuffer=jn,O.isDate=SA,O.isElement=BA,O.isEmpty=OA,O.isEqual=TA,O.isEqualWith=IA,O.isError=dl,O.isFinite=$A,O.isFunction=Dn,O.isInteger=yp,O.isLength=sa,O.isMap=wp,O.isMatch=LA,O.isMatchWith=RA,O.isNaN=PA,O.isNative=zA,O.isNil=kA,O.isNull=qA,O.isNumber=Dp,O.isObject=Ct,O.isObjectLike=Ft,O.isPlainObject=Ds,O.isRegExp=_l,O.isSafeInteger=UA,O.isSet=bp,O.isString=oa,O.isSymbol=Er,O.isTypedArray=ji,O.isUndefined=WA,O.isWeakMap=jA,O.isWeakSet=YA,O.join=KE,O.kebabCase=IC,O.last=Rr,O.lastIndexOf=GE,O.lowerCase=$C,O.lowerFirst=LC,O.lt=VA,O.lte=ZA,O.max=S2,O.maxBy=B2,O.mean=O2,O.meanBy=T2,O.min=I2,O.minBy=$2,O.stubArray=El,O.stubFalse=xl,O.stubObject=w2,O.stubString=D2,O.stubTrue=b2,O.multiply=L2,O.nth=HE,O.noConflict=h2,O.noop=bl,O.now=ra,O.pad=RC,O.padEnd=PC,O.padStart=zC,O.parseInt=qC,O.random=NC,O.reduce=Qx,O.reduceRight=eA,O.repeat=kC,O.replace=UC,O.result=yC,O.round=R2,O.runInContext=j,O.sample=rA,O.size=sA,O.snakeCase=WC,O.some=oA,O.sortedIndex=nx,O.sortedIndexBy=ix,O.sortedIndexOf=sx,O.sortedLastIndex=ox,O.sortedLastIndexBy=ax,O.sortedLastIndexOf=ux,O.startCase=YC,O.startsWith=VC,O.subtract=P2,O.sum=z2,O.sumBy=q2,O.template=ZC,O.times=E2,O.toFinite=bn,O.toInteger=Le,O.toLength=xp,O.toLower=KC,O.toNumber=Pr,O.toSafeInteger=KA,O.toString=it,O.toUpper=GC,O.trim=HC,O.trimEnd=JC,O.trimStart=XC,O.truncate=QC,O.unescape=e2,O.uniqueId=A2,O.upperCase=t2,O.upperFirst=vl,O.each=cp,O.eachRight=fp,O.first=op,Dl(O,function(){var o={};return nn(O,function(u,_){at.call(O.prototype,_)||(o[_]=u)}),o}(),{chain:!1}),O.VERSION=r,Or(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){O[o].placeholder=O}),Or(["drop","take"],function(o,u){je.prototype[o]=function(_){_=_===t?1:kt(Le(_),0);var D=this.__filtered__&&!u?new je(this):this.clone();return D.__filtered__?D.__takeCount__=Qt(_,D.__takeCount__):D.__views__.push({size:Qt(_,ce),type:o+(D.__dir__<0?"Right":"")}),D},je.prototype[o+"Right"]=function(_){return this.reverse()[o](_).reverse()}}),Or(["filter","map","takeWhile"],function(o,u){var _=u+1,D=_==k||_==z;je.prototype[o]=function(A){var T=this.clone();return T.__iteratees__.push({iteratee:Ae(A,3),type:_}),T.__filtered__=T.__filtered__||D,T}}),Or(["head","last"],function(o,u){var _="take"+(u?"Right":"");je.prototype[o]=function(){return this[_](1).value()[0]}}),Or(["initial","tail"],function(o,u){var _="drop"+(u?"":"Right");je.prototype[o]=function(){return this.__filtered__?new je(this):this[_](1)}}),je.prototype.compact=function(){return this.filter(hr)},je.prototype.find=function(o){return this.filter(o).head()},je.prototype.findLast=function(o){return this.reverse().find(o)},je.prototype.invokeMap=Pe(function(o,u){return typeof o=="function"?new je(this):this.map(function(_){return _s(_,o,u)})}),je.prototype.reject=function(o){return this.filter(ia(Ae(o)))},je.prototype.slice=function(o,u){o=Le(o);var _=this;return _.__filtered__&&(o>0||u<0)?new je(_):(o<0?_=_.takeRight(-o):o&&(_=_.drop(o)),u!==t&&(u=Le(u),_=u<0?_.dropRight(-u):_.take(u-o)),_)},je.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},je.prototype.toArray=function(){return this.take(ce)},nn(je.prototype,function(o,u){var _=/^(?:filter|find|map|reject)|While$/.test(u),D=/^(?:head|last)$/.test(u),A=O[D?"take"+(u=="last"?"Right":""):u],T=D||/^find/.test(u);A&&(O.prototype[u]=function(){var P=this.__wrapped__,q=D?[1]:arguments,Y=P instanceof je,ee=q[0],te=Y||Ie(P),oe=function(Ue){var Ye=A.apply(O,Rn([Ue],q));return D&&de?Ye[0]:Ye};te&&_&&typeof ee=="function"&&ee.length!=1&&(Y=te=!1);var de=this.__chain__,ye=!!this.__actions__.length,Ce=T&&!de,Re=Y&&!ye;if(!T&&te){P=Re?P:new je(this);var Fe=o.apply(P,q);return Fe.__actions__.push({func:ea,args:[oe],thisArg:t}),new Ir(Fe,de)}return Ce&&Re?o.apply(this,q):(Fe=this.thru(oe),Ce?D?Fe.value()[0]:Fe.value():Fe)})}),Or(["pop","push","shift","sort","splice","unshift"],function(o){var u=Co[o],_=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);O.prototype[o]=function(){var A=arguments;if(D&&!this.__chain__){var T=this.value();return u.apply(Ie(T)?T:[],A)}return this[_](function(P){return u.apply(Ie(P)?P:[],A)})}}),nn(je.prototype,function(o,u){var _=O[u];if(_){var D=_.name+"";at.call(zi,D)||(zi[D]=[]),zi[D].push({name:u,func:_})}}),zi[Zo(t,v).name]=[{name:"wrapper",func:t}],je.prototype.clone=eb,je.prototype.reverse=tb,je.prototype.value=rb,O.prototype.at=Bx,O.prototype.chain=Ox,O.prototype.commit=Tx,O.prototype.next=Ix,O.prototype.plant=Lx,O.prototype.reverse=Rx,O.prototype.toJSON=O.prototype.valueOf=O.prototype.value=Px,O.prototype.first=O.prototype.head,us&&(O.prototype[us]=$x),O},Li=TD();ri?((ri.exports=Li)._=Li,wu._=Li):Kt._=Li}).call(Ve)}(Yn,Yn.exports);var zr=Yn.exports;class Rp{constructor(e,t){R(this,"_defaultParams");R(this,"_UserTypeFileds");R(this,"_varipKeys");this._defaultParams=e,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=t}copy(e){return zr.cloneDeep(e)}new(e={}){return new this._UserTypeFileds(Object.assign(zr.cloneDeep(this._defaultParams),e),this._varipKeys)}addNewMethod(e,t){this._UserTypeFileds.prototype[e]=t}_createDynamicClass(){return class{constructor(e,t){R(this,"_varipKeys");Object.assign(this,e),this._varipKeys=t}get varipKeys(){return[...this._varipKeys]}copy(){return zr.cloneDeep(this)}}}}var Nl={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(Ve,function(){var t=1e3,r=6e4,n=36e5,i="millisecond",a="second",l="minute",c="hour",p="day",h="week",f="month",d="quarter",g="year",y="date",m="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,E={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(k){var W=["th","st","nd","rd"],z=k%100;return"["+k+(W[(z-20)%10]||W[z]||W[0])+"]"}},b=function(k,W,z){var K=String(k);return!K||K.length>=W?k:""+Array(W+1-K.length).join(z)+k},N={s:b,z:function(k){var W=-k.utcOffset(),z=Math.abs(W),K=Math.floor(z/60),Z=z%60;return(W<=0?"+":"-")+b(K,2,"0")+":"+b(Z,2,"0")},m:function k(W,z){if(W.date()<z.date())return-k(z,W);var K=12*(z.year()-W.year())+(z.month()-W.month()),Z=W.clone().add(K,f),X=z-Z<0,Q=W.clone().add(K+(X?-1:1),f);return+(-(K+(z-Z)/(X?Z-Q:Q-Z))||0)},a:function(k){return k<0?Math.ceil(k)||0:Math.floor(k)},p:function(k){return{M:f,y:g,w:h,d:p,D:y,h:c,m:l,s:a,ms:i,Q:d}[k]||String(k||"").toLowerCase().replace(/s$/,"")},u:function(k){return k===void 0}},x="en",F={};F[x]=E;var M="$isDayjsObject",S=function(k){return k instanceof L||!(!k||!k[M])},I=function k(W,z,K){var Z;if(!W)return x;if(typeof W=="string"){var X=W.toLowerCase();F[X]&&(Z=X),z&&(F[X]=z,Z=X);var Q=W.split("-");if(!Z&&Q.length>1)return k(Q[0])}else{var ce=W.name;F[ce]=W,Z=ce}return!K&&Z&&(x=Z),Z||!K&&x},C=function(k,W){if(S(k))return k.clone();var z=typeof W=="object"?W:{};return z.date=k,z.args=arguments,new L(z)},B=N;B.l=I,B.i=S,B.w=function(k,W){return C(k,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var L=function(){function k(z){this.$L=I(z.locale,null,!0),this.parse(z),this.$x=this.$x||z.x||{},this[M]=!0}var W=k.prototype;return W.parse=function(z){this.$d=function(K){var Z=K.date,X=K.utc;if(Z===null)return new Date(NaN);if(B.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var Q=Z.match(w);if(Q){var ce=Q[2]-1||0,ve=(Q[7]||"0").substring(0,3);return X?new Date(Date.UTC(Q[1],ce,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,ve)):new Date(Q[1],ce,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,ve)}}return new Date(Z)}(z),this.init()},W.init=function(){var z=this.$d;this.$y=z.getFullYear(),this.$M=z.getMonth(),this.$D=z.getDate(),this.$W=z.getDay(),this.$H=z.getHours(),this.$m=z.getMinutes(),this.$s=z.getSeconds(),this.$ms=z.getMilliseconds()},W.$utils=function(){return B},W.isValid=function(){return this.$d.toString()!==m},W.isSame=function(z,K){var Z=C(z);return this.startOf(K)<=Z&&Z<=this.endOf(K)},W.isAfter=function(z,K){return C(z)<this.startOf(K)},W.isBefore=function(z,K){return this.endOf(K)<C(z)},W.$g=function(z,K,Z){return B.u(z)?this[K]:this.set(Z,z)},W.unix=function(){return Math.floor(this.valueOf()/1e3)},W.valueOf=function(){return this.$d.getTime()},W.startOf=function(z,K){var Z=this,X=!!B.u(K)||K,Q=B.p(z),ce=function(Te,Ne){var lt=B.w(Z.$u?Date.UTC(Z.$y,Ne,Te):new Date(Z.$y,Ne,Te),Z);return X?lt:lt.endOf(p)},ve=function(Te,Ne){return B.w(Z.toDate()[Te].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(Ne)),Z)},le=this.$W,we=this.$M,be=this.$D,Be="set"+(this.$u?"UTC":"");switch(Q){case g:return X?ce(1,0):ce(31,11);case f:return X?ce(1,we):ce(0,we+1);case h:var Ee=this.$locale().weekStart||0,ot=(le<Ee?le+7:le)-Ee;return ce(X?be-ot:be+(6-ot),we);case p:case y:return ve(Be+"Hours",0);case c:return ve(Be+"Minutes",1);case l:return ve(Be+"Seconds",2);case a:return ve(Be+"Milliseconds",3);default:return this.clone()}},W.endOf=function(z){return this.startOf(z,!1)},W.$set=function(z,K){var Z,X=B.p(z),Q="set"+(this.$u?"UTC":""),ce=(Z={},Z[p]=Q+"Date",Z[y]=Q+"Date",Z[f]=Q+"Month",Z[g]=Q+"FullYear",Z[c]=Q+"Hours",Z[l]=Q+"Minutes",Z[a]=Q+"Seconds",Z[i]=Q+"Milliseconds",Z)[X],ve=X===p?this.$D+(K-this.$W):K;if(X===f||X===g){var le=this.clone().set(y,1);le.$d[ce](ve),le.init(),this.$d=le.set(y,Math.min(this.$D,le.daysInMonth())).$d}else ce&&this.$d[ce](ve);return this.init(),this},W.set=function(z,K){return this.clone().$set(z,K)},W.get=function(z){return this[B.p(z)]()},W.add=function(z,K){var Z,X=this;z=Number(z);var Q=B.p(K),ce=function(we){var be=C(X);return B.w(be.date(be.date()+Math.round(we*z)),X)};if(Q===f)return this.set(f,this.$M+z);if(Q===g)return this.set(g,this.$y+z);if(Q===p)return ce(1);if(Q===h)return ce(7);var ve=(Z={},Z[l]=r,Z[c]=n,Z[a]=t,Z)[Q]||1,le=this.$d.getTime()+z*ve;return B.w(le,this)},W.subtract=function(z,K){return this.add(-1*z,K)},W.format=function(z){var K=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||m;var X=z||"YYYY-MM-DDTHH:mm:ssZ",Q=B.z(this),ce=this.$H,ve=this.$m,le=this.$M,we=Z.weekdays,be=Z.months,Be=Z.meridiem,Ee=function(Ne,lt,rt,ke){return Ne&&(Ne[lt]||Ne(K,X))||rt[lt].slice(0,ke)},ot=function(Ne){return B.s(ce%12||12,Ne,"0")},Te=Be||function(Ne,lt,rt){var ke=Ne<12?"AM":"PM";return rt?ke.toLowerCase():ke};return X.replace(v,function(Ne,lt){return lt||function(rt){switch(rt){case"YY":return String(K.$y).slice(-2);case"YYYY":return B.s(K.$y,4,"0");case"M":return le+1;case"MM":return B.s(le+1,2,"0");case"MMM":return Ee(Z.monthsShort,le,be,3);case"MMMM":return Ee(be,le);case"D":return K.$D;case"DD":return B.s(K.$D,2,"0");case"d":return String(K.$W);case"dd":return Ee(Z.weekdaysMin,K.$W,we,2);case"ddd":return Ee(Z.weekdaysShort,K.$W,we,3);case"dddd":return we[K.$W];case"H":return String(ce);case"HH":return B.s(ce,2,"0");case"h":return ot(1);case"hh":return ot(2);case"a":return Te(ce,ve,!0);case"A":return Te(ce,ve,!1);case"m":return String(ve);case"mm":return B.s(ve,2,"0");case"s":return String(K.$s);case"ss":return B.s(K.$s,2,"0");case"SSS":return B.s(K.$ms,3,"0");case"Z":return Q}return null}(Ne)||Q.replace(":","")})},W.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},W.diff=function(z,K,Z){var X,Q=this,ce=B.p(K),ve=C(z),le=(ve.utcOffset()-this.utcOffset())*r,we=this-ve,be=function(){return B.m(Q,ve)};switch(ce){case g:X=be()/12;break;case f:X=be();break;case d:X=be()/3;break;case h:X=(we-le)/6048e5;break;case p:X=(we-le)/864e5;break;case c:X=we/n;break;case l:X=we/r;break;case a:X=we/t;break;default:X=we}return Z?X:B.a(X)},W.daysInMonth=function(){return this.endOf(f).$D},W.$locale=function(){return F[this.$L]},W.locale=function(z,K){if(!z)return this.$L;var Z=this.clone(),X=I(z,K,!0);return X&&(Z.$L=X),Z},W.clone=function(){return B.w(this.$d,this)},W.toDate=function(){return new Date(this.valueOf())},W.toJSON=function(){return this.isValid()?this.toISOString():null},W.toISOString=function(){return this.$d.toISOString()},W.toString=function(){return this.$d.toUTCString()},k}(),U=L.prototype;return C.prototype=U,[["$ms",i],["$s",a],["$m",l],["$H",c],["$W",p],["$M",f],["$y",g],["$D",y]].forEach(function(k){U[k[1]]=function(W){return this.$g(W,k[0],k[1])}}),C.extend=function(k,W){return k.$i||(k(W,L,C),k.$i=!0),C},C.locale=I,C.isDayjs=S,C.unix=function(k){return C(1e3*k)},C.en=F[x],C.Ls=F,C.p={},C})})(Nl);var Pp=Nl.exports,tt=Ge(Pp),Sl={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(Ve,function(){var t="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(i,a,l){var c=a.prototype;l.utc=function(m){var w={date:m,utc:!0,args:arguments};return new a(w)},c.utc=function(m){var w=l(this.toDate(),{locale:this.$L,utc:!0});return m?w.add(this.utcOffset(),t):w},c.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var p=c.parse;c.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),p.call(this,m)};var h=c.init;c.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else h.call(this)};var f=c.utcOffset;c.utcOffset=function(m,w){var v=this.$utils().u;if(v(m))return this.$u?0:v(this.$offset)?f.call(this):this.$offset;if(typeof m=="string"&&(m=function(x){x===void 0&&(x="");var F=x.match(r);if(!F)return null;var M=(""+F[0]).match(n)||["-",0,0],S=M[0],I=60*+M[1]+ +M[2];return I===0?0:S==="+"?I:-I}(m),m===null))return this;var E=Math.abs(m)<=16?60*m:m,b=this;if(w)return b.$offset=E,b.$u=m===0,b;if(m!==0){var N=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(E+N,t)).$offset=E,b.$x.$localOffset=N}else b=this.utc();return b};var d=c.format;c.format=function(m){var w=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return d.call(this,w)},c.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},c.isUTC=function(){return!!this.$u},c.toISOString=function(){return this.toDate().toISOString()},c.toString=function(){return this.toDate().toUTCString()};var g=c.toDate;c.toDate=function(m){return m==="s"&&this.$offset?l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var y=c.diff;c.diff=function(m,w,v){if(m&&this.$u===m.$u)return y.call(this,m,w,v);var E=this.local(),b=l(m).local();return y.call(E,b,w,v)}}})})(Sl);var zp=Sl.exports,Bl=Ge(zp),Ol={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(Ve,function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,i,a){var l,c=function(d,g,y){y===void 0&&(y={});var m=new Date(d),w=function(v,E){E===void 0&&(E={});var b=E.timeZoneName||"short",N=v+"|"+b,x=r[N];return x||(x=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:v,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:b}),r[N]=x),x}(g,y);return w.formatToParts(m)},p=function(d,g){for(var y=c(d,g),m=[],w=0;w<y.length;w+=1){var v=y[w],E=v.type,b=v.value,N=t[E];N>=0&&(m[N]=parseInt(b,10))}var x=m[3],F=x===24?0:x,M=m[0]+"-"+m[1]+"-"+m[2]+" "+F+":"+m[4]+":"+m[5]+":000",S=+d;return(a.utc(M).valueOf()-(S-=S%1e3))/6e4},h=i.prototype;h.tz=function(d,g){d===void 0&&(d=l);var y=this.utcOffset(),m=this.toDate(),w=m.toLocaleString("en-US",{timeZone:d}),v=Math.round((m-new Date(w))/1e3/60),E=a(w,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-v,!0);if(g){var b=E.utcOffset();E=E.add(y-b,"minute")}return E.$x.$timezone=d,E},h.offsetName=function(d){var g=this.$x.$timezone||a.tz.guess(),y=c(this.valueOf(),g,{timeZoneName:d}).find(function(m){return m.type.toLowerCase()==="timezonename"});return y&&y.value};var f=h.startOf;h.startOf=function(d,g){if(!this.$x||!this.$x.$timezone)return f.call(this,d,g);var y=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return f.call(y,d,g).tz(this.$x.$timezone,!0)},a.tz=function(d,g,y){var m=y&&g,w=y||g||l,v=p(+a(),w);if(typeof d!="string")return a(d).tz(w);var E=function(F,M,S){var I=F-60*M*1e3,C=p(I,S);if(M===C)return[I,M];var B=p(I-=60*(C-M)*1e3,S);return C===B?[I,C]:[F-60*Math.min(C,B)*1e3,Math.max(C,B)]}(a.utc(d,m).valueOf(),v,w),b=E[0],N=E[1],x=a(b).utcOffset(N);return x.$x.$timezone=w,x},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(d){l=d}}})})(Ol);var qp=Ol.exports,kp=Ge(qp),Tl={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(Ve,function(){var t="week",r="year";return function(n,i,a){var l=i.prototype;l.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var p=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var h=a(this).startOf(r).add(1,r).date(p),f=a(this).endOf(t);if(h.isBefore(f))return 1}var d=a(this).startOf(r).date(p).startOf(t).subtract(1,"millisecond"),g=this.diff(d,t,!0);return g<0?a(this).startOf("week").week():Math.ceil(g)},l.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(Tl);var Up=Tl.exports,Wp=Ge(Up);function jt(s,e){return s.replace(/\$(\w+)/g,(t,r)=>String(e[r])||t)}function bs(s){const e=parseInt(s)||1;let t=s.replace(/\d+/,"");return t==="m"||t==="M"?t="M":t?t=t.toLocaleLowerCase():t="m",[e,t]}function jp(s){const e=/([+-])(\d{1,2})(\d{0,2})/,t=s.replace(/GMT|UTC/,"").match(e);if(!t)throw new Error("Invalid timezone string");const[,r,n,i]=t,a=parseInt(n,10)*60||0,l=parseInt(i,10)||0;return(r==="+"?-1:1)*(a+l)}function qr(s,e){return e&&(e.startsWith("UTC")||e.startsWith("GMT"))?tt(s).utcOffset(jp(e)):tt(s).tz(e)}function Xr(s){const[e,t]=bs(s);let r=0;switch(t){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(e)*r)}function _e(s){return typeof s!="number"||isNaN(s)}function _t(s,e){for(const t of e)s!=null&&s.hasOwnProperty(t)&&s[t]===void 0&&(s[t]=null)}function Il(s){var e=atob(s),t=decodeURI(e);return t}var Qr=(s=>(s.BOOL="bool",s.INT="int",s.FLOAT="float",s.ARRAY="array",s.BOX="box",s.CHART_POINT="chart.point",s.COLOR="color",s.CONST="const",s.LABEL="label",s.LINE="line",s.LINEFILL="linefill",s.MAP="map",s.MATRIX="matrix",s.POLYLINE="polyline",s.SERIES="series",s.SIMPLE="simple",s.STRING="string",s.TABLE="table",s.UNDETERMINED="undetermined type",s.INPUT="input",s.NA="na",s.VOID="void",s.ENUM="enum",s))(Qr||{}),Es=(s=>(s.dividends="dividends",s.none="none",s.splits="splits",s))(Es||{}),kr=(s=>(s.freqAll="freq_all",s.freqOncePerBar="freq_once_per_bar",s.freqOncePerBarClose="freq_once_per_bar_close",s))(kr||{}),Vi=(s=>(s.gapsOff="gaps_off",s.gapsOn="gaps_on",s.lookaheadOff="lookahead_off",s.lookaheadOn="lookahead_on",s))(Vi||{}),Yt=(s=>(s.all="all",s.dataWindow="data_window",s.none="none",s.pane="pane",s.priceScale="price_scale",s.statusLine="status_line",s))(Yt||{}),Ur=(s=>(s.both="both",s.left="left",s.none="none",s.right="right",s))(Ur||{}),Ke=(s=>(s.inherit="inherit",s.mintick="mintick",s.percent="percent",s.price="price",s.volume="volume",s))(Ke||{}),xs=(s=>(s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(xs||{}),mt=(s=>(s.styleArrowdown="style_arrowdown",s.styleArrowup="style_arrowup",s.styleCircle="style_circle",s.styleCross="style_cross",s.styleDiamond="style_diamond",s.styleFlag="style_flag",s.styleLabelCenter="style_label_center",s.styleLabelDown="style_label_down",s.styleLabelLeft="style_label_left",s.styleLabelLowerLeft="style_label_lower_left",s.styleLabelLowerRight="style_label_lower_right",s.styleLabelRight="style_label_right",s.styleLabelUp="style_label_up",s.styleLabelUpperLeft="style_label_upper_left",s.styleLabelUpperRight="style_label_upper_right",s.styleNone="style_none",s.styleSquare="style_square",s.styleTextOutline="style_text_outline",s.styleTriangledown="style_triangledown",s.styleTriangleup="style_triangleup",s.styleXcross="style_xcross",s))(mt||{}),Lt=(s=>(s.styleArrowBoth="style_arrow_both",s.styleArrowLeft="style_arrow_left",s.styleArrowRight="style_arrow_right",s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid",s))(Lt||{}),an=(s=>(s.abovebar="abovebar",s.absolute="absolute",s.belowbar="belowbar",s.bottom="bottom",s.top="top",s))(an||{}),Vn=(s=>(s.ascending="ascending",s.descending="descending",s))(Vn||{}),Cr=(s=>(s.styleArea="Area",s.styleAreabr="Area With Breaks",s.styleCircles="Circles",s.styleColumns="Columns",s.styleCross="Cross",s.styleHistogram="Histogram",s.styleLine="Line",s.styleLinebr="Line With Breaks",s.styleStepline="Step Line",s.styleSteplineDiamond="Step Line With Diamonds",s.styleSteplinebr="Step line with Breaks",s))(Cr||{}),pr=(s=>(s.bottomCenter="bottom_center",s.bottomLeft="bottom_left",s.bottomRight="bottom_right",s.middleCenter="middle_center",s.middleLeft="middle_left",s.middleRight="middle_right",s.topCenter="top_center",s.topLeft="top_left",s.topRight="top_right",s))(pr||{}),As=(s=>(s.left="left",s.none="none",s.right="right",s))(As||{}),fi=(s=>(s.extended="extended",s.regular="regular",s))(fi||{}),or=(s=>(s.arrowdown="arrowdown",s.arrowup="arrowup",s.circle="circle",s.cross="cross",s.diamond="diamond",s.flag="flag",s.labeldown="labeldown",s.labelup="labelup",s.square="square",s.triangledown="triangledown",s.triangleup="triangleup",s.xcross="xcross",s))(or||{}),tr=(s=>(s.auto="auto",s.huge="huge",s.large="large",s.normal="normal",s.small="small",s.tiny="tiny",s))(tr||{}),Zn=(s=>(s.familyDefault="default",s.familyMonospace="monospace",s))(Zn||{}),Ot=(s=>(s.cash="cash",s.fixed="fixed",s.percentOfEquity="percent_of_equity",s))(Ot||{}),Fr=(s=>(s.cashPerContract="cash_per_contract",s.cashPerOrder="cash_per_order",s.percent="percent",s))(Fr||{}),gt=(s=>(s.all="all",s.long="long",s.short="short",s))(gt||{}),un=(s=>(s.cancel="cancel",s.none="none",s.reduce="reduce",s))(un||{}),We=(s=>(s.alignBottom="align_bottom",s.alignCenter="align_center",s.alignLeft="align_left",s.alignRight="align_right",s.alignTop="align_top",s.wrapAuto="wrap_auto",s.wrapNone="wrap_none",s))(We||{}),wt=(s=>(s.bar_index="bar_index",s.bar_time="bar_time",s))(wt||{}),Wr=(s=>(s.abovebar="abovebar",s.belowbar="belowbar",s.price="price",s))(Wr||{}),Cs=(s=>(s.actual="actual",s.estimate="estimate",s.standardized="standardized",s))(Cs||{}),Kn=(s=>(s.traditional="Traditional",s.fibonacci="Fibonacci",s.woodie="Woodie",s.classic="Classic",s.dm="DM",s.camarilla="Camarilla",s))(Kn||{}),rr=(s=>(s.INT="int",s.BOOL="bool",s.TIME="time",s.COLOR="color",s.FLOAT="float",s.PRICE="price",s.SOURCE="source",s.STRING="string",s.SYMBOL="symbol",s.SESSION="session",s.TEXT_AREA="text_area",s.TIMEFRAME="timeframe",s.ENUM="enum",s))(rr||{}),ze=(s=>(s[s.Hint=1]="Hint",s[s.Info=2]="Info",s[s.Warning=4]="Warning",s[s.Error=8]="Error",s))(ze||{});const ut={onlyInLoop:"'$text' is only allowed inside loops",invalidType:"Invalid argument 'expr$index' in 'operator SQBR' call",typeUseError:"Cannot specify a type form '$text' without also specifying the type.",notTypeKeyword:"'$text' is not a valid type keyword in variable declaration",undeclared:"Undeclared identifier '$name'",repeatVar:"'$name' is already defined",typeRepeatErr:"$keyword '$name' is already defined.",typeMismatch:"Cannot call '$operator' with argument '$index'. An argument of '$typeE' type was used but a '$typeR' is expected.",assignTypeMismatch:"Cannot assign a value of the `$typeE` type to the '$name' variable. The variable is declared with the `$typeR` type.",voidNotVar:"Void expression cannot be assigned to a variable",declareTypeErr:"Declared type '$type' is not compatible with assigned type '$valueType'",mapKeyValErr:"Cannot put <$typeA, $typeB> pairs into a map containing `$typeC` keys and `$typeD` values. The maps passed into the `$name()` function must have the same key types and value types.",inputSourceErr:"Invalid value for the '$name' parameter of the '$funcName' function. Possible values: [open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume].",buildInUseErr:"Cannot use '$name' as the default value of a type's field. The default value cannot be a function, variable or calculation.",argsLenErr:"Too many arguments passed into the `$name()` function call. Passed $lenA arguments but expected $lenB.",requiredParamErr:"No value assigned to the `$argName` parameter in $name()",argsSyntaxErr:"Syntax error after the argument for `$argName`. Arguments without their parameter name cannot be used after arguments with parameter names.",requestArgsErr:"Type $type cannot be used in $name '$argName' argument",mapKeyErr:"Incorrect `key` type `$type` in the variable. The `key` type must be one of the following: int, float, string, bool, color.",templateErr:"Incorrect number of arguments for the template: $countA expected, $countB passed.",templateNoSupportErr:"The '$name()' function does not support templates",ifOrSwitchTypeErr:"Return type of one of the '$keyword' blocks is not compatible with return type of other block(s) ($types)",argsNameErr:"The '$name' function does not have an argument with the name '$argName'",noFiledErr:"Object has no field $name",methodNotExistErr:"Could not find method or method reference '$methodName' for '$name'",tupleVarErr:"Syntax error: The quantities of tuple elements on each side of the assignment operator do not match. The right side has $indexA but the left side has $indexB.",tupleLeftVarErr:"Invalid assignment. Cannot assign a tuple to a variable '$name'.",tupleRightVarErr:"Cannot assign a variable to a tuple. The right side must be a function call or structure ('if', 'switch', 'for', 'while') returning a tuple with the same number of elements.",tempateTypeErr:"Syntax error: Only templates for arrays and matrices consist of a single type identifier enclosed in angle brackets.",qualifierErr:"'$name' is not a valid type qualifier. Possible values: 'const', 'simple', 'series'",notFindFuncErr:"Could not find function or function reference '$name'",naVarErr:"Value with NA type cannot be assigned to a variable that was defined without type keyword",notHistoryErr:"Variable '$name' doesn't have history values",defaultValueErr:"The default value cannot be a function, variable or calculation.",defaultValueTypeErr:"Default value of type $typeE can not be assigned to an argument of type $typeR",typeFieldErr:"In a type declaration, all fields without a default value must be explicitly typified.",unaryErr:"Syntax error at input '$sign'",funcArgAssignErr:"Function arguments cannot be mutable ('$name')",declaredErr:"A variable declared with the '$prefix' keyword cannot accept values of the '$type' form. Assign a '$prefix' value to this variable or remove the '$prefix' keyword from its declaration.",globalFuncErr:"Cannot use '$name' in local scope",onlyStatementErr:"Scripts must contain one declaration statement: `indicator()`, `strategy()` or `library()`, Your script has $count.",modifyGlobalVarErr:"Cannot modify global variable '$name' in function",inputDefvalErr:"Arguments of input function must be of constant type, or 'source' builtin variables.",objectIsNaErr:"Cannot access the '$name' $type of an na object. The object is 'na'.",buidinAssignErr:"Cannot assign a new value to the built-in variable '$name'.",buidinVarErr:"Cannot shadow the built-in variable `$name` because it has already been used as a built-in.",useNaErr:"Cannot use an `na` value of an unspecified type in the `$name` function.",libraryTitleErr:"Invalid argument 'title' in 'library' call. It cannot contain spaces, special characters or begin with a digit.",exportFuncArgErr:"All exported functions args should be typified",indiRunErr:"An indicator must contain at least one of the following: any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, `alertcondition()`, or any drawing (line, label, box, table, polyline).",libraryExportErr:"A library must contain at least one exported function, method, or type.",strategyRunErr:"A strategy must contain at least one of the following: any `strategy.*()` function that creates orders, any `plot*()` function, `barcolor()`, `bgcolor()`, `hline()`, or any drawing (line, label, box, table, polyline).",exportUseErr:"Only libraries can contain exported $type.",funcRepeatErr:"The '$name' function has overloads with the same parameters. The type of parameters must be different in overloaded versions of functions.",importMultipleErr:"Cannot import a library more than once",importNotExitErr:"The user '$username' does not have a published library titled '$libraryName'",importNameRepeatErr:"More than one import uses the same alias: $name. Previous usage at line: $line",exportFuncHasInputErr:"The exported function '$func' depends on the '$name' input variable, which is not allowed.",libraryTitleIsKeywordErr:"Invalid argument 'title' in 'library' call. Token: '$name' can't be used as library title.",exportFuncUseGlobalVarErr:"Cannot use global variables in exported functions. Function: $func",loopRuntimeErr:"Loop takes too long to execute (> 500 ms)",paramsErr:"Invalid value '$value' for '$param' parameter of the '$func' function. Possible values: $targetVal",displayErr:"Invalid argument 'display' in '$func' call. Possible values: $values",exportFuncUseReqErr:"Cannot use `request.*()` call in exported function `$name()`",requestExprErr:"Type series $type cannot be used in $name 'expression' argument",argDefaultErr:"The default value assigned to a parameter must be either a literal value (e.g., `5`) or a built-in variable (e.g., `close`)",overloadFuncErr:"Cannot use global variables or any values qualified as 'input' in the local scopes of overloaded functions or methods. Remove any global variables or inputs from the scopes of all '$name()' overloads.",againAssignErr:"Unable to determine the object for the field assignment. Try putting the object into a separate variable before assigning values to its fields.",requestUserInLoopErr:"Cannot use `request.*()` call within loops or conditional structures.",enumVarNameErr:"Invalid enum name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumVarNameBuiltinErr:"Invalid object name: $name. Namespaces of built-ins cannot be used.",typeNameErr:"Invalid user-defined type name '$name': `bool`, `int`, `float`, `string`, and `color` are not allowed.",enumUseErr:"Cannot use the '$name' as a value. Use one of the enum's fields instead.",conditionalErr:"'$name' conditional expression must be of a bool type!",fortoErr:'The value of the "for" loop must be a number.',indicatorUseStrategyFuncErr:"You cannot use strategy $type ($name) in indicator script.",arrEmptyErr:"Array must not be empty",arrLengthDiffErr:"Arrays have different lengths",arrTypeErr:"数组类型错误,array.$name方法只能使用$type类型数组!",inputOptErr:"input's defval should be in options, but '$defval' is not in [$args]",mathRandomErr:"min must be less than max",matrixRehapeErr:"New matrix must be of same area as original matrix",strategyExitErr:"strategy.exit must have at least one of the following parameters: 'profit', 'limit', 'loss', 'stop' or one of the following pairs: 'trail_offset' and 'trail_price' / 'trail_points'. To close the position at market price, use 'strategy.close'",arrLenErr:"Invalid array length",mergeCellErr:"error: start_column > end_column or start_row > end_row"},Yp={repeatVar:"Shadowing variable '$name' which exists in parent scope. Did you want to use the ':=' operator instead of '=' ?",typeMismatch:"The `$index` parameter of the `$operator` function accepts a '$type' argument. To avoid potential unexpected results, pass a '$type' value or expression to this parameter.",moreSameArg:"More than one '$arg' arguments are supplied. Only the first one will be used.",localScopeGetHistory:"The variable '$name' is declared in local scope, which may not be executed at every update. So, obtaining its historical values may lead to unexpected results",localScopeWarning:"The function '$name' should be called on each calculation for consistency. It is recommended to extract the call from this scope",strategyCalcTickWarn:"Strategies without `calc_on_every_tick = true` only calculate on confirmed chart bars. In this case, `barstate.islast` may not initially return `true` on realtime bars, as the last bar is unconfirmed until it closes. If you need to check whether a bar is the latest before it closes, enable `calc_on_every_tick` in the `strategy()` function.",conditionWarning:"The `condition` parameter of the `$name` accepts a 'bool' argument. To avoid potential unexpected results, pass a 'bool' value or expression to this parameter.",lineWidthWarning:"Passing a value below 1 to `linewidth` will be replaced with 1 during compilation.",boolVarNumWarning:"The `$name` variable casts a numeric value to the 'bool' type. To avoid potential unexpected results, assign a 'bool' value to this variable."};Qr.SERIES,Qr.SIMPLE,Qr.INPUT,Qr.CONST,Qr.INT,Qr.FLOAT,Qr.BOOL,Qr.COLOR,Qr.STRING;const Vp=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],Zp=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],Kp=["linefill","polyline","matrix","series","simple","string","array","color","const","float","label","table","bool","line","box","int","map","continue","for","varip","var","in","export","import","method","switch","break","while","else","type","and","for","not","as","by","if","in","or","to"];class Gp{constructor(e){R(this,"_errorListener");this._errorListener=e}new({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}new_float({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}new_int({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}new_color({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}new_bool({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}new_string({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}new_line({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}new_box({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}new_table({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}new_linefill({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}new_label({size:e,initial_value:t}={}){return new Qe(e,t,this._errorListener)}copy({id:e}){return e==null?void 0:e.copy()}slice({id:e,index_from:t,index_to:r}){return e==null?void 0:e.slice({index_from:t,index_to:r})}size({id:e}){return e==null?void 0:e.size()}first({id:e}){return e==null?void 0:e.first()}abs({id:e},t){return e==null?void 0:e.abs(t)}avg({id:e},t){return e==null?void 0:e.avg(t)}binary_search({id:e,val:t},r){return e==null?void 0:e.binary_search({val:t},r)}binary_search_leftmost({id:e,val:t},r){return e==null?void 0:e.binary_search_leftmost({val:t},r)}binary_search_rightmost({id:e,val:t},r){return e==null?void 0:e.binary_search_rightmost({val:t},r)}clear({id:e}){e==null||e.clear()}concat({id1:e,id2:t}){return e==null?void 0:e.concat({id2:t})}covariance({id1:e,id2:t,biased:r},n){return e==null?void 0:e.covariance({id2:t,biased:r},n)}every({id:e},t){return e==null?void 0:e.every(t)}from(e,t){const r=new Qe(0,void 0,this._errorListener);return r._value=t,r}fill({id:e,value:t,index_from:r,index_to:n}){e==null||e.fill({value:t,index_from:r,index_to:n})}get({id:e,index:t}){return e==null?void 0:e.get({index:t})}includes({id:e,value:t}){return e==null?void 0:e.includes({value:t})}indexof({id:e,value:t}){return e==null?void 0:e.indexof({value:t})}insert({id:e,index:t,value:r}){e==null||e.insert({index:t,value:r})}join({id:e,separator:t},r){return e==null?void 0:e.join({separator:t},r)}last({id:e}){return e==null?void 0:e.last()}lastindexof({id:e,value:t}){return e==null?void 0:e.lastindexof({value:t})}max({id:e,nth:t},r){return e==null?void 0:e.max({nth:t},r)}median({id:e},t){return e==null?void 0:e.median(t)}min({id:e,nth:t},r){return e==null?void 0:e.min({nth:t},r)}mode({id:e},t){return e==null?void 0:e.mode(t)}percentile_linear_interpolation({id:e,percentage:t},r){return e==null?void 0:e.percentile_linear_interpolation({percentage:t},r)}percentile_nearest_rank({id:e,percentage:t},r){return e==null?void 0:e.percentile_nearest_rank({percentage:t},r)}percentrank({id:e,index:t},r){return e==null?void 0:e.percentrank({index:t},r)}pop({id:e}){return e==null?void 0:e.pop()}push({id:e,value:t}){e==null||e.push({value:t})}range({id:e},t){return e==null?void 0:e.range(t)}remove({id:e,index:t}){return e==null?void 0:e.remove({index:t})}reverse({id:e}){return e==null?void 0:e.reverse()}set({id:e,index:t,value:r}){e==null||e.set({index:t,value:r})}shift({id:e}){return e==null?void 0:e.shift()}some({id:e},t){return e==null?void 0:e.some(t)}sort({id:e,order:t},r){e==null||e.sort({order:t},r)}sort_indices({id:e,order:t},r){return e==null?void 0:e.sort_indices({order:t},r)}standardize({id:e},t){return e==null?void 0:e.standardize(t)}stdev({id:e,biased:t},r){return e==null?void 0:e.stdev({biased:t},r)}sum({id:e},t){return e==null?void 0:e.sum(t)}unshift({id:e,value:t}){e==null||e.unshift({value:t})}variance({id:e,biased:t},r){return e==null?void 0:e.variance({biased:t},r)}}class Qe{constructor(e=0,t,r){R(this,"_arrInstance");R(this,"_errorListener");this._errorListener=r,this._arrInstance=Array.from(new Array(e||0),()=>zr.cloneDeep(t))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(e){this._arrInstance=[...e]}_deepCopyData(e){this._arrInstance=zr.cloneDeep(e)}_copyData(e){this._arrInstance=e}copy(){const e=new Qe(0,void 0,this._errorListener);return e._deepCopyData(this._arrInstance),e}slice({index_from:e,index_to:t}){const r=new Qe(0,void 0,this._errorListener);return r._copyData(this._arrInstance.slice(e,t)),r}size(){return this._arrInstance.length}first(){return this._arrInstance[0]}abs(e){const t=new Qe(0,void 0,this._errorListener);this._verifySimpleType("number","abs","int/float",e);const r=this._arrInstance.map(n=>Math.abs(n));return t._copyData(r),t}avg(e){return this._verifySimpleType("number","avg","int/float",e),zr.mean(this._arrInstance)}binary_search({val:e},t){return this._verifySimpleType("number","binary_search","int/float",t),_e(e)?-1:this._binarySearch(this._arrInstance,e)}binary_search_leftmost({val:e},t){return this._verifySimpleType("number","binary_search_leftmost","int/float",t),_e(e)?this._arrInstance.length-1:this._binarySearchLeftMost(this._arrInstance,e)}binary_search_rightmost({val:e},t){return this._verifySimpleType("number","binary_search_rightmost","int/float",t),_e(e)?this._arrInstance.length:this._binarySearchRightMost(this._arrInstance,e)}clear(){this._arrInstance=[]}concat({id2:e}){return this._arrInstance=this._arrInstance.concat(e==null?void 0:e._value),this}covariance({id2:e,biased:t},r){return this._verifySimpleType("number","covariance","int/float",r),this._verifySimpleType("number","covariance","int/float",r,e==null?void 0:e._value),this._covariance(this._arrInstance,e._value,t,r)}every(e){return this._verifySimpleType("number|boolean","every","int/float/bool",e),this._arrInstance.every(t=>!!t)}fill({value:e,index_from:t=0,index_to:r}){this._arrInstance=this._setElements(this._arrInstance,e,t,r)}get({index:e}){if(!_e(e))return this._arrInstance[e]}includes({value:e}){return this._arrInstance.includes(e)}indexof({value:e}){return this._arrInstance.indexOf(e)}insert({index:e,value:t}){_e(e)||this._arrInstance.splice(e,0,t)}join({separator:e}={},t){return this._verifySimpleType("number|string","join","int/float/string",t),this._arrInstance.join(e)}last(){return this._arrInstance[this._arrInstance.length-1]}lastindexof({value:e}){return this._arrInstance.lastIndexOf(e)}max({nth:e}={},t){return this._verifySimpleType("number","max","int/float",t),this._maxNth([...this._arrInstance],e)}median(e){return this._verifySimpleType("number","median","int/float",e),this._median([...this._arrInstance])}min({nth:e}={},t){return this._verifySimpleType("number","min","int/float",t),this._minNth([...this._arrInstance],e)}mode(e){return this._verifySimpleType("number","mode","int/float",e),this._mode([...this._arrInstance])}percentile_linear_interpolation({percentage:e},t){return this._verifySimpleType("number","percentile_linear_interpolation","int/float",t),this._percentileLinearInterpolation([...this._arrInstance],e)}percentile_nearest_rank({percentage:e=0},t){var r;if(this._arrInstance.length===0||e<0||e>100||_e(e)){(r=this._errorListener)==null||r.addError("Invalid percentile or empty array",t,ze.Error);return}return this._verifySimpleType("number","percentile_nearest_rank","int/float",t),this._getNearestRankPercentile([...this._arrInstance],e)}percentrank({index:e},t){return this._verifySimpleType("number","percentrank","int/float",t),this._getPercentileRank([...this._arrInstance],e)}pop(){return this._arrInstance.pop()}push({value:e}){this._arrInstance.push(e)}range(e){var i;if(this._arrInstance.length===0){(i=this._errorListener)==null||i.addError(ut.arrEmptyErr,e,ze.Error);return}this._verifySimpleType("number","range","int/float",e);const t=Math.min(...this._arrInstance);return Math.max(...this._arrInstance)-t}remove({index:e}){if(!_e(e))return this._arrInstance.splice(e,1)[0]}reverse(){this._arrInstance.reverse()}set({index:e,value:t}){_e(e)||(this._arrInstance[e]=t)}shift(){return this._arrInstance.shift()}some(e){return this._verifySimpleType("number|boolean","some","int/float/bool",e),this._arrInstance.some(t=>!!t)}sort({order:e}={},t){this._verifySimpleType("number","sort","int/float",t),this._arrInstance.sort((r,n)=>e!==Vn.descending?r-n:n-r)}sort_indices({order:e}={},t){this._verifySimpleType("number","sort_indices","int/float",t);const r=this._arrInstance.map((i,a)=>a);r.sort((i,a)=>e!==Vn.descending?this._arrInstance[i]-this._arrInstance[a]:this._arrInstance[a]-this._arrInstance[i]);const n=new Qe(0,void 0,this._errorListener);return n._copyData(r),n}standardize(e){this._verifySimpleType("number","standardize","int/float",e);const t=new Qe(0,void 0,this._errorListener);return t._copyData(this._standardizeArray([...this._arrInstance])),t}stdev({biased:e}={},t){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(ut.arrEmptyErr,t,ze.Error);return}return this._verifySimpleType("number","stdev","int/float",t),this._calculateStandardDeviations([...this._arrInstance],e)}sum(e){return this._verifySimpleType("number","sum","int/float",e),this._arrInstance.reduce((r,n)=>r+(n||0),0)}unshift({value:e}){this._arrInstance.unshift(e)}variance({biased:e}={},t){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(ut.arrEmptyErr,t,ze.Error);return}return this._verifySimpleType("number","variance","int/float",t),this._calculateVariances([...this._arrInstance],e)}_calculateVariances(e,t=!0){const r=e.reduce((a,l)=>a+(l||0),0)/e.length,n=e.reduce((a,l)=>a+((l||0)-r)**2,0),i=n/e.length;return t?i:e.length>1?n/(e.length-1):i}_calculateStandardDeviations(e,t=!0){const r=e.reduce((a,l)=>a+(l||0),0)/e.length,n=e.reduce((a,l)=>{const c=(l||0)-r;return a+c*c},0),i=Math.sqrt(n/e.length);return t?i:e.length>1?Math.sqrt(n/(e.length-1)):i}_standardizeArray(e){const t=e.reduce((i,a)=>i+(a||0),0)/e.length,r=Math.sqrt(e.reduce((i,a)=>i+Math.pow((a||0)-t,2),0)/e.length);return e.map(i=>((i||0)-t)/r)}_getPercentileRank(e,t=0){if(_e(t))return;const r=e[t];let n=0;for(let a=0;a<e.length;a++)(e[a]<r||e[a]===r&&a!=t)&&n++;return n/(e.length-1)*100}_getNearestRankPercentile(e,t=0){const r=e.slice().sort((a,l)=>a-l),n=t/100*r.length,i=Math.ceil(n)-1;return r[i>=r.length?r.length-1:i]}_percentileLinearInterpolation(e,t=0){if(t<0||t>100||_e(t))return;e.sort(function(i,a){return i-a});const r=e.length;t/=100;const n=1/(r*2);if(t<=n)return e[0];if(t>=1-1/(r*2))return e[r-1];for(const[i,a]of e.entries()){const l=e[i-1];if(t<(i+.5)/r)return l+(a-l)*(t-(i-.5)/r)/(1/r)}}_mode(e){const t={};let r=0;const n=[];for(const i of e)t[i]=(t[i]||0)+1,r=Math.max(r,t[i]);for(const i in t)t[i]===r&&n.push(Number(i));return Math.min(...r===1?e:n)}_median(e){e.sort(function(r,n){return r-n});const t=Math.floor(e.length/2);return e.length%2?e[t]:(e[t-1]+e[t])/2}_minNth(e,t=0){return e.sort(function(r,n){return r-n}),e[t]}_maxNth(e,t=0){return e.sort(function(r,n){return n-r}),e[t]}_setElements(e,t,r=0,n){n===void 0&&(n=e.length);for(let i=r;i<n;i++)e[i]=t;return e}_covariance(e,t,r=!0,n){var c;if(e.length!=t.length){(c=this._errorListener)==null||c.addError(ut.arrLengthDiffErr,n,ze.Error);return}e=e.filter(p=>p!==void 0),t=t.filter(p=>p!==void 0);const i=e.reduce((p,h)=>p+h,0)/e.length,a=t.reduce((p,h)=>p+h,0)/t.length;let l=0;for(let p=0;p<e.length;p++)l+=(e[p]-i)*(t[p]-a);return r?l/e.length:l/(e.length-1)}_verifySimpleType(e,t,r,n,i=this._arrInstance){var l;i.filter(c=>c!==void 0).some(c=>!e.split("|").includes(typeof c))&&((l=this._errorListener)==null||l.addError(jt(ut.arrTypeErr,{name:t,type:r}),n,ze.Error))}_binarySearch(e,t){let r=0,n=e.length-1;for(;r<=n;){const i=Math.floor((r+n)/2);if(e[i]===t)return i;e[i]<t?r=i+1:n=i-1}return-1}_binarySearchLeftMost(e,t){let r=0,n=e.length-1;const i=[];for(;r<=n;){const a=Math.floor((r+n)/2);e[a]===t&&i.push(a),e[a]<t?r=a+1:n=a-1}return i.length?Math.min(...i):r-1}_binarySearchRightMost(e,t){let r=0,n=e.length-1;const i=[];for(;r<=n;){const a=Math.floor((r+n)/2);e[a]===t&&i.push(a),e[a]<=t?r=a+1:n=a-1}return i.length?Math.max(...i):r}}class Hp{constructor(e,t){R(this,"_randomNums");R(this,"_mintick");R(this,"_cacheData");R(this,"_barIndex");R(this,"_errorListener");this._mintick=e,this._randomNums={},this._cacheData={},this._barIndex=0,this._errorListener=t}update(e){this._barIndex=e,this._randomNums={}}abs({number:e}){if(!_e(e))return Math.abs(e)}acos({angle:e}){if(_e(e))return;const t=Math.acos(e);return isNaN(t)?void 0:t}asin({angle:e}){if(_e(e))return;const t=Math.asin(e);return isNaN(t)?void 0:t}atan({angle:e}){if(_e(e))return;const t=Math.atan(e);return isNaN(t)?void 0:t}avg(e,t){return zr.mean(t)}ceil({number:e}){if(!_e(e))return Math.ceil(e)}floor({number:e}){if(!_e(e))return Math.floor(e)}cos({angle:e}){if(_e(e))return;const t=Math.cos(e);return isNaN(t)?void 0:t}sin({angle:e}){if(_e(e))return;const t=Math.sin(e);return isNaN(t)?void 0:t}tan({angle:e}){if(_e(e))return;const t=Math.tan(e);return isNaN(t)?void 0:t}exp({number:e}){if(!_e(e))return Math.exp(e)}log({number:e}){if(!_e(e))return Math.log(e)}log10({number:e}){if(!_e(e))return Math.log10(e)}max(e,t){return t=t.filter(r=>!_e(r)),Math.max(...t)}min(e,t){return t=t.filter(r=>!_e(r)),Math.min(...t)}pow({base:e,exponent:t}){if(!(_e(e)||_e(t)))return Math.pow(e,t)}random({min:e=0,max:t=1,seed:r},n){if(_e(e)&&(e=0),_e(t)&&(t=1),r&&this._randomNums[r])return this._randomNums[r];if(e>=t){this._errorListener.addError(ut.mathRandomErr,n,ze.Error);return}let i;do i=Math.random()*(t-e)+e;while(i===e||i===t);return r&&(this._randomNums[r]=i),i}round({number:e,precision:t}){if(!_e(e))return _e(t)?Math.round(e):Number(e==null?void 0:e.toFixed(t))}round_to_mintick({number:e}){if(!_e(e))return Number(e==null?void 0:e.toFixed(this._mintick))}sign({number:e}){if(!_e(e))return e&&Math.sign(e)}sqrt({number:e}){if(!_e(e))return Math.sqrt(e)}sum({source:e,length:t=1},r){let n=this._cacheData[`sum_${r}`];n||(n=[]),n[this._barIndex]=e,this._cacheData[`sum_${r}`]=n;const i=n.filter(a=>!_e(a));if(!(i.length<t))return zr.sum(i.slice(-t))}todegrees({radians:e}){if(!_e(e))return e*(180/Math.PI)}toradians({degrees:e}){if(!_e(e))return e*(Math.PI/180)}}function Fs(){return Fs=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},Fs.apply(this,arguments)}var $l={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function pt(s){return typeof s=="number"}function Nt(s){return!s||typeof s!="object"||typeof s.constructor!="function"?!1:s.isBigNumber===!0&&typeof s.constructor.prototype=="object"&&s.constructor.prototype.isBigNumber===!0||typeof s.constructor.isDecimal=="function"&&s.constructor.isDecimal(s)===!0}function Ll(s){return s&&typeof s=="object"&&Object.getPrototypeOf(s).isComplex===!0||!1}function Rl(s){return s&&typeof s=="object"&&Object.getPrototypeOf(s).isFraction===!0||!1}function Pl(s){return s&&s.constructor.prototype.isUnit===!0||!1}function en(s){return typeof s=="string"}var xt=Array.isArray;function vt(s){return s&&s.constructor.prototype.isMatrix===!0||!1}function Zi(s){return Array.isArray(s)||vt(s)}function Jp(s){return s&&s.isDenseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function Xp(s){return s&&s.isSparseMatrix&&s.constructor.prototype.isMatrix===!0||!1}function Qp(s){return s&&s.constructor.prototype.isRange===!0||!1}function la(s){return s&&s.constructor.prototype.isIndex===!0||!1}function ed(s){return typeof s=="boolean"}function td(s){return s&&s.constructor.prototype.isResultSet===!0||!1}function rd(s){return s&&s.constructor.prototype.isHelp===!0||!1}function nd(s){return typeof s=="function"}function id(s){return s instanceof Date}function sd(s){return s instanceof RegExp}function ca(s){return!!(s&&typeof s=="object"&&s.constructor===Object&&!Ll(s)&&!Rl(s))}function od(s){return s===null}function ad(s){return s===void 0}function ud(s){return s&&s.isAccessorNode===!0&&s.constructor.prototype.isNode===!0||!1}function ld(s){return s&&s.isArrayNode===!0&&s.constructor.prototype.isNode===!0||!1}function cd(s){return s&&s.isAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function fd(s){return s&&s.isBlockNode===!0&&s.constructor.prototype.isNode===!0||!1}function hd(s){return s&&s.isConditionalNode===!0&&s.constructor.prototype.isNode===!0||!1}function pd(s){return s&&s.isConstantNode===!0&&s.constructor.prototype.isNode===!0||!1}function dd(s){return s&&s.isFunctionAssignmentNode===!0&&s.constructor.prototype.isNode===!0||!1}function _d(s){return s&&s.isFunctionNode===!0&&s.constructor.prototype.isNode===!0||!1}function md(s){return s&&s.isIndexNode===!0&&s.constructor.prototype.isNode===!0||!1}function gd(s){return s&&s.isNode===!0&&s.constructor.prototype.isNode===!0||!1}function vd(s){return s&&s.isObjectNode===!0&&s.constructor.prototype.isNode===!0||!1}function yd(s){return s&&s.isOperatorNode===!0&&s.constructor.prototype.isNode===!0||!1}function wd(s){return s&&s.isParenthesisNode===!0&&s.constructor.prototype.isNode===!0||!1}function Dd(s){return s&&s.isRangeNode===!0&&s.constructor.prototype.isNode===!0||!1}function bd(s){return s&&s.isRelationalNode===!0&&s.constructor.prototype.isNode===!0||!1}function Ed(s){return s&&s.isSymbolNode===!0&&s.constructor.prototype.isNode===!0||!1}function xd(s){return s&&s.constructor.prototype.isChain===!0||!1}function xn(s){var e=typeof s;return e==="object"?s===null?"null":Nt(s)?"BigNumber":s.constructor&&s.constructor.name?s.constructor.name:"Object":e}function st(s){var e=typeof s;if(e==="number"||e==="string"||e==="boolean"||s===null||s===void 0)return s;if(typeof s.clone=="function")return s.clone();if(Array.isArray(s))return s.map(function(t){return st(t)});if(s instanceof Date)return new Date(s.valueOf());if(Nt(s))return s;if(ca(s))return Ad(s,st);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(s,")"))}function Ad(s,e){var t={};for(var r in s)Ki(s,r)&&(t[r]=e(s[r]));return t}function zl(s,e){for(var t in e)Ki(e,t)&&(s[t]=e[t]);return s}function hi(s,e){var t,r,n;if(Array.isArray(s)){if(!Array.isArray(e)||s.length!==e.length)return!1;for(r=0,n=s.length;r<n;r++)if(!hi(s[r],e[r]))return!1;return!0}else{if(typeof s=="function")return s===e;if(s instanceof Object){if(Array.isArray(e)||!(e instanceof Object))return!1;for(t in s)if(!(t in e)||!hi(s[t],e[t]))return!1;for(t in e)if(!(t in s))return!1;return!0}else return s===e}}function Ki(s,e){return s&&Object.hasOwnProperty.call(s,e)}function Cd(s,e){for(var t={},r=0;r<e.length;r++){var n=e[r],i=s[n];i!==void 0&&(t[n]=i)}return t}var Fd=["Matrix","Array"],Md=["number","BigNumber","Fraction"],dr=function(e){if(e)throw new Error(`The global config is readonly.
|
28
|
+
Please create a mathjs instance if you want to change the default configuration.
|
29
|
+
Example:
|
30
|
+
|
31
|
+
import { create, all } from 'mathjs';
|
32
|
+
const mathjs = create(all);
|
33
|
+
mathjs.config({ number: 'BigNumber' });
|
34
|
+
`);return Object.freeze($l)};Fs(dr,$l,{MATRIX_OPTIONS:Fd,NUMBER_OPTIONS:Md});function ql(){return!0}function Mr(){return!1}function pi(){}const kl="Argument is not a typed-function.";function Ul(){function s($){return typeof $=="object"&&$!==null&&$.constructor===Object}const e=[{name:"number",test:function($){return typeof $=="number"}},{name:"string",test:function($){return typeof $=="string"}},{name:"boolean",test:function($){return typeof $=="boolean"}},{name:"Function",test:function($){return typeof $=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function($){return $ instanceof Date}},{name:"RegExp",test:function($){return $ instanceof RegExp}},{name:"Object",test:s},{name:"null",test:function($){return $===null}},{name:"undefined",test:function($){return $===void 0}}],t={name:"any",test:ql,isAny:!0};let r,n,i=0,a={createCount:0};function l($){const V=r.get($);if(V)return V;let G='Unknown type "'+$+'"';const ne=$.toLowerCase();let se;for(se of n)if(se.toLowerCase()===ne){G+='. Did you mean "'+se+'" ?';break}throw new TypeError(G)}function c($){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const G=V?l(V).index:n.length,ne=[];for(let re=0;re<$.length;++re){if(!$[re]||typeof $[re].name!="string"||typeof $[re].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const fe=$[re].name;if(r.has(fe))throw new TypeError('Duplicate type name "'+fe+'"');ne.push(fe),r.set(fe,{name:fe,test:$[re].test,isAny:$[re].isAny,index:G+re,conversionsTo:[]})}const se=n.slice(G);n=n.slice(0,G).concat(ne).concat(se);for(let re=G+ne.length;re<n.length;++re)r.get(n[re]).index=re}function p(){r=new Map,n=[],i=0,c([t],!1)}p(),c(e);function h(){let $;for($ of n)r.get($).conversionsTo=[];i=0}function f($){const V=n.filter(G=>{const ne=r.get(G);return!ne.isAny&&ne.test($)});return V.length?V:["any"]}function d($){return $&&typeof $=="function"&&"_typedFunctionData"in $}function g($,V,G){if(!d($))throw new TypeError(kl);const ne=G&&G.exact,se=Array.isArray(V)?V.join(","):V,re=N(se),fe=w(re);if(!ne||fe in $.signatures){const Xe=$._typedFunctionData.signatureMap.get(fe);if(Xe)return Xe}const ue=re.length;let he;if(ne){he=[];let Xe;for(Xe in $.signatures)he.push($._typedFunctionData.signatureMap.get(Xe))}else he=$._typedFunctionData.signatures;for(let Xe=0;Xe<ue;++Xe){const nt=re[Xe],bt=[];let Ut;for(Ut of he){const zt=S(Ut.params,Xe);if(!(!zt||nt.restParam&&!zt.restParam)){if(!zt.hasAny){const vr=b(zt);if(nt.types.some(yr=>!vr.has(yr.name)))continue}bt.push(Ut)}}if(he=bt,he.length===0)break}let ae;for(ae of he)if(ae.params.length<=ue)return ae;throw new TypeError("Signature not found (signature: "+($.name||"unnamed")+"("+w(re,", ")+"))")}function y($,V,G){return g($,V,G).implementation}function m($,V){const G=l(V);if(G.test($))return $;const ne=G.conversionsTo;if(ne.length===0)throw new Error("There are no conversions to "+V+" defined.");for(let se=0;se<ne.length;se++)if(l(ne[se].from).test($))return ne[se].convert($);throw new Error("Cannot convert "+$+" to "+V)}function w($){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return $.map(G=>G.name).join(V)}function v($){const V=$.indexOf("...")===0,ne=(V?$.length>3?$.slice(3):"any":$).split("|").map(ue=>l(ue.trim()));let se=!1,re=V?"...":"";return{types:ne.map(function(ue){return se=ue.isAny||se,re+=ue.name+"|",{name:ue.name,typeIndex:ue.index,test:ue.test,isAny:ue.isAny,conversion:null,conversionIndex:-1}}),name:re.slice(0,-1),hasAny:se,hasConversion:!1,restParam:V}}function E($){const V=$.types.map(fe=>fe.name),G=K(V);let ne=$.hasAny,se=$.name;const re=G.map(function(fe){const ue=l(fe.from);return ne=ue.isAny||ne,se+="|"+fe.from,{name:fe.from,typeIndex:ue.index,test:ue.test,isAny:ue.isAny,conversion:fe,conversionIndex:fe.index}});return{types:$.types.concat(re),name:se,hasAny:ne,hasConversion:re.length>0,restParam:$.restParam}}function b($){return $.typeSet||($.typeSet=new Set,$.types.forEach(V=>$.typeSet.add(V.name))),$.typeSet}function N($){const V=[];if(typeof $!="string")throw new TypeError("Signatures must be strings");const G=$.trim();if(G==="")return V;const ne=G.split(",");for(let se=0;se<ne.length;++se){const re=v(ne[se].trim());if(re.restParam&&se!==ne.length-1)throw new SyntaxError('Unexpected rest parameter "'+ne[se]+'": only allowed for the last parameter');if(re.types.length===0)return null;V.push(re)}return V}function x($){const V=Te($);return V?V.restParam:!1}function F($){if(!$||$.types.length===0)return ql;if($.types.length===1)return l($.types[0].name).test;if($.types.length===2){const V=l($.types[0].name).test,G=l($.types[1].name).test;return function(se){return V(se)||G(se)}}else{const V=$.types.map(function(G){return l(G.name).test});return function(ne){for(let se=0;se<V.length;se++)if(V[se](ne))return!0;return!1}}}function M($){let V,G,ne;if(x($)){V=ot($).map(F);const se=V.length,re=F(Te($)),fe=function(ue){for(let he=se;he<ue.length;he++)if(!re(ue[he]))return!1;return!0};return function(he){for(let ae=0;ae<V.length;ae++)if(!V[ae](he[ae]))return!1;return fe(he)&&he.length>=se+1}}else return $.length===0?function(re){return re.length===0}:$.length===1?(G=F($[0]),function(re){return G(re[0])&&re.length===1}):$.length===2?(G=F($[0]),ne=F($[1]),function(re){return G(re[0])&&ne(re[1])&&re.length===2}):(V=$.map(F),function(re){for(let fe=0;fe<V.length;fe++)if(!V[fe](re[fe]))return!1;return re.length===V.length})}function S($,V){return V<$.length?$[V]:x($)?Te($):null}function I($,V){const G=S($,V);return G?b(G):new Set}function C($){return $.conversion===null||$.conversion===void 0}function B($,V){const G=new Set;return $.forEach(ne=>{const se=I(ne.params,V);let re;for(re of se)G.add(re)}),G.has("any")?["any"]:Array.from(G)}function L($,V,G){let ne,se;const re=$||"unnamed";let fe=G,ue;for(ue=0;ue<V.length;ue++){const nt=[];if(fe.forEach(bt=>{const Ut=S(bt.params,ue),zt=F(Ut);(ue<bt.params.length||x(bt.params))&&zt(V[ue])&&nt.push(bt)}),nt.length===0){if(se=B(fe,ue),se.length>0){const bt=f(V[ue]);return ne=new TypeError("Unexpected type of argument in function "+re+" (expected: "+se.join(" or ")+", actual: "+bt.join(" | ")+", index: "+ue+")"),ne.data={category:"wrongType",fn:re,index:ue,actual:bt,expected:se},ne}}else fe=nt}const he=fe.map(function(nt){return x(nt.params)?1/0:nt.params.length});if(V.length<Math.min.apply(null,he))return se=B(fe,ue),ne=new TypeError("Too few arguments in function "+re+" (expected: "+se.join(" or ")+", index: "+V.length+")"),ne.data={category:"tooFewArgs",fn:re,index:V.length,expected:se},ne;const ae=Math.max.apply(null,he);if(V.length>ae)return ne=new TypeError("Too many arguments in function "+re+" (expected: "+ae+", actual: "+V.length+")"),ne.data={category:"tooManyArgs",fn:re,index:V.length,expectedLength:ae},ne;const Xe=[];for(let nt=0;nt<V.length;++nt)Xe.push(f(V[nt]).join("|"));return ne=new TypeError('Arguments of type "'+Xe.join(", ")+'" do not match any of the defined signatures of function '+re+"."),ne.data={category:"mismatch",actual:Xe},ne}function U($){let V=n.length+1;for(let G=0;G<$.types.length;G++)C($.types[G])&&(V=Math.min(V,$.types[G].typeIndex));return V}function k($){let V=i+1;for(let G=0;G<$.types.length;G++)C($.types[G])||(V=Math.min(V,$.types[G].conversionIndex));return V}function W($,V){if($.hasAny){if(!V.hasAny)return 1}else if(V.hasAny)return-1;if($.restParam){if(!V.restParam)return 1}else if(V.restParam)return-1;if($.hasConversion){if(!V.hasConversion)return 1}else if(V.hasConversion)return-1;const G=U($)-U(V);if(G<0)return-1;if(G>0)return 1;const ne=k($)-k(V);return ne<0?-1:ne>0?1:0}function z($,V){const G=$.params,ne=V.params,se=Te(G),re=Te(ne),fe=x(G),ue=x(ne);if(fe&&se.hasAny){if(!ue||!re.hasAny)return 1}else if(ue&&re.hasAny)return-1;let he=0,ae=0,Xe;for(Xe of G)Xe.hasAny&&++he,Xe.hasConversion&&++ae;let nt=0,bt=0;for(Xe of ne)Xe.hasAny&&++nt,Xe.hasConversion&&++bt;if(he!==nt)return he-nt;if(fe&&se.hasConversion){if(!ue||!re.hasConversion)return 1}else if(ue&&re.hasConversion)return-1;if(ae!==bt)return ae-bt;if(fe){if(!ue)return 1}else if(ue)return-1;const Ut=(G.length-ne.length)*(fe?-1:1);if(Ut!==0)return Ut;const zt=[];let vr=0;for(let In=0;In<G.length;++In){const ei=W(G[In],ne[In]);zt.push(ei),vr+=ei}if(vr!==0)return vr;let yr;for(yr of zt)if(yr!==0)return yr;return 0}function K($){if($.length===0)return[];const V=$.map(l);$.length>1&&V.sort((se,re)=>se.index-re.index);let G=V[0].conversionsTo;if($.length===1)return G;G=G.concat([]);const ne=new Set($);for(let se=1;se<V.length;++se){let re;for(re of V[se].conversionsTo)ne.has(re.from)||(G.push(re),ne.add(re.from))}return G}function Z($,V){let G=V;if($.some(se=>se.hasConversion)){const se=x($),re=$.map(X);G=function(){const ue=[],he=se?arguments.length-1:arguments.length;for(let ae=0;ae<he;ae++)ue[ae]=re[ae](arguments[ae]);return se&&(ue[he]=arguments[he].map(re[he])),V.apply(this,ue)}}let ne=G;if(x($)){const se=$.length-1;ne=function(){return G.apply(this,Ne(arguments,0,se).concat([Ne(arguments,se)]))}}return ne}function X($){let V,G,ne,se;const re=[],fe=[];switch($.types.forEach(function(ue){ue.conversion&&(re.push(l(ue.conversion.from).test),fe.push(ue.conversion.convert))}),fe.length){case 0:return function(he){return he};case 1:return V=re[0],ne=fe[0],function(he){return V(he)?ne(he):he};case 2:return V=re[0],G=re[1],ne=fe[0],se=fe[1],function(he){return V(he)?ne(he):G(he)?se(he):he};default:return function(he){for(let ae=0;ae<fe.length;ae++)if(re[ae](he))return fe[ae](he);return he}}}function Q($){function V(G,ne,se){if(ne<G.length){const re=G[ne];let fe=[];if(re.restParam){const ue=re.types.filter(C);ue.length<re.types.length&&fe.push({types:ue,name:"..."+ue.map(he=>he.name).join("|"),hasAny:ue.some(he=>he.isAny),hasConversion:!1,restParam:!0}),fe.push(re)}else fe=re.types.map(function(ue){return{types:[ue],name:ue.name,hasAny:ue.isAny,hasConversion:ue.conversion,restParam:!1}});return rt(fe,function(ue){return V(G,ne+1,se.concat([ue]))})}else return[se]}return V($,0,[])}function ce($,V){const G=Math.max($.length,V.length);for(let ue=0;ue<G;ue++){const he=I($,ue),ae=I(V,ue);let Xe=!1,nt;for(nt of ae)if(he.has(nt)){Xe=!0;break}if(!Xe)return!1}const ne=$.length,se=V.length,re=x($),fe=x(V);return re?fe?ne===se:se>=ne:fe?ne>=se:ne===se}function ve($){return $.map(V=>Pt(V)?$t(V.referToSelf.callback):mr(V)?Je(V.referTo.references,V.referTo.callback):V)}function le($,V,G){const ne=[];let se;for(se of $){let re=G[se];if(typeof re!="number")throw new TypeError('No definition for referenced signature "'+se+'"');if(re=V[re],typeof re!="function")return!1;ne.push(re)}return ne}function we($,V,G){const ne=ve($),se=new Array(ne.length).fill(!1);let re=!0;for(;re;){re=!1;let fe=!0;for(let ue=0;ue<ne.length;++ue){if(se[ue])continue;const he=ne[ue];if(Pt(he))ne[ue]=he.referToSelf.callback(G),ne[ue].referToSelf=he.referToSelf,se[ue]=!0,fe=!1;else if(mr(he)){const ae=le(he.referTo.references,ne,V);ae?(ne[ue]=he.referTo.callback.apply(this,ae),ne[ue].referTo=he.referTo,se[ue]=!0,fe=!1):re=!0}}if(fe&&re)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return ne}function be($){const V=/\bthis(\(|\.signatures\b)/;Object.keys($).forEach(G=>{const ne=$[G];if(V.test(ne.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 Be($,V){if(a.createCount++,Object.keys(V).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&be(V);const G=[],ne=[],se={},re=[];let fe;for(fe in V){if(!Object.prototype.hasOwnProperty.call(V,fe))continue;const Ze=N(fe);if(!Ze)continue;G.forEach(function($n){if(ce($n,Ze))throw new TypeError('Conflicting signatures "'+w($n)+'" and "'+w(Ze)+'".')}),G.push(Ze);const Xt=ne.length;ne.push(V[fe]);const du=Ze.map(E);let Bi;for(Bi of Q(du)){const $n=w(Bi);re.push({params:Bi,name:$n,fn:Xt}),Bi.every(Do=>!Do.hasConversion)&&(se[$n]=Xt)}}re.sort(z);const ue=we(ne,se,ti);let he;for(he in se)Object.prototype.hasOwnProperty.call(se,he)&&(se[he]=ue[se[he]]);const ae=[],Xe=new Map;for(he of re)Xe.has(he.name)||(he.fn=ue[he.fn],ae.push(he),Xe.set(he.name,he));const nt=ae[0]&&ae[0].params.length<=2&&!x(ae[0].params),bt=ae[1]&&ae[1].params.length<=2&&!x(ae[1].params),Ut=ae[2]&&ae[2].params.length<=2&&!x(ae[2].params),zt=ae[3]&&ae[3].params.length<=2&&!x(ae[3].params),vr=ae[4]&&ae[4].params.length<=2&&!x(ae[4].params),yr=ae[5]&&ae[5].params.length<=2&&!x(ae[5].params),In=nt&&bt&&Ut&&zt&&vr&&yr;for(let Ze=0;Ze<ae.length;++Ze)ae[Ze].test=M(ae[Ze].params);const ei=nt?F(ae[0].params[0]):Mr,vo=bt?F(ae[1].params[0]):Mr,Va=Ut?F(ae[2].params[0]):Mr,Za=zt?F(ae[3].params[0]):Mr,Ka=vr?F(ae[4].params[0]):Mr,Ga=yr?F(ae[5].params[0]):Mr,yo=nt?F(ae[0].params[1]):Mr,Ha=bt?F(ae[1].params[1]):Mr,Ja=Ut?F(ae[2].params[1]):Mr,Xa=zt?F(ae[3].params[1]):Mr,ss=vr?F(ae[4].params[1]):Mr,Qa=yr?F(ae[5].params[1]):Mr;for(let Ze=0;Ze<ae.length;++Ze)ae[Ze].implementation=Z(ae[Ze].params,ae[Ze].fn);const os=nt?ae[0].implementation:pi,eu=bt?ae[1].implementation:pi,tu=Ut?ae[2].implementation:pi,ru=zt?ae[3].implementation:pi,nu=vr?ae[4].implementation:pi,iu=yr?ae[5].implementation:pi,su=nt?ae[0].params.length:-1,ou=bt?ae[1].params.length:-1,au=Ut?ae[2].params.length:-1,wo=zt?ae[3].params.length:-1,uu=vr?ae[4].params.length:-1,lu=yr?ae[5].params.length:-1,cu=In?6:0,fu=ae.length,hu=ae.map(Ze=>Ze.test),pu=ae.map(Ze=>Ze.implementation),Si=function(){for(let Xt=cu;Xt<fu;Xt++)if(hu[Xt](arguments))return pu[Xt].apply(this,arguments);return a.onMismatch($,arguments,ae)};function ti(Ze,Xt){return arguments.length===su&&ei(Ze)&&yo(Xt)?os.apply(this,arguments):arguments.length===ou&&vo(Ze)&&Ha(Xt)?eu.apply(this,arguments):arguments.length===au&&Va(Ze)&&Ja(Xt)?tu.apply(this,arguments):arguments.length===wo&&Za(Ze)&&Xa(Xt)?ru.apply(this,arguments):arguments.length===uu&&Ka(Ze)&&ss(Xt)?nu.apply(this,arguments):arguments.length===lu&&Ga(Ze)&&Qa(Xt)?iu.apply(this,arguments):Si.apply(this,arguments)}try{Object.defineProperty(ti,"name",{value:$})}catch{}return ti.signatures=se,ti._typedFunctionData={signatures:ae,signatureMap:Xe},ti}function Ee($,V,G){throw L($,V,G)}function ot($){return Ne($,0,$.length-1)}function Te($){return $[$.length-1]}function Ne($,V,G){return Array.prototype.slice.call($,V,G)}function lt($,V){for(let G=0;G<$.length;G++)if(V($[G]))return $[G]}function rt($,V){return Array.prototype.concat.apply([],$.map(V))}function ke(){const $=ot(arguments).map(G=>w(N(G))),V=Te(arguments);if(typeof V!="function")throw new TypeError("Callback function expected as last argument");return Je($,V)}function Je($,V){return{referTo:{references:$,callback:V}}}function $t($){if(typeof $!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:$}}}function mr($){return $&&typeof $.referTo=="object"&&Array.isArray($.referTo.references)&&typeof $.referTo.callback=="function"}function Pt($){return $&&typeof $.referToSelf=="object"&&typeof $.referToSelf.callback=="function"}function pn($,V){if(!$)return V;if(V&&V!==$){const G=new Error("Function names do not match (expected: "+$+", actual: "+V+")");throw G.data={actual:V,expected:$},G}return $}function On($){let V;for(const G in $)Object.prototype.hasOwnProperty.call($,G)&&(d($[G])||typeof $[G].signature=="string")&&(V=pn(V,$[G].name));return V}function dn($,V){let G;for(G in V)if(Object.prototype.hasOwnProperty.call(V,G)){if(G in $&&V[G]!==$[G]){const ne=new Error('Signature "'+G+'" is defined twice');throw ne.data={signature:G,sourceFunction:V[G],destFunction:$[G]},ne}$[G]=V[G]}}const gr=a;a=function($){const V=typeof $=="string",G=V?1:0;let ne=V?$:"";const se={};for(let re=G;re<arguments.length;++re){const fe=arguments[re];let ue={},he;if(typeof fe=="function"?(he=fe.name,typeof fe.signature=="string"?ue[fe.signature]=fe:d(fe)&&(ue=fe.signatures)):s(fe)&&(ue=fe,V||(he=On(fe))),Object.keys(ue).length===0){const ae=new TypeError("Argument to 'typed' at index "+re+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw ae.data={index:re,argument:fe},ae}V||(ne=pn(ne,he)),dn(se,ue)}return Be(ne||"",se)},a.create=Ul,a.createCount=gr.createCount,a.onMismatch=Ee,a.throwMismatchError=Ee,a.createError=L,a.clear=p,a.clearConversions=h,a.addTypes=c,a._findType=l,a.referTo=ke,a.referToSelf=$t,a.convert=m,a.findSignature=g,a.find=y,a.isTypedFunction=d,a.warnAgainstDeprecatedThis=!0,a.addType=function($,V){let G="any";V!==!1&&r.has("Object")&&(G="Object"),a.addTypes([$],G)};function Tn($){if(!$||typeof $.from!="string"||typeof $.to!="string"||typeof $.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if($.to===$.from)throw new SyntaxError('Illegal to define conversion from "'+$.from+'" to itself.')}return a.addConversion=function($){Tn($);const V=l($.to);if(V.conversionsTo.every(function(G){return G.from!==$.from}))V.conversionsTo.push({from:$.from,convert:$.convert,index:i++});else throw new Error('There is already a conversion from "'+$.from+'" to "'+V.name+'"')},a.addConversions=function($){$.forEach(a.addConversion)},a.removeConversion=function($){Tn($);const V=l($.to),G=lt(V.conversionsTo,se=>se.from===$.from);if(!G)throw new Error("Attempt to remove nonexistent conversion from "+$.from+" to "+$.to);if(G.convert!==$.convert)throw new Error("Conversion to remove does not match existing conversion");const ne=V.conversionsTo.indexOf(G);V.conversionsTo.splice(ne,1)},a.resolve=function($,V){if(!d($))throw new TypeError(kl);const G=$._typedFunctionData.signatures;for(let ne=0;ne<G.length;++ne)if(G[ne].test(V))return G[ne];return null},a}var Wl=Ul();function Dt(s){return typeof s=="boolean"?!0:isFinite(s)?s===Math.round(s):!1}function fa(s,e,t){var r={2:"0b",8:"0o",16:"0x"},n=r[e],i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!Dt(t))throw new Error("size must be an integer");if(s>2**(t-1)-1||s<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!Dt(s))throw new Error("Value must be an integer");s<0&&(s=s+2**t),i="i".concat(t)}var a="";return s<0&&(s=-s,a="-"),"".concat(a).concat(n).concat(s.toString(e)).concat(i)}function ha(s,e){if(typeof e=="function")return e(s);if(s===1/0)return"Infinity";if(s===-1/0)return"-Infinity";if(isNaN(s))return"NaN";var{notation:t,precision:r,wordSize:n}=jl(e);switch(t){case"fixed":return Sd(s,r);case"exponential":return Yl(s,r);case"engineering":return Nd(s,r);case"bin":return fa(s,2,n);case"oct":return fa(s,8,n);case"hex":return fa(s,16,n);case"auto":return Bd(s,r,e).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],a=arguments[4];return i!=="."?i+a:a});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function jl(s){var e="auto",t,r;if(s!==void 0)if(pt(s))t=s;else if(Nt(s))t=s.toNumber();else if(ca(s))s.precision!==void 0&&(t=Vl(s.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),s.wordSize!==void 0&&(r=Vl(s.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),s.notation&&(e=s.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:e,precision:t,wordSize:r}}function Ms(s){var e=String(s).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!e)throw new SyntaxError("Invalid number "+s);var t=e[1],r=e[2],n=parseFloat(e[4]||"0"),i=r.indexOf(".");n+=i!==-1?i-1:r.length-1;var a=r.replace(".","").replace(/^0*/,function(l){return n-=l.length,""}).replace(/0*$/,"").split("").map(function(l){return parseInt(l)});return a.length===0&&(a.push(0),n++),{sign:t,coefficients:a,exponent:n}}function Nd(s,e){if(isNaN(s)||!isFinite(s))return String(s);var t=Ms(s),r=Ns(t,e),n=r.exponent,i=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(pt(e))for(;e>i.length||n-a+1>i.length;)i.push(0);else for(var l=Math.abs(n-a)-(i.length-1),c=0;c<l;c++)i.push(0);for(var p=Math.abs(n-a),h=1;p>0;)h++,p--;var f=i.slice(h).join(""),d=pt(e)&&f.length||f.match(/[1-9]/)?"."+f:"",g=i.slice(0,h).join("")+d+"e"+(n>=0?"+":"")+a.toString();return r.sign+g}function Sd(s,e){if(isNaN(s)||!isFinite(s))return String(s);var t=Ms(s),r=typeof e=="number"?Ns(t,t.exponent+1+e):t,n=r.coefficients,i=r.exponent+1,a=i+(e||0);return n.length<a&&(n=n.concat(di(a-n.length))),i<0&&(n=di(-i+1).concat(n),i=1),i<n.length&&n.splice(i,0,i===0?"0.":"."),r.sign+n.join("")}function Yl(s,e){if(isNaN(s)||!isFinite(s))return String(s);var t=Ms(s),r=e?Ns(t,e):t,n=r.coefficients,i=r.exponent;n.length<e&&(n=n.concat(di(e-n.length)));var a=n.shift();return r.sign+a+(n.length>0?"."+n.join(""):"")+"e"+(i>=0?"+":"")+i}function Bd(s,e,t){if(isNaN(s)||!isFinite(s))return String(s);var r=Zl(t==null?void 0:t.lowerExp,-3),n=Zl(t==null?void 0:t.upperExp,5),i=Ms(s),a=e?Ns(i,e):i;if(a.exponent<r||a.exponent>=n)return Yl(s,e);var l=a.coefficients,c=a.exponent;l.length<e&&(l=l.concat(di(e-l.length))),l=l.concat(di(c-l.length+1+(l.length<e?e-l.length:0))),l=di(-c).concat(l);var p=c>0?c:0;return p<l.length-1&&l.splice(p+1,0,"."),a.sign+l.join("")}function Ns(s,e){for(var t={sign:s.sign,coefficients:s.coefficients,exponent:s.exponent},r=t.coefficients;e<=0;)r.unshift(0),t.exponent++,e++;if(r.length>e){var n=r.splice(e,r.length-e);if(n[0]>=5){var i=e-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),t.exponent++,i++),i--,r[i]++}}return t}function di(s){for(var e=[],t=0;t<s;t++)e.push(0);return e}function Od(s){return s.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Td=Number.EPSILON||2220446049250313e-31;function Gn(s,e,t){if(t==null)return s===e;if(s===e)return!0;if(isNaN(s)||isNaN(e))return!1;if(isFinite(s)&&isFinite(e)){var r=Math.abs(s-e);return r<=Td?!0:r<=Math.max(Math.abs(s),Math.abs(e))*t}return!1}function Vl(s,e){if(pt(s))return s;if(Nt(s))return s.toNumber();e()}function Zl(s,e){return pt(s)?s:Nt(s)?s.toNumber():e}function pa(s,e,t){var r=s.constructor,n=new r(2),i="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!Dt(t))throw new Error("size must be an integer");if(s.greaterThan(n.pow(t-1).sub(1))||s.lessThan(n.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!s.isInteger())throw new Error("Value must be an integer");s.lessThan(0)&&(s=s.add(n.pow(t))),i="i".concat(t)}switch(e){case 2:return"".concat(s.toBinary()).concat(i);case 8:return"".concat(s.toOctal()).concat(i);case 16:return"".concat(s.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(e," not supported "))}}function Id(s,e){if(typeof e=="function")return e(s);if(!s.isFinite())return s.isNaN()?"NaN":s.gt(0)?"Infinity":"-Infinity";var{notation:t,precision:r,wordSize:n}=jl(e);switch(t){case"fixed":return Ld(s,r);case"exponential":return Kl(s,r);case"engineering":return $d(s,r);case"bin":return pa(s,2,n);case"oct":return pa(s,8,n);case"hex":return pa(s,16,n);case"auto":{var i=Gl(e==null?void 0:e.lowerExp,-3),a=Gl(e==null?void 0:e.upperExp,5);if(s.isZero())return"0";var l,c=s.toSignificantDigits(r),p=c.e;return p>=i&&p<a?l=c.toFixed():l=Kl(s,r),l.replace(/((\.\d*?)(0+))($|e)/,function(){var h=arguments[2],f=arguments[4];return h!=="."?h+f:f})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function $d(s,e){var t=s.e,r=t%3===0?t:t<0?t-3-t%3:t-t%3,n=s.mul(Math.pow(10,-r)),i=n.toPrecision(e);if(i.indexOf("e")!==-1){var a=s.constructor;i=new a(i).toFixed()}return i+"e"+(t>=0?"+":"")+r.toString()}function Kl(s,e){return e!==void 0?s.toExponential(e-1):s.toExponential()}function Ld(s,e){return s.toFixed(e)}function Gl(s,e){return pt(s)?s:Nt(s)?s.toNumber():e}function ct(s,e){var t=Rd(s,e);return e&&typeof e=="object"&&"truncate"in e&&t.length>e.truncate?t.substring(0,e.truncate-3)+"...":t}function Rd(s,e){if(typeof s=="number")return ha(s,e);if(Nt(s))return Id(s,e);if(Pd(s))return!e||e.fraction!=="decimal"?s.s*s.n+"/"+s.d:s.toString();if(Array.isArray(s))return Xl(s,e);if(en(s))return Hl(s);if(typeof s=="function")return s.syntax?String(s.syntax):"function";if(s&&typeof s=="object"){if(typeof s.format=="function")return s.format(e);if(s&&s.toString(e)!=={}.toString())return s.toString(e);var t=Object.keys(s).map(r=>Hl(r)+": "+ct(s[r],e));return"{"+t.join(", ")+"}"}return String(s)}function Hl(s){for(var e=String(s),t="",r=0;r<e.length;){var n=e.charAt(r);t+=n in Jl?Jl[n]:n,r++}return'"'+t+'"'}var Jl={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Xl(s,e){if(Array.isArray(s)){for(var t="[",r=s.length,n=0;n<r;n++)n!==0&&(t+=", "),t+=Xl(s[n],e);return t+="]",t}else return ct(s,e)}function Pd(s){return s&&typeof s=="object"&&typeof s.s=="number"&&typeof s.n=="number"&&typeof s.d=="number"||!1}function He(s,e,t){if(!(this instanceof He))throw new SyntaxError("Constructor must be called with the new operator");this.actual=s,this.expected=e,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(s)?"["+s.join(", ")+"]":s)+" "+(this.relation||"!=")+" "+(Array.isArray(e)?"["+e.join(", ")+"]":e)+")",this.stack=new Error().stack}He.prototype=new RangeError,He.prototype.constructor=RangeError,He.prototype.name="DimensionError",He.prototype.isDimensionError=!0;function An(s,e,t){if(!(this instanceof An))throw new SyntaxError("Constructor must be called with the new operator");this.index=s,arguments.length<3?(this.min=0,this.max=e):(this.min=e,this.max=t),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}An.prototype=new RangeError,An.prototype.constructor=RangeError,An.prototype.name="IndexError",An.prototype.isIndexError=!0;function Tt(s){for(var e=[];Array.isArray(s);)e.push(s.length),s=s[0];return e}function Ql(s,e,t){var r,n=s.length;if(n!==e[t])throw new He(n,e[t]);if(t<e.length-1){var i=t+1;for(r=0;r<n;r++){var a=s[r];if(!Array.isArray(a))throw new He(e.length-1,e.length,"<");Ql(s[r],e,i)}}else for(r=0;r<n;r++)if(Array.isArray(s[r]))throw new He(e.length+1,e.length,">")}function ec(s,e){var t=e.length===0;if(t){if(Array.isArray(s))throw new He(s.length,0)}else Ql(s,e,0)}function At(s,e){if(s!==void 0){if(!pt(s)||!Dt(s))throw new TypeError("Index must be an integer (value: "+s+")");if(s<0||typeof e=="number"&&s>=e)throw new An(s,e)}}function da(s,e,t){if(!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new Error("Resizing to scalar is not supported");e.forEach(function(n){if(!pt(n)||!Dt(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+ct(e)+")")}),(pt(s)||Nt(s))&&(s=[s]);var r=t!==void 0?t:0;return _a(s,e,0,r),s}function _a(s,e,t,r){var n,i,a=s.length,l=e[t],c=Math.min(a,l);if(s.length=l,t<e.length-1){var p=t+1;for(n=0;n<c;n++)i=s[n],Array.isArray(i)||(i=[i],s[n]=i),_a(i,e,p,r);for(n=c;n<l;n++)i=[],s[n]=i,_a(i,e,p,r)}else{for(n=0;n<c;n++)for(;Array.isArray(s[n]);)s[n]=s[n][0];for(n=c;n<l;n++)s[n]=r}}function ma(s,e){var t=va(s),r=t.length;if(!Array.isArray(s)||!Array.isArray(e))throw new TypeError("Array expected");if(e.length===0)throw new He(0,r,"!=");e=ga(e,r);var n=tc(e);if(r!==n)throw new He(n,r,"!=");try{return zd(t,e)}catch(i){throw i instanceof He?new He(n,r,"!="):i}}function ga(s,e){var t=tc(s),r=s.slice(),n=-1,i=s.indexOf(n),a=s.indexOf(n,i+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var l=i>=0,c=e%t===0;if(l)if(c)r[i]=-e/t;else throw new Error("Could not replace wildcard, since "+e+" is no multiple of "+-t);return r}function tc(s){return s.reduce((e,t)=>e*t,1)}function zd(s,e){for(var t=s,r,n=e.length-1;n>0;n--){var i=e[n];r=[];for(var a=t.length/i,l=0;l<a;l++)r.push(t.slice(l*i,(l+1)*i));t=r}return t}function rc(s,e,t,r){var n=r||Tt(s);if(t)for(var i=0;i<t;i++)s=[s],n.unshift(1);for(s=nc(s,e,0);n.length<e;)n.push(1);return s}function nc(s,e,t){var r,n;if(Array.isArray(s)){var i=t+1;for(r=0,n=s.length;r<n;r++)s[r]=nc(s[r],e,i)}else for(var a=t;a<e;a++)s=[s];return s}function va(s){if(!Array.isArray(s))return s;var e=[];return s.forEach(function t(r){Array.isArray(r)?r.forEach(t):e.push(r)}),e}function Ss(s,e){for(var t,r=0,n=0;n<s.length;n++){var i=s[n],a=Array.isArray(i);if(n===0&&a&&(r=i.length),a&&i.length!==r)return;var l=a?Ss(i,e):e(i);if(t===void 0)t=l;else if(t!==l)return"mixed"}return t}function ic(s,e,t,r){if(r<t){if(s.length!==e.length)throw new He(s.length,e.length);for(var n=[],i=0;i<s.length;i++)n[i]=ic(s[i],e[i],t,r+1);return n}else return s.concat(e)}function sc(){var s=Array.prototype.slice.call(arguments,0,-1),e=Array.prototype.slice.call(arguments,-1);if(s.length===1)return s[0];if(s.length>1)return s.slice(1).reduce(function(t,r){return ic(t,r,e,0)},s[0]);throw new Error("Wrong number of arguments in function concat")}function qd(){for(var s=arguments.length,e=new Array(s),t=0;t<s;t++)e[t]=arguments[t];for(var r=e.map(d=>d.length),n=Math.max(...r),i=new Array(n).fill(null),a=0;a<e.length;a++)for(var l=e[a],c=r[a],p=0;p<c;p++){var h=n-c+p;l[p]>i[h]&&(i[h]=l[p])}for(var f=0;f<e.length;f++)Bs(e[f],i);return i}function Bs(s,e){for(var t=e.length,r=s.length,n=0;n<r;n++){var i=t-r+n;if(s[n]<e[i]&&s[n]>1||s[n]>e[i])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(s,") not possible to broadcast dimension ").concat(r," with size ").concat(s[n]," to size ").concat(e[i]))}}function oc(s,e){var t=Tt(s);if(hi(t,e))return s;Bs(t,e);var r=qd(t,e),n=r.length,i=[...Array(n-t.length).fill(1),...t],a=Ud(s);t.length<n&&(a=ma(a,i),t=Tt(a));for(var l=0;l<n;l++)t[l]<r[l]&&(a=kd(a,r[l],l),t=Tt(a));return a}function kd(s,e,t){return sc(...Array(e).fill(s),t)}function Ud(s){return Fs([],s)}function me(s,e,t,r){function n(i){var a=Cd(i,e.map(Yd));return Wd(s,e,i),t(a)}return n.isFactory=!0,n.fn=s,n.dependencies=e.slice().sort(),r&&(n.meta=r),n}function Wd(s,e,t){var r=e.filter(i=>!jd(i)).every(i=>t[i]!==void 0);if(!r){var n=e.filter(i=>t[i]===void 0);throw new Error('Cannot create function "'.concat(s,'", ')+"some dependencies are missing: ".concat(n.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function jd(s){return s&&s[0]==="?"}function Yd(s){return s&&s[0]==="?"?s.slice(1):s}function Vd(s,e){if(uc(s)&&ac(s,e))return s[e];throw typeof s[e]=="function"&&Gd(s,e)?new Error('Cannot access method "'+e+'" as a property'):new Error('No access to property "'+e+'"')}function Zd(s,e,t){if(uc(s)&&ac(s,e))return s[e]=t,t;throw new Error('No access to property "'+e+'"')}function Kd(s,e){return e in s}function ac(s,e){return!s||typeof s!="object"?!1:Ki(Hd,e)?!0:!(e in Object.prototype||e in Function.prototype)}function Gd(s,e){return s==null||typeof s[e]!="function"||Ki(s,e)&&Object.getPrototypeOf&&e in Object.getPrototypeOf(s)?!1:Ki(Jd,e)?!0:!(e in Object.prototype||e in Function.prototype)}function uc(s){return typeof s=="object"&&s&&s.constructor===Object}var Hd={length:!0,name:!0},Jd={toString:!0,valueOf:!0,toLocaleString:!0};class Xd{constructor(e){this.wrappedObject=e,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(e){return Vd(this.wrappedObject,e)}set(e,t){return Zd(this.wrappedObject,e,t),this}has(e){return Kd(this.wrappedObject,e)}entries(){return Qd(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){delete this.wrappedObject[e]}clear(){for(var e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}}function Qd(s,e){return{next:()=>{var t=s.next();return t.done?t:{value:e(t.value),done:!1}}}}function e_(s){return s?s instanceof Map||s instanceof Xd||typeof s.set=="function"&&typeof s.get=="function"&&typeof s.keys=="function"&&typeof s.has=="function":!1}var lc=function(){return lc=Wl.create,Wl},t_=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],r_=me("typed",t_,function(e){var{BigNumber:t,Complex:r,DenseMatrix:n,Fraction:i}=e,a=lc();return a.clear(),a.addTypes([{name:"number",test:pt},{name:"Complex",test:Ll},{name:"BigNumber",test:Nt},{name:"Fraction",test:Rl},{name:"Unit",test:Pl},{name:"identifier",test:l=>en&&/^(?:[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:en},{name:"Chain",test:xd},{name:"Array",test:xt},{name:"Matrix",test:vt},{name:"DenseMatrix",test:Jp},{name:"SparseMatrix",test:Xp},{name:"Range",test:Qp},{name:"Index",test:la},{name:"boolean",test:ed},{name:"ResultSet",test:td},{name:"Help",test:rd},{name:"function",test:nd},{name:"Date",test:id},{name:"RegExp",test:sd},{name:"null",test:od},{name:"undefined",test:ad},{name:"AccessorNode",test:ud},{name:"ArrayNode",test:ld},{name:"AssignmentNode",test:cd},{name:"BlockNode",test:fd},{name:"ConditionalNode",test:hd},{name:"ConstantNode",test:pd},{name:"FunctionNode",test:_d},{name:"FunctionAssignmentNode",test:dd},{name:"IndexNode",test:md},{name:"Node",test:gd},{name:"ObjectNode",test:vd},{name:"OperatorNode",test:yd},{name:"ParenthesisNode",test:wd},{name:"RangeNode",test:Dd},{name:"RelationalNode",test:bd},{name:"SymbolNode",test:Ed},{name:"Map",test:e_},{name:"Object",test:ca}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(t||ya(c),Od(c)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+c+"). Use function bignumber(x) to convert to BigNumber.");return new t(c)}},{from:"number",to:"Complex",convert:function(c){return r||Os(c),new r(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return r||Os(c),new r(c.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(c){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(c){return r||Os(c),new r(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){i||wa(c);var p=new i(c);if(p.valueOf()!==c)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+c+"). Use function fraction(x) to convert to Fraction.");return p}},{from:"string",to:"number",convert:function(c){var p=Number(c);if(isNaN(p))throw new Error('Cannot convert "'+c+'" to a number');return p}},{from:"string",to:"BigNumber",convert:function(c){t||ya(c);try{return new t(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(c){i||wa(c);try{return new i(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){r||Os(c);try{return new r(c)}catch{throw new Error('Cannot convert "'+c+'" to Complex')}}},{from:"boolean",to:"number",convert:function(c){return+c}},{from:"boolean",to:"BigNumber",convert:function(c){return t||ya(c),new t(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return i||wa(c),new i(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return n||n_(),new n(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),a.onMismatch=(l,c,p)=>{var h=a.createError(l,c,p);if(["wrongType","mismatch"].includes(h.data.category)&&c.length===1&&Zi(c[0])&&p.some(d=>!d.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=h.data,f}throw h},a.onMismatch=(l,c,p)=>{var h=a.createError(l,c,p);if(["wrongType","mismatch"].includes(h.data.category)&&c.length===1&&Zi(c[0])&&p.some(d=>!d.params.includes(","))){var f=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw f.data=h.data,f}throw h},a});function ya(s){throw new Error("Cannot convert value ".concat(s," into a BigNumber: no class 'BigNumber' provided"))}function Os(s){throw new Error("Cannot convert value ".concat(s," into a Complex number: no class 'Complex' provided"))}function n_(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function wa(s){throw new Error("Cannot convert value ".concat(s," into a Fraction, no class 'Fraction' provided."))}/*!
|
35
|
+
* decimal.js v10.4.3
|
36
|
+
* An arbitrary-precision Decimal type for JavaScript.
|
37
|
+
* https://github.com/MikeMcl/decimal.js
|
38
|
+
* Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
|
39
|
+
* MIT Licence
|
40
|
+
*/var _i=9e15,Cn=1e9,Da="0123456789abcdef",Ts="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Is="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ba={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-_i,maxE:_i,crypto:!1},cc,ln,Se=!0,$s="[DecimalError] ",Fn=$s+"Invalid argument: ",fc=$s+"Precision limit exceeded",hc=$s+"crypto unavailable",pc="[object Decimal]",Ht=Math.floor,Rt=Math.pow,i_=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,s_=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,o_=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,dc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,jr=1e7,xe=7,a_=9007199254740991,u_=Ts.length-1,Ea=Is.length-1,ie={toStringTag:pc};ie.absoluteValue=ie.abs=function(){var s=new this.constructor(this);return s.s<0&&(s.s=1),De(s)},ie.ceil=function(){return De(new this.constructor(this),this.e+1,2)},ie.clampedTo=ie.clamp=function(s,e){var t,r=this,n=r.constructor;if(s=new n(s),e=new n(e),!s.s||!e.s)return new n(NaN);if(s.gt(e))throw Error(Fn+e);return t=r.cmp(s),t<0?s:r.cmp(e)>0?e:new n(r)},ie.comparedTo=ie.cmp=function(s){var e,t,r,n,i=this,a=i.d,l=(s=new i.constructor(s)).d,c=i.s,p=s.s;if(!a||!l)return!c||!p?NaN:c!==p?c:a===l?0:!a^c<0?1:-1;if(!a[0]||!l[0])return a[0]?c:l[0]?-p:0;if(c!==p)return c;if(i.e!==s.e)return i.e>s.e^c<0?1:-1;for(r=a.length,n=l.length,e=0,t=r<n?r:n;e<t;++e)if(a[e]!==l[e])return a[e]>l[e]^c<0?1:-1;return r===n?0:r>n^c<0?1:-1},ie.cosine=ie.cos=function(){var s,e,t=this,r=t.constructor;return t.d?t.d[0]?(s=r.precision,e=r.rounding,r.precision=s+Math.max(t.e,t.sd())+xe,r.rounding=1,t=l_(r,wc(r,t)),r.precision=s,r.rounding=e,De(ln==2||ln==3?t.neg():t,s,e,!0)):new r(1):new r(NaN)},ie.cubeRoot=ie.cbrt=function(){var s,e,t,r,n,i,a,l,c,p,h=this,f=h.constructor;if(!h.isFinite()||h.isZero())return new f(h);for(Se=!1,i=h.s*Rt(h.s*h,1/3),!i||Math.abs(i)==1/0?(t=Vt(h.d),s=h.e,(i=(s-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Rt(t,1/3),s=Ht((s+1)/3)-(s%3==(s<0?-1:2)),i==1/0?t="5e"+s:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+s),r=new f(t),r.s=h.s):r=new f(i.toString()),a=(s=f.precision)+3;;)if(l=r,c=l.times(l).times(l),p=c.plus(h),r=ft(p.plus(h).times(l),p.plus(c),a+2,1),Vt(l.d).slice(0,a)===(t=Vt(r.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!n&&t=="4999"){if(!n&&(De(l,s+1,0),l.times(l).times(l).eq(h))){r=l;break}a+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(De(r,s+1,1),e=!r.times(r).times(r).eq(h));break}return Se=!0,De(r,s,f.rounding,e)},ie.decimalPlaces=ie.dp=function(){var s,e=this.d,t=NaN;if(e){if(s=e.length-1,t=(s-Ht(this.e/xe))*xe,s=e[s],s)for(;s%10==0;s/=10)t--;t<0&&(t=0)}return t},ie.dividedBy=ie.div=function(s){return ft(this,new this.constructor(s))},ie.dividedToIntegerBy=ie.divToInt=function(s){var e=this,t=e.constructor;return De(ft(e,new t(s),0,1,1),t.precision,t.rounding)},ie.equals=ie.eq=function(s){return this.cmp(s)===0},ie.floor=function(){return De(new this.constructor(this),this.e+1,3)},ie.greaterThan=ie.gt=function(s){return this.cmp(s)>0},ie.greaterThanOrEqualTo=ie.gte=function(s){var e=this.cmp(s);return e==1||e===0},ie.hyperbolicCosine=ie.cosh=function(){var s,e,t,r,n,i=this,a=i.constructor,l=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return l;t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,n=i.d.length,n<32?(s=Math.ceil(n/3),e=(1/zs(4,s)).toString()):(s=16,e="2.3283064365386962890625e-10"),i=mi(a,1,i.times(e),new a(1),!0);for(var c,p=s,h=new a(8);p--;)c=i.times(i),i=l.minus(c.times(h.minus(c.times(h))));return De(i,a.precision=t,a.rounding=r,!0)},ie.hyperbolicSine=ie.sinh=function(){var s,e,t,r,n=this,i=n.constructor;if(!n.isFinite()||n.isZero())return new i(n);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(n.e,n.sd())+4,i.rounding=1,r=n.d.length,r<3)n=mi(i,2,n,n,!0);else{s=1.4*Math.sqrt(r),s=s>16?16:s|0,n=n.times(1/zs(5,s)),n=mi(i,2,n,n,!0);for(var a,l=new i(5),c=new i(16),p=new i(20);s--;)a=n.times(n),n=n.times(l.plus(a.times(c.times(a).plus(p))))}return i.precision=e,i.rounding=t,De(n,e,t,!0)},ie.hyperbolicTangent=ie.tanh=function(){var s,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(s=r.precision,e=r.rounding,r.precision=s+7,r.rounding=1,ft(t.sinh(),t.cosh(),r.precision=s,r.rounding=e)):new r(t.s)},ie.inverseCosine=ie.acos=function(){var s,e=this,t=e.constructor,r=e.abs().cmp(1),n=t.precision,i=t.rounding;return r!==-1?r===0?e.isNeg()?Yr(t,n,i):new t(0):new t(NaN):e.isZero()?Yr(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=e.asin(),s=Yr(t,n+4,i).times(.5),t.precision=n,t.rounding=i,s.minus(e))},ie.inverseHyperbolicCosine=ie.acosh=function(){var s,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(s=r.precision,e=r.rounding,r.precision=s+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,Se=!1,t=t.times(t).minus(1).sqrt().plus(t),Se=!0,r.precision=s,r.rounding=e,t.ln()):new r(t)},ie.inverseHyperbolicSine=ie.asinh=function(){var s,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(s=r.precision,e=r.rounding,r.precision=s+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,Se=!1,t=t.times(t).plus(1).sqrt().plus(t),Se=!0,r.precision=s,r.rounding=e,t.ln())},ie.inverseHyperbolicTangent=ie.atanh=function(){var s,e,t,r,n=this,i=n.constructor;return n.isFinite()?n.e>=0?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(s=i.precision,e=i.rounding,r=n.sd(),Math.max(r,s)<2*-n.e-1?De(new i(n),s,e,!0):(i.precision=t=r-n.e,n=ft(n.plus(1),new i(1).minus(n),t+s,1),i.precision=s+4,i.rounding=1,n=n.ln(),i.precision=s,i.rounding=e,n.times(.5))):new i(NaN)},ie.inverseSine=ie.asin=function(){var s,e,t,r,n=this,i=n.constructor;return n.isZero()?new i(n):(e=n.abs().cmp(1),t=i.precision,r=i.rounding,e!==-1?e===0?(s=Yr(i,t+4,r).times(.5),s.s=n.s,s):new i(NaN):(i.precision=t+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=r,n.times(2)))},ie.inverseTangent=ie.atan=function(){var s,e,t,r,n,i,a,l,c,p=this,h=p.constructor,f=h.precision,d=h.rounding;if(p.isFinite()){if(p.isZero())return new h(p);if(p.abs().eq(1)&&f+4<=Ea)return a=Yr(h,f+4,d).times(.25),a.s=p.s,a}else{if(!p.s)return new h(NaN);if(f+4<=Ea)return a=Yr(h,f+4,d).times(.5),a.s=p.s,a}for(h.precision=l=f+10,h.rounding=1,t=Math.min(28,l/xe+2|0),s=t;s;--s)p=p.div(p.times(p).plus(1).sqrt().plus(1));for(Se=!1,e=Math.ceil(l/xe),r=1,c=p.times(p),a=new h(p),n=p;s!==-1;)if(n=n.times(c),i=a.minus(n.div(r+=2)),n=n.times(c),a=i.plus(n.div(r+=2)),a.d[e]!==void 0)for(s=e;a.d[s]===i.d[s]&&s--;);return t&&(a=a.times(2<<t-1)),Se=!0,De(a,h.precision=f,h.rounding=d,!0)},ie.isFinite=function(){return!!this.d},ie.isInteger=ie.isInt=function(){return!!this.d&&Ht(this.e/xe)>this.d.length-2},ie.isNaN=function(){return!this.s},ie.isNegative=ie.isNeg=function(){return this.s<0},ie.isPositive=ie.isPos=function(){return this.s>0},ie.isZero=function(){return!!this.d&&this.d[0]===0},ie.lessThan=ie.lt=function(s){return this.cmp(s)<0},ie.lessThanOrEqualTo=ie.lte=function(s){return this.cmp(s)<1},ie.logarithm=ie.log=function(s){var e,t,r,n,i,a,l,c,p=this,h=p.constructor,f=h.precision,d=h.rounding,g=5;if(s==null)s=new h(10),e=!0;else{if(s=new h(s),t=s.d,s.s<0||!t||!t[0]||s.eq(1))return new h(NaN);e=s.eq(10)}if(t=p.d,p.s<0||!t||!t[0]||p.eq(1))return new h(t&&!t[0]?-1/0:p.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(n=t[0];n%10===0;)n/=10;i=n!==1}if(Se=!1,l=f+g,a=Nn(p,l),r=e?Ps(h,l+10):Nn(s,l),c=ft(a,r,l,1),Gi(c.d,n=f,d))do if(l+=10,a=Nn(p,l),r=e?Ps(h,l+10):Nn(s,l),c=ft(a,r,l,1),!i){+Vt(c.d).slice(n+1,n+15)+1==1e14&&(c=De(c,f+1,0));break}while(Gi(c.d,n+=10,d));return Se=!0,De(c,f,d)},ie.minus=ie.sub=function(s){var e,t,r,n,i,a,l,c,p,h,f,d,g=this,y=g.constructor;if(s=new y(s),!g.d||!s.d)return!g.s||!s.s?s=new y(NaN):g.d?s.s=-s.s:s=new y(s.d||g.s!==s.s?g:NaN),s;if(g.s!=s.s)return s.s=-s.s,g.plus(s);if(p=g.d,d=s.d,l=y.precision,c=y.rounding,!p[0]||!d[0]){if(d[0])s.s=-s.s;else if(p[0])s=new y(g);else return new y(c===3?-0:0);return Se?De(s,l,c):s}if(t=Ht(s.e/xe),h=Ht(g.e/xe),p=p.slice(),i=h-t,i){for(f=i<0,f?(e=p,i=-i,a=d.length):(e=d,t=h,a=p.length),r=Math.max(Math.ceil(l/xe),a)+2,i>r&&(i=r,e.length=1),e.reverse(),r=i;r--;)e.push(0);e.reverse()}else{for(r=p.length,a=d.length,f=r<a,f&&(a=r),r=0;r<a;r++)if(p[r]!=d[r]){f=p[r]<d[r];break}i=0}for(f&&(e=p,p=d,d=e,s.s=-s.s),a=p.length,r=d.length-a;r>0;--r)p[a++]=0;for(r=d.length;r>i;){if(p[--r]<d[r]){for(n=r;n&&p[--n]===0;)p[n]=jr-1;--p[n],p[r]+=jr}p[r]-=d[r]}for(;p[--a]===0;)p.pop();for(;p[0]===0;p.shift())--t;return p[0]?(s.d=p,s.e=Rs(p,t),Se?De(s,l,c):s):new y(c===3?-0:0)},ie.modulo=ie.mod=function(s){var e,t=this,r=t.constructor;return s=new r(s),!t.d||!s.s||s.d&&!s.d[0]?new r(NaN):!s.d||t.d&&!t.d[0]?De(new r(t),r.precision,r.rounding):(Se=!1,r.modulo==9?(e=ft(t,s.abs(),0,3,1),e.s*=s.s):e=ft(t,s,0,r.modulo,1),e=e.times(s),Se=!0,t.minus(e))},ie.naturalExponential=ie.exp=function(){return xa(this)},ie.naturalLogarithm=ie.ln=function(){return Nn(this)},ie.negated=ie.neg=function(){var s=new this.constructor(this);return s.s=-s.s,De(s)},ie.plus=ie.add=function(s){var e,t,r,n,i,a,l,c,p,h,f=this,d=f.constructor;if(s=new d(s),!f.d||!s.d)return!f.s||!s.s?s=new d(NaN):f.d||(s=new d(s.d||f.s===s.s?f:NaN)),s;if(f.s!=s.s)return s.s=-s.s,f.minus(s);if(p=f.d,h=s.d,l=d.precision,c=d.rounding,!p[0]||!h[0])return h[0]||(s=new d(f)),Se?De(s,l,c):s;if(i=Ht(f.e/xe),r=Ht(s.e/xe),p=p.slice(),n=i-r,n){for(n<0?(t=p,n=-n,a=h.length):(t=h,r=i,a=p.length),i=Math.ceil(l/xe),a=i>a?i+1:a+1,n>a&&(n=a,t.length=1),t.reverse();n--;)t.push(0);t.reverse()}for(a=p.length,n=h.length,a-n<0&&(n=a,t=h,h=p,p=t),e=0;n;)e=(p[--n]=p[n]+h[n]+e)/jr|0,p[n]%=jr;for(e&&(p.unshift(e),++r),a=p.length;p[--a]==0;)p.pop();return s.d=p,s.e=Rs(p,r),Se?De(s,l,c):s},ie.precision=ie.sd=function(s){var e,t=this;if(s!==void 0&&s!==!!s&&s!==1&&s!==0)throw Error(Fn+s);return t.d?(e=_c(t.d),s&&t.e+1>e&&(e=t.e+1)):e=NaN,e},ie.round=function(){var s=this,e=s.constructor;return De(new e(s),s.e+1,e.rounding)},ie.sine=ie.sin=function(){var s,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(s=r.precision,e=r.rounding,r.precision=s+Math.max(t.e,t.sd())+xe,r.rounding=1,t=f_(r,wc(r,t)),r.precision=s,r.rounding=e,De(ln>2?t.neg():t,s,e,!0)):new r(NaN)},ie.squareRoot=ie.sqrt=function(){var s,e,t,r,n,i,a=this,l=a.d,c=a.e,p=a.s,h=a.constructor;if(p!==1||!l||!l[0])return new h(!p||p<0&&(!l||l[0])?NaN:l?a:1/0);for(Se=!1,p=Math.sqrt(+a),p==0||p==1/0?(e=Vt(l),(e.length+c)%2==0&&(e+="0"),p=Math.sqrt(e),c=Ht((c+1)/2)-(c<0||c%2),p==1/0?e="5e"+c:(e=p.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),r=new h(e)):r=new h(p.toString()),t=(c=h.precision)+3;;)if(i=r,r=i.plus(ft(a,i,t+2,1)).times(.5),Vt(i.d).slice(0,t)===(e=Vt(r.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!n&&e=="4999"){if(!n&&(De(i,c+1,0),i.times(i).eq(a))){r=i;break}t+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(De(r,c+1,1),s=!r.times(r).eq(a));break}return Se=!0,De(r,c,h.rounding,s)},ie.tangent=ie.tan=function(){var s,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(s=r.precision,e=r.rounding,r.precision=s+10,r.rounding=1,t=t.sin(),t.s=1,t=ft(t,new r(1).minus(t.times(t)).sqrt(),s+10,0),r.precision=s,r.rounding=e,De(ln==2||ln==4?t.neg():t,s,e,!0)):new r(NaN)},ie.times=ie.mul=function(s){var e,t,r,n,i,a,l,c,p,h=this,f=h.constructor,d=h.d,g=(s=new f(s)).d;if(s.s*=h.s,!d||!d[0]||!g||!g[0])return new f(!s.s||d&&!d[0]&&!g||g&&!g[0]&&!d?NaN:!d||!g?s.s/0:s.s*0);for(t=Ht(h.e/xe)+Ht(s.e/xe),c=d.length,p=g.length,c<p&&(i=d,d=g,g=i,a=c,c=p,p=a),i=[],a=c+p,r=a;r--;)i.push(0);for(r=p;--r>=0;){for(e=0,n=c+r;n>r;)l=i[n]+g[r]*d[n-r-1]+e,i[n--]=l%jr|0,e=l/jr|0;i[n]=(i[n]+e)%jr|0}for(;!i[--a];)i.pop();return e?++t:i.shift(),s.d=i,s.e=Rs(i,t),Se?De(s,f.precision,f.rounding):s},ie.toBinary=function(s,e){return Ca(this,2,s,e)},ie.toDecimalPlaces=ie.toDP=function(s,e){var t=this,r=t.constructor;return t=new r(t),s===void 0?t:(ar(s,0,Cn),e===void 0?e=r.rounding:ar(e,0,8),De(t,s+t.e+1,e))},ie.toExponential=function(s,e){var t,r=this,n=r.constructor;return s===void 0?t=tn(r,!0):(ar(s,0,Cn),e===void 0?e=n.rounding:ar(e,0,8),r=De(new n(r),s+1,e),t=tn(r,!0,s+1)),r.isNeg()&&!r.isZero()?"-"+t:t},ie.toFixed=function(s,e){var t,r,n=this,i=n.constructor;return s===void 0?t=tn(n):(ar(s,0,Cn),e===void 0?e=i.rounding:ar(e,0,8),r=De(new i(n),s+n.e+1,e),t=tn(r,!1,s+r.e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},ie.toFraction=function(s){var e,t,r,n,i,a,l,c,p,h,f,d,g=this,y=g.d,m=g.constructor;if(!y)return new m(g);if(p=t=new m(1),r=c=new m(0),e=new m(r),i=e.e=_c(y)-g.e-1,a=i%xe,e.d[0]=Rt(10,a<0?xe+a:a),s==null)s=i>0?e:p;else{if(l=new m(s),!l.isInt()||l.lt(p))throw Error(Fn+l);s=l.gt(e)?i>0?e:p:l}for(Se=!1,l=new m(Vt(y)),h=m.precision,m.precision=i=y.length*xe*2;f=ft(l,e,0,1,1),n=t.plus(f.times(r)),n.cmp(s)!=1;)t=r,r=n,n=p,p=c.plus(f.times(n)),c=n,n=e,e=l.minus(f.times(n)),l=n;return n=ft(s.minus(t),r,0,1,1),c=c.plus(n.times(p)),t=t.plus(n.times(r)),c.s=p.s=g.s,d=ft(p,r,i,1).minus(g).abs().cmp(ft(c,t,i,1).minus(g).abs())<1?[p,r]:[c,t],m.precision=h,Se=!0,d},ie.toHexadecimal=ie.toHex=function(s,e){return Ca(this,16,s,e)},ie.toNearest=function(s,e){var t=this,r=t.constructor;if(t=new r(t),s==null){if(!t.d)return t;s=new r(1),e=r.rounding}else{if(s=new r(s),e===void 0?e=r.rounding:ar(e,0,8),!t.d)return s.s?t:s;if(!s.d)return s.s&&(s.s=t.s),s}return s.d[0]?(Se=!1,t=ft(t,s,0,e,1).times(s),Se=!0,De(t)):(s.s=t.s,t=s),t},ie.toNumber=function(){return+this},ie.toOctal=function(s,e){return Ca(this,8,s,e)},ie.toPower=ie.pow=function(s){var e,t,r,n,i,a,l=this,c=l.constructor,p=+(s=new c(s));if(!l.d||!s.d||!l.d[0]||!s.d[0])return new c(Rt(+l,p));if(l=new c(l),l.eq(1))return l;if(r=c.precision,i=c.rounding,s.eq(1))return De(l,r,i);if(e=Ht(s.e/xe),e>=s.d.length-1&&(t=p<0?-p:p)<=a_)return n=mc(c,l,t,r),s.s<0?new c(1).div(n):De(n,r,i);if(a=l.s,a<0){if(e<s.d.length-1)return new c(NaN);if(s.d[e]&1||(a=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=a,l}return t=Rt(+l,p),e=t==0||!isFinite(t)?Ht(p*(Math.log("0."+Vt(l.d))/Math.LN10+l.e+1)):new c(t+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?a/0:0):(Se=!1,c.rounding=l.s=1,t=Math.min(12,(e+"").length),n=xa(s.times(Nn(l,r+t)),r),n.d&&(n=De(n,r+5,1),Gi(n.d,r,i)&&(e=r+10,n=De(xa(s.times(Nn(l,e+t)),e),e+5,1),+Vt(n.d).slice(r+1,r+15)+1==1e14&&(n=De(n,r+1,0)))),n.s=a,Se=!0,c.rounding=i,De(n,r,i))},ie.toPrecision=function(s,e){var t,r=this,n=r.constructor;return s===void 0?t=tn(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(ar(s,1,Cn),e===void 0?e=n.rounding:ar(e,0,8),r=De(new n(r),s,e),t=tn(r,s<=r.e||r.e<=n.toExpNeg,s)),r.isNeg()&&!r.isZero()?"-"+t:t},ie.toSignificantDigits=ie.toSD=function(s,e){var t=this,r=t.constructor;return s===void 0?(s=r.precision,e=r.rounding):(ar(s,1,Cn),e===void 0?e=r.rounding:ar(e,0,8)),De(new r(t),s,e)},ie.toString=function(){var s=this,e=s.constructor,t=tn(s,s.e<=e.toExpNeg||s.e>=e.toExpPos);return s.isNeg()&&!s.isZero()?"-"+t:t},ie.truncated=ie.trunc=function(){return De(new this.constructor(this),this.e+1,1)},ie.valueOf=ie.toJSON=function(){var s=this,e=s.constructor,t=tn(s,s.e<=e.toExpNeg||s.e>=e.toExpPos);return s.isNeg()?"-"+t:t};function Vt(s){var e,t,r,n=s.length-1,i="",a=s[0];if(n>0){for(i+=a,e=1;e<n;e++)r=s[e]+"",t=xe-r.length,t&&(i+=Mn(t)),i+=r;a=s[e],r=a+"",t=xe-r.length,t&&(i+=Mn(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function ar(s,e,t){if(s!==~~s||s<e||s>t)throw Error(Fn+s)}function Gi(s,e,t,r){var n,i,a,l;for(i=s[0];i>=10;i/=10)--e;return--e<0?(e+=xe,n=0):(n=Math.ceil((e+1)/xe),e%=xe),i=Rt(10,xe-e),l=s[n]%i|0,r==null?e<3?(e==0?l=l/100|0:e==1&&(l=l/10|0),a=t<4&&l==99999||t>3&&l==49999||l==5e4||l==0):a=(t<4&&l+1==i||t>3&&l+1==i/2)&&(s[n+1]/i/100|0)==Rt(10,e-2)-1||(l==i/2||l==0)&&(s[n+1]/i/100|0)==0:e<4?(e==0?l=l/1e3|0:e==1?l=l/100|0:e==2&&(l=l/10|0),a=(r||t<4)&&l==9999||!r&&t>3&&l==4999):a=((r||t<4)&&l+1==i||!r&&t>3&&l+1==i/2)&&(s[n+1]/i/1e3|0)==Rt(10,e-3)-1,a}function Ls(s,e,t){for(var r,n=[0],i,a=0,l=s.length;a<l;){for(i=n.length;i--;)n[i]*=e;for(n[0]+=Da.indexOf(s.charAt(a++)),r=0;r<n.length;r++)n[r]>t-1&&(n[r+1]===void 0&&(n[r+1]=0),n[r+1]+=n[r]/t|0,n[r]%=t)}return n.reverse()}function l_(s,e){var t,r,n;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),n=(1/zs(4,t)).toString()):(t=16,n="2.3283064365386962890625e-10"),s.precision+=t,e=mi(s,1,e.times(n),new s(1));for(var i=t;i--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return s.precision-=t,e}var ft=function(){function s(r,n,i){var a,l=0,c=r.length;for(r=r.slice();c--;)a=r[c]*n+l,r[c]=a%i|0,l=a/i|0;return l&&r.unshift(l),r}function e(r,n,i,a){var l,c;if(i!=a)c=i>a?1:-1;else for(l=c=0;l<i;l++)if(r[l]!=n[l]){c=r[l]>n[l]?1:-1;break}return c}function t(r,n,i,a){for(var l=0;i--;)r[i]-=l,l=r[i]<n[i]?1:0,r[i]=l*a+r[i]-n[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,i,a,l,c){var p,h,f,d,g,y,m,w,v,E,b,N,x,F,M,S,I,C,B,L,U=r.constructor,k=r.s==n.s?1:-1,W=r.d,z=n.d;if(!W||!W[0]||!z||!z[0])return new U(!r.s||!n.s||(W?z&&W[0]==z[0]:!z)?NaN:W&&W[0]==0||!z?k*0:k/0);for(c?(g=1,h=r.e-n.e):(c=jr,g=xe,h=Ht(r.e/g)-Ht(n.e/g)),B=z.length,I=W.length,v=new U(k),E=v.d=[],f=0;z[f]==(W[f]||0);f++);if(z[f]>(W[f]||0)&&h--,i==null?(F=i=U.precision,a=U.rounding):l?F=i+(r.e-n.e)+1:F=i,F<0)E.push(1),y=!0;else{if(F=F/g+2|0,f=0,B==1){for(d=0,z=z[0],F++;(f<I||d)&&F--;f++)M=d*c+(W[f]||0),E[f]=M/z|0,d=M%z|0;y=d||f<I}else{for(d=c/(z[0]+1)|0,d>1&&(z=s(z,d,c),W=s(W,d,c),B=z.length,I=W.length),S=B,b=W.slice(0,B),N=b.length;N<B;)b[N++]=0;L=z.slice(),L.unshift(0),C=z[0],z[1]>=c/2&&++C;do d=0,p=e(z,b,B,N),p<0?(x=b[0],B!=N&&(x=x*c+(b[1]||0)),d=x/C|0,d>1?(d>=c&&(d=c-1),m=s(z,d,c),w=m.length,N=b.length,p=e(m,b,w,N),p==1&&(d--,t(m,B<w?L:z,w,c))):(d==0&&(p=d=1),m=z.slice()),w=m.length,w<N&&m.unshift(0),t(b,m,N,c),p==-1&&(N=b.length,p=e(z,b,B,N),p<1&&(d++,t(b,B<N?L:z,N,c))),N=b.length):p===0&&(d++,b=[0]),E[f++]=d,p&&b[0]?b[N++]=W[S]||0:(b=[W[S]],N=1);while((S++<I||b[0]!==void 0)&&F--);y=b[0]!==void 0}E[0]||E.shift()}if(g==1)v.e=h,cc=y;else{for(f=1,d=E[0];d>=10;d/=10)f++;v.e=f+h*g-1,De(v,l?i+v.e+1:i,a,y)}return v}}();function De(s,e,t,r){var n,i,a,l,c,p,h,f,d,g=s.constructor;e:if(e!=null){if(f=s.d,!f)return s;for(n=1,l=f[0];l>=10;l/=10)n++;if(i=e-n,i<0)i+=xe,a=e,h=f[d=0],c=h/Rt(10,n-a-1)%10|0;else if(d=Math.ceil((i+1)/xe),l=f.length,d>=l)if(r){for(;l++<=d;)f.push(0);h=c=0,n=1,i%=xe,a=i-xe+1}else break e;else{for(h=l=f[d],n=1;l>=10;l/=10)n++;i%=xe,a=i-xe+n,c=a<0?0:h/Rt(10,n-a-1)%10|0}if(r=r||e<0||f[d+1]!==void 0||(a<0?h:h%Rt(10,n-a-1)),p=t<4?(c||r)&&(t==0||t==(s.s<0?3:2)):c>5||c==5&&(t==4||r||t==6&&(i>0?a>0?h/Rt(10,n-a):0:f[d-1])%10&1||t==(s.s<0?8:7)),e<1||!f[0])return f.length=0,p?(e-=s.e+1,f[0]=Rt(10,(xe-e%xe)%xe),s.e=-e||0):f[0]=s.e=0,s;if(i==0?(f.length=d,l=1,d--):(f.length=d+1,l=Rt(10,xe-i),f[d]=a>0?(h/Rt(10,n-a)%Rt(10,a)|0)*l:0),p)for(;;)if(d==0){for(i=1,a=f[0];a>=10;a/=10)i++;for(a=f[0]+=l,l=1;a>=10;a/=10)l++;i!=l&&(s.e++,f[0]==jr&&(f[0]=1));break}else{if(f[d]+=l,f[d]!=jr)break;f[d--]=0,l=1}for(i=f.length;f[--i]===0;)f.pop()}return Se&&(s.e>g.maxE?(s.d=null,s.e=NaN):s.e<g.minE&&(s.e=0,s.d=[0])),s}function tn(s,e,t){if(!s.isFinite())return yc(s);var r,n=s.e,i=Vt(s.d),a=i.length;return e?(t&&(r=t-a)>0?i=i.charAt(0)+"."+i.slice(1)+Mn(r):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(s.e<0?"e":"e+")+s.e):n<0?(i="0."+Mn(-n-1)+i,t&&(r=t-a)>0&&(i+=Mn(r))):n>=a?(i+=Mn(n+1-a),t&&(r=t-n-1)>0&&(i=i+"."+Mn(r))):((r=n+1)<a&&(i=i.slice(0,r)+"."+i.slice(r)),t&&(r=t-a)>0&&(n+1===a&&(i+="."),i+=Mn(r))),i}function Rs(s,e){var t=s[0];for(e*=xe;t>=10;t/=10)e++;return e}function Ps(s,e,t){if(e>u_)throw Se=!0,t&&(s.precision=t),Error(fc);return De(new s(Ts),e,1,!0)}function Yr(s,e,t){if(e>Ea)throw Error(fc);return De(new s(Is),e,t,!0)}function _c(s){var e=s.length-1,t=e*xe+1;if(e=s[e],e){for(;e%10==0;e/=10)t--;for(e=s[0];e>=10;e/=10)t++}return t}function Mn(s){for(var e="";s--;)e+="0";return e}function mc(s,e,t,r){var n,i=new s(1),a=Math.ceil(r/xe+4);for(Se=!1;;){if(t%2&&(i=i.times(e),Dc(i.d,a)&&(n=!0)),t=Ht(t/2),t===0){t=i.d.length-1,n&&i.d[t]===0&&++i.d[t];break}e=e.times(e),Dc(e.d,a)}return Se=!0,i}function gc(s){return s.d[s.d.length-1]&1}function vc(s,e,t){for(var r,n=new s(e[0]),i=0;++i<e.length;)if(r=new s(e[i]),r.s)n[t](r)&&(n=r);else{n=r;break}return n}function xa(s,e){var t,r,n,i,a,l,c,p=0,h=0,f=0,d=s.constructor,g=d.rounding,y=d.precision;if(!s.d||!s.d[0]||s.e>17)return new d(s.d?s.d[0]?s.s<0?0:1/0:1:s.s?s.s<0?0:s:NaN);for(e==null?(Se=!1,c=y):c=e,l=new d(.03125);s.e>-2;)s=s.times(l),f+=5;for(r=Math.log(Rt(2,f))/Math.LN10*2+5|0,c+=r,t=i=a=new d(1),d.precision=c;;){if(i=De(i.times(s),c,1),t=t.times(++h),l=a.plus(ft(i,t,c,1)),Vt(l.d).slice(0,c)===Vt(a.d).slice(0,c)){for(n=f;n--;)a=De(a.times(a),c,1);if(e==null)if(p<3&&Gi(a.d,c-r,g,p))d.precision=c+=10,t=i=l=new d(1),h=0,p++;else return De(a,d.precision=y,g,Se=!0);else return d.precision=y,a}a=l}}function Nn(s,e){var t,r,n,i,a,l,c,p,h,f,d,g=1,y=10,m=s,w=m.d,v=m.constructor,E=v.rounding,b=v.precision;if(m.s<0||!w||!w[0]||!m.e&&w[0]==1&&w.length==1)return new v(w&&!w[0]?-1/0:m.s!=1?NaN:w?0:m);if(e==null?(Se=!1,h=b):h=e,v.precision=h+=y,t=Vt(w),r=t.charAt(0),Math.abs(i=m.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)m=m.times(s),t=Vt(m.d),r=t.charAt(0),g++;i=m.e,r>1?(m=new v("0."+t),i++):m=new v(r+"."+t.slice(1))}else return p=Ps(v,h+2,b).times(i+""),m=Nn(new v(r+"."+t.slice(1)),h-y).plus(p),v.precision=b,e==null?De(m,b,E,Se=!0):m;for(f=m,c=a=m=ft(m.minus(1),m.plus(1),h,1),d=De(m.times(m),h,1),n=3;;){if(a=De(a.times(d),h,1),p=c.plus(ft(a,new v(n),h,1)),Vt(p.d).slice(0,h)===Vt(c.d).slice(0,h))if(c=c.times(2),i!==0&&(c=c.plus(Ps(v,h+2,b).times(i+""))),c=ft(c,new v(g),h,1),e==null)if(Gi(c.d,h-y,E,l))v.precision=h+=y,p=a=m=ft(f.minus(1),f.plus(1),h,1),d=De(m.times(m),h,1),n=l=1;else return De(c,v.precision=b,E,Se=!0);else return v.precision=b,c;c=p,n+=2}}function yc(s){return String(s.s*s.s/0)}function Aa(s,e){var t,r,n;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;e.charCodeAt(r)===48;r++);for(n=e.length;e.charCodeAt(n-1)===48;--n);if(e=e.slice(r,n),e){if(n-=r,s.e=t=t-r-1,s.d=[],r=(t+1)%xe,t<0&&(r+=xe),r<n){for(r&&s.d.push(+e.slice(0,r)),n-=xe;r<n;)s.d.push(+e.slice(r,r+=xe));e=e.slice(r),r=xe-e.length}else r-=n;for(;r--;)e+="0";s.d.push(+e),Se&&(s.e>s.constructor.maxE?(s.d=null,s.e=NaN):s.e<s.constructor.minE&&(s.e=0,s.d=[0]))}else s.e=0,s.d=[0];return s}function c_(s,e){var t,r,n,i,a,l,c,p,h;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),dc.test(e))return Aa(s,e)}else if(e==="Infinity"||e==="NaN")return+e||(s.s=NaN),s.e=NaN,s.d=null,s;if(s_.test(e))t=16,e=e.toLowerCase();else if(i_.test(e))t=2;else if(o_.test(e))t=8;else throw Error(Fn+e);for(i=e.search(/p/i),i>0?(c=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),a=i>=0,r=s.constructor,a&&(e=e.replace(".",""),l=e.length,i=l-i,n=mc(r,new r(t),i,i*2)),p=Ls(e,t,jr),h=p.length-1,i=h;p[i]===0;--i)p.pop();return i<0?new r(s.s*0):(s.e=Rs(p,h),s.d=p,Se=!1,a&&(s=ft(s,n,l*4)),c&&(s=s.times(Math.abs(c)<54?Rt(2,c):gi.pow(2,c))),Se=!0,s)}function f_(s,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:mi(s,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/zs(5,t)),e=mi(s,2,e,e);for(var n,i=new s(5),a=new s(16),l=new s(20);t--;)n=e.times(e),e=e.times(i.plus(n.times(a.times(n).minus(l))));return e}function mi(s,e,t,r,n){var i,a,l,c,p=s.precision,h=Math.ceil(p/xe);for(Se=!1,c=t.times(t),l=new s(r);;){if(a=ft(l.times(c),new s(e++*e++),p,1),l=n?r.plus(a):r.minus(a),r=ft(a.times(c),new s(e++*e++),p,1),a=l.plus(r),a.d[h]!==void 0){for(i=h;a.d[i]===l.d[i]&&i--;);if(i==-1)break}i=l,l=r,r=a,a=i}return Se=!0,a.d.length=h+1,a}function zs(s,e){for(var t=s;--e;)t*=s;return t}function wc(s,e){var t,r=e.s<0,n=Yr(s,s.precision,1),i=n.times(.5);if(e=e.abs(),e.lte(i))return ln=r?4:1,e;if(t=e.divToInt(n),t.isZero())ln=r?3:2;else{if(e=e.minus(t.times(n)),e.lte(i))return ln=gc(t)?r?2:3:r?4:1,e;ln=gc(t)?r?1:4:r?3:2}return e.minus(n).abs()}function Ca(s,e,t,r){var n,i,a,l,c,p,h,f,d,g=s.constructor,y=t!==void 0;if(y?(ar(t,1,Cn),r===void 0?r=g.rounding:ar(r,0,8)):(t=g.precision,r=g.rounding),!s.isFinite())h=yc(s);else{for(h=tn(s),a=h.indexOf("."),y?(n=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):n=e,a>=0&&(h=h.replace(".",""),d=new g(1),d.e=h.length-a,d.d=Ls(tn(d),10,n),d.e=d.d.length),f=Ls(h,10,n),i=c=f.length;f[--c]==0;)f.pop();if(!f[0])h=y?"0p+0":"0";else{if(a<0?i--:(s=new g(s),s.d=f,s.e=i,s=ft(s,d,t,r,0,n),f=s.d,i=s.e,p=cc),a=f[t],l=n/2,p=p||f[t+1]!==void 0,p=r<4?(a!==void 0||p)&&(r===0||r===(s.s<0?3:2)):a>l||a===l&&(r===4||p||r===6&&f[t-1]&1||r===(s.s<0?8:7)),f.length=t,p)for(;++f[--t]>n-1;)f[t]=0,t||(++i,f.unshift(1));for(c=f.length;!f[c-1];--c);for(a=0,h="";a<c;a++)h+=Da.charAt(f[a]);if(y){if(c>1)if(e==16||e==8){for(a=e==16?4:3,--c;c%a;c++)h+="0";for(f=Ls(h,n,e),c=f.length;!f[c-1];--c);for(a=1,h="1.";a<c;a++)h+=Da.charAt(f[a])}else h=h.charAt(0)+"."+h.slice(1);h=h+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)h="0"+h;h="0."+h}else if(++i>c)for(i-=c;i--;)h+="0";else i<c&&(h=h.slice(0,i)+"."+h.slice(i))}h=(e==16?"0x":e==2?"0b":e==8?"0o":"")+h}return s.s<0?"-"+h:h}function Dc(s,e){if(s.length>e)return s.length=e,!0}function h_(s){return new this(s).abs()}function p_(s){return new this(s).acos()}function d_(s){return new this(s).acosh()}function __(s,e){return new this(s).plus(e)}function m_(s){return new this(s).asin()}function g_(s){return new this(s).asinh()}function v_(s){return new this(s).atan()}function y_(s){return new this(s).atanh()}function w_(s,e){s=new this(s),e=new this(e);var t,r=this.precision,n=this.rounding,i=r+4;return!s.s||!e.s?t=new this(NaN):!s.d&&!e.d?(t=Yr(this,i,1).times(e.s>0?.25:.75),t.s=s.s):!e.d||s.isZero()?(t=e.s<0?Yr(this,r,n):new this(0),t.s=s.s):!s.d||e.isZero()?(t=Yr(this,i,1).times(.5),t.s=s.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(ft(s,e,i,1)),e=Yr(this,i,1),this.precision=r,this.rounding=n,t=s.s<0?t.minus(e):t.plus(e)):t=this.atan(ft(s,e,i,1)),t}function D_(s){return new this(s).cbrt()}function b_(s){return De(s=new this(s),s.e+1,2)}function E_(s,e,t){return new this(s).clamp(e,t)}function x_(s){if(!s||typeof s!="object")throw Error($s+"Object expected");var e,t,r,n=s.defaults===!0,i=["precision",1,Cn,"rounding",0,8,"toExpNeg",-_i,0,"toExpPos",0,_i,"maxE",0,_i,"minE",-_i,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],n&&(this[t]=ba[t]),(r=s[t])!==void 0)if(Ht(r)===r&&r>=i[e+1]&&r<=i[e+2])this[t]=r;else throw Error(Fn+t+": "+r);if(t="crypto",n&&(this[t]=ba[t]),(r=s[t])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(hc);else this[t]=!1;else throw Error(Fn+t+": "+r);return this}function A_(s){return new this(s).cos()}function C_(s){return new this(s).cosh()}function bc(s){var e,t,r;function n(i){var a,l,c,p=this;if(!(p instanceof n))return new n(i);if(p.constructor=n,Ec(i)){p.s=i.s,Se?!i.d||i.e>n.maxE?(p.e=NaN,p.d=null):i.e<n.minE?(p.e=0,p.d=[0]):(p.e=i.e,p.d=i.d.slice()):(p.e=i.e,p.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){p.s=1/i<0?-1:1,p.e=0,p.d=[0];return}if(i<0?(i=-i,p.s=-1):p.s=1,i===~~i&&i<1e7){for(a=0,l=i;l>=10;l/=10)a++;Se?a>n.maxE?(p.e=NaN,p.d=null):a<n.minE?(p.e=0,p.d=[0]):(p.e=a,p.d=[i]):(p.e=a,p.d=[i]);return}else if(i*0!==0){i||(p.s=NaN),p.e=NaN,p.d=null;return}return Aa(p,i.toString())}else if(c!=="string")throw Error(Fn+i);return(l=i.charCodeAt(0))===45?(i=i.slice(1),p.s=-1):(l===43&&(i=i.slice(1)),p.s=1),dc.test(i)?Aa(p,i):c_(p,i)}if(n.prototype=ie,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=x_,n.clone=bc,n.isDecimal=Ec,n.abs=h_,n.acos=p_,n.acosh=d_,n.add=__,n.asin=m_,n.asinh=g_,n.atan=v_,n.atanh=y_,n.atan2=w_,n.cbrt=D_,n.ceil=b_,n.clamp=E_,n.cos=A_,n.cosh=C_,n.div=F_,n.exp=M_,n.floor=N_,n.hypot=S_,n.ln=B_,n.log=O_,n.log10=I_,n.log2=T_,n.max=$_,n.min=L_,n.mod=R_,n.mul=P_,n.pow=z_,n.random=q_,n.round=k_,n.sign=U_,n.sin=W_,n.sinh=j_,n.sqrt=Y_,n.sub=V_,n.sum=Z_,n.tan=K_,n.tanh=G_,n.trunc=H_,s===void 0&&(s={}),s&&s.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)s.hasOwnProperty(t=r[e++])||(s[t]=this[t]);return n.config(s),n}function F_(s,e){return new this(s).div(e)}function M_(s){return new this(s).exp()}function N_(s){return De(s=new this(s),s.e+1,3)}function S_(){var s,e,t=new this(0);for(Se=!1,s=0;s<arguments.length;)if(e=new this(arguments[s++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return Se=!0,new this(1/0);t=e}return Se=!0,t.sqrt()}function Ec(s){return s instanceof gi||s&&s.toStringTag===pc||!1}function B_(s){return new this(s).ln()}function O_(s,e){return new this(s).log(e)}function T_(s){return new this(s).log(2)}function I_(s){return new this(s).log(10)}function $_(){return vc(this,arguments,"lt")}function L_(){return vc(this,arguments,"gt")}function R_(s,e){return new this(s).mod(e)}function P_(s,e){return new this(s).mul(e)}function z_(s,e){return new this(s).pow(e)}function q_(s){var e,t,r,n,i=0,a=new this(1),l=[];if(s===void 0?s=this.precision:ar(s,1,Cn),r=Math.ceil(s/xe),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));i<r;)n=e[i],n>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:l[i++]=n%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);i<r;)n=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(e,i):(l.push(n%1e7),i+=4);i=r/4}else throw Error(hc);else for(;i<r;)l[i++]=Math.random()*1e7|0;for(r=l[--i],s%=xe,r&&s&&(n=Rt(10,xe-s),l[i]=(r/n|0)*n);l[i]===0;i--)l.pop();if(i<0)t=0,l=[0];else{for(t=-1;l[0]===0;t-=xe)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<xe&&(t-=xe-r)}return a.e=t,a.d=l,a}function k_(s){return De(s=new this(s),s.e+1,this.rounding)}function U_(s){return s=new this(s),s.d?s.d[0]?s.s:0*s.s:s.s||NaN}function W_(s){return new this(s).sin()}function j_(s){return new this(s).sinh()}function Y_(s){return new this(s).sqrt()}function V_(s,e){return new this(s).sub(e)}function Z_(){var s=0,e=arguments,t=new this(e[s]);for(Se=!1;t.s&&++s<e.length;)t=t.plus(e[s]);return Se=!0,De(t,this.precision,this.rounding)}function K_(s){return new this(s).tan()}function G_(s){return new this(s).tanh()}function H_(s){return De(s=new this(s),s.e+1,1)}ie[Symbol.for("nodejs.util.inspect.custom")]=ie.toString,ie[Symbol.toStringTag]="Decimal";var gi=ie.constructor=bc(ba);Ts=new gi(Ts),Is=new gi(Is);var J_="BigNumber",X_=["?on","config"],Q_=me(J_,X_,s=>{var{on:e,config:t}=s,r=gi.clone({precision:t.precision,modulo:gi.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(n){return new r(n.value)},e&&e("config",function(n,i){n.precision!==i.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),xc={exports:{}};/**
|
41
|
+
* @license Complex.js v2.1.1 12/05/2020
|
42
|
+
*
|
43
|
+
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
44
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
45
|
+
**/(function(s,e){(function(t){var r=Math.cosh||function(f){return Math.abs(f)<1e-9?1-f:(Math.exp(f)+Math.exp(-f))*.5},n=Math.sinh||function(f){return Math.abs(f)<1e-9?f:(Math.exp(f)-Math.exp(-f))*.5},i=function(f){var d=Math.PI/4;if(-d>f||f>d)return Math.cos(f)-1;var g=f*f;return g*(g*(g*(g*(g*(g*(g*(g/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},a=function(f,d){var g=Math.abs(f),y=Math.abs(d);return g<3e3&&y<3e3?Math.sqrt(g*g+y*y):(g<y?(g=y,y=f/d):y=d/f,g*Math.sqrt(1+y*y))},l=function(){throw SyntaxError("Invalid Param")};function c(f,d){var g=Math.abs(f),y=Math.abs(d);return f===0?Math.log(y):d===0?Math.log(g):g<3e3&&y<3e3?Math.log(f*f+d*d)*.5:(f=f/2,d=d/2,.5*Math.log(f*f+d*d)+Math.LN2)}var p=function(f,d){var g={re:0,im:0};if(f==null)g.re=g.im=0;else if(d!==void 0)g.re=f,g.im=d;else switch(typeof f){case"object":if("im"in f&&"re"in f)g.re=f.re,g.im=f.im;else if("abs"in f&&"arg"in f){if(!Number.isFinite(f.abs)&&Number.isFinite(f.arg))return h.INFINITY;g.re=f.abs*Math.cos(f.arg),g.im=f.abs*Math.sin(f.arg)}else if("r"in f&&"phi"in f){if(!Number.isFinite(f.r)&&Number.isFinite(f.phi))return h.INFINITY;g.re=f.r*Math.cos(f.phi),g.im=f.r*Math.sin(f.phi)}else f.length===2?(g.re=f[0],g.im=f[1]):l();break;case"string":g.im=g.re=0;var y=f.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),m=1,w=0;y===null&&l();for(var v=0;v<y.length;v++){var E=y[v];E===" "||E===" "||E===`
|
46
|
+
`||(E==="+"?m++:E==="-"?w++:E==="i"||E==="I"?(m+w===0&&l(),y[v+1]!==" "&&!isNaN(y[v+1])?(g.im+=parseFloat((w%2?"-":"")+y[v+1]),v++):g.im+=parseFloat((w%2?"-":"")+"1"),m=w=0):((m+w===0||isNaN(E))&&l(),y[v+1]==="i"||y[v+1]==="I"?(g.im+=parseFloat((w%2?"-":"")+E),v++):g.re+=parseFloat((w%2?"-":"")+E),m=w=0))}m+w>0&&l();break;case"number":g.im=0,g.re=f;break;default:l()}return isNaN(g.re)||isNaN(g.im),g};function h(f,d){if(!(this instanceof h))return new h(f,d);var g=p(f,d);this.re=g.re,this.im=g.im}h.prototype={re:0,im:0,sign:function(){var f=this.abs();return new h(this.re/f,this.im/f)},add:function(f,d){var g=new h(f,d);return this.isInfinite()&&g.isInfinite()?h.NAN:this.isInfinite()||g.isInfinite()?h.INFINITY:new h(this.re+g.re,this.im+g.im)},sub:function(f,d){var g=new h(f,d);return this.isInfinite()&&g.isInfinite()?h.NAN:this.isInfinite()||g.isInfinite()?h.INFINITY:new h(this.re-g.re,this.im-g.im)},mul:function(f,d){var g=new h(f,d);return this.isInfinite()&&g.isZero()||this.isZero()&&g.isInfinite()?h.NAN:this.isInfinite()||g.isInfinite()?h.INFINITY:g.im===0&&this.im===0?new h(this.re*g.re,0):new h(this.re*g.re-this.im*g.im,this.re*g.im+this.im*g.re)},div:function(f,d){var g=new h(f,d);if(this.isZero()&&g.isZero()||this.isInfinite()&&g.isInfinite())return h.NAN;if(this.isInfinite()||g.isZero())return h.INFINITY;if(this.isZero()||g.isInfinite())return h.ZERO;f=this.re,d=this.im;var y=g.re,m=g.im,w,v;return m===0?new h(f/y,d/y):Math.abs(y)<Math.abs(m)?(v=y/m,w=y*v+m,new h((f*v+d)/w,(d*v-f)/w)):(v=m/y,w=m*v+y,new h((f+d*v)/w,(d-f*v)/w))},pow:function(f,d){var g=new h(f,d);if(f=this.re,d=this.im,g.isZero())return h.ONE;if(g.im===0){if(d===0&&f>0)return new h(Math.pow(f,g.re),0);if(f===0)switch((g.re%4+4)%4){case 0:return new h(Math.pow(d,g.re),0);case 1:return new h(0,Math.pow(d,g.re));case 2:return new h(-Math.pow(d,g.re),0);case 3:return new h(0,-Math.pow(d,g.re))}}if(f===0&&d===0&&g.re>0&&g.im>=0)return h.ZERO;var y=Math.atan2(d,f),m=c(f,d);return f=Math.exp(g.re*m-g.im*y),d=g.im*m+g.re*y,new h(f*Math.cos(d),f*Math.sin(d))},sqrt:function(){var f=this.re,d=this.im,g=this.abs(),y,m;if(f>=0){if(d===0)return new h(Math.sqrt(f),0);y=.5*Math.sqrt(2*(g+f))}else y=Math.abs(d)/Math.sqrt(2*(g-f));return f<=0?m=.5*Math.sqrt(2*(g-f)):m=Math.abs(d)/Math.sqrt(2*(g+f)),new h(y,d<0?-m:m)},exp:function(){var f=Math.exp(this.re);return this.im,new h(f*Math.cos(this.im),f*Math.sin(this.im))},expm1:function(){var f=this.re,d=this.im;return new h(Math.expm1(f)*Math.cos(d)+i(d),Math.exp(f)*Math.sin(d))},log:function(){var f=this.re,d=this.im;return new h(c(f,d),Math.atan2(d,f))},abs:function(){return a(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var f=this.re,d=this.im;return new h(Math.sin(f)*r(d),Math.cos(f)*n(d))},cos:function(){var f=this.re,d=this.im;return new h(Math.cos(f)*r(d),-Math.sin(f)*n(d))},tan:function(){var f=2*this.re,d=2*this.im,g=Math.cos(f)+r(d);return new h(Math.sin(f)/g,n(d)/g)},cot:function(){var f=2*this.re,d=2*this.im,g=Math.cos(f)-r(d);return new h(-Math.sin(f)/g,n(d)/g)},sec:function(){var f=this.re,d=this.im,g=.5*r(2*d)+.5*Math.cos(2*f);return new h(Math.cos(f)*r(d)/g,Math.sin(f)*n(d)/g)},csc:function(){var f=this.re,d=this.im,g=.5*r(2*d)-.5*Math.cos(2*f);return new h(Math.sin(f)*r(d)/g,-Math.cos(f)*n(d)/g)},asin:function(){var f=this.re,d=this.im,g=new h(d*d-f*f+1,-2*f*d).sqrt(),y=new h(g.re-d,g.im+f).log();return new h(y.im,-y.re)},acos:function(){var f=this.re,d=this.im,g=new h(d*d-f*f+1,-2*f*d).sqrt(),y=new h(g.re-d,g.im+f).log();return new h(Math.PI/2-y.im,y.re)},atan:function(){var f=this.re,d=this.im;if(f===0){if(d===1)return new h(0,1/0);if(d===-1)return new h(0,-1/0)}var g=f*f+(1-d)*(1-d),y=new h((1-d*d-f*f)/g,-2*f/g).log();return new h(-.5*y.im,.5*y.re)},acot:function(){var f=this.re,d=this.im;if(d===0)return new h(Math.atan2(1,f),0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).atan():new h(f!==0?f/0:0,d!==0?-d/0:0).atan()},asec:function(){var f=this.re,d=this.im;if(f===0&&d===0)return new h(0,1/0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).acos():new h(f!==0?f/0:0,d!==0?-d/0:0).acos()},acsc:function(){var f=this.re,d=this.im;if(f===0&&d===0)return new h(Math.PI/2,1/0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).asin():new h(f!==0?f/0:0,d!==0?-d/0:0).asin()},sinh:function(){var f=this.re,d=this.im;return new h(n(f)*Math.cos(d),r(f)*Math.sin(d))},cosh:function(){var f=this.re,d=this.im;return new h(r(f)*Math.cos(d),n(f)*Math.sin(d))},tanh:function(){var f=2*this.re,d=2*this.im,g=r(f)+Math.cos(d);return new h(n(f)/g,Math.sin(d)/g)},coth:function(){var f=2*this.re,d=2*this.im,g=r(f)-Math.cos(d);return new h(n(f)/g,-Math.sin(d)/g)},csch:function(){var f=this.re,d=this.im,g=Math.cos(2*d)-r(2*f);return new h(-2*n(f)*Math.cos(d)/g,2*r(f)*Math.sin(d)/g)},sech:function(){var f=this.re,d=this.im,g=Math.cos(2*d)+r(2*f);return new h(2*r(f)*Math.cos(d)/g,-2*n(f)*Math.sin(d)/g)},asinh:function(){var f=this.im;this.im=-this.re,this.re=f;var d=this.asin();return this.re=-this.im,this.im=f,f=d.re,d.re=-d.im,d.im=f,d},acosh:function(){var f=this.acos();if(f.im<=0){var d=f.re;f.re=-f.im,f.im=d}else{var d=f.im;f.im=-f.re,f.re=d}return f},atanh:function(){var f=this.re,d=this.im,g=f>1&&d===0,y=1-f,m=1+f,w=y*y+d*d,v=w!==0?new h((m*y-d*d)/w,(d*y+m*d)/w):new h(f!==-1?f/0:0,d!==0?d/0:0),E=v.re;return v.re=c(v.re,v.im)/2,v.im=Math.atan2(v.im,E)/2,g&&(v.im=-v.im),v},acoth:function(){var f=this.re,d=this.im;if(f===0&&d===0)return new h(0,Math.PI/2);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).atanh():new h(f!==0?f/0:0,d!==0?-d/0:0).atanh()},acsch:function(){var f=this.re,d=this.im;if(d===0)return new h(f!==0?Math.log(f+Math.sqrt(f*f+1)):1/0,0);var g=f*f+d*d;return g!==0?new h(f/g,-d/g).asinh():new h(f!==0?f/0:0,d!==0?-d/0:0).asinh()},asech:function(){var f=this.re,d=this.im;if(this.isZero())return h.INFINITY;var g=f*f+d*d;return g!==0?new h(f/g,-d/g).acosh():new h(f!==0?f/0:0,d!==0?-d/0:0).acosh()},inverse:function(){if(this.isZero())return h.INFINITY;if(this.isInfinite())return h.ZERO;var f=this.re,d=this.im,g=f*f+d*d;return new h(f/g,-d/g)},conjugate:function(){return new h(this.re,-this.im)},neg:function(){return new h(-this.re,-this.im)},ceil:function(f){return f=Math.pow(10,f||0),new h(Math.ceil(this.re*f)/f,Math.ceil(this.im*f)/f)},floor:function(f){return f=Math.pow(10,f||0),new h(Math.floor(this.re*f)/f,Math.floor(this.im*f)/f)},round:function(f){return f=Math.pow(10,f||0),new h(Math.round(this.re*f)/f,Math.round(this.im*f)/f)},equals:function(f,d){var g=new h(f,d);return Math.abs(g.re-this.re)<=h.EPSILON&&Math.abs(g.im-this.im)<=h.EPSILON},clone:function(){return new h(this.re,this.im)},toString:function(){var f=this.re,d=this.im,g="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(f)<h.EPSILON&&(f=0),Math.abs(d)<h.EPSILON&&(d=0),d===0?g+f:(f!==0?(g+=f,g+=" ",d<0?(d=-d,g+="-"):g+="+",g+=" "):d<0&&(d=-d,g+="-"),d!==1&&(g+=d),g+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},h.ZERO=new h(0,0),h.ONE=new h(1,0),h.I=new h(0,1),h.PI=new h(Math.PI,0),h.E=new h(Math.E,0),h.INFINITY=new h(1/0,1/0),h.NAN=new h(NaN,NaN),h.EPSILON=1e-15,Object.defineProperty(h,"__esModule",{value:!0}),h.default=h,h.Complex=h,s.exports=h})()})(xc);var em=xc.exports,Zt=Ge(em),tm="Complex",rm=[],nm=me(tm,rm,()=>(Object.defineProperty(Zt,"name",{value:"Complex"}),Zt.prototype.constructor=Zt,Zt.prototype.type="Complex",Zt.prototype.isComplex=!0,Zt.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},Zt.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},Zt.prototype.format=function(s){var e="",t=this.im,r=this.re,n=ha(this.re,s),i=ha(this.im,s),a=pt(s)?s:s?s.precision:null;if(a!==null){var l=Math.pow(10,-a);Math.abs(r/t)<l&&(r=0),Math.abs(t/r)<l&&(t=0)}return t===0?e=n:r===0?t===1?e="i":t===-1?e="-i":e=i+"i":t<0?t===-1?e=n+" - i":e=n+" - "+i.substring(1)+"i":t===1?e=n+" + i":e=n+" + "+i+"i",e},Zt.fromPolar=function(s){switch(arguments.length){case 1:{var e=arguments[0];if(typeof e=="object")return Zt(e);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],r=arguments[1];if(pt(t)){if(Pl(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),pt(r))return new Zt({r:t,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")}},Zt.prototype.valueOf=Zt.prototype.toString,Zt.fromJSON=function(s){return new Zt(s)},Zt.compare=function(s,e){return s.re>e.re?1:s.re<e.re?-1:s.im>e.im?1:s.im<e.im?-1:0},Zt),{isClass:!0}),Ac={exports:{}};/**
|
47
|
+
* @license Fraction.js v4.3.0 20/08/2023
|
48
|
+
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
49
|
+
*
|
50
|
+
* Copyright (c) 2023, Robert Eisele (robert@raw.org)
|
51
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
52
|
+
**/(function(s,e){(function(t){var r=2e3,n={s:1,n:0,d:1};function i(v,E){if(isNaN(v=parseInt(v,10)))throw m();return v*E}function a(v,E){if(E===0)throw y();var b=Object.create(g.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var N=d(v,E);return b.n=v/N,b.d=E/N,b}function l(v){for(var E={},b=v,N=2,x=4;x<=b;){for(;b%N===0;)b/=N,E[N]=(E[N]||0)+1;x+=1+2*N++}return b!==v?b>1&&(E[b]=(E[b]||0)+1):E[v]=(E[v]||0)+1,E}var c=function(v,E){var b=0,N=1,x=1,F=0,M=0,S=0,I=1,C=1,B=0,L=1,U=1,k=1,W=1e7,z;if(v!=null)if(E!==void 0){if(b=v,N=E,x=b*N,b%1!==0||N%1!==0)throw w()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,N=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(N=v[1]);else throw m();x=b*N;break}case"number":{if(v<0&&(x=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(C=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=C);L<=W&&k<=W;)if(z=(B+U)/(L+k),v===z){L+k<=W?(b=B+U,N=L+k):k>L?(b=U,N=k):(b=B,N=L);break}else v>z?(B+=U,L+=k):(U+=B,k+=L),L>W?(b=U,N=k):(b=B,N=L);b*=C}else(isNaN(v)||isNaN(E))&&(N=b=NaN);break}case"string":{if(L=v.match(/\d+|./g),L===null)throw m();if(L[B]==="-"?(x=-1,B++):L[B]==="+"&&B++,L.length===B+1?M=i(L[B++],x):L[B+1]==="."||L[B]==="."?(L[B]!=="."&&(F=i(L[B++],x)),B++,(B+1===L.length||L[B+1]==="("&&L[B+3]===")"||L[B+1]==="'"&&L[B+3]==="'")&&(M=i(L[B],x),I=Math.pow(10,L[B].length),B++),(L[B]==="("&&L[B+2]===")"||L[B]==="'"&&L[B+2]==="'")&&(S=i(L[B+1],x),C=Math.pow(10,L[B+1].length)-1,B+=3)):L[B+1]==="/"||L[B+1]===":"?(M=i(L[B],x),I=i(L[B+2],1),B+=3):L[B+3]==="/"&&L[B+1]===" "&&(F=i(L[B],x),M=i(L[B+2],x),I=i(L[B+4],1),B+=5),L.length<=B){N=I*C,x=b=S+N*F+C*M;break}}default:throw m()}if(N===0)throw y();n.s=x<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(N)};function p(v,E,b){for(var N=1;E>0;v=v*v%b,E>>=1)E&1&&(N=N*v%b);return N}function h(v,E){for(;E%2===0;E/=2);for(;E%5===0;E/=5);if(E===1)return 0;for(var b=10%E,N=1;b!==1;N++)if(b=b*10%E,N>r)return 0;return N}function f(v,E,b){for(var N=1,x=p(10,b,E),F=0;F<300;F++){if(N===x)return F;N=N*10%E,x=x*10%E}return 0}function d(v,E){if(!v)return E;if(!E)return v;for(;;){if(v%=E,!v)return E;if(E%=v,!E)return v}}function g(v,E){if(c(v,E),this instanceof g)v=d(n.d,n.n),this.s=n.s,this.n=n.n/v,this.d=n.d/v;else return a(n.s*n.n,n.d)}var y=function(){return new Error("Division by Zero")},m=function(){return new Error("Invalid argument")},w=function(){return new Error("Parameters must be integer")};g.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(v,E){return c(v,E),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,E){return c(v,E),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,E){return c(v,E),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,E){return c(v,E),a(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(v,E){if(isNaN(this.n)||isNaN(this.d))return new g(NaN);if(v===void 0)return a(this.s*this.n%this.d,1);if(c(v,E),n.n===0&&this.d===0)throw y();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(v,E){return c(v,E),a(d(n.n,this.n)*d(n.d,this.d),n.d*this.d)},lcm:function(v,E){return c(v,E),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,d(n.n,this.n)*d(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,E){if(c(v,E),n.d===1)return n.s<0?a(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):a(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=l(this.n),N=l(this.d),x=1,F=1;for(var M in b)if(M!=="1"){if(M==="0"){x=0;break}if(b[M]*=n.n,b[M]%n.d===0)b[M]/=n.d;else return null;x*=Math.pow(M,b[M])}for(var M in N)if(M!=="1"){if(N[M]*=n.n,N[M]%n.d===0)N[M]/=n.d;else return null;F*=Math.pow(M,N[M])}return n.s<0?a(F,x):a(x,F)},equals:function(v,E){return c(v,E),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,E){c(v,E);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var E=this.abs(),b=E.toContinued(),N=1;N<b.length;N++){for(var x=a(b[N-1],1),F=N-2;F>=0;F--)x=x.inverse().add(b[F]);if(Math.abs(x.sub(E).valueOf())<v)return x.mul(this.s)}return this},divisible:function(v,E){return c(v,E),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var E,b="",N=this.n,x=this.d;return this.s<0&&(b+="-"),x===1?b+=N:(v&&(E=Math.floor(N/x))>0&&(b+=E,b+=" ",N%=x),b+=N,b+="/",b+=x),b},toLatex:function(v){var E,b="",N=this.n,x=this.d;return this.s<0&&(b+="-"),x===1?b+=N:(v&&(E=Math.floor(N/x))>0&&(b+=E,N%=x),b+="\\frac{",b+=N,b+="}{",b+=x,b+="}"),b},toContinued:function(){var v,E=this.n,b=this.d,N=[];if(isNaN(E)||isNaN(b))return N;do N.push(Math.floor(E/b)),v=E%b,E=b,b=v;while(E!==1);return N},toString:function(v){var E=this.n,b=this.d;if(isNaN(E)||isNaN(b))return"NaN";v=v||15;var N=h(E,b),x=f(E,b,N),F=this.s<0?"-":"";if(F+=E/b|0,E%=b,E*=10,E&&(F+="."),N){for(var M=x;M--;)F+=E/b|0,E%=b,E*=10;F+="(";for(var M=N;M--;)F+=E/b|0,E%=b,E*=10;F+=")"}else for(var M=v;E&&M--;)F+=E/b|0,E%=b,E*=10;return F}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,s.exports=g})()})(Ac);var im=Ac.exports,cn=Ge(im),sm="Fraction",om=[],am=me(sm,om,()=>(Object.defineProperty(cn,"name",{value:"Fraction"}),cn.prototype.constructor=cn,cn.prototype.type="Fraction",cn.prototype.isFraction=!0,cn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},cn.fromJSON=function(s){return new cn(s)},cn),{isClass:!0}),um="Matrix",lm=[],cm=me(um,lm,()=>{function s(){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator")}return s.prototype.type="Matrix",s.prototype.isMatrix=!0,s.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},s.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},s.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},s.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},s.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},s.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},s.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},s.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},s.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},s.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},s.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},s.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},s.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},s.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},s.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},s.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},s.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},s},{isClass:!0});function Cc(s){return Object.keys(s.signatures||{}).reduce(function(e,t){var r=(t.match(/,/g)||[]).length+1;return Math.max(e,r)},-1)}var fm="DenseMatrix",hm=["Matrix"],pm=me(fm,hm,s=>{var{Matrix:e}=s;function t(h,f){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(f&&!en(f))throw new Error("Invalid datatype: "+f);if(vt(h))h.type==="DenseMatrix"?(this._data=st(h._data),this._size=st(h._size),this._datatype=f||h._datatype):(this._data=h.toArray(),this._size=h.size(),this._datatype=f||h._datatype);else if(h&&xt(h.data)&&xt(h.size))this._data=h.data,this._size=h.size,ec(this._data,this._size),this._datatype=f||h.datatype;else if(xt(h))this._data=p(h),this._size=Tt(this._data),ec(this._data,this._size),this._datatype=f;else{if(h)throw new TypeError("Unsupported type of data ("+xn(h)+")");this._data=[],this._size=[0],this._datatype=f}}t.prototype=new e,t.prototype.createDenseMatrix=function(h,f){return new t(h,f)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return Ss(this._data,xn)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(h,f){return new t(h,f)},t.prototype.subset=function(h,f,d){switch(arguments.length){case 1:return r(this,h);case 2:case 3:return i(this,h,f,d);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(h){if(!xt(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new He(h.length,this._size.length);for(var f=0;f<h.length;f++)At(h[f],this._size[f]);for(var d=this._data,g=0,y=h.length;g<y;g++){var m=h[g];At(m,d.length),d=d[m]}return d},t.prototype.set=function(h,f,d){if(!xt(h))throw new TypeError("Array expected");if(h.length<this._size.length)throw new He(h.length,this._size.length,"<");var g,y,m,w=h.map(function(E){return E+1});c(this,w,d);var v=this._data;for(g=0,y=h.length-1;g<y;g++)m=h[g],At(m,v.length),v=v[m];return m=h[h.length-1],At(m,v.length),v[m]=f,this};function r(h,f){if(!la(f))throw new TypeError("Invalid index");var d=f.isScalar();if(d)return h.get(f.min());var g=f.size();if(g.length!==h._size.length)throw new He(g.length,h._size.length);for(var y=f.min(),m=f.max(),w=0,v=h._size.length;w<v;w++)At(y[w],h._size[w]),At(m[w],h._size[w]);return new t(n(h._data,f,g.length,0),h._datatype)}function n(h,f,d,g){var y=g===d-1,m=f.dimension(g);return y?m.map(function(w){return At(w,h.length),h[w]}).valueOf():m.map(function(w){At(w,h.length);var v=h[w];return n(v,f,d,g+1)}).valueOf()}function i(h,f,d,g){if(!f||f.isIndex!==!0)throw new TypeError("Invalid index");var y=f.size(),m=f.isScalar(),w;if(vt(d)?(w=d.size(),d=d.valueOf()):w=Tt(d),m){if(w.length!==0)throw new TypeError("Scalar expected");h.set(f.min(),d,g)}else{if(!hi(w,y))try{w.length===0?d=oc([d],y):d=oc(d,y),w=Tt(d)}catch{}if(y.length<h._size.length)throw new He(y.length,h._size.length,"<");if(w.length<y.length){for(var v=0,E=0;y[v]===1&&w[v]===1;)v++;for(;y[v]===1;)E++,v++;d=rc(d,y.length,E,w)}if(!hi(y,w))throw new He(y,w,">");var b=f.max().map(function(F){return F+1});c(h,b,g);var N=y.length,x=0;a(h._data,f,d,N,x)}return h}function a(h,f,d,g,y){var m=y===g-1,w=f.dimension(y);m?w.forEach(function(v,E){At(v),h[v]=d[E[0]]}):w.forEach(function(v,E){At(v),a(h[v],f,d[E[0]],g,y+1)})}t.prototype.resize=function(h,f,d){if(!Zi(h))throw new TypeError("Array or Matrix expected");var g=h.valueOf().map(m=>Array.isArray(m)&&m.length===1?m[0]:m),y=d?this.clone():this;return l(y,g,f)};function l(h,f,d){if(f.length===0){for(var g=h._data;xt(g);)g=g[0];return g}return h._size=f.slice(0),h._data=da(h._data,h._size,d),h}t.prototype.reshape=function(h,f){var d=f?this.clone():this;d._data=ma(d._data,h);var g=d._size.reduce((y,m)=>y*m);return d._size=ga(h,g),d};function c(h,f,d){for(var g=h._size.slice(0),y=!1;g.length<f.length;)g.push(0),y=!0;for(var m=0,w=f.length;m<w;m++)f[m]>g[m]&&(g[m]=f[m],y=!0);y&&l(h,g,d)}t.prototype.clone=function(){var h=new t({data:st(this._data),size:st(this._size),datatype:this._datatype});return h},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(h){var f=this,d=Cc(h),g=function w(v,E){return xt(v)?v.map(function(b,N){return w(b,E.concat(N))}):d===1?h(v):d===2?h(v,E):h(v,E,f)},y=g(this._data,[]),m=this._datatype!==void 0?Ss(y,xn):void 0;return new t(y,m)},t.prototype.forEach=function(h){var f=this,d=function g(y,m){xt(y)?y.forEach(function(w,v){g(w,m.concat(v))}):h(y,m,f)};d(this._data,[])},t.prototype[Symbol.iterator]=function*(){var h=function*f(d,g){if(xt(d))for(var y=0;y<d.length;y++)yield*f(d[y],g.concat(y));else yield{value:d,index:g}};yield*h(this._data,[])},t.prototype.rows=function(){var h=[],f=this.size();if(f.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var d=this._data;for(var g of d)h.push(new t([g],this._datatype));return h},t.prototype.columns=function(){var h=this,f=[],d=this.size();if(d.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var g=this._data,y=function(v){var E=g.map(b=>[b[v]]);f.push(new t(E,h._datatype))},m=0;m<d[1];m++)y(m);return f},t.prototype.toArray=function(){return st(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(h){return ct(this._data,h)},t.prototype.toString=function(){return ct(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(h){if(h){if(Nt(h)&&(h=h.toNumber()),!pt(h)||!Dt(h))throw new TypeError("The parameter k must be an integer number")}else h=0;for(var f=h>0?h:0,d=h<0?-h:0,g=this._size[0],y=this._size[1],m=Math.min(g-d,y-f),w=[],v=0;v<m;v++)w[v]=this._data[v+d][v+f];return new t({data:w,size:[m],datatype:this._datatype})},t.diagonal=function(h,f,d,g){if(!xt(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(M){if(Nt(M)&&(M=M.toNumber()),!pt(M)||!Dt(M)||M<1)throw new Error("Size values must be positive integers");return M}),d){if(Nt(d)&&(d=d.toNumber()),!pt(d)||!Dt(d))throw new TypeError("The parameter k must be an integer number")}else d=0;var y=d>0?d:0,m=d<0?-d:0,w=h[0],v=h[1],E=Math.min(w-m,v-y),b;if(xt(f)){if(f.length!==E)throw new Error("Invalid value array length");b=function(S){return f[S]}}else if(vt(f)){var N=f.size();if(N.length!==1||N[0]!==E)throw new Error("Invalid matrix length");b=function(S){return f.get([S])}}else b=function(){return f};g||(g=Nt(b(0))?b(0).mul(0):0);var x=[];if(h.length>0){x=da(x,h,g);for(var F=0;F<E;F++)x[F+m][F+y]=b(F)}return new t({data:x,size:[w,v]})},t.fromJSON=function(h){return new t(h)},t.prototype.swapRows=function(h,f){if(!pt(h)||!Dt(h)||!pt(f)||!Dt(f))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return At(h,this._size[0]),At(f,this._size[0]),t._swapRows(h,f,this._data),this},t._swapRows=function(h,f,d){var g=d[h];d[h]=d[f],d[f]=g};function p(h){return vt(h)?p(h.valueOf()):xt(h)?h.map(p):h}return t},{isClass:!0});function dm(s){var e=s.length,t=s[0].length,r,n,i=[];for(n=0;n<t;n++){var a=[];for(r=0;r<e;r++)a.push(s[r][n]);i.push(a)}return i}function qs(s){for(var e=0;e<s.length;e++)if(Zi(s[e]))return!0;return!1}function Hi(s,e){vt(s)&&(s=s.valueOf());for(var t=0,r=s.length;t<r;t++){var n=s[t];Array.isArray(n)?Hi(n,e):e(n)}}function Vr(s,e,t){return s&&typeof s.map=="function"?s.map(function(r){return Vr(r,e)}):e(s)}function Fa(s,e,t){var r=Array.isArray(s)?Tt(s):s.size();if(e<0||e>=r.length)throw new An(e,r.length);return vt(s)?s.create(ks(s.valueOf(),e,t)):ks(s,e,t)}function ks(s,e,t){var r,n,i,a;if(e<=0)if(Array.isArray(s[0])){for(a=dm(s),n=[],r=0;r<a.length;r++)n[r]=ks(a[r],e-1,t);return n}else{for(i=s[0],r=1;r<s.length;r++)i=t(i,s[r]);return i}else{for(n=[],r=0;r<s.length;r++)n[r]=ks(s[r],e-1,t);return n}}var Fc="isInteger",_m=["typed"],mm=me(Fc,_m,s=>{var{typed:e}=s;return e(Fc,{number:Dt,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":e.referToSelf(t=>r=>Vr(r,t))})}),Mc="number",Us="number, number";function Nc(s){return Math.abs(s)}Nc.signature=Mc;function Sc(s,e){return s+e}Sc.signature=Us;function Bc(s,e){return s-e}Bc.signature=Us;function Oc(s,e){return s*e}Oc.signature=Us;function Tc(s){return-s}Tc.signature=Mc;function Ic(s,e){return s*s<1&&e===1/0||s*s>1&&e===-1/0?0:Math.pow(s,e)}Ic.signature=Us;var $c="number";function Lc(s){return s===0}Lc.signature=$c;function Rc(s){return Number.isNaN(s)}Rc.signature=$c;var Pc="isNumeric",gm=["typed"],vm=me(Pc,gm,s=>{var{typed:e}=s;return e(Pc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":e.referToSelf(t=>r=>Vr(r,t))})}),zc="isZero",ym=["typed"],wm=me(zc,ym,s=>{var{typed:e}=s;return e(zc,{number:Lc,BigNumber:function(r){return r.isZero()},Complex:function(r){return r.re===0&&r.im===0},Fraction:function(r){return r.d===1&&r.n===0},Unit:e.referToSelf(t=>r=>e.find(t,r.valueType())(r.value)),"Array | Matrix":e.referToSelf(t=>r=>Vr(r,t))})}),qc="isNaN",Dm=["typed"],bm=me(qc,Dm,s=>{var{typed:e}=s;return e(qc,{number:Rc,BigNumber:function(r){return r.isNaN()},Fraction:function(r){return!1},Complex:function(r){return r.isNaN()},Unit:function(r){return Number.isNaN(r.value)},"Array | Matrix":function(r){return Vr(r,Number.isNaN)}})});function Ws(s,e,t){if(t==null)return s.eq(e);if(s.eq(e))return!0;if(s.isNaN()||e.isNaN())return!1;if(s.isFinite()&&e.isFinite()){var r=s.minus(e).abs();if(r.isZero())return!0;var n=s.constructor.max(s.abs(),e.abs());return r.lte(n.times(t))}return!1}function Em(s,e,t){return Gn(s.re,e.re,t)&&Gn(s.im,e.im,t)}var js=me("compareUnits",["typed"],s=>{var{typed:e}=s;return{"Unit, Unit":e.referToSelf(t=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return e.find(t,[r.valueType(),n.valueType()])(r.value,n.value)})}}),Ys="equalScalar",xm=["typed","config"],Am=me(Ys,xm,s=>{var{typed:e,config:t}=s,r=js({typed:e});return e(Ys,{"boolean, boolean":function(i,a){return i===a},"number, number":function(i,a){return Gn(i,a,t.epsilon)},"BigNumber, BigNumber":function(i,a){return i.eq(a)||Ws(i,a,t.epsilon)},"Fraction, Fraction":function(i,a){return i.equals(a)},"Complex, Complex":function(i,a){return Em(i,a,t.epsilon)}},r)});me(Ys,["typed","config"],s=>{var{typed:e,config:t}=s;return e(Ys,{"number, number":function(n,i){return Gn(n,i,t.epsilon)}})});var Cm="SparseMatrix",Fm=["typed","equalScalar","Matrix"],Mm=me(Cm,Fm,s=>{var{typed:e,equalScalar:t,Matrix:r}=s;function n(m,w){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(w&&!en(w))throw new Error("Invalid datatype: "+w);if(vt(m))i(this,m,w);else if(m&&xt(m.index)&&xt(m.ptr)&&xt(m.size))this._values=m.values,this._index=m.index,this._ptr=m.ptr,this._size=m.size,this._datatype=w||m.datatype;else if(xt(m))a(this,m,w);else{if(m)throw new TypeError("Unsupported type of data ("+xn(m)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=w}}function i(m,w,v){w.type==="SparseMatrix"?(m._values=w._values?st(w._values):void 0,m._index=st(w._index),m._ptr=st(w._ptr),m._size=st(w._size),m._datatype=v||w._datatype):a(m,w.valueOf(),v||w._datatype)}function a(m,w,v){m._values=[],m._index=[],m._ptr=[],m._datatype=v;var E=w.length,b=0,N=t,x=0;if(en(v)&&(N=e.find(t,[v,v])||t,x=e.convert(0,v)),E>0){var F=0;do{m._ptr.push(m._index.length);for(var M=0;M<E;M++){var S=w[M];if(xt(S)){if(F===0&&b<S.length&&(b=S.length),F<S.length){var I=S[F];N(I,x)||(m._values.push(I),m._index.push(M))}}else F===0&&b<1&&(b=1),N(S,x)||(m._values.push(S),m._index.push(M))}F++}while(F<b)}m._ptr.push(m._index.length),m._size=[E,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(m,w){return new n(m,w)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Ss(this._values,xn)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(m,w){return new n(m,w)},n.prototype.density=function(){var m=this._size[0],w=this._size[1];return m!==0&&w!==0?this._index.length/(m*w):0},n.prototype.subset=function(m,w,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,m);case 2:case 3:return c(this,m,w,v);default:throw new SyntaxError("Wrong number of arguments")}};function l(m,w){if(!la(w))throw new TypeError("Invalid index");var v=w.isScalar();if(v)return m.get(w.min());var E=w.size();if(E.length!==m._size.length)throw new He(E.length,m._size.length);var b,N,x,F,M=w.min(),S=w.max();for(b=0,N=m._size.length;b<N;b++)At(M[b],m._size[b]),At(S[b],m._size[b]);var I=m._values,C=m._index,B=m._ptr,L=w.dimension(0),U=w.dimension(1),k=[],W=[];L.forEach(function(X,Q){W[X]=Q[0],k[X]=!0});var z=I?[]:void 0,K=[],Z=[];return U.forEach(function(X){for(Z.push(K.length),x=B[X],F=B[X+1];x<F;x++)b=C[x],k[b]===!0&&(K.push(W[b]),z&&z.push(I[x]))}),Z.push(K.length),new n({values:z,index:K,ptr:Z,size:E,datatype:m._datatype})}function c(m,w,v,E){if(!w||w.isIndex!==!0)throw new TypeError("Invalid index");var b=w.size(),N=w.isScalar(),x;if(vt(v)?(x=v.size(),v=v.toArray()):x=Tt(v),N){if(x.length!==0)throw new TypeError("Scalar expected");m.set(w.min(),v,E)}else{if(b.length!==1&&b.length!==2)throw new He(b.length,m._size.length,"<");if(x.length<b.length){for(var F=0,M=0;b[F]===1&&x[F]===1;)F++;for(;b[F]===1;)M++,F++;v=rc(v,b.length,M,x)}if(!hi(b,x))throw new He(b,x,">");if(b.length===1){var S=w.dimension(0);S.forEach(function(B,L){At(B),m.set([B,0],v[L[0]],E)})}else{var I=w.dimension(0),C=w.dimension(1);I.forEach(function(B,L){At(B),C.forEach(function(U,k){At(U),m.set([B,U],v[L[0]][k[0]],E)})})}}return m}n.prototype.get=function(m){if(!xt(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new He(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var w=m[0],v=m[1];At(w,this._size[0]),At(v,this._size[1]);var E=p(w,this._ptr[v],this._ptr[v+1],this._index);return E<this._ptr[v+1]&&this._index[E]===w?this._values[E]:0},n.prototype.set=function(m,w,v){if(!xt(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new He(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var E=m[0],b=m[1],N=this._size[0],x=this._size[1],F=t,M=0;en(this._datatype)&&(F=e.find(t,[this._datatype,this._datatype])||t,M=e.convert(0,this._datatype)),(E>N-1||b>x-1)&&(d(this,Math.max(E+1,N),Math.max(b+1,x),v),N=this._size[0],x=this._size[1]),At(E,N),At(b,x);var S=p(E,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===E?F(w,M)?h(S,b,this._values,this._index,this._ptr):this._values[S]=w:F(w,M)||f(S,E,b,w,this._values,this._index,this._ptr),this};function p(m,w,v,E){if(v-w===0)return v;for(var b=w;b<v;b++)if(E[b]===m)return b;return w}function h(m,w,v,E,b){v.splice(m,1),E.splice(m,1);for(var N=w+1;N<b.length;N++)b[N]--}function f(m,w,v,E,b,N,x){b.splice(m,0,E),N.splice(m,0,w);for(var F=v+1;F<x.length;F++)x[F]++}n.prototype.resize=function(m,w,v){if(!Zi(m))throw new TypeError("Array or Matrix expected");var E=m.valueOf().map(N=>Array.isArray(N)&&N.length===1?N[0]:N);if(E.length!==2)throw new Error("Only two dimensions matrix are supported");E.forEach(function(N){if(!pt(N)||!Dt(N)||N<0)throw new TypeError("Invalid size, must contain positive integers (size: "+ct(E)+")")});var b=v?this.clone():this;return d(b,E[0],E[1],w)};function d(m,w,v,E){var b=E||0,N=t,x=0;en(m._datatype)&&(N=e.find(t,[m._datatype,m._datatype])||t,x=e.convert(0,m._datatype),b=e.convert(b,m._datatype));var F=!N(b,x),M=m._size[0],S=m._size[1],I,C,B;if(v>S){for(C=S;C<v;C++)if(m._ptr[C]=m._values.length,F)for(I=0;I<M;I++)m._values.push(b),m._index.push(I);m._ptr[v]=m._values.length}else v<S&&(m._ptr.splice(v+1,S-v),m._values.splice(m._ptr[v],m._values.length),m._index.splice(m._ptr[v],m._index.length));if(S=v,w>M){if(F){var L=0;for(C=0;C<S;C++){m._ptr[C]=m._ptr[C]+L,B=m._ptr[C+1]+L;var U=0;for(I=M;I<w;I++,U++)m._values.splice(B+U,0,b),m._index.splice(B+U,0,I),L++}m._ptr[S]=m._values.length}}else if(w<M){var k=0;for(C=0;C<S;C++){m._ptr[C]=m._ptr[C]-k;var W=m._ptr[C],z=m._ptr[C+1]-k;for(B=W;B<z;B++)I=m._index[B],I>w-1&&(m._values.splice(B,1),m._index.splice(B,1),k++)}m._ptr[C]=m._values.length}return m._size[0]=w,m._size[1]=v,m}n.prototype.reshape=function(m,w){if(!xt(m))throw new TypeError("Array expected");if(m.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");m.forEach(function(X){if(!pt(X)||!Dt(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+ct(m)+")")});var v=this._size[0]*this._size[1];m=ga(m,v);var E=m[0]*m[1];if(v!==E)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=w?this.clone():this;if(this._size[0]===m[0]&&this._size[1]===m[1])return b;for(var N=[],x=0;x<b._ptr.length;x++)for(var F=0;F<b._ptr[x+1]-b._ptr[x];F++)N.push(x);for(var M=b._values.slice(),S=b._index.slice(),I=0;I<b._index.length;I++){var C=S[I],B=N[I],L=C*b._size[1]+B;N[I]=L%m[1],S[I]=Math.floor(L/m[1])}b._values.length=0,b._index.length=0,b._ptr.length=m[1]+1,b._size=m.slice();for(var U=0;U<b._ptr.length;U++)b._ptr[U]=0;for(var k=0;k<M.length;k++){var W=S[k],z=N[k],K=M[k],Z=p(W,b._ptr[z],b._ptr[z+1],b._index);f(Z,W,z,K,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var m=new n({values:this._values?st(this._values):void 0,index:st(this._index),ptr:st(this._ptr),size:st(this._size),datatype:this._datatype});return m},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(m,w){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,E=this._size[0],b=this._size[1],N=Cc(m),x=function(M,S,I){return N===1?m(M):N===2?m(M,[S,I]):m(M,[S,I],v)};return g(this,0,E-1,0,b-1,x,w)};function g(m,w,v,E,b,N,x){var F=[],M=[],S=[],I=t,C=0;en(m._datatype)&&(I=e.find(t,[m._datatype,m._datatype])||t,C=e.convert(0,m._datatype));for(var B=function(le,we,be){le=N(le,we,be),I(le,C)||(F.push(le),M.push(we))},L=E;L<=b;L++){S.push(F.length);var U=m._ptr[L],k=m._ptr[L+1];if(x)for(var W=U;W<k;W++){var z=m._index[W];z>=w&&z<=v&&B(m._values[W],z-w,L-E)}else{for(var K={},Z=U;Z<k;Z++){var X=m._index[Z];K[X]=m._values[Z]}for(var Q=w;Q<=v;Q++){var ce=Q in K?K[Q]:0;B(ce,Q-w,L-E)}}}return S.push(F.length),new n({values:F,index:M,ptr:S,size:[v-w+1,b-E+1]})}n.prototype.forEach=function(m,w){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,E=this._size[0],b=this._size[1],N=0;N<b;N++){var x=this._ptr[N],F=this._ptr[N+1];if(w)for(var M=x;M<F;M++){var S=this._index[M];m(this._values[M],[S,N],v)}else{for(var I={},C=x;C<F;C++){var B=this._index[C];I[B]=this._values[C]}for(var L=0;L<E;L++){var U=L in I?I[L]:0;m(U,[L,N],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var m=this._size[1],w=0;w<m;w++)for(var v=this._ptr[w],E=this._ptr[w+1],b=v;b<E;b++){var N=this._index[b];yield{value:this._values[b],index:[N,w]}}},n.prototype.toArray=function(){return y(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return y(this._values,this._index,this._ptr,this._size,!1)};function y(m,w,v,E,b){var N=E[0],x=E[1],F=[],M,S;for(M=0;M<N;M++)for(F[M]=[],S=0;S<x;S++)F[M][S]=0;for(S=0;S<x;S++)for(var I=v[S],C=v[S+1],B=I;B<C;B++)M=w[B],F[M][S]=m?b?st(m[B]):m[B]:1;return F}return n.prototype.format=function(m){for(var w=this._size[0],v=this._size[1],E=this.density(),b="Sparse Matrix ["+ct(w,m)+" x "+ct(v,m)+"] density: "+ct(E,m)+`
|
53
|
+
`,N=0;N<v;N++)for(var x=this._ptr[N],F=this._ptr[N+1],M=x;M<F;M++){var S=this._index[M];b+=`
|
54
|
+
(`+ct(S,m)+", "+ct(N,m)+") ==> "+(this._values?ct(this._values[M],m):"X")}return b},n.prototype.toString=function(){return ct(this.toArray())},n.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(m){if(m){if(Nt(m)&&(m=m.toNumber()),!pt(m)||!Dt(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var w=m>0?m:0,v=m<0?-m:0,E=this._size[0],b=this._size[1],N=Math.min(E-v,b-w),x=[],F=[],M=[];M[0]=0;for(var S=w;S<b&&x.length<N;S++)for(var I=this._ptr[S],C=this._ptr[S+1],B=I;B<C;B++){var L=this._index[B];if(L===S-w+v){x.push(this._values[B]),F[x.length-1]=L-v;break}}return M.push(x.length),new n({values:x,index:F,ptr:M,size:[N,1]})},n.fromJSON=function(m){return new n(m)},n.diagonal=function(m,w,v,E,b){if(!xt(m))throw new TypeError("Array expected, size parameter");if(m.length!==2)throw new Error("Only two dimensions matrix are supported");if(m=m.map(function(X){if(Nt(X)&&(X=X.toNumber()),!pt(X)||!Dt(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Nt(v)&&(v=v.toNumber()),!pt(v)||!Dt(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var N=t,x=0;en(b)&&(N=e.find(t,[b,b])||t,x=e.convert(0,b));var F=v>0?v:0,M=v<0?-v:0,S=m[0],I=m[1],C=Math.min(S-M,I-F),B;if(xt(w)){if(w.length!==C)throw new Error("Invalid value array length");B=function(Q){return w[Q]}}else if(vt(w)){var L=w.size();if(L.length!==1||L[0]!==C)throw new Error("Invalid matrix length");B=function(Q){return w.get([Q])}}else B=function(){return w};for(var U=[],k=[],W=[],z=0;z<I;z++){W.push(U.length);var K=z-F;if(K>=0&&K<C){var Z=B(K);N(Z,x)||(k.push(K+M),U.push(Z))}}return W.push(U.length),new n({values:U,index:k,ptr:W,size:[S,I]})},n.prototype.swapRows=function(m,w){if(!pt(m)||!Dt(m)||!pt(w)||!Dt(w))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return At(m,this._size[0]),At(w,this._size[0]),n._swapRows(m,w,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(m,w,v,E,b){for(var N=E[m],x=E[m+1],F=N;F<x;F++)b(v[F],w[F])},n._swapRows=function(m,w,v,E,b,N){for(var x=0;x<v;x++){var F=N[x],M=N[x+1],S=p(m,F,M,b),I=p(w,F,M,b);if(S<M&&I<M&&b[S]===m&&b[I]===w){if(E){var C=E[S];E[S]=E[I],E[I]=C}continue}if(S<M&&b[S]===m&&(I>=M||b[I]!==w)){var B=E?E[S]:void 0;b.splice(I,0,w),E&&E.splice(I,0,B),b.splice(I<=S?S+1:S,1),E&&E.splice(I<=S?S+1:S,1);continue}if(I<M&&b[I]===w&&(S>=M||b[S]!==m)){var L=E?E[I]:void 0;b.splice(S,0,m),E&&E.splice(S,0,L),b.splice(S<=I?I+1:I,1),E&&E.splice(S<=I?I+1:I,1)}}},n},{isClass:!0}),Nm="number",Sm=["typed"];function Bm(s){var e=s.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(e){var t={"0b":2,"0o":8,"0x":16}[e[1]],r=e[2],n=e[3];return{input:s,radix:t,integerPart:r,fractionalPart:n}}else return null}function Om(s){for(var e=parseInt(s.integerPart,s.radix),t=0,r=0;r<s.fractionalPart.length;r++){var n=parseInt(s.fractionalPart[r],s.radix);t+=n/Math.pow(s.radix,r+1)}var i=e+t;if(isNaN(i))throw new SyntaxError('String "'+s.input+'" is not a valid number');return i}var Tm=me(Nm,Sm,s=>{var{typed:e}=s,t=e("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var i=Bm(n);if(i)return Om(i);var a=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(a=Number(l[2]),n=l[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:e.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),null:function(n){return 0},"Unit, string | Unit":function(n,i){return n.toNumber(i)},"Array | Matrix":e.referToSelf(r=>n=>Vr(n,r))});return t.fromJSON=function(r){return parseFloat(r.value)},t}),Im="bignumber",$m=["typed","BigNumber"],Lm=me(Im,$m,s=>{var{typed:e,BigNumber:t}=s;return e("bignumber",{"":function(){return new t(0)},number:function(n){return new t(n+"")},string:function(n){var i=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var a=i[2],l=t(i[1]),c=new t(2).pow(Number(a));if(l.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var p=new t(2).pow(Number(a)-1);return l.gte(p)?l.sub(c):l}return new t(n)},BigNumber:function(n){return n},Unit:e.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),Fraction:function(n){return new t(n.n).div(n.d).times(n.s)},null:function(n){return new t(0)},"Array | Matrix":e.referToSelf(r=>n=>Vr(n,r))})}),Rm="fraction",Pm=["typed","Fraction"],zm=me(Rm,Pm,s=>{var{typed:e,Fraction:t}=s;return e("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new t(n)},string:function(n){return new t(n)},"number, number":function(n,i){return new t(n,i)},null:function(n){return new t(0)},BigNumber:function(n){return new t(n.toString())},Fraction:function(n){return n},Unit:e.referToSelf(r=>n=>{var i=n.clone();return i.value=r(n.value),i}),Object:function(n){return new t(n)},"Array | Matrix":e.referToSelf(r=>n=>Vr(n,r))})}),kc="matrix",qm=["typed","Matrix","DenseMatrix","SparseMatrix"],km=me(kc,qm,s=>{var{typed:e,Matrix:t,DenseMatrix:r,SparseMatrix:n}=s;return e(kc,{"":function(){return i([])},string:function(l){return i([],l)},"string, string":function(l,c){return i([],l,c)},Array:function(l){return i(l)},Matrix:function(l){return i(l,l.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(a,l,c){if(l==="dense"||l==="default"||l===void 0)return new r(a,c);if(l==="sparse")return new n(a,c);throw new TypeError("Unknown matrix type "+JSON.stringify(l)+".")}}),Uc="unaryMinus",Um=["typed"],Wm=me(Uc,Um,s=>{var{typed:e}=s;return e(Uc,{number:Tc,"Complex | BigNumber | Fraction":t=>t.neg(),Unit:e.referToSelf(t=>r=>{var n=r.clone();return n.value=e.find(t,n.valueType())(r.value),n}),"Array | Matrix":e.referToSelf(t=>r=>Vr(r,t))})}),Wc="abs",jm=["typed"],Ym=me(Wc,jm,s=>{var{typed:e}=s;return e(Wc,{number:Nc,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),"Array | Matrix":e.referToSelf(t=>r=>Vr(r,t))})}),jc="addScalar",Vm=["typed"],Zm=me(jc,Vm,s=>{var{typed:e}=s;return e(jc,{"number, number":Sc,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":e.referToSelf(t=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var i=r.clone();return i.value=e.find(t,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),Yc="subtractScalar",Km=["typed"],Gm=me(Yc,Km,s=>{var{typed:e}=s;return e(Yc,{"number, number":Bc,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":e.referToSelf(t=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var i=r.clone();return i.value=e.find(t,[i.valueType(),n.valueType()])(i.value,n.value),i.fixPrefix=!1,i})})}),Hm="matAlgo11xS0s",Jm=["typed","equalScalar"],Ma=me(Hm,Jm,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a,l){var c=n._values,p=n._index,h=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=t,v=0,E=a;typeof d=="string"&&(m=d,w=e.find(t,[m,m]),v=e.convert(0,m),i=e.convert(i,m),E=e.find(a,[m,m]));for(var b=[],N=[],x=[],F=0;F<y;F++){x[F]=N.length;for(var M=h[F],S=h[F+1],I=M;I<S;I++){var C=p[I],B=l?E(i,c[I]):E(c[I],i);w(B,v)||(N.push(C),b.push(B))}}return x[y]=N.length,n.createSparseMatrix({values:b,index:N,ptr:x,size:[g,y],datatype:m})}}),Xm="matAlgo12xSfs",Qm=["typed","DenseMatrix"],vi=me(Xm,Qm,s=>{var{typed:e,DenseMatrix:t}=s;return function(n,i,a,l){var c=n._values,p=n._index,h=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=a;typeof d=="string"&&(m=d,i=e.convert(i,m),w=e.find(a,[m,m]));for(var v=[],E=[],b=[],N=0;N<y;N++){for(var x=N+1,F=h[N],M=h[N+1],S=F;S<M;S++){var I=p[S];E[I]=c[S],b[I]=x}for(var C=0;C<g;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?w(i,E[C]):w(E[C],i):v[C][N]=l?w(i,0):w(0,i)}return new t({data:v,size:[g,y],datatype:m})}}),eg="matAlgo14xDs",tg=["typed"],Na=me(eg,tg,s=>{var{typed:e}=s;return function(n,i,a,l){var c=n._data,p=n._size,h=n._datatype,f,d=a;typeof h=="string"&&(f=h,i=e.convert(i,f),d=e.find(a,[f,f]));var g=p.length>0?t(d,0,p,p[0],c,i,l):[];return n.createDenseMatrix({data:g,size:st(p),datatype:f})};function t(r,n,i,a,l,c,p){var h=[];if(n===i.length-1)for(var f=0;f<a;f++)h[f]=p?r(c,l[f]):r(l[f],c);else for(var d=0;d<a;d++)h[d]=t(r,n+1,i,i[n+1],l[d],c,p);return h}}),rg="matAlgo02xDS0",ng=["typed","equalScalar"],ig=me(rg,ng,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a,l){var c=n._data,p=n._size,h=n._datatype||n.getDataType(),f=i._values,d=i._index,g=i._ptr,y=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(p.length!==y.length)throw new He(p.length,y.length);if(p[0]!==y[0]||p[1]!==y[1])throw new RangeError("Dimension mismatch. Matrix A ("+p+") must match Matrix B ("+y+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var w=p[0],v=p[1],E,b=t,N=0,x=a;typeof h=="string"&&h===m&&h!=="mixed"&&(E=h,b=e.find(t,[E,E]),N=e.convert(0,E),x=e.find(a,[E,E]));for(var F=[],M=[],S=[],I=0;I<v;I++){S[I]=M.length;for(var C=g[I],B=g[I+1],L=C;L<B;L++){var U=d[L],k=l?x(f[L],c[U][I]):x(c[U][I],f[L]);b(k,N)||(M.push(U),F.push(k))}}return S[v]=M.length,i.createSparseMatrix({values:F,index:M,ptr:S,size:[w,v],datatype:h===n._datatype&&m===i._datatype?E:void 0})}}),sg="matAlgo03xDSf",og=["typed"],yi=me(sg,og,s=>{var{typed:e}=s;return function(r,n,i,a){var l=r._data,c=r._size,p=r._datatype||r.getDataType(),h=n._values,f=n._index,d=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new He(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v,E=0,b=i;typeof p=="string"&&p===y&&p!=="mixed"&&(v=p,E=e.convert(0,v),b=e.find(i,[v,v]));for(var N=[],x=0;x<m;x++)N[x]=[];for(var F=[],M=[],S=0;S<w;S++){for(var I=S+1,C=d[S],B=d[S+1],L=C;L<B;L++){var U=f[L];F[U]=a?b(h[L],l[U][S]):b(l[U][S],h[L]),M[U]=I}for(var k=0;k<m;k++)M[k]===I?N[k][S]=F[k]:N[k][S]=a?b(E,l[k][S]):b(l[k][S],E)}return r.createDenseMatrix({data:N,size:[m,w],datatype:p===r._datatype&&y===n._datatype?v:void 0})}}),ag="matAlgo05xSfSf",ug=["typed","equalScalar"],Vc=me(ag,ug,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a){var l=n._values,c=n._index,p=n._ptr,h=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=i._values,g=i._index,y=i._ptr,m=i._size,w=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==m.length)throw new He(h.length,m.length);if(h[0]!==m[0]||h[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+m+")");var v=h[0],E=h[1],b,N=t,x=0,F=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=e.find(t,[b,b]),x=e.convert(0,b),F=e.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],I=[],C=M?[]:void 0,B=M?[]:void 0,L=[],U=[],k,W,z,K;for(W=0;W<E;W++){I[W]=S.length;var Z=W+1;for(z=p[W],K=p[W+1];z<K;z++)k=c[z],S.push(k),L[k]=Z,C&&(C[k]=l[z]);for(z=y[W],K=y[W+1];z<K;z++)k=g[z],L[k]!==Z&&S.push(k),U[k]=Z,B&&(B[k]=d[z]);if(M)for(z=I[W];z<S.length;){k=S[z];var X=L[k],Q=U[k];if(X===Z||Q===Z){var ce=X===Z?C[k]:x,ve=Q===Z?B[k]:x,le=F(ce,ve);N(le,x)?S.splice(z,1):(M.push(le),z++)}}}return I[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:I,size:[v,E],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),lg="matAlgo13xDD",cg=["typed"],fg=me(lg,cg,s=>{var{typed:e}=s;return function(n,i,a){var l=n._data,c=n._size,p=n._datatype,h=i._data,f=i._size,d=i._datatype,g=[];if(c.length!==f.length)throw new He(c.length,f.length);for(var y=0;y<c.length;y++){if(c[y]!==f[y])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+f+")");g[y]=c[y]}var m,w=a;typeof p=="string"&&p===d&&(m=p,w=e.find(a,[m,m]));var v=g.length>0?t(w,0,g,g[0],l,h):[];return n.createDenseMatrix({data:v,size:g,datatype:m})};function t(r,n,i,a,l,c){var p=[];if(n===i.length-1)for(var h=0;h<a;h++)p[h]=r(l[h],c[h]);else for(var f=0;f<a;f++)p[f]=t(r,n+1,i,i[n+1],l[f],c[f]);return p}}),hg="broadcast",pg=["concat"],dg=me(hg,pg,s=>{var{concat:e}=s;return function(n,i){var a=Math.max(n._size.length,i._size.length);if(n._size.length===i._size.length&&n._size.every((y,m)=>y===i._size[m]))return[n,i];for(var l=t(n._size,a,0),c=t(i._size,a,0),p=[],h=0;h<a;h++)p[h]=Math.max(l[h],c[h]);Bs(l,p),Bs(c,p);var f=n.clone(),d=i.clone();f._size.length<a?f.reshape(t(f._size,a,1)):d._size.length<a&&d.reshape(t(d._size,a,1));for(var g=0;g<a;g++)f._size[g]<p[g]&&(f=r(f,p[g],g)),d._size[g]<p[g]&&(d=r(d,p[g],g));return[f,d]};function t(n,i,a){return[...Array(i-n.length).fill(a),...n]}function r(n,i,a){return e(...Array(i).fill(n),a)}}),_g="matrixAlgorithmSuite",mg=["typed","matrix","concat"],Hn=me(_g,mg,s=>{var{typed:e,matrix:t,concat:r}=s,n=fg({typed:e}),i=Na({typed:e}),a=dg({concat:r});return function(c){var p=c.elop,h=c.SD||c.DS,f;p?(f={"DenseMatrix, DenseMatrix":(m,w)=>n(...a(m,w),p),"Array, Array":(m,w)=>n(...a(t(m),t(w)),p).valueOf(),"Array, DenseMatrix":(m,w)=>n(...a(t(m),w),p),"DenseMatrix, Array":(m,w)=>n(...a(m,t(w)),p)},c.SS&&(f["SparseMatrix, SparseMatrix"]=(m,w)=>c.SS(...a(m,w),p,!1)),c.DS&&(f["DenseMatrix, SparseMatrix"]=(m,w)=>c.DS(...a(m,w),p,!1),f["Array, SparseMatrix"]=(m,w)=>c.DS(...a(t(m),w),p,!1)),h&&(f["SparseMatrix, DenseMatrix"]=(m,w)=>h(...a(w,m),p,!0),f["SparseMatrix, Array"]=(m,w)=>h(...a(t(w),m),p,!0))):(f={"DenseMatrix, DenseMatrix":e.referToSelf(m=>(w,v)=>n(...a(w,v),m)),"Array, Array":e.referToSelf(m=>(w,v)=>n(...a(t(w),t(v)),m).valueOf()),"Array, DenseMatrix":e.referToSelf(m=>(w,v)=>n(...a(t(w),v),m)),"DenseMatrix, Array":e.referToSelf(m=>(w,v)=>n(...a(w,t(v)),m))},c.SS&&(f["SparseMatrix, SparseMatrix"]=e.referToSelf(m=>(w,v)=>c.SS(...a(w,v),m,!1))),c.DS&&(f["DenseMatrix, SparseMatrix"]=e.referToSelf(m=>(w,v)=>c.DS(...a(w,v),m,!1)),f["Array, SparseMatrix"]=e.referToSelf(m=>(w,v)=>c.DS(...a(t(w),v),m,!1))),h&&(f["SparseMatrix, DenseMatrix"]=e.referToSelf(m=>(w,v)=>h(...a(v,w),m,!0)),f["SparseMatrix, Array"]=e.referToSelf(m=>(w,v)=>h(...a(t(v),w),m,!0))));var d=c.scalar||"any",g=c.Ds||c.Ss;g&&(p?(f["DenseMatrix,"+d]=(m,w)=>i(m,w,p,!1),f[d+", DenseMatrix"]=(m,w)=>i(w,m,p,!0),f["Array,"+d]=(m,w)=>i(t(m),w,p,!1).valueOf(),f[d+", Array"]=(m,w)=>i(t(w),m,p,!0).valueOf()):(f["DenseMatrix,"+d]=e.referToSelf(m=>(w,v)=>i(w,v,m,!1)),f[d+", DenseMatrix"]=e.referToSelf(m=>(w,v)=>i(v,w,m,!0)),f["Array,"+d]=e.referToSelf(m=>(w,v)=>i(t(w),v,m,!1).valueOf()),f[d+", Array"]=e.referToSelf(m=>(w,v)=>i(t(v),w,m,!0).valueOf())));var y=c.sS!==void 0?c.sS:c.Ss;return p?(c.Ss&&(f["SparseMatrix,"+d]=(m,w)=>c.Ss(m,w,p,!1)),y&&(f[d+", SparseMatrix"]=(m,w)=>y(w,m,p,!0))):(c.Ss&&(f["SparseMatrix,"+d]=e.referToSelf(m=>(w,v)=>c.Ss(w,v,m,!1))),y&&(f[d+", SparseMatrix"]=e.referToSelf(m=>(w,v)=>y(v,w,m,!0)))),p&&p.signatures&&zl(f,p.signatures),f}}),gg="matAlgo01xDSid",vg=["typed"],Zc=me(gg,vg,s=>{var{typed:e}=s;return function(r,n,i,a){var l=r._data,c=r._size,p=r._datatype||r.getDataType(),h=n._values,f=n._index,d=n._ptr,g=n._size,y=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new He(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],w=c[1],v=typeof p=="string"&&p!=="mixed"&&p===y?p:void 0,E=v?e.find(i,[v,v]):i,b,N,x=[];for(b=0;b<m;b++)x[b]=[];var F=[],M=[];for(N=0;N<w;N++){for(var S=N+1,I=d[N],C=d[N+1],B=I;B<C;B++)b=f[B],F[b]=a?E(h[B],l[b][N]):E(l[b][N],h[B]),M[b]=S;for(b=0;b<m;b++)M[b]===S?x[b][N]=F[b]:x[b][N]=l[b][N]}return r.createDenseMatrix({data:x,size:[m,w],datatype:p===r._datatype&&y===n._datatype?v:void 0})}}),yg="matAlgo04xSidSid",wg=["typed","equalScalar"],Dg=me(yg,wg,s=>{var{typed:e,equalScalar:t}=s;return function(n,i,a){var l=n._values,c=n._index,p=n._ptr,h=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),d=i._values,g=i._index,y=i._ptr,m=i._size,w=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(h.length!==m.length)throw new He(h.length,m.length);if(h[0]!==m[0]||h[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+m+")");var v=h[0],E=h[1],b,N=t,x=0,F=a;typeof f=="string"&&f===w&&f!=="mixed"&&(b=f,N=e.find(t,[b,b]),x=e.convert(0,b),F=e.find(a,[b,b]));var M=l&&d?[]:void 0,S=[],I=[],C=l&&d?[]:void 0,B=l&&d?[]:void 0,L=[],U=[],k,W,z,K,Z;for(W=0;W<E;W++){I[W]=S.length;var X=W+1;for(K=p[W],Z=p[W+1],z=K;z<Z;z++)k=c[z],S.push(k),L[k]=X,C&&(C[k]=l[z]);for(K=y[W],Z=y[W+1],z=K;z<Z;z++)if(k=g[z],L[k]===X){if(C){var Q=F(C[k],d[z]);N(Q,x)?L[k]=null:C[k]=Q}}else S.push(k),U[k]=X,B&&(B[k]=d[z]);if(C&&B)for(z=I[W];z<S.length;)k=S[z],L[k]===X?(M[z]=C[k],z++):U[k]===X?(M[z]=B[k],z++):S.splice(z,1)}return I[E]=S.length,n.createSparseMatrix({values:M,index:S,ptr:I,size:[v,E],datatype:f===n._datatype&&w===i._datatype?b:void 0})}}),bg="matAlgo10xSids",Eg=["typed","DenseMatrix"],Kc=me(bg,Eg,s=>{var{typed:e,DenseMatrix:t}=s;return function(n,i,a,l){var c=n._values,p=n._index,h=n._ptr,f=n._size,d=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],y=f[1],m,w=a;typeof d=="string"&&(m=d,i=e.convert(i,m),w=e.find(a,[m,m]));for(var v=[],E=[],b=[],N=0;N<y;N++){for(var x=N+1,F=h[N],M=h[N+1],S=F;S<M;S++){var I=p[S];E[I]=c[S],b[I]=x}for(var C=0;C<g;C++)N===0&&(v[C]=[]),b[C]===x?v[C][N]=l?w(i,E[C]):w(E[C],i):v[C][N]=i}return new t({data:v,size:[g,y],datatype:m})}}),xg="multiplyScalar",Ag=["typed"],Cg=me(xg,Ag,s=>{var{typed:e}=s;return e("multiplyScalar",{"number, number":Oc,"Complex, Complex":function(r,n){return r.mul(n)},"BigNumber, BigNumber":function(r,n){return r.times(n)},"Fraction, Fraction":function(r,n){return r.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(t,r)=>r.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,r)=>t.multiply(r)})}),Gc="multiply",Fg=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Mg=me(Gc,Fg,s=>{var{typed:e,matrix:t,addScalar:r,multiplyScalar:n,equalScalar:i,dot:a}=s,l=Ma({typed:e,equalScalar:i}),c=Na({typed:e});function p(x,F){switch(x.length){case 1:switch(F.length){case 1:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;case 2:switch(F.length){case 1:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+F[0]+")");break;case 2:if(x[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+F[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+F.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function h(x,F,M){if(M===0)throw new Error("Cannot multiply two empty vectors");return a(x,F)}function f(x,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return d(x,F)}function d(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,B=F._size,L=F._datatype||F.getDataType(),U=S[0],k=B[1],W,z=r,K=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&(W=I,z=e.find(r,[W,W]),K=e.find(n,[W,W]));for(var Z=[],X=0;X<k;X++){for(var Q=K(M[0],C[0][X]),ce=1;ce<U;ce++)Q=z(Q,K(M[ce],C[ce][X]));Z[X]=Q}return x.createDenseMatrix({data:Z,size:[k],datatype:I===x._datatype&&L===F._datatype?W:void 0})}var g=e("_multiplyMatrixVector",{"DenseMatrix, any":m,"SparseMatrix, any":E}),y=e("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":w,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":N});function m(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,B=F._datatype||F.getDataType(),L=S[0],U=S[1],k,W=r,z=n;I&&B&&I===B&&typeof I=="string"&&I!=="mixed"&&(k=I,W=e.find(r,[k,k]),z=e.find(n,[k,k]));for(var K=[],Z=0;Z<L;Z++){for(var X=M[Z],Q=z(X[0],C[0]),ce=1;ce<U;ce++)Q=W(Q,z(X[ce],C[ce]));K[Z]=Q}return x.createDenseMatrix({data:K,size:[L],datatype:I===x._datatype&&B===F._datatype?k:void 0})}function w(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._data,B=F._size,L=F._datatype||F.getDataType(),U=S[0],k=S[1],W=B[1],z,K=r,Z=n;I&&L&&I===L&&typeof I=="string"&&I!=="mixed"&&I!=="mixed"&&(z=I,K=e.find(r,[z,z]),Z=e.find(n,[z,z]));for(var X=[],Q=0;Q<U;Q++){var ce=M[Q];X[Q]=[];for(var ve=0;ve<W;ve++){for(var le=Z(ce[0],C[0][ve]),we=1;we<k;we++)le=K(le,Z(ce[we],C[we][ve]));X[Q][ve]=le}}return x.createDenseMatrix({data:X,size:[U,W],datatype:I===x._datatype&&L===F._datatype?z:void 0})}function v(x,F){var M=x._data,S=x._size,I=x._datatype||x.getDataType(),C=F._values,B=F._index,L=F._ptr,U=F._size,k=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!C)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=S[0],z=U[1],K,Z=r,X=n,Q=i,ce=0;I&&k&&I===k&&typeof I=="string"&&I!=="mixed"&&(K=I,Z=e.find(r,[K,K]),X=e.find(n,[K,K]),Q=e.find(i,[K,K]),ce=e.convert(0,K));for(var ve=[],le=[],we=[],be=F.createSparseMatrix({values:ve,index:le,ptr:we,size:[W,z],datatype:I===x._datatype&&k===F._datatype?K:void 0}),Be=0;Be<z;Be++){we[Be]=le.length;var Ee=L[Be],ot=L[Be+1];if(ot>Ee)for(var Te=0,Ne=0;Ne<W;Ne++){for(var lt=Ne+1,rt=void 0,ke=Ee;ke<ot;ke++){var Je=B[ke];Te!==lt?(rt=X(M[Ne][Je],C[ke]),Te=lt):rt=Z(rt,X(M[Ne][Je],C[ke]))}Te===lt&&!Q(rt,ce)&&(le.push(Ne),ve.push(rt))}}return we[z]=le.length,be}function E(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var B=F._data,L=F._datatype||F.getDataType(),U=x._size[0],k=F._size[0],W=[],z=[],K=[],Z,X=r,Q=n,ce=i,ve=0;C&&L&&C===L&&typeof C=="string"&&C!=="mixed"&&(Z=C,X=e.find(r,[Z,Z]),Q=e.find(n,[Z,Z]),ce=e.find(i,[Z,Z]),ve=e.convert(0,Z));var le=[],we=[];K[0]=0;for(var be=0;be<k;be++){var Be=B[be];if(!ce(Be,ve))for(var Ee=I[be],ot=I[be+1],Te=Ee;Te<ot;Te++){var Ne=S[Te];we[Ne]?le[Ne]=X(le[Ne],Q(Be,M[Te])):(we[Ne]=!0,z.push(Ne),le[Ne]=Q(Be,M[Te]))}}for(var lt=z.length,rt=0;rt<lt;rt++){var ke=z[rt];W[rt]=le[ke]}return K[1]=z.length,x.createSparseMatrix({values:W,index:z,ptr:K,size:[U,1],datatype:C===x._datatype&&L===F._datatype?Z:void 0})}function b(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType();if(!M)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var B=F._data,L=F._datatype||F.getDataType(),U=x._size[0],k=F._size[0],W=F._size[1],z,K=r,Z=n,X=i,Q=0;C&&L&&C===L&&typeof C=="string"&&C!=="mixed"&&(z=C,K=e.find(r,[z,z]),Z=e.find(n,[z,z]),X=e.find(i,[z,z]),Q=e.convert(0,z));for(var ce=[],ve=[],le=[],we=x.createSparseMatrix({values:ce,index:ve,ptr:le,size:[U,W],datatype:C===x._datatype&&L===F._datatype?z:void 0}),be=[],Be=[],Ee=0;Ee<W;Ee++){le[Ee]=ve.length;for(var ot=Ee+1,Te=0;Te<k;Te++){var Ne=B[Te][Ee];if(!X(Ne,Q))for(var lt=I[Te],rt=I[Te+1],ke=lt;ke<rt;ke++){var Je=S[ke];Be[Je]!==ot?(Be[Je]=ot,ve.push(Je),be[Je]=Z(Ne,M[ke])):be[Je]=K(be[Je],Z(Ne,M[ke]))}}for(var $t=le[Ee],mr=ve.length,Pt=$t;Pt<mr;Pt++){var pn=ve[Pt];ce[Pt]=be[pn]}}return le[W]=ve.length,we}function N(x,F){var M=x._values,S=x._index,I=x._ptr,C=x._datatype||x._data===void 0?x._datatype:x.getDataType(),B=F._values,L=F._index,U=F._ptr,k=F._datatype||F._data===void 0?F._datatype:F.getDataType(),W=x._size[0],z=F._size[1],K=M&&B,Z,X=r,Q=n;C&&k&&C===k&&typeof C=="string"&&C!=="mixed"&&(Z=C,X=e.find(r,[Z,Z]),Q=e.find(n,[Z,Z]));for(var ce=K?[]:void 0,ve=[],le=[],we=x.createSparseMatrix({values:ce,index:ve,ptr:le,size:[W,z],datatype:C===x._datatype&&k===F._datatype?Z:void 0}),be=K?[]:void 0,Be=[],Ee,ot,Te,Ne,lt,rt,ke,Je,$t=0;$t<z;$t++){le[$t]=ve.length;var mr=$t+1;for(lt=U[$t],rt=U[$t+1],Ne=lt;Ne<rt;Ne++)if(Je=L[Ne],K)for(ot=I[Je],Te=I[Je+1],Ee=ot;Ee<Te;Ee++)ke=S[Ee],Be[ke]!==mr?(Be[ke]=mr,ve.push(ke),be[ke]=Q(B[Ne],M[Ee])):be[ke]=X(be[ke],Q(B[Ne],M[Ee]));else for(ot=I[Je],Te=I[Je+1],Ee=ot;Ee<Te;Ee++)ke=S[Ee],Be[ke]!==mr&&(Be[ke]=mr,ve.push(ke));if(K)for(var Pt=le[$t],pn=ve.length,On=Pt;On<pn;On++){var dn=ve[On];ce[On]=be[dn]}}return le[z]=ve.length,we}return e(Gc,n,{"Array, Array":e.referTo("Matrix, Matrix",x=>(F,M)=>{p(Tt(F),Tt(M));var S=x(t(F),t(M));return vt(S)?S.valueOf():S}),"Matrix, Matrix":function(F,M){var S=F.size(),I=M.size();return p(S,I),S.length===1?I.length===1?h(F,M,S[0]):f(F,M):I.length===1?g(F,M):y(F,M)},"Matrix, Array":e.referTo("Matrix,Matrix",x=>(F,M)=>x(F,t(M))),"Array, Matrix":e.referToSelf(x=>(F,M)=>x(t(F,M.storage()),M)),"SparseMatrix, any":function(F,M){return l(F,M,n,!1)},"DenseMatrix, any":function(F,M){return c(F,M,n,!1)},"any, SparseMatrix":function(F,M){return l(M,F,n,!0)},"any, DenseMatrix":function(F,M){return c(M,F,n,!0)},"Array, any":function(F,M){return c(t(F),M,n,!1).valueOf()},"any, Array":function(F,M){return c(t(M),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":e.referToSelf(x=>(F,M,S)=>{for(var I=x(F,M),C=0;C<S.length;C++)I=x(I,S[C]);return I})})}),Hc="subtract",Ng=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],Sg=me(Hc,Ng,s=>{var{typed:e,matrix:t,equalScalar:r,subtractScalar:n,unaryMinus:i,DenseMatrix:a,concat:l}=s,c=Zc({typed:e}),p=yi({typed:e}),h=Vc({typed:e,equalScalar:r}),f=Kc({typed:e,DenseMatrix:a}),d=vi({typed:e,DenseMatrix:a}),g=Hn({typed:e,matrix:t,concat:l});return e(Hc,{"any, any":n},g({elop:n,SS:h,DS:c,SD:p,Ss:d,sS:f}))}),Bg="matAlgo07xSSf",Og=["typed","DenseMatrix"],Vs=me(Bg,Og,s=>{var{typed:e,DenseMatrix:t}=s;return function(i,a,l){var c=i._size,p=i._datatype||i._data===void 0?i._datatype:i.getDataType(),h=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==h.length)throw new He(c.length,h.length);if(c[0]!==h[0]||c[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+h+")");var d=c[0],g=c[1],y,m=0,w=l;typeof p=="string"&&p===f&&p!=="mixed"&&(y=p,m=e.convert(0,y),w=e.find(l,[y,y]));var v,E,b=[];for(v=0;v<d;v++)b[v]=[];var N=[],x=[],F=[],M=[];for(E=0;E<g;E++){var S=E+1;for(r(i,E,F,N,S),r(a,E,M,x,S),v=0;v<d;v++){var I=F[v]===S?N[v]:m,C=M[v]===S?x[v]:m;b[v][E]=w(I,C)}}return new t({data:b,size:[d,g],datatype:p===i._datatype&&f===a._datatype?y:void 0})};function r(n,i,a,l,c){for(var p=n._values,h=n._index,f=n._ptr,d=f[i],g=f[i+1];d<g;d++){var y=h[d];a[y]=c,l[y]=p[d]}}}),Jc="conj",Tg=["typed"],Ig=me(Jc,Tg,s=>{var{typed:e}=s;return e(Jc,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),"Array | Matrix":e.referToSelf(t=>r=>Vr(r,t))})}),Xc="concat",$g=["typed","matrix","isInteger"],Lg=me(Xc,$g,s=>{var{typed:e,matrix:t,isInteger:r}=s;return e(Xc,{"...Array | Matrix | number | BigNumber":function(i){var a,l=i.length,c=-1,p,h=!1,f=[];for(a=0;a<l;a++){var d=i[a];if(vt(d)&&(h=!0),pt(d)||Nt(d)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(p=c,c=d.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>p)throw new An(c,p+1)}else{var g=st(d).valueOf(),y=Tt(g);if(f[a]=g,p=c,c=y.length-1,a>0&&c!==p)throw new He(p+1,c+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var m=f.shift();f.length;)m=sc(m,f.shift(),c);return h?t(m):m},"...string":function(i){return i.join("")}})}),Qc="count",Rg=["typed","size","prod"],Pg=me(Qc,Rg,s=>{var{typed:e,size:t,prod:r}=s;return e(Qc,{string:function(i){return i.length},"Matrix | Array":function(i){return r(t(i))}})}),ef="identity",zg=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],qg=me(ef,zg,s=>{var{typed:e,config:t,matrix:r,BigNumber:n,DenseMatrix:i,SparseMatrix:a}=s;return e(ef,{"":function(){return t.matrix==="Matrix"?r([]):[]},string:function(h){return r(h)},"number | BigNumber":function(h){return c(h,h,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(h,f){return c(h,h,f)},"number | BigNumber, number | BigNumber":function(h,f){return c(h,f,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(h,f,d){return c(h,f,d)},Array:function(h){return l(h)},"Array, string":function(h,f){return l(h,f)},Matrix:function(h){return l(h.valueOf(),h.storage())},"Matrix, string":function(h,f){return l(h.valueOf(),f)}});function l(p,h){switch(p.length){case 0:return h?r(h):[];case 1:return c(p[0],p[0],h);case 2:return c(p[0],p[1],h);default:throw new Error("Vector containing two values expected")}}function c(p,h,f){var d=Nt(p)||Nt(h)?n:null;if(Nt(p)&&(p=p.toNumber()),Nt(h)&&(h=h.toNumber()),!Dt(p)||p<1)throw new Error("Parameters in function identity must be positive integers");if(!Dt(h)||h<1)throw new Error("Parameters in function identity must be positive integers");var g=d?new n(1):1,y=d?new d(0):0,m=[p,h];if(f){if(f==="sparse")return a.diagonal(m,g,0,y);if(f==="dense")return i.diagonal(m,g,0,y);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var w=da([],m,y),v=p<h?p:h,E=0;E<v;E++)w[E][E]=g;return w}}),tf="kron",kg=["typed","matrix","multiplyScalar"],Ug=me(tf,kg,s=>{var{typed:e,matrix:t,multiplyScalar:r}=s;return e(tf,{"Matrix, Matrix":function(a,l){return t(n(a.toArray(),l.toArray()))},"Matrix, Array":function(a,l){return t(n(a.toArray(),l))},"Array, Matrix":function(a,l){return t(n(a,l.toArray()))},"Array, Array":n});function n(i,a){if(Tt(i).length===1&&(i=[i]),Tt(a).length===1&&(a=[a]),Tt(i).length>2||Tt(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(a.length)+")");var l=[],c=[];return i.map(function(p){return a.map(function(h){return c=[],l.push(c),p.map(function(f){return h.map(function(d){return c.push(r(f,d))})})})})&&l}});function Wg(){throw new Error('No "bignumber" implementation available')}function jg(){throw new Error('No "fraction" implementation available')}function Yg(){throw new Error('No "matrix" implementation available')}var rf="reshape",Vg=["typed","isInteger","matrix"],Zg=me(rf,Vg,s=>{var{typed:e,isInteger:t}=s;return e(rf,{"Matrix, Array":function(n,i){return n.reshape(i,!0)},"Array, Array":function(n,i){return i.forEach(function(a){if(!t(a))throw new TypeError("Invalid size for dimension: "+a)}),ma(n,i)}})}),nf="size",Kg=["typed","config","?matrix"],Gg=me(nf,Kg,s=>{var{typed:e,config:t,matrix:r}=s;return e(nf,{Matrix:function(i){return i.create(i.size())},Array:Tt,string:function(i){return t.matrix==="Array"?[i.length]:r([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return t.matrix==="Array"?[]:r?r([]):Yg()}})}),sf="transpose",Hg=["typed","matrix"],Jg=me(sf,Hg,s=>{var{typed:e,matrix:t}=s;return e(sf,{Array:a=>r(t(a)).valueOf(),Matrix:r,any:st});function r(a){var l=a.size(),c;switch(l.length){case 1:c=a.clone();break;case 2:{var p=l[0],h=l[1];if(h===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+ct(l)+")");switch(a.storage()){case"dense":c=n(a,p,h);break;case"sparse":c=i(a,p,h);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+ct(l)+")")}return c}function n(a,l,c){for(var p=a._data,h=[],f,d=0;d<c;d++){f=h[d]=[];for(var g=0;g<l;g++)f[g]=st(p[g][d])}return a.createDenseMatrix({data:h,size:[c,l],datatype:a._datatype})}function i(a,l,c){for(var p=a._values,h=a._index,f=a._ptr,d=p?[]:void 0,g=[],y=[],m=[],w=0;w<l;w++)m[w]=0;var v,E,b;for(v=0,E=h.length;v<E;v++)m[h[v]]++;for(var N=0,x=0;x<l;x++)y.push(N),N+=m[x],m[x]=y[x];for(y.push(N),b=0;b<c;b++)for(var F=f[b],M=f[b+1],S=F;S<M;S++){var I=m[h[S]]++;g[I]=b,p&&(d[I]=st(p[S]))}return a.createSparseMatrix({values:d,index:g,ptr:y,size:[c,l],datatype:a._datatype})}}),of="ctranspose",Xg=["typed","transpose","conj"],Qg=me(of,Xg,s=>{var{typed:e,transpose:t,conj:r}=s;return e(of,{any:function(i){return r(t(i))}})}),af="mode",ev=["typed","isNaN","isNumeric"],tv=me(af,ev,s=>{var{typed:e,isNaN:t,isNumeric:r}=s;return e(af,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(i){i=va(i.valueOf());var a=i.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},c=[],p=0,h=0;h<i.length;h++){var f=i[h];if(r(f)&&t(f))throw new Error("Cannot calculate mode of an array containing NaN values");f in l||(l[f]=0),l[f]++,l[f]===p?c.push(f):l[f]>p&&(p=l[f],c=[f])}return c}});function Sn(s,e,t){var r;return String(s).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+xn(t)+", value: "+JSON.stringify(t)+")":" (type: "+s.data.actual+")",new TypeError("Cannot calculate "+e+", unexpected type of argument"+r)):String(s).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+xn(t)+", value: "+JSON.stringify(t)+")":"",new TypeError("Cannot calculate "+e+", no ordering relation is defined for complex numbers"+r)):s}var uf="prod",rv=["typed","config","multiplyScalar","numeric"],nv=me(uf,rv,s=>{var{typed:e,config:t,multiplyScalar:r,numeric:n}=s;return e(uf,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(l,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return i(l)}});function i(a){var l;if(Hi(a,function(c){try{l=l===void 0?c:r(l,c)}catch(p){throw Sn(p,"prod",c)}}),typeof l=="string"&&(l=n(l,t.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),iv="numeric",sv=["number","?bignumber","?fraction"],ov=me(iv,sv,s=>{var{number:e,bignumber:t,fraction:r}=s,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:a=>e(a),BigNumber:t?a=>t(a):Wg,Fraction:r?a=>r(a):jg};return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",p=arguments.length>2?arguments[2]:void 0;if(p!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var h=xn(l);if(!(h in n))throw new TypeError("Cannot convert "+l+' of type "'+h+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in i))throw new TypeError("Cannot convert "+l+' to type "'+c+'"; valid output types are '+Object.keys(i).join(", "));return c===h?l:i[c](l)}}),lf="divideScalar",av=["typed","numeric"],uv=me(lf,av,s=>{var{typed:e,numeric:t}=s;return e(lf,{"number, number":function(n,i){return n/i},"Complex, Complex":function(n,i){return n.div(i)},"BigNumber, BigNumber":function(n,i){return n.div(i)},"Fraction, Fraction":function(n,i){return n.div(i)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),cf="pow",lv=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],cv=me(cf,lv,s=>{var{typed:e,config:t,identity:r,multiply:n,matrix:i,inv:a,number:l,fraction:c,Complex:p}=s;return e(cf,{"number, number":h,"Complex, Complex":function(y,m){return y.pow(m)},"BigNumber, BigNumber":function(y,m){return m.isInteger()||y>=0||t.predictable?y.pow(m):new p(y.toNumber(),0).pow(m.toNumber(),0)},"Fraction, Fraction":function(y,m){var w=y.pow(m);if(w!=null)return w;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return h(y.valueOf(),m.valueOf())},"Array, number":f,"Array, BigNumber":function(y,m){return f(y,m.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(y,m){return d(y,m.toNumber())},"Unit, number | BigNumber":function(y,m){return y.pow(m)}});function h(g,y){if(t.predictable&&!Dt(y)&&g<0)try{var m=c(y),w=l(m);if((y===w||Math.abs((y-w)/y)<1e-14)&&m.d%2===1)return(m.n%2===0?1:-1)*Math.pow(-g,y)}catch{}return t.predictable&&(g<-1&&y===1/0||g>-1&&g<0&&y===-1/0)?NaN:Dt(y)||g>=0||t.predictable?Ic(g,y):g*g<1&&y===1/0||g*g>1&&y===-1/0?0:new p(g,0).pow(y,0)}function f(g,y){if(!Dt(y))throw new TypeError("For A^b, b must be an integer (value is "+y+")");var m=Tt(g);if(m.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+m.length+" dimensions)");if(m[0]!==m[1])throw new Error("For A^b, A must be square (size is "+m[0]+"x"+m[1]+")");if(y<0)try{return f(a(g),-y)}catch(E){throw E.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+y+")"):E}for(var w=r(m[0]).valueOf(),v=g;y>=1;)(y&1)===1&&(w=n(v,w)),y>>=1,v=n(v,v);return w}function d(g,y){return i(f(g.valueOf(),y))}}),ff="dotDivide",fv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],hv=me(ff,fv,s=>{var{typed:e,matrix:t,equalScalar:r,divideScalar:n,DenseMatrix:i,concat:a}=s,l=ig({typed:e,equalScalar:r}),c=yi({typed:e}),p=Vs({typed:e,DenseMatrix:i}),h=Ma({typed:e,equalScalar:r}),f=vi({typed:e,DenseMatrix:i}),d=Hn({typed:e,matrix:t,concat:a});return e(ff,d({elop:n,SS:p,DS:c,SD:l,Ss:h,sS:f}))}),Zs="compare",pv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],dv=me(Zs,pv,s=>{var{typed:e,config:t,equalScalar:r,matrix:n,BigNumber:i,Fraction:a,DenseMatrix:l,concat:c}=s,p=yi({typed:e}),h=Vc({typed:e,equalScalar:r}),f=vi({typed:e,DenseMatrix:l}),d=Hn({typed:e,matrix:n,concat:c}),g=js({typed:e});return e(Zs,_v({typed:e,config:t}),{"boolean, boolean":function(m,w){return m===w?0:m>w?1:-1},"BigNumber, BigNumber":function(m,w){return Ws(m,w,t.epsilon)?new i(0):new i(m.cmp(w))},"Fraction, Fraction":function(m,w){return new a(m.compare(w))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,d({SS:h,DS:p,Ss:f}))}),_v=me(Zs,["typed","config"],s=>{var{typed:e,config:t}=s;return e(Zs,{"number, number":function(n,i){return Gn(n,i,t.epsilon)?0:n>i?1:-1}})}),Ks="equal",mv=["typed","matrix","equalScalar","DenseMatrix","concat"],gv=me(Ks,mv,s=>{var{typed:e,matrix:t,equalScalar:r,DenseMatrix:n,concat:i}=s,a=yi({typed:e}),l=Vs({typed:e,DenseMatrix:n}),c=vi({typed:e,DenseMatrix:n}),p=Hn({typed:e,matrix:t,concat:i});return e(Ks,vv({typed:e,equalScalar:r}),p({elop:r,SS:l,DS:a,Ss:c}))}),vv=me(Ks,["typed","equalScalar"],s=>{var{typed:e,equalScalar:t}=s;return e(Ks,{"any, any":function(n,i){return n===null?i===null:i===null?n===null:n===void 0?i===void 0:i===void 0?n===void 0:t(n,i)}})}),Gs="smaller",yv=["typed","config","matrix","DenseMatrix","concat"],wv=me(Gs,yv,s=>{var{typed:e,config:t,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:e}),l=Vs({typed:e,DenseMatrix:n}),c=vi({typed:e,DenseMatrix:n}),p=Hn({typed:e,matrix:r,concat:i}),h=js({typed:e});return e(Gs,Dv({typed:e,config:t}),{"boolean, boolean":(f,d)=>f<d,"BigNumber, BigNumber":function(d,g){return d.lt(g)&&!Ws(d,g,t.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===-1,"Complex, Complex":function(d,g){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:l,DS:a,Ss:c}))}),Dv=me(Gs,["typed","config"],s=>{var{typed:e,config:t}=s;return e(Gs,{"number, number":function(n,i){return n<i&&!Gn(n,i,t.epsilon)}})}),Hs="larger",bv=["typed","config","matrix","DenseMatrix","concat"],Ev=me(Hs,bv,s=>{var{typed:e,config:t,matrix:r,DenseMatrix:n,concat:i}=s,a=yi({typed:e}),l=Vs({typed:e,DenseMatrix:n}),c=vi({typed:e,DenseMatrix:n}),p=Hn({typed:e,matrix:r,concat:i}),h=js({typed:e});return e(Hs,xv({typed:e,config:t}),{"boolean, boolean":(f,d)=>f>d,"BigNumber, BigNumber":function(d,g){return d.gt(g)&&!Ws(d,g,t.epsilon)},"Fraction, Fraction":(f,d)=>f.compare(d)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,p({SS:l,DS:a,Ss:c}))}),xv=me(Hs,["typed","config"],s=>{var{typed:e,config:t}=s;return e(Hs,{"number, number":function(n,i){return n>i&&!Gn(n,i,t.epsilon)}})}),hf="deepEqual",Av=["typed","equal"],Cv=me(hf,Av,s=>{var{typed:e,equal:t}=s;return e(hf,{"any, any":function(i,a){return r(i.valueOf(),a.valueOf())}});function r(n,i){if(Array.isArray(n))if(Array.isArray(i)){var a=n.length;if(a!==i.length)return!1;for(var l=0;l<a;l++)if(!r(n[l],i[l]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:t(n,i)}}),pf="partitionSelect",Fv=["typed","isNumeric","isNaN","compare"],Mv=me(pf,Fv,s=>{var{typed:e,isNumeric:t,isNaN:r,compare:n}=s,i=n,a=(p,h)=>-n(p,h);return e(pf,{"Array | Matrix, number":function(h,f){return l(h,f,i)},"Array | Matrix, number, string":function(h,f,d){if(d==="asc")return l(h,f,i);if(d==="desc")return l(h,f,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(p,h,f){if(!Dt(h)||h<0)throw new Error("k must be a non-negative integer");if(vt(p)){var d=p.size();if(d.length>1)throw new Error("Only one dimensional matrices supported");return c(p.valueOf(),h,f)}if(Array.isArray(p))return c(p,h,f)}function c(p,h,f){if(h>=p.length)throw new Error("k out of bounds");for(var d=0;d<p.length;d++)if(t(p[d])&&r(p[d]))return p[d];for(var g=0,y=p.length-1;g<y;){for(var m=g,w=y,v=p[Math.floor(Math.random()*(y-g+1))+g];m<w;)if(f(p[m],v)>=0){var E=p[w];p[w]=p[m],p[m]=E,--w}else++m;f(p[m],v)>0&&--m,h<=m?y=m:g=m+1}return p[h]}}),df="max",Nv=["typed","config","numeric","larger"],Sv=me(df,Nv,s=>{var{typed:e,config:t,numeric:r,larger:n}=s;return e(df,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,p){return Fa(c,p.valueOf(),i)},"...":function(c){if(qs(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function i(l,c){try{return n(l,c)?l:c}catch(p){throw Sn(p,"max",c)}}function a(l){var c;if(Hi(l,function(p){try{isNaN(p)&&typeof p=="number"?c=NaN:(c===void 0||n(p,c))&&(c=p)}catch(h){throw Sn(h,"max",p)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,t.number)),c}}),_f="min",Bv=["typed","config","numeric","smaller"],Ov=me(_f,Bv,s=>{var{typed:e,config:t,numeric:r,smaller:n}=s;return e(_f,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,p){return Fa(c,p.valueOf(),i)},"...":function(c){if(qs(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function i(l,c){try{return n(l,c)?l:c}catch(p){throw Sn(p,"min",c)}}function a(l){var c;if(Hi(l,function(p){try{isNaN(p)&&typeof p=="number"?c=NaN:(c===void 0||n(p,c))&&(c=p)}catch(h){throw Sn(h,"min",p)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,t.number)),c}}),mf="add",Tv=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Iv=me(mf,Tv,s=>{var{typed:e,matrix:t,addScalar:r,equalScalar:n,DenseMatrix:i,SparseMatrix:a,concat:l}=s,c=Zc({typed:e}),p=Dg({typed:e,equalScalar:n}),h=Kc({typed:e,DenseMatrix:i}),f=Hn({typed:e,matrix:t,concat:l});return e(mf,{"any, any":r,"any, any, ...any":e.referToSelf(d=>(g,y,m)=>{for(var w=d(g,y),v=0;v<m.length;v++)w=d(w,m[v]);return w})},f({elop:r,DS:c,SS:p,Ss:h}))}),gf="dot",$v=["typed","addScalar","multiplyScalar","conj","size"],Lv=me(gf,$v,s=>{var{typed:e,addScalar:t,multiplyScalar:r,conj:n,size:i}=s;return e(gf,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":c});function a(h,f){var d=p(h),g=p(f),y,m;if(d.length===1)y=d[0];else if(d.length===2&&d[1]===1)y=d[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+d.join(", ")+")");if(g.length===1)m=g[0];else if(g.length===2&&g[1]===1)m=g[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+g.join(", ")+")");if(y!==m)throw new RangeError("Vectors must have equal length ("+y+" != "+m+")");if(y===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return y}function l(h,f){var d=a(h,f),g=vt(h)?h._data:h,y=vt(h)?h._datatype||h.getDataType():void 0,m=vt(f)?f._data:f,w=vt(f)?f._datatype||f.getDataType():void 0,v=p(h).length===2,E=p(f).length===2,b=t,N=r;if(y&&w&&y===w&&typeof y=="string"&&y!=="mixed"){var x=y;b=e.find(t,[x,x]),N=e.find(r,[x,x])}if(!v&&!E){for(var F=N(n(g[0]),m[0]),M=1;M<d;M++)F=b(F,N(n(g[M]),m[M]));return F}if(!v&&E){for(var S=N(n(g[0]),m[0][0]),I=1;I<d;I++)S=b(S,N(n(g[I]),m[I][0]));return S}if(v&&!E){for(var C=N(n(g[0][0]),m[0]),B=1;B<d;B++)C=b(C,N(n(g[B][0]),m[B]));return C}if(v&&E){for(var L=N(n(g[0][0]),m[0][0]),U=1;U<d;U++)L=b(L,N(n(g[U][0]),m[U][0]));return L}}function c(h,f){a(h,f);for(var d=h._index,g=h._values,y=f._index,m=f._values,w=0,v=t,E=r,b=0,N=0;b<d.length&&N<y.length;){var x=d[b],F=y[N];if(x<F){b++;continue}if(x>F){N++;continue}x===F&&(w=v(w,E(g[b],m[N])),b++,N++)}return w}function p(h){return vt(h)?h.size():i(h)}}),Rv="trace",Pv=["typed","matrix","add"],zv=me(Rv,Pv,s=>{var{typed:e,matrix:t,add:r}=s;return e("trace",{Array:function(l){return n(t(l))},SparseMatrix:i,DenseMatrix:n,any:st});function n(a){var l=a._size,c=a._data;switch(l.length){case 1:if(l[0]===1)return st(c[0]);throw new RangeError("Matrix must be square (size: "+ct(l)+")");case 2:{var p=l[0],h=l[1];if(p===h){for(var f=0,d=0;d<p;d++)f=r(f,c[d][d]);return f}else throw new RangeError("Matrix must be square (size: "+ct(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(l)+")")}}function i(a){var l=a._values,c=a._index,p=a._ptr,h=a._size,f=h[0],d=h[1];if(f===d){var g=0;if(l.length>0)for(var y=0;y<d;y++)for(var m=p[y],w=p[y+1],v=m;v<w;v++){var E=c[v];if(E===y){g=r(g,l[v]);break}if(E>y)break}return g}throw new RangeError("Matrix must be square (size: "+ct(h)+")")}}),vf="det",qv=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],kv=me(vf,qv,s=>{var{typed:e,matrix:t,subtractScalar:r,multiply:n,divideScalar:i,isZero:a,unaryMinus:l}=s;return e(vf,{any:function(h){return st(h)},"Array | Matrix":function(h){var f;switch(vt(h)?f=h.size():Array.isArray(h)?(h=t(h),f=h.size()):f=[],f.length){case 0:return st(h);case 1:if(f[0]===1)return st(h.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+ct(f)+")");case 2:{var d=f[0],g=f[1];if(d===g)return c(h.clone().valueOf(),d);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+ct(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(f)+")")}}});function c(p,h,f){if(h===1)return st(p[0][0]);if(h===2)return r(n(p[0][0],p[1][1]),n(p[1][0],p[0][1]));for(var d=!1,g=new Array(h).fill(0).map((M,S)=>S),y=0;y<h;y++){var m=g[y];if(a(p[m][y])){var w=void 0;for(w=y+1;w<h;w++)if(!a(p[g[w]][y])){m=g[w],g[w]=g[y],g[y]=m,d=!d;break}if(w===h)return p[m][y]}for(var v=p[m][y],E=y===0?1:p[g[y-1]][y-1],b=y+1;b<h;b++)for(var N=g[b],x=y+1;x<h;x++)p[N][x]=i(r(n(p[N][x],v),n(p[N][y],p[m][x])),E)}var F=p[g[h-1]][h-1];return d?l(F):F}}),yf="inv",Uv=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Wv=me(yf,Uv,s=>{var{typed:e,matrix:t,divideScalar:r,addScalar:n,multiply:i,unaryMinus:a,det:l,identity:c,abs:p}=s;return e(yf,{"Array | Matrix":function(d){var g=vt(d)?d.size():Tt(d);switch(g.length){case 1:if(g[0]===1)return vt(d)?t([r(1,d.valueOf()[0])]):[r(1,d[0])];throw new RangeError("Matrix must be square (size: "+ct(g)+")");case 2:{var y=g[0],m=g[1];if(y===m)return vt(d)?t(h(d.valueOf(),y,m),d.storage()):h(d,y,m);throw new RangeError("Matrix must be square (size: "+ct(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(g)+")")}},any:function(d){return r(1,d)}});function h(f,d,g){var y,m,w,v,E;if(d===1){if(v=f[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(d===2){var b=l(f);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(f[1][1],b),r(a(f[0][1]),b)],[r(a(f[1][0]),b),r(f[0][0],b)]]}else{var N=f.concat();for(y=0;y<d;y++)N[y]=N[y].concat();for(var x=c(d).valueOf(),F=0;F<g;F++){var M=p(N[F][F]),S=F;for(y=F+1;y<d;)p(N[y][F])>M&&(M=p(N[y][F]),S=y),y++;if(M===0)throw Error("Cannot calculate inverse, determinant is zero");y=S,y!==F&&(E=N[F],N[F]=N[y],N[y]=E,E=x[F],x[F]=x[y],x[y]=E);var I=N[F],C=x[F];for(y=0;y<d;y++){var B=N[y],L=x[y];if(y!==F){if(B[F]!==0){for(w=r(a(B[F]),I[F]),m=F;m<g;m++)B[m]=n(B[m],i(w,I[m]));for(m=0;m<g;m++)L[m]=n(L[m],i(w,C[m]))}}else{for(w=I[F],m=F;m<g;m++)B[m]=r(B[m],w);for(m=0;m<g;m++)L[m]=r(L[m],w)}}}return x}}}),wf="pinv",jv=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],Yv=me(wf,jv,s=>{var{typed:e,matrix:t,inv:r,deepEqual:n,equal:i,dotDivide:a,dot:l,ctranspose:c,divideScalar:p,multiply:h,add:f,Complex:d}=s;return e(wf,{"Array | Matrix":function(b){var N=vt(b)?b.size():Tt(b);switch(N.length){case 1:return v(b)?c(b):N[0]===1?r(b):a(c(b),l(b,b));case 2:{if(v(b))return c(b);var x=N[0],F=N[1];if(x===F)try{return r(b)}catch(M){if(!(M instanceof Error&&M.message.match(/Cannot calculate inverse, determinant is zero/)))throw M}return vt(b)?t(g(b.valueOf(),x,F),b.storage()):g(b,x,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+ct(N)+")")}},any:function(b){return i(b,0)?st(b):p(1,b)}});function g(E,b,N){var{C:x,F}=m(E,b,N),M=h(r(h(c(x),x)),c(x)),S=h(c(F),r(h(F,c(F))));return h(S,M)}function y(E,b,N){for(var x=st(E),F=0,M=0;M<b;M++){if(N<=F)return x;for(var S=M;w(x[S][F]);)if(S++,b===S&&(S=M,F++,N===F))return x;[x[S],x[M]]=[x[M],x[S]];for(var I=x[M][F],C=0;C<N;C++)x[M][C]=a(x[M][C],I);for(var B=0;B<b;B++)if(B!==M){I=x[B][F];for(var L=0;L<N;L++)x[B][L]=f(x[B][L],h(-1,h(I,x[M][L])))}F++}return x}function m(E,b,N){var x=y(E,b,N),F=E.map((S,I)=>S.filter((C,B)=>B<b&&!w(l(x[B],x[B])))),M=x.filter((S,I)=>!w(l(x[I],x[I])));return{C:F,F:M}}function w(E){return i(f(E,d(1,1)),f(0,d(1,1)))}function v(E){return n(f(E,d(1,1)),f(h(E,0),d(1,1)))}}),Vv="divide",Zv=["typed","matrix","multiply","equalScalar","divideScalar","inv"],Kv=me(Vv,Zv,s=>{var{typed:e,matrix:t,multiply:r,equalScalar:n,divideScalar:i,inv:a}=s,l=Ma({typed:e,equalScalar:n}),c=Na({typed:e});return e("divide",zl({"Array | Matrix, Array | Matrix":function(h,f){return r(h,a(f))},"DenseMatrix, any":function(h,f){return c(h,f,i,!1)},"SparseMatrix, any":function(h,f){return l(h,f,i,!1)},"Array, any":function(h,f){return c(t(h),f,i,!1).valueOf()},"any, Array | Matrix":function(h,f){return r(h,a(f))}},i.signatures))}),Df="sum",Gv=["typed","config","add","numeric"],Hv=me(Df,Gv,s=>{var{typed:e,config:t,add:r,numeric:n}=s;return e(Df,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":a,"...":function(c){if(qs(c))throw new TypeError("Scalar values expected in function sum");return i(c)}});function i(l){var c;return Hi(l,function(p){try{c=c===void 0?p:r(c,p)}catch(h){throw Sn(h,"sum",p)}}),c===void 0&&(c=n(0,t.number)),typeof c=="string"&&(c=n(c,t.number)),c}function a(l,c){try{var p=Fa(l,c,r);return p}catch(h){throw Sn(h,"sum")}}}),bf="median",Jv=["typed","add","divide","compare","partitionSelect"],Xv=me(bf,Jv,s=>{var{typed:e,add:t,divide:r,compare:n,partitionSelect:i}=s;function a(p){try{p=va(p.valueOf());var h=p.length;if(h===0)throw new Error("Cannot calculate median of an empty array");if(h%2===0){for(var f=h/2-1,d=i(p,f+1),g=p[f],y=0;y<f;++y)n(p[y],g)>0&&(g=p[y]);return c(g,d)}else{var m=i(p,(h-1)/2);return l(m)}}catch(w){throw Sn(w,"median")}}var l=e({"number | BigNumber | Complex | Unit":function(h){return h}}),c=e({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(h,f){return r(t(h,f),2)}});return e(bf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(h,f){throw new Error("median(A, dim) is not yet supported")},"...":function(h){if(qs(h))throw new TypeError("Scalar values expected in function median");return a(h)}})}),Js=Q_({config:dr}),Sa=nm({}),Ba=am({}),Oa=cm({}),rn=pm({Matrix:Oa}),Me=r_({BigNumber:Js,Complex:Sa,DenseMatrix:rn,Fraction:Ba}),Qv=Ym({typed:Me}),Xs=Zm({typed:Me}),e1=Lm({BigNumber:Js,typed:Me}),Ef=Ig({typed:Me}),Bn=Am({config:dr,typed:Me}),Qs=mm({typed:Me}),t1=wm({typed:Me}),eo=Cg({typed:Me}),xf=Tm({typed:Me}),Ta=Mm({Matrix:Oa,equalScalar:Bn,typed:Me}),Af=Gm({typed:Me}),Cf=bm({typed:Me}),Ia=Wm({typed:Me}),Ff=zm({Fraction:Ba,typed:Me}),Mf=vm({typed:Me}),It=km({DenseMatrix:rn,Matrix:Oa,SparseMatrix:Ta,typed:Me}),Nf=tv({isNaN:Cf,isNumeric:Mf,typed:Me}),Ji=ov({bignumber:e1,fraction:Ff,number:xf}),r1=nv({config:dr,multiplyScalar:eo,numeric:Ji,typed:Me}),n1=Zg({isInteger:Qs,matrix:It,typed:Me}),Sf=Gg({matrix:It,config:dr,typed:Me}),Bf=Jg({matrix:It,typed:Me}),Jn=Lg({isInteger:Qs,matrix:It,typed:Me}),i1=Pg({prod:r1,size:Sf,typed:Me}),s1=Qg({conj:Ef,transpose:Bf,typed:Me}),Xi=uv({numeric:Ji,typed:Me}),o1=hv({DenseMatrix:rn,concat:Jn,divideScalar:Xi,equalScalar:Bn,matrix:It,typed:Me}),Of=gv({DenseMatrix:rn,concat:Jn,equalScalar:Bn,matrix:It,typed:Me}),Tf=qg({BigNumber:Js,DenseMatrix:rn,SparseMatrix:Ta,config:dr,matrix:It,typed:Me}),a1=Ug({matrix:It,multiplyScalar:eo,typed:Me}),u1=wv({DenseMatrix:rn,concat:Jn,config:dr,matrix:It,typed:Me}),l1=Sg({DenseMatrix:rn,concat:Jn,equalScalar:Bn,matrix:It,subtractScalar:Af,typed:Me,unaryMinus:Ia}),Qi=Iv({DenseMatrix:rn,SparseMatrix:Ta,addScalar:Xs,concat:Jn,equalScalar:Bn,matrix:It,typed:Me}),If=dv({BigNumber:Js,DenseMatrix:rn,Fraction:Ba,concat:Jn,config:dr,equalScalar:Bn,matrix:It,typed:Me}),c1=Cv({equal:Of,typed:Me}),$f=Lv({addScalar:Xs,conj:Ef,multiplyScalar:eo,size:Sf,typed:Me}),f1=Ev({DenseMatrix:rn,concat:Jn,config:dr,matrix:It,typed:Me}),$a=Ov({config:dr,numeric:Ji,smaller:u1,typed:Me}),wi=Mg({addScalar:Xs,dot:$f,equalScalar:Bn,matrix:It,multiplyScalar:eo,typed:Me}),h1=Mv({compare:If,isNaN:Cf,isNumeric:Mf,typed:Me}),p1=Hv({add:Qi,config:dr,numeric:Ji,typed:Me}),d1=zv({add:Qi,matrix:It,typed:Me}),Lf=kv({divideScalar:Xi,isZero:t1,matrix:It,multiply:wi,subtractScalar:Af,typed:Me,unaryMinus:Ia}),_1=Sv({config:dr,larger:f1,numeric:Ji,typed:Me}),to=Wv({abs:Qv,addScalar:Xs,det:Lf,divideScalar:Xi,identity:Tf,matrix:It,multiply:wi,typed:Me,unaryMinus:Ia}),m1=Yv({Complex:Sa,add:Qi,ctranspose:s1,deepEqual:c1,divideScalar:Xi,dot:$f,dotDivide:o1,equal:Of,inv:to,matrix:It,multiply:wi,typed:Me}),g1=cv({Complex:Sa,config:dr,fraction:Ff,identity:Tf,inv:to,matrix:It,multiply:wi,number:xf,typed:Me}),v1=Kv({divideScalar:Xi,equalScalar:Bn,inv:to,matrix:It,multiply:wi,typed:Me}),Rf=Xv({add:Qi,compare:If,divide:v1,partitionSelect:h1,typed:Me});class y1{constructor(e,t,r){R(this,"_cacheData");R(this,"_variables");R(this,"_math");R(this,"_timeframe");this._cacheData={},this._variables=e,this._math=t,this._timeframe=r}alma({series:e,length:t,offset:r,sigma:n,floor:i},a){if(t===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(e,t,`alma_${a}`);if(l===void 0)return;let c=r*(t-1);i&&(c=Math.floor(c));const p=t/n;let h=0,f=0;for(let d=0;d<=t-1;d++){const g=Math.exp(-1*Math.pow(d-c,2)/(2*Math.pow(p,2)));h+=g,f+=l[l.length-1-(t-d-1)]*g}return f/h}sma({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;let n=0;const i=this._cacheDataList(e,t,`sma_${r}`);if(i===void 0)return;const a=i.slice(-t);return n=p1(...a)/t,n}rma({source:e,length:t},r){if(e===void 0||t===void 0||isNaN(e))return;this._cacheDataList(e,t,`sma_${r}`);const{sum:n}=this._cacheData[`rma_${r}`]||{},i=1/t,a=n===void 0?this.sma({source:e,length:t},r):i*e+(1-i)*(n||0);return this._cacheDataHandle(`rma_${r}`,{sum:a}),a}atr({length:e},t){const{high:r,close:n}=this._cacheData[`atr_${t}`]||{},{high:i,close:a,low:l}=this._variables,c=r===void 0?i-l:Math.max(Math.max(i-l,Math.abs(i-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${t}`,{high:i,close:a}),this.rma({source:c,length:e},t)}barssince({condition:e},t){let{count:r}=this._cacheData[`barssince_${t}`]||{};if(e)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${t}`,{count:r}),r}stdev({source:e,length:t,biased:r=!0},n){if(e===void 0||isNaN(e)||t===void 0)return;const i=this._cacheDataList(e,t,`stdev_${n}`),a=this.sma({source:e,length:t},n);if(i===void 0)return;let l=0;for(let c=0;c<t;c++){const p=this._sum(i[i.length-1-c],-(a||0));l+=p*p}return r||t<=1?Math.sqrt(l/t):Math.sqrt(l/(t-1))}_sum(e,t){let n=e+t;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:e,length:t,mult:r},n){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return[];const i=this.sma({source:e,length:t},n),a=this.stdev({source:e,length:t},n);if(i===void 0||a===void 0)return[];const l=r*a;return[i,i+l,i-l]}bbw({series:e,length:t,mult:r},n){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return;const i=this.sma({source:e,length:t},n),a=this.stdev({source:e,length:t},n);if(i===void 0||a===void 0)return;const l=r*a;return(i+l-(i-l))/i}cci({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this.sma({source:e,length:t},r),i=this.dev({source:e,length:t},r);if(!(n===void 0||i===void 0))return(e-n)/(.015*i)}change({source:e,length:t=1},r){const n=this._cacheData[`change_${r}`]||[];n[this._variables.bar_index]=e,this._cacheData[`change_${r}`]=n;const i=n[n.length-1-t];if(!(e===void 0||isNaN(e)))return i===void 0?i:typeof e=="boolean"?i!==e:e-i}cmo({series:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this.change({source:e},r);if(n===void 0)return;const i=this._math.sum({source:n>=0?n:0,length:t},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:t},`sm2_${r}`);if(!(i===void 0||a===void 0))return 100*(i-a)/(i+a)}cog({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this._cacheDataList(e,t,`cog_${r}`),i=this._math.sum({source:e,length:t},r);if(i===void 0||n===void 0)return;let a=0;for(let l=0;l<t;l++){const c=n[n.length-1-l];a+=c*(l+1)}return-a/i}correlation({source1:e,source2:t,length:r},n){if(e===void 0||isNaN(e)||t===void 0||isNaN(t)||r===void 0)return;const i=this._cacheDataList([e,t],r,`correlation_${n}`),a=this.sma({source:e,length:r},`sma1_${n}`),l=this.sma({source:t,length:r},`sma2_${n}`);if(a===void 0||l===void 0||i===void 0)return;let c=0,p=0,h=0;for(let d=0;d<r;d++){const[g,y]=i[i.length-1-d],m=g-a,w=y-l;c+=m*w,p+=m*m,h+=w*w}return isNaN(p)||isNaN(c)||isNaN(h)?void 0:c/Math.sqrt(p*h)}cross({source1:e,source2:t},r){if(e===void 0||t===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:e,source2:t}),n===void 0||i===void 0?!1:n>=i&&e<t||n<=i&&e>t}crossover({source1:e,source2:t},r){if(e===void 0||t===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:e,source2:t}),n===void 0||i===void 0?!1:n<=i&&e>t}crossunder({source1:e,source2:t},r){if(e===void 0||t===void 0)return!1;const{source1:n,source2:i}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:e,source2:t}),n===void 0||i===void 0?!1:n>=i&&e<t}cum({source:e=0},t){e=isNaN(e)?0:e;let{sum:r}=this._cacheData[`cum_${t}`]||{};return r=r||0,r+=e,this._cacheDataHandle(`cum_${t}`,{sum:r}),r}dev({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return;const n=this.sma({source:e,length:t},r);let i=0;const a=this._cacheDataList(e,t,`dev_${r}`);if(!(!a||n===void 0)){for(let l=0;l<t;l++){const c=a[a.length-1-l];i+=Math.abs(c-n)}return i/t}}dmi({diLength:e,adxSmoothing:t},r){if(e===void 0||t===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:i,high:a,close:l,PDMS:c,NDMS:p,TRS:h,ADX:f,count:d=0}=this._cacheData[n]||{},{low:g,high:y,close:m}=this._variables;if(i===void 0||a===void 0||l===void 0)return this._cacheData[n]={low:g,high:y,close:m,PDMS:c,NDMS:p,TRS:y-g,count:1},[void 0,void 0,void 0];let w=y-a,v=i-g;w=w>v&&w>0?w:0,v=v>w&&v>0?v:0,w===v&&(w=v=0);const E=Math.max(y-g,Math.abs(y-l),Math.abs(g-l));if(d<e)return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:(c||0)+w,NDMS:(p||0)+v,TRS:(h||0)+E,count:d+1}),[void 0,void 0,void 0];{const b=c-c/e+w,N=p-p/e+v,x=h-h/e+E,F=b/x*100,M=N/x*100,S=Math.abs((F-M)/(F+M))*100;let I=S,C=[F,M,void 0];if(d+1-e<t){const B=d+1-e;I=((f||0)*(B-1)+S)/B}else I=(f*(t-1)+S)/t,C=[F,M,I];return this._cacheDataHandle(n,{low:g,high:y,close:m,PDMS:b,NDMS:N,TRS:x,ADX:I,count:d+1}),C}}ema({source:e,length:t},r){if(e===void 0||t===void 0||isNaN(e))return;let{sum:n,count:i=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:e,length:t},r);if(i>t){const l=2/(t+1);n=n===void 0?e:l*e+(1-l)*(n||0)}else n=a;return i+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:i}),n}falling({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return!1;const{source:n,fallings:i=[]}=this._cacheData[`falling_${r}`]||{};i.push(n>e);const a=i.slice(-t);return this._cacheDataHandle(`falling_${r}`,{source:e,fallings:a}),a.length<t?!1:a.every(l=>l)}rising({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0)return!1;const{source:n,risings:i=[]}=this._cacheData[`rising_${r}`]||{};i.push(n<e);const a=i.slice(-t);return this._cacheDataHandle(`rising_${r}`,{source:e,risings:a}),a.length<t?!1:a.every(l=>l)}highest({source:e,length:t},r){if(t===void 0||t<=0)return;const{high:n}=this._variables,i=this._cacheDataList(typeof e!="number"?n:e,t,`highest_${r}`);if(i)return Math.max(...i.slice(-t))}highestbars({source:e,length:t},r){if(t===void 0||t<=0)return;const{high:n}=this._variables,i=this._cacheDataList(typeof e!="number"?n:e,t,`highestbars_${r}`);return i?i.slice(-t).reduce((l,c,p,h)=>c>=h[l]?p:l,0)-t+1:void 0}wma({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this._cacheDataList(e,t,`wma_${r}`);if(!n)return;let i=0,a=0;for(let l=0;l<t;l++){const c=(t-l)*t;i+=c,a+=n[n.length-1-l]*c}return a/i}hma({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this.wma({source:e,length:t},r),i=this.wma({source:e,length:Math.round(t/2)},r);return n===void 0||i===void 0?void 0:this.wma({source:2*i-n,length:Math.floor(Math.sqrt(t))},`hma_${r}`)}kc({series:e,length:t,mult:r,useTrueRange:n=!0},i){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:e,length:t},i),{ta:l,high:c,low:p}=this._variables,h=n?l.tr:c-p,f=this.ema({source:h,length:t},`range_${i}`);return[a,a+f*r,a-f*r]}kcw({series:e,length:t,mult:r,useTrueRange:n=!0},i){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return;const a=this.ema({source:e,length:t},i),{ta:l,high:c,low:p}=this._variables,h=n?l.tr:c-p,f=this.ema({source:h,length:t},`range_${i}`);return(a+f*r-(a-f*r))/a}linreg({source:e,length:t,offset:r},n){if(t===void 0||r===void 0)return;const i=this._cacheDataList(e,t,`dev_${n}`);if(!i)return;const a=i.slice(-t).filter(g=>g!==void 0);let l=0,c=0,p=0,h=0;for(const[g,y]of a.entries())l+=g,c+=y,p+=g*y,h+=g*g;const f=(t*p-l*c)/(t*h-l*l);return(c-f*l)/t+f*(t-1-r)}lowest({source:e,length:t},r){if(t===void 0||t<=0)return;const{low:n}=this._variables,i=this._cacheDataList(typeof e!="number"?n:e,t,`lowest_${r}`);if(i)return Math.min(...i.slice(-t))}lowestbars({source:e,length:t},r){if(t===void 0||t<=0)return;const{low:n}=this._variables,i=this._cacheDataList(typeof e!="number"?n:e,t,`lowestbars_${r}`);return i?i.slice(-t).reduce((l,c,p,h)=>c<=h[l]?p:l,0)-t+1:void 0}macd({source:e,fastlen:t,slowlen:r,siglen:n},i){if(e===void 0||isNaN(e)||t===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:e,length:t},`ema1_${i}`),l=this.ema({source:e,length:r},`ema2_${i}`);if(a===void 0||l===void 0)return[void 0,void 0,void 0];const c=a-l,p=this.ema({source:c,length:n},`macd_${i}`);if(p===void 0)return[c,p,void 0];const h=c-p;return[c,p,h]}max({source:e},t){if(e===void 0||isNaN(e))return;let r=this._cacheData[`max_${t}`]||0;return e>r&&(r=e),this._cacheData[`max_${t}`]=r,r}min({source:e},t){if(e===void 0||isNaN(e))return;let r=this._cacheData[`min_${t}`]||1/0;return e<r&&(r=e),this._cacheData[`min_${t}`]=r,r}median({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this._cacheDataList(e,t,`dev_${r}`);if(n)return Rf(n.slice(-t))}mfi({series:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const{volume:n}=this._variables,i=this.change({source:e},r),a=this._math.sum({source:n*(i>=0?0:e),length:t},`lower_${r}`),l=this._math.sum({source:n*(i<=0?0:e),length:t},`upper_${r}`);if(!(l===void 0||a===void 0))return 100-100/(1+l/a)}mode({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<=0)return;const n=this._cacheDataList(e,t,`mode_${r}`);if(n)return $a(Nf(n.slice(-t)))}mom({source:e,length:t},r){if(t===void 0||t<0)return;const n=`mom_${r}`,i=this._cacheData[n]||[];if(i[this._variables.bar_index]=e,this._cacheData[n]=i,i.length<=t||e===void 0||isNaN(e))return;let a=i.length-t-1,l;for(;l===void 0&&a>=0;)l=i[a],a--;return l===void 0?l:e-l}percentile_linear_interpolation({source:e,length:t,percentage:r},n){if(t===void 0||r===void 0||t<0||r<0||r>100)return;const i=this._cacheDataList(e,t+1,`percentile_linear_interpolation_${n}`);if(!i)return;const a=this._sort(i.slice(-(t+1))),l=a.length;r/=100;const c=1/(l*2);if(r<=c)return a[0];if(r>=1-1/(l*2))return a[l-1];for(const[p,h]of a.entries()){const f=a[p-1];if(r<(p+.5)/l)return f===void 0||h===void 0?void 0:f+(h-f)*(r-(p-.5)/l)/(1/l)}}percentile_nearest_rank({source:e,length:t,percentage:r},n){if(t===void 0||r===void 0||e===void 0||isNaN(e)||t<0||r<0||r>100)return;const i=this._cacheDataList(e,t,`percentile_nearest_rank_${n}`);if(!i)return;const a=this._sort(i.slice(-t)),l=r/100*a.length,c=Math.ceil(l)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:e,length:t},r){if(t===void 0||t<0)return;const n=this._cacheDataList(e,t+1,`percentile_nearest_rank_${r}`);if(!n)return;const i=n.slice(-(t+1)),a=e;if(a===void 0)return;let l=0;for(let c=0;c<i.length;c++)i[c]!==void 0&&(i[c]<a||i[c]===a&&c<t)&&l++;return l/(i.length-1)*100}pivot_point_levels({type:e,anchor:t,developing:r},n){const i=new Qe;let{close:a,open:l,low:c,high:p}=this._variables;const h=`pivot_point_levels_${n}`,{close:f,low:d,high:g,open:y,result:m}=this._cacheData[h]||{};if(!t&&(g&&d&&(p=Math.max(g,p),c=Math.min(d,c)),this._cacheDataHandle(h,{close:a,open:l,low:c,high:p,result:m}),!r))return i._value=m||[],i;const w={close:a,open:l,low:c,high:p};t===!0&&!r&&(a=f,l=y,c=d,p=g);const v=this._getPivotPointLevels(p,c,a,l,r,e);return this._cacheDataHandle(h,{...w,result:v}),i._value=v,i}_getPivotPointLevels(e,t,r,n,i,a){if(r===void 0||n===void 0||t===void 0||e===void 0)return[];switch(a){case Kn.traditional:return this._traditional(e,t,r);case Kn.fibonacci:return this._fibonacci(e,t,r);case Kn.woodie:return i?[]:this._woodie(e,t);case Kn.classic:return this._classic(e,t,r);case Kn.dm:return this._DM(e,t,r,n);case Kn.camarilla:return this._camarilla(e,t,r);default:return[]}}_traditional(e,t,r){const n=(e+t+r)/3,i=n*2-t,a=n+(e-t),l=n*2+(e-2*t),c=n*3+(e-3*t),p=n*4+(e-4*t),h=n*2-e,f=n-(e-t),d=n*2-(2*e-t),g=n*3-(3*e-t),y=n*4-(4*e-t);return[n,i,h,a,f,l,d,c,g,p,y]}_fibonacci(e,t,r){const n=(e+t+r)/3,i=n+.382*(e-t),a=n-.382*(e-t),l=n+.618*(e-t),c=n-.618*(e-t),p=n+(e-t),h=n-(e-t);return[n,i,a,l,c,p,h]}_woodie(e,t){const{open:r}=this._variables,n=(e+t+2*r)/4,i=2*n-t,a=2*n-e,l=n+(e-t),c=n-(e-t),p=e+2*(n-t),h=t-2*(e-n),f=p+(e-t),d=h-(e-t);return[n,i,a,l,c,p,h,f,d]}_classic(e,t,r){const n=(e+t+r)/3,i=2*n-t,a=2*n-e,l=n+(e-t),c=n-(e-t),p=n+2*(e-t),h=n-2*(e-t),f=n+3*(e-t),d=n-3*(e-t);return[n,i,a,l,c,p,h,f,d]}_DM(e,t,r,n){let i;n===r?i=e+t+2*r:r>n?i=2*e+t+r:i=2*t+e+r;const a=i/4,l=i/2-t,c=i/2-e;return[a,l,c]}_camarilla(e,t,r){const n=(e+t+r)/3,i=r+1.1*(e-t)/12,a=r-1.1*(e-t)/12,l=r+1.1*(e-t)/6,c=r-1.1*(e-t)/6,p=r+1.1*(e-t)/4,h=r-1.1*(e-t)/4,f=r+1.1*(e-t)/2,d=r-1.1*(e-t)/2,g=e/t*r,y=r-(g-r);return[n,i,a,l,c,p,h,f,d,g,y]}pivothigh({source:e=this._variables.high,leftbars:t,rightbars:r},n){if(t===void 0||r===void 0||t<0||r<0)return;const i=this._cacheDataList(e,t+r+1,`pivothigh_${n}`);if(!i)return;const a=i.slice(-(t+r+1)),l=a[t];return Math.max(...a)===l?l:void 0}pivotlow({source:e=this._variables.low,leftbars:t,rightbars:r},n){if(t===void 0||r===void 0||t<0||r<0)return;const i=this._cacheDataList(e,t+r+1,`pivotlow_${n}`);if(!i)return;const a=i.slice(-(t+r+1)),l=a[t];return Math.min(...a)===l?l:void 0}range({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<0)return;const n=this._cacheDataList(e,t,`range_${r}`);if(!n)return;const i=n.filter(c=>c!==void 0).slice(-t),a=Math.max(...i),l=Math.min(...i);return a-l}roc({source:e,length:t},r){if(t===void 0||t<0)return;const n=this._cacheDataList(e,t+1,`roc_${r}`),i=this.change({source:e,length:t},r);if(n)return 100*i/n[n.length-1-t]}rsi({source:e,length:t},r){if(t===void 0||e===void 0||isNaN(e)||t<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},i=Math.max(e-n,0),a=Math.max(n-e,0),l=this.rma({source:i,length:t},`rma1_${r}`),c=this.rma({source:a,length:t},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:e}),!(l===void 0||c===void 0))return 100-100/(1+l/c)}sar({start:e,inc:t,max:r},n){if(e===void 0||t===void 0||r===void 0)return;const{close:i,low:a,high:l,preLow:c,preHigh:p,data:h={}}=this._cacheData[`sar_${n}`]||{};let{result:f,maxMin:d,acceleration:g,isBelow:y}=h,m=!1;const{close:w,low:v,high:E,bar_index:b}=this._variables;return b===1&&(w>i?(y=!0,d=E,f=a):(y=!1,d=v,f=l),m=!0,g=e),f=f+g*(d-f),y?f>v&&(m=!0,y=!1,f=Math.max(E,d||0),d=v,g=e):f<E&&(m=!0,y=!0,f=Math.min(v,d||0),d=E,g=e),m||(y?E>(d||0)&&(d=E,g=Math.min((g||0)+t,r)):v<(d||0)&&(d=v,g=Math.min((g||0)+t,r))),y?(f=Math.min(f,a),b>1&&(f=Math.min(f,c))):(f=Math.max(f,l),b>1&&(f=Math.max(f,p))),this._cacheDataHandle(`sar_${n}`,{high:E,close:w,low:v,preLow:a,preHigh:l,data:Object.assign(h,{result:f,maxMin:d,acceleration:g,isBelow:y})}),f}stoch({source:e,high:t,low:r,length:n},i){if(n===void 0||t===void 0||r===void 0||e===void 0||isNaN(e)||n<0)return;const a=this.lowest({source:r,length:n},i),l=this.highest({source:t,length:n},i);if(!(a===void 0||l===void 0))return 100*(this._variables.close-a)/(l-a)}supertrend({factor:e,atrPeriod:t},r){if(e===void 0||t===void 0)return[void 0,void 0];const{hl2:n,close:i}=this._variables,a=`supertrend_${r}`,{upperBand:l,lowerBand:c,superTrend:p,atr:h,close:f}=this._cacheData[a]||{},d=this.atr({length:t},r);if(d===void 0)return this._cacheDataHandle(a,{close:i}),[void 0,void 0];let g=n+e*d,y=n-e*d;const m=l||0,w=c||0;y=y>w||f<w?y:w,g=g<m||f>m?g:m;let v;h===void 0?v=1:p===m?v=i>g?-1:1:v=i<y?1:-1;const E=v===-1?y:g;return this._cacheDataHandle(a,{upperBand:g,lowerBand:y,superTrend:E,atr:d,close:i}),[E,v]}swma({source:e},t){let{list:r}=this._cacheData[`swma_${t}`]||{};if(r||(r=[]),r.push(e),r=r.slice(-4),this._cacheDataHandle(`swma_${t}`,{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:e=!1},t){const{close:r,low:n,high:i}=this._variables,{close:a}=this._cacheData[`tr_${t}`]||{};return this._cacheDataHandle(`tr_${t}`,{close:r}),a===void 0?e?i-n:void 0:Math.max(i-n,Math.abs(i-a),Math.abs(n-a))}tsi({source:e,short_length:t,long_length:r},n){if(e===void 0||isNaN(e)||t===void 0||r===void 0)return;const i=this.change({source:e},n);if(i===void 0)return;const a=this.ema({source:Math.abs(i),length:t},`absema1_${n}`),l=this.ema({source:i,length:t},`ema1_${n}`);if(l===void 0)return;const c=this.ema({source:l,length:r},`ema2_${n}`),p=this.ema({source:a,length:t},`absema2_${n}`);if(c!==void 0)return c/p}valuewhen({condition:e,source:t,occurrence:r},n){if(t===void 0||r===void 0||r<0)return;let{list:i}=this._cacheData[`valuewhen_${n}`]||{};return i||(i=[]),e&&i.push(t),this._cacheDataHandle(`valuewhen_${n}`,{list:i}),i[i.length-1-r]}variance({source:e,length:t,biased:r=!0},n){if(e===void 0||isNaN(e)||t===void 0||t<0)return;const i=this.sma({source:e,length:t},n),a=this._cacheDataList(e,t,`mode_${n}`);if(!a||i===void 0)return;const l=a.filter(p=>p!==void 0&&!isNaN(p)).slice(-t);if(l.length<t)return;const c=l.reduce((p,h)=>p+Math.pow(h-i,2),0);if(c!==void 0)return r||t<=1?c/t:c/(t-1)}vwap({source:e,anchor:t,stdev_mult:r},n){if(e===void 0)return;t=t===void 0?this._timeframe.change({timeframe:"1D"},n):t;const{volume:i}=this._variables;let{sum:a=0,sumV:l=0,count:c=0,isReset:p,sumS:h=0}=this._cacheData[`vwap_${n}`]||{};if(t&&(a=l=c=h=0,p=!0),!p)return r!==void 0?[]:void 0;const f=e*i+a,d=i+l,g=f/d;return c++,r!==void 0?(h=i*Math.pow(e,2)+h,this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:p,sumS:h}),this._computeBands(h,d,r,g)):(this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:d,count:c,isReset:p}),g)}_computeBands(e,t,r,n){let i=e/t-Math.pow(n,2);i=i<0?0:i;const a=Math.sqrt(i),l=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,l,c]}vwma({source:e,length:t},r){if(e===void 0||isNaN(e)||t===void 0||t<=0)return;const{volume:n}=this._variables,i=this.sma({source:e*n,length:t},`sma1_${r}`),a=this.sma({source:n,length:t},`sma2_${r}`);if(!(i===void 0||a===void 0))return i/a}wpr({length:e},t){if(e===void 0||e<=0)return;const r=this.highest({length:e},t),n=this.lowest({length:e},t),{close:i}=this._variables;if(!(r===void 0||n===void 0))return(r-i)/(r-n)*-100}_sort(e){const t=e.length;for(let r=0;r<t;r++){let n={};for(let i=0;i<t-r;i++){const{currentVal:a,currentIndex:l}=n,c=e[i];if(c!==void 0){if(a!==void 0&&c<a){e.splice(i,1),e.splice(l,0,c),n={currentIndex:l+1,currentVal:a};continue}n={currentIndex:i,currentVal:c}}}}return e}_cacheDataList(e,t,r){const n=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:i}=this._variables;if(n.barIndex<=i&&(n.barIndex===i?n.list[n.list.length-1]=e:n.list.push(e),n.barIndex=i,this._cacheData[r]=n),!(n.list.length<t))return n.list}_cacheDataHandle(e,t){const{barIndex:r}=this._cacheData[e]||{};r!==this._variables.bar_index&&(this._cacheData[e]=Object.assign(t,{barIndex:this._variables.bar_index}))}}class w1{constructor(e,t,r){R(this,"_cacheData");R(this,"_variables");R(this,"_errorListener");R(this,"_historyInputs");R(this,"_name");this._cacheData={},this._variables=e,this._errorListener=t,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(e){if(!(e!=null&&e.length)){self.workerStorage.delete(this._name),this._cacheData={};return}for(const t of e){const r=t.id,n=this._historyInputs[r];(!(t!=null&&t.sourceTypeName)&&(n==null?void 0:n.defval)!==t.defval||n!=null&&n.sourceTypeName&&t.sourceTypeName!==(n==null?void 0:n.sourceTypeName))&&(this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...t,isModify:!0}))}}input(e,t){return this._cacheHandle(e,t)}int(e,t){return this._cacheHandle(e,t,rr.INT)}bool(e,t){return this._cacheHandle(e,t,rr.BOOL)}color(e,t){return this._cacheHandle(e,t,rr.COLOR)}time(e,t){return this._cacheHandle(e,t,rr.TIME)}float(e,t){return this._cacheHandle(e,t,rr.FLOAT)}price(e,t){return this._cacheHandle(e,t,rr.PRICE)}source(e,t){return this._cacheHandle(e,t,rr.SOURCE)}string(e,t){return this._cacheHandle(e,t,rr.STRING)}symbol(e,t){return this._cacheHandle(e,t,rr.SYMBOL)}session(e,t){return this._cacheHandle(e,t,rr.SESSION)}text_area(e,t){return this._cacheHandle(e,t,rr.TEXT_AREA)}timeframe(e,t){return this._cacheHandle(e,t,rr.TIMEFRAME)}enum(e,t){return this._cacheHandle(e,t,rr.ENUM)}_cacheHandle(e,t,r){if(t.startsWith("export"))return e.defval;const n=`${r||"input"}_${t}`,i=this._cacheData[n];if(e.defval===void 0&&this._errorListener.addError(ut.inputDefvalErr,t,ze.Error),self.workerStorage.setValue(this._name,n,{...e}),i)if(!i.isModify)Object.assign(this._cacheData[n],e);else{const a=this._historyInputs[n];!(e.sourceTypeName||a!=null&&a.sourceTypeName)&&e.defval===(a==null?void 0:a.defval)||e.sourceTypeName&&(a==null?void 0:a.sourceTypeName)===e.sourceTypeName?i.sourceTypeName&&(this._cacheData[n].defval=this._variables[i.sourceTypeName]):Object.assign(this._cacheData[n],e)}else{const{defval:a,display:l}=e;this._displayVerify(t,l),e={inputType:r,...e},this._cacheData[n]=e,(r||e.inputType)===rr.SOURCE?this._cacheData[n].options=Vp:e.options&&!e.options.includes(a)&&this._errorListener.addError(jt(ut.inputOptErr,{defval:String(a),args:e.options.toString()}),t,ze.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_displayVerify(e,t){!t||!t.length||t.includes(Yt.dataWindow)||t.includes(Yt.statusLine)||this._errorListener.addError(jt(ut.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),e,ze.Error)}getInputs(){const e=Object.keys(this._cacheData),t=[];for(const r of e){const n=this._cacheData[r];n.id=r,t.push(n)}return t.sort((r,n)=>(r.index||0)-(n.index||0))}}class D1{color({x:e}){return e}new({color:e,transp:t=100}){_e(t)&&(t=100);const r=(100-t)/100,{r:n,g:i,b:a}=this._parseColor(e||"");return`rgba(${Math.round(n)}, ${Math.round(i)}, ${Math.round(a)}, ${r})`}rgb({red:e=0,green:t=0,blue:r=0,transp:n=0}){return _e(n)&&(n=0),_e(e)&&(e=0),_e(t)&&(t=0),_e(r)&&(r=0),`rgba(${e}, ${t}, ${r}, ${(100-n)/100})`}g({color:e}){return e?this._parseColor(e).g:0}r({color:e}){return e?this._parseColor(e).r:0}b({color:e}){return e?this._parseColor(e).b:0}t({color:e}){return e?Math.round(this._parseColor(e).a*100):0}from_gradient({value:e,bottom_value:t,top_value:r,bottom_color:n,top_color:i}){if(_e(e)||_e(t)||_e(r)||r===t)return"rgba(0,0,0,1)";const a=(e-t)/(r-t),l=Math.min(Math.max(a,0),1),{r:c,g:p,b:h,a:f}=this._parseColor(n||"rgba(0,0,0,0)"),{r:d,g,b:y,a:m}=this._parseColor(i||"rgba(0,0,0,0)"),w=c+l*(d-c),v=p+l*(g-p),E=h+l*(y-h),b=f+l*(m-f);return`rgba(${Math.round(w)}, ${Math.round(v)}, ${Math.round(E)}, ${b.toFixed(2)})`}_parseColor(e){let t,r,n,i;if(e.startsWith("#")){t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);const a=e.substring(7);a?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(e);t=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:t,g:r,b:n,a:i}}_parserRgbColor(e){var t;return((t=e.match(/\d+/g))==null?void 0:t.map(Number))||[]}}var qe={};const b1=Object.prototype.toString;function es(s){const e=b1.call(s);return e.endsWith("Array]")&&!e.includes("Big")}var E1=Object.freeze({__proto__:null,isAnyArray:es}),x1=Mt(E1);function A1(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!es(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,r=t===void 0?0:t,n=e.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],l=r+1;l<i;l++)s[l]>a&&(a=s[l]);return a}function C1(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!es(s))throw new TypeError("input must be an array");if(s.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,r=t===void 0?0:t,n=e.toIndex,i=n===void 0?s.length:n;if(r<0||r>=s.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=r||i>s.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=s[r],l=r+1;l<i;l++)s[l]<a&&(a=s[l]);return a}function F1(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(es(s)){if(s.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var t;if(e.output!==void 0){if(!es(e.output))throw new TypeError("output option must be an array if specified");t=e.output}else t=new Array(s.length);var r=C1(s),n=A1(s);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=e.min,a=i===void 0?e.autoMinMax?r:0:i,l=e.max,c=l===void 0?e.autoMinMax?n:1:l;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var p=(c-a)/(n-r),h=0;h<s.length;h++)t[h]=(s[h]-r)*p+a;return t}var M1=Object.freeze({__proto__:null,default:F1}),N1=Mt(M1);Object.defineProperty(qe,"__esModule",{value:!0});var ur=x1,Pf=N1;const ro=" ".repeat(2),zf=" ".repeat(4);function S1(){return qf(this)}function qf(s,e={}){const{maxRows:t=15,maxColumns:r=10,maxNumSize:n=8,padMinus:i="auto"}=e;return`${s.constructor.name} {
|
55
|
+
${ro}[
|
56
|
+
${zf}${B1(s,t,r,n,i)}
|
57
|
+
${ro}]
|
58
|
+
${ro}rows: ${s.rows}
|
59
|
+
${ro}columns: ${s.columns}
|
60
|
+
}`}function B1(s,e,t,r,n){const{rows:i,columns:a}=s,l=Math.min(i,e),c=Math.min(a,t),p=[];if(n==="auto"){n=!1;e:for(let h=0;h<l;h++)for(let f=0;f<c;f++)if(s.get(h,f)<0){n=!0;break e}}for(let h=0;h<l;h++){let f=[];for(let d=0;d<c;d++)f.push(O1(s.get(h,d),r,n));p.push(`${f.join(" ")}`)}return c!==a&&(p[p.length-1]+=` ... ${a-t} more columns`),l!==i&&p.push(`... ${i-e} more rows`),p.join(`
|
61
|
+
${zf}`)}function O1(s,e,t){return(s>=0&&t?` ${kf(s,e-1)}`:kf(s,e)).padEnd(e)}function kf(s,e){let t=s.toString();if(t.length<=e)return t;let r=s.toFixed(e);if(r.length>e&&(r=s.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=s.toExponential(e);return n.length>e&&(n=s.toExponential(Math.max(0,e-(n.length-e)))),n.slice(0)}function T1(s,e){s.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},s.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)+r);return this},s.prototype.addM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)+r.get(n,i));return this},s.add=function(r,n){return new e(r).add(n)},s.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},s.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)-r);return this},s.prototype.subM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)-r.get(n,i));return this},s.sub=function(r,n){return new e(r).sub(n)},s.prototype.subtract=s.prototype.sub,s.prototype.subtractS=s.prototype.subS,s.prototype.subtractM=s.prototype.subM,s.subtract=s.sub,s.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},s.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)*r);return this},s.prototype.mulM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)*r.get(n,i));return this},s.mul=function(r,n){return new e(r).mul(n)},s.prototype.multiply=s.prototype.mul,s.prototype.multiplyS=s.prototype.mulS,s.prototype.multiplyM=s.prototype.mulM,s.multiply=s.mul,s.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},s.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)/r);return this},s.prototype.divM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)/r.get(n,i));return this},s.div=function(r,n){return new e(r).div(n)},s.prototype.divide=s.prototype.div,s.prototype.divideS=s.prototype.divS,s.prototype.divideM=s.prototype.divM,s.divide=s.div,s.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},s.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)%r);return this},s.prototype.modM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)%r.get(n,i));return this},s.mod=function(r,n){return new e(r).mod(n)},s.prototype.modulus=s.prototype.mod,s.prototype.modulusS=s.prototype.modS,s.prototype.modulusM=s.prototype.modM,s.modulus=s.mod,s.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},s.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)&r);return this},s.prototype.andM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)&r.get(n,i));return this},s.and=function(r,n){return new e(r).and(n)},s.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},s.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)|r);return this},s.prototype.orM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)|r.get(n,i));return this},s.or=function(r,n){return new e(r).or(n)},s.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},s.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)^r);return this},s.prototype.xorM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)^r.get(n,i));return this},s.xor=function(r,n){return new e(r).xor(n)},s.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},s.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)<<r);return this},s.prototype.leftShiftM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)<<r.get(n,i));return this},s.leftShift=function(r,n){return new e(r).leftShift(n)},s.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},s.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>r);return this},s.prototype.signPropagatingRightShiftM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>r.get(n,i));return this},s.signPropagatingRightShift=function(r,n){return new e(r).signPropagatingRightShift(n)},s.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},s.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>>r);return this},s.prototype.rightShiftM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,this.get(n,i)>>>r.get(n,i));return this},s.rightShift=function(r,n){return new e(r).rightShift(n)},s.prototype.zeroFillRightShift=s.prototype.rightShift,s.prototype.zeroFillRightShiftS=s.prototype.rightShiftS,s.prototype.zeroFillRightShiftM=s.prototype.rightShiftM,s.zeroFillRightShift=s.rightShift,s.prototype.not=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,~this.get(r,n));return this},s.not=function(r){return new e(r).not()},s.prototype.abs=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.abs(this.get(r,n)));return this},s.abs=function(r){return new e(r).abs()},s.prototype.acos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acos(this.get(r,n)));return this},s.acos=function(r){return new e(r).acos()},s.prototype.acosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acosh(this.get(r,n)));return this},s.acosh=function(r){return new e(r).acosh()},s.prototype.asin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asin(this.get(r,n)));return this},s.asin=function(r){return new e(r).asin()},s.prototype.asinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asinh(this.get(r,n)));return this},s.asinh=function(r){return new e(r).asinh()},s.prototype.atan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atan(this.get(r,n)));return this},s.atan=function(r){return new e(r).atan()},s.prototype.atanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atanh(this.get(r,n)));return this},s.atanh=function(r){return new e(r).atanh()},s.prototype.cbrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cbrt(this.get(r,n)));return this},s.cbrt=function(r){return new e(r).cbrt()},s.prototype.ceil=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.ceil(this.get(r,n)));return this},s.ceil=function(r){return new e(r).ceil()},s.prototype.clz32=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.clz32(this.get(r,n)));return this},s.clz32=function(r){return new e(r).clz32()},s.prototype.cos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cos(this.get(r,n)));return this},s.cos=function(r){return new e(r).cos()},s.prototype.cosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cosh(this.get(r,n)));return this},s.cosh=function(r){return new e(r).cosh()},s.prototype.exp=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.exp(this.get(r,n)));return this},s.exp=function(r){return new e(r).exp()},s.prototype.expm1=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.expm1(this.get(r,n)));return this},s.expm1=function(r){return new e(r).expm1()},s.prototype.floor=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.floor(this.get(r,n)));return this},s.floor=function(r){return new e(r).floor()},s.prototype.fround=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.fround(this.get(r,n)));return this},s.fround=function(r){return new e(r).fround()},s.prototype.log=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log(this.get(r,n)));return this},s.log=function(r){return new e(r).log()},s.prototype.log1p=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log1p(this.get(r,n)));return this},s.log1p=function(r){return new e(r).log1p()},s.prototype.log10=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log10(this.get(r,n)));return this},s.log10=function(r){return new e(r).log10()},s.prototype.log2=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log2(this.get(r,n)));return this},s.log2=function(r){return new e(r).log2()},s.prototype.round=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.round(this.get(r,n)));return this},s.round=function(r){return new e(r).round()},s.prototype.sign=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sign(this.get(r,n)));return this},s.sign=function(r){return new e(r).sign()},s.prototype.sin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sin(this.get(r,n)));return this},s.sin=function(r){return new e(r).sin()},s.prototype.sinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sinh(this.get(r,n)));return this},s.sinh=function(r){return new e(r).sinh()},s.prototype.sqrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sqrt(this.get(r,n)));return this},s.sqrt=function(r){return new e(r).sqrt()},s.prototype.tan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tan(this.get(r,n)));return this},s.tan=function(r){return new e(r).tan()},s.prototype.tanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tanh(this.get(r,n)));return this},s.tanh=function(r){return new e(r).tanh()},s.prototype.trunc=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.trunc(this.get(r,n)));return this},s.trunc=function(r){return new e(r).trunc()},s.pow=function(r,n){return new e(r).pow(n)},s.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},s.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,Math.pow(this.get(n,i),r));return this},s.prototype.powM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.set(n,i,Math.pow(this.get(n,i),r.get(n,i)));return this}}function Nr(s,e,t){let r=t?s.rows:s.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function Sr(s,e,t){let r=t?s.columns:s.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function Di(s,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==s.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function bi(s,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==s.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function La(s,e){if(!ur.isAnyArray(e))throw new TypeError("row indices must be an array");for(let t=0;t<e.length;t++)if(e[t]<0||e[t]>=s.rows)throw new RangeError("row indices are out of range")}function Ra(s,e){if(!ur.isAnyArray(e))throw new TypeError("column indices must be an array");for(let t=0;t<e.length;t++)if(e[t]<0||e[t]>=s.columns)throw new RangeError("column indices are out of range")}function Pa(s,e,t,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(io("startRow",e),io("endRow",t),io("startColumn",r),io("endColumn",n),e>t||r>n||e<0||e>=s.rows||t<0||t>=s.rows||r<0||r>=s.columns||n<0||n>=s.columns)throw new RangeError("Submatrix indices are out of range")}function no(s,e=0){let t=[];for(let r=0;r<s;r++)t.push(e);return t}function io(s,e){if(typeof e!="number")throw new TypeError(`${s} must be a number`)}function Ei(s){if(s.isEmpty())throw new Error("Empty matrix has no elements to index")}function I1(s){let e=no(s.rows);for(let t=0;t<s.rows;++t)for(let r=0;r<s.columns;++r)e[t]+=s.get(t,r);return e}function $1(s){let e=no(s.columns);for(let t=0;t<s.rows;++t)for(let r=0;r<s.columns;++r)e[r]+=s.get(t,r);return e}function L1(s){let e=0;for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)e+=s.get(t,r);return e}function R1(s){let e=no(s.rows,1);for(let t=0;t<s.rows;++t)for(let r=0;r<s.columns;++r)e[t]*=s.get(t,r);return e}function P1(s){let e=no(s.columns,1);for(let t=0;t<s.rows;++t)for(let r=0;r<s.columns;++r)e[r]*=s.get(t,r);return e}function z1(s){let e=1;for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)e*=s.get(t,r);return e}function q1(s,e,t){const r=s.rows,n=s.columns,i=[];for(let a=0;a<r;a++){let l=0,c=0,p=0;for(let h=0;h<n;h++)p=s.get(a,h)-t[a],l+=p,c+=p*p;e?i.push((c-l*l/n)/(n-1)):i.push((c-l*l/n)/n)}return i}function k1(s,e,t){const r=s.rows,n=s.columns,i=[];for(let a=0;a<n;a++){let l=0,c=0,p=0;for(let h=0;h<r;h++)p=s.get(h,a)-t[a],l+=p,c+=p*p;e?i.push((c-l*l/r)/(r-1)):i.push((c-l*l/r)/r)}return i}function U1(s,e,t){const r=s.rows,n=s.columns,i=r*n;let a=0,l=0,c=0;for(let p=0;p<r;p++)for(let h=0;h<n;h++)c=s.get(p,h)-t,a+=c,l+=c*c;return e?(l-a*a/i)/(i-1):(l-a*a/i)/i}function W1(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)-e[t])}function j1(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)-e[r])}function Y1(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)-e)}function V1(s){const e=[];for(let t=0;t<s.rows;t++){let r=0;for(let n=0;n<s.columns;n++)r+=Math.pow(s.get(t,n),2)/(s.columns-1);e.push(Math.sqrt(r))}return e}function Z1(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)/e[t])}function K1(s){const e=[];for(let t=0;t<s.columns;t++){let r=0;for(let n=0;n<s.rows;n++)r+=Math.pow(s.get(n,t),2)/(s.rows-1);e.push(Math.sqrt(r))}return e}function G1(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)/e[r])}function H1(s){const e=s.size-1;let t=0;for(let r=0;r<s.columns;r++)for(let n=0;n<s.rows;n++)t+=Math.pow(s.get(n,r),2)/e;return Math.sqrt(t)}function J1(s,e){for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)/e)}class $e{static from1DArray(e,t,r){if(e*t!==r.length)throw new RangeError("data length does not match given dimensions");let i=new pe(e,t);for(let a=0;a<e;a++)for(let l=0;l<t;l++)i.set(a,l,r[a*t+l]);return i}static rowVector(e){let t=new pe(1,e.length);for(let r=0;r<e.length;r++)t.set(0,r,e[r]);return t}static columnVector(e){let t=new pe(e.length,1);for(let r=0;r<e.length;r++)t.set(r,0,e[r]);return t}static zeros(e,t){return new pe(e,t)}static ones(e,t){return new pe(e,t).fill(1)}static rand(e,t,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{random:n=Math.random}=r;let i=new pe(e,t);for(let a=0;a<e;a++)for(let l=0;l<t;l++)i.set(a,l,n());return i}static randInt(e,t,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:i=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(n>=i)throw new RangeError("min must be smaller than max");let l=i-n,c=new pe(e,t);for(let p=0;p<e;p++)for(let h=0;h<t;h++){let f=n+Math.round(a()*l);c.set(p,h,f)}return c}static eye(e,t,r){t===void 0&&(t=e),r===void 0&&(r=1);let n=Math.min(e,t),i=this.zeros(e,t);for(let a=0;a<n;a++)i.set(a,a,r);return i}static diag(e,t,r){let n=e.length;t===void 0&&(t=n),r===void 0&&(r=t);let i=Math.min(n,t,r),a=this.zeros(t,r);for(let l=0;l<i;l++)a.set(l,l,e[l]);return a}static min(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let r=e.rows,n=e.columns,i=new pe(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)i.set(a,l,Math.min(e.get(a,l),t.get(a,l)));return i}static max(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let r=e.rows,n=e.columns,i=new this(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)i.set(a,l,Math.max(e.get(a,l),t.get(a,l)));return i}static checkMatrix(e){return $e.isMatrix(e)?e:new pe(e)}static isMatrix(e){return e!=null&&e.klass==="Matrix"}get size(){return this.rows*this.columns}apply(e){if(typeof e!="function")throw new TypeError("callback must be a function");for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.call(this,t,r);return this}to1DArray(){let e=[];for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}to2DArray(){let e=[];for(let t=0;t<this.rows;t++){e.push([]);for(let r=0;r<this.columns;r++)e[t].push(this.get(t,r))}return e}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let e=0;e<this.rows;e++)for(let t=0;t<=e;t++)if(this.get(e,t)!==this.get(t,e))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let e=0;e<this.rows;e++)if(this.get(e,e)!==0)return!1;return!0}isEchelonForm(){let e=0,t=0,r=-1,n=!0,i=!1;for(;e<this.rows&&n;){for(t=0,i=!1;t<this.columns&&i===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>r?(i=!0,r=t):(n=!1,i=!0);e++}return n}isReducedEchelonForm(){let e=0,t=0,r=-1,n=!0,i=!1;for(;e<this.rows&&n;){for(t=0,i=!1;t<this.columns&&i===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>r?(i=!0,r=t):(n=!1,i=!0);for(let a=t+1;a<this.rows;a++)this.get(e,a)!==0&&(n=!1);e++}return n}echelonForm(){let e=this.clone(),t=0,r=0;for(;t<e.rows&&r<e.columns;){let n=t;for(let i=t;i<e.rows;i++)e.get(i,r)>e.get(n,r)&&(n=i);if(e.get(n,r)===0)r++;else{e.swapRows(t,n);let i=e.get(t,r);for(let a=r;a<e.columns;a++)e.set(t,a,e.get(t,a)/i);for(let a=t+1;a<e.rows;a++){let l=e.get(a,r)/e.get(t,r);e.set(a,r,0);for(let c=r+1;c<e.columns;c++)e.set(a,c,e.get(a,c)-e.get(t,c)*l)}t++,r++}}return e}reducedEchelonForm(){let e=this.echelonForm(),t=e.columns,r=e.rows,n=r-1;for(;n>=0;)if(e.maxRow(n)===0)n--;else{let i=0,a=!1;for(;i<r&&a===!1;)e.get(n,i)===1?a=!0:i++;for(let l=0;l<n;l++){let c=e.get(l,i);for(let p=i;p<t;p++){let h=e.get(l,p)-c*e.get(n,p);e.set(l,p,h)}}n--}return e}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{rows:t=1,columns:r=1}=e;if(!Number.isInteger(t)||t<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new pe(this.rows*t,this.columns*r);for(let i=0;i<t;i++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*i,this.columns*a);return n}fill(e){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,e);return this}neg(){return this.mulS(-1)}getRow(e){Nr(this,e);let t=[];for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}getRowVector(e){return pe.rowVector(this.getRow(e))}setRow(e,t){Nr(this,e),t=Di(this,t);for(let r=0;r<this.columns;r++)this.set(e,r,t[r]);return this}swapRows(e,t){Nr(this,e),Nr(this,t);for(let r=0;r<this.columns;r++){let n=this.get(e,r);this.set(e,r,this.get(t,r)),this.set(t,r,n)}return this}getColumn(e){Sr(this,e);let t=[];for(let r=0;r<this.rows;r++)t.push(this.get(r,e));return t}getColumnVector(e){return pe.columnVector(this.getColumn(e))}setColumn(e,t){Sr(this,e),t=bi(this,t);for(let r=0;r<this.rows;r++)this.set(r,e,t[r]);return this}swapColumns(e,t){Sr(this,e),Sr(this,t);for(let r=0;r<this.rows;r++){let n=this.get(r,e);this.set(r,e,this.get(r,t)),this.set(r,t,n)}return this}addRowVector(e){e=Di(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)+e[r]);return this}subRowVector(e){e=Di(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)-e[r]);return this}mulRowVector(e){e=Di(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e[r]);return this}divRowVector(e){e=Di(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)/e[r]);return this}addColumnVector(e){e=bi(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)+e[t]);return this}subColumnVector(e){e=bi(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)-e[t]);return this}mulColumnVector(e){e=bi(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e[t]);return this}divColumnVector(e){e=bi(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)/e[t]);return this}mulRow(e,t){Nr(this,e);for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this}mulColumn(e,t){Sr(this,e);for(let r=0;r<this.rows;r++)this.set(r,e,this.get(r,e)*t);return this}max(e){if(this.isEmpty())return NaN;switch(e){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t[r]&&(t[r]=this.get(r,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t[n]&&(t[n]=this.get(r,n));return t}case void 0:{let t=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n));return t}default:throw new Error(`invalid option: ${e}`)}}maxIndex(){Ei(this);let e=this.get(0,0),t=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e&&(e=this.get(r,n),t[0]=r,t[1]=n);return t}min(e){if(this.isEmpty())return NaN;switch(e){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t[r]&&(t[r]=this.get(r,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t[n]&&(t[n]=this.get(r,n));return t}case void 0:{let t=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n));return t}default:throw new Error(`invalid option: ${e}`)}}minIndex(){Ei(this);let e=this.get(0,0),t=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e&&(e=this.get(r,n),t[0]=r,t[1]=n);return t}maxRow(e){if(Nr(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let r=1;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}maxRowIndex(e){Nr(this,e),Ei(this);let t=this.get(e,0),r=[e,0];for(let n=1;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n),r[1]=n);return r}minRow(e){if(Nr(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let r=1;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}minRowIndex(e){Nr(this,e),Ei(this);let t=this.get(e,0),r=[e,0];for(let n=1;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n),r[1]=n);return r}maxColumn(e){if(Sr(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let r=1;r<this.rows;r++)this.get(r,e)>t&&(t=this.get(r,e));return t}maxColumnIndex(e){Sr(this,e),Ei(this);let t=this.get(0,e),r=[0,e];for(let n=1;n<this.rows;n++)this.get(n,e)>t&&(t=this.get(n,e),r[0]=n);return r}minColumn(e){if(Sr(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let r=1;r<this.rows;r++)this.get(r,e)<t&&(t=this.get(r,e));return t}minColumnIndex(e){Sr(this,e),Ei(this);let t=this.get(0,e),r=[0,e];for(let n=1;n<this.rows;n++)this.get(n,e)<t&&(t=this.get(n,e),r[0]=n);return r}diag(){let e=Math.min(this.rows,this.columns),t=[];for(let r=0;r<e;r++)t.push(this.get(r,r));return t}norm(e="frobenius"){switch(e){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${e}`)}}cumulativeSum(){let e=0;for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r),this.set(t,r,e);return this}dot(e){$e.isMatrix(e)&&(e=e.to1DArray());let t=this.to1DArray();if(t.length!==e.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<t.length;n++)r+=t[n]*e[n];return r}mmul(e){e=pe.checkMatrix(e);let t=this.rows,r=this.columns,n=e.columns,i=new pe(t,n),a=new Float64Array(r);for(let l=0;l<n;l++){for(let c=0;c<r;c++)a[c]=e.get(c,l);for(let c=0;c<t;c++){let p=0;for(let h=0;h<r;h++)p+=this.get(c,h)*a[h];i.set(c,l,p)}}return i}strassen2x2(e){e=pe.checkMatrix(e);let t=new pe(2,2);const r=this.get(0,0),n=e.get(0,0),i=this.get(0,1),a=e.get(0,1),l=this.get(1,0),c=e.get(1,0),p=this.get(1,1),h=e.get(1,1),f=(r+p)*(n+h),d=(l+p)*n,g=r*(a-h),y=p*(c-n),m=(r+i)*h,w=(l-r)*(n+a),v=(i-p)*(c+h),E=f+y-m+v,b=g+m,N=d+y,x=f-d+g+w;return t.set(0,0,E),t.set(0,1,b),t.set(1,0,N),t.set(1,1,x),t}strassen3x3(e){e=pe.checkMatrix(e);let t=new pe(3,3);const r=this.get(0,0),n=this.get(0,1),i=this.get(0,2),a=this.get(1,0),l=this.get(1,1),c=this.get(1,2),p=this.get(2,0),h=this.get(2,1),f=this.get(2,2),d=e.get(0,0),g=e.get(0,1),y=e.get(0,2),m=e.get(1,0),w=e.get(1,1),v=e.get(1,2),E=e.get(2,0),b=e.get(2,1),N=e.get(2,2),x=(r+n+i-a-l-h-f)*w,F=(r-a)*(-g+w),M=l*(-d+g+m-w-v-E+N),S=(-r+a+l)*(d-g+w),I=(a+l)*(-d+g),C=r*d,B=(-r+p+h)*(d-y+v),L=(-r+p)*(y-v),U=(p+h)*(-d+y),k=(r+n+i-l-c-p-h)*v,W=h*(-d+y+m-w-v-E+b),z=(-i+h+f)*(w+E-b),K=(i-f)*(w-b),Z=i*E,X=(h+f)*(-E+b),Q=(-i+l+c)*(v+E-N),ce=(i-c)*(v-N),ve=(l+c)*(-E+N),le=n*m,we=c*b,be=a*y,Be=p*g,Ee=f*N,ot=C+Z+le,Te=x+S+I+C+z+Z+X,Ne=C+B+U+k+Z+Q+ve,lt=F+M+S+C+Z+Q+ce,rt=F+S+I+C+we,ke=Z+Q+ce+ve+be,Je=C+B+L+W+z+K+Z,$t=z+K+Z+X+Be,mr=C+B+L+U+Ee;return t.set(0,0,ot),t.set(0,1,Te),t.set(0,2,Ne),t.set(1,0,lt),t.set(1,1,rt),t.set(1,2,ke),t.set(2,0,Je),t.set(2,1,$t),t.set(2,2,mr),t}mmulStrassen(e){e=pe.checkMatrix(e);let t=this.clone(),r=t.rows,n=t.columns,i=e.rows,a=e.columns;n!==i&&console.warn(`Multiplying ${r} x ${n} and ${i} x ${a} matrix: dimensions do not match.`);function l(f,d,g){let y=f.rows,m=f.columns;if(y===d&&m===g)return f;{let w=$e.zeros(d,g);return w=w.setSubMatrix(f,0,0),w}}let c=Math.max(r,i),p=Math.max(n,a);t=l(t,c,p),e=l(e,c,p);function h(f,d,g,y){if(g<=512||y<=512)return f.mmul(d);g%2===1&&y%2===1?(f=l(f,g+1,y+1),d=l(d,g+1,y+1)):g%2===1?(f=l(f,g+1,y),d=l(d,g+1,y)):y%2===1&&(f=l(f,g,y+1),d=l(d,g,y+1));let m=parseInt(f.rows/2,10),w=parseInt(f.columns/2,10),v=f.subMatrix(0,m-1,0,w-1),E=d.subMatrix(0,m-1,0,w-1),b=f.subMatrix(0,m-1,w,f.columns-1),N=d.subMatrix(0,m-1,w,d.columns-1),x=f.subMatrix(m,f.rows-1,0,w-1),F=d.subMatrix(m,d.rows-1,0,w-1),M=f.subMatrix(m,f.rows-1,w,f.columns-1),S=d.subMatrix(m,d.rows-1,w,d.columns-1),I=h($e.add(v,M),$e.add(E,S),m,w),C=h($e.add(x,M),E,m,w),B=h(v,$e.sub(N,S),m,w),L=h(M,$e.sub(F,E),m,w),U=h($e.add(v,b),S,m,w),k=h($e.sub(x,v),$e.add(E,N),m,w),W=h($e.sub(b,M),$e.add(F,S),m,w),z=$e.add(I,L);z.sub(U),z.add(W);let K=$e.add(B,U),Z=$e.add(C,L),X=$e.sub(I,C);X.add(B),X.add(k);let Q=$e.zeros(2*z.rows,2*z.columns);return Q=Q.setSubMatrix(z,0,0),Q=Q.setSubMatrix(K,z.rows,0),Q=Q.setSubMatrix(Z,0,z.columns),Q=Q.setSubMatrix(X,z.rows,z.columns),Q.subMatrix(0,g-1,0,y-1)}return h(t,e,c,p)}scaleRows(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(t>=r)throw new RangeError("min must be smaller than max");let n=new pe(this.rows,this.columns);for(let i=0;i<this.rows;i++){const a=this.getRow(i);a.length>0&&Pf(a,{min:t,max:r,output:a}),n.setRow(i,a)}return n}scaleColumns(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(t>=r)throw new RangeError("min must be smaller than max");let n=new pe(this.rows,this.columns);for(let i=0;i<this.columns;i++){const a=this.getColumn(i);a.length&&Pf(a,{min:t,max:r,output:a}),n.setColumn(i,a)}return n}flipRows(){const e=Math.ceil(this.columns/2);for(let t=0;t<this.rows;t++)for(let r=0;r<e;r++){let n=this.get(t,r),i=this.get(t,this.columns-1-r);this.set(t,r,i),this.set(t,this.columns-1-r,n)}return this}flipColumns(){const e=Math.ceil(this.rows/2);for(let t=0;t<this.columns;t++)for(let r=0;r<e;r++){let n=this.get(r,t),i=this.get(this.rows-1-r,t);this.set(r,t,i),this.set(this.rows-1-r,t,n)}return this}kroneckerProduct(e){e=pe.checkMatrix(e);let t=this.rows,r=this.columns,n=e.rows,i=e.columns,a=new pe(t*n,r*i);for(let l=0;l<t;l++)for(let c=0;c<r;c++)for(let p=0;p<n;p++)for(let h=0;h<i;h++)a.set(n*l+p,i*c+h,this.get(l,c)*e.get(p,h));return a}kroneckerSum(e){if(e=pe.checkMatrix(e),!this.isSquare()||!e.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let t=this.rows,r=e.rows,n=this.kroneckerProduct(pe.eye(r,r)),i=pe.eye(t,t).kroneckerProduct(e);return n.add(i)}transpose(){let e=new pe(this.columns,this.rows);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.set(r,t,this.get(t,r));return e}sortRows(e=Uf){for(let t=0;t<this.rows;t++)this.setRow(t,this.getRow(t).sort(e));return this}sortColumns(e=Uf){for(let t=0;t<this.columns;t++)this.setColumn(t,this.getColumn(t).sort(e));return this}subMatrix(e,t,r,n){Pa(this,e,t,r,n);let i=new pe(t-e+1,n-r+1);for(let a=e;a<=t;a++)for(let l=r;l<=n;l++)i.set(a-e,l-r,this.get(a,l));return i}subMatrixRow(e,t,r){if(t===void 0&&(t=0),r===void 0&&(r=this.columns-1),t>r||t<0||t>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new pe(e.length,r-t+1);for(let i=0;i<e.length;i++)for(let a=t;a<=r;a++){if(e[i]<0||e[i]>=this.rows)throw new RangeError(`Row index out of range: ${e[i]}`);n.set(i,a-t,this.get(e[i],a))}return n}subMatrixColumn(e,t,r){if(t===void 0&&(t=0),r===void 0&&(r=this.rows-1),t>r||t<0||t>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new pe(r-t+1,e.length);for(let i=0;i<e.length;i++)for(let a=t;a<=r;a++){if(e[i]<0||e[i]>=this.columns)throw new RangeError(`Column index out of range: ${e[i]}`);n.set(a-t,i,this.get(a,e[i]))}return n}setSubMatrix(e,t,r){if(e=pe.checkMatrix(e),e.isEmpty())return this;let n=t+e.rows-1,i=r+e.columns-1;Pa(this,t,n,r,i);for(let a=0;a<e.rows;a++)for(let l=0;l<e.columns;l++)this.set(t+a,r+l,e.get(a,l));return this}selection(e,t){La(this,e),Ra(this,t);let r=new pe(e.length,t.length);for(let n=0;n<e.length;n++){let i=e[n];for(let a=0;a<t.length;a++){let l=t[a];r.set(n,a,this.get(i,l))}}return r}trace(){let e=Math.min(this.rows,this.columns),t=0;for(let r=0;r<e;r++)t+=this.get(r,r);return t}clone(){return this.constructor.copy(this,new pe(this.rows,this.columns))}static copy(e,t){for(const[r,n,i]of e.entries())t.set(r,n,i);return t}sum(e){switch(e){case"row":return I1(this);case"column":return $1(this);case void 0:return L1(this);default:throw new Error(`invalid option: ${e}`)}}product(e){switch(e){case"row":return R1(this);case"column":return P1(this);case void 0:return z1(this);default:throw new Error(`invalid option: ${e}`)}}mean(e){const t=this.sum(e);switch(e){case"row":{for(let r=0;r<this.rows;r++)t[r]/=this.columns;return t}case"column":{for(let r=0;r<this.columns;r++)t[r]/=this.rows;return t}case void 0:return t/this.size;default:throw new Error(`invalid option: ${e}`)}}variance(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(e)}=t;if(typeof r!="boolean")throw new TypeError("unbiased must be a boolean");switch(e){case"row":{if(!ur.isAnyArray(n))throw new TypeError("mean must be an array");return q1(this,r,n)}case"column":{if(!ur.isAnyArray(n))throw new TypeError("mean must be an array");return k1(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return U1(this,r,n)}default:throw new Error(`invalid option: ${e}`)}}standardDeviation(e,t){typeof e=="object"&&(t=e,e=void 0);const r=this.variance(e,t);if(e===void 0)return Math.sqrt(r);for(let n=0;n<r.length;n++)r[n]=Math.sqrt(r[n]);return r}center(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");const{center:r=this.mean(e)}=t;switch(e){case"row":{if(!ur.isAnyArray(r))throw new TypeError("center must be an array");return W1(this,r),this}case"column":{if(!ur.isAnyArray(r))throw new TypeError("center must be an array");return j1(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return Y1(this,r),this}default:throw new Error(`invalid option: ${e}`)}}scale(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");let r=t.scale;switch(e){case"row":{if(r===void 0)r=V1(this);else if(!ur.isAnyArray(r))throw new TypeError("scale must be an array");return Z1(this,r),this}case"column":{if(r===void 0)r=K1(this);else if(!ur.isAnyArray(r))throw new TypeError("scale must be an array");return G1(this,r),this}case void 0:{if(r===void 0)r=H1(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return J1(this,r),this}default:throw new Error(`invalid option: ${e}`)}}toString(e){return qf(this,e)}[Symbol.iterator](){return this.entries()}*entries(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield[e,t,this.get(e,t)]}*values(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield this.get(e,t)}}$e.prototype.klass="Matrix",typeof Symbol<"u"&&($e.prototype[Symbol.for("nodejs.util.inspect.custom")]=S1);function Uf(s,e){return s-e}function X1(s){return s.every(e=>typeof e=="number")}$e.random=$e.rand,$e.randomInt=$e.randInt,$e.diagonal=$e.diag,$e.prototype.diagonal=$e.prototype.diag,$e.identity=$e.eye,$e.prototype.negate=$e.prototype.neg,$e.prototype.tensorProduct=$e.prototype.kroneckerProduct;let pe=(Ni=class extends $e{constructor(t,r){super();Cl(this,is);R(this,"data");if(Ni.isMatrix(t))Fl(this,is,Ml).call(this,t.rows,t.columns),Ni.copy(t,this);else if(Number.isInteger(t)&&t>=0)Fl(this,is,Ml).call(this,t,r);else if(ur.isAnyArray(t)){const n=t;if(t=n.length,r=t?n[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let i=0;i<t;i++){if(n[i].length!==r)throw new RangeError("Inconsistent array dimensions");if(!X1(n[i]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[i]))}this.rows=t,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(t,r,n){return this.data[t][r]=n,this}get(t,r){return this.data[t][r]}removeRow(t){return Nr(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,r){return r===void 0&&(r=t,t=this.rows),Nr(this,t,!0),r=Float64Array.from(Di(this,r)),this.data.splice(t,0,r),this.rows+=1,this}removeColumn(t){Sr(this,t);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let i=0;i<t;i++)n[i]=this.data[r][i];for(let i=t+1;i<this.columns;i++)n[i-1]=this.data[r][i];this.data[r]=n}return this.columns-=1,this}addColumn(t,r){typeof r>"u"&&(r=t,t=this.columns),Sr(this,t,!0),r=bi(this,r);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let a=0;for(;a<t;a++)i[a]=this.data[n][a];for(i[a++]=r[n];a<this.columns+1;a++)i[a]=this.data[n][a-1];this.data[n]=i}return this.columns+=1,this}},is=new WeakSet,Ml=function(t,r){if(this.data=[],Number.isInteger(r)&&r>=0)for(let n=0;n<t;n++)this.data.push(new Float64Array(r));else throw new TypeError("nColumns must be a positive integer");this.rows=t,this.columns=r},Ni);T1($e,pe);const go=class go extends $e{constructor(t){super();Cl(this,Jt,void 0);if(pe.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");ua(this,Jt,pe.copy(t,new pe(t.rows,t.rows)))}else if(Number.isInteger(t)&&t>=0)ua(this,Jt,new pe(t,t));else if(ua(this,Jt,new pe(t)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Jr(this,Jt).size}get rows(){return Jr(this,Jt).rows}get columns(){return Jr(this,Jt).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return pe.isMatrix(t)&&t.klassType==="SymmetricMatrix"}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}clone(){const t=new go(this.diagonalSize);for(const[r,n,i]of this.upperRightEntries())t.set(r,n,i);return t}toMatrix(){return new pe(this)}get(t,r){return Jr(this,Jt).get(t,r)}set(t,r,n){return Jr(this,Jt).set(t,r,n),Jr(this,Jt).set(r,t,n),this}removeCross(t){return Jr(this,Jt).removeRow(t),Jr(this,Jt).removeColumn(t),this}addCross(t,r){r===void 0&&(r=t,t=this.diagonalSize);const n=r.slice();return n.splice(t,1),Jr(this,Jt).addRow(t,n),Jr(this,Jt).addColumn(t,r),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[n,i]of t.entries())i||r.push(n);r.reverse();for(const n of r)this.removeCross(n);return this}toCompact(){const{diagonalSize:t}=this,r=new Array(t*(t+1)/2);for(let n=0,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=t&&(n=++i);return r}static fromCompact(t){const r=t.length,n=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const i=new go(n);for(let a=0,l=0,c=0;c<r;c++)i.set(a,l,t[c]),++a>=n&&(a=++l);return i}*upperRightEntries(){for(let t=0,r=0;t<this.diagonalSize;void 0){const n=this.get(t,r);yield[t,r,n],++r>=this.diagonalSize&&(r=++t)}}*upperRightValues(){for(let t=0,r=0;t<this.diagonalSize;void 0)yield this.get(t,r),++r>=this.diagonalSize&&(r=++t)}};Jt=new WeakMap;let Xn=go;Xn.prototype.klassType="SymmetricMatrix";class so extends Xn{static isDistanceMatrix(e){return Xn.isSymmetricMatrix(e)&&e.klassSubType==="DistanceMatrix"}constructor(e){if(super(e),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(e,t,r){return e===t&&(r=0),super.set(e,t,r)}addCross(e,t){return t===void 0&&(t=e,e=this.diagonalSize),t=t.slice(),t[e]=0,super.addCross(e,t)}toSymmetricMatrix(){return new Xn(this)}clone(){const e=new so(this.diagonalSize);for(const[t,r,n]of this.upperRightEntries())t!==r&&e.set(t,r,n);return e}toCompact(){const{diagonalSize:e}=this,t=(e-1)*e/2,r=new Array(t);for(let n=1,i=0,a=0;a<r.length;a++)r[a]=this.get(i,n),++n>=e&&(n=++i+1);return r}static fromCompact(e){const t=e.length,r=(Math.sqrt(8*t+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(e)}`);const n=new this(r);for(let i=1,a=0,l=0;l<t;l++)n.set(i,a,e[l]),++i>=r&&(i=++a+1);return n}}so.prototype.klassSubType="DistanceMatrix";class fn extends $e{constructor(e,t,r){super(),this.matrix=e,this.rows=t,this.columns=r}}class Q1 extends fn{constructor(e,t){Sr(e,t),super(e,e.rows,1),this.column=t}set(e,t,r){return this.matrix.set(e,this.column,r),this}get(e){return this.matrix.get(e,this.column)}}class ey extends fn{constructor(e,t){Ra(e,t),super(e,e.rows,t.length),this.columnIndices=t}set(e,t,r){return this.matrix.set(e,this.columnIndices[t],r),this}get(e,t){return this.matrix.get(e,this.columnIndices[t])}}class ty extends fn{constructor(e){super(e,e.rows,e.columns)}set(e,t,r){return this.matrix.set(e,this.columns-t-1,r),this}get(e,t){return this.matrix.get(e,this.columns-t-1)}}class ry extends fn{constructor(e){super(e,e.rows,e.columns)}set(e,t,r){return this.matrix.set(this.rows-e-1,t,r),this}get(e,t){return this.matrix.get(this.rows-e-1,t)}}class ny extends fn{constructor(e,t){Nr(e,t),super(e,1,e.columns),this.row=t}set(e,t,r){return this.matrix.set(this.row,t,r),this}get(e,t){return this.matrix.get(this.row,t)}}class iy extends fn{constructor(e,t){La(e,t),super(e,t.length,e.columns),this.rowIndices=t}set(e,t,r){return this.matrix.set(this.rowIndices[e],t,r),this}get(e,t){return this.matrix.get(this.rowIndices[e],t)}}class oo extends fn{constructor(e,t,r){La(e,t),Ra(e,r),super(e,t.length,r.length),this.rowIndices=t,this.columnIndices=r}set(e,t,r){return this.matrix.set(this.rowIndices[e],this.columnIndices[t],r),this}get(e,t){return this.matrix.get(this.rowIndices[e],this.columnIndices[t])}}class sy extends fn{constructor(e,t,r,n,i){Pa(e,t,r,n,i),super(e,r-t+1,i-n+1),this.startRow=t,this.startColumn=n}set(e,t,r){return this.matrix.set(this.startRow+e,this.startColumn+t,r),this}get(e,t){return this.matrix.get(this.startRow+e,this.startColumn+t)}}class oy extends fn{constructor(e){super(e,e.columns,e.rows)}set(e,t,r){return this.matrix.set(t,e,r),this}get(e,t){return this.matrix.get(t,e)}}class Wf extends $e{constructor(e,t={}){const{rows:r=1}=t;if(e.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=e.length/r,this.data=e}set(e,t,r){let n=this._calculateIndex(e,t);return this.data[n]=r,this}get(e,t){let r=this._calculateIndex(e,t);return this.data[r]}_calculateIndex(e,t){return e*this.columns+t}}class _r extends $e{constructor(e){super(),this.data=e,this.rows=e.length,this.columns=e[0].length}set(e,t,r){return this.data[e][t]=r,this}get(e,t){return this.data[e][t]}}function ay(s,e){if(ur.isAnyArray(s))return s[0]&&ur.isAnyArray(s[0])?new _r(s):new Wf(s,e);throw new Error("the argument is not an array")}class ao{constructor(e){e=_r.checkMatrix(e);let t=e.clone(),r=t.rows,n=t.columns,i=new Float64Array(r),a=1,l,c,p,h,f,d,g,y,m;for(l=0;l<r;l++)i[l]=l;for(y=new Float64Array(r),c=0;c<n;c++){for(l=0;l<r;l++)y[l]=t.get(l,c);for(l=0;l<r;l++){for(m=Math.min(l,c),f=0,p=0;p<m;p++)f+=t.get(l,p)*y[p];y[l]-=f,t.set(l,c,y[l])}for(h=c,l=c+1;l<r;l++)Math.abs(y[l])>Math.abs(y[h])&&(h=l);if(h!==c){for(p=0;p<n;p++)d=t.get(h,p),t.set(h,p,t.get(c,p)),t.set(c,p,d);g=i[h],i[h]=i[c],i[c]=g,a=-a}if(c<r&&t.get(c,c)!==0)for(l=c+1;l<r;l++)t.set(l,c,t.get(l,c)/t.get(c,c))}this.LU=t,this.pivotVector=i,this.pivotSign=a}isSingular(){let e=this.LU,t=e.columns;for(let r=0;r<t;r++)if(e.get(r,r)===0)return!0;return!1}solve(e){e=pe.checkMatrix(e);let t=this.LU;if(t.rows!==e.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n=e.columns,i=e.subMatrixRow(this.pivotVector,0,n-1),a=t.columns,l,c,p;for(p=0;p<a;p++)for(l=p+1;l<a;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(p,c)*t.get(l,p));for(p=a-1;p>=0;p--){for(c=0;c<n;c++)i.set(p,c,i.get(p,c)/t.get(p,p));for(l=0;l<p;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(p,c)*t.get(l,p))}return i}get determinant(){let e=this.LU;if(!e.isSquare())throw new Error("Matrix must be square");let t=this.pivotSign,r=e.columns;for(let n=0;n<r;n++)t*=e.get(n,n);return t}get lowerTriangularMatrix(){let e=this.LU,t=e.rows,r=e.columns,n=new pe(t,r);for(let i=0;i<t;i++)for(let a=0;a<r;a++)i>a?n.set(i,a,e.get(i,a)):i===a?n.set(i,a,1):n.set(i,a,0);return n}get upperTriangularMatrix(){let e=this.LU,t=e.rows,r=e.columns,n=new pe(t,r);for(let i=0;i<t;i++)for(let a=0;a<r;a++)i<=a?n.set(i,a,e.get(i,a)):n.set(i,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function hn(s,e){let t=0;return Math.abs(s)>Math.abs(e)?(t=e/s,Math.abs(s)*Math.sqrt(1+t*t)):e!==0?(t=s/e,Math.abs(e)*Math.sqrt(1+t*t)):0}class za{constructor(e){e=_r.checkMatrix(e);let t=e.clone(),r=e.rows,n=e.columns,i=new Float64Array(n),a,l,c,p;for(c=0;c<n;c++){let h=0;for(a=c;a<r;a++)h=hn(h,t.get(a,c));if(h!==0){for(t.get(c,c)<0&&(h=-h),a=c;a<r;a++)t.set(a,c,t.get(a,c)/h);for(t.set(c,c,t.get(c,c)+1),l=c+1;l<n;l++){for(p=0,a=c;a<r;a++)p+=t.get(a,c)*t.get(a,l);for(p=-p/t.get(c,c),a=c;a<r;a++)t.set(a,l,t.get(a,l)+p*t.get(a,c))}}i[c]=-h}this.QR=t,this.Rdiag=i}solve(e){e=pe.checkMatrix(e);let t=this.QR,r=t.rows;if(e.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n=e.columns,i=e.clone(),a=t.columns,l,c,p,h;for(p=0;p<a;p++)for(c=0;c<n;c++){for(h=0,l=p;l<r;l++)h+=t.get(l,p)*i.get(l,c);for(h=-h/t.get(p,p),l=p;l<r;l++)i.set(l,c,i.get(l,c)+h*t.get(l,p))}for(p=a-1;p>=0;p--){for(c=0;c<n;c++)i.set(p,c,i.get(p,c)/this.Rdiag[p]);for(l=0;l<p;l++)for(c=0;c<n;c++)i.set(l,c,i.get(l,c)-i.get(p,c)*t.get(l,p))}return i.subMatrix(0,a-1,0,n-1)}isFullRank(){let e=this.QR.columns;for(let t=0;t<e;t++)if(this.Rdiag[t]===0)return!1;return!0}get upperTriangularMatrix(){let e=this.QR,t=e.columns,r=new pe(t,t),n,i;for(n=0;n<t;n++)for(i=0;i<t;i++)n<i?r.set(n,i,e.get(n,i)):n===i?r.set(n,i,this.Rdiag[n]):r.set(n,i,0);return r}get orthogonalMatrix(){let e=this.QR,t=e.rows,r=e.columns,n=new pe(t,r),i,a,l,c;for(l=r-1;l>=0;l--){for(i=0;i<t;i++)n.set(i,l,0);for(n.set(l,l,1),a=l;a<r;a++)if(e.get(l,l)!==0){for(c=0,i=l;i<t;i++)c+=e.get(i,l)*n.get(i,a);for(c=-c/e.get(l,l),i=l;i<t;i++)n.set(i,a,n.get(i,a)+c*e.get(i,l))}}return n}}class xi{constructor(e,t={}){if(e=_r.checkMatrix(e),e.isEmpty())throw new Error("Matrix must be non-empty");let r=e.rows,n=e.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:a=!0,autoTranspose:l=!1}=t;let c=!!i,p=!!a,h=!1,f;if(r<n)if(!l)f=e.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{f=e.transpose(),r=f.rows,n=f.columns,h=!0;let C=c;c=p,p=C}else f=e.clone();let d=Math.min(r,n),g=Math.min(r+1,n),y=new Float64Array(g),m=new pe(r,d),w=new pe(n,n),v=new Float64Array(n),E=new Float64Array(r),b=new Float64Array(g);for(let C=0;C<g;C++)b[C]=C;let N=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),F=Math.max(N,x);for(let C=0;C<F;C++){if(C<N){y[C]=0;for(let B=C;B<r;B++)y[C]=hn(y[C],f.get(B,C));if(y[C]!==0){f.get(C,C)<0&&(y[C]=-y[C]);for(let B=C;B<r;B++)f.set(B,C,f.get(B,C)/y[C]);f.set(C,C,f.get(C,C)+1)}y[C]=-y[C]}for(let B=C+1;B<n;B++){if(C<N&&y[C]!==0){let L=0;for(let U=C;U<r;U++)L+=f.get(U,C)*f.get(U,B);L=-L/f.get(C,C);for(let U=C;U<r;U++)f.set(U,B,f.get(U,B)+L*f.get(U,C))}v[B]=f.get(C,B)}if(c&&C<N)for(let B=C;B<r;B++)m.set(B,C,f.get(B,C));if(C<x){v[C]=0;for(let B=C+1;B<n;B++)v[C]=hn(v[C],v[B]);if(v[C]!==0){v[C+1]<0&&(v[C]=0-v[C]);for(let B=C+1;B<n;B++)v[B]/=v[C];v[C+1]+=1}if(v[C]=-v[C],C+1<r&&v[C]!==0){for(let B=C+1;B<r;B++)E[B]=0;for(let B=C+1;B<r;B++)for(let L=C+1;L<n;L++)E[B]+=v[L]*f.get(B,L);for(let B=C+1;B<n;B++){let L=-v[B]/v[C+1];for(let U=C+1;U<r;U++)f.set(U,B,f.get(U,B)+L*E[U])}}if(p)for(let B=C+1;B<n;B++)w.set(B,C,v[B])}}let M=Math.min(n,r+1);if(N<n&&(y[N]=f.get(N,N)),r<M&&(y[M-1]=0),x+1<M&&(v[x]=f.get(x,M-1)),v[M-1]=0,c){for(let C=N;C<d;C++){for(let B=0;B<r;B++)m.set(B,C,0);m.set(C,C,1)}for(let C=N-1;C>=0;C--)if(y[C]!==0){for(let B=C+1;B<d;B++){let L=0;for(let U=C;U<r;U++)L+=m.get(U,C)*m.get(U,B);L=-L/m.get(C,C);for(let U=C;U<r;U++)m.set(U,B,m.get(U,B)+L*m.get(U,C))}for(let B=C;B<r;B++)m.set(B,C,-m.get(B,C));m.set(C,C,1+m.get(C,C));for(let B=0;B<C-1;B++)m.set(B,C,0)}else{for(let B=0;B<r;B++)m.set(B,C,0);m.set(C,C,1)}}if(p)for(let C=n-1;C>=0;C--){if(C<x&&v[C]!==0)for(let B=C+1;B<n;B++){let L=0;for(let U=C+1;U<n;U++)L+=w.get(U,C)*w.get(U,B);L=-L/w.get(C+1,C);for(let U=C+1;U<n;U++)w.set(U,B,w.get(U,B)+L*w.get(U,C))}for(let B=0;B<n;B++)w.set(B,C,0);w.set(C,C,1)}let S=M-1,I=Number.EPSILON;for(;M>0;){let C,B;for(C=M-2;C>=-1&&C!==-1;C--){const L=Number.MIN_VALUE+I*Math.abs(y[C]+Math.abs(y[C+1]));if(Math.abs(v[C])<=L||Number.isNaN(v[C])){v[C]=0;break}}if(C===M-2)B=4;else{let L;for(L=M-1;L>=C&&L!==C;L--){let U=(L!==M?Math.abs(v[L]):0)+(L!==C+1?Math.abs(v[L-1]):0);if(Math.abs(y[L])<=I*U){y[L]=0;break}}L===C?B=3:L===M-1?B=1:(B=2,C=L)}switch(C++,B){case 1:{let L=v[M-2];v[M-2]=0;for(let U=M-2;U>=C;U--){let k=hn(y[U],L),W=y[U]/k,z=L/k;if(y[U]=k,U!==C&&(L=-z*v[U-1],v[U-1]=W*v[U-1]),p)for(let K=0;K<n;K++)k=W*w.get(K,U)+z*w.get(K,M-1),w.set(K,M-1,-z*w.get(K,U)+W*w.get(K,M-1)),w.set(K,U,k)}break}case 2:{let L=v[C-1];v[C-1]=0;for(let U=C;U<M;U++){let k=hn(y[U],L),W=y[U]/k,z=L/k;if(y[U]=k,L=-z*v[U],v[U]=W*v[U],c)for(let K=0;K<r;K++)k=W*m.get(K,U)+z*m.get(K,C-1),m.set(K,C-1,-z*m.get(K,U)+W*m.get(K,C-1)),m.set(K,U,k)}break}case 3:{const L=Math.max(Math.abs(y[M-1]),Math.abs(y[M-2]),Math.abs(v[M-2]),Math.abs(y[C]),Math.abs(v[C])),U=y[M-1]/L,k=y[M-2]/L,W=v[M-2]/L,z=y[C]/L,K=v[C]/L,Z=((k+U)*(k-U)+W*W)/2,X=U*W*(U*W);let Q=0;(Z!==0||X!==0)&&(Z<0?Q=0-Math.sqrt(Z*Z+X):Q=Math.sqrt(Z*Z+X),Q=X/(Z+Q));let ce=(z+U)*(z-U)+Q,ve=z*K;for(let le=C;le<M-1;le++){let we=hn(ce,ve);we===0&&(we=Number.MIN_VALUE);let be=ce/we,Be=ve/we;if(le!==C&&(v[le-1]=we),ce=be*y[le]+Be*v[le],v[le]=be*v[le]-Be*y[le],ve=Be*y[le+1],y[le+1]=be*y[le+1],p)for(let Ee=0;Ee<n;Ee++)we=be*w.get(Ee,le)+Be*w.get(Ee,le+1),w.set(Ee,le+1,-Be*w.get(Ee,le)+be*w.get(Ee,le+1)),w.set(Ee,le,we);if(we=hn(ce,ve),we===0&&(we=Number.MIN_VALUE),be=ce/we,Be=ve/we,y[le]=we,ce=be*v[le]+Be*y[le+1],y[le+1]=-Be*v[le]+be*y[le+1],ve=Be*v[le+1],v[le+1]=be*v[le+1],c&&le<r-1)for(let Ee=0;Ee<r;Ee++)we=be*m.get(Ee,le)+Be*m.get(Ee,le+1),m.set(Ee,le+1,-Be*m.get(Ee,le)+be*m.get(Ee,le+1)),m.set(Ee,le,we)}v[M-2]=ce;break}case 4:{if(y[C]<=0&&(y[C]=y[C]<0?-y[C]:0,p))for(let L=0;L<=S;L++)w.set(L,C,-w.get(L,C));for(;C<S&&!(y[C]>=y[C+1]);){let L=y[C];if(y[C]=y[C+1],y[C+1]=L,p&&C<n-1)for(let U=0;U<n;U++)L=w.get(U,C+1),w.set(U,C+1,w.get(U,C)),w.set(U,C,L);if(c&&C<r-1)for(let U=0;U<r;U++)L=m.get(U,C+1),m.set(U,C+1,m.get(U,C)),m.set(U,C,L);C++}M--;break}}}if(h){let C=w;w=m,m=C}this.m=r,this.n=n,this.s=y,this.U=m,this.V=w}solve(e){let t=e,r=this.threshold,n=this.s.length,i=pe.zeros(n,n);for(let d=0;d<n;d++)Math.abs(this.s[d])<=r?i.set(d,d,0):i.set(d,d,1/this.s[d]);let a=this.U,l=this.rightSingularVectors,c=l.mmul(i),p=l.rows,h=a.rows,f=pe.zeros(p,h);for(let d=0;d<p;d++)for(let g=0;g<h;g++){let y=0;for(let m=0;m<n;m++)y+=c.get(d,m)*a.get(g,m);f.set(d,g,y)}return f.mmul(t)}solveForDiagonal(e){return this.solve(pe.diag(e))}inverse(){let e=this.V,t=this.threshold,r=e.rows,n=e.columns,i=new pe(r,this.s.length);for(let h=0;h<r;h++)for(let f=0;f<n;f++)Math.abs(this.s[f])>t&&i.set(h,f,e.get(h,f)/this.s[f]);let a=this.U,l=a.rows,c=a.columns,p=new pe(r,l);for(let h=0;h<r;h++)for(let f=0;f<l;f++){let d=0;for(let g=0;g<c;g++)d+=i.get(h,g)*a.get(f,g);p.set(h,f,d)}return p}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let e=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,t=0,r=this.s;for(let n=0,i=r.length;n<i;n++)r[n]>e&&t++;return t}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return pe.diag(this.s)}}function uy(s,e=!1){return s=_r.checkMatrix(s),e?new xi(s).inverse():jf(s,pe.eye(s.rows))}function jf(s,e,t=!1){return s=_r.checkMatrix(s),e=_r.checkMatrix(e),t?new xi(s).solve(e):s.isSquare()?new ao(s).solve(e):new za(s).solve(e)}function uo(s){if(s=pe.checkMatrix(s),s.isSquare()){if(s.columns===0)return 1;let e,t,r,n;if(s.columns===2)return e=s.get(0,0),t=s.get(0,1),r=s.get(1,0),n=s.get(1,1),e*n-t*r;if(s.columns===3){let i,a,l;return i=new oo(s,[1,2],[1,2]),a=new oo(s,[1,2],[0,2]),l=new oo(s,[1,2],[0,1]),e=s.get(0,0),t=s.get(0,1),r=s.get(0,2),e*uo(i)-t*uo(a)+r*uo(l)}else return new ao(s).determinant}else throw Error("determinant can only be calculated for a square matrix")}function ly(s,e){let t=[];for(let r=0;r<s;r++)r!==e&&t.push(r);return t}function cy(s,e,t,r=1e-9,n=1e-9){if(s>n)return new Array(e.rows+1).fill(0);{let i=e.addRow(t,[0]);for(let a=0;a<i.rows;a++)Math.abs(i.get(a,0))<r&&i.set(a,0,0);return i.to1DArray()}}function fy(s,e={}){const{thresholdValue:t=1e-9,thresholdError:r=1e-9}=e;s=pe.checkMatrix(s);let n=s.rows,i=new pe(n,n);for(let a=0;a<n;a++){let l=pe.columnVector(s.getRow(a)),c=s.subMatrixRow(ly(n,a)).transpose(),h=new xi(c).solve(l),f=pe.sub(l,c.mmul(h)).abs().max();i.setRow(a,cy(f,h,a,t,r))}return i}function hy(s,e=Number.EPSILON){if(s=pe.checkMatrix(s),s.isEmpty())return s.transpose();let t=new xi(s,{autoTranspose:!0}),r=t.leftSingularVectors,n=t.rightSingularVectors,i=t.diagonal;for(let a=0;a<i.length;a++)Math.abs(i[a])>e?i[a]=1/i[a]:i[a]=0;return n.mmul(pe.diag(i).mmul(r.transpose()))}function py(s,e=s,t={}){s=new pe(s);let r=!1;if(typeof e=="object"&&!pe.isMatrix(e)&&!ur.isAnyArray(e)?(t=e,e=s,r=!0):e=new pe(e),s.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=t;n&&(s=s.center("column"),r||(e=e.center("column")));const i=s.transpose().mmul(e);for(let a=0;a<i.rows;a++)for(let l=0;l<i.columns;l++)i.set(a,l,i.get(a,l)*(1/(s.rows-1)));return i}function dy(s,e=s,t={}){s=new pe(s);let r=!1;if(typeof e=="object"&&!pe.isMatrix(e)&&!ur.isAnyArray(e)?(t=e,e=s,r=!0):e=new pe(e),s.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:i=!0}=t;n&&(s.center("column"),r||e.center("column")),i&&(s.scale("column"),r||e.scale("column"));const a=s.standardDeviation("column",{unbiased:!0}),l=r?a:e.standardDeviation("column",{unbiased:!0}),c=s.transpose().mmul(e);for(let p=0;p<c.rows;p++)for(let h=0;h<c.columns;h++)c.set(p,h,c.get(p,h)*(1/(a[p]*l[h]))*(1/(s.rows-1)));return c}let Yf=class{constructor(e,t={}){const{assumeSymmetric:r=!1}=t;if(e=_r.checkMatrix(e),!e.isSquare())throw new Error("Matrix is not a square matrix");if(e.isEmpty())throw new Error("Matrix must be non-empty");let n=e.columns,i=new pe(n,n),a=new Float64Array(n),l=new Float64Array(n),c=e,p,h,f=!1;if(r?f=!0:f=e.isSymmetric(),f){for(p=0;p<n;p++)for(h=0;h<n;h++)i.set(p,h,c.get(p,h));_y(n,l,a,i),my(n,l,a,i)}else{let d=new pe(n,n),g=new Float64Array(n);for(h=0;h<n;h++)for(p=0;p<n;p++)d.set(p,h,c.get(p,h));gy(n,d,g,i),vy(n,l,a,i,d)}this.n=n,this.e=l,this.d=a,this.V=i}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let e=this.n,t=this.e,r=this.d,n=new pe(e,e),i,a;for(i=0;i<e;i++){for(a=0;a<e;a++)n.set(i,a,0);n.set(i,i,r[i]),t[i]>0?n.set(i,i+1,t[i]):t[i]<0&&n.set(i,i-1,t[i])}return n}};function _y(s,e,t,r){let n,i,a,l,c,p,h,f;for(c=0;c<s;c++)t[c]=r.get(s-1,c);for(l=s-1;l>0;l--){for(f=0,a=0,p=0;p<l;p++)f=f+Math.abs(t[p]);if(f===0)for(e[l]=t[l-1],c=0;c<l;c++)t[c]=r.get(l-1,c),r.set(l,c,0),r.set(c,l,0);else{for(p=0;p<l;p++)t[p]/=f,a+=t[p]*t[p];for(n=t[l-1],i=Math.sqrt(a),n>0&&(i=-i),e[l]=f*i,a=a-n*i,t[l-1]=n-i,c=0;c<l;c++)e[c]=0;for(c=0;c<l;c++){for(n=t[c],r.set(c,l,n),i=e[c]+r.get(c,c)*n,p=c+1;p<=l-1;p++)i+=r.get(p,c)*t[p],e[p]+=r.get(p,c)*n;e[c]=i}for(n=0,c=0;c<l;c++)e[c]/=a,n+=e[c]*t[c];for(h=n/(a+a),c=0;c<l;c++)e[c]-=h*t[c];for(c=0;c<l;c++){for(n=t[c],i=e[c],p=c;p<=l-1;p++)r.set(p,c,r.get(p,c)-(n*e[p]+i*t[p]));t[c]=r.get(l-1,c),r.set(l,c,0)}}t[l]=a}for(l=0;l<s-1;l++){if(r.set(s-1,l,r.get(l,l)),r.set(l,l,1),a=t[l+1],a!==0){for(p=0;p<=l;p++)t[p]=r.get(p,l+1)/a;for(c=0;c<=l;c++){for(i=0,p=0;p<=l;p++)i+=r.get(p,l+1)*r.get(p,c);for(p=0;p<=l;p++)r.set(p,c,r.get(p,c)-i*t[p])}}for(p=0;p<=l;p++)r.set(p,l+1,0)}for(c=0;c<s;c++)t[c]=r.get(s-1,c),r.set(s-1,c,0);r.set(s-1,s-1,1),e[0]=0}function my(s,e,t,r){let n,i,a,l,c,p,h,f,d,g,y,m,w,v,E,b;for(a=1;a<s;a++)e[a-1]=e[a];e[s-1]=0;let N=0,x=0,F=Number.EPSILON;for(p=0;p<s;p++){for(x=Math.max(x,Math.abs(t[p])+Math.abs(e[p])),h=p;h<s&&!(Math.abs(e[h])<=F*x);)h++;if(h>p)do{for(n=t[p],f=(t[p+1]-n)/(2*e[p]),d=hn(f,1),f<0&&(d=-d),t[p]=e[p]/(f+d),t[p+1]=e[p]*(f+d),g=t[p+1],i=n-t[p],a=p+2;a<s;a++)t[a]-=i;for(N=N+i,f=t[h],y=1,m=y,w=y,v=e[p+1],E=0,b=0,a=h-1;a>=p;a--)for(w=m,m=y,b=E,n=y*e[a],i=y*f,d=hn(f,e[a]),e[a+1]=E*d,E=e[a]/d,y=f/d,f=y*t[a]-E*n,t[a+1]=i+E*(y*n+E*t[a]),c=0;c<s;c++)i=r.get(c,a+1),r.set(c,a+1,E*r.get(c,a)+y*i),r.set(c,a,y*r.get(c,a)-E*i);f=-E*b*w*v*e[p]/g,e[p]=E*f,t[p]=y*f}while(Math.abs(e[p])>F*x);t[p]=t[p]+N,e[p]=0}for(a=0;a<s-1;a++){for(c=a,f=t[a],l=a+1;l<s;l++)t[l]<f&&(c=l,f=t[l]);if(c!==a)for(t[c]=t[a],t[a]=f,l=0;l<s;l++)f=r.get(l,a),r.set(l,a,r.get(l,c)),r.set(l,c,f)}}function gy(s,e,t,r){let n=0,i=s-1,a,l,c,p,h,f,d;for(f=n+1;f<=i-1;f++){for(d=0,p=f;p<=i;p++)d=d+Math.abs(e.get(p,f-1));if(d!==0){for(c=0,p=i;p>=f;p--)t[p]=e.get(p,f-1)/d,c+=t[p]*t[p];for(l=Math.sqrt(c),t[f]>0&&(l=-l),c=c-t[f]*l,t[f]=t[f]-l,h=f;h<s;h++){for(a=0,p=i;p>=f;p--)a+=t[p]*e.get(p,h);for(a=a/c,p=f;p<=i;p++)e.set(p,h,e.get(p,h)-a*t[p])}for(p=0;p<=i;p++){for(a=0,h=i;h>=f;h--)a+=t[h]*e.get(p,h);for(a=a/c,h=f;h<=i;h++)e.set(p,h,e.get(p,h)-a*t[h])}t[f]=d*t[f],e.set(f,f-1,d*l)}}for(p=0;p<s;p++)for(h=0;h<s;h++)r.set(p,h,p===h?1:0);for(f=i-1;f>=n+1;f--)if(e.get(f,f-1)!==0){for(p=f+1;p<=i;p++)t[p]=e.get(p,f-1);for(h=f;h<=i;h++){for(l=0,p=f;p<=i;p++)l+=t[p]*r.get(p,h);for(l=l/t[f]/e.get(f,f-1),p=f;p<=i;p++)r.set(p,h,r.get(p,h)+l*t[p])}}}function vy(s,e,t,r,n){let i=s-1,a=0,l=s-1,c=Number.EPSILON,p=0,h=0,f=0,d=0,g=0,y=0,m=0,w=0,v,E,b,N,x,F,M,S,I,C,B,L,U,k,W;for(v=0;v<s;v++)for((v<a||v>l)&&(t[v]=n.get(v,v),e[v]=0),E=Math.max(v-1,0);E<s;E++)h=h+Math.abs(n.get(v,E));for(;i>=a;){for(N=i;N>a&&(y=Math.abs(n.get(N-1,N-1))+Math.abs(n.get(N,N)),y===0&&(y=h),!(Math.abs(n.get(N,N-1))<c*y));)N--;if(N===i)n.set(i,i,n.get(i,i)+p),t[i]=n.get(i,i),e[i]=0,i--,w=0;else if(N===i-1){if(M=n.get(i,i-1)*n.get(i-1,i),f=(n.get(i-1,i-1)-n.get(i,i))/2,d=f*f+M,m=Math.sqrt(Math.abs(d)),n.set(i,i,n.get(i,i)+p),n.set(i-1,i-1,n.get(i-1,i-1)+p),S=n.get(i,i),d>=0){for(m=f>=0?f+m:f-m,t[i-1]=S+m,t[i]=t[i-1],m!==0&&(t[i]=S-M/m),e[i-1]=0,e[i]=0,S=n.get(i,i-1),y=Math.abs(S)+Math.abs(m),f=S/y,d=m/y,g=Math.sqrt(f*f+d*d),f=f/g,d=d/g,E=i-1;E<s;E++)m=n.get(i-1,E),n.set(i-1,E,d*m+f*n.get(i,E)),n.set(i,E,d*n.get(i,E)-f*m);for(v=0;v<=i;v++)m=n.get(v,i-1),n.set(v,i-1,d*m+f*n.get(v,i)),n.set(v,i,d*n.get(v,i)-f*m);for(v=a;v<=l;v++)m=r.get(v,i-1),r.set(v,i-1,d*m+f*r.get(v,i)),r.set(v,i,d*r.get(v,i)-f*m)}else t[i-1]=S+f,t[i]=S+f,e[i-1]=m,e[i]=-m;i=i-2,w=0}else{if(S=n.get(i,i),I=0,M=0,N<i&&(I=n.get(i-1,i-1),M=n.get(i,i-1)*n.get(i-1,i)),w===10){for(p+=S,v=a;v<=i;v++)n.set(v,v,n.get(v,v)-S);y=Math.abs(n.get(i,i-1))+Math.abs(n.get(i-1,i-2)),S=I=.75*y,M=-.4375*y*y}if(w===30&&(y=(I-S)/2,y=y*y+M,y>0)){for(y=Math.sqrt(y),I<S&&(y=-y),y=S-M/((I-S)/2+y),v=a;v<=i;v++)n.set(v,v,n.get(v,v)-y);p+=y,S=I=M=.964}for(w=w+1,x=i-2;x>=N&&(m=n.get(x,x),g=S-m,y=I-m,f=(g*y-M)/n.get(x+1,x)+n.get(x,x+1),d=n.get(x+1,x+1)-m-g-y,g=n.get(x+2,x+1),y=Math.abs(f)+Math.abs(d)+Math.abs(g),f=f/y,d=d/y,g=g/y,!(x===N||Math.abs(n.get(x,x-1))*(Math.abs(d)+Math.abs(g))<c*(Math.abs(f)*(Math.abs(n.get(x-1,x-1))+Math.abs(m)+Math.abs(n.get(x+1,x+1))))));)x--;for(v=x+2;v<=i;v++)n.set(v,v-2,0),v>x+2&&n.set(v,v-3,0);for(b=x;b<=i-1&&(k=b!==i-1,b!==x&&(f=n.get(b,b-1),d=n.get(b+1,b-1),g=k?n.get(b+2,b-1):0,S=Math.abs(f)+Math.abs(d)+Math.abs(g),S!==0&&(f=f/S,d=d/S,g=g/S)),S!==0);b++)if(y=Math.sqrt(f*f+d*d+g*g),f<0&&(y=-y),y!==0){for(b!==x?n.set(b,b-1,-y*S):N!==x&&n.set(b,b-1,-n.get(b,b-1)),f=f+y,S=f/y,I=d/y,m=g/y,d=d/f,g=g/f,E=b;E<s;E++)f=n.get(b,E)+d*n.get(b+1,E),k&&(f=f+g*n.get(b+2,E),n.set(b+2,E,n.get(b+2,E)-f*m)),n.set(b,E,n.get(b,E)-f*S),n.set(b+1,E,n.get(b+1,E)-f*I);for(v=0;v<=Math.min(i,b+3);v++)f=S*n.get(v,b)+I*n.get(v,b+1),k&&(f=f+m*n.get(v,b+2),n.set(v,b+2,n.get(v,b+2)-f*g)),n.set(v,b,n.get(v,b)-f),n.set(v,b+1,n.get(v,b+1)-f*d);for(v=a;v<=l;v++)f=S*r.get(v,b)+I*r.get(v,b+1),k&&(f=f+m*r.get(v,b+2),r.set(v,b+2,r.get(v,b+2)-f*g)),r.set(v,b,r.get(v,b)-f),r.set(v,b+1,r.get(v,b+1)-f*d)}}}if(h!==0){for(i=s-1;i>=0;i--)if(f=t[i],d=e[i],d===0)for(N=i,n.set(i,i,1),v=i-1;v>=0;v--){for(M=n.get(v,v)-f,g=0,E=N;E<=i;E++)g=g+n.get(v,E)*n.get(E,i);if(e[v]<0)m=M,y=g;else if(N=v,e[v]===0?n.set(v,i,M!==0?-g/M:-g/(c*h)):(S=n.get(v,v+1),I=n.get(v+1,v),d=(t[v]-f)*(t[v]-f)+e[v]*e[v],F=(S*y-m*g)/d,n.set(v,i,F),n.set(v+1,i,Math.abs(S)>Math.abs(m)?(-g-M*F)/S:(-y-I*F)/m)),F=Math.abs(n.get(v,i)),c*F*F>1)for(E=v;E<=i;E++)n.set(E,i,n.get(E,i)/F)}else if(d<0)for(N=i-1,Math.abs(n.get(i,i-1))>Math.abs(n.get(i-1,i))?(n.set(i-1,i-1,d/n.get(i,i-1)),n.set(i-1,i,-(n.get(i,i)-f)/n.get(i,i-1))):(W=lo(0,-n.get(i-1,i),n.get(i-1,i-1)-f,d),n.set(i-1,i-1,W[0]),n.set(i-1,i,W[1])),n.set(i,i-1,0),n.set(i,i,1),v=i-2;v>=0;v--){for(C=0,B=0,E=N;E<=i;E++)C=C+n.get(v,E)*n.get(E,i-1),B=B+n.get(v,E)*n.get(E,i);if(M=n.get(v,v)-f,e[v]<0)m=M,g=C,y=B;else if(N=v,e[v]===0?(W=lo(-C,-B,M,d),n.set(v,i-1,W[0]),n.set(v,i,W[1])):(S=n.get(v,v+1),I=n.get(v+1,v),L=(t[v]-f)*(t[v]-f)+e[v]*e[v]-d*d,U=(t[v]-f)*2*d,L===0&&U===0&&(L=c*h*(Math.abs(M)+Math.abs(d)+Math.abs(S)+Math.abs(I)+Math.abs(m))),W=lo(S*g-m*C+d*B,S*y-m*B-d*C,L,U),n.set(v,i-1,W[0]),n.set(v,i,W[1]),Math.abs(S)>Math.abs(m)+Math.abs(d)?(n.set(v+1,i-1,(-C-M*n.get(v,i-1)+d*n.get(v,i))/S),n.set(v+1,i,(-B-M*n.get(v,i)-d*n.get(v,i-1))/S)):(W=lo(-g-I*n.get(v,i-1),-y-I*n.get(v,i),m,d),n.set(v+1,i-1,W[0]),n.set(v+1,i,W[1]))),F=Math.max(Math.abs(n.get(v,i-1)),Math.abs(n.get(v,i))),c*F*F>1)for(E=v;E<=i;E++)n.set(E,i-1,n.get(E,i-1)/F),n.set(E,i,n.get(E,i)/F)}for(v=0;v<s;v++)if(v<a||v>l)for(E=v;E<s;E++)r.set(v,E,n.get(v,E));for(E=s-1;E>=a;E--)for(v=a;v<=l;v++){for(m=0,b=a;b<=Math.min(E,l);b++)m=m+r.get(v,b)*n.get(b,E);r.set(v,E,m)}}}function lo(s,e,t,r){let n,i;return Math.abs(t)>Math.abs(r)?(n=r/t,i=t+n*r,[(s+n*e)/i,(e-n*s)/i]):(n=t/r,i=r+n*t,[(n*s+e)/i,(n*e-s)/i])}class Vf{constructor(e){if(e=_r.checkMatrix(e),!e.isSymmetric())throw new Error("Matrix is not symmetric");let t=e,r=t.rows,n=new pe(r,r),i=!0,a,l,c;for(l=0;l<r;l++){let p=0;for(c=0;c<l;c++){let h=0;for(a=0;a<c;a++)h+=n.get(c,a)*n.get(l,a);h=(t.get(l,c)-h)/n.get(c,c),n.set(l,c,h),p=p+h*h}for(p=t.get(l,l)-p,i&=p>0,n.set(l,l,Math.sqrt(Math.max(p,0))),c=l+1;c<r;c++)n.set(l,c,0)}this.L=n,this.positiveDefinite=!!i}isPositiveDefinite(){return this.positiveDefinite}solve(e){e=_r.checkMatrix(e);let t=this.L,r=t.rows;if(e.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let n=e.columns,i=e.clone(),a,l,c;for(c=0;c<r;c++)for(l=0;l<n;l++){for(a=0;a<c;a++)i.set(c,l,i.get(c,l)-i.get(a,l)*t.get(c,a));i.set(c,l,i.get(c,l)/t.get(c,c))}for(c=r-1;c>=0;c--)for(l=0;l<n;l++){for(a=c+1;a<r;a++)i.set(c,l,i.get(c,l)-i.get(a,l)*t.get(a,c));i.set(c,l,i.get(c,l)/t.get(c,c))}return i}get lowerTriangularMatrix(){return this.L}}class Zf{constructor(e,t={}){e=_r.checkMatrix(e);let{Y:r}=t;const{scaleScores:n=!1,maxIterations:i=1e3,terminationCriteria:a=1e-10}=t;let l;if(r){if(ur.isAnyArray(r)&&typeof r[0]=="number"?r=pe.columnVector(r):r=_r.checkMatrix(r),r.rows!==e.rows)throw new Error("Y should have the same number of rows as X");l=r.getColumnVector(0)}else l=e.getColumnVector(0);let c=1,p,h,f,d;for(let g=0;g<i&&c>a;g++)f=e.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),f=f.div(f.norm()),p=e.mmul(f).div(f.transpose().mmul(f).get(0,0)),g>0&&(c=p.clone().sub(d).pow(2).sum()),d=p.clone(),r?(h=r.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0)),h=h.div(h.norm()),l=r.mmul(h).div(h.transpose().mmul(h).get(0,0))):l=p;if(r){let g=e.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0));g=g.div(g.norm());let y=e.clone().sub(p.clone().mmul(g.transpose())),m=l.transpose().mmul(p).div(p.transpose().mmul(p).get(0,0)),w=r.clone().sub(p.clone().mulS(m.get(0,0)).mmul(h.transpose()));this.t=p,this.p=g.transpose(),this.w=f.transpose(),this.q=h,this.u=l,this.s=p.transpose().mmul(p),this.xResidual=y,this.yResidual=w,this.betas=m}else this.w=f.transpose(),this.s=p.transpose().mmul(p).sqrt(),n?this.t=p.clone().div(this.s.get(0,0)):this.t=p,this.xResidual=e.sub(p.mmul(f.transpose()))}}qe.AbstractMatrix=$e,qe.CHO=Vf,qe.CholeskyDecomposition=Vf,qe.DistanceMatrix=so,qe.EVD=Yf;var yy=qe.EigenvalueDecomposition=Yf;qe.LU=ao,qe.LuDecomposition=ao;var Kf=qe.Matrix=pe;qe.MatrixColumnSelectionView=ey,qe.MatrixColumnView=Q1,qe.MatrixFlipColumnView=ty,qe.MatrixFlipRowView=ry,qe.MatrixRowSelectionView=iy,qe.MatrixRowView=ny,qe.MatrixSelectionView=oo,qe.MatrixSubView=sy,qe.MatrixTransposeView=oy,qe.NIPALS=Zf,qe.Nipals=Zf,qe.QR=za,qe.QrDecomposition=za,qe.SVD=xi,qe.SingularValueDecomposition=xi,qe.SymmetricMatrix=Xn,qe.WrapperMatrix1D=Wf,qe.WrapperMatrix2D=_r,qe.correlation=dy,qe.covariance=py;var Gf=qe.default=pe;qe.determinant=uo,qe.inverse=uy,qe.linearDependencies=fy,qe.pseudoInverse=hy,qe.solve=jf,qe.wrap=ay;const Hf=yy,Jf=Kf;Gf.Matrix&&Gf.Matrix;class wy{constructor(e){R(this,"_errorListener");this._errorListener=e}new({rows:e,columns:t,initial_value:r}={}){return new qa(e,t,r,this._errorListener)}avg({id:e}){return e==null?void 0:e.avg()}col({id:e,column:t}){return e==null?void 0:e.col({column:t})}det({id:e}){return e==null?void 0:e.det()}get({id:e,row:t,column:r}){return e==null?void 0:e.get({row:t,column:r})}inv({id:e}){return e==null?void 0:e.inv()}max({id:e}){return e==null?void 0:e.max()}min({id:e}){return e==null?void 0:e.min()}pow({id:e,power:t}){return e==null?void 0:e.pow({power:t})}row({id:e,row:t}){return e==null?void 0:e.row({row:t})}set({id:e,row:t,column:r,value:n}){e==null||e.set({row:t,column:r,value:n})}sum({id1:e,id2:t}){return e==null?void 0:e.sum({id2:t})}copy({id:e}){return e==null?void 0:e.copy()}diff({id1:e,id2:t}){return e==null?void 0:e.diff({id2:t})}rows({id:e}){return e==null?void 0:e.rows()}columns({id:e}){return e==null?void 0:e.columns()}fill({id:e,value:t,from_row:r,to_row:n,from_column:i,to_column:a}){e==null||e.fill({value:t,from_row:r,to_row:n,from_column:i,to_column:a})}kron({id1:e,id2:t}){return e==null?void 0:e.kron({id2:t})}mode({id:e}){return e==null?void 0:e.mode()}mult({id1:e,id2:t}){return e==null?void 0:e.mult({id2:t})}pinv({id:e}){return e==null?void 0:e.pinv()}rank({id:e}){return e==null?void 0:e.rank()}sort({id:e,column:t,order:r}){e==null||e.sort({column:t,order:r})}trace({id:e}){return e==null?void 0:e.trace()}concat({id1:e,id2:t}){return e==null?void 0:e.concat({id2:t})}median({id:e}){return e==null?void 0:e.median()}add_col({id:e,column:t,array_id:r}){e==null||e.add_col({column:t,array_id:r})}add_row({id:e,row:t,array_id:r}){e==null||e.add_row({row:t,array_id:r})}is_zero({id:e}){return e==null?void 0:e.is_zero()}reshape({id:e,rows:t,columns:r},n){return e==null?void 0:e.reshape({rows:t,columns:r},n)}reverse({id:e}){e==null||e.reverse()}is_binary({id:e}){return e==null?void 0:e.is_binary()}is_square({id:e}){return e==null?void 0:e.is_square()}submatrix({id:e,from_row:t,to_row:r,from_column:n,to_column:i}){return e==null?void 0:e.submatrix({from_row:t,to_row:r,from_column:n,to_column:i})}swap_rows({id:e,row1:t,row2:r}){e==null||e.swap_rows({row1:t,row2:r})}transpose({id:e}){return e==null?void 0:e.transpose()}remove_col({id:e,column:t}){return e==null?void 0:e.remove_col({column:t})}remove_row({id:e,row:t}){return e==null?void 0:e.remove_row({row:t})}eigenvalues({id:e}){return e==null?void 0:e.eigenvalues()}is_diagonal({id:e}){return e==null?void 0:e.is_diagonal()}is_identity({id:e}){return e==null?void 0:e.is_identity()}eigenvectors({id:e}){return e==null?void 0:e.eigenvectors()}is_symmetric({id:e}){return e==null?void 0:e.is_symmetric()}swap_columns({id:e,column1:t,column2:r}){e==null||e.swap_columns({column1:t,column2:r})}is_stochastic({id:e}){return e==null?void 0:e.is_stochastic()}is_triangular({id:e}){return e==null?void 0:e.is_triangular()}elements_count({id:e}){return e==null?void 0:e.elements_count()}is_antidiagonal({id:e}){return e==null?void 0:e.is_antidiagonal()}is_antisymmetric({id:e}){return e==null?void 0:e.is_antisymmetric()}}class qa{constructor(e=0,t=0,r=void 0,n){R(this,"_matrixInstance");R(this,"_errorListener");this._matrixInstance=this._createMatrix(e,t,r),this._errorListener=n}get _matrixArray(){return this._matrixInstance.map(e=>[...e._value])}get _value(){return this._matrixInstance}set _value(e){this._matrixInstance=e}get isMatrix(){return!0}_createMatrix(e,t,r){return Array.from(new Array(e),()=>new Qe(t,r,this._errorListener))}avg(){let e=0,t=0;for(const n of this._matrixInstance)for(const i of n._value)e+=_e(i)?0:i,t+=1;return e/t}col({column:e}){const t=[],r=new Qe(0,void 0,this._errorListener);if(_e(e))return r;for(const n of this._matrixInstance)t.push(n._value[e]);return r._value=t,r}det(){return Lf(this._matrixArray)}get({row:e,column:t}){var r,n;if(!(_e(e)||_e(t)))return(n=(r=this._matrixInstance[e])==null?void 0:r._value)==null?void 0:n[t]}inv(){const e=to(this._matrixArray);return this._newMatrix(e)}max(){return _1(this._matrixArray)}min(){return $a(this._matrixArray)}pow({power:e}){const t=_e(e)?this._matrixArray:g1(this._matrixArray,e);return this._newMatrix(t)}row({row:e}){return _e(e)?new Qe(0,void 0,this._errorListener):this._matrixInstance[e]}set({row:e,column:t,value:r}){_e(e)||_e(t)||this._matrixInstance[e].set({index:t,value:r})}sum({id2:e}){const t=Qi(this._matrixArray,typeof e=="number"?e:e._matrixArray);return this._newMatrix(t)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:e}){const t=l1(this._matrixArray,typeof e=="number"?e:e._matrixArray);return this._newMatrix(t)}rows(){return this._matrixInstance.length}columns(){return this._matrixArray.length&&this._matrixArray[0].length}fill({value:e,from_row:t,to_row:r,from_column:n,to_column:i}={}){_e(t)&&(t=0),_e(r)&&(r=this.rows()),_e(n)&&(n=0),_e(i)&&(i=this.columns());for(const[a,l]of this._matrixInstance.entries())for(const[c]of l._value.entries())a<r&&a>=t&&c>=n&&c<i&&l.set({index:c,value:e})}kron({id2:e}){const t=a1(this._matrixArray,e._matrixArray);return this._newMatrix(t)}mode(){return $a(Nf(this._matrixArray))}mult({id2:e}){const t=typeof e=="number"?e:e._matrixArray?e._matrixArray:e._value,r=wi(this._matrixArray,t);return this._newMatrix(r)}pinv(){const e=m1(this._matrixArray);return this._newMatrix(e)}rank(){return this._matrixRank(this._matrixArray)}sort({column:e,order:t=Vn.ascending}={}){_e(e)&&(e=0),this._matrixInstance.sort((r,n)=>{const i=r._value[e],a=n._value[e];return t!==Vn.descending?i-a:a-i})}trace(){return d1(this._matrixArray)}concat({id2:e}){for(const t of e._value)this._matrixInstance.push(t);return this}median(){return Rf(this._matrixArray)}add_col({column:e,array_id:t}={}){_e(e)&&(e=this.columns());for(const[r,n]of this._matrixInstance.entries())n.insert({index:e,value:t?t._value[r]:void 0})}add_row({row:e,array_id:t}){_e(e)&&(e=this.rows()),this._matrixInstance.splice(e,0,t||new Qe(this.columns(),void 0,this._errorListener))}is_zero(){return this._matrixArray.every(e=>e.every(t=>t===0))}reshape({rows:e=0,columns:t=0},r){if(e*t!==this.columns()*this.rows()){this._errorListener.addError(ut.matrixRehapeErr,r,ze.Error);return}const n=n1(this._matrixArray,[e,t]);this._matrixInstance=n.map(i=>{const a=new Qe(0,void 0,this._errorListener);return a._value=[...i],a})}reverse(){this._matrixInstance.reverse();for(const e of this._matrixInstance)e.reverse()}is_binary(){return this._matrixArray.every(e=>e.every(t=>t===0||t===1))}is_square(){return this.rows()===this.columns()}submatrix({from_row:e,to_row:t,from_column:r,to_column:n}={}){_e(e)&&(e=0),_e(t)&&(t=this.rows()),_e(r)&&(r=0),_e(n)&&(n=this.columns());const i=this._matrixArray.splice(e,t),a=[];for(const l of i)a.push(l.splice(r,n));return this._newMatrix(a)}swap_rows({row1:e,row2:t}){if(_e(e)||_e(t))return;const r=this._matrixInstance[e],n=this._matrixInstance[t];this._matrixInstance[e]=n,this._matrixInstance[t]=r}transpose(){const e=Bf(this._matrixArray);return this._newMatrix(e)}remove_col({column:e}={}){_e(e)&&(e=this.columns());const t=[];for(const n of this._matrixInstance){const i=n._value.splice(e,1);t.push(i[0])}const r=new Qe(0,void 0,this._errorListener);return r._value=t,r}remove_row({row:e}={}){return _e(e)&&(e=this.rows()),this._matrixInstance.splice(e,1)[0]}eigenvalues(){const e=new Hf(new Jf(this._matrixArray)),t=new Qe(0,void 0,this._errorListener);return t._value=e.realEigenvalues,t}is_diagonal(){const e=this.rows(),t=this.columns();if(e!==t)return!1;const r=this._matrixArray;for(let n=0;n<e;n++)for(let i=0;i<t;i++)if(n!==i&&r[n][i]!==0)return!1;return!0}is_identity(){const e=this.rows(),t=this.columns();if(e!==t)return!1;const r=this._matrixArray;for(let n=0;n<e;n++)for(let i=0;i<t;i++)if(n!==i&&r[n][i]!==0||n===i&&r[n][i]!==1)return!1;return!0}eigenvectors(){const e=new Hf(new Jf(this._matrixArray));return this._newMatrix(e.eigenvectorMatrix.to2DArray())}is_symmetric(){const e=this.rows(),t=this.columns();if(e!==t)return!1;const r=this._matrixArray;for(let n=0;n<e;n++)for(let i=n+1;i<t;i++)if(r[n][i]!==r[i][n])return!1;return!0}swap_columns({column1:e,column2:t}){if(!(_e(e)||_e(t)))for(const r of this._matrixInstance){const n=r._value[e],i=r._value[t];r.set({index:e,value:i}),r.set({index:t,value:n})}}is_stochastic(){const e=this._matrixArray;for(let t=0;t<e.length;t++){let r=0;for(let n=0;n<e[t].length;n++){if(e[t][n]<0)return!1;r+=e[t][n]}if(Math.abs(r-1)>Number.EPSILON)return!1}return!0}is_triangular(){const e=this.rows(),t=this.columns();return e!==t?!1:this._isUpperTriangular(e)||this._isLowerTriangular(e)}elements_count(){return i1(this._matrixArray)}is_antidiagonal(){const e=this.rows(),t=this.columns();if(e!==t)return!1;const r=this._matrixArray;for(let n=0;n<e;n++)for(let i=0;i<e;i++)if(n+i!==e-1&&r[n][i]!==0)return!1;return!0}is_antisymmetric(){const e=this.rows(),t=this.columns();if(e!==t)return!1;const r=this._matrixArray;for(let n=0;n<e;n++)for(let i=0;i<e;i++)if(n!==i&&r[n][i]!==-r[i][n])return!1;return!0}_isUpperTriangular(e){const t=this._matrixArray;for(let r=1;r<e;r++)for(let n=0;n<r;n++)if(t[r][n]!==0)return!1;return!0}_isLowerTriangular(e){const t=this._matrixArray;for(let r=0;r<e-1;r++)for(let n=r+1;n<e;n++)if(t[r][n]!==0)return!1;return!0}_newMatrix(e){const t=new qa(0,0,void 0,this._errorListener);return t._value=e.map(r=>{const n=new Qe(0,void 0,this._errorListener);return n._value=[...r],n}),t}_matrixRank(e){let t=0;const r=e.length,n=e[0].length,i=[...e].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let l=a;for(;l<r&&i[l][a]===0;)l++;if(l===r)continue;if(l!==a){const p=i[l];i[l]=i[a],i[a]=p}const c=i[a][a];for(let p=0;p<n;p++)i[a][p]/=c;for(let p=a+1;p<r;p++){const h=i[p][a];i[p]=i[p].map((f,d)=>f-h*i[a][d]),i[p][a]=0}}for(let a=0;a<r;a++)i[a].some(l=>Number(l.toFixed(8))!==0)&&t++;return t}}class Dy{constructor(e){R(this,"_variables");R(this,"_cacheData");this._variables=e,this._cacheData={}}change({timeframe:e},t){if(!e)return!0;const r=Xr(e),n=Xr(this._variables.timeframe.period);if(r<n)return!0;const i=`change_${t}`,a=this._cacheData[i],l=this._variables.time;if(a){if(a.offset){if(a.currentTime+a.offset<=l)return this._cacheData[i]={currentTime:l,offset:0},!0}else if(a.currentTime+r*1e3<=l)return this._cacheData[i]={currentTime:l,offset:0},!0}else{const c=this._calcTimeOffset(l,e);return this._cacheData[i]={currentTime:l,offset:c},!1}return!1}in_seconds({timeframe:e}={}){return Xr(e||this._variables.timeframe.period)}from_seconds({seconds:e=0}){const t=e*1e3,r=tt.duration(t);if(r.years())return"12M";const i=r.asMonths();if(Qs(i))return`${i}M`;const a=r.asWeeks();if(Qs(a))return`${a}M`;const l=r.asDays();if(l>=1)return`${Math.ceil(l)}D`;const c=r.asMinutes();if(c>=1)return`${Math.ceil(c)}`;const p=r.asSeconds();return p<=1?"1S":p<=5?"5S":p<=10?"10S":p<=15?"15S":p<=30?"30S":"1"}_calcTimeOffset(e,t){let r=0;if(t.includes("W")){const l=tt(e).day();t="1D",l!==1&&(r=(8-l)*60*60*24*1e3)}else if(t.includes("M")){const l=tt(e).date();t="1D";const c=tt(e).daysInMonth();l!==1&&(r=(c-l+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(e,t),i=Xr(t)*1e3,a=e-n-Math.floor((e-n)/i)*i;return r?r-a:a}}class by{constructor(e,t){R(this,"_errorListener");R(this,"_intlNumberFormatter");R(this,"_precision");this._errorListener=e,this._precision=t,this._intlNumberFormatter=new Intl.NumberFormat("en",{notation:"compact"})}pos({source:e="",str:t=""}){return e==null?void 0:e.indexOf(t)}trim({source:e=""}){return e==null?void 0:e.trim()}lower({source:e=""}){return e==null?void 0:e.toLocaleLowerCase()}match({source:e="",regex:t=""}){const r=e==null?void 0:e.match(new RegExp(t));return r?r[0]:""}split({string:e="",separator:t=""}){const r=e==null?void 0:e.split(t),n=new Qe;return n._value=r||[],n}upper({source:e=""}){return e==null?void 0:e.toLocaleUpperCase()}format({formatString:e=""},t){return this._strFormat(e,t)}length({string:e=""}){return e==null?void 0:e.length}repeat({source:e="",repeat:t,separator:r=""},n){if(_e(t)){this._errorListener.addError(ut.arrLenErr,n,ze.Error);return}return Array.from(new Array(t),()=>e).join(r)}replace({source:e="",target:t="",replacement:r="",occurrence:n}){_e(n)&&(n=0);let i=-1;for(let a=0;a<n+1&&(i=e.indexOf(t,i+1),i!==-1);a++);return i!==-1?e.substring(0,i)+r+e.substring(i+t.length):e}contains({source:e="",str:t=""}){return e==null?void 0:e.includes(t)}endswith({source:e="",str:t=""}){return e==null?void 0:e.endsWith(t)}tonumber({string:e=""}){if(/[^\d.]/.test(e))return;const t=parseFloat(e);return isNaN(t)?void 0:t}tostring({value:e,format:t}){if(e===void 0)return"NaN";if(typeof e=="object"){if(e.isArray)return this._arrToStr(e._value,t);if(e.isMatrix){const r=[];for(const n of e._matrixArray)r.push(this._arrToStr(n,t));return r.join(`
|
62
|
+
`)}}if(typeof e=="string")return e;if(typeof e=="boolean")return String(e);if(typeof e=="number")return String(this._toStringFormat(e,t))}_arrToStr(e,t){return`[${e.map(n=>typeof n=="number"?this._toStringFormat(n,t):n).toString()}]`}substring({source:e="",begin_pos:t=0,end_pos:r}){return _e(t)&&(t=0),_e(r)&&(r=void 0),e==null?void 0:e.substring(t,r)}startswith({source:e="",str:t=""}){return e==null?void 0:e.startsWith(t)}format_time({time:e,format:t="yyyy-MM-dd'T'HH:mm:ssZ",timezone:r}){return _e(e)&&(e=0),qr(e,r).format(t)}replace_all({source:e="",target:t="",replacement:r=""}){return e==null?void 0:e.replace(new RegExp(t,"g"),r)}_toStringFormat(e,t){if(!t)return Number(e.toFixed(this._precision));switch(t){case Ke.mintick:return e.toFixed(this._precision);case Ke.percent:return`${e}%`;case Ke.volume:return this._intlNumberFormatter.format(Math.round(e));default:return this._formatOthers(e,t)}}_formatOthers(e,t){var l;let[r,n]=t.split(".");t.split("%").length===2&&(e=e*100);let[i,a=""]=String(e).split(".");if(r.includes("#")){if(r.includes(",")){const c=r.split(","),p=((l=c[c.length-1])==null?void 0:l.replace(/[^#]/g,"").length)||0;p&&(i=i.replace(new RegExp(`\\B(?=(\\d{${p}})+(?!\\d))`,"g"),",")),r=c.join("")}i=r.replace(/#/,i).replace(/#/g,"")}else i=`${r}${i}`;if(n&&n.includes("#")){const c=n.split("#").length-1;a=`${a.substring(0,c)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${i}.${a}`:i}_formatNumber(e,t){if(!t)return Number(e.toFixed(this._precision));switch(t){case"integer":return String(Math.round(e));case"currency":return`$${e}`;case"percent":return`${e*100}%`;default:return this._formatOthers(e,t)}}_strFormat(e,t){let r=e;for(const[n,i]of t.entries()){if(i===void 0||isNaN(i)){r="NaN";continue}if(typeof i=="number"){const a=`\\{\\s*${n}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,l=e.match(new RegExp(a));if(l){const c=l[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(i,c)))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(i))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),i)}return r}}class Ey{constructor(e){R(this,"_errorListener");this._errorListener=e}new(){return new ka(this._errorListener)}copy({id:e}){return e==null?void 0:e.copy()}get({id:e,key:t}){return e==null?void 0:e.get({key:t})}put({id:e,key:t,value:r}){return e==null?void 0:e.put({key:t,value:r})}keys({id:e}){return e==null?void 0:e.keys()}size({id:e}){return e==null?void 0:e.size()}clear({id:e}){e==null||e.clear()}remove({id:e,key:t}){return e==null?void 0:e.remove({key:t})}values({id:e}){return e==null?void 0:e.values()}put_all({id:e,id2:t}){e==null||e.put_all({id2:t})}contains({id:e,key:t}){return e==null?void 0:e.contains({key:t})}}class ka{constructor(e){R(this,"_errorListener");R(this,"_mapInstance");this._errorListener=e,this._mapInstance=new Map}get isMap(){return!0}_copyMap(e){const t=new ka(this._errorListener);return t._mapInstance=new Map(e.entries()),t}copy(){return this._copyMap(this._mapInstance)}get({key:e}){return this._mapInstance.get(e)}put({key:e,value:t}){return this._mapInstance.set(e,t)}keys(){const e=new Qe(0,void 0,this._errorListener);return e._value=[...this._mapInstance.keys()],e}size(){return this._mapInstance.size}clear(){this._mapInstance.clear()}remove({key:e}){const t=this._mapInstance.get(e);return this._mapInstance.delete(e),t||void 0}values(){const e=new Qe(0,void 0,this._errorListener);return e._value=[...this._mapInstance.values()],e}put_all({id2:e}){this._mapInstance=new Map([...this._mapInstance,...e._mapInstance])}contains({key:e}){return this._mapInstance.has(e)}}class xy{constructor(e){R(this,"_variables");this._variables=e}new({price:e,time:t,index:r}){return new Ai(e,r,t)}now({price:e}){const{time:t,bar_index:r}=this._variables;return new Ai(e,r,t)}copy({id:e}){return e==null?void 0:e.copy()}from_index({price:e,index:t}){return new Ai(e,t)}from_time({price:e,time:t}){return new Ai(e,void 0,t)}}class Ai{constructor(e,t,r){R(this,"_index");R(this,"_price");R(this,"_time");this._index=t,this._price=e,this._time=r}get index(){return this._index}get price(){return this._price}get time(){return this._time}copy(){return new Ai(this._price,this._index,this._time)}}class Ay{constructor(e,t){R(this,"_variables");R(this,"_errorListener");R(this,"_defaultLabel",{text:"",xloc:wt.bar_index,yloc:Wr.price,size:tr.normal,style:mt.styleLabelDown,textalign:We.alignCenter});this._variables=e,this._errorListener=t}new(e,t){const{time:r,high:n,low:i,bar_index:a}=this._variables,l=`label_${t}_${a}`;_t(e,["color","textcolor"]);const c={...this._defaultLabel,...e,id:l,time:r,high:n,low:i};e.point&&(c.x=c.xloc===wt.bar_index?e.point.index:e.point.time,c.y=e.point.price),c.yloc===Wr.abovebar?c.y=n:c.yloc===Wr.belowbar&&(c.y=i),this._verfiyArgs(e,t);const p=new ts(l,this._variables,this._errorListener);return t.startsWith("export")||this._variables.label.add(l,c,p),p}_verfiyArgs(e,t){const{xloc:r,yloc:n,style:i,size:a,textalign:l,text_font_family:c}=e,p="label.new";this._paramVerfiy(i,t,p,Object.values(mt),"style"),this._paramVerfiy(r,t,p,Object.values(wt),"xloc"),this._paramVerfiy(n,t,p,Object.values(Wr),"yloc"),this._paramVerfiy(a,t,p,Object.values(tr),"size"),this._paramVerfiy(l,t,p,[We.alignLeft,We.alignCenter,We.alignRight],"textalign"),this._paramVerfiy(c,t,p,Object.values(Zn),"text_font_family")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}label(e,t){return e.x?e.x:new ts(t,this._variables,this._errorListener)}copy({id:e},t){return e==null?void 0:e.copy(t)}get_x({id:e},t){return e==null?void 0:e.get_x(t)}get_y({id:e},t){return e==null?void 0:e.get_y(t)}set_x({id:e,...t},r){e==null||e.set_x(t,r)}set_y({id:e,...t},r){e==null||e.set_y(t,r)}delete({id:e}){e==null||e.delete()}get_text({id:e},t){return e==null?void 0:e.get_text(t)}set_xy({id:e,...t},r){e==null||e.set_xy(t,r)}set_size({id:e,...t},r){e==null||e.set_size(t,r)}set_xloc({id:e,...t},r){e==null||e.set_xloc(t,r)}set_yloc({id:e,...t},r){e==null||e.set_yloc(t,r)}set_style({id:e,...t},r){e==null||e.set_style(t,r)}set_color({id:e,...t},r){e==null||e.set_color(t,r)}set_tooltip({id:e,...t},r){e==null||e.set_tooltip(t,r)}set_point({id:e,...t},r){e==null||e.set_point(t,r)}set_text({id:e,...t},r){e==null||e.set_text(t,r)}set_textcolor({id:e,...t},r){e==null||e.set_textcolor(t,r)}set_textalign({id:e,...t},r){e==null||e.set_textalign(t,r)}set_text_font_family({id:e,...t},r){e==null||e.set_text_font_family(t,r)}}class ts{constructor(e,t,r){R(this,"_id");R(this,"_variables");R(this,"_errorListener");this._id=e,this._variables=t,this._errorListener=r}copy(e){const t=`label_${e}_${this._variables.bar_index}`,r=this._getLabel(e),n=new ts(t,this._variables,this._errorListener);if(r){const i={...r,id:t};this._variables.label.add(t,i,n)}return n}get_x(e){var t;return(t=this._getLabel(e))==null?void 0:t.x}get_y(e){var t;return(t=this._getLabel(e))==null?void 0:t.y}set_x({x:e},t){const r=this._getLabel(t);r&&(r.x=e)}set_y({y:e},t){const r=this._getLabel(t);r&&(r.y=e)}delete(){this._variables.label.delete(this._id)}set_xy({x:e,y:t},r){const n=this._getLabel(r);n&&(n.x=e,n.y=t)}get_text(e){var t;return(t=this._getLabel(e))==null?void 0:t.text}set_size({size:e},t){const r=this._getLabel(t);r&&(r.size=e),this._paramVerfiy(e,t,"label.set_size",Object.values(tr),"size")}set_text({text:e},t){const r=this._getLabel(t);r&&(r.text=e)}set_xloc({x:e,xloc:t},r){const n=this._getLabel(r);n&&(n.x=e,n.xloc=t,this._paramVerfiy(t,r,"label.set_xloc",Object.values(wt),"xloc"))}set_yloc({yloc:e},t){const r=this._getLabel(t),{high:n,low:i}=this._variables;r&&(r.yloc=e,e===Wr.abovebar?r.y=n:e===Wr.belowbar&&(r.y=i),this._paramVerfiy(e,t,"label.set_yloc",Object.values(Wr),"yloc"))}set_color(e,t){const r=this._getLabel(t);_t(e,["color"]),r&&(r.color=e.color)}set_point({point:e},t){const r=this._getLabel(t);r&&(r.x=r.xloc===wt.bar_index?e==null?void 0:e.index:e==null?void 0:e.time,r.y=e==null?void 0:e.price)}set_style({style:e},t){const r=this._getLabel(t);r&&(r.style=e),this._paramVerfiy(e,t,"label.set_style",Object.values(mt),"style")}set_tooltip({tooltip:e},t){const r=this._getLabel(t);r&&(r.tooltip=e)}set_textalign({textalign:e},t){const r=this._getLabel(t);r&&(r.textalign=e),this._paramVerfiy(e,t,"label.set_textalign",[We.alignLeft,We.alignCenter,We.alignRight],"textalign")}set_textcolor(e,t){const r=this._getLabel(t);_t(e,["textcolor"]),r&&(r.textcolor=e.textcolor)}set_text_font_family({text_font_family:e},t){const r=this._getLabel(t);r&&(r.text_font_family=e),this._paramVerfiy(e,t,"label.set_text_font_family",Object.values(Zn),"text_font_family")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}_getLabel(e){const t=this._variables.label.get(this._id);return t||console.log(`错误${e}: label 不存在`),t}}const Cy={freq_all:kr.freqAll,freq_once_per_bar:kr.freqOncePerBar,freq_once_per_bar_close:kr.freqOncePerBarClose},Fy={gaps_off:Vi.gapsOff,gaps_on:Vi.gapsOn,lookahead_off:Vi.lookaheadOff,lookahead_on:Vi.lookaheadOn},Ci={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#FF5252",silver:"#B2B5BE",teal:"#00897B",white:"#FFFFFF",yellow:"#FFEB3B"},Xf={AUD:"AUD",BTC:"BTC",CAD:"CAD",CHF:"CHF",ETH:"ETH",EUR:"EUR",GBP:"GBP",HKD:"HKD",INR:"INR",JPY:"JPY",KRW:"KRW",MYR:"MYR",NOK:"NOK",NONE:"NONE",NZD:"NZD",RUB:"RUB",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",USDT:"USDT",ZAR:"ZAR"},My={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},Qf={all:[Yt.dataWindow,Yt.pane,Yt.priceScale,Yt.statusLine],data_window:[Yt.dataWindow],none:[],pane:[Yt.pane],price_scale:[Yt.priceScale],status_line:[Yt.statusLine]},Ny={both:Ur.both,left:Ur.left,none:Ur.none,right:Ur.right},Sy={inherit:Ke.inherit,mintick:Ke.mintick,percent:Ke.percent,price:Ke.price,volume:Ke.volume},By={style_solid:xs.styleSolid,style_dashed:xs.styleDashed,style_dotted:xs.styleDotted},Oy={style_arrowdown:mt.styleArrowdown,style_arrowup:mt.styleArrowup,style_circle:mt.styleCircle,style_cross:mt.styleCross,style_diamond:mt.styleDiamond,style_flag:mt.styleFlag,style_label_center:mt.styleLabelCenter,style_label_down:mt.styleLabelDown,style_label_left:mt.styleLabelLeft,style_label_lower_left:mt.styleLabelLowerLeft,style_label_lower_right:mt.styleLabelLowerRight,style_label_right:mt.styleLabelRight,style_label_up:mt.styleLabelUp,style_label_upper_left:mt.styleLabelUpperLeft,style_label_upper_right:mt.styleLabelUpperRight,style_none:mt.styleNone,style_square:mt.styleSquare,style_text_outline:mt.styleTextOutline,style_triangledown:mt.styleTriangledown,style_triangleup:mt.styleTriangleup,style_xcross:mt.styleXcross},Ty={style_arrow_both:Lt.styleArrowBoth,style_arrow_left:Lt.styleArrowLeft,style_arrow_right:Lt.styleArrowRight,style_dashed:Lt.styleDashed,style_dotted:Lt.styleDotted,style_solid:Lt.styleSolid},Iy={abovebar:an.abovebar,absolute:an.absolute,belowbar:an.belowbar,bottom:an.bottom,top:an.top},$y={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},Ly={style_area:Cr.styleArea,style_areabr:Cr.styleAreabr,style_circles:Cr.styleCircles,style_columns:Cr.styleColumns,style_cross:Cr.styleCross,style_histogram:Cr.styleHistogram,style_line:Cr.styleLine,style_linebr:Cr.styleLinebr,style_stepline:Cr.styleStepline,style_stepline_diamond:Cr.styleSteplineDiamond,style_steplinebr:Cr.styleSteplinebr},Ry={bottom_center:pr.bottomCenter,bottom_left:pr.bottomLeft,bottom_right:pr.bottomRight,middle_center:pr.middleCenter,middle_left:pr.middleLeft,middle_right:pr.middleRight,top_center:pr.topCenter,top_left:pr.topLeft,top_right:pr.topRight},Py={left:As.left,none:As.none,right:As.right},zy={arrowdown:or.arrowdown,arrowup:or.arrowup,circle:or.circle,cross:or.cross,diamond:or.diamond,flag:or.flag,labeldown:or.labeldown,labelup:or.labelup,square:or.square,triangledown:or.triangledown,triangleup:or.triangleup,xcross:or.xcross},qy={auto:tr.auto,huge:tr.huge,large:tr.large,normal:tr.normal,small:tr.small,tiny:tr.tiny},ky={cash:Ot.cash,fixed:Ot.fixed,percent_of_equity:Ot.percentOfEquity,commission:{cash_per_contract:Fr.cashPerContract,cash_per_order:Fr.cashPerOrder,percent:Fr.percent},direction:{all:gt.all,long:gt.long,short:gt.short},oca:{cancel:un.cancel,none:un.none,reduce:un.reduce}},Uy={align_bottom:We.alignBottom,align_center:We.alignCenter,align_left:We.alignLeft,align_right:We.alignRight,align_top:We.alignTop,wrap_auto:We.wrapAuto,wrap_none:We.wrapNone},Wy={bar_index:wt.bar_index,bar_time:wt.bar_time},jy={abovebar:Wr.abovebar,belowbar:Wr.belowbar,price:Wr.price},Yy={actual:Cs.actual,estimate:Cs.estimate,standardized:Cs.standardized};class eh{constructor(){R(this,"adjustment",{dividends:Es.dividends,none:Es.none,splits:Es.splits});R(this,"alert",Cy);R(this,"barmerge",Fy);R(this,"color",Ci);R(this,"currency",Xf);R(this,"dayofweek",My);R(this,"earnings",Yy);R(this,"display",Qf);R(this,"extend",Ny);R(this,"font",{family_default:Zn.familyDefault,family_monospace:Zn.familyMonospace});R(this,"format",Sy);R(this,"hline",By);R(this,"label",Oy);R(this,"line",Ty);R(this,"location",Iy);R(this,"math",$y);R(this,"order",{ascending:Vn.ascending,descending:Vn.descending});R(this,"plot",Ly);R(this,"position",Ry);R(this,"scale",Py);R(this,"session",{extended:fi.extended,regular:fi.regular});R(this,"shape",zy);R(this,"size",qy);R(this,"splits",{denominator:"denominator",numerator:"numerator"});R(this,"strategy",ky);R(this,"text",Uy);R(this,"xloc",Wy);R(this,"yloc",jy)}updateData(){}}class Vy{constructor(e,t){R(this,"_variables");R(this,"_errorListener");R(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:wt.bar_index,line_color:Ci.blue,line_style:Lt.styleSolid,line_width:1});this._variables=e,this._errorListener=t}new(e,t){var a;const r=`polyline_${t}_${this._variables.bar_index}`,n=Object.assign({},this._defaultPolyline,e,{id:r,points:(a=e.points)==null?void 0:a._value.map(l=>({time:l.time,index:l.index,price:l.price}))});_t(n,["line_color","fill_color"]);const i=new th(r,this._variables);return this._verfiyArgs(e,t),t.startsWith("export")||this._variables.polyline.add(r,n,i),i}_verfiyArgs(e,t){const{line_style:r,xloc:n}=e,i="polyline.new";this._paramVerfiy(r,t,i,Object.values(Lt),"line_style"),this._paramVerfiy(n,t,i,Object.values(wt),"xloc")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}delete({id:e}){e&&e.delete()}}class th{constructor(e,t){R(this,"_id");R(this,"_variables");this._variables=t,this._id=e}delete(){this._variables.polyline.delete(this._id)}}class Zy{constructor(e,t){R(this,"_variables");R(this,"_errorListener");R(this,"_defaultLine",{xloc:wt.bar_index,extend:Ur.none,style:Lt.styleSolid});this._variables=e,this._errorListener=t}new({first_point:e,second_point:t,...r},n){const i=`line_${n}_${this._variables.bar_index}`;_t(r,["color"]);const a={...this._defaultLine,...r,id:i};if(e&&t){const c=a.xloc===wt.bar_index?e==null?void 0:e.index:e==null?void 0:e.time,p=a.xloc===wt.bar_index?t==null?void 0:t.index:t==null?void 0:t.time;Object.assign(a,{x1:c,y1:e==null?void 0:e.price,x2:p,y2:t==null?void 0:t.price})}this._verfiyArgs(r,n);const l=new rs(i,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(i,a,l),l}_verfiyArgs(e,t){const{extend:r,xloc:n,style:i}=e,a="line.new";this._paramVerfiy(i,t,a,Object.values(Lt),"style"),this._paramVerfiy(r,t,a,Object.values(Ur),"extend"),this._paramVerfiy(n,t,a,Object.values(wt),"xloc")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}line(e,t){return e.x?e.x:new rs(t,this._variables,this._errorListener)}copy({id:e},t){return e==null?void 0:e.copy(t)}delete({id:e}){e==null||e.delete()}get_x1({id:e},t){return e==null?void 0:e.get_x1(t)}get_x2({id:e},t){return e==null?void 0:e.get_x2(t)}get_y1({id:e},t){return e==null?void 0:e.get_y1(t)}get_y2({id:e},t){return e==null?void 0:e.get_y2(t)}set_x1({id:e,...t},r){e==null||e.set_x1(t,r)}set_x2({id:e,...t},r){e==null||e.set_x2(t,r)}set_y1({id:e,...t},r){e==null||e.set_y1(t,r)}set_y2({id:e,...t},r){e==null||e.set_y2(t,r)}set_xy1({id:e,...t},r){e==null||e.set_xy1(t,r)}set_xy2({id:e,...t},r){e==null||e.set_xy2(t,r)}set_xloc({id:e,...t},r){e==null||e.set_xloc(t,r)}get_price({id:e,...t},r){return e==null?void 0:e.get_price(t,r)}set_color({id:e,...t},r){e==null||e.set_color(t,r)}set_style({id:e,...t},r){e==null||e.set_style(t,r)}set_width({id:e,...t},r){e==null||e.set_width(t,r)}set_extend({id:e,...t},r){e==null||e.set_extend(t,r)}set_first_point({id:e,...t},r){e==null||e.set_first_point(t,r)}set_second_point({id:e,...t},r){e==null||e.set_second_point(t,r)}}class rs{constructor(e,t,r){R(this,"_variables");R(this,"_id");R(this,"_errorListener");this._id=e,this._variables=t,this._errorListener=r}get data(){return this._variables.line.get(this._id)}copy(e){const t=`line_${e}_${this._variables.bar_index}`,r=this._getLine(e),n=new rs(t,this._variables,this._errorListener);return r&&this._variables.line.add(t,{...r,id:t},n),n}delete(){this._variables.line.delete(this._id)}get_price({x:e},t){const r=this._getLine(t);if(e===void 0)return e;if(r&&r.xloc===wt.bar_index){const{x1:n,y1:i,x2:a,y2:l}=r;return n===void 0||a===void 0||i===void 0||l===void 0?void 0:(l-i)/(a-n)*(e-n)+i}}get_x1(e){var t;return(t=this._getLine(e))==null?void 0:t.x1}get_x2(e){var t;return(t=this._getLine(e))==null?void 0:t.x2}get_y1(e){var t;return(t=this._getLine(e))==null?void 0:t.y1}get_y2(e){var t;return(t=this._getLine(e))==null?void 0:t.y2}set_x1({x:e},t){const r=this._getLine(t);r&&(r.x1=e)}set_x2({x:e},t){const r=this._getLine(t);r&&(r.x2=e)}set_y1({y:e},t){const r=this._getLine(t);r&&(r.y1=e)}set_y2({y:e},t){const r=this._getLine(t);r&&(r.y2=e)}set_xy1({x:e,y:t},r){const n=this._getLine(r);n&&(n.x1=e,n.y1=t)}set_xy2({x:e,y:t},r){const n=this._getLine(r);n&&(n.x2=e,n.y2=t)}set_xloc({xloc:e,x1:t,x2:r},n){const i=this._getLine(n);i&&(i.xloc=e,i.x1=t,i.x2=r,this._paramVerfiy(e,n,"line.set_xloc",Object.values(wt),"xloc"))}set_color(e,t){const r=this._getLine(t);r&&(_t(e,["color"]),r.color=e.color)}set_style({style:e},t){const r=this._getLine(t);r&&(r.style=e,this._paramVerfiy(e,t,"line.set_style",Object.values(Lt),"style"))}set_width({width:e},t){const r=this._getLine(t);r&&(r.width=e)}set_extend({extend:e},t){const r=this._getLine(t);r&&(r.extend=e,this._paramVerfiy(e,t,"line.set_extend",Object.values(Ur),"extend"))}set_first_point({point:e},t){const r=this._getLine(t);if(r){const{index:n,time:i,price:a}=e||{},l=r.xloc===wt.bar_index?n:i,c=a;l&&(r.x1=l),c&&(r.y1=c)}}set_second_point({point:e},t){const r=this._getLine(t);if(r){const{index:n,time:i,price:a}=e||{},l=r.xloc===wt.bar_index?n:i,c=a;l&&(r.x2=l),c&&(r.y2=c)}}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}_getLine(e){const t=this._variables.line.get(this._id);return t||console.log(`${e}: line 不存在`),t}}class Ky{constructor(e){R(this,"_variables");this._variables=e}new(e,t){const{line1:r,line2:n}=e,i=`linefill_${t}_${this._variables.bar_index}`,a=r==null?void 0:r.data,l=n==null?void 0:n.data;a&&(a.linefills=a.linefills||[],a.linefills.push(i)),l&&(l.linefills=l.linefills||[],l.linefills.push(i)),_t(e,["color"]);const c=new co(this._variables,i,r,n);return t.startsWith("export")||(a||l)&&this._variables.linefill.add(i,{line1:a,line2:l,color:e.color,id:i},c),c}delete({id:e}){e==null||e.delete()}get_line1({id:e}){return e==null?void 0:e.get_line1()}get_line2({id:e}){return e==null?void 0:e.get_line2()}set_color({id:e,...t}){e==null||e.set_color(t)}}class co{constructor(e,t,r,n){R(this,"_id");R(this,"_line1");R(this,"_line2");R(this,"_variables");this._variables=e,this._id=t,this._line1=r,this._line2=n}linefill(e,t){return e.x?e.x:new co(this._variables,t)}delete(){var t,r;const e=this._variables.linefill.get(this._id);if(e){const{line1:n,line2:i}=e;n&&(n.linefills=(t=n.linefills)==null?void 0:t.filter(a=>a!==this._id)),i&&(i.linefills=(r=i.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id)}get_line1(){return this._line1}get_line2(){return this._line2}set_color(e){const t=this._variables.linefill.get(this._id);t&&(_t(e,["color"]),t.color=e.color)}}class Gy{constructor(e,t){R(this,"_variables");R(this,"_errorListener");R(this,"_defaultBox",{border_color:Ci.blue,border_width:1,bgcolor:Ci.blue,xloc:wt.bar_index,extend:Ur.none,style:Lt.styleSolid,text:"",text_size:tr.auto,text_color:Ci.black,text_halign:We.alignCenter,text_valign:We.alignCenter,text_wrap:We.wrapNone});this._variables=e,this._errorListener=t}box({x:e},t){return e===void 0?new ns(this._variables,t,this._errorListener):e}new({top_left:e,bottom_right:t,...r},n){const i=`box_${n}_${this._variables.bar_index}`,a={...this._defaultBox,...r,id:i};if(_t(a,["border_color","bgcolor","text_color"]),e){const{price:c,time:p,index:h}=e;a.top=c,a.left=a.xloc===wt.bar_index?h:p}if(t){const{price:c,time:p,index:h}=t;a.bottom=c,a.right=a.xloc===wt.bar_index?h:p}this._verfiyArgs(r,n);const l=new ns(this._variables,i,this._errorListener);return n.startsWith("export")||this._variables.box.add(i,a,l),l}_verfiyArgs(e,t){const{border_style:r,extend:n,xloc:i,text_size:a,text_halign:l,text_valign:c,text_wrap:p,text_font_family:h}=e,f="box.new";this._paramVerfiy(r,t,f,[Lt.styleDashed,Lt.styleDotted,Lt.styleSolid],"border_style"),this._paramVerfiy(n,t,f,Object.values(Ur),"extend"),this._paramVerfiy(i,t,f,Object.values(wt),"xloc"),this._paramVerfiy(a,t,f,Object.values(tr),"text_size"),this._paramVerfiy(l,t,f,[We.alignLeft,We.alignCenter,We.alignRight],"text_halign"),this._paramVerfiy(c,t,f,[We.alignBottom,We.alignCenter,We.alignTop],"text_valign"),this._paramVerfiy(p,t,f,[We.wrapAuto,We.wrapNone],"text_wrap"),this._paramVerfiy(h,t,f,Object.values(Zn),"text_font_family")}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}copy({id:e},t){return e==null?void 0:e.copy(t)}delete({id:e}){e==null||e.delete()}get_top({id:e}){return e==null?void 0:e.get_top()}get_bottom({id:e}){return e==null?void 0:e.get_bottom()}get_left({id:e}){return e==null?void 0:e.get_left()}get_right({id:e}){return e==null?void 0:e.get_right()}set_top({id:e,...t}){e==null||e.set_top(t)}set_bottom({id:e,...t}){e==null||e.set_bottom(t)}set_left({id:e,...t}){e==null||e.set_left(t)}set_right({id:e,...t}){e==null||e.set_right(t)}set_extend({id:e,...t},r){e==null||e.set_extend(t,r)}set_bgcolor({id:e,...t}){e==null||e.set_bgcolor(t)}set_border_color({id:e,...t}){e==null||e.set_border_color(t)}set_border_width({id:e,...t}){e==null||e.set_border_width(t)}set_border_style({id:e,...t},r){e==null||e.set_border_style(t,r)}set_lefttop({id:e,...t}){e==null||e.set_lefttop(t)}set_rightbottom({id:e,...t}){e==null||e.set_rightbottom(t)}set_text_size({id:e,...t},r){e==null||e.set_text_size(t,r)}set_text_wrap({id:e,...t},r){e==null||e.set_text_wrap(t,r)}set_text_color({id:e,...t}){e==null||e.set_text_color(t)}set_text_halign({id:e,...t},r){e==null||e.set_text_halign(t,r)}set_text_valign({id:e,...t},r){e==null||e.set_text_valign(t,r)}set_top_left_point({id:e,...t}){e==null||e.set_top_left_point(t)}set_bottom_right_point({id:e,...t}){e==null||e.set_bottom_right_point(t)}set_text_font_family({id:e,...t},r){e==null||e.set_text_font_family(t,r)}}class ns{constructor(e,t,r){R(this,"_id");R(this,"_variables");R(this,"_errorListener");this._variables=e,this._id=t,this._errorListener=r}copy(e){const t=`box_${e}_${this._variables.bar_index}`,r=this._getBox(),n=new ns(this._variables,t,this._errorListener);return r&&this._variables.box.add(t,{...r,id:t},n),n}delete(){this._variables.box.delete(this._id)}get_top(){const e=this._getBox();return e&&e.top}set_top({top:e}){const t=this._getBox();t&&(t.top=e)}get_left(){const e=this._getBox();return e&&e.left}set_left({left:e}){const t=this._getBox();t&&(t.left=e)}set_text({text:e}){const t=this._getBox();t&&(t.text=e)}get_right(){const e=this._getBox();return e&&e.right}set_right({right:e}){const t=this._getBox();t&&(t.right=e)}get_bottom(){const e=this._getBox();return e&&e.bottom}set_bottom({bottom:e}){const t=this._getBox();t&&(t.bottom=e)}set_extend({extend:e},t){const r=this._getBox();r&&(r.extend=e,this._paramVerfiy(e,t,"box.set_extend",Object.values(Ur),"extend"))}set_bgcolor({color:e}){const t=this._getBox();t&&(t.bgcolor=e,_t(t,["bgcolor"]))}set_lefttop({left:e,top:t}){const r=this._getBox();r&&(r.left=e,r.top=t)}set_text_size({text_size:e},t){const r=this._getBox();r&&(r.text_size=e,this._paramVerfiy(e,t,"box.set_text_size",Object.values(tr),"text_size"))}set_text_wrap({text_wrap:e},t){const r=this._getBox();r&&(r.text_wrap=e,this._paramVerfiy(e,t,"box.set_text_wrap",[We.wrapAuto,We.wrapNone],"text_wrap"))}set_text_color({text_color:e}){const t=this._getBox();t&&(t.text_color=e,_t(t,["text_color"]))}set_rightbottom({right:e,bottom:t}){const r=this._getBox();r&&(r.right=e,r.bottom=t)}set_text_halign({text_halign:e},t){const r=this._getBox();r&&(r.text_halign=e,this._paramVerfiy(e,t,"box.set_text_halign",[We.alignLeft,We.alignCenter,We.alignRight],"text_halign"))}set_text_valign({text_valign:e},t){const r=this._getBox();r&&(r.text_valign=e,this._paramVerfiy(e,t,"box.set_text_valign",[We.alignBottom,We.alignCenter,We.alignTop],"text_valign"))}set_top_left_point({point:e}){const t=this._getBox();if(t){const{index:r,price:n,time:i}=e||{};t.top=n,t.left=t.xloc===wt.bar_index?r:i}}set_border_color({color:e}){const t=this._getBox();t&&(t.border_color=e,_t(t,["border_color"]))}set_border_style({style:e},t){const r=this._getBox();r&&(r.border_style=e,this._paramVerfiy(e,t,"box.set_border_style",[Lt.styleDashed,Lt.styleDotted,Lt.styleSolid],"style"))}set_border_width({width:e}){const t=this._getBox();t&&(t.border_width=e)}set_bottom_right_point({point:e}){const t=this._getBox();if(t){const{index:r,price:n,time:i}=e||{};t.bottom=n,t.right=t.xloc===wt.bar_index?r:i}}set_text_font_family({text_font_family:e},t){const r=this._getBox();r&&(r.text_font_family=e,this._paramVerfiy(e,t,"box.set_text_font_family",Object.values(Zn),"text_font_family"))}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}_getBox(){return this._variables.box.get(this._id)}}class Hy{constructor(e,t){R(this,"_variables");R(this,"_errorListener");R(this,"_defaultTable",{position:pr.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=e,this._errorListener=t}table({x:e},t){return e||new Ua(this._variables,t,this._errorListener)}new(e,t){const r=`table_${t}_${this._variables.bar_index}`,{columns:n,rows:i}=e;_t(e,["text_color","bgcolor","border_color"]);const a=Array.from(Array(i),()=>Array.from(Array(n),()=>{})),l={...this._defaultTable,...e,cell:a,id:r},c=new Ua(this._variables,r,this._errorListener);return this._paramVerfiy(e.position,t,"table.new",Object.values(pr),"position"),t.startsWith("export")||this._variables.table.add(r,l,c),c}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}cell({table_id:e,...t}){e==null||e.cell(t)}cell_set_bgcolor({table_id:e,...t}){e==null||e.cell_set_bgcolor(t)}cell_set_height({table_id:e,...t}){e==null||e.cell_set_height(t)}cell_set_text({table_id:e,...t}){e==null||e.cell_set_text(t)}cell_set_text_color({table_id:e,...t}){e==null||e.cell_set_text_color(t)}cell_set_text_font_family({table_id:e,...t}){e==null||e.cell_set_text_font_family(t)}cell_set_text_halign({table_id:e,...t}){e==null||e.cell_set_text_halign(t)}cell_set_text_valign({table_id:e,...t}){e==null||e.cell_set_text_valign(t)}cell_set_text_size({table_id:e,...t}){e==null||e.cell_set_text_size(t)}cell_set_tooltip({table_id:e,...t}){e==null||e.cell_set_tooltip(t)}cell_set_width({table_id:e,...t}){e==null||e.cell_set_width(t)}clear({table_id:e,...t}){e==null||e.clear(t)}delete({table_id:e}){e==null||e.delete()}merge_cells({table_id:e,...t},r){e==null||e.merge_cells(t,r)}set_bgcolor({table_id:e,...t}){e==null||e.set_bgcolor(t)}set_border_color({table_id:e,...t}){e==null||e.set_border_color(t)}set_border_width({table_id:e,...t}){e==null||e.set_border_width(t)}set_frame_color({table_id:e,...t}){e==null||e.set_frame_color(t)}set_frame_width({table_id:e,...t}){e==null||e.set_frame_width(t)}set_position({table_id:e,...t},r){e==null||e.set_position(t,r)}}class Ua{constructor(e,t,r){R(this,"_id");R(this,"_variables");R(this,"_errorListener");R(this,"_defaultCell",{column:0,row:0,text:"",text_color:Ci.black,text_halign:We.alignCenter,text_valign:We.alignCenter,text_size:tr.normal});this._variables=e,this._id=t,this._errorListener=r}cell(e){const t={...this._defaultCell,...e},{column:r=0,row:n=0}=t,i=this._variables.table.get(this._id);if(i){const a=i.cell||[],l=a[n]||[];l[r]=t,a[n]=l,i.cell=a}}cell_set_bgcolor({column:e=0,row:t=0,bgcolor:r}){const n=this._getTableItem(e,t);n&&(n.bgcolor=r)}cell_set_height({column:e=0,row:t=0,height:r}){const n=this._getTableItem(e,t);n&&(n.height=r)}cell_set_text({column:e=0,row:t=0,text:r}){const n=this._getTableItem(e,t);n&&(n.text=r)}cell_set_text_color({column:e=0,row:t=0,text_color:r}){const n=this._getTableItem(e,t);n&&(n.text_color=r,_t(n,["text_color"]))}cell_set_text_font_family({column:e=0,row:t=0,text_font_family:r}){const n=this._getTableItem(e,t);n&&(n.text_font_family=r)}cell_set_text_halign({column:e=0,row:t=0,text_halign:r}){const n=this._getTableItem(e,t);n&&(n.text_halign=r)}cell_set_text_valign({column:e=0,row:t=0,text_valign:r}){const n=this._getTableItem(e,t);n&&(n.text_valign=r)}cell_set_text_size({column:e=0,row:t=0,text_size:r}){const n=this._getTableItem(e,t);n&&(n.text_size=r)}cell_set_tooltip({column:e=0,row:t=0,tooltip:r}){const n=this._getTableItem(e,t);n&&(n.tooltip=r)}cell_set_width({column:e=0,row:t=0,width:r}){const n=this._getTableItem(e,t);n&&(n.width=r)}clear({start_column:e=0,start_row:t=0,end_column:r=0,end_row:n=0}){const i=this._variables.table.get(this._id);if(i){const a=i.cell;if(a)for(let l=t;l<=n;l++)for(let c=e;c<=r;c++){const p=a[l];p&&(p[c]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:e=0,start_row:t=0,end_column:r=0,end_row:n=0},i){if(e>r||t>n){this._errorListener.addError(ut.mergeCellErr,i,ze.Error);return}const a=this._variables.table.get(this._id);if(!a)return;const l=a.merge_cells||[];l.push({start_column:e,start_row:t,end_column:r,end_row:n}),a.merge_cells=l}set_bgcolor({bgcolor:e}){const t=this._variables.table.get(this._id);t&&(t.bgcolor=e,_t(t,["bgcolor"]))}set_border_color({border_color:e}){const t=this._variables.table.get(this._id);t&&(t.border_color=e,_t(t,["border_color"]))}set_border_width({border_width:e}){const t=this._variables.table.get(this._id);t&&(t.border_width=e)}set_frame_color({frame_color:e}){const t=this._variables.table.get(this._id);t&&(t.frame_color=e)}set_frame_width({frame_width:e}){const t=this._variables.table.get(this._id);t&&(t.frame_width=e)}set_position({position:e},t){const r=this._variables.table.get(this._id);r&&(r.position=e,this._paramVerfiy(e,t,"table.set_position",Object.values(pr),"position"))}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}_getTableItem(e,t){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[t][e]:void 0}}}class Jy{constructor(e){R(this,"_strategy");this._strategy=e}commission({trade_num:e}){return this._verifyTradeNum(e)&&this._strategy.historyOrders[e].commission||0}entry_bar_index({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].in_index}entry_comment({trade_num:e}){if(!this._verifyTradeNum(e))return"";const{comment:t,id:r}=this._strategy.historyOrders[e];return t||r}entry_id({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].id:""}entry_price({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].in_price}entry_time({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].in_time}exit_bar_index({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].out_index}exit_comment({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].out_comment:""}exit_id({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].out_id:""}exit_price({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].out_price}exit_time({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.historyOrders[e].out_time}max_drawdown({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].trading_loss:0}max_drawdown_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].trading_loss_percent:0}max_runup({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].max_profit:0}max_runup_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].max_profit_percent:0}profit({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].profit:0}profit_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.historyOrders[e].profit_percent:0}size({trade_num:e}){if(!this._verifyTradeNum(e))return 0;const{out_qty:t=0,direction:r}=this._strategy.historyOrders[e];return r===gt.long?t:-t}_verifyTradeNum(e){if(typeof e!="number"||e<0)return!1;const t=this._strategy.historyOrders.length;return!(e>=t)}}class Xy{constructor(e){R(this,"_strategy");this._strategy=e}commission({trade_num:e}){if(!this._verifyTradeNum(e))return 0;const{qty:t=0,original_qty:r=0,commission:n=0}=this._strategy.orders[e];return n*t/r}entry_bar_index({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.orders[e].in_index}entry_comment({trade_num:e}){if(!this._verifyTradeNum(e))return"";const{comment:t,id:r}=this._strategy.orders[e];return t||r}entry_id({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].id:""}entry_price({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.orders[e].in_price}entry_time({trade_num:e}){if(this._verifyTradeNum(e))return this._strategy.orders[e].in_time}max_drawdown({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].trading_loss:0}max_drawdown_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].trading_loss_percent:0}max_runup({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].max_profit:0}max_runup_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].max_profit_percent:0}profit({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].profit:0}profit_percent({trade_num:e}){return this._verifyTradeNum(e)?this._strategy.orders[e].profit_percent:0}size({trade_num:e}){if(!this._verifyTradeNum(e))return 0;const{qty:t=0,direction:r}=this._strategy.orders[e];return r===gt.long?t:-t}_verifyTradeNum(e){if(typeof e!="number"||e<0)return!1;const t=this._strategy.orders.length;return!(e>=t)}}class Qy{constructor(e,t){R(this,"_strategy");R(this,"_errorListener");this._strategy=e,this._errorListener=t}allow_entry_in({value:e},t){this._paramVerfiy(e,t,"strategy.risk.allow_entry_in",Object.values(gt),"value"),this._strategy.updateRisk({allow_entry_in:e})}max_cons_loss_days({count:e}){this._strategy.updateRisk({max_cons_loss_days:e})}max_drawdown({value:e,type:t},r){this._paramVerfiy(t,r,"strategy.risk.max_drawdown",[Ot.percentOfEquity,Ot.cash],"type"),t===Ot.percentOfEquity&&(e=e>100?100:e),this._strategy.updateRisk({max_drawdown:e,max_drawdown_type:t})}max_intraday_filled_orders({count:e}){this._strategy.updateRisk({max_intraday_filled_orders:e})}max_intraday_loss({value:e,type:t},r){this._paramVerfiy(t,r,"strategy.risk.max_intraday_loss",[Ot.percentOfEquity,Ot.cash],"type"),t===Ot.percentOfEquity&&(e=e>100?100:e),this._strategy.updateRisk({max_intraday_loss:e,max_intraday_loss_type:t})}max_position_size({contracts:e}){this._strategy.updateRisk({max_position_size:e})}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}}let ew=class{constructor(e,t,r,n){R(this,"_variables");R(this,"_options");R(this,"_totalChangeCapital");R(this,"_historyOrder");R(this,"_orders");R(this,"_pendingOrders");R(this,"_mintick");R(this,"_funcOptions");R(this,"_pendingCloseOrders");R(this,"_errorListener");R(this,"_risk");R(this,"_opentrades");R(this,"_closedtrades");R(this,"_riskNamespace");this._variables=e,this._errorListener=n,this._options={overlay:!1,format:Ke.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:Ot.fixed,default_qty_value:1,initial_capital:1e6,currency:Xf.NONE,slippage:0,commission_type:Fr.percent,commission_value:0,process_orders_on_close:!1,close_entries_rule:"FIFO",margin_long:0,margin_short:0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,max_polylines_count:50},this._funcOptions=t,this._totalChangeCapital=0,this._orders=[],this._pendingOrders=[],this._historyOrder=[],this._pendingCloseOrders=[],this._mintick=r,this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),this._variables.strategy.updateStrategyOptions(this._options),this._risk={intradayOrders:0},this._opentrades=new Xy(this),this._closedtrades=new Jy(this),this._riskNamespace=new Qy(this,n)}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _orderProfit(){return this._orders.reduce((e,t)=>e+(t.profit||0),0)}get _freezeCapital(){const{close:e}=this._variables;return this._orders.reduce((t,r)=>t+e*(r.qty||0),0)}get opentrades(){return this._opentrades}get closedtrades(){return this._closedtrades}get risk(){return this._riskNamespace}updateOptions(e){Object.assign(this._options,e),this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),!this._options.process_orders_on_close&&this._calcLiquidate()}updateRisk(e){Object.assign(this._risk,e)}endExecution(){this._calcProfitAndLoss(),this._variables.strategy.update(),this._maxDrawdownVerify(),this._maxIntradayLoss(),this._pendingCloseOrderHandle(),this._options.process_orders_on_close&&this._calcLiquidate()}_maxIntradayLoss(){var g;const{max_intraday_loss:e,max_intraday_loss_type:t,isDisabledOpen:r}=this._risk;if(e===void 0||!t||r)return;const{high:n,low:i,time_tradingday:a,time:l,strategy:{netprofit:c,initial_capital:p}}=this._variables;let{preNetprofit:h=0}=this._risk;l===a&&(h=c,this._risk.preNetprofit=c,this._risk.isTemporaryBan=!1);let f=h-c;f+=this._orders.reduce((y,m)=>{const{in_price:w,direction:v,qty:E=0,commission:b=0,original_qty:N=0}=m,x=v===gt.long?1:-1,F=(n-w)*E,M=(i-w)*E,S=x===1?-M:F;return y+S+E/N*b},0);let d=!1;switch(t){case Ot.cash:d=e<f;break;case Ot.percentOfEquity:const y=f/(p+c)*100;d=e<y;break}if(d){this._risk.isTemporaryBan=!0;const y=(g=this._orders[0])==null?void 0:g.direction;this._closeOrders(this._orders,y===gt.long?i:n,"Close Position (Max intraday Loss)"),this._pendingOrders=[]}}_maxIntradayFilledOrdersVerify(){const{max_intraday_filled_orders:e,intradayOrders:t=0,isDisabledOpen:r}=this._risk;if(e===void 0||r)return;const{time:n,time_tradingday:i,open:a}=this._variables;n===i&&(this._risk.intradayOrders=0,this._risk.isTemporaryBan=!1),e<=t&&(this._risk.isTemporaryBan=!0,this._closeOrders(this._orders,a,"Close Position (Max number of filled orders in one day)"),this._pendingOrders=[])}_maxConsLossDaysVerify(){const{max_cons_loss_days:e,lossDays:t=0,isDisabledOpen:r,totalProfit:n=0}=this._risk;if(e===void 0||r)return;const{time:i,time_tradingday:a,strategy:l,open:c}=this._variables;let p=t;if(i===a){const h=l.netprofit+l.openprofit;h<n?p=0:p++,Object.assign(this._risk,{lossDays:p,totalProfit:h})}e<=p&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){var n;const{max_drawdown:e,max_drawdown_type:t,isDisabledOpen:r}=this._risk;if(!r&&e!==void 0&&t){const{max_drawdown:i,max_drawdown_percent:a}=this._variables.strategy;let l=!1;switch(t){case Ot.percentOfEquity:l=a<i;break;case Ot.cash:l=e<i;break}if(l){const{high:c,low:p}=this._variables,h=(n=this._orders[0])==null?void 0:n.direction;this._riskTouchOff(h===gt.long?c:p,"Close Position (Max Drawdown)")}}}_riskTouchOff(e,t){this._risk.isDisabledOpen=!0,this._closeOrders(this._orders,e,t),this._pendingOrders=[]}strategy(e,t){this._variables.bar_index||(this._paramVerfiy(e.format,t,"strategy",[Ke.inherit,Ke.price,Ke.percent,Ke.volume],"format"),this._paramVerfiy(e.default_qty_type,t,"strategy",Object.values(Ot),"default_qty_type"),this._paramVerfiy(e.commission_type,t,"strategy",Object.values(Fr),"commission_type"),Object.assign(this._options,e),this._variables.updateMaxLength(e),Object.assign(this._funcOptions,{strategy:this._options,scriptType:"strategy"}))}order(e,t){this._risk.isDisabledOpen||(this._paramVerfiy(e.oca_type,t,"strategy.order",Object.values(un),"oca_type"),this._orderHandle(e))}entry(e,t){this._risk.isDisabledOpen||(this._paramVerfiy(e.oca_type,t,"strategy.entry",Object.values(un),"oca_type"),this._entryHandle(e))}close(e){if(!this._orders.length)return;const{immediately:t}=e;t||this._options.process_orders_on_close?this._pendingCloseOrders.push({...e,place_order_type:"close"}):this._pendingOrders.push({...e,place_order_type:"close"})}close_all(e){if(typeof e=="string"&&(e={}),!this._orders.length)return;const{immediately:t}=e;t||this._options.process_orders_on_close?this._pendingCloseOrders.push({...e,place_order_type:"close_all"}):this._pendingOrders.push({...e,place_order_type:"close_all"})}cancel({id:e}){this._pendingOrders=this._pendingOrders.filter(t=>!(t.id===e&&t.place_order_type!=="close"))}cancel_all(){this._pendingOrders=this._pendingOrders.filter(e=>e.place_order_type==="close_all")}exit(e,t){this._exit(e,t)}convert_to_account({value:e}){return e}convert_to_symbol({value:e}){return e}default_entry_qty({fill_price:e}){return e?this._calcDefaultQty(e):0}_calcDefaultQty(e){const{default_qty_type:t=Ot.fixed,default_qty_value:r=1,initial_capital:n}=this._options;switch(t){case Ot.fixed:return r;case Ot.cash:return r/e;case Ot.percentOfEquity:return(n+this._orderProfit+this._totalChangeCapital)*r/100/e}}_getCapital(e,t){const{margin_long:r=0,margin_short:n=0}=this._options;return r<100&&r>0&&e===1?t=t*100/r:n<=100&&n>0&&e===-1&&(t=t*100/n),t}_calcProfitAndLoss(){const{high:e,low:t,close:r}=this._variables;for(const n of this._orders){const{in_price:i,qty:a=0,direction:l}=n,c=l===gt.long?1:-1,p=(r-i)*c*a,h=(e-i)*a,f=(t-i)*a,d=c===1?h:-f,g=c===1?-f:h;this._calcOrderPercent(n,p,d,g)}}_calcOrderPercent(e,t,r,n){const{commission_value:i}=this._options,{close:a}=this._variables,{original_qty:l=0,qty:c=0,in_price:p,max_profit:h=0,trading_loss:f=0}=e;let{commission:d=0}=e;const g=p*c;if(i){const y=this._getCommission(a,c);t=t-y,d=d*c/l,r-=d,n+=d}r=Math.max(r,h),n=Math.min(n,f),t=t-d,Object.assign(e,{profit:t,total_profit:this._totalChangeCapital+t,total_profit_percent:t/this._options.initial_capital*100,max_profit:r,trading_loss:n,profit_percent:t/g*100,max_profit_percent:r/g*100,trading_loss_percent:n/g*100})}_calcLiquidate(){if(!this._orders.length)return;const{high:e,low:t}=this._variables,{initial_capital:r,margin_long:n=0,margin_short:i=0,commission_value:a=0}=this._options,l=this._orders[0].direction===gt.long?1:-1,c=l===1?t:e,p=(l===1?n:i)/100;if(p<=0)return;const[h,f,d]=this._orders.reduce((v,E)=>{let[b,N,x]=v;const{in_price:F,qty:M=0,original_qty:S=0,commission:I=0}=E,C=F*M,B=c*M;if(b+=C,N+=B,a){const L=this._getCommission(c,M);x+=L+M/S*I}return[b,N,x]},[0,0,0]),g=l*(f-h),m=r+this._totalChangeCapital+g-d-f*p;if(m>=0)return;const w=Math.trunc(m/p/c)*4;this._marginCallOrders(c,w,"Margin Call")}_marginCallOrders(e,t,r){const{close_entries_rule:n="FIFO"}=this._options;if(n==="FIFO"){this._processOrders(this._orders,e,t*this._orders.length,r,r);return}for(const i of this.orders)this._processOrder(i,e,t,r,r);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders)}_orderHandle(e){const{process_orders_on_close:t,slippage:r=0}=this._options,{orders:n,isMarketPrice:i,quantities:a,close:l,price:c,activePrice:p}=this._orderArgsParse(e),h=e.direction===gt.long?1:-1;if(a<=0)return;let f=a;if(i&&t){if(n.length){const m=this._processOrders(n,l,f,e.id,e.comment);if(m<=0)return;f=m}const g=l+h*r*this._mintick;if(!this._judgeCapitalEnough(f,g,h))return;this._ocaGroupVerify(f,e.oca_name,e.oca_type),this._calcCurrentOrder({...e,in_price:g,in_index:this._variables.bar_index,in_time:this._variables.time,qty:f,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,h)&&this._addPendingOrders(e,c,f,i,p)}_judgeCapitalEnough(e,t,r){if(e<=0)return!1;const{margin_long:n=0,margin_short:i=0}=this._options;if((n===0||n===100)&&r===1||i===0&&r===-1)return!0;const l=this._getCapital(r,this._options.initial_capital+this._orderProfit+this._totalChangeCapital)-this._freezeCapital;return e*t<=l}_ocaGroupVerify(e,t,r){if(!t||!r||r===un.none)return!1;let n=!1;switch(r){case un.cancel:this._pendingOrders=this._pendingOrders.filter(i=>{if(i.oca_name===t)i.isCancel=!0,n=!0;else return!0});break;case un.reduce:this._pendingOrders=this._pendingOrders.filter(i=>{const{qty:a=0,oca_name:l}=i;if(t===l){const c=a-e;return n=!0,c<=0?(i.isCancel=!0,!1):(i.qty=c,!0)}else return!0});break}return n}_processOrders(e,t,r,n,i){let a=r;for(const l of e)if(a=this._processOrder(l,t,a,n,i),a<=0)break;return this._orders=this._orders.filter(l=>!l.isDeal),this._variables.strategy.updateOrders(this._orders),a}_addPendingOrders(e,t,r,n,i){const a=this._pendingOrders.find(l=>l.id===e.id&&!l.isMarketPrice);if(a)Object.assign(a,{...e,in_price:t,isMarketPrice:n,qty:r,active_price:i});else{const l={...e,in_price:t,isMarketPrice:n,qty:r,active_price:i,place_order_type:"order"};this._pendingOrders.push(l)}}_orderArgsParse(e){const{direction:t,qty:r,stop:n}=e;let i=e.limit||0;const{close:a}=this._variables;let l=a,c=!1,p;const h=t===gt.long?1:-1,f=n&&(n-a)*h>0,{backtest_fill_limits_assumption:d=0}=this._options;d>0&&i&&(i-=d*this._mintick*h);const g=i&&(i-a)*h<0;f&&g?(p=n,l=i):f?l=n:g?l=i:c=!0;const y=r||this._calcDefaultQty(l)||1;return{orders:this._orders.filter(w=>w.direction!==t),isMarketPrice:c,activePrice:p,quantities:y,close:a,price:l}}_entryHandle(e){const{process_orders_on_close:t}=this._options,{orders:r,isMarketPrice:n,quantities:i,close:a,price:l,activePrice:c}=this._orderArgsParse(e);if(i<=0)return;if(r.length&&n&&t){this._entryOrder(r,a,i,e);return}this._judgeCapitalEnough(i,a,e.direction===gt.long?1:-1)&&this._addPendingEntry(e,l,i,n,c)}_entryOrder(e,t,r,n){const{time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{oca_name:c,oca_type:p,direction:h,comment:f,isMarketPrice:d,id:g}=n,y=h===gt.long?1:-1;if(this._closeOrders(e,t,g,f),r=this._getAvailablePositionSize(r,h),r<=0)return;t=t+l*this._mintick*y;const m={...n,in_price:t,original_qty:r,qty:r,in_index:a,in_time:i,place_order_type:"entry"};if(d){this._calcCurrentOrder(m);return}const{pendingOrders:w,orders:v}=this._getEntryOrders(h),E=w.length+v.length;E&&E>=(this._options.pyramiding||0)||!this._judgeCapitalEnough(r,t,y)||(this._ocaGroupVerify(r,c,p),this._calcCurrentOrder(m))}_getAvailablePositionSize(e,t){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==gt.all&&n!==t)return 0;if(r===void 0)return e;const i=this._orders.reduce((a,l)=>a+(l.qty||0),0);return i?i+e>r?0:e:e>r?e-r:0}_getEntryOrders(e){const t=this._pendingOrders.filter(n=>["entry","order"].includes(n.place_order_type)&&n.direction===e),r=this._orders.filter(n=>n.direction===e);return{pendingOrders:t,orders:r}}_addPendingEntry(e,t,r,n,i){if(r=this._getAvailablePositionSize(r,e.direction),r<=0)return;const{pendingOrders:a,orders:l}=this._getEntryOrders(e.direction),c=a.length+l.length,p=a.find(h=>h.id===e.id&&h.place_order_type==="entry");if(p)Object.assign(p,{...e,in_price:t,isMarketPrice:n,qty:r,active_price:i});else if(!c||c<(this._options.pyramiding||1)){const h={...e,in_price:t,isMarketPrice:n,qty:r,active_price:i,place_order_type:"entry"};this._pendingOrders.push(h)}}_closeAllOrders(e,t){const{comment:r}=e,{bar_index:n}=this._variables,i=this._orders.filter(a=>a.in_index!==n);i.length&&(this._closeOrders(i,t,"Close position order",r),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(e,t,r,n){for(const i of e)this._closeOrder(i,t,r,n);this._orders=this._orders.filter(i=>!i.isDeal),this._variables.strategy.updateOrders(this._orders)}_closeOrder(e,t,r,n){const{time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{in_price:c,qty:p=0,direction:h}=e,f=h===gt.long?1:-1;t=t-f*l*this._mintick,e.isDeal=!0;const d=(t-c)*f*p,g={...e,out_price:t,out_id:r,out_index:a,out_time:i,out_comment:n,out_qty:p,profit:d};this._calcPercent(g),this._risk.intradayOrders+=1,this._historyOrder.push(g),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_ordersHandle(){const e=this._orders.filter(a=>a.place_order_type==="exit"&&!a.hasExit);if(!e.length)return;const{open:t,low:r,high:n,close:i}=this._variables;for(const a of e){const{stop:l,limit:c,trail_stop_price:p,isMarketPriceLimit:h,isMarketPriceStop:f,direction:d,id:g,out_comment:y,active_price:m,trail_offset:w=0,out_qty:v,comment_loss:E,comment_profit:b,comment_trailing:N}=a;let x=p;const F=d===gt.long?1:-1;let M,S=y;if(h||f?M=t:(c&&r<=c&&n>=c&&(S=b||y,M=c),l&&r<=l&&n>=l&&(M=x?(l-x)*F>0?l:x:l,S=(x===M?N:E)||y)),M)this._processExitOnClose(a,M,{from_entry:g,comment:S,qty:v});else{let I=!1;if(m&&m<=n&&m>=r&&(x=m-w*F*this._mintick,(x-i)*F>=0&&(a.isMarketPriceStop=!0,this._options.process_orders_on_close&&(M=x)),I=!0,a.trail_stop_price=x),x)if((x-t)*F>=0&&!I)M=x;else{const C=(F===1?n:r)-w*F*this._mintick;F===1?x<t&&x>=r&&C>x&&C<i?M=x:C>x?(x=C,C>=i&&(M=C)):x<=n&&r<=x&&(M=x):x>t&&x<=n&&C<x&&C>i?M=x:C<x?(x=C,C<=i&&(M=C)):x<=n&&r<=x&&(M=x),a.trail_stop_price=x}M&&this._processExitOnClose(a,M,{from_entry:g,comment:N||y,qty:v})}}}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const e=[],t=this._pendingOrders.filter(n=>n.place_order_type==="exit"),r=this._pendingOrders.filter(n=>["close","close_all"].includes(n.place_order_type||""));for(const n of r)switch(n.place_order_type){case"close":this._closeOrderHandle(n);break;case"close_all":this._closeAllOrders(n,this._variables.open);break}for(const n of this._pendingOrders){const{isCancel:i,place_order_type:a}=n;if(i)continue;let l;switch(a){case"entry":l=this._entryOrderHandle(n);break;case"order":l=this._orderOrderHandle(n);break}l&&e.push(l)}for(const n of t){const i=this._exitOrderHandle(n);i&&e.push(i)}this._pendingOrders=e}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const e=this._pendingCloseOrders.filter(n=>n.place_order_type==="exit"),t=this._pendingCloseOrders.filter(n=>["close","close_all"].includes(n.place_order_type||"")),{close:r}=this._variables;for(const n of t)switch(n.place_order_type){case"close":this._closeOrderHandle(n,!0);break;case"close_all":this._closeAllOrders(n,r);break}for(const n of e){const{from_entry:i}=n,a=this._orders.filter(l=>!i||l.id===i&&(l.isMarketPriceLimit||l.isMarketPriceStop));for(const l of a)this._processExitOnClose(l,l.limit||l.stop||l.trail_stop_price||r,n)}this._pendingCloseOrders=[]}_entryOrderHandle(e){const{open:t,low:r,high:n}=this._variables,{isMarketPrice:i,qty:a=0,in_price:l,direction:c,active_price:p}=e;if(p&&n>=p&&r<=p)return delete e.active_price,e;let h=l;if(i&&(h=t),h<=n&&h>=r){const f=this._orders.filter(d=>d.direction!==c);this._entryOrder(f,h,a,e)}else return e}_orderOrderHandle(e){const{open:t,low:r,high:n,time:i,bar_index:a}=this._variables,{slippage:l=0}=this._options,{isMarketPrice:c,qty:p=0,in_price:h,direction:f,comment:d,oca_name:g,oca_type:y,active_price:m,id:w}=e;if(m&&n>=m&&r<=m)return delete e.active_price,e;let v=h,E=p;if(c&&(v=t),v<=n&&v>=r){const b=this._orders.filter(x=>x.direction!==f);if(b.length&&(E=this._processOrders(b,v,p,w,d),E<=0))return;const N=f===gt.long?1:-1;this._ocaGroupVerify(E,g,y),this._calcCurrentOrder({...e,in_price:v+N*l*this._mintick,in_index:a,in_time:i,qty:E});return}else return e}_closeOrderHandle(e,t){const{id:r,qty:n,qty_percent:i=100,comment:a}=e,{bar_index:l}=this._variables,c=this._orders.filter(g=>g.id===r&&g.in_index!==l&&(!g.close_qty||g.close_qty<(g.qty||0)));if(!c.length)return;let p=0;if(n?p=n:(p=c.reduce((g,y)=>g+(y.qty||0),p),p=i/100*p),p<=0)return;const{open:h,close:f}=this._variables;let d=p;for(const g of c){const{qty:y=0}=g;d<y?g.close_qty=d:(g.close_qty=y,d-=y)}this._processOrders(this._options.close_entries_rule==="ANY"?c:this._orders,t?f:h,p,`Close entry(s) order ${r}`,a)}_exitOrderHandle(e){const{from_entry:t}=e,r=this._orders.filter(n=>(!t||t===n.id)&&!n.hasExit);if(!(r.length&&!this._ordersToExit(r,e)))return e}_exit(e,t){const{profit:r,loss:n,stop:i,limit:a,trail_offset:l,trail_price:c,trail_points:p,from_entry:h="",id:f}=e;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(i)&&this._isNaN(a)&&(this._isNaN(l)||this._isNaN(p)&&this._isNaN(c))){this._errorListener.addError(ut.strategyExitErr,t,ze.Error);return}const d={...e,place_order_type:"exit"},g=this._orders.filter(w=>(!h||h===w.id)&&!w.hasExit),y=this._pendingOrders.filter(w=>!h||h===w.id);if(g.length){if(!this._ordersToExit(g,d))return}else if(!y.length)return;const m=this._pendingOrders.find(w=>w.id===f);m?Object.assign(m,{...e}):this._pendingOrders.push(d)}_ordersToExit(e,t){const{qty:r,qty_percent:n=100,id:i,comment:a,comment_loss:l,comment_profit:c,comment_trailing:p}=t;let h=r,f=!1;t.comment=a||i;for(const d of e){const{qty:g=0}=d,y=d.direction===gt.long?1:-1;h=r?r>=g?g:r:n/100*g,d.out_qty=h,h<g&&(f=!0),Object.assign(d,{out_comment:a||i,comment_loss:l,comment_profit:c,comment_trailing:p}),!(this._stopProfit(d,y,{...t,qty:h})||this._stopLoss(d,y,{...t,qty:h})||this._trailStopLoss(d,y,{...t,qty:h}))&&(d.place_order_type="exit")}return f}_addExitPendingCloseOrders(e){e.place_order_type="exit";const t=this._pendingCloseOrders.find(r=>r.id===e.id);t?Object.assign(t,{...e}):this._pendingCloseOrders.push(e)}_stopProfit(e,t,r){const{limit:n,profit:i,comment_profit:a,comment:l}=r;let c=n;const{close:p}=this._variables,{in_price:h}=e,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=h+t*i*this._mintick),e.limit=c,c&&(c-p)*t<=0&&(e.isMarketPriceLimit=!0,r.comment=a||l,Object.assign(e,{out_comment:r.comment}),c=p,f))return this._addExitPendingCloseOrders(r),!0}_stopLoss(e,t,r){const{stop:n,loss:i,comment_loss:a,comment:l}=r;let c=n;const{close:p}=this._variables,{in_price:h}=e,{process_orders_on_close:f}=this._options;if(!this._isNaN(i)&&this._isNaN(n)&&(c=h-t*i*this._mintick),e.stop=c,c&&(c-p)*t>=0&&(e.isMarketPriceStop=!0,r.comment=a||l,Object.assign(e,{out_comment:r.comment}),c=p,f))return this._addExitPendingCloseOrders(r),!0}_trailStopLoss(e,t,r){const{trail_offset:n,trail_price:i,trail_points:a,comment_trailing:l,comment:c}=r;if(!this._isNaN(n)){const{close:p}=this._variables,{in_price:h}=e,{process_orders_on_close:f}=this._options;let d;if(this._isNaN(i)?this._isNaN(a)||(d=h+a*t*this._mintick):d=i,e.trail_offset=n,d&&(d-p)*t<=0){const g=p-n*t*this._mintick;if((g-p)*t>=0&&(e.trail_stop_price=p,e.isMarketPriceStop=!0,r.comment=l||c,Object.assign(e,{out_comment:r.comment}),f))return this._addExitPendingCloseOrders(r),!0;e.trail_stop_price=g}e.active_price=d}}_processExitOnClose(e,t,r){const{qty:n=0,comment:i,id:a}=r,{close_entries_rule:l="FIFO"}=this._options;if(l==="FIFO"){const c=this._processExitOrders(this._orders,t,n,a,i);c&&!c.hasExit?(c.hasExit=!0,Object.assign(e,{trail_stop_price:c.trail_stop_price,stop:c.stop,limit:c.limit,trail_offset:c.trail_offset,active_price:c.active_price})):c&&(e.hasExit=!0)}else e.hasExit=!0,this._processOrders([e],t,n,a,i)}_processExitOrders(e,t,r,n,i){let a=r,l;for(const c of e)if(l=c,a=this._processOrder(c,t,a,n,i),a<=0||!c.hasExit)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),l}_processOrder(e,t,r,n,i){const{time:a,bar_index:l}=this._variables,{slippage:c=0}=this._options,{in_price:p,qty:h=0,max_profit:f=0,trading_loss:d=0,direction:g,commission:y=0,original_qty:m=0}=e,w=g===gt.long?1:-1;if(t=t-w*c*this._mintick,r<h){const v=h-r,E=(t-p)*w*r,b=f/h*r,N=d/h*r;this._calcPercent({...e,out_price:t,out_id:n,out_index:l,out_time:a,out_comment:i,profit:E,out_qty:r,max_profit:b,trading_loss:N});const x=(t-p)*w*v-y*v/m;Object.assign(e,{qty:v,profit:x,max_profit:f-b,trading_loss:d-N,total_profit:this._totalChangeCapital+x}),r=0}else{e.isDeal=!0;const v=(t-p)*w*h;this._calcPercent({...e,out_price:t,out_id:n,out_index:l,out_time:a,out_comment:i,out_qty:h,profit:v}),r-=h}return r}_calcPercent(e){const{commission_value:t}=this._options,{in_price:r,out_qty:n=0,out_price:i=0,original_qty:a=0}=e;let{profit:l=0,max_profit:c=0,trading_loss:p=0,commission:h=0}=e;c=c<0?0:c;const f=r*n;if(this._totalChangeCapital+=l,t){const d=this._getCommission(i,n);this._totalChangeCapital-=d,h=h*n/a+d,l=l-h,Object.assign(e,{commission:h,profit:l,max_profit:c})}Object.assign(e,{total_profit:this._totalChangeCapital,total_profit_percent:l/this._options.initial_capital*100,profit_percent:l/f*100,max_profit_percent:c/f*100,trading_loss_percent:p/f*100}),this._risk.intradayOrders+=1,this._historyOrder.push(e),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_getCommission(e,t){const{commission_value:r=0,commission_type:n}=this._options,i=e*t;let a=0;switch(n){case Fr.percent:a=i*r/100;break;case Fr.cashPerContract:a=t*r;break;case Fr.cashPerOrder:a=r;break}return a}_calcCurrentOrder(e){const{commission_value:t}=this._options,{in_price:r,qty:n=0,max_profit:i=0,trading_loss:a=0}=e;let{profit:l=0}=e;const c=r*n;if(t){const p=this._getCommission(r,n);this._totalChangeCapital-=p,l=l-p,Object.assign(e,{commission:p,profit:l,total_profit:this._totalChangeCapital})}Object.assign(e,{original_qty:n,total_profit_percent:l/this._options.initial_capital*100,profit_percent:l/c*100,max_profit_percent:i/c*100,trading_loss_percent:a/c*100}),this._risk.intradayOrders+=1,this._orders.push(e),this._variables.strategy.updateOrders(this._orders)}_isNaN(e){return e===void 0||isNaN(e)}_paramVerfiy(e="",t,r,n,i){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}};var rh={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(Ve,function(){return function(t,r,n){r.prototype.isBetween=function(i,a,l,c){var p=n(i),h=n(a),f=(c=c||"()")[0]==="(",d=c[1]===")";return(f?this.isAfter(p,l):!this.isBefore(p,l))&&(d?this.isBefore(h,l):!this.isAfter(h,l))||(f?this.isBefore(p,l):!this.isAfter(p,l))&&(d?this.isAfter(h,l):!this.isBefore(h,l))}}})})(rh);var tw=rh.exports,rw=Ge(tw),nh={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(Ve,function(){return function(t,r,n){var i=r.prototype,a=function(d){var g,y=d.date,m=d.utc,w={};if(!((g=y)===null||g instanceof Date||g instanceof Array||i.$utils().u(g)||g.constructor.name!=="Object")){if(!Object.keys(y).length)return new Date;var v=m?n.utc():n();Object.keys(y).forEach(function(I){var C,B;w[C=I,B=i.$utils().p(C),B==="date"?"day":B]=y[I]});var E=w.day||(w.year||w.month>=0?1:v.date()),b=w.year||v.year(),N=w.month>=0?w.month:w.year||w.day?0:v.month(),x=w.hour||0,F=w.minute||0,M=w.second||0,S=w.millisecond||0;return m?new Date(Date.UTC(b,N,E,x,F,M,S)):new Date(b,N,E,x,F,M,S)}return y},l=i.parse;i.parse=function(d){d.date=a.bind(this)(d),l.bind(this)(d)};var c=i.set,p=i.add,h=i.subtract,f=function(d,g,y,m){m===void 0&&(m=1);var w=Object.keys(g),v=this;return w.forEach(function(E){v=d.bind(v)(g[E]*m,E)}),v};i.set=function(d,g){return g=g===void 0?d:g,d.constructor.name==="Object"?f.bind(this)(function(y,m){return c.bind(this)(m,y)},g,d):c.bind(this)(d,g)},i.add=function(d,g){return d.constructor.name==="Object"?f.bind(this)(p,d,g):p.bind(this)(d,g)},i.subtract=function(d,g){return d.constructor.name==="Object"?f.bind(this)(p,d,g,-1):h.bind(this)(d,g)}}})})(nh);var nw=nh.exports,iw=Ge(nw),ih={exports:{}};(function(s,e){(function(t,r){s.exports=r()})(Ve,function(){var t,r,n=1e3,i=6e4,a=36e5,l=864e5,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p=31536e6,h=2628e6,f=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,d={years:p,months:h,days:l,hours:a,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},g=function(F){return F instanceof N},y=function(F,M,S){return new N(F,S,M.$l)},m=function(F){return r.p(F)+"s"},w=function(F){return F<0},v=function(F){return w(F)?Math.ceil(F):Math.floor(F)},E=function(F){return Math.abs(F)},b=function(F,M){return F?w(F)?{negative:!0,format:""+E(F)+M}:{negative:!1,format:""+F+M}:{negative:!1,format:""}},N=function(){function F(S,I,C){var B=this;if(this.$d={},this.$l=C,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),I)return y(S*d[m(I)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(k){B.$d[m(k)]=S[k]}),this.calMilliseconds(),this;if(typeof S=="string"){var L=S.match(f);if(L){var U=L.slice(2).map(function(k){return k!=null?Number(k):0});return this.$d.years=U[0],this.$d.months=U[1],this.$d.weeks=U[2],this.$d.days=U[3],this.$d.hours=U[4],this.$d.minutes=U[5],this.$d.seconds=U[6],this.calMilliseconds(),this}}return this}var M=F.prototype;return M.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(I,C){return I+(S.$d[C]||0)*d[C]},0)},M.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/p),S%=p,this.$d.months=v(S/h),S%=h,this.$d.days=v(S/l),S%=l,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/i),S%=i,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},M.toISOString=function(){var S=b(this.$d.years,"Y"),I=b(this.$d.months,"M"),C=+this.$d.days||0;this.$d.weeks&&(C+=7*this.$d.weeks);var B=b(C,"D"),L=b(this.$d.hours,"H"),U=b(this.$d.minutes,"M"),k=this.$d.seconds||0;this.$d.milliseconds&&(k+=this.$d.milliseconds/1e3,k=Math.round(1e3*k)/1e3);var W=b(k,"S"),z=S.negative||I.negative||B.negative||L.negative||U.negative||W.negative,K=L.format||U.format||W.format?"T":"",Z=(z?"-":"")+"P"+S.format+I.format+B.format+K+L.format+U.format+W.format;return Z==="P"||Z==="-P"?"P0D":Z},M.toJSON=function(){return this.toISOString()},M.format=function(S){var I=S||"YYYY-MM-DDTHH:mm:ss",C={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return I.replace(c,function(B,L){return L||String(C[B])})},M.as=function(S){return this.$ms/d[m(S)]},M.get=function(S){var I=this.$ms,C=m(S);return C==="milliseconds"?I%=1e3:I=C==="weeks"?v(I/d[C]):this.$d[C],I||0},M.add=function(S,I,C){var B;return B=I?S*d[m(I)]:g(S)?S.$ms:y(S,this).$ms,y(this.$ms+B*(C?-1:1),this)},M.subtract=function(S,I){return this.add(S,I,!0)},M.locale=function(S){var I=this.clone();return I.$l=S,I},M.clone=function(){return y(this.$ms,this)},M.humanize=function(S){return t().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},M.valueOf=function(){return this.asMilliseconds()},M.milliseconds=function(){return this.get("milliseconds")},M.asMilliseconds=function(){return this.as("milliseconds")},M.seconds=function(){return this.get("seconds")},M.asSeconds=function(){return this.as("seconds")},M.minutes=function(){return this.get("minutes")},M.asMinutes=function(){return this.as("minutes")},M.hours=function(){return this.get("hours")},M.asHours=function(){return this.as("hours")},M.days=function(){return this.get("days")},M.asDays=function(){return this.as("days")},M.weeks=function(){return this.get("weeks")},M.asWeeks=function(){return this.as("weeks")},M.months=function(){return this.get("months")},M.asMonths=function(){return this.as("months")},M.years=function(){return this.get("years")},M.asYears=function(){return this.as("years")},F}(),x=function(F,M,S){return F.add(M.years()*S,"y").add(M.months()*S,"M").add(M.days()*S,"d").add(M.hours()*S,"h").add(M.minutes()*S,"m").add(M.seconds()*S,"s").add(M.milliseconds()*S,"ms")};return function(F,M,S){t=S,r=S().$utils(),S.duration=function(B,L){var U=S.locale();return y(B,{$l:U},L)},S.isDuration=g;var I=M.prototype.add,C=M.prototype.subtract;M.prototype.add=function(B,L){return g(B)?x(this,B,1):I.bind(this)(B,L)},M.prototype.subtract=function(B,L){return g(B)?x(this,B,-1):C.bind(this)(B,L)}}})})(ih);var sw=ih.exports,ow=Ge(sw);tt.extend(Bl),tt.extend(rw),tt.extend(iw),tt.extend(ow);class sh{constructor(e,t,r){R(this,"array");R(this,"color");R(this,"math");R(this,"str");R(this,"map");R(this,"matrix");R(this,"timeframe");R(this,"ta");R(this,"input");R(this,"_variables");R(this,"_cacheData");R(this,"_options");R(this,"_errorListener");R(this,"_plots");R(this,"_plotshapes");R(this,"_plotbars");R(this,"_plotchars");R(this,"_plotarrows");R(this,"_plotcandles");R(this,"_alerts");R(this,"_bgColors");R(this,"_hlines");R(this,"_fills");R(this,"chart");R(this,"line");R(this,"label");R(this,"polyline");R(this,"box");R(this,"table");R(this,"linefill");R(this,"log");R(this,"runtime");R(this,"strategy");R(this,"request");R(this,"syminfo");R(this,"_count",0);var i;const n=((i=e.toString().split(".")[1])==null?void 0:i.length)||5;this._variables=t,this._errorListener=new fw,this.array=new Gp(this._errorListener),this.math=new Hp(n,this._errorListener),this.color=new D1,this.str=new by(this._errorListener,n),this.map=new Ey(this._errorListener),this.timeframe=new Dy(t),this.matrix=new wy(this._errorListener),this.ta=new y1(t,this.math,this.timeframe),this._cacheData={},this._options={},this._bgColors={},this._alerts=new Map,this._hlines=new Map,this._fills=new Map,this.input=new w1(t,this._errorListener,r),this._plots=new Map,this._plotshapes=new Map,this._plotbars=new Map,this._plotcandles=new Map,this._plotchars=new Map,this._plotarrows=new Map,this.chart={point:new xy(t)},this.line=new Zy(t,this._errorListener),this.label=new Ay(t,this._errorListener),this.polyline=new Vy(t,this._errorListener),this.box=new Gy(t,this._errorListener),this.table=new Hy(t,this._errorListener),this.linefill=new Ky(t),this.log=new lw(t),this.runtime=new cw(this._errorListener),this.strategy=new ew(this._variables,this._options,e,this._errorListener),this.request=new aw(this._variables,r),this.syminfo=new uw}get errors(){return this._errorListener.errors}options(e){if(e.length)return this._getDataOfBarindex(e);const t=this.input.getInputs(),r=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const n=Object.keys(this._bgColors);let i;if(n.length){i={};for(const v of n)i[v]=[...this._bgColors[v].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,l=this._fills.size?[...this._fills.values()]:void 0,c=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const p=this._plots.size>0?[...this._plots.values()]:void 0,h=this._plotbars.size>0?[...this._plotbars.values()]:void 0,f=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,d=this._plotarrows.size>0?[...this._plotarrows.values()]:void 0,g=this._plotcandles.size>0?[...this._plotcandles.values()]:void 0,y=this._plotchars.size>0?[...this._plotchars.values()]:void 0,m=this._getDraws(),w=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:t,plots:p,draws:m,alerts:r,colors:i,hlines:a,fills:l,logs:c,plotshapes:f,plotarrows:d,plotcandles:g,plotchars:y,plotbars:h,isUseBgColor:w})}_getDataOfBarindex(e){const t=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const r=Object.keys(this._bgColors);let n;if(r.length){n={};for(const d of r)n[d]=[...this._bgColors[d].values()].map(g=>{const y=[];for(const m of e){const w=g.colors[m];w&&y.push(w)}return g.colors=y,g})}const i=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(e,[...this._fills.values()]):void 0,l=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const c=this._getDataFromBarindex(e,[...this._plots.values()]),p=this._plotshapes.size>0?this._getDataFromBarindex(e,[...this._plotshapes.values()]):void 0,h=this._getDrawsFromBarindex(e),f=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,draws:h,alerts:t,colors:n,hlines:i,fills:a,logs:l,plotshapes:p,isUseBgColor:f})}_getDataFromBarindex(e,t){return t.map(r=>{const n=[];for(const i of e){const a=r.data[i];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:e,linefill:t,table:r,box:n,polyline:i,label:a}=this._variables,l={};return e.data.length&&(l.lines=e.data),t.data.length&&(l.linefills=t.data),r.data.length&&(l.tables=r.data),n.data.length&&(l.boxes=n.data),i.data.length&&(l.polylines=i.data),a.data.length&&(l.labels=a.data),Object.keys(l).length?l:void 0}_getDrawsFromBarindex(e){const{line:t,linefill:r,table:n,box:i,polyline:a,label:l}=this._variables,c={};return t.data.length&&(c.lines=t.getValOfBarIndex(e)),r.data.length&&(c.linefills=r.getValOfBarIndex(e)),n.data.length&&(c.tables=n.getValOfBarIndex(e)),i.data.length&&(c.boxes=i.getValOfBarIndex(e)),a.data.length&&(c.polylines=a.getValOfBarIndex(e)),l.data.length&&(c.labels=l.getValOfBarIndex(e)),Object.keys(c).length?c:void 0}updateOptions(e){const{inputs:t}=e;this.input.update(t)}update(e){const{barIndex:t}=e;this.strategy.updateOptions(),this.math.update(t)}endExecution(){this.strategy.endExecution()}library(e,t){if(!this._variables.bar_index){const r=/^[^\W\d\s][^\W\s]*$/,{title:n}=e;r.test(n)?(Kp.includes(n)||Zp.includes(n))&&this._errorListener.addError(jt(ut.libraryTitleIsKeywordErr,{name:n}),t,ze.Error):this._errorListener.addError(ut.libraryTitleErr,t,ze.Error),this._options.scriptType="library",this._options.library=e}}indicator(e,t){if(!this._variables.bar_index){const{format:r}=e;this._paramVerfiy(r,t,"indicator",[Ke.inherit,Ke.percent,Ke.price,Ke.volume]),this._variables.updateMaxLength(e),this._options.scriptType="indicator",this._options.indicator=e}}_paramVerfiy(e="",t,r,n,i="format"){e&&!n.includes(e)&&this._errorListener.addError(jt(ut.paramsErr,{value:e,func:r,param:i,targetVal:`[${n.join(", ")}]`}),t,ze.Error)}_lineWidthVerify(e,t){const{linewidth:r=1}=e;r<1&&(this._errorListener.addError(Yp.lineWidthWarning,t,ze.Warning),e.linewidth=1)}plot(e,t){const r=["color"];_t(e,r);const{series:n,color:i,...a}=e,{bar_index:l,time:c}=this._variables,p=`plot_${t}`,h=this._plots.get(p),f=(h==null?void 0:h.data)||[],d=n!==void 0&&isNaN(n)?void 0:n;if(f[l]={value:[c,d],itemStyle:{color:i}},this._seriesColorHandle(e,r,h),!h){this._count++,this._lineWidthVerify(a,t),this._paramVerfiy(e.format,t,"plot",[Ke.percent,Ke.price,Ke.volume]);const g=i?[i]:void 0;this._plots.set(p,{editable:!0,...a,colors:g,data:f,id:p,zIndex:this._count})}return{type:"plot",key:p}}plotbar(e,t){const r=["color"];_t(e,r);const{open:n,close:i,low:a,high:l,color:c,...p}=e,{bar_index:h,time:f}=this._variables,d=`plotbar_${t}`,g=this._plotbars.get(d),y=(g==null?void 0:g.data)||[],m=i!==void 0&&isNaN(i)?void 0:i,w=n!==void 0&&isNaN(n)?void 0:n,v=a!==void 0&&isNaN(a)?void 0:a,E=l!==void 0&&isNaN(l)?void 0:l,b=[f,w,m,v,E];if(y[h]={value:b,itemStyle:{color:c}},this._seriesColorHandle(e,r,g),!g){this._count++,this._paramVerfiy(e.format,t,"plotbar",[Ke.percent,Ke.price,Ke.volume]);const N=c?[c]:void 0;this._plotbars.set(d,{editable:!0,...p,colors:N,data:y,id:d,zIndex:this._count})}}_verfiyArgs(e,t,r){const{size:n,format:i,location:a,style:l}=e;this._paramVerfiy(l,r,t,Object.values(or),"style"),this._paramVerfiy(a,r,t,Object.values(an),"location"),this._paramVerfiy(n,r,t,Object.values(tr),"size"),this._paramVerfiy(i,r,t,[Ke.percent,Ke.price,Ke.volume],"format")}plotchar(e,t){const r=["color","textcolor"];_t(e,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=e,{bar_index:p,time:h,high:f,low:d}=this._variables,g=`plotchar_${t}`,y=this._plotchars.get(g),m=(y==null?void 0:y.data)||[],w={value:[h,n],itemStyle:{color:i,textcolor:a},low:d,high:f};m[p]=w,this._seriesColorHandle(e,r,y),y||(this._count++,this._verfiyArgs(e,"plotchar",t),this._plotchars.set(g,{editable:!0,...c,location:l,data:m,id:g,zIndex:this._count}))}plotarrow(e,t){const r=["colorup","colordown"];_t(e,r);const{series:n,colorup:i,colordown:a,...l}=e,{bar_index:c,time:p}=this._variables,h=`plotarrow_${t}`,f=this._plotarrows.get(h),d=(f==null?void 0:f.data)||[];d[c]={value:[p,n!==void 0&&isNaN(n)?void 0:n],itemStyle:{colorup:i,colordown:a}},this._seriesColorHandle(e,r,f),f||(this._count++,this._paramVerfiy(e.format,t,"plotarrow",[Ke.percent,Ke.price,Ke.volume]),this._plotarrows.set(h,{editable:!0,...l,data:d,id:h,zIndex:this._count}))}plotshape(e,t){const r=["color","textcolor"];_t(e,r);const{series:n,color:i,textcolor:a,location:l=an.abovebar,...c}=e,{bar_index:p,time:h,low:f,high:d}=this._variables,g=`plotshape_${t}`,y=this._plotshapes.get(g),m=(y==null?void 0:y.data)||[],w={value:n,color:i,textcolor:a,time:h,low:f,high:d};if(m[p]=w,this._seriesColorHandle(e,r,y),!y){this._count++;const v=i?[i]:void 0;this._verfiyArgs(e,"plotshape",t),this._plotshapes.set(g,{editable:!0,...c,data:m,location:l,id:g,colors:v,zIndex:this._count})}}plotcandle(e,t){const r=["wickcolor","bordercolor","color"];_t(e,r);const{wickcolor:n,bordercolor:i,color:a,close:l,open:c,low:p,high:h,...f}=e,{bar_index:d,time:g}=this._variables,y=`plotcandle_${t}`,m=this._plotcandles.get(y),w=(m==null?void 0:m.data)||[],v=l!==void 0&&isNaN(l)?void 0:l,E=c!==void 0&&isNaN(c)?void 0:c,b=p!==void 0&&isNaN(p)?void 0:p,N=h!==void 0&&isNaN(h)?void 0:h,x=[g,E,v,b,N];w[d]={value:x,wickcolor:n,bordercolor:i,color:a},this._seriesColorHandle(e,r,m),m||(this._count++,this._paramVerfiy(e.format,t,"plotcandle",[Ke.percent,Ke.price,Ke.volume]),this._plotcandles.set(y,{editable:!0,...f,data:w,id:y,zIndex:this._count}))}hline(e,t){const r=`hline_${t}`;_t(e,["color"]),this._verifyDisplay(e.display,"hline",t);const i=e.display&&!e.display.length?Yt.none:Yt.all;return this._hlines.has(r)||(this._count++,this._lineWidthVerify(e,t),this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:i,...e,zIndex:this._count})),{type:"hline",key:r}}fill(e,t){var S,I,C,B,L,U,k,W,z,K;const r=["color","top_color","bottom_color"];_t(e,r);const{color:n,top_color:i,bottom_color:a,seriesColors:l,hline1:c,hline2:p,plot1:h,plot2:f,top_value:d,bottom_value:g,...y}=e,{bar_index:m,time:w}=this._variables,v=`fill_${t}`,E=this._fills.get(v),b=(E==null?void 0:E.data)||[];this._verifyDisplay(e.display,"fill",t);const N=e.display&&!e.display.length?Yt.none:Yt.all;let x,F,M="plot";if(c&&p)x=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,F=(I=this._hlines.get(p==null?void 0:p.key))==null?void 0:I.price,M="hline";else{const Z=((C=this._plots.get(h==null?void 0:h.key))==null?void 0:C.data)||[],X=((B=this._plots.get(f==null?void 0:f.key))==null?void 0:B.data)||[];x=(U=(L=Z[m])==null?void 0:L.value)==null?void 0:U[1],F=(W=(k=X[m])==null?void 0:k.value)==null?void 0:W[1]}if(b[m]={time:w,color:n,top_color:i,bottom_color:a,plot1:x,plot2:F,top_value:d,bottom_value:g},this._seriesColorHandle(e,r,E),!E){this._count++;const Z=((z=this._options.indicator)==null?void 0:z.explicit_plot_zorder)||((K=this._options.strategy)==null?void 0:K.explicit_plot_zorder),X=n?[n]:void 0,Q=i?[i]:void 0,ce=a?[a]:void 0;this._fills.set(v,{id:v,colors:X,top_colors:Q,bottom_colors:ce,display:N,data:b,type:M,editable:!0,fillgaps:!1,hline1:c,hline2:p,plot1:h,plot2:f,...y,zIndex:Z?this._count:void 0})}}alert({message:e,freq:t=kr.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:i,last_bar_index:a}=this._variables,l=`alert_${r}`,c=this._cacheData[l]||{},p=c.barIndex;if(this._paramVerfiy(t,r,"alert",[kr.freqAll,kr.freqOncePerBar,kr.freqOncePerBarClose]),t===kr.freqOncePerBar&&n===p){this._alerts.delete(l);return}this._cacheData[l]=c;const h={message:e,freq:t,id:l,type:"alert"};if(i){t!==kr.freqOncePerBarClose&&this._alerts.set(l,h),c.barIndex=n;return}if(!i&&t===kr.freqOncePerBarClose&&n===p&&a===n-1){this._alerts.set(l,h),c.barIndex=n;return}this._alerts.delete(l)}alertcondition({condition:e,message:t,title:r},n){const{_isRealTimeBar:i}=this._variables,a=`alertcondition_${n}`;i&&e?this._alerts.set(a,{message:t,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(e,t){this._setColors(e,"barcolor",t)}bgcolor(e,t){this._setColors(e,"bgcolor",t)}_verifyDisplay(e=Qf.all,t,r){e.length&&e.length<4&&this._errorListener.addError(jt(ut.displayErr,{func:t,values:"[display.none, display.all]"}),r,ze.Error)}_setColors(e,t,r){_t(e,["color"]);const{color:i,...a}=e;this._verifyDisplay(a.display,t,r);const l=e.display&&!e.display.length?Yt.none:Yt.all,{bar_index:c,time:p}=this._variables,h=`${t}_${r}`;this._bgColors[t]||(this._bgColors[t]=new Map);const f=this._bgColors[t].get(h),d=(f==null?void 0:f.colors)||[],g=(f==null?void 0:f.setColors)||[];i&&!g.includes(i)&&g.push(i),d[c]={color:i,time:p},f||this._bgColors[t].set(h,{...a,display:l,colors:d,setColors:g,id:h})}max_bars_back({var:e,num:t,var_name:r}){console.log(e,t,r)}float({x:e}){return e}bool({x:e}){return e||!1}string({x:e}){return e}int({x:e}){return e&&Math.trunc(e)}na({x:e}){return!!(e===void 0||isNaN(e))}fixnan({source:e},t){return e===void 0||isNaN(e)?this._cacheData[`fixnan_${t}`]:(this._cacheData[`fixnan_${t}`]=e,e)}nz({source:e,replacement:t}){return e!==void 0&&!isNaN(e)?e:t||0}time({timeframe:e="",session:t,timezone:r,bars_back:n=0},i){return this._timeHandle(this._variables.time,i,e,t,r,n)}time_close({timeframe:e="",session:t,timezone:r,bars_back:n=0},i){return this._variables.time_close&&this._timeHandle(this._variables.time_close,i,e,t,r,n)}timestamp(e){const{dateString:t,timezone:r,year:n,month:i,day:a,hour:l=0,minute:c=0,second:p=0}=e;if(t)return tt(t).utc(!/GMT|UTC/.test(t)).valueOf();let h=i-1,f=n;if(h<0){const g=Math.ceil(Math.abs(h/12));h=12*g+h,f=n-g}let d=tt({year:f,month:h,day:a,hour:l,minute:c,second:p});return r&&(d=qr(d.utc(!0).valueOf(),r)),d.utc(!0).valueOf()}weekofyear({time:e,timezone:t}){return qr(e,t).week()}year({time:e,timezone:t}){return qr(e,t).year()}second({time:e,timezone:t}){return qr(e,t).second()}month({time:e,timezone:t}){return qr(e,t).month()+1}minute({time:e,timezone:t}){return qr(e,t).minute()}hour({time:e,timezone:t}){return qr(e,t).hour()}dayofweek({time:e,timezone:t}){return qr(e,t).day()+1}dayofmonth({time:e,timezone:t}){return qr(e,t).date()}_calcTimeOffset(e,t){const r=this._variables.getTimeTradingday(e,t),n=Xr(t)*1e3;return e-r-Math.floor((e-r)/n)*n}_timeHandle(e,t,r="",n,i,a=0){const l=r||this._variables.timeframe.period,c=Xr(l),p=Xr(this._variables.timeframe.period);let h;if(c<=p)h=e;else{const f=`time_${t}`,d=this._cacheData[f];if(d)d.currentTime+c*1e3-d.offset<=e?(h=e,this._cacheData[f]={currentTime:e,offset:0}):h=d;else{const g=this._calcTimeOffset(e,l);this._cacheData[f]={currentTime:e,offset:g},h=e}}if(n){const{timePeriods:f,weeks:d}=this._parserSession(n,t),g=tt(e).format("YYYY-MM-DD"),y=h;h=void 0;for(const w of f){const[v,E]=w;if(tt(e).isBetween(`${g} ${v}`,`${g} ${E}`,"hour")){tt(y).isBetween(`${g} ${v}`,`${g} ${E}`,"hour")?h=y:h=tt(`${g} ${v}`).valueOf();break}}const m=this._variables.dayofweek;h&&!d.includes(m)&&(h=void 0)}return i&&(h=h&&qr(h,i).valueOf()),h&&h-a*p*1e3}_seriesColorHandle(e,t,r){var n;if(r&&t!=null&&t.length)for(const i of t){if((n=r.gradientColorKeys)!=null&&n.includes(i))continue;const a=e[i];if(!a)continue;const l=r[`${i}s`]||[];l.includes(a)||(l.push(a),r[`${i}s`]=l,l.length>5&&(r[`${i}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(i)))}}_parserSession(e,t){const r=e.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(c=>{const p=parseInt(c,10);if(p<1||p>7){this._errorListener.addError(`Invalid day of week: ${c}`,t,ze.Error);return}return p});return{timePeriods:n.split(",").map(c=>{c===""||c===fi.regular?c="0930-1500":c===fi.extended&&(c="1500-1830");const p=c.split("-");return p.length!==2?(this._errorListener.addError(`Invalid time period: ${c}`,t,ze.Error),[]):[this._processTime(p[0],t),this._processTime(p[1],t)]}),weeks:a}}_processTime(e,t){const r=parseInt(e.slice(0,2),10),n=parseInt(e.slice(2),10);if(!(r>=0&&r<=23)&&n>=0&&n<=59){this._errorListener.addError("Invalid time: Time must be within 00:00 to 23:59",t,ze.Error);return}return`${r}:${n}`}}class aw{constructor(e,t){R(this,"_variables");R(this,"_scriptId");R(this,"_cacheData");this._variables=e,this._scriptId=t,this._cacheData=new Map}security(e,t){const r=self.workerStorage.get(`request_${this._scriptId}`),{paramsExpr:n=[]}=e,i=this._getRequestData(e,t);if(r!=null&&r.has(t)){const c=r.get(t);return this._runScripts(c,t,!1,n,i)}const a=this._parseExprCode(e),l=this._runScripts(a,t,!0,n,i);return r==null||r.set(t,a),l}_parseExprCode(e){let{expression:t,paramsExpr:r=[]}=e,n=[],i=1;t=Il(t);const a=JSON.parse(t),l=a.pop();let c=(l==null?void 0:l.memberCodes)||{},p=(l==null?void 0:l.depends)||[];if(!p.length)return`return ${l==null?void 0:l.code}`;let h=[],f=[];const d=[];if(this._getDependCodes(p,a,n,h,f,d),f.length){const m=r.length;let w=[];for(let v=m-1;v>=0;v--){const E=r[v];let b=JSON.parse(Il(E));const N=[];i!==0&&f.length&&(w.unshift("{"),i++),b=b.map(S=>{const{scope:I,code:C,varNames:B,dependSelf:L}=S;return I===2&&!N.includes(B)&&!L&&(S.code=`let ${C}`),B&&N.push(...B.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const x=[],F=[];let M=f.map(S=>({...S,isArg:!1,isPreArg:!0}));f=[],this._getDependCodes(M,b,F,h,f,x),w.unshift(...F,...x),n=w.concat(n),w=[]}}for(n.push(`return ${l==null?void 0:l.code}`);i>1;)n.push("}"),i--;n=h.concat(n),n.push(...d);let g=n.join(`
|
63
|
+
`);const y=[];for(const m of Object.keys(c))g.includes(`$_var.getCacheData("${m}"`)&&y.push(c[m]);return y.length&&(g=`${y.join(`
|
64
|
+
`)}
|
65
|
+
${g}`),g}_getRequestData(e,t){let{symbol:r,timeframe:n,calc_bars_count:i}=e;const a=self.workerStorage.get(`request_${this._scriptId}_data`),l=`${r}--${n}`;if(a!=null&&a.has(l)){const{index:c=0,periodStamp:p=Xr(this._variables.__period)*1e3}=this._cacheData.get(t)||{},h=(a.get(l)||[]).slice(c),f=this._variables.time,d=p+f;for(const[g,y]of h.entries()){const{timestamp:m,close:w,open:v,high:E,low:b,volume:N}=y;let x=m*1e3;if(x>=d){this._cacheData.set(t,{index:g,periodStamp:p});return}if(x>=f)return this._cacheData.set(t,{index:g+1,periodStamp:p}),{close:Number(w),open:Number(v),high:Number(E),low:Number(b),timestamp:m,volume:N}}this._cacheData.set(t,{index:h.length,periodStamp:p})}else{const c=self.workerStorage.get(`request_${this._scriptId}_list`);(c==null?void 0:c.get(l))||c==null||c.set(l,{id:l,calc_bars_count:i,symbol:r,timeframe:n})}}_getDependCodes(e,t,r,n,i,a){for(const l of e){if(!l.isArg){const c=t.filter(h=>{var f;return(f=h==null?void 0:h.depends)==null?void 0:f.some(d=>d.name===l.name&&d.scope===l.scope&&d.isAgainAssign)});for(const h of c){const{code:f,depends:d}=h;if(!r.includes(f)&&(r.unshift(f),d!=null&&d.length)){for(const g of d)g.memberCode&&a.push(g.memberCode);this._getDependCodes(d,t,r,n,i,a)}}const p=t.find(h=>{var f;return((f=h.varNames)==null?void 0:f.split(", ").includes(l.name))&&(!l.isPreArg||l.isPreArg&&h.methodName===l.functionName)||h.funcName===l.name});if(p){const{code:h,depends:f}=p,d=r.findIndex(g=>g===h);if(d!==-1&&r.splice(d,1),r.unshift(h),f!=null&&f.length){for(const g of f)g.memberCode&&a.push(g.memberCode);this._getDependCodes(f,t,r,n,i,a)}continue}}i.some(c=>c.name===l.name)||i.push(l)}}_runScripts(e,t,r,n,i){const a=`${this._scriptId}_${t}`;let{builtInGather:l,buildinConstants:c,buildInFunctions:p,tradingvueFunc:h}=self.workerStorage.get(a)||{};return r&&(l=new oh(a),c=new eh,p=new sh(this._variables.mintick||1e-5,l,this._scriptId),h=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",e),self.workerStorage.set(a,{builtInGather:l,buildinConstants:c,buildInFunctions:p,tradingvueFunc:h})),h(l,c,p,n||[],t)}}let uw=class{constructor(){}prefix(e){var r;const{symbol:t}=e;return((r=t==null?void 0:t.split("."))==null?void 0:r[0])||""}ticker(e){var r;const{symbol:t}=e;return((r=t==null?void 0:t.split("."))==null?void 0:r[1])||""}};class lw{constructor(e){R(this,"_logs");R(this,"_variables");R(this,"_intlFormat");this._variables=e,this._logs=[],this._intlFormat=new Intl.NumberFormat("en-US")}get logs(){return this._logs}clearLogs(){this._logs=[]}info(e,t,r){this._addLog(e,t,"info",r)}error(e,t,r){this._addLog(e,t,"error",r)}warning(e,t,r){this._addLog(e,t,"warning",r)}_addLog(e,t,r,n){if(typeof t=="string"&&(n=t),n.startsWith("export"))return;const{message:i,formatString:a}=e,{time:l,bar_index:c}=this._variables;let p=i;a&&Array.isArray(t)&&t.length&&(p=a.replace(/{(\d+)}/g,(h,f)=>{let d=t[f];return typeof d=="number"&&(d=this._intlFormat.format(parseFloat(d.toFixed(3)))),typeof d=="object"&&(d.isArray?d=JSON.stringify(d._value):d=d.toString()),d!==void 0?d:h})),p&&this._logs.push({message:`[${tt(l).format()}]: ${p}`,time:l,barIndex:c,type:r})}}class cw{constructor(e){R(this,"_errorListener");this._errorListener=e}error({message:e},t){t.startsWith("export")||this._errorListener.addError(e,t,ze.Error)}}class fw{constructor(){R(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return zr.flatMap([...this._errors.values()])}addError(e,t,r,n=0){const[i,a]=t.split("_").slice(-2),l=this._errors.get(t),c={message:e,endLineNumber:Number(i),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(i),type:r};l?l.push(c):this._errors.set(t,[c])}}class hw{constructor(){R(this,"_isMarketOpen");R(this,"_currentBarIndex");R(this,"_totalBarIndex");R(this,"_isRealTimeBar");R(this,"_preBarIndex");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0}update(e,t,r,n){this._preBarIndex=this._currentBarIndex,this._currentBarIndex=e,this._totalBarIndex=t,this._isRealTimeBar=r,this._isMarketOpen=n}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1:this._currentBarIndex===this._totalBarIndex}}class pw{constructor(e){R(this,"_variables");this._variables=e}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const e=Xr(this._variables.timeframe.period);return this._variables.time+e===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const e=Xr(this._variables.timeframe.period);return this._variables.time+e===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class dw{constructor(e){R(this,"_orders");R(this,"_historyOrders");R(this,"_options");R(this,"_max_contracts_held_all",0);R(this,"_max_contracts_held_long",0);R(this,"_max_contracts_held_short",0);R(this,"_max_drawdown",0);R(this,"_max_runup",0);R(this,"_max_runup_percent",0);R(this,"_max_drawdown_percent",0);R(this,"_variables");R(this,"_netprofit",0);R(this,"_eventrades",0);R(this,"_avg_trade_percent");R(this,"_closedtrades",0);R(this,"_losstrades",0);R(this,"_grossloss",0);R(this,"_grossloss_percent",0);R(this,"_grossprofit",0);R(this,"_grossprofit_percent",0);R(this,"_wintrades",0);R(this,"_opentrades_capital_held",0);R(this,"_position_avg_price",0);R(this,"_position_size",0);this._orders=[],this._historyOrders=[],this._variables=e}update(){this._calcMaxDrawdownAndMaxRunup()}_calcMaxDrawdownAndMaxRunup(){let e=0,t=0;const{high:r,low:n}=this._variables;for(const p of this._orders){const{in_price:h,qty:f=0,commission:d=0,original_qty:g=0,direction:y}=p,m=y===gt.long?1:-1,w=(r-h)*f,v=(n-h)*f,E=m===1?w:-v,b=m===1?-v:w;e+=b+d*f/g,t+=E+d*f/g}const[i,a]=this._historyOrders.reduce((p,h)=>{let[f,d]=p;const{profit:g=0,commission:y=0}=h;return f+=g,d+=g-y,[f,d]},[0,0]);e-=i,t+=a;const l=e/(this.initial_capital+this.netprofit)*100;this._max_drawdown<e&&(this._max_drawdown=e),l>this._max_drawdown_percent&&(this._max_drawdown_percent=l);const c=t/(this.initial_capital+this.netprofit)*100;t>this._max_runup&&(this._max_runup=t),c>this._max_runup_percent&&(this._max_runup_percent=c)}updateOrders(e){this._orders=e,this._calcMaxContracts()}_calcMaxContracts(){const e=this._orders.length;if(!e)return;const[t,r,n,i,a,l]=this._orders.reduce(([c,p,h,f,d,g],y)=>{const{direction:m,qty:w=0,in_price:v}=y;return m===gt.long?(c+=w,p+=w,g+=w):(c+=w,h+=w,g-=w),f+=w*v,d+=v,[c,p,h,f,d,g]},[0,0,0,0,0,0]);this._position_size=l,this._position_avg_price=a/e,this._opentrades_capital_held=i,this._max_contracts_held_all=Math.max(t,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(n,this._max_contracts_held_short)}updateHistoryOrders(e){this._historyOrders=e;const t=this._historyOrders.length;this._closedtrades=t;const[r,n,i,a,l,c]=this._historyOrders.reduce((p,h)=>{let[f,d,g,y,m,w]=p;const{profit:v=0,profit_percent:E=0}=h;return f+=v,d+=E,v<0?(g+=v,y+=E):(m+=v,w+=E),[f,d,g,y,m,w]},[0,0,0,0,0,0]);this._avg_trade_percent=t?n/t:void 0,this._netprofit=r,this._grossloss=i,this._grossloss_percent=a,this._grossprofit=l,this._grossprofit_percent=c,this._eventrades=this._historyOrders.filter(p=>p.profit===0).length,this._losstrades=this._historyOrders.filter(p=>(p.profit||0)<0).length,this._wintrades=this._historyOrders.filter(p=>(p.profit||0)>0).length}updateStrategyOptions(e){this._options=e}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const e=this.losstrades;return e?Math.abs(this.grossloss/e):void 0}get avg_losing_trade_percent(){const e=this.losstrades;return e?Math.abs(this.grossloss_percent/e):void 0}get avg_trade(){if(this.closedtrades)return Math.abs(this.netprofit/this.closedtrades)}get equity(){return this.initial_capital+this.netprofit+this.openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._orders.reduce((e,t)=>{const{profit:r=0}=t;return e+r},0)}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const e=this.wintrades;return e?Math.abs(this.grossprofit/e):void 0}get avg_winning_trade_percent(){const e=this.wintrades;return e?Math.abs(this.grossprofit_percent/e):void 0}get initial_capital(){var e;return((e=this._options)==null?void 0:e.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss_percent}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit_percent}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:e,margin_long:t=0,margin_short:r=0,commission_type:n,commission_value:i=0}=this._options,a=this._orders[0].direction===gt.long?1:-1,l=(a===1?t:r)/100;if(l<=0)return;const{close:c}=this._variables,[p,h]=this._orders.reduce((f,d)=>{let[g,y]=f;const{in_price:m,qty:w=0,original_qty:v=0}=d,E=m*w;if(g+=E,i){let b=0;switch(n){case Fr.percent:b=(E+w*c)*i/100;break;case Fr.cashPerContract:b=w*i*2;break;case Fr.cashPerOrder:b=w/v*i+i;break}y+=b}return[g,y]},[0,0]);return(p-(e+this.netprofit-h))*a/this.position_size/(1-a*l)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this.netprofit/this.initial_capital*100}get openprofit_percent(){return this.openprofit/(this.initial_capital+this.netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}}class _w{constructor(e){R(this,"_preAccdist");R(this,"_preNvi");R(this,"_prePvi");R(this,"_preObv");R(this,"_prePvt");R(this,"_preWad");R(this,"_preVwap");R(this,"_preValue");R(this,"_currentData");R(this,"_preData");R(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=e}update(e){this._preValue={},e.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...e}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:e,low:t,high:r,volume:n}=this._currentData;if(r===t)return this._preAccdist;const i=(e-t-(r-e))/(r-t)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=i),this._preValue.accdist=i,i}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:e,low:t,high:r,volume:n}=this._currentData,i=(2*e-r-t)/((r-t)*n);return this._preValue.iii=i,i}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:e,low:t,high:r,volume:n,open:i}=this._currentData,a=(e-i)/(r-t)*n;return this._preValue.wvad=a,a}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:e,volume:t}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const n=Math.sign(e-r)*t+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:e,high:t}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const n=Math.max(t-e,Math.abs(t-r),Math.abs(e-r));return this._preValue.tr=n,n}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:e,volume:t}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const n=(e-r)/r*t+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:e,high:t,low:r}=this._currentData,{close:n}=this._preData;if(n===void 0)return this._preWad=0,0;const i=Math.max(t,n),a=Math.min(r,n),l=e-n,p=(l>0?e-a:l<0?e-i:0)+this._preWad;return!this.isRealTime&&(this._preWad=p),this._preValue.wad=p,p}get vwap(){var h,f;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:e,volume:t}=this._currentData;let{sum:r=0,sumV:n=0,isReset:i}=this._preVwap;if(((f=(h=self.workerStorage)==null?void 0:h.get(this._id))==null?void 0:f.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(i=!0,r=n=0),!i)return;const l=e*t+r,c=t+n;!this.isRealTime&&(this._preVwap={sum:l,sumV:c,isReset:i});const p=l/c;return this._preValue.vwap=p,p}_getNvi(){const e=this._preNvi||1,{close:t=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=e||1;return n&&t?a=i<r?l+(n-t)/t*l:l:a=l,!this.isRealTime&&(this._preNvi=a),this._preValue.nvi=a,a}_getPvi(){const e=this._prePvi||1,{close:t=0,volume:r=0}=this._preData,{close:n,volume:i}=this._currentData;let a=1;const l=e||1;return n&&t?a=i>r?l+(n-t)/t*l:l:a=l,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class mw{constructor(){R(this,"_period");R(this,"_multiplier");R(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(e){if(!e)return;this._period=e;const[t,r]=bs(e);this._multiplier=t,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}}class gw{constructor(e){R(this,"_variables");R(this,"_bgColor");R(this,"_fgColor");R(this,"isUseBgColor",!1);this._variables=e}updateOptions(e){e!=null&&e.bg_color&&(this._bgColor=e.bg_color,this._fgColor=this._contrastColor(e.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){return this._variables.time}get right_visible_bar_time(){return this._variables.time}_parseColor(e){let t,r,n,i;if(e.startsWith("#")){t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);const a=e.substring(7);a?i=parseInt(a,16)/255:i=1}else{const a=this._parserRgbColor(e);t=a[0]||0,r=a[1]||0,n=a[2]||0,i=a[3]||1}return{r:t,g:r,b:n,a:i}}_parserRgbColor(e){var t;return((t=e.match(/\d+/g))==null?void 0:t.map(Number))||[]}_contrastColor(e){const{r:t,g:r,b:n}=this._parseColor(e);return(299*t+587*r+114*n)/1e3>128?"#000000":"#ffffff"}}class vw{constructor(e){R(this,"_variables");this._variables=e}get basecurrency(){return""}get country(){}get currency(){return"CNY"}get description(){return""}get employees(){return 100}get expiration_date(){}get industry(){}get minmove(){}get mintick(){return this._variables.mintick}get pointvalue(){}get prefix(){}get pricescale(){}get recommendations_buy(){}get recommendations_buy_strong(){}get recommendations_date(){}get recommendations_hold(){}get recommendations_sell(){}get recommendations_sell_strong(){}get recommendations_total(){}get root(){return""}get sector(){}get session(){return fi.regular}get shareholders(){}get shares_outstanding_float(){}get shares_outstanding_total(){}get target_price_average(){}get target_price_date(){}get target_price_estimates(){}get target_price_high(){}get target_price_low(){}get target_price_median(){}get ticker(){}get tickerid(){}get timezone(){}get type(){}get volumetype(){return"n/a"}}class yw{constructor(e){R(this,"_variables");this._variables=e}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class ww{constructor(e){R(this,"_variables");this._variables=e}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}tt.extend(Wp),tt.extend(Bl),tt.extend(kp);class oh{constructor(e){R(this,"_cacheData");R(this,"_barIndex");R(this,"_isRealTimeBar");R(this,"_barstate");R(this,"_priceVariables");R(this,"_lastBarIndex");R(this,"_currentBarTime");R(this,"_lastBarTime");R(this,"_period");R(this,"_offsetTime");R(this,"_timeframe");R(this,"_ta");R(this,"_polyline");R(this,"_label");R(this,"_line");R(this,"_linefill");R(this,"_box");R(this,"_table");R(this,"_strategy");R(this,"_session");R(this,"syminfo");R(this,"chart");R(this,"earnings");R(this,"dividends");R(this,"_timeTradingday");R(this,"_mintick");this._cacheData={varData:{},varNewData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new hw,this._timeframe=new mw,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new _w(e),this._polyline=new Fi,this._label=new Fi,this._line=new Fi,this._linefill=new Fi,this._box=new Fi,this._table=new Fi(1),this._strategy=new dw(this),this._session=new pw(this),this.syminfo=new vw(this),this.chart=new gw(this),this.earnings=new ww(this),this.dividends=new yw(this)}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:e,open:t,high:r,low:n}=this._priceVariables;return(e+t+r+n)/4}get hl2(){const{high:e,low:t}=this._priceVariables;return(e+t)/2}get hlc3(){const{close:e,high:t,low:r}=this._priceVariables;return(e+t+r)/3}get hlcc4(){const{close:e,high:t,low:r}=this._priceVariables;return(e*2+t+r)/4}get hour(){return tt(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return tt(this._currentBarTime).minute()}get second(){return tt(this._currentBarTime).second()}get month(){return tt(this._currentBarTime).month()+1}get year(){return tt(this._currentBarTime).year()}get dayofweek(){return tt(this._currentBarTime).day()+1}get dayofmonth(){return tt(this._currentBarTime).date()}get weekofyear(){return tt(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[e,t]=bs(this._period);return this._isRealTimeBar?void 0:tt(this._currentBarTime).add(e,t).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}updateMaxLength(e){const{max_lines_count:t,max_labels_count:r,max_boxes_count:n,max_polylines_count:i}=e;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),t&&this._line.setMaxLen(t),i&&this._polyline.setMaxLen(i)}getTimeTradingday(e,t){const[r,n]=bs(t),i=tt(e);return["M","w","y","d"].includes(n)?i.valueOf():(i.subtract(this._offsetTime,"h"),i.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(e){const{interval:t="1D",offsetTime:r=5,mintick:n,chart:i}=e;this._period=t,this._mintick=n,this._offsetTime=r,this._timeframe.update(t),this.chart.updateOptions(i)}updateData(e){const{barIndex:t,c:r,o:n,h:i,l:a,volume:l,time:c,lastBarIndex:p,lastBarTime:h,complete:f,time_tradingday:d}=e;this._priceVariables={close:Number(r),open:Number(n),high:Number(i),low:Number(a),volume:Number(l)},this._isRealTimeBar=f,t>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varData=this._cacheData.varNewData,this._cacheData.varNewData={}),this._timeTradingday=d,this._currentBarTime=c*1e3,this._lastBarIndex=p,this._barIndex=t,this._lastBarTime=h*1e3,this._barstate.update(t,p,f,!1),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:t})}getCacheData(e,t,r){const n=this.setCacheData(e,r);return n[n.length-1-t]}setCacheData(e,t){let r=this._cacheData[e]||{barIndex:-1,data:[]};return r.barIndex>this._barIndex||(r.barIndex===this._barIndex?r.data[r.data.length-1]=t:r.data.push(t),r.barIndex=this._barIndex,this._cacheData[e]=r),r.data}getTypeInstance(e,t){return new Rp(e,t)}getVarValue(e,t,r){const n=`${e}_${t}`,i=r==="var"?this._cacheData.varData[n]:this._cacheData.varipData[n];if(i)return i}setVarValue(e,t,r,n){const i=`${e}_${t}`;let a;switch(typeof r=="object"&&r&&(n="var",a=r.varipKeys),n){case"var":if(this._isRealTimeBar){const l=zr.cloneDeep(r);if(this._cacheData.varNewData[i]=l,a&&a.length)for(const c of a)this._cacheData.varData[i][c]=l[c]}else this._cacheData.varData[i]=r;break;case"varip":this._cacheData.varipData[i]=r;break}return r}add(e,t){return Array.isArray(e)&&Array.isArray(t)?zr.uniq([...e,...t]):typeof e=="number"||typeof t=="number"?Number(e)+Number(t):e+t}sub(e,t){return Array.isArray(e)&&Array.isArray(t)?e.filter(r=>!t.includes(r)):Number(e)-Number(t)}againAssignParse(e,t){var n;if(t)return;const r=(n=e==null?void 0:e.constructor)==null?void 0:n.name;if(r)switch(r){case ts.name:case th.name:case ns.name:case Ua.name:case rs.name:case co.name:e==null||e.delete();break}}}class Fi{constructor(e=50){R(this,"_all");R(this,"_allInstance");R(this,"_pseudoArrayAll");R(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Qe,this._maxLength=e}setMaxLen(e){this._maxLength=e}get data(){return[...this._all.values()]}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(e,t,r){if(this._all.set(e,t),this._allInstance.set(e,r),this._all.size>this._maxLength){const n=this._all.keys().next().value;n&&this.delete(n)}}getValOfBarIndex(e){let t=[];const r=[...this._all.keys()];for(const n of e){const i=r.filter(a=>a.endsWith(`_${n}`));for(const a of i){const l=this._all.get(a);l&&t.push(l)}}return t.length?t:void 0}get(e){return this._all.get(e)}getInstance(e){return this._allInstance.get(e)}delete(e){this._all.delete(e),this._allInstance.delete(e)}}/**
|
66
|
+
* @license
|
67
|
+
* Copyright 2019 Google LLC
|
68
|
+
* SPDX-License-Identifier: Apache-2.0
|
69
|
+
*/const ah=Symbol("Comlink.proxy"),Dw=Symbol("Comlink.endpoint"),bw=Symbol("Comlink.releaseProxy"),Wa=Symbol("Comlink.finalizer"),fo=Symbol("Comlink.thrown"),uh=s=>typeof s=="object"&&s!==null||typeof s=="function",Ew={canHandle:s=>uh(s)&&s[ah],serialize(s){const{port1:e,port2:t}=new MessageChannel;return ja(s,e),[t,[t]]},deserialize(s){return s.start(),Fw(s)}},xw={canHandle:s=>uh(s)&&fo in s,serialize({value:s}){let e;return s instanceof Error?e={isError:!0,value:{message:s.message,name:s.name,stack:s.stack}}:e={isError:!1,value:s},[e,[]]},deserialize(s){throw s.isError?Object.assign(new Error(s.value.message),s.value):s.value}},lh=new Map([["proxy",Ew],["throw",xw]]);function Aw(s,e){for(const t of s)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function ja(s,e=globalThis,t=["*"]){e.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Aw(t,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:i,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(Qn);let p;try{const h=l.slice(0,-1).reduce((d,g)=>d[g],s),f=l.reduce((d,g)=>d[g],s);switch(a){case"GET":p=f;break;case"SET":h[l.slice(-1)[0]]=Qn(n.data.value),p=!0;break;case"APPLY":p=f.apply(h,c);break;case"CONSTRUCT":{const d=new f(...c);p=Ow(d)}break;case"ENDPOINT":{const{port1:d,port2:g}=new MessageChannel;ja(s,g),p=Bw(d,[d])}break;case"RELEASE":p=void 0;break;default:return}}catch(h){p={value:h,[fo]:0}}Promise.resolve(p).catch(h=>({value:h,[fo]:0})).then(h=>{const[f,d]=mo(h);e.postMessage(Object.assign(Object.assign({},f),{id:i}),d),a==="RELEASE"&&(e.removeEventListener("message",r),ch(e),Wa in s&&typeof s[Wa]=="function"&&s[Wa]())}).catch(h=>{const[f,d]=mo({value:new TypeError("Unserializable return value"),[fo]:0});e.postMessage(Object.assign(Object.assign({},f),{id:i}),d)})}),e.start&&e.start()}function Cw(s){return s.constructor.name==="MessagePort"}function ch(s){Cw(s)&&s.close()}function Fw(s,e){return Ya(s,[],e)}function ho(s){if(s)throw new Error("Proxy has been released and is not useable")}function fh(s){return Mi(s,{type:"RELEASE"}).then(()=>{ch(s)})}const po=new WeakMap,_o="FinalizationRegistry"in globalThis&&new FinalizationRegistry(s=>{const e=(po.get(s)||0)-1;po.set(s,e),e===0&&fh(s)});function Mw(s,e){const t=(po.get(e)||0)+1;po.set(e,t),_o&&_o.register(s,e,s)}function Nw(s){_o&&_o.unregister(s)}function Ya(s,e=[],t=function(){}){let r=!1;const n=new Proxy(t,{get(i,a){if(ho(r),a===bw)return()=>{Nw(n),fh(s),r=!0};if(a==="then"){if(e.length===0)return{then:()=>n};const l=Mi(s,{type:"GET",path:e.map(c=>c.toString())}).then(Qn);return l.then.bind(l)}return Ya(s,[...e,a])},set(i,a,l){ho(r);const[c,p]=mo(l);return Mi(s,{type:"SET",path:[...e,a].map(h=>h.toString()),value:c},p).then(Qn)},apply(i,a,l){ho(r);const c=e[e.length-1];if(c===Dw)return Mi(s,{type:"ENDPOINT"}).then(Qn);if(c==="bind")return Ya(s,e.slice(0,-1));const[p,h]=hh(l);return Mi(s,{type:"APPLY",path:e.map(f=>f.toString()),argumentList:p},h).then(Qn)},construct(i,a){ho(r);const[l,c]=hh(a);return Mi(s,{type:"CONSTRUCT",path:e.map(p=>p.toString()),argumentList:l},c).then(Qn)}});return Mw(n,s),n}function Sw(s){return Array.prototype.concat.apply([],s)}function hh(s){const e=s.map(mo);return[e.map(t=>t[0]),Sw(e.map(t=>t[1]))]}const ph=new WeakMap;function Bw(s,e){return ph.set(s,e),s}function Ow(s){return Object.assign(s,{[ah]:!0})}function mo(s){for(const[e,t]of lh)if(t.canHandle(s)){const[r,n]=t.serialize(s);return[{type:"HANDLER",name:e,value:r},n]}return[{type:"RAW",value:s},ph.get(s)||[]]}function Qn(s){switch(s.type){case"HANDLER":return lh.get(s.name).deserialize(s.value);case"RAW":return s.value}}function Mi(s,e,t){return new Promise(r=>{const n=Tw();s.addEventListener("message",function i(a){!a.data||!a.data.id||a.data.id!==n||(s.removeEventListener("message",i),r(a.data))}),s.start&&s.start(),s.postMessage(Object.assign({id:n},e),t)})}function Tw(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class Iw{constructor(){R(this,"_cache");this._cache=new Map}set(e,t){this._cache.set(e,t)}setValue(e,t,r){const n=this._cache.get(e)||{};n[t]=r,this._cache.set(e,n)}updateValue(e,t,r){const n=this._cache.get(e)||{};this._cache.set(e,Object.assign(n[t]||{},r))}get(e){return this._cache.get(e)}has(e){return this._cache.has(e)}deleteStartwidthKey(e){for(const t of this._cache.keys())t.startsWith(e)&&this._cache.delete(t)}delete(e){this._cache.delete(e)}clear(){this._cache.clear()}}function $w(s,e,t){var v;const{data:r,isPreParser:n,id:i="default",syminfo:a,interval:l,inputs:c,chart:p}=e;self.workerStorage||(self.workerStorage=new Iw);let{builtInGather:h,buildinConstants:f,buildInFunctions:d,tradingvueFunc:g}=self.workerStorage.get(i)||{},y=[];t&&(h=new oh(i),f=new eh,d=new sh((a==null?void 0:a.mintick)||1e-5,h,i),g=new Function("$_var","$_const","$_func",s),self.workerStorage.set(i,{builtInGather:h,buildinConstants:f,buildInFunctions:d,tradingvueFunc:g}),self.workerStorage.set(`request_${i}`,new Map),self.workerStorage.set(`request_${i}_data`,new Map),self.workerStorage.set(`request_${i}_list`,new Map));let m=[];if(n)g(h,f,d);else if(r&&r.length){const E=r.length-1;h.updateOptions({interval:l,mintick:(a==null?void 0:a.mintick)||1e-5,chart:p}),d.updateOptions({inputs:c});try{for(const[b,N]of r.entries()){const{barindex:x}=N;!t&&(x||x===0)&&(y.push(x),h.clearDrawCache(x)),h.updateData(Object.assign(N,{barIndex:x||b,lastBarIndex:r[E].bar_index||E,lastBarTime:r[E].time})),d.update({barIndex:x||b}),g(h,f,d),d.endExecution();const F=d.errors;if(F.length&&F.some(M=>M.type===ze.Error))return{status:1,errors:F}}m=[...((v=self.workerStorage.get(`request_${i}_list`))==null?void 0:v.values())||[]],m.length&&self.workerStorage.delete(`request_${i}_list`)}catch(b){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:b==null?void 0:b.message,type:ze.Error}]}}}const w=d.errors;return w.length&&w.some(E=>E.type===ze.Error)?{status:1,errors:w}:{status:0,requestList:m,errors:w,options:{...d.options(y),id:i}}}function Lw(s){self==null||self.workerStorage.deleteStartwidthKey(s),self==null||self.workerStorage.delete(`inputs_${s}`),self==null||self.workerStorage.delete(`request_${s}`),self==null||self.workerStorage.delete(`request_${s}_data`),self==null||self.workerStorage.delete(`request_${s}_list`)}ja({runScript:$w,removeScript:Lw})})();
|