@guihz/trading-vue-editor-tes 0.0.209 → 0.0.210

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.
@@ -1,13 +1,13 @@
1
- var h2=Object.defineProperty;var d2=(Yt,Gt,Se)=>Gt in Yt?h2(Yt,Gt,{enumerable:!0,configurable:!0,writable:!0,value:Se}):Yt[Gt]=Se;var L=(Yt,Gt,Se)=>(d2(Yt,typeof Gt!="symbol"?Gt+"":Gt,Se),Se),$l=(Yt,Gt,Se)=>{if(!Gt.has(Yt))throw TypeError("Cannot "+Se)};var Xr=(Yt,Gt,Se)=>($l(Yt,Gt,"read from private field"),Se?Se.call(Yt):Gt.get(Yt)),Ll=(Yt,Gt,Se)=>{if(Gt.has(Yt))throw TypeError("Cannot add the same private member more than once");Gt instanceof WeakSet?Gt.add(Yt):Gt.set(Yt,Se)},ga=(Yt,Gt,Se,Zn)=>($l(Yt,Gt,"write to private field"),Zn?Zn.call(Yt,Se):Gt.set(Yt,Se),Se);var Rl=(Yt,Gt,Se)=>($l(Yt,Gt,"access private method"),Se);(function(){"use strict";var us,Pl,$i,tr;var Yt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Gt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Se(i){if(i.__esModule)return i;var t=i.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(i).forEach(function(r){var n=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return i[r]}})}),e}var Zn={exports:{}};/**
1
+ var h2=Object.defineProperty;var d2=(Yt,Gt,Se)=>Gt in Yt?h2(Yt,Gt,{enumerable:!0,configurable:!0,writable:!0,value:Se}):Yt[Gt]=Se;var $=(Yt,Gt,Se)=>(d2(Yt,typeof Gt!="symbol"?Gt+"":Gt,Se),Se),$l=(Yt,Gt,Se)=>{if(!Gt.has(Yt))throw TypeError("Cannot "+Se)};var Xr=(Yt,Gt,Se)=>($l(Yt,Gt,"read from private field"),Se?Se.call(Yt):Gt.get(Yt)),Ll=(Yt,Gt,Se)=>{if(Gt.has(Yt))throw TypeError("Cannot add the same private member more than once");Gt instanceof WeakSet?Gt.add(Yt):Gt.set(Yt,Se)},ga=(Yt,Gt,Se,Zn)=>($l(Yt,Gt,"write to private field"),Zn?Zn.call(Yt,Se):Gt.set(Yt,Se),Se);var Rl=(Yt,Gt,Se)=>($l(Yt,Gt,"access private method"),Se);(function(){"use strict";var us,Pl,$i,tr;var Yt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Gt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Se(i){if(i.__esModule)return i;var t=i.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(i).forEach(function(r){var n=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return i[r]}})}),e}var Zn={exports:{}};/**
2
2
  * @license
3
3
  * Lodash <https://lodash.com/>
4
4
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
5
5
  * Released under MIT license <https://lodash.com/license>
6
6
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7
7
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8
- */Zn.exports,function(i,t){(function(){var e,r="4.17.21",n=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",f=500,d="__lodash_placeholder__",h=1,p=2,g=4,w=1,_=2,y=1,v=2,x=4,b=8,M=16,E=32,F=64,N=128,S=256,T=512,C=30,O="...",$=800,W=16,q=1,U=2,z=3,K=1/0,Z=9007199254740991,X=17976931348623157e292,Q=NaN,ct=4294967295,vt=ct-1,lt=ct>>>1,yt=[["ary",N],["bind",y],["bindKey",v],["curry",b],["curryRight",M],["flip",T],["partial",E],["partialRight",F],["rearg",S]],bt="[object Arguments]",Ot="[object Array]",xt="[object AsyncFunction]",ue="[object Boolean]",It="[object Date]",Nt="[object DOMException]",fe="[object Error]",re="[object Function]",qt="[object GeneratorFunction]",Jt="[object Map]",Le="[object Number]",wr="[object Null]",ke="[object Object]",_n="[object Promise]",Tn="[object Proxy]",mn="[object RegExp]",yr="[object Set]",$n="[object String]",R="[object Symbol]",Y="[object Undefined]",G="[object WeakMap]",nt="[object WeakSet]",st="[object ArrayBuffer]",rt="[object DataView]",ft="[object Float32Array]",ut="[object Float64Array]",ht="[object Int8Array]",at="[object Int16Array]",Xt="[object Int32Array]",ne="[object Uint8Array]",xe="[object Uint8ClampedArray]",Ve="[object Uint16Array]",qe="[object Uint32Array]",Dr=/\b__p \+= '';/g,br=/\b(__p \+=) '' \+/g,Ln=/(__e\(.*?\)|\b__t\)) \+\n'';/g,oi=/&(?:amp|lt|gt|quot|#39);/g,Fo=/[&<>"']/g,ru=RegExp(oi.source),nu=RegExp(Fo.source),iu=/<%-([\s\S]+?)%>/g,su=/<%([\s\S]+?)%>/g,Mo=/<%=([\s\S]+?)%>/g,ou=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,au=/^\w*$/,uu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ls=/[\\^$.*+?()[\]{}|]/g,lu=RegExp(ls.source),cs=/^\s+/,cu=/\s/,fu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,hu=/\{\n\/\* \[wrapped with (.+)\] \*/,du=/,? & /,pu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,_u=/[()=,{}\[\]\/\s]/,mu=/\\(\\)?/g,gu=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,No=/\w*$/,vu=/^[-+]0x[0-9a-f]+$/i,wu=/^0b[01]+$/i,yu=/^\[object .+?Constructor\]$/,Du=/^0o[0-7]+$/i,bu=/^(?:0|[1-9]\d*)$/,xu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Li=/($^)/,ai=/['\n\r\u2028\u2029\\]/g,Zt="\\ud800-\\udfff",er="\\u0300-\\u036f",Eu="\\ufe20-\\ufe2f",Ri="\\u20d0-\\u20ff",Rn=er+Eu+Ri,So="\\u2700-\\u27bf",Sh="a-z\\xdf-\\xf6\\xf8-\\xff",uD="\\xac\\xb1\\xd7\\xf7",lD="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",cD="\\u2000-\\u206f",fD=" \\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",Oh="A-Z\\xc0-\\xd6\\xd8-\\xde",Bh="\\ufe0e\\ufe0f",Ih=uD+lD+cD+fD,Au="['’]",hD="["+Zt+"]",Th="["+Ih+"]",Oo="["+Rn+"]",$h="\\d+",dD="["+So+"]",Lh="["+Sh+"]",Rh="[^"+Zt+Ih+$h+So+Sh+Oh+"]",Cu="\\ud83c[\\udffb-\\udfff]",pD="(?:"+Oo+"|"+Cu+")",Ph="[^"+Zt+"]",Fu="(?:\\ud83c[\\udde6-\\uddff]){2}",Mu="[\\ud800-\\udbff][\\udc00-\\udfff]",Pi="["+Oh+"]",zh="\\u200d",kh="(?:"+Lh+"|"+Rh+")",_D="(?:"+Pi+"|"+Rh+")",qh="(?:"+Au+"(?:d|ll|m|re|s|t|ve))?",Uh="(?:"+Au+"(?:D|LL|M|RE|S|T|VE))?",Wh=pD+"?",jh="["+Bh+"]?",mD="(?:"+zh+"(?:"+[Ph,Fu,Mu].join("|")+")"+jh+Wh+")*",gD="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",vD="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Vh=jh+Wh+mD,wD="(?:"+[dD,Fu,Mu].join("|")+")"+Vh,yD="(?:"+[Ph+Oo+"?",Oo,Fu,Mu,hD].join("|")+")",DD=RegExp(Au,"g"),bD=RegExp(Oo,"g"),Nu=RegExp(Cu+"(?="+Cu+")|"+yD+Vh,"g"),xD=RegExp([Pi+"?"+Lh+"+"+qh+"(?="+[Th,Pi,"$"].join("|")+")",_D+"+"+Uh+"(?="+[Th,Pi+kh,"$"].join("|")+")",Pi+"?"+kh+"+"+qh,Pi+"+"+Uh,vD,gD,$h,wD].join("|"),"g"),ED=RegExp("["+zh+Zt+Rn+Bh+"]"),AD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,CD=["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"],FD=-1,ye={};ye[ft]=ye[ut]=ye[ht]=ye[at]=ye[Xt]=ye[ne]=ye[xe]=ye[Ve]=ye[qe]=!0,ye[bt]=ye[Ot]=ye[st]=ye[ue]=ye[rt]=ye[It]=ye[fe]=ye[re]=ye[Jt]=ye[Le]=ye[ke]=ye[mn]=ye[yr]=ye[$n]=ye[G]=!1;var me={};me[bt]=me[Ot]=me[st]=me[rt]=me[ue]=me[It]=me[ft]=me[ut]=me[ht]=me[at]=me[Xt]=me[Jt]=me[Le]=me[ke]=me[mn]=me[yr]=me[$n]=me[R]=me[ne]=me[xe]=me[Ve]=me[qe]=!0,me[fe]=me[re]=me[G]=!1;var MD={À:"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"},ND={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},SD={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},OD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},BD=parseFloat,ID=parseInt,Yh=typeof Yt=="object"&&Yt&&Yt.Object===Object&&Yt,TD=typeof self=="object"&&self&&self.Object===Object&&self,Je=Yh||TD||Function("return this")(),Su=t&&!t.nodeType&&t,ui=Su&&!0&&i&&!i.nodeType&&i,Zh=ui&&ui.exports===Su,Ou=Zh&&Yh.process,Ir=function(){try{var j=ui&&ui.require&&ui.require("util").types;return j||Ou&&Ou.binding&&Ou.binding("util")}catch{}}(),Kh=Ir&&Ir.isArrayBuffer,Gh=Ir&&Ir.isDate,Hh=Ir&&Ir.isMap,Jh=Ir&&Ir.isRegExp,Xh=Ir&&Ir.isSet,Qh=Ir&&Ir.isTypedArray;function xr(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 $D(j,J,H,gt){for(var Bt=-1,te=j==null?0:j.length;++Bt<te;){var Ue=j[Bt];J(gt,Ue,H(Ue),j)}return gt}function Tr(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt&&J(j[H],H,j)!==!1;);return j}function LD(j,J){for(var H=j==null?0:j.length;H--&&J(j[H],H,j)!==!1;);return j}function t0(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(!J(j[H],H,j))return!1;return!0}function Pn(j,J){for(var H=-1,gt=j==null?0:j.length,Bt=0,te=[];++H<gt;){var Ue=j[H];J(Ue,H,j)&&(te[Bt++]=Ue)}return te}function Bo(j,J){var H=j==null?0:j.length;return!!H&&zi(j,J,0)>-1}function Bu(j,J,H){for(var gt=-1,Bt=j==null?0:j.length;++gt<Bt;)if(H(J,j[gt]))return!0;return!1}function Ee(j,J){for(var H=-1,gt=j==null?0:j.length,Bt=Array(gt);++H<gt;)Bt[H]=J(j[H],H,j);return Bt}function zn(j,J){for(var H=-1,gt=J.length,Bt=j.length;++H<gt;)j[Bt+H]=J[H];return j}function Iu(j,J,H,gt){var Bt=-1,te=j==null?0:j.length;for(gt&&te&&(H=j[++Bt]);++Bt<te;)H=J(H,j[Bt],Bt,j);return H}function RD(j,J,H,gt){var Bt=j==null?0:j.length;for(gt&&Bt&&(H=j[--Bt]);Bt--;)H=J(H,j[Bt],Bt,j);return H}function Tu(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(J(j[H],H,j))return!0;return!1}var PD=$u("length");function zD(j){return j.split("")}function kD(j){return j.match(pu)||[]}function e0(j,J,H){var gt;return H(j,function(Bt,te,Ue){if(J(Bt,te,Ue))return gt=te,!1}),gt}function Io(j,J,H,gt){for(var Bt=j.length,te=H+(gt?1:-1);gt?te--:++te<Bt;)if(J(j[te],te,j))return te;return-1}function zi(j,J,H){return J===J?XD(j,J,H):Io(j,r0,H)}function qD(j,J,H,gt){for(var Bt=H-1,te=j.length;++Bt<te;)if(gt(j[Bt],J))return Bt;return-1}function r0(j){return j!==j}function n0(j,J){var H=j==null?0:j.length;return H?Ru(j,J)/H:Q}function $u(j){return function(J){return J==null?e:J[j]}}function Lu(j){return function(J){return j==null?e:j[J]}}function i0(j,J,H,gt,Bt){return Bt(j,function(te,Ue,pe){H=gt?(gt=!1,te):J(H,te,Ue,pe)}),H}function UD(j,J){var H=j.length;for(j.sort(J);H--;)j[H]=j[H].value;return j}function Ru(j,J){for(var H,gt=-1,Bt=j.length;++gt<Bt;){var te=J(j[gt]);te!==e&&(H=H===e?te:H+te)}return H}function Pu(j,J){for(var H=-1,gt=Array(j);++H<j;)gt[H]=J(H);return gt}function WD(j,J){return Ee(J,function(H){return[H,j[H]]})}function s0(j){return j&&j.slice(0,l0(j)+1).replace(cs,"")}function Er(j){return function(J){return j(J)}}function zu(j,J){return Ee(J,function(H){return j[H]})}function fs(j,J){return j.has(J)}function o0(j,J){for(var H=-1,gt=j.length;++H<gt&&zi(J,j[H],0)>-1;);return H}function a0(j,J){for(var H=j.length;H--&&zi(J,j[H],0)>-1;);return H}function jD(j,J){for(var H=j.length,gt=0;H--;)j[H]===J&&++gt;return gt}var VD=Lu(MD),YD=Lu(ND);function ZD(j){return"\\"+OD[j]}function KD(j,J){return j==null?e:j[J]}function ki(j){return ED.test(j)}function GD(j){return AD.test(j)}function HD(j){for(var J,H=[];!(J=j.next()).done;)H.push(J.value);return H}function ku(j){var J=-1,H=Array(j.size);return j.forEach(function(gt,Bt){H[++J]=[Bt,gt]}),H}function u0(j,J){return function(H){return j(J(H))}}function kn(j,J){for(var H=-1,gt=j.length,Bt=0,te=[];++H<gt;){var Ue=j[H];(Ue===J||Ue===d)&&(j[H]=d,te[Bt++]=H)}return te}function To(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=gt}),H}function JD(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=[gt,gt]}),H}function XD(j,J,H){for(var gt=H-1,Bt=j.length;++gt<Bt;)if(j[gt]===J)return gt;return-1}function QD(j,J,H){for(var gt=H+1;gt--;)if(j[gt]===J)return gt;return gt}function qi(j){return ki(j)?eb(j):PD(j)}function Kr(j){return ki(j)?rb(j):zD(j)}function l0(j){for(var J=j.length;J--&&cu.test(j.charAt(J)););return J}var tb=Lu(SD);function eb(j){for(var J=Nu.lastIndex=0;Nu.test(j);)++J;return J}function rb(j){return j.match(Nu)||[]}function nb(j){return j.match(xD)||[]}var ib=function j(J){J=J==null?Je:Ui.defaults(Je.Object(),J,Ui.pick(Je,CD));var H=J.Array,gt=J.Date,Bt=J.Error,te=J.Function,Ue=J.Math,pe=J.Object,qu=J.RegExp,sb=J.String,$r=J.TypeError,$o=H.prototype,ob=te.prototype,Wi=pe.prototype,Lo=J["__core-js_shared__"],Ro=ob.toString,le=Wi.hasOwnProperty,ab=0,c0=function(){var o=/[^.]+$/.exec(Lo&&Lo.keys&&Lo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),Po=Wi.toString,ub=Ro.call(pe),lb=Je._,cb=qu("^"+Ro.call(le).replace(ls,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),zo=Zh?J.Buffer:e,qn=J.Symbol,ko=J.Uint8Array,f0=zo?zo.allocUnsafe:e,qo=u0(pe.getPrototypeOf,pe),h0=pe.create,d0=Wi.propertyIsEnumerable,Uo=$o.splice,p0=qn?qn.isConcatSpreadable:e,hs=qn?qn.iterator:e,li=qn?qn.toStringTag:e,Wo=function(){try{var o=pi(pe,"defineProperty");return o({},"",{}),o}catch{}}(),fb=J.clearTimeout!==Je.clearTimeout&&J.clearTimeout,hb=gt&&gt.now!==Je.Date.now&&gt.now,db=J.setTimeout!==Je.setTimeout&&J.setTimeout,jo=Ue.ceil,Vo=Ue.floor,Uu=pe.getOwnPropertySymbols,pb=zo?zo.isBuffer:e,_0=J.isFinite,_b=$o.join,mb=u0(pe.keys,pe),We=Ue.max,rr=Ue.min,gb=gt.now,vb=J.parseInt,m0=Ue.random,wb=$o.reverse,Wu=pi(J,"DataView"),ds=pi(J,"Map"),ju=pi(J,"Promise"),ji=pi(J,"Set"),ps=pi(J,"WeakMap"),_s=pi(pe,"create"),Yo=ps&&new ps,Vi={},yb=_i(Wu),Db=_i(ds),bb=_i(ju),xb=_i(ji),Eb=_i(ps),Zo=qn?qn.prototype:e,ms=Zo?Zo.valueOf:e,g0=Zo?Zo.toString:e;function B(o){if(Ne(o)&&!Tt(o)&&!(o instanceof jt)){if(o instanceof Lr)return o;if(le.call(o,"__wrapped__"))return vd(o)}return new Lr(o)}var Yi=function(){function o(){}return function(u){if(!Fe(u))return{};if(h0)return h0(u);o.prototype=u;var m=new o;return o.prototype=e,m}}();function Ko(){}function Lr(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}B.templateSettings={escape:iu,evaluate:su,interpolate:Mo,variable:"",imports:{_:B}},B.prototype=Ko.prototype,B.prototype.constructor=B,Lr.prototype=Yi(Ko.prototype),Lr.prototype.constructor=Lr;function jt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ct,this.__views__=[]}function Ab(){var o=new jt(this.__wrapped__);return o.__actions__=hr(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=hr(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=hr(this.__views__),o}function Cb(){if(this.__filtered__){var o=new jt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function Fb(){var o=this.__wrapped__.value(),u=this.__dir__,m=Tt(o),D=u<0,A=m?o.length:0,I=zx(0,A,this.__views__),P=I.start,k=I.end,V=k-P,tt=D?k:P-1,et=this.__iteratees__,ot=et.length,pt=0,wt=rr(V,this.__takeCount__);if(!m||!D&&A==V&&wt==V)return q0(o,this.__actions__);var Ct=[];t:for(;V--&&pt<wt;){tt+=u;for(var Rt=-1,Ft=o[tt];++Rt<ot;){var Ut=et[Rt],Vt=Ut.iteratee,Fr=Ut.type,ur=Vt(Ft);if(Fr==U)Ft=ur;else if(!ur){if(Fr==q)continue t;break t}}Ct[pt++]=Ft}return Ct}jt.prototype=Yi(Ko.prototype),jt.prototype.constructor=jt;function ci(o){var u=-1,m=o==null?0:o.length;for(this.clear();++u<m;){var D=o[u];this.set(D[0],D[1])}}function Mb(){this.__data__=_s?_s(null):{},this.size=0}function Nb(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(_s){var m=u[o];return m===c?e:m}return le.call(u,o)?u[o]:e}function Ob(o){var u=this.__data__;return _s?u[o]!==e:le.call(u,o)}function Bb(o,u){var m=this.__data__;return this.size+=this.has(o)?0:1,m[o]=_s&&u===e?c:u,this}ci.prototype.clear=Mb,ci.prototype.delete=Nb,ci.prototype.get=Sb,ci.prototype.has=Ob,ci.prototype.set=Bb;function gn(o){var u=-1,m=o==null?0:o.length;for(this.clear();++u<m;){var D=o[u];this.set(D[0],D[1])}}function Ib(){this.__data__=[],this.size=0}function Tb(o){var u=this.__data__,m=Go(u,o);if(m<0)return!1;var D=u.length-1;return m==D?u.pop():Uo.call(u,m,1),--this.size,!0}function $b(o){var u=this.__data__,m=Go(u,o);return m<0?e:u[m][1]}function Lb(o){return Go(this.__data__,o)>-1}function Rb(o,u){var m=this.__data__,D=Go(m,o);return D<0?(++this.size,m.push([o,u])):m[D][1]=u,this}gn.prototype.clear=Ib,gn.prototype.delete=Tb,gn.prototype.get=$b,gn.prototype.has=Lb,gn.prototype.set=Rb;function vn(o){var u=-1,m=o==null?0:o.length;for(this.clear();++u<m;){var D=o[u];this.set(D[0],D[1])}}function Pb(){this.size=0,this.__data__={hash:new ci,map:new(ds||gn),string:new ci}}function zb(o){var u=aa(this,o).delete(o);return this.size-=u?1:0,u}function kb(o){return aa(this,o).get(o)}function qb(o){return aa(this,o).has(o)}function Ub(o,u){var m=aa(this,o),D=m.size;return m.set(o,u),this.size+=m.size==D?0:1,this}vn.prototype.clear=Pb,vn.prototype.delete=zb,vn.prototype.get=kb,vn.prototype.has=qb,vn.prototype.set=Ub;function fi(o){var u=-1,m=o==null?0:o.length;for(this.__data__=new vn;++u<m;)this.add(o[u])}function Wb(o){return this.__data__.set(o,c),this}function jb(o){return this.__data__.has(o)}fi.prototype.add=fi.prototype.push=Wb,fi.prototype.has=jb;function Gr(o){var u=this.__data__=new gn(o);this.size=u.size}function Vb(){this.__data__=new gn,this.size=0}function Yb(o){var u=this.__data__,m=u.delete(o);return this.size=u.size,m}function Zb(o){return this.__data__.get(o)}function Kb(o){return this.__data__.has(o)}function Gb(o,u){var m=this.__data__;if(m instanceof gn){var D=m.__data__;if(!ds||D.length<n-1)return D.push([o,u]),this.size=++m.size,this;m=this.__data__=new vn(D)}return m.set(o,u),this.size=m.size,this}Gr.prototype.clear=Vb,Gr.prototype.delete=Yb,Gr.prototype.get=Zb,Gr.prototype.has=Kb,Gr.prototype.set=Gb;function v0(o,u){var m=Tt(o),D=!m&&mi(o),A=!m&&!D&&Yn(o),I=!m&&!D&&!A&&Hi(o),P=m||D||A||I,k=P?Pu(o.length,sb):[],V=k.length;for(var tt in o)(u||le.call(o,tt))&&!(P&&(tt=="length"||A&&(tt=="offset"||tt=="parent")||I&&(tt=="buffer"||tt=="byteLength"||tt=="byteOffset")||bn(tt,V)))&&k.push(tt);return k}function w0(o){var u=o.length;return u?o[el(0,u-1)]:e}function Hb(o,u){return ua(hr(o),hi(u,0,o.length))}function Jb(o){return ua(hr(o))}function Vu(o,u,m){(m!==e&&!Hr(o[u],m)||m===e&&!(u in o))&&wn(o,u,m)}function gs(o,u,m){var D=o[u];(!(le.call(o,u)&&Hr(D,m))||m===e&&!(u in o))&&wn(o,u,m)}function Go(o,u){for(var m=o.length;m--;)if(Hr(o[m][0],u))return m;return-1}function Xb(o,u,m,D){return Un(o,function(A,I,P){u(D,A,m(A),P)}),D}function y0(o,u){return o&&an(u,Ye(u),o)}function Qb(o,u){return o&&an(u,pr(u),o)}function wn(o,u,m){u=="__proto__"&&Wo?Wo(o,u,{configurable:!0,enumerable:!0,value:m,writable:!0}):o[u]=m}function Yu(o,u){for(var m=-1,D=u.length,A=H(D),I=o==null;++m<D;)A[m]=I?e:Cl(o,u[m]);return A}function hi(o,u,m){return o===o&&(m!==e&&(o=o<=m?o:m),u!==e&&(o=o>=u?o:u)),o}function Rr(o,u,m,D,A,I){var P,k=u&h,V=u&p,tt=u&g;if(m&&(P=A?m(o,D,A,I):m(o)),P!==e)return P;if(!Fe(o))return o;var et=Tt(o);if(et){if(P=qx(o),!k)return hr(o,P)}else{var ot=nr(o),pt=ot==re||ot==qt;if(Yn(o))return j0(o,k);if(ot==ke||ot==bt||pt&&!A){if(P=V||pt?{}:ld(o),!k)return V?Sx(o,Qb(P,o)):Nx(o,y0(P,o))}else{if(!me[ot])return A?o:{};P=Ux(o,ot,k)}}I||(I=new Gr);var wt=I.get(o);if(wt)return wt;I.set(o,P),Pd(o)?o.forEach(function(Ft){P.add(Rr(Ft,u,m,Ft,o,I))}):Ld(o)&&o.forEach(function(Ft,Ut){P.set(Ut,Rr(Ft,u,m,Ut,o,I))});var Ct=tt?V?hl:fl:V?pr:Ye,Rt=et?e:Ct(o);return Tr(Rt||o,function(Ft,Ut){Rt&&(Ut=Ft,Ft=o[Ut]),gs(P,Ut,Rr(Ft,u,m,Ut,o,I))}),P}function tx(o){var u=Ye(o);return function(m){return D0(m,o,u)}}function D0(o,u,m){var D=m.length;if(o==null)return!D;for(o=pe(o);D--;){var A=m[D],I=u[A],P=o[A];if(P===e&&!(A in o)||!I(P))return!1}return!0}function b0(o,u,m){if(typeof o!="function")throw new $r(a);return Es(function(){o.apply(e,m)},u)}function vs(o,u,m,D){var A=-1,I=Bo,P=!0,k=o.length,V=[],tt=u.length;if(!k)return V;m&&(u=Ee(u,Er(m))),D?(I=Bu,P=!1):u.length>=n&&(I=fs,P=!1,u=new fi(u));t:for(;++A<k;){var et=o[A],ot=m==null?et:m(et);if(et=D||et!==0?et:0,P&&ot===ot){for(var pt=tt;pt--;)if(u[pt]===ot)continue t;V.push(et)}else I(u,ot,D)||V.push(et)}return V}var Un=G0(on),x0=G0(Ku,!0);function ex(o,u){var m=!0;return Un(o,function(D,A,I){return m=!!u(D,A,I),m}),m}function Ho(o,u,m){for(var D=-1,A=o.length;++D<A;){var I=o[D],P=u(I);if(P!=null&&(k===e?P===P&&!Cr(P):m(P,k)))var k=P,V=I}return V}function rx(o,u,m,D){var A=o.length;for(m=Lt(m),m<0&&(m=-m>A?0:A+m),D=D===e||D>A?A:Lt(D),D<0&&(D+=A),D=m>D?0:kd(D);m<D;)o[m++]=u;return o}function E0(o,u){var m=[];return Un(o,function(D,A,I){u(D,A,I)&&m.push(D)}),m}function Xe(o,u,m,D,A){var I=-1,P=o.length;for(m||(m=jx),A||(A=[]);++I<P;){var k=o[I];u>0&&m(k)?u>1?Xe(k,u-1,m,D,A):zn(A,k):D||(A[A.length]=k)}return A}var Zu=H0(),A0=H0(!0);function on(o,u){return o&&Zu(o,u,Ye)}function Ku(o,u){return o&&A0(o,u,Ye)}function Jo(o,u){return Pn(u,function(m){return xn(o[m])})}function di(o,u){u=jn(u,o);for(var m=0,D=u.length;o!=null&&m<D;)o=o[un(u[m++])];return m&&m==D?o:e}function C0(o,u,m){var D=u(o);return Tt(o)?D:zn(D,m(o))}function or(o){return o==null?o===e?Y:wr:li&&li in pe(o)?Px(o):Jx(o)}function Gu(o,u){return o>u}function nx(o,u){return o!=null&&le.call(o,u)}function ix(o,u){return o!=null&&u in pe(o)}function sx(o,u,m){return o>=rr(u,m)&&o<We(u,m)}function Hu(o,u,m){for(var D=m?Bu:Bo,A=o[0].length,I=o.length,P=I,k=H(I),V=1/0,tt=[];P--;){var et=o[P];P&&u&&(et=Ee(et,Er(u))),V=rr(et.length,V),k[P]=!m&&(u||A>=120&&et.length>=120)?new fi(P&&et):e}et=o[0];var ot=-1,pt=k[0];t:for(;++ot<A&&tt.length<V;){var wt=et[ot],Ct=u?u(wt):wt;if(wt=m||wt!==0?wt:0,!(pt?fs(pt,Ct):D(tt,Ct,m))){for(P=I;--P;){var Rt=k[P];if(!(Rt?fs(Rt,Ct):D(o[P],Ct,m)))continue t}pt&&pt.push(Ct),tt.push(wt)}}return tt}function ox(o,u,m,D){return on(o,function(A,I,P){u(D,m(A),I,P)}),D}function ws(o,u,m){u=jn(u,o),o=dd(o,u);var D=o==null?o:o[un(zr(u))];return D==null?e:xr(D,o,m)}function F0(o){return Ne(o)&&or(o)==bt}function ax(o){return Ne(o)&&or(o)==st}function ux(o){return Ne(o)&&or(o)==It}function ys(o,u,m,D,A){return o===u?!0:o==null||u==null||!Ne(o)&&!Ne(u)?o!==o&&u!==u:lx(o,u,m,D,ys,A)}function lx(o,u,m,D,A,I){var P=Tt(o),k=Tt(u),V=P?Ot:nr(o),tt=k?Ot:nr(u);V=V==bt?ke:V,tt=tt==bt?ke:tt;var et=V==ke,ot=tt==ke,pt=V==tt;if(pt&&Yn(o)){if(!Yn(u))return!1;P=!0,et=!1}if(pt&&!et)return I||(I=new Gr),P||Hi(o)?od(o,u,m,D,A,I):Lx(o,u,V,m,D,A,I);if(!(m&w)){var wt=et&&le.call(o,"__wrapped__"),Ct=ot&&le.call(u,"__wrapped__");if(wt||Ct){var Rt=wt?o.value():o,Ft=Ct?u.value():u;return I||(I=new Gr),A(Rt,Ft,m,D,I)}}return pt?(I||(I=new Gr),Rx(o,u,m,D,A,I)):!1}function cx(o){return Ne(o)&&nr(o)==Jt}function Ju(o,u,m,D){var A=m.length,I=A,P=!D;if(o==null)return!I;for(o=pe(o);A--;){var k=m[A];if(P&&k[2]?k[1]!==o[k[0]]:!(k[0]in o))return!1}for(;++A<I;){k=m[A];var V=k[0],tt=o[V],et=k[1];if(P&&k[2]){if(tt===e&&!(V in o))return!1}else{var ot=new Gr;if(D)var pt=D(tt,et,V,o,u,ot);if(!(pt===e?ys(et,tt,w|_,D,ot):pt))return!1}}return!0}function M0(o){if(!Fe(o)||Yx(o))return!1;var u=xn(o)?cb:yu;return u.test(_i(o))}function fx(o){return Ne(o)&&or(o)==mn}function hx(o){return Ne(o)&&nr(o)==yr}function dx(o){return Ne(o)&&pa(o.length)&&!!ye[or(o)]}function N0(o){return typeof o=="function"?o:o==null?_r:typeof o=="object"?Tt(o)?B0(o[0],o[1]):O0(o):Jd(o)}function Xu(o){if(!xs(o))return mb(o);var u=[];for(var m in pe(o))le.call(o,m)&&m!="constructor"&&u.push(m);return u}function px(o){if(!Fe(o))return Hx(o);var u=xs(o),m=[];for(var D in o)D=="constructor"&&(u||!le.call(o,D))||m.push(D);return m}function Qu(o,u){return o<u}function S0(o,u){var m=-1,D=dr(o)?H(o.length):[];return Un(o,function(A,I,P){D[++m]=u(A,I,P)}),D}function O0(o){var u=pl(o);return u.length==1&&u[0][2]?fd(u[0][0],u[0][1]):function(m){return m===o||Ju(m,o,u)}}function B0(o,u){return ml(o)&&cd(u)?fd(un(o),u):function(m){var D=Cl(m,o);return D===e&&D===u?Fl(m,o):ys(u,D,w|_)}}function Xo(o,u,m,D,A){o!==u&&Zu(u,function(I,P){if(A||(A=new Gr),Fe(I))_x(o,u,P,m,Xo,D,A);else{var k=D?D(vl(o,P),I,P+"",o,u,A):e;k===e&&(k=I),Vu(o,P,k)}},pr)}function _x(o,u,m,D,A,I,P){var k=vl(o,m),V=vl(u,m),tt=P.get(V);if(tt){Vu(o,m,tt);return}var et=I?I(k,V,m+"",o,u,P):e,ot=et===e;if(ot){var pt=Tt(V),wt=!pt&&Yn(V),Ct=!pt&&!wt&&Hi(V);et=V,pt||wt||Ct?Tt(k)?et=k:Be(k)?et=hr(k):wt?(ot=!1,et=j0(V,!0)):Ct?(ot=!1,et=V0(V,!0)):et=[]:As(V)||mi(V)?(et=k,mi(k)?et=qd(k):(!Fe(k)||xn(k))&&(et=ld(V))):ot=!1}ot&&(P.set(V,et),A(et,V,D,I,P),P.delete(V)),Vu(o,m,et)}function I0(o,u){var m=o.length;if(m)return u+=u<0?m:0,bn(u,m)?o[u]:e}function T0(o,u,m){u.length?u=Ee(u,function(I){return Tt(I)?function(P){return di(P,I.length===1?I[0]:I)}:I}):u=[_r];var D=-1;u=Ee(u,Er(At()));var A=S0(o,function(I,P,k){var V=Ee(u,function(tt){return tt(I)});return{criteria:V,index:++D,value:I}});return UD(A,function(I,P){return Mx(I,P,m)})}function mx(o,u){return $0(o,u,function(m,D){return Fl(o,D)})}function $0(o,u,m){for(var D=-1,A=u.length,I={};++D<A;){var P=u[D],k=di(o,P);m(k,P)&&Ds(I,jn(P,o),k)}return I}function gx(o){return function(u){return di(u,o)}}function tl(o,u,m,D){var A=D?qD:zi,I=-1,P=u.length,k=o;for(o===u&&(u=hr(u)),m&&(k=Ee(o,Er(m)));++I<P;)for(var V=0,tt=u[I],et=m?m(tt):tt;(V=A(k,et,V,D))>-1;)k!==o&&Uo.call(k,V,1),Uo.call(o,V,1);return o}function L0(o,u){for(var m=o?u.length:0,D=m-1;m--;){var A=u[m];if(m==D||A!==I){var I=A;bn(A)?Uo.call(o,A,1):il(o,A)}}return o}function el(o,u){return o+Vo(m0()*(u-o+1))}function vx(o,u,m,D){for(var A=-1,I=We(jo((u-o)/(m||1)),0),P=H(I);I--;)P[D?I:++A]=o,o+=m;return P}function rl(o,u){var m="";if(!o||u<1||u>Z)return m;do u%2&&(m+=o),u=Vo(u/2),u&&(o+=o);while(u);return m}function Pt(o,u){return wl(hd(o,u,_r),o+"")}function wx(o){return w0(Ji(o))}function yx(o,u){var m=Ji(o);return ua(m,hi(u,0,m.length))}function Ds(o,u,m,D){if(!Fe(o))return o;u=jn(u,o);for(var A=-1,I=u.length,P=I-1,k=o;k!=null&&++A<I;){var V=un(u[A]),tt=m;if(V==="__proto__"||V==="constructor"||V==="prototype")return o;if(A!=P){var et=k[V];tt=D?D(et,V,k):e,tt===e&&(tt=Fe(et)?et:bn(u[A+1])?[]:{})}gs(k,V,tt),k=k[V]}return o}var R0=Yo?function(o,u){return Yo.set(o,u),o}:_r,Dx=Wo?function(o,u){return Wo(o,"toString",{configurable:!0,enumerable:!1,value:Nl(u),writable:!0})}:_r;function bx(o){return ua(Ji(o))}function Pr(o,u,m){var D=-1,A=o.length;u<0&&(u=-u>A?0:A+u),m=m>A?A:m,m<0&&(m+=A),A=u>m?0:m-u>>>0,u>>>=0;for(var I=H(A);++D<A;)I[D]=o[D+u];return I}function xx(o,u){var m;return Un(o,function(D,A,I){return m=u(D,A,I),!m}),!!m}function Qo(o,u,m){var D=0,A=o==null?D:o.length;if(typeof u=="number"&&u===u&&A<=lt){for(;D<A;){var I=D+A>>>1,P=o[I];P!==null&&!Cr(P)&&(m?P<=u:P<u)?D=I+1:A=I}return A}return nl(o,u,_r,m)}function nl(o,u,m,D){var A=0,I=o==null?0:o.length;if(I===0)return 0;u=m(u);for(var P=u!==u,k=u===null,V=Cr(u),tt=u===e;A<I;){var et=Vo((A+I)/2),ot=m(o[et]),pt=ot!==e,wt=ot===null,Ct=ot===ot,Rt=Cr(ot);if(P)var Ft=D||Ct;else tt?Ft=Ct&&(D||pt):k?Ft=Ct&&pt&&(D||!wt):V?Ft=Ct&&pt&&!wt&&(D||!Rt):wt||Rt?Ft=!1:Ft=D?ot<=u:ot<u;Ft?A=et+1:I=et}return rr(I,vt)}function P0(o,u){for(var m=-1,D=o.length,A=0,I=[];++m<D;){var P=o[m],k=u?u(P):P;if(!m||!Hr(k,V)){var V=k;I[A++]=P===0?0:P}}return I}function z0(o){return typeof o=="number"?o:Cr(o)?Q:+o}function Ar(o){if(typeof o=="string")return o;if(Tt(o))return Ee(o,Ar)+"";if(Cr(o))return g0?g0.call(o):"";var u=o+"";return u=="0"&&1/o==-K?"-0":u}function Wn(o,u,m){var D=-1,A=Bo,I=o.length,P=!0,k=[],V=k;if(m)P=!1,A=Bu;else if(I>=n){var tt=u?null:Tx(o);if(tt)return To(tt);P=!1,A=fs,V=new fi}else V=u?[]:k;t:for(;++D<I;){var et=o[D],ot=u?u(et):et;if(et=m||et!==0?et:0,P&&ot===ot){for(var pt=V.length;pt--;)if(V[pt]===ot)continue t;u&&V.push(ot),k.push(et)}else A(V,ot,m)||(V!==k&&V.push(ot),k.push(et))}return k}function il(o,u){return u=jn(u,o),o=dd(o,u),o==null||delete o[un(zr(u))]}function k0(o,u,m,D){return Ds(o,u,m(di(o,u)),D)}function ta(o,u,m,D){for(var A=o.length,I=D?A:-1;(D?I--:++I<A)&&u(o[I],I,o););return m?Pr(o,D?0:I,D?I+1:A):Pr(o,D?I+1:0,D?A:I)}function q0(o,u){var m=o;return m instanceof jt&&(m=m.value()),Iu(u,function(D,A){return A.func.apply(A.thisArg,zn([D],A.args))},m)}function sl(o,u,m){var D=o.length;if(D<2)return D?Wn(o[0]):[];for(var A=-1,I=H(D);++A<D;)for(var P=o[A],k=-1;++k<D;)k!=A&&(I[A]=vs(I[A]||P,o[k],u,m));return Wn(Xe(I,1),u,m)}function U0(o,u,m){for(var D=-1,A=o.length,I=u.length,P={};++D<A;){var k=D<I?u[D]:e;m(P,o[D],k)}return P}function ol(o){return Be(o)?o:[]}function al(o){return typeof o=="function"?o:_r}function jn(o,u){return Tt(o)?o:ml(o,u)?[o]:gd(ie(o))}var Ex=Pt;function Vn(o,u,m){var D=o.length;return m=m===e?D:m,!u&&m>=D?o:Pr(o,u,m)}var W0=fb||function(o){return Je.clearTimeout(o)};function j0(o,u){if(u)return o.slice();var m=o.length,D=f0?f0(m):new o.constructor(m);return o.copy(D),D}function ul(o){var u=new o.constructor(o.byteLength);return new ko(u).set(new ko(o)),u}function Ax(o,u){var m=u?ul(o.buffer):o.buffer;return new o.constructor(m,o.byteOffset,o.byteLength)}function Cx(o){var u=new o.constructor(o.source,No.exec(o));return u.lastIndex=o.lastIndex,u}function Fx(o){return ms?pe(ms.call(o)):{}}function V0(o,u){var m=u?ul(o.buffer):o.buffer;return new o.constructor(m,o.byteOffset,o.length)}function Y0(o,u){if(o!==u){var m=o!==e,D=o===null,A=o===o,I=Cr(o),P=u!==e,k=u===null,V=u===u,tt=Cr(u);if(!k&&!tt&&!I&&o>u||I&&P&&V&&!k&&!tt||D&&P&&V||!m&&V||!A)return 1;if(!D&&!I&&!tt&&o<u||tt&&m&&A&&!D&&!I||k&&m&&A||!P&&A||!V)return-1}return 0}function Mx(o,u,m){for(var D=-1,A=o.criteria,I=u.criteria,P=A.length,k=m.length;++D<P;){var V=Y0(A[D],I[D]);if(V){if(D>=k)return V;var tt=m[D];return V*(tt=="desc"?-1:1)}}return o.index-u.index}function Z0(o,u,m,D){for(var A=-1,I=o.length,P=m.length,k=-1,V=u.length,tt=We(I-P,0),et=H(V+tt),ot=!D;++k<V;)et[k]=u[k];for(;++A<P;)(ot||A<I)&&(et[m[A]]=o[A]);for(;tt--;)et[k++]=o[A++];return et}function K0(o,u,m,D){for(var A=-1,I=o.length,P=-1,k=m.length,V=-1,tt=u.length,et=We(I-k,0),ot=H(et+tt),pt=!D;++A<et;)ot[A]=o[A];for(var wt=A;++V<tt;)ot[wt+V]=u[V];for(;++P<k;)(pt||A<I)&&(ot[wt+m[P]]=o[A++]);return ot}function hr(o,u){var m=-1,D=o.length;for(u||(u=H(D));++m<D;)u[m]=o[m];return u}function an(o,u,m,D){var A=!m;m||(m={});for(var I=-1,P=u.length;++I<P;){var k=u[I],V=D?D(m[k],o[k],k,m,o):e;V===e&&(V=o[k]),A?wn(m,k,V):gs(m,k,V)}return m}function Nx(o,u){return an(o,_l(o),u)}function Sx(o,u){return an(o,ad(o),u)}function ea(o,u){return function(m,D){var A=Tt(m)?$D:Xb,I=u?u():{};return A(m,o,At(D,2),I)}}function Zi(o){return Pt(function(u,m){var D=-1,A=m.length,I=A>1?m[A-1]:e,P=A>2?m[2]:e;for(I=o.length>3&&typeof I=="function"?(A--,I):e,P&&ar(m[0],m[1],P)&&(I=A<3?e:I,A=1),u=pe(u);++D<A;){var k=m[D];k&&o(u,k,D,I)}return u})}function G0(o,u){return function(m,D){if(m==null)return m;if(!dr(m))return o(m,D);for(var A=m.length,I=u?A:-1,P=pe(m);(u?I--:++I<A)&&D(P[I],I,P)!==!1;);return m}}function H0(o){return function(u,m,D){for(var A=-1,I=pe(u),P=D(u),k=P.length;k--;){var V=P[o?k:++A];if(m(I[V],V,I)===!1)break}return u}}function Ox(o,u,m){var D=u&y,A=bs(o);function I(){var P=this&&this!==Je&&this instanceof I?A:o;return P.apply(D?m:this,arguments)}return I}function J0(o){return function(u){u=ie(u);var m=ki(u)?Kr(u):e,D=m?m[0]:u.charAt(0),A=m?Vn(m,1).join(""):u.slice(1);return D[o]()+A}}function Ki(o){return function(u){return Iu(Gd(Kd(u).replace(DD,"")),o,"")}}function bs(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 m=Yi(o.prototype),D=o.apply(m,u);return Fe(D)?D:m}}function Bx(o,u,m){var D=bs(o);function A(){for(var I=arguments.length,P=H(I),k=I,V=Gi(A);k--;)P[k]=arguments[k];var tt=I<3&&P[0]!==V&&P[I-1]!==V?[]:kn(P,V);if(I-=tt.length,I<m)return rd(o,u,ra,A.placeholder,e,P,tt,e,e,m-I);var et=this&&this!==Je&&this instanceof A?D:o;return xr(et,this,P)}return A}function X0(o){return function(u,m,D){var A=pe(u);if(!dr(u)){var I=At(m,3);u=Ye(u),m=function(k){return I(A[k],k,A)}}var P=o(u,m,D);return P>-1?A[I?u[P]:P]:e}}function Q0(o){return Dn(function(u){var m=u.length,D=m,A=Lr.prototype.thru;for(o&&u.reverse();D--;){var I=u[D];if(typeof I!="function")throw new $r(a);if(A&&!P&&oa(I)=="wrapper")var P=new Lr([],!0)}for(D=P?D:m;++D<m;){I=u[D];var k=oa(I),V=k=="wrapper"?dl(I):e;V&&gl(V[0])&&V[1]==(N|b|E|S)&&!V[4].length&&V[9]==1?P=P[oa(V[0])].apply(P,V[3]):P=I.length==1&&gl(I)?P[k]():P.thru(I)}return function(){var tt=arguments,et=tt[0];if(P&&tt.length==1&&Tt(et))return P.plant(et).value();for(var ot=0,pt=m?u[ot].apply(this,tt):et;++ot<m;)pt=u[ot].call(this,pt);return pt}})}function ra(o,u,m,D,A,I,P,k,V,tt){var et=u&N,ot=u&y,pt=u&v,wt=u&(b|M),Ct=u&T,Rt=pt?e:bs(o);function Ft(){for(var Ut=arguments.length,Vt=H(Ut),Fr=Ut;Fr--;)Vt[Fr]=arguments[Fr];if(wt)var ur=Gi(Ft),Mr=jD(Vt,ur);if(D&&(Vt=Z0(Vt,D,A,wt)),I&&(Vt=K0(Vt,I,P,wt)),Ut-=Mr,wt&&Ut<tt){var Ie=kn(Vt,ur);return rd(o,u,ra,Ft.placeholder,m,Vt,Ie,k,V,tt-Ut)}var Jr=ot?m:this,An=pt?Jr[o]:o;return Ut=Vt.length,k?Vt=Xx(Vt,k):Ct&&Ut>1&&Vt.reverse(),et&&V<Ut&&(Vt.length=V),this&&this!==Je&&this instanceof Ft&&(An=Rt||bs(An)),An.apply(Jr,Vt)}return Ft}function td(o,u){return function(m,D){return ox(m,o,u(D),{})}}function na(o,u){return function(m,D){var A;if(m===e&&D===e)return u;if(m!==e&&(A=m),D!==e){if(A===e)return D;typeof m=="string"||typeof D=="string"?(m=Ar(m),D=Ar(D)):(m=z0(m),D=z0(D)),A=o(m,D)}return A}}function ll(o){return Dn(function(u){return u=Ee(u,Er(At())),Pt(function(m){var D=this;return o(u,function(A){return xr(A,D,m)})})})}function ia(o,u){u=u===e?" ":Ar(u);var m=u.length;if(m<2)return m?rl(u,o):u;var D=rl(u,jo(o/qi(u)));return ki(u)?Vn(Kr(D),0,o).join(""):D.slice(0,o)}function Ix(o,u,m,D){var A=u&y,I=bs(o);function P(){for(var k=-1,V=arguments.length,tt=-1,et=D.length,ot=H(et+V),pt=this&&this!==Je&&this instanceof P?I:o;++tt<et;)ot[tt]=D[tt];for(;V--;)ot[tt++]=arguments[++k];return xr(pt,A?m:this,ot)}return P}function ed(o){return function(u,m,D){return D&&typeof D!="number"&&ar(u,m,D)&&(m=D=e),u=En(u),m===e?(m=u,u=0):m=En(m),D=D===e?u<m?1:-1:En(D),vx(u,m,D,o)}}function sa(o){return function(u,m){return typeof u=="string"&&typeof m=="string"||(u=kr(u),m=kr(m)),o(u,m)}}function rd(o,u,m,D,A,I,P,k,V,tt){var et=u&b,ot=et?P:e,pt=et?e:P,wt=et?I:e,Ct=et?e:I;u|=et?E:F,u&=~(et?F:E),u&x||(u&=~(y|v));var Rt=[o,u,A,wt,ot,Ct,pt,k,V,tt],Ft=m.apply(e,Rt);return gl(o)&&pd(Ft,Rt),Ft.placeholder=D,_d(Ft,o,u)}function cl(o){var u=Ue[o];return function(m,D){if(m=kr(m),D=D==null?0:rr(Lt(D),292),D&&_0(m)){var A=(ie(m)+"e").split("e"),I=u(A[0]+"e"+(+A[1]+D));return A=(ie(I)+"e").split("e"),+(A[0]+"e"+(+A[1]-D))}return u(m)}}var Tx=ji&&1/To(new ji([,-0]))[1]==K?function(o){return new ji(o)}:Bl;function nd(o){return function(u){var m=nr(u);return m==Jt?ku(u):m==yr?JD(u):WD(u,o(u))}}function yn(o,u,m,D,A,I,P,k){var V=u&v;if(!V&&typeof o!="function")throw new $r(a);var tt=D?D.length:0;if(tt||(u&=~(E|F),D=A=e),P=P===e?P:We(Lt(P),0),k=k===e?k:Lt(k),tt-=A?A.length:0,u&F){var et=D,ot=A;D=A=e}var pt=V?e:dl(o),wt=[o,u,m,D,A,et,ot,I,P,k];if(pt&&Gx(wt,pt),o=wt[0],u=wt[1],m=wt[2],D=wt[3],A=wt[4],k=wt[9]=wt[9]===e?V?0:o.length:We(wt[9]-tt,0),!k&&u&(b|M)&&(u&=~(b|M)),!u||u==y)var Ct=Ox(o,u,m);else u==b||u==M?Ct=Bx(o,u,k):(u==E||u==(y|E))&&!A.length?Ct=Ix(o,u,m,D):Ct=ra.apply(e,wt);var Rt=pt?R0:pd;return _d(Rt(Ct,wt),o,u)}function id(o,u,m,D){return o===e||Hr(o,Wi[m])&&!le.call(D,m)?u:o}function sd(o,u,m,D,A,I){return Fe(o)&&Fe(u)&&(I.set(u,o),Xo(o,u,e,sd,I),I.delete(u)),o}function $x(o){return As(o)?e:o}function od(o,u,m,D,A,I){var P=m&w,k=o.length,V=u.length;if(k!=V&&!(P&&V>k))return!1;var tt=I.get(o),et=I.get(u);if(tt&&et)return tt==u&&et==o;var ot=-1,pt=!0,wt=m&_?new fi:e;for(I.set(o,u),I.set(u,o);++ot<k;){var Ct=o[ot],Rt=u[ot];if(D)var Ft=P?D(Rt,Ct,ot,u,o,I):D(Ct,Rt,ot,o,u,I);if(Ft!==e){if(Ft)continue;pt=!1;break}if(wt){if(!Tu(u,function(Ut,Vt){if(!fs(wt,Vt)&&(Ct===Ut||A(Ct,Ut,m,D,I)))return wt.push(Vt)})){pt=!1;break}}else if(!(Ct===Rt||A(Ct,Rt,m,D,I))){pt=!1;break}}return I.delete(o),I.delete(u),pt}function Lx(o,u,m,D,A,I,P){switch(m){case rt:if(o.byteLength!=u.byteLength||o.byteOffset!=u.byteOffset)return!1;o=o.buffer,u=u.buffer;case st:return!(o.byteLength!=u.byteLength||!I(new ko(o),new ko(u)));case ue:case It:case Le:return Hr(+o,+u);case fe:return o.name==u.name&&o.message==u.message;case mn:case $n:return o==u+"";case Jt:var k=ku;case yr:var V=D&w;if(k||(k=To),o.size!=u.size&&!V)return!1;var tt=P.get(o);if(tt)return tt==u;D|=_,P.set(o,u);var et=od(k(o),k(u),D,A,I,P);return P.delete(o),et;case R:if(ms)return ms.call(o)==ms.call(u)}return!1}function Rx(o,u,m,D,A,I){var P=m&w,k=fl(o),V=k.length,tt=fl(u),et=tt.length;if(V!=et&&!P)return!1;for(var ot=V;ot--;){var pt=k[ot];if(!(P?pt in u:le.call(u,pt)))return!1}var wt=I.get(o),Ct=I.get(u);if(wt&&Ct)return wt==u&&Ct==o;var Rt=!0;I.set(o,u),I.set(u,o);for(var Ft=P;++ot<V;){pt=k[ot];var Ut=o[pt],Vt=u[pt];if(D)var Fr=P?D(Vt,Ut,pt,u,o,I):D(Ut,Vt,pt,o,u,I);if(!(Fr===e?Ut===Vt||A(Ut,Vt,m,D,I):Fr)){Rt=!1;break}Ft||(Ft=pt=="constructor")}if(Rt&&!Ft){var ur=o.constructor,Mr=u.constructor;ur!=Mr&&"constructor"in o&&"constructor"in u&&!(typeof ur=="function"&&ur instanceof ur&&typeof Mr=="function"&&Mr instanceof Mr)&&(Rt=!1)}return I.delete(o),I.delete(u),Rt}function Dn(o){return wl(hd(o,e,Dd),o+"")}function fl(o){return C0(o,Ye,_l)}function hl(o){return C0(o,pr,ad)}var dl=Yo?function(o){return Yo.get(o)}:Bl;function oa(o){for(var u=o.name+"",m=Vi[u],D=le.call(Vi,u)?m.length:0;D--;){var A=m[D],I=A.func;if(I==null||I==o)return A.name}return u}function Gi(o){var u=le.call(B,"placeholder")?B:o;return u.placeholder}function At(){var o=B.iteratee||Sl;return o=o===Sl?N0:o,arguments.length?o(arguments[0],arguments[1]):o}function aa(o,u){var m=o.__data__;return Vx(u)?m[typeof u=="string"?"string":"hash"]:m.map}function pl(o){for(var u=Ye(o),m=u.length;m--;){var D=u[m],A=o[D];u[m]=[D,A,cd(A)]}return u}function pi(o,u){var m=KD(o,u);return M0(m)?m:e}function Px(o){var u=le.call(o,li),m=o[li];try{o[li]=e;var D=!0}catch{}var A=Po.call(o);return D&&(u?o[li]=m:delete o[li]),A}var _l=Uu?function(o){return o==null?[]:(o=pe(o),Pn(Uu(o),function(u){return d0.call(o,u)}))}:Il,ad=Uu?function(o){for(var u=[];o;)zn(u,_l(o)),o=qo(o);return u}:Il,nr=or;(Wu&&nr(new Wu(new ArrayBuffer(1)))!=rt||ds&&nr(new ds)!=Jt||ju&&nr(ju.resolve())!=_n||ji&&nr(new ji)!=yr||ps&&nr(new ps)!=G)&&(nr=function(o){var u=or(o),m=u==ke?o.constructor:e,D=m?_i(m):"";if(D)switch(D){case yb:return rt;case Db:return Jt;case bb:return _n;case xb:return yr;case Eb:return G}return u});function zx(o,u,m){for(var D=-1,A=m.length;++D<A;){var I=m[D],P=I.size;switch(I.type){case"drop":o+=P;break;case"dropRight":u-=P;break;case"take":u=rr(u,o+P);break;case"takeRight":o=We(o,u-P);break}}return{start:o,end:u}}function kx(o){var u=o.match(hu);return u?u[1].split(du):[]}function ud(o,u,m){u=jn(u,o);for(var D=-1,A=u.length,I=!1;++D<A;){var P=un(u[D]);if(!(I=o!=null&&m(o,P)))break;o=o[P]}return I||++D!=A?I:(A=o==null?0:o.length,!!A&&pa(A)&&bn(P,A)&&(Tt(o)||mi(o)))}function qx(o){var u=o.length,m=new o.constructor(u);return u&&typeof o[0]=="string"&&le.call(o,"index")&&(m.index=o.index,m.input=o.input),m}function ld(o){return typeof o.constructor=="function"&&!xs(o)?Yi(qo(o)):{}}function Ux(o,u,m){var D=o.constructor;switch(u){case st:return ul(o);case ue:case It:return new D(+o);case rt:return Ax(o,m);case ft:case ut:case ht:case at:case Xt:case ne:case xe:case Ve:case qe:return V0(o,m);case Jt:return new D;case Le:case $n:return new D(o);case mn:return Cx(o);case yr:return new D;case R:return Fx(o)}}function Wx(o,u){var m=u.length;if(!m)return o;var D=m-1;return u[D]=(m>1?"& ":"")+u[D],u=u.join(m>2?", ":" "),o.replace(fu,`{
8
+ */Zn.exports,function(i,t){(function(){var e,r="4.17.21",n=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",h=500,d="__lodash_placeholder__",f=1,p=2,g=4,w=1,m=2,y=1,v=2,x=4,b=8,M=16,E=32,F=64,N=128,S=256,T=512,A=30,O="...",L=800,q=16,U=1,W=2,z=3,K=1/0,Z=9007199254740991,X=17976931348623157e292,Q=NaN,ct=4294967295,vt=ct-1,lt=ct>>>1,yt=[["ary",N],["bind",y],["bindKey",v],["curry",b],["curryRight",M],["flip",T],["partial",E],["partialRight",F],["rearg",S]],bt="[object Arguments]",Ot="[object Array]",xt="[object AsyncFunction]",ue="[object Boolean]",It="[object Date]",Nt="[object DOMException]",fe="[object Error]",re="[object Function]",qt="[object GeneratorFunction]",Jt="[object Map]",Le="[object Number]",wr="[object Null]",ke="[object Object]",_n="[object Promise]",Tn="[object Proxy]",mn="[object RegExp]",yr="[object Set]",$n="[object String]",R="[object Symbol]",Y="[object Undefined]",G="[object WeakMap]",nt="[object WeakSet]",st="[object ArrayBuffer]",rt="[object DataView]",ft="[object Float32Array]",ut="[object Float64Array]",ht="[object Int8Array]",at="[object Int16Array]",Xt="[object Int32Array]",ne="[object Uint8Array]",xe="[object Uint8ClampedArray]",Ve="[object Uint16Array]",qe="[object Uint32Array]",Dr=/\b__p \+= '';/g,br=/\b(__p \+=) '' \+/g,Ln=/(__e\(.*?\)|\b__t\)) \+\n'';/g,oi=/&(?:amp|lt|gt|quot|#39);/g,Fo=/[&<>"']/g,ru=RegExp(oi.source),nu=RegExp(Fo.source),iu=/<%-([\s\S]+?)%>/g,su=/<%([\s\S]+?)%>/g,Mo=/<%=([\s\S]+?)%>/g,ou=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,au=/^\w*$/,uu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ls=/[\\^$.*+?()[\]{}|]/g,lu=RegExp(ls.source),cs=/^\s+/,cu=/\s/,fu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,hu=/\{\n\/\* \[wrapped with (.+)\] \*/,du=/,? & /,pu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,_u=/[()=,{}\[\]\/\s]/,mu=/\\(\\)?/g,gu=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,No=/\w*$/,vu=/^[-+]0x[0-9a-f]+$/i,wu=/^0b[01]+$/i,yu=/^\[object .+?Constructor\]$/,Du=/^0o[0-7]+$/i,bu=/^(?:0|[1-9]\d*)$/,xu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Li=/($^)/,ai=/['\n\r\u2028\u2029\\]/g,Zt="\\ud800-\\udfff",er="\\u0300-\\u036f",Eu="\\ufe20-\\ufe2f",Ri="\\u20d0-\\u20ff",Rn=er+Eu+Ri,So="\\u2700-\\u27bf",Sh="a-z\\xdf-\\xf6\\xf8-\\xff",uD="\\xac\\xb1\\xd7\\xf7",lD="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",cD="\\u2000-\\u206f",fD=" \\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",Oh="A-Z\\xc0-\\xd6\\xd8-\\xde",Bh="\\ufe0e\\ufe0f",Ih=uD+lD+cD+fD,Au="['’]",hD="["+Zt+"]",Th="["+Ih+"]",Oo="["+Rn+"]",$h="\\d+",dD="["+So+"]",Lh="["+Sh+"]",Rh="[^"+Zt+Ih+$h+So+Sh+Oh+"]",Cu="\\ud83c[\\udffb-\\udfff]",pD="(?:"+Oo+"|"+Cu+")",Ph="[^"+Zt+"]",Fu="(?:\\ud83c[\\udde6-\\uddff]){2}",Mu="[\\ud800-\\udbff][\\udc00-\\udfff]",Pi="["+Oh+"]",zh="\\u200d",kh="(?:"+Lh+"|"+Rh+")",_D="(?:"+Pi+"|"+Rh+")",qh="(?:"+Au+"(?:d|ll|m|re|s|t|ve))?",Uh="(?:"+Au+"(?:D|LL|M|RE|S|T|VE))?",Wh=pD+"?",jh="["+Bh+"]?",mD="(?:"+zh+"(?:"+[Ph,Fu,Mu].join("|")+")"+jh+Wh+")*",gD="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",vD="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Vh=jh+Wh+mD,wD="(?:"+[dD,Fu,Mu].join("|")+")"+Vh,yD="(?:"+[Ph+Oo+"?",Oo,Fu,Mu,hD].join("|")+")",DD=RegExp(Au,"g"),bD=RegExp(Oo,"g"),Nu=RegExp(Cu+"(?="+Cu+")|"+yD+Vh,"g"),xD=RegExp([Pi+"?"+Lh+"+"+qh+"(?="+[Th,Pi,"$"].join("|")+")",_D+"+"+Uh+"(?="+[Th,Pi+kh,"$"].join("|")+")",Pi+"?"+kh+"+"+qh,Pi+"+"+Uh,vD,gD,$h,wD].join("|"),"g"),ED=RegExp("["+zh+Zt+Rn+Bh+"]"),AD=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,CD=["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"],FD=-1,ye={};ye[ft]=ye[ut]=ye[ht]=ye[at]=ye[Xt]=ye[ne]=ye[xe]=ye[Ve]=ye[qe]=!0,ye[bt]=ye[Ot]=ye[st]=ye[ue]=ye[rt]=ye[It]=ye[fe]=ye[re]=ye[Jt]=ye[Le]=ye[ke]=ye[mn]=ye[yr]=ye[$n]=ye[G]=!1;var me={};me[bt]=me[Ot]=me[st]=me[rt]=me[ue]=me[It]=me[ft]=me[ut]=me[ht]=me[at]=me[Xt]=me[Jt]=me[Le]=me[ke]=me[mn]=me[yr]=me[$n]=me[R]=me[ne]=me[xe]=me[Ve]=me[qe]=!0,me[fe]=me[re]=me[G]=!1;var MD={À:"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"},ND={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},SD={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},OD={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},BD=parseFloat,ID=parseInt,Yh=typeof Yt=="object"&&Yt&&Yt.Object===Object&&Yt,TD=typeof self=="object"&&self&&self.Object===Object&&self,Je=Yh||TD||Function("return this")(),Su=t&&!t.nodeType&&t,ui=Su&&!0&&i&&!i.nodeType&&i,Zh=ui&&ui.exports===Su,Ou=Zh&&Yh.process,Ir=function(){try{var j=ui&&ui.require&&ui.require("util").types;return j||Ou&&Ou.binding&&Ou.binding("util")}catch{}}(),Kh=Ir&&Ir.isArrayBuffer,Gh=Ir&&Ir.isDate,Hh=Ir&&Ir.isMap,Jh=Ir&&Ir.isRegExp,Xh=Ir&&Ir.isSet,Qh=Ir&&Ir.isTypedArray;function xr(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 $D(j,J,H,gt){for(var Bt=-1,te=j==null?0:j.length;++Bt<te;){var Ue=j[Bt];J(gt,Ue,H(Ue),j)}return gt}function Tr(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt&&J(j[H],H,j)!==!1;);return j}function LD(j,J){for(var H=j==null?0:j.length;H--&&J(j[H],H,j)!==!1;);return j}function t0(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(!J(j[H],H,j))return!1;return!0}function Pn(j,J){for(var H=-1,gt=j==null?0:j.length,Bt=0,te=[];++H<gt;){var Ue=j[H];J(Ue,H,j)&&(te[Bt++]=Ue)}return te}function Bo(j,J){var H=j==null?0:j.length;return!!H&&zi(j,J,0)>-1}function Bu(j,J,H){for(var gt=-1,Bt=j==null?0:j.length;++gt<Bt;)if(H(J,j[gt]))return!0;return!1}function Ee(j,J){for(var H=-1,gt=j==null?0:j.length,Bt=Array(gt);++H<gt;)Bt[H]=J(j[H],H,j);return Bt}function zn(j,J){for(var H=-1,gt=J.length,Bt=j.length;++H<gt;)j[Bt+H]=J[H];return j}function Iu(j,J,H,gt){var Bt=-1,te=j==null?0:j.length;for(gt&&te&&(H=j[++Bt]);++Bt<te;)H=J(H,j[Bt],Bt,j);return H}function RD(j,J,H,gt){var Bt=j==null?0:j.length;for(gt&&Bt&&(H=j[--Bt]);Bt--;)H=J(H,j[Bt],Bt,j);return H}function Tu(j,J){for(var H=-1,gt=j==null?0:j.length;++H<gt;)if(J(j[H],H,j))return!0;return!1}var PD=$u("length");function zD(j){return j.split("")}function kD(j){return j.match(pu)||[]}function e0(j,J,H){var gt;return H(j,function(Bt,te,Ue){if(J(Bt,te,Ue))return gt=te,!1}),gt}function Io(j,J,H,gt){for(var Bt=j.length,te=H+(gt?1:-1);gt?te--:++te<Bt;)if(J(j[te],te,j))return te;return-1}function zi(j,J,H){return J===J?XD(j,J,H):Io(j,r0,H)}function qD(j,J,H,gt){for(var Bt=H-1,te=j.length;++Bt<te;)if(gt(j[Bt],J))return Bt;return-1}function r0(j){return j!==j}function n0(j,J){var H=j==null?0:j.length;return H?Ru(j,J)/H:Q}function $u(j){return function(J){return J==null?e:J[j]}}function Lu(j){return function(J){return j==null?e:j[J]}}function i0(j,J,H,gt,Bt){return Bt(j,function(te,Ue,pe){H=gt?(gt=!1,te):J(H,te,Ue,pe)}),H}function UD(j,J){var H=j.length;for(j.sort(J);H--;)j[H]=j[H].value;return j}function Ru(j,J){for(var H,gt=-1,Bt=j.length;++gt<Bt;){var te=J(j[gt]);te!==e&&(H=H===e?te:H+te)}return H}function Pu(j,J){for(var H=-1,gt=Array(j);++H<j;)gt[H]=J(H);return gt}function WD(j,J){return Ee(J,function(H){return[H,j[H]]})}function s0(j){return j&&j.slice(0,l0(j)+1).replace(cs,"")}function Er(j){return function(J){return j(J)}}function zu(j,J){return Ee(J,function(H){return j[H]})}function fs(j,J){return j.has(J)}function o0(j,J){for(var H=-1,gt=j.length;++H<gt&&zi(J,j[H],0)>-1;);return H}function a0(j,J){for(var H=j.length;H--&&zi(J,j[H],0)>-1;);return H}function jD(j,J){for(var H=j.length,gt=0;H--;)j[H]===J&&++gt;return gt}var VD=Lu(MD),YD=Lu(ND);function ZD(j){return"\\"+OD[j]}function KD(j,J){return j==null?e:j[J]}function ki(j){return ED.test(j)}function GD(j){return AD.test(j)}function HD(j){for(var J,H=[];!(J=j.next()).done;)H.push(J.value);return H}function ku(j){var J=-1,H=Array(j.size);return j.forEach(function(gt,Bt){H[++J]=[Bt,gt]}),H}function u0(j,J){return function(H){return j(J(H))}}function kn(j,J){for(var H=-1,gt=j.length,Bt=0,te=[];++H<gt;){var Ue=j[H];(Ue===J||Ue===d)&&(j[H]=d,te[Bt++]=H)}return te}function To(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=gt}),H}function JD(j){var J=-1,H=Array(j.size);return j.forEach(function(gt){H[++J]=[gt,gt]}),H}function XD(j,J,H){for(var gt=H-1,Bt=j.length;++gt<Bt;)if(j[gt]===J)return gt;return-1}function QD(j,J,H){for(var gt=H+1;gt--;)if(j[gt]===J)return gt;return gt}function qi(j){return ki(j)?eb(j):PD(j)}function Kr(j){return ki(j)?rb(j):zD(j)}function l0(j){for(var J=j.length;J--&&cu.test(j.charAt(J)););return J}var tb=Lu(SD);function eb(j){for(var J=Nu.lastIndex=0;Nu.test(j);)++J;return J}function rb(j){return j.match(Nu)||[]}function nb(j){return j.match(xD)||[]}var ib=function j(J){J=J==null?Je:Ui.defaults(Je.Object(),J,Ui.pick(Je,CD));var H=J.Array,gt=J.Date,Bt=J.Error,te=J.Function,Ue=J.Math,pe=J.Object,qu=J.RegExp,sb=J.String,$r=J.TypeError,$o=H.prototype,ob=te.prototype,Wi=pe.prototype,Lo=J["__core-js_shared__"],Ro=ob.toString,le=Wi.hasOwnProperty,ab=0,c0=function(){var o=/[^.]+$/.exec(Lo&&Lo.keys&&Lo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),Po=Wi.toString,ub=Ro.call(pe),lb=Je._,cb=qu("^"+Ro.call(le).replace(ls,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),zo=Zh?J.Buffer:e,qn=J.Symbol,ko=J.Uint8Array,f0=zo?zo.allocUnsafe:e,qo=u0(pe.getPrototypeOf,pe),h0=pe.create,d0=Wi.propertyIsEnumerable,Uo=$o.splice,p0=qn?qn.isConcatSpreadable:e,hs=qn?qn.iterator:e,li=qn?qn.toStringTag:e,Wo=function(){try{var o=pi(pe,"defineProperty");return o({},"",{}),o}catch{}}(),fb=J.clearTimeout!==Je.clearTimeout&&J.clearTimeout,hb=gt&&gt.now!==Je.Date.now&&gt.now,db=J.setTimeout!==Je.setTimeout&&J.setTimeout,jo=Ue.ceil,Vo=Ue.floor,Uu=pe.getOwnPropertySymbols,pb=zo?zo.isBuffer:e,_0=J.isFinite,_b=$o.join,mb=u0(pe.keys,pe),We=Ue.max,rr=Ue.min,gb=gt.now,vb=J.parseInt,m0=Ue.random,wb=$o.reverse,Wu=pi(J,"DataView"),ds=pi(J,"Map"),ju=pi(J,"Promise"),ji=pi(J,"Set"),ps=pi(J,"WeakMap"),_s=pi(pe,"create"),Yo=ps&&new ps,Vi={},yb=_i(Wu),Db=_i(ds),bb=_i(ju),xb=_i(ji),Eb=_i(ps),Zo=qn?qn.prototype:e,ms=Zo?Zo.valueOf:e,g0=Zo?Zo.toString:e;function B(o){if(Ne(o)&&!Tt(o)&&!(o instanceof jt)){if(o instanceof Lr)return o;if(le.call(o,"__wrapped__"))return vd(o)}return new Lr(o)}var Yi=function(){function o(){}return function(u){if(!Fe(u))return{};if(h0)return h0(u);o.prototype=u;var _=new o;return o.prototype=e,_}}();function Ko(){}function Lr(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}B.templateSettings={escape:iu,evaluate:su,interpolate:Mo,variable:"",imports:{_:B}},B.prototype=Ko.prototype,B.prototype.constructor=B,Lr.prototype=Yi(Ko.prototype),Lr.prototype.constructor=Lr;function jt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ct,this.__views__=[]}function Ab(){var o=new jt(this.__wrapped__);return o.__actions__=hr(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=hr(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=hr(this.__views__),o}function Cb(){if(this.__filtered__){var o=new jt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function Fb(){var o=this.__wrapped__.value(),u=this.__dir__,_=Tt(o),D=u<0,C=_?o.length:0,I=zx(0,C,this.__views__),P=I.start,k=I.end,V=k-P,tt=D?k:P-1,et=this.__iteratees__,ot=et.length,pt=0,wt=rr(V,this.__takeCount__);if(!_||!D&&C==V&&wt==V)return q0(o,this.__actions__);var Ct=[];t:for(;V--&&pt<wt;){tt+=u;for(var Rt=-1,Ft=o[tt];++Rt<ot;){var Ut=et[Rt],Vt=Ut.iteratee,Fr=Ut.type,ur=Vt(Ft);if(Fr==W)Ft=ur;else if(!ur){if(Fr==U)continue t;break t}}Ct[pt++]=Ft}return Ct}jt.prototype=Yi(Ko.prototype),jt.prototype.constructor=jt;function ci(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function Mb(){this.__data__=_s?_s(null):{},this.size=0}function Nb(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(_s){var _=u[o];return _===c?e:_}return le.call(u,o)?u[o]:e}function Ob(o){var u=this.__data__;return _s?u[o]!==e:le.call(u,o)}function Bb(o,u){var _=this.__data__;return this.size+=this.has(o)?0:1,_[o]=_s&&u===e?c:u,this}ci.prototype.clear=Mb,ci.prototype.delete=Nb,ci.prototype.get=Sb,ci.prototype.has=Ob,ci.prototype.set=Bb;function gn(o){var u=-1,_=o==null?0:o.length;for(this.clear();++u<_;){var D=o[u];this.set(D[0],D[1])}}function Ib(){this.__data__=[],this.size=0}function Tb(o){var u=this.__data__,_=Go(u,o);if(_<0)return!1;var D=u.length-1;return _==D?u.pop():Uo.call(u,_,1),--this.size,!0}function $b(o){var u=this.__data__,_=Go(u,o);return _<0?e:u[_][1]}function Lb(o){return Go(this.__data__,o)>-1}function Rb(o,u){var _=this.__data__,D=Go(_,o);return D<0?(++this.size,_.push([o,u])):_[D][1]=u,this}gn.prototype.clear=Ib,gn.prototype.delete=Tb,gn.prototype.get=$b,gn.prototype.has=Lb,gn.prototype.set=Rb;function vn(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 ci,map:new(ds||gn),string:new ci}}function zb(o){var u=aa(this,o).delete(o);return this.size-=u?1:0,u}function kb(o){return aa(this,o).get(o)}function qb(o){return aa(this,o).has(o)}function Ub(o,u){var _=aa(this,o),D=_.size;return _.set(o,u),this.size+=_.size==D?0:1,this}vn.prototype.clear=Pb,vn.prototype.delete=zb,vn.prototype.get=kb,vn.prototype.has=qb,vn.prototype.set=Ub;function fi(o){var u=-1,_=o==null?0:o.length;for(this.__data__=new vn;++u<_;)this.add(o[u])}function Wb(o){return this.__data__.set(o,c),this}function jb(o){return this.__data__.has(o)}fi.prototype.add=fi.prototype.push=Wb,fi.prototype.has=jb;function Gr(o){var u=this.__data__=new gn(o);this.size=u.size}function Vb(){this.__data__=new gn,this.size=0}function Yb(o){var u=this.__data__,_=u.delete(o);return this.size=u.size,_}function Zb(o){return this.__data__.get(o)}function Kb(o){return this.__data__.has(o)}function Gb(o,u){var _=this.__data__;if(_ instanceof gn){var D=_.__data__;if(!ds||D.length<n-1)return D.push([o,u]),this.size=++_.size,this;_=this.__data__=new vn(D)}return _.set(o,u),this.size=_.size,this}Gr.prototype.clear=Vb,Gr.prototype.delete=Yb,Gr.prototype.get=Zb,Gr.prototype.has=Kb,Gr.prototype.set=Gb;function v0(o,u){var _=Tt(o),D=!_&&mi(o),C=!_&&!D&&Yn(o),I=!_&&!D&&!C&&Hi(o),P=_||D||C||I,k=P?Pu(o.length,sb):[],V=k.length;for(var tt in o)(u||le.call(o,tt))&&!(P&&(tt=="length"||C&&(tt=="offset"||tt=="parent")||I&&(tt=="buffer"||tt=="byteLength"||tt=="byteOffset")||bn(tt,V)))&&k.push(tt);return k}function w0(o){var u=o.length;return u?o[el(0,u-1)]:e}function Hb(o,u){return ua(hr(o),hi(u,0,o.length))}function Jb(o){return ua(hr(o))}function Vu(o,u,_){(_!==e&&!Hr(o[u],_)||_===e&&!(u in o))&&wn(o,u,_)}function gs(o,u,_){var D=o[u];(!(le.call(o,u)&&Hr(D,_))||_===e&&!(u in o))&&wn(o,u,_)}function Go(o,u){for(var _=o.length;_--;)if(Hr(o[_][0],u))return _;return-1}function Xb(o,u,_,D){return Un(o,function(C,I,P){u(D,C,_(C),P)}),D}function y0(o,u){return o&&an(u,Ye(u),o)}function Qb(o,u){return o&&an(u,pr(u),o)}function wn(o,u,_){u=="__proto__"&&Wo?Wo(o,u,{configurable:!0,enumerable:!0,value:_,writable:!0}):o[u]=_}function Yu(o,u){for(var _=-1,D=u.length,C=H(D),I=o==null;++_<D;)C[_]=I?e:Cl(o,u[_]);return C}function hi(o,u,_){return o===o&&(_!==e&&(o=o<=_?o:_),u!==e&&(o=o>=u?o:u)),o}function Rr(o,u,_,D,C,I){var P,k=u&f,V=u&p,tt=u&g;if(_&&(P=C?_(o,D,C,I):_(o)),P!==e)return P;if(!Fe(o))return o;var et=Tt(o);if(et){if(P=qx(o),!k)return hr(o,P)}else{var ot=nr(o),pt=ot==re||ot==qt;if(Yn(o))return j0(o,k);if(ot==ke||ot==bt||pt&&!C){if(P=V||pt?{}:ld(o),!k)return V?Sx(o,Qb(P,o)):Nx(o,y0(P,o))}else{if(!me[ot])return C?o:{};P=Ux(o,ot,k)}}I||(I=new Gr);var wt=I.get(o);if(wt)return wt;I.set(o,P),Pd(o)?o.forEach(function(Ft){P.add(Rr(Ft,u,_,Ft,o,I))}):Ld(o)&&o.forEach(function(Ft,Ut){P.set(Ut,Rr(Ft,u,_,Ut,o,I))});var Ct=tt?V?hl:fl:V?pr:Ye,Rt=et?e:Ct(o);return Tr(Rt||o,function(Ft,Ut){Rt&&(Ut=Ft,Ft=o[Ut]),gs(P,Ut,Rr(Ft,u,_,Ut,o,I))}),P}function tx(o){var u=Ye(o);return function(_){return D0(_,o,u)}}function D0(o,u,_){var D=_.length;if(o==null)return!D;for(o=pe(o);D--;){var C=_[D],I=u[C],P=o[C];if(P===e&&!(C in o)||!I(P))return!1}return!0}function b0(o,u,_){if(typeof o!="function")throw new $r(a);return Es(function(){o.apply(e,_)},u)}function vs(o,u,_,D){var C=-1,I=Bo,P=!0,k=o.length,V=[],tt=u.length;if(!k)return V;_&&(u=Ee(u,Er(_))),D?(I=Bu,P=!1):u.length>=n&&(I=fs,P=!1,u=new fi(u));t:for(;++C<k;){var et=o[C],ot=_==null?et:_(et);if(et=D||et!==0?et:0,P&&ot===ot){for(var pt=tt;pt--;)if(u[pt]===ot)continue t;V.push(et)}else I(u,ot,D)||V.push(et)}return V}var Un=G0(on),x0=G0(Ku,!0);function ex(o,u){var _=!0;return Un(o,function(D,C,I){return _=!!u(D,C,I),_}),_}function Ho(o,u,_){for(var D=-1,C=o.length;++D<C;){var I=o[D],P=u(I);if(P!=null&&(k===e?P===P&&!Cr(P):_(P,k)))var k=P,V=I}return V}function rx(o,u,_,D){var C=o.length;for(_=Lt(_),_<0&&(_=-_>C?0:C+_),D=D===e||D>C?C:Lt(D),D<0&&(D+=C),D=_>D?0:kd(D);_<D;)o[_++]=u;return o}function E0(o,u){var _=[];return Un(o,function(D,C,I){u(D,C,I)&&_.push(D)}),_}function Xe(o,u,_,D,C){var I=-1,P=o.length;for(_||(_=jx),C||(C=[]);++I<P;){var k=o[I];u>0&&_(k)?u>1?Xe(k,u-1,_,D,C):zn(C,k):D||(C[C.length]=k)}return C}var Zu=H0(),A0=H0(!0);function on(o,u){return o&&Zu(o,u,Ye)}function Ku(o,u){return o&&A0(o,u,Ye)}function Jo(o,u){return Pn(u,function(_){return xn(o[_])})}function di(o,u){u=jn(u,o);for(var _=0,D=u.length;o!=null&&_<D;)o=o[un(u[_++])];return _&&_==D?o:e}function C0(o,u,_){var D=u(o);return Tt(o)?D:zn(D,_(o))}function or(o){return o==null?o===e?Y:wr:li&&li in pe(o)?Px(o):Jx(o)}function Gu(o,u){return o>u}function nx(o,u){return o!=null&&le.call(o,u)}function ix(o,u){return o!=null&&u in pe(o)}function sx(o,u,_){return o>=rr(u,_)&&o<We(u,_)}function Hu(o,u,_){for(var D=_?Bu:Bo,C=o[0].length,I=o.length,P=I,k=H(I),V=1/0,tt=[];P--;){var et=o[P];P&&u&&(et=Ee(et,Er(u))),V=rr(et.length,V),k[P]=!_&&(u||C>=120&&et.length>=120)?new fi(P&&et):e}et=o[0];var ot=-1,pt=k[0];t:for(;++ot<C&&tt.length<V;){var wt=et[ot],Ct=u?u(wt):wt;if(wt=_||wt!==0?wt:0,!(pt?fs(pt,Ct):D(tt,Ct,_))){for(P=I;--P;){var Rt=k[P];if(!(Rt?fs(Rt,Ct):D(o[P],Ct,_)))continue t}pt&&pt.push(Ct),tt.push(wt)}}return tt}function ox(o,u,_,D){return on(o,function(C,I,P){u(D,_(C),I,P)}),D}function ws(o,u,_){u=jn(u,o),o=dd(o,u);var D=o==null?o:o[un(zr(u))];return D==null?e:xr(D,o,_)}function F0(o){return Ne(o)&&or(o)==bt}function ax(o){return Ne(o)&&or(o)==st}function ux(o){return Ne(o)&&or(o)==It}function ys(o,u,_,D,C){return o===u?!0:o==null||u==null||!Ne(o)&&!Ne(u)?o!==o&&u!==u:lx(o,u,_,D,ys,C)}function lx(o,u,_,D,C,I){var P=Tt(o),k=Tt(u),V=P?Ot:nr(o),tt=k?Ot:nr(u);V=V==bt?ke:V,tt=tt==bt?ke:tt;var et=V==ke,ot=tt==ke,pt=V==tt;if(pt&&Yn(o)){if(!Yn(u))return!1;P=!0,et=!1}if(pt&&!et)return I||(I=new Gr),P||Hi(o)?od(o,u,_,D,C,I):Lx(o,u,V,_,D,C,I);if(!(_&w)){var wt=et&&le.call(o,"__wrapped__"),Ct=ot&&le.call(u,"__wrapped__");if(wt||Ct){var Rt=wt?o.value():o,Ft=Ct?u.value():u;return I||(I=new Gr),C(Rt,Ft,_,D,I)}}return pt?(I||(I=new Gr),Rx(o,u,_,D,C,I)):!1}function cx(o){return Ne(o)&&nr(o)==Jt}function Ju(o,u,_,D){var C=_.length,I=C,P=!D;if(o==null)return!I;for(o=pe(o);C--;){var k=_[C];if(P&&k[2]?k[1]!==o[k[0]]:!(k[0]in o))return!1}for(;++C<I;){k=_[C];var V=k[0],tt=o[V],et=k[1];if(P&&k[2]){if(tt===e&&!(V in o))return!1}else{var ot=new Gr;if(D)var pt=D(tt,et,V,o,u,ot);if(!(pt===e?ys(et,tt,w|m,D,ot):pt))return!1}}return!0}function M0(o){if(!Fe(o)||Yx(o))return!1;var u=xn(o)?cb:yu;return u.test(_i(o))}function fx(o){return Ne(o)&&or(o)==mn}function hx(o){return Ne(o)&&nr(o)==yr}function dx(o){return Ne(o)&&pa(o.length)&&!!ye[or(o)]}function N0(o){return typeof o=="function"?o:o==null?_r:typeof o=="object"?Tt(o)?B0(o[0],o[1]):O0(o):Jd(o)}function Xu(o){if(!xs(o))return mb(o);var u=[];for(var _ in pe(o))le.call(o,_)&&_!="constructor"&&u.push(_);return u}function px(o){if(!Fe(o))return Hx(o);var u=xs(o),_=[];for(var D in o)D=="constructor"&&(u||!le.call(o,D))||_.push(D);return _}function Qu(o,u){return o<u}function S0(o,u){var _=-1,D=dr(o)?H(o.length):[];return Un(o,function(C,I,P){D[++_]=u(C,I,P)}),D}function O0(o){var u=pl(o);return u.length==1&&u[0][2]?fd(u[0][0],u[0][1]):function(_){return _===o||Ju(_,o,u)}}function B0(o,u){return ml(o)&&cd(u)?fd(un(o),u):function(_){var D=Cl(_,o);return D===e&&D===u?Fl(_,o):ys(u,D,w|m)}}function Xo(o,u,_,D,C){o!==u&&Zu(u,function(I,P){if(C||(C=new Gr),Fe(I))_x(o,u,P,_,Xo,D,C);else{var k=D?D(vl(o,P),I,P+"",o,u,C):e;k===e&&(k=I),Vu(o,P,k)}},pr)}function _x(o,u,_,D,C,I,P){var k=vl(o,_),V=vl(u,_),tt=P.get(V);if(tt){Vu(o,_,tt);return}var et=I?I(k,V,_+"",o,u,P):e,ot=et===e;if(ot){var pt=Tt(V),wt=!pt&&Yn(V),Ct=!pt&&!wt&&Hi(V);et=V,pt||wt||Ct?Tt(k)?et=k:Be(k)?et=hr(k):wt?(ot=!1,et=j0(V,!0)):Ct?(ot=!1,et=V0(V,!0)):et=[]:As(V)||mi(V)?(et=k,mi(k)?et=qd(k):(!Fe(k)||xn(k))&&(et=ld(V))):ot=!1}ot&&(P.set(V,et),C(et,V,D,I,P),P.delete(V)),Vu(o,_,et)}function I0(o,u){var _=o.length;if(_)return u+=u<0?_:0,bn(u,_)?o[u]:e}function T0(o,u,_){u.length?u=Ee(u,function(I){return Tt(I)?function(P){return di(P,I.length===1?I[0]:I)}:I}):u=[_r];var D=-1;u=Ee(u,Er(At()));var C=S0(o,function(I,P,k){var V=Ee(u,function(tt){return tt(I)});return{criteria:V,index:++D,value:I}});return UD(C,function(I,P){return Mx(I,P,_)})}function mx(o,u){return $0(o,u,function(_,D){return Fl(o,D)})}function $0(o,u,_){for(var D=-1,C=u.length,I={};++D<C;){var P=u[D],k=di(o,P);_(k,P)&&Ds(I,jn(P,o),k)}return I}function gx(o){return function(u){return di(u,o)}}function tl(o,u,_,D){var C=D?qD:zi,I=-1,P=u.length,k=o;for(o===u&&(u=hr(u)),_&&(k=Ee(o,Er(_)));++I<P;)for(var V=0,tt=u[I],et=_?_(tt):tt;(V=C(k,et,V,D))>-1;)k!==o&&Uo.call(k,V,1),Uo.call(o,V,1);return o}function L0(o,u){for(var _=o?u.length:0,D=_-1;_--;){var C=u[_];if(_==D||C!==I){var I=C;bn(C)?Uo.call(o,C,1):il(o,C)}}return o}function el(o,u){return o+Vo(m0()*(u-o+1))}function vx(o,u,_,D){for(var C=-1,I=We(jo((u-o)/(_||1)),0),P=H(I);I--;)P[D?I:++C]=o,o+=_;return P}function rl(o,u){var _="";if(!o||u<1||u>Z)return _;do u%2&&(_+=o),u=Vo(u/2),u&&(o+=o);while(u);return _}function zt(o,u){return wl(hd(o,u,_r),o+"")}function wx(o){return w0(Ji(o))}function yx(o,u){var _=Ji(o);return ua(_,hi(u,0,_.length))}function Ds(o,u,_,D){if(!Fe(o))return o;u=jn(u,o);for(var C=-1,I=u.length,P=I-1,k=o;k!=null&&++C<I;){var V=un(u[C]),tt=_;if(V==="__proto__"||V==="constructor"||V==="prototype")return o;if(C!=P){var et=k[V];tt=D?D(et,V,k):e,tt===e&&(tt=Fe(et)?et:bn(u[C+1])?[]:{})}gs(k,V,tt),k=k[V]}return o}var R0=Yo?function(o,u){return Yo.set(o,u),o}:_r,Dx=Wo?function(o,u){return Wo(o,"toString",{configurable:!0,enumerable:!1,value:Nl(u),writable:!0})}:_r;function bx(o){return ua(Ji(o))}function Pr(o,u,_){var D=-1,C=o.length;u<0&&(u=-u>C?0:C+u),_=_>C?C:_,_<0&&(_+=C),C=u>_?0:_-u>>>0,u>>>=0;for(var I=H(C);++D<C;)I[D]=o[D+u];return I}function xx(o,u){var _;return Un(o,function(D,C,I){return _=u(D,C,I),!_}),!!_}function Qo(o,u,_){var D=0,C=o==null?D:o.length;if(typeof u=="number"&&u===u&&C<=lt){for(;D<C;){var I=D+C>>>1,P=o[I];P!==null&&!Cr(P)&&(_?P<=u:P<u)?D=I+1:C=I}return C}return nl(o,u,_r,_)}function nl(o,u,_,D){var C=0,I=o==null?0:o.length;if(I===0)return 0;u=_(u);for(var P=u!==u,k=u===null,V=Cr(u),tt=u===e;C<I;){var et=Vo((C+I)/2),ot=_(o[et]),pt=ot!==e,wt=ot===null,Ct=ot===ot,Rt=Cr(ot);if(P)var Ft=D||Ct;else tt?Ft=Ct&&(D||pt):k?Ft=Ct&&pt&&(D||!wt):V?Ft=Ct&&pt&&!wt&&(D||!Rt):wt||Rt?Ft=!1:Ft=D?ot<=u:ot<u;Ft?C=et+1:I=et}return rr(I,vt)}function P0(o,u){for(var _=-1,D=o.length,C=0,I=[];++_<D;){var P=o[_],k=u?u(P):P;if(!_||!Hr(k,V)){var V=k;I[C++]=P===0?0:P}}return I}function z0(o){return typeof o=="number"?o:Cr(o)?Q:+o}function Ar(o){if(typeof o=="string")return o;if(Tt(o))return Ee(o,Ar)+"";if(Cr(o))return g0?g0.call(o):"";var u=o+"";return u=="0"&&1/o==-K?"-0":u}function Wn(o,u,_){var D=-1,C=Bo,I=o.length,P=!0,k=[],V=k;if(_)P=!1,C=Bu;else if(I>=n){var tt=u?null:Tx(o);if(tt)return To(tt);P=!1,C=fs,V=new fi}else V=u?[]:k;t:for(;++D<I;){var et=o[D],ot=u?u(et):et;if(et=_||et!==0?et:0,P&&ot===ot){for(var pt=V.length;pt--;)if(V[pt]===ot)continue t;u&&V.push(ot),k.push(et)}else C(V,ot,_)||(V!==k&&V.push(ot),k.push(et))}return k}function il(o,u){return u=jn(u,o),o=dd(o,u),o==null||delete o[un(zr(u))]}function k0(o,u,_,D){return Ds(o,u,_(di(o,u)),D)}function ta(o,u,_,D){for(var C=o.length,I=D?C:-1;(D?I--:++I<C)&&u(o[I],I,o););return _?Pr(o,D?0:I,D?I+1:C):Pr(o,D?I+1:0,D?C:I)}function q0(o,u){var _=o;return _ instanceof jt&&(_=_.value()),Iu(u,function(D,C){return C.func.apply(C.thisArg,zn([D],C.args))},_)}function sl(o,u,_){var D=o.length;if(D<2)return D?Wn(o[0]):[];for(var C=-1,I=H(D);++C<D;)for(var P=o[C],k=-1;++k<D;)k!=C&&(I[C]=vs(I[C]||P,o[k],u,_));return Wn(Xe(I,1),u,_)}function U0(o,u,_){for(var D=-1,C=o.length,I=u.length,P={};++D<C;){var k=D<I?u[D]:e;_(P,o[D],k)}return P}function ol(o){return Be(o)?o:[]}function al(o){return typeof o=="function"?o:_r}function jn(o,u){return Tt(o)?o:ml(o,u)?[o]:gd(ie(o))}var Ex=zt;function Vn(o,u,_){var D=o.length;return _=_===e?D:_,!u&&_>=D?o:Pr(o,u,_)}var W0=fb||function(o){return Je.clearTimeout(o)};function j0(o,u){if(u)return o.slice();var _=o.length,D=f0?f0(_):new o.constructor(_);return o.copy(D),D}function ul(o){var u=new o.constructor(o.byteLength);return new ko(u).set(new ko(o)),u}function Ax(o,u){var _=u?ul(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.byteLength)}function Cx(o){var u=new o.constructor(o.source,No.exec(o));return u.lastIndex=o.lastIndex,u}function Fx(o){return ms?pe(ms.call(o)):{}}function V0(o,u){var _=u?ul(o.buffer):o.buffer;return new o.constructor(_,o.byteOffset,o.length)}function Y0(o,u){if(o!==u){var _=o!==e,D=o===null,C=o===o,I=Cr(o),P=u!==e,k=u===null,V=u===u,tt=Cr(u);if(!k&&!tt&&!I&&o>u||I&&P&&V&&!k&&!tt||D&&P&&V||!_&&V||!C)return 1;if(!D&&!I&&!tt&&o<u||tt&&_&&C&&!D&&!I||k&&_&&C||!P&&C||!V)return-1}return 0}function Mx(o,u,_){for(var D=-1,C=o.criteria,I=u.criteria,P=C.length,k=_.length;++D<P;){var V=Y0(C[D],I[D]);if(V){if(D>=k)return V;var tt=_[D];return V*(tt=="desc"?-1:1)}}return o.index-u.index}function Z0(o,u,_,D){for(var C=-1,I=o.length,P=_.length,k=-1,V=u.length,tt=We(I-P,0),et=H(V+tt),ot=!D;++k<V;)et[k]=u[k];for(;++C<P;)(ot||C<I)&&(et[_[C]]=o[C]);for(;tt--;)et[k++]=o[C++];return et}function K0(o,u,_,D){for(var C=-1,I=o.length,P=-1,k=_.length,V=-1,tt=u.length,et=We(I-k,0),ot=H(et+tt),pt=!D;++C<et;)ot[C]=o[C];for(var wt=C;++V<tt;)ot[wt+V]=u[V];for(;++P<k;)(pt||C<I)&&(ot[wt+_[P]]=o[C++]);return ot}function hr(o,u){var _=-1,D=o.length;for(u||(u=H(D));++_<D;)u[_]=o[_];return u}function an(o,u,_,D){var C=!_;_||(_={});for(var I=-1,P=u.length;++I<P;){var k=u[I],V=D?D(_[k],o[k],k,_,o):e;V===e&&(V=o[k]),C?wn(_,k,V):gs(_,k,V)}return _}function Nx(o,u){return an(o,_l(o),u)}function Sx(o,u){return an(o,ad(o),u)}function ea(o,u){return function(_,D){var C=Tt(_)?$D:Xb,I=u?u():{};return C(_,o,At(D,2),I)}}function Zi(o){return zt(function(u,_){var D=-1,C=_.length,I=C>1?_[C-1]:e,P=C>2?_[2]:e;for(I=o.length>3&&typeof I=="function"?(C--,I):e,P&&ar(_[0],_[1],P)&&(I=C<3?e:I,C=1),u=pe(u);++D<C;){var k=_[D];k&&o(u,k,D,I)}return u})}function G0(o,u){return function(_,D){if(_==null)return _;if(!dr(_))return o(_,D);for(var C=_.length,I=u?C:-1,P=pe(_);(u?I--:++I<C)&&D(P[I],I,P)!==!1;);return _}}function H0(o){return function(u,_,D){for(var C=-1,I=pe(u),P=D(u),k=P.length;k--;){var V=P[o?k:++C];if(_(I[V],V,I)===!1)break}return u}}function Ox(o,u,_){var D=u&y,C=bs(o);function I(){var P=this&&this!==Je&&this instanceof I?C:o;return P.apply(D?_:this,arguments)}return I}function J0(o){return function(u){u=ie(u);var _=ki(u)?Kr(u):e,D=_?_[0]:u.charAt(0),C=_?Vn(_,1).join(""):u.slice(1);return D[o]()+C}}function Ki(o){return function(u){return Iu(Gd(Kd(u).replace(DD,"")),o,"")}}function bs(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 _=Yi(o.prototype),D=o.apply(_,u);return Fe(D)?D:_}}function Bx(o,u,_){var D=bs(o);function C(){for(var I=arguments.length,P=H(I),k=I,V=Gi(C);k--;)P[k]=arguments[k];var tt=I<3&&P[0]!==V&&P[I-1]!==V?[]:kn(P,V);if(I-=tt.length,I<_)return rd(o,u,ra,C.placeholder,e,P,tt,e,e,_-I);var et=this&&this!==Je&&this instanceof C?D:o;return xr(et,this,P)}return C}function X0(o){return function(u,_,D){var C=pe(u);if(!dr(u)){var I=At(_,3);u=Ye(u),_=function(k){return I(C[k],k,C)}}var P=o(u,_,D);return P>-1?C[I?u[P]:P]:e}}function Q0(o){return Dn(function(u){var _=u.length,D=_,C=Lr.prototype.thru;for(o&&u.reverse();D--;){var I=u[D];if(typeof I!="function")throw new $r(a);if(C&&!P&&oa(I)=="wrapper")var P=new Lr([],!0)}for(D=P?D:_;++D<_;){I=u[D];var k=oa(I),V=k=="wrapper"?dl(I):e;V&&gl(V[0])&&V[1]==(N|b|E|S)&&!V[4].length&&V[9]==1?P=P[oa(V[0])].apply(P,V[3]):P=I.length==1&&gl(I)?P[k]():P.thru(I)}return function(){var tt=arguments,et=tt[0];if(P&&tt.length==1&&Tt(et))return P.plant(et).value();for(var ot=0,pt=_?u[ot].apply(this,tt):et;++ot<_;)pt=u[ot].call(this,pt);return pt}})}function ra(o,u,_,D,C,I,P,k,V,tt){var et=u&N,ot=u&y,pt=u&v,wt=u&(b|M),Ct=u&T,Rt=pt?e:bs(o);function Ft(){for(var Ut=arguments.length,Vt=H(Ut),Fr=Ut;Fr--;)Vt[Fr]=arguments[Fr];if(wt)var ur=Gi(Ft),Mr=jD(Vt,ur);if(D&&(Vt=Z0(Vt,D,C,wt)),I&&(Vt=K0(Vt,I,P,wt)),Ut-=Mr,wt&&Ut<tt){var Ie=kn(Vt,ur);return rd(o,u,ra,Ft.placeholder,_,Vt,Ie,k,V,tt-Ut)}var Jr=ot?_:this,An=pt?Jr[o]:o;return Ut=Vt.length,k?Vt=Xx(Vt,k):Ct&&Ut>1&&Vt.reverse(),et&&V<Ut&&(Vt.length=V),this&&this!==Je&&this instanceof Ft&&(An=Rt||bs(An)),An.apply(Jr,Vt)}return Ft}function td(o,u){return function(_,D){return ox(_,o,u(D),{})}}function na(o,u){return function(_,D){var C;if(_===e&&D===e)return u;if(_!==e&&(C=_),D!==e){if(C===e)return D;typeof _=="string"||typeof D=="string"?(_=Ar(_),D=Ar(D)):(_=z0(_),D=z0(D)),C=o(_,D)}return C}}function ll(o){return Dn(function(u){return u=Ee(u,Er(At())),zt(function(_){var D=this;return o(u,function(C){return xr(C,D,_)})})})}function ia(o,u){u=u===e?" ":Ar(u);var _=u.length;if(_<2)return _?rl(u,o):u;var D=rl(u,jo(o/qi(u)));return ki(u)?Vn(Kr(D),0,o).join(""):D.slice(0,o)}function Ix(o,u,_,D){var C=u&y,I=bs(o);function P(){for(var k=-1,V=arguments.length,tt=-1,et=D.length,ot=H(et+V),pt=this&&this!==Je&&this instanceof P?I:o;++tt<et;)ot[tt]=D[tt];for(;V--;)ot[tt++]=arguments[++k];return xr(pt,C?_:this,ot)}return P}function ed(o){return function(u,_,D){return D&&typeof D!="number"&&ar(u,_,D)&&(_=D=e),u=En(u),_===e?(_=u,u=0):_=En(_),D=D===e?u<_?1:-1:En(D),vx(u,_,D,o)}}function sa(o){return function(u,_){return typeof u=="string"&&typeof _=="string"||(u=kr(u),_=kr(_)),o(u,_)}}function rd(o,u,_,D,C,I,P,k,V,tt){var et=u&b,ot=et?P:e,pt=et?e:P,wt=et?I:e,Ct=et?e:I;u|=et?E:F,u&=~(et?F:E),u&x||(u&=~(y|v));var Rt=[o,u,C,wt,ot,Ct,pt,k,V,tt],Ft=_.apply(e,Rt);return gl(o)&&pd(Ft,Rt),Ft.placeholder=D,_d(Ft,o,u)}function cl(o){var u=Ue[o];return function(_,D){if(_=kr(_),D=D==null?0:rr(Lt(D),292),D&&_0(_)){var C=(ie(_)+"e").split("e"),I=u(C[0]+"e"+(+C[1]+D));return C=(ie(I)+"e").split("e"),+(C[0]+"e"+(+C[1]-D))}return u(_)}}var Tx=ji&&1/To(new ji([,-0]))[1]==K?function(o){return new ji(o)}:Bl;function nd(o){return function(u){var _=nr(u);return _==Jt?ku(u):_==yr?JD(u):WD(u,o(u))}}function yn(o,u,_,D,C,I,P,k){var V=u&v;if(!V&&typeof o!="function")throw new $r(a);var tt=D?D.length:0;if(tt||(u&=~(E|F),D=C=e),P=P===e?P:We(Lt(P),0),k=k===e?k:Lt(k),tt-=C?C.length:0,u&F){var et=D,ot=C;D=C=e}var pt=V?e:dl(o),wt=[o,u,_,D,C,et,ot,I,P,k];if(pt&&Gx(wt,pt),o=wt[0],u=wt[1],_=wt[2],D=wt[3],C=wt[4],k=wt[9]=wt[9]===e?V?0:o.length:We(wt[9]-tt,0),!k&&u&(b|M)&&(u&=~(b|M)),!u||u==y)var Ct=Ox(o,u,_);else u==b||u==M?Ct=Bx(o,u,k):(u==E||u==(y|E))&&!C.length?Ct=Ix(o,u,_,D):Ct=ra.apply(e,wt);var Rt=pt?R0:pd;return _d(Rt(Ct,wt),o,u)}function id(o,u,_,D){return o===e||Hr(o,Wi[_])&&!le.call(D,_)?u:o}function sd(o,u,_,D,C,I){return Fe(o)&&Fe(u)&&(I.set(u,o),Xo(o,u,e,sd,I),I.delete(u)),o}function $x(o){return As(o)?e:o}function od(o,u,_,D,C,I){var P=_&w,k=o.length,V=u.length;if(k!=V&&!(P&&V>k))return!1;var tt=I.get(o),et=I.get(u);if(tt&&et)return tt==u&&et==o;var ot=-1,pt=!0,wt=_&m?new fi:e;for(I.set(o,u),I.set(u,o);++ot<k;){var Ct=o[ot],Rt=u[ot];if(D)var Ft=P?D(Rt,Ct,ot,u,o,I):D(Ct,Rt,ot,o,u,I);if(Ft!==e){if(Ft)continue;pt=!1;break}if(wt){if(!Tu(u,function(Ut,Vt){if(!fs(wt,Vt)&&(Ct===Ut||C(Ct,Ut,_,D,I)))return wt.push(Vt)})){pt=!1;break}}else if(!(Ct===Rt||C(Ct,Rt,_,D,I))){pt=!1;break}}return I.delete(o),I.delete(u),pt}function Lx(o,u,_,D,C,I,P){switch(_){case rt:if(o.byteLength!=u.byteLength||o.byteOffset!=u.byteOffset)return!1;o=o.buffer,u=u.buffer;case st:return!(o.byteLength!=u.byteLength||!I(new ko(o),new ko(u)));case ue:case It:case Le:return Hr(+o,+u);case fe:return o.name==u.name&&o.message==u.message;case mn:case $n:return o==u+"";case Jt:var k=ku;case yr:var V=D&w;if(k||(k=To),o.size!=u.size&&!V)return!1;var tt=P.get(o);if(tt)return tt==u;D|=m,P.set(o,u);var et=od(k(o),k(u),D,C,I,P);return P.delete(o),et;case R:if(ms)return ms.call(o)==ms.call(u)}return!1}function Rx(o,u,_,D,C,I){var P=_&w,k=fl(o),V=k.length,tt=fl(u),et=tt.length;if(V!=et&&!P)return!1;for(var ot=V;ot--;){var pt=k[ot];if(!(P?pt in u:le.call(u,pt)))return!1}var wt=I.get(o),Ct=I.get(u);if(wt&&Ct)return wt==u&&Ct==o;var Rt=!0;I.set(o,u),I.set(u,o);for(var Ft=P;++ot<V;){pt=k[ot];var Ut=o[pt],Vt=u[pt];if(D)var Fr=P?D(Vt,Ut,pt,u,o,I):D(Ut,Vt,pt,o,u,I);if(!(Fr===e?Ut===Vt||C(Ut,Vt,_,D,I):Fr)){Rt=!1;break}Ft||(Ft=pt=="constructor")}if(Rt&&!Ft){var ur=o.constructor,Mr=u.constructor;ur!=Mr&&"constructor"in o&&"constructor"in u&&!(typeof ur=="function"&&ur instanceof ur&&typeof Mr=="function"&&Mr instanceof Mr)&&(Rt=!1)}return I.delete(o),I.delete(u),Rt}function Dn(o){return wl(hd(o,e,Dd),o+"")}function fl(o){return C0(o,Ye,_l)}function hl(o){return C0(o,pr,ad)}var dl=Yo?function(o){return Yo.get(o)}:Bl;function oa(o){for(var u=o.name+"",_=Vi[u],D=le.call(Vi,u)?_.length:0;D--;){var C=_[D],I=C.func;if(I==null||I==o)return C.name}return u}function Gi(o){var u=le.call(B,"placeholder")?B:o;return u.placeholder}function At(){var o=B.iteratee||Sl;return o=o===Sl?N0:o,arguments.length?o(arguments[0],arguments[1]):o}function aa(o,u){var _=o.__data__;return Vx(u)?_[typeof u=="string"?"string":"hash"]:_.map}function pl(o){for(var u=Ye(o),_=u.length;_--;){var D=u[_],C=o[D];u[_]=[D,C,cd(C)]}return u}function pi(o,u){var _=KD(o,u);return M0(_)?_:e}function Px(o){var u=le.call(o,li),_=o[li];try{o[li]=e;var D=!0}catch{}var C=Po.call(o);return D&&(u?o[li]=_:delete o[li]),C}var _l=Uu?function(o){return o==null?[]:(o=pe(o),Pn(Uu(o),function(u){return d0.call(o,u)}))}:Il,ad=Uu?function(o){for(var u=[];o;)zn(u,_l(o)),o=qo(o);return u}:Il,nr=or;(Wu&&nr(new Wu(new ArrayBuffer(1)))!=rt||ds&&nr(new ds)!=Jt||ju&&nr(ju.resolve())!=_n||ji&&nr(new ji)!=yr||ps&&nr(new ps)!=G)&&(nr=function(o){var u=or(o),_=u==ke?o.constructor:e,D=_?_i(_):"";if(D)switch(D){case yb:return rt;case Db:return Jt;case bb:return _n;case xb:return yr;case Eb:return G}return u});function zx(o,u,_){for(var D=-1,C=_.length;++D<C;){var I=_[D],P=I.size;switch(I.type){case"drop":o+=P;break;case"dropRight":u-=P;break;case"take":u=rr(u,o+P);break;case"takeRight":o=We(o,u-P);break}}return{start:o,end:u}}function kx(o){var u=o.match(hu);return u?u[1].split(du):[]}function ud(o,u,_){u=jn(u,o);for(var D=-1,C=u.length,I=!1;++D<C;){var P=un(u[D]);if(!(I=o!=null&&_(o,P)))break;o=o[P]}return I||++D!=C?I:(C=o==null?0:o.length,!!C&&pa(C)&&bn(P,C)&&(Tt(o)||mi(o)))}function qx(o){var u=o.length,_=new o.constructor(u);return u&&typeof o[0]=="string"&&le.call(o,"index")&&(_.index=o.index,_.input=o.input),_}function ld(o){return typeof o.constructor=="function"&&!xs(o)?Yi(qo(o)):{}}function Ux(o,u,_){var D=o.constructor;switch(u){case st:return ul(o);case ue:case It:return new D(+o);case rt:return Ax(o,_);case ft:case ut:case ht:case at:case Xt:case ne:case xe:case Ve:case qe:return V0(o,_);case Jt:return new D;case Le:case $n:return new D(o);case mn:return Cx(o);case yr:return new D;case R:return Fx(o)}}function Wx(o,u){var _=u.length;if(!_)return o;var D=_-1;return u[D]=(_>1?"& ":"")+u[D],u=u.join(_>2?", ":" "),o.replace(fu,`{
9
9
  /* [wrapped with `+u+`] */
10
- `)}function jx(o){return Tt(o)||mi(o)||!!(p0&&o&&o[p0])}function bn(o,u){var m=typeof o;return u=u??Z,!!u&&(m=="number"||m!="symbol"&&bu.test(o))&&o>-1&&o%1==0&&o<u}function ar(o,u,m){if(!Fe(m))return!1;var D=typeof u;return(D=="number"?dr(m)&&bn(u,m.length):D=="string"&&u in m)?Hr(m[u],o):!1}function ml(o,u){if(Tt(o))return!1;var m=typeof o;return m=="number"||m=="symbol"||m=="boolean"||o==null||Cr(o)?!0:au.test(o)||!ou.test(o)||u!=null&&o in pe(u)}function Vx(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function gl(o){var u=oa(o),m=B[u];if(typeof m!="function"||!(u in jt.prototype))return!1;if(o===m)return!0;var D=dl(m);return!!D&&o===D[0]}function Yx(o){return!!c0&&c0 in o}var Zx=Lo?xn:Tl;function xs(o){var u=o&&o.constructor,m=typeof u=="function"&&u.prototype||Wi;return o===m}function cd(o){return o===o&&!Fe(o)}function fd(o,u){return function(m){return m==null?!1:m[o]===u&&(u!==e||o in pe(m))}}function Kx(o){var u=ha(o,function(D){return m.size===f&&m.clear(),D}),m=u.cache;return u}function Gx(o,u){var m=o[1],D=u[1],A=m|D,I=A<(y|v|N),P=D==N&&m==b||D==N&&m==S&&o[7].length<=u[8]||D==(N|S)&&u[7].length<=u[8]&&m==b;if(!(I||P))return o;D&y&&(o[2]=u[2],A|=m&y?0:x);var k=u[3];if(k){var V=o[3];o[3]=V?Z0(V,k,u[4]):k,o[4]=V?kn(o[3],d):u[4]}return k=u[5],k&&(V=o[5],o[5]=V?K0(V,k,u[6]):k,o[6]=V?kn(o[5],d):u[6]),k=u[7],k&&(o[7]=k),D&N&&(o[8]=o[8]==null?u[8]:rr(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=A,o}function Hx(o){var u=[];if(o!=null)for(var m in pe(o))u.push(m);return u}function Jx(o){return Po.call(o)}function hd(o,u,m){return u=We(u===e?o.length-1:u,0),function(){for(var D=arguments,A=-1,I=We(D.length-u,0),P=H(I);++A<I;)P[A]=D[u+A];A=-1;for(var k=H(u+1);++A<u;)k[A]=D[A];return k[u]=m(P),xr(o,this,k)}}function dd(o,u){return u.length<2?o:di(o,Pr(u,0,-1))}function Xx(o,u){for(var m=o.length,D=rr(u.length,m),A=hr(o);D--;){var I=u[D];o[D]=bn(I,m)?A[I]:e}return o}function vl(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var pd=md(R0),Es=db||function(o,u){return Je.setTimeout(o,u)},wl=md(Dx);function _d(o,u,m){var D=u+"";return wl(o,Wx(D,Qx(kx(D),m)))}function md(o){var u=0,m=0;return function(){var D=gb(),A=W-(D-m);if(m=D,A>0){if(++u>=$)return arguments[0]}else u=0;return o.apply(e,arguments)}}function ua(o,u){var m=-1,D=o.length,A=D-1;for(u=u===e?D:u;++m<u;){var I=el(m,A),P=o[I];o[I]=o[m],o[m]=P}return o.length=u,o}var gd=Kx(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(uu,function(m,D,A,I){u.push(A?I.replace(mu,"$1"):D||m)}),u});function un(o){if(typeof o=="string"||Cr(o))return o;var u=o+"";return u=="0"&&1/o==-K?"-0":u}function _i(o){if(o!=null){try{return Ro.call(o)}catch{}try{return o+""}catch{}}return""}function Qx(o,u){return Tr(yt,function(m){var D="_."+m[0];u&m[1]&&!Bo(o,D)&&o.push(D)}),o.sort()}function vd(o){if(o instanceof jt)return o.clone();var u=new Lr(o.__wrapped__,o.__chain__);return u.__actions__=hr(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function tE(o,u,m){(m?ar(o,u,m):u===e)?u=1:u=We(Lt(u),0);var D=o==null?0:o.length;if(!D||u<1)return[];for(var A=0,I=0,P=H(jo(D/u));A<D;)P[I++]=Pr(o,A,A+=u);return P}function eE(o){for(var u=-1,m=o==null?0:o.length,D=0,A=[];++u<m;){var I=o[u];I&&(A[D++]=I)}return A}function rE(){var o=arguments.length;if(!o)return[];for(var u=H(o-1),m=arguments[0],D=o;D--;)u[D-1]=arguments[D];return zn(Tt(m)?hr(m):[m],Xe(u,1))}var nE=Pt(function(o,u){return Be(o)?vs(o,Xe(u,1,Be,!0)):[]}),iE=Pt(function(o,u){var m=zr(u);return Be(m)&&(m=e),Be(o)?vs(o,Xe(u,1,Be,!0),At(m,2)):[]}),sE=Pt(function(o,u){var m=zr(u);return Be(m)&&(m=e),Be(o)?vs(o,Xe(u,1,Be,!0),e,m):[]});function oE(o,u,m){var D=o==null?0:o.length;return D?(u=m||u===e?1:Lt(u),Pr(o,u<0?0:u,D)):[]}function aE(o,u,m){var D=o==null?0:o.length;return D?(u=m||u===e?1:Lt(u),u=D-u,Pr(o,0,u<0?0:u)):[]}function uE(o,u){return o&&o.length?ta(o,At(u,3),!0,!0):[]}function lE(o,u){return o&&o.length?ta(o,At(u,3),!0):[]}function cE(o,u,m,D){var A=o==null?0:o.length;return A?(m&&typeof m!="number"&&ar(o,u,m)&&(m=0,D=A),rx(o,u,m,D)):[]}function wd(o,u,m){var D=o==null?0:o.length;if(!D)return-1;var A=m==null?0:Lt(m);return A<0&&(A=We(D+A,0)),Io(o,At(u,3),A)}function yd(o,u,m){var D=o==null?0:o.length;if(!D)return-1;var A=D-1;return m!==e&&(A=Lt(m),A=m<0?We(D+A,0):rr(A,D-1)),Io(o,At(u,3),A,!0)}function Dd(o){var u=o==null?0:o.length;return u?Xe(o,1):[]}function fE(o){var u=o==null?0:o.length;return u?Xe(o,K):[]}function hE(o,u){var m=o==null?0:o.length;return m?(u=u===e?1:Lt(u),Xe(o,u)):[]}function dE(o){for(var u=-1,m=o==null?0:o.length,D={};++u<m;){var A=o[u];D[A[0]]=A[1]}return D}function bd(o){return o&&o.length?o[0]:e}function pE(o,u,m){var D=o==null?0:o.length;if(!D)return-1;var A=m==null?0:Lt(m);return A<0&&(A=We(D+A,0)),zi(o,u,A)}function _E(o){var u=o==null?0:o.length;return u?Pr(o,0,-1):[]}var mE=Pt(function(o){var u=Ee(o,ol);return u.length&&u[0]===o[0]?Hu(u):[]}),gE=Pt(function(o){var u=zr(o),m=Ee(o,ol);return u===zr(m)?u=e:m.pop(),m.length&&m[0]===o[0]?Hu(m,At(u,2)):[]}),vE=Pt(function(o){var u=zr(o),m=Ee(o,ol);return u=typeof u=="function"?u:e,u&&m.pop(),m.length&&m[0]===o[0]?Hu(m,e,u):[]});function wE(o,u){return o==null?"":_b.call(o,u)}function zr(o){var u=o==null?0:o.length;return u?o[u-1]:e}function yE(o,u,m){var D=o==null?0:o.length;if(!D)return-1;var A=D;return m!==e&&(A=Lt(m),A=A<0?We(D+A,0):rr(A,D-1)),u===u?QD(o,u,A):Io(o,r0,A,!0)}function DE(o,u){return o&&o.length?I0(o,Lt(u)):e}var bE=Pt(xd);function xd(o,u){return o&&o.length&&u&&u.length?tl(o,u):o}function xE(o,u,m){return o&&o.length&&u&&u.length?tl(o,u,At(m,2)):o}function EE(o,u,m){return o&&o.length&&u&&u.length?tl(o,u,e,m):o}var AE=Dn(function(o,u){var m=o==null?0:o.length,D=Yu(o,u);return L0(o,Ee(u,function(A){return bn(A,m)?+A:A}).sort(Y0)),D});function CE(o,u){var m=[];if(!(o&&o.length))return m;var D=-1,A=[],I=o.length;for(u=At(u,3);++D<I;){var P=o[D];u(P,D,o)&&(m.push(P),A.push(D))}return L0(o,A),m}function yl(o){return o==null?o:wb.call(o)}function FE(o,u,m){var D=o==null?0:o.length;return D?(m&&typeof m!="number"&&ar(o,u,m)?(u=0,m=D):(u=u==null?0:Lt(u),m=m===e?D:Lt(m)),Pr(o,u,m)):[]}function ME(o,u){return Qo(o,u)}function NE(o,u,m){return nl(o,u,At(m,2))}function SE(o,u){var m=o==null?0:o.length;if(m){var D=Qo(o,u);if(D<m&&Hr(o[D],u))return D}return-1}function OE(o,u){return Qo(o,u,!0)}function BE(o,u,m){return nl(o,u,At(m,2),!0)}function IE(o,u){var m=o==null?0:o.length;if(m){var D=Qo(o,u,!0)-1;if(Hr(o[D],u))return D}return-1}function TE(o){return o&&o.length?P0(o):[]}function $E(o,u){return o&&o.length?P0(o,At(u,2)):[]}function LE(o){var u=o==null?0:o.length;return u?Pr(o,1,u):[]}function RE(o,u,m){return o&&o.length?(u=m||u===e?1:Lt(u),Pr(o,0,u<0?0:u)):[]}function PE(o,u,m){var D=o==null?0:o.length;return D?(u=m||u===e?1:Lt(u),u=D-u,Pr(o,u<0?0:u,D)):[]}function zE(o,u){return o&&o.length?ta(o,At(u,3),!1,!0):[]}function kE(o,u){return o&&o.length?ta(o,At(u,3)):[]}var qE=Pt(function(o){return Wn(Xe(o,1,Be,!0))}),UE=Pt(function(o){var u=zr(o);return Be(u)&&(u=e),Wn(Xe(o,1,Be,!0),At(u,2))}),WE=Pt(function(o){var u=zr(o);return u=typeof u=="function"?u:e,Wn(Xe(o,1,Be,!0),e,u)});function jE(o){return o&&o.length?Wn(o):[]}function VE(o,u){return o&&o.length?Wn(o,At(u,2)):[]}function YE(o,u){return u=typeof u=="function"?u:e,o&&o.length?Wn(o,e,u):[]}function Dl(o){if(!(o&&o.length))return[];var u=0;return o=Pn(o,function(m){if(Be(m))return u=We(m.length,u),!0}),Pu(u,function(m){return Ee(o,$u(m))})}function Ed(o,u){if(!(o&&o.length))return[];var m=Dl(o);return u==null?m:Ee(m,function(D){return xr(u,e,D)})}var ZE=Pt(function(o,u){return Be(o)?vs(o,u):[]}),KE=Pt(function(o){return sl(Pn(o,Be))}),GE=Pt(function(o){var u=zr(o);return Be(u)&&(u=e),sl(Pn(o,Be),At(u,2))}),HE=Pt(function(o){var u=zr(o);return u=typeof u=="function"?u:e,sl(Pn(o,Be),e,u)}),JE=Pt(Dl);function XE(o,u){return U0(o||[],u||[],gs)}function QE(o,u){return U0(o||[],u||[],Ds)}var tA=Pt(function(o){var u=o.length,m=u>1?o[u-1]:e;return m=typeof m=="function"?(o.pop(),m):e,Ed(o,m)});function Ad(o){var u=B(o);return u.__chain__=!0,u}function eA(o,u){return u(o),o}function la(o,u){return u(o)}var rA=Dn(function(o){var u=o.length,m=u?o[0]:0,D=this.__wrapped__,A=function(I){return Yu(I,o)};return u>1||this.__actions__.length||!(D instanceof jt)||!bn(m)?this.thru(A):(D=D.slice(m,+m+(u?1:0)),D.__actions__.push({func:la,args:[A],thisArg:e}),new Lr(D,this.__chain__).thru(function(I){return u&&!I.length&&I.push(e),I}))});function nA(){return Ad(this)}function iA(){return new Lr(this.value(),this.__chain__)}function sA(){this.__values__===e&&(this.__values__=zd(this.value()));var o=this.__index__>=this.__values__.length,u=o?e:this.__values__[this.__index__++];return{done:o,value:u}}function oA(){return this}function aA(o){for(var u,m=this;m instanceof Ko;){var D=vd(m);D.__index__=0,D.__values__=e,u?A.__wrapped__=D:u=D;var A=D;m=m.__wrapped__}return A.__wrapped__=o,u}function uA(){var o=this.__wrapped__;if(o instanceof jt){var u=o;return this.__actions__.length&&(u=new jt(this)),u=u.reverse(),u.__actions__.push({func:la,args:[yl],thisArg:e}),new Lr(u,this.__chain__)}return this.thru(yl)}function lA(){return q0(this.__wrapped__,this.__actions__)}var cA=ea(function(o,u,m){le.call(o,m)?++o[m]:wn(o,m,1)});function fA(o,u,m){var D=Tt(o)?t0:ex;return m&&ar(o,u,m)&&(u=e),D(o,At(u,3))}function hA(o,u){var m=Tt(o)?Pn:E0;return m(o,At(u,3))}var dA=X0(wd),pA=X0(yd);function _A(o,u){return Xe(ca(o,u),1)}function mA(o,u){return Xe(ca(o,u),K)}function gA(o,u,m){return m=m===e?1:Lt(m),Xe(ca(o,u),m)}function Cd(o,u){var m=Tt(o)?Tr:Un;return m(o,At(u,3))}function Fd(o,u){var m=Tt(o)?LD:x0;return m(o,At(u,3))}var vA=ea(function(o,u,m){le.call(o,m)?o[m].push(u):wn(o,m,[u])});function wA(o,u,m,D){o=dr(o)?o:Ji(o),m=m&&!D?Lt(m):0;var A=o.length;return m<0&&(m=We(A+m,0)),_a(o)?m<=A&&o.indexOf(u,m)>-1:!!A&&zi(o,u,m)>-1}var yA=Pt(function(o,u,m){var D=-1,A=typeof u=="function",I=dr(o)?H(o.length):[];return Un(o,function(P){I[++D]=A?xr(u,P,m):ws(P,u,m)}),I}),DA=ea(function(o,u,m){wn(o,m,u)});function ca(o,u){var m=Tt(o)?Ee:S0;return m(o,At(u,3))}function bA(o,u,m,D){return o==null?[]:(Tt(u)||(u=u==null?[]:[u]),m=D?e:m,Tt(m)||(m=m==null?[]:[m]),T0(o,u,m))}var xA=ea(function(o,u,m){o[m?0:1].push(u)},function(){return[[],[]]});function EA(o,u,m){var D=Tt(o)?Iu:i0,A=arguments.length<3;return D(o,At(u,4),m,A,Un)}function AA(o,u,m){var D=Tt(o)?RD:i0,A=arguments.length<3;return D(o,At(u,4),m,A,x0)}function CA(o,u){var m=Tt(o)?Pn:E0;return m(o,da(At(u,3)))}function FA(o){var u=Tt(o)?w0:wx;return u(o)}function MA(o,u,m){(m?ar(o,u,m):u===e)?u=1:u=Lt(u);var D=Tt(o)?Hb:yx;return D(o,u)}function NA(o){var u=Tt(o)?Jb:bx;return u(o)}function SA(o){if(o==null)return 0;if(dr(o))return _a(o)?qi(o):o.length;var u=nr(o);return u==Jt||u==yr?o.size:Xu(o).length}function OA(o,u,m){var D=Tt(o)?Tu:xx;return m&&ar(o,u,m)&&(u=e),D(o,At(u,3))}var BA=Pt(function(o,u){if(o==null)return[];var m=u.length;return m>1&&ar(o,u[0],u[1])?u=[]:m>2&&ar(u[0],u[1],u[2])&&(u=[u[0]]),T0(o,Xe(u,1),[])}),fa=hb||function(){return Je.Date.now()};function IA(o,u){if(typeof u!="function")throw new $r(a);return o=Lt(o),function(){if(--o<1)return u.apply(this,arguments)}}function Md(o,u,m){return u=m?e:u,u=o&&u==null?o.length:u,yn(o,N,e,e,e,e,u)}function Nd(o,u){var m;if(typeof u!="function")throw new $r(a);return o=Lt(o),function(){return--o>0&&(m=u.apply(this,arguments)),o<=1&&(u=e),m}}var bl=Pt(function(o,u,m){var D=y;if(m.length){var A=kn(m,Gi(bl));D|=E}return yn(o,D,u,m,A)}),Sd=Pt(function(o,u,m){var D=y|v;if(m.length){var A=kn(m,Gi(Sd));D|=E}return yn(u,D,o,m,A)});function Od(o,u,m){u=m?e:u;var D=yn(o,b,e,e,e,e,e,u);return D.placeholder=Od.placeholder,D}function Bd(o,u,m){u=m?e:u;var D=yn(o,M,e,e,e,e,e,u);return D.placeholder=Bd.placeholder,D}function Id(o,u,m){var D,A,I,P,k,V,tt=0,et=!1,ot=!1,pt=!0;if(typeof o!="function")throw new $r(a);u=kr(u)||0,Fe(m)&&(et=!!m.leading,ot="maxWait"in m,I=ot?We(kr(m.maxWait)||0,u):I,pt="trailing"in m?!!m.trailing:pt);function wt(Ie){var Jr=D,An=A;return D=A=e,tt=Ie,P=o.apply(An,Jr),P}function Ct(Ie){return tt=Ie,k=Es(Ut,u),et?wt(Ie):P}function Rt(Ie){var Jr=Ie-V,An=Ie-tt,Xd=u-Jr;return ot?rr(Xd,I-An):Xd}function Ft(Ie){var Jr=Ie-V,An=Ie-tt;return V===e||Jr>=u||Jr<0||ot&&An>=I}function Ut(){var Ie=fa();if(Ft(Ie))return Vt(Ie);k=Es(Ut,Rt(Ie))}function Vt(Ie){return k=e,pt&&D?wt(Ie):(D=A=e,P)}function Fr(){k!==e&&W0(k),tt=0,D=V=A=k=e}function ur(){return k===e?P:Vt(fa())}function Mr(){var Ie=fa(),Jr=Ft(Ie);if(D=arguments,A=this,V=Ie,Jr){if(k===e)return Ct(V);if(ot)return W0(k),k=Es(Ut,u),wt(V)}return k===e&&(k=Es(Ut,u)),P}return Mr.cancel=Fr,Mr.flush=ur,Mr}var TA=Pt(function(o,u){return b0(o,1,u)}),$A=Pt(function(o,u,m){return b0(o,kr(u)||0,m)});function LA(o){return yn(o,T)}function ha(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new $r(a);var m=function(){var D=arguments,A=u?u.apply(this,D):D[0],I=m.cache;if(I.has(A))return I.get(A);var P=o.apply(this,D);return m.cache=I.set(A,P)||I,P};return m.cache=new(ha.Cache||vn),m}ha.Cache=vn;function da(o){if(typeof o!="function")throw new $r(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 RA(o){return Nd(2,o)}var PA=Ex(function(o,u){u=u.length==1&&Tt(u[0])?Ee(u[0],Er(At())):Ee(Xe(u,1),Er(At()));var m=u.length;return Pt(function(D){for(var A=-1,I=rr(D.length,m);++A<I;)D[A]=u[A].call(this,D[A]);return xr(o,this,D)})}),xl=Pt(function(o,u){var m=kn(u,Gi(xl));return yn(o,E,e,u,m)}),Td=Pt(function(o,u){var m=kn(u,Gi(Td));return yn(o,F,e,u,m)}),zA=Dn(function(o,u){return yn(o,S,e,e,e,u)});function kA(o,u){if(typeof o!="function")throw new $r(a);return u=u===e?u:Lt(u),Pt(o,u)}function qA(o,u){if(typeof o!="function")throw new $r(a);return u=u==null?0:We(Lt(u),0),Pt(function(m){var D=m[u],A=Vn(m,0,u);return D&&zn(A,D),xr(o,this,A)})}function UA(o,u,m){var D=!0,A=!0;if(typeof o!="function")throw new $r(a);return Fe(m)&&(D="leading"in m?!!m.leading:D,A="trailing"in m?!!m.trailing:A),Id(o,u,{leading:D,maxWait:u,trailing:A})}function WA(o){return Md(o,1)}function jA(o,u){return xl(al(u),o)}function VA(){if(!arguments.length)return[];var o=arguments[0];return Tt(o)?o:[o]}function YA(o){return Rr(o,g)}function ZA(o,u){return u=typeof u=="function"?u:e,Rr(o,g,u)}function KA(o){return Rr(o,h|g)}function GA(o,u){return u=typeof u=="function"?u:e,Rr(o,h|g,u)}function HA(o,u){return u==null||D0(o,u,Ye(u))}function Hr(o,u){return o===u||o!==o&&u!==u}var JA=sa(Gu),XA=sa(function(o,u){return o>=u}),mi=F0(function(){return arguments}())?F0:function(o){return Ne(o)&&le.call(o,"callee")&&!d0.call(o,"callee")},Tt=H.isArray,QA=Kh?Er(Kh):ax;function dr(o){return o!=null&&pa(o.length)&&!xn(o)}function Be(o){return Ne(o)&&dr(o)}function tC(o){return o===!0||o===!1||Ne(o)&&or(o)==ue}var Yn=pb||Tl,eC=Gh?Er(Gh):ux;function rC(o){return Ne(o)&&o.nodeType===1&&!As(o)}function nC(o){if(o==null)return!0;if(dr(o)&&(Tt(o)||typeof o=="string"||typeof o.splice=="function"||Yn(o)||Hi(o)||mi(o)))return!o.length;var u=nr(o);if(u==Jt||u==yr)return!o.size;if(xs(o))return!Xu(o).length;for(var m in o)if(le.call(o,m))return!1;return!0}function iC(o,u){return ys(o,u)}function sC(o,u,m){m=typeof m=="function"?m:e;var D=m?m(o,u):e;return D===e?ys(o,u,e,m):!!D}function El(o){if(!Ne(o))return!1;var u=or(o);return u==fe||u==Nt||typeof o.message=="string"&&typeof o.name=="string"&&!As(o)}function oC(o){return typeof o=="number"&&_0(o)}function xn(o){if(!Fe(o))return!1;var u=or(o);return u==re||u==qt||u==xt||u==Tn}function $d(o){return typeof o=="number"&&o==Lt(o)}function pa(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Z}function Fe(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function Ne(o){return o!=null&&typeof o=="object"}var Ld=Hh?Er(Hh):cx;function aC(o,u){return o===u||Ju(o,u,pl(u))}function uC(o,u,m){return m=typeof m=="function"?m:e,Ju(o,u,pl(u),m)}function lC(o){return Rd(o)&&o!=+o}function cC(o){if(Zx(o))throw new Bt(s);return M0(o)}function fC(o){return o===null}function hC(o){return o==null}function Rd(o){return typeof o=="number"||Ne(o)&&or(o)==Le}function As(o){if(!Ne(o)||or(o)!=ke)return!1;var u=qo(o);if(u===null)return!0;var m=le.call(u,"constructor")&&u.constructor;return typeof m=="function"&&m instanceof m&&Ro.call(m)==ub}var Al=Jh?Er(Jh):fx;function dC(o){return $d(o)&&o>=-Z&&o<=Z}var Pd=Xh?Er(Xh):hx;function _a(o){return typeof o=="string"||!Tt(o)&&Ne(o)&&or(o)==$n}function Cr(o){return typeof o=="symbol"||Ne(o)&&or(o)==R}var Hi=Qh?Er(Qh):dx;function pC(o){return o===e}function _C(o){return Ne(o)&&nr(o)==G}function mC(o){return Ne(o)&&or(o)==nt}var gC=sa(Qu),vC=sa(function(o,u){return o<=u});function zd(o){if(!o)return[];if(dr(o))return _a(o)?Kr(o):hr(o);if(hs&&o[hs])return HD(o[hs]());var u=nr(o),m=u==Jt?ku:u==yr?To:Ji;return m(o)}function En(o){if(!o)return o===0?o:0;if(o=kr(o),o===K||o===-K){var u=o<0?-1:1;return u*X}return o===o?o:0}function Lt(o){var u=En(o),m=u%1;return u===u?m?u-m:u:0}function kd(o){return o?hi(Lt(o),0,ct):0}function kr(o){if(typeof o=="number")return o;if(Cr(o))return Q;if(Fe(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=Fe(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=s0(o);var m=wu.test(o);return m||Du.test(o)?ID(o.slice(2),m?2:8):vu.test(o)?Q:+o}function qd(o){return an(o,pr(o))}function wC(o){return o?hi(Lt(o),-Z,Z):o===0?o:0}function ie(o){return o==null?"":Ar(o)}var yC=Zi(function(o,u){if(xs(u)||dr(u)){an(u,Ye(u),o);return}for(var m in u)le.call(u,m)&&gs(o,m,u[m])}),Ud=Zi(function(o,u){an(u,pr(u),o)}),ma=Zi(function(o,u,m,D){an(u,pr(u),o,D)}),DC=Zi(function(o,u,m,D){an(u,Ye(u),o,D)}),bC=Dn(Yu);function xC(o,u){var m=Yi(o);return u==null?m:y0(m,u)}var EC=Pt(function(o,u){o=pe(o);var m=-1,D=u.length,A=D>2?u[2]:e;for(A&&ar(u[0],u[1],A)&&(D=1);++m<D;)for(var I=u[m],P=pr(I),k=-1,V=P.length;++k<V;){var tt=P[k],et=o[tt];(et===e||Hr(et,Wi[tt])&&!le.call(o,tt))&&(o[tt]=I[tt])}return o}),AC=Pt(function(o){return o.push(e,sd),xr(Wd,e,o)});function CC(o,u){return e0(o,At(u,3),on)}function FC(o,u){return e0(o,At(u,3),Ku)}function MC(o,u){return o==null?o:Zu(o,At(u,3),pr)}function NC(o,u){return o==null?o:A0(o,At(u,3),pr)}function SC(o,u){return o&&on(o,At(u,3))}function OC(o,u){return o&&Ku(o,At(u,3))}function BC(o){return o==null?[]:Jo(o,Ye(o))}function IC(o){return o==null?[]:Jo(o,pr(o))}function Cl(o,u,m){var D=o==null?e:di(o,u);return D===e?m:D}function TC(o,u){return o!=null&&ud(o,u,nx)}function Fl(o,u){return o!=null&&ud(o,u,ix)}var $C=td(function(o,u,m){u!=null&&typeof u.toString!="function"&&(u=Po.call(u)),o[u]=m},Nl(_r)),LC=td(function(o,u,m){u!=null&&typeof u.toString!="function"&&(u=Po.call(u)),le.call(o,u)?o[u].push(m):o[u]=[m]},At),RC=Pt(ws);function Ye(o){return dr(o)?v0(o):Xu(o)}function pr(o){return dr(o)?v0(o,!0):px(o)}function PC(o,u){var m={};return u=At(u,3),on(o,function(D,A,I){wn(m,u(D,A,I),D)}),m}function zC(o,u){var m={};return u=At(u,3),on(o,function(D,A,I){wn(m,A,u(D,A,I))}),m}var kC=Zi(function(o,u,m){Xo(o,u,m)}),Wd=Zi(function(o,u,m,D){Xo(o,u,m,D)}),qC=Dn(function(o,u){var m={};if(o==null)return m;var D=!1;u=Ee(u,function(I){return I=jn(I,o),D||(D=I.length>1),I}),an(o,hl(o),m),D&&(m=Rr(m,h|p|g,$x));for(var A=u.length;A--;)il(m,u[A]);return m});function UC(o,u){return jd(o,da(At(u)))}var WC=Dn(function(o,u){return o==null?{}:mx(o,u)});function jd(o,u){if(o==null)return{};var m=Ee(hl(o),function(D){return[D]});return u=At(u),$0(o,m,function(D,A){return u(D,A[0])})}function jC(o,u,m){u=jn(u,o);var D=-1,A=u.length;for(A||(A=1,o=e);++D<A;){var I=o==null?e:o[un(u[D])];I===e&&(D=A,I=m),o=xn(I)?I.call(o):I}return o}function VC(o,u,m){return o==null?o:Ds(o,u,m)}function YC(o,u,m,D){return D=typeof D=="function"?D:e,o==null?o:Ds(o,u,m,D)}var Vd=nd(Ye),Yd=nd(pr);function ZC(o,u,m){var D=Tt(o),A=D||Yn(o)||Hi(o);if(u=At(u,4),m==null){var I=o&&o.constructor;A?m=D?new I:[]:Fe(o)?m=xn(I)?Yi(qo(o)):{}:m={}}return(A?Tr:on)(o,function(P,k,V){return u(m,P,k,V)}),m}function KC(o,u){return o==null?!0:il(o,u)}function GC(o,u,m){return o==null?o:k0(o,u,al(m))}function HC(o,u,m,D){return D=typeof D=="function"?D:e,o==null?o:k0(o,u,al(m),D)}function Ji(o){return o==null?[]:zu(o,Ye(o))}function JC(o){return o==null?[]:zu(o,pr(o))}function XC(o,u,m){return m===e&&(m=u,u=e),m!==e&&(m=kr(m),m=m===m?m:0),u!==e&&(u=kr(u),u=u===u?u:0),hi(kr(o),u,m)}function QC(o,u,m){return u=En(u),m===e?(m=u,u=0):m=En(m),o=kr(o),sx(o,u,m)}function tF(o,u,m){if(m&&typeof m!="boolean"&&ar(o,u,m)&&(u=m=e),m===e&&(typeof u=="boolean"?(m=u,u=e):typeof o=="boolean"&&(m=o,o=e)),o===e&&u===e?(o=0,u=1):(o=En(o),u===e?(u=o,o=0):u=En(u)),o>u){var D=o;o=u,u=D}if(m||o%1||u%1){var A=m0();return rr(o+A*(u-o+BD("1e-"+((A+"").length-1))),u)}return el(o,u)}var eF=Ki(function(o,u,m){return u=u.toLowerCase(),o+(m?Zd(u):u)});function Zd(o){return Ml(ie(o).toLowerCase())}function Kd(o){return o=ie(o),o&&o.replace(xu,VD).replace(bD,"")}function rF(o,u,m){o=ie(o),u=Ar(u);var D=o.length;m=m===e?D:hi(Lt(m),0,D);var A=m;return m-=u.length,m>=0&&o.slice(m,A)==u}function nF(o){return o=ie(o),o&&nu.test(o)?o.replace(Fo,YD):o}function iF(o){return o=ie(o),o&&lu.test(o)?o.replace(ls,"\\$&"):o}var sF=Ki(function(o,u,m){return o+(m?"-":"")+u.toLowerCase()}),oF=Ki(function(o,u,m){return o+(m?" ":"")+u.toLowerCase()}),aF=J0("toLowerCase");function uF(o,u,m){o=ie(o),u=Lt(u);var D=u?qi(o):0;if(!u||D>=u)return o;var A=(u-D)/2;return ia(Vo(A),m)+o+ia(jo(A),m)}function lF(o,u,m){o=ie(o),u=Lt(u);var D=u?qi(o):0;return u&&D<u?o+ia(u-D,m):o}function cF(o,u,m){o=ie(o),u=Lt(u);var D=u?qi(o):0;return u&&D<u?ia(u-D,m)+o:o}function fF(o,u,m){return m||u==null?u=0:u&&(u=+u),vb(ie(o).replace(cs,""),u||0)}function hF(o,u,m){return(m?ar(o,u,m):u===e)?u=1:u=Lt(u),rl(ie(o),u)}function dF(){var o=arguments,u=ie(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var pF=Ki(function(o,u,m){return o+(m?"_":"")+u.toLowerCase()});function _F(o,u,m){return m&&typeof m!="number"&&ar(o,u,m)&&(u=m=e),m=m===e?ct:m>>>0,m?(o=ie(o),o&&(typeof u=="string"||u!=null&&!Al(u))&&(u=Ar(u),!u&&ki(o))?Vn(Kr(o),0,m):o.split(u,m)):[]}var mF=Ki(function(o,u,m){return o+(m?" ":"")+Ml(u)});function gF(o,u,m){return o=ie(o),m=m==null?0:hi(Lt(m),0,o.length),u=Ar(u),o.slice(m,m+u.length)==u}function vF(o,u,m){var D=B.templateSettings;m&&ar(o,u,m)&&(u=e),o=ie(o),u=ma({},u,D,id);var A=ma({},u.imports,D.imports,id),I=Ye(A),P=zu(A,I),k,V,tt=0,et=u.interpolate||Li,ot="__p += '",pt=qu((u.escape||Li).source+"|"+et.source+"|"+(et===Mo?gu:Li).source+"|"+(u.evaluate||Li).source+"|$","g"),wt="//# sourceURL="+(le.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++FD+"]")+`
10
+ `)}function jx(o){return Tt(o)||mi(o)||!!(p0&&o&&o[p0])}function bn(o,u){var _=typeof o;return u=u??Z,!!u&&(_=="number"||_!="symbol"&&bu.test(o))&&o>-1&&o%1==0&&o<u}function ar(o,u,_){if(!Fe(_))return!1;var D=typeof u;return(D=="number"?dr(_)&&bn(u,_.length):D=="string"&&u in _)?Hr(_[u],o):!1}function ml(o,u){if(Tt(o))return!1;var _=typeof o;return _=="number"||_=="symbol"||_=="boolean"||o==null||Cr(o)?!0:au.test(o)||!ou.test(o)||u!=null&&o in pe(u)}function Vx(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function gl(o){var u=oa(o),_=B[u];if(typeof _!="function"||!(u in jt.prototype))return!1;if(o===_)return!0;var D=dl(_);return!!D&&o===D[0]}function Yx(o){return!!c0&&c0 in o}var Zx=Lo?xn:Tl;function xs(o){var u=o&&o.constructor,_=typeof u=="function"&&u.prototype||Wi;return o===_}function cd(o){return o===o&&!Fe(o)}function fd(o,u){return function(_){return _==null?!1:_[o]===u&&(u!==e||o in pe(_))}}function Kx(o){var u=ha(o,function(D){return _.size===h&&_.clear(),D}),_=u.cache;return u}function Gx(o,u){var _=o[1],D=u[1],C=_|D,I=C<(y|v|N),P=D==N&&_==b||D==N&&_==S&&o[7].length<=u[8]||D==(N|S)&&u[7].length<=u[8]&&_==b;if(!(I||P))return o;D&y&&(o[2]=u[2],C|=_&y?0:x);var k=u[3];if(k){var V=o[3];o[3]=V?Z0(V,k,u[4]):k,o[4]=V?kn(o[3],d):u[4]}return k=u[5],k&&(V=o[5],o[5]=V?K0(V,k,u[6]):k,o[6]=V?kn(o[5],d):u[6]),k=u[7],k&&(o[7]=k),D&N&&(o[8]=o[8]==null?u[8]:rr(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=C,o}function Hx(o){var u=[];if(o!=null)for(var _ in pe(o))u.push(_);return u}function Jx(o){return Po.call(o)}function hd(o,u,_){return u=We(u===e?o.length-1:u,0),function(){for(var D=arguments,C=-1,I=We(D.length-u,0),P=H(I);++C<I;)P[C]=D[u+C];C=-1;for(var k=H(u+1);++C<u;)k[C]=D[C];return k[u]=_(P),xr(o,this,k)}}function dd(o,u){return u.length<2?o:di(o,Pr(u,0,-1))}function Xx(o,u){for(var _=o.length,D=rr(u.length,_),C=hr(o);D--;){var I=u[D];o[D]=bn(I,_)?C[I]:e}return o}function vl(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var pd=md(R0),Es=db||function(o,u){return Je.setTimeout(o,u)},wl=md(Dx);function _d(o,u,_){var D=u+"";return wl(o,Wx(D,Qx(kx(D),_)))}function md(o){var u=0,_=0;return function(){var D=gb(),C=q-(D-_);if(_=D,C>0){if(++u>=L)return arguments[0]}else u=0;return o.apply(e,arguments)}}function ua(o,u){var _=-1,D=o.length,C=D-1;for(u=u===e?D:u;++_<u;){var I=el(_,C),P=o[I];o[I]=o[_],o[_]=P}return o.length=u,o}var gd=Kx(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(uu,function(_,D,C,I){u.push(C?I.replace(mu,"$1"):D||_)}),u});function un(o){if(typeof o=="string"||Cr(o))return o;var u=o+"";return u=="0"&&1/o==-K?"-0":u}function _i(o){if(o!=null){try{return Ro.call(o)}catch{}try{return o+""}catch{}}return""}function Qx(o,u){return Tr(yt,function(_){var D="_."+_[0];u&_[1]&&!Bo(o,D)&&o.push(D)}),o.sort()}function vd(o){if(o instanceof jt)return o.clone();var u=new Lr(o.__wrapped__,o.__chain__);return u.__actions__=hr(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function tE(o,u,_){(_?ar(o,u,_):u===e)?u=1:u=We(Lt(u),0);var D=o==null?0:o.length;if(!D||u<1)return[];for(var C=0,I=0,P=H(jo(D/u));C<D;)P[I++]=Pr(o,C,C+=u);return P}function eE(o){for(var u=-1,_=o==null?0:o.length,D=0,C=[];++u<_;){var I=o[u];I&&(C[D++]=I)}return C}function rE(){var o=arguments.length;if(!o)return[];for(var u=H(o-1),_=arguments[0],D=o;D--;)u[D-1]=arguments[D];return zn(Tt(_)?hr(_):[_],Xe(u,1))}var nE=zt(function(o,u){return Be(o)?vs(o,Xe(u,1,Be,!0)):[]}),iE=zt(function(o,u){var _=zr(u);return Be(_)&&(_=e),Be(o)?vs(o,Xe(u,1,Be,!0),At(_,2)):[]}),sE=zt(function(o,u){var _=zr(u);return Be(_)&&(_=e),Be(o)?vs(o,Xe(u,1,Be,!0),e,_):[]});function oE(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),Pr(o,u<0?0:u,D)):[]}function aE(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,Pr(o,0,u<0?0:u)):[]}function uE(o,u){return o&&o.length?ta(o,At(u,3),!0,!0):[]}function lE(o,u){return o&&o.length?ta(o,At(u,3),!0):[]}function cE(o,u,_,D){var C=o==null?0:o.length;return C?(_&&typeof _!="number"&&ar(o,u,_)&&(_=0,D=C),rx(o,u,_,D)):[]}function wd(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=_==null?0:Lt(_);return C<0&&(C=We(D+C,0)),Io(o,At(u,3),C)}function yd(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=D-1;return _!==e&&(C=Lt(_),C=_<0?We(D+C,0):rr(C,D-1)),Io(o,At(u,3),C,!0)}function Dd(o){var u=o==null?0:o.length;return u?Xe(o,1):[]}function fE(o){var u=o==null?0:o.length;return u?Xe(o,K):[]}function hE(o,u){var _=o==null?0:o.length;return _?(u=u===e?1:Lt(u),Xe(o,u)):[]}function dE(o){for(var u=-1,_=o==null?0:o.length,D={};++u<_;){var C=o[u];D[C[0]]=C[1]}return D}function bd(o){return o&&o.length?o[0]:e}function pE(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=_==null?0:Lt(_);return C<0&&(C=We(D+C,0)),zi(o,u,C)}function _E(o){var u=o==null?0:o.length;return u?Pr(o,0,-1):[]}var mE=zt(function(o){var u=Ee(o,ol);return u.length&&u[0]===o[0]?Hu(u):[]}),gE=zt(function(o){var u=zr(o),_=Ee(o,ol);return u===zr(_)?u=e:_.pop(),_.length&&_[0]===o[0]?Hu(_,At(u,2)):[]}),vE=zt(function(o){var u=zr(o),_=Ee(o,ol);return u=typeof u=="function"?u:e,u&&_.pop(),_.length&&_[0]===o[0]?Hu(_,e,u):[]});function wE(o,u){return o==null?"":_b.call(o,u)}function zr(o){var u=o==null?0:o.length;return u?o[u-1]:e}function yE(o,u,_){var D=o==null?0:o.length;if(!D)return-1;var C=D;return _!==e&&(C=Lt(_),C=C<0?We(D+C,0):rr(C,D-1)),u===u?QD(o,u,C):Io(o,r0,C,!0)}function DE(o,u){return o&&o.length?I0(o,Lt(u)):e}var bE=zt(xd);function xd(o,u){return o&&o.length&&u&&u.length?tl(o,u):o}function xE(o,u,_){return o&&o.length&&u&&u.length?tl(o,u,At(_,2)):o}function EE(o,u,_){return o&&o.length&&u&&u.length?tl(o,u,e,_):o}var AE=Dn(function(o,u){var _=o==null?0:o.length,D=Yu(o,u);return L0(o,Ee(u,function(C){return bn(C,_)?+C:C}).sort(Y0)),D});function CE(o,u){var _=[];if(!(o&&o.length))return _;var D=-1,C=[],I=o.length;for(u=At(u,3);++D<I;){var P=o[D];u(P,D,o)&&(_.push(P),C.push(D))}return L0(o,C),_}function yl(o){return o==null?o:wb.call(o)}function FE(o,u,_){var D=o==null?0:o.length;return D?(_&&typeof _!="number"&&ar(o,u,_)?(u=0,_=D):(u=u==null?0:Lt(u),_=_===e?D:Lt(_)),Pr(o,u,_)):[]}function ME(o,u){return Qo(o,u)}function NE(o,u,_){return nl(o,u,At(_,2))}function SE(o,u){var _=o==null?0:o.length;if(_){var D=Qo(o,u);if(D<_&&Hr(o[D],u))return D}return-1}function OE(o,u){return Qo(o,u,!0)}function BE(o,u,_){return nl(o,u,At(_,2),!0)}function IE(o,u){var _=o==null?0:o.length;if(_){var D=Qo(o,u,!0)-1;if(Hr(o[D],u))return D}return-1}function TE(o){return o&&o.length?P0(o):[]}function $E(o,u){return o&&o.length?P0(o,At(u,2)):[]}function LE(o){var u=o==null?0:o.length;return u?Pr(o,1,u):[]}function RE(o,u,_){return o&&o.length?(u=_||u===e?1:Lt(u),Pr(o,0,u<0?0:u)):[]}function PE(o,u,_){var D=o==null?0:o.length;return D?(u=_||u===e?1:Lt(u),u=D-u,Pr(o,u<0?0:u,D)):[]}function zE(o,u){return o&&o.length?ta(o,At(u,3),!1,!0):[]}function kE(o,u){return o&&o.length?ta(o,At(u,3)):[]}var qE=zt(function(o){return Wn(Xe(o,1,Be,!0))}),UE=zt(function(o){var u=zr(o);return Be(u)&&(u=e),Wn(Xe(o,1,Be,!0),At(u,2))}),WE=zt(function(o){var u=zr(o);return u=typeof u=="function"?u:e,Wn(Xe(o,1,Be,!0),e,u)});function jE(o){return o&&o.length?Wn(o):[]}function VE(o,u){return o&&o.length?Wn(o,At(u,2)):[]}function YE(o,u){return u=typeof u=="function"?u:e,o&&o.length?Wn(o,e,u):[]}function Dl(o){if(!(o&&o.length))return[];var u=0;return o=Pn(o,function(_){if(Be(_))return u=We(_.length,u),!0}),Pu(u,function(_){return Ee(o,$u(_))})}function Ed(o,u){if(!(o&&o.length))return[];var _=Dl(o);return u==null?_:Ee(_,function(D){return xr(u,e,D)})}var ZE=zt(function(o,u){return Be(o)?vs(o,u):[]}),KE=zt(function(o){return sl(Pn(o,Be))}),GE=zt(function(o){var u=zr(o);return Be(u)&&(u=e),sl(Pn(o,Be),At(u,2))}),HE=zt(function(o){var u=zr(o);return u=typeof u=="function"?u:e,sl(Pn(o,Be),e,u)}),JE=zt(Dl);function XE(o,u){return U0(o||[],u||[],gs)}function QE(o,u){return U0(o||[],u||[],Ds)}var tA=zt(function(o){var u=o.length,_=u>1?o[u-1]:e;return _=typeof _=="function"?(o.pop(),_):e,Ed(o,_)});function Ad(o){var u=B(o);return u.__chain__=!0,u}function eA(o,u){return u(o),o}function la(o,u){return u(o)}var rA=Dn(function(o){var u=o.length,_=u?o[0]:0,D=this.__wrapped__,C=function(I){return Yu(I,o)};return u>1||this.__actions__.length||!(D instanceof jt)||!bn(_)?this.thru(C):(D=D.slice(_,+_+(u?1:0)),D.__actions__.push({func:la,args:[C],thisArg:e}),new Lr(D,this.__chain__).thru(function(I){return u&&!I.length&&I.push(e),I}))});function nA(){return Ad(this)}function iA(){return new Lr(this.value(),this.__chain__)}function sA(){this.__values__===e&&(this.__values__=zd(this.value()));var o=this.__index__>=this.__values__.length,u=o?e:this.__values__[this.__index__++];return{done:o,value:u}}function oA(){return this}function aA(o){for(var u,_=this;_ instanceof Ko;){var D=vd(_);D.__index__=0,D.__values__=e,u?C.__wrapped__=D:u=D;var C=D;_=_.__wrapped__}return C.__wrapped__=o,u}function uA(){var o=this.__wrapped__;if(o instanceof jt){var u=o;return this.__actions__.length&&(u=new jt(this)),u=u.reverse(),u.__actions__.push({func:la,args:[yl],thisArg:e}),new Lr(u,this.__chain__)}return this.thru(yl)}function lA(){return q0(this.__wrapped__,this.__actions__)}var cA=ea(function(o,u,_){le.call(o,_)?++o[_]:wn(o,_,1)});function fA(o,u,_){var D=Tt(o)?t0:ex;return _&&ar(o,u,_)&&(u=e),D(o,At(u,3))}function hA(o,u){var _=Tt(o)?Pn:E0;return _(o,At(u,3))}var dA=X0(wd),pA=X0(yd);function _A(o,u){return Xe(ca(o,u),1)}function mA(o,u){return Xe(ca(o,u),K)}function gA(o,u,_){return _=_===e?1:Lt(_),Xe(ca(o,u),_)}function Cd(o,u){var _=Tt(o)?Tr:Un;return _(o,At(u,3))}function Fd(o,u){var _=Tt(o)?LD:x0;return _(o,At(u,3))}var vA=ea(function(o,u,_){le.call(o,_)?o[_].push(u):wn(o,_,[u])});function wA(o,u,_,D){o=dr(o)?o:Ji(o),_=_&&!D?Lt(_):0;var C=o.length;return _<0&&(_=We(C+_,0)),_a(o)?_<=C&&o.indexOf(u,_)>-1:!!C&&zi(o,u,_)>-1}var yA=zt(function(o,u,_){var D=-1,C=typeof u=="function",I=dr(o)?H(o.length):[];return Un(o,function(P){I[++D]=C?xr(u,P,_):ws(P,u,_)}),I}),DA=ea(function(o,u,_){wn(o,_,u)});function ca(o,u){var _=Tt(o)?Ee:S0;return _(o,At(u,3))}function bA(o,u,_,D){return o==null?[]:(Tt(u)||(u=u==null?[]:[u]),_=D?e:_,Tt(_)||(_=_==null?[]:[_]),T0(o,u,_))}var xA=ea(function(o,u,_){o[_?0:1].push(u)},function(){return[[],[]]});function EA(o,u,_){var D=Tt(o)?Iu:i0,C=arguments.length<3;return D(o,At(u,4),_,C,Un)}function AA(o,u,_){var D=Tt(o)?RD:i0,C=arguments.length<3;return D(o,At(u,4),_,C,x0)}function CA(o,u){var _=Tt(o)?Pn:E0;return _(o,da(At(u,3)))}function FA(o){var u=Tt(o)?w0:wx;return u(o)}function MA(o,u,_){(_?ar(o,u,_):u===e)?u=1:u=Lt(u);var D=Tt(o)?Hb:yx;return D(o,u)}function NA(o){var u=Tt(o)?Jb:bx;return u(o)}function SA(o){if(o==null)return 0;if(dr(o))return _a(o)?qi(o):o.length;var u=nr(o);return u==Jt||u==yr?o.size:Xu(o).length}function OA(o,u,_){var D=Tt(o)?Tu:xx;return _&&ar(o,u,_)&&(u=e),D(o,At(u,3))}var BA=zt(function(o,u){if(o==null)return[];var _=u.length;return _>1&&ar(o,u[0],u[1])?u=[]:_>2&&ar(u[0],u[1],u[2])&&(u=[u[0]]),T0(o,Xe(u,1),[])}),fa=hb||function(){return Je.Date.now()};function IA(o,u){if(typeof u!="function")throw new $r(a);return o=Lt(o),function(){if(--o<1)return u.apply(this,arguments)}}function Md(o,u,_){return u=_?e:u,u=o&&u==null?o.length:u,yn(o,N,e,e,e,e,u)}function Nd(o,u){var _;if(typeof u!="function")throw new $r(a);return o=Lt(o),function(){return--o>0&&(_=u.apply(this,arguments)),o<=1&&(u=e),_}}var bl=zt(function(o,u,_){var D=y;if(_.length){var C=kn(_,Gi(bl));D|=E}return yn(o,D,u,_,C)}),Sd=zt(function(o,u,_){var D=y|v;if(_.length){var C=kn(_,Gi(Sd));D|=E}return yn(u,D,o,_,C)});function Od(o,u,_){u=_?e:u;var D=yn(o,b,e,e,e,e,e,u);return D.placeholder=Od.placeholder,D}function Bd(o,u,_){u=_?e:u;var D=yn(o,M,e,e,e,e,e,u);return D.placeholder=Bd.placeholder,D}function Id(o,u,_){var D,C,I,P,k,V,tt=0,et=!1,ot=!1,pt=!0;if(typeof o!="function")throw new $r(a);u=kr(u)||0,Fe(_)&&(et=!!_.leading,ot="maxWait"in _,I=ot?We(kr(_.maxWait)||0,u):I,pt="trailing"in _?!!_.trailing:pt);function wt(Ie){var Jr=D,An=C;return D=C=e,tt=Ie,P=o.apply(An,Jr),P}function Ct(Ie){return tt=Ie,k=Es(Ut,u),et?wt(Ie):P}function Rt(Ie){var Jr=Ie-V,An=Ie-tt,Xd=u-Jr;return ot?rr(Xd,I-An):Xd}function Ft(Ie){var Jr=Ie-V,An=Ie-tt;return V===e||Jr>=u||Jr<0||ot&&An>=I}function Ut(){var Ie=fa();if(Ft(Ie))return Vt(Ie);k=Es(Ut,Rt(Ie))}function Vt(Ie){return k=e,pt&&D?wt(Ie):(D=C=e,P)}function Fr(){k!==e&&W0(k),tt=0,D=V=C=k=e}function ur(){return k===e?P:Vt(fa())}function Mr(){var Ie=fa(),Jr=Ft(Ie);if(D=arguments,C=this,V=Ie,Jr){if(k===e)return Ct(V);if(ot)return W0(k),k=Es(Ut,u),wt(V)}return k===e&&(k=Es(Ut,u)),P}return Mr.cancel=Fr,Mr.flush=ur,Mr}var TA=zt(function(o,u){return b0(o,1,u)}),$A=zt(function(o,u,_){return b0(o,kr(u)||0,_)});function LA(o){return yn(o,T)}function ha(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new $r(a);var _=function(){var D=arguments,C=u?u.apply(this,D):D[0],I=_.cache;if(I.has(C))return I.get(C);var P=o.apply(this,D);return _.cache=I.set(C,P)||I,P};return _.cache=new(ha.Cache||vn),_}ha.Cache=vn;function da(o){if(typeof o!="function")throw new $r(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 RA(o){return Nd(2,o)}var PA=Ex(function(o,u){u=u.length==1&&Tt(u[0])?Ee(u[0],Er(At())):Ee(Xe(u,1),Er(At()));var _=u.length;return zt(function(D){for(var C=-1,I=rr(D.length,_);++C<I;)D[C]=u[C].call(this,D[C]);return xr(o,this,D)})}),xl=zt(function(o,u){var _=kn(u,Gi(xl));return yn(o,E,e,u,_)}),Td=zt(function(o,u){var _=kn(u,Gi(Td));return yn(o,F,e,u,_)}),zA=Dn(function(o,u){return yn(o,S,e,e,e,u)});function kA(o,u){if(typeof o!="function")throw new $r(a);return u=u===e?u:Lt(u),zt(o,u)}function qA(o,u){if(typeof o!="function")throw new $r(a);return u=u==null?0:We(Lt(u),0),zt(function(_){var D=_[u],C=Vn(_,0,u);return D&&zn(C,D),xr(o,this,C)})}function UA(o,u,_){var D=!0,C=!0;if(typeof o!="function")throw new $r(a);return Fe(_)&&(D="leading"in _?!!_.leading:D,C="trailing"in _?!!_.trailing:C),Id(o,u,{leading:D,maxWait:u,trailing:C})}function WA(o){return Md(o,1)}function jA(o,u){return xl(al(u),o)}function VA(){if(!arguments.length)return[];var o=arguments[0];return Tt(o)?o:[o]}function YA(o){return Rr(o,g)}function ZA(o,u){return u=typeof u=="function"?u:e,Rr(o,g,u)}function KA(o){return Rr(o,f|g)}function GA(o,u){return u=typeof u=="function"?u:e,Rr(o,f|g,u)}function HA(o,u){return u==null||D0(o,u,Ye(u))}function Hr(o,u){return o===u||o!==o&&u!==u}var JA=sa(Gu),XA=sa(function(o,u){return o>=u}),mi=F0(function(){return arguments}())?F0:function(o){return Ne(o)&&le.call(o,"callee")&&!d0.call(o,"callee")},Tt=H.isArray,QA=Kh?Er(Kh):ax;function dr(o){return o!=null&&pa(o.length)&&!xn(o)}function Be(o){return Ne(o)&&dr(o)}function tC(o){return o===!0||o===!1||Ne(o)&&or(o)==ue}var Yn=pb||Tl,eC=Gh?Er(Gh):ux;function rC(o){return Ne(o)&&o.nodeType===1&&!As(o)}function nC(o){if(o==null)return!0;if(dr(o)&&(Tt(o)||typeof o=="string"||typeof o.splice=="function"||Yn(o)||Hi(o)||mi(o)))return!o.length;var u=nr(o);if(u==Jt||u==yr)return!o.size;if(xs(o))return!Xu(o).length;for(var _ in o)if(le.call(o,_))return!1;return!0}function iC(o,u){return ys(o,u)}function sC(o,u,_){_=typeof _=="function"?_:e;var D=_?_(o,u):e;return D===e?ys(o,u,e,_):!!D}function El(o){if(!Ne(o))return!1;var u=or(o);return u==fe||u==Nt||typeof o.message=="string"&&typeof o.name=="string"&&!As(o)}function oC(o){return typeof o=="number"&&_0(o)}function xn(o){if(!Fe(o))return!1;var u=or(o);return u==re||u==qt||u==xt||u==Tn}function $d(o){return typeof o=="number"&&o==Lt(o)}function pa(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Z}function Fe(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function Ne(o){return o!=null&&typeof o=="object"}var Ld=Hh?Er(Hh):cx;function aC(o,u){return o===u||Ju(o,u,pl(u))}function uC(o,u,_){return _=typeof _=="function"?_:e,Ju(o,u,pl(u),_)}function lC(o){return Rd(o)&&o!=+o}function cC(o){if(Zx(o))throw new Bt(s);return M0(o)}function fC(o){return o===null}function hC(o){return o==null}function Rd(o){return typeof o=="number"||Ne(o)&&or(o)==Le}function As(o){if(!Ne(o)||or(o)!=ke)return!1;var u=qo(o);if(u===null)return!0;var _=le.call(u,"constructor")&&u.constructor;return typeof _=="function"&&_ instanceof _&&Ro.call(_)==ub}var Al=Jh?Er(Jh):fx;function dC(o){return $d(o)&&o>=-Z&&o<=Z}var Pd=Xh?Er(Xh):hx;function _a(o){return typeof o=="string"||!Tt(o)&&Ne(o)&&or(o)==$n}function Cr(o){return typeof o=="symbol"||Ne(o)&&or(o)==R}var Hi=Qh?Er(Qh):dx;function pC(o){return o===e}function _C(o){return Ne(o)&&nr(o)==G}function mC(o){return Ne(o)&&or(o)==nt}var gC=sa(Qu),vC=sa(function(o,u){return o<=u});function zd(o){if(!o)return[];if(dr(o))return _a(o)?Kr(o):hr(o);if(hs&&o[hs])return HD(o[hs]());var u=nr(o),_=u==Jt?ku:u==yr?To:Ji;return _(o)}function En(o){if(!o)return o===0?o:0;if(o=kr(o),o===K||o===-K){var u=o<0?-1:1;return u*X}return o===o?o:0}function Lt(o){var u=En(o),_=u%1;return u===u?_?u-_:u:0}function kd(o){return o?hi(Lt(o),0,ct):0}function kr(o){if(typeof o=="number")return o;if(Cr(o))return Q;if(Fe(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=Fe(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=s0(o);var _=wu.test(o);return _||Du.test(o)?ID(o.slice(2),_?2:8):vu.test(o)?Q:+o}function qd(o){return an(o,pr(o))}function wC(o){return o?hi(Lt(o),-Z,Z):o===0?o:0}function ie(o){return o==null?"":Ar(o)}var yC=Zi(function(o,u){if(xs(u)||dr(u)){an(u,Ye(u),o);return}for(var _ in u)le.call(u,_)&&gs(o,_,u[_])}),Ud=Zi(function(o,u){an(u,pr(u),o)}),ma=Zi(function(o,u,_,D){an(u,pr(u),o,D)}),DC=Zi(function(o,u,_,D){an(u,Ye(u),o,D)}),bC=Dn(Yu);function xC(o,u){var _=Yi(o);return u==null?_:y0(_,u)}var EC=zt(function(o,u){o=pe(o);var _=-1,D=u.length,C=D>2?u[2]:e;for(C&&ar(u[0],u[1],C)&&(D=1);++_<D;)for(var I=u[_],P=pr(I),k=-1,V=P.length;++k<V;){var tt=P[k],et=o[tt];(et===e||Hr(et,Wi[tt])&&!le.call(o,tt))&&(o[tt]=I[tt])}return o}),AC=zt(function(o){return o.push(e,sd),xr(Wd,e,o)});function CC(o,u){return e0(o,At(u,3),on)}function FC(o,u){return e0(o,At(u,3),Ku)}function MC(o,u){return o==null?o:Zu(o,At(u,3),pr)}function NC(o,u){return o==null?o:A0(o,At(u,3),pr)}function SC(o,u){return o&&on(o,At(u,3))}function OC(o,u){return o&&Ku(o,At(u,3))}function BC(o){return o==null?[]:Jo(o,Ye(o))}function IC(o){return o==null?[]:Jo(o,pr(o))}function Cl(o,u,_){var D=o==null?e:di(o,u);return D===e?_:D}function TC(o,u){return o!=null&&ud(o,u,nx)}function Fl(o,u){return o!=null&&ud(o,u,ix)}var $C=td(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=Po.call(u)),o[u]=_},Nl(_r)),LC=td(function(o,u,_){u!=null&&typeof u.toString!="function"&&(u=Po.call(u)),le.call(o,u)?o[u].push(_):o[u]=[_]},At),RC=zt(ws);function Ye(o){return dr(o)?v0(o):Xu(o)}function pr(o){return dr(o)?v0(o,!0):px(o)}function PC(o,u){var _={};return u=At(u,3),on(o,function(D,C,I){wn(_,u(D,C,I),D)}),_}function zC(o,u){var _={};return u=At(u,3),on(o,function(D,C,I){wn(_,C,u(D,C,I))}),_}var kC=Zi(function(o,u,_){Xo(o,u,_)}),Wd=Zi(function(o,u,_,D){Xo(o,u,_,D)}),qC=Dn(function(o,u){var _={};if(o==null)return _;var D=!1;u=Ee(u,function(I){return I=jn(I,o),D||(D=I.length>1),I}),an(o,hl(o),_),D&&(_=Rr(_,f|p|g,$x));for(var C=u.length;C--;)il(_,u[C]);return _});function UC(o,u){return jd(o,da(At(u)))}var WC=Dn(function(o,u){return o==null?{}:mx(o,u)});function jd(o,u){if(o==null)return{};var _=Ee(hl(o),function(D){return[D]});return u=At(u),$0(o,_,function(D,C){return u(D,C[0])})}function jC(o,u,_){u=jn(u,o);var D=-1,C=u.length;for(C||(C=1,o=e);++D<C;){var I=o==null?e:o[un(u[D])];I===e&&(D=C,I=_),o=xn(I)?I.call(o):I}return o}function VC(o,u,_){return o==null?o:Ds(o,u,_)}function YC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:Ds(o,u,_,D)}var Vd=nd(Ye),Yd=nd(pr);function ZC(o,u,_){var D=Tt(o),C=D||Yn(o)||Hi(o);if(u=At(u,4),_==null){var I=o&&o.constructor;C?_=D?new I:[]:Fe(o)?_=xn(I)?Yi(qo(o)):{}:_={}}return(C?Tr:on)(o,function(P,k,V){return u(_,P,k,V)}),_}function KC(o,u){return o==null?!0:il(o,u)}function GC(o,u,_){return o==null?o:k0(o,u,al(_))}function HC(o,u,_,D){return D=typeof D=="function"?D:e,o==null?o:k0(o,u,al(_),D)}function Ji(o){return o==null?[]:zu(o,Ye(o))}function JC(o){return o==null?[]:zu(o,pr(o))}function XC(o,u,_){return _===e&&(_=u,u=e),_!==e&&(_=kr(_),_=_===_?_:0),u!==e&&(u=kr(u),u=u===u?u:0),hi(kr(o),u,_)}function QC(o,u,_){return u=En(u),_===e?(_=u,u=0):_=En(_),o=kr(o),sx(o,u,_)}function tF(o,u,_){if(_&&typeof _!="boolean"&&ar(o,u,_)&&(u=_=e),_===e&&(typeof u=="boolean"?(_=u,u=e):typeof o=="boolean"&&(_=o,o=e)),o===e&&u===e?(o=0,u=1):(o=En(o),u===e?(u=o,o=0):u=En(u)),o>u){var D=o;o=u,u=D}if(_||o%1||u%1){var C=m0();return rr(o+C*(u-o+BD("1e-"+((C+"").length-1))),u)}return el(o,u)}var eF=Ki(function(o,u,_){return u=u.toLowerCase(),o+(_?Zd(u):u)});function Zd(o){return Ml(ie(o).toLowerCase())}function Kd(o){return o=ie(o),o&&o.replace(xu,VD).replace(bD,"")}function rF(o,u,_){o=ie(o),u=Ar(u);var D=o.length;_=_===e?D:hi(Lt(_),0,D);var C=_;return _-=u.length,_>=0&&o.slice(_,C)==u}function nF(o){return o=ie(o),o&&nu.test(o)?o.replace(Fo,YD):o}function iF(o){return o=ie(o),o&&lu.test(o)?o.replace(ls,"\\$&"):o}var sF=Ki(function(o,u,_){return o+(_?"-":"")+u.toLowerCase()}),oF=Ki(function(o,u,_){return o+(_?" ":"")+u.toLowerCase()}),aF=J0("toLowerCase");function uF(o,u,_){o=ie(o),u=Lt(u);var D=u?qi(o):0;if(!u||D>=u)return o;var C=(u-D)/2;return ia(Vo(C),_)+o+ia(jo(C),_)}function lF(o,u,_){o=ie(o),u=Lt(u);var D=u?qi(o):0;return u&&D<u?o+ia(u-D,_):o}function cF(o,u,_){o=ie(o),u=Lt(u);var D=u?qi(o):0;return u&&D<u?ia(u-D,_)+o:o}function fF(o,u,_){return _||u==null?u=0:u&&(u=+u),vb(ie(o).replace(cs,""),u||0)}function hF(o,u,_){return(_?ar(o,u,_):u===e)?u=1:u=Lt(u),rl(ie(o),u)}function dF(){var o=arguments,u=ie(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var pF=Ki(function(o,u,_){return o+(_?"_":"")+u.toLowerCase()});function _F(o,u,_){return _&&typeof _!="number"&&ar(o,u,_)&&(u=_=e),_=_===e?ct:_>>>0,_?(o=ie(o),o&&(typeof u=="string"||u!=null&&!Al(u))&&(u=Ar(u),!u&&ki(o))?Vn(Kr(o),0,_):o.split(u,_)):[]}var mF=Ki(function(o,u,_){return o+(_?" ":"")+Ml(u)});function gF(o,u,_){return o=ie(o),_=_==null?0:hi(Lt(_),0,o.length),u=Ar(u),o.slice(_,_+u.length)==u}function vF(o,u,_){var D=B.templateSettings;_&&ar(o,u,_)&&(u=e),o=ie(o),u=ma({},u,D,id);var C=ma({},u.imports,D.imports,id),I=Ye(C),P=zu(C,I),k,V,tt=0,et=u.interpolate||Li,ot="__p += '",pt=qu((u.escape||Li).source+"|"+et.source+"|"+(et===Mo?gu:Li).source+"|"+(u.evaluate||Li).source+"|$","g"),wt="//# sourceURL="+(le.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++FD+"]")+`
11
11
  `;o.replace(pt,function(Ft,Ut,Vt,Fr,ur,Mr){return Vt||(Vt=Fr),ot+=o.slice(tt,Mr).replace(ai,ZD),Ut&&(k=!0,ot+=`' +
12
12
  __e(`+Ut+`) +
13
13
  '`),ur&&(V=!0,ot+=`';
@@ -24,46 +24,46 @@ __p += '`),Vt&&(ot+=`' +
24
24
  function print() { __p += __j.call(arguments, '') }
25
25
  `:`;
26
26
  `)+ot+`return __p
27
- }`;var Rt=Hd(function(){return te(I,wt+"return "+ot).apply(e,P)});if(Rt.source=ot,El(Rt))throw Rt;return Rt}function wF(o){return ie(o).toLowerCase()}function yF(o){return ie(o).toUpperCase()}function DF(o,u,m){if(o=ie(o),o&&(m||u===e))return s0(o);if(!o||!(u=Ar(u)))return o;var D=Kr(o),A=Kr(u),I=o0(D,A),P=a0(D,A)+1;return Vn(D,I,P).join("")}function bF(o,u,m){if(o=ie(o),o&&(m||u===e))return o.slice(0,l0(o)+1);if(!o||!(u=Ar(u)))return o;var D=Kr(o),A=a0(D,Kr(u))+1;return Vn(D,0,A).join("")}function xF(o,u,m){if(o=ie(o),o&&(m||u===e))return o.replace(cs,"");if(!o||!(u=Ar(u)))return o;var D=Kr(o),A=o0(D,Kr(u));return Vn(D,A).join("")}function EF(o,u){var m=C,D=O;if(Fe(u)){var A="separator"in u?u.separator:A;m="length"in u?Lt(u.length):m,D="omission"in u?Ar(u.omission):D}o=ie(o);var I=o.length;if(ki(o)){var P=Kr(o);I=P.length}if(m>=I)return o;var k=m-qi(D);if(k<1)return D;var V=P?Vn(P,0,k).join(""):o.slice(0,k);if(A===e)return V+D;if(P&&(k+=V.length-k),Al(A)){if(o.slice(k).search(A)){var tt,et=V;for(A.global||(A=qu(A.source,ie(No.exec(A))+"g")),A.lastIndex=0;tt=A.exec(et);)var ot=tt.index;V=V.slice(0,ot===e?k:ot)}}else if(o.indexOf(Ar(A),k)!=k){var pt=V.lastIndexOf(A);pt>-1&&(V=V.slice(0,pt))}return V+D}function AF(o){return o=ie(o),o&&ru.test(o)?o.replace(oi,tb):o}var CF=Ki(function(o,u,m){return o+(m?" ":"")+u.toUpperCase()}),Ml=J0("toUpperCase");function Gd(o,u,m){return o=ie(o),u=m?e:u,u===e?GD(o)?nb(o):kD(o):o.match(u)||[]}var Hd=Pt(function(o,u){try{return xr(o,e,u)}catch(m){return El(m)?m:new Bt(m)}}),FF=Dn(function(o,u){return Tr(u,function(m){m=un(m),wn(o,m,bl(o[m],o))}),o});function MF(o){var u=o==null?0:o.length,m=At();return o=u?Ee(o,function(D){if(typeof D[1]!="function")throw new $r(a);return[m(D[0]),D[1]]}):[],Pt(function(D){for(var A=-1;++A<u;){var I=o[A];if(xr(I[0],this,D))return xr(I[1],this,D)}})}function NF(o){return tx(Rr(o,h))}function Nl(o){return function(){return o}}function SF(o,u){return o==null||o!==o?u:o}var OF=Q0(),BF=Q0(!0);function _r(o){return o}function Sl(o){return N0(typeof o=="function"?o:Rr(o,h))}function IF(o){return O0(Rr(o,h))}function TF(o,u){return B0(o,Rr(u,h))}var $F=Pt(function(o,u){return function(m){return ws(m,o,u)}}),LF=Pt(function(o,u){return function(m){return ws(o,m,u)}});function Ol(o,u,m){var D=Ye(u),A=Jo(u,D);m==null&&!(Fe(u)&&(A.length||!D.length))&&(m=u,u=o,o=this,A=Jo(u,Ye(u)));var I=!(Fe(m)&&"chain"in m)||!!m.chain,P=xn(o);return Tr(A,function(k){var V=u[k];o[k]=V,P&&(o.prototype[k]=function(){var tt=this.__chain__;if(I||tt){var et=o(this.__wrapped__),ot=et.__actions__=hr(this.__actions__);return ot.push({func:V,args:arguments,thisArg:o}),et.__chain__=tt,et}return V.apply(o,zn([this.value()],arguments))})}),o}function RF(){return Je._===this&&(Je._=lb),this}function Bl(){}function PF(o){return o=Lt(o),Pt(function(u){return I0(u,o)})}var zF=ll(Ee),kF=ll(t0),qF=ll(Tu);function Jd(o){return ml(o)?$u(un(o)):gx(o)}function UF(o){return function(u){return o==null?e:di(o,u)}}var WF=ed(),jF=ed(!0);function Il(){return[]}function Tl(){return!1}function VF(){return{}}function YF(){return""}function ZF(){return!0}function KF(o,u){if(o=Lt(o),o<1||o>Z)return[];var m=ct,D=rr(o,ct);u=At(u),o-=ct;for(var A=Pu(D,u);++m<o;)u(m);return A}function GF(o){return Tt(o)?Ee(o,un):Cr(o)?[o]:hr(gd(ie(o)))}function HF(o){var u=++ab;return ie(o)+u}var JF=na(function(o,u){return o+u},0),XF=cl("ceil"),QF=na(function(o,u){return o/u},1),t2=cl("floor");function e2(o){return o&&o.length?Ho(o,_r,Gu):e}function r2(o,u){return o&&o.length?Ho(o,At(u,2),Gu):e}function n2(o){return n0(o,_r)}function i2(o,u){return n0(o,At(u,2))}function s2(o){return o&&o.length?Ho(o,_r,Qu):e}function o2(o,u){return o&&o.length?Ho(o,At(u,2),Qu):e}var a2=na(function(o,u){return o*u},1),u2=cl("round"),l2=na(function(o,u){return o-u},0);function c2(o){return o&&o.length?Ru(o,_r):0}function f2(o,u){return o&&o.length?Ru(o,At(u,2)):0}return B.after=IA,B.ary=Md,B.assign=yC,B.assignIn=Ud,B.assignInWith=ma,B.assignWith=DC,B.at=bC,B.before=Nd,B.bind=bl,B.bindAll=FF,B.bindKey=Sd,B.castArray=VA,B.chain=Ad,B.chunk=tE,B.compact=eE,B.concat=rE,B.cond=MF,B.conforms=NF,B.constant=Nl,B.countBy=cA,B.create=xC,B.curry=Od,B.curryRight=Bd,B.debounce=Id,B.defaults=EC,B.defaultsDeep=AC,B.defer=TA,B.delay=$A,B.difference=nE,B.differenceBy=iE,B.differenceWith=sE,B.drop=oE,B.dropRight=aE,B.dropRightWhile=uE,B.dropWhile=lE,B.fill=cE,B.filter=hA,B.flatMap=_A,B.flatMapDeep=mA,B.flatMapDepth=gA,B.flatten=Dd,B.flattenDeep=fE,B.flattenDepth=hE,B.flip=LA,B.flow=OF,B.flowRight=BF,B.fromPairs=dE,B.functions=BC,B.functionsIn=IC,B.groupBy=vA,B.initial=_E,B.intersection=mE,B.intersectionBy=gE,B.intersectionWith=vE,B.invert=$C,B.invertBy=LC,B.invokeMap=yA,B.iteratee=Sl,B.keyBy=DA,B.keys=Ye,B.keysIn=pr,B.map=ca,B.mapKeys=PC,B.mapValues=zC,B.matches=IF,B.matchesProperty=TF,B.memoize=ha,B.merge=kC,B.mergeWith=Wd,B.method=$F,B.methodOf=LF,B.mixin=Ol,B.negate=da,B.nthArg=PF,B.omit=qC,B.omitBy=UC,B.once=RA,B.orderBy=bA,B.over=zF,B.overArgs=PA,B.overEvery=kF,B.overSome=qF,B.partial=xl,B.partialRight=Td,B.partition=xA,B.pick=WC,B.pickBy=jd,B.property=Jd,B.propertyOf=UF,B.pull=bE,B.pullAll=xd,B.pullAllBy=xE,B.pullAllWith=EE,B.pullAt=AE,B.range=WF,B.rangeRight=jF,B.rearg=zA,B.reject=CA,B.remove=CE,B.rest=kA,B.reverse=yl,B.sampleSize=MA,B.set=VC,B.setWith=YC,B.shuffle=NA,B.slice=FE,B.sortBy=BA,B.sortedUniq=TE,B.sortedUniqBy=$E,B.split=_F,B.spread=qA,B.tail=LE,B.take=RE,B.takeRight=PE,B.takeRightWhile=zE,B.takeWhile=kE,B.tap=eA,B.throttle=UA,B.thru=la,B.toArray=zd,B.toPairs=Vd,B.toPairsIn=Yd,B.toPath=GF,B.toPlainObject=qd,B.transform=ZC,B.unary=WA,B.union=qE,B.unionBy=UE,B.unionWith=WE,B.uniq=jE,B.uniqBy=VE,B.uniqWith=YE,B.unset=KC,B.unzip=Dl,B.unzipWith=Ed,B.update=GC,B.updateWith=HC,B.values=Ji,B.valuesIn=JC,B.without=ZE,B.words=Gd,B.wrap=jA,B.xor=KE,B.xorBy=GE,B.xorWith=HE,B.zip=JE,B.zipObject=XE,B.zipObjectDeep=QE,B.zipWith=tA,B.entries=Vd,B.entriesIn=Yd,B.extend=Ud,B.extendWith=ma,Ol(B,B),B.add=JF,B.attempt=Hd,B.camelCase=eF,B.capitalize=Zd,B.ceil=XF,B.clamp=XC,B.clone=YA,B.cloneDeep=KA,B.cloneDeepWith=GA,B.cloneWith=ZA,B.conformsTo=HA,B.deburr=Kd,B.defaultTo=SF,B.divide=QF,B.endsWith=rF,B.eq=Hr,B.escape=nF,B.escapeRegExp=iF,B.every=fA,B.find=dA,B.findIndex=wd,B.findKey=CC,B.findLast=pA,B.findLastIndex=yd,B.findLastKey=FC,B.floor=t2,B.forEach=Cd,B.forEachRight=Fd,B.forIn=MC,B.forInRight=NC,B.forOwn=SC,B.forOwnRight=OC,B.get=Cl,B.gt=JA,B.gte=XA,B.has=TC,B.hasIn=Fl,B.head=bd,B.identity=_r,B.includes=wA,B.indexOf=pE,B.inRange=QC,B.invoke=RC,B.isArguments=mi,B.isArray=Tt,B.isArrayBuffer=QA,B.isArrayLike=dr,B.isArrayLikeObject=Be,B.isBoolean=tC,B.isBuffer=Yn,B.isDate=eC,B.isElement=rC,B.isEmpty=nC,B.isEqual=iC,B.isEqualWith=sC,B.isError=El,B.isFinite=oC,B.isFunction=xn,B.isInteger=$d,B.isLength=pa,B.isMap=Ld,B.isMatch=aC,B.isMatchWith=uC,B.isNaN=lC,B.isNative=cC,B.isNil=hC,B.isNull=fC,B.isNumber=Rd,B.isObject=Fe,B.isObjectLike=Ne,B.isPlainObject=As,B.isRegExp=Al,B.isSafeInteger=dC,B.isSet=Pd,B.isString=_a,B.isSymbol=Cr,B.isTypedArray=Hi,B.isUndefined=pC,B.isWeakMap=_C,B.isWeakSet=mC,B.join=wE,B.kebabCase=sF,B.last=zr,B.lastIndexOf=yE,B.lowerCase=oF,B.lowerFirst=aF,B.lt=gC,B.lte=vC,B.max=e2,B.maxBy=r2,B.mean=n2,B.meanBy=i2,B.min=s2,B.minBy=o2,B.stubArray=Il,B.stubFalse=Tl,B.stubObject=VF,B.stubString=YF,B.stubTrue=ZF,B.multiply=a2,B.nth=DE,B.noConflict=RF,B.noop=Bl,B.now=fa,B.pad=uF,B.padEnd=lF,B.padStart=cF,B.parseInt=fF,B.random=tF,B.reduce=EA,B.reduceRight=AA,B.repeat=hF,B.replace=dF,B.result=jC,B.round=u2,B.runInContext=j,B.sample=FA,B.size=SA,B.snakeCase=pF,B.some=OA,B.sortedIndex=ME,B.sortedIndexBy=NE,B.sortedIndexOf=SE,B.sortedLastIndex=OE,B.sortedLastIndexBy=BE,B.sortedLastIndexOf=IE,B.startCase=mF,B.startsWith=gF,B.subtract=l2,B.sum=c2,B.sumBy=f2,B.template=vF,B.times=KF,B.toFinite=En,B.toInteger=Lt,B.toLength=kd,B.toLower=wF,B.toNumber=kr,B.toSafeInteger=wC,B.toString=ie,B.toUpper=yF,B.trim=DF,B.trimEnd=bF,B.trimStart=xF,B.truncate=EF,B.unescape=AF,B.uniqueId=HF,B.upperCase=CF,B.upperFirst=Ml,B.each=Cd,B.eachRight=Fd,B.first=bd,Ol(B,function(){var o={};return on(B,function(u,m){le.call(B.prototype,m)||(o[m]=u)}),o}(),{chain:!1}),B.VERSION=r,Tr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){B[o].placeholder=B}),Tr(["drop","take"],function(o,u){jt.prototype[o]=function(m){m=m===e?1:We(Lt(m),0);var D=this.__filtered__&&!u?new jt(this):this.clone();return D.__filtered__?D.__takeCount__=rr(m,D.__takeCount__):D.__views__.push({size:rr(m,ct),type:o+(D.__dir__<0?"Right":"")}),D},jt.prototype[o+"Right"]=function(m){return this.reverse()[o](m).reverse()}}),Tr(["filter","map","takeWhile"],function(o,u){var m=u+1,D=m==q||m==z;jt.prototype[o]=function(A){var I=this.clone();return I.__iteratees__.push({iteratee:At(A,3),type:m}),I.__filtered__=I.__filtered__||D,I}}),Tr(["head","last"],function(o,u){var m="take"+(u?"Right":"");jt.prototype[o]=function(){return this[m](1).value()[0]}}),Tr(["initial","tail"],function(o,u){var m="drop"+(u?"":"Right");jt.prototype[o]=function(){return this.__filtered__?new jt(this):this[m](1)}}),jt.prototype.compact=function(){return this.filter(_r)},jt.prototype.find=function(o){return this.filter(o).head()},jt.prototype.findLast=function(o){return this.reverse().find(o)},jt.prototype.invokeMap=Pt(function(o,u){return typeof o=="function"?new jt(this):this.map(function(m){return ws(m,o,u)})}),jt.prototype.reject=function(o){return this.filter(da(At(o)))},jt.prototype.slice=function(o,u){o=Lt(o);var m=this;return m.__filtered__&&(o>0||u<0)?new jt(m):(o<0?m=m.takeRight(-o):o&&(m=m.drop(o)),u!==e&&(u=Lt(u),m=u<0?m.dropRight(-u):m.take(u-o)),m)},jt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},jt.prototype.toArray=function(){return this.take(ct)},on(jt.prototype,function(o,u){var m=/^(?:filter|find|map|reject)|While$/.test(u),D=/^(?:head|last)$/.test(u),A=B[D?"take"+(u=="last"?"Right":""):u],I=D||/^find/.test(u);A&&(B.prototype[u]=function(){var P=this.__wrapped__,k=D?[1]:arguments,V=P instanceof jt,tt=k[0],et=V||Tt(P),ot=function(Ut){var Vt=A.apply(B,zn([Ut],k));return D&&pt?Vt[0]:Vt};et&&m&&typeof tt=="function"&&tt.length!=1&&(V=et=!1);var pt=this.__chain__,wt=!!this.__actions__.length,Ct=I&&!pt,Rt=V&&!wt;if(!I&&et){P=Rt?P:new jt(this);var Ft=o.apply(P,k);return Ft.__actions__.push({func:la,args:[ot],thisArg:e}),new Lr(Ft,pt)}return Ct&&Rt?o.apply(this,k):(Ft=this.thru(ot),Ct?D?Ft.value()[0]:Ft.value():Ft)})}),Tr(["pop","push","shift","sort","splice","unshift"],function(o){var u=$o[o],m=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);B.prototype[o]=function(){var A=arguments;if(D&&!this.__chain__){var I=this.value();return u.apply(Tt(I)?I:[],A)}return this[m](function(P){return u.apply(Tt(P)?P:[],A)})}}),on(jt.prototype,function(o,u){var m=B[u];if(m){var D=m.name+"";le.call(Vi,D)||(Vi[D]=[]),Vi[D].push({name:u,func:m})}}),Vi[ra(e,v).name]=[{name:"wrapper",func:e}],jt.prototype.clone=Ab,jt.prototype.reverse=Cb,jt.prototype.value=Fb,B.prototype.at=rA,B.prototype.chain=nA,B.prototype.commit=iA,B.prototype.next=sA,B.prototype.plant=aA,B.prototype.reverse=uA,B.prototype.toJSON=B.prototype.valueOf=B.prototype.value=lA,B.prototype.first=B.prototype.head,hs&&(B.prototype[hs]=oA),B},Ui=ib();ui?((ui.exports=Ui)._=Ui,Su._=Ui):Je._=Ui}).call(Yt)}(Zn,Zn.exports);var Qr=Zn.exports;class Qd{constructor(t,e){L(this,"_defaultParams");L(this,"_UserTypeFileds");L(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Qr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Qr.cloneDeep(this._defaultParams),t),this._varipKeys)}addNewMethod(t,e){this._UserTypeFileds.prototype[t]=e}_createDynamicClass(){return class{constructor(t,e){L(this,"_varipKeys");Object.assign(this,t),this._varipKeys=e}get varipKeys(){return[...this._varipKeys]}copy(){return Qr.cloneDeep(this)}}}}var zl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){var e=1e3,r=6e4,n=36e5,s="millisecond",a="second",l="minute",c="hour",f="day",d="week",h="month",p="quarter",g="year",w="date",_="Invalid Date",y=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,x={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(q){var U=["th","st","nd","rd"],z=q%100;return"["+q+(U[(z-20)%10]||U[z]||U[0])+"]"}},b=function(q,U,z){var K=String(q);return!K||K.length>=U?q:""+Array(U+1-K.length).join(z)+q},M={s:b,z:function(q){var U=-q.utcOffset(),z=Math.abs(U),K=Math.floor(z/60),Z=z%60;return(U<=0?"+":"-")+b(K,2,"0")+":"+b(Z,2,"0")},m:function q(U,z){if(U.date()<z.date())return-q(z,U);var K=12*(z.year()-U.year())+(z.month()-U.month()),Z=U.clone().add(K,h),X=z-Z<0,Q=U.clone().add(K+(X?-1:1),h);return+(-(K+(z-Z)/(X?Z-Q:Q-Z))||0)},a:function(q){return q<0?Math.ceil(q)||0:Math.floor(q)},p:function(q){return{M:h,y:g,w:d,d:f,D:w,h:c,m:l,s:a,ms:s,Q:p}[q]||String(q||"").toLowerCase().replace(/s$/,"")},u:function(q){return q===void 0}},E="en",F={};F[E]=x;var N="$isDayjsObject",S=function(q){return q instanceof $||!(!q||!q[N])},T=function q(U,z,K){var Z;if(!U)return E;if(typeof U=="string"){var X=U.toLowerCase();F[X]&&(Z=X),z&&(F[X]=z,Z=X);var Q=U.split("-");if(!Z&&Q.length>1)return q(Q[0])}else{var ct=U.name;F[ct]=U,Z=ct}return!K&&Z&&(E=Z),Z||!K&&E},C=function(q,U){if(S(q))return q.clone();var z=typeof U=="object"?U:{};return z.date=q,z.args=arguments,new $(z)},O=M;O.l=T,O.i=S,O.w=function(q,U){return C(q,{locale:U.$L,utc:U.$u,x:U.$x,$offset:U.$offset})};var $=function(){function q(z){this.$L=T(z.locale,null,!0),this.parse(z),this.$x=this.$x||z.x||{},this[N]=!0}var U=q.prototype;return U.parse=function(z){this.$d=function(K){var Z=K.date,X=K.utc;if(Z===null)return new Date(NaN);if(O.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var Q=Z.match(y);if(Q){var ct=Q[2]-1||0,vt=(Q[7]||"0").substring(0,3);return X?new Date(Date.UTC(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)):new Date(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)}}return new Date(Z)}(z),this.init()},U.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()},U.$utils=function(){return O},U.isValid=function(){return this.$d.toString()!==_},U.isSame=function(z,K){var Z=C(z);return this.startOf(K)<=Z&&Z<=this.endOf(K)},U.isAfter=function(z,K){return C(z)<this.startOf(K)},U.isBefore=function(z,K){return this.endOf(K)<C(z)},U.$g=function(z,K,Z){return O.u(z)?this[K]:this.set(Z,z)},U.unix=function(){return Math.floor(this.valueOf()/1e3)},U.valueOf=function(){return this.$d.getTime()},U.startOf=function(z,K){var Z=this,X=!!O.u(K)||K,Q=O.p(z),ct=function(It,Nt){var fe=O.w(Z.$u?Date.UTC(Z.$y,Nt,It):new Date(Z.$y,Nt,It),Z);return X?fe:fe.endOf(f)},vt=function(It,Nt){return O.w(Z.toDate()[It].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(Nt)),Z)},lt=this.$W,yt=this.$M,bt=this.$D,Ot="set"+(this.$u?"UTC":"");switch(Q){case g:return X?ct(1,0):ct(31,11);case h:return X?ct(1,yt):ct(0,yt+1);case d:var xt=this.$locale().weekStart||0,ue=(lt<xt?lt+7:lt)-xt;return ct(X?bt-ue:bt+(6-ue),yt);case f:case w:return vt(Ot+"Hours",0);case c:return vt(Ot+"Minutes",1);case l:return vt(Ot+"Seconds",2);case a:return vt(Ot+"Milliseconds",3);default:return this.clone()}},U.endOf=function(z){return this.startOf(z,!1)},U.$set=function(z,K){var Z,X=O.p(z),Q="set"+(this.$u?"UTC":""),ct=(Z={},Z[f]=Q+"Date",Z[w]=Q+"Date",Z[h]=Q+"Month",Z[g]=Q+"FullYear",Z[c]=Q+"Hours",Z[l]=Q+"Minutes",Z[a]=Q+"Seconds",Z[s]=Q+"Milliseconds",Z)[X],vt=X===f?this.$D+(K-this.$W):K;if(X===h||X===g){var lt=this.clone().set(w,1);lt.$d[ct](vt),lt.init(),this.$d=lt.set(w,Math.min(this.$D,lt.daysInMonth())).$d}else ct&&this.$d[ct](vt);return this.init(),this},U.set=function(z,K){return this.clone().$set(z,K)},U.get=function(z){return this[O.p(z)]()},U.add=function(z,K){var Z,X=this;z=Number(z);var Q=O.p(K),ct=function(yt){var bt=C(X);return O.w(bt.date(bt.date()+Math.round(yt*z)),X)};if(Q===h)return this.set(h,this.$M+z);if(Q===g)return this.set(g,this.$y+z);if(Q===f)return ct(1);if(Q===d)return ct(7);var vt=(Z={},Z[l]=r,Z[c]=n,Z[a]=e,Z)[Q]||1,lt=this.$d.getTime()+z*vt;return O.w(lt,this)},U.subtract=function(z,K){return this.add(-1*z,K)},U.format=function(z){var K=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||_;var X=z||"YYYY-MM-DDTHH:mm:ssZ",Q=O.z(this),ct=this.$H,vt=this.$m,lt=this.$M,yt=Z.weekdays,bt=Z.months,Ot=Z.meridiem,xt=function(Nt,fe,re,qt){return Nt&&(Nt[fe]||Nt(K,X))||re[fe].slice(0,qt)},ue=function(Nt){return O.s(ct%12||12,Nt,"0")},It=Ot||function(Nt,fe,re){var qt=Nt<12?"AM":"PM";return re?qt.toLowerCase():qt};return X.replace(v,function(Nt,fe){return fe||function(re){switch(re){case"YY":return String(K.$y).slice(-2);case"YYYY":return O.s(K.$y,4,"0");case"M":return lt+1;case"MM":return O.s(lt+1,2,"0");case"MMM":return xt(Z.monthsShort,lt,bt,3);case"MMMM":return xt(bt,lt);case"D":return K.$D;case"DD":return O.s(K.$D,2,"0");case"d":return String(K.$W);case"dd":return xt(Z.weekdaysMin,K.$W,yt,2);case"ddd":return xt(Z.weekdaysShort,K.$W,yt,3);case"dddd":return yt[K.$W];case"H":return String(ct);case"HH":return O.s(ct,2,"0");case"h":return ue(1);case"hh":return ue(2);case"a":return It(ct,vt,!0);case"A":return It(ct,vt,!1);case"m":return String(vt);case"mm":return O.s(vt,2,"0");case"s":return String(K.$s);case"ss":return O.s(K.$s,2,"0");case"SSS":return O.s(K.$ms,3,"0");case"Z":return Q}return null}(Nt)||Q.replace(":","")})},U.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},U.diff=function(z,K,Z){var X,Q=this,ct=O.p(K),vt=C(z),lt=(vt.utcOffset()-this.utcOffset())*r,yt=this-vt,bt=function(){return O.m(Q,vt)};switch(ct){case g:X=bt()/12;break;case h:X=bt();break;case p:X=bt()/3;break;case d:X=(yt-lt)/6048e5;break;case f:X=(yt-lt)/864e5;break;case c:X=yt/n;break;case l:X=yt/r;break;case a:X=yt/e;break;default:X=yt}return Z?X:O.a(X)},U.daysInMonth=function(){return this.endOf(h).$D},U.$locale=function(){return F[this.$L]},U.locale=function(z,K){if(!z)return this.$L;var Z=this.clone(),X=T(z,K,!0);return X&&(Z.$L=X),Z},U.clone=function(){return O.w(this.$d,this)},U.toDate=function(){return new Date(this.valueOf())},U.toJSON=function(){return this.isValid()?this.toISOString():null},U.toISOString=function(){return this.$d.toISOString()},U.toString=function(){return this.$d.toUTCString()},q}(),W=$.prototype;return C.prototype=W,[["$ms",s],["$s",a],["$m",l],["$H",c],["$W",f],["$M",h],["$y",g],["$D",w]].forEach(function(q){W[q[1]]=function(U){return this.$g(U,q[0],q[1])}}),C.extend=function(q,U){return q.$i||(q(U,$,C),q.$i=!0),C},C.locale=T,C.isDayjs=S,C.unix=function(q){return C(1e3*q)},C.en=F[E],C.Ls=F,C.p={},C})})(zl);var tp=zl.exports,ee=Gt(tp),kl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(s,a,l){var c=a.prototype;l.utc=function(_){var y={date:_,utc:!0,args:arguments};return new a(y)},c.utc=function(_){var y=l(this.toDate(),{locale:this.$L,utc:!0});return _?y.add(this.utcOffset(),e):y},c.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var f=c.parse;c.parse=function(_){_.utc&&(this.$u=!0),this.$utils().u(_.$offset)||(this.$offset=_.$offset),f.call(this,_)};var d=c.init;c.init=function(){if(this.$u){var _=this.$d;this.$y=_.getUTCFullYear(),this.$M=_.getUTCMonth(),this.$D=_.getUTCDate(),this.$W=_.getUTCDay(),this.$H=_.getUTCHours(),this.$m=_.getUTCMinutes(),this.$s=_.getUTCSeconds(),this.$ms=_.getUTCMilliseconds()}else d.call(this)};var h=c.utcOffset;c.utcOffset=function(_,y){var v=this.$utils().u;if(v(_))return this.$u?0:v(this.$offset)?h.call(this):this.$offset;if(typeof _=="string"&&(_=function(E){E===void 0&&(E="");var F=E.match(r);if(!F)return null;var N=(""+F[0]).match(n)||["-",0,0],S=N[0],T=60*+N[1]+ +N[2];return T===0?0:S==="+"?T:-T}(_),_===null))return this;var x=Math.abs(_)<=16?60*_:_,b=this;if(y)return b.$offset=x,b.$u=_===0,b;if(_!==0){var M=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(x+M,e)).$offset=x,b.$x.$localOffset=M}else b=this.utc();return b};var p=c.format;c.format=function(_){var y=_||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return p.call(this,y)},c.valueOf=function(){var _=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*_},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(_){return _==="s"&&this.$offset?l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var w=c.diff;c.diff=function(_,y,v){if(_&&this.$u===_.$u)return w.call(this,_,y,v);var x=this.local(),b=l(_).local();return w.call(x,b,y,v)}}})})(kl);var ep=kl.exports,ql=Gt(ep),Ul={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,s,a){var l,c=function(p,g,w){w===void 0&&(w={});var _=new Date(p),y=function(v,x){x===void 0&&(x={});var b=x.timeZoneName||"short",M=v+"|"+b,E=r[M];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:v,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:b}),r[M]=E),E}(g,w);return y.formatToParts(_)},f=function(p,g){for(var w=c(p,g),_=[],y=0;y<w.length;y+=1){var v=w[y],x=v.type,b=v.value,M=e[x];M>=0&&(_[M]=parseInt(b,10))}var E=_[3],F=E===24?0:E,N=_[0]+"-"+_[1]+"-"+_[2]+" "+F+":"+_[4]+":"+_[5]+":000",S=+p;return(a.utc(N).valueOf()-(S-=S%1e3))/6e4},d=s.prototype;d.tz=function(p,g){p===void 0&&(p=l);var w=this.utcOffset(),_=this.toDate(),y=_.toLocaleString("en-US",{timeZone:p}),v=Math.round((_-new Date(y))/1e3/60),x=a(y,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(_.getTimezoneOffset()/15)-v,!0);if(g){var b=x.utcOffset();x=x.add(w-b,"minute")}return x.$x.$timezone=p,x},d.offsetName=function(p){var g=this.$x.$timezone||a.tz.guess(),w=c(this.valueOf(),g,{timeZoneName:p}).find(function(_){return _.type.toLowerCase()==="timezonename"});return w&&w.value};var h=d.startOf;d.startOf=function(p,g){if(!this.$x||!this.$x.$timezone)return h.call(this,p,g);var w=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return h.call(w,p,g).tz(this.$x.$timezone,!0)},a.tz=function(p,g,w){var _=w&&g,y=w||g||l,v=f(+a(),y);if(typeof p!="string")return a(p).tz(y);var x=function(F,N,S){var T=F-60*N*1e3,C=f(T,S);if(N===C)return[T,N];var O=f(T-=60*(C-N)*1e3,S);return C===O?[T,C]:[F-60*Math.min(C,O)*1e3,Math.max(C,O)]}(a.utc(p,_).valueOf(),v,y),b=x[0],M=x[1],E=a(b).utcOffset(M);return E.$x.$timezone=y,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(p){l=p}}})})(Ul);var rp=Ul.exports,np=Gt(rp),Wl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){var e="week",r="year";return function(n,s,a){var l=s.prototype;l.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var f=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var d=a(this).startOf(r).add(1,r).date(f),h=a(this).endOf(e);if(d.isBefore(h))return 1}var p=a(this).startOf(r).date(f).startOf(e).subtract(1,"millisecond"),g=this.diff(p,e,!0);return g<0?a(this).startOf("week").week():Math.ceil(g)},l.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(Wl);var ip=Wl.exports,sp=Gt(ip);function Ze(i,t){return i.replace(/\$(\w+)/g,(e,r)=>String(t[r])||e)}function Cs(i){const t=parseInt(i)||1;let e=i.replace(/\d+/,"");return e==="m"||e==="M"?e="M":e?e=e.toLocaleLowerCase():e="m",[t,e]}function op(i){const t=/([+-])(\d{1,2})(\d{0,2})/,e=i.replace(/GMT|UTC/,"").match(t);if(!e)throw new Error("Invalid timezone string");const[,r,n,s]=e,a=parseInt(n,10)*60||0,l=parseInt(s,10)||0;return(r==="+"?-1:1)*(a+l)}function qr(i,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?ee(i).utcOffset(op(t)):ee(i).tz(t)}function tn(i){const[t,e]=Cs(i);let r=0;switch(e){case"m":r=60;break;case"s":r=1;break;case"M":r=31*24*60*60;break;case"d":r=24*60*60;break;case"w":r=7*24*60*60;break;default:r=60*60;break}return Math.round(Number(t)*r)}function _t(i){return typeof i!="number"||isNaN(i)}function ge(i,t){for(const e of t)i!=null&&i.hasOwnProperty(e)&&i[e]===void 0&&(i[e]=null)}function jl(i){var t=atob(i),e=decodeURI(t);return e}function Vl(i,t){if(!String(i).includes("."))return i;const e=Math.pow(10,t);return Math.floor(i*e)/e}var Me=(i=>(i.BOOL="bool",i.INT="int",i.FLOAT="float",i.ARRAY="array",i.BOX="box",i.CHART_POINT="chart.point",i.COLOR="color",i.CONST="const",i.LABEL="label",i.LINE="line",i.LINEFILL="linefill",i.MAP="map",i.MATRIX="matrix",i.POLYLINE="polyline",i.SERIES="series",i.SIMPLE="simple",i.STRING="string",i.TABLE="table",i.UNDETERMINED="undetermined type",i.INPUT="input",i.NA="na",i.VOID="void",i.ENUM="enum",i))(Me||{}),Fs=(i=>(i.dividends="dividends",i.none="none",i.splits="splits",i))(Fs||{}),Ur=(i=>(i.freqAll="freq_all",i.freqOncePerBar="freq_once_per_bar",i.freqOncePerBarClose="freq_once_per_bar_close",i))(Ur||{}),Xi=(i=>(i.gapsOff="gaps_off",i.gapsOn="gaps_on",i.lookaheadOff="lookahead_off",i.lookaheadOn="lookahead_on",i))(Xi||{}),Ke=(i=>(i.all="all",i.dataWindow="data_window",i.none="none",i.pane="pane",i.priceScale="price_scale",i.statusLine="status_line",i))(Ke||{}),Wr=(i=>(i.both="both",i.left="left",i.none="none",i.right="right",i))(Wr||{}),Kt=(i=>(i.inherit="inherit",i.mintick="mintick",i.percent="percent",i.price="price",i.volume="volume",i))(Kt||{}),Ms=(i=>(i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(Ms||{}),ve=(i=>(i.styleArrowdown="style_arrowdown",i.styleArrowup="style_arrowup",i.styleCircle="style_circle",i.styleCross="style_cross",i.styleDiamond="style_diamond",i.styleFlag="style_flag",i.styleLabelCenter="style_label_center",i.styleLabelDown="style_label_down",i.styleLabelLeft="style_label_left",i.styleLabelLowerLeft="style_label_lower_left",i.styleLabelLowerRight="style_label_lower_right",i.styleLabelRight="style_label_right",i.styleLabelUp="style_label_up",i.styleLabelUpperLeft="style_label_upper_left",i.styleLabelUpperRight="style_label_upper_right",i.styleNone="style_none",i.styleSquare="style_square",i.styleTextOutline="style_text_outline",i.styleTriangledown="style_triangledown",i.styleTriangleup="style_triangleup",i.styleXcross="style_xcross",i))(ve||{}),Re=(i=>(i.styleArrowBoth="style_arrow_both",i.styleArrowLeft="style_arrow_left",i.styleArrowRight="style_arrow_right",i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(Re||{}),ln=(i=>(i.abovebar="abovebar",i.absolute="absolute",i.belowbar="belowbar",i.bottom="bottom",i.top="top",i))(ln||{}),Kn=(i=>(i.ascending="ascending",i.descending="descending",i))(Kn||{}),Nr=(i=>(i.styleArea="Area",i.styleAreabr="Area With Breaks",i.styleCircles="Circles",i.styleColumns="Columns",i.styleCross="Cross",i.styleHistogram="Histogram",i.styleLine="Line",i.styleLinebr="Line With Breaks",i.styleStepline="Step Line",i.styleSteplineDiamond="Step Line With Diamonds",i.styleSteplinebr="Step line with Breaks",i))(Nr||{}),mr=(i=>(i.bottomCenter="bottom_center",i.bottomLeft="bottom_left",i.bottomRight="bottom_right",i.middleCenter="middle_center",i.middleLeft="middle_left",i.middleRight="middle_right",i.topCenter="top_center",i.topLeft="top_left",i.topRight="top_right",i))(mr||{}),Ns=(i=>(i.left="left",i.none="none",i.right="right",i))(Ns||{}),gi=(i=>(i.extended="extended",i.regular="regular",i))(gi||{}),lr=(i=>(i.arrowdown="arrowdown",i.arrowup="arrowup",i.circle="circle",i.cross="cross",i.diamond="diamond",i.flag="flag",i.labeldown="labeldown",i.labelup="labelup",i.square="square",i.triangledown="triangledown",i.triangleup="triangleup",i.xcross="xcross",i))(lr||{}),ir=(i=>(i.auto="auto",i.huge="huge",i.large="large",i.normal="normal",i.small="small",i.tiny="tiny",i))(ir||{}),Gn=(i=>(i.familyDefault="default",i.familyMonospace="monospace",i))(Gn||{}),Pe=(i=>(i.cash="cash",i.fixed="fixed",i.percentOfEquity="percent_of_equity",i))(Pe||{}),je=(i=>(i.cashPerContract="cash_per_contract",i.cashPerOrder="cash_per_order",i.percent="percent",i))(je||{}),se=(i=>(i.all="all",i.long="long",i.short="short",i))(se||{}),cn=(i=>(i.cancel="cancel",i.none="none",i.reduce="reduce",i))(cn||{}),Wt=(i=>(i.alignBottom="align_bottom",i.alignCenter="align_center",i.alignLeft="align_left",i.alignRight="align_right",i.alignTop="align_top",i.wrapAuto="wrap_auto",i.wrapNone="wrap_none",i))(Wt||{}),De=(i=>(i.bar_index="bar_index",i.bar_time="bar_time",i))(De||{}),jr=(i=>(i.abovebar="abovebar",i.belowbar="belowbar",i.price="price",i))(jr||{}),Ss=(i=>(i.actual="actual",i.estimate="estimate",i.standardized="standardized",i))(Ss||{}),Hn=(i=>(i.traditional="Traditional",i.fibonacci="Fibonacci",i.woodie="Woodie",i.classic="Classic",i.dm="DM",i.camarilla="Camarilla",i))(Hn||{}),sr=(i=>(i.INT="int",i.BOOL="bool",i.TIME="time",i.COLOR="color",i.FLOAT="float",i.PRICE="price",i.SOURCE="source",i.STRING="string",i.SYMBOL="symbol",i.SESSION="session",i.TEXT_AREA="text_area",i.TIMEFRAME="timeframe",i.ENUM="enum",i))(sr||{}),Yl=(i=>(i.library="library",i.indicator="indicator",i.strategy="strategy",i))(Yl||{}),zt=(i=>(i[i.Hint=1]="Hint",i[i.Info=2]="Info",i[i.Warning=4]="Warning",i[i.Error=8]="Error",i))(zt||{});const ce={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"},ap={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."};Me.SERIES,Me.SIMPLE,Me.INPUT,Me.CONST,Me.INT,Me.FLOAT,Me.BOOL,Me.COLOR,Me.STRING;const up=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],lp=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],cp=["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 fp{constructor(t){L(this,"_errorListener");this._errorListener=t}new({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_float({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_int({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_color({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_bool({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_string({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_line({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_box({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_table({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_linefill({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_label({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}slice({id:t,index_from:e,index_to:r}){return t==null?void 0:t.slice({index_from:e,index_to:r})}size({id:t}){return t==null?void 0:t.size()}first({id:t}){return t==null?void 0:t.first()}abs({id:t},e){return t==null?void 0:t.abs(e)}avg({id:t},e){return t==null?void 0:t.avg(e)}binary_search({id:t,val:e},r){return t==null?void 0:t.binary_search({val:e},r)}binary_search_leftmost({id:t,val:e},r){return t==null?void 0:t.binary_search_leftmost({val:e},r)}binary_search_rightmost({id:t,val:e},r){return t==null?void 0:t.binary_search_rightmost({val:e},r)}clear({id:t}){t==null||t.clear()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}covariance({id1:t,id2:e,biased:r},n){return t==null?void 0:t.covariance({id2:e,biased:r},n)}every({id:t},e){return t==null?void 0:t.every(e)}from(t,e){const r=new Qt(0,void 0,this._errorListener);return r._value=e,r}fill({id:t,value:e,index_from:r,index_to:n}){t==null||t.fill({value:e,index_from:r,index_to:n})}get({id:t,index:e}){return t==null?void 0:t.get({index:e})}includes({id:t,value:e}){return t==null?void 0:t.includes({value:e})}indexof({id:t,value:e}){return t==null?void 0:t.indexof({value:e})}insert({id:t,index:e,value:r}){t==null||t.insert({index:e,value:r})}join({id:t,separator:e},r){return t==null?void 0:t.join({separator:e},r)}last({id:t}){return t==null?void 0:t.last()}lastindexof({id:t,value:e}){return t==null?void 0:t.lastindexof({value:e})}max({id:t,nth:e},r){return t==null?void 0:t.max({nth:e},r)}median({id:t},e){return t==null?void 0:t.median(e)}min({id:t,nth:e},r){return t==null?void 0:t.min({nth:e},r)}mode({id:t},e){return t==null?void 0:t.mode(e)}percentile_linear_interpolation({id:t,percentage:e},r){return t==null?void 0:t.percentile_linear_interpolation({percentage:e},r)}percentile_nearest_rank({id:t,percentage:e},r){return t==null?void 0:t.percentile_nearest_rank({percentage:e},r)}percentrank({id:t,index:e},r){return t==null?void 0:t.percentrank({index:e},r)}pop({id:t}){return t==null?void 0:t.pop()}push({id:t,value:e}){t==null||t.push({value:e})}range({id:t},e){return t==null?void 0:t.range(e)}remove({id:t,index:e}){return t==null?void 0:t.remove({index:e})}reverse({id:t}){return t==null?void 0:t.reverse()}set({id:t,index:e,value:r}){t==null||t.set({index:e,value:r})}shift({id:t}){return t==null?void 0:t.shift()}some({id:t},e){return t==null?void 0:t.some(e)}sort({id:t,order:e},r){t==null||t.sort({order:e},r)}sort_indices({id:t,order:e},r){return t==null?void 0:t.sort_indices({order:e},r)}standardize({id:t},e){return t==null?void 0:t.standardize(e)}stdev({id:t,biased:e},r){return t==null?void 0:t.stdev({biased:e},r)}sum({id:t},e){return t==null?void 0:t.sum(e)}unshift({id:t,value:e}){t==null||t.unshift({value:e})}variance({id:t,biased:e},r){return t==null?void 0:t.variance({biased:e},r)}}class Qt{constructor(t=0,e,r){L(this,"_arrInstance");L(this,"_errorListener");this._errorListener=r,this._arrInstance=Array.from(new Array(t||0),()=>Qr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Qr.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new Qt(0,void 0,this._errorListener);return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new Qt(0,void 0,this._errorListener);return r._copyData(this._arrInstance.slice(t,e)),r}size(){return this._arrInstance.length}first(){return this._arrInstance[0]}abs(t){const e=new Qt(0,void 0,this._errorListener);this._verifySimpleType("number","abs","int/float",t);const r=this._arrInstance.map(n=>Math.abs(n));return e._copyData(r),e}avg(t){return this._verifySimpleType("number","avg","int/float",t),Qr.mean(this._arrInstance)}binary_search({val:t},e){return this._verifySimpleType("number","binary_search","int/float",e),_t(t)?-1:this._binarySearch(this._arrInstance,t)}binary_search_leftmost({val:t},e){return this._verifySimpleType("number","binary_search_leftmost","int/float",e),_t(t)?this._arrInstance.length-1:this._binarySearchLeftMost(this._arrInstance,t)}binary_search_rightmost({val:t},e){return this._verifySimpleType("number","binary_search_rightmost","int/float",e),_t(t)?this._arrInstance.length:this._binarySearchRightMost(this._arrInstance,t)}clear(){this._arrInstance=[]}concat({id2:t}){return this._arrInstance=this._arrInstance.concat(t==null?void 0:t._value),this}covariance({id2:t,biased:e},r){return this._verifySimpleType("number","covariance","int/float",r),this._verifySimpleType("number","covariance","int/float",r,t==null?void 0:t._value),this._covariance(this._arrInstance,t._value,e,r)}every(t){return this._verifySimpleType("number|boolean","every","int/float/bool",t),this._arrInstance.every(e=>!!e)}fill({value:t,index_from:e=0,index_to:r}){this._arrInstance=this._setElements(this._arrInstance,t,e,r)}get({index:t}){if(!_t(t))return this._arrInstance[t]}includes({value:t}){return this._arrInstance.includes(t)}indexof({value:t}){return this._arrInstance.indexOf(t)}insert({index:t,value:e}){_t(t)||this._arrInstance.splice(t,0,e)}join({separator:t}={},e){return this._verifySimpleType("number|string","join","int/float/string",e),this._arrInstance.join(t)}last(){return this._arrInstance[this._arrInstance.length-1]}lastindexof({value:t}){return this._arrInstance.lastIndexOf(t)}max({nth:t}={},e){return this._verifySimpleType("number","max","int/float",e),this._maxNth([...this._arrInstance],t)}median(t){return this._verifySimpleType("number","median","int/float",t),this._median([...this._arrInstance])}min({nth:t}={},e){return this._verifySimpleType("number","min","int/float",e),this._minNth([...this._arrInstance],t)}mode(t){return this._verifySimpleType("number","mode","int/float",t),this._mode([...this._arrInstance])}percentile_linear_interpolation({percentage:t},e){return this._verifySimpleType("number","percentile_linear_interpolation","int/float",e),this._percentileLinearInterpolation([...this._arrInstance],t)}percentile_nearest_rank({percentage:t=0},e){var r;if(this._arrInstance.length===0||t<0||t>100||_t(t)){(r=this._errorListener)==null||r.addError("Invalid percentile or empty array",e,zt.Error);return}return this._verifySimpleType("number","percentile_nearest_rank","int/float",e),this._getNearestRankPercentile([...this._arrInstance],t)}percentrank({index:t},e){return this._verifySimpleType("number","percentrank","int/float",e),this._getPercentileRank([...this._arrInstance],t)}pop(){return this._arrInstance.pop()}push({value:t}){this._arrInstance.push(t)}range(t){var s;if(this._arrInstance.length===0){(s=this._errorListener)==null||s.addError(ce.arrEmptyErr,t,zt.Error);return}this._verifySimpleType("number","range","int/float",t);const e=Math.min(...this._arrInstance);return Math.max(...this._arrInstance)-e}remove({index:t}){if(!_t(t))return this._arrInstance.splice(t,1)[0]}reverse(){this._arrInstance.reverse()}set({index:t,value:e}){_t(t)||(this._arrInstance[t]=e)}shift(){return this._arrInstance.shift()}some(t){return this._verifySimpleType("number|boolean","some","int/float/bool",t),this._arrInstance.some(e=>!!e)}sort({order:t}={},e){this._verifySimpleType("number","sort","int/float",e),this._arrInstance.sort((r,n)=>t!==Kn.descending?r-n:n-r)}sort_indices({order:t}={},e){this._verifySimpleType("number","sort_indices","int/float",e);const r=this._arrInstance.map((s,a)=>a);r.sort((s,a)=>t!==Kn.descending?this._arrInstance[s]-this._arrInstance[a]:this._arrInstance[a]-this._arrInstance[s]);const n=new Qt(0,void 0,this._errorListener);return n._copyData(r),n}standardize(t){this._verifySimpleType("number","standardize","int/float",t);const e=new Qt(0,void 0,this._errorListener);return e._copyData(this._standardizeArray([...this._arrInstance])),e}stdev({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(ce.arrEmptyErr,e,zt.Error);return}return this._verifySimpleType("number","stdev","int/float",e),this._calculateStandardDeviations([...this._arrInstance],t)}sum(t){return this._verifySimpleType("number","sum","int/float",t),this._arrInstance.reduce((r,n)=>r+(n||0),0)}unshift({value:t}){this._arrInstance.unshift(t)}variance({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(ce.arrEmptyErr,e,zt.Error);return}return this._verifySimpleType("number","variance","int/float",e),this._calculateVariances([...this._arrInstance],t)}_calculateVariances(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>a+((l||0)-r)**2,0),s=n/t.length;return e?s:t.length>1?n/(t.length-1):s}_calculateStandardDeviations(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>{const c=(l||0)-r;return a+c*c},0),s=Math.sqrt(n/t.length);return e?s:t.length>1?Math.sqrt(n/(t.length-1)):s}_standardizeArray(t){const e=t.reduce((s,a)=>s+(a||0),0)/t.length,r=Math.sqrt(t.reduce((s,a)=>s+Math.pow((a||0)-e,2),0)/t.length);return t.map(s=>((s||0)-e)/r)}_getPercentileRank(t,e=0){if(_t(e))return;const r=t[e];let n=0;for(let a=0;a<t.length;a++)(t[a]<r||t[a]===r&&a!=e)&&n++;return n/(t.length-1)*100}_getNearestRankPercentile(t,e=0){const r=t.slice().sort((a,l)=>a-l),n=e/100*r.length,s=Math.ceil(n)-1;return r[s>=r.length?r.length-1:s]}_percentileLinearInterpolation(t,e=0){if(e<0||e>100||_t(e))return;t.sort(function(s,a){return s-a});const r=t.length;e/=100;const n=1/(r*2);if(e<=n)return t[0];if(e>=1-1/(r*2))return t[r-1];for(const[s,a]of t.entries()){const l=t[s-1];if(e<(s+.5)/r)return l+(a-l)*(e-(s-.5)/r)/(1/r)}}_mode(t){const e={};let r=0;const n=[];for(const s of t)e[s]=(e[s]||0)+1,r=Math.max(r,e[s]);for(const s in e)e[s]===r&&n.push(Number(s));return Math.min(...r===1?t:n)}_median(t){t.sort(function(r,n){return r-n});const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}_minNth(t,e=0){return t.sort(function(r,n){return r-n}),t[e]}_maxNth(t,e=0){return t.sort(function(r,n){return n-r}),t[e]}_setElements(t,e,r=0,n){n===void 0&&(n=t.length);for(let s=r;s<n;s++)t[s]=e;return t}_covariance(t,e,r=!0,n){var c;if(t.length!=e.length){(c=this._errorListener)==null||c.addError(ce.arrLengthDiffErr,n,zt.Error);return}t=t.filter(f=>f!==void 0),e=e.filter(f=>f!==void 0);const s=t.reduce((f,d)=>f+d,0)/t.length,a=e.reduce((f,d)=>f+d,0)/e.length;let l=0;for(let f=0;f<t.length;f++)l+=(t[f]-s)*(e[f]-a);return r?l/t.length:l/(t.length-1)}_verifySimpleType(t,e,r,n,s=this._arrInstance){var l;s.filter(c=>c!==void 0).some(c=>!t.split("|").includes(typeof c))&&((l=this._errorListener)==null||l.addError(Ze(ce.arrTypeErr,{name:e,type:r}),n,zt.Error))}_binarySearch(t,e){let r=0,n=t.length-1;for(;r<=n;){const s=Math.floor((r+n)/2);if(t[s]===e)return s;t[s]<e?r=s+1:n=s-1}return-1}_binarySearchLeftMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<e?r=a+1:n=a-1}return s.length?Math.min(...s):r-1}_binarySearchRightMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<=e?r=a+1:n=a-1}return s.length?Math.max(...s):r}}class hp{constructor(t,e){L(this,"_randomNums");L(this,"_mintick");L(this,"_cacheData");L(this,"_barIndex");L(this,"_errorListener");this._mintick=t,this._randomNums={},this._cacheData={},this._barIndex=0,this._errorListener=e}update(t){this._barIndex=t,this._randomNums={}}abs({number:t}){if(!_t(t))return Math.abs(t)}acos({angle:t}){if(_t(t))return;const e=Math.acos(t);return isNaN(e)?void 0:e}asin({angle:t}){if(_t(t))return;const e=Math.asin(t);return isNaN(e)?void 0:e}atan({angle:t}){if(_t(t))return;const e=Math.atan(t);return isNaN(e)?void 0:e}avg(t,e){return Qr.mean(e)}ceil({number:t}){if(!_t(t))return Math.ceil(t)}floor({number:t}){if(!_t(t))return Math.floor(t)}cos({angle:t}){if(_t(t))return;const e=Math.cos(t);return isNaN(e)?void 0:e}sin({angle:t}){if(_t(t))return;const e=Math.sin(t);return isNaN(e)?void 0:e}tan({angle:t}){if(_t(t))return;const e=Math.tan(t);return isNaN(e)?void 0:e}exp({number:t}){if(!_t(t))return Math.exp(t)}log({number:t}){if(!_t(t))return Math.log(t)}log10({number:t}){if(!_t(t))return Math.log10(t)}max(t,e){if(!e.some(r=>_t(r)))return Math.max(...e)}min(t,e){if(!e.some(r=>_t(r)))return Math.min(...e)}pow({base:t,exponent:e}){if(!(_t(t)||_t(e)))return Math.pow(t,e)}random({min:t=0,max:e=1,seed:r},n){if(_t(t)&&(t=0),_t(e)&&(e=1),r&&this._randomNums[r])return this._randomNums[r];if(t>=e){this._errorListener.addError(ce.mathRandomErr,n,zt.Error);return}let s;do s=Math.random()*(e-t)+t;while(s===t||s===e);return r&&(this._randomNums[r]=s),s}round({number:t,precision:e}){if(!_t(t))return _t(e)?Math.round(t):Number(t==null?void 0:t.toFixed(e))}round_to_mintick({number:t}){if(!_t(t))return Number(t==null?void 0:t.toFixed(this._mintick))}sign({number:t}){if(!_t(t))return t&&Math.sign(t)}sqrt({number:t}){if(!_t(t))return Math.sqrt(t)}sum({source:t,length:e=1},r){let n=this._cacheData[`sum_${r}`];n||(n=[]),n[this._barIndex]=t,this._cacheData[`sum_${r}`]=n;const s=n.filter(a=>!_t(a));if(!(s.length<e))return Qr.sum(s.slice(-e))}todegrees({radians:t}){if(!_t(t))return t*(180/Math.PI)}toradians({degrees:t}){if(!_t(t))return t*(Math.PI/180)}}function Os(){return Os=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},Os.apply(this,arguments)}var Zl={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function _e(i){return typeof i=="number"}function Oe(i){return!i||typeof i!="object"||typeof i.constructor!="function"?!1:i.isBigNumber===!0&&typeof i.constructor.prototype=="object"&&i.constructor.prototype.isBigNumber===!0||typeof i.constructor.isDecimal=="function"&&i.constructor.isDecimal(i)===!0}function Kl(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isComplex===!0||!1}function Gl(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isFraction===!0||!1}function Hl(i){return i&&i.constructor.prototype.isUnit===!0||!1}function en(i){return typeof i=="string"}var Ae=Array.isArray;function we(i){return i&&i.constructor.prototype.isMatrix===!0||!1}function Qi(i){return Array.isArray(i)||we(i)}function dp(i){return i&&i.isDenseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function pp(i){return i&&i.isSparseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function _p(i){return i&&i.constructor.prototype.isRange===!0||!1}function va(i){return i&&i.constructor.prototype.isIndex===!0||!1}function mp(i){return typeof i=="boolean"}function gp(i){return i&&i.constructor.prototype.isResultSet===!0||!1}function vp(i){return i&&i.constructor.prototype.isHelp===!0||!1}function wp(i){return typeof i=="function"}function yp(i){return i instanceof Date}function Dp(i){return i instanceof RegExp}function wa(i){return!!(i&&typeof i=="object"&&i.constructor===Object&&!Kl(i)&&!Gl(i))}function bp(i){return i===null}function xp(i){return i===void 0}function Ep(i){return i&&i.isAccessorNode===!0&&i.constructor.prototype.isNode===!0||!1}function Ap(i){return i&&i.isArrayNode===!0&&i.constructor.prototype.isNode===!0||!1}function Cp(i){return i&&i.isAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function Fp(i){return i&&i.isBlockNode===!0&&i.constructor.prototype.isNode===!0||!1}function Mp(i){return i&&i.isConditionalNode===!0&&i.constructor.prototype.isNode===!0||!1}function Np(i){return i&&i.isConstantNode===!0&&i.constructor.prototype.isNode===!0||!1}function Sp(i){return i&&i.isFunctionAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function Op(i){return i&&i.isFunctionNode===!0&&i.constructor.prototype.isNode===!0||!1}function Bp(i){return i&&i.isIndexNode===!0&&i.constructor.prototype.isNode===!0||!1}function Ip(i){return i&&i.isNode===!0&&i.constructor.prototype.isNode===!0||!1}function Tp(i){return i&&i.isObjectNode===!0&&i.constructor.prototype.isNode===!0||!1}function $p(i){return i&&i.isOperatorNode===!0&&i.constructor.prototype.isNode===!0||!1}function Lp(i){return i&&i.isParenthesisNode===!0&&i.constructor.prototype.isNode===!0||!1}function Rp(i){return i&&i.isRangeNode===!0&&i.constructor.prototype.isNode===!0||!1}function Pp(i){return i&&i.isRelationalNode===!0&&i.constructor.prototype.isNode===!0||!1}function zp(i){return i&&i.isSymbolNode===!0&&i.constructor.prototype.isNode===!0||!1}function kp(i){return i&&i.constructor.prototype.isChain===!0||!1}function Cn(i){var t=typeof i;return t==="object"?i===null?"null":Oe(i)?"BigNumber":i.constructor&&i.constructor.name?i.constructor.name:"Object":t}function oe(i){var t=typeof i;if(t==="number"||t==="string"||t==="boolean"||i===null||i===void 0)return i;if(typeof i.clone=="function")return i.clone();if(Array.isArray(i))return i.map(function(e){return oe(e)});if(i instanceof Date)return new Date(i.valueOf());if(Oe(i))return i;if(wa(i))return qp(i,oe);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(i,")"))}function qp(i,t){var e={};for(var r in i)ts(i,r)&&(e[r]=t(i[r]));return e}function Jl(i,t){for(var e in t)ts(t,e)&&(i[e]=t[e]);return i}function vi(i,t){var e,r,n;if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(r=0,n=i.length;r<n;r++)if(!vi(i[r],t[r]))return!1;return!0}else{if(typeof i=="function")return i===t;if(i instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(e in i)if(!(e in t)||!vi(i[e],t[e]))return!1;for(e in t)if(!(e in i))return!1;return!0}else return i===t}}function ts(i,t){return i&&Object.hasOwnProperty.call(i,t)}function Up(i,t){for(var e={},r=0;r<t.length;r++){var n=t[r],s=i[n];s!==void 0&&(e[n]=s)}return e}var Wp=["Matrix","Array"],jp=["number","BigNumber","Fraction"],gr=function(t){if(t)throw new Error(`The global config is readonly.
27
+ }`;var Rt=Hd(function(){return te(I,wt+"return "+ot).apply(e,P)});if(Rt.source=ot,El(Rt))throw Rt;return Rt}function wF(o){return ie(o).toLowerCase()}function yF(o){return ie(o).toUpperCase()}function DF(o,u,_){if(o=ie(o),o&&(_||u===e))return s0(o);if(!o||!(u=Ar(u)))return o;var D=Kr(o),C=Kr(u),I=o0(D,C),P=a0(D,C)+1;return Vn(D,I,P).join("")}function bF(o,u,_){if(o=ie(o),o&&(_||u===e))return o.slice(0,l0(o)+1);if(!o||!(u=Ar(u)))return o;var D=Kr(o),C=a0(D,Kr(u))+1;return Vn(D,0,C).join("")}function xF(o,u,_){if(o=ie(o),o&&(_||u===e))return o.replace(cs,"");if(!o||!(u=Ar(u)))return o;var D=Kr(o),C=o0(D,Kr(u));return Vn(D,C).join("")}function EF(o,u){var _=A,D=O;if(Fe(u)){var C="separator"in u?u.separator:C;_="length"in u?Lt(u.length):_,D="omission"in u?Ar(u.omission):D}o=ie(o);var I=o.length;if(ki(o)){var P=Kr(o);I=P.length}if(_>=I)return o;var k=_-qi(D);if(k<1)return D;var V=P?Vn(P,0,k).join(""):o.slice(0,k);if(C===e)return V+D;if(P&&(k+=V.length-k),Al(C)){if(o.slice(k).search(C)){var tt,et=V;for(C.global||(C=qu(C.source,ie(No.exec(C))+"g")),C.lastIndex=0;tt=C.exec(et);)var ot=tt.index;V=V.slice(0,ot===e?k:ot)}}else if(o.indexOf(Ar(C),k)!=k){var pt=V.lastIndexOf(C);pt>-1&&(V=V.slice(0,pt))}return V+D}function AF(o){return o=ie(o),o&&ru.test(o)?o.replace(oi,tb):o}var CF=Ki(function(o,u,_){return o+(_?" ":"")+u.toUpperCase()}),Ml=J0("toUpperCase");function Gd(o,u,_){return o=ie(o),u=_?e:u,u===e?GD(o)?nb(o):kD(o):o.match(u)||[]}var Hd=zt(function(o,u){try{return xr(o,e,u)}catch(_){return El(_)?_:new Bt(_)}}),FF=Dn(function(o,u){return Tr(u,function(_){_=un(_),wn(o,_,bl(o[_],o))}),o});function MF(o){var u=o==null?0:o.length,_=At();return o=u?Ee(o,function(D){if(typeof D[1]!="function")throw new $r(a);return[_(D[0]),D[1]]}):[],zt(function(D){for(var C=-1;++C<u;){var I=o[C];if(xr(I[0],this,D))return xr(I[1],this,D)}})}function NF(o){return tx(Rr(o,f))}function Nl(o){return function(){return o}}function SF(o,u){return o==null||o!==o?u:o}var OF=Q0(),BF=Q0(!0);function _r(o){return o}function Sl(o){return N0(typeof o=="function"?o:Rr(o,f))}function IF(o){return O0(Rr(o,f))}function TF(o,u){return B0(o,Rr(u,f))}var $F=zt(function(o,u){return function(_){return ws(_,o,u)}}),LF=zt(function(o,u){return function(_){return ws(o,_,u)}});function Ol(o,u,_){var D=Ye(u),C=Jo(u,D);_==null&&!(Fe(u)&&(C.length||!D.length))&&(_=u,u=o,o=this,C=Jo(u,Ye(u)));var I=!(Fe(_)&&"chain"in _)||!!_.chain,P=xn(o);return Tr(C,function(k){var V=u[k];o[k]=V,P&&(o.prototype[k]=function(){var tt=this.__chain__;if(I||tt){var et=o(this.__wrapped__),ot=et.__actions__=hr(this.__actions__);return ot.push({func:V,args:arguments,thisArg:o}),et.__chain__=tt,et}return V.apply(o,zn([this.value()],arguments))})}),o}function RF(){return Je._===this&&(Je._=lb),this}function Bl(){}function PF(o){return o=Lt(o),zt(function(u){return I0(u,o)})}var zF=ll(Ee),kF=ll(t0),qF=ll(Tu);function Jd(o){return ml(o)?$u(un(o)):gx(o)}function UF(o){return function(u){return o==null?e:di(o,u)}}var WF=ed(),jF=ed(!0);function Il(){return[]}function Tl(){return!1}function VF(){return{}}function YF(){return""}function ZF(){return!0}function KF(o,u){if(o=Lt(o),o<1||o>Z)return[];var _=ct,D=rr(o,ct);u=At(u),o-=ct;for(var C=Pu(D,u);++_<o;)u(_);return C}function GF(o){return Tt(o)?Ee(o,un):Cr(o)?[o]:hr(gd(ie(o)))}function HF(o){var u=++ab;return ie(o)+u}var JF=na(function(o,u){return o+u},0),XF=cl("ceil"),QF=na(function(o,u){return o/u},1),t2=cl("floor");function e2(o){return o&&o.length?Ho(o,_r,Gu):e}function r2(o,u){return o&&o.length?Ho(o,At(u,2),Gu):e}function n2(o){return n0(o,_r)}function i2(o,u){return n0(o,At(u,2))}function s2(o){return o&&o.length?Ho(o,_r,Qu):e}function o2(o,u){return o&&o.length?Ho(o,At(u,2),Qu):e}var a2=na(function(o,u){return o*u},1),u2=cl("round"),l2=na(function(o,u){return o-u},0);function c2(o){return o&&o.length?Ru(o,_r):0}function f2(o,u){return o&&o.length?Ru(o,At(u,2)):0}return B.after=IA,B.ary=Md,B.assign=yC,B.assignIn=Ud,B.assignInWith=ma,B.assignWith=DC,B.at=bC,B.before=Nd,B.bind=bl,B.bindAll=FF,B.bindKey=Sd,B.castArray=VA,B.chain=Ad,B.chunk=tE,B.compact=eE,B.concat=rE,B.cond=MF,B.conforms=NF,B.constant=Nl,B.countBy=cA,B.create=xC,B.curry=Od,B.curryRight=Bd,B.debounce=Id,B.defaults=EC,B.defaultsDeep=AC,B.defer=TA,B.delay=$A,B.difference=nE,B.differenceBy=iE,B.differenceWith=sE,B.drop=oE,B.dropRight=aE,B.dropRightWhile=uE,B.dropWhile=lE,B.fill=cE,B.filter=hA,B.flatMap=_A,B.flatMapDeep=mA,B.flatMapDepth=gA,B.flatten=Dd,B.flattenDeep=fE,B.flattenDepth=hE,B.flip=LA,B.flow=OF,B.flowRight=BF,B.fromPairs=dE,B.functions=BC,B.functionsIn=IC,B.groupBy=vA,B.initial=_E,B.intersection=mE,B.intersectionBy=gE,B.intersectionWith=vE,B.invert=$C,B.invertBy=LC,B.invokeMap=yA,B.iteratee=Sl,B.keyBy=DA,B.keys=Ye,B.keysIn=pr,B.map=ca,B.mapKeys=PC,B.mapValues=zC,B.matches=IF,B.matchesProperty=TF,B.memoize=ha,B.merge=kC,B.mergeWith=Wd,B.method=$F,B.methodOf=LF,B.mixin=Ol,B.negate=da,B.nthArg=PF,B.omit=qC,B.omitBy=UC,B.once=RA,B.orderBy=bA,B.over=zF,B.overArgs=PA,B.overEvery=kF,B.overSome=qF,B.partial=xl,B.partialRight=Td,B.partition=xA,B.pick=WC,B.pickBy=jd,B.property=Jd,B.propertyOf=UF,B.pull=bE,B.pullAll=xd,B.pullAllBy=xE,B.pullAllWith=EE,B.pullAt=AE,B.range=WF,B.rangeRight=jF,B.rearg=zA,B.reject=CA,B.remove=CE,B.rest=kA,B.reverse=yl,B.sampleSize=MA,B.set=VC,B.setWith=YC,B.shuffle=NA,B.slice=FE,B.sortBy=BA,B.sortedUniq=TE,B.sortedUniqBy=$E,B.split=_F,B.spread=qA,B.tail=LE,B.take=RE,B.takeRight=PE,B.takeRightWhile=zE,B.takeWhile=kE,B.tap=eA,B.throttle=UA,B.thru=la,B.toArray=zd,B.toPairs=Vd,B.toPairsIn=Yd,B.toPath=GF,B.toPlainObject=qd,B.transform=ZC,B.unary=WA,B.union=qE,B.unionBy=UE,B.unionWith=WE,B.uniq=jE,B.uniqBy=VE,B.uniqWith=YE,B.unset=KC,B.unzip=Dl,B.unzipWith=Ed,B.update=GC,B.updateWith=HC,B.values=Ji,B.valuesIn=JC,B.without=ZE,B.words=Gd,B.wrap=jA,B.xor=KE,B.xorBy=GE,B.xorWith=HE,B.zip=JE,B.zipObject=XE,B.zipObjectDeep=QE,B.zipWith=tA,B.entries=Vd,B.entriesIn=Yd,B.extend=Ud,B.extendWith=ma,Ol(B,B),B.add=JF,B.attempt=Hd,B.camelCase=eF,B.capitalize=Zd,B.ceil=XF,B.clamp=XC,B.clone=YA,B.cloneDeep=KA,B.cloneDeepWith=GA,B.cloneWith=ZA,B.conformsTo=HA,B.deburr=Kd,B.defaultTo=SF,B.divide=QF,B.endsWith=rF,B.eq=Hr,B.escape=nF,B.escapeRegExp=iF,B.every=fA,B.find=dA,B.findIndex=wd,B.findKey=CC,B.findLast=pA,B.findLastIndex=yd,B.findLastKey=FC,B.floor=t2,B.forEach=Cd,B.forEachRight=Fd,B.forIn=MC,B.forInRight=NC,B.forOwn=SC,B.forOwnRight=OC,B.get=Cl,B.gt=JA,B.gte=XA,B.has=TC,B.hasIn=Fl,B.head=bd,B.identity=_r,B.includes=wA,B.indexOf=pE,B.inRange=QC,B.invoke=RC,B.isArguments=mi,B.isArray=Tt,B.isArrayBuffer=QA,B.isArrayLike=dr,B.isArrayLikeObject=Be,B.isBoolean=tC,B.isBuffer=Yn,B.isDate=eC,B.isElement=rC,B.isEmpty=nC,B.isEqual=iC,B.isEqualWith=sC,B.isError=El,B.isFinite=oC,B.isFunction=xn,B.isInteger=$d,B.isLength=pa,B.isMap=Ld,B.isMatch=aC,B.isMatchWith=uC,B.isNaN=lC,B.isNative=cC,B.isNil=hC,B.isNull=fC,B.isNumber=Rd,B.isObject=Fe,B.isObjectLike=Ne,B.isPlainObject=As,B.isRegExp=Al,B.isSafeInteger=dC,B.isSet=Pd,B.isString=_a,B.isSymbol=Cr,B.isTypedArray=Hi,B.isUndefined=pC,B.isWeakMap=_C,B.isWeakSet=mC,B.join=wE,B.kebabCase=sF,B.last=zr,B.lastIndexOf=yE,B.lowerCase=oF,B.lowerFirst=aF,B.lt=gC,B.lte=vC,B.max=e2,B.maxBy=r2,B.mean=n2,B.meanBy=i2,B.min=s2,B.minBy=o2,B.stubArray=Il,B.stubFalse=Tl,B.stubObject=VF,B.stubString=YF,B.stubTrue=ZF,B.multiply=a2,B.nth=DE,B.noConflict=RF,B.noop=Bl,B.now=fa,B.pad=uF,B.padEnd=lF,B.padStart=cF,B.parseInt=fF,B.random=tF,B.reduce=EA,B.reduceRight=AA,B.repeat=hF,B.replace=dF,B.result=jC,B.round=u2,B.runInContext=j,B.sample=FA,B.size=SA,B.snakeCase=pF,B.some=OA,B.sortedIndex=ME,B.sortedIndexBy=NE,B.sortedIndexOf=SE,B.sortedLastIndex=OE,B.sortedLastIndexBy=BE,B.sortedLastIndexOf=IE,B.startCase=mF,B.startsWith=gF,B.subtract=l2,B.sum=c2,B.sumBy=f2,B.template=vF,B.times=KF,B.toFinite=En,B.toInteger=Lt,B.toLength=kd,B.toLower=wF,B.toNumber=kr,B.toSafeInteger=wC,B.toString=ie,B.toUpper=yF,B.trim=DF,B.trimEnd=bF,B.trimStart=xF,B.truncate=EF,B.unescape=AF,B.uniqueId=HF,B.upperCase=CF,B.upperFirst=Ml,B.each=Cd,B.eachRight=Fd,B.first=bd,Ol(B,function(){var o={};return on(B,function(u,_){le.call(B.prototype,_)||(o[_]=u)}),o}(),{chain:!1}),B.VERSION=r,Tr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){B[o].placeholder=B}),Tr(["drop","take"],function(o,u){jt.prototype[o]=function(_){_=_===e?1:We(Lt(_),0);var D=this.__filtered__&&!u?new jt(this):this.clone();return D.__filtered__?D.__takeCount__=rr(_,D.__takeCount__):D.__views__.push({size:rr(_,ct),type:o+(D.__dir__<0?"Right":"")}),D},jt.prototype[o+"Right"]=function(_){return this.reverse()[o](_).reverse()}}),Tr(["filter","map","takeWhile"],function(o,u){var _=u+1,D=_==U||_==z;jt.prototype[o]=function(C){var I=this.clone();return I.__iteratees__.push({iteratee:At(C,3),type:_}),I.__filtered__=I.__filtered__||D,I}}),Tr(["head","last"],function(o,u){var _="take"+(u?"Right":"");jt.prototype[o]=function(){return this[_](1).value()[0]}}),Tr(["initial","tail"],function(o,u){var _="drop"+(u?"":"Right");jt.prototype[o]=function(){return this.__filtered__?new jt(this):this[_](1)}}),jt.prototype.compact=function(){return this.filter(_r)},jt.prototype.find=function(o){return this.filter(o).head()},jt.prototype.findLast=function(o){return this.reverse().find(o)},jt.prototype.invokeMap=zt(function(o,u){return typeof o=="function"?new jt(this):this.map(function(_){return ws(_,o,u)})}),jt.prototype.reject=function(o){return this.filter(da(At(o)))},jt.prototype.slice=function(o,u){o=Lt(o);var _=this;return _.__filtered__&&(o>0||u<0)?new jt(_):(o<0?_=_.takeRight(-o):o&&(_=_.drop(o)),u!==e&&(u=Lt(u),_=u<0?_.dropRight(-u):_.take(u-o)),_)},jt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},jt.prototype.toArray=function(){return this.take(ct)},on(jt.prototype,function(o,u){var _=/^(?:filter|find|map|reject)|While$/.test(u),D=/^(?:head|last)$/.test(u),C=B[D?"take"+(u=="last"?"Right":""):u],I=D||/^find/.test(u);C&&(B.prototype[u]=function(){var P=this.__wrapped__,k=D?[1]:arguments,V=P instanceof jt,tt=k[0],et=V||Tt(P),ot=function(Ut){var Vt=C.apply(B,zn([Ut],k));return D&&pt?Vt[0]:Vt};et&&_&&typeof tt=="function"&&tt.length!=1&&(V=et=!1);var pt=this.__chain__,wt=!!this.__actions__.length,Ct=I&&!pt,Rt=V&&!wt;if(!I&&et){P=Rt?P:new jt(this);var Ft=o.apply(P,k);return Ft.__actions__.push({func:la,args:[ot],thisArg:e}),new Lr(Ft,pt)}return Ct&&Rt?o.apply(this,k):(Ft=this.thru(ot),Ct?D?Ft.value()[0]:Ft.value():Ft)})}),Tr(["pop","push","shift","sort","splice","unshift"],function(o){var u=$o[o],_=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",D=/^(?:pop|shift)$/.test(o);B.prototype[o]=function(){var C=arguments;if(D&&!this.__chain__){var I=this.value();return u.apply(Tt(I)?I:[],C)}return this[_](function(P){return u.apply(Tt(P)?P:[],C)})}}),on(jt.prototype,function(o,u){var _=B[u];if(_){var D=_.name+"";le.call(Vi,D)||(Vi[D]=[]),Vi[D].push({name:u,func:_})}}),Vi[ra(e,v).name]=[{name:"wrapper",func:e}],jt.prototype.clone=Ab,jt.prototype.reverse=Cb,jt.prototype.value=Fb,B.prototype.at=rA,B.prototype.chain=nA,B.prototype.commit=iA,B.prototype.next=sA,B.prototype.plant=aA,B.prototype.reverse=uA,B.prototype.toJSON=B.prototype.valueOf=B.prototype.value=lA,B.prototype.first=B.prototype.head,hs&&(B.prototype[hs]=oA),B},Ui=ib();ui?((ui.exports=Ui)._=Ui,Su._=Ui):Je._=Ui}).call(Yt)}(Zn,Zn.exports);var Qr=Zn.exports;class Qd{constructor(t,e){$(this,"_defaultParams");$(this,"_UserTypeFileds");$(this,"_varipKeys");this._defaultParams=t,this._UserTypeFileds=this._createDynamicClass(),this._varipKeys=e}copy(t){return Qr.cloneDeep(t)}new(t={}){return new this._UserTypeFileds(Object.assign(Qr.cloneDeep(this._defaultParams),t),this._varipKeys)}addNewMethod(t,e){this._UserTypeFileds.prototype[t]=e}_createDynamicClass(){return class{constructor(t,e){$(this,"_varipKeys");Object.assign(this,t),this._varipKeys=e}get varipKeys(){return[...this._varipKeys]}copy(){return Qr.cloneDeep(this)}}}}var zl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){var e=1e3,r=6e4,n=36e5,s="millisecond",a="second",l="minute",c="hour",h="day",d="week",f="month",p="quarter",g="year",w="date",m="Invalid Date",y=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,x={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(U){var W=["th","st","nd","rd"],z=U%100;return"["+U+(W[(z-20)%10]||W[z]||W[0])+"]"}},b=function(U,W,z){var K=String(U);return!K||K.length>=W?U:""+Array(W+1-K.length).join(z)+U},M={s:b,z:function(U){var W=-U.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 U(W,z){if(W.date()<z.date())return-U(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(U){return U<0?Math.ceil(U)||0:Math.floor(U)},p:function(U){return{M:f,y:g,w:d,d:h,D:w,h:c,m:l,s:a,ms:s,Q:p}[U]||String(U||"").toLowerCase().replace(/s$/,"")},u:function(U){return U===void 0}},E="en",F={};F[E]=x;var N="$isDayjsObject",S=function(U){return U instanceof L||!(!U||!U[N])},T=function U(W,z,K){var Z;if(!W)return E;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 U(Q[0])}else{var ct=W.name;F[ct]=W,Z=ct}return!K&&Z&&(E=Z),Z||!K&&E},A=function(U,W){if(S(U))return U.clone();var z=typeof W=="object"?W:{};return z.date=U,z.args=arguments,new L(z)},O=M;O.l=T,O.i=S,O.w=function(U,W){return A(U,{locale:W.$L,utc:W.$u,x:W.$x,$offset:W.$offset})};var L=function(){function U(z){this.$L=T(z.locale,null,!0),this.parse(z),this.$x=this.$x||z.x||{},this[N]=!0}var W=U.prototype;return W.parse=function(z){this.$d=function(K){var Z=K.date,X=K.utc;if(Z===null)return new Date(NaN);if(O.u(Z))return new Date;if(Z instanceof Date)return new Date(Z);if(typeof Z=="string"&&!/Z$/i.test(Z)){var Q=Z.match(y);if(Q){var ct=Q[2]-1||0,vt=(Q[7]||"0").substring(0,3);return X?new Date(Date.UTC(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)):new Date(Q[1],ct,Q[3]||1,Q[4]||0,Q[5]||0,Q[6]||0,vt)}}return new Date(Z)}(z),this.init()},W.init=function(){var z=this.$d;this.$y=z.getFullYear(),this.$M=z.getMonth(),this.$D=z.getDate(),this.$W=z.getDay(),this.$H=z.getHours(),this.$m=z.getMinutes(),this.$s=z.getSeconds(),this.$ms=z.getMilliseconds()},W.$utils=function(){return O},W.isValid=function(){return this.$d.toString()!==m},W.isSame=function(z,K){var Z=A(z);return this.startOf(K)<=Z&&Z<=this.endOf(K)},W.isAfter=function(z,K){return A(z)<this.startOf(K)},W.isBefore=function(z,K){return this.endOf(K)<A(z)},W.$g=function(z,K,Z){return O.u(z)?this[K]:this.set(Z,z)},W.unix=function(){return Math.floor(this.valueOf()/1e3)},W.valueOf=function(){return this.$d.getTime()},W.startOf=function(z,K){var Z=this,X=!!O.u(K)||K,Q=O.p(z),ct=function(It,Nt){var fe=O.w(Z.$u?Date.UTC(Z.$y,Nt,It):new Date(Z.$y,Nt,It),Z);return X?fe:fe.endOf(h)},vt=function(It,Nt){return O.w(Z.toDate()[It].apply(Z.toDate("s"),(X?[0,0,0,0]:[23,59,59,999]).slice(Nt)),Z)},lt=this.$W,yt=this.$M,bt=this.$D,Ot="set"+(this.$u?"UTC":"");switch(Q){case g:return X?ct(1,0):ct(31,11);case f:return X?ct(1,yt):ct(0,yt+1);case d:var xt=this.$locale().weekStart||0,ue=(lt<xt?lt+7:lt)-xt;return ct(X?bt-ue:bt+(6-ue),yt);case h:case w:return vt(Ot+"Hours",0);case c:return vt(Ot+"Minutes",1);case l:return vt(Ot+"Seconds",2);case a:return vt(Ot+"Milliseconds",3);default:return this.clone()}},W.endOf=function(z){return this.startOf(z,!1)},W.$set=function(z,K){var Z,X=O.p(z),Q="set"+(this.$u?"UTC":""),ct=(Z={},Z[h]=Q+"Date",Z[w]=Q+"Date",Z[f]=Q+"Month",Z[g]=Q+"FullYear",Z[c]=Q+"Hours",Z[l]=Q+"Minutes",Z[a]=Q+"Seconds",Z[s]=Q+"Milliseconds",Z)[X],vt=X===h?this.$D+(K-this.$W):K;if(X===f||X===g){var lt=this.clone().set(w,1);lt.$d[ct](vt),lt.init(),this.$d=lt.set(w,Math.min(this.$D,lt.daysInMonth())).$d}else ct&&this.$d[ct](vt);return this.init(),this},W.set=function(z,K){return this.clone().$set(z,K)},W.get=function(z){return this[O.p(z)]()},W.add=function(z,K){var Z,X=this;z=Number(z);var Q=O.p(K),ct=function(yt){var bt=A(X);return O.w(bt.date(bt.date()+Math.round(yt*z)),X)};if(Q===f)return this.set(f,this.$M+z);if(Q===g)return this.set(g,this.$y+z);if(Q===h)return ct(1);if(Q===d)return ct(7);var vt=(Z={},Z[l]=r,Z[c]=n,Z[a]=e,Z)[Q]||1,lt=this.$d.getTime()+z*vt;return O.w(lt,this)},W.subtract=function(z,K){return this.add(-1*z,K)},W.format=function(z){var K=this,Z=this.$locale();if(!this.isValid())return Z.invalidDate||m;var X=z||"YYYY-MM-DDTHH:mm:ssZ",Q=O.z(this),ct=this.$H,vt=this.$m,lt=this.$M,yt=Z.weekdays,bt=Z.months,Ot=Z.meridiem,xt=function(Nt,fe,re,qt){return Nt&&(Nt[fe]||Nt(K,X))||re[fe].slice(0,qt)},ue=function(Nt){return O.s(ct%12||12,Nt,"0")},It=Ot||function(Nt,fe,re){var qt=Nt<12?"AM":"PM";return re?qt.toLowerCase():qt};return X.replace(v,function(Nt,fe){return fe||function(re){switch(re){case"YY":return String(K.$y).slice(-2);case"YYYY":return O.s(K.$y,4,"0");case"M":return lt+1;case"MM":return O.s(lt+1,2,"0");case"MMM":return xt(Z.monthsShort,lt,bt,3);case"MMMM":return xt(bt,lt);case"D":return K.$D;case"DD":return O.s(K.$D,2,"0");case"d":return String(K.$W);case"dd":return xt(Z.weekdaysMin,K.$W,yt,2);case"ddd":return xt(Z.weekdaysShort,K.$W,yt,3);case"dddd":return yt[K.$W];case"H":return String(ct);case"HH":return O.s(ct,2,"0");case"h":return ue(1);case"hh":return ue(2);case"a":return It(ct,vt,!0);case"A":return It(ct,vt,!1);case"m":return String(vt);case"mm":return O.s(vt,2,"0");case"s":return String(K.$s);case"ss":return O.s(K.$s,2,"0");case"SSS":return O.s(K.$ms,3,"0");case"Z":return Q}return null}(Nt)||Q.replace(":","")})},W.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},W.diff=function(z,K,Z){var X,Q=this,ct=O.p(K),vt=A(z),lt=(vt.utcOffset()-this.utcOffset())*r,yt=this-vt,bt=function(){return O.m(Q,vt)};switch(ct){case g:X=bt()/12;break;case f:X=bt();break;case p:X=bt()/3;break;case d:X=(yt-lt)/6048e5;break;case h:X=(yt-lt)/864e5;break;case c:X=yt/n;break;case l:X=yt/r;break;case a:X=yt/e;break;default:X=yt}return Z?X:O.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=T(z,K,!0);return X&&(Z.$L=X),Z},W.clone=function(){return O.w(this.$d,this)},W.toDate=function(){return new Date(this.valueOf())},W.toJSON=function(){return this.isValid()?this.toISOString():null},W.toISOString=function(){return this.$d.toISOString()},W.toString=function(){return this.$d.toUTCString()},U}(),q=L.prototype;return A.prototype=q,[["$ms",s],["$s",a],["$m",l],["$H",c],["$W",h],["$M",f],["$y",g],["$D",w]].forEach(function(U){q[U[1]]=function(W){return this.$g(W,U[0],U[1])}}),A.extend=function(U,W){return U.$i||(U(W,L,A),U.$i=!0),A},A.locale=T,A.isDayjs=S,A.unix=function(U){return A(1e3*U)},A.en=F[E],A.Ls=F,A.p={},A})})(zl);var tp=zl.exports,ee=Gt(tp),kl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){var e="minute",r=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(s,a,l){var c=a.prototype;l.utc=function(m){var y={date:m,utc:!0,args:arguments};return new a(y)},c.utc=function(m){var y=l(this.toDate(),{locale:this.$L,utc:!0});return m?y.add(this.utcOffset(),e):y},c.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var h=c.parse;c.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),h.call(this,m)};var d=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 d.call(this)};var f=c.utcOffset;c.utcOffset=function(m,y){var v=this.$utils().u;if(v(m))return this.$u?0:v(this.$offset)?f.call(this):this.$offset;if(typeof m=="string"&&(m=function(E){E===void 0&&(E="");var F=E.match(r);if(!F)return null;var N=(""+F[0]).match(n)||["-",0,0],S=N[0],T=60*+N[1]+ +N[2];return T===0?0:S==="+"?T:-T}(m),m===null))return this;var x=Math.abs(m)<=16?60*m:m,b=this;if(y)return b.$offset=x,b.$u=m===0,b;if(m!==0){var M=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(b=this.local().add(x+M,e)).$offset=x,b.$x.$localOffset=M}else b=this.utc();return b};var p=c.format;c.format=function(m){var y=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return p.call(this,y)},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 w=c.diff;c.diff=function(m,y,v){if(m&&this.$u===m.$u)return w.call(this,m,y,v);var x=this.local(),b=l(m).local();return w.call(x,b,y,v)}}})})(kl);var ep=kl.exports,ql=Gt(ep),Ul={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(n,s,a){var l,c=function(p,g,w){w===void 0&&(w={});var m=new Date(p),y=function(v,x){x===void 0&&(x={});var b=x.timeZoneName||"short",M=v+"|"+b,E=r[M];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:v,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:b}),r[M]=E),E}(g,w);return y.formatToParts(m)},h=function(p,g){for(var w=c(p,g),m=[],y=0;y<w.length;y+=1){var v=w[y],x=v.type,b=v.value,M=e[x];M>=0&&(m[M]=parseInt(b,10))}var E=m[3],F=E===24?0:E,N=m[0]+"-"+m[1]+"-"+m[2]+" "+F+":"+m[4]+":"+m[5]+":000",S=+p;return(a.utc(N).valueOf()-(S-=S%1e3))/6e4},d=s.prototype;d.tz=function(p,g){p===void 0&&(p=l);var w=this.utcOffset(),m=this.toDate(),y=m.toLocaleString("en-US",{timeZone:p}),v=Math.round((m-new Date(y))/1e3/60),x=a(y,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-v,!0);if(g){var b=x.utcOffset();x=x.add(w-b,"minute")}return x.$x.$timezone=p,x},d.offsetName=function(p){var g=this.$x.$timezone||a.tz.guess(),w=c(this.valueOf(),g,{timeZoneName:p}).find(function(m){return m.type.toLowerCase()==="timezonename"});return w&&w.value};var f=d.startOf;d.startOf=function(p,g){if(!this.$x||!this.$x.$timezone)return f.call(this,p,g);var w=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return f.call(w,p,g).tz(this.$x.$timezone,!0)},a.tz=function(p,g,w){var m=w&&g,y=w||g||l,v=h(+a(),y);if(typeof p!="string")return a(p).tz(y);var x=function(F,N,S){var T=F-60*N*1e3,A=h(T,S);if(N===A)return[T,N];var O=h(T-=60*(A-N)*1e3,S);return A===O?[T,A]:[F-60*Math.min(A,O)*1e3,Math.max(A,O)]}(a.utc(p,m).valueOf(),v,y),b=x[0],M=x[1],E=a(b).utcOffset(M);return E.$x.$timezone=y,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(p){l=p}}})})(Ul);var rp=Ul.exports,np=Gt(rp),Wl={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){var e="week",r="year";return function(n,s,a){var l=s.prototype;l.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var h=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var d=a(this).startOf(r).add(1,r).date(h),f=a(this).endOf(e);if(d.isBefore(f))return 1}var p=a(this).startOf(r).date(h).startOf(e).subtract(1,"millisecond"),g=this.diff(p,e,!0);return g<0?a(this).startOf("week").week():Math.ceil(g)},l.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(Wl);var ip=Wl.exports,sp=Gt(ip);function Ze(i,t){return i.replace(/\$(\w+)/g,(e,r)=>String(t[r])||e)}function Cs(i){const t=parseInt(i)||1;let e=i.replace(/\d+/,"");return e==="m"||e==="M"?e="M":e?e=e.toLocaleLowerCase():e="m",[t,e]}function op(i){const t=/([+-])(\d{1,2})(\d{0,2})/,e=i.replace(/GMT|UTC/,"").match(t);if(!e)throw new Error("Invalid timezone string");const[,r,n,s]=e,a=parseInt(n,10)*60||0,l=parseInt(s,10)||0;return(r==="+"?-1:1)*(a+l)}function qr(i,t){return t&&(t.startsWith("UTC")||t.startsWith("GMT"))?ee(i).utcOffset(op(t)):ee(i).tz(t)}function tn(i){const[t,e]=Cs(i);let r=0;switch(e){case"m":r=60;break;case"s":r=1;break;case"M":r=31*24*60*60;break;case"d":r=24*60*60;break;case"w":r=7*24*60*60;break;default:r=60*60;break}return Math.round(Number(t)*r)}function _t(i){return typeof i!="number"||isNaN(i)}function ge(i,t){for(const e of t)i!=null&&i.hasOwnProperty(e)&&i[e]===void 0&&(i[e]=null)}function jl(i){var t=atob(i),e=decodeURI(t);return e}function Vl(i,t){if(!String(i).includes("."))return i;const e=Math.pow(10,t);return Math.floor(i*e)/e}var Me=(i=>(i.BOOL="bool",i.INT="int",i.FLOAT="float",i.ARRAY="array",i.BOX="box",i.CHART_POINT="chart.point",i.COLOR="color",i.CONST="const",i.LABEL="label",i.LINE="line",i.LINEFILL="linefill",i.MAP="map",i.MATRIX="matrix",i.POLYLINE="polyline",i.SERIES="series",i.SIMPLE="simple",i.STRING="string",i.TABLE="table",i.UNDETERMINED="undetermined type",i.INPUT="input",i.NA="na",i.VOID="void",i.ENUM="enum",i))(Me||{}),Fs=(i=>(i.dividends="dividends",i.none="none",i.splits="splits",i))(Fs||{}),Ur=(i=>(i.freqAll="freq_all",i.freqOncePerBar="freq_once_per_bar",i.freqOncePerBarClose="freq_once_per_bar_close",i))(Ur||{}),Xi=(i=>(i.gapsOff="gaps_off",i.gapsOn="gaps_on",i.lookaheadOff="lookahead_off",i.lookaheadOn="lookahead_on",i))(Xi||{}),Ke=(i=>(i.all="all",i.dataWindow="data_window",i.none="none",i.pane="pane",i.priceScale="price_scale",i.statusLine="status_line",i))(Ke||{}),Wr=(i=>(i.both="both",i.left="left",i.none="none",i.right="right",i))(Wr||{}),Kt=(i=>(i.inherit="inherit",i.mintick="mintick",i.percent="percent",i.price="price",i.volume="volume",i))(Kt||{}),Ms=(i=>(i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(Ms||{}),ve=(i=>(i.styleArrowdown="style_arrowdown",i.styleArrowup="style_arrowup",i.styleCircle="style_circle",i.styleCross="style_cross",i.styleDiamond="style_diamond",i.styleFlag="style_flag",i.styleLabelCenter="style_label_center",i.styleLabelDown="style_label_down",i.styleLabelLeft="style_label_left",i.styleLabelLowerLeft="style_label_lower_left",i.styleLabelLowerRight="style_label_lower_right",i.styleLabelRight="style_label_right",i.styleLabelUp="style_label_up",i.styleLabelUpperLeft="style_label_upper_left",i.styleLabelUpperRight="style_label_upper_right",i.styleNone="style_none",i.styleSquare="style_square",i.styleTextOutline="style_text_outline",i.styleTriangledown="style_triangledown",i.styleTriangleup="style_triangleup",i.styleXcross="style_xcross",i))(ve||{}),Re=(i=>(i.styleArrowBoth="style_arrow_both",i.styleArrowLeft="style_arrow_left",i.styleArrowRight="style_arrow_right",i.styleDashed="style_dashed",i.styleDotted="style_dotted",i.styleSolid="style_solid",i))(Re||{}),ln=(i=>(i.abovebar="abovebar",i.absolute="absolute",i.belowbar="belowbar",i.bottom="bottom",i.top="top",i))(ln||{}),Kn=(i=>(i.ascending="ascending",i.descending="descending",i))(Kn||{}),Nr=(i=>(i.styleArea="Area",i.styleAreabr="Area With Breaks",i.styleCircles="Circles",i.styleColumns="Columns",i.styleCross="Cross",i.styleHistogram="Histogram",i.styleLine="Line",i.styleLinebr="Line With Breaks",i.styleStepline="Step Line",i.styleSteplineDiamond="Step Line With Diamonds",i.styleSteplinebr="Step line with Breaks",i))(Nr||{}),mr=(i=>(i.bottomCenter="bottom_center",i.bottomLeft="bottom_left",i.bottomRight="bottom_right",i.middleCenter="middle_center",i.middleLeft="middle_left",i.middleRight="middle_right",i.topCenter="top_center",i.topLeft="top_left",i.topRight="top_right",i))(mr||{}),Ns=(i=>(i.left="left",i.none="none",i.right="right",i))(Ns||{}),gi=(i=>(i.extended="extended",i.regular="regular",i))(gi||{}),lr=(i=>(i.arrowdown="arrowdown",i.arrowup="arrowup",i.circle="circle",i.cross="cross",i.diamond="diamond",i.flag="flag",i.labeldown="labeldown",i.labelup="labelup",i.square="square",i.triangledown="triangledown",i.triangleup="triangleup",i.xcross="xcross",i))(lr||{}),ir=(i=>(i.auto="auto",i.huge="huge",i.large="large",i.normal="normal",i.small="small",i.tiny="tiny",i))(ir||{}),Gn=(i=>(i.familyDefault="default",i.familyMonospace="monospace",i))(Gn||{}),Pe=(i=>(i.cash="cash",i.fixed="fixed",i.percentOfEquity="percent_of_equity",i))(Pe||{}),je=(i=>(i.cashPerContract="cash_per_contract",i.cashPerOrder="cash_per_order",i.percent="percent",i))(je||{}),ce=(i=>(i.all="all",i.long="long",i.short="short",i))(ce||{}),cn=(i=>(i.cancel="cancel",i.none="none",i.reduce="reduce",i))(cn||{}),Wt=(i=>(i.alignBottom="align_bottom",i.alignCenter="align_center",i.alignLeft="align_left",i.alignRight="align_right",i.alignTop="align_top",i.wrapAuto="wrap_auto",i.wrapNone="wrap_none",i))(Wt||{}),De=(i=>(i.bar_index="bar_index",i.bar_time="bar_time",i))(De||{}),jr=(i=>(i.abovebar="abovebar",i.belowbar="belowbar",i.price="price",i))(jr||{}),Ss=(i=>(i.actual="actual",i.estimate="estimate",i.standardized="standardized",i))(Ss||{}),Hn=(i=>(i.traditional="Traditional",i.fibonacci="Fibonacci",i.woodie="Woodie",i.classic="Classic",i.dm="DM",i.camarilla="Camarilla",i))(Hn||{}),sr=(i=>(i.INT="int",i.BOOL="bool",i.TIME="time",i.COLOR="color",i.FLOAT="float",i.PRICE="price",i.SOURCE="source",i.STRING="string",i.SYMBOL="symbol",i.SESSION="session",i.TEXT_AREA="text_area",i.TIMEFRAME="timeframe",i.ENUM="enum",i))(sr||{}),Yl=(i=>(i.library="library",i.indicator="indicator",i.strategy="strategy",i))(Yl||{}),Pt=(i=>(i[i.Hint=1]="Hint",i[i.Info=2]="Info",i[i.Warning=4]="Warning",i[i.Error=8]="Error",i))(Pt||{});const se={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",minOrMaxErr:"Input's `defval` value must be between `minval` and `maxval`"},ap={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."};Me.SERIES,Me.SIMPLE,Me.INPUT,Me.CONST,Me.INT,Me.FLOAT,Me.BOOL,Me.COLOR,Me.STRING;const up=["close","open","high","low","hl2","hlc3","hlcc4","ohlc4","volume"],lp=["case","catch","default","delete","do","finally","function","instanceof","new","return","this","throw","try","typeof","void","with"],cp=["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 fp{constructor(t){$(this,"_errorListener");this._errorListener=t}new({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_float({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_int({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_color({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_bool({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_string({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_line({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_box({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_table({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_linefill({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}new_label({size:t,initial_value:e}={}){return new Qt(t,e,this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}slice({id:t,index_from:e,index_to:r}){return t==null?void 0:t.slice({index_from:e,index_to:r})}size({id:t}){return t==null?void 0:t.size()}first({id:t}){return t==null?void 0:t.first()}abs({id:t},e){return t==null?void 0:t.abs(e)}avg({id:t},e){return t==null?void 0:t.avg(e)}binary_search({id:t,val:e},r){return t==null?void 0:t.binary_search({val:e},r)}binary_search_leftmost({id:t,val:e},r){return t==null?void 0:t.binary_search_leftmost({val:e},r)}binary_search_rightmost({id:t,val:e},r){return t==null?void 0:t.binary_search_rightmost({val:e},r)}clear({id:t}){t==null||t.clear()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}covariance({id1:t,id2:e,biased:r},n){return t==null?void 0:t.covariance({id2:e,biased:r},n)}every({id:t},e){return t==null?void 0:t.every(e)}from(t,e){const r=new Qt(0,void 0,this._errorListener);return r._value=e,r}fill({id:t,value:e,index_from:r,index_to:n}){t==null||t.fill({value:e,index_from:r,index_to:n})}get({id:t,index:e}){return t==null?void 0:t.get({index:e})}includes({id:t,value:e}){return t==null?void 0:t.includes({value:e})}indexof({id:t,value:e}){return t==null?void 0:t.indexof({value:e})}insert({id:t,index:e,value:r}){t==null||t.insert({index:e,value:r})}join({id:t,separator:e},r){return t==null?void 0:t.join({separator:e},r)}last({id:t}){return t==null?void 0:t.last()}lastindexof({id:t,value:e}){return t==null?void 0:t.lastindexof({value:e})}max({id:t,nth:e},r){return t==null?void 0:t.max({nth:e},r)}median({id:t},e){return t==null?void 0:t.median(e)}min({id:t,nth:e},r){return t==null?void 0:t.min({nth:e},r)}mode({id:t},e){return t==null?void 0:t.mode(e)}percentile_linear_interpolation({id:t,percentage:e},r){return t==null?void 0:t.percentile_linear_interpolation({percentage:e},r)}percentile_nearest_rank({id:t,percentage:e},r){return t==null?void 0:t.percentile_nearest_rank({percentage:e},r)}percentrank({id:t,index:e},r){return t==null?void 0:t.percentrank({index:e},r)}pop({id:t}){return t==null?void 0:t.pop()}push({id:t,value:e}){t==null||t.push({value:e})}range({id:t},e){return t==null?void 0:t.range(e)}remove({id:t,index:e}){return t==null?void 0:t.remove({index:e})}reverse({id:t}){return t==null?void 0:t.reverse()}set({id:t,index:e,value:r}){t==null||t.set({index:e,value:r})}shift({id:t}){return t==null?void 0:t.shift()}some({id:t},e){return t==null?void 0:t.some(e)}sort({id:t,order:e},r){t==null||t.sort({order:e},r)}sort_indices({id:t,order:e},r){return t==null?void 0:t.sort_indices({order:e},r)}standardize({id:t},e){return t==null?void 0:t.standardize(e)}stdev({id:t,biased:e},r){return t==null?void 0:t.stdev({biased:e},r)}sum({id:t},e){return t==null?void 0:t.sum(e)}unshift({id:t,value:e}){t==null||t.unshift({value:e})}variance({id:t,biased:e},r){return t==null?void 0:t.variance({biased:e},r)}}class Qt{constructor(t=0,e,r){$(this,"_arrInstance");$(this,"_errorListener");this._errorListener=r,this._arrInstance=Array.from(new Array(t||0),()=>Qr.cloneDeep(e))}get isArray(){return!0}get _value(){return[...this._arrInstance]}set _value(t){this._arrInstance=[...t]}_deepCopyData(t){this._arrInstance=Qr.cloneDeep(t)}_copyData(t){this._arrInstance=t}copy(){const t=new Qt(0,void 0,this._errorListener);return t._deepCopyData(this._arrInstance),t}slice({index_from:t,index_to:e}){const r=new Qt(0,void 0,this._errorListener);return r._copyData(this._arrInstance.slice(t,e)),r}size(){return this._arrInstance.length}first(){return this._arrInstance[0]}abs(t){const e=new Qt(0,void 0,this._errorListener);this._verifySimpleType("number","abs","int/float",t);const r=this._arrInstance.map(n=>Math.abs(n));return e._copyData(r),e}avg(t){return this._verifySimpleType("number","avg","int/float",t),Qr.mean(this._arrInstance)}binary_search({val:t},e){return this._verifySimpleType("number","binary_search","int/float",e),_t(t)?-1:this._binarySearch(this._arrInstance,t)}binary_search_leftmost({val:t},e){return this._verifySimpleType("number","binary_search_leftmost","int/float",e),_t(t)?this._arrInstance.length-1:this._binarySearchLeftMost(this._arrInstance,t)}binary_search_rightmost({val:t},e){return this._verifySimpleType("number","binary_search_rightmost","int/float",e),_t(t)?this._arrInstance.length:this._binarySearchRightMost(this._arrInstance,t)}clear(){this._arrInstance=[]}concat({id2:t}){return this._arrInstance=this._arrInstance.concat(t==null?void 0:t._value),this}covariance({id2:t,biased:e},r){return this._verifySimpleType("number","covariance","int/float",r),this._verifySimpleType("number","covariance","int/float",r,t==null?void 0:t._value),this._covariance(this._arrInstance,t._value,e,r)}every(t){return this._verifySimpleType("number|boolean","every","int/float/bool",t),this._arrInstance.every(e=>!!e)}fill({value:t,index_from:e=0,index_to:r}){this._arrInstance=this._setElements(this._arrInstance,t,e,r)}get({index:t}){if(!_t(t))return this._arrInstance[t]}includes({value:t}){return this._arrInstance.includes(t)}indexof({value:t}){return this._arrInstance.indexOf(t)}insert({index:t,value:e}){_t(t)||this._arrInstance.splice(t,0,e)}join({separator:t}={},e){return this._verifySimpleType("number|string","join","int/float/string",e),this._arrInstance.join(t)}last(){return this._arrInstance[this._arrInstance.length-1]}lastindexof({value:t}){return this._arrInstance.lastIndexOf(t)}max({nth:t}={},e){return this._verifySimpleType("number","max","int/float",e),this._maxNth([...this._arrInstance],t)}median(t){return this._verifySimpleType("number","median","int/float",t),this._median([...this._arrInstance])}min({nth:t}={},e){return this._verifySimpleType("number","min","int/float",e),this._minNth([...this._arrInstance],t)}mode(t){return this._verifySimpleType("number","mode","int/float",t),this._mode([...this._arrInstance])}percentile_linear_interpolation({percentage:t},e){return this._verifySimpleType("number","percentile_linear_interpolation","int/float",e),this._percentileLinearInterpolation([...this._arrInstance],t)}percentile_nearest_rank({percentage:t=0},e){var r;if(this._arrInstance.length===0||t<0||t>100||_t(t)){(r=this._errorListener)==null||r.addError("Invalid percentile or empty array",e,Pt.Error);return}return this._verifySimpleType("number","percentile_nearest_rank","int/float",e),this._getNearestRankPercentile([...this._arrInstance],t)}percentrank({index:t},e){return this._verifySimpleType("number","percentrank","int/float",e),this._getPercentileRank([...this._arrInstance],t)}pop(){return this._arrInstance.pop()}push({value:t}){this._arrInstance.push(t)}range(t){var s;if(this._arrInstance.length===0){(s=this._errorListener)==null||s.addError(se.arrEmptyErr,t,Pt.Error);return}this._verifySimpleType("number","range","int/float",t);const e=Math.min(...this._arrInstance);return Math.max(...this._arrInstance)-e}remove({index:t}){if(!_t(t))return this._arrInstance.splice(t,1)[0]}reverse(){this._arrInstance.reverse()}set({index:t,value:e}){_t(t)||(this._arrInstance[t]=e)}shift(){return this._arrInstance.shift()}some(t){return this._verifySimpleType("number|boolean","some","int/float/bool",t),this._arrInstance.some(e=>!!e)}sort({order:t}={},e){this._verifySimpleType("number","sort","int/float",e),this._arrInstance.sort((r,n)=>t!==Kn.descending?r-n:n-r)}sort_indices({order:t}={},e){this._verifySimpleType("number","sort_indices","int/float",e);const r=this._arrInstance.map((s,a)=>a);r.sort((s,a)=>t!==Kn.descending?this._arrInstance[s]-this._arrInstance[a]:this._arrInstance[a]-this._arrInstance[s]);const n=new Qt(0,void 0,this._errorListener);return n._copyData(r),n}standardize(t){this._verifySimpleType("number","standardize","int/float",t);const e=new Qt(0,void 0,this._errorListener);return e._copyData(this._standardizeArray([...this._arrInstance])),e}stdev({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(se.arrEmptyErr,e,Pt.Error);return}return this._verifySimpleType("number","stdev","int/float",e),this._calculateStandardDeviations([...this._arrInstance],t)}sum(t){return this._verifySimpleType("number","sum","int/float",t),this._arrInstance.reduce((r,n)=>r+(n||0),0)}unshift({value:t}){this._arrInstance.unshift(t)}variance({biased:t}={},e){var r;if(this._arrInstance.length===0){(r=this._errorListener)==null||r.addError(se.arrEmptyErr,e,Pt.Error);return}return this._verifySimpleType("number","variance","int/float",e),this._calculateVariances([...this._arrInstance],t)}_calculateVariances(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>a+((l||0)-r)**2,0),s=n/t.length;return e?s:t.length>1?n/(t.length-1):s}_calculateStandardDeviations(t,e=!0){const r=t.reduce((a,l)=>a+(l||0),0)/t.length,n=t.reduce((a,l)=>{const c=(l||0)-r;return a+c*c},0),s=Math.sqrt(n/t.length);return e?s:t.length>1?Math.sqrt(n/(t.length-1)):s}_standardizeArray(t){const e=t.reduce((s,a)=>s+(a||0),0)/t.length,r=Math.sqrt(t.reduce((s,a)=>s+Math.pow((a||0)-e,2),0)/t.length);return t.map(s=>((s||0)-e)/r)}_getPercentileRank(t,e=0){if(_t(e))return;const r=t[e];let n=0;for(let a=0;a<t.length;a++)(t[a]<r||t[a]===r&&a!=e)&&n++;return n/(t.length-1)*100}_getNearestRankPercentile(t,e=0){const r=t.slice().sort((a,l)=>a-l),n=e/100*r.length,s=Math.ceil(n)-1;return r[s>=r.length?r.length-1:s]}_percentileLinearInterpolation(t,e=0){if(e<0||e>100||_t(e))return;t.sort(function(s,a){return s-a});const r=t.length;e/=100;const n=1/(r*2);if(e<=n)return t[0];if(e>=1-1/(r*2))return t[r-1];for(const[s,a]of t.entries()){const l=t[s-1];if(e<(s+.5)/r)return l+(a-l)*(e-(s-.5)/r)/(1/r)}}_mode(t){const e={};let r=0;const n=[];for(const s of t)e[s]=(e[s]||0)+1,r=Math.max(r,e[s]);for(const s in e)e[s]===r&&n.push(Number(s));return Math.min(...r===1?t:n)}_median(t){t.sort(function(r,n){return r-n});const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}_minNth(t,e=0){return t.sort(function(r,n){return r-n}),t[e]}_maxNth(t,e=0){return t.sort(function(r,n){return n-r}),t[e]}_setElements(t,e,r=0,n){n===void 0&&(n=t.length);for(let s=r;s<n;s++)t[s]=e;return t}_covariance(t,e,r=!0,n){var c;if(t.length!=e.length){(c=this._errorListener)==null||c.addError(se.arrLengthDiffErr,n,Pt.Error);return}t=t.filter(h=>h!==void 0),e=e.filter(h=>h!==void 0);const s=t.reduce((h,d)=>h+d,0)/t.length,a=e.reduce((h,d)=>h+d,0)/e.length;let l=0;for(let h=0;h<t.length;h++)l+=(t[h]-s)*(e[h]-a);return r?l/t.length:l/(t.length-1)}_verifySimpleType(t,e,r,n,s=this._arrInstance){var l;s.filter(c=>c!==void 0).some(c=>!t.split("|").includes(typeof c))&&((l=this._errorListener)==null||l.addError(Ze(se.arrTypeErr,{name:e,type:r}),n,Pt.Error))}_binarySearch(t,e){let r=0,n=t.length-1;for(;r<=n;){const s=Math.floor((r+n)/2);if(t[s]===e)return s;t[s]<e?r=s+1:n=s-1}return-1}_binarySearchLeftMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<e?r=a+1:n=a-1}return s.length?Math.min(...s):r-1}_binarySearchRightMost(t,e){let r=0,n=t.length-1;const s=[];for(;r<=n;){const a=Math.floor((r+n)/2);t[a]===e&&s.push(a),t[a]<=e?r=a+1:n=a-1}return s.length?Math.max(...s):r}}class hp{constructor(t,e){$(this,"_randomNums");$(this,"_mintick");$(this,"_cacheData");$(this,"_barIndex");$(this,"_errorListener");this._mintick=t,this._randomNums={},this._cacheData={},this._barIndex=0,this._errorListener=e}update(t){this._barIndex=t,this._randomNums={}}abs({number:t}){if(!_t(t))return Math.abs(t)}acos({angle:t}){if(_t(t))return;const e=Math.acos(t);return isNaN(e)?void 0:e}asin({angle:t}){if(_t(t))return;const e=Math.asin(t);return isNaN(e)?void 0:e}atan({angle:t}){if(_t(t))return;const e=Math.atan(t);return isNaN(e)?void 0:e}avg(t,e){return Qr.mean(e)}ceil({number:t}){if(!_t(t))return Math.ceil(t)}floor({number:t}){if(!_t(t))return Math.floor(t)}cos({angle:t}){if(_t(t))return;const e=Math.cos(t);return isNaN(e)?void 0:e}sin({angle:t}){if(_t(t))return;const e=Math.sin(t);return isNaN(e)?void 0:e}tan({angle:t}){if(_t(t))return;const e=Math.tan(t);return isNaN(e)?void 0:e}exp({number:t}){if(!_t(t))return Math.exp(t)}log({number:t}){if(!_t(t))return Math.log(t)}log10({number:t}){if(!_t(t))return Math.log10(t)}max(t,e){if(!e.some(r=>_t(r)))return Math.max(...e)}min(t,e){if(!e.some(r=>_t(r)))return Math.min(...e)}pow({base:t,exponent:e}){if(!(_t(t)||_t(e)))return Math.pow(t,e)}random({min:t=0,max:e=1,seed:r},n){if(_t(t)&&(t=0),_t(e)&&(e=1),r&&this._randomNums[r])return this._randomNums[r];if(t>=e){this._errorListener.addError(se.mathRandomErr,n,Pt.Error);return}let s;do s=Math.random()*(e-t)+t;while(s===t||s===e);return r&&(this._randomNums[r]=s),s}round({number:t,precision:e}){if(!_t(t))return _t(e)?Math.round(t):Number(t==null?void 0:t.toFixed(e))}round_to_mintick({number:t}){if(!_t(t))return Number(t==null?void 0:t.toFixed(this._mintick))}sign({number:t}){if(!_t(t))return t&&Math.sign(t)}sqrt({number:t}){if(!_t(t))return Math.sqrt(t)}sum({source:t,length:e=1},r){let n=this._cacheData[`sum_${r}`];n||(n=[]),n[this._barIndex]=t,this._cacheData[`sum_${r}`]=n;const s=n.filter(a=>!_t(a));if(!(s.length<e))return Qr.sum(s.slice(-e))}todegrees({radians:t}){if(!_t(t))return t*(180/Math.PI)}toradians({degrees:t}){if(!_t(t))return t*(Math.PI/180)}}function Os(){return Os=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},Os.apply(this,arguments)}var Zl={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function _e(i){return typeof i=="number"}function Oe(i){return!i||typeof i!="object"||typeof i.constructor!="function"?!1:i.isBigNumber===!0&&typeof i.constructor.prototype=="object"&&i.constructor.prototype.isBigNumber===!0||typeof i.constructor.isDecimal=="function"&&i.constructor.isDecimal(i)===!0}function Kl(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isComplex===!0||!1}function Gl(i){return i&&typeof i=="object"&&Object.getPrototypeOf(i).isFraction===!0||!1}function Hl(i){return i&&i.constructor.prototype.isUnit===!0||!1}function en(i){return typeof i=="string"}var Ae=Array.isArray;function we(i){return i&&i.constructor.prototype.isMatrix===!0||!1}function Qi(i){return Array.isArray(i)||we(i)}function dp(i){return i&&i.isDenseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function pp(i){return i&&i.isSparseMatrix&&i.constructor.prototype.isMatrix===!0||!1}function _p(i){return i&&i.constructor.prototype.isRange===!0||!1}function va(i){return i&&i.constructor.prototype.isIndex===!0||!1}function mp(i){return typeof i=="boolean"}function gp(i){return i&&i.constructor.prototype.isResultSet===!0||!1}function vp(i){return i&&i.constructor.prototype.isHelp===!0||!1}function wp(i){return typeof i=="function"}function yp(i){return i instanceof Date}function Dp(i){return i instanceof RegExp}function wa(i){return!!(i&&typeof i=="object"&&i.constructor===Object&&!Kl(i)&&!Gl(i))}function bp(i){return i===null}function xp(i){return i===void 0}function Ep(i){return i&&i.isAccessorNode===!0&&i.constructor.prototype.isNode===!0||!1}function Ap(i){return i&&i.isArrayNode===!0&&i.constructor.prototype.isNode===!0||!1}function Cp(i){return i&&i.isAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function Fp(i){return i&&i.isBlockNode===!0&&i.constructor.prototype.isNode===!0||!1}function Mp(i){return i&&i.isConditionalNode===!0&&i.constructor.prototype.isNode===!0||!1}function Np(i){return i&&i.isConstantNode===!0&&i.constructor.prototype.isNode===!0||!1}function Sp(i){return i&&i.isFunctionAssignmentNode===!0&&i.constructor.prototype.isNode===!0||!1}function Op(i){return i&&i.isFunctionNode===!0&&i.constructor.prototype.isNode===!0||!1}function Bp(i){return i&&i.isIndexNode===!0&&i.constructor.prototype.isNode===!0||!1}function Ip(i){return i&&i.isNode===!0&&i.constructor.prototype.isNode===!0||!1}function Tp(i){return i&&i.isObjectNode===!0&&i.constructor.prototype.isNode===!0||!1}function $p(i){return i&&i.isOperatorNode===!0&&i.constructor.prototype.isNode===!0||!1}function Lp(i){return i&&i.isParenthesisNode===!0&&i.constructor.prototype.isNode===!0||!1}function Rp(i){return i&&i.isRangeNode===!0&&i.constructor.prototype.isNode===!0||!1}function Pp(i){return i&&i.isRelationalNode===!0&&i.constructor.prototype.isNode===!0||!1}function zp(i){return i&&i.isSymbolNode===!0&&i.constructor.prototype.isNode===!0||!1}function kp(i){return i&&i.constructor.prototype.isChain===!0||!1}function Cn(i){var t=typeof i;return t==="object"?i===null?"null":Oe(i)?"BigNumber":i.constructor&&i.constructor.name?i.constructor.name:"Object":t}function oe(i){var t=typeof i;if(t==="number"||t==="string"||t==="boolean"||i===null||i===void 0)return i;if(typeof i.clone=="function")return i.clone();if(Array.isArray(i))return i.map(function(e){return oe(e)});if(i instanceof Date)return new Date(i.valueOf());if(Oe(i))return i;if(wa(i))return qp(i,oe);throw new TypeError("Cannot clone: unknown type of value (value: ".concat(i,")"))}function qp(i,t){var e={};for(var r in i)ts(i,r)&&(e[r]=t(i[r]));return e}function Jl(i,t){for(var e in t)ts(t,e)&&(i[e]=t[e]);return i}function vi(i,t){var e,r,n;if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(r=0,n=i.length;r<n;r++)if(!vi(i[r],t[r]))return!1;return!0}else{if(typeof i=="function")return i===t;if(i instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(e in i)if(!(e in t)||!vi(i[e],t[e]))return!1;for(e in t)if(!(e in i))return!1;return!0}else return i===t}}function ts(i,t){return i&&Object.hasOwnProperty.call(i,t)}function Up(i,t){for(var e={},r=0;r<t.length;r++){var n=t[r],s=i[n];s!==void 0&&(e[n]=s)}return e}var Wp=["Matrix","Array"],jp=["number","BigNumber","Fraction"],gr=function(t){if(t)throw new Error(`The global config is readonly.
28
28
  Please create a mathjs instance if you want to change the default configuration.
29
29
  Example:
30
30
 
31
31
  import { create, all } from 'mathjs';
32
32
  const mathjs = create(all);
33
33
  mathjs.config({ number: 'BigNumber' });
34
- `);return Object.freeze(Zl)};Os(gr,Zl,{MATRIX_OPTIONS:Wp,NUMBER_OPTIONS:jp});function Xl(){return!0}function Sr(){return!1}function wi(){}const Ql="Argument is not a typed-function.";function tc(){function i(R){return typeof R=="object"&&R!==null&&R.constructor===Object}const t=[{name:"number",test:function(R){return typeof R=="number"}},{name:"string",test:function(R){return typeof R=="string"}},{name:"boolean",test:function(R){return typeof R=="boolean"}},{name:"Function",test:function(R){return typeof R=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(R){return R instanceof Date}},{name:"RegExp",test:function(R){return R instanceof RegExp}},{name:"Object",test:i},{name:"null",test:function(R){return R===null}},{name:"undefined",test:function(R){return R===void 0}}],e={name:"any",test:Xl,isAny:!0};let r,n,s=0,a={createCount:0};function l(R){const Y=r.get(R);if(Y)return Y;let G='Unknown type "'+R+'"';const nt=R.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){G+='. Did you mean "'+st+'" ?';break}throw new TypeError(G)}function c(R){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const G=Y?l(Y).index:n.length,nt=[];for(let rt=0;rt<R.length;++rt){if(!R[rt]||typeof R[rt].name!="string"||typeof R[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ft=R[rt].name;if(r.has(ft))throw new TypeError('Duplicate type name "'+ft+'"');nt.push(ft),r.set(ft,{name:ft,test:R[rt].test,isAny:R[rt].isAny,index:G+rt,conversionsTo:[]})}const st=n.slice(G);n=n.slice(0,G).concat(nt).concat(st);for(let rt=G+nt.length;rt<n.length;++rt)r.get(n[rt]).index=rt}function f(){r=new Map,n=[],s=0,c([e],!1)}f(),c(t);function d(){let R;for(R of n)r.get(R).conversionsTo=[];s=0}function h(R){const Y=n.filter(G=>{const nt=r.get(G);return!nt.isAny&&nt.test(R)});return Y.length?Y:["any"]}function p(R){return R&&typeof R=="function"&&"_typedFunctionData"in R}function g(R,Y,G){if(!p(R))throw new TypeError(Ql);const nt=G&&G.exact,st=Array.isArray(Y)?Y.join(","):Y,rt=M(st),ft=y(rt);if(!nt||ft in R.signatures){const Xt=R._typedFunctionData.signatureMap.get(ft);if(Xt)return Xt}const ut=rt.length;let ht;if(nt){ht=[];let Xt;for(Xt in R.signatures)ht.push(R._typedFunctionData.signatureMap.get(Xt))}else ht=R._typedFunctionData.signatures;for(let Xt=0;Xt<ut;++Xt){const ne=rt[Xt],xe=[];let Ve;for(Ve of ht){const qe=S(Ve.params,Xt);if(!(!qe||ne.restParam&&!qe.restParam)){if(!qe.hasAny){const Dr=b(qe);if(ne.types.some(br=>!Dr.has(br.name)))continue}xe.push(Ve)}}if(ht=xe,ht.length===0)break}let at;for(at of ht)if(at.params.length<=ut)return at;throw new TypeError("Signature not found (signature: "+(R.name||"unnamed")+"("+y(rt,", ")+"))")}function w(R,Y,G){return g(R,Y,G).implementation}function _(R,Y){const G=l(Y);if(G.test(R))return R;const nt=G.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+Y+" defined.");for(let st=0;st<nt.length;st++)if(l(nt[st].from).test(R))return nt[st].convert(R);throw new Error("Cannot convert "+R+" to "+Y)}function y(R){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return R.map(G=>G.name).join(Y)}function v(R){const Y=R.indexOf("...")===0,nt=(Y?R.length>3?R.slice(3):"any":R).split("|").map(ut=>l(ut.trim()));let st=!1,rt=Y?"...":"";return{types:nt.map(function(ut){return st=ut.isAny||st,rt+=ut.name+"|",{name:ut.name,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:null,conversionIndex:-1}}),name:rt.slice(0,-1),hasAny:st,hasConversion:!1,restParam:Y}}function x(R){const Y=R.types.map(ft=>ft.name),G=K(Y);let nt=R.hasAny,st=R.name;const rt=G.map(function(ft){const ut=l(ft.from);return nt=ut.isAny||nt,st+="|"+ft.from,{name:ft.from,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:ft,conversionIndex:ft.index}});return{types:R.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:R.restParam}}function b(R){return R.typeSet||(R.typeSet=new Set,R.types.forEach(Y=>R.typeSet.add(Y.name))),R.typeSet}function M(R){const Y=[];if(typeof R!="string")throw new TypeError("Signatures must be strings");const G=R.trim();if(G==="")return Y;const nt=G.split(",");for(let st=0;st<nt.length;++st){const rt=v(nt[st].trim());if(rt.restParam&&st!==nt.length-1)throw new SyntaxError('Unexpected rest parameter "'+nt[st]+'": only allowed for the last parameter');if(rt.types.length===0)return null;Y.push(rt)}return Y}function E(R){const Y=It(R);return Y?Y.restParam:!1}function F(R){if(!R||R.types.length===0)return Xl;if(R.types.length===1)return l(R.types[0].name).test;if(R.types.length===2){const Y=l(R.types[0].name).test,G=l(R.types[1].name).test;return function(st){return Y(st)||G(st)}}else{const Y=R.types.map(function(G){return l(G.name).test});return function(nt){for(let st=0;st<Y.length;st++)if(Y[st](nt))return!0;return!1}}}function N(R){let Y,G,nt;if(E(R)){Y=ue(R).map(F);const st=Y.length,rt=F(It(R)),ft=function(ut){for(let ht=st;ht<ut.length;ht++)if(!rt(ut[ht]))return!1;return!0};return function(ht){for(let at=0;at<Y.length;at++)if(!Y[at](ht[at]))return!1;return ft(ht)&&ht.length>=st+1}}else return R.length===0?function(rt){return rt.length===0}:R.length===1?(G=F(R[0]),function(rt){return G(rt[0])&&rt.length===1}):R.length===2?(G=F(R[0]),nt=F(R[1]),function(rt){return G(rt[0])&&nt(rt[1])&&rt.length===2}):(Y=R.map(F),function(rt){for(let ft=0;ft<Y.length;ft++)if(!Y[ft](rt[ft]))return!1;return rt.length===Y.length})}function S(R,Y){return Y<R.length?R[Y]:E(R)?It(R):null}function T(R,Y){const G=S(R,Y);return G?b(G):new Set}function C(R){return R.conversion===null||R.conversion===void 0}function O(R,Y){const G=new Set;return R.forEach(nt=>{const st=T(nt.params,Y);let rt;for(rt of st)G.add(rt)}),G.has("any")?["any"]:Array.from(G)}function $(R,Y,G){let nt,st;const rt=R||"unnamed";let ft=G,ut;for(ut=0;ut<Y.length;ut++){const ne=[];if(ft.forEach(xe=>{const Ve=S(xe.params,ut),qe=F(Ve);(ut<xe.params.length||E(xe.params))&&qe(Y[ut])&&ne.push(xe)}),ne.length===0){if(st=O(ft,ut),st.length>0){const xe=h(Y[ut]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+xe.join(" | ")+", index: "+ut+")"),nt.data={category:"wrongType",fn:rt,index:ut,actual:xe,expected:st},nt}}else ft=ne}const ht=ft.map(function(ne){return E(ne.params)?1/0:ne.params.length});if(Y.length<Math.min.apply(null,ht))return st=O(ft,ut),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+Y.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:Y.length,expected:st},nt;const at=Math.max.apply(null,ht);if(Y.length>at)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+at+", actual: "+Y.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:Y.length,expectedLength:at},nt;const Xt=[];for(let ne=0;ne<Y.length;++ne)Xt.push(h(Y[ne]).join("|"));return nt=new TypeError('Arguments of type "'+Xt.join(", ")+'" do not match any of the defined signatures of function '+rt+"."),nt.data={category:"mismatch",actual:Xt},nt}function W(R){let Y=n.length+1;for(let G=0;G<R.types.length;G++)C(R.types[G])&&(Y=Math.min(Y,R.types[G].typeIndex));return Y}function q(R){let Y=s+1;for(let G=0;G<R.types.length;G++)C(R.types[G])||(Y=Math.min(Y,R.types[G].conversionIndex));return Y}function U(R,Y){if(R.hasAny){if(!Y.hasAny)return 1}else if(Y.hasAny)return-1;if(R.restParam){if(!Y.restParam)return 1}else if(Y.restParam)return-1;if(R.hasConversion){if(!Y.hasConversion)return 1}else if(Y.hasConversion)return-1;const G=W(R)-W(Y);if(G<0)return-1;if(G>0)return 1;const nt=q(R)-q(Y);return nt<0?-1:nt>0?1:0}function z(R,Y){const G=R.params,nt=Y.params,st=It(G),rt=It(nt),ft=E(G),ut=E(nt);if(ft&&st.hasAny){if(!ut||!rt.hasAny)return 1}else if(ut&&rt.hasAny)return-1;let ht=0,at=0,Xt;for(Xt of G)Xt.hasAny&&++ht,Xt.hasConversion&&++at;let ne=0,xe=0;for(Xt of nt)Xt.hasAny&&++ne,Xt.hasConversion&&++xe;if(ht!==ne)return ht-ne;if(ft&&st.hasConversion){if(!ut||!rt.hasConversion)return 1}else if(ut&&rt.hasConversion)return-1;if(at!==xe)return at-xe;if(ft){if(!ut)return 1}else if(ut)return-1;const Ve=(G.length-nt.length)*(ft?-1:1);if(Ve!==0)return Ve;const qe=[];let Dr=0;for(let Ln=0;Ln<G.length;++Ln){const oi=U(G[Ln],nt[Ln]);qe.push(oi),Dr+=oi}if(Dr!==0)return Dr;let br;for(br of qe)if(br!==0)return br;return 0}function K(R){if(R.length===0)return[];const Y=R.map(l);R.length>1&&Y.sort((st,rt)=>st.index-rt.index);let G=Y[0].conversionsTo;if(R.length===1)return G;G=G.concat([]);const nt=new Set(R);for(let st=1;st<Y.length;++st){let rt;for(rt of Y[st].conversionsTo)nt.has(rt.from)||(G.push(rt),nt.add(rt.from))}return G}function Z(R,Y){let G=Y;if(R.some(st=>st.hasConversion)){const st=E(R),rt=R.map(X);G=function(){const ut=[],ht=st?arguments.length-1:arguments.length;for(let at=0;at<ht;at++)ut[at]=rt[at](arguments[at]);return st&&(ut[ht]=arguments[ht].map(rt[ht])),Y.apply(this,ut)}}let nt=G;if(E(R)){const st=R.length-1;nt=function(){return G.apply(this,Nt(arguments,0,st).concat([Nt(arguments,st)]))}}return nt}function X(R){let Y,G,nt,st;const rt=[],ft=[];switch(R.types.forEach(function(ut){ut.conversion&&(rt.push(l(ut.conversion.from).test),ft.push(ut.conversion.convert))}),ft.length){case 0:return function(ht){return ht};case 1:return Y=rt[0],nt=ft[0],function(ht){return Y(ht)?nt(ht):ht};case 2:return Y=rt[0],G=rt[1],nt=ft[0],st=ft[1],function(ht){return Y(ht)?nt(ht):G(ht)?st(ht):ht};default:return function(ht){for(let at=0;at<ft.length;at++)if(rt[at](ht))return ft[at](ht);return ht}}}function Q(R){function Y(G,nt,st){if(nt<G.length){const rt=G[nt];let ft=[];if(rt.restParam){const ut=rt.types.filter(C);ut.length<rt.types.length&&ft.push({types:ut,name:"..."+ut.map(ht=>ht.name).join("|"),hasAny:ut.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),ft.push(rt)}else ft=rt.types.map(function(ut){return{types:[ut],name:ut.name,hasAny:ut.isAny,hasConversion:ut.conversion,restParam:!1}});return re(ft,function(ut){return Y(G,nt+1,st.concat([ut]))})}else return[st]}return Y(R,0,[])}function ct(R,Y){const G=Math.max(R.length,Y.length);for(let ut=0;ut<G;ut++){const ht=T(R,ut),at=T(Y,ut);let Xt=!1,ne;for(ne of at)if(ht.has(ne)){Xt=!0;break}if(!Xt)return!1}const nt=R.length,st=Y.length,rt=E(R),ft=E(Y);return rt?ft?nt===st:st>=nt:ft?nt>=st:nt===st}function vt(R){return R.map(Y=>ke(Y)?Le(Y.referToSelf.callback):wr(Y)?Jt(Y.referTo.references,Y.referTo.callback):Y)}function lt(R,Y,G){const nt=[];let st;for(st of R){let rt=G[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=Y[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function yt(R,Y,G){const nt=vt(R),st=new Array(nt.length).fill(!1);let rt=!0;for(;rt;){rt=!1;let ft=!0;for(let ut=0;ut<nt.length;++ut){if(st[ut])continue;const ht=nt[ut];if(ke(ht))nt[ut]=ht.referToSelf.callback(G),nt[ut].referToSelf=ht.referToSelf,st[ut]=!0,ft=!1;else if(wr(ht)){const at=lt(ht.referTo.references,nt,Y);at?(nt[ut]=ht.referTo.callback.apply(this,at),nt[ut].referTo=ht.referTo,st[ut]=!0,ft=!1):rt=!0}}if(ft&&rt)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return nt}function bt(R){const Y=/\bthis(\(|\.signatures\b)/;Object.keys(R).forEach(G=>{const nt=R[G];if(Y.test(nt.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function Ot(R,Y){if(a.createCount++,Object.keys(Y).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&bt(Y);const G=[],nt=[],st={},rt=[];let ft;for(ft in Y){if(!Object.prototype.hasOwnProperty.call(Y,ft))continue;const Zt=M(ft);if(!Zt)continue;G.forEach(function(Rn){if(ct(Rn,Zt))throw new TypeError('Conflicting signatures "'+y(Rn)+'" and "'+y(Zt)+'".')}),G.push(Zt);const er=nt.length;nt.push(Y[ft]);const Eu=Zt.map(x);let Ri;for(Ri of Q(Eu)){const Rn=y(Ri);rt.push({params:Ri,name:Rn,fn:er}),Ri.every(So=>!So.hasConversion)&&(st[Rn]=er)}}rt.sort(z);const ut=yt(nt,st,ai);let ht;for(ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(st[ht]=ut[st[ht]]);const at=[],Xt=new Map;for(ht of rt)Xt.has(ht.name)||(ht.fn=ut[ht.fn],at.push(ht),Xt.set(ht.name,ht));const ne=at[0]&&at[0].params.length<=2&&!E(at[0].params),xe=at[1]&&at[1].params.length<=2&&!E(at[1].params),Ve=at[2]&&at[2].params.length<=2&&!E(at[2].params),qe=at[3]&&at[3].params.length<=2&&!E(at[3].params),Dr=at[4]&&at[4].params.length<=2&&!E(at[4].params),br=at[5]&&at[5].params.length<=2&&!E(at[5].params),Ln=ne&&xe&&Ve&&qe&&Dr&&br;for(let Zt=0;Zt<at.length;++Zt)at[Zt].test=N(at[Zt].params);const oi=ne?F(at[0].params[0]):Sr,Fo=xe?F(at[1].params[0]):Sr,ru=Ve?F(at[2].params[0]):Sr,nu=qe?F(at[3].params[0]):Sr,iu=Dr?F(at[4].params[0]):Sr,su=br?F(at[5].params[0]):Sr,Mo=ne?F(at[0].params[1]):Sr,ou=xe?F(at[1].params[1]):Sr,au=Ve?F(at[2].params[1]):Sr,uu=qe?F(at[3].params[1]):Sr,ls=Dr?F(at[4].params[1]):Sr,lu=br?F(at[5].params[1]):Sr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].implementation=Z(at[Zt].params,at[Zt].fn);const cs=ne?at[0].implementation:wi,cu=xe?at[1].implementation:wi,fu=Ve?at[2].implementation:wi,hu=qe?at[3].implementation:wi,du=Dr?at[4].implementation:wi,pu=br?at[5].implementation:wi,_u=ne?at[0].params.length:-1,mu=xe?at[1].params.length:-1,gu=Ve?at[2].params.length:-1,No=qe?at[3].params.length:-1,vu=Dr?at[4].params.length:-1,wu=br?at[5].params.length:-1,yu=Ln?6:0,Du=at.length,bu=at.map(Zt=>Zt.test),xu=at.map(Zt=>Zt.implementation),Li=function(){for(let er=yu;er<Du;er++)if(bu[er](arguments))return xu[er].apply(this,arguments);return a.onMismatch(R,arguments,at)};function ai(Zt,er){return arguments.length===_u&&oi(Zt)&&Mo(er)?cs.apply(this,arguments):arguments.length===mu&&Fo(Zt)&&ou(er)?cu.apply(this,arguments):arguments.length===gu&&ru(Zt)&&au(er)?fu.apply(this,arguments):arguments.length===No&&nu(Zt)&&uu(er)?hu.apply(this,arguments):arguments.length===vu&&iu(Zt)&&ls(er)?du.apply(this,arguments):arguments.length===wu&&su(Zt)&&lu(er)?pu.apply(this,arguments):Li.apply(this,arguments)}try{Object.defineProperty(ai,"name",{value:R})}catch{}return ai.signatures=st,ai._typedFunctionData={signatures:at,signatureMap:Xt},ai}function xt(R,Y,G){throw $(R,Y,G)}function ue(R){return Nt(R,0,R.length-1)}function It(R){return R[R.length-1]}function Nt(R,Y,G){return Array.prototype.slice.call(R,Y,G)}function fe(R,Y){for(let G=0;G<R.length;G++)if(Y(R[G]))return R[G]}function re(R,Y){return Array.prototype.concat.apply([],R.map(Y))}function qt(){const R=ue(arguments).map(G=>y(M(G))),Y=It(arguments);if(typeof Y!="function")throw new TypeError("Callback function expected as last argument");return Jt(R,Y)}function Jt(R,Y){return{referTo:{references:R,callback:Y}}}function Le(R){if(typeof R!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:R}}}function wr(R){return R&&typeof R.referTo=="object"&&Array.isArray(R.referTo.references)&&typeof R.referTo.callback=="function"}function ke(R){return R&&typeof R.referToSelf=="object"&&typeof R.referToSelf.callback=="function"}function _n(R,Y){if(!R)return Y;if(Y&&Y!==R){const G=new Error("Function names do not match (expected: "+R+", actual: "+Y+")");throw G.data={actual:Y,expected:R},G}return R}function Tn(R){let Y;for(const G in R)Object.prototype.hasOwnProperty.call(R,G)&&(p(R[G])||typeof R[G].signature=="string")&&(Y=_n(Y,R[G].name));return Y}function mn(R,Y){let G;for(G in Y)if(Object.prototype.hasOwnProperty.call(Y,G)){if(G in R&&Y[G]!==R[G]){const nt=new Error('Signature "'+G+'" is defined twice');throw nt.data={signature:G,sourceFunction:Y[G],destFunction:R[G]},nt}R[G]=Y[G]}}const yr=a;a=function(R){const Y=typeof R=="string",G=Y?1:0;let nt=Y?R:"";const st={};for(let rt=G;rt<arguments.length;++rt){const ft=arguments[rt];let ut={},ht;if(typeof ft=="function"?(ht=ft.name,typeof ft.signature=="string"?ut[ft.signature]=ft:p(ft)&&(ut=ft.signatures)):i(ft)&&(ut=ft,Y||(ht=Tn(ft))),Object.keys(ut).length===0){const at=new TypeError("Argument to 'typed' at index "+rt+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw at.data={index:rt,argument:ft},at}Y||(nt=_n(nt,ht)),mn(st,ut)}return Ot(nt||"",st)},a.create=tc,a.createCount=yr.createCount,a.onMismatch=xt,a.throwMismatchError=xt,a.createError=$,a.clear=f,a.clearConversions=d,a.addTypes=c,a._findType=l,a.referTo=qt,a.referToSelf=Le,a.convert=_,a.findSignature=g,a.find=w,a.isTypedFunction=p,a.warnAgainstDeprecatedThis=!0,a.addType=function(R,Y){let G="any";Y!==!1&&r.has("Object")&&(G="Object"),a.addTypes([R],G)};function $n(R){if(!R||typeof R.from!="string"||typeof R.to!="string"||typeof R.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(R.to===R.from)throw new SyntaxError('Illegal to define conversion from "'+R.from+'" to itself.')}return a.addConversion=function(R){$n(R);const Y=l(R.to);if(Y.conversionsTo.every(function(G){return G.from!==R.from}))Y.conversionsTo.push({from:R.from,convert:R.convert,index:s++});else throw new Error('There is already a conversion from "'+R.from+'" to "'+Y.name+'"')},a.addConversions=function(R){R.forEach(a.addConversion)},a.removeConversion=function(R){$n(R);const Y=l(R.to),G=fe(Y.conversionsTo,st=>st.from===R.from);if(!G)throw new Error("Attempt to remove nonexistent conversion from "+R.from+" to "+R.to);if(G.convert!==R.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=Y.conversionsTo.indexOf(G);Y.conversionsTo.splice(nt,1)},a.resolve=function(R,Y){if(!p(R))throw new TypeError(Ql);const G=R._typedFunctionData.signatures;for(let nt=0;nt<G.length;++nt)if(G[nt].test(Y))return G[nt];return null},a}var ec=tc();function be(i){return typeof i=="boolean"?!0:isFinite(i)?i===Math.round(i):!1}function ya(i,t,e){var r={2:"0b",8:"0o",16:"0x"},n=r[t],s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!be(e))throw new Error("size must be an integer");if(i>2**(e-1)-1||i<-(2**(e-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!be(i))throw new Error("Value must be an integer");i<0&&(i=i+2**e),s="i".concat(e)}var a="";return i<0&&(i=-i,a="-"),"".concat(a).concat(n).concat(i.toString(t)).concat(s)}function Da(i,t){if(typeof t=="function")return t(i);if(i===1/0)return"Infinity";if(i===-1/0)return"-Infinity";if(isNaN(i))return"NaN";var{notation:e,precision:r,wordSize:n}=rc(t);switch(e){case"fixed":return Yp(i,r);case"exponential":return nc(i,r);case"engineering":return Vp(i,r);case"bin":return ya(i,2,n);case"oct":return ya(i,8,n);case"hex":return ya(i,16,n);case"auto":return Zp(i,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],a=arguments[4];return s!=="."?s+a:a});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function rc(i){var t="auto",e,r;if(i!==void 0)if(_e(i))e=i;else if(Oe(i))e=i.toNumber();else if(wa(i))i.precision!==void 0&&(e=ic(i.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),i.wordSize!==void 0&&(r=ic(i.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),i.notation&&(t=i.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:t,precision:e,wordSize:r}}function Bs(i){var t=String(i).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+i);var e=t[1],r=t[2],n=parseFloat(t[4]||"0"),s=r.indexOf(".");n+=s!==-1?s-1:r.length-1;var a=r.replace(".","").replace(/^0*/,function(l){return n-=l.length,""}).replace(/0*$/,"").split("").map(function(l){return parseInt(l)});return a.length===0&&(a.push(0),n++),{sign:e,coefficients:a,exponent:n}}function Vp(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Bs(i),r=Is(e,t),n=r.exponent,s=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(_e(t))for(;t>s.length||n-a+1>s.length;)s.push(0);else for(var l=Math.abs(n-a)-(s.length-1),c=0;c<l;c++)s.push(0);for(var f=Math.abs(n-a),d=1;f>0;)d++,f--;var h=s.slice(d).join(""),p=_e(t)&&h.length||h.match(/[1-9]/)?"."+h:"",g=s.slice(0,d).join("")+p+"e"+(n>=0?"+":"")+a.toString();return r.sign+g}function Yp(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Bs(i),r=typeof t=="number"?Is(e,e.exponent+1+t):e,n=r.coefficients,s=r.exponent+1,a=s+(t||0);return n.length<a&&(n=n.concat(yi(a-n.length))),s<0&&(n=yi(-s+1).concat(n),s=1),s<n.length&&n.splice(s,0,s===0?"0.":"."),r.sign+n.join("")}function nc(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Bs(i),r=t?Is(e,t):e,n=r.coefficients,s=r.exponent;n.length<t&&(n=n.concat(yi(t-n.length)));var a=n.shift();return r.sign+a+(n.length>0?"."+n.join(""):"")+"e"+(s>=0?"+":"")+s}function Zp(i,t,e){if(isNaN(i)||!isFinite(i))return String(i);var r=sc(e==null?void 0:e.lowerExp,-3),n=sc(e==null?void 0:e.upperExp,5),s=Bs(i),a=t?Is(s,t):s;if(a.exponent<r||a.exponent>=n)return nc(i,t);var l=a.coefficients,c=a.exponent;l.length<t&&(l=l.concat(yi(t-l.length))),l=l.concat(yi(c-l.length+1+(l.length<t?t-l.length:0))),l=yi(-c).concat(l);var f=c>0?c:0;return f<l.length-1&&l.splice(f+1,0,"."),a.sign+l.join("")}function Is(i,t){for(var e={sign:i.sign,coefficients:i.coefficients,exponent:i.exponent},r=e.coefficients;t<=0;)r.unshift(0),e.exponent++,t++;if(r.length>t){var n=r.splice(t,r.length-t);if(n[0]>=5){var s=t-1;for(r[s]++;r[s]===10;)r.pop(),s===0&&(r.unshift(0),e.exponent++,s++),s--,r[s]++}}return e}function yi(i){for(var t=[],e=0;e<i;e++)t.push(0);return t}function Kp(i){return i.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Gp=Number.EPSILON||2220446049250313e-31;function Jn(i,t,e){if(e==null)return i===t;if(i===t)return!0;if(isNaN(i)||isNaN(t))return!1;if(isFinite(i)&&isFinite(t)){var r=Math.abs(i-t);return r<=Gp?!0:r<=Math.max(Math.abs(i),Math.abs(t))*e}return!1}function ic(i,t){if(_e(i))return i;if(Oe(i))return i.toNumber();t()}function sc(i,t){return _e(i)?i:Oe(i)?i.toNumber():t}function ba(i,t,e){var r=i.constructor,n=new r(2),s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!be(e))throw new Error("size must be an integer");if(i.greaterThan(n.pow(e-1).sub(1))||i.lessThan(n.pow(e-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!i.isInteger())throw new Error("Value must be an integer");i.lessThan(0)&&(i=i.add(n.pow(e))),s="i".concat(e)}switch(t){case 2:return"".concat(i.toBinary()).concat(s);case 8:return"".concat(i.toOctal()).concat(s);case 16:return"".concat(i.toHexadecimal()).concat(s);default:throw new Error("Base ".concat(t," not supported "))}}function Hp(i,t){if(typeof t=="function")return t(i);if(!i.isFinite())return i.isNaN()?"NaN":i.gt(0)?"Infinity":"-Infinity";var{notation:e,precision:r,wordSize:n}=rc(t);switch(e){case"fixed":return Xp(i,r);case"exponential":return oc(i,r);case"engineering":return Jp(i,r);case"bin":return ba(i,2,n);case"oct":return ba(i,8,n);case"hex":return ba(i,16,n);case"auto":{var s=ac(t==null?void 0:t.lowerExp,-3),a=ac(t==null?void 0:t.upperExp,5);if(i.isZero())return"0";var l,c=i.toSignificantDigits(r),f=c.e;return f>=s&&f<a?l=c.toFixed():l=oc(i,r),l.replace(/((\.\d*?)(0+))($|e)/,function(){var d=arguments[2],h=arguments[4];return d!=="."?d+h:h})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Jp(i,t){var e=i.e,r=e%3===0?e:e<0?e-3-e%3:e-e%3,n=i.mul(Math.pow(10,-r)),s=n.toPrecision(t);if(s.indexOf("e")!==-1){var a=i.constructor;s=new a(s).toFixed()}return s+"e"+(e>=0?"+":"")+r.toString()}function oc(i,t){return t!==void 0?i.toExponential(t-1):i.toExponential()}function Xp(i,t){return i.toFixed(t)}function ac(i,t){return _e(i)?i:Oe(i)?i.toNumber():t}function he(i,t){var e=Qp(i,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function Qp(i,t){if(typeof i=="number")return Da(i,t);if(Oe(i))return Hp(i,t);if(t_(i))return!t||t.fraction!=="decimal"?i.s*i.n+"/"+i.d:i.toString();if(Array.isArray(i))return cc(i,t);if(en(i))return uc(i);if(typeof i=="function")return i.syntax?String(i.syntax):"function";if(i&&typeof i=="object"){if(typeof i.format=="function")return i.format(t);if(i&&i.toString(t)!=={}.toString())return i.toString(t);var e=Object.keys(i).map(r=>uc(r)+": "+he(i[r],t));return"{"+e.join(", ")+"}"}return String(i)}function uc(i){for(var t=String(i),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in lc?lc[n]:n,r++}return'"'+e+'"'}var lc={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function cc(i,t){if(Array.isArray(i)){for(var e="[",r=i.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=cc(i[n],t);return e+="]",e}else return he(i,t)}function t_(i){return i&&typeof i=="object"&&typeof i.s=="number"&&typeof i.n=="number"&&typeof i.d=="number"||!1}function Ht(i,t,e){if(!(this instanceof Ht))throw new SyntaxError("Constructor must be called with the new operator");this.actual=i,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(i)?"["+i.join(", ")+"]":i)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}Ht.prototype=new RangeError,Ht.prototype.constructor=RangeError,Ht.prototype.name="DimensionError",Ht.prototype.isDimensionError=!0;function Fn(i,t,e){if(!(this instanceof Fn))throw new SyntaxError("Constructor must be called with the new operator");this.index=i,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=e),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}Fn.prototype=new RangeError,Fn.prototype.constructor=RangeError,Fn.prototype.name="IndexError",Fn.prototype.isIndexError=!0;function Te(i){for(var t=[];Array.isArray(i);)t.push(i.length),i=i[0];return t}function fc(i,t,e){var r,n=i.length;if(n!==t[e])throw new Ht(n,t[e]);if(e<t.length-1){var s=e+1;for(r=0;r<n;r++){var a=i[r];if(!Array.isArray(a))throw new Ht(t.length-1,t.length,"<");fc(i[r],t,s)}}else for(r=0;r<n;r++)if(Array.isArray(i[r]))throw new Ht(t.length+1,t.length,">")}function hc(i,t){var e=t.length===0;if(e){if(Array.isArray(i))throw new Ht(i.length,0)}else fc(i,t,0)}function Ce(i,t){if(i!==void 0){if(!_e(i)||!be(i))throw new TypeError("Index must be an integer (value: "+i+")");if(i<0||typeof t=="number"&&i>=t)throw new Fn(i,t)}}function xa(i,t,e){if(!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Error("Resizing to scalar is not supported");t.forEach(function(n){if(!_e(n)||!be(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+he(t)+")")}),(_e(i)||Oe(i))&&(i=[i]);var r=e!==void 0?e:0;return Ea(i,t,0,r),i}function Ea(i,t,e,r){var n,s,a=i.length,l=t[e],c=Math.min(a,l);if(i.length=l,e<t.length-1){var f=e+1;for(n=0;n<c;n++)s=i[n],Array.isArray(s)||(s=[s],i[n]=s),Ea(s,t,f,r);for(n=c;n<l;n++)s=[],i[n]=s,Ea(s,t,f,r)}else{for(n=0;n<c;n++)for(;Array.isArray(i[n]);)i[n]=i[n][0];for(n=c;n<l;n++)i[n]=r}}function Aa(i,t){var e=Fa(i),r=e.length;if(!Array.isArray(i)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Ht(0,r,"!=");t=Ca(t,r);var n=dc(t);if(r!==n)throw new Ht(n,r,"!=");try{return e_(e,t)}catch(s){throw s instanceof Ht?new Ht(n,r,"!="):s}}function Ca(i,t){var e=dc(i),r=i.slice(),n=-1,s=i.indexOf(n),a=i.indexOf(n,s+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var l=s>=0,c=t%e===0;if(l)if(c)r[s]=-t/e;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-e);return r}function dc(i){return i.reduce((t,e)=>t*e,1)}function e_(i,t){for(var e=i,r,n=t.length-1;n>0;n--){var s=t[n];r=[];for(var a=e.length/s,l=0;l<a;l++)r.push(e.slice(l*s,(l+1)*s));e=r}return e}function pc(i,t,e,r){var n=r||Te(i);if(e)for(var s=0;s<e;s++)i=[i],n.unshift(1);for(i=_c(i,t,0);n.length<t;)n.push(1);return i}function _c(i,t,e){var r,n;if(Array.isArray(i)){var s=e+1;for(r=0,n=i.length;r<n;r++)i[r]=_c(i[r],t,s)}else for(var a=e;a<t;a++)i=[i];return i}function Fa(i){if(!Array.isArray(i))return i;var t=[];return i.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t}function Ts(i,t){for(var e,r=0,n=0;n<i.length;n++){var s=i[n],a=Array.isArray(s);if(n===0&&a&&(r=s.length),a&&s.length!==r)return;var l=a?Ts(s,t):t(s);if(e===void 0)e=l;else if(e!==l)return"mixed"}return e}function mc(i,t,e,r){if(r<e){if(i.length!==t.length)throw new Ht(i.length,t.length);for(var n=[],s=0;s<i.length;s++)n[s]=mc(i[s],t[s],e,r+1);return n}else return i.concat(t)}function gc(){var i=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(i.length===1)return i[0];if(i.length>1)return i.slice(1).reduce(function(e,r){return mc(e,r,t,0)},i[0]);throw new Error("Wrong number of arguments in function concat")}function r_(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];for(var r=t.map(p=>p.length),n=Math.max(...r),s=new Array(n).fill(null),a=0;a<t.length;a++)for(var l=t[a],c=r[a],f=0;f<c;f++){var d=n-c+f;l[f]>s[d]&&(s[d]=l[f])}for(var h=0;h<t.length;h++)$s(t[h],s);return s}function $s(i,t){for(var e=t.length,r=i.length,n=0;n<r;n++){var s=e-r+n;if(i[n]<t[s]&&i[n]>1||i[n]>t[s])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(i,") not possible to broadcast dimension ").concat(r," with size ").concat(i[n]," to size ").concat(t[s]))}}function vc(i,t){var e=Te(i);if(vi(e,t))return i;$s(e,t);var r=r_(e,t),n=r.length,s=[...Array(n-e.length).fill(1),...e],a=i_(i);e.length<n&&(a=Aa(a,s),e=Te(a));for(var l=0;l<n;l++)e[l]<r[l]&&(a=n_(a,r[l],l),e=Te(a));return a}function n_(i,t,e){return gc(...Array(t).fill(i),e)}function i_(i){return Os([],i)}function mt(i,t,e,r){function n(s){var a=Up(s,t.map(a_));return s_(i,t,s),e(a)}return n.isFactory=!0,n.fn=i,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function s_(i,t,e){var r=t.filter(s=>!o_(s)).every(s=>e[s]!==void 0);if(!r){var n=t.filter(s=>e[s]===void 0);throw new Error('Cannot create function "'.concat(i,'", ')+"some dependencies are missing: ".concat(n.map(s=>'"'.concat(s,'"')).join(", "),"."))}}function o_(i){return i&&i[0]==="?"}function a_(i){return i&&i[0]==="?"?i.slice(1):i}function u_(i,t){if(yc(i)&&wc(i,t))return i[t];throw typeof i[t]=="function"&&f_(i,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function l_(i,t,e){if(yc(i)&&wc(i,t))return i[t]=e,e;throw new Error('No access to property "'+t+'"')}function c_(i,t){return t in i}function wc(i,t){return!i||typeof i!="object"?!1:ts(h_,t)?!0:!(t in Object.prototype||t in Function.prototype)}function f_(i,t){return i==null||typeof i[t]!="function"||ts(i,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(i)?!1:ts(d_,t)?!0:!(t in Object.prototype||t in Function.prototype)}function yc(i){return typeof i=="object"&&i&&i.constructor===Object}var h_={length:!0,name:!0},d_={toString:!0,valueOf:!0,toLocaleString:!0};class p_{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return u_(this.wrappedObject,t)}set(t,e){return l_(this.wrappedObject,t,e),this}has(t){return c_(this.wrappedObject,t)}entries(){return __(this.keys(),t=>[t,this.get(t)])}forEach(t){for(var e of this.keys())t(this.get(e),e,this)}delete(t){delete this.wrappedObject[t]}clear(){for(var t of this.keys())this.delete(t)}get size(){return Object.keys(this.wrappedObject).length}}function __(i,t){return{next:()=>{var e=i.next();return e.done?e:{value:t(e.value),done:!1}}}}function m_(i){return i?i instanceof Map||i instanceof p_||typeof i.set=="function"&&typeof i.get=="function"&&typeof i.keys=="function"&&typeof i.has=="function":!1}var Dc=function(){return Dc=ec.create,ec},g_=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],v_=mt("typed",g_,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:s}=t,a=Dc();return a.clear(),a.addTypes([{name:"number",test:_e},{name:"Complex",test:Kl},{name:"BigNumber",test:Oe},{name:"Fraction",test:Gl},{name:"Unit",test:Hl},{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:kp},{name:"Array",test:Ae},{name:"Matrix",test:we},{name:"DenseMatrix",test:dp},{name:"SparseMatrix",test:pp},{name:"Range",test:_p},{name:"Index",test:va},{name:"boolean",test:mp},{name:"ResultSet",test:gp},{name:"Help",test:vp},{name:"function",test:wp},{name:"Date",test:yp},{name:"RegExp",test:Dp},{name:"null",test:bp},{name:"undefined",test:xp},{name:"AccessorNode",test:Ep},{name:"ArrayNode",test:Ap},{name:"AssignmentNode",test:Cp},{name:"BlockNode",test:Fp},{name:"ConditionalNode",test:Mp},{name:"ConstantNode",test:Np},{name:"FunctionNode",test:Op},{name:"FunctionAssignmentNode",test:Sp},{name:"IndexNode",test:Bp},{name:"Node",test:Ip},{name:"ObjectNode",test:Tp},{name:"OperatorNode",test:$p},{name:"ParenthesisNode",test:Lp},{name:"RangeNode",test:Rp},{name:"RelationalNode",test:Pp},{name:"SymbolNode",test:zp},{name:"Map",test:m_},{name:"Object",test:wa}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(e||Ma(c),Kp(c)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+c+"). Use function bignumber(x) to convert to BigNumber.");return new e(c)}},{from:"number",to:"Complex",convert:function(c){return r||Ls(c),new r(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return r||Ls(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||Ls(c),new r(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){s||Na(c);var f=new s(c);if(f.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 f}},{from:"string",to:"number",convert:function(c){var f=Number(c);if(isNaN(f))throw new Error('Cannot convert "'+c+'" to a number');return f}},{from:"string",to:"BigNumber",convert:function(c){e||Ma(c);try{return new e(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(c){s||Na(c);try{return new s(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){r||Ls(c);try{return new r(c)}catch{throw new Error('Cannot convert "'+c+'" to Complex')}}},{from:"boolean",to:"number",convert:function(c){return+c}},{from:"boolean",to:"BigNumber",convert:function(c){return e||Ma(c),new e(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return s||Na(c),new s(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return n||w_(),new n(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),a.onMismatch=(l,c,f)=>{var d=a.createError(l,c,f);if(["wrongType","mismatch"].includes(d.data.category)&&c.length===1&&Qi(c[0])&&f.some(p=>!p.params.includes(","))){var h=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw h.data=d.data,h}throw d},a.onMismatch=(l,c,f)=>{var d=a.createError(l,c,f);if(["wrongType","mismatch"].includes(d.data.category)&&c.length===1&&Qi(c[0])&&f.some(p=>!p.params.includes(","))){var h=new TypeError("Function '".concat(l,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(l,")'."));throw h.data=d.data,h}throw d},a});function Ma(i){throw new Error("Cannot convert value ".concat(i," into a BigNumber: no class 'BigNumber' provided"))}function Ls(i){throw new Error("Cannot convert value ".concat(i," into a Complex number: no class 'Complex' provided"))}function w_(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function Na(i){throw new Error("Cannot convert value ".concat(i," into a Fraction, no class 'Fraction' provided."))}/*!
34
+ `);return Object.freeze(Zl)};Os(gr,Zl,{MATRIX_OPTIONS:Wp,NUMBER_OPTIONS:jp});function Xl(){return!0}function Sr(){return!1}function wi(){}const Ql="Argument is not a typed-function.";function tc(){function i(R){return typeof R=="object"&&R!==null&&R.constructor===Object}const t=[{name:"number",test:function(R){return typeof R=="number"}},{name:"string",test:function(R){return typeof R=="string"}},{name:"boolean",test:function(R){return typeof R=="boolean"}},{name:"Function",test:function(R){return typeof R=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(R){return R instanceof Date}},{name:"RegExp",test:function(R){return R instanceof RegExp}},{name:"Object",test:i},{name:"null",test:function(R){return R===null}},{name:"undefined",test:function(R){return R===void 0}}],e={name:"any",test:Xl,isAny:!0};let r,n,s=0,a={createCount:0};function l(R){const Y=r.get(R);if(Y)return Y;let G='Unknown type "'+R+'"';const nt=R.toLowerCase();let st;for(st of n)if(st.toLowerCase()===nt){G+='. Did you mean "'+st+'" ?';break}throw new TypeError(G)}function c(R){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const G=Y?l(Y).index:n.length,nt=[];for(let rt=0;rt<R.length;++rt){if(!R[rt]||typeof R[rt].name!="string"||typeof R[rt].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const ft=R[rt].name;if(r.has(ft))throw new TypeError('Duplicate type name "'+ft+'"');nt.push(ft),r.set(ft,{name:ft,test:R[rt].test,isAny:R[rt].isAny,index:G+rt,conversionsTo:[]})}const st=n.slice(G);n=n.slice(0,G).concat(nt).concat(st);for(let rt=G+nt.length;rt<n.length;++rt)r.get(n[rt]).index=rt}function h(){r=new Map,n=[],s=0,c([e],!1)}h(),c(t);function d(){let R;for(R of n)r.get(R).conversionsTo=[];s=0}function f(R){const Y=n.filter(G=>{const nt=r.get(G);return!nt.isAny&&nt.test(R)});return Y.length?Y:["any"]}function p(R){return R&&typeof R=="function"&&"_typedFunctionData"in R}function g(R,Y,G){if(!p(R))throw new TypeError(Ql);const nt=G&&G.exact,st=Array.isArray(Y)?Y.join(","):Y,rt=M(st),ft=y(rt);if(!nt||ft in R.signatures){const Xt=R._typedFunctionData.signatureMap.get(ft);if(Xt)return Xt}const ut=rt.length;let ht;if(nt){ht=[];let Xt;for(Xt in R.signatures)ht.push(R._typedFunctionData.signatureMap.get(Xt))}else ht=R._typedFunctionData.signatures;for(let Xt=0;Xt<ut;++Xt){const ne=rt[Xt],xe=[];let Ve;for(Ve of ht){const qe=S(Ve.params,Xt);if(!(!qe||ne.restParam&&!qe.restParam)){if(!qe.hasAny){const Dr=b(qe);if(ne.types.some(br=>!Dr.has(br.name)))continue}xe.push(Ve)}}if(ht=xe,ht.length===0)break}let at;for(at of ht)if(at.params.length<=ut)return at;throw new TypeError("Signature not found (signature: "+(R.name||"unnamed")+"("+y(rt,", ")+"))")}function w(R,Y,G){return g(R,Y,G).implementation}function m(R,Y){const G=l(Y);if(G.test(R))return R;const nt=G.conversionsTo;if(nt.length===0)throw new Error("There are no conversions to "+Y+" defined.");for(let st=0;st<nt.length;st++)if(l(nt[st].from).test(R))return nt[st].convert(R);throw new Error("Cannot convert "+R+" to "+Y)}function y(R){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return R.map(G=>G.name).join(Y)}function v(R){const Y=R.indexOf("...")===0,nt=(Y?R.length>3?R.slice(3):"any":R).split("|").map(ut=>l(ut.trim()));let st=!1,rt=Y?"...":"";return{types:nt.map(function(ut){return st=ut.isAny||st,rt+=ut.name+"|",{name:ut.name,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:null,conversionIndex:-1}}),name:rt.slice(0,-1),hasAny:st,hasConversion:!1,restParam:Y}}function x(R){const Y=R.types.map(ft=>ft.name),G=K(Y);let nt=R.hasAny,st=R.name;const rt=G.map(function(ft){const ut=l(ft.from);return nt=ut.isAny||nt,st+="|"+ft.from,{name:ft.from,typeIndex:ut.index,test:ut.test,isAny:ut.isAny,conversion:ft,conversionIndex:ft.index}});return{types:R.types.concat(rt),name:st,hasAny:nt,hasConversion:rt.length>0,restParam:R.restParam}}function b(R){return R.typeSet||(R.typeSet=new Set,R.types.forEach(Y=>R.typeSet.add(Y.name))),R.typeSet}function M(R){const Y=[];if(typeof R!="string")throw new TypeError("Signatures must be strings");const G=R.trim();if(G==="")return Y;const nt=G.split(",");for(let st=0;st<nt.length;++st){const rt=v(nt[st].trim());if(rt.restParam&&st!==nt.length-1)throw new SyntaxError('Unexpected rest parameter "'+nt[st]+'": only allowed for the last parameter');if(rt.types.length===0)return null;Y.push(rt)}return Y}function E(R){const Y=It(R);return Y?Y.restParam:!1}function F(R){if(!R||R.types.length===0)return Xl;if(R.types.length===1)return l(R.types[0].name).test;if(R.types.length===2){const Y=l(R.types[0].name).test,G=l(R.types[1].name).test;return function(st){return Y(st)||G(st)}}else{const Y=R.types.map(function(G){return l(G.name).test});return function(nt){for(let st=0;st<Y.length;st++)if(Y[st](nt))return!0;return!1}}}function N(R){let Y,G,nt;if(E(R)){Y=ue(R).map(F);const st=Y.length,rt=F(It(R)),ft=function(ut){for(let ht=st;ht<ut.length;ht++)if(!rt(ut[ht]))return!1;return!0};return function(ht){for(let at=0;at<Y.length;at++)if(!Y[at](ht[at]))return!1;return ft(ht)&&ht.length>=st+1}}else return R.length===0?function(rt){return rt.length===0}:R.length===1?(G=F(R[0]),function(rt){return G(rt[0])&&rt.length===1}):R.length===2?(G=F(R[0]),nt=F(R[1]),function(rt){return G(rt[0])&&nt(rt[1])&&rt.length===2}):(Y=R.map(F),function(rt){for(let ft=0;ft<Y.length;ft++)if(!Y[ft](rt[ft]))return!1;return rt.length===Y.length})}function S(R,Y){return Y<R.length?R[Y]:E(R)?It(R):null}function T(R,Y){const G=S(R,Y);return G?b(G):new Set}function A(R){return R.conversion===null||R.conversion===void 0}function O(R,Y){const G=new Set;return R.forEach(nt=>{const st=T(nt.params,Y);let rt;for(rt of st)G.add(rt)}),G.has("any")?["any"]:Array.from(G)}function L(R,Y,G){let nt,st;const rt=R||"unnamed";let ft=G,ut;for(ut=0;ut<Y.length;ut++){const ne=[];if(ft.forEach(xe=>{const Ve=S(xe.params,ut),qe=F(Ve);(ut<xe.params.length||E(xe.params))&&qe(Y[ut])&&ne.push(xe)}),ne.length===0){if(st=O(ft,ut),st.length>0){const xe=f(Y[ut]);return nt=new TypeError("Unexpected type of argument in function "+rt+" (expected: "+st.join(" or ")+", actual: "+xe.join(" | ")+", index: "+ut+")"),nt.data={category:"wrongType",fn:rt,index:ut,actual:xe,expected:st},nt}}else ft=ne}const ht=ft.map(function(ne){return E(ne.params)?1/0:ne.params.length});if(Y.length<Math.min.apply(null,ht))return st=O(ft,ut),nt=new TypeError("Too few arguments in function "+rt+" (expected: "+st.join(" or ")+", index: "+Y.length+")"),nt.data={category:"tooFewArgs",fn:rt,index:Y.length,expected:st},nt;const at=Math.max.apply(null,ht);if(Y.length>at)return nt=new TypeError("Too many arguments in function "+rt+" (expected: "+at+", actual: "+Y.length+")"),nt.data={category:"tooManyArgs",fn:rt,index:Y.length,expectedLength:at},nt;const Xt=[];for(let ne=0;ne<Y.length;++ne)Xt.push(f(Y[ne]).join("|"));return nt=new TypeError('Arguments of type "'+Xt.join(", ")+'" do not match any of the defined signatures of function '+rt+"."),nt.data={category:"mismatch",actual:Xt},nt}function q(R){let Y=n.length+1;for(let G=0;G<R.types.length;G++)A(R.types[G])&&(Y=Math.min(Y,R.types[G].typeIndex));return Y}function U(R){let Y=s+1;for(let G=0;G<R.types.length;G++)A(R.types[G])||(Y=Math.min(Y,R.types[G].conversionIndex));return Y}function W(R,Y){if(R.hasAny){if(!Y.hasAny)return 1}else if(Y.hasAny)return-1;if(R.restParam){if(!Y.restParam)return 1}else if(Y.restParam)return-1;if(R.hasConversion){if(!Y.hasConversion)return 1}else if(Y.hasConversion)return-1;const G=q(R)-q(Y);if(G<0)return-1;if(G>0)return 1;const nt=U(R)-U(Y);return nt<0?-1:nt>0?1:0}function z(R,Y){const G=R.params,nt=Y.params,st=It(G),rt=It(nt),ft=E(G),ut=E(nt);if(ft&&st.hasAny){if(!ut||!rt.hasAny)return 1}else if(ut&&rt.hasAny)return-1;let ht=0,at=0,Xt;for(Xt of G)Xt.hasAny&&++ht,Xt.hasConversion&&++at;let ne=0,xe=0;for(Xt of nt)Xt.hasAny&&++ne,Xt.hasConversion&&++xe;if(ht!==ne)return ht-ne;if(ft&&st.hasConversion){if(!ut||!rt.hasConversion)return 1}else if(ut&&rt.hasConversion)return-1;if(at!==xe)return at-xe;if(ft){if(!ut)return 1}else if(ut)return-1;const Ve=(G.length-nt.length)*(ft?-1:1);if(Ve!==0)return Ve;const qe=[];let Dr=0;for(let Ln=0;Ln<G.length;++Ln){const oi=W(G[Ln],nt[Ln]);qe.push(oi),Dr+=oi}if(Dr!==0)return Dr;let br;for(br of qe)if(br!==0)return br;return 0}function K(R){if(R.length===0)return[];const Y=R.map(l);R.length>1&&Y.sort((st,rt)=>st.index-rt.index);let G=Y[0].conversionsTo;if(R.length===1)return G;G=G.concat([]);const nt=new Set(R);for(let st=1;st<Y.length;++st){let rt;for(rt of Y[st].conversionsTo)nt.has(rt.from)||(G.push(rt),nt.add(rt.from))}return G}function Z(R,Y){let G=Y;if(R.some(st=>st.hasConversion)){const st=E(R),rt=R.map(X);G=function(){const ut=[],ht=st?arguments.length-1:arguments.length;for(let at=0;at<ht;at++)ut[at]=rt[at](arguments[at]);return st&&(ut[ht]=arguments[ht].map(rt[ht])),Y.apply(this,ut)}}let nt=G;if(E(R)){const st=R.length-1;nt=function(){return G.apply(this,Nt(arguments,0,st).concat([Nt(arguments,st)]))}}return nt}function X(R){let Y,G,nt,st;const rt=[],ft=[];switch(R.types.forEach(function(ut){ut.conversion&&(rt.push(l(ut.conversion.from).test),ft.push(ut.conversion.convert))}),ft.length){case 0:return function(ht){return ht};case 1:return Y=rt[0],nt=ft[0],function(ht){return Y(ht)?nt(ht):ht};case 2:return Y=rt[0],G=rt[1],nt=ft[0],st=ft[1],function(ht){return Y(ht)?nt(ht):G(ht)?st(ht):ht};default:return function(ht){for(let at=0;at<ft.length;at++)if(rt[at](ht))return ft[at](ht);return ht}}}function Q(R){function Y(G,nt,st){if(nt<G.length){const rt=G[nt];let ft=[];if(rt.restParam){const ut=rt.types.filter(A);ut.length<rt.types.length&&ft.push({types:ut,name:"..."+ut.map(ht=>ht.name).join("|"),hasAny:ut.some(ht=>ht.isAny),hasConversion:!1,restParam:!0}),ft.push(rt)}else ft=rt.types.map(function(ut){return{types:[ut],name:ut.name,hasAny:ut.isAny,hasConversion:ut.conversion,restParam:!1}});return re(ft,function(ut){return Y(G,nt+1,st.concat([ut]))})}else return[st]}return Y(R,0,[])}function ct(R,Y){const G=Math.max(R.length,Y.length);for(let ut=0;ut<G;ut++){const ht=T(R,ut),at=T(Y,ut);let Xt=!1,ne;for(ne of at)if(ht.has(ne)){Xt=!0;break}if(!Xt)return!1}const nt=R.length,st=Y.length,rt=E(R),ft=E(Y);return rt?ft?nt===st:st>=nt:ft?nt>=st:nt===st}function vt(R){return R.map(Y=>ke(Y)?Le(Y.referToSelf.callback):wr(Y)?Jt(Y.referTo.references,Y.referTo.callback):Y)}function lt(R,Y,G){const nt=[];let st;for(st of R){let rt=G[st];if(typeof rt!="number")throw new TypeError('No definition for referenced signature "'+st+'"');if(rt=Y[rt],typeof rt!="function")return!1;nt.push(rt)}return nt}function yt(R,Y,G){const nt=vt(R),st=new Array(nt.length).fill(!1);let rt=!0;for(;rt;){rt=!1;let ft=!0;for(let ut=0;ut<nt.length;++ut){if(st[ut])continue;const ht=nt[ut];if(ke(ht))nt[ut]=ht.referToSelf.callback(G),nt[ut].referToSelf=ht.referToSelf,st[ut]=!0,ft=!1;else if(wr(ht)){const at=lt(ht.referTo.references,nt,Y);at?(nt[ut]=ht.referTo.callback.apply(this,at),nt[ut].referTo=ht.referTo,st[ut]=!0,ft=!1):rt=!0}}if(ft&&rt)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return nt}function bt(R){const Y=/\bthis(\(|\.signatures\b)/;Object.keys(R).forEach(G=>{const nt=R[G];if(Y.test(nt.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function Ot(R,Y){if(a.createCount++,Object.keys(Y).length===0)throw new SyntaxError("No signatures provided");a.warnAgainstDeprecatedThis&&bt(Y);const G=[],nt=[],st={},rt=[];let ft;for(ft in Y){if(!Object.prototype.hasOwnProperty.call(Y,ft))continue;const Zt=M(ft);if(!Zt)continue;G.forEach(function(Rn){if(ct(Rn,Zt))throw new TypeError('Conflicting signatures "'+y(Rn)+'" and "'+y(Zt)+'".')}),G.push(Zt);const er=nt.length;nt.push(Y[ft]);const Eu=Zt.map(x);let Ri;for(Ri of Q(Eu)){const Rn=y(Ri);rt.push({params:Ri,name:Rn,fn:er}),Ri.every(So=>!So.hasConversion)&&(st[Rn]=er)}}rt.sort(z);const ut=yt(nt,st,ai);let ht;for(ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(st[ht]=ut[st[ht]]);const at=[],Xt=new Map;for(ht of rt)Xt.has(ht.name)||(ht.fn=ut[ht.fn],at.push(ht),Xt.set(ht.name,ht));const ne=at[0]&&at[0].params.length<=2&&!E(at[0].params),xe=at[1]&&at[1].params.length<=2&&!E(at[1].params),Ve=at[2]&&at[2].params.length<=2&&!E(at[2].params),qe=at[3]&&at[3].params.length<=2&&!E(at[3].params),Dr=at[4]&&at[4].params.length<=2&&!E(at[4].params),br=at[5]&&at[5].params.length<=2&&!E(at[5].params),Ln=ne&&xe&&Ve&&qe&&Dr&&br;for(let Zt=0;Zt<at.length;++Zt)at[Zt].test=N(at[Zt].params);const oi=ne?F(at[0].params[0]):Sr,Fo=xe?F(at[1].params[0]):Sr,ru=Ve?F(at[2].params[0]):Sr,nu=qe?F(at[3].params[0]):Sr,iu=Dr?F(at[4].params[0]):Sr,su=br?F(at[5].params[0]):Sr,Mo=ne?F(at[0].params[1]):Sr,ou=xe?F(at[1].params[1]):Sr,au=Ve?F(at[2].params[1]):Sr,uu=qe?F(at[3].params[1]):Sr,ls=Dr?F(at[4].params[1]):Sr,lu=br?F(at[5].params[1]):Sr;for(let Zt=0;Zt<at.length;++Zt)at[Zt].implementation=Z(at[Zt].params,at[Zt].fn);const cs=ne?at[0].implementation:wi,cu=xe?at[1].implementation:wi,fu=Ve?at[2].implementation:wi,hu=qe?at[3].implementation:wi,du=Dr?at[4].implementation:wi,pu=br?at[5].implementation:wi,_u=ne?at[0].params.length:-1,mu=xe?at[1].params.length:-1,gu=Ve?at[2].params.length:-1,No=qe?at[3].params.length:-1,vu=Dr?at[4].params.length:-1,wu=br?at[5].params.length:-1,yu=Ln?6:0,Du=at.length,bu=at.map(Zt=>Zt.test),xu=at.map(Zt=>Zt.implementation),Li=function(){for(let er=yu;er<Du;er++)if(bu[er](arguments))return xu[er].apply(this,arguments);return a.onMismatch(R,arguments,at)};function ai(Zt,er){return arguments.length===_u&&oi(Zt)&&Mo(er)?cs.apply(this,arguments):arguments.length===mu&&Fo(Zt)&&ou(er)?cu.apply(this,arguments):arguments.length===gu&&ru(Zt)&&au(er)?fu.apply(this,arguments):arguments.length===No&&nu(Zt)&&uu(er)?hu.apply(this,arguments):arguments.length===vu&&iu(Zt)&&ls(er)?du.apply(this,arguments):arguments.length===wu&&su(Zt)&&lu(er)?pu.apply(this,arguments):Li.apply(this,arguments)}try{Object.defineProperty(ai,"name",{value:R})}catch{}return ai.signatures=st,ai._typedFunctionData={signatures:at,signatureMap:Xt},ai}function xt(R,Y,G){throw L(R,Y,G)}function ue(R){return Nt(R,0,R.length-1)}function It(R){return R[R.length-1]}function Nt(R,Y,G){return Array.prototype.slice.call(R,Y,G)}function fe(R,Y){for(let G=0;G<R.length;G++)if(Y(R[G]))return R[G]}function re(R,Y){return Array.prototype.concat.apply([],R.map(Y))}function qt(){const R=ue(arguments).map(G=>y(M(G))),Y=It(arguments);if(typeof Y!="function")throw new TypeError("Callback function expected as last argument");return Jt(R,Y)}function Jt(R,Y){return{referTo:{references:R,callback:Y}}}function Le(R){if(typeof R!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:R}}}function wr(R){return R&&typeof R.referTo=="object"&&Array.isArray(R.referTo.references)&&typeof R.referTo.callback=="function"}function ke(R){return R&&typeof R.referToSelf=="object"&&typeof R.referToSelf.callback=="function"}function _n(R,Y){if(!R)return Y;if(Y&&Y!==R){const G=new Error("Function names do not match (expected: "+R+", actual: "+Y+")");throw G.data={actual:Y,expected:R},G}return R}function Tn(R){let Y;for(const G in R)Object.prototype.hasOwnProperty.call(R,G)&&(p(R[G])||typeof R[G].signature=="string")&&(Y=_n(Y,R[G].name));return Y}function mn(R,Y){let G;for(G in Y)if(Object.prototype.hasOwnProperty.call(Y,G)){if(G in R&&Y[G]!==R[G]){const nt=new Error('Signature "'+G+'" is defined twice');throw nt.data={signature:G,sourceFunction:Y[G],destFunction:R[G]},nt}R[G]=Y[G]}}const yr=a;a=function(R){const Y=typeof R=="string",G=Y?1:0;let nt=Y?R:"";const st={};for(let rt=G;rt<arguments.length;++rt){const ft=arguments[rt];let ut={},ht;if(typeof ft=="function"?(ht=ft.name,typeof ft.signature=="string"?ut[ft.signature]=ft:p(ft)&&(ut=ft.signatures)):i(ft)&&(ut=ft,Y||(ht=Tn(ft))),Object.keys(ut).length===0){const at=new TypeError("Argument to 'typed' at index "+rt+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw at.data={index:rt,argument:ft},at}Y||(nt=_n(nt,ht)),mn(st,ut)}return Ot(nt||"",st)},a.create=tc,a.createCount=yr.createCount,a.onMismatch=xt,a.throwMismatchError=xt,a.createError=L,a.clear=h,a.clearConversions=d,a.addTypes=c,a._findType=l,a.referTo=qt,a.referToSelf=Le,a.convert=m,a.findSignature=g,a.find=w,a.isTypedFunction=p,a.warnAgainstDeprecatedThis=!0,a.addType=function(R,Y){let G="any";Y!==!1&&r.has("Object")&&(G="Object"),a.addTypes([R],G)};function $n(R){if(!R||typeof R.from!="string"||typeof R.to!="string"||typeof R.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(R.to===R.from)throw new SyntaxError('Illegal to define conversion from "'+R.from+'" to itself.')}return a.addConversion=function(R){$n(R);const Y=l(R.to);if(Y.conversionsTo.every(function(G){return G.from!==R.from}))Y.conversionsTo.push({from:R.from,convert:R.convert,index:s++});else throw new Error('There is already a conversion from "'+R.from+'" to "'+Y.name+'"')},a.addConversions=function(R){R.forEach(a.addConversion)},a.removeConversion=function(R){$n(R);const Y=l(R.to),G=fe(Y.conversionsTo,st=>st.from===R.from);if(!G)throw new Error("Attempt to remove nonexistent conversion from "+R.from+" to "+R.to);if(G.convert!==R.convert)throw new Error("Conversion to remove does not match existing conversion");const nt=Y.conversionsTo.indexOf(G);Y.conversionsTo.splice(nt,1)},a.resolve=function(R,Y){if(!p(R))throw new TypeError(Ql);const G=R._typedFunctionData.signatures;for(let nt=0;nt<G.length;++nt)if(G[nt].test(Y))return G[nt];return null},a}var ec=tc();function be(i){return typeof i=="boolean"?!0:isFinite(i)?i===Math.round(i):!1}function ya(i,t,e){var r={2:"0b",8:"0o",16:"0x"},n=r[t],s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!be(e))throw new Error("size must be an integer");if(i>2**(e-1)-1||i<-(2**(e-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!be(i))throw new Error("Value must be an integer");i<0&&(i=i+2**e),s="i".concat(e)}var a="";return i<0&&(i=-i,a="-"),"".concat(a).concat(n).concat(i.toString(t)).concat(s)}function Da(i,t){if(typeof t=="function")return t(i);if(i===1/0)return"Infinity";if(i===-1/0)return"-Infinity";if(isNaN(i))return"NaN";var{notation:e,precision:r,wordSize:n}=rc(t);switch(e){case"fixed":return Yp(i,r);case"exponential":return nc(i,r);case"engineering":return Vp(i,r);case"bin":return ya(i,2,n);case"oct":return ya(i,8,n);case"hex":return ya(i,16,n);case"auto":return Zp(i,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],a=arguments[4];return s!=="."?s+a:a});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function rc(i){var t="auto",e,r;if(i!==void 0)if(_e(i))e=i;else if(Oe(i))e=i.toNumber();else if(wa(i))i.precision!==void 0&&(e=ic(i.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),i.wordSize!==void 0&&(r=ic(i.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),i.notation&&(t=i.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:t,precision:e,wordSize:r}}function Bs(i){var t=String(i).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+i);var e=t[1],r=t[2],n=parseFloat(t[4]||"0"),s=r.indexOf(".");n+=s!==-1?s-1:r.length-1;var a=r.replace(".","").replace(/^0*/,function(l){return n-=l.length,""}).replace(/0*$/,"").split("").map(function(l){return parseInt(l)});return a.length===0&&(a.push(0),n++),{sign:e,coefficients:a,exponent:n}}function Vp(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Bs(i),r=Is(e,t),n=r.exponent,s=r.coefficients,a=n%3===0?n:n<0?n-3-n%3:n-n%3;if(_e(t))for(;t>s.length||n-a+1>s.length;)s.push(0);else for(var l=Math.abs(n-a)-(s.length-1),c=0;c<l;c++)s.push(0);for(var h=Math.abs(n-a),d=1;h>0;)d++,h--;var f=s.slice(d).join(""),p=_e(t)&&f.length||f.match(/[1-9]/)?"."+f:"",g=s.slice(0,d).join("")+p+"e"+(n>=0?"+":"")+a.toString();return r.sign+g}function Yp(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Bs(i),r=typeof t=="number"?Is(e,e.exponent+1+t):e,n=r.coefficients,s=r.exponent+1,a=s+(t||0);return n.length<a&&(n=n.concat(yi(a-n.length))),s<0&&(n=yi(-s+1).concat(n),s=1),s<n.length&&n.splice(s,0,s===0?"0.":"."),r.sign+n.join("")}function nc(i,t){if(isNaN(i)||!isFinite(i))return String(i);var e=Bs(i),r=t?Is(e,t):e,n=r.coefficients,s=r.exponent;n.length<t&&(n=n.concat(yi(t-n.length)));var a=n.shift();return r.sign+a+(n.length>0?"."+n.join(""):"")+"e"+(s>=0?"+":"")+s}function Zp(i,t,e){if(isNaN(i)||!isFinite(i))return String(i);var r=sc(e==null?void 0:e.lowerExp,-3),n=sc(e==null?void 0:e.upperExp,5),s=Bs(i),a=t?Is(s,t):s;if(a.exponent<r||a.exponent>=n)return nc(i,t);var l=a.coefficients,c=a.exponent;l.length<t&&(l=l.concat(yi(t-l.length))),l=l.concat(yi(c-l.length+1+(l.length<t?t-l.length:0))),l=yi(-c).concat(l);var h=c>0?c:0;return h<l.length-1&&l.splice(h+1,0,"."),a.sign+l.join("")}function Is(i,t){for(var e={sign:i.sign,coefficients:i.coefficients,exponent:i.exponent},r=e.coefficients;t<=0;)r.unshift(0),e.exponent++,t++;if(r.length>t){var n=r.splice(t,r.length-t);if(n[0]>=5){var s=t-1;for(r[s]++;r[s]===10;)r.pop(),s===0&&(r.unshift(0),e.exponent++,s++),s--,r[s]++}}return e}function yi(i){for(var t=[],e=0;e<i;e++)t.push(0);return t}function Kp(i){return i.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Gp=Number.EPSILON||2220446049250313e-31;function Jn(i,t,e){if(e==null)return i===t;if(i===t)return!0;if(isNaN(i)||isNaN(t))return!1;if(isFinite(i)&&isFinite(t)){var r=Math.abs(i-t);return r<=Gp?!0:r<=Math.max(Math.abs(i),Math.abs(t))*e}return!1}function ic(i,t){if(_e(i))return i;if(Oe(i))return i.toNumber();t()}function sc(i,t){return _e(i)?i:Oe(i)?i.toNumber():t}function ba(i,t,e){var r=i.constructor,n=new r(2),s="";if(e){if(e<1)throw new Error("size must be in greater than 0");if(!be(e))throw new Error("size must be an integer");if(i.greaterThan(n.pow(e-1).sub(1))||i.lessThan(n.pow(e-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(e-1,", 2^").concat(e-1,"-1]"));if(!i.isInteger())throw new Error("Value must be an integer");i.lessThan(0)&&(i=i.add(n.pow(e))),s="i".concat(e)}switch(t){case 2:return"".concat(i.toBinary()).concat(s);case 8:return"".concat(i.toOctal()).concat(s);case 16:return"".concat(i.toHexadecimal()).concat(s);default:throw new Error("Base ".concat(t," not supported "))}}function Hp(i,t){if(typeof t=="function")return t(i);if(!i.isFinite())return i.isNaN()?"NaN":i.gt(0)?"Infinity":"-Infinity";var{notation:e,precision:r,wordSize:n}=rc(t);switch(e){case"fixed":return Xp(i,r);case"exponential":return oc(i,r);case"engineering":return Jp(i,r);case"bin":return ba(i,2,n);case"oct":return ba(i,8,n);case"hex":return ba(i,16,n);case"auto":{var s=ac(t==null?void 0:t.lowerExp,-3),a=ac(t==null?void 0:t.upperExp,5);if(i.isZero())return"0";var l,c=i.toSignificantDigits(r),h=c.e;return h>=s&&h<a?l=c.toFixed():l=oc(i,r),l.replace(/((\.\d*?)(0+))($|e)/,function(){var d=arguments[2],f=arguments[4];return d!=="."?d+f:f})}default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function Jp(i,t){var e=i.e,r=e%3===0?e:e<0?e-3-e%3:e-e%3,n=i.mul(Math.pow(10,-r)),s=n.toPrecision(t);if(s.indexOf("e")!==-1){var a=i.constructor;s=new a(s).toFixed()}return s+"e"+(e>=0?"+":"")+r.toString()}function oc(i,t){return t!==void 0?i.toExponential(t-1):i.toExponential()}function Xp(i,t){return i.toFixed(t)}function ac(i,t){return _e(i)?i:Oe(i)?i.toNumber():t}function he(i,t){var e=Qp(i,t);return t&&typeof t=="object"&&"truncate"in t&&e.length>t.truncate?e.substring(0,t.truncate-3)+"...":e}function Qp(i,t){if(typeof i=="number")return Da(i,t);if(Oe(i))return Hp(i,t);if(t_(i))return!t||t.fraction!=="decimal"?i.s*i.n+"/"+i.d:i.toString();if(Array.isArray(i))return cc(i,t);if(en(i))return uc(i);if(typeof i=="function")return i.syntax?String(i.syntax):"function";if(i&&typeof i=="object"){if(typeof i.format=="function")return i.format(t);if(i&&i.toString(t)!=={}.toString())return i.toString(t);var e=Object.keys(i).map(r=>uc(r)+": "+he(i[r],t));return"{"+e.join(", ")+"}"}return String(i)}function uc(i){for(var t=String(i),e="",r=0;r<t.length;){var n=t.charAt(r);e+=n in lc?lc[n]:n,r++}return'"'+e+'"'}var lc={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function cc(i,t){if(Array.isArray(i)){for(var e="[",r=i.length,n=0;n<r;n++)n!==0&&(e+=", "),e+=cc(i[n],t);return e+="]",e}else return he(i,t)}function t_(i){return i&&typeof i=="object"&&typeof i.s=="number"&&typeof i.n=="number"&&typeof i.d=="number"||!1}function Ht(i,t,e){if(!(this instanceof Ht))throw new SyntaxError("Constructor must be called with the new operator");this.actual=i,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(i)?"["+i.join(", ")+"]":i)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=new Error().stack}Ht.prototype=new RangeError,Ht.prototype.constructor=RangeError,Ht.prototype.name="DimensionError",Ht.prototype.isDimensionError=!0;function Fn(i,t,e){if(!(this instanceof Fn))throw new SyntaxError("Constructor must be called with the new operator");this.index=i,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=e),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}Fn.prototype=new RangeError,Fn.prototype.constructor=RangeError,Fn.prototype.name="IndexError",Fn.prototype.isIndexError=!0;function Te(i){for(var t=[];Array.isArray(i);)t.push(i.length),i=i[0];return t}function fc(i,t,e){var r,n=i.length;if(n!==t[e])throw new Ht(n,t[e]);if(e<t.length-1){var s=e+1;for(r=0;r<n;r++){var a=i[r];if(!Array.isArray(a))throw new Ht(t.length-1,t.length,"<");fc(i[r],t,s)}}else for(r=0;r<n;r++)if(Array.isArray(i[r]))throw new Ht(t.length+1,t.length,">")}function hc(i,t){var e=t.length===0;if(e){if(Array.isArray(i))throw new Ht(i.length,0)}else fc(i,t,0)}function Ce(i,t){if(i!==void 0){if(!_e(i)||!be(i))throw new TypeError("Index must be an integer (value: "+i+")");if(i<0||typeof t=="number"&&i>=t)throw new Fn(i,t)}}function xa(i,t,e){if(!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Error("Resizing to scalar is not supported");t.forEach(function(n){if(!_e(n)||!be(n)||n<0)throw new TypeError("Invalid size, must contain positive integers (size: "+he(t)+")")}),(_e(i)||Oe(i))&&(i=[i]);var r=e!==void 0?e:0;return Ea(i,t,0,r),i}function Ea(i,t,e,r){var n,s,a=i.length,l=t[e],c=Math.min(a,l);if(i.length=l,e<t.length-1){var h=e+1;for(n=0;n<c;n++)s=i[n],Array.isArray(s)||(s=[s],i[n]=s),Ea(s,t,h,r);for(n=c;n<l;n++)s=[],i[n]=s,Ea(s,t,h,r)}else{for(n=0;n<c;n++)for(;Array.isArray(i[n]);)i[n]=i[n][0];for(n=c;n<l;n++)i[n]=r}}function Aa(i,t){var e=Fa(i),r=e.length;if(!Array.isArray(i)||!Array.isArray(t))throw new TypeError("Array expected");if(t.length===0)throw new Ht(0,r,"!=");t=Ca(t,r);var n=dc(t);if(r!==n)throw new Ht(n,r,"!=");try{return e_(e,t)}catch(s){throw s instanceof Ht?new Ht(n,r,"!="):s}}function Ca(i,t){var e=dc(i),r=i.slice(),n=-1,s=i.indexOf(n),a=i.indexOf(n,s+1)>=0;if(a)throw new Error("More than one wildcard in sizes");var l=s>=0,c=t%e===0;if(l)if(c)r[s]=-t/e;else throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-e);return r}function dc(i){return i.reduce((t,e)=>t*e,1)}function e_(i,t){for(var e=i,r,n=t.length-1;n>0;n--){var s=t[n];r=[];for(var a=e.length/s,l=0;l<a;l++)r.push(e.slice(l*s,(l+1)*s));e=r}return e}function pc(i,t,e,r){var n=r||Te(i);if(e)for(var s=0;s<e;s++)i=[i],n.unshift(1);for(i=_c(i,t,0);n.length<t;)n.push(1);return i}function _c(i,t,e){var r,n;if(Array.isArray(i)){var s=e+1;for(r=0,n=i.length;r<n;r++)i[r]=_c(i[r],t,s)}else for(var a=e;a<t;a++)i=[i];return i}function Fa(i){if(!Array.isArray(i))return i;var t=[];return i.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t}function Ts(i,t){for(var e,r=0,n=0;n<i.length;n++){var s=i[n],a=Array.isArray(s);if(n===0&&a&&(r=s.length),a&&s.length!==r)return;var l=a?Ts(s,t):t(s);if(e===void 0)e=l;else if(e!==l)return"mixed"}return e}function mc(i,t,e,r){if(r<e){if(i.length!==t.length)throw new Ht(i.length,t.length);for(var n=[],s=0;s<i.length;s++)n[s]=mc(i[s],t[s],e,r+1);return n}else return i.concat(t)}function gc(){var i=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(i.length===1)return i[0];if(i.length>1)return i.slice(1).reduce(function(e,r){return mc(e,r,t,0)},i[0]);throw new Error("Wrong number of arguments in function concat")}function r_(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];for(var r=t.map(p=>p.length),n=Math.max(...r),s=new Array(n).fill(null),a=0;a<t.length;a++)for(var l=t[a],c=r[a],h=0;h<c;h++){var d=n-c+h;l[h]>s[d]&&(s[d]=l[h])}for(var f=0;f<t.length;f++)$s(t[f],s);return s}function $s(i,t){for(var e=t.length,r=i.length,n=0;n<r;n++){var s=e-r+n;if(i[n]<t[s]&&i[n]>1||i[n]>t[s])throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(i,") not possible to broadcast dimension ").concat(r," with size ").concat(i[n]," to size ").concat(t[s]))}}function vc(i,t){var e=Te(i);if(vi(e,t))return i;$s(e,t);var r=r_(e,t),n=r.length,s=[...Array(n-e.length).fill(1),...e],a=i_(i);e.length<n&&(a=Aa(a,s),e=Te(a));for(var l=0;l<n;l++)e[l]<r[l]&&(a=n_(a,r[l],l),e=Te(a));return a}function n_(i,t,e){return gc(...Array(t).fill(i),e)}function i_(i){return Os([],i)}function mt(i,t,e,r){function n(s){var a=Up(s,t.map(a_));return s_(i,t,s),e(a)}return n.isFactory=!0,n.fn=i,n.dependencies=t.slice().sort(),r&&(n.meta=r),n}function s_(i,t,e){var r=t.filter(s=>!o_(s)).every(s=>e[s]!==void 0);if(!r){var n=t.filter(s=>e[s]===void 0);throw new Error('Cannot create function "'.concat(i,'", ')+"some dependencies are missing: ".concat(n.map(s=>'"'.concat(s,'"')).join(", "),"."))}}function o_(i){return i&&i[0]==="?"}function a_(i){return i&&i[0]==="?"?i.slice(1):i}function u_(i,t){if(yc(i)&&wc(i,t))return i[t];throw typeof i[t]=="function"&&f_(i,t)?new Error('Cannot access method "'+t+'" as a property'):new Error('No access to property "'+t+'"')}function l_(i,t,e){if(yc(i)&&wc(i,t))return i[t]=e,e;throw new Error('No access to property "'+t+'"')}function c_(i,t){return t in i}function wc(i,t){return!i||typeof i!="object"?!1:ts(h_,t)?!0:!(t in Object.prototype||t in Function.prototype)}function f_(i,t){return i==null||typeof i[t]!="function"||ts(i,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(i)?!1:ts(d_,t)?!0:!(t in Object.prototype||t in Function.prototype)}function yc(i){return typeof i=="object"&&i&&i.constructor===Object}var h_={length:!0,name:!0},d_={toString:!0,valueOf:!0,toLocaleString:!0};class p_{constructor(t){this.wrappedObject=t,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).values()}get(t){return u_(this.wrappedObject,t)}set(t,e){return l_(this.wrappedObject,t,e),this}has(t){return c_(this.wrappedObject,t)}entries(){return __(this.keys(),t=>[t,this.get(t)])}forEach(t){for(var e of this.keys())t(this.get(e),e,this)}delete(t){delete this.wrappedObject[t]}clear(){for(var t of this.keys())this.delete(t)}get size(){return Object.keys(this.wrappedObject).length}}function __(i,t){return{next:()=>{var e=i.next();return e.done?e:{value:t(e.value),done:!1}}}}function m_(i){return i?i instanceof Map||i instanceof p_||typeof i.set=="function"&&typeof i.get=="function"&&typeof i.keys=="function"&&typeof i.has=="function":!1}var Dc=function(){return Dc=ec.create,ec},g_=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],v_=mt("typed",g_,function(t){var{BigNumber:e,Complex:r,DenseMatrix:n,Fraction:s}=t,a=Dc();return a.clear(),a.addTypes([{name:"number",test:_e},{name:"Complex",test:Kl},{name:"BigNumber",test:Oe},{name:"Fraction",test:Gl},{name:"Unit",test:Hl},{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:kp},{name:"Array",test:Ae},{name:"Matrix",test:we},{name:"DenseMatrix",test:dp},{name:"SparseMatrix",test:pp},{name:"Range",test:_p},{name:"Index",test:va},{name:"boolean",test:mp},{name:"ResultSet",test:gp},{name:"Help",test:vp},{name:"function",test:wp},{name:"Date",test:yp},{name:"RegExp",test:Dp},{name:"null",test:bp},{name:"undefined",test:xp},{name:"AccessorNode",test:Ep},{name:"ArrayNode",test:Ap},{name:"AssignmentNode",test:Cp},{name:"BlockNode",test:Fp},{name:"ConditionalNode",test:Mp},{name:"ConstantNode",test:Np},{name:"FunctionNode",test:Op},{name:"FunctionAssignmentNode",test:Sp},{name:"IndexNode",test:Bp},{name:"Node",test:Ip},{name:"ObjectNode",test:Tp},{name:"OperatorNode",test:$p},{name:"ParenthesisNode",test:Lp},{name:"RangeNode",test:Rp},{name:"RelationalNode",test:Pp},{name:"SymbolNode",test:zp},{name:"Map",test:m_},{name:"Object",test:wa}]),a.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(e||Ma(c),Kp(c)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+c+"). Use function bignumber(x) to convert to BigNumber.");return new e(c)}},{from:"number",to:"Complex",convert:function(c){return r||Ls(c),new r(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return r||Ls(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||Ls(c),new r(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){s||Na(c);var h=new s(c);if(h.valueOf()!==c)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+c+"). Use function fraction(x) to convert to Fraction.");return h}},{from:"string",to:"number",convert:function(c){var h=Number(c);if(isNaN(h))throw new Error('Cannot convert "'+c+'" to a number');return h}},{from:"string",to:"BigNumber",convert:function(c){e||Ma(c);try{return new e(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(c){s||Na(c);try{return new s(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){r||Ls(c);try{return new r(c)}catch{throw new Error('Cannot convert "'+c+'" to Complex')}}},{from:"boolean",to:"number",convert:function(c){return+c}},{from:"boolean",to:"BigNumber",convert:function(c){return e||Ma(c),new e(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return s||Na(c),new s(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return n||w_(),new n(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),a.onMismatch=(l,c,h)=>{var d=a.createError(l,c,h);if(["wrongType","mismatch"].includes(d.data.category)&&c.length===1&&Qi(c[0])&&h.some(p=>!p.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=d.data,f}throw d},a.onMismatch=(l,c,h)=>{var d=a.createError(l,c,h);if(["wrongType","mismatch"].includes(d.data.category)&&c.length===1&&Qi(c[0])&&h.some(p=>!p.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=d.data,f}throw d},a});function Ma(i){throw new Error("Cannot convert value ".concat(i," into a BigNumber: no class 'BigNumber' provided"))}function Ls(i){throw new Error("Cannot convert value ".concat(i," into a Complex number: no class 'Complex' provided"))}function w_(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function Na(i){throw new Error("Cannot convert value ".concat(i," into a Fraction, no class 'Fraction' provided."))}/*!
35
35
  * decimal.js v10.4.3
36
36
  * An arbitrary-precision Decimal type for JavaScript.
37
37
  * https://github.com/MikeMcl/decimal.js
38
38
  * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
39
39
  * MIT Licence
40
- */var Di=9e15,Mn=1e9,Sa="0123456789abcdef",Rs="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ps="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Oa={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Di,maxE:Di,crypto:!1},bc,fn,St=!0,zs="[DecimalError] ",Nn=zs+"Invalid argument: ",xc=zs+"Precision limit exceeded",Ec=zs+"crypto unavailable",Ac="[object Decimal]",Qe=Math.floor,ze=Math.pow,y_=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,D_=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,b_=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Cc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Vr=1e7,Et=7,x_=9007199254740991,E_=Rs.length-1,Ba=Ps.length-1,it={toStringTag:Ac};it.absoluteValue=it.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),Dt(i)},it.ceil=function(){return Dt(new this.constructor(this),this.e+1,2)},it.clampedTo=it.clamp=function(i,t){var e,r=this,n=r.constructor;if(i=new n(i),t=new n(t),!i.s||!t.s)return new n(NaN);if(i.gt(t))throw Error(Nn+t);return e=r.cmp(i),e<0?i:r.cmp(t)>0?t:new n(r)},it.comparedTo=it.cmp=function(i){var t,e,r,n,s=this,a=s.d,l=(i=new s.constructor(i)).d,c=s.s,f=i.s;if(!a||!l)return!c||!f?NaN:c!==f?c:a===l?0:!a^c<0?1:-1;if(!a[0]||!l[0])return a[0]?c:l[0]?-f:0;if(c!==f)return c;if(s.e!==i.e)return s.e>i.e^c<0?1:-1;for(r=a.length,n=l.length,t=0,e=r<n?r:n;t<e;++t)if(a[t]!==l[t])return a[t]>l[t]^c<0?1:-1;return r===n?0:r>n^c<0?1:-1},it.cosine=it.cos=function(){var i,t,e=this,r=e.constructor;return e.d?e.d[0]?(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=A_(r,Bc(r,e)),r.precision=i,r.rounding=t,Dt(fn==2||fn==3?e.neg():e,i,t,!0)):new r(1):new r(NaN)},it.cubeRoot=it.cbrt=function(){var i,t,e,r,n,s,a,l,c,f,d=this,h=d.constructor;if(!d.isFinite()||d.isZero())return new h(d);for(St=!1,s=d.s*ze(d.s*d,1/3),!s||Math.abs(s)==1/0?(e=Ge(d.d),i=d.e,(s=(i-e.length+1)%3)&&(e+=s==1||s==-2?"0":"00"),s=ze(e,1/3),i=Qe((i+1)/3)-(i%3==(i<0?-1:2)),s==1/0?e="5e"+i:(e=s.toExponential(),e=e.slice(0,e.indexOf("e")+1)+i),r=new h(e),r.s=d.s):r=new h(s.toString()),a=(i=h.precision)+3;;)if(l=r,c=l.times(l).times(l),f=c.plus(d),r=de(f.plus(d).times(l),f.plus(c),a+2,1),Ge(l.d).slice(0,a)===(e=Ge(r.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!n&&e=="4999"){if(!n&&(Dt(l,i+1,0),l.times(l).times(l).eq(d))){r=l;break}a+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Dt(r,i+1,1),t=!r.times(r).times(r).eq(d));break}return St=!0,Dt(r,i,h.rounding,t)},it.decimalPlaces=it.dp=function(){var i,t=this.d,e=NaN;if(t){if(i=t.length-1,e=(i-Qe(this.e/Et))*Et,i=t[i],i)for(;i%10==0;i/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(i){return de(this,new this.constructor(i))},it.dividedToIntegerBy=it.divToInt=function(i){var t=this,e=t.constructor;return Dt(de(t,new e(i),0,1,1),e.precision,e.rounding)},it.equals=it.eq=function(i){return this.cmp(i)===0},it.floor=function(){return Dt(new this.constructor(this),this.e+1,3)},it.greaterThan=it.gt=function(i){return this.cmp(i)>0},it.greaterThanOrEqualTo=it.gte=function(i){var t=this.cmp(i);return t==1||t===0},it.hyperbolicCosine=it.cosh=function(){var i,t,e,r,n,s=this,a=s.constructor,l=new a(1);if(!s.isFinite())return new a(s.s?1/0:NaN);if(s.isZero())return l;e=a.precision,r=a.rounding,a.precision=e+Math.max(s.e,s.sd())+4,a.rounding=1,n=s.d.length,n<32?(i=Math.ceil(n/3),t=(1/Ws(4,i)).toString()):(i=16,t="2.3283064365386962890625e-10"),s=bi(a,1,s.times(t),new a(1),!0);for(var c,f=i,d=new a(8);f--;)c=s.times(s),s=l.minus(c.times(d.minus(c.times(d))));return Dt(s,a.precision=e,a.rounding=r,!0)},it.hyperbolicSine=it.sinh=function(){var i,t,e,r,n=this,s=n.constructor;if(!n.isFinite()||n.isZero())return new s(n);if(t=s.precision,e=s.rounding,s.precision=t+Math.max(n.e,n.sd())+4,s.rounding=1,r=n.d.length,r<3)n=bi(s,2,n,n,!0);else{i=1.4*Math.sqrt(r),i=i>16?16:i|0,n=n.times(1/Ws(5,i)),n=bi(s,2,n,n,!0);for(var a,l=new s(5),c=new s(16),f=new s(20);i--;)a=n.times(n),n=n.times(l.plus(a.times(c.times(a).plus(f))))}return s.precision=t,s.rounding=e,Dt(n,t,e,!0)},it.hyperbolicTangent=it.tanh=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+7,r.rounding=1,de(e.sinh(),e.cosh(),r.precision=i,r.rounding=t)):new r(e.s)},it.inverseCosine=it.acos=function(){var i,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,s=e.rounding;return r!==-1?r===0?t.isNeg()?Yr(e,n,s):new e(0):new e(NaN):t.isZero()?Yr(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),i=Yr(e,n+4,s).times(.5),e.precision=n,e.rounding=s,i.minus(t))},it.inverseHyperbolicCosine=it.acosh=function(){var i,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(i=r.precision,t=r.rounding,r.precision=i+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,St=!1,e=e.times(e).minus(1).sqrt().plus(e),St=!0,r.precision=i,r.rounding=t,e.ln()):new r(e)},it.inverseHyperbolicSine=it.asinh=function(){var i,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,St=!1,e=e.times(e).plus(1).sqrt().plus(e),St=!0,r.precision=i,r.rounding=t,e.ln())},it.inverseHyperbolicTangent=it.atanh=function(){var i,t,e,r,n=this,s=n.constructor;return n.isFinite()?n.e>=0?new s(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(i=s.precision,t=s.rounding,r=n.sd(),Math.max(r,i)<2*-n.e-1?Dt(new s(n),i,t,!0):(s.precision=e=r-n.e,n=de(n.plus(1),new s(1).minus(n),e+i,1),s.precision=i+4,s.rounding=1,n=n.ln(),s.precision=i,s.rounding=t,n.times(.5))):new s(NaN)},it.inverseSine=it.asin=function(){var i,t,e,r,n=this,s=n.constructor;return n.isZero()?new s(n):(t=n.abs().cmp(1),e=s.precision,r=s.rounding,t!==-1?t===0?(i=Yr(s,e+4,r).times(.5),i.s=n.s,i):new s(NaN):(s.precision=e+6,s.rounding=1,n=n.div(new s(1).minus(n.times(n)).sqrt().plus(1)).atan(),s.precision=e,s.rounding=r,n.times(2)))},it.inverseTangent=it.atan=function(){var i,t,e,r,n,s,a,l,c,f=this,d=f.constructor,h=d.precision,p=d.rounding;if(f.isFinite()){if(f.isZero())return new d(f);if(f.abs().eq(1)&&h+4<=Ba)return a=Yr(d,h+4,p).times(.25),a.s=f.s,a}else{if(!f.s)return new d(NaN);if(h+4<=Ba)return a=Yr(d,h+4,p).times(.5),a.s=f.s,a}for(d.precision=l=h+10,d.rounding=1,e=Math.min(28,l/Et+2|0),i=e;i;--i)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(St=!1,t=Math.ceil(l/Et),r=1,c=f.times(f),a=new d(f),n=f;i!==-1;)if(n=n.times(c),s=a.minus(n.div(r+=2)),n=n.times(c),a=s.plus(n.div(r+=2)),a.d[t]!==void 0)for(i=t;a.d[i]===s.d[i]&&i--;);return e&&(a=a.times(2<<e-1)),St=!0,Dt(a,d.precision=h,d.rounding=p,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&Qe(this.e/Et)>this.d.length-2},it.isNaN=function(){return!this.s},it.isNegative=it.isNeg=function(){return this.s<0},it.isPositive=it.isPos=function(){return this.s>0},it.isZero=function(){return!!this.d&&this.d[0]===0},it.lessThan=it.lt=function(i){return this.cmp(i)<0},it.lessThanOrEqualTo=it.lte=function(i){return this.cmp(i)<1},it.logarithm=it.log=function(i){var t,e,r,n,s,a,l,c,f=this,d=f.constructor,h=d.precision,p=d.rounding,g=5;if(i==null)i=new d(10),t=!0;else{if(i=new d(i),e=i.d,i.s<0||!e||!e[0]||i.eq(1))return new d(NaN);t=i.eq(10)}if(e=f.d,f.s<0||!e||!e[0]||f.eq(1))return new d(e&&!e[0]?-1/0:f.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)s=!0;else{for(n=e[0];n%10===0;)n/=10;s=n!==1}if(St=!1,l=h+g,a=On(f,l),r=t?Us(d,l+10):On(i,l),c=de(a,r,l,1),es(c.d,n=h,p))do if(l+=10,a=On(f,l),r=t?Us(d,l+10):On(i,l),c=de(a,r,l,1),!s){+Ge(c.d).slice(n+1,n+15)+1==1e14&&(c=Dt(c,h+1,0));break}while(es(c.d,n+=10,p));return St=!0,Dt(c,h,p)},it.minus=it.sub=function(i){var t,e,r,n,s,a,l,c,f,d,h,p,g=this,w=g.constructor;if(i=new w(i),!g.d||!i.d)return!g.s||!i.s?i=new w(NaN):g.d?i.s=-i.s:i=new w(i.d||g.s!==i.s?g:NaN),i;if(g.s!=i.s)return i.s=-i.s,g.plus(i);if(f=g.d,p=i.d,l=w.precision,c=w.rounding,!f[0]||!p[0]){if(p[0])i.s=-i.s;else if(f[0])i=new w(g);else return new w(c===3?-0:0);return St?Dt(i,l,c):i}if(e=Qe(i.e/Et),d=Qe(g.e/Et),f=f.slice(),s=d-e,s){for(h=s<0,h?(t=f,s=-s,a=p.length):(t=p,e=d,a=f.length),r=Math.max(Math.ceil(l/Et),a)+2,s>r&&(s=r,t.length=1),t.reverse(),r=s;r--;)t.push(0);t.reverse()}else{for(r=f.length,a=p.length,h=r<a,h&&(a=r),r=0;r<a;r++)if(f[r]!=p[r]){h=f[r]<p[r];break}s=0}for(h&&(t=f,f=p,p=t,i.s=-i.s),a=f.length,r=p.length-a;r>0;--r)f[a++]=0;for(r=p.length;r>s;){if(f[--r]<p[r]){for(n=r;n&&f[--n]===0;)f[n]=Vr-1;--f[n],f[r]+=Vr}f[r]-=p[r]}for(;f[--a]===0;)f.pop();for(;f[0]===0;f.shift())--e;return f[0]?(i.d=f,i.e=qs(f,e),St?Dt(i,l,c):i):new w(c===3?-0:0)},it.modulo=it.mod=function(i){var t,e=this,r=e.constructor;return i=new r(i),!e.d||!i.s||i.d&&!i.d[0]?new r(NaN):!i.d||e.d&&!e.d[0]?Dt(new r(e),r.precision,r.rounding):(St=!1,r.modulo==9?(t=de(e,i.abs(),0,3,1),t.s*=i.s):t=de(e,i,0,r.modulo,1),t=t.times(i),St=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return Ia(this)},it.naturalLogarithm=it.ln=function(){return On(this)},it.negated=it.neg=function(){var i=new this.constructor(this);return i.s=-i.s,Dt(i)},it.plus=it.add=function(i){var t,e,r,n,s,a,l,c,f,d,h=this,p=h.constructor;if(i=new p(i),!h.d||!i.d)return!h.s||!i.s?i=new p(NaN):h.d||(i=new p(i.d||h.s===i.s?h:NaN)),i;if(h.s!=i.s)return i.s=-i.s,h.minus(i);if(f=h.d,d=i.d,l=p.precision,c=p.rounding,!f[0]||!d[0])return d[0]||(i=new p(h)),St?Dt(i,l,c):i;if(s=Qe(h.e/Et),r=Qe(i.e/Et),f=f.slice(),n=s-r,n){for(n<0?(e=f,n=-n,a=d.length):(e=d,r=s,a=f.length),s=Math.ceil(l/Et),a=s>a?s+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=f.length,n=d.length,a-n<0&&(n=a,e=d,d=f,f=e),t=0;n;)t=(f[--n]=f[n]+d[n]+t)/Vr|0,f[n]%=Vr;for(t&&(f.unshift(t),++r),a=f.length;f[--a]==0;)f.pop();return i.d=f,i.e=qs(f,r),St?Dt(i,l,c):i},it.precision=it.sd=function(i){var t,e=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(Nn+i);return e.d?(t=Fc(e.d),i&&e.e+1>t&&(t=e.e+1)):t=NaN,t},it.round=function(){var i=this,t=i.constructor;return Dt(new t(i),i.e+1,t.rounding)},it.sine=it.sin=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=F_(r,Bc(r,e)),r.precision=i,r.rounding=t,Dt(fn>2?e.neg():e,i,t,!0)):new r(NaN)},it.squareRoot=it.sqrt=function(){var i,t,e,r,n,s,a=this,l=a.d,c=a.e,f=a.s,d=a.constructor;if(f!==1||!l||!l[0])return new d(!f||f<0&&(!l||l[0])?NaN:l?a:1/0);for(St=!1,f=Math.sqrt(+a),f==0||f==1/0?(t=Ge(l),(t.length+c)%2==0&&(t+="0"),f=Math.sqrt(t),c=Qe((c+1)/2)-(c<0||c%2),f==1/0?t="5e"+c:(t=f.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new d(t)):r=new d(f.toString()),e=(c=d.precision)+3;;)if(s=r,r=s.plus(de(a,s,e+2,1)).times(.5),Ge(s.d).slice(0,e)===(t=Ge(r.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!n&&t=="4999"){if(!n&&(Dt(s,c+1,0),s.times(s).eq(a))){r=s;break}e+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Dt(r,c+1,1),i=!r.times(r).eq(a));break}return St=!0,Dt(r,c,d.rounding,i)},it.tangent=it.tan=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+10,r.rounding=1,e=e.sin(),e.s=1,e=de(e,new r(1).minus(e.times(e)).sqrt(),i+10,0),r.precision=i,r.rounding=t,Dt(fn==2||fn==4?e.neg():e,i,t,!0)):new r(NaN)},it.times=it.mul=function(i){var t,e,r,n,s,a,l,c,f,d=this,h=d.constructor,p=d.d,g=(i=new h(i)).d;if(i.s*=d.s,!p||!p[0]||!g||!g[0])return new h(!i.s||p&&!p[0]&&!g||g&&!g[0]&&!p?NaN:!p||!g?i.s/0:i.s*0);for(e=Qe(d.e/Et)+Qe(i.e/Et),c=p.length,f=g.length,c<f&&(s=p,p=g,g=s,a=c,c=f,f=a),s=[],a=c+f,r=a;r--;)s.push(0);for(r=f;--r>=0;){for(t=0,n=c+r;n>r;)l=s[n]+g[r]*p[n-r-1]+t,s[n--]=l%Vr|0,t=l/Vr|0;s[n]=(s[n]+t)%Vr|0}for(;!s[--a];)s.pop();return t?++e:s.shift(),i.d=s,i.e=qs(s,e),St?Dt(i,h.precision,h.rounding):i},it.toBinary=function(i,t){return $a(this,2,i,t)},it.toDecimalPlaces=it.toDP=function(i,t){var e=this,r=e.constructor;return e=new r(e),i===void 0?e:(cr(i,0,Mn),t===void 0?t=r.rounding:cr(t,0,8),Dt(e,i+e.e+1,t))},it.toExponential=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=rn(r,!0):(cr(i,0,Mn),t===void 0?t=n.rounding:cr(t,0,8),r=Dt(new n(r),i+1,t),e=rn(r,!0,i+1)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toFixed=function(i,t){var e,r,n=this,s=n.constructor;return i===void 0?e=rn(n):(cr(i,0,Mn),t===void 0?t=s.rounding:cr(t,0,8),r=Dt(new s(n),i+n.e+1,t),e=rn(r,!1,i+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},it.toFraction=function(i){var t,e,r,n,s,a,l,c,f,d,h,p,g=this,w=g.d,_=g.constructor;if(!w)return new _(g);if(f=e=new _(1),r=c=new _(0),t=new _(r),s=t.e=Fc(w)-g.e-1,a=s%Et,t.d[0]=ze(10,a<0?Et+a:a),i==null)i=s>0?t:f;else{if(l=new _(i),!l.isInt()||l.lt(f))throw Error(Nn+l);i=l.gt(t)?s>0?t:f:l}for(St=!1,l=new _(Ge(w)),d=_.precision,_.precision=s=w.length*Et*2;h=de(l,t,0,1,1),n=e.plus(h.times(r)),n.cmp(i)!=1;)e=r,r=n,n=f,f=c.plus(h.times(n)),c=n,n=t,t=l.minus(h.times(n)),l=n;return n=de(i.minus(e),r,0,1,1),c=c.plus(n.times(f)),e=e.plus(n.times(r)),c.s=f.s=g.s,p=de(f,r,s,1).minus(g).abs().cmp(de(c,e,s,1).minus(g).abs())<1?[f,r]:[c,e],_.precision=d,St=!0,p},it.toHexadecimal=it.toHex=function(i,t){return $a(this,16,i,t)},it.toNearest=function(i,t){var e=this,r=e.constructor;if(e=new r(e),i==null){if(!e.d)return e;i=new r(1),t=r.rounding}else{if(i=new r(i),t===void 0?t=r.rounding:cr(t,0,8),!e.d)return i.s?e:i;if(!i.d)return i.s&&(i.s=e.s),i}return i.d[0]?(St=!1,e=de(e,i,0,t,1).times(i),St=!0,Dt(e)):(i.s=e.s,e=i),e},it.toNumber=function(){return+this},it.toOctal=function(i,t){return $a(this,8,i,t)},it.toPower=it.pow=function(i){var t,e,r,n,s,a,l=this,c=l.constructor,f=+(i=new c(i));if(!l.d||!i.d||!l.d[0]||!i.d[0])return new c(ze(+l,f));if(l=new c(l),l.eq(1))return l;if(r=c.precision,s=c.rounding,i.eq(1))return Dt(l,r,s);if(t=Qe(i.e/Et),t>=i.d.length-1&&(e=f<0?-f:f)<=x_)return n=Mc(c,l,e,r),i.s<0?new c(1).div(n):Dt(n,r,s);if(a=l.s,a<0){if(t<i.d.length-1)return new c(NaN);if(i.d[t]&1||(a=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=a,l}return e=ze(+l,f),t=e==0||!isFinite(e)?Qe(f*(Math.log("0."+Ge(l.d))/Math.LN10+l.e+1)):new c(e+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?a/0:0):(St=!1,c.rounding=l.s=1,e=Math.min(12,(t+"").length),n=Ia(i.times(On(l,r+e)),r),n.d&&(n=Dt(n,r+5,1),es(n.d,r,s)&&(t=r+10,n=Dt(Ia(i.times(On(l,t+e)),t),t+5,1),+Ge(n.d).slice(r+1,r+15)+1==1e14&&(n=Dt(n,r+1,0)))),n.s=a,St=!0,c.rounding=s,Dt(n,r,s))},it.toPrecision=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=rn(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(cr(i,1,Mn),t===void 0?t=n.rounding:cr(t,0,8),r=Dt(new n(r),i,t),e=rn(r,i<=r.e||r.e<=n.toExpNeg,i)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toSignificantDigits=it.toSD=function(i,t){var e=this,r=e.constructor;return i===void 0?(i=r.precision,t=r.rounding):(cr(i,1,Mn),t===void 0?t=r.rounding:cr(t,0,8)),Dt(new r(e),i,t)},it.toString=function(){var i=this,t=i.constructor,e=rn(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()&&!i.isZero()?"-"+e:e},it.truncated=it.trunc=function(){return Dt(new this.constructor(this),this.e+1,1)},it.valueOf=it.toJSON=function(){var i=this,t=i.constructor,e=rn(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()?"-"+e:e};function Ge(i){var t,e,r,n=i.length-1,s="",a=i[0];if(n>0){for(s+=a,t=1;t<n;t++)r=i[t]+"",e=Et-r.length,e&&(s+=Sn(e)),s+=r;a=i[t],r=a+"",e=Et-r.length,e&&(s+=Sn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}function cr(i,t,e){if(i!==~~i||i<t||i>e)throw Error(Nn+i)}function es(i,t,e,r){var n,s,a,l;for(s=i[0];s>=10;s/=10)--t;return--t<0?(t+=Et,n=0):(n=Math.ceil((t+1)/Et),t%=Et),s=ze(10,Et-t),l=i[n]%s|0,r==null?t<3?(t==0?l=l/100|0:t==1&&(l=l/10|0),a=e<4&&l==99999||e>3&&l==49999||l==5e4||l==0):a=(e<4&&l+1==s||e>3&&l+1==s/2)&&(i[n+1]/s/100|0)==ze(10,t-2)-1||(l==s/2||l==0)&&(i[n+1]/s/100|0)==0:t<4?(t==0?l=l/1e3|0:t==1?l=l/100|0:t==2&&(l=l/10|0),a=(r||e<4)&&l==9999||!r&&e>3&&l==4999):a=((r||e<4)&&l+1==s||!r&&e>3&&l+1==s/2)&&(i[n+1]/s/1e3|0)==ze(10,t-3)-1,a}function ks(i,t,e){for(var r,n=[0],s,a=0,l=i.length;a<l;){for(s=n.length;s--;)n[s]*=t;for(n[0]+=Sa.indexOf(i.charAt(a++)),r=0;r<n.length;r++)n[r]>e-1&&(n[r+1]===void 0&&(n[r+1]=0),n[r+1]+=n[r]/e|0,n[r]%=e)}return n.reverse()}function A_(i,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/Ws(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i.precision+=e,t=bi(i,1,t.times(n),new i(1));for(var s=e;s--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return i.precision-=e,t}var de=function(){function i(r,n,s){var a,l=0,c=r.length;for(r=r.slice();c--;)a=r[c]*n+l,r[c]=a%s|0,l=a/s|0;return l&&r.unshift(l),r}function t(r,n,s,a){var l,c;if(s!=a)c=s>a?1:-1;else for(l=c=0;l<s;l++)if(r[l]!=n[l]){c=r[l]>n[l]?1:-1;break}return c}function e(r,n,s,a){for(var l=0;s--;)r[s]-=l,l=r[s]<n[s]?1:0,r[s]=l*a+r[s]-n[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,s,a,l,c){var f,d,h,p,g,w,_,y,v,x,b,M,E,F,N,S,T,C,O,$,W=r.constructor,q=r.s==n.s?1:-1,U=r.d,z=n.d;if(!U||!U[0]||!z||!z[0])return new W(!r.s||!n.s||(U?z&&U[0]==z[0]:!z)?NaN:U&&U[0]==0||!z?q*0:q/0);for(c?(g=1,d=r.e-n.e):(c=Vr,g=Et,d=Qe(r.e/g)-Qe(n.e/g)),O=z.length,T=U.length,v=new W(q),x=v.d=[],h=0;z[h]==(U[h]||0);h++);if(z[h]>(U[h]||0)&&d--,s==null?(F=s=W.precision,a=W.rounding):l?F=s+(r.e-n.e)+1:F=s,F<0)x.push(1),w=!0;else{if(F=F/g+2|0,h=0,O==1){for(p=0,z=z[0],F++;(h<T||p)&&F--;h++)N=p*c+(U[h]||0),x[h]=N/z|0,p=N%z|0;w=p||h<T}else{for(p=c/(z[0]+1)|0,p>1&&(z=i(z,p,c),U=i(U,p,c),O=z.length,T=U.length),S=O,b=U.slice(0,O),M=b.length;M<O;)b[M++]=0;$=z.slice(),$.unshift(0),C=z[0],z[1]>=c/2&&++C;do p=0,f=t(z,b,O,M),f<0?(E=b[0],O!=M&&(E=E*c+(b[1]||0)),p=E/C|0,p>1?(p>=c&&(p=c-1),_=i(z,p,c),y=_.length,M=b.length,f=t(_,b,y,M),f==1&&(p--,e(_,O<y?$:z,y,c))):(p==0&&(f=p=1),_=z.slice()),y=_.length,y<M&&_.unshift(0),e(b,_,M,c),f==-1&&(M=b.length,f=t(z,b,O,M),f<1&&(p++,e(b,O<M?$:z,M,c))),M=b.length):f===0&&(p++,b=[0]),x[h++]=p,f&&b[0]?b[M++]=U[S]||0:(b=[U[S]],M=1);while((S++<T||b[0]!==void 0)&&F--);w=b[0]!==void 0}x[0]||x.shift()}if(g==1)v.e=d,bc=w;else{for(h=1,p=x[0];p>=10;p/=10)h++;v.e=h+d*g-1,Dt(v,l?s+v.e+1:s,a,w)}return v}}();function Dt(i,t,e,r){var n,s,a,l,c,f,d,h,p,g=i.constructor;t:if(t!=null){if(h=i.d,!h)return i;for(n=1,l=h[0];l>=10;l/=10)n++;if(s=t-n,s<0)s+=Et,a=t,d=h[p=0],c=d/ze(10,n-a-1)%10|0;else if(p=Math.ceil((s+1)/Et),l=h.length,p>=l)if(r){for(;l++<=p;)h.push(0);d=c=0,n=1,s%=Et,a=s-Et+1}else break t;else{for(d=l=h[p],n=1;l>=10;l/=10)n++;s%=Et,a=s-Et+n,c=a<0?0:d/ze(10,n-a-1)%10|0}if(r=r||t<0||h[p+1]!==void 0||(a<0?d:d%ze(10,n-a-1)),f=e<4?(c||r)&&(e==0||e==(i.s<0?3:2)):c>5||c==5&&(e==4||r||e==6&&(s>0?a>0?d/ze(10,n-a):0:h[p-1])%10&1||e==(i.s<0?8:7)),t<1||!h[0])return h.length=0,f?(t-=i.e+1,h[0]=ze(10,(Et-t%Et)%Et),i.e=-t||0):h[0]=i.e=0,i;if(s==0?(h.length=p,l=1,p--):(h.length=p+1,l=ze(10,Et-s),h[p]=a>0?(d/ze(10,n-a)%ze(10,a)|0)*l:0),f)for(;;)if(p==0){for(s=1,a=h[0];a>=10;a/=10)s++;for(a=h[0]+=l,l=1;a>=10;a/=10)l++;s!=l&&(i.e++,h[0]==Vr&&(h[0]=1));break}else{if(h[p]+=l,h[p]!=Vr)break;h[p--]=0,l=1}for(s=h.length;h[--s]===0;)h.pop()}return St&&(i.e>g.maxE?(i.d=null,i.e=NaN):i.e<g.minE&&(i.e=0,i.d=[0])),i}function rn(i,t,e){if(!i.isFinite())return Oc(i);var r,n=i.e,s=Ge(i.d),a=s.length;return t?(e&&(r=e-a)>0?s=s.charAt(0)+"."+s.slice(1)+Sn(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i.e<0?"e":"e+")+i.e):n<0?(s="0."+Sn(-n-1)+s,e&&(r=e-a)>0&&(s+=Sn(r))):n>=a?(s+=Sn(n+1-a),e&&(r=e-n-1)>0&&(s=s+"."+Sn(r))):((r=n+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(s+="."),s+=Sn(r))),s}function qs(i,t){var e=i[0];for(t*=Et;e>=10;e/=10)t++;return t}function Us(i,t,e){if(t>E_)throw St=!0,e&&(i.precision=e),Error(xc);return Dt(new i(Rs),t,1,!0)}function Yr(i,t,e){if(t>Ba)throw Error(xc);return Dt(new i(Ps),t,e,!0)}function Fc(i){var t=i.length-1,e=t*Et+1;if(t=i[t],t){for(;t%10==0;t/=10)e--;for(t=i[0];t>=10;t/=10)e++}return e}function Sn(i){for(var t="";i--;)t+="0";return t}function Mc(i,t,e,r){var n,s=new i(1),a=Math.ceil(r/Et+4);for(St=!1;;){if(e%2&&(s=s.times(t),Ic(s.d,a)&&(n=!0)),e=Qe(e/2),e===0){e=s.d.length-1,n&&s.d[e]===0&&++s.d[e];break}t=t.times(t),Ic(t.d,a)}return St=!0,s}function Nc(i){return i.d[i.d.length-1]&1}function Sc(i,t,e){for(var r,n=new i(t[0]),s=0;++s<t.length;)if(r=new i(t[s]),r.s)n[e](r)&&(n=r);else{n=r;break}return n}function Ia(i,t){var e,r,n,s,a,l,c,f=0,d=0,h=0,p=i.constructor,g=p.rounding,w=p.precision;if(!i.d||!i.d[0]||i.e>17)return new p(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:NaN);for(t==null?(St=!1,c=w):c=t,l=new p(.03125);i.e>-2;)i=i.times(l),h+=5;for(r=Math.log(ze(2,h))/Math.LN10*2+5|0,c+=r,e=s=a=new p(1),p.precision=c;;){if(s=Dt(s.times(i),c,1),e=e.times(++d),l=a.plus(de(s,e,c,1)),Ge(l.d).slice(0,c)===Ge(a.d).slice(0,c)){for(n=h;n--;)a=Dt(a.times(a),c,1);if(t==null)if(f<3&&es(a.d,c-r,g,f))p.precision=c+=10,e=s=l=new p(1),d=0,f++;else return Dt(a,p.precision=w,g,St=!0);else return p.precision=w,a}a=l}}function On(i,t){var e,r,n,s,a,l,c,f,d,h,p,g=1,w=10,_=i,y=_.d,v=_.constructor,x=v.rounding,b=v.precision;if(_.s<0||!y||!y[0]||!_.e&&y[0]==1&&y.length==1)return new v(y&&!y[0]?-1/0:_.s!=1?NaN:y?0:_);if(t==null?(St=!1,d=b):d=t,v.precision=d+=w,e=Ge(y),r=e.charAt(0),Math.abs(s=_.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)_=_.times(i),e=Ge(_.d),r=e.charAt(0),g++;s=_.e,r>1?(_=new v("0."+e),s++):_=new v(r+"."+e.slice(1))}else return f=Us(v,d+2,b).times(s+""),_=On(new v(r+"."+e.slice(1)),d-w).plus(f),v.precision=b,t==null?Dt(_,b,x,St=!0):_;for(h=_,c=a=_=de(_.minus(1),_.plus(1),d,1),p=Dt(_.times(_),d,1),n=3;;){if(a=Dt(a.times(p),d,1),f=c.plus(de(a,new v(n),d,1)),Ge(f.d).slice(0,d)===Ge(c.d).slice(0,d))if(c=c.times(2),s!==0&&(c=c.plus(Us(v,d+2,b).times(s+""))),c=de(c,new v(g),d,1),t==null)if(es(c.d,d-w,x,l))v.precision=d+=w,f=a=_=de(h.minus(1),h.plus(1),d,1),p=Dt(_.times(_),d,1),n=l=1;else return Dt(c,v.precision=b,x,St=!0);else return v.precision=b,c;c=f,n+=2}}function Oc(i){return String(i.s*i.s/0)}function Ta(i,t){var e,r,n;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),r=0;t.charCodeAt(r)===48;r++);for(n=t.length;t.charCodeAt(n-1)===48;--n);if(t=t.slice(r,n),t){if(n-=r,i.e=e=e-r-1,i.d=[],r=(e+1)%Et,e<0&&(r+=Et),r<n){for(r&&i.d.push(+t.slice(0,r)),n-=Et;r<n;)i.d.push(+t.slice(r,r+=Et));t=t.slice(r),r=Et-t.length}else r-=n;for(;r--;)t+="0";i.d.push(+t),St&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function C_(i,t){var e,r,n,s,a,l,c,f,d;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Cc.test(t))return Ta(i,t)}else if(t==="Infinity"||t==="NaN")return+t||(i.s=NaN),i.e=NaN,i.d=null,i;if(D_.test(t))e=16,t=t.toLowerCase();else if(y_.test(t))e=2;else if(b_.test(t))e=8;else throw Error(Nn+t);for(s=t.search(/p/i),s>0?(c=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),a=s>=0,r=i.constructor,a&&(t=t.replace(".",""),l=t.length,s=l-s,n=Mc(r,new r(e),s,s*2)),f=ks(t,e,Vr),d=f.length-1,s=d;f[s]===0;--s)f.pop();return s<0?new r(i.s*0):(i.e=qs(f,d),i.d=f,St=!1,a&&(i=de(i,n,l*4)),c&&(i=i.times(Math.abs(c)<54?ze(2,c):xi.pow(2,c))),St=!0,i)}function F_(i,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:bi(i,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/Ws(5,e)),t=bi(i,2,t,t);for(var n,s=new i(5),a=new i(16),l=new i(20);e--;)n=t.times(t),t=t.times(s.plus(n.times(a.times(n).minus(l))));return t}function bi(i,t,e,r,n){var s,a,l,c,f=i.precision,d=Math.ceil(f/Et);for(St=!1,c=e.times(e),l=new i(r);;){if(a=de(l.times(c),new i(t++*t++),f,1),l=n?r.plus(a):r.minus(a),r=de(a.times(c),new i(t++*t++),f,1),a=l.plus(r),a.d[d]!==void 0){for(s=d;a.d[s]===l.d[s]&&s--;);if(s==-1)break}s=l,l=r,r=a,a=s}return St=!0,a.d.length=d+1,a}function Ws(i,t){for(var e=i;--t;)e*=i;return e}function Bc(i,t){var e,r=t.s<0,n=Yr(i,i.precision,1),s=n.times(.5);if(t=t.abs(),t.lte(s))return fn=r?4:1,t;if(e=t.divToInt(n),e.isZero())fn=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(s))return fn=Nc(e)?r?2:3:r?4:1,t;fn=Nc(e)?r?1:4:r?3:2}return t.minus(n).abs()}function $a(i,t,e,r){var n,s,a,l,c,f,d,h,p,g=i.constructor,w=e!==void 0;if(w?(cr(e,1,Mn),r===void 0?r=g.rounding:cr(r,0,8)):(e=g.precision,r=g.rounding),!i.isFinite())d=Oc(i);else{for(d=rn(i),a=d.indexOf("."),w?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(d=d.replace(".",""),p=new g(1),p.e=d.length-a,p.d=ks(rn(p),10,n),p.e=p.d.length),h=ks(d,10,n),s=c=h.length;h[--c]==0;)h.pop();if(!h[0])d=w?"0p+0":"0";else{if(a<0?s--:(i=new g(i),i.d=h,i.e=s,i=de(i,p,e,r,0,n),h=i.d,s=i.e,f=bc),a=h[e],l=n/2,f=f||h[e+1]!==void 0,f=r<4?(a!==void 0||f)&&(r===0||r===(i.s<0?3:2)):a>l||a===l&&(r===4||f||r===6&&h[e-1]&1||r===(i.s<0?8:7)),h.length=e,f)for(;++h[--e]>n-1;)h[e]=0,e||(++s,h.unshift(1));for(c=h.length;!h[c-1];--c);for(a=0,d="";a<c;a++)d+=Sa.charAt(h[a]);if(w){if(c>1)if(t==16||t==8){for(a=t==16?4:3,--c;c%a;c++)d+="0";for(h=ks(d,n,t),c=h.length;!h[c-1];--c);for(a=1,d="1.";a<c;a++)d+=Sa.charAt(h[a])}else d=d.charAt(0)+"."+d.slice(1);d=d+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)d="0"+d;d="0."+d}else if(++s>c)for(s-=c;s--;)d+="0";else s<c&&(d=d.slice(0,s)+"."+d.slice(s))}d=(t==16?"0x":t==2?"0b":t==8?"0o":"")+d}return i.s<0?"-"+d:d}function Ic(i,t){if(i.length>t)return i.length=t,!0}function M_(i){return new this(i).abs()}function N_(i){return new this(i).acos()}function S_(i){return new this(i).acosh()}function O_(i,t){return new this(i).plus(t)}function B_(i){return new this(i).asin()}function I_(i){return new this(i).asinh()}function T_(i){return new this(i).atan()}function $_(i){return new this(i).atanh()}function L_(i,t){i=new this(i),t=new this(t);var e,r=this.precision,n=this.rounding,s=r+4;return!i.s||!t.s?e=new this(NaN):!i.d&&!t.d?(e=Yr(this,s,1).times(t.s>0?.25:.75),e.s=i.s):!t.d||i.isZero()?(e=t.s<0?Yr(this,r,n):new this(0),e.s=i.s):!i.d||t.isZero()?(e=Yr(this,s,1).times(.5),e.s=i.s):t.s<0?(this.precision=s,this.rounding=1,e=this.atan(de(i,t,s,1)),t=Yr(this,s,1),this.precision=r,this.rounding=n,e=i.s<0?e.minus(t):e.plus(t)):e=this.atan(de(i,t,s,1)),e}function R_(i){return new this(i).cbrt()}function P_(i){return Dt(i=new this(i),i.e+1,2)}function z_(i,t,e){return new this(i).clamp(t,e)}function k_(i){if(!i||typeof i!="object")throw Error(zs+"Object expected");var t,e,r,n=i.defaults===!0,s=["precision",1,Mn,"rounding",0,8,"toExpNeg",-Di,0,"toExpPos",0,Di,"maxE",0,Di,"minE",-Di,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(e=s[t],n&&(this[e]=Oa[e]),(r=i[e])!==void 0)if(Qe(r)===r&&r>=s[t+1]&&r<=s[t+2])this[e]=r;else throw Error(Nn+e+": "+r);if(e="crypto",n&&(this[e]=Oa[e]),(r=i[e])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(Ec);else this[e]=!1;else throw Error(Nn+e+": "+r);return this}function q_(i){return new this(i).cos()}function U_(i){return new this(i).cosh()}function Tc(i){var t,e,r;function n(s){var a,l,c,f=this;if(!(f instanceof n))return new n(s);if(f.constructor=n,$c(s)){f.s=s.s,St?!s.d||s.e>n.maxE?(f.e=NaN,f.d=null):s.e<n.minE?(f.e=0,f.d=[0]):(f.e=s.e,f.d=s.d.slice()):(f.e=s.e,f.d=s.d?s.d.slice():s.d);return}if(c=typeof s,c==="number"){if(s===0){f.s=1/s<0?-1:1,f.e=0,f.d=[0];return}if(s<0?(s=-s,f.s=-1):f.s=1,s===~~s&&s<1e7){for(a=0,l=s;l>=10;l/=10)a++;St?a>n.maxE?(f.e=NaN,f.d=null):a<n.minE?(f.e=0,f.d=[0]):(f.e=a,f.d=[s]):(f.e=a,f.d=[s]);return}else if(s*0!==0){s||(f.s=NaN),f.e=NaN,f.d=null;return}return Ta(f,s.toString())}else if(c!=="string")throw Error(Nn+s);return(l=s.charCodeAt(0))===45?(s=s.slice(1),f.s=-1):(l===43&&(s=s.slice(1)),f.s=1),Cc.test(s)?Ta(f,s):C_(f,s)}if(n.prototype=it,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=k_,n.clone=Tc,n.isDecimal=$c,n.abs=M_,n.acos=N_,n.acosh=S_,n.add=O_,n.asin=B_,n.asinh=I_,n.atan=T_,n.atanh=$_,n.atan2=L_,n.cbrt=R_,n.ceil=P_,n.clamp=z_,n.cos=q_,n.cosh=U_,n.div=W_,n.exp=j_,n.floor=V_,n.hypot=Y_,n.ln=Z_,n.log=K_,n.log10=H_,n.log2=G_,n.max=J_,n.min=X_,n.mod=Q_,n.mul=tm,n.pow=em,n.random=rm,n.round=nm,n.sign=im,n.sin=sm,n.sinh=om,n.sqrt=am,n.sub=um,n.sum=lm,n.tan=cm,n.tanh=fm,n.trunc=hm,i===void 0&&(i={}),i&&i.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)i.hasOwnProperty(e=r[t++])||(i[e]=this[e]);return n.config(i),n}function W_(i,t){return new this(i).div(t)}function j_(i){return new this(i).exp()}function V_(i){return Dt(i=new this(i),i.e+1,3)}function Y_(){var i,t,e=new this(0);for(St=!1,i=0;i<arguments.length;)if(t=new this(arguments[i++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return St=!0,new this(1/0);e=t}return St=!0,e.sqrt()}function $c(i){return i instanceof xi||i&&i.toStringTag===Ac||!1}function Z_(i){return new this(i).ln()}function K_(i,t){return new this(i).log(t)}function G_(i){return new this(i).log(2)}function H_(i){return new this(i).log(10)}function J_(){return Sc(this,arguments,"lt")}function X_(){return Sc(this,arguments,"gt")}function Q_(i,t){return new this(i).mod(t)}function tm(i,t){return new this(i).mul(t)}function em(i,t){return new this(i).pow(t)}function rm(i){var t,e,r,n,s=0,a=new this(1),l=[];if(i===void 0?i=this.precision:cr(i,1,Mn),r=Math.ceil(i/Et),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));s<r;)n=t[s],n>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:l[s++]=n%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);s<r;)n=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(t,s):(l.push(n%1e7),s+=4);s=r/4}else throw Error(Ec);else for(;s<r;)l[s++]=Math.random()*1e7|0;for(r=l[--s],i%=Et,r&&i&&(n=ze(10,Et-i),l[s]=(r/n|0)*n);l[s]===0;s--)l.pop();if(s<0)e=0,l=[0];else{for(e=-1;l[0]===0;e-=Et)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<Et&&(e-=Et-r)}return a.e=e,a.d=l,a}function nm(i){return Dt(i=new this(i),i.e+1,this.rounding)}function im(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function sm(i){return new this(i).sin()}function om(i){return new this(i).sinh()}function am(i){return new this(i).sqrt()}function um(i,t){return new this(i).sub(t)}function lm(){var i=0,t=arguments,e=new this(t[i]);for(St=!1;e.s&&++i<t.length;)e=e.plus(t[i]);return St=!0,Dt(e,this.precision,this.rounding)}function cm(i){return new this(i).tan()}function fm(i){return new this(i).tanh()}function hm(i){return Dt(i=new this(i),i.e+1,1)}it[Symbol.for("nodejs.util.inspect.custom")]=it.toString,it[Symbol.toStringTag]="Decimal";var xi=it.constructor=Tc(Oa);Rs=new xi(Rs),Ps=new xi(Ps);var dm="BigNumber",pm=["?on","config"],_m=mt(dm,pm,i=>{var{on:t,config:e}=i,r=xi.clone({precision:e.precision,modulo:xi.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(n){return new r(n.value)},t&&t("config",function(n,s){n.precision!==s.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),Lc={exports:{}};/**
40
+ */var Di=9e15,Mn=1e9,Sa="0123456789abcdef",Rs="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ps="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Oa={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Di,maxE:Di,crypto:!1},bc,fn,St=!0,zs="[DecimalError] ",Nn=zs+"Invalid argument: ",xc=zs+"Precision limit exceeded",Ec=zs+"crypto unavailable",Ac="[object Decimal]",Qe=Math.floor,ze=Math.pow,y_=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,D_=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,b_=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Cc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Vr=1e7,Et=7,x_=9007199254740991,E_=Rs.length-1,Ba=Ps.length-1,it={toStringTag:Ac};it.absoluteValue=it.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),Dt(i)},it.ceil=function(){return Dt(new this.constructor(this),this.e+1,2)},it.clampedTo=it.clamp=function(i,t){var e,r=this,n=r.constructor;if(i=new n(i),t=new n(t),!i.s||!t.s)return new n(NaN);if(i.gt(t))throw Error(Nn+t);return e=r.cmp(i),e<0?i:r.cmp(t)>0?t:new n(r)},it.comparedTo=it.cmp=function(i){var t,e,r,n,s=this,a=s.d,l=(i=new s.constructor(i)).d,c=s.s,h=i.s;if(!a||!l)return!c||!h?NaN:c!==h?c:a===l?0:!a^c<0?1:-1;if(!a[0]||!l[0])return a[0]?c:l[0]?-h:0;if(c!==h)return c;if(s.e!==i.e)return s.e>i.e^c<0?1:-1;for(r=a.length,n=l.length,t=0,e=r<n?r:n;t<e;++t)if(a[t]!==l[t])return a[t]>l[t]^c<0?1:-1;return r===n?0:r>n^c<0?1:-1},it.cosine=it.cos=function(){var i,t,e=this,r=e.constructor;return e.d?e.d[0]?(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=A_(r,Bc(r,e)),r.precision=i,r.rounding=t,Dt(fn==2||fn==3?e.neg():e,i,t,!0)):new r(1):new r(NaN)},it.cubeRoot=it.cbrt=function(){var i,t,e,r,n,s,a,l,c,h,d=this,f=d.constructor;if(!d.isFinite()||d.isZero())return new f(d);for(St=!1,s=d.s*ze(d.s*d,1/3),!s||Math.abs(s)==1/0?(e=Ge(d.d),i=d.e,(s=(i-e.length+1)%3)&&(e+=s==1||s==-2?"0":"00"),s=ze(e,1/3),i=Qe((i+1)/3)-(i%3==(i<0?-1:2)),s==1/0?e="5e"+i:(e=s.toExponential(),e=e.slice(0,e.indexOf("e")+1)+i),r=new f(e),r.s=d.s):r=new f(s.toString()),a=(i=f.precision)+3;;)if(l=r,c=l.times(l).times(l),h=c.plus(d),r=de(h.plus(d).times(l),h.plus(c),a+2,1),Ge(l.d).slice(0,a)===(e=Ge(r.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!n&&e=="4999"){if(!n&&(Dt(l,i+1,0),l.times(l).times(l).eq(d))){r=l;break}a+=4,n=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Dt(r,i+1,1),t=!r.times(r).times(r).eq(d));break}return St=!0,Dt(r,i,f.rounding,t)},it.decimalPlaces=it.dp=function(){var i,t=this.d,e=NaN;if(t){if(i=t.length-1,e=(i-Qe(this.e/Et))*Et,i=t[i],i)for(;i%10==0;i/=10)e--;e<0&&(e=0)}return e},it.dividedBy=it.div=function(i){return de(this,new this.constructor(i))},it.dividedToIntegerBy=it.divToInt=function(i){var t=this,e=t.constructor;return Dt(de(t,new e(i),0,1,1),e.precision,e.rounding)},it.equals=it.eq=function(i){return this.cmp(i)===0},it.floor=function(){return Dt(new this.constructor(this),this.e+1,3)},it.greaterThan=it.gt=function(i){return this.cmp(i)>0},it.greaterThanOrEqualTo=it.gte=function(i){var t=this.cmp(i);return t==1||t===0},it.hyperbolicCosine=it.cosh=function(){var i,t,e,r,n,s=this,a=s.constructor,l=new a(1);if(!s.isFinite())return new a(s.s?1/0:NaN);if(s.isZero())return l;e=a.precision,r=a.rounding,a.precision=e+Math.max(s.e,s.sd())+4,a.rounding=1,n=s.d.length,n<32?(i=Math.ceil(n/3),t=(1/Ws(4,i)).toString()):(i=16,t="2.3283064365386962890625e-10"),s=bi(a,1,s.times(t),new a(1),!0);for(var c,h=i,d=new a(8);h--;)c=s.times(s),s=l.minus(c.times(d.minus(c.times(d))));return Dt(s,a.precision=e,a.rounding=r,!0)},it.hyperbolicSine=it.sinh=function(){var i,t,e,r,n=this,s=n.constructor;if(!n.isFinite()||n.isZero())return new s(n);if(t=s.precision,e=s.rounding,s.precision=t+Math.max(n.e,n.sd())+4,s.rounding=1,r=n.d.length,r<3)n=bi(s,2,n,n,!0);else{i=1.4*Math.sqrt(r),i=i>16?16:i|0,n=n.times(1/Ws(5,i)),n=bi(s,2,n,n,!0);for(var a,l=new s(5),c=new s(16),h=new s(20);i--;)a=n.times(n),n=n.times(l.plus(a.times(c.times(a).plus(h))))}return s.precision=t,s.rounding=e,Dt(n,t,e,!0)},it.hyperbolicTangent=it.tanh=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+7,r.rounding=1,de(e.sinh(),e.cosh(),r.precision=i,r.rounding=t)):new r(e.s)},it.inverseCosine=it.acos=function(){var i,t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,s=e.rounding;return r!==-1?r===0?t.isNeg()?Yr(e,n,s):new e(0):new e(NaN):t.isZero()?Yr(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,t=t.asin(),i=Yr(e,n+4,s).times(.5),e.precision=n,e.rounding=s,i.minus(t))},it.inverseHyperbolicCosine=it.acosh=function(){var i,t,e=this,r=e.constructor;return e.lte(1)?new r(e.eq(1)?0:NaN):e.isFinite()?(i=r.precision,t=r.rounding,r.precision=i+Math.max(Math.abs(e.e),e.sd())+4,r.rounding=1,St=!1,e=e.times(e).minus(1).sqrt().plus(e),St=!0,r.precision=i,r.rounding=t,e.ln()):new r(e)},it.inverseHyperbolicSine=it.asinh=function(){var i,t,e=this,r=e.constructor;return!e.isFinite()||e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+2*Math.max(Math.abs(e.e),e.sd())+6,r.rounding=1,St=!1,e=e.times(e).plus(1).sqrt().plus(e),St=!0,r.precision=i,r.rounding=t,e.ln())},it.inverseHyperbolicTangent=it.atanh=function(){var i,t,e,r,n=this,s=n.constructor;return n.isFinite()?n.e>=0?new s(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(i=s.precision,t=s.rounding,r=n.sd(),Math.max(r,i)<2*-n.e-1?Dt(new s(n),i,t,!0):(s.precision=e=r-n.e,n=de(n.plus(1),new s(1).minus(n),e+i,1),s.precision=i+4,s.rounding=1,n=n.ln(),s.precision=i,s.rounding=t,n.times(.5))):new s(NaN)},it.inverseSine=it.asin=function(){var i,t,e,r,n=this,s=n.constructor;return n.isZero()?new s(n):(t=n.abs().cmp(1),e=s.precision,r=s.rounding,t!==-1?t===0?(i=Yr(s,e+4,r).times(.5),i.s=n.s,i):new s(NaN):(s.precision=e+6,s.rounding=1,n=n.div(new s(1).minus(n.times(n)).sqrt().plus(1)).atan(),s.precision=e,s.rounding=r,n.times(2)))},it.inverseTangent=it.atan=function(){var i,t,e,r,n,s,a,l,c,h=this,d=h.constructor,f=d.precision,p=d.rounding;if(h.isFinite()){if(h.isZero())return new d(h);if(h.abs().eq(1)&&f+4<=Ba)return a=Yr(d,f+4,p).times(.25),a.s=h.s,a}else{if(!h.s)return new d(NaN);if(f+4<=Ba)return a=Yr(d,f+4,p).times(.5),a.s=h.s,a}for(d.precision=l=f+10,d.rounding=1,e=Math.min(28,l/Et+2|0),i=e;i;--i)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(St=!1,t=Math.ceil(l/Et),r=1,c=h.times(h),a=new d(h),n=h;i!==-1;)if(n=n.times(c),s=a.minus(n.div(r+=2)),n=n.times(c),a=s.plus(n.div(r+=2)),a.d[t]!==void 0)for(i=t;a.d[i]===s.d[i]&&i--;);return e&&(a=a.times(2<<e-1)),St=!0,Dt(a,d.precision=f,d.rounding=p,!0)},it.isFinite=function(){return!!this.d},it.isInteger=it.isInt=function(){return!!this.d&&Qe(this.e/Et)>this.d.length-2},it.isNaN=function(){return!this.s},it.isNegative=it.isNeg=function(){return this.s<0},it.isPositive=it.isPos=function(){return this.s>0},it.isZero=function(){return!!this.d&&this.d[0]===0},it.lessThan=it.lt=function(i){return this.cmp(i)<0},it.lessThanOrEqualTo=it.lte=function(i){return this.cmp(i)<1},it.logarithm=it.log=function(i){var t,e,r,n,s,a,l,c,h=this,d=h.constructor,f=d.precision,p=d.rounding,g=5;if(i==null)i=new d(10),t=!0;else{if(i=new d(i),e=i.d,i.s<0||!e||!e[0]||i.eq(1))return new d(NaN);t=i.eq(10)}if(e=h.d,h.s<0||!e||!e[0]||h.eq(1))return new d(e&&!e[0]?-1/0:h.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)s=!0;else{for(n=e[0];n%10===0;)n/=10;s=n!==1}if(St=!1,l=f+g,a=On(h,l),r=t?Us(d,l+10):On(i,l),c=de(a,r,l,1),es(c.d,n=f,p))do if(l+=10,a=On(h,l),r=t?Us(d,l+10):On(i,l),c=de(a,r,l,1),!s){+Ge(c.d).slice(n+1,n+15)+1==1e14&&(c=Dt(c,f+1,0));break}while(es(c.d,n+=10,p));return St=!0,Dt(c,f,p)},it.minus=it.sub=function(i){var t,e,r,n,s,a,l,c,h,d,f,p,g=this,w=g.constructor;if(i=new w(i),!g.d||!i.d)return!g.s||!i.s?i=new w(NaN):g.d?i.s=-i.s:i=new w(i.d||g.s!==i.s?g:NaN),i;if(g.s!=i.s)return i.s=-i.s,g.plus(i);if(h=g.d,p=i.d,l=w.precision,c=w.rounding,!h[0]||!p[0]){if(p[0])i.s=-i.s;else if(h[0])i=new w(g);else return new w(c===3?-0:0);return St?Dt(i,l,c):i}if(e=Qe(i.e/Et),d=Qe(g.e/Et),h=h.slice(),s=d-e,s){for(f=s<0,f?(t=h,s=-s,a=p.length):(t=p,e=d,a=h.length),r=Math.max(Math.ceil(l/Et),a)+2,s>r&&(s=r,t.length=1),t.reverse(),r=s;r--;)t.push(0);t.reverse()}else{for(r=h.length,a=p.length,f=r<a,f&&(a=r),r=0;r<a;r++)if(h[r]!=p[r]){f=h[r]<p[r];break}s=0}for(f&&(t=h,h=p,p=t,i.s=-i.s),a=h.length,r=p.length-a;r>0;--r)h[a++]=0;for(r=p.length;r>s;){if(h[--r]<p[r]){for(n=r;n&&h[--n]===0;)h[n]=Vr-1;--h[n],h[r]+=Vr}h[r]-=p[r]}for(;h[--a]===0;)h.pop();for(;h[0]===0;h.shift())--e;return h[0]?(i.d=h,i.e=qs(h,e),St?Dt(i,l,c):i):new w(c===3?-0:0)},it.modulo=it.mod=function(i){var t,e=this,r=e.constructor;return i=new r(i),!e.d||!i.s||i.d&&!i.d[0]?new r(NaN):!i.d||e.d&&!e.d[0]?Dt(new r(e),r.precision,r.rounding):(St=!1,r.modulo==9?(t=de(e,i.abs(),0,3,1),t.s*=i.s):t=de(e,i,0,r.modulo,1),t=t.times(i),St=!0,e.minus(t))},it.naturalExponential=it.exp=function(){return Ia(this)},it.naturalLogarithm=it.ln=function(){return On(this)},it.negated=it.neg=function(){var i=new this.constructor(this);return i.s=-i.s,Dt(i)},it.plus=it.add=function(i){var t,e,r,n,s,a,l,c,h,d,f=this,p=f.constructor;if(i=new p(i),!f.d||!i.d)return!f.s||!i.s?i=new p(NaN):f.d||(i=new p(i.d||f.s===i.s?f:NaN)),i;if(f.s!=i.s)return i.s=-i.s,f.minus(i);if(h=f.d,d=i.d,l=p.precision,c=p.rounding,!h[0]||!d[0])return d[0]||(i=new p(f)),St?Dt(i,l,c):i;if(s=Qe(f.e/Et),r=Qe(i.e/Et),h=h.slice(),n=s-r,n){for(n<0?(e=h,n=-n,a=d.length):(e=d,r=s,a=h.length),s=Math.ceil(l/Et),a=s>a?s+1:a+1,n>a&&(n=a,e.length=1),e.reverse();n--;)e.push(0);e.reverse()}for(a=h.length,n=d.length,a-n<0&&(n=a,e=d,d=h,h=e),t=0;n;)t=(h[--n]=h[n]+d[n]+t)/Vr|0,h[n]%=Vr;for(t&&(h.unshift(t),++r),a=h.length;h[--a]==0;)h.pop();return i.d=h,i.e=qs(h,r),St?Dt(i,l,c):i},it.precision=it.sd=function(i){var t,e=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(Nn+i);return e.d?(t=Fc(e.d),i&&e.e+1>t&&(t=e.e+1)):t=NaN,t},it.round=function(){var i=this,t=i.constructor;return Dt(new t(i),i.e+1,t.rounding)},it.sine=it.sin=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+Math.max(e.e,e.sd())+Et,r.rounding=1,e=F_(r,Bc(r,e)),r.precision=i,r.rounding=t,Dt(fn>2?e.neg():e,i,t,!0)):new r(NaN)},it.squareRoot=it.sqrt=function(){var i,t,e,r,n,s,a=this,l=a.d,c=a.e,h=a.s,d=a.constructor;if(h!==1||!l||!l[0])return new d(!h||h<0&&(!l||l[0])?NaN:l?a:1/0);for(St=!1,h=Math.sqrt(+a),h==0||h==1/0?(t=Ge(l),(t.length+c)%2==0&&(t+="0"),h=Math.sqrt(t),c=Qe((c+1)/2)-(c<0||c%2),h==1/0?t="5e"+c:(t=h.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new d(t)):r=new d(h.toString()),e=(c=d.precision)+3;;)if(s=r,r=s.plus(de(a,s,e+2,1)).times(.5),Ge(s.d).slice(0,e)===(t=Ge(r.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!n&&t=="4999"){if(!n&&(Dt(s,c+1,0),s.times(s).eq(a))){r=s;break}e+=4,n=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Dt(r,c+1,1),i=!r.times(r).eq(a));break}return St=!0,Dt(r,c,d.rounding,i)},it.tangent=it.tan=function(){var i,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(i=r.precision,t=r.rounding,r.precision=i+10,r.rounding=1,e=e.sin(),e.s=1,e=de(e,new r(1).minus(e.times(e)).sqrt(),i+10,0),r.precision=i,r.rounding=t,Dt(fn==2||fn==4?e.neg():e,i,t,!0)):new r(NaN)},it.times=it.mul=function(i){var t,e,r,n,s,a,l,c,h,d=this,f=d.constructor,p=d.d,g=(i=new f(i)).d;if(i.s*=d.s,!p||!p[0]||!g||!g[0])return new f(!i.s||p&&!p[0]&&!g||g&&!g[0]&&!p?NaN:!p||!g?i.s/0:i.s*0);for(e=Qe(d.e/Et)+Qe(i.e/Et),c=p.length,h=g.length,c<h&&(s=p,p=g,g=s,a=c,c=h,h=a),s=[],a=c+h,r=a;r--;)s.push(0);for(r=h;--r>=0;){for(t=0,n=c+r;n>r;)l=s[n]+g[r]*p[n-r-1]+t,s[n--]=l%Vr|0,t=l/Vr|0;s[n]=(s[n]+t)%Vr|0}for(;!s[--a];)s.pop();return t?++e:s.shift(),i.d=s,i.e=qs(s,e),St?Dt(i,f.precision,f.rounding):i},it.toBinary=function(i,t){return $a(this,2,i,t)},it.toDecimalPlaces=it.toDP=function(i,t){var e=this,r=e.constructor;return e=new r(e),i===void 0?e:(cr(i,0,Mn),t===void 0?t=r.rounding:cr(t,0,8),Dt(e,i+e.e+1,t))},it.toExponential=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=rn(r,!0):(cr(i,0,Mn),t===void 0?t=n.rounding:cr(t,0,8),r=Dt(new n(r),i+1,t),e=rn(r,!0,i+1)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toFixed=function(i,t){var e,r,n=this,s=n.constructor;return i===void 0?e=rn(n):(cr(i,0,Mn),t===void 0?t=s.rounding:cr(t,0,8),r=Dt(new s(n),i+n.e+1,t),e=rn(r,!1,i+r.e+1)),n.isNeg()&&!n.isZero()?"-"+e:e},it.toFraction=function(i){var t,e,r,n,s,a,l,c,h,d,f,p,g=this,w=g.d,m=g.constructor;if(!w)return new m(g);if(h=e=new m(1),r=c=new m(0),t=new m(r),s=t.e=Fc(w)-g.e-1,a=s%Et,t.d[0]=ze(10,a<0?Et+a:a),i==null)i=s>0?t:h;else{if(l=new m(i),!l.isInt()||l.lt(h))throw Error(Nn+l);i=l.gt(t)?s>0?t:h:l}for(St=!1,l=new m(Ge(w)),d=m.precision,m.precision=s=w.length*Et*2;f=de(l,t,0,1,1),n=e.plus(f.times(r)),n.cmp(i)!=1;)e=r,r=n,n=h,h=c.plus(f.times(n)),c=n,n=t,t=l.minus(f.times(n)),l=n;return n=de(i.minus(e),r,0,1,1),c=c.plus(n.times(h)),e=e.plus(n.times(r)),c.s=h.s=g.s,p=de(h,r,s,1).minus(g).abs().cmp(de(c,e,s,1).minus(g).abs())<1?[h,r]:[c,e],m.precision=d,St=!0,p},it.toHexadecimal=it.toHex=function(i,t){return $a(this,16,i,t)},it.toNearest=function(i,t){var e=this,r=e.constructor;if(e=new r(e),i==null){if(!e.d)return e;i=new r(1),t=r.rounding}else{if(i=new r(i),t===void 0?t=r.rounding:cr(t,0,8),!e.d)return i.s?e:i;if(!i.d)return i.s&&(i.s=e.s),i}return i.d[0]?(St=!1,e=de(e,i,0,t,1).times(i),St=!0,Dt(e)):(i.s=e.s,e=i),e},it.toNumber=function(){return+this},it.toOctal=function(i,t){return $a(this,8,i,t)},it.toPower=it.pow=function(i){var t,e,r,n,s,a,l=this,c=l.constructor,h=+(i=new c(i));if(!l.d||!i.d||!l.d[0]||!i.d[0])return new c(ze(+l,h));if(l=new c(l),l.eq(1))return l;if(r=c.precision,s=c.rounding,i.eq(1))return Dt(l,r,s);if(t=Qe(i.e/Et),t>=i.d.length-1&&(e=h<0?-h:h)<=x_)return n=Mc(c,l,e,r),i.s<0?new c(1).div(n):Dt(n,r,s);if(a=l.s,a<0){if(t<i.d.length-1)return new c(NaN);if(i.d[t]&1||(a=1),l.e==0&&l.d[0]==1&&l.d.length==1)return l.s=a,l}return e=ze(+l,h),t=e==0||!isFinite(e)?Qe(h*(Math.log("0."+Ge(l.d))/Math.LN10+l.e+1)):new c(e+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?a/0:0):(St=!1,c.rounding=l.s=1,e=Math.min(12,(t+"").length),n=Ia(i.times(On(l,r+e)),r),n.d&&(n=Dt(n,r+5,1),es(n.d,r,s)&&(t=r+10,n=Dt(Ia(i.times(On(l,t+e)),t),t+5,1),+Ge(n.d).slice(r+1,r+15)+1==1e14&&(n=Dt(n,r+1,0)))),n.s=a,St=!0,c.rounding=s,Dt(n,r,s))},it.toPrecision=function(i,t){var e,r=this,n=r.constructor;return i===void 0?e=rn(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(cr(i,1,Mn),t===void 0?t=n.rounding:cr(t,0,8),r=Dt(new n(r),i,t),e=rn(r,i<=r.e||r.e<=n.toExpNeg,i)),r.isNeg()&&!r.isZero()?"-"+e:e},it.toSignificantDigits=it.toSD=function(i,t){var e=this,r=e.constructor;return i===void 0?(i=r.precision,t=r.rounding):(cr(i,1,Mn),t===void 0?t=r.rounding:cr(t,0,8)),Dt(new r(e),i,t)},it.toString=function(){var i=this,t=i.constructor,e=rn(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()&&!i.isZero()?"-"+e:e},it.truncated=it.trunc=function(){return Dt(new this.constructor(this),this.e+1,1)},it.valueOf=it.toJSON=function(){var i=this,t=i.constructor,e=rn(i,i.e<=t.toExpNeg||i.e>=t.toExpPos);return i.isNeg()?"-"+e:e};function Ge(i){var t,e,r,n=i.length-1,s="",a=i[0];if(n>0){for(s+=a,t=1;t<n;t++)r=i[t]+"",e=Et-r.length,e&&(s+=Sn(e)),s+=r;a=i[t],r=a+"",e=Et-r.length,e&&(s+=Sn(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}function cr(i,t,e){if(i!==~~i||i<t||i>e)throw Error(Nn+i)}function es(i,t,e,r){var n,s,a,l;for(s=i[0];s>=10;s/=10)--t;return--t<0?(t+=Et,n=0):(n=Math.ceil((t+1)/Et),t%=Et),s=ze(10,Et-t),l=i[n]%s|0,r==null?t<3?(t==0?l=l/100|0:t==1&&(l=l/10|0),a=e<4&&l==99999||e>3&&l==49999||l==5e4||l==0):a=(e<4&&l+1==s||e>3&&l+1==s/2)&&(i[n+1]/s/100|0)==ze(10,t-2)-1||(l==s/2||l==0)&&(i[n+1]/s/100|0)==0:t<4?(t==0?l=l/1e3|0:t==1?l=l/100|0:t==2&&(l=l/10|0),a=(r||e<4)&&l==9999||!r&&e>3&&l==4999):a=((r||e<4)&&l+1==s||!r&&e>3&&l+1==s/2)&&(i[n+1]/s/1e3|0)==ze(10,t-3)-1,a}function ks(i,t,e){for(var r,n=[0],s,a=0,l=i.length;a<l;){for(s=n.length;s--;)n[s]*=t;for(n[0]+=Sa.indexOf(i.charAt(a++)),r=0;r<n.length;r++)n[r]>e-1&&(n[r+1]===void 0&&(n[r+1]=0),n[r+1]+=n[r]/e|0,n[r]%=e)}return n.reverse()}function A_(i,t){var e,r,n;if(t.isZero())return t;r=t.d.length,r<32?(e=Math.ceil(r/3),n=(1/Ws(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i.precision+=e,t=bi(i,1,t.times(n),new i(1));for(var s=e;s--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return i.precision-=e,t}var de=function(){function i(r,n,s){var a,l=0,c=r.length;for(r=r.slice();c--;)a=r[c]*n+l,r[c]=a%s|0,l=a/s|0;return l&&r.unshift(l),r}function t(r,n,s,a){var l,c;if(s!=a)c=s>a?1:-1;else for(l=c=0;l<s;l++)if(r[l]!=n[l]){c=r[l]>n[l]?1:-1;break}return c}function e(r,n,s,a){for(var l=0;s--;)r[s]-=l,l=r[s]<n[s]?1:0,r[s]=l*a+r[s]-n[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,n,s,a,l,c){var h,d,f,p,g,w,m,y,v,x,b,M,E,F,N,S,T,A,O,L,q=r.constructor,U=r.s==n.s?1:-1,W=r.d,z=n.d;if(!W||!W[0]||!z||!z[0])return new q(!r.s||!n.s||(W?z&&W[0]==z[0]:!z)?NaN:W&&W[0]==0||!z?U*0:U/0);for(c?(g=1,d=r.e-n.e):(c=Vr,g=Et,d=Qe(r.e/g)-Qe(n.e/g)),O=z.length,T=W.length,v=new q(U),x=v.d=[],f=0;z[f]==(W[f]||0);f++);if(z[f]>(W[f]||0)&&d--,s==null?(F=s=q.precision,a=q.rounding):l?F=s+(r.e-n.e)+1:F=s,F<0)x.push(1),w=!0;else{if(F=F/g+2|0,f=0,O==1){for(p=0,z=z[0],F++;(f<T||p)&&F--;f++)N=p*c+(W[f]||0),x[f]=N/z|0,p=N%z|0;w=p||f<T}else{for(p=c/(z[0]+1)|0,p>1&&(z=i(z,p,c),W=i(W,p,c),O=z.length,T=W.length),S=O,b=W.slice(0,O),M=b.length;M<O;)b[M++]=0;L=z.slice(),L.unshift(0),A=z[0],z[1]>=c/2&&++A;do p=0,h=t(z,b,O,M),h<0?(E=b[0],O!=M&&(E=E*c+(b[1]||0)),p=E/A|0,p>1?(p>=c&&(p=c-1),m=i(z,p,c),y=m.length,M=b.length,h=t(m,b,y,M),h==1&&(p--,e(m,O<y?L:z,y,c))):(p==0&&(h=p=1),m=z.slice()),y=m.length,y<M&&m.unshift(0),e(b,m,M,c),h==-1&&(M=b.length,h=t(z,b,O,M),h<1&&(p++,e(b,O<M?L:z,M,c))),M=b.length):h===0&&(p++,b=[0]),x[f++]=p,h&&b[0]?b[M++]=W[S]||0:(b=[W[S]],M=1);while((S++<T||b[0]!==void 0)&&F--);w=b[0]!==void 0}x[0]||x.shift()}if(g==1)v.e=d,bc=w;else{for(f=1,p=x[0];p>=10;p/=10)f++;v.e=f+d*g-1,Dt(v,l?s+v.e+1:s,a,w)}return v}}();function Dt(i,t,e,r){var n,s,a,l,c,h,d,f,p,g=i.constructor;t:if(t!=null){if(f=i.d,!f)return i;for(n=1,l=f[0];l>=10;l/=10)n++;if(s=t-n,s<0)s+=Et,a=t,d=f[p=0],c=d/ze(10,n-a-1)%10|0;else if(p=Math.ceil((s+1)/Et),l=f.length,p>=l)if(r){for(;l++<=p;)f.push(0);d=c=0,n=1,s%=Et,a=s-Et+1}else break t;else{for(d=l=f[p],n=1;l>=10;l/=10)n++;s%=Et,a=s-Et+n,c=a<0?0:d/ze(10,n-a-1)%10|0}if(r=r||t<0||f[p+1]!==void 0||(a<0?d:d%ze(10,n-a-1)),h=e<4?(c||r)&&(e==0||e==(i.s<0?3:2)):c>5||c==5&&(e==4||r||e==6&&(s>0?a>0?d/ze(10,n-a):0:f[p-1])%10&1||e==(i.s<0?8:7)),t<1||!f[0])return f.length=0,h?(t-=i.e+1,f[0]=ze(10,(Et-t%Et)%Et),i.e=-t||0):f[0]=i.e=0,i;if(s==0?(f.length=p,l=1,p--):(f.length=p+1,l=ze(10,Et-s),f[p]=a>0?(d/ze(10,n-a)%ze(10,a)|0)*l:0),h)for(;;)if(p==0){for(s=1,a=f[0];a>=10;a/=10)s++;for(a=f[0]+=l,l=1;a>=10;a/=10)l++;s!=l&&(i.e++,f[0]==Vr&&(f[0]=1));break}else{if(f[p]+=l,f[p]!=Vr)break;f[p--]=0,l=1}for(s=f.length;f[--s]===0;)f.pop()}return St&&(i.e>g.maxE?(i.d=null,i.e=NaN):i.e<g.minE&&(i.e=0,i.d=[0])),i}function rn(i,t,e){if(!i.isFinite())return Oc(i);var r,n=i.e,s=Ge(i.d),a=s.length;return t?(e&&(r=e-a)>0?s=s.charAt(0)+"."+s.slice(1)+Sn(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i.e<0?"e":"e+")+i.e):n<0?(s="0."+Sn(-n-1)+s,e&&(r=e-a)>0&&(s+=Sn(r))):n>=a?(s+=Sn(n+1-a),e&&(r=e-n-1)>0&&(s=s+"."+Sn(r))):((r=n+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),e&&(r=e-a)>0&&(n+1===a&&(s+="."),s+=Sn(r))),s}function qs(i,t){var e=i[0];for(t*=Et;e>=10;e/=10)t++;return t}function Us(i,t,e){if(t>E_)throw St=!0,e&&(i.precision=e),Error(xc);return Dt(new i(Rs),t,1,!0)}function Yr(i,t,e){if(t>Ba)throw Error(xc);return Dt(new i(Ps),t,e,!0)}function Fc(i){var t=i.length-1,e=t*Et+1;if(t=i[t],t){for(;t%10==0;t/=10)e--;for(t=i[0];t>=10;t/=10)e++}return e}function Sn(i){for(var t="";i--;)t+="0";return t}function Mc(i,t,e,r){var n,s=new i(1),a=Math.ceil(r/Et+4);for(St=!1;;){if(e%2&&(s=s.times(t),Ic(s.d,a)&&(n=!0)),e=Qe(e/2),e===0){e=s.d.length-1,n&&s.d[e]===0&&++s.d[e];break}t=t.times(t),Ic(t.d,a)}return St=!0,s}function Nc(i){return i.d[i.d.length-1]&1}function Sc(i,t,e){for(var r,n=new i(t[0]),s=0;++s<t.length;)if(r=new i(t[s]),r.s)n[e](r)&&(n=r);else{n=r;break}return n}function Ia(i,t){var e,r,n,s,a,l,c,h=0,d=0,f=0,p=i.constructor,g=p.rounding,w=p.precision;if(!i.d||!i.d[0]||i.e>17)return new p(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:NaN);for(t==null?(St=!1,c=w):c=t,l=new p(.03125);i.e>-2;)i=i.times(l),f+=5;for(r=Math.log(ze(2,f))/Math.LN10*2+5|0,c+=r,e=s=a=new p(1),p.precision=c;;){if(s=Dt(s.times(i),c,1),e=e.times(++d),l=a.plus(de(s,e,c,1)),Ge(l.d).slice(0,c)===Ge(a.d).slice(0,c)){for(n=f;n--;)a=Dt(a.times(a),c,1);if(t==null)if(h<3&&es(a.d,c-r,g,h))p.precision=c+=10,e=s=l=new p(1),d=0,h++;else return Dt(a,p.precision=w,g,St=!0);else return p.precision=w,a}a=l}}function On(i,t){var e,r,n,s,a,l,c,h,d,f,p,g=1,w=10,m=i,y=m.d,v=m.constructor,x=v.rounding,b=v.precision;if(m.s<0||!y||!y[0]||!m.e&&y[0]==1&&y.length==1)return new v(y&&!y[0]?-1/0:m.s!=1?NaN:y?0:m);if(t==null?(St=!1,d=b):d=t,v.precision=d+=w,e=Ge(y),r=e.charAt(0),Math.abs(s=m.e)<15e14){for(;r<7&&r!=1||r==1&&e.charAt(1)>3;)m=m.times(i),e=Ge(m.d),r=e.charAt(0),g++;s=m.e,r>1?(m=new v("0."+e),s++):m=new v(r+"."+e.slice(1))}else return h=Us(v,d+2,b).times(s+""),m=On(new v(r+"."+e.slice(1)),d-w).plus(h),v.precision=b,t==null?Dt(m,b,x,St=!0):m;for(f=m,c=a=m=de(m.minus(1),m.plus(1),d,1),p=Dt(m.times(m),d,1),n=3;;){if(a=Dt(a.times(p),d,1),h=c.plus(de(a,new v(n),d,1)),Ge(h.d).slice(0,d)===Ge(c.d).slice(0,d))if(c=c.times(2),s!==0&&(c=c.plus(Us(v,d+2,b).times(s+""))),c=de(c,new v(g),d,1),t==null)if(es(c.d,d-w,x,l))v.precision=d+=w,h=a=m=de(f.minus(1),f.plus(1),d,1),p=Dt(m.times(m),d,1),n=l=1;else return Dt(c,v.precision=b,x,St=!0);else return v.precision=b,c;c=h,n+=2}}function Oc(i){return String(i.s*i.s/0)}function Ta(i,t){var e,r,n;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),r=0;t.charCodeAt(r)===48;r++);for(n=t.length;t.charCodeAt(n-1)===48;--n);if(t=t.slice(r,n),t){if(n-=r,i.e=e=e-r-1,i.d=[],r=(e+1)%Et,e<0&&(r+=Et),r<n){for(r&&i.d.push(+t.slice(0,r)),n-=Et;r<n;)i.d.push(+t.slice(r,r+=Et));t=t.slice(r),r=Et-t.length}else r-=n;for(;r--;)t+="0";i.d.push(+t),St&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function C_(i,t){var e,r,n,s,a,l,c,h,d;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Cc.test(t))return Ta(i,t)}else if(t==="Infinity"||t==="NaN")return+t||(i.s=NaN),i.e=NaN,i.d=null,i;if(D_.test(t))e=16,t=t.toLowerCase();else if(y_.test(t))e=2;else if(b_.test(t))e=8;else throw Error(Nn+t);for(s=t.search(/p/i),s>0?(c=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),a=s>=0,r=i.constructor,a&&(t=t.replace(".",""),l=t.length,s=l-s,n=Mc(r,new r(e),s,s*2)),h=ks(t,e,Vr),d=h.length-1,s=d;h[s]===0;--s)h.pop();return s<0?new r(i.s*0):(i.e=qs(h,d),i.d=h,St=!1,a&&(i=de(i,n,l*4)),c&&(i=i.times(Math.abs(c)<54?ze(2,c):xi.pow(2,c))),St=!0,i)}function F_(i,t){var e,r=t.d.length;if(r<3)return t.isZero()?t:bi(i,2,t,t);e=1.4*Math.sqrt(r),e=e>16?16:e|0,t=t.times(1/Ws(5,e)),t=bi(i,2,t,t);for(var n,s=new i(5),a=new i(16),l=new i(20);e--;)n=t.times(t),t=t.times(s.plus(n.times(a.times(n).minus(l))));return t}function bi(i,t,e,r,n){var s,a,l,c,h=i.precision,d=Math.ceil(h/Et);for(St=!1,c=e.times(e),l=new i(r);;){if(a=de(l.times(c),new i(t++*t++),h,1),l=n?r.plus(a):r.minus(a),r=de(a.times(c),new i(t++*t++),h,1),a=l.plus(r),a.d[d]!==void 0){for(s=d;a.d[s]===l.d[s]&&s--;);if(s==-1)break}s=l,l=r,r=a,a=s}return St=!0,a.d.length=d+1,a}function Ws(i,t){for(var e=i;--t;)e*=i;return e}function Bc(i,t){var e,r=t.s<0,n=Yr(i,i.precision,1),s=n.times(.5);if(t=t.abs(),t.lte(s))return fn=r?4:1,t;if(e=t.divToInt(n),e.isZero())fn=r?3:2;else{if(t=t.minus(e.times(n)),t.lte(s))return fn=Nc(e)?r?2:3:r?4:1,t;fn=Nc(e)?r?1:4:r?3:2}return t.minus(n).abs()}function $a(i,t,e,r){var n,s,a,l,c,h,d,f,p,g=i.constructor,w=e!==void 0;if(w?(cr(e,1,Mn),r===void 0?r=g.rounding:cr(r,0,8)):(e=g.precision,r=g.rounding),!i.isFinite())d=Oc(i);else{for(d=rn(i),a=d.indexOf("."),w?(n=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):n=t,a>=0&&(d=d.replace(".",""),p=new g(1),p.e=d.length-a,p.d=ks(rn(p),10,n),p.e=p.d.length),f=ks(d,10,n),s=c=f.length;f[--c]==0;)f.pop();if(!f[0])d=w?"0p+0":"0";else{if(a<0?s--:(i=new g(i),i.d=f,i.e=s,i=de(i,p,e,r,0,n),f=i.d,s=i.e,h=bc),a=f[e],l=n/2,h=h||f[e+1]!==void 0,h=r<4?(a!==void 0||h)&&(r===0||r===(i.s<0?3:2)):a>l||a===l&&(r===4||h||r===6&&f[e-1]&1||r===(i.s<0?8:7)),f.length=e,h)for(;++f[--e]>n-1;)f[e]=0,e||(++s,f.unshift(1));for(c=f.length;!f[c-1];--c);for(a=0,d="";a<c;a++)d+=Sa.charAt(f[a]);if(w){if(c>1)if(t==16||t==8){for(a=t==16?4:3,--c;c%a;c++)d+="0";for(f=ks(d,n,t),c=f.length;!f[c-1];--c);for(a=1,d="1.";a<c;a++)d+=Sa.charAt(f[a])}else d=d.charAt(0)+"."+d.slice(1);d=d+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)d="0"+d;d="0."+d}else if(++s>c)for(s-=c;s--;)d+="0";else s<c&&(d=d.slice(0,s)+"."+d.slice(s))}d=(t==16?"0x":t==2?"0b":t==8?"0o":"")+d}return i.s<0?"-"+d:d}function Ic(i,t){if(i.length>t)return i.length=t,!0}function M_(i){return new this(i).abs()}function N_(i){return new this(i).acos()}function S_(i){return new this(i).acosh()}function O_(i,t){return new this(i).plus(t)}function B_(i){return new this(i).asin()}function I_(i){return new this(i).asinh()}function T_(i){return new this(i).atan()}function $_(i){return new this(i).atanh()}function L_(i,t){i=new this(i),t=new this(t);var e,r=this.precision,n=this.rounding,s=r+4;return!i.s||!t.s?e=new this(NaN):!i.d&&!t.d?(e=Yr(this,s,1).times(t.s>0?.25:.75),e.s=i.s):!t.d||i.isZero()?(e=t.s<0?Yr(this,r,n):new this(0),e.s=i.s):!i.d||t.isZero()?(e=Yr(this,s,1).times(.5),e.s=i.s):t.s<0?(this.precision=s,this.rounding=1,e=this.atan(de(i,t,s,1)),t=Yr(this,s,1),this.precision=r,this.rounding=n,e=i.s<0?e.minus(t):e.plus(t)):e=this.atan(de(i,t,s,1)),e}function R_(i){return new this(i).cbrt()}function P_(i){return Dt(i=new this(i),i.e+1,2)}function z_(i,t,e){return new this(i).clamp(t,e)}function k_(i){if(!i||typeof i!="object")throw Error(zs+"Object expected");var t,e,r,n=i.defaults===!0,s=["precision",1,Mn,"rounding",0,8,"toExpNeg",-Di,0,"toExpPos",0,Di,"maxE",0,Di,"minE",-Di,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(e=s[t],n&&(this[e]=Oa[e]),(r=i[e])!==void 0)if(Qe(r)===r&&r>=s[t+1]&&r<=s[t+2])this[e]=r;else throw Error(Nn+e+": "+r);if(e="crypto",n&&(this[e]=Oa[e]),(r=i[e])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(Ec);else this[e]=!1;else throw Error(Nn+e+": "+r);return this}function q_(i){return new this(i).cos()}function U_(i){return new this(i).cosh()}function Tc(i){var t,e,r;function n(s){var a,l,c,h=this;if(!(h instanceof n))return new n(s);if(h.constructor=n,$c(s)){h.s=s.s,St?!s.d||s.e>n.maxE?(h.e=NaN,h.d=null):s.e<n.minE?(h.e=0,h.d=[0]):(h.e=s.e,h.d=s.d.slice()):(h.e=s.e,h.d=s.d?s.d.slice():s.d);return}if(c=typeof s,c==="number"){if(s===0){h.s=1/s<0?-1:1,h.e=0,h.d=[0];return}if(s<0?(s=-s,h.s=-1):h.s=1,s===~~s&&s<1e7){for(a=0,l=s;l>=10;l/=10)a++;St?a>n.maxE?(h.e=NaN,h.d=null):a<n.minE?(h.e=0,h.d=[0]):(h.e=a,h.d=[s]):(h.e=a,h.d=[s]);return}else if(s*0!==0){s||(h.s=NaN),h.e=NaN,h.d=null;return}return Ta(h,s.toString())}else if(c!=="string")throw Error(Nn+s);return(l=s.charCodeAt(0))===45?(s=s.slice(1),h.s=-1):(l===43&&(s=s.slice(1)),h.s=1),Cc.test(s)?Ta(h,s):C_(h,s)}if(n.prototype=it,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=k_,n.clone=Tc,n.isDecimal=$c,n.abs=M_,n.acos=N_,n.acosh=S_,n.add=O_,n.asin=B_,n.asinh=I_,n.atan=T_,n.atanh=$_,n.atan2=L_,n.cbrt=R_,n.ceil=P_,n.clamp=z_,n.cos=q_,n.cosh=U_,n.div=W_,n.exp=j_,n.floor=V_,n.hypot=Y_,n.ln=Z_,n.log=K_,n.log10=H_,n.log2=G_,n.max=J_,n.min=X_,n.mod=Q_,n.mul=tm,n.pow=em,n.random=rm,n.round=nm,n.sign=im,n.sin=sm,n.sinh=om,n.sqrt=am,n.sub=um,n.sum=lm,n.tan=cm,n.tanh=fm,n.trunc=hm,i===void 0&&(i={}),i&&i.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)i.hasOwnProperty(e=r[t++])||(i[e]=this[e]);return n.config(i),n}function W_(i,t){return new this(i).div(t)}function j_(i){return new this(i).exp()}function V_(i){return Dt(i=new this(i),i.e+1,3)}function Y_(){var i,t,e=new this(0);for(St=!1,i=0;i<arguments.length;)if(t=new this(arguments[i++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return St=!0,new this(1/0);e=t}return St=!0,e.sqrt()}function $c(i){return i instanceof xi||i&&i.toStringTag===Ac||!1}function Z_(i){return new this(i).ln()}function K_(i,t){return new this(i).log(t)}function G_(i){return new this(i).log(2)}function H_(i){return new this(i).log(10)}function J_(){return Sc(this,arguments,"lt")}function X_(){return Sc(this,arguments,"gt")}function Q_(i,t){return new this(i).mod(t)}function tm(i,t){return new this(i).mul(t)}function em(i,t){return new this(i).pow(t)}function rm(i){var t,e,r,n,s=0,a=new this(1),l=[];if(i===void 0?i=this.precision:cr(i,1,Mn),r=Math.ceil(i/Et),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));s<r;)n=t[s],n>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:l[s++]=n%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);s<r;)n=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),n>=214e7?crypto.randomBytes(4).copy(t,s):(l.push(n%1e7),s+=4);s=r/4}else throw Error(Ec);else for(;s<r;)l[s++]=Math.random()*1e7|0;for(r=l[--s],i%=Et,r&&i&&(n=ze(10,Et-i),l[s]=(r/n|0)*n);l[s]===0;s--)l.pop();if(s<0)e=0,l=[0];else{for(e=-1;l[0]===0;e-=Et)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<Et&&(e-=Et-r)}return a.e=e,a.d=l,a}function nm(i){return Dt(i=new this(i),i.e+1,this.rounding)}function im(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function sm(i){return new this(i).sin()}function om(i){return new this(i).sinh()}function am(i){return new this(i).sqrt()}function um(i,t){return new this(i).sub(t)}function lm(){var i=0,t=arguments,e=new this(t[i]);for(St=!1;e.s&&++i<t.length;)e=e.plus(t[i]);return St=!0,Dt(e,this.precision,this.rounding)}function cm(i){return new this(i).tan()}function fm(i){return new this(i).tanh()}function hm(i){return Dt(i=new this(i),i.e+1,1)}it[Symbol.for("nodejs.util.inspect.custom")]=it.toString,it[Symbol.toStringTag]="Decimal";var xi=it.constructor=Tc(Oa);Rs=new xi(Rs),Ps=new xi(Ps);var dm="BigNumber",pm=["?on","config"],_m=mt(dm,pm,i=>{var{on:t,config:e}=i,r=xi.clone({precision:e.precision,modulo:xi.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(n){return new r(n.value)},t&&t("config",function(n,s){n.precision!==s.precision&&r.config({precision:n.precision})}),r},{isClass:!0}),Lc={exports:{}};/**
41
41
  * @license Complex.js v2.1.1 12/05/2020
42
42
  *
43
43
  * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
44
44
  * Dual licensed under the MIT or GPL Version 2 licenses.
45
- **/(function(i,t){(function(e){var r=Math.cosh||function(h){return Math.abs(h)<1e-9?1-h:(Math.exp(h)+Math.exp(-h))*.5},n=Math.sinh||function(h){return Math.abs(h)<1e-9?h:(Math.exp(h)-Math.exp(-h))*.5},s=function(h){var p=Math.PI/4;if(-p>h||h>p)return Math.cos(h)-1;var g=h*h;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(h,p){var g=Math.abs(h),w=Math.abs(p);return g<3e3&&w<3e3?Math.sqrt(g*g+w*w):(g<w?(g=w,w=h/p):w=p/h,g*Math.sqrt(1+w*w))},l=function(){throw SyntaxError("Invalid Param")};function c(h,p){var g=Math.abs(h),w=Math.abs(p);return h===0?Math.log(w):p===0?Math.log(g):g<3e3&&w<3e3?Math.log(h*h+p*p)*.5:(h=h/2,p=p/2,.5*Math.log(h*h+p*p)+Math.LN2)}var f=function(h,p){var g={re:0,im:0};if(h==null)g.re=g.im=0;else if(p!==void 0)g.re=h,g.im=p;else switch(typeof h){case"object":if("im"in h&&"re"in h)g.re=h.re,g.im=h.im;else if("abs"in h&&"arg"in h){if(!Number.isFinite(h.abs)&&Number.isFinite(h.arg))return d.INFINITY;g.re=h.abs*Math.cos(h.arg),g.im=h.abs*Math.sin(h.arg)}else if("r"in h&&"phi"in h){if(!Number.isFinite(h.r)&&Number.isFinite(h.phi))return d.INFINITY;g.re=h.r*Math.cos(h.phi),g.im=h.r*Math.sin(h.phi)}else h.length===2?(g.re=h[0],g.im=h[1]):l();break;case"string":g.im=g.re=0;var w=h.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),_=1,y=0;w===null&&l();for(var v=0;v<w.length;v++){var x=w[v];x===" "||x===" "||x===`
46
- `||(x==="+"?_++:x==="-"?y++:x==="i"||x==="I"?(_+y===0&&l(),w[v+1]!==" "&&!isNaN(w[v+1])?(g.im+=parseFloat((y%2?"-":"")+w[v+1]),v++):g.im+=parseFloat((y%2?"-":"")+"1"),_=y=0):((_+y===0||isNaN(x))&&l(),w[v+1]==="i"||w[v+1]==="I"?(g.im+=parseFloat((y%2?"-":"")+x),v++):g.re+=parseFloat((y%2?"-":"")+x),_=y=0))}_+y>0&&l();break;case"number":g.im=0,g.re=h;break;default:l()}return isNaN(g.re)||isNaN(g.im),g};function d(h,p){if(!(this instanceof d))return new d(h,p);var g=f(h,p);this.re=g.re,this.im=g.im}d.prototype={re:0,im:0,sign:function(){var h=this.abs();return new d(this.re/h,this.im/h)},add:function(h,p){var g=new d(h,p);return this.isInfinite()&&g.isInfinite()?d.NAN:this.isInfinite()||g.isInfinite()?d.INFINITY:new d(this.re+g.re,this.im+g.im)},sub:function(h,p){var g=new d(h,p);return this.isInfinite()&&g.isInfinite()?d.NAN:this.isInfinite()||g.isInfinite()?d.INFINITY:new d(this.re-g.re,this.im-g.im)},mul:function(h,p){var g=new d(h,p);return this.isInfinite()&&g.isZero()||this.isZero()&&g.isInfinite()?d.NAN:this.isInfinite()||g.isInfinite()?d.INFINITY:g.im===0&&this.im===0?new d(this.re*g.re,0):new d(this.re*g.re-this.im*g.im,this.re*g.im+this.im*g.re)},div:function(h,p){var g=new d(h,p);if(this.isZero()&&g.isZero()||this.isInfinite()&&g.isInfinite())return d.NAN;if(this.isInfinite()||g.isZero())return d.INFINITY;if(this.isZero()||g.isInfinite())return d.ZERO;h=this.re,p=this.im;var w=g.re,_=g.im,y,v;return _===0?new d(h/w,p/w):Math.abs(w)<Math.abs(_)?(v=w/_,y=w*v+_,new d((h*v+p)/y,(p*v-h)/y)):(v=_/w,y=_*v+w,new d((h+p*v)/y,(p-h*v)/y))},pow:function(h,p){var g=new d(h,p);if(h=this.re,p=this.im,g.isZero())return d.ONE;if(g.im===0){if(p===0&&h>0)return new d(Math.pow(h,g.re),0);if(h===0)switch((g.re%4+4)%4){case 0:return new d(Math.pow(p,g.re),0);case 1:return new d(0,Math.pow(p,g.re));case 2:return new d(-Math.pow(p,g.re),0);case 3:return new d(0,-Math.pow(p,g.re))}}if(h===0&&p===0&&g.re>0&&g.im>=0)return d.ZERO;var w=Math.atan2(p,h),_=c(h,p);return h=Math.exp(g.re*_-g.im*w),p=g.im*_+g.re*w,new d(h*Math.cos(p),h*Math.sin(p))},sqrt:function(){var h=this.re,p=this.im,g=this.abs(),w,_;if(h>=0){if(p===0)return new d(Math.sqrt(h),0);w=.5*Math.sqrt(2*(g+h))}else w=Math.abs(p)/Math.sqrt(2*(g-h));return h<=0?_=.5*Math.sqrt(2*(g-h)):_=Math.abs(p)/Math.sqrt(2*(g+h)),new d(w,p<0?-_:_)},exp:function(){var h=Math.exp(this.re);return this.im,new d(h*Math.cos(this.im),h*Math.sin(this.im))},expm1:function(){var h=this.re,p=this.im;return new d(Math.expm1(h)*Math.cos(p)+s(p),Math.exp(h)*Math.sin(p))},log:function(){var h=this.re,p=this.im;return new d(c(h,p),Math.atan2(p,h))},abs:function(){return a(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var h=this.re,p=this.im;return new d(Math.sin(h)*r(p),Math.cos(h)*n(p))},cos:function(){var h=this.re,p=this.im;return new d(Math.cos(h)*r(p),-Math.sin(h)*n(p))},tan:function(){var h=2*this.re,p=2*this.im,g=Math.cos(h)+r(p);return new d(Math.sin(h)/g,n(p)/g)},cot:function(){var h=2*this.re,p=2*this.im,g=Math.cos(h)-r(p);return new d(-Math.sin(h)/g,n(p)/g)},sec:function(){var h=this.re,p=this.im,g=.5*r(2*p)+.5*Math.cos(2*h);return new d(Math.cos(h)*r(p)/g,Math.sin(h)*n(p)/g)},csc:function(){var h=this.re,p=this.im,g=.5*r(2*p)-.5*Math.cos(2*h);return new d(Math.sin(h)*r(p)/g,-Math.cos(h)*n(p)/g)},asin:function(){var h=this.re,p=this.im,g=new d(p*p-h*h+1,-2*h*p).sqrt(),w=new d(g.re-p,g.im+h).log();return new d(w.im,-w.re)},acos:function(){var h=this.re,p=this.im,g=new d(p*p-h*h+1,-2*h*p).sqrt(),w=new d(g.re-p,g.im+h).log();return new d(Math.PI/2-w.im,w.re)},atan:function(){var h=this.re,p=this.im;if(h===0){if(p===1)return new d(0,1/0);if(p===-1)return new d(0,-1/0)}var g=h*h+(1-p)*(1-p),w=new d((1-p*p-h*h)/g,-2*h/g).log();return new d(-.5*w.im,.5*w.re)},acot:function(){var h=this.re,p=this.im;if(p===0)return new d(Math.atan2(1,h),0);var g=h*h+p*p;return g!==0?new d(h/g,-p/g).atan():new d(h!==0?h/0:0,p!==0?-p/0:0).atan()},asec:function(){var h=this.re,p=this.im;if(h===0&&p===0)return new d(0,1/0);var g=h*h+p*p;return g!==0?new d(h/g,-p/g).acos():new d(h!==0?h/0:0,p!==0?-p/0:0).acos()},acsc:function(){var h=this.re,p=this.im;if(h===0&&p===0)return new d(Math.PI/2,1/0);var g=h*h+p*p;return g!==0?new d(h/g,-p/g).asin():new d(h!==0?h/0:0,p!==0?-p/0:0).asin()},sinh:function(){var h=this.re,p=this.im;return new d(n(h)*Math.cos(p),r(h)*Math.sin(p))},cosh:function(){var h=this.re,p=this.im;return new d(r(h)*Math.cos(p),n(h)*Math.sin(p))},tanh:function(){var h=2*this.re,p=2*this.im,g=r(h)+Math.cos(p);return new d(n(h)/g,Math.sin(p)/g)},coth:function(){var h=2*this.re,p=2*this.im,g=r(h)-Math.cos(p);return new d(n(h)/g,-Math.sin(p)/g)},csch:function(){var h=this.re,p=this.im,g=Math.cos(2*p)-r(2*h);return new d(-2*n(h)*Math.cos(p)/g,2*r(h)*Math.sin(p)/g)},sech:function(){var h=this.re,p=this.im,g=Math.cos(2*p)+r(2*h);return new d(2*r(h)*Math.cos(p)/g,-2*n(h)*Math.sin(p)/g)},asinh:function(){var h=this.im;this.im=-this.re,this.re=h;var p=this.asin();return this.re=-this.im,this.im=h,h=p.re,p.re=-p.im,p.im=h,p},acosh:function(){var h=this.acos();if(h.im<=0){var p=h.re;h.re=-h.im,h.im=p}else{var p=h.im;h.im=-h.re,h.re=p}return h},atanh:function(){var h=this.re,p=this.im,g=h>1&&p===0,w=1-h,_=1+h,y=w*w+p*p,v=y!==0?new d((_*w-p*p)/y,(p*w+_*p)/y):new d(h!==-1?h/0:0,p!==0?p/0:0),x=v.re;return v.re=c(v.re,v.im)/2,v.im=Math.atan2(v.im,x)/2,g&&(v.im=-v.im),v},acoth:function(){var h=this.re,p=this.im;if(h===0&&p===0)return new d(0,Math.PI/2);var g=h*h+p*p;return g!==0?new d(h/g,-p/g).atanh():new d(h!==0?h/0:0,p!==0?-p/0:0).atanh()},acsch:function(){var h=this.re,p=this.im;if(p===0)return new d(h!==0?Math.log(h+Math.sqrt(h*h+1)):1/0,0);var g=h*h+p*p;return g!==0?new d(h/g,-p/g).asinh():new d(h!==0?h/0:0,p!==0?-p/0:0).asinh()},asech:function(){var h=this.re,p=this.im;if(this.isZero())return d.INFINITY;var g=h*h+p*p;return g!==0?new d(h/g,-p/g).acosh():new d(h!==0?h/0:0,p!==0?-p/0:0).acosh()},inverse:function(){if(this.isZero())return d.INFINITY;if(this.isInfinite())return d.ZERO;var h=this.re,p=this.im,g=h*h+p*p;return new d(h/g,-p/g)},conjugate:function(){return new d(this.re,-this.im)},neg:function(){return new d(-this.re,-this.im)},ceil:function(h){return h=Math.pow(10,h||0),new d(Math.ceil(this.re*h)/h,Math.ceil(this.im*h)/h)},floor:function(h){return h=Math.pow(10,h||0),new d(Math.floor(this.re*h)/h,Math.floor(this.im*h)/h)},round:function(h){return h=Math.pow(10,h||0),new d(Math.round(this.re*h)/h,Math.round(this.im*h)/h)},equals:function(h,p){var g=new d(h,p);return Math.abs(g.re-this.re)<=d.EPSILON&&Math.abs(g.im-this.im)<=d.EPSILON},clone:function(){return new d(this.re,this.im)},toString:function(){var h=this.re,p=this.im,g="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(h)<d.EPSILON&&(h=0),Math.abs(p)<d.EPSILON&&(p=0),p===0?g+h:(h!==0?(g+=h,g+=" ",p<0?(p=-p,g+="-"):g+="+",g+=" "):p<0&&(p=-p,g+="-"),p!==1&&(g+=p),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())}},d.ZERO=new d(0,0),d.ONE=new d(1,0),d.I=new d(0,1),d.PI=new d(Math.PI,0),d.E=new d(Math.E,0),d.INFINITY=new d(1/0,1/0),d.NAN=new d(NaN,NaN),d.EPSILON=1e-15,Object.defineProperty(d,"__esModule",{value:!0}),d.default=d,d.Complex=d,i.exports=d})()})(Lc);var mm=Lc.exports,He=Gt(mm),gm="Complex",vm=[],wm=mt(gm,vm,()=>(Object.defineProperty(He,"name",{value:"Complex"}),He.prototype.constructor=He,He.prototype.type="Complex",He.prototype.isComplex=!0,He.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},He.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},He.prototype.format=function(i){var t="",e=this.im,r=this.re,n=Da(this.re,i),s=Da(this.im,i),a=_e(i)?i:i?i.precision:null;if(a!==null){var l=Math.pow(10,-a);Math.abs(r/e)<l&&(r=0),Math.abs(e/r)<l&&(e=0)}return e===0?t=n:r===0?e===1?t="i":e===-1?t="-i":t=s+"i":e<0?e===-1?t=n+" - i":t=n+" - "+s.substring(1)+"i":e===1?t=n+" + i":t=n+" + "+s+"i",t},He.fromPolar=function(i){switch(arguments.length){case 1:{var t=arguments[0];if(typeof t=="object")return He(t);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var e=arguments[0],r=arguments[1];if(_e(e)){if(Hl(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),_e(r))return new He({r:e,phi:r});throw new TypeError("Phi is not a number nor an angle unit.")}else throw new TypeError("Radius r is not a number.")}default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},He.prototype.valueOf=He.prototype.toString,He.fromJSON=function(i){return new He(i)},He.compare=function(i,t){return i.re>t.re?1:i.re<t.re?-1:i.im>t.im?1:i.im<t.im?-1:0},He),{isClass:!0}),Rc={exports:{}};/**
45
+ **/(function(i,t){(function(e){var r=Math.cosh||function(f){return Math.abs(f)<1e-9?1-f:(Math.exp(f)+Math.exp(-f))*.5},n=Math.sinh||function(f){return Math.abs(f)<1e-9?f:(Math.exp(f)-Math.exp(-f))*.5},s=function(f){var p=Math.PI/4;if(-p>f||f>p)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,p){var g=Math.abs(f),w=Math.abs(p);return g<3e3&&w<3e3?Math.sqrt(g*g+w*w):(g<w?(g=w,w=f/p):w=p/f,g*Math.sqrt(1+w*w))},l=function(){throw SyntaxError("Invalid Param")};function c(f,p){var g=Math.abs(f),w=Math.abs(p);return f===0?Math.log(w):p===0?Math.log(g):g<3e3&&w<3e3?Math.log(f*f+p*p)*.5:(f=f/2,p=p/2,.5*Math.log(f*f+p*p)+Math.LN2)}var h=function(f,p){var g={re:0,im:0};if(f==null)g.re=g.im=0;else if(p!==void 0)g.re=f,g.im=p;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 d.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 d.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 w=f.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),m=1,y=0;w===null&&l();for(var v=0;v<w.length;v++){var x=w[v];x===" "||x===" "||x===`
46
+ `||(x==="+"?m++:x==="-"?y++:x==="i"||x==="I"?(m+y===0&&l(),w[v+1]!==" "&&!isNaN(w[v+1])?(g.im+=parseFloat((y%2?"-":"")+w[v+1]),v++):g.im+=parseFloat((y%2?"-":"")+"1"),m=y=0):((m+y===0||isNaN(x))&&l(),w[v+1]==="i"||w[v+1]==="I"?(g.im+=parseFloat((y%2?"-":"")+x),v++):g.re+=parseFloat((y%2?"-":"")+x),m=y=0))}m+y>0&&l();break;case"number":g.im=0,g.re=f;break;default:l()}return isNaN(g.re)||isNaN(g.im),g};function d(f,p){if(!(this instanceof d))return new d(f,p);var g=h(f,p);this.re=g.re,this.im=g.im}d.prototype={re:0,im:0,sign:function(){var f=this.abs();return new d(this.re/f,this.im/f)},add:function(f,p){var g=new d(f,p);return this.isInfinite()&&g.isInfinite()?d.NAN:this.isInfinite()||g.isInfinite()?d.INFINITY:new d(this.re+g.re,this.im+g.im)},sub:function(f,p){var g=new d(f,p);return this.isInfinite()&&g.isInfinite()?d.NAN:this.isInfinite()||g.isInfinite()?d.INFINITY:new d(this.re-g.re,this.im-g.im)},mul:function(f,p){var g=new d(f,p);return this.isInfinite()&&g.isZero()||this.isZero()&&g.isInfinite()?d.NAN:this.isInfinite()||g.isInfinite()?d.INFINITY:g.im===0&&this.im===0?new d(this.re*g.re,0):new d(this.re*g.re-this.im*g.im,this.re*g.im+this.im*g.re)},div:function(f,p){var g=new d(f,p);if(this.isZero()&&g.isZero()||this.isInfinite()&&g.isInfinite())return d.NAN;if(this.isInfinite()||g.isZero())return d.INFINITY;if(this.isZero()||g.isInfinite())return d.ZERO;f=this.re,p=this.im;var w=g.re,m=g.im,y,v;return m===0?new d(f/w,p/w):Math.abs(w)<Math.abs(m)?(v=w/m,y=w*v+m,new d((f*v+p)/y,(p*v-f)/y)):(v=m/w,y=m*v+w,new d((f+p*v)/y,(p-f*v)/y))},pow:function(f,p){var g=new d(f,p);if(f=this.re,p=this.im,g.isZero())return d.ONE;if(g.im===0){if(p===0&&f>0)return new d(Math.pow(f,g.re),0);if(f===0)switch((g.re%4+4)%4){case 0:return new d(Math.pow(p,g.re),0);case 1:return new d(0,Math.pow(p,g.re));case 2:return new d(-Math.pow(p,g.re),0);case 3:return new d(0,-Math.pow(p,g.re))}}if(f===0&&p===0&&g.re>0&&g.im>=0)return d.ZERO;var w=Math.atan2(p,f),m=c(f,p);return f=Math.exp(g.re*m-g.im*w),p=g.im*m+g.re*w,new d(f*Math.cos(p),f*Math.sin(p))},sqrt:function(){var f=this.re,p=this.im,g=this.abs(),w,m;if(f>=0){if(p===0)return new d(Math.sqrt(f),0);w=.5*Math.sqrt(2*(g+f))}else w=Math.abs(p)/Math.sqrt(2*(g-f));return f<=0?m=.5*Math.sqrt(2*(g-f)):m=Math.abs(p)/Math.sqrt(2*(g+f)),new d(w,p<0?-m:m)},exp:function(){var f=Math.exp(this.re);return this.im,new d(f*Math.cos(this.im),f*Math.sin(this.im))},expm1:function(){var f=this.re,p=this.im;return new d(Math.expm1(f)*Math.cos(p)+s(p),Math.exp(f)*Math.sin(p))},log:function(){var f=this.re,p=this.im;return new d(c(f,p),Math.atan2(p,f))},abs:function(){return a(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var f=this.re,p=this.im;return new d(Math.sin(f)*r(p),Math.cos(f)*n(p))},cos:function(){var f=this.re,p=this.im;return new d(Math.cos(f)*r(p),-Math.sin(f)*n(p))},tan:function(){var f=2*this.re,p=2*this.im,g=Math.cos(f)+r(p);return new d(Math.sin(f)/g,n(p)/g)},cot:function(){var f=2*this.re,p=2*this.im,g=Math.cos(f)-r(p);return new d(-Math.sin(f)/g,n(p)/g)},sec:function(){var f=this.re,p=this.im,g=.5*r(2*p)+.5*Math.cos(2*f);return new d(Math.cos(f)*r(p)/g,Math.sin(f)*n(p)/g)},csc:function(){var f=this.re,p=this.im,g=.5*r(2*p)-.5*Math.cos(2*f);return new d(Math.sin(f)*r(p)/g,-Math.cos(f)*n(p)/g)},asin:function(){var f=this.re,p=this.im,g=new d(p*p-f*f+1,-2*f*p).sqrt(),w=new d(g.re-p,g.im+f).log();return new d(w.im,-w.re)},acos:function(){var f=this.re,p=this.im,g=new d(p*p-f*f+1,-2*f*p).sqrt(),w=new d(g.re-p,g.im+f).log();return new d(Math.PI/2-w.im,w.re)},atan:function(){var f=this.re,p=this.im;if(f===0){if(p===1)return new d(0,1/0);if(p===-1)return new d(0,-1/0)}var g=f*f+(1-p)*(1-p),w=new d((1-p*p-f*f)/g,-2*f/g).log();return new d(-.5*w.im,.5*w.re)},acot:function(){var f=this.re,p=this.im;if(p===0)return new d(Math.atan2(1,f),0);var g=f*f+p*p;return g!==0?new d(f/g,-p/g).atan():new d(f!==0?f/0:0,p!==0?-p/0:0).atan()},asec:function(){var f=this.re,p=this.im;if(f===0&&p===0)return new d(0,1/0);var g=f*f+p*p;return g!==0?new d(f/g,-p/g).acos():new d(f!==0?f/0:0,p!==0?-p/0:0).acos()},acsc:function(){var f=this.re,p=this.im;if(f===0&&p===0)return new d(Math.PI/2,1/0);var g=f*f+p*p;return g!==0?new d(f/g,-p/g).asin():new d(f!==0?f/0:0,p!==0?-p/0:0).asin()},sinh:function(){var f=this.re,p=this.im;return new d(n(f)*Math.cos(p),r(f)*Math.sin(p))},cosh:function(){var f=this.re,p=this.im;return new d(r(f)*Math.cos(p),n(f)*Math.sin(p))},tanh:function(){var f=2*this.re,p=2*this.im,g=r(f)+Math.cos(p);return new d(n(f)/g,Math.sin(p)/g)},coth:function(){var f=2*this.re,p=2*this.im,g=r(f)-Math.cos(p);return new d(n(f)/g,-Math.sin(p)/g)},csch:function(){var f=this.re,p=this.im,g=Math.cos(2*p)-r(2*f);return new d(-2*n(f)*Math.cos(p)/g,2*r(f)*Math.sin(p)/g)},sech:function(){var f=this.re,p=this.im,g=Math.cos(2*p)+r(2*f);return new d(2*r(f)*Math.cos(p)/g,-2*n(f)*Math.sin(p)/g)},asinh:function(){var f=this.im;this.im=-this.re,this.re=f;var p=this.asin();return this.re=-this.im,this.im=f,f=p.re,p.re=-p.im,p.im=f,p},acosh:function(){var f=this.acos();if(f.im<=0){var p=f.re;f.re=-f.im,f.im=p}else{var p=f.im;f.im=-f.re,f.re=p}return f},atanh:function(){var f=this.re,p=this.im,g=f>1&&p===0,w=1-f,m=1+f,y=w*w+p*p,v=y!==0?new d((m*w-p*p)/y,(p*w+m*p)/y):new d(f!==-1?f/0:0,p!==0?p/0:0),x=v.re;return v.re=c(v.re,v.im)/2,v.im=Math.atan2(v.im,x)/2,g&&(v.im=-v.im),v},acoth:function(){var f=this.re,p=this.im;if(f===0&&p===0)return new d(0,Math.PI/2);var g=f*f+p*p;return g!==0?new d(f/g,-p/g).atanh():new d(f!==0?f/0:0,p!==0?-p/0:0).atanh()},acsch:function(){var f=this.re,p=this.im;if(p===0)return new d(f!==0?Math.log(f+Math.sqrt(f*f+1)):1/0,0);var g=f*f+p*p;return g!==0?new d(f/g,-p/g).asinh():new d(f!==0?f/0:0,p!==0?-p/0:0).asinh()},asech:function(){var f=this.re,p=this.im;if(this.isZero())return d.INFINITY;var g=f*f+p*p;return g!==0?new d(f/g,-p/g).acosh():new d(f!==0?f/0:0,p!==0?-p/0:0).acosh()},inverse:function(){if(this.isZero())return d.INFINITY;if(this.isInfinite())return d.ZERO;var f=this.re,p=this.im,g=f*f+p*p;return new d(f/g,-p/g)},conjugate:function(){return new d(this.re,-this.im)},neg:function(){return new d(-this.re,-this.im)},ceil:function(f){return f=Math.pow(10,f||0),new d(Math.ceil(this.re*f)/f,Math.ceil(this.im*f)/f)},floor:function(f){return f=Math.pow(10,f||0),new d(Math.floor(this.re*f)/f,Math.floor(this.im*f)/f)},round:function(f){return f=Math.pow(10,f||0),new d(Math.round(this.re*f)/f,Math.round(this.im*f)/f)},equals:function(f,p){var g=new d(f,p);return Math.abs(g.re-this.re)<=d.EPSILON&&Math.abs(g.im-this.im)<=d.EPSILON},clone:function(){return new d(this.re,this.im)},toString:function(){var f=this.re,p=this.im,g="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(f)<d.EPSILON&&(f=0),Math.abs(p)<d.EPSILON&&(p=0),p===0?g+f:(f!==0?(g+=f,g+=" ",p<0?(p=-p,g+="-"):g+="+",g+=" "):p<0&&(p=-p,g+="-"),p!==1&&(g+=p),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())}},d.ZERO=new d(0,0),d.ONE=new d(1,0),d.I=new d(0,1),d.PI=new d(Math.PI,0),d.E=new d(Math.E,0),d.INFINITY=new d(1/0,1/0),d.NAN=new d(NaN,NaN),d.EPSILON=1e-15,Object.defineProperty(d,"__esModule",{value:!0}),d.default=d,d.Complex=d,i.exports=d})()})(Lc);var mm=Lc.exports,He=Gt(mm),gm="Complex",vm=[],wm=mt(gm,vm,()=>(Object.defineProperty(He,"name",{value:"Complex"}),He.prototype.constructor=He,He.prototype.type="Complex",He.prototype.isComplex=!0,He.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},He.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},He.prototype.format=function(i){var t="",e=this.im,r=this.re,n=Da(this.re,i),s=Da(this.im,i),a=_e(i)?i:i?i.precision:null;if(a!==null){var l=Math.pow(10,-a);Math.abs(r/e)<l&&(r=0),Math.abs(e/r)<l&&(e=0)}return e===0?t=n:r===0?e===1?t="i":e===-1?t="-i":t=s+"i":e<0?e===-1?t=n+" - i":t=n+" - "+s.substring(1)+"i":e===1?t=n+" + i":t=n+" + "+s+"i",t},He.fromPolar=function(i){switch(arguments.length){case 1:{var t=arguments[0];if(typeof t=="object")return He(t);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var e=arguments[0],r=arguments[1];if(_e(e)){if(Hl(r)&&r.hasBase("ANGLE")&&(r=r.toNumber("rad")),_e(r))return new He({r:e,phi:r});throw new TypeError("Phi is not a number nor an angle unit.")}else throw new TypeError("Radius r is not a number.")}default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},He.prototype.valueOf=He.prototype.toString,He.fromJSON=function(i){return new He(i)},He.compare=function(i,t){return i.re>t.re?1:i.re<t.re?-1:i.im>t.im?1:i.im<t.im?-1:0},He),{isClass:!0}),Rc={exports:{}};/**
47
47
  * @license Fraction.js v4.3.0 20/08/2023
48
48
  * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
49
49
  *
50
50
  * Copyright (c) 2023, Robert Eisele (robert@raw.org)
51
51
  * Dual licensed under the MIT or GPL Version 2 licenses.
52
- **/(function(i,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function s(v,x){if(isNaN(v=parseInt(v,10)))throw _();return v*x}function a(v,x){if(x===0)throw w();var b=Object.create(g.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var M=p(v,x);return b.n=v/M,b.d=x/M,b}function l(v){for(var x={},b=v,M=2,E=4;E<=b;){for(;b%M===0;)b/=M,x[M]=(x[M]||0)+1;E+=1+2*M++}return b!==v?b>1&&(x[b]=(x[b]||0)+1):x[v]=(x[v]||0)+1,x}var c=function(v,x){var b=0,M=1,E=1,F=0,N=0,S=0,T=1,C=1,O=0,$=1,W=1,q=1,U=1e7,z;if(v!=null)if(x!==void 0){if(b=v,M=x,E=b*M,b%1!==0||M%1!==0)throw y()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,M=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(M=v[1]);else throw _();E=b*M;break}case"number":{if(v<0&&(E=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);$<=U&&q<=U;)if(z=(O+W)/($+q),v===z){$+q<=U?(b=O+W,M=$+q):q>$?(b=W,M=q):(b=O,M=$);break}else v>z?(O+=W,$+=q):(W+=O,q+=$),$>U?(b=W,M=q):(b=O,M=$);b*=C}else(isNaN(v)||isNaN(x))&&(M=b=NaN);break}case"string":{if($=v.match(/\d+|./g),$===null)throw _();if($[O]==="-"?(E=-1,O++):$[O]==="+"&&O++,$.length===O+1?N=s($[O++],E):$[O+1]==="."||$[O]==="."?($[O]!=="."&&(F=s($[O++],E)),O++,(O+1===$.length||$[O+1]==="("&&$[O+3]===")"||$[O+1]==="'"&&$[O+3]==="'")&&(N=s($[O],E),T=Math.pow(10,$[O].length),O++),($[O]==="("&&$[O+2]===")"||$[O]==="'"&&$[O+2]==="'")&&(S=s($[O+1],E),C=Math.pow(10,$[O+1].length)-1,O+=3)):$[O+1]==="/"||$[O+1]===":"?(N=s($[O],E),T=s($[O+2],1),O+=3):$[O+3]==="/"&&$[O+1]===" "&&(F=s($[O],E),N=s($[O+2],E),T=s($[O+4],1),O+=5),$.length<=O){M=T*C,E=b=S+M*F+C*N;break}}default:throw _()}if(M===0)throw w();n.s=E<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(M)};function f(v,x,b){for(var M=1;x>0;v=v*v%b,x>>=1)x&1&&(M=M*v%b);return M}function d(v,x){for(;x%2===0;x/=2);for(;x%5===0;x/=5);if(x===1)return 0;for(var b=10%x,M=1;b!==1;M++)if(b=b*10%x,M>r)return 0;return M}function h(v,x,b){for(var M=1,E=f(10,b,x),F=0;F<300;F++){if(M===E)return F;M=M*10%x,E=E*10%x}return 0}function p(v,x){if(!v)return x;if(!x)return v;for(;;){if(v%=x,!v)return x;if(x%=v,!x)return v}}function g(v,x){if(c(v,x),this instanceof g)v=p(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 w=function(){return new Error("Division by Zero")},_=function(){return new Error("Invalid argument")},y=function(){return new Error("Parameters must be integer")};g.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(v,x){return c(v,x),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,x){return c(v,x),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(v,x){if(isNaN(this.n)||isNaN(this.d))return new g(NaN);if(v===void 0)return a(this.s*this.n%this.d,1);if(c(v,x),n.n===0&&this.d===0)throw w();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(v,x){return c(v,x),a(p(n.n,this.n)*p(n.d,this.d),n.d*this.d)},lcm:function(v,x){return c(v,x),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,p(n.n,this.n)*p(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,x){if(c(v,x),n.d===1)return n.s<0?a(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):a(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=l(this.n),M=l(this.d),E=1,F=1;for(var N in b)if(N!=="1"){if(N==="0"){E=0;break}if(b[N]*=n.n,b[N]%n.d===0)b[N]/=n.d;else return null;E*=Math.pow(N,b[N])}for(var N in M)if(N!=="1"){if(M[N]*=n.n,M[N]%n.d===0)M[N]/=n.d;else return null;F*=Math.pow(N,M[N])}return n.s<0?a(F,E):a(E,F)},equals:function(v,x){return c(v,x),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,x){c(v,x);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var x=this.abs(),b=x.toContinued(),M=1;M<b.length;M++){for(var E=a(b[M-1],1),F=M-2;F>=0;F--)E=E.inverse().add(b[F]);if(Math.abs(E.sub(x).valueOf())<v)return E.mul(this.s)}return this},divisible:function(v,x){return c(v,x),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var x,b="",M=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=M:(v&&(x=Math.floor(M/E))>0&&(b+=x,b+=" ",M%=E),b+=M,b+="/",b+=E),b},toLatex:function(v){var x,b="",M=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=M:(v&&(x=Math.floor(M/E))>0&&(b+=x,M%=E),b+="\\frac{",b+=M,b+="}{",b+=E,b+="}"),b},toContinued:function(){var v,x=this.n,b=this.d,M=[];if(isNaN(x)||isNaN(b))return M;do M.push(Math.floor(x/b)),v=x%b,x=b,b=v;while(x!==1);return M},toString:function(v){var x=this.n,b=this.d;if(isNaN(x)||isNaN(b))return"NaN";v=v||15;var M=d(x,b),E=h(x,b,M),F=this.s<0?"-":"";if(F+=x/b|0,x%=b,x*=10,x&&(F+="."),M){for(var N=E;N--;)F+=x/b|0,x%=b,x*=10;F+="(";for(var N=M;N--;)F+=x/b|0,x%=b,x*=10;F+=")"}else for(var N=v;x&&N--;)F+=x/b|0,x%=b,x*=10;return F}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,i.exports=g})()})(Rc);var ym=Rc.exports,hn=Gt(ym),Dm="Fraction",bm=[],xm=mt(Dm,bm,()=>(Object.defineProperty(hn,"name",{value:"Fraction"}),hn.prototype.constructor=hn,hn.prototype.type="Fraction",hn.prototype.isFraction=!0,hn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},hn.fromJSON=function(i){return new hn(i)},hn),{isClass:!0}),Em="Matrix",Am=[],Cm=mt(Em,Am,()=>{function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.prototype.type="Matrix",i.prototype.isMatrix=!0,i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},i.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i},{isClass:!0});function Pc(i){return Object.keys(i.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var Fm="DenseMatrix",Mm=["Matrix"],Nm=mt(Fm,Mm,i=>{var{Matrix:t}=i;function e(d,h){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(h&&!en(h))throw new Error("Invalid datatype: "+h);if(we(d))d.type==="DenseMatrix"?(this._data=oe(d._data),this._size=oe(d._size),this._datatype=h||d._datatype):(this._data=d.toArray(),this._size=d.size(),this._datatype=h||d._datatype);else if(d&&Ae(d.data)&&Ae(d.size))this._data=d.data,this._size=d.size,hc(this._data,this._size),this._datatype=h||d.datatype;else if(Ae(d))this._data=f(d),this._size=Te(this._data),hc(this._data,this._size),this._datatype=h;else{if(d)throw new TypeError("Unsupported type of data ("+Cn(d)+")");this._data=[],this._size=[0],this._datatype=h}}e.prototype=new t,e.prototype.createDenseMatrix=function(d,h){return new e(d,h)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Ts(this._data,Cn)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(d,h){return new e(d,h)},e.prototype.subset=function(d,h,p){switch(arguments.length){case 1:return r(this,d);case 2:case 3:return s(this,d,h,p);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(d){if(!Ae(d))throw new TypeError("Array expected");if(d.length!==this._size.length)throw new Ht(d.length,this._size.length);for(var h=0;h<d.length;h++)Ce(d[h],this._size[h]);for(var p=this._data,g=0,w=d.length;g<w;g++){var _=d[g];Ce(_,p.length),p=p[_]}return p},e.prototype.set=function(d,h,p){if(!Ae(d))throw new TypeError("Array expected");if(d.length<this._size.length)throw new Ht(d.length,this._size.length,"<");var g,w,_,y=d.map(function(x){return x+1});c(this,y,p);var v=this._data;for(g=0,w=d.length-1;g<w;g++)_=d[g],Ce(_,v.length),v=v[_];return _=d[d.length-1],Ce(_,v.length),v[_]=h,this};function r(d,h){if(!va(h))throw new TypeError("Invalid index");var p=h.isScalar();if(p)return d.get(h.min());var g=h.size();if(g.length!==d._size.length)throw new Ht(g.length,d._size.length);for(var w=h.min(),_=h.max(),y=0,v=d._size.length;y<v;y++)Ce(w[y],d._size[y]),Ce(_[y],d._size[y]);return new e(n(d._data,h,g.length,0),d._datatype)}function n(d,h,p,g){var w=g===p-1,_=h.dimension(g);return w?_.map(function(y){return Ce(y,d.length),d[y]}).valueOf():_.map(function(y){Ce(y,d.length);var v=d[y];return n(v,h,p,g+1)}).valueOf()}function s(d,h,p,g){if(!h||h.isIndex!==!0)throw new TypeError("Invalid index");var w=h.size(),_=h.isScalar(),y;if(we(p)?(y=p.size(),p=p.valueOf()):y=Te(p),_){if(y.length!==0)throw new TypeError("Scalar expected");d.set(h.min(),p,g)}else{if(!vi(y,w))try{y.length===0?p=vc([p],w):p=vc(p,w),y=Te(p)}catch{}if(w.length<d._size.length)throw new Ht(w.length,d._size.length,"<");if(y.length<w.length){for(var v=0,x=0;w[v]===1&&y[v]===1;)v++;for(;w[v]===1;)x++,v++;p=pc(p,w.length,x,y)}if(!vi(w,y))throw new Ht(w,y,">");var b=h.max().map(function(F){return F+1});c(d,b,g);var M=w.length,E=0;a(d._data,h,p,M,E)}return d}function a(d,h,p,g,w){var _=w===g-1,y=h.dimension(w);_?y.forEach(function(v,x){Ce(v),d[v]=p[x[0]]}):y.forEach(function(v,x){Ce(v),a(d[v],h,p[x[0]],g,w+1)})}e.prototype.resize=function(d,h,p){if(!Qi(d))throw new TypeError("Array or Matrix expected");var g=d.valueOf().map(_=>Array.isArray(_)&&_.length===1?_[0]:_),w=p?this.clone():this;return l(w,g,h)};function l(d,h,p){if(h.length===0){for(var g=d._data;Ae(g);)g=g[0];return g}return d._size=h.slice(0),d._data=xa(d._data,d._size,p),d}e.prototype.reshape=function(d,h){var p=h?this.clone():this;p._data=Aa(p._data,d);var g=p._size.reduce((w,_)=>w*_);return p._size=Ca(d,g),p};function c(d,h,p){for(var g=d._size.slice(0),w=!1;g.length<h.length;)g.push(0),w=!0;for(var _=0,y=h.length;_<y;_++)h[_]>g[_]&&(g[_]=h[_],w=!0);w&&l(d,g,p)}e.prototype.clone=function(){var d=new e({data:oe(this._data),size:oe(this._size),datatype:this._datatype});return d},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(d){var h=this,p=Pc(d),g=function y(v,x){return Ae(v)?v.map(function(b,M){return y(b,x.concat(M))}):p===1?d(v):p===2?d(v,x):d(v,x,h)},w=g(this._data,[]),_=this._datatype!==void 0?Ts(w,Cn):void 0;return new e(w,_)},e.prototype.forEach=function(d){var h=this,p=function g(w,_){Ae(w)?w.forEach(function(y,v){g(y,_.concat(v))}):d(w,_,h)};p(this._data,[])},e.prototype[Symbol.iterator]=function*(){var d=function*h(p,g){if(Ae(p))for(var w=0;w<p.length;w++)yield*h(p[w],g.concat(w));else yield{value:p,index:g}};yield*d(this._data,[])},e.prototype.rows=function(){var d=[],h=this.size();if(h.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var p=this._data;for(var g of p)d.push(new e([g],this._datatype));return d},e.prototype.columns=function(){var d=this,h=[],p=this.size();if(p.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var g=this._data,w=function(v){var x=g.map(b=>[b[v]]);h.push(new e(x,d._datatype))},_=0;_<p[1];_++)w(_);return h},e.prototype.toArray=function(){return oe(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(d){return he(this._data,d)},e.prototype.toString=function(){return he(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(d){if(d){if(Oe(d)&&(d=d.toNumber()),!_e(d)||!be(d))throw new TypeError("The parameter k must be an integer number")}else d=0;for(var h=d>0?d:0,p=d<0?-d:0,g=this._size[0],w=this._size[1],_=Math.min(g-p,w-h),y=[],v=0;v<_;v++)y[v]=this._data[v+p][v+h];return new e({data:y,size:[_],datatype:this._datatype})},e.diagonal=function(d,h,p,g){if(!Ae(d))throw new TypeError("Array expected, size parameter");if(d.length!==2)throw new Error("Only two dimensions matrix are supported");if(d=d.map(function(N){if(Oe(N)&&(N=N.toNumber()),!_e(N)||!be(N)||N<1)throw new Error("Size values must be positive integers");return N}),p){if(Oe(p)&&(p=p.toNumber()),!_e(p)||!be(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var w=p>0?p:0,_=p<0?-p:0,y=d[0],v=d[1],x=Math.min(y-_,v-w),b;if(Ae(h)){if(h.length!==x)throw new Error("Invalid value array length");b=function(S){return h[S]}}else if(we(h)){var M=h.size();if(M.length!==1||M[0]!==x)throw new Error("Invalid matrix length");b=function(S){return h.get([S])}}else b=function(){return h};g||(g=Oe(b(0))?b(0).mul(0):0);var E=[];if(d.length>0){E=xa(E,d,g);for(var F=0;F<x;F++)E[F+_][F+w]=b(F)}return new e({data:E,size:[y,v]})},e.fromJSON=function(d){return new e(d)},e.prototype.swapRows=function(d,h){if(!_e(d)||!be(d)||!_e(h)||!be(h))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ce(d,this._size[0]),Ce(h,this._size[0]),e._swapRows(d,h,this._data),this},e._swapRows=function(d,h,p){var g=p[d];p[d]=p[h],p[h]=g};function f(d){return we(d)?f(d.valueOf()):Ae(d)?d.map(f):d}return e},{isClass:!0});function Sm(i){var t=i.length,e=i[0].length,r,n,s=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(i[r][n]);s.push(a)}return s}function js(i){for(var t=0;t<i.length;t++)if(Qi(i[t]))return!0;return!1}function rs(i,t){we(i)&&(i=i.valueOf());for(var e=0,r=i.length;e<r;e++){var n=i[e];Array.isArray(n)?rs(n,t):t(n)}}function Zr(i,t,e){return i&&typeof i.map=="function"?i.map(function(r){return Zr(r,t)}):t(i)}function La(i,t,e){var r=Array.isArray(i)?Te(i):i.size();if(t<0||t>=r.length)throw new Fn(t,r.length);return we(i)?i.create(Vs(i.valueOf(),t,e)):Vs(i,t,e)}function Vs(i,t,e){var r,n,s,a;if(t<=0)if(Array.isArray(i[0])){for(a=Sm(i),n=[],r=0;r<a.length;r++)n[r]=Vs(a[r],t-1,e);return n}else{for(s=i[0],r=1;r<i.length;r++)s=e(s,i[r]);return s}else{for(n=[],r=0;r<i.length;r++)n[r]=Vs(i[r],t-1,e);return n}}var zc="isInteger",Om=["typed"],Bm=mt(zc,Om,i=>{var{typed:t}=i;return t(zc,{number:be,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),kc="number",Ys="number, number";function qc(i){return Math.abs(i)}qc.signature=kc;function Uc(i,t){return i+t}Uc.signature=Ys;function Wc(i,t){return i-t}Wc.signature=Ys;function jc(i,t){return i*t}jc.signature=Ys;function Vc(i){return-i}Vc.signature=kc;function Yc(i,t){return i*i<1&&t===1/0||i*i>1&&t===-1/0?0:Math.pow(i,t)}Yc.signature=Ys;var Zc="number";function Kc(i){return i===0}Kc.signature=Zc;function Gc(i){return Number.isNaN(i)}Gc.signature=Zc;var Hc="isNumeric",Im=["typed"],Tm=mt(Hc,Im,i=>{var{typed:t}=i;return t(Hc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),Jc="isZero",$m=["typed"],Lm=mt(Jc,$m,i=>{var{typed:t}=i;return t(Jc,{number:Kc,BigNumber:function(r){return r.isZero()},Complex:function(r){return r.re===0&&r.im===0},Fraction:function(r){return r.d===1&&r.n===0},Unit:t.referToSelf(e=>r=>t.find(e,r.valueType())(r.value)),"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),Xc="isNaN",Rm=["typed"],Pm=mt(Xc,Rm,i=>{var{typed:t}=i;return t(Xc,{number:Gc,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 Zr(r,Number.isNaN)}})});function Zs(i,t,e){if(e==null)return i.eq(t);if(i.eq(t))return!0;if(i.isNaN()||t.isNaN())return!1;if(i.isFinite()&&t.isFinite()){var r=i.minus(t).abs();if(r.isZero())return!0;var n=i.constructor.max(i.abs(),t.abs());return r.lte(n.times(e))}return!1}function zm(i,t,e){return Jn(i.re,t.re,e)&&Jn(i.im,t.im,e)}var Ks=mt("compareUnits",["typed"],i=>{var{typed:t}=i;return{"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)})}}),Gs="equalScalar",km=["typed","config"],qm=mt(Gs,km,i=>{var{typed:t,config:e}=i,r=Ks({typed:t});return t(Gs,{"boolean, boolean":function(s,a){return s===a},"number, number":function(s,a){return Jn(s,a,e.epsilon)},"BigNumber, BigNumber":function(s,a){return s.eq(a)||Zs(s,a,e.epsilon)},"Fraction, Fraction":function(s,a){return s.equals(a)},"Complex, Complex":function(s,a){return zm(s,a,e.epsilon)}},r)});mt(Gs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Gs,{"number, number":function(n,s){return Jn(n,s,e.epsilon)}})});var Um="SparseMatrix",Wm=["typed","equalScalar","Matrix"],jm=mt(Um,Wm,i=>{var{typed:t,equalScalar:e,Matrix:r}=i;function n(_,y){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!en(y))throw new Error("Invalid datatype: "+y);if(we(_))s(this,_,y);else if(_&&Ae(_.index)&&Ae(_.ptr)&&Ae(_.size))this._values=_.values,this._index=_.index,this._ptr=_.ptr,this._size=_.size,this._datatype=y||_.datatype;else if(Ae(_))a(this,_,y);else{if(_)throw new TypeError("Unsupported type of data ("+Cn(_)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function s(_,y,v){y.type==="SparseMatrix"?(_._values=y._values?oe(y._values):void 0,_._index=oe(y._index),_._ptr=oe(y._ptr),_._size=oe(y._size),_._datatype=v||y._datatype):a(_,y.valueOf(),v||y._datatype)}function a(_,y,v){_._values=[],_._index=[],_._ptr=[],_._datatype=v;var x=y.length,b=0,M=e,E=0;if(en(v)&&(M=t.find(e,[v,v])||e,E=t.convert(0,v)),x>0){var F=0;do{_._ptr.push(_._index.length);for(var N=0;N<x;N++){var S=y[N];if(Ae(S)){if(F===0&&b<S.length&&(b=S.length),F<S.length){var T=S[F];M(T,E)||(_._values.push(T),_._index.push(N))}}else F===0&&b<1&&(b=1),M(S,E)||(_._values.push(S),_._index.push(N))}F++}while(F<b)}_._ptr.push(_._index.length),_._size=[x,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(_,y){return new n(_,y)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Ts(this._values,Cn)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(_,y){return new n(_,y)},n.prototype.density=function(){var _=this._size[0],y=this._size[1];return _!==0&&y!==0?this._index.length/(_*y):0},n.prototype.subset=function(_,y,v){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return l(this,_);case 2:case 3:return c(this,_,y,v);default:throw new SyntaxError("Wrong number of arguments")}};function l(_,y){if(!va(y))throw new TypeError("Invalid index");var v=y.isScalar();if(v)return _.get(y.min());var x=y.size();if(x.length!==_._size.length)throw new Ht(x.length,_._size.length);var b,M,E,F,N=y.min(),S=y.max();for(b=0,M=_._size.length;b<M;b++)Ce(N[b],_._size[b]),Ce(S[b],_._size[b]);var T=_._values,C=_._index,O=_._ptr,$=y.dimension(0),W=y.dimension(1),q=[],U=[];$.forEach(function(X,Q){U[X]=Q[0],q[X]=!0});var z=T?[]:void 0,K=[],Z=[];return W.forEach(function(X){for(Z.push(K.length),E=O[X],F=O[X+1];E<F;E++)b=C[E],q[b]===!0&&(K.push(U[b]),z&&z.push(T[E]))}),Z.push(K.length),new n({values:z,index:K,ptr:Z,size:x,datatype:_._datatype})}function c(_,y,v,x){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var b=y.size(),M=y.isScalar(),E;if(we(v)?(E=v.size(),v=v.toArray()):E=Te(v),M){if(E.length!==0)throw new TypeError("Scalar expected");_.set(y.min(),v,x)}else{if(b.length!==1&&b.length!==2)throw new Ht(b.length,_._size.length,"<");if(E.length<b.length){for(var F=0,N=0;b[F]===1&&E[F]===1;)F++;for(;b[F]===1;)N++,F++;v=pc(v,b.length,N,E)}if(!vi(b,E))throw new Ht(b,E,">");if(b.length===1){var S=y.dimension(0);S.forEach(function(O,$){Ce(O),_.set([O,0],v[$[0]],x)})}else{var T=y.dimension(0),C=y.dimension(1);T.forEach(function(O,$){Ce(O),C.forEach(function(W,q){Ce(W),_.set([O,W],v[$[0]][q[0]],x)})})}}return _}n.prototype.get=function(_){if(!Ae(_))throw new TypeError("Array expected");if(_.length!==this._size.length)throw new Ht(_.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=_[0],v=_[1];Ce(y,this._size[0]),Ce(v,this._size[1]);var x=f(y,this._ptr[v],this._ptr[v+1],this._index);return x<this._ptr[v+1]&&this._index[x]===y?this._values[x]:0},n.prototype.set=function(_,y,v){if(!Ae(_))throw new TypeError("Array expected");if(_.length!==this._size.length)throw new Ht(_.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var x=_[0],b=_[1],M=this._size[0],E=this._size[1],F=e,N=0;en(this._datatype)&&(F=t.find(e,[this._datatype,this._datatype])||e,N=t.convert(0,this._datatype)),(x>M-1||b>E-1)&&(p(this,Math.max(x+1,M),Math.max(b+1,E),v),M=this._size[0],E=this._size[1]),Ce(x,M),Ce(b,E);var S=f(x,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===x?F(y,N)?d(S,b,this._values,this._index,this._ptr):this._values[S]=y:F(y,N)||h(S,x,b,y,this._values,this._index,this._ptr),this};function f(_,y,v,x){if(v-y===0)return v;for(var b=y;b<v;b++)if(x[b]===_)return b;return y}function d(_,y,v,x,b){v.splice(_,1),x.splice(_,1);for(var M=y+1;M<b.length;M++)b[M]--}function h(_,y,v,x,b,M,E){b.splice(_,0,x),M.splice(_,0,y);for(var F=v+1;F<E.length;F++)E[F]++}n.prototype.resize=function(_,y,v){if(!Qi(_))throw new TypeError("Array or Matrix expected");var x=_.valueOf().map(M=>Array.isArray(M)&&M.length===1?M[0]:M);if(x.length!==2)throw new Error("Only two dimensions matrix are supported");x.forEach(function(M){if(!_e(M)||!be(M)||M<0)throw new TypeError("Invalid size, must contain positive integers (size: "+he(x)+")")});var b=v?this.clone():this;return p(b,x[0],x[1],y)};function p(_,y,v,x){var b=x||0,M=e,E=0;en(_._datatype)&&(M=t.find(e,[_._datatype,_._datatype])||e,E=t.convert(0,_._datatype),b=t.convert(b,_._datatype));var F=!M(b,E),N=_._size[0],S=_._size[1],T,C,O;if(v>S){for(C=S;C<v;C++)if(_._ptr[C]=_._values.length,F)for(T=0;T<N;T++)_._values.push(b),_._index.push(T);_._ptr[v]=_._values.length}else v<S&&(_._ptr.splice(v+1,S-v),_._values.splice(_._ptr[v],_._values.length),_._index.splice(_._ptr[v],_._index.length));if(S=v,y>N){if(F){var $=0;for(C=0;C<S;C++){_._ptr[C]=_._ptr[C]+$,O=_._ptr[C+1]+$;var W=0;for(T=N;T<y;T++,W++)_._values.splice(O+W,0,b),_._index.splice(O+W,0,T),$++}_._ptr[S]=_._values.length}}else if(y<N){var q=0;for(C=0;C<S;C++){_._ptr[C]=_._ptr[C]-q;var U=_._ptr[C],z=_._ptr[C+1]-q;for(O=U;O<z;O++)T=_._index[O],T>y-1&&(_._values.splice(O,1),_._index.splice(O,1),q++)}_._ptr[C]=_._values.length}return _._size[0]=y,_._size[1]=v,_}n.prototype.reshape=function(_,y){if(!Ae(_))throw new TypeError("Array expected");if(_.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");_.forEach(function(X){if(!_e(X)||!be(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+he(_)+")")});var v=this._size[0]*this._size[1];_=Ca(_,v);var x=_[0]*_[1];if(v!==x)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=y?this.clone():this;if(this._size[0]===_[0]&&this._size[1]===_[1])return b;for(var M=[],E=0;E<b._ptr.length;E++)for(var F=0;F<b._ptr[E+1]-b._ptr[E];F++)M.push(E);for(var N=b._values.slice(),S=b._index.slice(),T=0;T<b._index.length;T++){var C=S[T],O=M[T],$=C*b._size[1]+O;M[T]=$%_[1],S[T]=Math.floor($/_[1])}b._values.length=0,b._index.length=0,b._ptr.length=_[1]+1,b._size=_.slice();for(var W=0;W<b._ptr.length;W++)b._ptr[W]=0;for(var q=0;q<N.length;q++){var U=S[q],z=M[q],K=N[q],Z=f(U,b._ptr[z],b._ptr[z+1],b._index);h(Z,U,z,K,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var _=new n({values:this._values?oe(this._values):void 0,index:oe(this._index),ptr:oe(this._ptr),size:oe(this._size),datatype:this._datatype});return _},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(_,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,x=this._size[0],b=this._size[1],M=Pc(_),E=function(N,S,T){return M===1?_(N):M===2?_(N,[S,T]):_(N,[S,T],v)};return g(this,0,x-1,0,b-1,E,y)};function g(_,y,v,x,b,M,E){var F=[],N=[],S=[],T=e,C=0;en(_._datatype)&&(T=t.find(e,[_._datatype,_._datatype])||e,C=t.convert(0,_._datatype));for(var O=function(lt,yt,bt){lt=M(lt,yt,bt),T(lt,C)||(F.push(lt),N.push(yt))},$=x;$<=b;$++){S.push(F.length);var W=_._ptr[$],q=_._ptr[$+1];if(E)for(var U=W;U<q;U++){var z=_._index[U];z>=y&&z<=v&&O(_._values[U],z-y,$-x)}else{for(var K={},Z=W;Z<q;Z++){var X=_._index[Z];K[X]=_._values[Z]}for(var Q=y;Q<=v;Q++){var ct=Q in K?K[Q]:0;O(ct,Q-y,$-x)}}}return S.push(F.length),new n({values:F,index:N,ptr:S,size:[v-y+1,b-x+1]})}n.prototype.forEach=function(_,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,x=this._size[0],b=this._size[1],M=0;M<b;M++){var E=this._ptr[M],F=this._ptr[M+1];if(y)for(var N=E;N<F;N++){var S=this._index[N];_(this._values[N],[S,M],v)}else{for(var T={},C=E;C<F;C++){var O=this._index[C];T[O]=this._values[C]}for(var $=0;$<x;$++){var W=$ in T?T[$]:0;_(W,[$,M],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var _=this._size[1],y=0;y<_;y++)for(var v=this._ptr[y],x=this._ptr[y+1],b=v;b<x;b++){var M=this._index[b];yield{value:this._values[b],index:[M,y]}}},n.prototype.toArray=function(){return w(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return w(this._values,this._index,this._ptr,this._size,!1)};function w(_,y,v,x,b){var M=x[0],E=x[1],F=[],N,S;for(N=0;N<M;N++)for(F[N]=[],S=0;S<E;S++)F[N][S]=0;for(S=0;S<E;S++)for(var T=v[S],C=v[S+1],O=T;O<C;O++)N=y[O],F[N][S]=_?b?oe(_[O]):_[O]:1;return F}return n.prototype.format=function(_){for(var y=this._size[0],v=this._size[1],x=this.density(),b="Sparse Matrix ["+he(y,_)+" x "+he(v,_)+"] density: "+he(x,_)+`
52
+ **/(function(i,t){(function(e){var r=2e3,n={s:1,n:0,d:1};function s(v,x){if(isNaN(v=parseInt(v,10)))throw m();return v*x}function a(v,x){if(x===0)throw w();var b=Object.create(g.prototype);b.s=v<0?-1:1,v=v<0?-v:v;var M=p(v,x);return b.n=v/M,b.d=x/M,b}function l(v){for(var x={},b=v,M=2,E=4;E<=b;){for(;b%M===0;)b/=M,x[M]=(x[M]||0)+1;E+=1+2*M++}return b!==v?b>1&&(x[b]=(x[b]||0)+1):x[v]=(x[v]||0)+1,x}var c=function(v,x){var b=0,M=1,E=1,F=0,N=0,S=0,T=1,A=1,O=0,L=1,q=1,U=1,W=1e7,z;if(v!=null)if(x!==void 0){if(b=v,M=x,E=b*M,b%1!==0||M%1!==0)throw y()}else switch(typeof v){case"object":{if("d"in v&&"n"in v)b=v.n,M=v.d,"s"in v&&(b*=v.s);else if(0 in v)b=v[0],1 in v&&(M=v[1]);else throw m();E=b*M;break}case"number":{if(v<0&&(E=v,v=-v),v%1===0)b=v;else if(v>0){for(v>=1&&(A=Math.pow(10,Math.floor(1+Math.log(v)/Math.LN10)),v/=A);L<=W&&U<=W;)if(z=(O+q)/(L+U),v===z){L+U<=W?(b=O+q,M=L+U):U>L?(b=q,M=U):(b=O,M=L);break}else v>z?(O+=q,L+=U):(q+=O,U+=L),L>W?(b=q,M=U):(b=O,M=L);b*=A}else(isNaN(v)||isNaN(x))&&(M=b=NaN);break}case"string":{if(L=v.match(/\d+|./g),L===null)throw m();if(L[O]==="-"?(E=-1,O++):L[O]==="+"&&O++,L.length===O+1?N=s(L[O++],E):L[O+1]==="."||L[O]==="."?(L[O]!=="."&&(F=s(L[O++],E)),O++,(O+1===L.length||L[O+1]==="("&&L[O+3]===")"||L[O+1]==="'"&&L[O+3]==="'")&&(N=s(L[O],E),T=Math.pow(10,L[O].length),O++),(L[O]==="("&&L[O+2]===")"||L[O]==="'"&&L[O+2]==="'")&&(S=s(L[O+1],E),A=Math.pow(10,L[O+1].length)-1,O+=3)):L[O+1]==="/"||L[O+1]===":"?(N=s(L[O],E),T=s(L[O+2],1),O+=3):L[O+3]==="/"&&L[O+1]===" "&&(F=s(L[O],E),N=s(L[O+2],E),T=s(L[O+4],1),O+=5),L.length<=O){M=T*A,E=b=S+M*F+A*N;break}}default:throw m()}if(M===0)throw w();n.s=E<0?-1:1,n.n=Math.abs(b),n.d=Math.abs(M)};function h(v,x,b){for(var M=1;x>0;v=v*v%b,x>>=1)x&1&&(M=M*v%b);return M}function d(v,x){for(;x%2===0;x/=2);for(;x%5===0;x/=5);if(x===1)return 0;for(var b=10%x,M=1;b!==1;M++)if(b=b*10%x,M>r)return 0;return M}function f(v,x,b){for(var M=1,E=h(10,b,x),F=0;F<300;F++){if(M===E)return F;M=M*10%x,E=E*10%x}return 0}function p(v,x){if(!v)return x;if(!x)return v;for(;;){if(v%=x,!v)return x;if(x%=v,!x)return v}}function g(v,x){if(c(v,x),this instanceof g)v=p(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 w=function(){return new Error("Division by Zero")},m=function(){return new Error("Invalid argument")},y=function(){return new Error("Parameters must be integer")};g.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(v,x){return c(v,x),a(this.s*this.n*n.d+n.s*this.d*n.n,this.d*n.d)},sub:function(v,x){return c(v,x),a(this.s*this.n*n.d-n.s*this.d*n.n,this.d*n.d)},mul:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.n,this.d*n.d)},div:function(v,x){return c(v,x),a(this.s*n.s*this.n*n.d,this.d*n.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(v,x){if(isNaN(this.n)||isNaN(this.d))return new g(NaN);if(v===void 0)return a(this.s*this.n%this.d,1);if(c(v,x),n.n===0&&this.d===0)throw w();return a(this.s*(n.d*this.n)%(n.n*this.d),n.d*this.d)},gcd:function(v,x){return c(v,x),a(p(n.n,this.n)*p(n.d,this.d),n.d*this.d)},lcm:function(v,x){return c(v,x),n.n===0&&this.n===0?a(0,1):a(n.n*this.n,p(n.n,this.n)*p(n.d,this.d))},ceil:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.ceil(v*this.s*this.n/this.d),v)},floor:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.floor(v*this.s*this.n/this.d),v)},round:function(v){return v=Math.pow(10,v||0),isNaN(this.n)||isNaN(this.d)?new g(NaN):a(Math.round(v*this.s*this.n/this.d),v)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(v,x){if(c(v,x),n.d===1)return n.s<0?a(Math.pow(this.s*this.d,n.n),Math.pow(this.n,n.n)):a(Math.pow(this.s*this.n,n.n),Math.pow(this.d,n.n));if(this.s<0)return null;var b=l(this.n),M=l(this.d),E=1,F=1;for(var N in b)if(N!=="1"){if(N==="0"){E=0;break}if(b[N]*=n.n,b[N]%n.d===0)b[N]/=n.d;else return null;E*=Math.pow(N,b[N])}for(var N in M)if(N!=="1"){if(M[N]*=n.n,M[N]%n.d===0)M[N]/=n.d;else return null;F*=Math.pow(N,M[N])}return n.s<0?a(F,E):a(E,F)},equals:function(v,x){return c(v,x),this.s*this.n*n.d===n.s*n.n*this.d},compare:function(v,x){c(v,x);var b=this.s*this.n*n.d-n.s*n.n*this.d;return(0<b)-(b<0)},simplify:function(v){if(isNaN(this.n)||isNaN(this.d))return this;v=v||.001;for(var x=this.abs(),b=x.toContinued(),M=1;M<b.length;M++){for(var E=a(b[M-1],1),F=M-2;F>=0;F--)E=E.inverse().add(b[F]);if(Math.abs(E.sub(x).valueOf())<v)return E.mul(this.s)}return this},divisible:function(v,x){return c(v,x),!(!(n.n*this.d)||this.n*n.d%(n.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(v){var x,b="",M=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=M:(v&&(x=Math.floor(M/E))>0&&(b+=x,b+=" ",M%=E),b+=M,b+="/",b+=E),b},toLatex:function(v){var x,b="",M=this.n,E=this.d;return this.s<0&&(b+="-"),E===1?b+=M:(v&&(x=Math.floor(M/E))>0&&(b+=x,M%=E),b+="\\frac{",b+=M,b+="}{",b+=E,b+="}"),b},toContinued:function(){var v,x=this.n,b=this.d,M=[];if(isNaN(x)||isNaN(b))return M;do M.push(Math.floor(x/b)),v=x%b,x=b,b=v;while(x!==1);return M},toString:function(v){var x=this.n,b=this.d;if(isNaN(x)||isNaN(b))return"NaN";v=v||15;var M=d(x,b),E=f(x,b,M),F=this.s<0?"-":"";if(F+=x/b|0,x%=b,x*=10,x&&(F+="."),M){for(var N=E;N--;)F+=x/b|0,x%=b,x*=10;F+="(";for(var N=M;N--;)F+=x/b|0,x%=b,x*=10;F+=")"}else for(var N=v;x&&N--;)F+=x/b|0,x%=b,x*=10;return F}},Object.defineProperty(g,"__esModule",{value:!0}),g.default=g,g.Fraction=g,i.exports=g})()})(Rc);var ym=Rc.exports,hn=Gt(ym),Dm="Fraction",bm=[],xm=mt(Dm,bm,()=>(Object.defineProperty(hn,"name",{value:"Fraction"}),hn.prototype.constructor=hn,hn.prototype.type="Fraction",hn.prototype.isFraction=!0,hn.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},hn.fromJSON=function(i){return new hn(i)},hn),{isClass:!0}),Em="Matrix",Am=[],Cm=mt(Em,Am,()=>{function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.prototype.type="Matrix",i.prototype.isMatrix=!0,i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},i.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i},{isClass:!0});function Pc(i){return Object.keys(i.signatures||{}).reduce(function(t,e){var r=(e.match(/,/g)||[]).length+1;return Math.max(t,r)},-1)}var Fm="DenseMatrix",Mm=["Matrix"],Nm=mt(Fm,Mm,i=>{var{Matrix:t}=i;function e(d,f){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(f&&!en(f))throw new Error("Invalid datatype: "+f);if(we(d))d.type==="DenseMatrix"?(this._data=oe(d._data),this._size=oe(d._size),this._datatype=f||d._datatype):(this._data=d.toArray(),this._size=d.size(),this._datatype=f||d._datatype);else if(d&&Ae(d.data)&&Ae(d.size))this._data=d.data,this._size=d.size,hc(this._data,this._size),this._datatype=f||d.datatype;else if(Ae(d))this._data=h(d),this._size=Te(this._data),hc(this._data,this._size),this._datatype=f;else{if(d)throw new TypeError("Unsupported type of data ("+Cn(d)+")");this._data=[],this._size=[0],this._datatype=f}}e.prototype=new t,e.prototype.createDenseMatrix=function(d,f){return new e(d,f)},Object.defineProperty(e,"name",{value:"DenseMatrix"}),e.prototype.constructor=e,e.prototype.type="DenseMatrix",e.prototype.isDenseMatrix=!0,e.prototype.getDataType=function(){return Ts(this._data,Cn)},e.prototype.storage=function(){return"dense"},e.prototype.datatype=function(){return this._datatype},e.prototype.create=function(d,f){return new e(d,f)},e.prototype.subset=function(d,f,p){switch(arguments.length){case 1:return r(this,d);case 2:case 3:return s(this,d,f,p);default:throw new SyntaxError("Wrong number of arguments")}},e.prototype.get=function(d){if(!Ae(d))throw new TypeError("Array expected");if(d.length!==this._size.length)throw new Ht(d.length,this._size.length);for(var f=0;f<d.length;f++)Ce(d[f],this._size[f]);for(var p=this._data,g=0,w=d.length;g<w;g++){var m=d[g];Ce(m,p.length),p=p[m]}return p},e.prototype.set=function(d,f,p){if(!Ae(d))throw new TypeError("Array expected");if(d.length<this._size.length)throw new Ht(d.length,this._size.length,"<");var g,w,m,y=d.map(function(x){return x+1});c(this,y,p);var v=this._data;for(g=0,w=d.length-1;g<w;g++)m=d[g],Ce(m,v.length),v=v[m];return m=d[d.length-1],Ce(m,v.length),v[m]=f,this};function r(d,f){if(!va(f))throw new TypeError("Invalid index");var p=f.isScalar();if(p)return d.get(f.min());var g=f.size();if(g.length!==d._size.length)throw new Ht(g.length,d._size.length);for(var w=f.min(),m=f.max(),y=0,v=d._size.length;y<v;y++)Ce(w[y],d._size[y]),Ce(m[y],d._size[y]);return new e(n(d._data,f,g.length,0),d._datatype)}function n(d,f,p,g){var w=g===p-1,m=f.dimension(g);return w?m.map(function(y){return Ce(y,d.length),d[y]}).valueOf():m.map(function(y){Ce(y,d.length);var v=d[y];return n(v,f,p,g+1)}).valueOf()}function s(d,f,p,g){if(!f||f.isIndex!==!0)throw new TypeError("Invalid index");var w=f.size(),m=f.isScalar(),y;if(we(p)?(y=p.size(),p=p.valueOf()):y=Te(p),m){if(y.length!==0)throw new TypeError("Scalar expected");d.set(f.min(),p,g)}else{if(!vi(y,w))try{y.length===0?p=vc([p],w):p=vc(p,w),y=Te(p)}catch{}if(w.length<d._size.length)throw new Ht(w.length,d._size.length,"<");if(y.length<w.length){for(var v=0,x=0;w[v]===1&&y[v]===1;)v++;for(;w[v]===1;)x++,v++;p=pc(p,w.length,x,y)}if(!vi(w,y))throw new Ht(w,y,">");var b=f.max().map(function(F){return F+1});c(d,b,g);var M=w.length,E=0;a(d._data,f,p,M,E)}return d}function a(d,f,p,g,w){var m=w===g-1,y=f.dimension(w);m?y.forEach(function(v,x){Ce(v),d[v]=p[x[0]]}):y.forEach(function(v,x){Ce(v),a(d[v],f,p[x[0]],g,w+1)})}e.prototype.resize=function(d,f,p){if(!Qi(d))throw new TypeError("Array or Matrix expected");var g=d.valueOf().map(m=>Array.isArray(m)&&m.length===1?m[0]:m),w=p?this.clone():this;return l(w,g,f)};function l(d,f,p){if(f.length===0){for(var g=d._data;Ae(g);)g=g[0];return g}return d._size=f.slice(0),d._data=xa(d._data,d._size,p),d}e.prototype.reshape=function(d,f){var p=f?this.clone():this;p._data=Aa(p._data,d);var g=p._size.reduce((w,m)=>w*m);return p._size=Ca(d,g),p};function c(d,f,p){for(var g=d._size.slice(0),w=!1;g.length<f.length;)g.push(0),w=!0;for(var m=0,y=f.length;m<y;m++)f[m]>g[m]&&(g[m]=f[m],w=!0);w&&l(d,g,p)}e.prototype.clone=function(){var d=new e({data:oe(this._data),size:oe(this._size),datatype:this._datatype});return d},e.prototype.size=function(){return this._size.slice(0)},e.prototype.map=function(d){var f=this,p=Pc(d),g=function y(v,x){return Ae(v)?v.map(function(b,M){return y(b,x.concat(M))}):p===1?d(v):p===2?d(v,x):d(v,x,f)},w=g(this._data,[]),m=this._datatype!==void 0?Ts(w,Cn):void 0;return new e(w,m)},e.prototype.forEach=function(d){var f=this,p=function g(w,m){Ae(w)?w.forEach(function(y,v){g(y,m.concat(v))}):d(w,m,f)};p(this._data,[])},e.prototype[Symbol.iterator]=function*(){var d=function*f(p,g){if(Ae(p))for(var w=0;w<p.length;w++)yield*f(p[w],g.concat(w));else yield{value:p,index:g}};yield*d(this._data,[])},e.prototype.rows=function(){var d=[],f=this.size();if(f.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var p=this._data;for(var g of p)d.push(new e([g],this._datatype));return d},e.prototype.columns=function(){var d=this,f=[],p=this.size();if(p.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var g=this._data,w=function(v){var x=g.map(b=>[b[v]]);f.push(new e(x,d._datatype))},m=0;m<p[1];m++)w(m);return f},e.prototype.toArray=function(){return oe(this._data)},e.prototype.valueOf=function(){return this._data},e.prototype.format=function(d){return he(this._data,d)},e.prototype.toString=function(){return he(this._data)},e.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},e.prototype.diagonal=function(d){if(d){if(Oe(d)&&(d=d.toNumber()),!_e(d)||!be(d))throw new TypeError("The parameter k must be an integer number")}else d=0;for(var f=d>0?d:0,p=d<0?-d:0,g=this._size[0],w=this._size[1],m=Math.min(g-p,w-f),y=[],v=0;v<m;v++)y[v]=this._data[v+p][v+f];return new e({data:y,size:[m],datatype:this._datatype})},e.diagonal=function(d,f,p,g){if(!Ae(d))throw new TypeError("Array expected, size parameter");if(d.length!==2)throw new Error("Only two dimensions matrix are supported");if(d=d.map(function(N){if(Oe(N)&&(N=N.toNumber()),!_e(N)||!be(N)||N<1)throw new Error("Size values must be positive integers");return N}),p){if(Oe(p)&&(p=p.toNumber()),!_e(p)||!be(p))throw new TypeError("The parameter k must be an integer number")}else p=0;var w=p>0?p:0,m=p<0?-p:0,y=d[0],v=d[1],x=Math.min(y-m,v-w),b;if(Ae(f)){if(f.length!==x)throw new Error("Invalid value array length");b=function(S){return f[S]}}else if(we(f)){var M=f.size();if(M.length!==1||M[0]!==x)throw new Error("Invalid matrix length");b=function(S){return f.get([S])}}else b=function(){return f};g||(g=Oe(b(0))?b(0).mul(0):0);var E=[];if(d.length>0){E=xa(E,d,g);for(var F=0;F<x;F++)E[F+m][F+w]=b(F)}return new e({data:E,size:[y,v]})},e.fromJSON=function(d){return new e(d)},e.prototype.swapRows=function(d,f){if(!_e(d)||!be(d)||!_e(f)||!be(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 Ce(d,this._size[0]),Ce(f,this._size[0]),e._swapRows(d,f,this._data),this},e._swapRows=function(d,f,p){var g=p[d];p[d]=p[f],p[f]=g};function h(d){return we(d)?h(d.valueOf()):Ae(d)?d.map(h):d}return e},{isClass:!0});function Sm(i){var t=i.length,e=i[0].length,r,n,s=[];for(n=0;n<e;n++){var a=[];for(r=0;r<t;r++)a.push(i[r][n]);s.push(a)}return s}function js(i){for(var t=0;t<i.length;t++)if(Qi(i[t]))return!0;return!1}function rs(i,t){we(i)&&(i=i.valueOf());for(var e=0,r=i.length;e<r;e++){var n=i[e];Array.isArray(n)?rs(n,t):t(n)}}function Zr(i,t,e){return i&&typeof i.map=="function"?i.map(function(r){return Zr(r,t)}):t(i)}function La(i,t,e){var r=Array.isArray(i)?Te(i):i.size();if(t<0||t>=r.length)throw new Fn(t,r.length);return we(i)?i.create(Vs(i.valueOf(),t,e)):Vs(i,t,e)}function Vs(i,t,e){var r,n,s,a;if(t<=0)if(Array.isArray(i[0])){for(a=Sm(i),n=[],r=0;r<a.length;r++)n[r]=Vs(a[r],t-1,e);return n}else{for(s=i[0],r=1;r<i.length;r++)s=e(s,i[r]);return s}else{for(n=[],r=0;r<i.length;r++)n[r]=Vs(i[r],t-1,e);return n}}var zc="isInteger",Om=["typed"],Bm=mt(zc,Om,i=>{var{typed:t}=i;return t(zc,{number:be,BigNumber:function(r){return r.isInt()},Fraction:function(r){return r.d===1&&isFinite(r.n)},"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),kc="number",Ys="number, number";function qc(i){return Math.abs(i)}qc.signature=kc;function Uc(i,t){return i+t}Uc.signature=Ys;function Wc(i,t){return i-t}Wc.signature=Ys;function jc(i,t){return i*t}jc.signature=Ys;function Vc(i){return-i}Vc.signature=kc;function Yc(i,t){return i*i<1&&t===1/0||i*i>1&&t===-1/0?0:Math.pow(i,t)}Yc.signature=Ys;var Zc="number";function Kc(i){return i===0}Kc.signature=Zc;function Gc(i){return Number.isNaN(i)}Gc.signature=Zc;var Hc="isNumeric",Im=["typed"],Tm=mt(Hc,Im,i=>{var{typed:t}=i;return t(Hc,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),Jc="isZero",$m=["typed"],Lm=mt(Jc,$m,i=>{var{typed:t}=i;return t(Jc,{number:Kc,BigNumber:function(r){return r.isZero()},Complex:function(r){return r.re===0&&r.im===0},Fraction:function(r){return r.d===1&&r.n===0},Unit:t.referToSelf(e=>r=>t.find(e,r.valueType())(r.value)),"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),Xc="isNaN",Rm=["typed"],Pm=mt(Xc,Rm,i=>{var{typed:t}=i;return t(Xc,{number:Gc,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 Zr(r,Number.isNaN)}})});function Zs(i,t,e){if(e==null)return i.eq(t);if(i.eq(t))return!0;if(i.isNaN()||t.isNaN())return!1;if(i.isFinite()&&t.isFinite()){var r=i.minus(t).abs();if(r.isZero())return!0;var n=i.constructor.max(i.abs(),t.abs());return r.lte(n.times(e))}return!1}function zm(i,t,e){return Jn(i.re,t.re,e)&&Jn(i.im,t.im,e)}var Ks=mt("compareUnits",["typed"],i=>{var{typed:t}=i;return{"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(!r.equalBase(n))throw new Error("Cannot compare units with different base");return t.find(e,[r.valueType(),n.valueType()])(r.value,n.value)})}}),Gs="equalScalar",km=["typed","config"],qm=mt(Gs,km,i=>{var{typed:t,config:e}=i,r=Ks({typed:t});return t(Gs,{"boolean, boolean":function(s,a){return s===a},"number, number":function(s,a){return Jn(s,a,e.epsilon)},"BigNumber, BigNumber":function(s,a){return s.eq(a)||Zs(s,a,e.epsilon)},"Fraction, Fraction":function(s,a){return s.equals(a)},"Complex, Complex":function(s,a){return zm(s,a,e.epsilon)}},r)});mt(Gs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Gs,{"number, number":function(n,s){return Jn(n,s,e.epsilon)}})});var Um="SparseMatrix",Wm=["typed","equalScalar","Matrix"],jm=mt(Um,Wm,i=>{var{typed:t,equalScalar:e,Matrix:r}=i;function n(m,y){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(y&&!en(y))throw new Error("Invalid datatype: "+y);if(we(m))s(this,m,y);else if(m&&Ae(m.index)&&Ae(m.ptr)&&Ae(m.size))this._values=m.values,this._index=m.index,this._ptr=m.ptr,this._size=m.size,this._datatype=y||m.datatype;else if(Ae(m))a(this,m,y);else{if(m)throw new TypeError("Unsupported type of data ("+Cn(m)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=y}}function s(m,y,v){y.type==="SparseMatrix"?(m._values=y._values?oe(y._values):void 0,m._index=oe(y._index),m._ptr=oe(y._ptr),m._size=oe(y._size),m._datatype=v||y._datatype):a(m,y.valueOf(),v||y._datatype)}function a(m,y,v){m._values=[],m._index=[],m._ptr=[],m._datatype=v;var x=y.length,b=0,M=e,E=0;if(en(v)&&(M=t.find(e,[v,v])||e,E=t.convert(0,v)),x>0){var F=0;do{m._ptr.push(m._index.length);for(var N=0;N<x;N++){var S=y[N];if(Ae(S)){if(F===0&&b<S.length&&(b=S.length),F<S.length){var T=S[F];M(T,E)||(m._values.push(T),m._index.push(N))}}else F===0&&b<1&&(b=1),M(S,E)||(m._values.push(S),m._index.push(N))}F++}while(F<b)}m._ptr.push(m._index.length),m._size=[x,b]}n.prototype=new r,n.prototype.createSparseMatrix=function(m,y){return new n(m,y)},Object.defineProperty(n,"name",{value:"SparseMatrix"}),n.prototype.constructor=n,n.prototype.type="SparseMatrix",n.prototype.isSparseMatrix=!0,n.prototype.getDataType=function(){return Ts(this._values,Cn)},n.prototype.storage=function(){return"sparse"},n.prototype.datatype=function(){return this._datatype},n.prototype.create=function(m,y){return new n(m,y)},n.prototype.density=function(){var m=this._size[0],y=this._size[1];return m!==0&&y!==0?this._index.length/(m*y):0},n.prototype.subset=function(m,y,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,y,v);default:throw new SyntaxError("Wrong number of arguments")}};function l(m,y){if(!va(y))throw new TypeError("Invalid index");var v=y.isScalar();if(v)return m.get(y.min());var x=y.size();if(x.length!==m._size.length)throw new Ht(x.length,m._size.length);var b,M,E,F,N=y.min(),S=y.max();for(b=0,M=m._size.length;b<M;b++)Ce(N[b],m._size[b]),Ce(S[b],m._size[b]);var T=m._values,A=m._index,O=m._ptr,L=y.dimension(0),q=y.dimension(1),U=[],W=[];L.forEach(function(X,Q){W[X]=Q[0],U[X]=!0});var z=T?[]:void 0,K=[],Z=[];return q.forEach(function(X){for(Z.push(K.length),E=O[X],F=O[X+1];E<F;E++)b=A[E],U[b]===!0&&(K.push(W[b]),z&&z.push(T[E]))}),Z.push(K.length),new n({values:z,index:K,ptr:Z,size:x,datatype:m._datatype})}function c(m,y,v,x){if(!y||y.isIndex!==!0)throw new TypeError("Invalid index");var b=y.size(),M=y.isScalar(),E;if(we(v)?(E=v.size(),v=v.toArray()):E=Te(v),M){if(E.length!==0)throw new TypeError("Scalar expected");m.set(y.min(),v,x)}else{if(b.length!==1&&b.length!==2)throw new Ht(b.length,m._size.length,"<");if(E.length<b.length){for(var F=0,N=0;b[F]===1&&E[F]===1;)F++;for(;b[F]===1;)N++,F++;v=pc(v,b.length,N,E)}if(!vi(b,E))throw new Ht(b,E,">");if(b.length===1){var S=y.dimension(0);S.forEach(function(O,L){Ce(O),m.set([O,0],v[L[0]],x)})}else{var T=y.dimension(0),A=y.dimension(1);T.forEach(function(O,L){Ce(O),A.forEach(function(q,U){Ce(q),m.set([O,q],v[L[0]][U[0]],x)})})}}return m}n.prototype.get=function(m){if(!Ae(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Ht(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var y=m[0],v=m[1];Ce(y,this._size[0]),Ce(v,this._size[1]);var x=h(y,this._ptr[v],this._ptr[v+1],this._index);return x<this._ptr[v+1]&&this._index[x]===y?this._values[x]:0},n.prototype.set=function(m,y,v){if(!Ae(m))throw new TypeError("Array expected");if(m.length!==this._size.length)throw new Ht(m.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var x=m[0],b=m[1],M=this._size[0],E=this._size[1],F=e,N=0;en(this._datatype)&&(F=t.find(e,[this._datatype,this._datatype])||e,N=t.convert(0,this._datatype)),(x>M-1||b>E-1)&&(p(this,Math.max(x+1,M),Math.max(b+1,E),v),M=this._size[0],E=this._size[1]),Ce(x,M),Ce(b,E);var S=h(x,this._ptr[b],this._ptr[b+1],this._index);return S<this._ptr[b+1]&&this._index[S]===x?F(y,N)?d(S,b,this._values,this._index,this._ptr):this._values[S]=y:F(y,N)||f(S,x,b,y,this._values,this._index,this._ptr),this};function h(m,y,v,x){if(v-y===0)return v;for(var b=y;b<v;b++)if(x[b]===m)return b;return y}function d(m,y,v,x,b){v.splice(m,1),x.splice(m,1);for(var M=y+1;M<b.length;M++)b[M]--}function f(m,y,v,x,b,M,E){b.splice(m,0,x),M.splice(m,0,y);for(var F=v+1;F<E.length;F++)E[F]++}n.prototype.resize=function(m,y,v){if(!Qi(m))throw new TypeError("Array or Matrix expected");var x=m.valueOf().map(M=>Array.isArray(M)&&M.length===1?M[0]:M);if(x.length!==2)throw new Error("Only two dimensions matrix are supported");x.forEach(function(M){if(!_e(M)||!be(M)||M<0)throw new TypeError("Invalid size, must contain positive integers (size: "+he(x)+")")});var b=v?this.clone():this;return p(b,x[0],x[1],y)};function p(m,y,v,x){var b=x||0,M=e,E=0;en(m._datatype)&&(M=t.find(e,[m._datatype,m._datatype])||e,E=t.convert(0,m._datatype),b=t.convert(b,m._datatype));var F=!M(b,E),N=m._size[0],S=m._size[1],T,A,O;if(v>S){for(A=S;A<v;A++)if(m._ptr[A]=m._values.length,F)for(T=0;T<N;T++)m._values.push(b),m._index.push(T);m._ptr[v]=m._values.length}else v<S&&(m._ptr.splice(v+1,S-v),m._values.splice(m._ptr[v],m._values.length),m._index.splice(m._ptr[v],m._index.length));if(S=v,y>N){if(F){var L=0;for(A=0;A<S;A++){m._ptr[A]=m._ptr[A]+L,O=m._ptr[A+1]+L;var q=0;for(T=N;T<y;T++,q++)m._values.splice(O+q,0,b),m._index.splice(O+q,0,T),L++}m._ptr[S]=m._values.length}}else if(y<N){var U=0;for(A=0;A<S;A++){m._ptr[A]=m._ptr[A]-U;var W=m._ptr[A],z=m._ptr[A+1]-U;for(O=W;O<z;O++)T=m._index[O],T>y-1&&(m._values.splice(O,1),m._index.splice(O,1),U++)}m._ptr[A]=m._values.length}return m._size[0]=y,m._size[1]=v,m}n.prototype.reshape=function(m,y){if(!Ae(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(!_e(X)||!be(X)||X<=-2||X===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+he(m)+")")});var v=this._size[0]*this._size[1];m=Ca(m,v);var x=m[0]*m[1];if(v!==x)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var b=y?this.clone():this;if(this._size[0]===m[0]&&this._size[1]===m[1])return b;for(var M=[],E=0;E<b._ptr.length;E++)for(var F=0;F<b._ptr[E+1]-b._ptr[E];F++)M.push(E);for(var N=b._values.slice(),S=b._index.slice(),T=0;T<b._index.length;T++){var A=S[T],O=M[T],L=A*b._size[1]+O;M[T]=L%m[1],S[T]=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 q=0;q<b._ptr.length;q++)b._ptr[q]=0;for(var U=0;U<N.length;U++){var W=S[U],z=M[U],K=N[U],Z=h(W,b._ptr[z],b._ptr[z+1],b._index);f(Z,W,z,K,b._values,b._index,b._ptr)}return b},n.prototype.clone=function(){var m=new n({values:this._values?oe(this._values):void 0,index:oe(this._index),ptr:oe(this._ptr),size:oe(this._size),datatype:this._datatype});return m},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(m,y){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var v=this,x=this._size[0],b=this._size[1],M=Pc(m),E=function(N,S,T){return M===1?m(N):M===2?m(N,[S,T]):m(N,[S,T],v)};return g(this,0,x-1,0,b-1,E,y)};function g(m,y,v,x,b,M,E){var F=[],N=[],S=[],T=e,A=0;en(m._datatype)&&(T=t.find(e,[m._datatype,m._datatype])||e,A=t.convert(0,m._datatype));for(var O=function(lt,yt,bt){lt=M(lt,yt,bt),T(lt,A)||(F.push(lt),N.push(yt))},L=x;L<=b;L++){S.push(F.length);var q=m._ptr[L],U=m._ptr[L+1];if(E)for(var W=q;W<U;W++){var z=m._index[W];z>=y&&z<=v&&O(m._values[W],z-y,L-x)}else{for(var K={},Z=q;Z<U;Z++){var X=m._index[Z];K[X]=m._values[Z]}for(var Q=y;Q<=v;Q++){var ct=Q in K?K[Q]:0;O(ct,Q-y,L-x)}}}return S.push(F.length),new n({values:F,index:N,ptr:S,size:[v-y+1,b-x+1]})}n.prototype.forEach=function(m,y){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var v=this,x=this._size[0],b=this._size[1],M=0;M<b;M++){var E=this._ptr[M],F=this._ptr[M+1];if(y)for(var N=E;N<F;N++){var S=this._index[N];m(this._values[N],[S,M],v)}else{for(var T={},A=E;A<F;A++){var O=this._index[A];T[O]=this._values[A]}for(var L=0;L<x;L++){var q=L in T?T[L]:0;m(q,[L,M],v)}}}},n.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var m=this._size[1],y=0;y<m;y++)for(var v=this._ptr[y],x=this._ptr[y+1],b=v;b<x;b++){var M=this._index[b];yield{value:this._values[b],index:[M,y]}}},n.prototype.toArray=function(){return w(this._values,this._index,this._ptr,this._size,!0)},n.prototype.valueOf=function(){return w(this._values,this._index,this._ptr,this._size,!1)};function w(m,y,v,x,b){var M=x[0],E=x[1],F=[],N,S;for(N=0;N<M;N++)for(F[N]=[],S=0;S<E;S++)F[N][S]=0;for(S=0;S<E;S++)for(var T=v[S],A=v[S+1],O=T;O<A;O++)N=y[O],F[N][S]=m?b?oe(m[O]):m[O]:1;return F}return n.prototype.format=function(m){for(var y=this._size[0],v=this._size[1],x=this.density(),b="Sparse Matrix ["+he(y,m)+" x "+he(v,m)+"] density: "+he(x,m)+`
53
53
  `,M=0;M<v;M++)for(var E=this._ptr[M],F=this._ptr[M+1],N=E;N<F;N++){var S=this._index[N];b+=`
54
- (`+he(S,_)+", "+he(M,_)+") ==> "+(this._values?he(this._values[N],_):"X")}return b},n.prototype.toString=function(){return he(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(_){if(_){if(Oe(_)&&(_=_.toNumber()),!_e(_)||!be(_))throw new TypeError("The parameter k must be an integer number")}else _=0;var y=_>0?_:0,v=_<0?-_:0,x=this._size[0],b=this._size[1],M=Math.min(x-v,b-y),E=[],F=[],N=[];N[0]=0;for(var S=y;S<b&&E.length<M;S++)for(var T=this._ptr[S],C=this._ptr[S+1],O=T;O<C;O++){var $=this._index[O];if($===S-y+v){E.push(this._values[O]),F[E.length-1]=$-v;break}}return N.push(E.length),new n({values:E,index:F,ptr:N,size:[M,1]})},n.fromJSON=function(_){return new n(_)},n.diagonal=function(_,y,v,x,b){if(!Ae(_))throw new TypeError("Array expected, size parameter");if(_.length!==2)throw new Error("Only two dimensions matrix are supported");if(_=_.map(function(X){if(Oe(X)&&(X=X.toNumber()),!_e(X)||!be(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Oe(v)&&(v=v.toNumber()),!_e(v)||!be(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var M=e,E=0;en(b)&&(M=t.find(e,[b,b])||e,E=t.convert(0,b));var F=v>0?v:0,N=v<0?-v:0,S=_[0],T=_[1],C=Math.min(S-N,T-F),O;if(Ae(y)){if(y.length!==C)throw new Error("Invalid value array length");O=function(Q){return y[Q]}}else if(we(y)){var $=y.size();if($.length!==1||$[0]!==C)throw new Error("Invalid matrix length");O=function(Q){return y.get([Q])}}else O=function(){return y};for(var W=[],q=[],U=[],z=0;z<T;z++){U.push(W.length);var K=z-F;if(K>=0&&K<C){var Z=O(K);M(Z,E)||(q.push(K+N),W.push(Z))}}return U.push(W.length),new n({values:W,index:q,ptr:U,size:[S,T]})},n.prototype.swapRows=function(_,y){if(!_e(_)||!be(_)||!_e(y)||!be(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ce(_,this._size[0]),Ce(y,this._size[0]),n._swapRows(_,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(_,y,v,x,b){for(var M=x[_],E=x[_+1],F=M;F<E;F++)b(v[F],y[F])},n._swapRows=function(_,y,v,x,b,M){for(var E=0;E<v;E++){var F=M[E],N=M[E+1],S=f(_,F,N,b),T=f(y,F,N,b);if(S<N&&T<N&&b[S]===_&&b[T]===y){if(x){var C=x[S];x[S]=x[T],x[T]=C}continue}if(S<N&&b[S]===_&&(T>=N||b[T]!==y)){var O=x?x[S]:void 0;b.splice(T,0,y),x&&x.splice(T,0,O),b.splice(T<=S?S+1:S,1),x&&x.splice(T<=S?S+1:S,1);continue}if(T<N&&b[T]===y&&(S>=N||b[S]!==_)){var $=x?x[T]:void 0;b.splice(S,0,_),x&&x.splice(S,0,$),b.splice(S<=T?T+1:T,1),x&&x.splice(S<=T?T+1:T,1)}}},n},{isClass:!0}),Vm="number",Ym=["typed"];function Zm(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function Km(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var Gm=mt(Vm,Ym,i=>{var{typed:t}=i,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var s=Zm(n);if(s)return Km(s);var a=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(a=Number(l[2]),n=l[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),null:function(n){return 0},"Unit, string | Unit":function(n,s){return n.toNumber(s)},"Array | Matrix":t.referToSelf(r=>n=>Zr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),Hm="bignumber",Jm=["typed","BigNumber"],Xm=mt(Hm,Jm,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var a=s[2],l=e(s[1]),c=new e(2).pow(Number(a));if(l.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var f=new e(2).pow(Number(a)-1);return l.gte(f)?l.sub(c):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Zr(n,r))})}),Qm="fraction",tg=["typed","Fraction"],eg=mt(Qm,tg,i=>{var{typed:t,Fraction:e}=i;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,s){return new e(n,s)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Zr(n,r))})}),Qc="matrix",rg=["typed","Matrix","DenseMatrix","SparseMatrix"],ng=mt(Qc,rg,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t(Qc,{"":function(){return s([])},string:function(l){return s([],l)},"string, string":function(l,c){return s([],l,c)},Array:function(l){return s(l)},Matrix:function(l){return s(l,l.storage())},"Array | Matrix, string":s,"Array | Matrix, string, string":s});function s(a,l,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)+".")}}),tf="unaryMinus",ig=["typed"],sg=mt(tf,ig,i=>{var{typed:t}=i;return t(tf,{number:Vc,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf(e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n}),"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),ef="abs",og=["typed"],ag=mt(ef,og,i=>{var{typed:t}=i;return t(ef,{number:qc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),rf="addScalar",ug=["typed"],lg=mt(rf,ug,i=>{var{typed:t}=i;return t(rf,{"number, number":Uc,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),nf="subtractScalar",cg=["typed"],fg=mt(nf,cg,i=>{var{typed:t}=i;return t(nf,{"number, number":Wc,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),hg="matAlgo11xS0s",dg=["typed","equalScalar"],Ra=mt(hg,dg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,l){var c=n._values,f=n._index,d=n._ptr,h=n._size,p=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=h[0],w=h[1],_,y=e,v=0,x=a;typeof p=="string"&&(_=p,y=t.find(e,[_,_]),v=t.convert(0,_),s=t.convert(s,_),x=t.find(a,[_,_]));for(var b=[],M=[],E=[],F=0;F<w;F++){E[F]=M.length;for(var N=d[F],S=d[F+1],T=N;T<S;T++){var C=f[T],O=l?x(s,c[T]):x(c[T],s);y(O,v)||(M.push(C),b.push(O))}}return E[w]=M.length,n.createSparseMatrix({values:b,index:M,ptr:E,size:[g,w],datatype:_})}}),pg="matAlgo12xSfs",_g=["typed","DenseMatrix"],Ei=mt(pg,_g,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,l){var c=n._values,f=n._index,d=n._ptr,h=n._size,p=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=h[0],w=h[1],_,y=a;typeof p=="string"&&(_=p,s=t.convert(s,_),y=t.find(a,[_,_]));for(var v=[],x=[],b=[],M=0;M<w;M++){for(var E=M+1,F=d[M],N=d[M+1],S=F;S<N;S++){var T=f[S];x[T]=c[S],b[T]=E}for(var C=0;C<g;C++)M===0&&(v[C]=[]),b[C]===E?v[C][M]=l?y(s,x[C]):y(x[C],s):v[C][M]=l?y(s,0):y(0,s)}return new e({data:v,size:[g,w],datatype:_})}}),mg="matAlgo14xDs",gg=["typed"],Pa=mt(mg,gg,i=>{var{typed:t}=i;return function(n,s,a,l){var c=n._data,f=n._size,d=n._datatype,h,p=a;typeof d=="string"&&(h=d,s=t.convert(s,h),p=t.find(a,[h,h]));var g=f.length>0?e(p,0,f,f[0],c,s,l):[];return n.createDenseMatrix({data:g,size:oe(f),datatype:h})};function e(r,n,s,a,l,c,f){var d=[];if(n===s.length-1)for(var h=0;h<a;h++)d[h]=f?r(c,l[h]):r(l[h],c);else for(var p=0;p<a;p++)d[p]=e(r,n+1,s,s[n+1],l[p],c,f);return d}}),vg="matAlgo02xDS0",wg=["typed","equalScalar"],yg=mt(vg,wg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,l){var c=n._data,f=n._size,d=n._datatype||n.getDataType(),h=s._values,p=s._index,g=s._ptr,w=s._size,_=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(f.length!==w.length)throw new Ht(f.length,w.length);if(f[0]!==w[0]||f[1]!==w[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+w+")");if(!h)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=f[0],v=f[1],x,b=e,M=0,E=a;typeof d=="string"&&d===_&&d!=="mixed"&&(x=d,b=t.find(e,[x,x]),M=t.convert(0,x),E=t.find(a,[x,x]));for(var F=[],N=[],S=[],T=0;T<v;T++){S[T]=N.length;for(var C=g[T],O=g[T+1],$=C;$<O;$++){var W=p[$],q=l?E(h[$],c[W][T]):E(c[W][T],h[$]);b(q,M)||(N.push(W),F.push(q))}}return S[v]=N.length,s.createSparseMatrix({values:F,index:N,ptr:S,size:[y,v],datatype:d===n._datatype&&_===s._datatype?x:void 0})}}),Dg="matAlgo03xDSf",bg=["typed"],Ai=mt(Dg,bg,i=>{var{typed:t}=i;return function(r,n,s,a){var l=r._data,c=r._size,f=r._datatype||r.getDataType(),d=n._values,h=n._index,p=n._ptr,g=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var _=c[0],y=c[1],v,x=0,b=s;typeof f=="string"&&f===w&&f!=="mixed"&&(v=f,x=t.convert(0,v),b=t.find(s,[v,v]));for(var M=[],E=0;E<_;E++)M[E]=[];for(var F=[],N=[],S=0;S<y;S++){for(var T=S+1,C=p[S],O=p[S+1],$=C;$<O;$++){var W=h[$];F[W]=a?b(d[$],l[W][S]):b(l[W][S],d[$]),N[W]=T}for(var q=0;q<_;q++)N[q]===T?M[q][S]=F[q]:M[q][S]=a?b(x,l[q][S]):b(l[q][S],x)}return r.createDenseMatrix({data:M,size:[_,y],datatype:f===r._datatype&&w===n._datatype?v:void 0})}}),xg="matAlgo05xSfSf",Eg=["typed","equalScalar"],sf=mt(xg,Eg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var l=n._values,c=n._index,f=n._ptr,d=n._size,h=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=s._values,g=s._index,w=s._ptr,_=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(d.length!==_.length)throw new Ht(d.length,_.length);if(d[0]!==_[0]||d[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+d+") must match Matrix B ("+_+")");var v=d[0],x=d[1],b,M=e,E=0,F=a;typeof h=="string"&&h===y&&h!=="mixed"&&(b=h,M=t.find(e,[b,b]),E=t.convert(0,b),F=t.find(a,[b,b]));var N=l&&p?[]:void 0,S=[],T=[],C=N?[]:void 0,O=N?[]:void 0,$=[],W=[],q,U,z,K;for(U=0;U<x;U++){T[U]=S.length;var Z=U+1;for(z=f[U],K=f[U+1];z<K;z++)q=c[z],S.push(q),$[q]=Z,C&&(C[q]=l[z]);for(z=w[U],K=w[U+1];z<K;z++)q=g[z],$[q]!==Z&&S.push(q),W[q]=Z,O&&(O[q]=p[z]);if(N)for(z=T[U];z<S.length;){q=S[z];var X=$[q],Q=W[q];if(X===Z||Q===Z){var ct=X===Z?C[q]:E,vt=Q===Z?O[q]:E,lt=F(ct,vt);M(lt,E)?S.splice(z,1):(N.push(lt),z++)}}}return T[x]=S.length,n.createSparseMatrix({values:N,index:S,ptr:T,size:[v,x],datatype:h===n._datatype&&y===s._datatype?b:void 0})}}),Ag="matAlgo13xDD",Cg=["typed"],Fg=mt(Ag,Cg,i=>{var{typed:t}=i;return function(n,s,a){var l=n._data,c=n._size,f=n._datatype,d=s._data,h=s._size,p=s._datatype,g=[];if(c.length!==h.length)throw new Ht(c.length,h.length);for(var w=0;w<c.length;w++){if(c[w]!==h[w])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+h+")");g[w]=c[w]}var _,y=a;typeof f=="string"&&f===p&&(_=f,y=t.find(a,[_,_]));var v=g.length>0?e(y,0,g,g[0],l,d):[];return n.createDenseMatrix({data:v,size:g,datatype:_})};function e(r,n,s,a,l,c){var f=[];if(n===s.length-1)for(var d=0;d<a;d++)f[d]=r(l[d],c[d]);else for(var h=0;h<a;h++)f[h]=e(r,n+1,s,s[n+1],l[h],c[h]);return f}}),Mg="broadcast",Ng=["concat"],Sg=mt(Mg,Ng,i=>{var{concat:t}=i;return function(n,s){var a=Math.max(n._size.length,s._size.length);if(n._size.length===s._size.length&&n._size.every((w,_)=>w===s._size[_]))return[n,s];for(var l=e(n._size,a,0),c=e(s._size,a,0),f=[],d=0;d<a;d++)f[d]=Math.max(l[d],c[d]);$s(l,f),$s(c,f);var h=n.clone(),p=s.clone();h._size.length<a?h.reshape(e(h._size,a,1)):p._size.length<a&&p.reshape(e(p._size,a,1));for(var g=0;g<a;g++)h._size[g]<f[g]&&(h=r(h,f[g],g)),p._size[g]<f[g]&&(p=r(p,f[g],g));return[h,p]};function e(n,s,a){return[...Array(s-n.length).fill(a),...n]}function r(n,s,a){return t(...Array(s).fill(n),a)}}),Og="matrixAlgorithmSuite",Bg=["typed","matrix","concat"],Xn=mt(Og,Bg,i=>{var{typed:t,matrix:e,concat:r}=i,n=Fg({typed:t}),s=Pa({typed:t}),a=Sg({concat:r});return function(c){var f=c.elop,d=c.SD||c.DS,h;f?(h={"DenseMatrix, DenseMatrix":(_,y)=>n(...a(_,y),f),"Array, Array":(_,y)=>n(...a(e(_),e(y)),f).valueOf(),"Array, DenseMatrix":(_,y)=>n(...a(e(_),y),f),"DenseMatrix, Array":(_,y)=>n(...a(_,e(y)),f)},c.SS&&(h["SparseMatrix, SparseMatrix"]=(_,y)=>c.SS(...a(_,y),f,!1)),c.DS&&(h["DenseMatrix, SparseMatrix"]=(_,y)=>c.DS(...a(_,y),f,!1),h["Array, SparseMatrix"]=(_,y)=>c.DS(...a(e(_),y),f,!1)),d&&(h["SparseMatrix, DenseMatrix"]=(_,y)=>d(...a(y,_),f,!0),h["SparseMatrix, Array"]=(_,y)=>d(...a(e(y),_),f,!0))):(h={"DenseMatrix, DenseMatrix":t.referToSelf(_=>(y,v)=>n(...a(y,v),_)),"Array, Array":t.referToSelf(_=>(y,v)=>n(...a(e(y),e(v)),_).valueOf()),"Array, DenseMatrix":t.referToSelf(_=>(y,v)=>n(...a(e(y),v),_)),"DenseMatrix, Array":t.referToSelf(_=>(y,v)=>n(...a(y,e(v)),_))},c.SS&&(h["SparseMatrix, SparseMatrix"]=t.referToSelf(_=>(y,v)=>c.SS(...a(y,v),_,!1))),c.DS&&(h["DenseMatrix, SparseMatrix"]=t.referToSelf(_=>(y,v)=>c.DS(...a(y,v),_,!1)),h["Array, SparseMatrix"]=t.referToSelf(_=>(y,v)=>c.DS(...a(e(y),v),_,!1))),d&&(h["SparseMatrix, DenseMatrix"]=t.referToSelf(_=>(y,v)=>d(...a(v,y),_,!0)),h["SparseMatrix, Array"]=t.referToSelf(_=>(y,v)=>d(...a(e(v),y),_,!0))));var p=c.scalar||"any",g=c.Ds||c.Ss;g&&(f?(h["DenseMatrix,"+p]=(_,y)=>s(_,y,f,!1),h[p+", DenseMatrix"]=(_,y)=>s(y,_,f,!0),h["Array,"+p]=(_,y)=>s(e(_),y,f,!1).valueOf(),h[p+", Array"]=(_,y)=>s(e(y),_,f,!0).valueOf()):(h["DenseMatrix,"+p]=t.referToSelf(_=>(y,v)=>s(y,v,_,!1)),h[p+", DenseMatrix"]=t.referToSelf(_=>(y,v)=>s(v,y,_,!0)),h["Array,"+p]=t.referToSelf(_=>(y,v)=>s(e(y),v,_,!1).valueOf()),h[p+", Array"]=t.referToSelf(_=>(y,v)=>s(e(v),y,_,!0).valueOf())));var w=c.sS!==void 0?c.sS:c.Ss;return f?(c.Ss&&(h["SparseMatrix,"+p]=(_,y)=>c.Ss(_,y,f,!1)),w&&(h[p+", SparseMatrix"]=(_,y)=>w(y,_,f,!0))):(c.Ss&&(h["SparseMatrix,"+p]=t.referToSelf(_=>(y,v)=>c.Ss(y,v,_,!1))),w&&(h[p+", SparseMatrix"]=t.referToSelf(_=>(y,v)=>w(v,y,_,!0)))),f&&f.signatures&&Jl(h,f.signatures),h}}),Ig="matAlgo01xDSid",Tg=["typed"],of=mt(Ig,Tg,i=>{var{typed:t}=i;return function(r,n,s,a){var l=r._data,c=r._size,f=r._datatype||r.getDataType(),d=n._values,h=n._index,p=n._ptr,g=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var _=c[0],y=c[1],v=typeof f=="string"&&f!=="mixed"&&f===w?f:void 0,x=v?t.find(s,[v,v]):s,b,M,E=[];for(b=0;b<_;b++)E[b]=[];var F=[],N=[];for(M=0;M<y;M++){for(var S=M+1,T=p[M],C=p[M+1],O=T;O<C;O++)b=h[O],F[b]=a?x(d[O],l[b][M]):x(l[b][M],d[O]),N[b]=S;for(b=0;b<_;b++)N[b]===S?E[b][M]=F[b]:E[b][M]=l[b][M]}return r.createDenseMatrix({data:E,size:[_,y],datatype:f===r._datatype&&w===n._datatype?v:void 0})}}),$g="matAlgo04xSidSid",Lg=["typed","equalScalar"],Rg=mt($g,Lg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var l=n._values,c=n._index,f=n._ptr,d=n._size,h=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=s._values,g=s._index,w=s._ptr,_=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(d.length!==_.length)throw new Ht(d.length,_.length);if(d[0]!==_[0]||d[1]!==_[1])throw new RangeError("Dimension mismatch. Matrix A ("+d+") must match Matrix B ("+_+")");var v=d[0],x=d[1],b,M=e,E=0,F=a;typeof h=="string"&&h===y&&h!=="mixed"&&(b=h,M=t.find(e,[b,b]),E=t.convert(0,b),F=t.find(a,[b,b]));var N=l&&p?[]:void 0,S=[],T=[],C=l&&p?[]:void 0,O=l&&p?[]:void 0,$=[],W=[],q,U,z,K,Z;for(U=0;U<x;U++){T[U]=S.length;var X=U+1;for(K=f[U],Z=f[U+1],z=K;z<Z;z++)q=c[z],S.push(q),$[q]=X,C&&(C[q]=l[z]);for(K=w[U],Z=w[U+1],z=K;z<Z;z++)if(q=g[z],$[q]===X){if(C){var Q=F(C[q],p[z]);M(Q,E)?$[q]=null:C[q]=Q}}else S.push(q),W[q]=X,O&&(O[q]=p[z]);if(C&&O)for(z=T[U];z<S.length;)q=S[z],$[q]===X?(N[z]=C[q],z++):W[q]===X?(N[z]=O[q],z++):S.splice(z,1)}return T[x]=S.length,n.createSparseMatrix({values:N,index:S,ptr:T,size:[v,x],datatype:h===n._datatype&&y===s._datatype?b:void 0})}}),Pg="matAlgo10xSids",zg=["typed","DenseMatrix"],af=mt(Pg,zg,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,l){var c=n._values,f=n._index,d=n._ptr,h=n._size,p=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=h[0],w=h[1],_,y=a;typeof p=="string"&&(_=p,s=t.convert(s,_),y=t.find(a,[_,_]));for(var v=[],x=[],b=[],M=0;M<w;M++){for(var E=M+1,F=d[M],N=d[M+1],S=F;S<N;S++){var T=f[S];x[T]=c[S],b[T]=E}for(var C=0;C<g;C++)M===0&&(v[C]=[]),b[C]===E?v[C][M]=l?y(s,x[C]):y(x[C],s):v[C][M]=s}return new e({data:v,size:[g,w],datatype:_})}}),kg="multiplyScalar",qg=["typed"],Ug=mt(kg,qg,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":jc,"Complex, Complex":function(r,n){return r.mul(n)},"BigNumber, BigNumber":function(r,n){return r.times(n)},"Fraction, Fraction":function(r,n){return r.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})}),uf="multiply",Wg=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],jg=mt(uf,Wg,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:a}=i,l=Ra({typed:t,equalScalar:s}),c=Pa({typed:t});function f(E,F){switch(E.length){case 1:switch(F.length){case 1:if(E[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(E[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+E[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(E[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+E[1]+") must match Vector length ("+F[0]+")");break;case 2:if(E[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+E[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 "+E.length+" dimensions)")}}function d(E,F,N){if(N===0)throw new Error("Cannot multiply two empty vectors");return a(E,F)}function h(E,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return p(E,F)}function p(E,F){var N=E._data,S=E._size,T=E._datatype||E.getDataType(),C=F._data,O=F._size,$=F._datatype||F.getDataType(),W=S[0],q=O[1],U,z=r,K=n;T&&$&&T===$&&typeof T=="string"&&T!=="mixed"&&(U=T,z=t.find(r,[U,U]),K=t.find(n,[U,U]));for(var Z=[],X=0;X<q;X++){for(var Q=K(N[0],C[0][X]),ct=1;ct<W;ct++)Q=z(Q,K(N[ct],C[ct][X]));Z[X]=Q}return E.createDenseMatrix({data:Z,size:[q],datatype:T===E._datatype&&$===F._datatype?U:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":_,"SparseMatrix, any":x}),w=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":M});function _(E,F){var N=E._data,S=E._size,T=E._datatype||E.getDataType(),C=F._data,O=F._datatype||F.getDataType(),$=S[0],W=S[1],q,U=r,z=n;T&&O&&T===O&&typeof T=="string"&&T!=="mixed"&&(q=T,U=t.find(r,[q,q]),z=t.find(n,[q,q]));for(var K=[],Z=0;Z<$;Z++){for(var X=N[Z],Q=z(X[0],C[0]),ct=1;ct<W;ct++)Q=U(Q,z(X[ct],C[ct]));K[Z]=Q}return E.createDenseMatrix({data:K,size:[$],datatype:T===E._datatype&&O===F._datatype?q:void 0})}function y(E,F){var N=E._data,S=E._size,T=E._datatype||E.getDataType(),C=F._data,O=F._size,$=F._datatype||F.getDataType(),W=S[0],q=S[1],U=O[1],z,K=r,Z=n;T&&$&&T===$&&typeof T=="string"&&T!=="mixed"&&T!=="mixed"&&(z=T,K=t.find(r,[z,z]),Z=t.find(n,[z,z]));for(var X=[],Q=0;Q<W;Q++){var ct=N[Q];X[Q]=[];for(var vt=0;vt<U;vt++){for(var lt=Z(ct[0],C[0][vt]),yt=1;yt<q;yt++)lt=K(lt,Z(ct[yt],C[yt][vt]));X[Q][vt]=lt}}return E.createDenseMatrix({data:X,size:[W,U],datatype:T===E._datatype&&$===F._datatype?z:void 0})}function v(E,F){var N=E._data,S=E._size,T=E._datatype||E.getDataType(),C=F._values,O=F._index,$=F._ptr,W=F._size,q=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!C)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var U=S[0],z=W[1],K,Z=r,X=n,Q=s,ct=0;T&&q&&T===q&&typeof T=="string"&&T!=="mixed"&&(K=T,Z=t.find(r,[K,K]),X=t.find(n,[K,K]),Q=t.find(s,[K,K]),ct=t.convert(0,K));for(var vt=[],lt=[],yt=[],bt=F.createSparseMatrix({values:vt,index:lt,ptr:yt,size:[U,z],datatype:T===E._datatype&&q===F._datatype?K:void 0}),Ot=0;Ot<z;Ot++){yt[Ot]=lt.length;var xt=$[Ot],ue=$[Ot+1];if(ue>xt)for(var It=0,Nt=0;Nt<U;Nt++){for(var fe=Nt+1,re=void 0,qt=xt;qt<ue;qt++){var Jt=O[qt];It!==fe?(re=X(N[Nt][Jt],C[qt]),It=fe):re=Z(re,X(N[Nt][Jt],C[qt]))}It===fe&&!Q(re,ct)&&(lt.push(Nt),vt.push(re))}}return yt[z]=lt.length,bt}function x(E,F){var N=E._values,S=E._index,T=E._ptr,C=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!N)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=F._data,$=F._datatype||F.getDataType(),W=E._size[0],q=F._size[0],U=[],z=[],K=[],Z,X=r,Q=n,ct=s,vt=0;C&&$&&C===$&&typeof C=="string"&&C!=="mixed"&&(Z=C,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]),ct=t.find(s,[Z,Z]),vt=t.convert(0,Z));var lt=[],yt=[];K[0]=0;for(var bt=0;bt<q;bt++){var Ot=O[bt];if(!ct(Ot,vt))for(var xt=T[bt],ue=T[bt+1],It=xt;It<ue;It++){var Nt=S[It];yt[Nt]?lt[Nt]=X(lt[Nt],Q(Ot,N[It])):(yt[Nt]=!0,z.push(Nt),lt[Nt]=Q(Ot,N[It]))}}for(var fe=z.length,re=0;re<fe;re++){var qt=z[re];U[re]=lt[qt]}return K[1]=z.length,E.createSparseMatrix({values:U,index:z,ptr:K,size:[W,1],datatype:C===E._datatype&&$===F._datatype?Z:void 0})}function b(E,F){var N=E._values,S=E._index,T=E._ptr,C=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!N)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=F._data,$=F._datatype||F.getDataType(),W=E._size[0],q=F._size[0],U=F._size[1],z,K=r,Z=n,X=s,Q=0;C&&$&&C===$&&typeof C=="string"&&C!=="mixed"&&(z=C,K=t.find(r,[z,z]),Z=t.find(n,[z,z]),X=t.find(s,[z,z]),Q=t.convert(0,z));for(var ct=[],vt=[],lt=[],yt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[W,U],datatype:C===E._datatype&&$===F._datatype?z:void 0}),bt=[],Ot=[],xt=0;xt<U;xt++){lt[xt]=vt.length;for(var ue=xt+1,It=0;It<q;It++){var Nt=O[It][xt];if(!X(Nt,Q))for(var fe=T[It],re=T[It+1],qt=fe;qt<re;qt++){var Jt=S[qt];Ot[Jt]!==ue?(Ot[Jt]=ue,vt.push(Jt),bt[Jt]=Z(Nt,N[qt])):bt[Jt]=K(bt[Jt],Z(Nt,N[qt]))}}for(var Le=lt[xt],wr=vt.length,ke=Le;ke<wr;ke++){var _n=vt[ke];ct[ke]=bt[_n]}}return lt[U]=vt.length,yt}function M(E,F){var N=E._values,S=E._index,T=E._ptr,C=E._datatype||E._data===void 0?E._datatype:E.getDataType(),O=F._values,$=F._index,W=F._ptr,q=F._datatype||F._data===void 0?F._datatype:F.getDataType(),U=E._size[0],z=F._size[1],K=N&&O,Z,X=r,Q=n;C&&q&&C===q&&typeof C=="string"&&C!=="mixed"&&(Z=C,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]));for(var ct=K?[]:void 0,vt=[],lt=[],yt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[U,z],datatype:C===E._datatype&&q===F._datatype?Z:void 0}),bt=K?[]:void 0,Ot=[],xt,ue,It,Nt,fe,re,qt,Jt,Le=0;Le<z;Le++){lt[Le]=vt.length;var wr=Le+1;for(fe=W[Le],re=W[Le+1],Nt=fe;Nt<re;Nt++)if(Jt=$[Nt],K)for(ue=T[Jt],It=T[Jt+1],xt=ue;xt<It;xt++)qt=S[xt],Ot[qt]!==wr?(Ot[qt]=wr,vt.push(qt),bt[qt]=Q(O[Nt],N[xt])):bt[qt]=X(bt[qt],Q(O[Nt],N[xt]));else for(ue=T[Jt],It=T[Jt+1],xt=ue;xt<It;xt++)qt=S[xt],Ot[qt]!==wr&&(Ot[qt]=wr,vt.push(qt));if(K)for(var ke=lt[Le],_n=vt.length,Tn=ke;Tn<_n;Tn++){var mn=vt[Tn];ct[Tn]=bt[mn]}}return lt[z]=vt.length,yt}return t(uf,n,{"Array, Array":t.referTo("Matrix, Matrix",E=>(F,N)=>{f(Te(F),Te(N));var S=E(e(F),e(N));return we(S)?S.valueOf():S}),"Matrix, Matrix":function(F,N){var S=F.size(),T=N.size();return f(S,T),S.length===1?T.length===1?d(F,N,S[0]):h(F,N):T.length===1?g(F,N):w(F,N)},"Matrix, Array":t.referTo("Matrix,Matrix",E=>(F,N)=>E(F,e(N))),"Array, Matrix":t.referToSelf(E=>(F,N)=>E(e(F,N.storage()),N)),"SparseMatrix, any":function(F,N){return l(F,N,n,!1)},"DenseMatrix, any":function(F,N){return c(F,N,n,!1)},"any, SparseMatrix":function(F,N){return l(N,F,n,!0)},"any, DenseMatrix":function(F,N){return c(N,F,n,!0)},"Array, any":function(F,N){return c(e(F),N,n,!1).valueOf()},"any, Array":function(F,N){return c(e(N),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(E=>(F,N,S)=>{for(var T=E(F,N),C=0;C<S.length;C++)T=E(T,S[C]);return T})})}),lf="subtract",Vg=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],Yg=mt(lf,Vg,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:a,concat:l}=i,c=of({typed:t}),f=Ai({typed:t}),d=sf({typed:t,equalScalar:r}),h=af({typed:t,DenseMatrix:a}),p=Ei({typed:t,DenseMatrix:a}),g=Xn({typed:t,matrix:e,concat:l});return t(lf,{"any, any":n},g({elop:n,SS:d,DS:c,SD:f,Ss:p,sS:h}))}),Zg="matAlgo07xSSf",Kg=["typed","DenseMatrix"],Hs=mt(Zg,Kg,i=>{var{typed:t,DenseMatrix:e}=i;return function(s,a,l){var c=s._size,f=s._datatype||s._data===void 0?s._datatype:s.getDataType(),d=a._size,h=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==d.length)throw new Ht(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var p=c[0],g=c[1],w,_=0,y=l;typeof f=="string"&&f===h&&f!=="mixed"&&(w=f,_=t.convert(0,w),y=t.find(l,[w,w]));var v,x,b=[];for(v=0;v<p;v++)b[v]=[];var M=[],E=[],F=[],N=[];for(x=0;x<g;x++){var S=x+1;for(r(s,x,F,M,S),r(a,x,N,E,S),v=0;v<p;v++){var T=F[v]===S?M[v]:_,C=N[v]===S?E[v]:_;b[v][x]=y(T,C)}}return new e({data:b,size:[p,g],datatype:f===s._datatype&&h===a._datatype?w:void 0})};function r(n,s,a,l,c){for(var f=n._values,d=n._index,h=n._ptr,p=h[s],g=h[s+1];p<g;p++){var w=d[p];a[w]=c,l[w]=f[p]}}}),cf="conj",Gg=["typed"],Hg=mt(cf,Gg,i=>{var{typed:t}=i;return t(cf,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),ff="concat",Jg=["typed","matrix","isInteger"],Xg=mt(ff,Jg,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(ff,{"...Array | Matrix | number | BigNumber":function(s){var a,l=s.length,c=-1,f,d=!1,h=[];for(a=0;a<l;a++){var p=s[a];if(we(p)&&(d=!0),_e(p)||Oe(p)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(f=c,c=p.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>f)throw new Fn(c,f+1)}else{var g=oe(p).valueOf(),w=Te(g);if(h[a]=g,f=c,c=w.length-1,a>0&&c!==f)throw new Ht(f+1,c+1)}}if(h.length===0)throw new SyntaxError("At least one matrix expected");for(var _=h.shift();h.length;)_=gc(_,h.shift(),c);return d?e(_):_},"...string":function(s){return s.join("")}})}),hf="count",Qg=["typed","size","prod"],tv=mt(hf,Qg,i=>{var{typed:t,size:e,prod:r}=i;return t(hf,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),df="identity",ev=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],rv=mt(df,ev,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:a}=i;return t(df,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(d){return r(d)},"number | BigNumber":function(d){return c(d,d,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(d,h){return c(d,d,h)},"number | BigNumber, number | BigNumber":function(d,h){return c(d,h,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(d,h,p){return c(d,h,p)},Array:function(d){return l(d)},"Array, string":function(d,h){return l(d,h)},Matrix:function(d){return l(d.valueOf(),d.storage())},"Matrix, string":function(d,h){return l(d.valueOf(),h)}});function l(f,d){switch(f.length){case 0:return d?r(d):[];case 1:return c(f[0],f[0],d);case 2:return c(f[0],f[1],d);default:throw new Error("Vector containing two values expected")}}function c(f,d,h){var p=Oe(f)||Oe(d)?n:null;if(Oe(f)&&(f=f.toNumber()),Oe(d)&&(d=d.toNumber()),!be(f)||f<1)throw new Error("Parameters in function identity must be positive integers");if(!be(d)||d<1)throw new Error("Parameters in function identity must be positive integers");var g=p?new n(1):1,w=p?new p(0):0,_=[f,d];if(h){if(h==="sparse")return a.diagonal(_,g,0,w);if(h==="dense")return s.diagonal(_,g,0,w);throw new TypeError('Unknown matrix type "'.concat(h,'"'))}for(var y=xa([],_,w),v=f<d?f:d,x=0;x<v;x++)y[x][x]=g;return y}}),pf="kron",nv=["typed","matrix","multiplyScalar"],iv=mt(pf,nv,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(pf,{"Matrix, Matrix":function(a,l){return e(n(a.toArray(),l.toArray()))},"Matrix, Array":function(a,l){return e(n(a.toArray(),l))},"Array, Matrix":function(a,l){return e(n(a,l.toArray()))},"Array, Array":n});function n(s,a){if(Te(s).length===1&&(s=[s]),Te(a).length===1&&(a=[a]),Te(s).length>2||Te(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(s.length)+", y = "+JSON.stringify(a.length)+")");var l=[],c=[];return s.map(function(f){return a.map(function(d){return c=[],l.push(c),f.map(function(h){return d.map(function(p){return c.push(r(h,p))})})})})&&l}});function sv(){throw new Error('No "bignumber" implementation available')}function ov(){throw new Error('No "fraction" implementation available')}function av(){throw new Error('No "matrix" implementation available')}var _f="reshape",uv=["typed","isInteger","matrix"],lv=mt(_f,uv,i=>{var{typed:t,isInteger:e}=i;return t(_f,{"Matrix, Array":function(n,s){return n.reshape(s,!0)},"Array, Array":function(n,s){return s.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),Aa(n,s)}})}),mf="size",cv=["typed","config","?matrix"],fv=mt(mf,cv,i=>{var{typed:t,config:e,matrix:r}=i;return t(mf,{Matrix:function(s){return s.create(s.size())},Array:Te,string:function(s){return e.matrix==="Array"?[s.length]:r([s.length])},"number | Complex | BigNumber | Unit | boolean | null":function(s){return e.matrix==="Array"?[]:r?r([]):av()}})}),gf="transpose",hv=["typed","matrix"],dv=mt(gf,hv,i=>{var{typed:t,matrix:e}=i;return t(gf,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:oe});function r(a){var l=a.size(),c;switch(l.length){case 1:c=a.clone();break;case 2:{var f=l[0],d=l[1];if(d===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+he(l)+")");switch(a.storage()){case"dense":c=n(a,f,d);break;case"sparse":c=s(a,f,d);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+he(l)+")")}return c}function n(a,l,c){for(var f=a._data,d=[],h,p=0;p<c;p++){h=d[p]=[];for(var g=0;g<l;g++)h[g]=oe(f[g][p])}return a.createDenseMatrix({data:d,size:[c,l],datatype:a._datatype})}function s(a,l,c){for(var f=a._values,d=a._index,h=a._ptr,p=f?[]:void 0,g=[],w=[],_=[],y=0;y<l;y++)_[y]=0;var v,x,b;for(v=0,x=d.length;v<x;v++)_[d[v]]++;for(var M=0,E=0;E<l;E++)w.push(M),M+=_[E],_[E]=w[E];for(w.push(M),b=0;b<c;b++)for(var F=h[b],N=h[b+1],S=F;S<N;S++){var T=_[d[S]]++;g[T]=b,f&&(p[T]=oe(f[S]))}return a.createSparseMatrix({values:p,index:g,ptr:w,size:[c,l],datatype:a._datatype})}}),vf="ctranspose",pv=["typed","transpose","conj"],_v=mt(vf,pv,i=>{var{typed:t,transpose:e,conj:r}=i;return t(vf,{any:function(s){return r(e(s))}})}),wf="mode",mv=["typed","isNaN","isNumeric"],gv=mt(wf,mv,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(wf,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(s){s=Fa(s.valueOf());var a=s.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},c=[],f=0,d=0;d<s.length;d++){var h=s[d];if(r(h)&&e(h))throw new Error("Cannot calculate mode of an array containing NaN values");h in l||(l[h]=0),l[h]++,l[h]===f?c.push(h):l[h]>f&&(f=l[h],c=[h])}return c}});function Bn(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+Cn(e)+", value: "+JSON.stringify(e)+")":" (type: "+i.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(i).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+Cn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var yf="prod",vv=["typed","config","multiplyScalar","numeric"],wv=mt(yf,vv,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(yf,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return s(l)}});function s(a){var l;if(rs(a,function(c){try{l=l===void 0?c:r(l,c)}catch(f){throw Bn(f,"prod",c)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),yv="numeric",Dv=["number","?bignumber","?fraction"],bv=mt(yv,Dv,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:a=>t(a),BigNumber:e?a=>e(a):sv,Fraction:r?a=>r(a):ov};return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",f=arguments.length>2?arguments[2]:void 0;if(f!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var d=Cn(l);if(!(d in n))throw new TypeError("Cannot convert "+l+' of type "'+d+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in s))throw new TypeError("Cannot convert "+l+' to type "'+c+'"; valid output types are '+Object.keys(s).join(", "));return c===d?l:s[c](l)}}),Df="divideScalar",xv=["typed","numeric"],Ev=mt(Df,xv,i=>{var{typed:t,numeric:e}=i;return t(Df,{"number, number":function(n,s){return n/s},"Complex, Complex":function(n,s){return n.div(s)},"BigNumber, BigNumber":function(n,s){return n.div(s)},"Fraction, Fraction":function(n,s){return n.div(s)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),bf="pow",Av=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Cv=mt(bf,Av,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:a,number:l,fraction:c,Complex:f}=i;return t(bf,{"number, number":d,"Complex, Complex":function(w,_){return w.pow(_)},"BigNumber, BigNumber":function(w,_){return _.isInteger()||w>=0||e.predictable?w.pow(_):new f(w.toNumber(),0).pow(_.toNumber(),0)},"Fraction, Fraction":function(w,_){var y=w.pow(_);if(y!=null)return y;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return d(w.valueOf(),_.valueOf())},"Array, number":h,"Array, BigNumber":function(w,_){return h(w,_.toNumber())},"Matrix, number":p,"Matrix, BigNumber":function(w,_){return p(w,_.toNumber())},"Unit, number | BigNumber":function(w,_){return w.pow(_)}});function d(g,w){if(e.predictable&&!be(w)&&g<0)try{var _=c(w),y=l(_);if((w===y||Math.abs((w-y)/w)<1e-14)&&_.d%2===1)return(_.n%2===0?1:-1)*Math.pow(-g,w)}catch{}return e.predictable&&(g<-1&&w===1/0||g>-1&&g<0&&w===-1/0)?NaN:be(w)||g>=0||e.predictable?Yc(g,w):g*g<1&&w===1/0||g*g>1&&w===-1/0?0:new f(g,0).pow(w,0)}function h(g,w){if(!be(w))throw new TypeError("For A^b, b must be an integer (value is "+w+")");var _=Te(g);if(_.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+_.length+" dimensions)");if(_[0]!==_[1])throw new Error("For A^b, A must be square (size is "+_[0]+"x"+_[1]+")");if(w<0)try{return h(a(g),-w)}catch(x){throw x.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+w+")"):x}for(var y=r(_[0]).valueOf(),v=g;w>=1;)(w&1)===1&&(y=n(v,y)),w>>=1,v=n(v,v);return y}function p(g,w){return s(h(g.valueOf(),w))}}),xf="dotDivide",Fv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],Mv=mt(xf,Fv,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:a}=i,l=yg({typed:t,equalScalar:r}),c=Ai({typed:t}),f=Hs({typed:t,DenseMatrix:s}),d=Ra({typed:t,equalScalar:r}),h=Ei({typed:t,DenseMatrix:s}),p=Xn({typed:t,matrix:e,concat:a});return t(xf,p({elop:n,SS:f,DS:c,SD:l,Ss:d,sS:h}))}),Js="compare",Nv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],Sv=mt(Js,Nv,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:a,DenseMatrix:l,concat:c}=i,f=Ai({typed:t}),d=sf({typed:t,equalScalar:r}),h=Ei({typed:t,DenseMatrix:l}),p=Xn({typed:t,matrix:n,concat:c}),g=Ks({typed:t});return t(Js,Ov({typed:t,config:e}),{"boolean, boolean":function(_,y){return _===y?0:_>y?1:-1},"BigNumber, BigNumber":function(_,y){return Zs(_,y,e.epsilon)?new s(0):new s(_.cmp(y))},"Fraction, Fraction":function(_,y){return new a(_.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,p({SS:d,DS:f,Ss:h}))}),Ov=mt(Js,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Js,{"number, number":function(n,s){return Jn(n,s,e.epsilon)?0:n>s?1:-1}})}),Xs="equal",Bv=["typed","matrix","equalScalar","DenseMatrix","concat"],Iv=mt(Xs,Bv,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),l=Hs({typed:t,DenseMatrix:n}),c=Ei({typed:t,DenseMatrix:n}),f=Xn({typed:t,matrix:e,concat:s});return t(Xs,Tv({typed:t,equalScalar:r}),f({elop:r,SS:l,DS:a,Ss:c}))}),Tv=mt(Xs,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(Xs,{"any, any":function(n,s){return n===null?s===null:s===null?n===null:n===void 0?s===void 0:s===void 0?n===void 0:e(n,s)}})}),Qs="smaller",$v=["typed","config","matrix","DenseMatrix","concat"],Lv=mt(Qs,$v,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),l=Hs({typed:t,DenseMatrix:n}),c=Ei({typed:t,DenseMatrix:n}),f=Xn({typed:t,matrix:r,concat:s}),d=Ks({typed:t});return t(Qs,Rv({typed:t,config:e}),{"boolean, boolean":(h,p)=>h<p,"BigNumber, BigNumber":function(p,g){return p.lt(g)&&!Zs(p,g,e.epsilon)},"Fraction, Fraction":(h,p)=>h.compare(p)===-1,"Complex, Complex":function(p,g){throw new TypeError("No ordering relation is defined for complex numbers")}},d,f({SS:l,DS:a,Ss:c}))}),Rv=mt(Qs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Qs,{"number, number":function(n,s){return n<s&&!Jn(n,s,e.epsilon)}})}),to="larger",Pv=["typed","config","matrix","DenseMatrix","concat"],zv=mt(to,Pv,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),l=Hs({typed:t,DenseMatrix:n}),c=Ei({typed:t,DenseMatrix:n}),f=Xn({typed:t,matrix:r,concat:s}),d=Ks({typed:t});return t(to,kv({typed:t,config:e}),{"boolean, boolean":(h,p)=>h>p,"BigNumber, BigNumber":function(p,g){return p.gt(g)&&!Zs(p,g,e.epsilon)},"Fraction, Fraction":(h,p)=>h.compare(p)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},d,f({SS:l,DS:a,Ss:c}))}),kv=mt(to,["typed","config"],i=>{var{typed:t,config:e}=i;return t(to,{"number, number":function(n,s){return n>s&&!Jn(n,s,e.epsilon)}})}),Ef="deepEqual",qv=["typed","equal"],Uv=mt(Ef,qv,i=>{var{typed:t,equal:e}=i;return t(Ef,{"any, any":function(s,a){return r(s.valueOf(),a.valueOf())}});function r(n,s){if(Array.isArray(n))if(Array.isArray(s)){var a=n.length;if(a!==s.length)return!1;for(var l=0;l<a;l++)if(!r(n[l],s[l]))return!1;return!0}else return!1;else return Array.isArray(s)?!1:e(n,s)}}),Af="partitionSelect",Wv=["typed","isNumeric","isNaN","compare"],jv=mt(Af,Wv,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,a=(f,d)=>-n(f,d);return t(Af,{"Array | Matrix, number":function(d,h){return l(d,h,s)},"Array | Matrix, number, string":function(d,h,p){if(p==="asc")return l(d,h,s);if(p==="desc")return l(d,h,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(f,d,h){if(!be(d)||d<0)throw new Error("k must be a non-negative integer");if(we(f)){var p=f.size();if(p.length>1)throw new Error("Only one dimensional matrices supported");return c(f.valueOf(),d,h)}if(Array.isArray(f))return c(f,d,h)}function c(f,d,h){if(d>=f.length)throw new Error("k out of bounds");for(var p=0;p<f.length;p++)if(e(f[p])&&r(f[p]))return f[p];for(var g=0,w=f.length-1;g<w;){for(var _=g,y=w,v=f[Math.floor(Math.random()*(w-g+1))+g];_<y;)if(h(f[_],v)>=0){var x=f[y];f[y]=f[_],f[_]=x,--y}else++_;h(f[_],v)>0&&--_,d<=_?w=_:g=_+1}return f[d]}}),Cf="max",Vv=["typed","config","numeric","larger"],Yv=mt(Cf,Vv,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(Cf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,f){return La(c,f.valueOf(),s)},"...":function(c){if(js(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function s(l,c){try{return n(l,c)?l:c}catch(f){throw Bn(f,"max",c)}}function a(l){var c;if(rs(l,function(f){try{isNaN(f)&&typeof f=="number"?c=NaN:(c===void 0||n(f,c))&&(c=f)}catch(d){throw Bn(d,"max",f)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),Ff="min",Zv=["typed","config","numeric","smaller"],Kv=mt(Ff,Zv,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(Ff,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,f){return La(c,f.valueOf(),s)},"...":function(c){if(js(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function s(l,c){try{return n(l,c)?l:c}catch(f){throw Bn(f,"min",c)}}function a(l){var c;if(rs(l,function(f){try{isNaN(f)&&typeof f=="number"?c=NaN:(c===void 0||n(f,c))&&(c=f)}catch(d){throw Bn(d,"min",f)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),Mf="add",Gv=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Hv=mt(Mf,Gv,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:a,concat:l}=i,c=of({typed:t}),f=Rg({typed:t,equalScalar:n}),d=af({typed:t,DenseMatrix:s}),h=Xn({typed:t,matrix:e,concat:l});return t(Mf,{"any, any":r,"any, any, ...any":t.referToSelf(p=>(g,w,_)=>{for(var y=p(g,w),v=0;v<_.length;v++)y=p(y,_[v]);return y})},h({elop:r,DS:c,SS:f,Ss:d}))}),Nf="dot",Jv=["typed","addScalar","multiplyScalar","conj","size"],Xv=mt(Nf,Jv,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(Nf,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":c});function a(d,h){var p=f(d),g=f(h),w,_;if(p.length===1)w=p[0];else if(p.length===2&&p[1]===1)w=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(g.length===1)_=g[0];else if(g.length===2&&g[1]===1)_=g[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+g.join(", ")+")");if(w!==_)throw new RangeError("Vectors must have equal length ("+w+" != "+_+")");if(w===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return w}function l(d,h){var p=a(d,h),g=we(d)?d._data:d,w=we(d)?d._datatype||d.getDataType():void 0,_=we(h)?h._data:h,y=we(h)?h._datatype||h.getDataType():void 0,v=f(d).length===2,x=f(h).length===2,b=e,M=r;if(w&&y&&w===y&&typeof w=="string"&&w!=="mixed"){var E=w;b=t.find(e,[E,E]),M=t.find(r,[E,E])}if(!v&&!x){for(var F=M(n(g[0]),_[0]),N=1;N<p;N++)F=b(F,M(n(g[N]),_[N]));return F}if(!v&&x){for(var S=M(n(g[0]),_[0][0]),T=1;T<p;T++)S=b(S,M(n(g[T]),_[T][0]));return S}if(v&&!x){for(var C=M(n(g[0][0]),_[0]),O=1;O<p;O++)C=b(C,M(n(g[O][0]),_[O]));return C}if(v&&x){for(var $=M(n(g[0][0]),_[0][0]),W=1;W<p;W++)$=b($,M(n(g[W][0]),_[W][0]));return $}}function c(d,h){a(d,h);for(var p=d._index,g=d._values,w=h._index,_=h._values,y=0,v=e,x=r,b=0,M=0;b<p.length&&M<w.length;){var E=p[b],F=w[M];if(E<F){b++;continue}if(E>F){M++;continue}E===F&&(y=v(y,x(g[b],_[M])),b++,M++)}return y}function f(d){return we(d)?d.size():s(d)}}),Qv="trace",t1=["typed","matrix","add"],e1=mt(Qv,t1,i=>{var{typed:t,matrix:e,add:r}=i;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:s,DenseMatrix:n,any:oe});function n(a){var l=a._size,c=a._data;switch(l.length){case 1:if(l[0]===1)return oe(c[0]);throw new RangeError("Matrix must be square (size: "+he(l)+")");case 2:{var f=l[0],d=l[1];if(f===d){for(var h=0,p=0;p<f;p++)h=r(h,c[p][p]);return h}else throw new RangeError("Matrix must be square (size: "+he(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+he(l)+")")}}function s(a){var l=a._values,c=a._index,f=a._ptr,d=a._size,h=d[0],p=d[1];if(h===p){var g=0;if(l.length>0)for(var w=0;w<p;w++)for(var _=f[w],y=f[w+1],v=_;v<y;v++){var x=c[v];if(x===w){g=r(g,l[v]);break}if(x>w)break}return g}throw new RangeError("Matrix must be square (size: "+he(d)+")")}}),Sf="det",r1=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],n1=mt(Sf,r1,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:a,unaryMinus:l}=i;return t(Sf,{any:function(d){return oe(d)},"Array | Matrix":function(d){var h;switch(we(d)?h=d.size():Array.isArray(d)?(d=e(d),h=d.size()):h=[],h.length){case 0:return oe(d);case 1:if(h[0]===1)return oe(d.valueOf()[0]);if(h[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+he(h)+")");case 2:{var p=h[0],g=h[1];if(p===g)return c(d.clone().valueOf(),p);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+he(h)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+he(h)+")")}}});function c(f,d,h){if(d===1)return oe(f[0][0]);if(d===2)return r(n(f[0][0],f[1][1]),n(f[1][0],f[0][1]));for(var p=!1,g=new Array(d).fill(0).map((N,S)=>S),w=0;w<d;w++){var _=g[w];if(a(f[_][w])){var y=void 0;for(y=w+1;y<d;y++)if(!a(f[g[y]][w])){_=g[y],g[y]=g[w],g[w]=_,p=!p;break}if(y===d)return f[_][w]}for(var v=f[_][w],x=w===0?1:f[g[w-1]][w-1],b=w+1;b<d;b++)for(var M=g[b],E=w+1;E<d;E++)f[M][E]=s(r(n(f[M][E],v),n(f[M][w],f[_][E])),x)}var F=f[g[d-1]][d-1];return p?l(F):F}}),Of="inv",i1=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],s1=mt(Of,i1,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:a,det:l,identity:c,abs:f}=i;return t(Of,{"Array | Matrix":function(p){var g=we(p)?p.size():Te(p);switch(g.length){case 1:if(g[0]===1)return we(p)?e([r(1,p.valueOf()[0])]):[r(1,p[0])];throw new RangeError("Matrix must be square (size: "+he(g)+")");case 2:{var w=g[0],_=g[1];if(w===_)return we(p)?e(d(p.valueOf(),w,_),p.storage()):d(p,w,_);throw new RangeError("Matrix must be square (size: "+he(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+he(g)+")")}},any:function(p){return r(1,p)}});function d(h,p,g){var w,_,y,v,x;if(p===1){if(v=h[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(p===2){var b=l(h);if(b===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(h[1][1],b),r(a(h[0][1]),b)],[r(a(h[1][0]),b),r(h[0][0],b)]]}else{var M=h.concat();for(w=0;w<p;w++)M[w]=M[w].concat();for(var E=c(p).valueOf(),F=0;F<g;F++){var N=f(M[F][F]),S=F;for(w=F+1;w<p;)f(M[w][F])>N&&(N=f(M[w][F]),S=w),w++;if(N===0)throw Error("Cannot calculate inverse, determinant is zero");w=S,w!==F&&(x=M[F],M[F]=M[w],M[w]=x,x=E[F],E[F]=E[w],E[w]=x);var T=M[F],C=E[F];for(w=0;w<p;w++){var O=M[w],$=E[w];if(w!==F){if(O[F]!==0){for(y=r(a(O[F]),T[F]),_=F;_<g;_++)O[_]=n(O[_],s(y,T[_]));for(_=0;_<g;_++)$[_]=n($[_],s(y,C[_]))}}else{for(y=T[F],_=F;_<g;_++)O[_]=r(O[_],y);for(_=0;_<g;_++)$[_]=r($[_],y)}}}return E}}}),Bf="pinv",o1=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],a1=mt(Bf,o1,i=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:s,dotDivide:a,dot:l,ctranspose:c,divideScalar:f,multiply:d,add:h,Complex:p}=i;return t(Bf,{"Array | Matrix":function(b){var M=we(b)?b.size():Te(b);switch(M.length){case 1:return v(b)?c(b):M[0]===1?r(b):a(c(b),l(b,b));case 2:{if(v(b))return c(b);var E=M[0],F=M[1];if(E===F)try{return r(b)}catch(N){if(!(N instanceof Error&&N.message.match(/Cannot calculate inverse, determinant is zero/)))throw N}return we(b)?e(g(b.valueOf(),E,F),b.storage()):g(b,E,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+he(M)+")")}},any:function(b){return s(b,0)?oe(b):f(1,b)}});function g(x,b,M){var{C:E,F}=_(x,b,M),N=d(r(d(c(E),E)),c(E)),S=d(c(F),r(d(F,c(F))));return d(S,N)}function w(x,b,M){for(var E=oe(x),F=0,N=0;N<b;N++){if(M<=F)return E;for(var S=N;y(E[S][F]);)if(S++,b===S&&(S=N,F++,M===F))return E;[E[S],E[N]]=[E[N],E[S]];for(var T=E[N][F],C=0;C<M;C++)E[N][C]=a(E[N][C],T);for(var O=0;O<b;O++)if(O!==N){T=E[O][F];for(var $=0;$<M;$++)E[O][$]=h(E[O][$],d(-1,d(T,E[N][$])))}F++}return E}function _(x,b,M){var E=w(x,b,M),F=x.map((S,T)=>S.filter((C,O)=>O<b&&!y(l(E[O],E[O])))),N=E.filter((S,T)=>!y(l(E[T],E[T])));return{C:F,F:N}}function y(x){return s(h(x,p(1,1)),h(0,p(1,1)))}function v(x){return n(h(x,p(1,1)),h(d(x,0),p(1,1)))}}),u1="divide",l1=["typed","matrix","multiply","equalScalar","divideScalar","inv"],c1=mt(u1,l1,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:a}=i,l=Ra({typed:t,equalScalar:n}),c=Pa({typed:t});return t("divide",Jl({"Array | Matrix, Array | Matrix":function(d,h){return r(d,a(h))},"DenseMatrix, any":function(d,h){return c(d,h,s,!1)},"SparseMatrix, any":function(d,h){return l(d,h,s,!1)},"Array, any":function(d,h){return c(e(d),h,s,!1).valueOf()},"any, Array | Matrix":function(d,h){return r(d,a(h))}},s.signatures))}),If="sum",f1=["typed","config","add","numeric"],h1=mt(If,f1,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(If,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":a,"...":function(c){if(js(c))throw new TypeError("Scalar values expected in function sum");return s(c)}});function s(l){var c;return rs(l,function(f){try{c=c===void 0?f:r(c,f)}catch(d){throw Bn(d,"sum",f)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(l,c){try{var f=La(l,c,r);return f}catch(d){throw Bn(d,"sum")}}}),Tf="median",d1=["typed","add","divide","compare","partitionSelect"],p1=mt(Tf,d1,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function a(f){try{f=Fa(f.valueOf());var d=f.length;if(d===0)throw new Error("Cannot calculate median of an empty array");if(d%2===0){for(var h=d/2-1,p=s(f,h+1),g=f[h],w=0;w<h;++w)n(f[w],g)>0&&(g=f[w]);return c(g,p)}else{var _=s(f,(d-1)/2);return l(_)}}catch(y){throw Bn(y,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(d){return d}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(d,h){return r(e(d,h),2)}});return t(Tf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(d,h){throw new Error("median(A, dim) is not yet supported")},"...":function(d){if(js(d))throw new TypeError("Scalar values expected in function median");return a(d)}})}),eo=_m({config:gr}),za=wm({}),ka=xm({}),qa=Cm({}),nn=Nm({Matrix:qa}),Mt=v_({BigNumber:eo,Complex:za,DenseMatrix:nn,Fraction:ka}),_1=ag({typed:Mt}),ro=lg({typed:Mt}),m1=Xm({BigNumber:eo,typed:Mt}),$f=Hg({typed:Mt}),In=qm({config:gr,typed:Mt}),no=Bm({typed:Mt}),g1=Lm({typed:Mt}),io=Ug({typed:Mt}),Lf=Gm({typed:Mt}),Ua=jm({Matrix:qa,equalScalar:In,typed:Mt}),Rf=fg({typed:Mt}),Pf=Pm({typed:Mt}),Wa=sg({typed:Mt}),zf=eg({Fraction:ka,typed:Mt}),kf=Tm({typed:Mt}),$e=ng({DenseMatrix:nn,Matrix:qa,SparseMatrix:Ua,typed:Mt}),qf=gv({isNaN:Pf,isNumeric:kf,typed:Mt}),ns=bv({bignumber:m1,fraction:zf,number:Lf}),v1=wv({config:gr,multiplyScalar:io,numeric:ns,typed:Mt}),w1=lv({isInteger:no,matrix:$e,typed:Mt}),Uf=fv({matrix:$e,config:gr,typed:Mt}),Wf=dv({matrix:$e,typed:Mt}),Qn=Xg({isInteger:no,matrix:$e,typed:Mt}),y1=tv({prod:v1,size:Uf,typed:Mt}),D1=_v({conj:$f,transpose:Wf,typed:Mt}),is=Ev({numeric:ns,typed:Mt}),b1=Mv({DenseMatrix:nn,concat:Qn,divideScalar:is,equalScalar:In,matrix:$e,typed:Mt}),jf=Iv({DenseMatrix:nn,concat:Qn,equalScalar:In,matrix:$e,typed:Mt}),Vf=rv({BigNumber:eo,DenseMatrix:nn,SparseMatrix:Ua,config:gr,matrix:$e,typed:Mt}),x1=iv({matrix:$e,multiplyScalar:io,typed:Mt}),E1=Lv({DenseMatrix:nn,concat:Qn,config:gr,matrix:$e,typed:Mt}),A1=Yg({DenseMatrix:nn,concat:Qn,equalScalar:In,matrix:$e,subtractScalar:Rf,typed:Mt,unaryMinus:Wa}),ss=Hv({DenseMatrix:nn,SparseMatrix:Ua,addScalar:ro,concat:Qn,equalScalar:In,matrix:$e,typed:Mt}),Yf=Sv({BigNumber:eo,DenseMatrix:nn,Fraction:ka,concat:Qn,config:gr,equalScalar:In,matrix:$e,typed:Mt}),C1=Uv({equal:jf,typed:Mt}),Zf=Xv({addScalar:ro,conj:$f,multiplyScalar:io,size:Uf,typed:Mt}),F1=zv({DenseMatrix:nn,concat:Qn,config:gr,matrix:$e,typed:Mt}),ja=Kv({config:gr,numeric:ns,smaller:E1,typed:Mt}),Ci=jg({addScalar:ro,dot:Zf,equalScalar:In,matrix:$e,multiplyScalar:io,typed:Mt}),M1=jv({compare:Yf,isNaN:Pf,isNumeric:kf,typed:Mt}),N1=h1({add:ss,config:gr,numeric:ns,typed:Mt}),S1=e1({add:ss,matrix:$e,typed:Mt}),Kf=n1({divideScalar:is,isZero:g1,matrix:$e,multiply:Ci,subtractScalar:Rf,typed:Mt,unaryMinus:Wa}),O1=Yv({config:gr,larger:F1,numeric:ns,typed:Mt}),so=s1({abs:_1,addScalar:ro,det:Kf,divideScalar:is,identity:Vf,matrix:$e,multiply:Ci,typed:Mt,unaryMinus:Wa}),B1=a1({Complex:za,add:ss,ctranspose:D1,deepEqual:C1,divideScalar:is,dot:Zf,dotDivide:b1,equal:jf,inv:so,matrix:$e,multiply:Ci,typed:Mt}),I1=Cv({Complex:za,config:gr,fraction:zf,identity:Vf,inv:so,matrix:$e,multiply:Ci,number:Lf,typed:Mt}),T1=c1({divideScalar:is,equalScalar:In,inv:so,matrix:$e,multiply:Ci,typed:Mt}),Gf=p1({add:ss,compare:Yf,divide:T1,partitionSelect:M1,typed:Mt});class $1{constructor(t,e,r){L(this,"_cacheData");L(this,"_variables");L(this,"_math");L(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},a){if(e===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(t,e,`alma_${a}`);if(l===void 0)return;let c=r*(e-1);s&&(c=Math.floor(c));const f=e/n;let d=0,h=0;for(let p=0;p<=e-1;p++){const g=Math.exp(-1*Math.pow(p-c,2)/(2*Math.pow(f,2)));d+=g,h+=l[l.length-1-(e-p-1)]*g}return h/d}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const a=s.slice(-e);return n=N1(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const{sum:n}=this._cacheData[`rma_${r}`]||{},s=1/e,a=this.sma({source:t,length:e},r),l=n===void 0?a:s*t+(1-s)*(n||0);return this._cacheDataHandle(`rma_${r}`,{sum:l}),l}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:s,close:a,low:l}=this._variables,c=r===void 0?s-l:Math.max(Math.max(s-l,Math.abs(s-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:s,close:a}),this.rma({source:c,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(s===void 0)return;let l=0;for(let c=0;c<e;c++){const f=this._sum(s[s.length-1-c],-(a||0));l+=f*f}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return[];const l=r*a;return[s,s+l,s-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return;const l=r*a;return(s+l-(s-l))/s}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){const n=this._cacheDataList(t,e,`change_${r}`);if(n===void 0)return;const s=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return s===void 0?s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||a===void 0))return 100*(s-a)/(s+a)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let a=0;for(let l=0;l<e;l++){const c=n[n.length-1-l];a+=c*(l+1)}return-a/s}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),l=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||l===void 0||s===void 0)return;let c=0,f=0,d=0;for(let p=0;p<r;p++){const[g,w]=s[s.length-1-p],_=g-a,y=w-l;c+=_*y,f+=_*_,d+=y*y}return isNaN(f)||isNaN(c)||isNaN(d)?void 0:c/Math.sqrt(f*d)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e||n<=s&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n<=s&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let s=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let l=0;l<e;l++){const c=a[a.length-1-l];s+=Math.abs(c-n)}return s/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:s,high:a,close:l,PDMS:c,NDMS:f,TRS:d,ADX:h,count:p=0}=this._cacheData[n]||{},{low:g,high:w,close:_}=this._variables;if(s===void 0||a===void 0||l===void 0)return this._cacheData[n]={low:g,high:w,close:_,PDMS:c,NDMS:f,TRS:w-g,count:1},[void 0,void 0,void 0];let y=w-a,v=s-g;y=y>v&&y>0?y:0,v=v>y&&v>0?v:0,y===v&&(y=v=0);const x=Math.max(w-g,Math.abs(w-l),Math.abs(g-l));if(p<t)return this._cacheDataHandle(n,{low:g,high:w,close:_,PDMS:(c||0)+y,NDMS:(f||0)+v,TRS:(d||0)+x,count:p+1}),[void 0,void 0,void 0];{const b=c-c/t+y,M=f-f/t+v,E=d-d/t+x,F=b/E*100,N=M/E*100,S=Math.abs((F-N)/(F+N))*100;let T=S,C=[F,N,void 0];if(p+1-t<e){const O=p+1-t;T=((h||0)*(O-1)+S)/O}else T=(h*(e-1)+S)/e,C=[F,N,T];return this._cacheDataHandle(n,{low:g,high:w,close:_,PDMS:b,NDMS:M,TRS:E,ADX:T,count:p+1}),C}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:s=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:t,length:e},r);if(s>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=a;return s+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:s}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:s=[]}=this._cacheData[`falling_${r}`]||{};s.push(n>t);const a=s.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:a}),a.length<e?!1:a.every(l=>l)}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,risings:s=[]}=this._cacheData[`rising_${r}`]||{};s.push(n<t);const a=s.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,risings:a}),a.length<e?!1:a.every(l=>l)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`highest_${r}`);if(s)return Math.max(...s.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`highestbars_${r}`);return s?s.slice(-e).reduce((l,c,f,d)=>c>=d[l]?f:l,0)-e+1:void 0}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,a=0;for(let l=0;l<e;l++){const c=(e-l)*e;s+=c,a+=n[n.length-1-l]*c}return a/s}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},s),{ta:l,high:c,low:f}=this._variables,d=n?l.tr:c-f,h=this.ema({source:d,length:e},`range_${s}`);return[a,a+h*r,a-h*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},s),{ta:l,high:c,low:f}=this._variables,d=n?l.tr:c-f,h=this.ema({source:d,length:e},`range_${s}`);return(a+h*r-(a-h*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const s=this._cacheDataList(t,e,`dev_${n}`);if(!s)return;const a=s.slice(-e).filter(g=>g!==void 0);let l=0,c=0,f=0,d=0;for(const[g,w]of a.entries())l+=g,c+=w,f+=g*w,d+=g*g;const h=(e*f-l*c)/(e*d-l*l);return(c-h*l)/e+h*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`lowest_${r}`);if(s)return Math.min(...s.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`lowestbars_${r}`);return s?s.slice(-e).reduce((l,c,f,d)=>c<=d[l]?f:l,0)-e+1:void 0}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${s}`),l=this.ema({source:t,length:r},`ema2_${s}`);if(a===void 0||l===void 0)return[void 0,void 0,void 0];const c=a-l,f=this.ema({source:c,length:n},`macd_${s}`);if(f===void 0)return[c,f,void 0];const d=c-f;return[c,f,d]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Gf(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),a=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(s<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||a===void 0))return 100-100/(1+l/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return ja(qf(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,s=this._cacheData[n]||[];if(s[this._variables.bar_index]=t,this._cacheData[n]=s,s.length<=e||t===void 0||isNaN(t))return;let a=s.length-e-1,l;for(;l===void 0&&a>=0;)l=s[a],a--;return l===void 0?l:t-l}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!s)return;const a=this._sort(s.slice(-(e+1))),l=a.length;r/=100;const c=1/(l*2);if(r<=c)return a[0];if(r>=1-1/(l*2))return a[l-1];for(const[f,d]of a.entries()){const h=a[f-1];if(r<(f+.5)/l)return h===void 0||d===void 0?void 0:h+(d-h)*(r-(f-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const a=this._sort(s.slice(-e)),l=r/100*a.length,c=Math.ceil(l)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const s=n.slice(-(e+1)),a=t;if(a===void 0)return;let l=0;for(let c=0;c<s.length;c++)s[c]!==void 0&&(s[c]<a||s[c]===a&&c<e)&&l++;return l/(s.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const s=new Qt;let{close:a,open:l,low:c,high:f}=this._variables;const d=`pivot_point_levels_${n}`,{close:h,low:p,high:g,open:w,result:_}=this._cacheData[d]||{};if(!e&&(g&&p&&(f=Math.max(g,f),c=Math.min(p,c)),this._cacheDataHandle(d,{close:a,open:l,low:c,high:f,result:_}),!r))return s._value=_||[],s;const y={close:a,open:l,low:c,high:f};e===!0&&!r&&(a=h,l=w,c=p,f=g);const v=this._getPivotPointLevels(f,c,a,l,r,t);return this._cacheDataHandle(d,{...y,result:v}),s._value=v,s}_getPivotPointLevels(t,e,r,n,s,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Hn.traditional:return this._traditional(t,e,r);case Hn.fibonacci:return this._fibonacci(t,e,r);case Hn.woodie:return s?[]:this._woodie(t,e);case Hn.classic:return this._classic(t,e,r);case Hn.dm:return this._DM(t,e,r,n);case Hn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,s=n*2-e,a=n+(t-e),l=n*2+(t-2*e),c=n*3+(t-3*e),f=n*4+(t-4*e),d=n*2-t,h=n-(t-e),p=n*2-(2*t-e),g=n*3-(3*t-e),w=n*4-(4*t-e);return[n,s,d,a,h,l,p,c,g,f,w]}_fibonacci(t,e,r){const n=(t+e+r)/3,s=n+.382*(t-e),a=n-.382*(t-e),l=n+.618*(t-e),c=n-.618*(t-e),f=n+(t-e),d=n-(t-e);return[n,s,a,l,c,f,d]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,s=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),f=t+2*(n-e),d=e-2*(t-n),h=f+(t-e),p=d-(t-e);return[n,s,a,l,c,f,d,h,p]}_classic(t,e,r){const n=(t+e+r)/3,s=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),f=n+2*(t-e),d=n-2*(t-e),h=n+3*(t-e),p=n-3*(t-e);return[n,s,a,l,c,f,d,h,p]}_DM(t,e,r,n){let s;n===r?s=t+e+2*r:r>n?s=2*t+e+r:s=2*e+t+r;const a=s/4,l=s/2-e,c=s/2-t;return[a,l,c]}_camarilla(t,e,r){const n=(t+e+r)/3,s=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,c=r-1.1*(t-e)/6,f=r+1.1*(t-e)/4,d=r-1.1*(t-e)/4,h=r+1.1*(t-e)/2,p=r-1.1*(t-e)/2,g=t/e*r,w=r-(g-r);return[n,s,a,l,c,f,d,h,p,g,w]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),l=a[e];return Math.max(...a)===l?l:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),l=a[e];return Math.min(...a)===l?l:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`,!0);if(!n)return;const s=n.filter(c=>c!==void 0).slice(-e),a=Math.max(...s),l=Math.min(...s);return a-l}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},s=Math.max(t-n,0),a=Math.max(n-t,0),l=this.rma({source:s,length:e},`rma1_${r}`),c=this.rma({source:a,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||c===void 0))return 100-100/(1+l/c)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:s,low:a,high:l,preLow:c,preHigh:f,data:d={}}=this._cacheData[`sar_${n}`]||{};let{result:h,maxMin:p,acceleration:g,isBelow:w}=d,_=!1;const{close:y,low:v,high:x,bar_index:b}=this._variables;return b===1&&(y>s?(w=!0,p=x,h=a):(w=!1,p=v,h=l),_=!0,g=t),h=h+g*(p-h),w?h>v&&(_=!0,w=!1,h=Math.max(x,p||0),p=v,g=t):h<x&&(_=!0,w=!0,h=Math.min(v,p||0),p=x,g=t),_||(w?x>(p||0)&&(p=x,g=Math.min((g||0)+e,r)):v<(p||0)&&(p=v,g=Math.min((g||0)+e,r))),w?(h=Math.min(h,a),b>1&&(h=Math.min(h,c))):(h=Math.max(h,l),b>1&&(h=Math.max(h,f))),this._cacheDataHandle(`sar_${n}`,{high:x,close:y,low:v,preLow:a,preHigh:l,data:Object.assign(d,{result:h,maxMin:p,acceleration:g,isBelow:w})}),h}stoch({source:t,high:e,low:r,length:n},s){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const a=this.lowest({source:r,length:n},s),l=this.highest({source:e,length:n},s);if(!(a===void 0||l===void 0))return 100*(t-a)/(l-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:s}=this._variables,a=`supertrend_${r}`,{upperBand:l,lowerBand:c,superTrend:f,atr:d,close:h}=this._cacheData[a]||{},p=this.atr({length:e},r);if(p===void 0)return this._cacheDataHandle(a,{close:s}),[void 0,void 0];let g=n+t*p,w=n-t*p;const _=l||0,y=c||0;w=w>y||h<y?w:y,g=g<_||h>_?g:_;let v;d===void 0?v=1:f===_?v=s>g?-1:1:v=s<w?1:-1;const x=v===-1?w:g;return this._cacheDataHandle(a,{upperBand:g,lowerBand:w,superTrend:x,atr:p,close:s}),[x,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:s}=this._variables,{close:a}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),a===void 0?t?s-n:void 0:Math.max(s-n,Math.abs(s-a),Math.abs(n-a))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.change({source:t},n);if(s===void 0)return;const a=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),l=this.ema({source:s,length:e},`ema1_${n}`);if(l===void 0)return;const c=this.ema({source:l,length:r},`ema2_${n}`),f=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/f}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:s}=this._cacheData[`valuewhen_${n}`]||{};return s||(s=[]),t&&s.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:s}),s[s.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const s=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`variance_${n}`,!0);if(!a||s===void 0)return;const l=a.filter(f=>f!==void 0&&!isNaN(f)).slice(-e);if(l.length<e)return;const c=l.reduce((f,d)=>f+Math.pow(d-s,2),0);if(c!==void 0)return r||e<=1?c/e:c/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:s}=this._variables;let{sum:a=0,sumV:l=0,count:c=0,isReset:f,sumS:d=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=l=c=d=0,f=!0),!f)return r!==void 0?[]:void 0;const h=t*s+a,p=s+l,g=h/p;return c++,r!==void 0?(d=s*Math.pow(t,2)+d,this._cacheDataHandle(`vwap_${n}`,{sum:h,sumV:p,count:c,isReset:f,sumS:d}),this._computeBands(d,p,r,g)):(this._cacheDataHandle(`vwap_${n}`,{sum:h,sumV:p,count:c,isReset:f}),g)}_computeBands(t,e,r,n){let s=t/e-Math.pow(n,2);s=s<0?0:s;const a=Math.sqrt(s),l=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,l,c]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||a===void 0))return s/a}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:a,currentIndex:l}=n,c=t[s];if(c!==void 0){if(a!==void 0&&c<a){t.splice(s,1),t.splice(l,0,c),n={currentIndex:l+1,currentVal:a};continue}n={currentIndex:s,currentVal:c}}}}return t}_cacheDataList(t,e,r,n=!1){const s=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:a}=this._variables;if(s.barIndex<=a){const l=s.list.length;if(s.barIndex===a)s.list[l-1]=t;else{let c=a-s.barIndex-1;if(s.barIndex!==-1&&c>0){const f=s.list[l-1];for(;c>0;)s.list.push(f),c--}s.list.push(t)}s.barIndex=a,s.list.length>e+5&&!n&&s.list.shift(),this._cacheData[r]=s}if(!(s.list.length<e))return s.list}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&!this._variables._isRealTimeBar&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}class L1{constructor(t,e,r){L(this,"_cacheData");L(this,"_variables");L(this,"_errorListener");L(this,"_historyInputs");L(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){if(!(t!=null&&t.length)){self.workerStorage.delete(this._name),this._cacheData={};return}for(const e of t){const r=e.id,n=this._historyInputs[r];(!(e!=null&&e.sourceTypeName)&&(n==null?void 0:n.defval)!==e.defval||n!=null&&n.sourceTypeName&&e.sourceTypeName!==(n==null?void 0:n.sourceTypeName))&&(this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...e,isModify:!0}))}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._cacheHandle(t,e,sr.INT)}bool(t,e){return this._cacheHandle(t,e,sr.BOOL)}color(t,e){return this._cacheHandle(t,e,sr.COLOR)}time(t,e){return this._cacheHandle(t,e,sr.TIME)}float(t,e){return this._cacheHandle(t,e,sr.FLOAT)}price(t,e){return this._cacheHandle(t,e,sr.PRICE)}source(t,e){return this._cacheHandle(t,e,sr.SOURCE)}string(t,e){return this._cacheHandle(t,e,sr.STRING)}symbol(t,e){return this._cacheHandle(t,e,sr.SYMBOL)}session(t,e){return this._cacheHandle(t,e,sr.SESSION)}text_area(t,e){return this._cacheHandle(t,e,sr.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,sr.TIMEFRAME)}enum(t,e){return this._cacheHandle(t,e,sr.ENUM)}_cacheHandle(t,e,r){if(e.startsWith("export"))return t.defval;const n=`${r||"input"}_${e}`,s=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(ce.inputDefvalErr,e,zt.Error),self.workerStorage.setValue(this._name,n,{...t}),s)if(!s.isModify)Object.assign(this._cacheData[n],t);else{const a=this._historyInputs[n];!(t.sourceTypeName||a!=null&&a.sourceTypeName)&&t.defval===(a==null?void 0:a.defval)||t.sourceTypeName&&(a==null?void 0:a.sourceTypeName)===t.sourceTypeName?s.sourceTypeName&&(this._cacheData[n].defval=this._variables[s.sourceTypeName]):Object.assign(this._cacheData[n],t)}else{const{defval:a,display:l}=t;this._displayVerify(e,l),t={inputType:r,...t},this._cacheData[n]=t,(r||t.inputType)===sr.SOURCE?this._cacheData[n].options=up:t.options&&!t.options.includes(a)&&this._errorListener.addError(Ze(ce.inputOptErr,{defval:String(a),args:t.options.toString()}),e,zt.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_displayVerify(t,e){!e||!e.length||e.includes(Ke.dataWindow)||e.includes(Ke.statusLine)||this._errorListener.addError(Ze(ce.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),t,zt.Error)}getInputs(){const t=Object.keys(this._cacheData),e=[];for(const r of t){const n=this._cacheData[r];n.id=r,e.push(n)}return e.sort((r,n)=>(r.index||0)-(n.index||0))}}class R1{color({x:t}){return t}new({color:t,transp:e=100}){_t(e)&&(e=100);const r=(100-e)/100,{r:n,g:s,b:a}=this._parseColor(t||"");return`rgba(${Math.round(n)}, ${Math.round(s)}, ${Math.round(a)}, ${r})`}rgb({red:t=0,green:e=0,blue:r=0,transp:n=0}){return _t(n)&&(n=0),_t(t)&&(t=0),_t(e)&&(e=0),_t(r)&&(r=0),`rgba(${t}, ${e}, ${r}, ${(100-n)/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:s}){if(_t(t)||_t(e)||_t(r)||r===e)return"rgba(0,0,0,1)";const a=(t-e)/(r-e),l=Math.min(Math.max(a,0),1),{r:c,g:f,b:d,a:h}=this._parseColor(n||"rgba(0,0,0,0)"),{r:p,g,b:w,a:_}=this._parseColor(s||"rgba(0,0,0,0)"),y=c+l*(p-c),v=f+l*(g-f),x=d+l*(w-d),b=h+l*(_-h);return`rgba(${Math.round(y)}, ${Math.round(v)}, ${Math.round(x)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=parseInt(a,16)/255:s=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var kt={};const P1=Object.prototype.toString;function os(i){const t=P1.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var z1=Object.freeze({__proto__:null,isAnyArray:os}),k1=Se(z1);function q1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!os(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],l=r+1;l<s;l++)i[l]>a&&(a=i[l]);return a}function U1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!os(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],l=r+1;l<s;l++)i[l]<a&&(a=i[l]);return a}function W1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(os(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!os(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=U1(i),n=q1(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,a=s===void 0?t.autoMinMax?r:0:s,l=t.max,c=l===void 0?t.autoMinMax?n:1:l;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var f=(c-a)/(n-r),d=0;d<i.length;d++)e[d]=(i[d]-r)*f+a;return e}var j1=Object.freeze({__proto__:null,default:W1}),V1=Se(j1);Object.defineProperty(kt,"__esModule",{value:!0});var fr=k1,Hf=V1;const oo=" ".repeat(2),Jf=" ".repeat(4);function Y1(){return Xf(this)}function Xf(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
54
+ (`+he(S,m)+", "+he(M,m)+") ==> "+(this._values?he(this._values[N],m):"X")}return b},n.prototype.toString=function(){return he(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(Oe(m)&&(m=m.toNumber()),!_e(m)||!be(m))throw new TypeError("The parameter k must be an integer number")}else m=0;var y=m>0?m:0,v=m<0?-m:0,x=this._size[0],b=this._size[1],M=Math.min(x-v,b-y),E=[],F=[],N=[];N[0]=0;for(var S=y;S<b&&E.length<M;S++)for(var T=this._ptr[S],A=this._ptr[S+1],O=T;O<A;O++){var L=this._index[O];if(L===S-y+v){E.push(this._values[O]),F[E.length-1]=L-v;break}}return N.push(E.length),new n({values:E,index:F,ptr:N,size:[M,1]})},n.fromJSON=function(m){return new n(m)},n.diagonal=function(m,y,v,x,b){if(!Ae(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(Oe(X)&&(X=X.toNumber()),!_e(X)||!be(X)||X<1)throw new Error("Size values must be positive integers");return X}),v){if(Oe(v)&&(v=v.toNumber()),!_e(v)||!be(v))throw new TypeError("The parameter k must be an integer number")}else v=0;var M=e,E=0;en(b)&&(M=t.find(e,[b,b])||e,E=t.convert(0,b));var F=v>0?v:0,N=v<0?-v:0,S=m[0],T=m[1],A=Math.min(S-N,T-F),O;if(Ae(y)){if(y.length!==A)throw new Error("Invalid value array length");O=function(Q){return y[Q]}}else if(we(y)){var L=y.size();if(L.length!==1||L[0]!==A)throw new Error("Invalid matrix length");O=function(Q){return y.get([Q])}}else O=function(){return y};for(var q=[],U=[],W=[],z=0;z<T;z++){W.push(q.length);var K=z-F;if(K>=0&&K<A){var Z=O(K);M(Z,E)||(U.push(K+N),q.push(Z))}}return W.push(q.length),new n({values:q,index:U,ptr:W,size:[S,T]})},n.prototype.swapRows=function(m,y){if(!_e(m)||!be(m)||!_e(y)||!be(y))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return Ce(m,this._size[0]),Ce(y,this._size[0]),n._swapRows(m,y,this._size[1],this._values,this._index,this._ptr),this},n._forEachRow=function(m,y,v,x,b){for(var M=x[m],E=x[m+1],F=M;F<E;F++)b(v[F],y[F])},n._swapRows=function(m,y,v,x,b,M){for(var E=0;E<v;E++){var F=M[E],N=M[E+1],S=h(m,F,N,b),T=h(y,F,N,b);if(S<N&&T<N&&b[S]===m&&b[T]===y){if(x){var A=x[S];x[S]=x[T],x[T]=A}continue}if(S<N&&b[S]===m&&(T>=N||b[T]!==y)){var O=x?x[S]:void 0;b.splice(T,0,y),x&&x.splice(T,0,O),b.splice(T<=S?S+1:S,1),x&&x.splice(T<=S?S+1:S,1);continue}if(T<N&&b[T]===y&&(S>=N||b[S]!==m)){var L=x?x[T]:void 0;b.splice(S,0,m),x&&x.splice(S,0,L),b.splice(S<=T?T+1:T,1),x&&x.splice(S<=T?T+1:T,1)}}},n},{isClass:!0}),Vm="number",Ym=["typed"];function Zm(i){var t=i.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(t){var e={"0b":2,"0o":8,"0x":16}[t[1]],r=t[2],n=t[3];return{input:i,radix:e,integerPart:r,fractionalPart:n}}else return null}function Km(i){for(var t=parseInt(i.integerPart,i.radix),e=0,r=0;r<i.fractionalPart.length;r++){var n=parseInt(i.fractionalPart[r],i.radix);e+=n/Math.pow(i.radix,r+1)}var s=t+e;if(isNaN(s))throw new SyntaxError('String "'+i.input+'" is not a valid number');return s}var Gm=mt(Vm,Ym,i=>{var{typed:t}=i,e=t("number",{"":function(){return 0},number:function(n){return n},string:function(n){if(n==="NaN")return NaN;var s=Zm(n);if(s)return Km(s);var a=0,l=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);l&&(a=Number(l[2]),n=l[1]);var c=Number(n);if(isNaN(c))throw new SyntaxError('String "'+n+'" is not a valid number');if(l){if(c>2**a-1)throw new SyntaxError('String "'.concat(n,'" is out of range'));c>=2**(a-1)&&(c=c-2**a)}return c},BigNumber:function(n){return n.toNumber()},Fraction:function(n){return n.valueOf()},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),null:function(n){return 0},"Unit, string | Unit":function(n,s){return n.toNumber(s)},"Array | Matrix":t.referToSelf(r=>n=>Zr(n,r))});return e.fromJSON=function(r){return parseFloat(r.value)},e}),Hm="bignumber",Jm=["typed","BigNumber"],Xm=mt(Hm,Jm,i=>{var{typed:t,BigNumber:e}=i;return t("bignumber",{"":function(){return new e(0)},number:function(n){return new e(n+"")},string:function(n){var s=n.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(s){var a=s[2],l=e(s[1]),c=new e(2).pow(Number(a));if(l.gt(c.sub(1)))throw new SyntaxError('String "'.concat(n,'" is out of range'));var h=new e(2).pow(Number(a)-1);return l.gte(h)?l.sub(c):l}return new e(n)},BigNumber:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Fraction:function(n){return new e(n.n).div(n.d).times(n.s)},null:function(n){return new e(0)},"Array | Matrix":t.referToSelf(r=>n=>Zr(n,r))})}),Qm="fraction",tg=["typed","Fraction"],eg=mt(Qm,tg,i=>{var{typed:t,Fraction:e}=i;return t("fraction",{number:function(n){if(!isFinite(n)||isNaN(n))throw new Error(n+" cannot be represented as a fraction");return new e(n)},string:function(n){return new e(n)},"number, number":function(n,s){return new e(n,s)},null:function(n){return new e(0)},BigNumber:function(n){return new e(n.toString())},Fraction:function(n){return n},Unit:t.referToSelf(r=>n=>{var s=n.clone();return s.value=r(n.value),s}),Object:function(n){return new e(n)},"Array | Matrix":t.referToSelf(r=>n=>Zr(n,r))})}),Qc="matrix",rg=["typed","Matrix","DenseMatrix","SparseMatrix"],ng=mt(Qc,rg,i=>{var{typed:t,Matrix:e,DenseMatrix:r,SparseMatrix:n}=i;return t(Qc,{"":function(){return s([])},string:function(l){return s([],l)},"string, string":function(l,c){return s([],l,c)},Array:function(l){return s(l)},Matrix:function(l){return s(l,l.storage())},"Array | Matrix, string":s,"Array | Matrix, string, string":s});function s(a,l,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)+".")}}),tf="unaryMinus",ig=["typed"],sg=mt(tf,ig,i=>{var{typed:t}=i;return t(tf,{number:Vc,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf(e=>r=>{var n=r.clone();return n.value=t.find(e,n.valueType())(r.value),n}),"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),ef="abs",og=["typed"],ag=mt(ef,og,i=>{var{typed:t}=i;return t(ef,{number:qc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),rf="addScalar",ug=["typed"],lg=mt(rf,ug,i=>{var{typed:t}=i;return t(rf,{"number, number":Uc,"Complex, Complex":function(r,n){return r.add(n)},"BigNumber, BigNumber":function(r,n){return r.plus(n)},"Fraction, Fraction":function(r,n){return r.add(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),nf="subtractScalar",cg=["typed"],fg=mt(nf,cg,i=>{var{typed:t}=i;return t(nf,{"number, number":Wc,"Complex, Complex":function(r,n){return r.sub(n)},"BigNumber, BigNumber":function(r,n){return r.minus(n)},"Fraction, Fraction":function(r,n){return r.sub(n)},"Unit, Unit":t.referToSelf(e=>(r,n)=>{if(r.value===null||r.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(n.value===null||n.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(n))throw new Error("Units do not match");var s=r.clone();return s.value=t.find(e,[s.valueType(),n.valueType()])(s.value,n.value),s.fixPrefix=!1,s})})}),hg="matAlgo11xS0s",dg=["typed","equalScalar"],Ra=mt(hg,dg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,l){var c=n._values,h=n._index,d=n._ptr,f=n._size,p=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],w=f[1],m,y=e,v=0,x=a;typeof p=="string"&&(m=p,y=t.find(e,[m,m]),v=t.convert(0,m),s=t.convert(s,m),x=t.find(a,[m,m]));for(var b=[],M=[],E=[],F=0;F<w;F++){E[F]=M.length;for(var N=d[F],S=d[F+1],T=N;T<S;T++){var A=h[T],O=l?x(s,c[T]):x(c[T],s);y(O,v)||(M.push(A),b.push(O))}}return E[w]=M.length,n.createSparseMatrix({values:b,index:M,ptr:E,size:[g,w],datatype:m})}}),pg="matAlgo12xSfs",_g=["typed","DenseMatrix"],Ei=mt(pg,_g,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,l){var c=n._values,h=n._index,d=n._ptr,f=n._size,p=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],w=f[1],m,y=a;typeof p=="string"&&(m=p,s=t.convert(s,m),y=t.find(a,[m,m]));for(var v=[],x=[],b=[],M=0;M<w;M++){for(var E=M+1,F=d[M],N=d[M+1],S=F;S<N;S++){var T=h[S];x[T]=c[S],b[T]=E}for(var A=0;A<g;A++)M===0&&(v[A]=[]),b[A]===E?v[A][M]=l?y(s,x[A]):y(x[A],s):v[A][M]=l?y(s,0):y(0,s)}return new e({data:v,size:[g,w],datatype:m})}}),mg="matAlgo14xDs",gg=["typed"],Pa=mt(mg,gg,i=>{var{typed:t}=i;return function(n,s,a,l){var c=n._data,h=n._size,d=n._datatype,f,p=a;typeof d=="string"&&(f=d,s=t.convert(s,f),p=t.find(a,[f,f]));var g=h.length>0?e(p,0,h,h[0],c,s,l):[];return n.createDenseMatrix({data:g,size:oe(h),datatype:f})};function e(r,n,s,a,l,c,h){var d=[];if(n===s.length-1)for(var f=0;f<a;f++)d[f]=h?r(c,l[f]):r(l[f],c);else for(var p=0;p<a;p++)d[p]=e(r,n+1,s,s[n+1],l[p],c,h);return d}}),vg="matAlgo02xDS0",wg=["typed","equalScalar"],yg=mt(vg,wg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a,l){var c=n._data,h=n._size,d=n._datatype||n.getDataType(),f=s._values,p=s._index,g=s._ptr,w=s._size,m=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(h.length!==w.length)throw new Ht(h.length,w.length);if(h[0]!==w[0]||h[1]!==w[1])throw new RangeError("Dimension mismatch. Matrix A ("+h+") must match Matrix B ("+w+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var y=h[0],v=h[1],x,b=e,M=0,E=a;typeof d=="string"&&d===m&&d!=="mixed"&&(x=d,b=t.find(e,[x,x]),M=t.convert(0,x),E=t.find(a,[x,x]));for(var F=[],N=[],S=[],T=0;T<v;T++){S[T]=N.length;for(var A=g[T],O=g[T+1],L=A;L<O;L++){var q=p[L],U=l?E(f[L],c[q][T]):E(c[q][T],f[L]);b(U,M)||(N.push(q),F.push(U))}}return S[v]=N.length,s.createSparseMatrix({values:F,index:N,ptr:S,size:[y,v],datatype:d===n._datatype&&m===s._datatype?x:void 0})}}),Dg="matAlgo03xDSf",bg=["typed"],Ai=mt(Dg,bg,i=>{var{typed:t}=i;return function(r,n,s,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),d=n._values,f=n._index,p=n._ptr,g=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],y=c[1],v,x=0,b=s;typeof h=="string"&&h===w&&h!=="mixed"&&(v=h,x=t.convert(0,v),b=t.find(s,[v,v]));for(var M=[],E=0;E<m;E++)M[E]=[];for(var F=[],N=[],S=0;S<y;S++){for(var T=S+1,A=p[S],O=p[S+1],L=A;L<O;L++){var q=f[L];F[q]=a?b(d[L],l[q][S]):b(l[q][S],d[L]),N[q]=T}for(var U=0;U<m;U++)N[U]===T?M[U][S]=F[U]:M[U][S]=a?b(x,l[U][S]):b(l[U][S],x)}return r.createDenseMatrix({data:M,size:[m,y],datatype:h===r._datatype&&w===n._datatype?v:void 0})}}),xg="matAlgo05xSfSf",Eg=["typed","equalScalar"],sf=mt(xg,Eg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var l=n._values,c=n._index,h=n._ptr,d=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=s._values,g=s._index,w=s._ptr,m=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(d.length!==m.length)throw new Ht(d.length,m.length);if(d[0]!==m[0]||d[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+d+") must match Matrix B ("+m+")");var v=d[0],x=d[1],b,M=e,E=0,F=a;typeof f=="string"&&f===y&&f!=="mixed"&&(b=f,M=t.find(e,[b,b]),E=t.convert(0,b),F=t.find(a,[b,b]));var N=l&&p?[]:void 0,S=[],T=[],A=N?[]:void 0,O=N?[]:void 0,L=[],q=[],U,W,z,K;for(W=0;W<x;W++){T[W]=S.length;var Z=W+1;for(z=h[W],K=h[W+1];z<K;z++)U=c[z],S.push(U),L[U]=Z,A&&(A[U]=l[z]);for(z=w[W],K=w[W+1];z<K;z++)U=g[z],L[U]!==Z&&S.push(U),q[U]=Z,O&&(O[U]=p[z]);if(N)for(z=T[W];z<S.length;){U=S[z];var X=L[U],Q=q[U];if(X===Z||Q===Z){var ct=X===Z?A[U]:E,vt=Q===Z?O[U]:E,lt=F(ct,vt);M(lt,E)?S.splice(z,1):(N.push(lt),z++)}}}return T[x]=S.length,n.createSparseMatrix({values:N,index:S,ptr:T,size:[v,x],datatype:f===n._datatype&&y===s._datatype?b:void 0})}}),Ag="matAlgo13xDD",Cg=["typed"],Fg=mt(Ag,Cg,i=>{var{typed:t}=i;return function(n,s,a){var l=n._data,c=n._size,h=n._datatype,d=s._data,f=s._size,p=s._datatype,g=[];if(c.length!==f.length)throw new Ht(c.length,f.length);for(var w=0;w<c.length;w++){if(c[w]!==f[w])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+f+")");g[w]=c[w]}var m,y=a;typeof h=="string"&&h===p&&(m=h,y=t.find(a,[m,m]));var v=g.length>0?e(y,0,g,g[0],l,d):[];return n.createDenseMatrix({data:v,size:g,datatype:m})};function e(r,n,s,a,l,c){var h=[];if(n===s.length-1)for(var d=0;d<a;d++)h[d]=r(l[d],c[d]);else for(var f=0;f<a;f++)h[f]=e(r,n+1,s,s[n+1],l[f],c[f]);return h}}),Mg="broadcast",Ng=["concat"],Sg=mt(Mg,Ng,i=>{var{concat:t}=i;return function(n,s){var a=Math.max(n._size.length,s._size.length);if(n._size.length===s._size.length&&n._size.every((w,m)=>w===s._size[m]))return[n,s];for(var l=e(n._size,a,0),c=e(s._size,a,0),h=[],d=0;d<a;d++)h[d]=Math.max(l[d],c[d]);$s(l,h),$s(c,h);var f=n.clone(),p=s.clone();f._size.length<a?f.reshape(e(f._size,a,1)):p._size.length<a&&p.reshape(e(p._size,a,1));for(var g=0;g<a;g++)f._size[g]<h[g]&&(f=r(f,h[g],g)),p._size[g]<h[g]&&(p=r(p,h[g],g));return[f,p]};function e(n,s,a){return[...Array(s-n.length).fill(a),...n]}function r(n,s,a){return t(...Array(s).fill(n),a)}}),Og="matrixAlgorithmSuite",Bg=["typed","matrix","concat"],Xn=mt(Og,Bg,i=>{var{typed:t,matrix:e,concat:r}=i,n=Fg({typed:t}),s=Pa({typed:t}),a=Sg({concat:r});return function(c){var h=c.elop,d=c.SD||c.DS,f;h?(f={"DenseMatrix, DenseMatrix":(m,y)=>n(...a(m,y),h),"Array, Array":(m,y)=>n(...a(e(m),e(y)),h).valueOf(),"Array, DenseMatrix":(m,y)=>n(...a(e(m),y),h),"DenseMatrix, Array":(m,y)=>n(...a(m,e(y)),h)},c.SS&&(f["SparseMatrix, SparseMatrix"]=(m,y)=>c.SS(...a(m,y),h,!1)),c.DS&&(f["DenseMatrix, SparseMatrix"]=(m,y)=>c.DS(...a(m,y),h,!1),f["Array, SparseMatrix"]=(m,y)=>c.DS(...a(e(m),y),h,!1)),d&&(f["SparseMatrix, DenseMatrix"]=(m,y)=>d(...a(y,m),h,!0),f["SparseMatrix, Array"]=(m,y)=>d(...a(e(y),m),h,!0))):(f={"DenseMatrix, DenseMatrix":t.referToSelf(m=>(y,v)=>n(...a(y,v),m)),"Array, Array":t.referToSelf(m=>(y,v)=>n(...a(e(y),e(v)),m).valueOf()),"Array, DenseMatrix":t.referToSelf(m=>(y,v)=>n(...a(e(y),v),m)),"DenseMatrix, Array":t.referToSelf(m=>(y,v)=>n(...a(y,e(v)),m))},c.SS&&(f["SparseMatrix, SparseMatrix"]=t.referToSelf(m=>(y,v)=>c.SS(...a(y,v),m,!1))),c.DS&&(f["DenseMatrix, SparseMatrix"]=t.referToSelf(m=>(y,v)=>c.DS(...a(y,v),m,!1)),f["Array, SparseMatrix"]=t.referToSelf(m=>(y,v)=>c.DS(...a(e(y),v),m,!1))),d&&(f["SparseMatrix, DenseMatrix"]=t.referToSelf(m=>(y,v)=>d(...a(v,y),m,!0)),f["SparseMatrix, Array"]=t.referToSelf(m=>(y,v)=>d(...a(e(v),y),m,!0))));var p=c.scalar||"any",g=c.Ds||c.Ss;g&&(h?(f["DenseMatrix,"+p]=(m,y)=>s(m,y,h,!1),f[p+", DenseMatrix"]=(m,y)=>s(y,m,h,!0),f["Array,"+p]=(m,y)=>s(e(m),y,h,!1).valueOf(),f[p+", Array"]=(m,y)=>s(e(y),m,h,!0).valueOf()):(f["DenseMatrix,"+p]=t.referToSelf(m=>(y,v)=>s(y,v,m,!1)),f[p+", DenseMatrix"]=t.referToSelf(m=>(y,v)=>s(v,y,m,!0)),f["Array,"+p]=t.referToSelf(m=>(y,v)=>s(e(y),v,m,!1).valueOf()),f[p+", Array"]=t.referToSelf(m=>(y,v)=>s(e(v),y,m,!0).valueOf())));var w=c.sS!==void 0?c.sS:c.Ss;return h?(c.Ss&&(f["SparseMatrix,"+p]=(m,y)=>c.Ss(m,y,h,!1)),w&&(f[p+", SparseMatrix"]=(m,y)=>w(y,m,h,!0))):(c.Ss&&(f["SparseMatrix,"+p]=t.referToSelf(m=>(y,v)=>c.Ss(y,v,m,!1))),w&&(f[p+", SparseMatrix"]=t.referToSelf(m=>(y,v)=>w(v,y,m,!0)))),h&&h.signatures&&Jl(f,h.signatures),f}}),Ig="matAlgo01xDSid",Tg=["typed"],of=mt(Ig,Tg,i=>{var{typed:t}=i;return function(r,n,s,a){var l=r._data,c=r._size,h=r._datatype||r.getDataType(),d=n._values,f=n._index,p=n._ptr,g=n._size,w=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(c.length!==g.length)throw new Ht(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!d)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var m=c[0],y=c[1],v=typeof h=="string"&&h!=="mixed"&&h===w?h:void 0,x=v?t.find(s,[v,v]):s,b,M,E=[];for(b=0;b<m;b++)E[b]=[];var F=[],N=[];for(M=0;M<y;M++){for(var S=M+1,T=p[M],A=p[M+1],O=T;O<A;O++)b=f[O],F[b]=a?x(d[O],l[b][M]):x(l[b][M],d[O]),N[b]=S;for(b=0;b<m;b++)N[b]===S?E[b][M]=F[b]:E[b][M]=l[b][M]}return r.createDenseMatrix({data:E,size:[m,y],datatype:h===r._datatype&&w===n._datatype?v:void 0})}}),$g="matAlgo04xSidSid",Lg=["typed","equalScalar"],Rg=mt($g,Lg,i=>{var{typed:t,equalScalar:e}=i;return function(n,s,a){var l=n._values,c=n._index,h=n._ptr,d=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=s._values,g=s._index,w=s._ptr,m=s._size,y=s._datatype||s._data===void 0?s._datatype:s.getDataType();if(d.length!==m.length)throw new Ht(d.length,m.length);if(d[0]!==m[0]||d[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+d+") must match Matrix B ("+m+")");var v=d[0],x=d[1],b,M=e,E=0,F=a;typeof f=="string"&&f===y&&f!=="mixed"&&(b=f,M=t.find(e,[b,b]),E=t.convert(0,b),F=t.find(a,[b,b]));var N=l&&p?[]:void 0,S=[],T=[],A=l&&p?[]:void 0,O=l&&p?[]:void 0,L=[],q=[],U,W,z,K,Z;for(W=0;W<x;W++){T[W]=S.length;var X=W+1;for(K=h[W],Z=h[W+1],z=K;z<Z;z++)U=c[z],S.push(U),L[U]=X,A&&(A[U]=l[z]);for(K=w[W],Z=w[W+1],z=K;z<Z;z++)if(U=g[z],L[U]===X){if(A){var Q=F(A[U],p[z]);M(Q,E)?L[U]=null:A[U]=Q}}else S.push(U),q[U]=X,O&&(O[U]=p[z]);if(A&&O)for(z=T[W];z<S.length;)U=S[z],L[U]===X?(N[z]=A[U],z++):q[U]===X?(N[z]=O[U],z++):S.splice(z,1)}return T[x]=S.length,n.createSparseMatrix({values:N,index:S,ptr:T,size:[v,x],datatype:f===n._datatype&&y===s._datatype?b:void 0})}}),Pg="matAlgo10xSids",zg=["typed","DenseMatrix"],af=mt(Pg,zg,i=>{var{typed:t,DenseMatrix:e}=i;return function(n,s,a,l){var c=n._values,h=n._index,d=n._ptr,f=n._size,p=n._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var g=f[0],w=f[1],m,y=a;typeof p=="string"&&(m=p,s=t.convert(s,m),y=t.find(a,[m,m]));for(var v=[],x=[],b=[],M=0;M<w;M++){for(var E=M+1,F=d[M],N=d[M+1],S=F;S<N;S++){var T=h[S];x[T]=c[S],b[T]=E}for(var A=0;A<g;A++)M===0&&(v[A]=[]),b[A]===E?v[A][M]=l?y(s,x[A]):y(x[A],s):v[A][M]=s}return new e({data:v,size:[g,w],datatype:m})}}),kg="multiplyScalar",qg=["typed"],Ug=mt(kg,qg,i=>{var{typed:t}=i;return t("multiplyScalar",{"number, number":jc,"Complex, Complex":function(r,n){return r.mul(n)},"BigNumber, BigNumber":function(r,n){return r.times(n)},"Fraction, Fraction":function(r,n){return r.mul(n)},"number | Fraction | BigNumber | Complex, Unit":(e,r)=>r.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,r)=>e.multiply(r)})}),uf="multiply",Wg=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],jg=mt(uf,Wg,i=>{var{typed:t,matrix:e,addScalar:r,multiplyScalar:n,equalScalar:s,dot:a}=i,l=Ra({typed:t,equalScalar:s}),c=Pa({typed:t});function h(E,F){switch(E.length){case 1:switch(F.length){case 1:if(E[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(E[0]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+E[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(E[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+E[1]+") must match Vector length ("+F[0]+")");break;case 2:if(E[1]!==F[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+E[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 "+E.length+" dimensions)")}}function d(E,F,N){if(N===0)throw new Error("Cannot multiply two empty vectors");return a(E,F)}function f(E,F){if(F.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return p(E,F)}function p(E,F){var N=E._data,S=E._size,T=E._datatype||E.getDataType(),A=F._data,O=F._size,L=F._datatype||F.getDataType(),q=S[0],U=O[1],W,z=r,K=n;T&&L&&T===L&&typeof T=="string"&&T!=="mixed"&&(W=T,z=t.find(r,[W,W]),K=t.find(n,[W,W]));for(var Z=[],X=0;X<U;X++){for(var Q=K(N[0],A[0][X]),ct=1;ct<q;ct++)Q=z(Q,K(N[ct],A[ct][X]));Z[X]=Q}return E.createDenseMatrix({data:Z,size:[U],datatype:T===E._datatype&&L===F._datatype?W:void 0})}var g=t("_multiplyMatrixVector",{"DenseMatrix, any":m,"SparseMatrix, any":x}),w=t("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":y,"DenseMatrix, SparseMatrix":v,"SparseMatrix, DenseMatrix":b,"SparseMatrix, SparseMatrix":M});function m(E,F){var N=E._data,S=E._size,T=E._datatype||E.getDataType(),A=F._data,O=F._datatype||F.getDataType(),L=S[0],q=S[1],U,W=r,z=n;T&&O&&T===O&&typeof T=="string"&&T!=="mixed"&&(U=T,W=t.find(r,[U,U]),z=t.find(n,[U,U]));for(var K=[],Z=0;Z<L;Z++){for(var X=N[Z],Q=z(X[0],A[0]),ct=1;ct<q;ct++)Q=W(Q,z(X[ct],A[ct]));K[Z]=Q}return E.createDenseMatrix({data:K,size:[L],datatype:T===E._datatype&&O===F._datatype?U:void 0})}function y(E,F){var N=E._data,S=E._size,T=E._datatype||E.getDataType(),A=F._data,O=F._size,L=F._datatype||F.getDataType(),q=S[0],U=S[1],W=O[1],z,K=r,Z=n;T&&L&&T===L&&typeof T=="string"&&T!=="mixed"&&T!=="mixed"&&(z=T,K=t.find(r,[z,z]),Z=t.find(n,[z,z]));for(var X=[],Q=0;Q<q;Q++){var ct=N[Q];X[Q]=[];for(var vt=0;vt<W;vt++){for(var lt=Z(ct[0],A[0][vt]),yt=1;yt<U;yt++)lt=K(lt,Z(ct[yt],A[yt][vt]));X[Q][vt]=lt}}return E.createDenseMatrix({data:X,size:[q,W],datatype:T===E._datatype&&L===F._datatype?z:void 0})}function v(E,F){var N=E._data,S=E._size,T=E._datatype||E.getDataType(),A=F._values,O=F._index,L=F._ptr,q=F._size,U=F._datatype||F._data===void 0?F._datatype:F.getDataType();if(!A)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=S[0],z=q[1],K,Z=r,X=n,Q=s,ct=0;T&&U&&T===U&&typeof T=="string"&&T!=="mixed"&&(K=T,Z=t.find(r,[K,K]),X=t.find(n,[K,K]),Q=t.find(s,[K,K]),ct=t.convert(0,K));for(var vt=[],lt=[],yt=[],bt=F.createSparseMatrix({values:vt,index:lt,ptr:yt,size:[W,z],datatype:T===E._datatype&&U===F._datatype?K:void 0}),Ot=0;Ot<z;Ot++){yt[Ot]=lt.length;var xt=L[Ot],ue=L[Ot+1];if(ue>xt)for(var It=0,Nt=0;Nt<W;Nt++){for(var fe=Nt+1,re=void 0,qt=xt;qt<ue;qt++){var Jt=O[qt];It!==fe?(re=X(N[Nt][Jt],A[qt]),It=fe):re=Z(re,X(N[Nt][Jt],A[qt]))}It===fe&&!Q(re,ct)&&(lt.push(Nt),vt.push(re))}}return yt[z]=lt.length,bt}function x(E,F){var N=E._values,S=E._index,T=E._ptr,A=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!N)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=F._data,L=F._datatype||F.getDataType(),q=E._size[0],U=F._size[0],W=[],z=[],K=[],Z,X=r,Q=n,ct=s,vt=0;A&&L&&A===L&&typeof A=="string"&&A!=="mixed"&&(Z=A,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]),ct=t.find(s,[Z,Z]),vt=t.convert(0,Z));var lt=[],yt=[];K[0]=0;for(var bt=0;bt<U;bt++){var Ot=O[bt];if(!ct(Ot,vt))for(var xt=T[bt],ue=T[bt+1],It=xt;It<ue;It++){var Nt=S[It];yt[Nt]?lt[Nt]=X(lt[Nt],Q(Ot,N[It])):(yt[Nt]=!0,z.push(Nt),lt[Nt]=Q(Ot,N[It]))}}for(var fe=z.length,re=0;re<fe;re++){var qt=z[re];W[re]=lt[qt]}return K[1]=z.length,E.createSparseMatrix({values:W,index:z,ptr:K,size:[q,1],datatype:A===E._datatype&&L===F._datatype?Z:void 0})}function b(E,F){var N=E._values,S=E._index,T=E._ptr,A=E._datatype||E._data===void 0?E._datatype:E.getDataType();if(!N)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var O=F._data,L=F._datatype||F.getDataType(),q=E._size[0],U=F._size[0],W=F._size[1],z,K=r,Z=n,X=s,Q=0;A&&L&&A===L&&typeof A=="string"&&A!=="mixed"&&(z=A,K=t.find(r,[z,z]),Z=t.find(n,[z,z]),X=t.find(s,[z,z]),Q=t.convert(0,z));for(var ct=[],vt=[],lt=[],yt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[q,W],datatype:A===E._datatype&&L===F._datatype?z:void 0}),bt=[],Ot=[],xt=0;xt<W;xt++){lt[xt]=vt.length;for(var ue=xt+1,It=0;It<U;It++){var Nt=O[It][xt];if(!X(Nt,Q))for(var fe=T[It],re=T[It+1],qt=fe;qt<re;qt++){var Jt=S[qt];Ot[Jt]!==ue?(Ot[Jt]=ue,vt.push(Jt),bt[Jt]=Z(Nt,N[qt])):bt[Jt]=K(bt[Jt],Z(Nt,N[qt]))}}for(var Le=lt[xt],wr=vt.length,ke=Le;ke<wr;ke++){var _n=vt[ke];ct[ke]=bt[_n]}}return lt[W]=vt.length,yt}function M(E,F){var N=E._values,S=E._index,T=E._ptr,A=E._datatype||E._data===void 0?E._datatype:E.getDataType(),O=F._values,L=F._index,q=F._ptr,U=F._datatype||F._data===void 0?F._datatype:F.getDataType(),W=E._size[0],z=F._size[1],K=N&&O,Z,X=r,Q=n;A&&U&&A===U&&typeof A=="string"&&A!=="mixed"&&(Z=A,X=t.find(r,[Z,Z]),Q=t.find(n,[Z,Z]));for(var ct=K?[]:void 0,vt=[],lt=[],yt=E.createSparseMatrix({values:ct,index:vt,ptr:lt,size:[W,z],datatype:A===E._datatype&&U===F._datatype?Z:void 0}),bt=K?[]:void 0,Ot=[],xt,ue,It,Nt,fe,re,qt,Jt,Le=0;Le<z;Le++){lt[Le]=vt.length;var wr=Le+1;for(fe=q[Le],re=q[Le+1],Nt=fe;Nt<re;Nt++)if(Jt=L[Nt],K)for(ue=T[Jt],It=T[Jt+1],xt=ue;xt<It;xt++)qt=S[xt],Ot[qt]!==wr?(Ot[qt]=wr,vt.push(qt),bt[qt]=Q(O[Nt],N[xt])):bt[qt]=X(bt[qt],Q(O[Nt],N[xt]));else for(ue=T[Jt],It=T[Jt+1],xt=ue;xt<It;xt++)qt=S[xt],Ot[qt]!==wr&&(Ot[qt]=wr,vt.push(qt));if(K)for(var ke=lt[Le],_n=vt.length,Tn=ke;Tn<_n;Tn++){var mn=vt[Tn];ct[Tn]=bt[mn]}}return lt[z]=vt.length,yt}return t(uf,n,{"Array, Array":t.referTo("Matrix, Matrix",E=>(F,N)=>{h(Te(F),Te(N));var S=E(e(F),e(N));return we(S)?S.valueOf():S}),"Matrix, Matrix":function(F,N){var S=F.size(),T=N.size();return h(S,T),S.length===1?T.length===1?d(F,N,S[0]):f(F,N):T.length===1?g(F,N):w(F,N)},"Matrix, Array":t.referTo("Matrix,Matrix",E=>(F,N)=>E(F,e(N))),"Array, Matrix":t.referToSelf(E=>(F,N)=>E(e(F,N.storage()),N)),"SparseMatrix, any":function(F,N){return l(F,N,n,!1)},"DenseMatrix, any":function(F,N){return c(F,N,n,!1)},"any, SparseMatrix":function(F,N){return l(N,F,n,!0)},"any, DenseMatrix":function(F,N){return c(N,F,n,!0)},"Array, any":function(F,N){return c(e(F),N,n,!1).valueOf()},"any, Array":function(F,N){return c(e(N),F,n,!0).valueOf()},"any, any":n,"any, any, ...any":t.referToSelf(E=>(F,N,S)=>{for(var T=E(F,N),A=0;A<S.length;A++)T=E(T,S[A]);return T})})}),lf="subtract",Vg=["typed","matrix","equalScalar","subtractScalar","unaryMinus","DenseMatrix","concat"],Yg=mt(lf,Vg,i=>{var{typed:t,matrix:e,equalScalar:r,subtractScalar:n,unaryMinus:s,DenseMatrix:a,concat:l}=i,c=of({typed:t}),h=Ai({typed:t}),d=sf({typed:t,equalScalar:r}),f=af({typed:t,DenseMatrix:a}),p=Ei({typed:t,DenseMatrix:a}),g=Xn({typed:t,matrix:e,concat:l});return t(lf,{"any, any":n},g({elop:n,SS:d,DS:c,SD:h,Ss:p,sS:f}))}),Zg="matAlgo07xSSf",Kg=["typed","DenseMatrix"],Hs=mt(Zg,Kg,i=>{var{typed:t,DenseMatrix:e}=i;return function(s,a,l){var c=s._size,h=s._datatype||s._data===void 0?s._datatype:s.getDataType(),d=a._size,f=a._datatype||a._data===void 0?a._datatype:a.getDataType();if(c.length!==d.length)throw new Ht(c.length,d.length);if(c[0]!==d[0]||c[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+d+")");var p=c[0],g=c[1],w,m=0,y=l;typeof h=="string"&&h===f&&h!=="mixed"&&(w=h,m=t.convert(0,w),y=t.find(l,[w,w]));var v,x,b=[];for(v=0;v<p;v++)b[v]=[];var M=[],E=[],F=[],N=[];for(x=0;x<g;x++){var S=x+1;for(r(s,x,F,M,S),r(a,x,N,E,S),v=0;v<p;v++){var T=F[v]===S?M[v]:m,A=N[v]===S?E[v]:m;b[v][x]=y(T,A)}}return new e({data:b,size:[p,g],datatype:h===s._datatype&&f===a._datatype?w:void 0})};function r(n,s,a,l,c){for(var h=n._values,d=n._index,f=n._ptr,p=f[s],g=f[s+1];p<g;p++){var w=d[p];a[w]=c,l[w]=h[p]}}}),cf="conj",Gg=["typed"],Hg=mt(cf,Gg,i=>{var{typed:t}=i;return t(cf,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf(e=>r=>Zr(r,e))})}),ff="concat",Jg=["typed","matrix","isInteger"],Xg=mt(ff,Jg,i=>{var{typed:t,matrix:e,isInteger:r}=i;return t(ff,{"...Array | Matrix | number | BigNumber":function(s){var a,l=s.length,c=-1,h,d=!1,f=[];for(a=0;a<l;a++){var p=s[a];if(we(p)&&(d=!0),_e(p)||Oe(p)){if(a!==l-1)throw new Error("Dimension must be specified as last argument");if(h=c,c=p.valueOf(),!r(c))throw new TypeError("Integer number expected for dimension");if(c<0||a>0&&c>h)throw new Fn(c,h+1)}else{var g=oe(p).valueOf(),w=Te(g);if(f[a]=g,h=c,c=w.length-1,a>0&&c!==h)throw new Ht(h+1,c+1)}}if(f.length===0)throw new SyntaxError("At least one matrix expected");for(var m=f.shift();f.length;)m=gc(m,f.shift(),c);return d?e(m):m},"...string":function(s){return s.join("")}})}),hf="count",Qg=["typed","size","prod"],tv=mt(hf,Qg,i=>{var{typed:t,size:e,prod:r}=i;return t(hf,{string:function(s){return s.length},"Matrix | Array":function(s){return r(e(s))}})}),df="identity",ev=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],rv=mt(df,ev,i=>{var{typed:t,config:e,matrix:r,BigNumber:n,DenseMatrix:s,SparseMatrix:a}=i;return t(df,{"":function(){return e.matrix==="Matrix"?r([]):[]},string:function(d){return r(d)},"number | BigNumber":function(d){return c(d,d,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(d,f){return c(d,d,f)},"number | BigNumber, number | BigNumber":function(d,f){return c(d,f,e.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(d,f,p){return c(d,f,p)},Array:function(d){return l(d)},"Array, string":function(d,f){return l(d,f)},Matrix:function(d){return l(d.valueOf(),d.storage())},"Matrix, string":function(d,f){return l(d.valueOf(),f)}});function l(h,d){switch(h.length){case 0:return d?r(d):[];case 1:return c(h[0],h[0],d);case 2:return c(h[0],h[1],d);default:throw new Error("Vector containing two values expected")}}function c(h,d,f){var p=Oe(h)||Oe(d)?n:null;if(Oe(h)&&(h=h.toNumber()),Oe(d)&&(d=d.toNumber()),!be(h)||h<1)throw new Error("Parameters in function identity must be positive integers");if(!be(d)||d<1)throw new Error("Parameters in function identity must be positive integers");var g=p?new n(1):1,w=p?new p(0):0,m=[h,d];if(f){if(f==="sparse")return a.diagonal(m,g,0,w);if(f==="dense")return s.diagonal(m,g,0,w);throw new TypeError('Unknown matrix type "'.concat(f,'"'))}for(var y=xa([],m,w),v=h<d?h:d,x=0;x<v;x++)y[x][x]=g;return y}}),pf="kron",nv=["typed","matrix","multiplyScalar"],iv=mt(pf,nv,i=>{var{typed:t,matrix:e,multiplyScalar:r}=i;return t(pf,{"Matrix, Matrix":function(a,l){return e(n(a.toArray(),l.toArray()))},"Matrix, Array":function(a,l){return e(n(a.toArray(),l))},"Array, Matrix":function(a,l){return e(n(a,l.toArray()))},"Array, Array":n});function n(s,a){if(Te(s).length===1&&(s=[s]),Te(a).length===1&&(a=[a]),Te(s).length>2||Te(a).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(s.length)+", y = "+JSON.stringify(a.length)+")");var l=[],c=[];return s.map(function(h){return a.map(function(d){return c=[],l.push(c),h.map(function(f){return d.map(function(p){return c.push(r(f,p))})})})})&&l}});function sv(){throw new Error('No "bignumber" implementation available')}function ov(){throw new Error('No "fraction" implementation available')}function av(){throw new Error('No "matrix" implementation available')}var _f="reshape",uv=["typed","isInteger","matrix"],lv=mt(_f,uv,i=>{var{typed:t,isInteger:e}=i;return t(_f,{"Matrix, Array":function(n,s){return n.reshape(s,!0)},"Array, Array":function(n,s){return s.forEach(function(a){if(!e(a))throw new TypeError("Invalid size for dimension: "+a)}),Aa(n,s)}})}),mf="size",cv=["typed","config","?matrix"],fv=mt(mf,cv,i=>{var{typed:t,config:e,matrix:r}=i;return t(mf,{Matrix:function(s){return s.create(s.size())},Array:Te,string:function(s){return e.matrix==="Array"?[s.length]:r([s.length])},"number | Complex | BigNumber | Unit | boolean | null":function(s){return e.matrix==="Array"?[]:r?r([]):av()}})}),gf="transpose",hv=["typed","matrix"],dv=mt(gf,hv,i=>{var{typed:t,matrix:e}=i;return t(gf,{Array:a=>r(e(a)).valueOf(),Matrix:r,any:oe});function r(a){var l=a.size(),c;switch(l.length){case 1:c=a.clone();break;case 2:{var h=l[0],d=l[1];if(d===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+he(l)+")");switch(a.storage()){case"dense":c=n(a,h,d);break;case"sparse":c=s(a,h,d);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+he(l)+")")}return c}function n(a,l,c){for(var h=a._data,d=[],f,p=0;p<c;p++){f=d[p]=[];for(var g=0;g<l;g++)f[g]=oe(h[g][p])}return a.createDenseMatrix({data:d,size:[c,l],datatype:a._datatype})}function s(a,l,c){for(var h=a._values,d=a._index,f=a._ptr,p=h?[]:void 0,g=[],w=[],m=[],y=0;y<l;y++)m[y]=0;var v,x,b;for(v=0,x=d.length;v<x;v++)m[d[v]]++;for(var M=0,E=0;E<l;E++)w.push(M),M+=m[E],m[E]=w[E];for(w.push(M),b=0;b<c;b++)for(var F=f[b],N=f[b+1],S=F;S<N;S++){var T=m[d[S]]++;g[T]=b,h&&(p[T]=oe(h[S]))}return a.createSparseMatrix({values:p,index:g,ptr:w,size:[c,l],datatype:a._datatype})}}),vf="ctranspose",pv=["typed","transpose","conj"],_v=mt(vf,pv,i=>{var{typed:t,transpose:e,conj:r}=i;return t(vf,{any:function(s){return r(e(s))}})}),wf="mode",mv=["typed","isNaN","isNumeric"],gv=mt(wf,mv,i=>{var{typed:t,isNaN:e,isNumeric:r}=i;return t(wf,{"Array | Matrix":n,"...":function(a){return n(a)}});function n(s){s=Fa(s.valueOf());var a=s.length;if(a===0)throw new Error("Cannot calculate mode of an empty array");for(var l={},c=[],h=0,d=0;d<s.length;d++){var f=s[d];if(r(f)&&e(f))throw new Error("Cannot calculate mode of an array containing NaN values");f in l||(l[f]=0),l[f]++,l[f]===h?c.push(f):l[f]>h&&(h=l[f],c=[f])}return c}});function Bn(i,t,e){var r;return String(i).indexOf("Unexpected type")!==-1?(r=arguments.length>2?" (type: "+Cn(e)+", value: "+JSON.stringify(e)+")":" (type: "+i.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):String(i).indexOf("complex numbers")!==-1?(r=arguments.length>2?" (type: "+Cn(e)+", value: "+JSON.stringify(e)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):i}var yf="prod",vv=["typed","config","multiplyScalar","numeric"],wv=mt(yf,vv,i=>{var{typed:t,config:e,multiplyScalar:r,numeric:n}=i;return t(yf,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(l,c){throw new Error("prod(A, dim) is not yet supported")},"...":function(l){return s(l)}});function s(a){var l;if(rs(a,function(c){try{l=l===void 0?c:r(l,c)}catch(h){throw Bn(h,"prod",c)}}),typeof l=="string"&&(l=n(l,e.number)),l===void 0)throw new Error("Cannot calculate prod of an empty array");return l}}),yv="numeric",Dv=["number","?bignumber","?fraction"],bv=mt(yv,Dv,i=>{var{number:t,bignumber:e,fraction:r}=i,n={string:!0,number:!0,BigNumber:!0,Fraction:!0},s={number:a=>t(a),BigNumber:e?a=>e(a):sv,Fraction:r?a=>r(a):ov};return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",h=arguments.length>2?arguments[2]:void 0;if(h!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var d=Cn(l);if(!(d in n))throw new TypeError("Cannot convert "+l+' of type "'+d+'"; valid input types are '+Object.keys(n).join(", "));if(!(c in s))throw new TypeError("Cannot convert "+l+' to type "'+c+'"; valid output types are '+Object.keys(s).join(", "));return c===d?l:s[c](l)}}),Df="divideScalar",xv=["typed","numeric"],Ev=mt(Df,xv,i=>{var{typed:t,numeric:e}=i;return t(Df,{"number, number":function(n,s){return n/s},"Complex, Complex":function(n,s){return n.div(s)},"BigNumber, BigNumber":function(n,s){return n.div(s)},"Fraction, Fraction":function(n,s){return n.div(s)},"Unit, number | Complex | Fraction | BigNumber | Unit":(r,n)=>r.divide(n),"number | Fraction | Complex | BigNumber, Unit":(r,n)=>n.divideInto(r)})}),bf="pow",Av=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Cv=mt(bf,Av,i=>{var{typed:t,config:e,identity:r,multiply:n,matrix:s,inv:a,number:l,fraction:c,Complex:h}=i;return t(bf,{"number, number":d,"Complex, Complex":function(w,m){return w.pow(m)},"BigNumber, BigNumber":function(w,m){return m.isInteger()||w>=0||e.predictable?w.pow(m):new h(w.toNumber(),0).pow(m.toNumber(),0)},"Fraction, Fraction":function(w,m){var y=w.pow(m);if(y!=null)return y;if(e.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return d(w.valueOf(),m.valueOf())},"Array, number":f,"Array, BigNumber":function(w,m){return f(w,m.toNumber())},"Matrix, number":p,"Matrix, BigNumber":function(w,m){return p(w,m.toNumber())},"Unit, number | BigNumber":function(w,m){return w.pow(m)}});function d(g,w){if(e.predictable&&!be(w)&&g<0)try{var m=c(w),y=l(m);if((w===y||Math.abs((w-y)/w)<1e-14)&&m.d%2===1)return(m.n%2===0?1:-1)*Math.pow(-g,w)}catch{}return e.predictable&&(g<-1&&w===1/0||g>-1&&g<0&&w===-1/0)?NaN:be(w)||g>=0||e.predictable?Yc(g,w):g*g<1&&w===1/0||g*g>1&&w===-1/0?0:new h(g,0).pow(w,0)}function f(g,w){if(!be(w))throw new TypeError("For A^b, b must be an integer (value is "+w+")");var m=Te(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(w<0)try{return f(a(g),-w)}catch(x){throw x.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+w+")"):x}for(var y=r(m[0]).valueOf(),v=g;w>=1;)(w&1)===1&&(y=n(v,y)),w>>=1,v=n(v,v);return y}function p(g,w){return s(f(g.valueOf(),w))}}),xf="dotDivide",Fv=["typed","matrix","equalScalar","divideScalar","DenseMatrix","concat"],Mv=mt(xf,Fv,i=>{var{typed:t,matrix:e,equalScalar:r,divideScalar:n,DenseMatrix:s,concat:a}=i,l=yg({typed:t,equalScalar:r}),c=Ai({typed:t}),h=Hs({typed:t,DenseMatrix:s}),d=Ra({typed:t,equalScalar:r}),f=Ei({typed:t,DenseMatrix:s}),p=Xn({typed:t,matrix:e,concat:a});return t(xf,p({elop:n,SS:h,DS:c,SD:l,Ss:d,sS:f}))}),Js="compare",Nv=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix","concat"],Sv=mt(Js,Nv,i=>{var{typed:t,config:e,equalScalar:r,matrix:n,BigNumber:s,Fraction:a,DenseMatrix:l,concat:c}=i,h=Ai({typed:t}),d=sf({typed:t,equalScalar:r}),f=Ei({typed:t,DenseMatrix:l}),p=Xn({typed:t,matrix:n,concat:c}),g=Ks({typed:t});return t(Js,Ov({typed:t,config:e}),{"boolean, boolean":function(m,y){return m===y?0:m>y?1:-1},"BigNumber, BigNumber":function(m,y){return Zs(m,y,e.epsilon)?new s(0):new s(m.cmp(y))},"Fraction, Fraction":function(m,y){return new a(m.compare(y))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},g,p({SS:d,DS:h,Ss:f}))}),Ov=mt(Js,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Js,{"number, number":function(n,s){return Jn(n,s,e.epsilon)?0:n>s?1:-1}})}),Xs="equal",Bv=["typed","matrix","equalScalar","DenseMatrix","concat"],Iv=mt(Xs,Bv,i=>{var{typed:t,matrix:e,equalScalar:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),l=Hs({typed:t,DenseMatrix:n}),c=Ei({typed:t,DenseMatrix:n}),h=Xn({typed:t,matrix:e,concat:s});return t(Xs,Tv({typed:t,equalScalar:r}),h({elop:r,SS:l,DS:a,Ss:c}))}),Tv=mt(Xs,["typed","equalScalar"],i=>{var{typed:t,equalScalar:e}=i;return t(Xs,{"any, any":function(n,s){return n===null?s===null:s===null?n===null:n===void 0?s===void 0:s===void 0?n===void 0:e(n,s)}})}),Qs="smaller",$v=["typed","config","matrix","DenseMatrix","concat"],Lv=mt(Qs,$v,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),l=Hs({typed:t,DenseMatrix:n}),c=Ei({typed:t,DenseMatrix:n}),h=Xn({typed:t,matrix:r,concat:s}),d=Ks({typed:t});return t(Qs,Rv({typed:t,config:e}),{"boolean, boolean":(f,p)=>f<p,"BigNumber, BigNumber":function(p,g){return p.lt(g)&&!Zs(p,g,e.epsilon)},"Fraction, Fraction":(f,p)=>f.compare(p)===-1,"Complex, Complex":function(p,g){throw new TypeError("No ordering relation is defined for complex numbers")}},d,h({SS:l,DS:a,Ss:c}))}),Rv=mt(Qs,["typed","config"],i=>{var{typed:t,config:e}=i;return t(Qs,{"number, number":function(n,s){return n<s&&!Jn(n,s,e.epsilon)}})}),to="larger",Pv=["typed","config","matrix","DenseMatrix","concat"],zv=mt(to,Pv,i=>{var{typed:t,config:e,matrix:r,DenseMatrix:n,concat:s}=i,a=Ai({typed:t}),l=Hs({typed:t,DenseMatrix:n}),c=Ei({typed:t,DenseMatrix:n}),h=Xn({typed:t,matrix:r,concat:s}),d=Ks({typed:t});return t(to,kv({typed:t,config:e}),{"boolean, boolean":(f,p)=>f>p,"BigNumber, BigNumber":function(p,g){return p.gt(g)&&!Zs(p,g,e.epsilon)},"Fraction, Fraction":(f,p)=>f.compare(p)===1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},d,h({SS:l,DS:a,Ss:c}))}),kv=mt(to,["typed","config"],i=>{var{typed:t,config:e}=i;return t(to,{"number, number":function(n,s){return n>s&&!Jn(n,s,e.epsilon)}})}),Ef="deepEqual",qv=["typed","equal"],Uv=mt(Ef,qv,i=>{var{typed:t,equal:e}=i;return t(Ef,{"any, any":function(s,a){return r(s.valueOf(),a.valueOf())}});function r(n,s){if(Array.isArray(n))if(Array.isArray(s)){var a=n.length;if(a!==s.length)return!1;for(var l=0;l<a;l++)if(!r(n[l],s[l]))return!1;return!0}else return!1;else return Array.isArray(s)?!1:e(n,s)}}),Af="partitionSelect",Wv=["typed","isNumeric","isNaN","compare"],jv=mt(Af,Wv,i=>{var{typed:t,isNumeric:e,isNaN:r,compare:n}=i,s=n,a=(h,d)=>-n(h,d);return t(Af,{"Array | Matrix, number":function(d,f){return l(d,f,s)},"Array | Matrix, number, string":function(d,f,p){if(p==="asc")return l(d,f,s);if(p==="desc")return l(d,f,a);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":l});function l(h,d,f){if(!be(d)||d<0)throw new Error("k must be a non-negative integer");if(we(h)){var p=h.size();if(p.length>1)throw new Error("Only one dimensional matrices supported");return c(h.valueOf(),d,f)}if(Array.isArray(h))return c(h,d,f)}function c(h,d,f){if(d>=h.length)throw new Error("k out of bounds");for(var p=0;p<h.length;p++)if(e(h[p])&&r(h[p]))return h[p];for(var g=0,w=h.length-1;g<w;){for(var m=g,y=w,v=h[Math.floor(Math.random()*(w-g+1))+g];m<y;)if(f(h[m],v)>=0){var x=h[y];h[y]=h[m],h[m]=x,--y}else++m;f(h[m],v)>0&&--m,d<=m?w=m:g=m+1}return h[d]}}),Cf="max",Vv=["typed","config","numeric","larger"],Yv=mt(Cf,Vv,i=>{var{typed:t,config:e,numeric:r,larger:n}=i;return t(Cf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return La(c,h.valueOf(),s)},"...":function(c){if(js(c))throw new TypeError("Scalar values expected in function max");return a(c)}});function s(l,c){try{return n(l,c)?l:c}catch(h){throw Bn(h,"max",c)}}function a(l){var c;if(rs(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(d){throw Bn(d,"max",h)}}),c===void 0)throw new Error("Cannot calculate max of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),Ff="min",Zv=["typed","config","numeric","smaller"],Kv=mt(Ff,Zv,i=>{var{typed:t,config:e,numeric:r,smaller:n}=i;return t(Ff,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(c,h){return La(c,h.valueOf(),s)},"...":function(c){if(js(c))throw new TypeError("Scalar values expected in function min");return a(c)}});function s(l,c){try{return n(l,c)?l:c}catch(h){throw Bn(h,"min",c)}}function a(l){var c;if(rs(l,function(h){try{isNaN(h)&&typeof h=="number"?c=NaN:(c===void 0||n(h,c))&&(c=h)}catch(d){throw Bn(d,"min",h)}}),c===void 0)throw new Error("Cannot calculate min of an empty array");return typeof c=="string"&&(c=r(c,e.number)),c}}),Mf="add",Gv=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Hv=mt(Mf,Gv,i=>{var{typed:t,matrix:e,addScalar:r,equalScalar:n,DenseMatrix:s,SparseMatrix:a,concat:l}=i,c=of({typed:t}),h=Rg({typed:t,equalScalar:n}),d=af({typed:t,DenseMatrix:s}),f=Xn({typed:t,matrix:e,concat:l});return t(Mf,{"any, any":r,"any, any, ...any":t.referToSelf(p=>(g,w,m)=>{for(var y=p(g,w),v=0;v<m.length;v++)y=p(y,m[v]);return y})},f({elop:r,DS:c,SS:h,Ss:d}))}),Nf="dot",Jv=["typed","addScalar","multiplyScalar","conj","size"],Xv=mt(Nf,Jv,i=>{var{typed:t,addScalar:e,multiplyScalar:r,conj:n,size:s}=i;return t(Nf,{"Array | DenseMatrix, Array | DenseMatrix":l,"SparseMatrix, SparseMatrix":c});function a(d,f){var p=h(d),g=h(f),w,m;if(p.length===1)w=p[0];else if(p.length===2&&p[1]===1)w=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.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(w!==m)throw new RangeError("Vectors must have equal length ("+w+" != "+m+")");if(w===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return w}function l(d,f){var p=a(d,f),g=we(d)?d._data:d,w=we(d)?d._datatype||d.getDataType():void 0,m=we(f)?f._data:f,y=we(f)?f._datatype||f.getDataType():void 0,v=h(d).length===2,x=h(f).length===2,b=e,M=r;if(w&&y&&w===y&&typeof w=="string"&&w!=="mixed"){var E=w;b=t.find(e,[E,E]),M=t.find(r,[E,E])}if(!v&&!x){for(var F=M(n(g[0]),m[0]),N=1;N<p;N++)F=b(F,M(n(g[N]),m[N]));return F}if(!v&&x){for(var S=M(n(g[0]),m[0][0]),T=1;T<p;T++)S=b(S,M(n(g[T]),m[T][0]));return S}if(v&&!x){for(var A=M(n(g[0][0]),m[0]),O=1;O<p;O++)A=b(A,M(n(g[O][0]),m[O]));return A}if(v&&x){for(var L=M(n(g[0][0]),m[0][0]),q=1;q<p;q++)L=b(L,M(n(g[q][0]),m[q][0]));return L}}function c(d,f){a(d,f);for(var p=d._index,g=d._values,w=f._index,m=f._values,y=0,v=e,x=r,b=0,M=0;b<p.length&&M<w.length;){var E=p[b],F=w[M];if(E<F){b++;continue}if(E>F){M++;continue}E===F&&(y=v(y,x(g[b],m[M])),b++,M++)}return y}function h(d){return we(d)?d.size():s(d)}}),Qv="trace",t1=["typed","matrix","add"],e1=mt(Qv,t1,i=>{var{typed:t,matrix:e,add:r}=i;return t("trace",{Array:function(l){return n(e(l))},SparseMatrix:s,DenseMatrix:n,any:oe});function n(a){var l=a._size,c=a._data;switch(l.length){case 1:if(l[0]===1)return oe(c[0]);throw new RangeError("Matrix must be square (size: "+he(l)+")");case 2:{var h=l[0],d=l[1];if(h===d){for(var f=0,p=0;p<h;p++)f=r(f,c[p][p]);return f}else throw new RangeError("Matrix must be square (size: "+he(l)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+he(l)+")")}}function s(a){var l=a._values,c=a._index,h=a._ptr,d=a._size,f=d[0],p=d[1];if(f===p){var g=0;if(l.length>0)for(var w=0;w<p;w++)for(var m=h[w],y=h[w+1],v=m;v<y;v++){var x=c[v];if(x===w){g=r(g,l[v]);break}if(x>w)break}return g}throw new RangeError("Matrix must be square (size: "+he(d)+")")}}),Sf="det",r1=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],n1=mt(Sf,r1,i=>{var{typed:t,matrix:e,subtractScalar:r,multiply:n,divideScalar:s,isZero:a,unaryMinus:l}=i;return t(Sf,{any:function(d){return oe(d)},"Array | Matrix":function(d){var f;switch(we(d)?f=d.size():Array.isArray(d)?(d=e(d),f=d.size()):f=[],f.length){case 0:return oe(d);case 1:if(f[0]===1)return oe(d.valueOf()[0]);if(f[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+he(f)+")");case 2:{var p=f[0],g=f[1];if(p===g)return c(d.clone().valueOf(),p);if(g===0)return 1;throw new RangeError("Matrix must be square (size: "+he(f)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+he(f)+")")}}});function c(h,d,f){if(d===1)return oe(h[0][0]);if(d===2)return r(n(h[0][0],h[1][1]),n(h[1][0],h[0][1]));for(var p=!1,g=new Array(d).fill(0).map((N,S)=>S),w=0;w<d;w++){var m=g[w];if(a(h[m][w])){var y=void 0;for(y=w+1;y<d;y++)if(!a(h[g[y]][w])){m=g[y],g[y]=g[w],g[w]=m,p=!p;break}if(y===d)return h[m][w]}for(var v=h[m][w],x=w===0?1:h[g[w-1]][w-1],b=w+1;b<d;b++)for(var M=g[b],E=w+1;E<d;E++)h[M][E]=s(r(n(h[M][E],v),n(h[M][w],h[m][E])),x)}var F=h[g[d-1]][d-1];return p?l(F):F}}),Of="inv",i1=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],s1=mt(Of,i1,i=>{var{typed:t,matrix:e,divideScalar:r,addScalar:n,multiply:s,unaryMinus:a,det:l,identity:c,abs:h}=i;return t(Of,{"Array | Matrix":function(p){var g=we(p)?p.size():Te(p);switch(g.length){case 1:if(g[0]===1)return we(p)?e([r(1,p.valueOf()[0])]):[r(1,p[0])];throw new RangeError("Matrix must be square (size: "+he(g)+")");case 2:{var w=g[0],m=g[1];if(w===m)return we(p)?e(d(p.valueOf(),w,m),p.storage()):d(p,w,m);throw new RangeError("Matrix must be square (size: "+he(g)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+he(g)+")")}},any:function(p){return r(1,p)}});function d(f,p,g){var w,m,y,v,x;if(p===1){if(v=f[0][0],v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,v)]]}else if(p===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 M=f.concat();for(w=0;w<p;w++)M[w]=M[w].concat();for(var E=c(p).valueOf(),F=0;F<g;F++){var N=h(M[F][F]),S=F;for(w=F+1;w<p;)h(M[w][F])>N&&(N=h(M[w][F]),S=w),w++;if(N===0)throw Error("Cannot calculate inverse, determinant is zero");w=S,w!==F&&(x=M[F],M[F]=M[w],M[w]=x,x=E[F],E[F]=E[w],E[w]=x);var T=M[F],A=E[F];for(w=0;w<p;w++){var O=M[w],L=E[w];if(w!==F){if(O[F]!==0){for(y=r(a(O[F]),T[F]),m=F;m<g;m++)O[m]=n(O[m],s(y,T[m]));for(m=0;m<g;m++)L[m]=n(L[m],s(y,A[m]))}}else{for(y=T[F],m=F;m<g;m++)O[m]=r(O[m],y);for(m=0;m<g;m++)L[m]=r(L[m],y)}}}return E}}}),Bf="pinv",o1=["typed","matrix","inv","deepEqual","equal","dotDivide","dot","ctranspose","divideScalar","multiply","add","Complex"],a1=mt(Bf,o1,i=>{var{typed:t,matrix:e,inv:r,deepEqual:n,equal:s,dotDivide:a,dot:l,ctranspose:c,divideScalar:h,multiply:d,add:f,Complex:p}=i;return t(Bf,{"Array | Matrix":function(b){var M=we(b)?b.size():Te(b);switch(M.length){case 1:return v(b)?c(b):M[0]===1?r(b):a(c(b),l(b,b));case 2:{if(v(b))return c(b);var E=M[0],F=M[1];if(E===F)try{return r(b)}catch(N){if(!(N instanceof Error&&N.message.match(/Cannot calculate inverse, determinant is zero/)))throw N}return we(b)?e(g(b.valueOf(),E,F),b.storage()):g(b,E,F)}default:throw new RangeError("Matrix must be two dimensional (size: "+he(M)+")")}},any:function(b){return s(b,0)?oe(b):h(1,b)}});function g(x,b,M){var{C:E,F}=m(x,b,M),N=d(r(d(c(E),E)),c(E)),S=d(c(F),r(d(F,c(F))));return d(S,N)}function w(x,b,M){for(var E=oe(x),F=0,N=0;N<b;N++){if(M<=F)return E;for(var S=N;y(E[S][F]);)if(S++,b===S&&(S=N,F++,M===F))return E;[E[S],E[N]]=[E[N],E[S]];for(var T=E[N][F],A=0;A<M;A++)E[N][A]=a(E[N][A],T);for(var O=0;O<b;O++)if(O!==N){T=E[O][F];for(var L=0;L<M;L++)E[O][L]=f(E[O][L],d(-1,d(T,E[N][L])))}F++}return E}function m(x,b,M){var E=w(x,b,M),F=x.map((S,T)=>S.filter((A,O)=>O<b&&!y(l(E[O],E[O])))),N=E.filter((S,T)=>!y(l(E[T],E[T])));return{C:F,F:N}}function y(x){return s(f(x,p(1,1)),f(0,p(1,1)))}function v(x){return n(f(x,p(1,1)),f(d(x,0),p(1,1)))}}),u1="divide",l1=["typed","matrix","multiply","equalScalar","divideScalar","inv"],c1=mt(u1,l1,i=>{var{typed:t,matrix:e,multiply:r,equalScalar:n,divideScalar:s,inv:a}=i,l=Ra({typed:t,equalScalar:n}),c=Pa({typed:t});return t("divide",Jl({"Array | Matrix, Array | Matrix":function(d,f){return r(d,a(f))},"DenseMatrix, any":function(d,f){return c(d,f,s,!1)},"SparseMatrix, any":function(d,f){return l(d,f,s,!1)},"Array, any":function(d,f){return c(e(d),f,s,!1).valueOf()},"any, Array | Matrix":function(d,f){return r(d,a(f))}},s.signatures))}),If="sum",f1=["typed","config","add","numeric"],h1=mt(If,f1,i=>{var{typed:t,config:e,add:r,numeric:n}=i;return t(If,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":a,"...":function(c){if(js(c))throw new TypeError("Scalar values expected in function sum");return s(c)}});function s(l){var c;return rs(l,function(h){try{c=c===void 0?h:r(c,h)}catch(d){throw Bn(d,"sum",h)}}),c===void 0&&(c=n(0,e.number)),typeof c=="string"&&(c=n(c,e.number)),c}function a(l,c){try{var h=La(l,c,r);return h}catch(d){throw Bn(d,"sum")}}}),Tf="median",d1=["typed","add","divide","compare","partitionSelect"],p1=mt(Tf,d1,i=>{var{typed:t,add:e,divide:r,compare:n,partitionSelect:s}=i;function a(h){try{h=Fa(h.valueOf());var d=h.length;if(d===0)throw new Error("Cannot calculate median of an empty array");if(d%2===0){for(var f=d/2-1,p=s(h,f+1),g=h[f],w=0;w<f;++w)n(h[w],g)>0&&(g=h[w]);return c(g,p)}else{var m=s(h,(d-1)/2);return l(m)}}catch(y){throw Bn(y,"median")}}var l=t({"number | BigNumber | Complex | Unit":function(d){return d}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(d,f){return r(e(d,f),2)}});return t(Tf,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(d,f){throw new Error("median(A, dim) is not yet supported")},"...":function(d){if(js(d))throw new TypeError("Scalar values expected in function median");return a(d)}})}),eo=_m({config:gr}),za=wm({}),ka=xm({}),qa=Cm({}),nn=Nm({Matrix:qa}),Mt=v_({BigNumber:eo,Complex:za,DenseMatrix:nn,Fraction:ka}),_1=ag({typed:Mt}),ro=lg({typed:Mt}),m1=Xm({BigNumber:eo,typed:Mt}),$f=Hg({typed:Mt}),In=qm({config:gr,typed:Mt}),no=Bm({typed:Mt}),g1=Lm({typed:Mt}),io=Ug({typed:Mt}),Lf=Gm({typed:Mt}),Ua=jm({Matrix:qa,equalScalar:In,typed:Mt}),Rf=fg({typed:Mt}),Pf=Pm({typed:Mt}),Wa=sg({typed:Mt}),zf=eg({Fraction:ka,typed:Mt}),kf=Tm({typed:Mt}),$e=ng({DenseMatrix:nn,Matrix:qa,SparseMatrix:Ua,typed:Mt}),qf=gv({isNaN:Pf,isNumeric:kf,typed:Mt}),ns=bv({bignumber:m1,fraction:zf,number:Lf}),v1=wv({config:gr,multiplyScalar:io,numeric:ns,typed:Mt}),w1=lv({isInteger:no,matrix:$e,typed:Mt}),Uf=fv({matrix:$e,config:gr,typed:Mt}),Wf=dv({matrix:$e,typed:Mt}),Qn=Xg({isInteger:no,matrix:$e,typed:Mt}),y1=tv({prod:v1,size:Uf,typed:Mt}),D1=_v({conj:$f,transpose:Wf,typed:Mt}),is=Ev({numeric:ns,typed:Mt}),b1=Mv({DenseMatrix:nn,concat:Qn,divideScalar:is,equalScalar:In,matrix:$e,typed:Mt}),jf=Iv({DenseMatrix:nn,concat:Qn,equalScalar:In,matrix:$e,typed:Mt}),Vf=rv({BigNumber:eo,DenseMatrix:nn,SparseMatrix:Ua,config:gr,matrix:$e,typed:Mt}),x1=iv({matrix:$e,multiplyScalar:io,typed:Mt}),E1=Lv({DenseMatrix:nn,concat:Qn,config:gr,matrix:$e,typed:Mt}),A1=Yg({DenseMatrix:nn,concat:Qn,equalScalar:In,matrix:$e,subtractScalar:Rf,typed:Mt,unaryMinus:Wa}),ss=Hv({DenseMatrix:nn,SparseMatrix:Ua,addScalar:ro,concat:Qn,equalScalar:In,matrix:$e,typed:Mt}),Yf=Sv({BigNumber:eo,DenseMatrix:nn,Fraction:ka,concat:Qn,config:gr,equalScalar:In,matrix:$e,typed:Mt}),C1=Uv({equal:jf,typed:Mt}),Zf=Xv({addScalar:ro,conj:$f,multiplyScalar:io,size:Uf,typed:Mt}),F1=zv({DenseMatrix:nn,concat:Qn,config:gr,matrix:$e,typed:Mt}),ja=Kv({config:gr,numeric:ns,smaller:E1,typed:Mt}),Ci=jg({addScalar:ro,dot:Zf,equalScalar:In,matrix:$e,multiplyScalar:io,typed:Mt}),M1=jv({compare:Yf,isNaN:Pf,isNumeric:kf,typed:Mt}),N1=h1({add:ss,config:gr,numeric:ns,typed:Mt}),S1=e1({add:ss,matrix:$e,typed:Mt}),Kf=n1({divideScalar:is,isZero:g1,matrix:$e,multiply:Ci,subtractScalar:Rf,typed:Mt,unaryMinus:Wa}),O1=Yv({config:gr,larger:F1,numeric:ns,typed:Mt}),so=s1({abs:_1,addScalar:ro,det:Kf,divideScalar:is,identity:Vf,matrix:$e,multiply:Ci,typed:Mt,unaryMinus:Wa}),B1=a1({Complex:za,add:ss,ctranspose:D1,deepEqual:C1,divideScalar:is,dot:Zf,dotDivide:b1,equal:jf,inv:so,matrix:$e,multiply:Ci,typed:Mt}),I1=Cv({Complex:za,config:gr,fraction:zf,identity:Vf,inv:so,matrix:$e,multiply:Ci,number:Lf,typed:Mt}),T1=c1({divideScalar:is,equalScalar:In,inv:so,matrix:$e,multiply:Ci,typed:Mt}),Gf=p1({add:ss,compare:Yf,divide:T1,partitionSelect:M1,typed:Mt});class $1{constructor(t,e,r){$(this,"_cacheData");$(this,"_variables");$(this,"_math");$(this,"_timeframe");this._cacheData={},this._variables=t,this._math=e,this._timeframe=r}alma({series:t,length:e,offset:r,sigma:n,floor:s},a){if(e===void 0||r===void 0||n===void 0)return;const l=this._cacheDataList(t,e,`alma_${a}`);if(l===void 0)return;let c=r*(e-1);s&&(c=Math.floor(c));const h=e/n;let d=0,f=0;for(let p=0;p<=e-1;p++){const g=Math.exp(-1*Math.pow(p-c,2)/(2*Math.pow(h,2)));d+=g,f+=l[l.length-1-(e-p-1)]*g}return f/d}sma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;let n=0;const s=this._cacheDataList(t,e,`sma_${r}`);if(s===void 0)return;const a=s.slice(-e);return n=N1(...a)/e,n}rma({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;const{sum:n}=this._cacheData[`rma_${r}`]||{},s=1/e,a=this.sma({source:t,length:e},r),l=n===void 0?a:s*t+(1-s)*(n||0);return this._cacheDataHandle(`rma_${r}`,{sum:l}),l}atr({length:t},e){const{high:r,close:n}=this._cacheData[`atr_${e}`]||{},{high:s,close:a,low:l}=this._variables,c=r===void 0?s-l:Math.max(Math.max(s-l,Math.abs(s-n)),Math.abs(l-n));return this._cacheDataHandle(`atr_${e}`,{high:s,close:a}),this.rma({source:c,length:t},e)}barssince({condition:t},e){let{count:r}=this._cacheData[`barssince_${e}`]||{};if(t)r=0;else{if(r===void 0)return;r+=1}return this._cacheDataHandle(`barssince_${e}`,{count:r}),r}stdev({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0)return;const s=this._cacheDataList(t,e,`stdev_${n}`),a=this.sma({source:t,length:e},n);if(s===void 0)return;let l=0;for(let c=0;c<e;c++){const h=this._sum(s[s.length-1-c],-(a||0));l+=h*h}return r||e<=1?Math.sqrt(l/e):Math.sqrt(l/(e-1))}_sum(t,e){let n=t+e;return Math.abs(n)<=1e-10&&(n=0),n}bb({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[];const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return[];const l=r*a;return[s,s+l,s-l]}bbw({series:t,length:e,mult:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.sma({source:t,length:e},n),a=this.stdev({source:t,length:e},n);if(s===void 0||a===void 0)return;const l=r*a;return(s+l-(s-l))/s}cci({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r),s=this.dev({source:t,length:e},r);if(!(n===void 0||s===void 0))return(t-n)/(.015*s)}change({source:t,length:e=1},r){const n=this._cacheDataList(t,e,`change_${r}`);if(n===void 0)return;const s=n[n.length-1-e];if(!(t===void 0||isNaN(t)))return s===void 0?s:typeof t=="boolean"?s!==t:t-s}cmo({series:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.change({source:t},r);if(n===void 0)return;const s=this._math.sum({source:n>=0?n:0,length:e},`sm1_${r}`),a=this._math.sum({source:n>=0?0:-n,length:e},`sm2_${r}`);if(!(s===void 0||a===void 0))return 100*(s-a)/(s+a)}cog({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this._cacheDataList(t,e,`cog_${r}`),s=this._math.sum({source:t,length:e},r);if(s===void 0||n===void 0)return;let a=0;for(let l=0;l<e;l++){const c=n[n.length-1-l];a+=c*(l+1)}return-a/s}correlation({source1:t,source2:e,length:r},n){if(t===void 0||isNaN(t)||e===void 0||isNaN(e)||r===void 0)return;const s=this._cacheDataList([t,e],r,`correlation_${n}`),a=this.sma({source:t,length:r},`sma1_${n}`),l=this.sma({source:e,length:r},`sma2_${n}`);if(a===void 0||l===void 0||s===void 0)return;let c=0,h=0,d=0;for(let p=0;p<r;p++){const[g,w]=s[s.length-1-p],m=g-a,y=w-l;c+=m*y,h+=m*m,d+=y*y}return isNaN(h)||isNaN(c)||isNaN(d)?void 0:c/Math.sqrt(h*d)}cross({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`cross_${r}`]||{};return this._cacheDataHandle(`cross_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e||n<=s&&t>e}crossover({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossover_${r}`]||{};return this._cacheDataHandle(`crossover_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n<=s&&t>e}crossunder({source1:t,source2:e},r){if(t===void 0||e===void 0)return!1;const{source1:n,source2:s}=this._cacheData[`crossunder_${r}`]||{};return this._cacheDataHandle(`crossunder_${r}`,{source1:t,source2:e}),n===void 0||s===void 0?!1:n>=s&&t<e}cum({source:t=0},e){t=isNaN(t)?0:t;let{sum:r}=this._cacheData[`cum_${e}`]||{};return r=r||0,r+=t,this._cacheDataHandle(`cum_${e}`,{sum:r}),r}dev({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return;const n=this.sma({source:t,length:e},r);let s=0;const a=this._cacheDataList(t,e,`dev_${r}`);if(!(!a||n===void 0)){for(let l=0;l<e;l++){const c=a[a.length-1-l];s+=Math.abs(c-n)}return s/e}}dmi({diLength:t,adxSmoothing:e},r){if(t===void 0||e===void 0)return[void 0,void 0,void 0];const n=`dmi_${r}`,{low:s,high:a,close:l,PDMS:c,NDMS:h,TRS:d,ADX:f,count:p=0}=this._cacheData[n]||{},{low:g,high:w,close:m}=this._variables;if(s===void 0||a===void 0||l===void 0)return this._cacheData[n]={low:g,high:w,close:m,PDMS:c,NDMS:h,TRS:w-g,count:1},[void 0,void 0,void 0];let y=w-a,v=s-g;y=y>v&&y>0?y:0,v=v>y&&v>0?v:0,y===v&&(y=v=0);const x=Math.max(w-g,Math.abs(w-l),Math.abs(g-l));if(p<t)return this._cacheDataHandle(n,{low:g,high:w,close:m,PDMS:(c||0)+y,NDMS:(h||0)+v,TRS:(d||0)+x,count:p+1}),[void 0,void 0,void 0];{const b=c-c/t+y,M=h-h/t+v,E=d-d/t+x,F=b/E*100,N=M/E*100,S=Math.abs((F-N)/(F+N))*100;let T=S,A=[F,N,void 0];if(p+1-t<e){const O=p+1-t;T=((f||0)*(O-1)+S)/O}else T=(f*(e-1)+S)/e,A=[F,N,T];return this._cacheDataHandle(n,{low:g,high:w,close:m,PDMS:b,NDMS:M,TRS:E,ADX:T,count:p+1}),A}}ema({source:t,length:e},r){if(t===void 0||e===void 0||isNaN(t))return;let{sum:n,count:s=1}=this._cacheData[`ema_${r}`]||{};const a=this.sma({source:t,length:e},r);if(s>e){const l=2/(e+1);n=n===void 0?t:l*t+(1-l)*(n||0)}else n=a;return s+=1,this._cacheDataHandle(`ema_${r}`,{sum:n,count:s}),n}falling({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,fallings:s=[]}=this._cacheData[`falling_${r}`]||{};s.push(n>t);const a=s.slice(-e);return this._cacheDataHandle(`falling_${r}`,{source:t,fallings:a}),a.length<e?!1:a.every(l=>l)}rising({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0)return!1;const{source:n,risings:s=[]}=this._cacheData[`rising_${r}`]||{};s.push(n<t);const a=s.slice(-e);return this._cacheDataHandle(`rising_${r}`,{source:t,risings:a}),a.length<e?!1:a.every(l=>l)}highest({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`highest_${r}`);if(s)return Math.max(...s.slice(-e))}highestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{high:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`highestbars_${r}`);return s?s.slice(-e).reduce((l,c,h,d)=>c>=d[l]?h:l,0)-e+1:void 0}wma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`wma_${r}`);if(!n)return;let s=0,a=0;for(let l=0;l<e;l++){const c=(e-l)*e;s+=c,a+=n[n.length-1-l]*c}return a/s}hma({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this.wma({source:t,length:e},r),s=this.wma({source:t,length:Math.round(e/2)},r);return n===void 0||s===void 0?void 0:this.wma({source:2*s-n,length:Math.floor(Math.sqrt(e))},`hma_${r}`)}kc({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},s),{ta:l,high:c,low:h}=this._variables,d=n?l.tr:c-h,f=this.ema({source:d,length:e},`range_${s}`);return[a,a+f*r,a-f*r]}kcw({series:t,length:e,mult:r,useTrueRange:n=!0},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const a=this.ema({source:t,length:e},s),{ta:l,high:c,low:h}=this._variables,d=n?l.tr:c-h,f=this.ema({source:d,length:e},`range_${s}`);return(a+f*r-(a-f*r))/a}linreg({source:t,length:e,offset:r},n){if(e===void 0||r===void 0)return;const s=this._cacheDataList(t,e,`dev_${n}`);if(!s)return;const a=s.slice(-e).filter(g=>g!==void 0);let l=0,c=0,h=0,d=0;for(const[g,w]of a.entries())l+=g,c+=w,h+=g*w,d+=g*g;const f=(e*h-l*c)/(e*d-l*l);return(c-f*l)/e+f*(e-1-r)}lowest({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`lowest_${r}`);if(s)return Math.min(...s.slice(-e))}lowestbars({source:t,length:e},r){if(e===void 0||e<=0)return;const{low:n}=this._variables,s=this._cacheDataList(typeof t!="number"?n:t,e,`lowestbars_${r}`);return s?s.slice(-e).reduce((l,c,h,d)=>c<=d[l]?h:l,0)-e+1:void 0}macd({source:t,fastlen:e,slowlen:r,siglen:n},s){if(t===void 0||isNaN(t)||e===void 0||r===void 0||n===void 0)return[void 0,void 0,void 0];const a=this.ema({source:t,length:e},`ema1_${s}`),l=this.ema({source:t,length:r},`ema2_${s}`);if(a===void 0||l===void 0)return[void 0,void 0,void 0];const c=a-l,h=this.ema({source:c,length:n},`macd_${s}`);if(h===void 0)return[c,h,void 0];const d=c-h;return[c,h,d]}max({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`max_${e}`]||0;return t>r&&(r=t),this._cacheData[`max_${e}`]=r,r}min({source:t},e){if(t===void 0||isNaN(t))return;let r=this._cacheData[`min_${e}`]||1/0;return t<r&&(r=t),this._cacheData[`min_${e}`]=r,r}median({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`dev_${r}`);if(n)return Gf(n.slice(-e))}mfi({series:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const{volume:n}=this._variables,s=this.change({source:t},r),a=this._math.sum({source:n*(s>=0?0:t),length:e},`lower_${r}`),l=this._math.sum({source:n*(s<=0?0:t),length:e},`upper_${r}`);if(!(l===void 0||a===void 0))return 100-100/(1+l/a)}mode({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<=0)return;const n=this._cacheDataList(t,e,`mode_${r}`);if(n)return ja(qf(n.slice(-e)))}mom({source:t,length:e},r){if(e===void 0||e<0)return;const n=`mom_${r}`,s=this._cacheData[n]||[];if(s[this._variables.bar_index]=t,this._cacheData[n]=s,s.length<=e||t===void 0||isNaN(t))return;let a=s.length-e-1,l;for(;l===void 0&&a>=0;)l=s[a],a--;return l===void 0?l:t-l}percentile_linear_interpolation({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e+1,`percentile_linear_interpolation_${n}`);if(!s)return;const a=this._sort(s.slice(-(e+1))),l=a.length;r/=100;const c=1/(l*2);if(r<=c)return a[0];if(r>=1-1/(l*2))return a[l-1];for(const[h,d]of a.entries()){const f=a[h-1];if(r<(h+.5)/l)return f===void 0||d===void 0?void 0:f+(d-f)*(r-(h-.5)/l)/(1/l)}}percentile_nearest_rank({source:t,length:e,percentage:r},n){if(e===void 0||r===void 0||t===void 0||isNaN(t)||e<0||r<0||r>100)return;const s=this._cacheDataList(t,e,`percentile_nearest_rank_${n}`);if(!s)return;const a=this._sort(s.slice(-e)),l=r/100*a.length,c=Math.ceil(l)-1;return a[c>=a.length?a.length-1:c]}percentrank({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`percentile_nearest_rank_${r}`);if(!n)return;const s=n.slice(-(e+1)),a=t;if(a===void 0)return;let l=0;for(let c=0;c<s.length;c++)s[c]!==void 0&&(s[c]<a||s[c]===a&&c<e)&&l++;return l/(s.length-1)*100}pivot_point_levels({type:t,anchor:e,developing:r},n){const s=new Qt;let{close:a,open:l,low:c,high:h}=this._variables;const d=`pivot_point_levels_${n}`,{close:f,low:p,high:g,open:w,result:m}=this._cacheData[d]||{};if(!e&&(g&&p&&(h=Math.max(g,h),c=Math.min(p,c)),this._cacheDataHandle(d,{close:a,open:l,low:c,high:h,result:m}),!r))return s._value=m||[],s;const y={close:a,open:l,low:c,high:h};e===!0&&!r&&(a=f,l=w,c=p,h=g);const v=this._getPivotPointLevels(h,c,a,l,r,t);return this._cacheDataHandle(d,{...y,result:v}),s._value=v,s}_getPivotPointLevels(t,e,r,n,s,a){if(r===void 0||n===void 0||e===void 0||t===void 0)return[];switch(a){case Hn.traditional:return this._traditional(t,e,r);case Hn.fibonacci:return this._fibonacci(t,e,r);case Hn.woodie:return s?[]:this._woodie(t,e);case Hn.classic:return this._classic(t,e,r);case Hn.dm:return this._DM(t,e,r,n);case Hn.camarilla:return this._camarilla(t,e,r);default:return[]}}_traditional(t,e,r){const n=(t+e+r)/3,s=n*2-e,a=n+(t-e),l=n*2+(t-2*e),c=n*3+(t-3*e),h=n*4+(t-4*e),d=n*2-t,f=n-(t-e),p=n*2-(2*t-e),g=n*3-(3*t-e),w=n*4-(4*t-e);return[n,s,d,a,f,l,p,c,g,h,w]}_fibonacci(t,e,r){const n=(t+e+r)/3,s=n+.382*(t-e),a=n-.382*(t-e),l=n+.618*(t-e),c=n-.618*(t-e),h=n+(t-e),d=n-(t-e);return[n,s,a,l,c,h,d]}_woodie(t,e){const{open:r}=this._variables,n=(t+e+2*r)/4,s=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=t+2*(n-e),d=e-2*(t-n),f=h+(t-e),p=d-(t-e);return[n,s,a,l,c,h,d,f,p]}_classic(t,e,r){const n=(t+e+r)/3,s=2*n-e,a=2*n-t,l=n+(t-e),c=n-(t-e),h=n+2*(t-e),d=n-2*(t-e),f=n+3*(t-e),p=n-3*(t-e);return[n,s,a,l,c,h,d,f,p]}_DM(t,e,r,n){let s;n===r?s=t+e+2*r:r>n?s=2*t+e+r:s=2*e+t+r;const a=s/4,l=s/2-e,c=s/2-t;return[a,l,c]}_camarilla(t,e,r){const n=(t+e+r)/3,s=r+1.1*(t-e)/12,a=r-1.1*(t-e)/12,l=r+1.1*(t-e)/6,c=r-1.1*(t-e)/6,h=r+1.1*(t-e)/4,d=r-1.1*(t-e)/4,f=r+1.1*(t-e)/2,p=r-1.1*(t-e)/2,g=t/e*r,w=r-(g-r);return[n,s,a,l,c,h,d,f,p,g,w]}pivothigh({source:t=this._variables.high,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivothigh_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),l=a[e];return Math.max(...a)===l?l:void 0}pivotlow({source:t=this._variables.low,leftbars:e,rightbars:r},n){if(e===void 0||r===void 0||e<0||r<0)return;const s=this._cacheDataList(t,e+r+1,`pivotlow_${n}`);if(!s)return;const a=s.slice(-(e+r+1)),l=a[e];return Math.min(...a)===l?l:void 0}range({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const n=this._cacheDataList(t,e,`range_${r}`,!0);if(!n)return;const s=n.filter(c=>c!==void 0).slice(-e),a=Math.max(...s),l=Math.min(...s);return a-l}roc({source:t,length:e},r){if(e===void 0||e<0)return;const n=this._cacheDataList(t,e+1,`roc_${r}`),s=this.change({source:t,length:e},r);if(n)return 100*s/n[n.length-1-e]}rsi({source:t,length:e},r){if(e===void 0||t===void 0||isNaN(t)||e<0)return;const{source:n}=this._cacheData[`rsi_${r}`]||{},s=Math.max(t-n,0),a=Math.max(n-t,0),l=this.rma({source:s,length:e},`rma1_${r}`),c=this.rma({source:a,length:e},`rma2_${r}`);if(this._cacheDataHandle(`rsi_${r}`,{source:t}),!(l===void 0||c===void 0))return 100-100/(1+l/c)}sar({start:t,inc:e,max:r},n){if(t===void 0||e===void 0||r===void 0)return;const{close:s,low:a,high:l,preLow:c,preHigh:h,data:d={}}=this._cacheData[`sar_${n}`]||{};let{result:f,maxMin:p,acceleration:g,isBelow:w}=d,m=!1;const{close:y,low:v,high:x,bar_index:b}=this._variables;return b===1&&(y>s?(w=!0,p=x,f=a):(w=!1,p=v,f=l),m=!0,g=t),f=f+g*(p-f),w?f>v&&(m=!0,w=!1,f=Math.max(x,p||0),p=v,g=t):f<x&&(m=!0,w=!0,f=Math.min(v,p||0),p=x,g=t),m||(w?x>(p||0)&&(p=x,g=Math.min((g||0)+e,r)):v<(p||0)&&(p=v,g=Math.min((g||0)+e,r))),w?(f=Math.min(f,a),b>1&&(f=Math.min(f,c))):(f=Math.max(f,l),b>1&&(f=Math.max(f,h))),this._cacheDataHandle(`sar_${n}`,{high:x,close:y,low:v,preLow:a,preHigh:l,data:Object.assign(d,{result:f,maxMin:p,acceleration:g,isBelow:w})}),f}stoch({source:t,high:e,low:r,length:n},s){if(n===void 0||e===void 0||r===void 0||t===void 0||isNaN(t)||n<0)return;const a=this.lowest({source:r,length:n},s),l=this.highest({source:e,length:n},s);if(!(a===void 0||l===void 0))return 100*(t-a)/(l-a)}supertrend({factor:t,atrPeriod:e},r){if(t===void 0||e===void 0)return[void 0,void 0];const{hl2:n,close:s}=this._variables,a=`supertrend_${r}`,{upperBand:l,lowerBand:c,superTrend:h,atr:d,close:f}=this._cacheData[a]||{},p=this.atr({length:e},r);if(p===void 0)return this._cacheDataHandle(a,{close:s}),[void 0,void 0];let g=n+t*p,w=n-t*p;const m=l||0,y=c||0;w=w>y||f<y?w:y,g=g<m||f>m?g:m;let v;d===void 0?v=1:h===m?v=s>g?-1:1:v=s<w?1:-1;const x=v===-1?w:g;return this._cacheDataHandle(a,{upperBand:g,lowerBand:w,superTrend:x,atr:p,close:s}),[x,v]}swma({source:t},e){let{list:r}=this._cacheData[`swma_${e}`]||{};if(r||(r=[]),r.push(t),r=r.slice(-4),this._cacheDataHandle(`swma_${e}`,{list:r}),!(r.filter(n=>n!==void 0).length<4))return r[3]*1/6+r[2]*2/6+r[1]*2/6+r[0]*1/6}tr({handle_na:t=!1},e){const{close:r,low:n,high:s}=this._variables,{close:a}=this._cacheData[`tr_${e}`]||{};return this._cacheDataHandle(`tr_${e}`,{close:r}),a===void 0?t?s-n:void 0:Math.max(s-n,Math.abs(s-a),Math.abs(n-a))}tsi({source:t,short_length:e,long_length:r},n){if(t===void 0||isNaN(t)||e===void 0||r===void 0)return;const s=this.change({source:t},n);if(s===void 0)return;const a=this.ema({source:Math.abs(s),length:e},`absema1_${n}`),l=this.ema({source:s,length:e},`ema1_${n}`);if(l===void 0)return;const c=this.ema({source:l,length:r},`ema2_${n}`),h=this.ema({source:a,length:e},`absema2_${n}`);if(c!==void 0)return c/h}valuewhen({condition:t,source:e,occurrence:r},n){if(e===void 0||r===void 0||r<0)return;let{list:s}=this._cacheData[`valuewhen_${n}`]||{};return s||(s=[]),t&&s.push(e),this._cacheDataHandle(`valuewhen_${n}`,{list:s}),s[s.length-1-r]}variance({source:t,length:e,biased:r=!0},n){if(t===void 0||isNaN(t)||e===void 0||e<0)return;const s=this.sma({source:t,length:e},n),a=this._cacheDataList(t,e,`variance_${n}`,!0);if(!a||s===void 0)return;const l=a.filter(h=>h!==void 0&&!isNaN(h)).slice(-e);if(l.length<e)return;const c=l.reduce((h,d)=>h+Math.pow(d-s,2),0);if(c!==void 0)return r||e<=1?c/e:c/(e-1)}vwap({source:t,anchor:e,stdev_mult:r},n){if(t===void 0)return;e=e===void 0?this._timeframe.change({timeframe:"1D"},n):e;const{volume:s}=this._variables;let{sum:a=0,sumV:l=0,count:c=0,isReset:h,sumS:d=0}=this._cacheData[`vwap_${n}`]||{};if(e&&(a=l=c=d=0,h=!0),!h)return r!==void 0?[]:void 0;const f=t*s+a,p=s+l,g=f/p;return c++,r!==void 0?(d=s*Math.pow(t,2)+d,this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:p,count:c,isReset:h,sumS:d}),this._computeBands(d,p,r,g)):(this._cacheDataHandle(`vwap_${n}`,{sum:f,sumV:p,count:c,isReset:h}),g)}_computeBands(t,e,r,n){let s=t/e-Math.pow(n,2);s=s<0?0:s;const a=Math.sqrt(s),l=a!==void 0&&!isNaN(a)?n+r*a:void 0,c=a!==void 0&&!isNaN(a)?n-r*a:void 0;return[n,l,c]}vwma({source:t,length:e},r){if(t===void 0||isNaN(t)||e===void 0||e<=0)return;const{volume:n}=this._variables,s=this.sma({source:t*n,length:e},`sma1_${r}`),a=this.sma({source:n,length:e},`sma2_${r}`);if(!(s===void 0||a===void 0))return s/a}wpr({length:t},e){if(t===void 0||t<=0)return;const r=this.highest({length:t},e),n=this.lowest({length:t},e),{close:s}=this._variables;if(!(r===void 0||n===void 0))return(r-s)/(r-n)*-100}_sort(t){const e=t.length;for(let r=0;r<e;r++){let n={};for(let s=0;s<e-r;s++){const{currentVal:a,currentIndex:l}=n,c=t[s];if(c!==void 0){if(a!==void 0&&c<a){t.splice(s,1),t.splice(l,0,c),n={currentIndex:l+1,currentVal:a};continue}n={currentIndex:s,currentVal:c}}}}return t}_cacheDataList(t,e,r,n=!1){const s=this._cacheData[r]||{barIndex:-1,list:[]},{bar_index:a}=this._variables;if(s.barIndex<=a){const l=s.list.length;if(s.barIndex===a)s.list[l-1]=t;else{let c=a-s.barIndex-1;if(s.barIndex!==-1&&c>0){const h=s.list[l-1];for(;c>0;)s.list.push(h),c--}s.list.push(t)}s.barIndex=a,s.list.length>e+5&&!n&&s.list.shift(),this._cacheData[r]=s}if(!(s.list.length<e))return s.list}_cacheDataHandle(t,e){const{barIndex:r}=this._cacheData[t]||{};r!==this._variables.bar_index&&!this._variables._isRealTimeBar&&(this._cacheData[t]=Object.assign(e,{barIndex:this._variables.bar_index}))}}class L1{constructor(t,e,r){$(this,"_cacheData");$(this,"_variables");$(this,"_errorListener");$(this,"_historyInputs");$(this,"_name");this._cacheData={},this._variables=t,this._errorListener=e,this._name=`inputs_${r}`,this._historyInputs=self.workerStorage.get(this._name)||{}}update(t){if(!(t!=null&&t.length)){self.workerStorage.delete(this._name),this._cacheData={};return}for(const e of t){const r=e.id,n=this._historyInputs[r];(!(e!=null&&e.sourceTypeName)&&(n==null?void 0:n.defval)!==e.defval||n!=null&&n.sourceTypeName&&e.sourceTypeName!==(n==null?void 0:n.sourceTypeName))&&(this._cacheData[r]=Object.assign(this._cacheData[r]||{},{...e,isModify:!0}))}}input(t,e){return this._cacheHandle(t,e)}int(t,e){return this._verifyMaxOrMin(t,e),this._cacheHandle(t,e,sr.INT)}bool(t,e){return this._cacheHandle(t,e,sr.BOOL)}color(t,e){return this._cacheHandle(t,e,sr.COLOR)}time(t,e){return this._cacheHandle(t,e,sr.TIME)}float(t,e){return this._verifyMaxOrMin(t,e),this._cacheHandle(t,e,sr.FLOAT)}price(t,e){return this._cacheHandle(t,e,sr.PRICE)}source(t,e){return this._cacheHandle(t,e,sr.SOURCE)}string(t,e){return this._cacheHandle(t,e,sr.STRING)}symbol(t,e){return this._cacheHandle(t,e,sr.SYMBOL)}session(t,e){return this._cacheHandle(t,e,sr.SESSION)}text_area(t,e){return this._cacheHandle(t,e,sr.TEXT_AREA)}timeframe(t,e){return this._cacheHandle(t,e,sr.TIMEFRAME)}enum(t,e){return this._cacheHandle(t,e,sr.ENUM)}_cacheHandle(t,e,r){if(e.startsWith("export"))return t.defval;const n=`${r||"input"}_${e}`,s=this._cacheData[n];if(t.defval===void 0&&this._errorListener.addError(se.inputDefvalErr,e,Pt.Error),self.workerStorage.setValue(this._name,n,{...t}),s)if(!s.isModify)Object.assign(this._cacheData[n],t);else{const a=this._historyInputs[n];!(t.sourceTypeName||a!=null&&a.sourceTypeName)&&t.defval===(a==null?void 0:a.defval)||t.sourceTypeName&&(a==null?void 0:a.sourceTypeName)===t.sourceTypeName?s.sourceTypeName&&(this._cacheData[n].defval=this._variables[s.sourceTypeName]):Object.assign(this._cacheData[n],t)}else{const{defval:a,display:l}=t;this._displayVerify(e,l),t={inputType:r,...t},this._cacheData[n]=t,(r||t.inputType)===sr.SOURCE?this._cacheData[n].options=up:t.options&&!t.options.includes(a)&&this._errorListener.addError(Ze(se.inputOptErr,{defval:String(a),args:t.options.toString()}),e,Pt.Error,6+((r==null?void 0:r.length)||-1))}return this._cacheData[n].defval}_displayVerify(t,e){!e||!e.length||e.includes(Ke.dataWindow)||e.includes(Ke.statusLine)||this._errorListener.addError(Ze(se.displayErr,{func:"input",values:"[display.none, display.data_window, display.status_line, display.all]"}),t,Pt.Error)}_verifyMaxOrMin(t,e){const{defval:r,maxval:n,minval:s}=t;typeof r=="number"&&(n!==void 0&&r>n||s!==void 0&&r<s)&&this._errorListener.addError(se.minOrMaxErr,e,Pt.Error)}getInputs(){const t=Object.keys(this._cacheData),e=[];for(const r of t){const n=this._cacheData[r];n.id=r,e.push(n)}return e.sort((r,n)=>(r.index||0)-(n.index||0))}}class R1{color({x:t}){return t}new({color:t,transp:e=100}){_t(e)&&(e=100);const r=(100-e)/100,{r:n,g:s,b:a}=this._parseColor(t||"");return`rgba(${Math.round(n)}, ${Math.round(s)}, ${Math.round(a)}, ${r})`}rgb({red:t=0,green:e=0,blue:r=0,transp:n=0}){return _t(n)&&(n=0),_t(t)&&(t=0),_t(e)&&(e=0),_t(r)&&(r=0),`rgba(${t}, ${e}, ${r}, ${(100-n)/100})`}g({color:t}){return t?this._parseColor(t).g:0}r({color:t}){return t?this._parseColor(t).r:0}b({color:t}){return t?this._parseColor(t).b:0}t({color:t}){return t?Math.round(this._parseColor(t).a*100):0}from_gradient({value:t,bottom_value:e,top_value:r,bottom_color:n,top_color:s}){if(_t(t)||_t(e)||_t(r)||r===e)return"rgba(0,0,0,1)";const a=(t-e)/(r-e),l=Math.min(Math.max(a,0),1),{r:c,g:h,b:d,a:f}=this._parseColor(n||"rgba(0,0,0,0)"),{r:p,g,b:w,a:m}=this._parseColor(s||"rgba(0,0,0,0)"),y=c+l*(p-c),v=h+l*(g-h),x=d+l*(w-d),b=f+l*(m-f);return`rgba(${Math.round(y)}, ${Math.round(v)}, ${Math.round(x)}, ${b.toFixed(2)})`}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=parseInt(a,16)/255:s=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}}var kt={};const P1=Object.prototype.toString;function os(i){const t=P1.call(i);return t.endsWith("Array]")&&!t.includes("Big")}var z1=Object.freeze({__proto__:null,isAnyArray:os}),k1=Se(z1);function q1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!os(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],l=r+1;l<s;l++)i[l]>a&&(a=i[l]);return a}function U1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!os(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,n=t.toIndex,s=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>i.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],l=r+1;l<s;l++)i[l]<a&&(a=i[l]);return a}function W1(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(os(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!os(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(i.length);var r=U1(i),n=q1(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,a=s===void 0?t.autoMinMax?r:0:s,l=t.max,c=l===void 0?t.autoMinMax?n:1:l;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var h=(c-a)/(n-r),d=0;d<i.length;d++)e[d]=(i[d]-r)*h+a;return e}var j1=Object.freeze({__proto__:null,default:W1}),V1=Se(j1);Object.defineProperty(kt,"__esModule",{value:!0});var fr=k1,Hf=V1;const oo=" ".repeat(2),Jf=" ".repeat(4);function Y1(){return Xf(this)}function Xf(i,t={}){const{maxRows:e=15,maxColumns:r=10,maxNumSize:n=8,padMinus:s="auto"}=t;return`${i.constructor.name} {
55
55
  ${oo}[
56
56
  ${Jf}${Z1(i,e,r,n,s)}
57
57
  ${oo}]
58
58
  ${oo}rows: ${i.rows}
59
59
  ${oo}columns: ${i.columns}
60
- }`}function Z1(i,t,e,r,n){const{rows:s,columns:a}=i,l=Math.min(s,t),c=Math.min(a,e),f=[];if(n==="auto"){n=!1;t:for(let d=0;d<l;d++)for(let h=0;h<c;h++)if(i.get(d,h)<0){n=!0;break t}}for(let d=0;d<l;d++){let h=[];for(let p=0;p<c;p++)h.push(K1(i.get(d,p),r,n));f.push(`${h.join(" ")}`)}return c!==a&&(f[f.length-1]+=` ... ${a-e} more columns`),l!==s&&f.push(`... ${s-t} more rows`),f.join(`
61
- ${Jf}`)}function K1(i,t,e){return(i>=0&&e?` ${Qf(i,t-1)}`:Qf(i,t)).padEnd(t)}function Qf(i,t){let e=i.toString();if(e.length<=t)return e;let r=i.toFixed(t);if(r.length>t&&(r=i.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=i.toExponential(t);return n.length>t&&(n=i.toExponential(Math.max(0,t-(n.length-t)))),n.slice(0)}function G1(i,t){i.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},i.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r);return this},i.prototype.addM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r.get(n,s));return this},i.add=function(r,n){return new t(r).add(n)},i.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},i.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r);return this},i.prototype.subM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r.get(n,s));return this},i.sub=function(r,n){return new t(r).sub(n)},i.prototype.subtract=i.prototype.sub,i.prototype.subtractS=i.prototype.subS,i.prototype.subtractM=i.prototype.subM,i.subtract=i.sub,i.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},i.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r);return this},i.prototype.mulM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r.get(n,s));return this},i.mul=function(r,n){return new t(r).mul(n)},i.prototype.multiply=i.prototype.mul,i.prototype.multiplyS=i.prototype.mulS,i.prototype.multiplyM=i.prototype.mulM,i.multiply=i.mul,i.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},i.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r);return this},i.prototype.divM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r.get(n,s));return this},i.div=function(r,n){return new t(r).div(n)},i.prototype.divide=i.prototype.div,i.prototype.divideS=i.prototype.divS,i.prototype.divideM=i.prototype.divM,i.divide=i.div,i.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},i.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r);return this},i.prototype.modM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r.get(n,s));return this},i.mod=function(r,n){return new t(r).mod(n)},i.prototype.modulus=i.prototype.mod,i.prototype.modulusS=i.prototype.modS,i.prototype.modulusM=i.prototype.modM,i.modulus=i.mod,i.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},i.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r);return this},i.prototype.andM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r.get(n,s));return this},i.and=function(r,n){return new t(r).and(n)},i.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},i.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r);return this},i.prototype.orM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r.get(n,s));return this},i.or=function(r,n){return new t(r).or(n)},i.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},i.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r);return this},i.prototype.xorM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r.get(n,s));return this},i.xor=function(r,n){return new t(r).xor(n)},i.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},i.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r);return this},i.prototype.leftShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r.get(n,s));return this},i.leftShift=function(r,n){return new t(r).leftShift(n)},i.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},i.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r);return this},i.prototype.signPropagatingRightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r.get(n,s));return this},i.signPropagatingRightShift=function(r,n){return new t(r).signPropagatingRightShift(n)},i.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},i.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r);return this},i.prototype.rightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r.get(n,s));return this},i.rightShift=function(r,n){return new t(r).rightShift(n)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.prototype.not=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,~this.get(r,n));return this},i.not=function(r){return new t(r).not()},i.prototype.abs=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.abs(this.get(r,n)));return this},i.abs=function(r){return new t(r).abs()},i.prototype.acos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acos(this.get(r,n)));return this},i.acos=function(r){return new t(r).acos()},i.prototype.acosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acosh(this.get(r,n)));return this},i.acosh=function(r){return new t(r).acosh()},i.prototype.asin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asin(this.get(r,n)));return this},i.asin=function(r){return new t(r).asin()},i.prototype.asinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asinh(this.get(r,n)));return this},i.asinh=function(r){return new t(r).asinh()},i.prototype.atan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atan(this.get(r,n)));return this},i.atan=function(r){return new t(r).atan()},i.prototype.atanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atanh(this.get(r,n)));return this},i.atanh=function(r){return new t(r).atanh()},i.prototype.cbrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cbrt(this.get(r,n)));return this},i.cbrt=function(r){return new t(r).cbrt()},i.prototype.ceil=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.ceil(this.get(r,n)));return this},i.ceil=function(r){return new t(r).ceil()},i.prototype.clz32=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.clz32(this.get(r,n)));return this},i.clz32=function(r){return new t(r).clz32()},i.prototype.cos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cos(this.get(r,n)));return this},i.cos=function(r){return new t(r).cos()},i.prototype.cosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cosh(this.get(r,n)));return this},i.cosh=function(r){return new t(r).cosh()},i.prototype.exp=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.exp(this.get(r,n)));return this},i.exp=function(r){return new t(r).exp()},i.prototype.expm1=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.expm1(this.get(r,n)));return this},i.expm1=function(r){return new t(r).expm1()},i.prototype.floor=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.floor(this.get(r,n)));return this},i.floor=function(r){return new t(r).floor()},i.prototype.fround=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.fround(this.get(r,n)));return this},i.fround=function(r){return new t(r).fround()},i.prototype.log=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log(this.get(r,n)));return this},i.log=function(r){return new t(r).log()},i.prototype.log1p=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log1p(this.get(r,n)));return this},i.log1p=function(r){return new t(r).log1p()},i.prototype.log10=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log10(this.get(r,n)));return this},i.log10=function(r){return new t(r).log10()},i.prototype.log2=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log2(this.get(r,n)));return this},i.log2=function(r){return new t(r).log2()},i.prototype.round=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.round(this.get(r,n)));return this},i.round=function(r){return new t(r).round()},i.prototype.sign=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sign(this.get(r,n)));return this},i.sign=function(r){return new t(r).sign()},i.prototype.sin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sin(this.get(r,n)));return this},i.sin=function(r){return new t(r).sin()},i.prototype.sinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sinh(this.get(r,n)));return this},i.sinh=function(r){return new t(r).sinh()},i.prototype.sqrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sqrt(this.get(r,n)));return this},i.sqrt=function(r){return new t(r).sqrt()},i.prototype.tan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tan(this.get(r,n)));return this},i.tan=function(r){return new t(r).tan()},i.prototype.tanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tanh(this.get(r,n)));return this},i.tanh=function(r){return new t(r).tanh()},i.prototype.trunc=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.trunc(this.get(r,n)));return this},i.trunc=function(r){return new t(r).trunc()},i.pow=function(r,n){return new t(r).pow(n)},i.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},i.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r));return this},i.prototype.powM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r.get(n,s)));return this}}function Or(i,t,e){let r=e?i.rows:i.rows-1;if(t<0||t>r)throw new RangeError("Row index out of range")}function Br(i,t,e){let r=e?i.columns:i.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function Fi(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function Mi(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function Va(i,t){if(!fr.isAnyArray(t))throw new TypeError("row indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=i.rows)throw new RangeError("row indices are out of range")}function Ya(i,t){if(!fr.isAnyArray(t))throw new TypeError("column indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=i.columns)throw new RangeError("column indices are out of range")}function Za(i,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(uo("startRow",t),uo("endRow",e),uo("startColumn",r),uo("endColumn",n),t>e||r>n||t<0||t>=i.rows||e<0||e>=i.rows||r<0||r>=i.columns||n<0||n>=i.columns)throw new RangeError("Submatrix indices are out of range")}function ao(i,t=0){let e=[];for(let r=0;r<i;r++)e.push(t);return e}function uo(i,t){if(typeof t!="number")throw new TypeError(`${i} must be a number`)}function Ni(i){if(i.isEmpty())throw new Error("Empty matrix has no elements to index")}function H1(i){let t=ao(i.rows);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]+=i.get(e,r);return t}function J1(i){let t=ao(i.columns);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]+=i.get(e,r);return t}function X1(i){let t=0;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t+=i.get(e,r);return t}function Q1(i){let t=ao(i.rows,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]*=i.get(e,r);return t}function tw(i){let t=ao(i.columns,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]*=i.get(e,r);return t}function ew(i){let t=1;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t*=i.get(e,r);return t}function rw(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<r;a++){let l=0,c=0,f=0;for(let d=0;d<n;d++)f=i.get(a,d)-e[a],l+=f,c+=f*f;t?s.push((c-l*l/n)/(n-1)):s.push((c-l*l/n)/n)}return s}function nw(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<n;a++){let l=0,c=0,f=0;for(let d=0;d<r;d++)f=i.get(d,a)-e[a],l+=f,c+=f*f;t?s.push((c-l*l/r)/(r-1)):s.push((c-l*l/r)/r)}return s}function iw(i,t,e){const r=i.rows,n=i.columns,s=r*n;let a=0,l=0,c=0;for(let f=0;f<r;f++)for(let d=0;d<n;d++)c=i.get(f,d)-e,a+=c,l+=c*c;return t?(l-a*a/s)/(s-1):(l-a*a/s)/s}function sw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[e])}function ow(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[r])}function aw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t)}function uw(i){const t=[];for(let e=0;e<i.rows;e++){let r=0;for(let n=0;n<i.columns;n++)r+=Math.pow(i.get(e,n),2)/(i.columns-1);t.push(Math.sqrt(r))}return t}function lw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[e])}function cw(i){const t=[];for(let e=0;e<i.columns;e++){let r=0;for(let n=0;n<i.rows;n++)r+=Math.pow(i.get(n,e),2)/(i.rows-1);t.push(Math.sqrt(r))}return t}function fw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[r])}function hw(i){const t=i.size-1;let e=0;for(let r=0;r<i.columns;r++)for(let n=0;n<i.rows;n++)e+=Math.pow(i.get(n,r),2)/t;return Math.sqrt(e)}function dw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t)}class $t{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let s=new dt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)s.set(a,l,r[a*e+l]);return s}static rowVector(t){let e=new dt(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new dt(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new dt(t,e)}static ones(t,e){return new dt(t,e).fill(1)}static rand(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{random:n=Math.random}=r;let s=new dt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)s.set(a,l,n());return s}static randInt(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:s=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(s))throw new TypeError("max must be an integer");if(n>=s)throw new RangeError("min must be smaller than max");let l=s-n,c=new dt(t,e);for(let f=0;f<t;f++)for(let d=0;d<e;d++){let h=n+Math.round(a()*l);c.set(f,d,h)}return c}static eye(t,e,r){e===void 0&&(e=t),r===void 0&&(r=1);let n=Math.min(t,e),s=this.zeros(t,e);for(let a=0;a<n;a++)s.set(a,a,r);return s}static diag(t,e,r){let n=t.length;e===void 0&&(e=n),r===void 0&&(r=e);let s=Math.min(n,e,r),a=this.zeros(e,r);for(let l=0;l<s;l++)a.set(l,l,t[l]);return a}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new dt(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)s.set(a,l,Math.min(t.get(a,l),e.get(a,l)));return s}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new this(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)s.set(a,l,Math.max(t.get(a,l),e.get(a,l)));return s}static checkMatrix(t){return $t.isMatrix(t)?t:new dt(t)}static isMatrix(t){return t!=null&&t.klass==="Matrix"}get size(){return this.rows*this.columns}apply(t){if(typeof t!="function")throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(this.get(t,t)!==0)return!1;return!0}isEchelonForm(){let t=0,e=0,r=-1,n=!0,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);for(let a=e+1;a<this.rows;a++)this.get(t,a)!==0&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let s=e;s<t.rows;s++)t.get(s,r)>t.get(n,r)&&(n=s);if(t.get(n,r)===0)r++;else{t.swapRows(e,n);let s=t.get(e,r);for(let a=r;a<t.columns;a++)t.set(e,a,t.get(e,a)/s);for(let a=e+1;a<t.rows;a++){let l=t.get(a,r)/t.get(e,r);t.set(a,r,0);for(let c=r+1;c<t.columns;c++)t.set(a,c,t.get(a,c)-t.get(e,c)*l)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(t.maxRow(n)===0)n--;else{let s=0,a=!1;for(;s<r&&a===!1;)t.get(n,s)===1?a=!0:s++;for(let l=0;l<n;l++){let c=t.get(l,s);for(let f=s;f<e;f++){let d=t.get(l,f)-c*t.get(n,f);t.set(l,f,d)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new dt(this.rows*e,this.columns*r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*s,this.columns*a);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Or(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return dt.rowVector(this.getRow(t))}setRow(t,e){Or(this,t),e=Fi(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Or(this,t),Or(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){Br(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return dt.columnVector(this.getColumn(t))}setColumn(t,e){Br(this,t),e=Mi(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Br(this,t),Br(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=Mi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=Mi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=Mi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=Mi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){Or(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Br(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e&&(e=this.get(r,n));return e}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Ni(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e&&(e=this.get(r,n));return e}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Ni(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(Or(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){Or(this,t),Ni(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(Or(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){Or(this,t),Ni(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(Br(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){Br(this,t),Ni(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(Br(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){Br(this,t),Ni(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){$t.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=dt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,s=new dt(e,n),a=new Float64Array(r);for(let l=0;l<n;l++){for(let c=0;c<r;c++)a[c]=t.get(c,l);for(let c=0;c<e;c++){let f=0;for(let d=0;d<r;d++)f+=this.get(c,d)*a[d];s.set(c,l,f)}}return s}strassen2x2(t){t=dt.checkMatrix(t);let e=new dt(2,2);const r=this.get(0,0),n=t.get(0,0),s=this.get(0,1),a=t.get(0,1),l=this.get(1,0),c=t.get(1,0),f=this.get(1,1),d=t.get(1,1),h=(r+f)*(n+d),p=(l+f)*n,g=r*(a-d),w=f*(c-n),_=(r+s)*d,y=(l-r)*(n+a),v=(s-f)*(c+d),x=h+w-_+v,b=g+_,M=p+w,E=h-p+g+y;return e.set(0,0,x),e.set(0,1,b),e.set(1,0,M),e.set(1,1,E),e}strassen3x3(t){t=dt.checkMatrix(t);let e=new dt(3,3);const r=this.get(0,0),n=this.get(0,1),s=this.get(0,2),a=this.get(1,0),l=this.get(1,1),c=this.get(1,2),f=this.get(2,0),d=this.get(2,1),h=this.get(2,2),p=t.get(0,0),g=t.get(0,1),w=t.get(0,2),_=t.get(1,0),y=t.get(1,1),v=t.get(1,2),x=t.get(2,0),b=t.get(2,1),M=t.get(2,2),E=(r+n+s-a-l-d-h)*y,F=(r-a)*(-g+y),N=l*(-p+g+_-y-v-x+M),S=(-r+a+l)*(p-g+y),T=(a+l)*(-p+g),C=r*p,O=(-r+f+d)*(p-w+v),$=(-r+f)*(w-v),W=(f+d)*(-p+w),q=(r+n+s-l-c-f-d)*v,U=d*(-p+w+_-y-v-x+b),z=(-s+d+h)*(y+x-b),K=(s-h)*(y-b),Z=s*x,X=(d+h)*(-x+b),Q=(-s+l+c)*(v+x-M),ct=(s-c)*(v-M),vt=(l+c)*(-x+M),lt=n*_,yt=c*b,bt=a*w,Ot=f*g,xt=h*M,ue=C+Z+lt,It=E+S+T+C+z+Z+X,Nt=C+O+W+q+Z+Q+vt,fe=F+N+S+C+Z+Q+ct,re=F+S+T+C+yt,qt=Z+Q+ct+vt+bt,Jt=C+O+$+U+z+K+Z,Le=z+K+Z+X+Ot,wr=C+O+$+W+xt;return e.set(0,0,ue),e.set(0,1,It),e.set(0,2,Nt),e.set(1,0,fe),e.set(1,1,re),e.set(1,2,qt),e.set(2,0,Jt),e.set(2,1,Le),e.set(2,2,wr),e}mmulStrassen(t){t=dt.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,s=t.rows,a=t.columns;n!==s&&console.warn(`Multiplying ${r} x ${n} and ${s} x ${a} matrix: dimensions do not match.`);function l(h,p,g){let w=h.rows,_=h.columns;if(w===p&&_===g)return h;{let y=$t.zeros(p,g);return y=y.setSubMatrix(h,0,0),y}}let c=Math.max(r,s),f=Math.max(n,a);e=l(e,c,f),t=l(t,c,f);function d(h,p,g,w){if(g<=512||w<=512)return h.mmul(p);g%2===1&&w%2===1?(h=l(h,g+1,w+1),p=l(p,g+1,w+1)):g%2===1?(h=l(h,g+1,w),p=l(p,g+1,w)):w%2===1&&(h=l(h,g,w+1),p=l(p,g,w+1));let _=parseInt(h.rows/2,10),y=parseInt(h.columns/2,10),v=h.subMatrix(0,_-1,0,y-1),x=p.subMatrix(0,_-1,0,y-1),b=h.subMatrix(0,_-1,y,h.columns-1),M=p.subMatrix(0,_-1,y,p.columns-1),E=h.subMatrix(_,h.rows-1,0,y-1),F=p.subMatrix(_,p.rows-1,0,y-1),N=h.subMatrix(_,h.rows-1,y,h.columns-1),S=p.subMatrix(_,p.rows-1,y,p.columns-1),T=d($t.add(v,N),$t.add(x,S),_,y),C=d($t.add(E,N),x,_,y),O=d(v,$t.sub(M,S),_,y),$=d(N,$t.sub(F,x),_,y),W=d($t.add(v,b),S,_,y),q=d($t.sub(E,v),$t.add(x,M),_,y),U=d($t.sub(b,N),$t.add(F,S),_,y),z=$t.add(T,$);z.sub(W),z.add(U);let K=$t.add(O,W),Z=$t.add(C,$),X=$t.sub(T,C);X.add(O),X.add(q);let Q=$t.zeros(2*z.rows,2*z.columns);return Q=Q.setSubMatrix(z,0,0),Q=Q.setSubMatrix(K,z.rows,0),Q=Q.setSubMatrix(Z,0,z.columns),Q=Q.setSubMatrix(X,z.rows,z.columns),Q.subMatrix(0,g-1,0,w-1)}return d(e,t,c,f)}scaleRows(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new dt(this.rows,this.columns);for(let s=0;s<this.rows;s++){const a=this.getRow(s);a.length>0&&Hf(a,{min:e,max:r,output:a}),n.setRow(s,a)}return n}scaleColumns(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new dt(this.rows,this.columns);for(let s=0;s<this.columns;s++){const a=this.getColumn(s);a.length&&Hf(a,{min:e,max:r,output:a}),n.setColumn(s,a)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let n=this.get(e,r),s=this.get(e,this.columns-1-r);this.set(e,r,s),this.set(e,this.columns-1-r,n)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let n=this.get(r,e),s=this.get(this.rows-1-r,e);this.set(r,e,s),this.set(this.rows-1-r,e,n)}return this}kroneckerProduct(t){t=dt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,s=t.columns,a=new dt(e*n,r*s);for(let l=0;l<e;l++)for(let c=0;c<r;c++)for(let f=0;f<n;f++)for(let d=0;d<s;d++)a.set(n*l+f,s*c+d,this.get(l,c)*t.get(f,d));return a}kroneckerSum(t){if(t=dt.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(dt.eye(r,r)),s=dt.eye(e,e).kroneckerProduct(t);return n.add(s)}transpose(){let t=new dt(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=th){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=th){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){Za(this,t,e,r,n);let s=new dt(e-t+1,n-r+1);for(let a=t;a<=e;a++)for(let l=r;l<=n;l++)s.set(a-t,l-r,this.get(a,l));return s}subMatrixRow(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new dt(t.length,r-e+1);for(let s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.rows)throw new RangeError(`Row index out of range: ${t[s]}`);n.set(s,a-e,this.get(t[s],a))}return n}subMatrixColumn(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new dt(r-e+1,t.length);for(let s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.columns)throw new RangeError(`Column index out of range: ${t[s]}`);n.set(a-e,s,this.get(a,t[s]))}return n}setSubMatrix(t,e,r){if(t=dt.checkMatrix(t),t.isEmpty())return this;let n=e+t.rows-1,s=r+t.columns-1;Za(this,e,n,r,s);for(let a=0;a<t.rows;a++)for(let l=0;l<t.columns;l++)this.set(e+a,r+l,t.get(a,l));return this}selection(t,e){Va(this,t),Ya(this,e);let r=new dt(t.length,e.length);for(let n=0;n<t.length;n++){let s=t[n];for(let a=0;a<e.length;a++){let l=e[a];r.set(n,a,this.get(s,l))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){return this.constructor.copy(this,new dt(this.rows,this.columns))}static copy(t,e){for(const[r,n,s]of t.entries())e.set(r,n,s);return e}sum(t){switch(t){case"row":return H1(this);case"column":return J1(this);case void 0:return X1(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return Q1(this);case"column":return tw(this);case void 0:return ew(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":{for(let r=0;r<this.rows;r++)e[r]/=this.columns;return e}case"column":{for(let r=0;r<this.columns;r++)e[r]/=this.rows;return e}case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if(typeof r!="boolean")throw new TypeError("unbiased must be a boolean");switch(t){case"row":{if(!fr.isAnyArray(n))throw new TypeError("mean must be an array");return rw(this,r,n)}case"column":{if(!fr.isAnyArray(n))throw new TypeError("mean must be an array");return nw(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return iw(this,r,n)}default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){typeof t=="object"&&(e=t,t=void 0);const r=this.variance(t,e);if(t===void 0)return Math.sqrt(r);for(let n=0;n<r.length;n++)r[n]=Math.sqrt(r[n]);return r}center(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":{if(!fr.isAnyArray(r))throw new TypeError("center must be an array");return sw(this,r),this}case"column":{if(!fr.isAnyArray(r))throw new TypeError("center must be an array");return ow(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return aw(this,r),this}default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":{if(r===void 0)r=uw(this);else if(!fr.isAnyArray(r))throw new TypeError("scale must be an array");return lw(this,r),this}case"column":{if(r===void 0)r=cw(this);else if(!fr.isAnyArray(r))throw new TypeError("scale must be an array");return fw(this,r),this}case void 0:{if(r===void 0)r=hw(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return dw(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return Xf(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}$t.prototype.klass="Matrix",typeof Symbol<"u"&&($t.prototype[Symbol.for("nodejs.util.inspect.custom")]=Y1);function th(i,t){return i-t}function pw(i){return i.every(t=>typeof t=="number")}$t.random=$t.rand,$t.randomInt=$t.randInt,$t.diagonal=$t.diag,$t.prototype.diagonal=$t.prototype.diag,$t.identity=$t.eye,$t.prototype.negate=$t.prototype.neg,$t.prototype.tensorProduct=$t.prototype.kroneckerProduct;let dt=($i=class extends $t{constructor(e,r){super();Ll(this,us);L(this,"data");if($i.isMatrix(e))Rl(this,us,Pl).call(this,e.rows,e.columns),$i.copy(e,this);else if(Number.isInteger(e)&&e>=0)Rl(this,us,Pl).call(this,e,r);else if(fr.isAnyArray(e)){const n=e;if(e=n.length,r=e?n[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let s=0;s<e;s++){if(n[s].length!==r)throw new RangeError("Inconsistent array dimensions");if(!pw(n[s]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[s]))}this.rows=e,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(e,r,n){return this.data[e][r]=n,this}get(e,r){return this.data[e][r]}removeRow(e){return Or(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),Or(this,e,!0),r=Float64Array.from(Fi(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){Br(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let s=0;s<e;s++)n[s]=this.data[r][s];for(let s=e+1;s<this.columns;s++)n[s-1]=this.data[r][s];this.data[r]=n}return this.columns-=1,this}addColumn(e,r){typeof r>"u"&&(r=e,e=this.columns),Br(this,e,!0),r=Mi(this,r);for(let n=0;n<this.rows;n++){const s=new Float64Array(this.columns+1);let a=0;for(;a<e;a++)s[a]=this.data[n][a];for(s[a++]=r[n];a<this.columns+1;a++)s[a]=this.data[n][a-1];this.data[n]=s}return this.columns+=1,this}},us=new WeakSet,Pl=function(e,r){if(this.data=[],Number.isInteger(r)&&r>=0)for(let n=0;n<e;n++)this.data.push(new Float64Array(r));else throw new TypeError("nColumns must be a positive integer");this.rows=e,this.columns=r},$i);G1($t,dt);const Co=class Co extends $t{constructor(e){super();Ll(this,tr,void 0);if(dt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ga(this,tr,dt.copy(e,new dt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ga(this,tr,new dt(e,e));else if(ga(this,tr,new dt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Xr(this,tr).size}get rows(){return Xr(this,tr).rows}get columns(){return Xr(this,tr).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return dt.isMatrix(e)&&e.klassType==="SymmetricMatrix"}static zeros(e){return new this(e)}static ones(e){return new this(e).fill(1)}clone(){const e=new Co(this.diagonalSize);for(const[r,n,s]of this.upperRightEntries())e.set(r,n,s);return e}toMatrix(){return new dt(this)}get(e,r){return Xr(this,tr).get(e,r)}set(e,r,n){return Xr(this,tr).set(e,r,n),Xr(this,tr).set(r,e,n),this}removeCross(e){return Xr(this,tr).removeRow(e),Xr(this,tr).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),Xr(this,tr).addRow(e,n),Xr(this,tr).addColumn(e,r),this}applyMask(e){if(e.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[n,s]of e.entries())s||r.push(n);r.reverse();for(const n of r)this.removeCross(n);return this}toCompact(){const{diagonalSize:e}=this,r=new Array(e*(e+1)/2);for(let n=0,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=e&&(n=++s);return r}static fromCompact(e){const r=e.length,n=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(e)}`);const s=new Co(n);for(let a=0,l=0,c=0;c<r;c++)s.set(a,l,e[c]),++a>=n&&(a=++l);return s}*upperRightEntries(){for(let e=0,r=0;e<this.diagonalSize;void 0){const n=this.get(e,r);yield[e,r,n],++r>=this.diagonalSize&&(r=++e)}}*upperRightValues(){for(let e=0,r=0;e<this.diagonalSize;void 0)yield this.get(e,r),++r>=this.diagonalSize&&(r=++e)}};tr=new WeakMap;let ti=Co;ti.prototype.klassType="SymmetricMatrix";class lo extends ti{static isDistanceMatrix(t){return ti.isSymmetricMatrix(t)&&t.klassSubType==="DistanceMatrix"}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return e===void 0&&(e=t,t=this.diagonalSize),e=e.slice(),e[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new ti(this)}clone(){const t=new lo(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=(t-1)*t/2,r=new Array(e);for(let n=1,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=t&&(n=++s+1);return r}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const n=new this(r);for(let s=1,a=0,l=0;l<e;l++)n.set(s,a,t[l]),++s>=r&&(s=++a+1);return n}}lo.prototype.klassSubType="DistanceMatrix";class dn extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class _w extends dn{constructor(t,e){Br(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}}class mw extends dn{constructor(t,e){Ya(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}}class gw extends dn{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}}class vw extends dn{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}}class ww extends dn{constructor(t,e){Or(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}}class yw extends dn{constructor(t,e){Va(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}}class co extends dn{constructor(t,e,r){Va(t,e),Ya(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class Dw extends dn{constructor(t,e,r,n,s){Za(t,e,r,n,s),super(t,r-e+1,s-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}class bw extends dn{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}}class eh extends $t{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class vr extends $t{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function xw(i,t){if(fr.isAnyArray(i))return i[0]&&fr.isAnyArray(i[0])?new vr(i):new eh(i,t);throw new Error("the argument is not an array")}class fo{constructor(t){t=vr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,s=new Float64Array(r),a=1,l,c,f,d,h,p,g,w,_;for(l=0;l<r;l++)s[l]=l;for(w=new Float64Array(r),c=0;c<n;c++){for(l=0;l<r;l++)w[l]=e.get(l,c);for(l=0;l<r;l++){for(_=Math.min(l,c),h=0,f=0;f<_;f++)h+=e.get(l,f)*w[f];w[l]-=h,e.set(l,c,w[l])}for(d=c,l=c+1;l<r;l++)Math.abs(w[l])>Math.abs(w[d])&&(d=l);if(d!==c){for(f=0;f<n;f++)p=e.get(d,f),e.set(d,f,e.get(c,f)),e.set(c,f,p);g=s[d],s[d]=s[c],s[c]=g,a=-a}if(c<r&&e.get(c,c)!==0)for(l=c+1;l<r;l++)e.set(l,c,e.get(l,c)/e.get(c,c))}this.LU=e,this.pivotVector=s,this.pivotSign=a}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(t.get(r,r)===0)return!0;return!1}solve(t){t=dt.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n=t.columns,s=t.subMatrixRow(this.pivotVector,0,n-1),a=e.columns,l,c,f;for(f=0;f<a;f++)for(l=f+1;l<a;l++)for(c=0;c<n;c++)s.set(l,c,s.get(l,c)-s.get(f,c)*e.get(l,f));for(f=a-1;f>=0;f--){for(c=0;c<n;c++)s.set(f,c,s.get(f,c)/e.get(f,f));for(l=0;l<f;l++)for(c=0;c<n;c++)s.set(l,c,s.get(l,c)-s.get(f,c)*e.get(l,f))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new dt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s>a?n.set(s,a,t.get(s,a)):s===a?n.set(s,a,1):n.set(s,a,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new dt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s<=a?n.set(s,a,t.get(s,a)):n.set(s,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function pn(i,t){let e=0;return Math.abs(i)>Math.abs(t)?(e=t/i,Math.abs(i)*Math.sqrt(1+e*e)):t!==0?(e=i/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class Ka{constructor(t){t=vr.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,s=new Float64Array(n),a,l,c,f;for(c=0;c<n;c++){let d=0;for(a=c;a<r;a++)d=pn(d,e.get(a,c));if(d!==0){for(e.get(c,c)<0&&(d=-d),a=c;a<r;a++)e.set(a,c,e.get(a,c)/d);for(e.set(c,c,e.get(c,c)+1),l=c+1;l<n;l++){for(f=0,a=c;a<r;a++)f+=e.get(a,c)*e.get(a,l);for(f=-f/e.get(c,c),a=c;a<r;a++)e.set(a,l,e.get(a,l)+f*e.get(a,c))}}s[c]=-d}this.QR=e,this.Rdiag=s}solve(t){t=dt.checkMatrix(t);let e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n=t.columns,s=t.clone(),a=e.columns,l,c,f,d;for(f=0;f<a;f++)for(c=0;c<n;c++){for(d=0,l=f;l<r;l++)d+=e.get(l,f)*s.get(l,c);for(d=-d/e.get(f,f),l=f;l<r;l++)s.set(l,c,s.get(l,c)+d*e.get(l,f))}for(f=a-1;f>=0;f--){for(c=0;c<n;c++)s.set(f,c,s.get(f,c)/this.Rdiag[f]);for(l=0;l<f;l++)for(c=0;c<n;c++)s.set(l,c,s.get(l,c)-s.get(f,c)*e.get(l,f))}return s.subMatrix(0,a-1,0,n-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(this.Rdiag[e]===0)return!1;return!0}get upperTriangularMatrix(){let t=this.QR,e=t.columns,r=new dt(e,e),n,s;for(n=0;n<e;n++)for(s=0;s<e;s++)n<s?r.set(n,s,t.get(n,s)):n===s?r.set(n,s,this.Rdiag[n]):r.set(n,s,0);return r}get orthogonalMatrix(){let t=this.QR,e=t.rows,r=t.columns,n=new dt(e,r),s,a,l,c;for(l=r-1;l>=0;l--){for(s=0;s<e;s++)n.set(s,l,0);for(n.set(l,l,1),a=l;a<r;a++)if(t.get(l,l)!==0){for(c=0,s=l;s<e;s++)c+=t.get(s,l)*n.get(s,a);for(c=-c/t.get(l,l),s=l;s<e;s++)n.set(s,a,n.get(s,a)+c*t.get(s,l))}}return n}}class Si{constructor(t,e={}){if(t=vr.checkMatrix(t),t.isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:s=!0,computeRightSingularVectors:a=!0,autoTranspose:l=!1}=e;let c=!!s,f=!!a,d=!1,h;if(r<n)if(!l)h=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{h=t.transpose(),r=h.rows,n=h.columns,d=!0;let C=c;c=f,f=C}else h=t.clone();let p=Math.min(r,n),g=Math.min(r+1,n),w=new Float64Array(g),_=new dt(r,p),y=new dt(n,n),v=new Float64Array(n),x=new Float64Array(r),b=new Float64Array(g);for(let C=0;C<g;C++)b[C]=C;let M=Math.min(r-1,n),E=Math.max(0,Math.min(n-2,r)),F=Math.max(M,E);for(let C=0;C<F;C++){if(C<M){w[C]=0;for(let O=C;O<r;O++)w[C]=pn(w[C],h.get(O,C));if(w[C]!==0){h.get(C,C)<0&&(w[C]=-w[C]);for(let O=C;O<r;O++)h.set(O,C,h.get(O,C)/w[C]);h.set(C,C,h.get(C,C)+1)}w[C]=-w[C]}for(let O=C+1;O<n;O++){if(C<M&&w[C]!==0){let $=0;for(let W=C;W<r;W++)$+=h.get(W,C)*h.get(W,O);$=-$/h.get(C,C);for(let W=C;W<r;W++)h.set(W,O,h.get(W,O)+$*h.get(W,C))}v[O]=h.get(C,O)}if(c&&C<M)for(let O=C;O<r;O++)_.set(O,C,h.get(O,C));if(C<E){v[C]=0;for(let O=C+1;O<n;O++)v[C]=pn(v[C],v[O]);if(v[C]!==0){v[C+1]<0&&(v[C]=0-v[C]);for(let O=C+1;O<n;O++)v[O]/=v[C];v[C+1]+=1}if(v[C]=-v[C],C+1<r&&v[C]!==0){for(let O=C+1;O<r;O++)x[O]=0;for(let O=C+1;O<r;O++)for(let $=C+1;$<n;$++)x[O]+=v[$]*h.get(O,$);for(let O=C+1;O<n;O++){let $=-v[O]/v[C+1];for(let W=C+1;W<r;W++)h.set(W,O,h.get(W,O)+$*x[W])}}if(f)for(let O=C+1;O<n;O++)y.set(O,C,v[O])}}let N=Math.min(n,r+1);if(M<n&&(w[M]=h.get(M,M)),r<N&&(w[N-1]=0),E+1<N&&(v[E]=h.get(E,N-1)),v[N-1]=0,c){for(let C=M;C<p;C++){for(let O=0;O<r;O++)_.set(O,C,0);_.set(C,C,1)}for(let C=M-1;C>=0;C--)if(w[C]!==0){for(let O=C+1;O<p;O++){let $=0;for(let W=C;W<r;W++)$+=_.get(W,C)*_.get(W,O);$=-$/_.get(C,C);for(let W=C;W<r;W++)_.set(W,O,_.get(W,O)+$*_.get(W,C))}for(let O=C;O<r;O++)_.set(O,C,-_.get(O,C));_.set(C,C,1+_.get(C,C));for(let O=0;O<C-1;O++)_.set(O,C,0)}else{for(let O=0;O<r;O++)_.set(O,C,0);_.set(C,C,1)}}if(f)for(let C=n-1;C>=0;C--){if(C<E&&v[C]!==0)for(let O=C+1;O<n;O++){let $=0;for(let W=C+1;W<n;W++)$+=y.get(W,C)*y.get(W,O);$=-$/y.get(C+1,C);for(let W=C+1;W<n;W++)y.set(W,O,y.get(W,O)+$*y.get(W,C))}for(let O=0;O<n;O++)y.set(O,C,0);y.set(C,C,1)}let S=N-1,T=Number.EPSILON;for(;N>0;){let C,O;for(C=N-2;C>=-1&&C!==-1;C--){const $=Number.MIN_VALUE+T*Math.abs(w[C]+Math.abs(w[C+1]));if(Math.abs(v[C])<=$||Number.isNaN(v[C])){v[C]=0;break}}if(C===N-2)O=4;else{let $;for($=N-1;$>=C&&$!==C;$--){let W=($!==N?Math.abs(v[$]):0)+($!==C+1?Math.abs(v[$-1]):0);if(Math.abs(w[$])<=T*W){w[$]=0;break}}$===C?O=3:$===N-1?O=1:(O=2,C=$)}switch(C++,O){case 1:{let $=v[N-2];v[N-2]=0;for(let W=N-2;W>=C;W--){let q=pn(w[W],$),U=w[W]/q,z=$/q;if(w[W]=q,W!==C&&($=-z*v[W-1],v[W-1]=U*v[W-1]),f)for(let K=0;K<n;K++)q=U*y.get(K,W)+z*y.get(K,N-1),y.set(K,N-1,-z*y.get(K,W)+U*y.get(K,N-1)),y.set(K,W,q)}break}case 2:{let $=v[C-1];v[C-1]=0;for(let W=C;W<N;W++){let q=pn(w[W],$),U=w[W]/q,z=$/q;if(w[W]=q,$=-z*v[W],v[W]=U*v[W],c)for(let K=0;K<r;K++)q=U*_.get(K,W)+z*_.get(K,C-1),_.set(K,C-1,-z*_.get(K,W)+U*_.get(K,C-1)),_.set(K,W,q)}break}case 3:{const $=Math.max(Math.abs(w[N-1]),Math.abs(w[N-2]),Math.abs(v[N-2]),Math.abs(w[C]),Math.abs(v[C])),W=w[N-1]/$,q=w[N-2]/$,U=v[N-2]/$,z=w[C]/$,K=v[C]/$,Z=((q+W)*(q-W)+U*U)/2,X=W*U*(W*U);let Q=0;(Z!==0||X!==0)&&(Z<0?Q=0-Math.sqrt(Z*Z+X):Q=Math.sqrt(Z*Z+X),Q=X/(Z+Q));let ct=(z+W)*(z-W)+Q,vt=z*K;for(let lt=C;lt<N-1;lt++){let yt=pn(ct,vt);yt===0&&(yt=Number.MIN_VALUE);let bt=ct/yt,Ot=vt/yt;if(lt!==C&&(v[lt-1]=yt),ct=bt*w[lt]+Ot*v[lt],v[lt]=bt*v[lt]-Ot*w[lt],vt=Ot*w[lt+1],w[lt+1]=bt*w[lt+1],f)for(let xt=0;xt<n;xt++)yt=bt*y.get(xt,lt)+Ot*y.get(xt,lt+1),y.set(xt,lt+1,-Ot*y.get(xt,lt)+bt*y.get(xt,lt+1)),y.set(xt,lt,yt);if(yt=pn(ct,vt),yt===0&&(yt=Number.MIN_VALUE),bt=ct/yt,Ot=vt/yt,w[lt]=yt,ct=bt*v[lt]+Ot*w[lt+1],w[lt+1]=-Ot*v[lt]+bt*w[lt+1],vt=Ot*v[lt+1],v[lt+1]=bt*v[lt+1],c&&lt<r-1)for(let xt=0;xt<r;xt++)yt=bt*_.get(xt,lt)+Ot*_.get(xt,lt+1),_.set(xt,lt+1,-Ot*_.get(xt,lt)+bt*_.get(xt,lt+1)),_.set(xt,lt,yt)}v[N-2]=ct;break}case 4:{if(w[C]<=0&&(w[C]=w[C]<0?-w[C]:0,f))for(let $=0;$<=S;$++)y.set($,C,-y.get($,C));for(;C<S&&!(w[C]>=w[C+1]);){let $=w[C];if(w[C]=w[C+1],w[C+1]=$,f&&C<n-1)for(let W=0;W<n;W++)$=y.get(W,C+1),y.set(W,C+1,y.get(W,C)),y.set(W,C,$);if(c&&C<r-1)for(let W=0;W<r;W++)$=_.get(W,C+1),_.set(W,C+1,_.get(W,C)),_.set(W,C,$);C++}N--;break}}}if(d){let C=y;y=_,_=C}this.m=r,this.n=n,this.s=w,this.U=_,this.V=y}solve(t){let e=t,r=this.threshold,n=this.s.length,s=dt.zeros(n,n);for(let p=0;p<n;p++)Math.abs(this.s[p])<=r?s.set(p,p,0):s.set(p,p,1/this.s[p]);let a=this.U,l=this.rightSingularVectors,c=l.mmul(s),f=l.rows,d=a.rows,h=dt.zeros(f,d);for(let p=0;p<f;p++)for(let g=0;g<d;g++){let w=0;for(let _=0;_<n;_++)w+=c.get(p,_)*a.get(g,_);h.set(p,g,w)}return h.mmul(e)}solveForDiagonal(t){return this.solve(dt.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,s=new dt(r,this.s.length);for(let d=0;d<r;d++)for(let h=0;h<n;h++)Math.abs(this.s[h])>e&&s.set(d,h,t.get(d,h)/this.s[h]);let a=this.U,l=a.rows,c=a.columns,f=new dt(r,l);for(let d=0;d<r;d++)for(let h=0;h<l;h++){let p=0;for(let g=0;g<c;g++)p+=s.get(d,g)*a.get(h,g);f.set(d,h,p)}return f}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,s=r.length;n<s;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return dt.diag(this.s)}}function Ew(i,t=!1){return i=vr.checkMatrix(i),t?new Si(i).inverse():rh(i,dt.eye(i.rows))}function rh(i,t,e=!1){return i=vr.checkMatrix(i),t=vr.checkMatrix(t),e?new Si(i).solve(t):i.isSquare()?new fo(i).solve(t):new Ka(i).solve(t)}function ho(i){if(i=dt.checkMatrix(i),i.isSquare()){if(i.columns===0)return 1;let t,e,r,n;if(i.columns===2)return t=i.get(0,0),e=i.get(0,1),r=i.get(1,0),n=i.get(1,1),t*n-e*r;if(i.columns===3){let s,a,l;return s=new co(i,[1,2],[1,2]),a=new co(i,[1,2],[0,2]),l=new co(i,[1,2],[0,1]),t=i.get(0,0),e=i.get(0,1),r=i.get(0,2),t*ho(s)-e*ho(a)+r*ho(l)}else return new fo(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Aw(i,t){let e=[];for(let r=0;r<i;r++)r!==t&&e.push(r);return e}function Cw(i,t,e,r=1e-9,n=1e-9){if(i>n)return new Array(t.rows+1).fill(0);{let s=t.addRow(e,[0]);for(let a=0;a<s.rows;a++)Math.abs(s.get(a,0))<r&&s.set(a,0,0);return s.to1DArray()}}function Fw(i,t={}){const{thresholdValue:e=1e-9,thresholdError:r=1e-9}=t;i=dt.checkMatrix(i);let n=i.rows,s=new dt(n,n);for(let a=0;a<n;a++){let l=dt.columnVector(i.getRow(a)),c=i.subMatrixRow(Aw(n,a)).transpose(),d=new Si(c).solve(l),h=dt.sub(l,c.mmul(d)).abs().max();s.setRow(a,Cw(h,d,a,e,r))}return s}function Mw(i,t=Number.EPSILON){if(i=dt.checkMatrix(i),i.isEmpty())return i.transpose();let e=new Si(i,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,s=e.diagonal;for(let a=0;a<s.length;a++)Math.abs(s[a])>t?s[a]=1/s[a]:s[a]=0;return n.mmul(dt.diag(s).mmul(r.transpose()))}function Nw(i,t=i,e={}){i=new dt(i);let r=!1;if(typeof t=="object"&&!dt.isMatrix(t)&&!fr.isAnyArray(t)?(e=t,t=i,r=!0):t=new dt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=e;n&&(i=i.center("column"),r||(t=t.center("column")));const s=i.transpose().mmul(t);for(let a=0;a<s.rows;a++)for(let l=0;l<s.columns;l++)s.set(a,l,s.get(a,l)*(1/(i.rows-1)));return s}function Sw(i,t=i,e={}){i=new dt(i);let r=!1;if(typeof t=="object"&&!dt.isMatrix(t)&&!fr.isAnyArray(t)?(e=t,t=i,r=!0):t=new dt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:s=!0}=e;n&&(i.center("column"),r||t.center("column")),s&&(i.scale("column"),r||t.scale("column"));const a=i.standardDeviation("column",{unbiased:!0}),l=r?a:t.standardDeviation("column",{unbiased:!0}),c=i.transpose().mmul(t);for(let f=0;f<c.rows;f++)for(let d=0;d<c.columns;d++)c.set(f,d,c.get(f,d)*(1/(a[f]*l[d]))*(1/(i.rows-1)));return c}let nh=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=vr.checkMatrix(t),!t.isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n=t.columns,s=new dt(n,n),a=new Float64Array(n),l=new Float64Array(n),c=t,f,d,h=!1;if(r?h=!0:h=t.isSymmetric(),h){for(f=0;f<n;f++)for(d=0;d<n;d++)s.set(f,d,c.get(f,d));Ow(n,l,a,s),Bw(n,l,a,s)}else{let p=new dt(n,n),g=new Float64Array(n);for(d=0;d<n;d++)for(f=0;f<n;f++)p.set(f,d,c.get(f,d));Iw(n,p,g,s),Tw(n,l,a,s,p)}this.n=n,this.e=l,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t=this.n,e=this.e,r=this.d,n=new dt(t,t),s,a;for(s=0;s<t;s++){for(a=0;a<t;a++)n.set(s,a,0);n.set(s,s,r[s]),e[s]>0?n.set(s,s+1,e[s]):e[s]<0&&n.set(s,s-1,e[s])}return n}};function Ow(i,t,e,r){let n,s,a,l,c,f,d,h;for(c=0;c<i;c++)e[c]=r.get(i-1,c);for(l=i-1;l>0;l--){for(h=0,a=0,f=0;f<l;f++)h=h+Math.abs(e[f]);if(h===0)for(t[l]=e[l-1],c=0;c<l;c++)e[c]=r.get(l-1,c),r.set(l,c,0),r.set(c,l,0);else{for(f=0;f<l;f++)e[f]/=h,a+=e[f]*e[f];for(n=e[l-1],s=Math.sqrt(a),n>0&&(s=-s),t[l]=h*s,a=a-n*s,e[l-1]=n-s,c=0;c<l;c++)t[c]=0;for(c=0;c<l;c++){for(n=e[c],r.set(c,l,n),s=t[c]+r.get(c,c)*n,f=c+1;f<=l-1;f++)s+=r.get(f,c)*e[f],t[f]+=r.get(f,c)*n;t[c]=s}for(n=0,c=0;c<l;c++)t[c]/=a,n+=t[c]*e[c];for(d=n/(a+a),c=0;c<l;c++)t[c]-=d*e[c];for(c=0;c<l;c++){for(n=e[c],s=t[c],f=c;f<=l-1;f++)r.set(f,c,r.get(f,c)-(n*t[f]+s*e[f]));e[c]=r.get(l-1,c),r.set(l,c,0)}}e[l]=a}for(l=0;l<i-1;l++){if(r.set(i-1,l,r.get(l,l)),r.set(l,l,1),a=e[l+1],a!==0){for(f=0;f<=l;f++)e[f]=r.get(f,l+1)/a;for(c=0;c<=l;c++){for(s=0,f=0;f<=l;f++)s+=r.get(f,l+1)*r.get(f,c);for(f=0;f<=l;f++)r.set(f,c,r.get(f,c)-s*e[f])}}for(f=0;f<=l;f++)r.set(f,l+1,0)}for(c=0;c<i;c++)e[c]=r.get(i-1,c),r.set(i-1,c,0);r.set(i-1,i-1,1),t[0]=0}function Bw(i,t,e,r){let n,s,a,l,c,f,d,h,p,g,w,_,y,v,x,b;for(a=1;a<i;a++)t[a-1]=t[a];t[i-1]=0;let M=0,E=0,F=Number.EPSILON;for(f=0;f<i;f++){for(E=Math.max(E,Math.abs(e[f])+Math.abs(t[f])),d=f;d<i&&!(Math.abs(t[d])<=F*E);)d++;if(d>f)do{for(n=e[f],h=(e[f+1]-n)/(2*t[f]),p=pn(h,1),h<0&&(p=-p),e[f]=t[f]/(h+p),e[f+1]=t[f]*(h+p),g=e[f+1],s=n-e[f],a=f+2;a<i;a++)e[a]-=s;for(M=M+s,h=e[d],w=1,_=w,y=w,v=t[f+1],x=0,b=0,a=d-1;a>=f;a--)for(y=_,_=w,b=x,n=w*t[a],s=w*h,p=pn(h,t[a]),t[a+1]=x*p,x=t[a]/p,w=h/p,h=w*e[a]-x*n,e[a+1]=s+x*(w*n+x*e[a]),c=0;c<i;c++)s=r.get(c,a+1),r.set(c,a+1,x*r.get(c,a)+w*s),r.set(c,a,w*r.get(c,a)-x*s);h=-x*b*y*v*t[f]/g,t[f]=x*h,e[f]=w*h}while(Math.abs(t[f])>F*E);e[f]=e[f]+M,t[f]=0}for(a=0;a<i-1;a++){for(c=a,h=e[a],l=a+1;l<i;l++)e[l]<h&&(c=l,h=e[l]);if(c!==a)for(e[c]=e[a],e[a]=h,l=0;l<i;l++)h=r.get(l,a),r.set(l,a,r.get(l,c)),r.set(l,c,h)}}function Iw(i,t,e,r){let n=0,s=i-1,a,l,c,f,d,h,p;for(h=n+1;h<=s-1;h++){for(p=0,f=h;f<=s;f++)p=p+Math.abs(t.get(f,h-1));if(p!==0){for(c=0,f=s;f>=h;f--)e[f]=t.get(f,h-1)/p,c+=e[f]*e[f];for(l=Math.sqrt(c),e[h]>0&&(l=-l),c=c-e[h]*l,e[h]=e[h]-l,d=h;d<i;d++){for(a=0,f=s;f>=h;f--)a+=e[f]*t.get(f,d);for(a=a/c,f=h;f<=s;f++)t.set(f,d,t.get(f,d)-a*e[f])}for(f=0;f<=s;f++){for(a=0,d=s;d>=h;d--)a+=e[d]*t.get(f,d);for(a=a/c,d=h;d<=s;d++)t.set(f,d,t.get(f,d)-a*e[d])}e[h]=p*e[h],t.set(h,h-1,p*l)}}for(f=0;f<i;f++)for(d=0;d<i;d++)r.set(f,d,f===d?1:0);for(h=s-1;h>=n+1;h--)if(t.get(h,h-1)!==0){for(f=h+1;f<=s;f++)e[f]=t.get(f,h-1);for(d=h;d<=s;d++){for(l=0,f=h;f<=s;f++)l+=e[f]*r.get(f,d);for(l=l/e[h]/t.get(h,h-1),f=h;f<=s;f++)r.set(f,d,r.get(f,d)+l*e[f])}}}function Tw(i,t,e,r,n){let s=i-1,a=0,l=i-1,c=Number.EPSILON,f=0,d=0,h=0,p=0,g=0,w=0,_=0,y=0,v,x,b,M,E,F,N,S,T,C,O,$,W,q,U;for(v=0;v<i;v++)for((v<a||v>l)&&(e[v]=n.get(v,v),t[v]=0),x=Math.max(v-1,0);x<i;x++)d=d+Math.abs(n.get(v,x));for(;s>=a;){for(M=s;M>a&&(w=Math.abs(n.get(M-1,M-1))+Math.abs(n.get(M,M)),w===0&&(w=d),!(Math.abs(n.get(M,M-1))<c*w));)M--;if(M===s)n.set(s,s,n.get(s,s)+f),e[s]=n.get(s,s),t[s]=0,s--,y=0;else if(M===s-1){if(N=n.get(s,s-1)*n.get(s-1,s),h=(n.get(s-1,s-1)-n.get(s,s))/2,p=h*h+N,_=Math.sqrt(Math.abs(p)),n.set(s,s,n.get(s,s)+f),n.set(s-1,s-1,n.get(s-1,s-1)+f),S=n.get(s,s),p>=0){for(_=h>=0?h+_:h-_,e[s-1]=S+_,e[s]=e[s-1],_!==0&&(e[s]=S-N/_),t[s-1]=0,t[s]=0,S=n.get(s,s-1),w=Math.abs(S)+Math.abs(_),h=S/w,p=_/w,g=Math.sqrt(h*h+p*p),h=h/g,p=p/g,x=s-1;x<i;x++)_=n.get(s-1,x),n.set(s-1,x,p*_+h*n.get(s,x)),n.set(s,x,p*n.get(s,x)-h*_);for(v=0;v<=s;v++)_=n.get(v,s-1),n.set(v,s-1,p*_+h*n.get(v,s)),n.set(v,s,p*n.get(v,s)-h*_);for(v=a;v<=l;v++)_=r.get(v,s-1),r.set(v,s-1,p*_+h*r.get(v,s)),r.set(v,s,p*r.get(v,s)-h*_)}else e[s-1]=S+h,e[s]=S+h,t[s-1]=_,t[s]=-_;s=s-2,y=0}else{if(S=n.get(s,s),T=0,N=0,M<s&&(T=n.get(s-1,s-1),N=n.get(s,s-1)*n.get(s-1,s)),y===10){for(f+=S,v=a;v<=s;v++)n.set(v,v,n.get(v,v)-S);w=Math.abs(n.get(s,s-1))+Math.abs(n.get(s-1,s-2)),S=T=.75*w,N=-.4375*w*w}if(y===30&&(w=(T-S)/2,w=w*w+N,w>0)){for(w=Math.sqrt(w),T<S&&(w=-w),w=S-N/((T-S)/2+w),v=a;v<=s;v++)n.set(v,v,n.get(v,v)-w);f+=w,S=T=N=.964}for(y=y+1,E=s-2;E>=M&&(_=n.get(E,E),g=S-_,w=T-_,h=(g*w-N)/n.get(E+1,E)+n.get(E,E+1),p=n.get(E+1,E+1)-_-g-w,g=n.get(E+2,E+1),w=Math.abs(h)+Math.abs(p)+Math.abs(g),h=h/w,p=p/w,g=g/w,!(E===M||Math.abs(n.get(E,E-1))*(Math.abs(p)+Math.abs(g))<c*(Math.abs(h)*(Math.abs(n.get(E-1,E-1))+Math.abs(_)+Math.abs(n.get(E+1,E+1))))));)E--;for(v=E+2;v<=s;v++)n.set(v,v-2,0),v>E+2&&n.set(v,v-3,0);for(b=E;b<=s-1&&(q=b!==s-1,b!==E&&(h=n.get(b,b-1),p=n.get(b+1,b-1),g=q?n.get(b+2,b-1):0,S=Math.abs(h)+Math.abs(p)+Math.abs(g),S!==0&&(h=h/S,p=p/S,g=g/S)),S!==0);b++)if(w=Math.sqrt(h*h+p*p+g*g),h<0&&(w=-w),w!==0){for(b!==E?n.set(b,b-1,-w*S):M!==E&&n.set(b,b-1,-n.get(b,b-1)),h=h+w,S=h/w,T=p/w,_=g/w,p=p/h,g=g/h,x=b;x<i;x++)h=n.get(b,x)+p*n.get(b+1,x),q&&(h=h+g*n.get(b+2,x),n.set(b+2,x,n.get(b+2,x)-h*_)),n.set(b,x,n.get(b,x)-h*S),n.set(b+1,x,n.get(b+1,x)-h*T);for(v=0;v<=Math.min(s,b+3);v++)h=S*n.get(v,b)+T*n.get(v,b+1),q&&(h=h+_*n.get(v,b+2),n.set(v,b+2,n.get(v,b+2)-h*g)),n.set(v,b,n.get(v,b)-h),n.set(v,b+1,n.get(v,b+1)-h*p);for(v=a;v<=l;v++)h=S*r.get(v,b)+T*r.get(v,b+1),q&&(h=h+_*r.get(v,b+2),r.set(v,b+2,r.get(v,b+2)-h*g)),r.set(v,b,r.get(v,b)-h),r.set(v,b+1,r.get(v,b+1)-h*p)}}}if(d!==0){for(s=i-1;s>=0;s--)if(h=e[s],p=t[s],p===0)for(M=s,n.set(s,s,1),v=s-1;v>=0;v--){for(N=n.get(v,v)-h,g=0,x=M;x<=s;x++)g=g+n.get(v,x)*n.get(x,s);if(t[v]<0)_=N,w=g;else if(M=v,t[v]===0?n.set(v,s,N!==0?-g/N:-g/(c*d)):(S=n.get(v,v+1),T=n.get(v+1,v),p=(e[v]-h)*(e[v]-h)+t[v]*t[v],F=(S*w-_*g)/p,n.set(v,s,F),n.set(v+1,s,Math.abs(S)>Math.abs(_)?(-g-N*F)/S:(-w-T*F)/_)),F=Math.abs(n.get(v,s)),c*F*F>1)for(x=v;x<=s;x++)n.set(x,s,n.get(x,s)/F)}else if(p<0)for(M=s-1,Math.abs(n.get(s,s-1))>Math.abs(n.get(s-1,s))?(n.set(s-1,s-1,p/n.get(s,s-1)),n.set(s-1,s,-(n.get(s,s)-h)/n.get(s,s-1))):(U=po(0,-n.get(s-1,s),n.get(s-1,s-1)-h,p),n.set(s-1,s-1,U[0]),n.set(s-1,s,U[1])),n.set(s,s-1,0),n.set(s,s,1),v=s-2;v>=0;v--){for(C=0,O=0,x=M;x<=s;x++)C=C+n.get(v,x)*n.get(x,s-1),O=O+n.get(v,x)*n.get(x,s);if(N=n.get(v,v)-h,t[v]<0)_=N,g=C,w=O;else if(M=v,t[v]===0?(U=po(-C,-O,N,p),n.set(v,s-1,U[0]),n.set(v,s,U[1])):(S=n.get(v,v+1),T=n.get(v+1,v),$=(e[v]-h)*(e[v]-h)+t[v]*t[v]-p*p,W=(e[v]-h)*2*p,$===0&&W===0&&($=c*d*(Math.abs(N)+Math.abs(p)+Math.abs(S)+Math.abs(T)+Math.abs(_))),U=po(S*g-_*C+p*O,S*w-_*O-p*C,$,W),n.set(v,s-1,U[0]),n.set(v,s,U[1]),Math.abs(S)>Math.abs(_)+Math.abs(p)?(n.set(v+1,s-1,(-C-N*n.get(v,s-1)+p*n.get(v,s))/S),n.set(v+1,s,(-O-N*n.get(v,s)-p*n.get(v,s-1))/S)):(U=po(-g-T*n.get(v,s-1),-w-T*n.get(v,s),_,p),n.set(v+1,s-1,U[0]),n.set(v+1,s,U[1]))),F=Math.max(Math.abs(n.get(v,s-1)),Math.abs(n.get(v,s))),c*F*F>1)for(x=v;x<=s;x++)n.set(x,s-1,n.get(x,s-1)/F),n.set(x,s,n.get(x,s)/F)}for(v=0;v<i;v++)if(v<a||v>l)for(x=v;x<i;x++)r.set(v,x,n.get(v,x));for(x=i-1;x>=a;x--)for(v=a;v<=l;v++){for(_=0,b=a;b<=Math.min(x,l);b++)_=_+r.get(v,b)*n.get(b,x);r.set(v,x,_)}}}function po(i,t,e,r){let n,s;return Math.abs(e)>Math.abs(r)?(n=r/e,s=e+n*r,[(i+n*t)/s,(t-n*i)/s]):(n=e/r,s=r+n*e,[(n*i+t)/s,(n*t-i)/s])}class ih{constructor(t){if(t=vr.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,n=new dt(r,r),s=!0,a,l,c;for(l=0;l<r;l++){let f=0;for(c=0;c<l;c++){let d=0;for(a=0;a<c;a++)d+=n.get(c,a)*n.get(l,a);d=(e.get(l,c)-d)/n.get(c,c),n.set(l,c,d),f=f+d*d}for(f=e.get(l,l)-f,s&=f>0,n.set(l,l,Math.sqrt(Math.max(f,0))),c=l+1;c<r;c++)n.set(l,c,0)}this.L=n,this.positiveDefinite=!!s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=vr.checkMatrix(t);let e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let n=t.columns,s=t.clone(),a,l,c;for(c=0;c<r;c++)for(l=0;l<n;l++){for(a=0;a<c;a++)s.set(c,l,s.get(c,l)-s.get(a,l)*e.get(c,a));s.set(c,l,s.get(c,l)/e.get(c,c))}for(c=r-1;c>=0;c--)for(l=0;l<n;l++){for(a=c+1;a<r;a++)s.set(c,l,s.get(c,l)-s.get(a,l)*e.get(a,c));s.set(c,l,s.get(c,l)/e.get(c,c))}return s}get lowerTriangularMatrix(){return this.L}}class sh{constructor(t,e={}){t=vr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:s=1e3,terminationCriteria:a=1e-10}=e;let l;if(r){if(fr.isAnyArray(r)&&typeof r[0]=="number"?r=dt.columnVector(r):r=vr.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");l=r.getColumnVector(0)}else l=t.getColumnVector(0);let c=1,f,d,h,p;for(let g=0;g<s&&c>a;g++)h=t.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),h=h.div(h.norm()),f=t.mmul(h).div(h.transpose().mmul(h).get(0,0)),g>0&&(c=f.clone().sub(p).pow(2).sum()),p=f.clone(),r?(d=r.transpose().mmul(f).div(f.transpose().mmul(f).get(0,0)),d=d.div(d.norm()),l=r.mmul(d).div(d.transpose().mmul(d).get(0,0))):l=f;if(r){let g=t.transpose().mmul(f).div(f.transpose().mmul(f).get(0,0));g=g.div(g.norm());let w=t.clone().sub(f.clone().mmul(g.transpose())),_=l.transpose().mmul(f).div(f.transpose().mmul(f).get(0,0)),y=r.clone().sub(f.clone().mulS(_.get(0,0)).mmul(d.transpose()));this.t=f,this.p=g.transpose(),this.w=h.transpose(),this.q=d,this.u=l,this.s=f.transpose().mmul(f),this.xResidual=w,this.yResidual=y,this.betas=_}else this.w=h.transpose(),this.s=f.transpose().mmul(f).sqrt(),n?this.t=f.clone().div(this.s.get(0,0)):this.t=f,this.xResidual=t.sub(f.mmul(h.transpose()))}}kt.AbstractMatrix=$t,kt.CHO=ih,kt.CholeskyDecomposition=ih,kt.DistanceMatrix=lo,kt.EVD=nh;var $w=kt.EigenvalueDecomposition=nh;kt.LU=fo,kt.LuDecomposition=fo;var oh=kt.Matrix=dt;kt.MatrixColumnSelectionView=mw,kt.MatrixColumnView=_w,kt.MatrixFlipColumnView=gw,kt.MatrixFlipRowView=vw,kt.MatrixRowSelectionView=yw,kt.MatrixRowView=ww,kt.MatrixSelectionView=co,kt.MatrixSubView=Dw,kt.MatrixTransposeView=bw,kt.NIPALS=sh,kt.Nipals=sh,kt.QR=Ka,kt.QrDecomposition=Ka,kt.SVD=Si,kt.SingularValueDecomposition=Si,kt.SymmetricMatrix=ti,kt.WrapperMatrix1D=eh,kt.WrapperMatrix2D=vr,kt.correlation=Sw,kt.covariance=Nw;var ah=kt.default=dt;kt.determinant=ho,kt.inverse=Ew,kt.linearDependencies=Fw,kt.pseudoInverse=Mw,kt.solve=rh,kt.wrap=xw;const uh=$w,lh=oh;ah.Matrix&&ah.Matrix;class Lw{constructor(t){L(this,"_errorListener");this._errorListener=t}new({rows:t,columns:e,initial_value:r}={}){return new Ga(t,e,r,this._errorListener)}avg({id:t}){return t==null?void 0:t.avg()}col({id:t,column:e}){return t==null?void 0:t.col({column:e})}det({id:t}){return t==null?void 0:t.det()}get({id:t,row:e,column:r}){return t==null?void 0:t.get({row:e,column:r})}inv({id:t}){return t==null?void 0:t.inv()}max({id:t}){return t==null?void 0:t.max()}min({id:t}){return t==null?void 0:t.min()}pow({id:t,power:e}){return t==null?void 0:t.pow({power:e})}row({id:t,row:e}){return t==null?void 0:t.row({row:e})}set({id:t,row:e,column:r,value:n}){t==null||t.set({row:e,column:r,value:n})}sum({id1:t,id2:e}){return t==null?void 0:t.sum({id2:e})}copy({id:t}){return t==null?void 0:t.copy()}diff({id1:t,id2:e}){return t==null?void 0:t.diff({id2:e})}rows({id:t}){return t==null?void 0:t.rows()}columns({id:t}){return t==null?void 0:t.columns()}fill({id:t,value:e,from_row:r,to_row:n,from_column:s,to_column:a}){t==null||t.fill({value:e,from_row:r,to_row:n,from_column:s,to_column:a})}kron({id1:t,id2:e}){return t==null?void 0:t.kron({id2:e})}mode({id:t}){return t==null?void 0:t.mode()}mult({id1:t,id2:e}){return t==null?void 0:t.mult({id2:e})}pinv({id:t}){return t==null?void 0:t.pinv()}rank({id:t}){return t==null?void 0:t.rank()}sort({id:t,column:e,order:r}){t==null||t.sort({column:e,order:r})}trace({id:t}){return t==null?void 0:t.trace()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}median({id:t}){return t==null?void 0:t.median()}add_col({id:t,column:e,array_id:r}){t==null||t.add_col({column:e,array_id:r})}add_row({id:t,row:e,array_id:r}){t==null||t.add_row({row:e,array_id:r})}is_zero({id:t}){return t==null?void 0:t.is_zero()}reshape({id:t,rows:e,columns:r},n){return t==null?void 0:t.reshape({rows:e,columns:r},n)}reverse({id:t}){t==null||t.reverse()}is_binary({id:t}){return t==null?void 0:t.is_binary()}is_square({id:t}){return t==null?void 0:t.is_square()}submatrix({id:t,from_row:e,to_row:r,from_column:n,to_column:s}){return t==null?void 0:t.submatrix({from_row:e,to_row:r,from_column:n,to_column:s})}swap_rows({id:t,row1:e,row2:r}){t==null||t.swap_rows({row1:e,row2:r})}transpose({id:t}){return t==null?void 0:t.transpose()}remove_col({id:t,column:e}){return t==null?void 0:t.remove_col({column:e})}remove_row({id:t,row:e}){return t==null?void 0:t.remove_row({row:e})}eigenvalues({id:t}){return t==null?void 0:t.eigenvalues()}is_diagonal({id:t}){return t==null?void 0:t.is_diagonal()}is_identity({id:t}){return t==null?void 0:t.is_identity()}eigenvectors({id:t}){return t==null?void 0:t.eigenvectors()}is_symmetric({id:t}){return t==null?void 0:t.is_symmetric()}swap_columns({id:t,column1:e,column2:r}){t==null||t.swap_columns({column1:e,column2:r})}is_stochastic({id:t}){return t==null?void 0:t.is_stochastic()}is_triangular({id:t}){return t==null?void 0:t.is_triangular()}elements_count({id:t}){return t==null?void 0:t.elements_count()}is_antidiagonal({id:t}){return t==null?void 0:t.is_antidiagonal()}is_antisymmetric({id:t}){return t==null?void 0:t.is_antisymmetric()}}class Ga{constructor(t=0,e=0,r=void 0,n){L(this,"_matrixInstance");L(this,"_errorListener");this._matrixInstance=this._createMatrix(t,e,r),this._errorListener=n}get _matrixArray(){return this._matrixInstance.map(t=>[...t._value])}get _value(){return this._matrixInstance}set _value(t){this._matrixInstance=t}get isMatrix(){return!0}_createMatrix(t,e,r){return Array.from(new Array(t),()=>new Qt(e,r,this._errorListener))}avg(){let t=0,e=0;for(const n of this._matrixInstance)for(const s of n._value)t+=_t(s)?0:s,e+=1;return t/e}col({column:t}){const e=[],r=new Qt(0,void 0,this._errorListener);if(_t(t))return r;for(const n of this._matrixInstance)e.push(n._value[t]);return r._value=e,r}det(){return Kf(this._matrixArray)}get({row:t,column:e}){var r,n;if(!(_t(t)||_t(e)))return(n=(r=this._matrixInstance[t])==null?void 0:r._value)==null?void 0:n[e]}inv(){const t=so(this._matrixArray);return this._newMatrix(t)}max(){return O1(this._matrixArray)}min(){return ja(this._matrixArray)}pow({power:t}){const e=_t(t)?this._matrixArray:I1(this._matrixArray,t);return this._newMatrix(e)}row({row:t}){return _t(t)?new Qt(0,void 0,this._errorListener):this._matrixInstance[t]}set({row:t,column:e,value:r}){_t(t)||_t(e)||this._matrixInstance[t].set({index:e,value:r})}sum({id2:t}){const e=ss(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=A1(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}rows(){return this._matrixInstance.length}columns(){return this._matrixArray.length&&this._matrixArray[0].length}fill({value:t,from_row:e,to_row:r,from_column:n,to_column:s}={}){_t(e)&&(e=0),_t(r)&&(r=this.rows()),_t(n)&&(n=0),_t(s)&&(s=this.columns());for(const[a,l]of this._matrixInstance.entries())for(const[c]of l._value.entries())a<r&&a>=e&&c>=n&&c<s&&l.set({index:c,value:t})}kron({id2:t}){const e=x1(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return ja(qf(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=Ci(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=B1(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t,order:e=Kn.ascending}={}){_t(t)&&(t=0),this._matrixInstance.sort((r,n)=>{const s=r._value[t],a=n._value[t];return e!==Kn.descending?s-a:a-s})}trace(){return S1(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return Gf(this._matrixArray)}add_col({column:t,array_id:e}={}){_t(t)&&(t=this.columns());for(const[r,n]of this._matrixInstance.entries())n.insert({index:t,value:e?e._value[r]:void 0})}add_row({row:t,array_id:e}){_t(t)&&(t=this.rows()),this._matrixInstance.splice(t,0,e||new Qt(this.columns(),void 0,this._errorListener))}is_zero(){return this._matrixArray.every(t=>t.every(e=>e===0))}reshape({rows:t=0,columns:e=0},r){if(t*e!==this.columns()*this.rows()){this._errorListener.addError(ce.matrixRehapeErr,r,zt.Error);return}const n=w1(this._matrixArray,[t,e]);this._matrixInstance=n.map(s=>{const a=new Qt(0,void 0,this._errorListener);return a._value=[...s],a})}reverse(){this._matrixInstance.reverse();for(const t of this._matrixInstance)t.reverse()}is_binary(){return this._matrixArray.every(t=>t.every(e=>e===0||e===1))}is_square(){return this.rows()===this.columns()}submatrix({from_row:t,to_row:e,from_column:r,to_column:n}={}){_t(t)&&(t=0),_t(e)&&(e=this.rows()),_t(r)&&(r=0),_t(n)&&(n=this.columns());const s=this._matrixArray.splice(t,e),a=[];for(const l of s)a.push(l.splice(r,n));return this._newMatrix(a)}swap_rows({row1:t,row2:e}){if(_t(t)||_t(e))return;const r=this._matrixInstance[t],n=this._matrixInstance[e];this._matrixInstance[t]=n,this._matrixInstance[e]=r}transpose(){const t=Wf(this._matrixArray);return this._newMatrix(t)}remove_col({column:t}={}){_t(t)&&(t=this.columns());const e=[];for(const n of this._matrixInstance){const s=n._value.splice(t,1);e.push(s[0])}const r=new Qt(0,void 0,this._errorListener);return r._value=e,r}remove_row({row:t}={}){return _t(t)&&(t=this.rows()),this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new uh(new lh(this._matrixArray)),e=new Qt(0,void 0,this._errorListener);return e._value=t.realEigenvalues,e}is_diagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<e;s++)if(n!==s&&r[n][s]!==0)return!1;return!0}is_identity(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<e;s++)if(n!==s&&r[n][s]!==0||n===s&&r[n][s]!==1)return!1;return!0}eigenvectors(){const t=new uh(new lh(this._matrixArray));return this._newMatrix(t.eigenvectorMatrix.to2DArray())}is_symmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=n+1;s<e;s++)if(r[n][s]!==r[s][n])return!1;return!0}swap_columns({column1:t,column2:e}){if(!(_t(t)||_t(e)))for(const r of this._matrixInstance){const n=r._value[t],s=r._value[e];r.set({index:t,value:s}),r.set({index:e,value:n})}}is_stochastic(){const t=this._matrixArray;for(let e=0;e<t.length;e++){let r=0;for(let n=0;n<t[e].length;n++){if(t[e][n]<0)return!1;r+=t[e][n]}if(Math.abs(r-1)>Number.EPSILON)return!1}return!0}is_triangular(){const t=this.rows(),e=this.columns();return t!==e?!1:this._isUpperTriangular(t)||this._isLowerTriangular(t)}elements_count(){return y1(this._matrixArray)}is_antidiagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<t;s++)if(n+s!==t-1&&r[n][s]!==0)return!1;return!0}is_antisymmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<t;s++)if(n!==s&&r[n][s]!==-r[s][n])return!1;return!0}_isUpperTriangular(t){const e=this._matrixArray;for(let r=1;r<t;r++)for(let n=0;n<r;n++)if(e[r][n]!==0)return!1;return!0}_isLowerTriangular(t){const e=this._matrixArray;for(let r=0;r<t-1;r++)for(let n=r+1;n<t;n++)if(e[r][n]!==0)return!1;return!0}_newMatrix(t){const e=new Ga(0,0,void 0,this._errorListener);return e._value=t.map(r=>{const n=new Qt(0,void 0,this._errorListener);return n._value=[...r],n}),e}_matrixRank(t){let e=0;const r=t.length,n=t[0].length,s=[...t].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let l=a;for(;l<r&&s[l][a]===0;)l++;if(l===r)continue;if(l!==a){const f=s[l];s[l]=s[a],s[a]=f}const c=s[a][a];for(let f=0;f<n;f++)s[a][f]/=c;for(let f=a+1;f<r;f++){const d=s[f][a];s[f]=s[f].map((h,p)=>h-d*s[a][p]),s[f][a]=0}}for(let a=0;a<r;a++)s[a].some(l=>Number(l.toFixed(8))!==0)&&e++;return e}}class Rw{constructor(t){L(this,"_variables");L(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){if(!t)return!0;const r=tn(t),n=tn(this._variables.timeframe.period);if(r<n)return!0;const s=`change_${e}`,a=this._cacheData[s],l=this._variables.time;if(a){if(a.offset){if(a.currentTime+a.offset<=l)return this._cacheData[s]={currentTime:l,offset:0},!0}else if(a.currentTime+r*1e3<=l)return this._cacheData[s]={currentTime:l,offset:0},!0}else{const c=this._calcTimeOffset(l,t);return this._cacheData[s]={currentTime:l,offset:c},!1}return!1}in_seconds({timeframe:t}={}){return tn(t||this._variables.timeframe.period)}from_seconds({seconds:t=0}){const e=t*1e3,r=ee.duration(e);if(r.years())return"12M";const s=r.asMonths();if(no(s))return`${s}M`;const a=r.asWeeks();if(no(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 f=r.asSeconds();return f<=1?"1S":f<=5?"5S":f<=10?"10S":f<=15?"15S":f<=30?"30S":"1"}_calcTimeOffset(t,e){let r=0;if(e.includes("W")){const l=ee(t).day();e="1D",l!==1&&(r=(8-l)*60*60*24*1e3)}else if(e.includes("M")){const l=ee(t).date();e="1D";const c=ee(t).daysInMonth();l!==1&&(r=(c-l+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(t,e),s=tn(e)*1e3,a=t-n-Math.floor((t-n)/s)*s;return r?r-a:a}}class Pw{constructor(t,e){L(this,"_errorListener");L(this,"_intlNumberFormatter");L(this,"_precision");this._errorListener=t,this._precision=e,this._intlNumberFormatter=new Intl.NumberFormat("en",{notation:"compact"})}pos({source:t="",str:e=""}){return t==null?void 0:t.indexOf(e)}trim({source:t=""}){return t==null?void 0:t.trim()}lower({source:t=""}){return t==null?void 0:t.toLocaleLowerCase()}match({source:t="",regex:e=""}){const r=t==null?void 0:t.match(new RegExp(e));return r?r[0]:""}split({string:t="",separator:e=""}){const r=t==null?void 0:t.split(e),n=new Qt;return n._value=r||[],n}upper({source:t=""}){return t==null?void 0:t.toLocaleUpperCase()}format({formatString:t=""},e){return this._strFormat(t,e)}length({string:t=""}){return t==null?void 0:t.length}repeat({source:t="",repeat:e,separator:r=""},n){if(_t(e)){this._errorListener.addError(ce.arrLenErr,n,zt.Error);return}return Array.from(new Array(e),()=>t).join(r)}replace({source:t="",target:e="",replacement:r="",occurrence:n}){_t(n)&&(n=0);let s=-1;for(let a=0;a<n+1&&(s=t.indexOf(e,s+1),s!==-1);a++);return s!==-1?t.substring(0,s)+r+t.substring(s+e.length):t}contains({source:t="",str:e=""}){return t==null?void 0:t.includes(e)}endswith({source:t="",str:e=""}){return t==null?void 0:t.endsWith(e)}tonumber({string:t=""}){if(/[^\d.]/.test(t))return;const e=parseFloat(t);return isNaN(e)?void 0:e}tostring({value:t,format:e}){if(t===void 0)return"NaN";if(typeof t=="object"){if(t.isArray)return this._arrToStr(t._value,e);if(t.isMatrix){const r=[];for(const n of t._matrixArray)r.push(this._arrToStr(n,e));return r.join(`
62
- `)}}if(typeof t=="string")return t;if(typeof t=="boolean")return String(t);if(typeof t=="number")return String(this._toStringFormat(t,e==null?void 0:e.replace(/0/g,"#")))}_arrToStr(t,e){return`[${t.map(n=>typeof n=="number"?this._toStringFormat(n,e):n).toString()}]`}substring({source:t="",begin_pos:e=0,end_pos:r}){return _t(e)&&(e=0),_t(r)&&(r=void 0),t==null?void 0:t.substring(e,r)}startswith({source:t="",str:e=""}){return t==null?void 0:t.startsWith(e)}format_time({time:t,format:e="yyyy-MM-dd'T'HH:mm:ssZ",timezone:r}){return _t(t)&&(t=0),qr(t,r).format(e)}replace_all({source:t="",target:e="",replacement:r=""}){return t==null?void 0:t.replace(new RegExp(e,"g"),r)}_toStringFormat(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case Kt.mintick:return t.toFixed(this._precision);case Kt.percent:return`${t}%`;case Kt.volume:return this._intlNumberFormatter.format(Math.round(t));default:return this._formatOthers(t,e)}}_formatOthers(t,e){var l;let[r,n]=e.split(".");e.split("%").length===2&&(t=t*100);let[s,a=""]=String(t).split(".");if(r.includes("#")){if(r.includes(",")){const c=r.split(","),f=((l=c[c.length-1])==null?void 0:l.replace(/[^#]/g,"").length)||0;f&&(s=s.replace(new RegExp(`\\B(?=(\\d{${f}})+(?!\\d))`,"g"),",")),r=c.join("")}s=r.replace(/#/,s).replace(/#/g,"")}else s=`${r}${s}`;if(n&&n.includes("#")){const c=n.split("#").length-1,f=+`${s}.${a}`;if(!isNaN(f))return`${f.toFixed(c)}${n.replace(/#/g,"")}`;a=`${a.substring(0,c)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${s}.${a}`:s}_formatNumber(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case"integer":return String(Math.round(t));case"currency":return`$${t}`;case"percent":return`${t*100}%`;default:return this._formatOthers(t,e)}}_strFormat(t,e){let r=t;for(const[n,s]of e.entries()){if(s===void 0||typeof s=="number"&&isNaN(s)){r="NaN";continue}if(typeof s=="number"){const a=`\\{\\s*${n}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,l=t.match(new RegExp(a));if(l){const c=l[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(s,c)))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(s))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),s)}return r}}class zw{constructor(t){L(this,"_errorListener");this._errorListener=t}new(){return new Ha(this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}get({id:t,key:e}){return t==null?void 0:t.get({key:e})}put({id:t,key:e,value:r}){return t==null?void 0:t.put({key:e,value:r})}keys({id:t}){return t==null?void 0:t.keys()}size({id:t}){return t==null?void 0:t.size()}clear({id:t}){t==null||t.clear()}remove({id:t,key:e}){return t==null?void 0:t.remove({key:e})}values({id:t}){return t==null?void 0:t.values()}put_all({id:t,id2:e}){t==null||t.put_all({id2:e})}contains({id:t,key:e}){return t==null?void 0:t.contains({key:e})}}class Ha{constructor(t){L(this,"_errorListener");L(this,"_mapInstance");this._errorListener=t,this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new Ha(this._errorListener);return e._mapInstance=new Map(t.entries()),e}copy(){return this._copyMap(this._mapInstance)}get({key:t}){return this._mapInstance.get(t)}put({key:t,value:e}){return this._mapInstance.set(t,e)}keys(){const t=new Qt(0,void 0,this._errorListener);return t._value=[...this._mapInstance.keys()],t}size(){return this._mapInstance.size}clear(){this._mapInstance.clear()}remove({key:t}){const e=this._mapInstance.get(t);return this._mapInstance.delete(t),e||void 0}values(){const t=new Qt(0,void 0,this._errorListener);return t._value=[...this._mapInstance.values()],t}put_all({id2:t}){this._mapInstance=new Map([...this._mapInstance,...t._mapInstance])}contains({key:t}){return this._mapInstance.has(t)}}class kw{constructor(t){L(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Oi(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Oi(t,r,e)}copy({id:t}){return t==null?void 0:t.copy()}from_index({price:t,index:e}){return new Oi(t,e)}from_time({price:t,time:e}){return new Oi(t,void 0,e)}}class Oi{constructor(t,e,r){L(this,"_index");L(this,"_price");L(this,"_time");this._index=e,this._price=t,this._time=r}get index(){return this._index}set index(t){this._index=t}get price(){return this._price}set price(t){this._price=t}get time(){return this._time}set time(t){this._time=t}copy(){return new Oi(this._price,this._index,this._time)}}class qw{constructor(t,e){L(this,"_variables");L(this,"_errorListener");L(this,"_defaultLabel",{text:"",xloc:De.bar_index,yloc:jr.price,size:ir.normal,style:ve.styleLabelDown,textalign:Wt.alignCenter});this._variables=t,this._errorListener=e}new(t,e){const{time:r,high:n,low:s,bar_index:a}=this._variables,l=`label_${e}_${a}`;ge(t,["color","textcolor"]);const c={...this._defaultLabel,...t,id:l,time:r,high:n,low:s,bar_index:a};t.point&&(c.x=c.xloc===De.bar_index?t.point.index:t.point.time,c.y=t.point.price),c.yloc===jr.abovebar?c.y=n:c.yloc===jr.belowbar&&(c.y=s),this._verfiyArgs(t,e);const f=new _o(l,this._variables,this._errorListener);return e.startsWith("export")||this._variables.label.add(l,c,f),f}_verfiyArgs(t,e){const{xloc:r,yloc:n,style:s,size:a,textalign:l,text_font_family:c}=t,f="label.new";this._paramVerfiy(s,e,f,Object.values(ve),"style"),this._paramVerfiy(r,e,f,Object.values(De),"xloc"),this._paramVerfiy(n,e,f,Object.values(jr),"yloc"),this._paramVerfiy(a,e,f,Object.values(ir),"size"),this._paramVerfiy(l,e,f,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign"),this._paramVerfiy(c,e,f,Object.values(Gn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}label(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}get_x({id:t},e){return t==null?void 0:t.get_x(e)}get_y({id:t},e){return t==null?void 0:t.get_y(e)}set_x({id:t,...e},r){t==null||t.set_x(e,r)}set_y({id:t,...e},r){t==null||t.set_y(e,r)}delete({id:t}){t==null||t.delete()}get_text({id:t},e){return t==null?void 0:t.get_text(e)}set_xy({id:t,...e},r){t==null||t.set_xy(e,r)}set_size({id:t,...e},r){t==null||t.set_size(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}set_yloc({id:t,...e},r){t==null||t.set_yloc(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_tooltip({id:t,...e},r){t==null||t.set_tooltip(e,r)}set_point({id:t,...e},r){t==null||t.set_point(e,r)}set_text({id:t,...e},r){t==null||t.set_text(e,r)}set_textcolor({id:t,...e},r){t==null||t.set_textcolor(e,r)}set_textalign({id:t,...e},r){t==null||t.set_textalign(e,r)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class _o{constructor(t,e,r){L(this,"_id");L(this,"_variables");L(this,"_errorListener");L(this,"_suffix","");this._id=t,this._variables=e,this._errorListener=r}get type(){return Me.LABEL}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.label.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`label_${t}_${e}`,n=this._getLabel(t),s=new _o(r,this._variables,this._errorListener);if(n){const a={...n,id:r,bar_index:e};this._variables.label.add(r,a,s)}return s}get_x(t){var e;return(e=this._getLabel(t))==null?void 0:e.x}get_y(t){var e;return(e=this._getLabel(t))==null?void 0:e.y}set_x({x:t},e){const r=this._getLabel(e);r&&(r.x=t)}set_y({y:t},e){const r=this._getLabel(e);r&&(r.y=t)}delete(){this._variables.label.delete(this._id)}set_xy({x:t,y:e},r){const n=this._getLabel(r);n&&(n.x=t,n.y=e)}get_text(t){var e;return(e=this._getLabel(t))==null?void 0:e.text}set_size({size:t},e){const r=this._getLabel(e);r&&(r.size=t),this._paramVerfiy(t,e,"label.set_size",Object.values(ir),"size")}set_text({text:t},e){const r=this._getLabel(e);r&&(r.text=t)}set_xloc({x:t,xloc:e},r){const n=this._getLabel(r);n&&(n.x=t,n.xloc=e,this._paramVerfiy(e,r,"label.set_xloc",Object.values(De),"xloc"))}set_yloc({yloc:t},e){const r=this._getLabel(e),{high:n,low:s}=this._variables;r&&(r.yloc=t,t===jr.abovebar?r.y=n:t===jr.belowbar&&(r.y=s),this._paramVerfiy(t,e,"label.set_yloc",Object.values(jr),"yloc"))}set_color(t,e){const r=this._getLabel(e);ge(t,["color"]),r&&(r.color=t.color)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===De.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,r.y=t==null?void 0:t.price)}set_style({style:t},e){const r=this._getLabel(e);r&&(r.style=t),this._paramVerfiy(t,e,"label.set_style",Object.values(ve),"style")}set_tooltip({tooltip:t},e){const r=this._getLabel(e);r&&(r.tooltip=t)}set_textalign({textalign:t},e){const r=this._getLabel(e);r&&(r.textalign=t),this._paramVerfiy(t,e,"label.set_textalign",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign")}set_textcolor(t,e){const r=this._getLabel(e);ge(t,["textcolor"]),r&&(r.textcolor=t.textcolor)}set_text_font_family({text_font_family:t},e){const r=this._getLabel(e);r&&(r.text_font_family=t),this._paramVerfiy(t,e,"label.set_text_font_family",Object.values(Gn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const Uw={freq_all:Ur.freqAll,freq_once_per_bar:Ur.freqOncePerBar,freq_once_per_bar_close:Ur.freqOncePerBarClose},Ww={gaps_off:Xi.gapsOff,gaps_on:Xi.gapsOn,lookahead_off:Xi.lookaheadOff,lookahead_on:Xi.lookaheadOn},Bi={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"},ch={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"},jw={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},fh={all:[Ke.dataWindow,Ke.pane,Ke.priceScale,Ke.statusLine],data_window:[Ke.dataWindow],none:[],pane:[Ke.pane],price_scale:[Ke.priceScale],status_line:[Ke.statusLine]},Vw={both:Wr.both,left:Wr.left,none:Wr.none,right:Wr.right},Yw={inherit:Kt.inherit,mintick:Kt.mintick,percent:Kt.percent,price:Kt.price,volume:Kt.volume},Zw={style_solid:Ms.styleSolid,style_dashed:Ms.styleDashed,style_dotted:Ms.styleDotted},Kw={style_arrowdown:ve.styleArrowdown,style_arrowup:ve.styleArrowup,style_circle:ve.styleCircle,style_cross:ve.styleCross,style_diamond:ve.styleDiamond,style_flag:ve.styleFlag,style_label_center:ve.styleLabelCenter,style_label_down:ve.styleLabelDown,style_label_left:ve.styleLabelLeft,style_label_lower_left:ve.styleLabelLowerLeft,style_label_lower_right:ve.styleLabelLowerRight,style_label_right:ve.styleLabelRight,style_label_up:ve.styleLabelUp,style_label_upper_left:ve.styleLabelUpperLeft,style_label_upper_right:ve.styleLabelUpperRight,style_none:ve.styleNone,style_square:ve.styleSquare,style_text_outline:ve.styleTextOutline,style_triangledown:ve.styleTriangledown,style_triangleup:ve.styleTriangleup,style_xcross:ve.styleXcross},Gw={style_arrow_both:Re.styleArrowBoth,style_arrow_left:Re.styleArrowLeft,style_arrow_right:Re.styleArrowRight,style_dashed:Re.styleDashed,style_dotted:Re.styleDotted,style_solid:Re.styleSolid},Hw={abovebar:ln.abovebar,absolute:ln.absolute,belowbar:ln.belowbar,bottom:ln.bottom,top:ln.top},Jw={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},Xw={style_area:Nr.styleArea,style_areabr:Nr.styleAreabr,style_circles:Nr.styleCircles,style_columns:Nr.styleColumns,style_cross:Nr.styleCross,style_histogram:Nr.styleHistogram,style_line:Nr.styleLine,style_linebr:Nr.styleLinebr,style_stepline:Nr.styleStepline,style_stepline_diamond:Nr.styleSteplineDiamond,style_steplinebr:Nr.styleSteplinebr},Qw={bottom_center:mr.bottomCenter,bottom_left:mr.bottomLeft,bottom_right:mr.bottomRight,middle_center:mr.middleCenter,middle_left:mr.middleLeft,middle_right:mr.middleRight,top_center:mr.topCenter,top_left:mr.topLeft,top_right:mr.topRight},ty={left:Ns.left,none:Ns.none,right:Ns.right},ey={arrowdown:lr.arrowdown,arrowup:lr.arrowup,circle:lr.circle,cross:lr.cross,diamond:lr.diamond,flag:lr.flag,labeldown:lr.labeldown,labelup:lr.labelup,square:lr.square,triangledown:lr.triangledown,triangleup:lr.triangleup,xcross:lr.xcross},ry={auto:ir.auto,huge:ir.huge,large:ir.large,normal:ir.normal,small:ir.small,tiny:ir.tiny},ny={cash:Pe.cash,fixed:Pe.fixed,percent_of_equity:Pe.percentOfEquity,commission:{cash_per_contract:je.cashPerContract,cash_per_order:je.cashPerOrder,percent:je.percent},direction:{all:se.all,long:se.long,short:se.short},oca:{cancel:cn.cancel,none:cn.none,reduce:cn.reduce}},iy={align_bottom:Wt.alignBottom,align_center:Wt.alignCenter,align_left:Wt.alignLeft,align_right:Wt.alignRight,align_top:Wt.alignTop,wrap_auto:Wt.wrapAuto,wrap_none:Wt.wrapNone},sy={bar_index:De.bar_index,bar_time:De.bar_time},oy={abovebar:jr.abovebar,belowbar:jr.belowbar,price:jr.price},ay={actual:Ss.actual,estimate:Ss.estimate,standardized:Ss.standardized};class hh{constructor(){L(this,"adjustment",{dividends:Fs.dividends,none:Fs.none,splits:Fs.splits});L(this,"alert",Uw);L(this,"barmerge",Ww);L(this,"color",Bi);L(this,"currency",ch);L(this,"dayofweek",jw);L(this,"earnings",ay);L(this,"display",fh);L(this,"extend",Vw);L(this,"font",{family_default:Gn.familyDefault,family_monospace:Gn.familyMonospace});L(this,"format",Yw);L(this,"hline",Zw);L(this,"label",Kw);L(this,"line",Gw);L(this,"location",Hw);L(this,"math",Jw);L(this,"order",{ascending:Kn.ascending,descending:Kn.descending});L(this,"plot",Xw);L(this,"position",Qw);L(this,"scale",ty);L(this,"session",{extended:gi.extended,regular:gi.regular});L(this,"shape",ey);L(this,"size",ry);L(this,"splits",{denominator:"denominator",numerator:"numerator"});L(this,"strategy",ny);L(this,"text",iy);L(this,"xloc",sy);L(this,"yloc",oy)}updateData(){}}class uy{constructor(t,e){L(this,"_variables");L(this,"_errorListener");L(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:De.bar_index,line_color:Bi.blue,line_style:Re.styleSolid,line_width:1});this._variables=t,this._errorListener=e}new(t,e){var l;const{bar_index:r}=this._variables,n=`polyline_${e}_${r}`,s=Object.assign({},this._defaultPolyline,t,{id:n,bar_index:r,points:(l=t.points)==null?void 0:l._value.map(c=>({time:c.time,index:c.index,price:c.price}))});ge(s,["line_color","fill_color"]);const a=new dh(n,this._variables);return this._verfiyArgs(t,e),e.startsWith("export")||this._variables.polyline.add(n,s,a),a}_verfiyArgs(t,e){const{line_style:r,xloc:n}=t,s="polyline.new";this._paramVerfiy(r,e,s,Object.values(Re),"line_style"),this._paramVerfiy(n,e,s,Object.values(De),"xloc")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}delete({id:t}){t&&t.delete()}}class dh{constructor(t,e){L(this,"_id");L(this,"_variables");L(this,"_suffix");this._variables=e,this._id=t}get type(){return Me.POLYLINE}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.polyline.get(this._id)}delete(){this._variables.polyline.delete(this._id)}}class ly{constructor(t,e){L(this,"_variables");L(this,"_errorListener");L(this,"_defaultLine",{xloc:De.bar_index,extend:Wr.none,style:Re.styleSolid});this._variables=t,this._errorListener=e}new({first_point:t,second_point:e,...r},n){const{bar_index:s}=this._variables,a=`line_${n}_${s}`;ge(r,["color"]);const l={...this._defaultLine,...r,id:a,bar_index:s};if(t&&e){const f=l.xloc===De.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,d=l.xloc===De.bar_index?e==null?void 0:e.index:e==null?void 0:e.time;Object.assign(l,{x1:f,y1:t==null?void 0:t.price,x2:d,y2:e==null?void 0:e.price})}this._verfiyArgs(r,n);const c=new mo(a,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(a,l,c),c}_verfiyArgs(t,e){const{extend:r,xloc:n,style:s}=t,a="line.new";this._paramVerfiy(s,e,a,Object.values(Re),"style"),this._paramVerfiy(r,e,a,Object.values(Wr),"extend"),this._paramVerfiy(n,e,a,Object.values(De),"xloc")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}line(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_x1({id:t},e){return t==null?void 0:t.get_x1(e)}get_x2({id:t},e){return t==null?void 0:t.get_x2(e)}get_y1({id:t},e){return t==null?void 0:t.get_y1(e)}get_y2({id:t},e){return t==null?void 0:t.get_y2(e)}set_x1({id:t,...e},r){t==null||t.set_x1(e,r)}set_x2({id:t,...e},r){t==null||t.set_x2(e,r)}set_y1({id:t,...e},r){t==null||t.set_y1(e,r)}set_y2({id:t,...e},r){t==null||t.set_y2(e,r)}set_xy1({id:t,...e},r){t==null||t.set_xy1(e,r)}set_xy2({id:t,...e},r){t==null||t.set_xy2(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}get_price({id:t,...e},r){return t==null?void 0:t.get_price(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_width({id:t,...e},r){t==null||t.set_width(e,r)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_first_point({id:t,...e},r){t==null||t.set_first_point(e,r)}set_second_point({id:t,...e},r){t==null||t.set_second_point(e,r)}}class mo{constructor(t,e,r){L(this,"_variables");L(this,"_id");L(this,"_suffix","");L(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get type(){return Me.LINE}get data(){return this._variables.line.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`line_${t}_${e}`,n=this._getLine(t),s=new mo(r,this._variables,this._errorListener);return n&&this._variables.line.add(r,{...n,id:r,bar_index:e,isVar:void 0},s),s}delete(){this._variables.line.delete(this._id)}get_price({x:t},e){const r=this._getLine(e);if(t===void 0)return t;if(r&&r.xloc===De.bar_index){const{x1:n,y1:s,x2:a,y2:l}=r;return n===void 0||a===void 0||s===void 0||l===void 0?void 0:(l-s)/(a-n)*(t-n)+s}}get_x1(t){var e;return(e=this._getLine(t))==null?void 0:e.x1}get_x2(t){var e;return(e=this._getLine(t))==null?void 0:e.x2}get_y1(t){var e;return(e=this._getLine(t))==null?void 0:e.y1}get_y2(t){var e;return(e=this._getLine(t))==null?void 0:e.y2}set_x1({x:t},e){const r=this._getLine(e);r&&(r.x1=t)}set_x2({x:t},e){const r=this._getLine(e);r&&(r.x2=t)}set_y1({y:t},e){const r=this._getLine(e);r&&(r.y1=t)}set_y2({y:t},e){const r=this._getLine(e);r&&(r.y2=t)}set_xy1({x:t,y:e},r){const n=this._getLine(r);n&&(n.x1=t,n.y1=e)}set_xy2({x:t,y:e},r){const n=this._getLine(r);n&&(n.x2=t,n.y2=e)}set_xloc({xloc:t,x1:e,x2:r},n){const s=this._getLine(n);s&&(s.xloc=t,s.x1=e,s.x2=r,this._paramVerfiy(t,n,"line.set_xloc",Object.values(De),"xloc"))}set_color(t,e){const r=this._getLine(e);r&&(ge(t,["color"]),r.color=t.color)}set_style({style:t},e){const r=this._getLine(e);r&&(r.style=t,this._paramVerfiy(t,e,"line.set_style",Object.values(Re),"style"))}set_width({width:t},e){const r=this._getLine(e);r&&(r.width=t)}set_extend({extend:t},e){const r=this._getLine(e);r&&(r.extend=t,this._paramVerfiy(t,e,"line.set_extend",Object.values(Wr),"extend"))}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},l=r.xloc===De.bar_index?n:s,c=a;l&&(r.x1=l),c&&(r.y1=c)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},l=r.xloc===De.bar_index?n:s,c=a;l&&(r.x2=l),c&&(r.y2=c)}}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class cy{constructor(t){L(this,"_variables");this._variables=t}new(t,e){const{line1:r,line2:n}=t,{bar_index:s}=this._variables,a=`linefill_${e}_${s}`,l=r==null?void 0:r.data,c=n==null?void 0:n.data;l&&(l.linefills=l.linefills||[],l.linefills.push(a)),c&&(c.linefills=c.linefills||[],c.linefills.push(a)),ge(t,["color"]);const f=new go(this._variables,a,r,n);return e.startsWith("export")||(l||c)&&this._variables.linefill.add(a,{line1:l,line2:c,color:t.color,id:a,bar_index:s},f),f}delete({id:t}){t==null||t.delete()}get_line1({id:t}){return t==null?void 0:t.get_line1()}get_line2({id:t}){return t==null?void 0:t.get_line2()}set_color({id:t,...e}){t==null||t.set_color(e)}}class go{constructor(t,e,r,n){L(this,"_id");L(this,"_line1");L(this,"_line2");L(this,"_variables");L(this,"_suffix");this._variables=t,this._id=e,this._line1=r,this._line2=n}get type(){return Me.LINEFILL}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.linefill.get(this._id)}linefill(t,e){return t.x?t.x:new go(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:s}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.filter(a=>a!==this._id)),s&&(s.linefills=(r=s.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id)}get_line1(){return this._line1}get_line2(){return this._line2}set_color(t){const e=this._variables.linefill.get(this._id);e&&(ge(t,["color"]),e.color=t.color)}}class fy{constructor(t,e){L(this,"_variables");L(this,"_errorListener");L(this,"_defaultBox",{border_color:Bi.blue,border_width:1,bgcolor:Bi.blue,xloc:De.bar_index,extend:Wr.none,style:Re.styleSolid,text:"",text_size:ir.auto,text_color:Bi.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_wrap:Wt.wrapNone});this._variables=t,this._errorListener=e}box({x:t}){return t}new({top_left:t,bottom_right:e,...r},n){const{bar_index:s}=this._variables,a=`box_${n}_${s}`,l={...this._defaultBox,...r,id:a,bar_index:s};if(ge(l,["border_color","bgcolor","text_color"]),t){const{price:f,time:d,index:h}=t;l.top=f,l.left=l.xloc===De.bar_index?h:d}if(e){const{price:f,time:d,index:h}=e;l.bottom=f,l.right=l.xloc===De.bar_index?h:d}this._verfiyArgs(r,n);const c=new vo(this._variables,a,this._errorListener);return n.startsWith("export")||this._variables.box.add(a,l,c),c}_verfiyArgs(t,e){const{border_style:r,extend:n,xloc:s,text_size:a,text_halign:l,text_valign:c,text_wrap:f,text_font_family:d}=t,h="box.new";this._paramVerfiy(r,e,h,[Re.styleDashed,Re.styleDotted,Re.styleSolid],"border_style"),this._paramVerfiy(n,e,h,Object.values(Wr),"extend"),this._paramVerfiy(s,e,h,Object.values(De),"xloc"),this._paramVerfiy(a,e,h,Object.values(ir),"text_size"),this._paramVerfiy(l,e,h,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"),this._paramVerfiy(c,e,h,[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"),this._paramVerfiy(f,e,h,[Wt.wrapAuto,Wt.wrapNone],"text_wrap"),this._paramVerfiy(d,e,h,Object.values(Gn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_top({id:t}){return t==null?void 0:t.get_top()}get_bottom({id:t}){return t==null?void 0:t.get_bottom()}get_left({id:t}){return t==null?void 0:t.get_left()}get_right({id:t}){return t==null?void 0:t.get_right()}set_top({id:t,...e}){t==null||t.set_top(e)}set_bottom({id:t,...e}){t==null||t.set_bottom(e)}set_text({id:t,...e}){t==null||t.set_text(e)}set_left({id:t,...e}){t==null||t.set_left(e)}set_right({id:t,...e}){t==null||t.set_right(e)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_bgcolor({id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({id:t,...e}){t==null||t.set_border_color(e)}set_border_width({id:t,...e}){t==null||t.set_border_width(e)}set_border_style({id:t,...e},r){t==null||t.set_border_style(e,r)}set_lefttop({id:t,...e}){t==null||t.set_lefttop(e)}set_rightbottom({id:t,...e}){t==null||t.set_rightbottom(e)}set_text_size({id:t,...e},r){t==null||t.set_text_size(e,r)}set_text_wrap({id:t,...e},r){t==null||t.set_text_wrap(e,r)}set_text_color({id:t,...e}){t==null||t.set_text_color(e)}set_text_halign({id:t,...e},r){t==null||t.set_text_halign(e,r)}set_text_valign({id:t,...e},r){t==null||t.set_text_valign(e,r)}set_top_left_point({id:t,...e}){t==null||t.set_top_left_point(e)}set_bottom_right_point({id:t,...e}){t==null||t.set_bottom_right_point(e)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class vo{constructor(t,e,r){L(this,"_id");L(this,"_variables");L(this,"_errorListener");L(this,"_suffix","");this._variables=t,this._id=e,this._errorListener=r}get type(){return Me.BOX}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.box.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`box_${t}_${e}`,n=this._getBox(),s=new vo(this._variables,r,this._errorListener);return n&&this._variables.box.add(r,{...n,id:r,bar_index:e},s),s}delete(){this._variables.box.delete(this._id)}get_top(){const t=this._getBox();return t&&t.top}set_top({top:t}){const e=this._getBox();e&&(e.top=t)}get_left(){const t=this._getBox();return t&&t.left}set_left({left:t}){const e=this._getBox();e&&(e.left=t)}set_text({text:t}){const e=this._getBox();e&&(e.text=t)}get_right(){const t=this._getBox();return t&&t.right}set_right({right:t}){const e=this._getBox();e&&(e.right=t)}get_bottom(){const t=this._getBox();return t&&t.bottom}set_bottom({bottom:t}){const e=this._getBox();e&&(e.bottom=t)}set_extend({extend:t},e){const r=this._getBox();r&&(r.extend=t,this._paramVerfiy(t,e,"box.set_extend",Object.values(Wr),"extend"))}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t,ge(e,["bgcolor"]))}set_lefttop({left:t,top:e}){const r=this._getBox();r&&(r.left=t,r.top=e)}set_text_size({text_size:t},e){const r=this._getBox();r&&(r.text_size=t,this._paramVerfiy(t,e,"box.set_text_size",Object.values(ir),"text_size"))}set_text_wrap({text_wrap:t},e){const r=this._getBox();r&&(r.text_wrap=t,this._paramVerfiy(t,e,"box.set_text_wrap",[Wt.wrapAuto,Wt.wrapNone],"text_wrap"))}set_text_color({text_color:t}){const e=this._getBox();e&&(e.text_color=t,ge(e,["text_color"]))}set_rightbottom({right:t,bottom:e}){const r=this._getBox();r&&(r.right=t,r.bottom=e)}set_text_halign({text_halign:t},e){const r=this._getBox();r&&(r.text_halign=t,this._paramVerfiy(t,e,"box.set_text_halign",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"))}set_text_valign({text_valign:t},e){const r=this._getBox();r&&(r.text_valign=t,this._paramVerfiy(t,e,"box.set_text_valign",[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"))}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.top=n,e.left=e.xloc===De.bar_index?r:s}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t,ge(e,["border_color"]))}set_border_style({style:t},e){const r=this._getBox();r&&(r.border_style=t,this._paramVerfiy(t,e,"box.set_border_style",[Re.styleDashed,Re.styleDotted,Re.styleSolid],"style"))}set_border_width({width:t}){const e=this._getBox();e&&(e.border_width=t)}set_bottom_right_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.bottom=n,e.right=e.xloc===De.bar_index?r:s}}set_text_font_family({text_font_family:t},e){const r=this._getBox();r&&(r.text_font_family=t,this._paramVerfiy(t,e,"box.set_text_font_family",Object.values(Gn),"text_font_family"))}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getBox(){return this._variables.box.get(this._id)}}class hy{constructor(t,e){L(this,"_variables");L(this,"_errorListener");L(this,"_defaultTable",{position:mr.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=t,this._errorListener=e}table({x:t}){return t}new(t,e){const{bar_index:r}=this._variables,n=`table_${e}_${r}`,{rows:s}=t;ge(t,["text_color","bgcolor","border_color"]);const a=Array.from(Array(s),()=>[]),l=e.split("_"),c=l.pop(),f=l.pop(),d={...this._defaultTable,...t,cell:a,id:n,bar_index:r,line:f,col:c},h=new ph(this._variables,n,this._errorListener);return this._paramVerfiy(t.position,e,"table.new",Object.values(mr),"position"),e.startsWith("export")||this._variables.table.add(n,d,h),h}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}cell({table_id:t,...e}){t==null||t.cell(e)}cell_set_bgcolor({table_id:t,...e}){t==null||t.cell_set_bgcolor(e)}cell_set_height({table_id:t,...e}){t==null||t.cell_set_height(e)}cell_set_text({table_id:t,...e}){t==null||t.cell_set_text(e)}cell_set_text_color({table_id:t,...e}){t==null||t.cell_set_text_color(e)}cell_set_text_font_family({table_id:t,...e}){t==null||t.cell_set_text_font_family(e)}cell_set_text_halign({table_id:t,...e}){t==null||t.cell_set_text_halign(e)}cell_set_text_valign({table_id:t,...e}){t==null||t.cell_set_text_valign(e)}cell_set_text_size({table_id:t,...e}){t==null||t.cell_set_text_size(e)}cell_set_tooltip({table_id:t,...e}){t==null||t.cell_set_tooltip(e)}cell_set_width({table_id:t,...e}){t==null||t.cell_set_width(e)}clear({table_id:t,...e}){t==null||t.clear(e)}delete({table_id:t}){t==null||t.delete()}merge_cells({table_id:t,...e},r){t==null||t.merge_cells(e,r)}set_bgcolor({table_id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({table_id:t,...e}){t==null||t.set_border_color(e)}set_border_width({table_id:t,...e}){t==null||t.set_border_width(e)}set_frame_color({table_id:t,...e}){t==null||t.set_frame_color(e)}set_frame_width({table_id:t,...e}){t==null||t.set_frame_width(e)}set_position({table_id:t,...e},r){t==null||t.set_position(e,r)}}class ph{constructor(t,e,r){L(this,"_id");L(this,"_variables");L(this,"_errorListener");L(this,"_suffix","");L(this,"_defaultCell",{column:0,row:0,text:"",text_color:Bi.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_size:ir.normal});this._variables=t,this._id=e,this._errorListener=r}get type(){return Me.TABLE}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.table.get(this._id)}cell(t){const e={...this._defaultCell,...t},{column:r=0,row:n=0}=e,s=this._variables.table.get(this._id);if(s){const a=s.cell||[],l=a[n]||[];l[r]=e,a[n]=l,s.cell=a}}cell_set_bgcolor({column:t=0,row:e=0,bgcolor:r}){const n=this._getTableItem(t,e);n&&(n.bgcolor=r)}cell_set_height({column:t=0,row:e=0,height:r}){const n=this._getTableItem(t,e);n&&(n.height=r)}cell_set_text({column:t=0,row:e=0,text:r}){const n=this._getTableItem(t,e);n&&(n.text=r)}cell_set_text_color({column:t=0,row:e=0,text_color:r}){const n=this._getTableItem(t,e);n&&(n.text_color=r,ge(n,["text_color"]))}cell_set_text_font_family({column:t=0,row:e=0,text_font_family:r}){const n=this._getTableItem(t,e);n&&(n.text_font_family=r)}cell_set_text_halign({column:t=0,row:e=0,text_halign:r}){const n=this._getTableItem(t,e);n&&(n.text_halign=r)}cell_set_text_valign({column:t=0,row:e=0,text_valign:r}){const n=this._getTableItem(t,e);n&&(n.text_valign=r)}cell_set_text_size({column:t=0,row:e=0,text_size:r}){const n=this._getTableItem(t,e);n&&(n.text_size=r)}cell_set_tooltip({column:t=0,row:e=0,tooltip:r}){const n=this._getTableItem(t,e);n&&(n.tooltip=r)}cell_set_width({column:t=0,row:e=0,width:r}){const n=this._getTableItem(t,e);n&&(n.width=r)}clear({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0}){const s=this._variables.table.get(this._id);if(s){const a=s.cell;if(a)for(let l=e;l<=n;l++)for(let c=t;c<=r;c++){const f=a[l];f&&(f[c]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0},s){if(t>r||e>n){this._errorListener.addError(ce.mergeCellErr,s,zt.Error);return}const a=this._variables.table.get(this._id);if(!a)return;const l=a.merge_cells||[];l.push({start_column:t,start_row:e,end_column:r,end_row:n}),a.merge_cells=l}set_bgcolor({bgcolor:t}){const e=this._variables.table.get(this._id);e&&(e.bgcolor=t,ge(e,["bgcolor"]))}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t,ge(e,["border_color"]))}set_border_width({border_width:t}){const e=this._variables.table.get(this._id);e&&(e.border_width=t)}set_frame_color({frame_color:t}){const e=this._variables.table.get(this._id);e&&(e.frame_color=t)}set_frame_width({frame_width:t}){const e=this._variables.table.get(this._id);e&&(e.frame_width=t)}set_position({position:t},e){const r=this._variables.table.get(this._id);r&&(r.position=t,this._paramVerfiy(t,e,"table.set_position",Object.values(mr),"position"))}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_getTableItem(t,e){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[e][t]:void 0}}}class dy{constructor(t){L(this,"_strategy");this._strategy=t}commission({trade_num:t}){return this._verifyTradeNum(t)&&this._strategy.historyOrders[t].commission||0}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.historyOrders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_price}entry_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_time}exit_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_index}exit_comment({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_comment:""}exit_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_id:""}exit_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_price}exit_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{out_qty:e=0,direction:r}=this._strategy.historyOrders[t];return r===se.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.historyOrders.length;return!(t>=e)}}class py{constructor(t){L(this,"_strategy");this._strategy=t}commission({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,original_qty:r=0,commission:n=0}=this._strategy.orders[t];return n*e/r}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.orders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_price}entry_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,direction:r}=this._strategy.orders[t];return r===se.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.orders.length;return!(t>=e)}}class _y{constructor(t,e){L(this,"_strategy");L(this,"_errorListener");this._strategy=t,this._errorListener=e}allow_entry_in({value:t},e){this._paramVerfiy(t,e,"strategy.risk.allow_entry_in",Object.values(se),"value"),this._strategy.updateRisk({allow_entry_in:t})}max_cons_loss_days({count:t}){this._strategy.updateRisk({max_cons_loss_days:t})}max_drawdown({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_drawdown",[Pe.percentOfEquity,Pe.cash],"type"),e===Pe.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_drawdown:t,max_drawdown_type:e})}max_intraday_filled_orders({count:t}){this._strategy.updateRisk({max_intraday_filled_orders:t})}max_intraday_loss({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_intraday_loss",[Pe.percentOfEquity,Pe.cash],"type"),e===Pe.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_intraday_loss:t,max_intraday_loss_type:e})}max_position_size({contracts:t}){this._strategy.updateRisk({max_position_size:t})}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}}var my=20,gy=1,ei=1e6,_h=1e6,vy=-7,wy=21,yy=!1,as="[big.js] ",ri=as+"Invalid ",wo=ri+"decimal places",Dy=ri+"rounding mode",mh=as+"Division by zero",ae={},sn=void 0,by=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function gh(){function i(t){var e=this;if(!(e instanceof i))return t===sn?gh():new i(t);if(t instanceof i)e.s=t.s,e.e=t.e,e.c=t.c.slice();else{if(typeof t!="string"){if(i.strict===!0&&typeof t!="bigint")throw TypeError(ri+"value");t=t===0&&1/t<0?"-0":String(t)}xy(e,t)}e.constructor=i}return i.prototype=ae,i.DP=my,i.RM=gy,i.NE=vy,i.PE=wy,i.strict=yy,i.roundDown=0,i.roundHalfUp=1,i.roundHalfEven=2,i.roundUp=3,i}function xy(i,t){var e,r,n;if(!by.test(t))throw Error(ri+"number");for(i.s=t.charAt(0)=="-"?(t=t.slice(1),-1):1,(e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),n=t.length,r=0;r<n&&t.charAt(r)=="0";)++r;if(r==n)i.c=[i.e=0];else{for(;n>0&&t.charAt(--n)=="0";);for(i.e=e-r-1,i.c=[],e=0;r<=n;)i.c[e++]=+t.charAt(r++)}return i}function ni(i,t,e,r){var n=i.c;if(e===sn&&(e=i.constructor.RM),e!==0&&e!==1&&e!==2&&e!==3)throw Error(Dy);if(t<1)r=e===3&&(r||!!n[0])||t===0&&(e===1&&n[0]>=5||e===2&&(n[0]>5||n[0]===5&&(r||n[1]!==sn))),n.length=1,r?(i.e=i.e-t+1,n[0]=1):n[0]=i.e=0;else if(t<n.length){if(r=e===1&&n[t]>=5||e===2&&(n[t]>5||n[t]===5&&(r||n[t+1]!==sn||n[t-1]&1))||e===3&&(r||!!n[0]),n.length=t,r){for(;++n[--t]>9;)if(n[t]=0,t===0){++i.e,n.unshift(1);break}}for(t=n.length;!n[--t];)n.pop()}return i}function ii(i,t,e){var r=i.e,n=i.c.join(""),s=n.length;if(t)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)n="0"+n;n="0."+n}else if(r>0)if(++r>s)for(r-=s;r--;)n+="0";else r<s&&(n=n.slice(0,r)+"."+n.slice(r));else s>1&&(n=n.charAt(0)+"."+n.slice(1));return i.s<0&&e?"-"+n:n}ae.abs=function(){var i=new this.constructor(this);return i.s=1,i},ae.cmp=function(i){var t,e=this,r=e.c,n=(i=new e.constructor(i)).c,s=e.s,a=i.s,l=e.e,c=i.e;if(!r[0]||!n[0])return r[0]?s:n[0]?-a:0;if(s!=a)return s;if(t=s<0,l!=c)return l>c^t?1:-1;for(a=(l=r.length)<(c=n.length)?l:c,s=-1;++s<a;)if(r[s]!=n[s])return r[s]>n[s]^t?1:-1;return l==c?0:l>c^t?1:-1},ae.div=function(i){var t=this,e=t.constructor,r=t.c,n=(i=new e(i)).c,s=t.s==i.s?1:-1,a=e.DP;if(a!==~~a||a<0||a>ei)throw Error(wo);if(!n[0])throw Error(mh);if(!r[0])return i.s=s,i.c=[i.e=0],i;var l,c,f,d,h,p=n.slice(),g=l=n.length,w=r.length,_=r.slice(0,l),y=_.length,v=i,x=v.c=[],b=0,M=a+(v.e=t.e-i.e)+1;for(v.s=s,s=M<0?0:M,p.unshift(0);y++<l;)_.push(0);do{for(f=0;f<10;f++){if(l!=(y=_.length))d=l>y?1:-1;else for(h=-1,d=0;++h<l;)if(n[h]!=_[h]){d=n[h]>_[h]?1:-1;break}if(d<0){for(c=y==l?n:p;y;){if(_[--y]<c[y]){for(h=y;h&&!_[--h];)_[h]=9;--_[h],_[y]+=10}_[y]-=c[y]}for(;!_[0];)_.shift()}else break}x[b++]=d?f:++f,_[0]&&d?_[y]=r[g]||0:_=[r[g]]}while((g++<w||_[0]!==sn)&&s--);return!x[0]&&b!=1&&(x.shift(),v.e--,M--),b>M&&ni(v,M,e.RM,_[0]!==sn),v},ae.eq=function(i){return this.cmp(i)===0},ae.gt=function(i){return this.cmp(i)>0},ae.gte=function(i){return this.cmp(i)>-1},ae.lt=function(i){return this.cmp(i)<0},ae.lte=function(i){return this.cmp(i)<1},ae.minus=ae.sub=function(i){var t,e,r,n,s=this,a=s.constructor,l=s.s,c=(i=new a(i)).s;if(l!=c)return i.s=-c,s.plus(i);var f=s.c.slice(),d=s.e,h=i.c,p=i.e;if(!f[0]||!h[0])return h[0]?i.s=-c:f[0]?i=new a(s):i.s=1,i;if(l=d-p){for((n=l<0)?(l=-l,r=f):(p=d,r=h),r.reverse(),c=l;c--;)r.push(0);r.reverse()}else for(e=((n=f.length<h.length)?f:h).length,l=c=0;c<e;c++)if(f[c]!=h[c]){n=f[c]<h[c];break}if(n&&(r=f,f=h,h=r,i.s=-i.s),(c=(e=h.length)-(t=f.length))>0)for(;c--;)f[t++]=0;for(c=t;e>l;){if(f[--e]<h[e]){for(t=e;t&&!f[--t];)f[t]=9;--f[t],f[e]+=10}f[e]-=h[e]}for(;f[--c]===0;)f.pop();for(;f[0]===0;)f.shift(),--p;return f[0]||(i.s=1,f=[p=0]),i.c=f,i.e=p,i},ae.mod=function(i){var t,e=this,r=e.constructor,n=e.s,s=(i=new r(i)).s;if(!i.c[0])throw Error(mh);return e.s=i.s=1,t=i.cmp(e)==1,e.s=n,i.s=s,t?new r(e):(n=r.DP,s=r.RM,r.DP=r.RM=0,e=e.div(i),r.DP=n,r.RM=s,this.minus(e.times(i)))},ae.neg=function(){var i=new this.constructor(this);return i.s=-i.s,i},ae.plus=ae.add=function(i){var t,e,r,n=this,s=n.constructor;if(i=new s(i),n.s!=i.s)return i.s=-i.s,n.minus(i);var a=n.e,l=n.c,c=i.e,f=i.c;if(!l[0]||!f[0])return f[0]||(l[0]?i=new s(n):i.s=n.s),i;if(l=l.slice(),t=a-c){for(t>0?(c=a,r=f):(t=-t,r=l),r.reverse();t--;)r.push(0);r.reverse()}for(l.length-f.length<0&&(r=f,f=l,l=r),t=f.length,e=0;t;l[t]%=10)e=(l[--t]=l[t]+f[t]+e)/10|0;for(e&&(l.unshift(e),++c),t=l.length;l[--t]===0;)l.pop();return i.c=l,i.e=c,i},ae.pow=function(i){var t=this,e=new t.constructor("1"),r=e,n=i<0;if(i!==~~i||i<-_h||i>_h)throw Error(ri+"exponent");for(n&&(i=-i);i&1&&(r=r.times(t)),i>>=1,!!i;)t=t.times(t);return n?e.div(r):r},ae.prec=function(i,t){if(i!==~~i||i<1||i>ei)throw Error(ri+"precision");return ni(new this.constructor(this),i,t)},ae.round=function(i,t){if(i===sn)i=0;else if(i!==~~i||i<-ei||i>ei)throw Error(wo);return ni(new this.constructor(this),i+this.e+1,t)},ae.sqrt=function(){var i,t,e,r=this,n=r.constructor,s=r.s,a=r.e,l=new n("0.5");if(!r.c[0])return new n(r);if(s<0)throw Error(as+"No square root");s=Math.sqrt(+ii(r,!0,!0)),s===0||s===1/0?(t=r.c.join(""),t.length+a&1||(t+="0"),s=Math.sqrt(t),a=((a+1)/2|0)-(a<0||a&1),i=new n((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+a)):i=new n(s+""),a=i.e+(n.DP+=4);do e=i,i=l.times(e.plus(r.div(e)));while(e.c.slice(0,a).join("")!==i.c.slice(0,a).join(""));return ni(i,(n.DP-=4)+i.e+1,n.RM)},ae.times=ae.mul=function(i){var t,e=this,r=e.constructor,n=e.c,s=(i=new r(i)).c,a=n.length,l=s.length,c=e.e,f=i.e;if(i.s=e.s==i.s?1:-1,!n[0]||!s[0])return i.c=[i.e=0],i;for(i.e=c+f,a<l&&(t=n,n=s,s=t,f=a,a=l,l=f),t=new Array(f=a+l);f--;)t[f]=0;for(c=l;c--;){for(l=0,f=a+c;f>c;)l=t[f]+s[c]*n[f-c-1]+l,t[f--]=l%10,l=l/10|0;t[f]=l}for(l?++i.e:t.shift(),c=t.length;!t[--c];)t.pop();return i.c=t,i},ae.toExponential=function(i,t){var e=this,r=e.c[0];if(i!==sn){if(i!==~~i||i<0||i>ei)throw Error(wo);for(e=ni(new e.constructor(e),++i,t);e.c.length<i;)e.c.push(0)}return ii(e,!0,!!r)},ae.toFixed=function(i,t){var e=this,r=e.c[0];if(i!==sn){if(i!==~~i||i<0||i>ei)throw Error(wo);for(e=ni(new e.constructor(e),i+e.e+1,t),i=i+e.e+1;e.c.length<i;)e.c.push(0)}return ii(e,!1,!!r)},ae[Symbol.for("nodejs.util.inspect.custom")]=ae.toJSON=ae.toString=function(){var i=this,t=i.constructor;return ii(i,i.e<=t.NE||i.e>=t.PE,!!i.c[0])},ae.toNumber=function(){var i=+ii(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(i.toString()))throw Error(as+"Imprecise conversion");return i},ae.toPrecision=function(i,t){var e=this,r=e.constructor,n=e.c[0];if(i!==sn){if(i!==~~i||i<1||i>ei)throw Error(ri+"precision");for(e=ni(new r(e),i,t);e.c.length<i;)e.c.push(0)}return ii(e,i<=e.e||e.e<=r.NE||e.e>=r.PE,!!n)},ae.valueOf=function(){var i=this,t=i.constructor;if(t.strict===!0)throw Error(as+"valueOf disallowed");return ii(i,i.e<=t.NE||i.e>=t.PE,!0)};var Ja=gh();function Ey(i,t){return Ja(i).plus(t).toNumber()}function Xa(i,t){return Ja(i).minus(t).toNumber()}function yo(i,t){return Ja(i).mul(t).toNumber()}let Ay=class{constructor(t,e,r,n,s){L(this,"_variables");L(this,"_options");L(this,"_totalChangeCapital");L(this,"_historyOrder");L(this,"_orders");L(this,"_pendingOrders");L(this,"_mintick");L(this,"_funcOptions");L(this,"_pendingCloseOrders");L(this,"_errorListener");L(this,"_risk");L(this,"_opentrades");L(this,"_closedtrades");L(this,"_riskNamespace");L(this,"_updateOptions",{});L(this,"_id");L(this,"_maxDrawdownVerifyIndex",0);L(this,"calcOnOrderFillsData",{index:-1});this._variables=t,this._errorListener=n,this._options={overlay:!1,format:Kt.inherit,pyramiding:1,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Pe.fixed,default_qty_value:1,initial_capital:1e6,currency:ch.NONE,slippage:0,commission_type:je.percent,commission_value:0,process_orders_on_close:!1,close_entries_rule:"FIFO",margin_long:0,margin_short:0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,max_polylines_count:50},this._funcOptions=e,this._totalChangeCapital=0,this._orders=[],this._pendingOrders=[],this._historyOrder=[],this._pendingCloseOrders=[],this._mintick=r,this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),this._variables.strategy.updateStrategyOptions(this._options),this._risk={intradayOrders:0},this._opentrades=new py(this),this._closedtrades=new dy(this),this._riskNamespace=new _y(this,n),this._id=`strategy_${s}`}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _freezeCapital(){const{close:t}=this.calcOnOrderFillsData.data||this._variables;return this._orders.reduce((e,r)=>e+t*(r.qty||0),0)}get opentrades(){return this._opentrades}get closedtrades(){return this._closedtrades}get risk(){return this._riskNamespace}get isCalcOnEveryTick(){return this._options.calc_on_every_tick}updateOptions(t){this._updateOptions=t||{},Object.assign(this._options,this._updateOptions)}update(){this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),this._maxDrawdownVerify();const{open:t,close:e,high:r,low:n}=this.calcOnOrderFillsData.data||this._variables;this._variables.strategy.update({open:t,close:e,high:r,low:n}),!this._options.process_orders_on_close&&this._calcLiquidate(),this._calcProfitAndLoss()}calcCurrentOrder(){this._calcProfitAndLoss()}updateRisk(t){Object.assign(this._risk,t)}endExecution(){this._maxIntradayLoss(),this._pendingCloseOrderHandle(),this._options.process_orders_on_close&&this._calcLiquidate()}_maxIntradayLoss(){var g;const{max_intraday_loss:t,max_intraday_loss_type:e,isDisabledOpen:r}=this._risk;if(t===void 0||!e||r)return;const{time_tradingday:n,time:s,strategy:{netprofit:a,initial_capital:l}}=this._variables,{high:c,low:f}=this.calcOnOrderFillsData.data||this._variables;let{preNetprofit:d=0}=this._risk;s===n&&(d=a,this._risk.preNetprofit=a,this._risk.isTemporaryBan=!1);let h=d-a;h+=this._orders.reduce((w,_)=>{const{in_price:y,direction:v,qty:x=0,commission:b=0,original_qty:M=0}=_,E=v===se.long?1:-1,F=(c-y)*x,N=(f-y)*x,S=E===1?N:-F;return w+S+x/M*b},0);let p=!1;switch(e){case Pe.cash:p=t<h;break;case Pe.percentOfEquity:const w=h/(l+a)*100;p=t<w;break}if(p){this._risk.isTemporaryBan=!0;const w=(g=this._orders[0])==null?void 0:g.direction;this._closeOrders(this._orders,w===se.long?f:c,"Close Position (Max intraday Loss)",void 0,"close"),this._pendingOrders=[]}}_maxIntradayFilledOrdersVerify(){const{max_intraday_filled_orders:t,intradayOrders:e=0,isDisabledOpen:r}=this._risk;if(t===void 0||r)return;const{time:n,time_tradingday:s}=this._variables,{open:a}=this.calcOnOrderFillsData.data||this._variables;n===s&&(this._risk.intradayOrders=0,this._risk.isTemporaryBan=!1),t<=e&&(this._risk.isTemporaryBan=!0,this._closeOrders(this._orders,a,"Close Position (Max number of filled orders in one day)",void 0,"close"),this._pendingOrders=[])}_maxConsLossDaysVerify(){const{max_cons_loss_days:t,lossDays:e=0,isDisabledOpen:r,totalProfit:n=0}=this._risk;if(t===void 0||r)return;const{time:s,time_tradingday:a,strategy:l}=this._variables,{open:c}=this.calcOnOrderFillsData.data||this._variables;let f=e;if(s===a){const d=l.netprofit+l.openprofit;d<n?f=0:f++,Object.assign(this._risk,{lossDays:f,totalProfit:d})}t<=f&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){const{max_drawdown:t,max_drawdown_type:e,isDisabledOpen:r}=this._risk;if(r)return;const{bar_index:n}=this._variables,{open:s}=this.calcOnOrderFillsData.data||this._variables;if(t!==void 0&&e&&this._maxDrawdownVerifyIndex===n){const{initial_capital:a}=this._options,c=this._orders.reduce((d,h)=>{const{in_price:p,commission:g=0,qty:w=0,original_qty:_=0,direction:y}=h,v=y===se.long?1:-1,x=(s-p)*v*w;return d+x+g*w/_},0)+this._totalChangeCapital;let f=!1;switch(e){case Pe.percentOfEquity:f=c/a*100<=-t;break;case Pe.cash:f=c<=-t;break}f&&this._riskTouchOff(s,"Close Position (Max Drawdown)")}}_riskTouchOff(t,e){this._risk.isDisabledOpen=!0,this._orders.length&&this._closeOrders(this._orders,t,e,"close"),this._pendingOrders=[]}strategy(t,e){if(!this._variables.bar_index){this._paramVerfiy(t.format,e,"strategy",[Kt.inherit,Kt.price,Kt.percent,Kt.volume],"format"),this._paramVerfiy(t.default_qty_type,e,"strategy",Object.values(Pe),"default_qty_type"),this._paramVerfiy(t.commission_type,e,"strategy",Object.values(je),"commission_type");const r=self==null?void 0:self.workerStorage.get(this._id),n={...this._updateOptions};if(r)for(const s of Object.keys({...r,...t}))t[s]!==r[s]&&delete n[s];self==null||self.workerStorage.set(this._id,t),Object.assign(this._options,t,n),this._variables.updateMaxLength(t),Object.assign(this._funcOptions,{strategy:this._options,userSetStrategyConfig:n,scriptType:"strategy"})}}order(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.order",Object.values(cn),"oca_type"),this._orderHandle(t))}entry(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.entry",Object.values(cn),"oca_type"),this._entryHandle(t))}close(t){if(!this._orders.filter(r=>!this._options.process_orders_on_close||r.in_index!==this._variables.bar_index).length)return;const{immediately:e}=t;if(e||this._options.process_orders_on_close){const r=this._pendingCloseOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingCloseOrders.push({...t,place_order_type:"close"})}else{const r=this._pendingOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingOrders.push({...t,place_order_type:"close"})}}close_all(t){if(typeof t=="string"&&(t={}),!this._orders.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close_all"}):this._pendingOrders.push({...t,place_order_type:"close_all"})}cancel({id:t}){this._pendingOrders=this._pendingOrders.filter(e=>!(e.id===t&&e.place_order_type!=="close"))}cancel_all(){this._pendingOrders=this._pendingOrders.filter(t=>t.place_order_type==="close_all")}exit(t,e){this._exit(t,e)}convert_to_account({value:t}){return t}convert_to_symbol({value:t}){return t}default_entry_qty({fill_price:t}){return t?this._calcDefaultQty(t):0}_calcDefaultQty(t){const{default_qty_type:e=Pe.fixed,default_qty_value:r=1,initial_capital:n,commission_value:s}=this._options;let a=r;switch(e){case Pe.cash:a=r/t;break;case Pe.percentOfEquity:const l=this._getOrderProfit(t),c=n+l+this._totalChangeCapital;s?a=this._getCommQty(c,t):a=c*r/100/t;break}return Vl(a,this._getLen(t))}_getCommQty(t,e){const{commission_type:r,commission_value:n=0,default_qty_value:s=0}=this._options;let a=0;switch(r){case je.percent:a=t*s/(100*e+n*e*s/100);break;case je.cashPerContract:a=t*s/(100*e+n*s);break;case je.cashPerOrder:a=(t-n)*s/100/e}return a}_getLen(t){const e=String(Math.floor(t)).length-2;return e<0?0:e}_getCapital(t,e){const{margin_long:r=0,margin_short:n=0}=this._options;return r<100&&r>0&&t===1?e=e*100/r:n<=100&&n>0&&t===-1&&(e=e*100/n),e}_calcProfitAndLoss(){const{close:t}=this.calcOnOrderFillsData.data||this._variables;for(const e of this._orders){const{in_price:r,qty:n=0,direction:s}=e,a=s===se.long?1:-1,l=(t-r)*a*n,[c,f]=this._calcProfitAndLossHandle(r,n,a);this._calcOrderPercent(e,l,c,f)}}_calcProfitAndLossHandle(t,e,r){const{high:n,low:s}=this.calcOnOrderFillsData.data||this._variables,a=(n-t)*e,l=(s-t)*e;let c=r===1?a:-l,f=r===1?l:-a;return[c,f]}_calcOrderPercent(t,e,r,n){const{commission_value:s}=this._options,{close:a}=this.calcOnOrderFillsData.data||this._variables,{original_qty:l=0,qty:c=0,in_price:f,max_profit:d=0,trading_loss:h=0}=t;let{commission:p=0}=t,g=f*c;if(s){const w=this._getCommission(a,c);p=p*c/l,r-=p,n-=p,g+=p,e=e-w-p}r=Math.max(r,d,0),n=Math.min(n,h,0),Object.assign(t,{profit:e,total_profit:this._totalChangeCapital+e,total_profit_percent:e/(this._options.initial_capital+this._totalChangeCapital)*100,max_profit:r,trading_loss:n,profit_percent:e/g*100,max_profit_percent:r/g*100,trading_loss_percent:n/g*100})}_calcLiquidate(){if(!this._orders.length)return;const{time:t}=this._variables,{high:e,low:r}=this.calcOnOrderFillsData.data||this._variables,{initial_capital:n,margin_long:s=0,margin_short:a=0}=this._options,l=this._orders[0].direction===se.long?1:-1;let c=l===1?r:e;if(l===1&&s===100)return;const f=(l===1?s:a)/100;if(f<=0)return;let d=!1;const[h,p]=this._orders.reduce((y,v)=>{let[x,b]=y;const{in_price:M,qty:E=0,in_time:F}=v;F===t&&(d=!0);const N=M*E,S=c*E;return x+=N,b+=S,[x,b]},[0,0]);let g=0,w=0;const _=n+this._totalChangeCapital;if(d&&(g=_-h*f,g<0&&(c=this._orders[0].in_price,w=Math.abs(Math.trunc(g/f/c)*4),w=Math.max(w,1))),g>=0){const y=l*(p-h);if(g=_+y-p*f,g>=0)return;w=Math.abs(Math.trunc(g/f/c)*4)}w<=0||this._marginCallOrders(c,w,"Margin Call")}_marginCallOrders(t,e,r){const{close_entries_rule:n="FIFO"}=this._options;if(n==="FIFO"){this._processOrders(this._orders,t,e*this._orders.length,r,r,!0);return}for(const s of this.orders)s.position_close_type=s.place_order_type,this._processOrder(s,t,e,r,r,!0);this._orders=this._orders.filter(s=>!s.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_orderHandle(t){const{process_orders_on_close:e,slippage:r=0}=this._options,{orders:n,isMarketPrice:s,quantities:a,close:l,price:c,activePrice:f,isTouch:d}=this._orderArgsParse(t),h=t.direction===se.long?1:-1;if(a<=0)return;let p=a;if((s||d)&&e){const w=d?c:l;if(n.length){const E=this._processOrders(n,w,p,t.id,t.comment,!1,"order");if(E<=0)return;p=E}const _=w+h*r*this._mintick;if(!this._judgeCapitalEnough(p,_,h))return;this._ocaGroupVerify(p,t.oca_name,t.oca_type);const{bar_index:v,time:x}=this._variables,{high:b,low:M}=this.calcOnOrderFillsData.data||this._variables;this._calcCurrentOrder({...t,in_price:_,in_high:b,in_low:M,in_index:v,in_time:x,qty:p,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,h)&&this._addPendingOrders(t,c,p,s,f)}_judgeCapitalEnough(t,e,r){let n=this._freezeCapital;if(this._orders.some(d=>(d.direction===se.long?1:-1)!==r)&&(n=0),t<=0)return!1;const{margin_long:s=0,margin_short:a=0}=this._options;if(s===0&&r===1||a===0&&r===-1)return!0;const l=this._getOrderProfit(e),f=this._getCapital(r,this._options.initial_capital+l+this._totalChangeCapital)-n;return t*e<=f}_getOrderProfit(t){return this._orders.reduce((e,r)=>{const{in_price:n,qty:s=0,direction:a}=r,l=a===se.long?1:-1;return e+(t-n)*s*l},0)}_ocaGroupVerify(t,e,r){if(!e||!r||r===cn.none)return!1;let n=!1;switch(r){case cn.cancel:this._pendingOrders=this._pendingOrders.filter(s=>{if(s.oca_name===e)s.isCancel=!0,n=!0;else return!0});break;case cn.reduce:this._pendingOrders=this._pendingOrders.filter(s=>{const{qty:a=0,oca_name:l}=s;if(e===l){const c=a-t;return n=!0,c<=0?(s.isCancel=!0,!1):(s.qty=c,!0)}else return!0});break}return n}_processOrders(t,e,r,n,s,a=!1,l,c){let f=r;for(const d of t)if(d.position_close_type=l||d.place_order_type,d.immediately=c,f=this._processOrder(d,e,f,n,s,a),f<=0)break;return this._orders=this._orders.filter(d=>!d.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),f}_addPendingOrders(t,e,r,n,s){const a=this._pendingOrders.find(l=>l.id===t.id&&!l.isMarketPrice);if(a)Object.assign(a,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:s});else{const l={...t,in_price:e,isMarketPrice:n,qty:r,active_price:s,place_order_type:"order"};this._pendingOrders.push(l)}}_orderArgsParse(t){const{direction:e,qty:r,stop:n}=t;let s=t.limit||0;const{close:a}=this.calcOnOrderFillsData.data||this._variables;let l=a,c=!1,f;const d=e===se.long?1:-1,h=n&&(n-a)*d>=0,{backtest_fill_limits_assumption:p=0}=this._options;p>0&&s&&(s-=p*this._mintick*d);const g=s&&(s-a)*d<=0;let w=!1;h&&g?(n!==a&&(f=n),l=s):h?(l=n,w=n===a):g?(l=s,w=s===a):c=!0;const _=r!==void 0?Vl(r,this._getLen(l)):this._calcDefaultQty(l);return{orders:this._orders.filter(v=>v.direction!==e),isMarketPrice:c,activePrice:f,quantities:_,close:a,price:l,isTouch:w}}_entryHandle(t){const{process_orders_on_close:e}=this._options,{orders:r,isMarketPrice:n,quantities:s,close:a,price:l,activePrice:c,isTouch:f}=this._orderArgsParse(t);if(s<=0)return;if((n||f)&&e){this._entryOrder(r,f?l:a,s,t);return}this._judgeCapitalEnough(s,a,t.direction===se.long?1:-1)&&this._addPendingEntry(t,l,s,n,c)}_entryOrder(t,e,r,n){const{time:s,bar_index:a}=this._variables,{high:l,low:c}=this.calcOnOrderFillsData.data||this._variables,{slippage:f=0}=this._options,{oca_name:d,oca_type:h,direction:p,comment:g,id:w}=n,_=p===se.long?1:-1;if(r=this._getAvailablePositionSize(r,p),r<=0||(e=e+f*this._mintick*_,!this._judgeCapitalEnough(r,e,_)))return;this._closeOrders(t,e,w,g,"entry");const v={...n,in_price:e,qty:r,in_index:a,in_high:l,in_low:c,in_time:s,place_order_type:"entry"},{orders:x}=this._getEntryOrders(p),b=x.length;b&&b>=(this._options.pyramiding||1)||(this._ocaGroupVerify(r,d,h),this._calcCurrentOrder(v))}_getAvailablePositionSize(t,e){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==se.all&&n!==e)return 0;if(r===void 0)return t;const s=this._orders.reduce((a,l)=>a+(l.qty||0),0);return s?s+t>r?0:t:t>r?t-r:0}_getEntryOrders(t){const e=this._pendingOrders.filter(n=>["entry","order"].includes(n.place_order_type)&&n.direction===t),r=this._orders.filter(n=>n.direction===t);return{pendingOrders:e,orders:r}}_addPendingEntry(t,e,r,n,s){if(r=this._getAvailablePositionSize(r,t.direction),r<=0)return;const{pendingOrders:a,orders:l}=this._getEntryOrders(t.direction),c=a.length+l.length,f=a.find(d=>d.id===t.id&&d.place_order_type==="entry");if(f)Object.assign(f,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:s});else if(!c||c<(this._options.pyramiding||1)){const d={...t,in_price:e,isMarketPrice:n,qty:r,active_price:s,place_order_type:"entry"};this._pendingOrders.push(d)}}_closeAllOrders(t,e){const{comment:r,immediately:n}=t,{bar_index:s}=this._variables,a=this._orders.filter(l=>l.in_index!==s);a.length&&(this._closeOrders(a,e,"Close position order",r,"close",n),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(t,e,r,n,s,a){for(const l of t)l.position_close_type=s,l.immediately=a,this._closeOrder(l,e,r,n);this._orders=this._orders.filter(l=>!l.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_closeOrder(t,e,r,n){const{time:s,bar_index:a}=this._variables,{high:l,low:c}=this.calcOnOrderFillsData.data||this._variables,{slippage:f=0}=this._options,{in_price:d,qty:h=0,direction:p}=t,g=p===se.long?1:-1;e=e-g*f*this._mintick,t.isDeal=!0;const w=(e-d)*g*h,_={...t,out_price:e,out_id:r,out_index:a,out_high:l,out_low:c,out_time:s,out_comment:n,out_qty:h,profit:w};this._calcPercent(_)}_ordersHandle(){const t=this._orders.filter(f=>f.place_order_type==="exit"&&!f.hasExit);if(!t.length)return;const{open:e,low:r,high:n,close:s}=this.calcOnOrderFillsData.data||this._variables,a=[],l=Math.abs(n-e),c=Math.abs(r-e);for(const f of t){const{stop:d,limit:h,trail_stop_price:p,isMarketPriceLimit:g,isMarketPriceStop:w,direction:_,id:y,out_comment:v,active_price:x,trail_offset:b=0,out_qty:M,comment_loss:E,comment_profit:F,comment_trailing:N}=f;let S=p;const T=_===se.long?1:-1;let C=l<c||l===c&&T===1,O,$=1,W=v;if(g||w?O=e:(h&&((e-h)*T>=0?(O=e,$=1):r<=h&&n>=h&&(O=h,C&&h>e||!C&&h<e?$=1:$=2),W=F||v),d&&!(S&&(d-S)*T<0)&&((e-d)*T<=0?(O=e,$=1):r>=d&&n<=d&&(O=d,C&&d>e||!C&&d<e?$=1:$=2),W=E||v)),O)a.push({order:f,price:O,index:$,isHighFront:C,exitInfo:{from_entry:y,comment:W,qty:M}});else{if(O=void 0,S)if((S-e)*T>=0)O=e,$=1;else{const[q,U,z]=this._calcTrailStopPrice(S,n,r,s,b,T,C);O=U,$=z||1,f.trail_stop_price=q}if(x&&!O&&x<=n&&x>=r)if(b===0)O=x,C&&x>e||!C&&x<e?$=1:$=2;else{S=Xa(x,yo(b*T,this._mintick));let q=n,U=r;C?x>=e&&x<=n?(q=n,$=1):(C=!1,q=s,$=2):x<e&&x>=r?(U=r,$=1):(C=!0,U=s,$=2);const[z,K,Z=1]=this._calcTrailStopPrice(S,q,U,s,b,T,C);delete f.active_price,$<Z&&($=Z),f.trail_stop_price=z,O=K}O&&a.push({order:f,price:O,index:$,isHighFront:C,exitInfo:{from_entry:y,comment:N||v,qty:M}})}}a.sort(({price:f,index:d,isHighFront:h},{price:p,index:g})=>d!==g?d-g:h?d===1?f-p:p-f:d===1?p-f:f-p);for(const f of a){const{order:d,price:h,exitInfo:p}=f;this._processExitOnClose(d,h,p)}}_calcTrailStopPrice(t,e,r,n,s,a,l){let c=t,f;const d=Xa(a===1?e:r,yo(s*a,this._mintick));let h=1;return a===1?l?(c<d&&(c=d),c>=r&&(h=2,f=c)):c>=r?(h=1,f=c):d>c&&(c=d,d>=n&&(h=3,f=d)):l?c<=e?(h=1,f=c):d<c&&(c=d,d<=n&&(h=3,f=d)):(d<c&&(c=d),c<=e&&(h=2,f=c)),[c,f,h]}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const t=[],e=this._pendingOrders.filter(n=>n.place_order_type==="exit"),r=this._pendingOrders.filter(n=>["close","close_all"].includes(n.place_order_type||""));for(const n of this._pendingOrders){const{isCancel:s,place_order_type:a}=n;if(s)continue;let l;switch(a){case"entry":l=this._entryOrderHandle(n);break;case"order":l=this._orderOrderHandle(n);break}l&&t.push(l)}for(const n of r)switch(n.place_order_type){case"close":const s=this._closeOrderHandle(n);s&&t.push(s);break;case"close_all":const{open:a}=this.calcOnOrderFillsData.data||this._variables;this._closeAllOrders(n,a);break}for(const n of e){const s=this._exitOrderHandle(n);s&&t.push(s)}this._pendingOrders=t}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const t=this._pendingCloseOrders.filter(n=>n.place_order_type==="exit"),e=this._pendingCloseOrders.filter(n=>["close","close_all"].includes(n.place_order_type||"")),{close:r}=this.calcOnOrderFillsData.data||this._variables;this._pendingCloseOrders=[];for(const n of e)switch(n.place_order_type){case"close":const s=this._closeOrderHandle(n,!0);s&&this._pendingCloseOrders.push(s);break;case"close_all":this._closeAllOrders(n,r);break}for(const n of t){const{from_entry:s}=n,a=this._orders.filter(l=>!s||l.id===s&&(l.isMarketPriceLimit||l.isMarketPriceStop));for(const l of a)this._processExitOnClose(l,l.limit||l.stop||l.trail_stop_price||r,n)}}_entryOrderHandle(t){const{open:e,low:r,high:n}=this.calcOnOrderFillsData.data||this._variables,{isMarketPrice:s,qty:a=0,in_price:l,direction:c,active_price:f}=t;if(f&&n>=f&&r<=f)return delete t.active_price,t;let d=l;if(s&&(d=e),d<=n&&d>=r){const h=this._orders.filter(p=>p.direction!==c);this._entryOrder(h,d,a,t)}else return t}_orderOrderHandle(t){const{time:e,bar_index:r}=this._variables,{open:n,low:s,high:a}=this.calcOnOrderFillsData.data||this._variables,{slippage:l=0}=this._options,{isMarketPrice:c,qty:f=0,in_price:d,direction:h,comment:p,oca_name:g,oca_type:w,active_price:_,id:y}=t;if(_&&a>=_&&s<=_)return delete t.active_price,t;let v=d,x=f;if(c&&(v=n),v<=a&&v>=s){const b=this._orders.filter(E=>E.direction!==h);if(b.length&&(x=this._processOrders(b,v,f,y,p,!1,"order"),x<=0))return;const M=h===se.long?1:-1;this._ocaGroupVerify(x,g,w),this._calcCurrentOrder({...t,in_price:v+M*l*this._mintick,in_index:r,in_time:e,in_high:a,in_low:s,qty:x});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:s=100,comment:a,immediately:l}=t,{close_entries_rule:c="FIFO"}=this._options;let f=[];if(c==="FIFO"?f=this._orders.filter(g=>g.id===r):f=this._orders.filter(g=>g.id===r&&!g.close_qty),!f.length)return t;let d=0;if(n?d=n:(d=f.reduce((g,w)=>g+(w.qty||0),d),d=s/100*d),d<=0)return;const{open:h,close:p}=this.calcOnOrderFillsData.data||this._variables;if(c==="FIFO")this._processOrders(f,e?p:h,d,`Close entry(s) order ${r}`,a,!1,"close",l);else if(this._processCloseOrders(f,e?p:h,d,`Close entry(s) order ${r}`,a,l))return t}_processCloseOrders(t,e,r,n,s,a){let l=!1;for(const c of t)c.close_qty=r,(c.qty||0)>r&&(l=!0),c.immediately=a,c.position_close_type="close",this._processOrder(c,e,r,n,s);return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_exitOrderHandle(t){const{from_entry:e}=t,r=this._orders.filter(n=>(!e||e===n.id)&&!n.hasExit);if(!(r.length&&!this._ordersToExit(r,t,!0)))return t}_exit(t,e){if(!t.hasOwnProperty("profit")&&!t.hasOwnProperty("loss")&&!t.hasOwnProperty("stop")&&!t.hasOwnProperty("limit")&&(!t.hasOwnProperty("trail_offset")||!t.hasOwnProperty("trail_price")&&!t.hasOwnProperty("trail_points"))){this._errorListener.addError(ce.strategyExitErr,e,zt.Error);return}const{profit:r,loss:n,stop:s,limit:a,trail_offset:l,trail_price:c,trail_points:f,from_entry:d="",id:h}=t;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(s)&&this._isNaN(a)&&(this._isNaN(l)||this._isNaN(f)&&this._isNaN(c)))return;const p={...t,place_order_type:"exit"},g=this._orders.filter(y=>(!d||d===y.id)&&!y.hasExit),w=this._pendingOrders.filter(y=>!d||d===y.id);if(g.length){if(!this._ordersToExit(g,p,!1))return}else if(!w.length)return;const _=this._pendingOrders.find(y=>y.id===h&&y.place_order_type==="exit");_?Object.assign(_,{...t}):this._pendingOrders.push(p)}_ordersToExit(t,e,r){const{qty:n,qty_percent:s=100,id:a,comment:l,comment_loss:c,comment_profit:f,comment_trailing:d}=e;let h=n,p=!1;e.comment=l||a;for(const g of t){const{qty:w=0}=g,_=g.direction===se.long?1:-1;h=n?n>=w?w:n:s/100*w,g.out_qty=h,h<w&&(p=!0),Object.assign(g,{out_comment:l||a,comment_loss:c,comment_profit:f,comment_trailing:d}),!(this._stopProfit(g,_,{...e,qty:h},r)||this._stopLoss(g,_,{...e,qty:h},r)||this._trailStopLoss(g,_,{...e,qty:h},r))&&(g.place_order_type="exit")}return p}_addExitPendingCloseOrders(t){t.place_order_type="exit";const e=this._pendingCloseOrders.find(r=>r.id===t.id);e?Object.assign(e,{...t}):this._pendingCloseOrders.push(t)}_stopProfit(t,e,r,n){const{limit:s,profit:a,comment_profit:l,comment:c}=r;let f=s;const{high:d,low:h,close:p}=this.calcOnOrderFillsData.data||this._variables,{in_price:g}=t,{process_orders_on_close:w}=this._options;if(!this._isNaN(a)&&this._isNaN(s)&&(f=g+e*a*this._mintick),t.limit=f,n)return f!==void 0&&f<=d&&f>=h?(r.comment=l||c,this._processExitOnClose(t,f,r),!0):void 0;if(f!==void 0&&(f-p)*e<=0&&(t.isMarketPriceLimit=!0,r.comment=l||c,Object.assign(t,{out_comment:r.comment}),f=p,t.limit=f,w))return this._addExitPendingCloseOrders(r),!0}_stopLoss(t,e,r,n){const{stop:s,loss:a,comment_loss:l,comment:c}=r;let f=s;const{close:d,high:h,low:p}=this.calcOnOrderFillsData.data||this._variables,{in_price:g}=t,{process_orders_on_close:w}=this._options;if(!this._isNaN(a)&&this._isNaN(s)&&(f=g-e*a*this._mintick),t.stop=f,n)return f!==void 0&&f<=h&&f>=p?(r.comment=l||c,this._processExitOnClose(t,f,r),!0):void 0;if(f!==void 0&&(f-d)*e>=0&&(t.isMarketPriceStop=!0,r.comment=l||c,Object.assign(t,{out_comment:r.comment}),f=d,t.stop=f,w))return this._addExitPendingCloseOrders(r),!0}_trailStopLoss(t,e,r,n){const{trail_offset:s,trail_price:a,trail_points:l,comment_trailing:c,comment:f}=r;if(!this._isNaN(s)){const{close:d,high:h,low:p}=this.calcOnOrderFillsData.data||this._variables,{in_price:g}=t,{process_orders_on_close:w}=this._options;let _;if(this._isNaN(a)?this._isNaN(l)||(_=Ey(g,yo(l*e,this._mintick)),console.log("activePrice",_,g,l*e*this._mintick)):_=a,t.trail_offset=s,t.active_price=_,n)return _!==void 0&&_<=h&&_>=p&&s===0?(r.comment=c||f,this._processExitOnClose(t,_,r),!0):void 0;if(_!==void 0&&(_-d)*e<=0){const y=Xa(d,yo(s*e,this._mintick));if((y-d)*e>=0&&(t.trail_stop_price=d,t.isMarketPriceStop=!0,r.comment=c||f,Object.assign(t,{out_comment:r.comment}),w))return this._addExitPendingCloseOrders(r),!0;t.trail_stop_price=y}}}_processExitOnClose(t,e,r){const{qty:n=0,comment:s,id:a}=r,{close_entries_rule:l="FIFO"}=this._options;if(l==="FIFO"){const c=this._processExitOrders(this._orders,e,n,a,s);c&&!c.hasExit?(c.hasExit=!0,Object.assign(t,{trail_stop_price:c.trail_stop_price,stop:c.stop,limit:c.limit,trail_offset:c.trail_offset,active_price:c.active_price})):c&&(t.hasExit=!0)}else t.hasExit=!0,this._processOrders([t],e,n,a,s,!1,"exit")}_processExitOrders(t,e,r,n,s){let a=r,l;for(const c of t)if(l=c,c.position_close_type="exit",a=this._processOrder(c,e,a,n,s),a<=0)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_processOrder(t,e,r,n,s,a=!1){const{time:l,bar_index:c}=this._variables,{low:f,high:d}=this.calcOnOrderFillsData.data||this._variables,{slippage:h=0}=this._options,{in_price:p,qty:g=0,max_profit:w,trading_loss:_,direction:y,commission:v=0,original_qty:x=0}=t,b=y===se.long?1:-1;if(e=e-b*h*this._mintick,r<g){const M=g-r,E=(e-p)*b*r,F=w!==void 0?w/g*r:void 0,N=_!==void 0?_/g*r:void 0,S=v*M/x;this._calcPercent({...t,out_price:e,last_commission:S,out_id:n,out_index:c,out_high:d,out_low:f,out_time:l,out_comment:s,profit:E,out_qty:r,max_profit:F,trading_loss:N});const T=(e-p)*b*M-S;Object.assign(t,{qty:M,profit:T,max_profit:w!==void 0?w-(F||0):void 0,trading_loss:_!==void 0?_-(N||0):void 0,total_profit:this._totalChangeCapital+T}),r=0}else{t.isDeal=!0;const M=(e-p)*b*g;this._calcPercent({...t,out_price:e,out_id:n,out_index:c,out_high:d,out_low:f,out_time:l,out_comment:s,out_qty:g,profit:M}),r-=g}return a&&(b===1?this._variables.strategy.marginCallLong++:this._variables.strategy.marginCallShort++),r}_calcPercent(t){const{commission_value:e,process_orders_on_close:r}=this._options,{in_price:n,out_qty:s=0,out_price:a=0,original_qty:l=0,direction:c,last_commission:f=0,immediately:d}=t;let{profit:h=0,max_profit:p,trading_loss:g,commission:w=0}=t,_=n*s,y=this._totalChangeCapital+this._options.initial_capital;if(this._totalChangeCapital+=h,e){const v=this._getCommission(a,s);this._totalChangeCapital-=v;let x=w*s/l;_+=x,x+=v,h=h-x,Object.assign(t,{commission:x,profit:h});const b=this._orders.reduce((M,E)=>{const{qty:F=0,original_qty:N=0,commission:S=0}=E;return M+S*F/N},0);y+=b-f}if(p===void 0||g===void 0){const v=c===se.long?1:-1,x=this._calcProfitAndLossHandle(n,s,v);if(p=x[0],g=x[1],e){const b=w*s/l;p-=b,g-=b}p=Math.max(0,p),g=Math.min(0,g)}Object.assign(t,{max_profit:p,trading_loss:g,total_profit:this._totalChangeCapital,total_profit_percent:h/y*100,profit_percent:h/_*100,max_profit_percent:p/_*100,trading_loss_percent:g/_*100}),this._maxDrawdownVerifyIndex=this._variables.bar_index+(r?1:0),this._risk.intradayOrders+=1,this._historyOrder.push(t),this._calcOrderFillsHandle(n,c,d)}_getCommission(t,e){const{commission_value:r=0,commission_type:n}=this._options,s=t*e;let a=0;switch(n){case je.percent:a=s*r/100;break;case je.cashPerContract:a=e*r;break;case je.cashPerOrder:a=r;break}return a}_calcCurrentOrder(t){const{commission_value:e}=this._options,{in_price:r,qty:n=0,max_profit:s=0,trading_loss:a=0,direction:l,immediately:c}=t;let{profit:f=0}=t,d=r*n;const h=this._totalChangeCapital+this._options.initial_capital;if(e){const p=this._getCommission(r,n);this._totalChangeCapital-=p,f=f-p,d+=p,Object.assign(t,{commission:p,profit:f,total_profit:this._totalChangeCapital})}Object.assign(t,{original_qty:n,total_profit_percent:f/h*100,profit_percent:f/d*100,max_profit_percent:s/d*100,trading_loss_percent:a/d*100,stop:void 0,limit:void 0}),this._risk.intradayOrders+=1,this._orders.push(t),this._variables.strategy.updateOrders(this._orders),e&&this._variables.strategy.updateHistoryOrders(this._historyOrder),this._calcOrderFillsHandle(r,l,c)}_calcOrderFillsHandle(t,e,r=!1){const{calc_on_order_fills:n,process_orders_on_close:s,slippage:a=0}=this._options;if(n){const{open:l,high:c,low:f,close:d}=this._variables,h=e===se.long?1:-1,p=d-h*a*this._mintick;if((r||s)&&t===p)return;const g=l-h*a*this._mintick;let w={open:l,high:c,low:f,close:d},_=this.calcOnOrderFillsData.index;const y=Math.abs(c-l)<=Math.abs(f-l);switch(_){case-1:t===g?_=0:t>g?y?(_=1,w={open:c,high:c,low:f,close:d}):(_=2,w={open:c,high:c,low:d,close:d}):y?(_=2,w={open:f,high:d,low:f,close:d}):(_=1,w={open:f,high:c,low:f,close:d});break;case 0:t===g?(_=1,y?w={open:c,high:c,low:f,close:d}:w={open:f,high:c,low:f,close:d}):t>g?y?(_=1,w={open:c,high:c,low:f,close:d}):(_=2,w={open:c,high:c,low:d,close:d}):y?(_=2,w={open:f,high:d,low:f,close:d}):(_=1,w={open:f,high:c,low:f,close:d});break;case 1:_=2,y?w={open:f,high:d,low:f,close:d}:w={open:c,high:c,low:d,close:d};break;case 2:_=-1,w=void 0;break}this.calcOnOrderFillsData={tradeData:w,index:_}}}_isNaN(t){return t===void 0||isNaN(t)}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}};var vh={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){return function(e,r,n){r.prototype.isBetween=function(s,a,l,c){var f=n(s),d=n(a),h=(c=c||"()")[0]==="(",p=c[1]===")";return(h?this.isAfter(f,l):!this.isBefore(f,l))&&(p?this.isBefore(d,l):!this.isAfter(d,l))||(h?this.isBefore(f,l):!this.isAfter(f,l))&&(p?this.isAfter(d,l):!this.isBefore(d,l))}}})})(vh);var Cy=vh.exports,Fy=Gt(Cy),wh={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){return function(e,r,n){var s=r.prototype,a=function(p){var g,w=p.date,_=p.utc,y={};if(!((g=w)===null||g instanceof Date||g instanceof Array||s.$utils().u(g)||g.constructor.name!=="Object")){if(!Object.keys(w).length)return new Date;var v=_?n.utc():n();Object.keys(w).forEach(function(T){var C,O;y[C=T,O=s.$utils().p(C),O==="date"?"day":O]=w[T]});var x=y.day||(y.year||y.month>=0?1:v.date()),b=y.year||v.year(),M=y.month>=0?y.month:y.year||y.day?0:v.month(),E=y.hour||0,F=y.minute||0,N=y.second||0,S=y.millisecond||0;return _?new Date(Date.UTC(b,M,x,E,F,N,S)):new Date(b,M,x,E,F,N,S)}return w},l=s.parse;s.parse=function(p){p.date=a.bind(this)(p),l.bind(this)(p)};var c=s.set,f=s.add,d=s.subtract,h=function(p,g,w,_){_===void 0&&(_=1);var y=Object.keys(g),v=this;return y.forEach(function(x){v=p.bind(v)(g[x]*_,x)}),v};s.set=function(p,g){return g=g===void 0?p:g,p.constructor.name==="Object"?h.bind(this)(function(w,_){return c.bind(this)(_,w)},g,p):c.bind(this)(p,g)},s.add=function(p,g){return p.constructor.name==="Object"?h.bind(this)(f,p,g):f.bind(this)(p,g)},s.subtract=function(p,g){return p.constructor.name==="Object"?h.bind(this)(f,p,g,-1):d.bind(this)(p,g)}}})})(wh);var My=wh.exports,Ny=Gt(My),yh={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){var e,r,n=1e3,s=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,f=31536e6,d=2628e6,h=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,p={years:f,months:d,days:l,hours:a,minutes:s,seconds:n,milliseconds:1,weeks:6048e5},g=function(F){return F instanceof M},w=function(F,N,S){return new M(F,S,N.$l)},_=function(F){return r.p(F)+"s"},y=function(F){return F<0},v=function(F){return y(F)?Math.ceil(F):Math.floor(F)},x=function(F){return Math.abs(F)},b=function(F,N){return F?y(F)?{negative:!0,format:""+x(F)+N}:{negative:!1,format:""+F+N}:{negative:!1,format:""}},M=function(){function F(S,T,C){var O=this;if(this.$d={},this.$l=C,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),T)return w(S*p[_(T)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(q){O.$d[_(q)]=S[q]}),this.calMilliseconds(),this;if(typeof S=="string"){var $=S.match(h);if($){var W=$.slice(2).map(function(q){return q!=null?Number(q):0});return this.$d.years=W[0],this.$d.months=W[1],this.$d.weeks=W[2],this.$d.days=W[3],this.$d.hours=W[4],this.$d.minutes=W[5],this.$d.seconds=W[6],this.calMilliseconds(),this}}return this}var N=F.prototype;return N.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(T,C){return T+(S.$d[C]||0)*p[C]},0)},N.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/f),S%=f,this.$d.months=v(S/d),S%=d,this.$d.days=v(S/l),S%=l,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/s),S%=s,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},N.toISOString=function(){var S=b(this.$d.years,"Y"),T=b(this.$d.months,"M"),C=+this.$d.days||0;this.$d.weeks&&(C+=7*this.$d.weeks);var O=b(C,"D"),$=b(this.$d.hours,"H"),W=b(this.$d.minutes,"M"),q=this.$d.seconds||0;this.$d.milliseconds&&(q+=this.$d.milliseconds/1e3,q=Math.round(1e3*q)/1e3);var U=b(q,"S"),z=S.negative||T.negative||O.negative||$.negative||W.negative||U.negative,K=$.format||W.format||U.format?"T":"",Z=(z?"-":"")+"P"+S.format+T.format+O.format+K+$.format+W.format+U.format;return Z==="P"||Z==="-P"?"P0D":Z},N.toJSON=function(){return this.toISOString()},N.format=function(S){var T=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 T.replace(c,function(O,$){return $||String(C[O])})},N.as=function(S){return this.$ms/p[_(S)]},N.get=function(S){var T=this.$ms,C=_(S);return C==="milliseconds"?T%=1e3:T=C==="weeks"?v(T/p[C]):this.$d[C],T||0},N.add=function(S,T,C){var O;return O=T?S*p[_(T)]:g(S)?S.$ms:w(S,this).$ms,w(this.$ms+O*(C?-1:1),this)},N.subtract=function(S,T){return this.add(S,T,!0)},N.locale=function(S){var T=this.clone();return T.$l=S,T},N.clone=function(){return w(this.$ms,this)},N.humanize=function(S){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},N.valueOf=function(){return this.asMilliseconds()},N.milliseconds=function(){return this.get("milliseconds")},N.asMilliseconds=function(){return this.as("milliseconds")},N.seconds=function(){return this.get("seconds")},N.asSeconds=function(){return this.as("seconds")},N.minutes=function(){return this.get("minutes")},N.asMinutes=function(){return this.as("minutes")},N.hours=function(){return this.get("hours")},N.asHours=function(){return this.as("hours")},N.days=function(){return this.get("days")},N.asDays=function(){return this.as("days")},N.weeks=function(){return this.get("weeks")},N.asWeeks=function(){return this.as("weeks")},N.months=function(){return this.get("months")},N.asMonths=function(){return this.as("months")},N.years=function(){return this.get("years")},N.asYears=function(){return this.as("years")},F}(),E=function(F,N,S){return F.add(N.years()*S,"y").add(N.months()*S,"M").add(N.days()*S,"d").add(N.hours()*S,"h").add(N.minutes()*S,"m").add(N.seconds()*S,"s").add(N.milliseconds()*S,"ms")};return function(F,N,S){e=S,r=S().$utils(),S.duration=function(O,$){var W=S.locale();return w(O,{$l:W},$)},S.isDuration=g;var T=N.prototype.add,C=N.prototype.subtract;N.prototype.add=function(O,$){return g(O)?E(this,O,1):T.bind(this)(O,$)},N.prototype.subtract=function(O,$){return g(O)?E(this,O,-1):C.bind(this)(O,$)}}})})(yh);var Sy=yh.exports,Oy=Gt(Sy);ee.extend(ql),ee.extend(Fy),ee.extend(Ny),ee.extend(Oy);class Dh{constructor(t,e,r){L(this,"array");L(this,"color");L(this,"math");L(this,"str");L(this,"map");L(this,"matrix");L(this,"timeframe");L(this,"ta");L(this,"input");L(this,"_variables");L(this,"_cacheData");L(this,"_options");L(this,"_errorListener");L(this,"_plots");L(this,"_plotshapes");L(this,"_plotbars");L(this,"_plotchars");L(this,"_plotarrows");L(this,"_plotcandles");L(this,"_alerts");L(this,"_bgColors");L(this,"_hlines");L(this,"_fills");L(this,"chart");L(this,"line");L(this,"label");L(this,"polyline");L(this,"box");L(this,"table");L(this,"linefill");L(this,"log");L(this,"runtime");L(this,"strategy");L(this,"request");L(this,"syminfo");L(this,"_count",0);var s;const n=((s=t.toString().split(".")[1])==null?void 0:s.length)||5;this._variables=e,this._errorListener=new Ly,this.array=new fp(this._errorListener),this.math=new hp(n,this._errorListener),this.color=new R1,this.str=new Pw(this._errorListener,n),this.map=new zw(this._errorListener),this.timeframe=new Rw(e),this.matrix=new Lw(this._errorListener),this.ta=new $1(e,this.math,this.timeframe),this._cacheData={},this._options={},this._bgColors={},this._alerts=new Map,this._hlines=new Map,this._fills=new Map,this.input=new L1(e,this._errorListener,r),this._plots=new Map,this._plotshapes=new Map,this._plotbars=new Map,this._plotcandles=new Map,this._plotchars=new Map,this._plotarrows=new Map,this.chart={point:new kw(e)},this.line=new ly(e,this._errorListener),this.label=new qw(e,this._errorListener),this.polyline=new uy(e,this._errorListener),this.box=new fy(e,this._errorListener),this.table=new hy(e,this._errorListener),this.linefill=new cy(e),this.log=new Ty(e),this.runtime=new $y(this._errorListener),this.strategy=new Ay(this._variables,this._options,t,this._errorListener,r),this.request=new By(this._variables,r),this.syminfo=new Iy}get errors(){return this._errorListener.errors}options(t){if(t.length)return this._getDataOfBarindex(t);const e=this.input.getInputs(),r=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const n=Object.keys(this._bgColors);let s;if(n.length){s={};for(const v of n)s[v]=[...this._bgColors[v].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,l=this._fills.size?[...this._fills.values()]:void 0,c=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders,strategySummary:this._variables.strategy.summaryData});const f=this._plots.size>0?[...this._plots.values()]:void 0,d=this._plotbars.size>0?[...this._plotbars.values()]:void 0,h=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,p=this._plotarrows.size>0?[...this._plotarrows.values()]:void 0,g=this._plotcandles.size>0?[...this._plotcandles.values()]:void 0,w=this._plotchars.size>0?[...this._plotchars.values()]:void 0,_=this._getDraws(),y=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:e,plots:f,draws:_,alerts:r,colors:s,hlines:a,fills:l,logs:c,plotshapes:h,plotarrows:p,plotcandles:g,plotchars:w,plotbars:d,isUseBgColor:y})}_getDataOfBarindex(t){const e=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const r=Object.keys(this._bgColors);let n;if(r.length){n={};for(const p of r)n[p]=[...this._bgColors[p].values()].map(g=>{const w=[];for(const _ of t){const y=g.colors[_];y&&w.push(y)}return g.colors=w,g})}const s=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(t,[...this._fills.values()]):void 0,l=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const c=this._getDataFromBarindex(t,[...this._plots.values()]),f=this._plotshapes.size>0?this._getDataFromBarindex(t,[...this._plotshapes.values()]):void 0,d=this._getDrawsFromBarindex(t),h=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,draws:d,alerts:e,colors:n,hlines:s,fills:a,logs:l,plotshapes:f,isUseBgColor:h})}_getDataFromBarindex(t,e){return e.map(r=>{const n=[];for(const s of t){const a=r.data[s];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:s,label:a}=this._variables,l={};return t.data.length&&(l.lines=t.data),e.data.length&&(l.linefills=e.data),r.data.length&&(l.tables=r.data),n.data.length&&(l.boxes=n.data),s.data.length&&(l.polylines=s.data),a.data.length&&(l.labels=a.data),Object.keys(l).length?l:void 0}_getDrawsFromBarindex(t){const{line:e,linefill:r,table:n,box:s,polyline:a,label:l}=this._variables,c={};return e.data.length&&(c.lines=e.getValOfBarIndex(t)),r.data.length&&(c.linefills=r.getValOfBarIndex(t)),n.data.length&&(c.tables=n.getValOfBarIndex(t)),s.data.length&&(c.boxes=s.getValOfBarIndex(t)),a.data.length&&(c.polylines=a.getValOfBarIndex(t)),l.data.length&&(c.labels=l.getValOfBarIndex(t)),Object.keys(c).length?c:void 0}updateOptions(t){const{inputs:e,strategy:r}=t;this.input.update(e),r&&this.strategy.updateOptions(r)}update(t){const{barIndex:e}=t;this.strategy.update(),this.math.update(e)}endExecution(){this.strategy.endExecution()}library(t,e){if(!this._variables.bar_index){const r=/^[^\W\d\s][^\W\s]*$/,{title:n}=t;r.test(n)?(cp.includes(n)||lp.includes(n))&&this._errorListener.addError(Ze(ce.libraryTitleIsKeywordErr,{name:n}),e,zt.Error):this._errorListener.addError(ce.libraryTitleErr,e,zt.Error),this._options.scriptType="library",this._options.library=t}}indicator(t,e){if(!this._variables.bar_index){const{format:r}=t;this._paramVerfiy(r,e,"indicator",[Kt.inherit,Kt.percent,Kt.price,Kt.volume]),this._variables.updateMaxLength(t),this._options.scriptType="indicator",this._options.indicator=t}}_paramVerfiy(t="",e,r,n,s="format"){t&&!n.includes(t)&&this._errorListener.addError(Ze(ce.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,zt.Error)}_lineWidthVerify(t,e){const{linewidth:r=1}=t;r<1&&(this._errorListener.addError(ap.lineWidthWarning,e,zt.Warning),t.linewidth=1)}plot(t,e){const r=["color"];ge(t,r);const{series:n,color:s,...a}=t,{bar_index:l,time:c}=this._variables,f=`plot_${e}`,d=this._plots.get(f),h=(d==null?void 0:d.data)||[],p=n!==void 0&&isNaN(n)?void 0:n;if(h[l]={value:[c,p],itemStyle:{color:s}},this._seriesColorHandle(t,r,d),!d){this._count++,this._lineWidthVerify(a,e),this._paramVerfiy(t.format,e,"plot",[Kt.percent,Kt.price,Kt.volume]);const g=s?[s]:void 0;this._plots.set(f,{editable:!0,...a,colors:g,data:h,id:f,zIndex:this._count})}return{type:"plot",key:f}}plotbar(t,e){const r=["color"];ge(t,r);const{open:n,close:s,low:a,high:l,color:c,...f}=t,{bar_index:d,time:h}=this._variables,p=`plotbar_${e}`,g=this._plotbars.get(p),w=(g==null?void 0:g.data)||[],_=s!==void 0&&isNaN(s)?void 0:s,y=n!==void 0&&isNaN(n)?void 0:n,v=a!==void 0&&isNaN(a)?void 0:a,x=l!==void 0&&isNaN(l)?void 0:l,b=[h,y,_,v,x];if(w[d]={value:b,itemStyle:{color:c}},this._seriesColorHandle(t,r,g),!g){this._count++,this._paramVerfiy(t.format,e,"plotbar",[Kt.percent,Kt.price,Kt.volume]);const M=c?[c]:void 0;this._plotbars.set(p,{editable:!0,...f,colors:M,data:w,id:p,zIndex:this._count})}}_verfiyArgs(t,e,r){const{size:n,format:s,location:a,style:l}=t;this._paramVerfiy(l,r,e,Object.values(lr),"style"),this._paramVerfiy(a,r,e,Object.values(ln),"location"),this._paramVerfiy(n,r,e,Object.values(ir),"size"),this._paramVerfiy(s,r,e,[Kt.percent,Kt.price,Kt.volume],"format")}plotchar(t,e){const r=["color","textcolor"];ge(t,r);const{series:n,color:s,textcolor:a,location:l=ln.abovebar,...c}=t,{bar_index:f,time:d,high:h,low:p}=this._variables,g=`plotchar_${e}`,w=this._plotchars.get(g),_=(w==null?void 0:w.data)||[],y={value:[d,n],itemStyle:{color:s,textcolor:a},low:p,high:h};_[f]=y,this._seriesColorHandle(t,r,w),w||(this._count++,this._verfiyArgs(t,"plotchar",e),this._plotchars.set(g,{editable:!0,...c,location:l,data:_,id:g,zIndex:this._count}))}plotarrow(t,e){const r=["colorup","colordown"];ge(t,r);const{series:n,colorup:s,colordown:a,...l}=t,{bar_index:c,time:f,low:d,high:h}=this._variables,p=`plotarrow_${e}`,g=this._plotarrows.get(p),w=(g==null?void 0:g.data)||[];w[c]={value:[f,n!==void 0&&isNaN(n)?void 0:n],itemStyle:{colorup:s,colordown:a},low:d,high:h},this._seriesColorHandle(t,r,g),g||(this._count++,this._paramVerfiy(t.format,e,"plotarrow",[Kt.percent,Kt.price,Kt.volume]),this._plotarrows.set(p,{editable:!0,...l,data:w,id:p,zIndex:this._count}))}plotshape(t,e){const r=["color","textcolor"];ge(t,r);const{series:n,color:s,textcolor:a,location:l=ln.abovebar,...c}=t,{bar_index:f,time:d,low:h,high:p}=this._variables,g=`plotshape_${e}`,w=this._plotshapes.get(g),_=(w==null?void 0:w.data)||[],y={value:n,color:s,textcolor:a,time:d,low:h,high:p};if(_[f]=y,this._seriesColorHandle(t,r,w),!w){this._count++;const v=s?[s]:void 0;this._verfiyArgs(t,"plotshape",e),this._plotshapes.set(g,{editable:!0,...c,data:_,location:l,id:g,colors:v,zIndex:this._count})}}plotcandle(t,e){const r=["wickcolor","bordercolor","color"];ge(t,r);const{wickcolor:n,bordercolor:s,color:a,close:l,open:c,low:f,high:d,...h}=t,{bar_index:p,time:g}=this._variables,w=`plotcandle_${e}`,_=this._plotcandles.get(w),y=(_==null?void 0:_.data)||[],v=l!==void 0&&isNaN(l)?void 0:l,x=c!==void 0&&isNaN(c)?void 0:c,b=f!==void 0&&isNaN(f)?void 0:f,M=d!==void 0&&isNaN(d)?void 0:d,E=[g,x,v,b,M];y[p]={value:E,wickcolor:n,bordercolor:s,color:a},this._seriesColorHandle(t,r,_),_||(this._count++,this._paramVerfiy(t.format,e,"plotcandle",[Kt.percent,Kt.price,Kt.volume]),this._plotcandles.set(w,{editable:!0,...h,data:y,id:w,zIndex:this._count}))}hline(t,e){const r=`hline_${e}`;ge(t,["color"]),this._verifyDisplay(t.display,"hline",e);const s=t.display&&!t.display.length?Ke.none:Ke.all;return this._hlines.has(r)||(this._count++,this._lineWidthVerify(t,e),this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:s,...t,zIndex:this._count})),{type:"hline",key:r}}fill(t,e){var S,T,C,O,$,W,q,U,z,K;const r=["color","top_color","bottom_color"];ge(t,r);const{color:n,top_color:s,bottom_color:a,seriesColors:l,hline1:c,hline2:f,plot1:d,plot2:h,top_value:p,bottom_value:g,...w}=t,{bar_index:_,time:y}=this._variables,v=`fill_${e}`,x=this._fills.get(v),b=(x==null?void 0:x.data)||[];this._verifyDisplay(t.display,"fill",e);const M=t.display&&!t.display.length?Ke.none:Ke.all;let E,F,N="plot";if(c&&f)E=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,F=(T=this._hlines.get(f==null?void 0:f.key))==null?void 0:T.price,N="hline";else{const Z=((C=this._plots.get(d==null?void 0:d.key))==null?void 0:C.data)||[],X=((O=this._plots.get(h==null?void 0:h.key))==null?void 0:O.data)||[];E=(W=($=Z[_])==null?void 0:$.value)==null?void 0:W[1],F=(U=(q=X[_])==null?void 0:q.value)==null?void 0:U[1]}if(b[_]={time:y,color:n,top_color:s,bottom_color:a,plot1:E,plot2:F,top_value:p,bottom_value:g},this._seriesColorHandle(t,r,x),!x){this._count++;const Z=((z=this._options.indicator)==null?void 0:z.explicit_plot_zorder)||((K=this._options.strategy)==null?void 0:K.explicit_plot_zorder),X=n?[n]:void 0,Q=s?[s]:void 0,ct=a?[a]:void 0;this._fills.set(v,{id:v,colors:X,top_colors:Q,bottom_colors:ct,display:M,data:b,type:N,editable:!0,fillgaps:!1,hline1:c,hline2:f,plot1:d,plot2:h,...w,zIndex:Z?this._count:void 0})}}alert({message:t,freq:e=Ur.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:s,last_bar_index:a}=this._variables,l=`alert_${r}`,c=this._cacheData[l]||{},f=c.barIndex;if(this._paramVerfiy(e,r,"alert",[Ur.freqAll,Ur.freqOncePerBar,Ur.freqOncePerBarClose]),e===Ur.freqOncePerBar&&n===f){this._alerts.delete(l);return}this._cacheData[l]=c;const d={message:t,freq:e,id:l,type:"alert"};if(s){e!==Ur.freqOncePerBarClose&&this._alerts.set(l,d),c.barIndex=n;return}if(!s&&e===Ur.freqOncePerBarClose&&n===f&&a===n-1){this._alerts.set(l,d),c.barIndex=n;return}this._alerts.delete(l)}alertcondition({condition:t,message:e,title:r},n){const{_isRealTimeBar:s}=this._variables,a=`alertcondition_${n}`;s&&t?this._alerts.set(a,{message:e,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(t,e){this._setColors(t,"barcolor",e)}bgcolor(t,e){this._setColors(t,"bgcolor",e)}_verifyDisplay(t=fh.all,e,r){t.length&&t.length<4&&this._errorListener.addError(Ze(ce.displayErr,{func:e,values:"[display.none, display.all]"}),r,zt.Error)}_setColors(t,e,r){ge(t,["color"]);const{color:s,...a}=t;this._verifyDisplay(a.display,e,r);const l=t.display&&!t.display.length?Ke.none:Ke.all,{bar_index:c,time:f}=this._variables,d=`${e}_${r}`;this._bgColors[e]||(this._bgColors[e]=new Map);const h=this._bgColors[e].get(d),p=(h==null?void 0:h.colors)||[],g=(h==null?void 0:h.setColors)||[];s&&!g.includes(s)&&g.push(s),p[c]={color:s,time:f},h||this._bgColors[e].set(d,{...a,display:l,colors:p,setColors:g,id:d})}max_bars_back({var:t,num:e,var_name:r}){console.log(t,e,r)}float({x:t}){return t}bool({x:t}){return t||!1}string({x:t}){return t}int({x:t}){return t&&Math.trunc(t)}na({x:t}){return!!(t===void 0||typeof t=="number"&&isNaN(t))}fixnan({source:t},e){return t===void 0||typeof t=="number"&&isNaN(t)?this._cacheData[`fixnan_${e}`]:(this._cacheData[`fixnan_${e}`]=t,t)}nz({source:t,replacement:e}){return t!==void 0&&!(typeof t=="number"&&isNaN(t))?t:e||0}time({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._timeHandle(this._variables.time,s,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._timeHandle(this._variables.time,s,t,e,r,n,!0)}timestamp(t){const{dateString:e,timezone:r,year:n,month:s,day:a,hour:l=0,minute:c=0,second:f=0}=t;if(e)return ee(e).utc(!/GMT|UTC/.test(e)).valueOf();let d=s-1,h=n;if(d<0){const g=Math.ceil(Math.abs(d/12));d=12*g+d,h=n-g}let p=ee({year:h,month:d,day:a,hour:l,minute:c,second:f});return r&&(p=qr(p.utc(!0).valueOf(),r)),p.utc(!0).valueOf()}weekofyear({time:t,timezone:e}){return qr(t,e).week()}year({time:t,timezone:e}){return qr(t,e).year()}second({time:t,timezone:e}){return qr(t,e).second()}month({time:t,timezone:e}){return qr(t,e).month()+1}minute({time:t,timezone:e}){return qr(t,e).minute()}hour({time:t,timezone:e}){return qr(t,e).hour()}dayofweek({time:t,timezone:e}){return qr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return qr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,this._variables.timeframe.period),n=tn(e)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,s,a=0,l=!1){const c=r||this._variables.timeframe.period,f=tn(c),d=tn(this._variables.timeframe.period);let h;if(f<=d)h=t,l&&(h+=d*1e3);else{const p=`time_${e}`,g=this._cacheData[p];if(g)g.currentTime+f*1e3-g.offset<=t?(h=t,this._cacheData[p]={currentTime:t,offset:0}):h=g.currentTime;else{const w=this._calcTimeOffset(t,c);this._cacheData[p]={currentTime:t,offset:w},h=t}l&&(h+=f*1e3)}if(n){const{timePeriods:p,weeks:g}=this._parserSession(n,e),w=ee(t).format("YYYY-MM-DD"),_=h;h=void 0;for(const v of p){const[x,b]=v;if(ee(t).isBetween(`${w} ${x}`,`${w} ${b}`,"hour")){ee(_).isBetween(`${w} ${x}`,`${w} ${b}`,"hour")?h=_:h=ee(`${w} ${x}`).valueOf();break}}const y=this._variables.dayofweek;h&&!g.includes(y)&&(h=void 0)}return s&&(h=h&&qr(h,s).valueOf()),h&&h-a*d*1e3}_seriesColorHandle(t,e,r){var n;if(r&&e!=null&&e.length)for(const s of e){if((n=r.gradientColorKeys)!=null&&n.includes(s))continue;const a=t[s];if(!a)continue;const l=r[`${s}s`]||[];l.includes(a)||(l.push(a),r[`${s}s`]=l,l.length>5&&(r[`${s}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(s)))}}_parserSession(t,e){const r=t.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(c=>{const f=parseInt(c,10);if(f<1||f>7){this._errorListener.addError(`Invalid day of week: ${c}`,e,zt.Error);return}return f});return{timePeriods:n.split(",").map(c=>{c===""||c===gi.regular?c="0930-1500":c===gi.extended&&(c="1500-1830");const f=c.split("-");return f.length!==2?(this._errorListener.addError(`Invalid time period: ${c}`,e,zt.Error),[]):[this._processTime(f[0],e),this._processTime(f[1],e)]}),weeks:a}}_processTime(t,e){const r=parseInt(t.slice(0,2),10),n=parseInt(t.slice(2),10);if(!(r>=0&&r<=23)&&n>=0&&n<=59){this._errorListener.addError("Invalid time: Time must be within 00:00 to 23:59",e,zt.Error);return}return`${r}:${n}`}}class By{constructor(t,e){L(this,"_variables");L(this,"_scriptId");L(this,"_cacheData");this._variables=t,this._scriptId=e,this._cacheData=new Map}security(t,e){const r=self.workerStorage.get(`request_${this._scriptId}`),{paramsExpr:n=[]}=t,s=this._getRequestData(t,e);if(r!=null&&r.has(e)){const c=r.get(e);return this._runScripts(c,e,!1,n,s)}const a=this._parseExprCode(t),l=this._runScripts(a,e,!0,n,s);return r==null||r.set(e,a),l}_parseExprCode(t){let{expression:e,paramsExpr:r=[]}=t,n=[],s=1;e=jl(e);const a=JSON.parse(e),l=a.pop();let c=(l==null?void 0:l.memberCodes)||{},f=(l==null?void 0:l.depends)||[];if(!f.length)return`return ${l==null?void 0:l.code}`;let d=[],h=[];const p=[];if(this._getDependCodes(f,a,n,d,h,p),n.push(...p),h.length){const _=r.length;let y=[];for(let v=_-1;v>=0;v--){const x=r[v];let b=JSON.parse(jl(x));const M=[];s!==0&&h.length&&(y.unshift("{"),s++),b=b.map(S=>{const{scope:T,code:C,varNames:O,dependSelf:$}=S;return T===2&&!M.includes(O)&&!$&&(S.code=`let ${C}`),O&&M.push(...O.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const E=[],F=[];let N=h.map(S=>({...S,isArg:!1,isPreArg:!0}));h=[],this._getDependCodes(N,b,F,d,h,E),y.unshift(...F,...E),n=y.concat(n),y=[]}}for(n.push(`return ${l==null?void 0:l.code}`);s>1;)n.push("}"),s--;n=d.concat(n);let g=n.join(`
63
- `);const w=[];for(const _ of Object.keys(c))g.includes(`$_var.getCacheData("${_}"`)&&w.push(c[_]);return w.length&&(g=`${w.join(`
60
+ }`}function Z1(i,t,e,r,n){const{rows:s,columns:a}=i,l=Math.min(s,t),c=Math.min(a,e),h=[];if(n==="auto"){n=!1;t:for(let d=0;d<l;d++)for(let f=0;f<c;f++)if(i.get(d,f)<0){n=!0;break t}}for(let d=0;d<l;d++){let f=[];for(let p=0;p<c;p++)f.push(K1(i.get(d,p),r,n));h.push(`${f.join(" ")}`)}return c!==a&&(h[h.length-1]+=` ... ${a-e} more columns`),l!==s&&h.push(`... ${s-t} more rows`),h.join(`
61
+ ${Jf}`)}function K1(i,t,e){return(i>=0&&e?` ${Qf(i,t-1)}`:Qf(i,t)).padEnd(t)}function Qf(i,t){let e=i.toString();if(e.length<=t)return e;let r=i.toFixed(t);if(r.length>t&&(r=i.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=i.toExponential(t);return n.length>t&&(n=i.toExponential(Math.max(0,t-(n.length-t)))),n.slice(0)}function G1(i,t){i.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},i.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r);return this},i.prototype.addM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)+r.get(n,s));return this},i.add=function(r,n){return new t(r).add(n)},i.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},i.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r);return this},i.prototype.subM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)-r.get(n,s));return this},i.sub=function(r,n){return new t(r).sub(n)},i.prototype.subtract=i.prototype.sub,i.prototype.subtractS=i.prototype.subS,i.prototype.subtractM=i.prototype.subM,i.subtract=i.sub,i.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},i.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r);return this},i.prototype.mulM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)*r.get(n,s));return this},i.mul=function(r,n){return new t(r).mul(n)},i.prototype.multiply=i.prototype.mul,i.prototype.multiplyS=i.prototype.mulS,i.prototype.multiplyM=i.prototype.mulM,i.multiply=i.mul,i.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},i.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r);return this},i.prototype.divM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)/r.get(n,s));return this},i.div=function(r,n){return new t(r).div(n)},i.prototype.divide=i.prototype.div,i.prototype.divideS=i.prototype.divS,i.prototype.divideM=i.prototype.divM,i.divide=i.div,i.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},i.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r);return this},i.prototype.modM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)%r.get(n,s));return this},i.mod=function(r,n){return new t(r).mod(n)},i.prototype.modulus=i.prototype.mod,i.prototype.modulusS=i.prototype.modS,i.prototype.modulusM=i.prototype.modM,i.modulus=i.mod,i.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},i.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r);return this},i.prototype.andM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)&r.get(n,s));return this},i.and=function(r,n){return new t(r).and(n)},i.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},i.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r);return this},i.prototype.orM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)|r.get(n,s));return this},i.or=function(r,n){return new t(r).or(n)},i.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},i.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r);return this},i.prototype.xorM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)^r.get(n,s));return this},i.xor=function(r,n){return new t(r).xor(n)},i.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},i.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r);return this},i.prototype.leftShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)<<r.get(n,s));return this},i.leftShift=function(r,n){return new t(r).leftShift(n)},i.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},i.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r);return this},i.prototype.signPropagatingRightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>r.get(n,s));return this},i.signPropagatingRightShift=function(r,n){return new t(r).signPropagatingRightShift(n)},i.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},i.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r);return this},i.prototype.rightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,this.get(n,s)>>>r.get(n,s));return this},i.rightShift=function(r,n){return new t(r).rightShift(n)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.prototype.not=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,~this.get(r,n));return this},i.not=function(r){return new t(r).not()},i.prototype.abs=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.abs(this.get(r,n)));return this},i.abs=function(r){return new t(r).abs()},i.prototype.acos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acos(this.get(r,n)));return this},i.acos=function(r){return new t(r).acos()},i.prototype.acosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acosh(this.get(r,n)));return this},i.acosh=function(r){return new t(r).acosh()},i.prototype.asin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asin(this.get(r,n)));return this},i.asin=function(r){return new t(r).asin()},i.prototype.asinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asinh(this.get(r,n)));return this},i.asinh=function(r){return new t(r).asinh()},i.prototype.atan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atan(this.get(r,n)));return this},i.atan=function(r){return new t(r).atan()},i.prototype.atanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atanh(this.get(r,n)));return this},i.atanh=function(r){return new t(r).atanh()},i.prototype.cbrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cbrt(this.get(r,n)));return this},i.cbrt=function(r){return new t(r).cbrt()},i.prototype.ceil=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.ceil(this.get(r,n)));return this},i.ceil=function(r){return new t(r).ceil()},i.prototype.clz32=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.clz32(this.get(r,n)));return this},i.clz32=function(r){return new t(r).clz32()},i.prototype.cos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cos(this.get(r,n)));return this},i.cos=function(r){return new t(r).cos()},i.prototype.cosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cosh(this.get(r,n)));return this},i.cosh=function(r){return new t(r).cosh()},i.prototype.exp=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.exp(this.get(r,n)));return this},i.exp=function(r){return new t(r).exp()},i.prototype.expm1=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.expm1(this.get(r,n)));return this},i.expm1=function(r){return new t(r).expm1()},i.prototype.floor=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.floor(this.get(r,n)));return this},i.floor=function(r){return new t(r).floor()},i.prototype.fround=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.fround(this.get(r,n)));return this},i.fround=function(r){return new t(r).fround()},i.prototype.log=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log(this.get(r,n)));return this},i.log=function(r){return new t(r).log()},i.prototype.log1p=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log1p(this.get(r,n)));return this},i.log1p=function(r){return new t(r).log1p()},i.prototype.log10=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log10(this.get(r,n)));return this},i.log10=function(r){return new t(r).log10()},i.prototype.log2=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log2(this.get(r,n)));return this},i.log2=function(r){return new t(r).log2()},i.prototype.round=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.round(this.get(r,n)));return this},i.round=function(r){return new t(r).round()},i.prototype.sign=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sign(this.get(r,n)));return this},i.sign=function(r){return new t(r).sign()},i.prototype.sin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sin(this.get(r,n)));return this},i.sin=function(r){return new t(r).sin()},i.prototype.sinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sinh(this.get(r,n)));return this},i.sinh=function(r){return new t(r).sinh()},i.prototype.sqrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sqrt(this.get(r,n)));return this},i.sqrt=function(r){return new t(r).sqrt()},i.prototype.tan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tan(this.get(r,n)));return this},i.tan=function(r){return new t(r).tan()},i.prototype.tanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tanh(this.get(r,n)));return this},i.tanh=function(r){return new t(r).tanh()},i.prototype.trunc=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.trunc(this.get(r,n)));return this},i.trunc=function(r){return new t(r).trunc()},i.pow=function(r,n){return new t(r).pow(n)},i.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},i.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r));return this},i.prototype.powM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let s=0;s<this.columns;s++)this.set(n,s,Math.pow(this.get(n,s),r.get(n,s)));return this}}function Or(i,t,e){let r=e?i.rows:i.rows-1;if(t<0||t>r)throw new RangeError("Row index out of range")}function Br(i,t,e){let r=e?i.columns:i.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function Fi(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function Mi(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function Va(i,t){if(!fr.isAnyArray(t))throw new TypeError("row indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=i.rows)throw new RangeError("row indices are out of range")}function Ya(i,t){if(!fr.isAnyArray(t))throw new TypeError("column indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=i.columns)throw new RangeError("column indices are out of range")}function Za(i,t,e,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(uo("startRow",t),uo("endRow",e),uo("startColumn",r),uo("endColumn",n),t>e||r>n||t<0||t>=i.rows||e<0||e>=i.rows||r<0||r>=i.columns||n<0||n>=i.columns)throw new RangeError("Submatrix indices are out of range")}function ao(i,t=0){let e=[];for(let r=0;r<i;r++)e.push(t);return e}function uo(i,t){if(typeof t!="number")throw new TypeError(`${i} must be a number`)}function Ni(i){if(i.isEmpty())throw new Error("Empty matrix has no elements to index")}function H1(i){let t=ao(i.rows);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]+=i.get(e,r);return t}function J1(i){let t=ao(i.columns);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]+=i.get(e,r);return t}function X1(i){let t=0;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t+=i.get(e,r);return t}function Q1(i){let t=ao(i.rows,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[e]*=i.get(e,r);return t}function tw(i){let t=ao(i.columns,1);for(let e=0;e<i.rows;++e)for(let r=0;r<i.columns;++r)t[r]*=i.get(e,r);return t}function ew(i){let t=1;for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)t*=i.get(e,r);return t}function rw(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<r;a++){let l=0,c=0,h=0;for(let d=0;d<n;d++)h=i.get(a,d)-e[a],l+=h,c+=h*h;t?s.push((c-l*l/n)/(n-1)):s.push((c-l*l/n)/n)}return s}function nw(i,t,e){const r=i.rows,n=i.columns,s=[];for(let a=0;a<n;a++){let l=0,c=0,h=0;for(let d=0;d<r;d++)h=i.get(d,a)-e[a],l+=h,c+=h*h;t?s.push((c-l*l/r)/(r-1)):s.push((c-l*l/r)/r)}return s}function iw(i,t,e){const r=i.rows,n=i.columns,s=r*n;let a=0,l=0,c=0;for(let h=0;h<r;h++)for(let d=0;d<n;d++)c=i.get(h,d)-e,a+=c,l+=c*c;return t?(l-a*a/s)/(s-1):(l-a*a/s)/s}function sw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[e])}function ow(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t[r])}function aw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)-t)}function uw(i){const t=[];for(let e=0;e<i.rows;e++){let r=0;for(let n=0;n<i.columns;n++)r+=Math.pow(i.get(e,n),2)/(i.columns-1);t.push(Math.sqrt(r))}return t}function lw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[e])}function cw(i){const t=[];for(let e=0;e<i.columns;e++){let r=0;for(let n=0;n<i.rows;n++)r+=Math.pow(i.get(n,e),2)/(i.rows-1);t.push(Math.sqrt(r))}return t}function fw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t[r])}function hw(i){const t=i.size-1;let e=0;for(let r=0;r<i.columns;r++)for(let n=0;n<i.rows;n++)e+=Math.pow(i.get(n,r),2)/t;return Math.sqrt(e)}function dw(i,t){for(let e=0;e<i.rows;e++)for(let r=0;r<i.columns;r++)i.set(e,r,i.get(e,r)/t)}class $t{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let s=new dt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)s.set(a,l,r[a*e+l]);return s}static rowVector(t){let e=new dt(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new dt(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new dt(t,e)}static ones(t,e){return new dt(t,e).fill(1)}static rand(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{random:n=Math.random}=r;let s=new dt(t,e);for(let a=0;a<t;a++)for(let l=0;l<e;l++)s.set(a,l,n());return s}static randInt(t,e,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:s=1e3,random:a=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(s))throw new TypeError("max must be an integer");if(n>=s)throw new RangeError("min must be smaller than max");let l=s-n,c=new dt(t,e);for(let h=0;h<t;h++)for(let d=0;d<e;d++){let f=n+Math.round(a()*l);c.set(h,d,f)}return c}static eye(t,e,r){e===void 0&&(e=t),r===void 0&&(r=1);let n=Math.min(t,e),s=this.zeros(t,e);for(let a=0;a<n;a++)s.set(a,a,r);return s}static diag(t,e,r){let n=t.length;e===void 0&&(e=n),r===void 0&&(r=e);let s=Math.min(n,e,r),a=this.zeros(e,r);for(let l=0;l<s;l++)a.set(l,l,t[l]);return a}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new dt(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)s.set(a,l,Math.min(t.get(a,l),e.get(a,l)));return s}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,s=new this(r,n);for(let a=0;a<r;a++)for(let l=0;l<n;l++)s.set(a,l,Math.max(t.get(a,l),e.get(a,l)));return s}static checkMatrix(t){return $t.isMatrix(t)?t:new dt(t)}static isMatrix(t){return t!=null&&t.klass==="Matrix"}get size(){return this.rows*this.columns}apply(t){if(typeof t!="function")throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(this.get(t,t)!==0)return!1;return!0}isEchelonForm(){let t=0,e=0,r=-1,n=!0,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,s=!1;for(;t<this.rows&&n;){for(e=0,s=!1;e<this.columns&&s===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>r?(s=!0,r=e):(n=!1,s=!0);for(let a=e+1;a<this.rows;a++)this.get(t,a)!==0&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let s=e;s<t.rows;s++)t.get(s,r)>t.get(n,r)&&(n=s);if(t.get(n,r)===0)r++;else{t.swapRows(e,n);let s=t.get(e,r);for(let a=r;a<t.columns;a++)t.set(e,a,t.get(e,a)/s);for(let a=e+1;a<t.rows;a++){let l=t.get(a,r)/t.get(e,r);t.set(a,r,0);for(let c=r+1;c<t.columns;c++)t.set(a,c,t.get(a,c)-t.get(e,c)*l)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(t.maxRow(n)===0)n--;else{let s=0,a=!1;for(;s<r&&a===!1;)t.get(n,s)===1?a=!0:s++;for(let l=0;l<n;l++){let c=t.get(l,s);for(let h=s;h<e;h++){let d=t.get(l,h)-c*t.get(n,h);t.set(l,h,d)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new dt(this.rows*e,this.columns*r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*s,this.columns*a);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Or(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return dt.rowVector(this.getRow(t))}setRow(t,e){Or(this,t),e=Fi(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Or(this,t),Or(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){Br(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return dt.columnVector(this.getColumn(t))}setColumn(t,e){Br(this,t),e=Mi(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Br(this,t),Br(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=Fi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=Mi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=Mi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=Mi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=Mi(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){Or(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Br(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e&&(e=this.get(r,n));return e}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Ni(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e[r]&&(e[r]=this.get(r,n));return e}case"column":{const e=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e[n]&&(e[n]=this.get(r,n));return e}case void 0:{let e=this.get(0,0);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e&&(e=this.get(r,n));return e}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Ni(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(Or(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){Or(this,t),Ni(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(Or(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){Or(this,t),Ni(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(Br(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){Br(this,t),Ni(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(Br(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){Br(this,t),Ni(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){$t.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=dt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,s=new dt(e,n),a=new Float64Array(r);for(let l=0;l<n;l++){for(let c=0;c<r;c++)a[c]=t.get(c,l);for(let c=0;c<e;c++){let h=0;for(let d=0;d<r;d++)h+=this.get(c,d)*a[d];s.set(c,l,h)}}return s}strassen2x2(t){t=dt.checkMatrix(t);let e=new dt(2,2);const r=this.get(0,0),n=t.get(0,0),s=this.get(0,1),a=t.get(0,1),l=this.get(1,0),c=t.get(1,0),h=this.get(1,1),d=t.get(1,1),f=(r+h)*(n+d),p=(l+h)*n,g=r*(a-d),w=h*(c-n),m=(r+s)*d,y=(l-r)*(n+a),v=(s-h)*(c+d),x=f+w-m+v,b=g+m,M=p+w,E=f-p+g+y;return e.set(0,0,x),e.set(0,1,b),e.set(1,0,M),e.set(1,1,E),e}strassen3x3(t){t=dt.checkMatrix(t);let e=new dt(3,3);const r=this.get(0,0),n=this.get(0,1),s=this.get(0,2),a=this.get(1,0),l=this.get(1,1),c=this.get(1,2),h=this.get(2,0),d=this.get(2,1),f=this.get(2,2),p=t.get(0,0),g=t.get(0,1),w=t.get(0,2),m=t.get(1,0),y=t.get(1,1),v=t.get(1,2),x=t.get(2,0),b=t.get(2,1),M=t.get(2,2),E=(r+n+s-a-l-d-f)*y,F=(r-a)*(-g+y),N=l*(-p+g+m-y-v-x+M),S=(-r+a+l)*(p-g+y),T=(a+l)*(-p+g),A=r*p,O=(-r+h+d)*(p-w+v),L=(-r+h)*(w-v),q=(h+d)*(-p+w),U=(r+n+s-l-c-h-d)*v,W=d*(-p+w+m-y-v-x+b),z=(-s+d+f)*(y+x-b),K=(s-f)*(y-b),Z=s*x,X=(d+f)*(-x+b),Q=(-s+l+c)*(v+x-M),ct=(s-c)*(v-M),vt=(l+c)*(-x+M),lt=n*m,yt=c*b,bt=a*w,Ot=h*g,xt=f*M,ue=A+Z+lt,It=E+S+T+A+z+Z+X,Nt=A+O+q+U+Z+Q+vt,fe=F+N+S+A+Z+Q+ct,re=F+S+T+A+yt,qt=Z+Q+ct+vt+bt,Jt=A+O+L+W+z+K+Z,Le=z+K+Z+X+Ot,wr=A+O+L+q+xt;return e.set(0,0,ue),e.set(0,1,It),e.set(0,2,Nt),e.set(1,0,fe),e.set(1,1,re),e.set(1,2,qt),e.set(2,0,Jt),e.set(2,1,Le),e.set(2,2,wr),e}mmulStrassen(t){t=dt.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,s=t.rows,a=t.columns;n!==s&&console.warn(`Multiplying ${r} x ${n} and ${s} x ${a} matrix: dimensions do not match.`);function l(f,p,g){let w=f.rows,m=f.columns;if(w===p&&m===g)return f;{let y=$t.zeros(p,g);return y=y.setSubMatrix(f,0,0),y}}let c=Math.max(r,s),h=Math.max(n,a);e=l(e,c,h),t=l(t,c,h);function d(f,p,g,w){if(g<=512||w<=512)return f.mmul(p);g%2===1&&w%2===1?(f=l(f,g+1,w+1),p=l(p,g+1,w+1)):g%2===1?(f=l(f,g+1,w),p=l(p,g+1,w)):w%2===1&&(f=l(f,g,w+1),p=l(p,g,w+1));let m=parseInt(f.rows/2,10),y=parseInt(f.columns/2,10),v=f.subMatrix(0,m-1,0,y-1),x=p.subMatrix(0,m-1,0,y-1),b=f.subMatrix(0,m-1,y,f.columns-1),M=p.subMatrix(0,m-1,y,p.columns-1),E=f.subMatrix(m,f.rows-1,0,y-1),F=p.subMatrix(m,p.rows-1,0,y-1),N=f.subMatrix(m,f.rows-1,y,f.columns-1),S=p.subMatrix(m,p.rows-1,y,p.columns-1),T=d($t.add(v,N),$t.add(x,S),m,y),A=d($t.add(E,N),x,m,y),O=d(v,$t.sub(M,S),m,y),L=d(N,$t.sub(F,x),m,y),q=d($t.add(v,b),S,m,y),U=d($t.sub(E,v),$t.add(x,M),m,y),W=d($t.sub(b,N),$t.add(F,S),m,y),z=$t.add(T,L);z.sub(q),z.add(W);let K=$t.add(O,q),Z=$t.add(A,L),X=$t.sub(T,A);X.add(O),X.add(U);let Q=$t.zeros(2*z.rows,2*z.columns);return Q=Q.setSubMatrix(z,0,0),Q=Q.setSubMatrix(K,z.rows,0),Q=Q.setSubMatrix(Z,0,z.columns),Q=Q.setSubMatrix(X,z.rows,z.columns),Q.subMatrix(0,g-1,0,w-1)}return d(e,t,c,h)}scaleRows(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new dt(this.rows,this.columns);for(let s=0;s<this.rows;s++){const a=this.getRow(s);a.length>0&&Hf(a,{min:e,max:r,output:a}),n.setRow(s,a)}return n}scaleColumns(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new dt(this.rows,this.columns);for(let s=0;s<this.columns;s++){const a=this.getColumn(s);a.length&&Hf(a,{min:e,max:r,output:a}),n.setColumn(s,a)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let n=this.get(e,r),s=this.get(e,this.columns-1-r);this.set(e,r,s),this.set(e,this.columns-1-r,n)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let n=this.get(r,e),s=this.get(this.rows-1-r,e);this.set(r,e,s),this.set(this.rows-1-r,e,n)}return this}kroneckerProduct(t){t=dt.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,s=t.columns,a=new dt(e*n,r*s);for(let l=0;l<e;l++)for(let c=0;c<r;c++)for(let h=0;h<n;h++)for(let d=0;d<s;d++)a.set(n*l+h,s*c+d,this.get(l,c)*t.get(h,d));return a}kroneckerSum(t){if(t=dt.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(dt.eye(r,r)),s=dt.eye(e,e).kroneckerProduct(t);return n.add(s)}transpose(){let t=new dt(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=th){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=th){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){Za(this,t,e,r,n);let s=new dt(e-t+1,n-r+1);for(let a=t;a<=e;a++)for(let l=r;l<=n;l++)s.set(a-t,l-r,this.get(a,l));return s}subMatrixRow(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new dt(t.length,r-e+1);for(let s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.rows)throw new RangeError(`Row index out of range: ${t[s]}`);n.set(s,a-e,this.get(t[s],a))}return n}subMatrixColumn(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new dt(r-e+1,t.length);for(let s=0;s<t.length;s++)for(let a=e;a<=r;a++){if(t[s]<0||t[s]>=this.columns)throw new RangeError(`Column index out of range: ${t[s]}`);n.set(a-e,s,this.get(a,t[s]))}return n}setSubMatrix(t,e,r){if(t=dt.checkMatrix(t),t.isEmpty())return this;let n=e+t.rows-1,s=r+t.columns-1;Za(this,e,n,r,s);for(let a=0;a<t.rows;a++)for(let l=0;l<t.columns;l++)this.set(e+a,r+l,t.get(a,l));return this}selection(t,e){Va(this,t),Ya(this,e);let r=new dt(t.length,e.length);for(let n=0;n<t.length;n++){let s=t[n];for(let a=0;a<e.length;a++){let l=e[a];r.set(n,a,this.get(s,l))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){return this.constructor.copy(this,new dt(this.rows,this.columns))}static copy(t,e){for(const[r,n,s]of t.entries())e.set(r,n,s);return e}sum(t){switch(t){case"row":return H1(this);case"column":return J1(this);case void 0:return X1(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return Q1(this);case"column":return tw(this);case void 0:return ew(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":{for(let r=0;r<this.rows;r++)e[r]/=this.columns;return e}case"column":{for(let r=0;r<this.columns;r++)e[r]/=this.rows;return e}case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if(typeof r!="boolean")throw new TypeError("unbiased must be a boolean");switch(t){case"row":{if(!fr.isAnyArray(n))throw new TypeError("mean must be an array");return rw(this,r,n)}case"column":{if(!fr.isAnyArray(n))throw new TypeError("mean must be an array");return nw(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return iw(this,r,n)}default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){typeof t=="object"&&(e=t,t=void 0);const r=this.variance(t,e);if(t===void 0)return Math.sqrt(r);for(let n=0;n<r.length;n++)r[n]=Math.sqrt(r[n]);return r}center(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":{if(!fr.isAnyArray(r))throw new TypeError("center must be an array");return sw(this,r),this}case"column":{if(!fr.isAnyArray(r))throw new TypeError("center must be an array");return ow(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return aw(this,r),this}default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":{if(r===void 0)r=uw(this);else if(!fr.isAnyArray(r))throw new TypeError("scale must be an array");return lw(this,r),this}case"column":{if(r===void 0)r=cw(this);else if(!fr.isAnyArray(r))throw new TypeError("scale must be an array");return fw(this,r),this}case void 0:{if(r===void 0)r=hw(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return dw(this,r),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return Xf(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}$t.prototype.klass="Matrix",typeof Symbol<"u"&&($t.prototype[Symbol.for("nodejs.util.inspect.custom")]=Y1);function th(i,t){return i-t}function pw(i){return i.every(t=>typeof t=="number")}$t.random=$t.rand,$t.randomInt=$t.randInt,$t.diagonal=$t.diag,$t.prototype.diagonal=$t.prototype.diag,$t.identity=$t.eye,$t.prototype.negate=$t.prototype.neg,$t.prototype.tensorProduct=$t.prototype.kroneckerProduct;let dt=($i=class extends $t{constructor(e,r){super();Ll(this,us);$(this,"data");if($i.isMatrix(e))Rl(this,us,Pl).call(this,e.rows,e.columns),$i.copy(e,this);else if(Number.isInteger(e)&&e>=0)Rl(this,us,Pl).call(this,e,r);else if(fr.isAnyArray(e)){const n=e;if(e=n.length,r=e?n[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let s=0;s<e;s++){if(n[s].length!==r)throw new RangeError("Inconsistent array dimensions");if(!pw(n[s]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[s]))}this.rows=e,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(e,r,n){return this.data[e][r]=n,this}get(e,r){return this.data[e][r]}removeRow(e){return Or(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,r){return r===void 0&&(r=e,e=this.rows),Or(this,e,!0),r=Float64Array.from(Fi(this,r)),this.data.splice(e,0,r),this.rows+=1,this}removeColumn(e){Br(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let s=0;s<e;s++)n[s]=this.data[r][s];for(let s=e+1;s<this.columns;s++)n[s-1]=this.data[r][s];this.data[r]=n}return this.columns-=1,this}addColumn(e,r){typeof r>"u"&&(r=e,e=this.columns),Br(this,e,!0),r=Mi(this,r);for(let n=0;n<this.rows;n++){const s=new Float64Array(this.columns+1);let a=0;for(;a<e;a++)s[a]=this.data[n][a];for(s[a++]=r[n];a<this.columns+1;a++)s[a]=this.data[n][a-1];this.data[n]=s}return this.columns+=1,this}},us=new WeakSet,Pl=function(e,r){if(this.data=[],Number.isInteger(r)&&r>=0)for(let n=0;n<e;n++)this.data.push(new Float64Array(r));else throw new TypeError("nColumns must be a positive integer");this.rows=e,this.columns=r},$i);G1($t,dt);const Co=class Co extends $t{constructor(e){super();Ll(this,tr,void 0);if(dt.isMatrix(e)){if(!e.isSymmetric())throw new TypeError("not symmetric data");ga(this,tr,dt.copy(e,new dt(e.rows,e.rows)))}else if(Number.isInteger(e)&&e>=0)ga(this,tr,new dt(e,e));else if(ga(this,tr,new dt(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Xr(this,tr).size}get rows(){return Xr(this,tr).rows}get columns(){return Xr(this,tr).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return dt.isMatrix(e)&&e.klassType==="SymmetricMatrix"}static zeros(e){return new this(e)}static ones(e){return new this(e).fill(1)}clone(){const e=new Co(this.diagonalSize);for(const[r,n,s]of this.upperRightEntries())e.set(r,n,s);return e}toMatrix(){return new dt(this)}get(e,r){return Xr(this,tr).get(e,r)}set(e,r,n){return Xr(this,tr).set(e,r,n),Xr(this,tr).set(r,e,n),this}removeCross(e){return Xr(this,tr).removeRow(e),Xr(this,tr).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const n=r.slice();return n.splice(e,1),Xr(this,tr).addRow(e,n),Xr(this,tr).addColumn(e,r),this}applyMask(e){if(e.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[n,s]of e.entries())s||r.push(n);r.reverse();for(const n of r)this.removeCross(n);return this}toCompact(){const{diagonalSize:e}=this,r=new Array(e*(e+1)/2);for(let n=0,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=e&&(n=++s);return r}static fromCompact(e){const r=e.length,n=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(e)}`);const s=new Co(n);for(let a=0,l=0,c=0;c<r;c++)s.set(a,l,e[c]),++a>=n&&(a=++l);return s}*upperRightEntries(){for(let e=0,r=0;e<this.diagonalSize;void 0){const n=this.get(e,r);yield[e,r,n],++r>=this.diagonalSize&&(r=++e)}}*upperRightValues(){for(let e=0,r=0;e<this.diagonalSize;void 0)yield this.get(e,r),++r>=this.diagonalSize&&(r=++e)}};tr=new WeakMap;let ti=Co;ti.prototype.klassType="SymmetricMatrix";class lo extends ti{static isDistanceMatrix(t){return ti.isSymmetricMatrix(t)&&t.klassSubType==="DistanceMatrix"}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return e===void 0&&(e=t,t=this.diagonalSize),e=e.slice(),e[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new ti(this)}clone(){const t=new lo(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=(t-1)*t/2,r=new Array(e);for(let n=1,s=0,a=0;a<r.length;a++)r[a]=this.get(s,n),++n>=t&&(n=++s+1);return r}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const n=new this(r);for(let s=1,a=0,l=0;l<e;l++)n.set(s,a,t[l]),++s>=r&&(s=++a+1);return n}}lo.prototype.klassSubType="DistanceMatrix";class dn extends $t{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class _w extends dn{constructor(t,e){Br(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}}class mw extends dn{constructor(t,e){Ya(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}}class gw extends dn{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}}class vw extends dn{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}}class ww extends dn{constructor(t,e){Or(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}}class yw extends dn{constructor(t,e){Va(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}}class co extends dn{constructor(t,e,r){Va(t,e),Ya(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class Dw extends dn{constructor(t,e,r,n,s){Za(t,e,r,n,s),super(t,r-e+1,s-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}class bw extends dn{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}}class eh extends $t{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class vr extends $t{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function xw(i,t){if(fr.isAnyArray(i))return i[0]&&fr.isAnyArray(i[0])?new vr(i):new eh(i,t);throw new Error("the argument is not an array")}class fo{constructor(t){t=vr.checkMatrix(t);let e=t.clone(),r=e.rows,n=e.columns,s=new Float64Array(r),a=1,l,c,h,d,f,p,g,w,m;for(l=0;l<r;l++)s[l]=l;for(w=new Float64Array(r),c=0;c<n;c++){for(l=0;l<r;l++)w[l]=e.get(l,c);for(l=0;l<r;l++){for(m=Math.min(l,c),f=0,h=0;h<m;h++)f+=e.get(l,h)*w[h];w[l]-=f,e.set(l,c,w[l])}for(d=c,l=c+1;l<r;l++)Math.abs(w[l])>Math.abs(w[d])&&(d=l);if(d!==c){for(h=0;h<n;h++)p=e.get(d,h),e.set(d,h,e.get(c,h)),e.set(c,h,p);g=s[d],s[d]=s[c],s[c]=g,a=-a}if(c<r&&e.get(c,c)!==0)for(l=c+1;l<r;l++)e.set(l,c,e.get(l,c)/e.get(c,c))}this.LU=e,this.pivotVector=s,this.pivotSign=a}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(t.get(r,r)===0)return!0;return!1}solve(t){t=dt.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n=t.columns,s=t.subMatrixRow(this.pivotVector,0,n-1),a=e.columns,l,c,h;for(h=0;h<a;h++)for(l=h+1;l<a;l++)for(c=0;c<n;c++)s.set(l,c,s.get(l,c)-s.get(h,c)*e.get(l,h));for(h=a-1;h>=0;h--){for(c=0;c<n;c++)s.set(h,c,s.get(h,c)/e.get(h,h));for(l=0;l<h;l++)for(c=0;c<n;c++)s.set(l,c,s.get(l,c)-s.get(h,c)*e.get(l,h))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new dt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s>a?n.set(s,a,t.get(s,a)):s===a?n.set(s,a,1):n.set(s,a,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new dt(e,r);for(let s=0;s<e;s++)for(let a=0;a<r;a++)s<=a?n.set(s,a,t.get(s,a)):n.set(s,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function pn(i,t){let e=0;return Math.abs(i)>Math.abs(t)?(e=t/i,Math.abs(i)*Math.sqrt(1+e*e)):t!==0?(e=i/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class Ka{constructor(t){t=vr.checkMatrix(t);let e=t.clone(),r=t.rows,n=t.columns,s=new Float64Array(n),a,l,c,h;for(c=0;c<n;c++){let d=0;for(a=c;a<r;a++)d=pn(d,e.get(a,c));if(d!==0){for(e.get(c,c)<0&&(d=-d),a=c;a<r;a++)e.set(a,c,e.get(a,c)/d);for(e.set(c,c,e.get(c,c)+1),l=c+1;l<n;l++){for(h=0,a=c;a<r;a++)h+=e.get(a,c)*e.get(a,l);for(h=-h/e.get(c,c),a=c;a<r;a++)e.set(a,l,e.get(a,l)+h*e.get(a,c))}}s[c]=-d}this.QR=e,this.Rdiag=s}solve(t){t=dt.checkMatrix(t);let e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n=t.columns,s=t.clone(),a=e.columns,l,c,h,d;for(h=0;h<a;h++)for(c=0;c<n;c++){for(d=0,l=h;l<r;l++)d+=e.get(l,h)*s.get(l,c);for(d=-d/e.get(h,h),l=h;l<r;l++)s.set(l,c,s.get(l,c)+d*e.get(l,h))}for(h=a-1;h>=0;h--){for(c=0;c<n;c++)s.set(h,c,s.get(h,c)/this.Rdiag[h]);for(l=0;l<h;l++)for(c=0;c<n;c++)s.set(l,c,s.get(l,c)-s.get(h,c)*e.get(l,h))}return s.subMatrix(0,a-1,0,n-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(this.Rdiag[e]===0)return!1;return!0}get upperTriangularMatrix(){let t=this.QR,e=t.columns,r=new dt(e,e),n,s;for(n=0;n<e;n++)for(s=0;s<e;s++)n<s?r.set(n,s,t.get(n,s)):n===s?r.set(n,s,this.Rdiag[n]):r.set(n,s,0);return r}get orthogonalMatrix(){let t=this.QR,e=t.rows,r=t.columns,n=new dt(e,r),s,a,l,c;for(l=r-1;l>=0;l--){for(s=0;s<e;s++)n.set(s,l,0);for(n.set(l,l,1),a=l;a<r;a++)if(t.get(l,l)!==0){for(c=0,s=l;s<e;s++)c+=t.get(s,l)*n.get(s,a);for(c=-c/t.get(l,l),s=l;s<e;s++)n.set(s,a,n.get(s,a)+c*t.get(s,l))}}return n}}class Si{constructor(t,e={}){if(t=vr.checkMatrix(t),t.isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:s=!0,computeRightSingularVectors:a=!0,autoTranspose:l=!1}=e;let c=!!s,h=!!a,d=!1,f;if(r<n)if(!l)f=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{f=t.transpose(),r=f.rows,n=f.columns,d=!0;let A=c;c=h,h=A}else f=t.clone();let p=Math.min(r,n),g=Math.min(r+1,n),w=new Float64Array(g),m=new dt(r,p),y=new dt(n,n),v=new Float64Array(n),x=new Float64Array(r),b=new Float64Array(g);for(let A=0;A<g;A++)b[A]=A;let M=Math.min(r-1,n),E=Math.max(0,Math.min(n-2,r)),F=Math.max(M,E);for(let A=0;A<F;A++){if(A<M){w[A]=0;for(let O=A;O<r;O++)w[A]=pn(w[A],f.get(O,A));if(w[A]!==0){f.get(A,A)<0&&(w[A]=-w[A]);for(let O=A;O<r;O++)f.set(O,A,f.get(O,A)/w[A]);f.set(A,A,f.get(A,A)+1)}w[A]=-w[A]}for(let O=A+1;O<n;O++){if(A<M&&w[A]!==0){let L=0;for(let q=A;q<r;q++)L+=f.get(q,A)*f.get(q,O);L=-L/f.get(A,A);for(let q=A;q<r;q++)f.set(q,O,f.get(q,O)+L*f.get(q,A))}v[O]=f.get(A,O)}if(c&&A<M)for(let O=A;O<r;O++)m.set(O,A,f.get(O,A));if(A<E){v[A]=0;for(let O=A+1;O<n;O++)v[A]=pn(v[A],v[O]);if(v[A]!==0){v[A+1]<0&&(v[A]=0-v[A]);for(let O=A+1;O<n;O++)v[O]/=v[A];v[A+1]+=1}if(v[A]=-v[A],A+1<r&&v[A]!==0){for(let O=A+1;O<r;O++)x[O]=0;for(let O=A+1;O<r;O++)for(let L=A+1;L<n;L++)x[O]+=v[L]*f.get(O,L);for(let O=A+1;O<n;O++){let L=-v[O]/v[A+1];for(let q=A+1;q<r;q++)f.set(q,O,f.get(q,O)+L*x[q])}}if(h)for(let O=A+1;O<n;O++)y.set(O,A,v[O])}}let N=Math.min(n,r+1);if(M<n&&(w[M]=f.get(M,M)),r<N&&(w[N-1]=0),E+1<N&&(v[E]=f.get(E,N-1)),v[N-1]=0,c){for(let A=M;A<p;A++){for(let O=0;O<r;O++)m.set(O,A,0);m.set(A,A,1)}for(let A=M-1;A>=0;A--)if(w[A]!==0){for(let O=A+1;O<p;O++){let L=0;for(let q=A;q<r;q++)L+=m.get(q,A)*m.get(q,O);L=-L/m.get(A,A);for(let q=A;q<r;q++)m.set(q,O,m.get(q,O)+L*m.get(q,A))}for(let O=A;O<r;O++)m.set(O,A,-m.get(O,A));m.set(A,A,1+m.get(A,A));for(let O=0;O<A-1;O++)m.set(O,A,0)}else{for(let O=0;O<r;O++)m.set(O,A,0);m.set(A,A,1)}}if(h)for(let A=n-1;A>=0;A--){if(A<E&&v[A]!==0)for(let O=A+1;O<n;O++){let L=0;for(let q=A+1;q<n;q++)L+=y.get(q,A)*y.get(q,O);L=-L/y.get(A+1,A);for(let q=A+1;q<n;q++)y.set(q,O,y.get(q,O)+L*y.get(q,A))}for(let O=0;O<n;O++)y.set(O,A,0);y.set(A,A,1)}let S=N-1,T=Number.EPSILON;for(;N>0;){let A,O;for(A=N-2;A>=-1&&A!==-1;A--){const L=Number.MIN_VALUE+T*Math.abs(w[A]+Math.abs(w[A+1]));if(Math.abs(v[A])<=L||Number.isNaN(v[A])){v[A]=0;break}}if(A===N-2)O=4;else{let L;for(L=N-1;L>=A&&L!==A;L--){let q=(L!==N?Math.abs(v[L]):0)+(L!==A+1?Math.abs(v[L-1]):0);if(Math.abs(w[L])<=T*q){w[L]=0;break}}L===A?O=3:L===N-1?O=1:(O=2,A=L)}switch(A++,O){case 1:{let L=v[N-2];v[N-2]=0;for(let q=N-2;q>=A;q--){let U=pn(w[q],L),W=w[q]/U,z=L/U;if(w[q]=U,q!==A&&(L=-z*v[q-1],v[q-1]=W*v[q-1]),h)for(let K=0;K<n;K++)U=W*y.get(K,q)+z*y.get(K,N-1),y.set(K,N-1,-z*y.get(K,q)+W*y.get(K,N-1)),y.set(K,q,U)}break}case 2:{let L=v[A-1];v[A-1]=0;for(let q=A;q<N;q++){let U=pn(w[q],L),W=w[q]/U,z=L/U;if(w[q]=U,L=-z*v[q],v[q]=W*v[q],c)for(let K=0;K<r;K++)U=W*m.get(K,q)+z*m.get(K,A-1),m.set(K,A-1,-z*m.get(K,q)+W*m.get(K,A-1)),m.set(K,q,U)}break}case 3:{const L=Math.max(Math.abs(w[N-1]),Math.abs(w[N-2]),Math.abs(v[N-2]),Math.abs(w[A]),Math.abs(v[A])),q=w[N-1]/L,U=w[N-2]/L,W=v[N-2]/L,z=w[A]/L,K=v[A]/L,Z=((U+q)*(U-q)+W*W)/2,X=q*W*(q*W);let Q=0;(Z!==0||X!==0)&&(Z<0?Q=0-Math.sqrt(Z*Z+X):Q=Math.sqrt(Z*Z+X),Q=X/(Z+Q));let ct=(z+q)*(z-q)+Q,vt=z*K;for(let lt=A;lt<N-1;lt++){let yt=pn(ct,vt);yt===0&&(yt=Number.MIN_VALUE);let bt=ct/yt,Ot=vt/yt;if(lt!==A&&(v[lt-1]=yt),ct=bt*w[lt]+Ot*v[lt],v[lt]=bt*v[lt]-Ot*w[lt],vt=Ot*w[lt+1],w[lt+1]=bt*w[lt+1],h)for(let xt=0;xt<n;xt++)yt=bt*y.get(xt,lt)+Ot*y.get(xt,lt+1),y.set(xt,lt+1,-Ot*y.get(xt,lt)+bt*y.get(xt,lt+1)),y.set(xt,lt,yt);if(yt=pn(ct,vt),yt===0&&(yt=Number.MIN_VALUE),bt=ct/yt,Ot=vt/yt,w[lt]=yt,ct=bt*v[lt]+Ot*w[lt+1],w[lt+1]=-Ot*v[lt]+bt*w[lt+1],vt=Ot*v[lt+1],v[lt+1]=bt*v[lt+1],c&&lt<r-1)for(let xt=0;xt<r;xt++)yt=bt*m.get(xt,lt)+Ot*m.get(xt,lt+1),m.set(xt,lt+1,-Ot*m.get(xt,lt)+bt*m.get(xt,lt+1)),m.set(xt,lt,yt)}v[N-2]=ct;break}case 4:{if(w[A]<=0&&(w[A]=w[A]<0?-w[A]:0,h))for(let L=0;L<=S;L++)y.set(L,A,-y.get(L,A));for(;A<S&&!(w[A]>=w[A+1]);){let L=w[A];if(w[A]=w[A+1],w[A+1]=L,h&&A<n-1)for(let q=0;q<n;q++)L=y.get(q,A+1),y.set(q,A+1,y.get(q,A)),y.set(q,A,L);if(c&&A<r-1)for(let q=0;q<r;q++)L=m.get(q,A+1),m.set(q,A+1,m.get(q,A)),m.set(q,A,L);A++}N--;break}}}if(d){let A=y;y=m,m=A}this.m=r,this.n=n,this.s=w,this.U=m,this.V=y}solve(t){let e=t,r=this.threshold,n=this.s.length,s=dt.zeros(n,n);for(let p=0;p<n;p++)Math.abs(this.s[p])<=r?s.set(p,p,0):s.set(p,p,1/this.s[p]);let a=this.U,l=this.rightSingularVectors,c=l.mmul(s),h=l.rows,d=a.rows,f=dt.zeros(h,d);for(let p=0;p<h;p++)for(let g=0;g<d;g++){let w=0;for(let m=0;m<n;m++)w+=c.get(p,m)*a.get(g,m);f.set(p,g,w)}return f.mmul(e)}solveForDiagonal(t){return this.solve(dt.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,s=new dt(r,this.s.length);for(let d=0;d<r;d++)for(let f=0;f<n;f++)Math.abs(this.s[f])>e&&s.set(d,f,t.get(d,f)/this.s[f]);let a=this.U,l=a.rows,c=a.columns,h=new dt(r,l);for(let d=0;d<r;d++)for(let f=0;f<l;f++){let p=0;for(let g=0;g<c;g++)p+=s.get(d,g)*a.get(f,g);h.set(d,f,p)}return h}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,s=r.length;n<s;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return dt.diag(this.s)}}function Ew(i,t=!1){return i=vr.checkMatrix(i),t?new Si(i).inverse():rh(i,dt.eye(i.rows))}function rh(i,t,e=!1){return i=vr.checkMatrix(i),t=vr.checkMatrix(t),e?new Si(i).solve(t):i.isSquare()?new fo(i).solve(t):new Ka(i).solve(t)}function ho(i){if(i=dt.checkMatrix(i),i.isSquare()){if(i.columns===0)return 1;let t,e,r,n;if(i.columns===2)return t=i.get(0,0),e=i.get(0,1),r=i.get(1,0),n=i.get(1,1),t*n-e*r;if(i.columns===3){let s,a,l;return s=new co(i,[1,2],[1,2]),a=new co(i,[1,2],[0,2]),l=new co(i,[1,2],[0,1]),t=i.get(0,0),e=i.get(0,1),r=i.get(0,2),t*ho(s)-e*ho(a)+r*ho(l)}else return new fo(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Aw(i,t){let e=[];for(let r=0;r<i;r++)r!==t&&e.push(r);return e}function Cw(i,t,e,r=1e-9,n=1e-9){if(i>n)return new Array(t.rows+1).fill(0);{let s=t.addRow(e,[0]);for(let a=0;a<s.rows;a++)Math.abs(s.get(a,0))<r&&s.set(a,0,0);return s.to1DArray()}}function Fw(i,t={}){const{thresholdValue:e=1e-9,thresholdError:r=1e-9}=t;i=dt.checkMatrix(i);let n=i.rows,s=new dt(n,n);for(let a=0;a<n;a++){let l=dt.columnVector(i.getRow(a)),c=i.subMatrixRow(Aw(n,a)).transpose(),d=new Si(c).solve(l),f=dt.sub(l,c.mmul(d)).abs().max();s.setRow(a,Cw(f,d,a,e,r))}return s}function Mw(i,t=Number.EPSILON){if(i=dt.checkMatrix(i),i.isEmpty())return i.transpose();let e=new Si(i,{autoTranspose:!0}),r=e.leftSingularVectors,n=e.rightSingularVectors,s=e.diagonal;for(let a=0;a<s.length;a++)Math.abs(s[a])>t?s[a]=1/s[a]:s[a]=0;return n.mmul(dt.diag(s).mmul(r.transpose()))}function Nw(i,t=i,e={}){i=new dt(i);let r=!1;if(typeof t=="object"&&!dt.isMatrix(t)&&!fr.isAnyArray(t)?(e=t,t=i,r=!0):t=new dt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=e;n&&(i=i.center("column"),r||(t=t.center("column")));const s=i.transpose().mmul(t);for(let a=0;a<s.rows;a++)for(let l=0;l<s.columns;l++)s.set(a,l,s.get(a,l)*(1/(i.rows-1)));return s}function Sw(i,t=i,e={}){i=new dt(i);let r=!1;if(typeof t=="object"&&!dt.isMatrix(t)&&!fr.isAnyArray(t)?(e=t,t=i,r=!0):t=new dt(t),i.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:s=!0}=e;n&&(i.center("column"),r||t.center("column")),s&&(i.scale("column"),r||t.scale("column"));const a=i.standardDeviation("column",{unbiased:!0}),l=r?a:t.standardDeviation("column",{unbiased:!0}),c=i.transpose().mmul(t);for(let h=0;h<c.rows;h++)for(let d=0;d<c.columns;d++)c.set(h,d,c.get(h,d)*(1/(a[h]*l[d]))*(1/(i.rows-1)));return c}let nh=class{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(t=vr.checkMatrix(t),!t.isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n=t.columns,s=new dt(n,n),a=new Float64Array(n),l=new Float64Array(n),c=t,h,d,f=!1;if(r?f=!0:f=t.isSymmetric(),f){for(h=0;h<n;h++)for(d=0;d<n;d++)s.set(h,d,c.get(h,d));Ow(n,l,a,s),Bw(n,l,a,s)}else{let p=new dt(n,n),g=new Float64Array(n);for(d=0;d<n;d++)for(h=0;h<n;h++)p.set(h,d,c.get(h,d));Iw(n,p,g,s),Tw(n,l,a,s,p)}this.n=n,this.e=l,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t=this.n,e=this.e,r=this.d,n=new dt(t,t),s,a;for(s=0;s<t;s++){for(a=0;a<t;a++)n.set(s,a,0);n.set(s,s,r[s]),e[s]>0?n.set(s,s+1,e[s]):e[s]<0&&n.set(s,s-1,e[s])}return n}};function Ow(i,t,e,r){let n,s,a,l,c,h,d,f;for(c=0;c<i;c++)e[c]=r.get(i-1,c);for(l=i-1;l>0;l--){for(f=0,a=0,h=0;h<l;h++)f=f+Math.abs(e[h]);if(f===0)for(t[l]=e[l-1],c=0;c<l;c++)e[c]=r.get(l-1,c),r.set(l,c,0),r.set(c,l,0);else{for(h=0;h<l;h++)e[h]/=f,a+=e[h]*e[h];for(n=e[l-1],s=Math.sqrt(a),n>0&&(s=-s),t[l]=f*s,a=a-n*s,e[l-1]=n-s,c=0;c<l;c++)t[c]=0;for(c=0;c<l;c++){for(n=e[c],r.set(c,l,n),s=t[c]+r.get(c,c)*n,h=c+1;h<=l-1;h++)s+=r.get(h,c)*e[h],t[h]+=r.get(h,c)*n;t[c]=s}for(n=0,c=0;c<l;c++)t[c]/=a,n+=t[c]*e[c];for(d=n/(a+a),c=0;c<l;c++)t[c]-=d*e[c];for(c=0;c<l;c++){for(n=e[c],s=t[c],h=c;h<=l-1;h++)r.set(h,c,r.get(h,c)-(n*t[h]+s*e[h]));e[c]=r.get(l-1,c),r.set(l,c,0)}}e[l]=a}for(l=0;l<i-1;l++){if(r.set(i-1,l,r.get(l,l)),r.set(l,l,1),a=e[l+1],a!==0){for(h=0;h<=l;h++)e[h]=r.get(h,l+1)/a;for(c=0;c<=l;c++){for(s=0,h=0;h<=l;h++)s+=r.get(h,l+1)*r.get(h,c);for(h=0;h<=l;h++)r.set(h,c,r.get(h,c)-s*e[h])}}for(h=0;h<=l;h++)r.set(h,l+1,0)}for(c=0;c<i;c++)e[c]=r.get(i-1,c),r.set(i-1,c,0);r.set(i-1,i-1,1),t[0]=0}function Bw(i,t,e,r){let n,s,a,l,c,h,d,f,p,g,w,m,y,v,x,b;for(a=1;a<i;a++)t[a-1]=t[a];t[i-1]=0;let M=0,E=0,F=Number.EPSILON;for(h=0;h<i;h++){for(E=Math.max(E,Math.abs(e[h])+Math.abs(t[h])),d=h;d<i&&!(Math.abs(t[d])<=F*E);)d++;if(d>h)do{for(n=e[h],f=(e[h+1]-n)/(2*t[h]),p=pn(f,1),f<0&&(p=-p),e[h]=t[h]/(f+p),e[h+1]=t[h]*(f+p),g=e[h+1],s=n-e[h],a=h+2;a<i;a++)e[a]-=s;for(M=M+s,f=e[d],w=1,m=w,y=w,v=t[h+1],x=0,b=0,a=d-1;a>=h;a--)for(y=m,m=w,b=x,n=w*t[a],s=w*f,p=pn(f,t[a]),t[a+1]=x*p,x=t[a]/p,w=f/p,f=w*e[a]-x*n,e[a+1]=s+x*(w*n+x*e[a]),c=0;c<i;c++)s=r.get(c,a+1),r.set(c,a+1,x*r.get(c,a)+w*s),r.set(c,a,w*r.get(c,a)-x*s);f=-x*b*y*v*t[h]/g,t[h]=x*f,e[h]=w*f}while(Math.abs(t[h])>F*E);e[h]=e[h]+M,t[h]=0}for(a=0;a<i-1;a++){for(c=a,f=e[a],l=a+1;l<i;l++)e[l]<f&&(c=l,f=e[l]);if(c!==a)for(e[c]=e[a],e[a]=f,l=0;l<i;l++)f=r.get(l,a),r.set(l,a,r.get(l,c)),r.set(l,c,f)}}function Iw(i,t,e,r){let n=0,s=i-1,a,l,c,h,d,f,p;for(f=n+1;f<=s-1;f++){for(p=0,h=f;h<=s;h++)p=p+Math.abs(t.get(h,f-1));if(p!==0){for(c=0,h=s;h>=f;h--)e[h]=t.get(h,f-1)/p,c+=e[h]*e[h];for(l=Math.sqrt(c),e[f]>0&&(l=-l),c=c-e[f]*l,e[f]=e[f]-l,d=f;d<i;d++){for(a=0,h=s;h>=f;h--)a+=e[h]*t.get(h,d);for(a=a/c,h=f;h<=s;h++)t.set(h,d,t.get(h,d)-a*e[h])}for(h=0;h<=s;h++){for(a=0,d=s;d>=f;d--)a+=e[d]*t.get(h,d);for(a=a/c,d=f;d<=s;d++)t.set(h,d,t.get(h,d)-a*e[d])}e[f]=p*e[f],t.set(f,f-1,p*l)}}for(h=0;h<i;h++)for(d=0;d<i;d++)r.set(h,d,h===d?1:0);for(f=s-1;f>=n+1;f--)if(t.get(f,f-1)!==0){for(h=f+1;h<=s;h++)e[h]=t.get(h,f-1);for(d=f;d<=s;d++){for(l=0,h=f;h<=s;h++)l+=e[h]*r.get(h,d);for(l=l/e[f]/t.get(f,f-1),h=f;h<=s;h++)r.set(h,d,r.get(h,d)+l*e[h])}}}function Tw(i,t,e,r,n){let s=i-1,a=0,l=i-1,c=Number.EPSILON,h=0,d=0,f=0,p=0,g=0,w=0,m=0,y=0,v,x,b,M,E,F,N,S,T,A,O,L,q,U,W;for(v=0;v<i;v++)for((v<a||v>l)&&(e[v]=n.get(v,v),t[v]=0),x=Math.max(v-1,0);x<i;x++)d=d+Math.abs(n.get(v,x));for(;s>=a;){for(M=s;M>a&&(w=Math.abs(n.get(M-1,M-1))+Math.abs(n.get(M,M)),w===0&&(w=d),!(Math.abs(n.get(M,M-1))<c*w));)M--;if(M===s)n.set(s,s,n.get(s,s)+h),e[s]=n.get(s,s),t[s]=0,s--,y=0;else if(M===s-1){if(N=n.get(s,s-1)*n.get(s-1,s),f=(n.get(s-1,s-1)-n.get(s,s))/2,p=f*f+N,m=Math.sqrt(Math.abs(p)),n.set(s,s,n.get(s,s)+h),n.set(s-1,s-1,n.get(s-1,s-1)+h),S=n.get(s,s),p>=0){for(m=f>=0?f+m:f-m,e[s-1]=S+m,e[s]=e[s-1],m!==0&&(e[s]=S-N/m),t[s-1]=0,t[s]=0,S=n.get(s,s-1),w=Math.abs(S)+Math.abs(m),f=S/w,p=m/w,g=Math.sqrt(f*f+p*p),f=f/g,p=p/g,x=s-1;x<i;x++)m=n.get(s-1,x),n.set(s-1,x,p*m+f*n.get(s,x)),n.set(s,x,p*n.get(s,x)-f*m);for(v=0;v<=s;v++)m=n.get(v,s-1),n.set(v,s-1,p*m+f*n.get(v,s)),n.set(v,s,p*n.get(v,s)-f*m);for(v=a;v<=l;v++)m=r.get(v,s-1),r.set(v,s-1,p*m+f*r.get(v,s)),r.set(v,s,p*r.get(v,s)-f*m)}else e[s-1]=S+f,e[s]=S+f,t[s-1]=m,t[s]=-m;s=s-2,y=0}else{if(S=n.get(s,s),T=0,N=0,M<s&&(T=n.get(s-1,s-1),N=n.get(s,s-1)*n.get(s-1,s)),y===10){for(h+=S,v=a;v<=s;v++)n.set(v,v,n.get(v,v)-S);w=Math.abs(n.get(s,s-1))+Math.abs(n.get(s-1,s-2)),S=T=.75*w,N=-.4375*w*w}if(y===30&&(w=(T-S)/2,w=w*w+N,w>0)){for(w=Math.sqrt(w),T<S&&(w=-w),w=S-N/((T-S)/2+w),v=a;v<=s;v++)n.set(v,v,n.get(v,v)-w);h+=w,S=T=N=.964}for(y=y+1,E=s-2;E>=M&&(m=n.get(E,E),g=S-m,w=T-m,f=(g*w-N)/n.get(E+1,E)+n.get(E,E+1),p=n.get(E+1,E+1)-m-g-w,g=n.get(E+2,E+1),w=Math.abs(f)+Math.abs(p)+Math.abs(g),f=f/w,p=p/w,g=g/w,!(E===M||Math.abs(n.get(E,E-1))*(Math.abs(p)+Math.abs(g))<c*(Math.abs(f)*(Math.abs(n.get(E-1,E-1))+Math.abs(m)+Math.abs(n.get(E+1,E+1))))));)E--;for(v=E+2;v<=s;v++)n.set(v,v-2,0),v>E+2&&n.set(v,v-3,0);for(b=E;b<=s-1&&(U=b!==s-1,b!==E&&(f=n.get(b,b-1),p=n.get(b+1,b-1),g=U?n.get(b+2,b-1):0,S=Math.abs(f)+Math.abs(p)+Math.abs(g),S!==0&&(f=f/S,p=p/S,g=g/S)),S!==0);b++)if(w=Math.sqrt(f*f+p*p+g*g),f<0&&(w=-w),w!==0){for(b!==E?n.set(b,b-1,-w*S):M!==E&&n.set(b,b-1,-n.get(b,b-1)),f=f+w,S=f/w,T=p/w,m=g/w,p=p/f,g=g/f,x=b;x<i;x++)f=n.get(b,x)+p*n.get(b+1,x),U&&(f=f+g*n.get(b+2,x),n.set(b+2,x,n.get(b+2,x)-f*m)),n.set(b,x,n.get(b,x)-f*S),n.set(b+1,x,n.get(b+1,x)-f*T);for(v=0;v<=Math.min(s,b+3);v++)f=S*n.get(v,b)+T*n.get(v,b+1),U&&(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*p);for(v=a;v<=l;v++)f=S*r.get(v,b)+T*r.get(v,b+1),U&&(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*p)}}}if(d!==0){for(s=i-1;s>=0;s--)if(f=e[s],p=t[s],p===0)for(M=s,n.set(s,s,1),v=s-1;v>=0;v--){for(N=n.get(v,v)-f,g=0,x=M;x<=s;x++)g=g+n.get(v,x)*n.get(x,s);if(t[v]<0)m=N,w=g;else if(M=v,t[v]===0?n.set(v,s,N!==0?-g/N:-g/(c*d)):(S=n.get(v,v+1),T=n.get(v+1,v),p=(e[v]-f)*(e[v]-f)+t[v]*t[v],F=(S*w-m*g)/p,n.set(v,s,F),n.set(v+1,s,Math.abs(S)>Math.abs(m)?(-g-N*F)/S:(-w-T*F)/m)),F=Math.abs(n.get(v,s)),c*F*F>1)for(x=v;x<=s;x++)n.set(x,s,n.get(x,s)/F)}else if(p<0)for(M=s-1,Math.abs(n.get(s,s-1))>Math.abs(n.get(s-1,s))?(n.set(s-1,s-1,p/n.get(s,s-1)),n.set(s-1,s,-(n.get(s,s)-f)/n.get(s,s-1))):(W=po(0,-n.get(s-1,s),n.get(s-1,s-1)-f,p),n.set(s-1,s-1,W[0]),n.set(s-1,s,W[1])),n.set(s,s-1,0),n.set(s,s,1),v=s-2;v>=0;v--){for(A=0,O=0,x=M;x<=s;x++)A=A+n.get(v,x)*n.get(x,s-1),O=O+n.get(v,x)*n.get(x,s);if(N=n.get(v,v)-f,t[v]<0)m=N,g=A,w=O;else if(M=v,t[v]===0?(W=po(-A,-O,N,p),n.set(v,s-1,W[0]),n.set(v,s,W[1])):(S=n.get(v,v+1),T=n.get(v+1,v),L=(e[v]-f)*(e[v]-f)+t[v]*t[v]-p*p,q=(e[v]-f)*2*p,L===0&&q===0&&(L=c*d*(Math.abs(N)+Math.abs(p)+Math.abs(S)+Math.abs(T)+Math.abs(m))),W=po(S*g-m*A+p*O,S*w-m*O-p*A,L,q),n.set(v,s-1,W[0]),n.set(v,s,W[1]),Math.abs(S)>Math.abs(m)+Math.abs(p)?(n.set(v+1,s-1,(-A-N*n.get(v,s-1)+p*n.get(v,s))/S),n.set(v+1,s,(-O-N*n.get(v,s)-p*n.get(v,s-1))/S)):(W=po(-g-T*n.get(v,s-1),-w-T*n.get(v,s),m,p),n.set(v+1,s-1,W[0]),n.set(v+1,s,W[1]))),F=Math.max(Math.abs(n.get(v,s-1)),Math.abs(n.get(v,s))),c*F*F>1)for(x=v;x<=s;x++)n.set(x,s-1,n.get(x,s-1)/F),n.set(x,s,n.get(x,s)/F)}for(v=0;v<i;v++)if(v<a||v>l)for(x=v;x<i;x++)r.set(v,x,n.get(v,x));for(x=i-1;x>=a;x--)for(v=a;v<=l;v++){for(m=0,b=a;b<=Math.min(x,l);b++)m=m+r.get(v,b)*n.get(b,x);r.set(v,x,m)}}}function po(i,t,e,r){let n,s;return Math.abs(e)>Math.abs(r)?(n=r/e,s=e+n*r,[(i+n*t)/s,(t-n*i)/s]):(n=e/r,s=r+n*e,[(n*i+t)/s,(n*t-i)/s])}class ih{constructor(t){if(t=vr.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,n=new dt(r,r),s=!0,a,l,c;for(l=0;l<r;l++){let h=0;for(c=0;c<l;c++){let d=0;for(a=0;a<c;a++)d+=n.get(c,a)*n.get(l,a);d=(e.get(l,c)-d)/n.get(c,c),n.set(l,c,d),h=h+d*d}for(h=e.get(l,l)-h,s&=h>0,n.set(l,l,Math.sqrt(Math.max(h,0))),c=l+1;c<r;c++)n.set(l,c,0)}this.L=n,this.positiveDefinite=!!s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=vr.checkMatrix(t);let e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let n=t.columns,s=t.clone(),a,l,c;for(c=0;c<r;c++)for(l=0;l<n;l++){for(a=0;a<c;a++)s.set(c,l,s.get(c,l)-s.get(a,l)*e.get(c,a));s.set(c,l,s.get(c,l)/e.get(c,c))}for(c=r-1;c>=0;c--)for(l=0;l<n;l++){for(a=c+1;a<r;a++)s.set(c,l,s.get(c,l)-s.get(a,l)*e.get(a,c));s.set(c,l,s.get(c,l)/e.get(c,c))}return s}get lowerTriangularMatrix(){return this.L}}class sh{constructor(t,e={}){t=vr.checkMatrix(t);let{Y:r}=e;const{scaleScores:n=!1,maxIterations:s=1e3,terminationCriteria:a=1e-10}=e;let l;if(r){if(fr.isAnyArray(r)&&typeof r[0]=="number"?r=dt.columnVector(r):r=vr.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");l=r.getColumnVector(0)}else l=t.getColumnVector(0);let c=1,h,d,f,p;for(let g=0;g<s&&c>a;g++)f=t.transpose().mmul(l).div(l.transpose().mmul(l).get(0,0)),f=f.div(f.norm()),h=t.mmul(f).div(f.transpose().mmul(f).get(0,0)),g>0&&(c=h.clone().sub(p).pow(2).sum()),p=h.clone(),r?(d=r.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),d=d.div(d.norm()),l=r.mmul(d).div(d.transpose().mmul(d).get(0,0))):l=h;if(r){let g=t.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0));g=g.div(g.norm());let w=t.clone().sub(h.clone().mmul(g.transpose())),m=l.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),y=r.clone().sub(h.clone().mulS(m.get(0,0)).mmul(d.transpose()));this.t=h,this.p=g.transpose(),this.w=f.transpose(),this.q=d,this.u=l,this.s=h.transpose().mmul(h),this.xResidual=w,this.yResidual=y,this.betas=m}else this.w=f.transpose(),this.s=h.transpose().mmul(h).sqrt(),n?this.t=h.clone().div(this.s.get(0,0)):this.t=h,this.xResidual=t.sub(h.mmul(f.transpose()))}}kt.AbstractMatrix=$t,kt.CHO=ih,kt.CholeskyDecomposition=ih,kt.DistanceMatrix=lo,kt.EVD=nh;var $w=kt.EigenvalueDecomposition=nh;kt.LU=fo,kt.LuDecomposition=fo;var oh=kt.Matrix=dt;kt.MatrixColumnSelectionView=mw,kt.MatrixColumnView=_w,kt.MatrixFlipColumnView=gw,kt.MatrixFlipRowView=vw,kt.MatrixRowSelectionView=yw,kt.MatrixRowView=ww,kt.MatrixSelectionView=co,kt.MatrixSubView=Dw,kt.MatrixTransposeView=bw,kt.NIPALS=sh,kt.Nipals=sh,kt.QR=Ka,kt.QrDecomposition=Ka,kt.SVD=Si,kt.SingularValueDecomposition=Si,kt.SymmetricMatrix=ti,kt.WrapperMatrix1D=eh,kt.WrapperMatrix2D=vr,kt.correlation=Sw,kt.covariance=Nw;var ah=kt.default=dt;kt.determinant=ho,kt.inverse=Ew,kt.linearDependencies=Fw,kt.pseudoInverse=Mw,kt.solve=rh,kt.wrap=xw;const uh=$w,lh=oh;ah.Matrix&&ah.Matrix;class Lw{constructor(t){$(this,"_errorListener");this._errorListener=t}new({rows:t,columns:e,initial_value:r}={}){return new Ga(t,e,r,this._errorListener)}avg({id:t}){return t==null?void 0:t.avg()}col({id:t,column:e}){return t==null?void 0:t.col({column:e})}det({id:t}){return t==null?void 0:t.det()}get({id:t,row:e,column:r}){return t==null?void 0:t.get({row:e,column:r})}inv({id:t}){return t==null?void 0:t.inv()}max({id:t}){return t==null?void 0:t.max()}min({id:t}){return t==null?void 0:t.min()}pow({id:t,power:e}){return t==null?void 0:t.pow({power:e})}row({id:t,row:e}){return t==null?void 0:t.row({row:e})}set({id:t,row:e,column:r,value:n}){t==null||t.set({row:e,column:r,value:n})}sum({id1:t,id2:e}){return t==null?void 0:t.sum({id2:e})}copy({id:t}){return t==null?void 0:t.copy()}diff({id1:t,id2:e}){return t==null?void 0:t.diff({id2:e})}rows({id:t}){return t==null?void 0:t.rows()}columns({id:t}){return t==null?void 0:t.columns()}fill({id:t,value:e,from_row:r,to_row:n,from_column:s,to_column:a}){t==null||t.fill({value:e,from_row:r,to_row:n,from_column:s,to_column:a})}kron({id1:t,id2:e}){return t==null?void 0:t.kron({id2:e})}mode({id:t}){return t==null?void 0:t.mode()}mult({id1:t,id2:e}){return t==null?void 0:t.mult({id2:e})}pinv({id:t}){return t==null?void 0:t.pinv()}rank({id:t}){return t==null?void 0:t.rank()}sort({id:t,column:e,order:r}){t==null||t.sort({column:e,order:r})}trace({id:t}){return t==null?void 0:t.trace()}concat({id1:t,id2:e}){return t==null?void 0:t.concat({id2:e})}median({id:t}){return t==null?void 0:t.median()}add_col({id:t,column:e,array_id:r}){t==null||t.add_col({column:e,array_id:r})}add_row({id:t,row:e,array_id:r}){t==null||t.add_row({row:e,array_id:r})}is_zero({id:t}){return t==null?void 0:t.is_zero()}reshape({id:t,rows:e,columns:r},n){return t==null?void 0:t.reshape({rows:e,columns:r},n)}reverse({id:t}){t==null||t.reverse()}is_binary({id:t}){return t==null?void 0:t.is_binary()}is_square({id:t}){return t==null?void 0:t.is_square()}submatrix({id:t,from_row:e,to_row:r,from_column:n,to_column:s}){return t==null?void 0:t.submatrix({from_row:e,to_row:r,from_column:n,to_column:s})}swap_rows({id:t,row1:e,row2:r}){t==null||t.swap_rows({row1:e,row2:r})}transpose({id:t}){return t==null?void 0:t.transpose()}remove_col({id:t,column:e}){return t==null?void 0:t.remove_col({column:e})}remove_row({id:t,row:e}){return t==null?void 0:t.remove_row({row:e})}eigenvalues({id:t}){return t==null?void 0:t.eigenvalues()}is_diagonal({id:t}){return t==null?void 0:t.is_diagonal()}is_identity({id:t}){return t==null?void 0:t.is_identity()}eigenvectors({id:t}){return t==null?void 0:t.eigenvectors()}is_symmetric({id:t}){return t==null?void 0:t.is_symmetric()}swap_columns({id:t,column1:e,column2:r}){t==null||t.swap_columns({column1:e,column2:r})}is_stochastic({id:t}){return t==null?void 0:t.is_stochastic()}is_triangular({id:t}){return t==null?void 0:t.is_triangular()}elements_count({id:t}){return t==null?void 0:t.elements_count()}is_antidiagonal({id:t}){return t==null?void 0:t.is_antidiagonal()}is_antisymmetric({id:t}){return t==null?void 0:t.is_antisymmetric()}}class Ga{constructor(t=0,e=0,r=void 0,n){$(this,"_matrixInstance");$(this,"_errorListener");this._matrixInstance=this._createMatrix(t,e,r),this._errorListener=n}get _matrixArray(){return this._matrixInstance.map(t=>[...t._value])}get _value(){return this._matrixInstance}set _value(t){this._matrixInstance=t}get isMatrix(){return!0}_createMatrix(t,e,r){return Array.from(new Array(t),()=>new Qt(e,r,this._errorListener))}avg(){let t=0,e=0;for(const n of this._matrixInstance)for(const s of n._value)t+=_t(s)?0:s,e+=1;return t/e}col({column:t}){const e=[],r=new Qt(0,void 0,this._errorListener);if(_t(t))return r;for(const n of this._matrixInstance)e.push(n._value[t]);return r._value=e,r}det(){return Kf(this._matrixArray)}get({row:t,column:e}){var r,n;if(!(_t(t)||_t(e)))return(n=(r=this._matrixInstance[t])==null?void 0:r._value)==null?void 0:n[e]}inv(){const t=so(this._matrixArray);return this._newMatrix(t)}max(){return O1(this._matrixArray)}min(){return ja(this._matrixArray)}pow({power:t}){const e=_t(t)?this._matrixArray:I1(this._matrixArray,t);return this._newMatrix(e)}row({row:t}){return _t(t)?new Qt(0,void 0,this._errorListener):this._matrixInstance[t]}set({row:t,column:e,value:r}){_t(t)||_t(e)||this._matrixInstance[t].set({index:e,value:r})}sum({id2:t}){const e=ss(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}copy(){return this._newMatrix(this._matrixArray)}diff({id2:t}){const e=A1(this._matrixArray,typeof t=="number"?t:t._matrixArray);return this._newMatrix(e)}rows(){return this._matrixInstance.length}columns(){return this._matrixArray.length&&this._matrixArray[0].length}fill({value:t,from_row:e,to_row:r,from_column:n,to_column:s}={}){_t(e)&&(e=0),_t(r)&&(r=this.rows()),_t(n)&&(n=0),_t(s)&&(s=this.columns());for(const[a,l]of this._matrixInstance.entries())for(const[c]of l._value.entries())a<r&&a>=e&&c>=n&&c<s&&l.set({index:c,value:t})}kron({id2:t}){const e=x1(this._matrixArray,t._matrixArray);return this._newMatrix(e)}mode(){return ja(qf(this._matrixArray))}mult({id2:t}){const e=typeof t=="number"?t:t._matrixArray?t._matrixArray:t._value,r=Ci(this._matrixArray,e);return this._newMatrix(r)}pinv(){const t=B1(this._matrixArray);return this._newMatrix(t)}rank(){return this._matrixRank(this._matrixArray)}sort({column:t,order:e=Kn.ascending}={}){_t(t)&&(t=0),this._matrixInstance.sort((r,n)=>{const s=r._value[t],a=n._value[t];return e!==Kn.descending?s-a:a-s})}trace(){return S1(this._matrixArray)}concat({id2:t}){for(const e of t._value)this._matrixInstance.push(e);return this}median(){return Gf(this._matrixArray)}add_col({column:t,array_id:e}={}){_t(t)&&(t=this.columns());for(const[r,n]of this._matrixInstance.entries())n.insert({index:t,value:e?e._value[r]:void 0})}add_row({row:t,array_id:e}){_t(t)&&(t=this.rows()),this._matrixInstance.splice(t,0,e||new Qt(this.columns(),void 0,this._errorListener))}is_zero(){return this._matrixArray.every(t=>t.every(e=>e===0))}reshape({rows:t=0,columns:e=0},r){if(t*e!==this.columns()*this.rows()){this._errorListener.addError(se.matrixRehapeErr,r,Pt.Error);return}const n=w1(this._matrixArray,[t,e]);this._matrixInstance=n.map(s=>{const a=new Qt(0,void 0,this._errorListener);return a._value=[...s],a})}reverse(){this._matrixInstance.reverse();for(const t of this._matrixInstance)t.reverse()}is_binary(){return this._matrixArray.every(t=>t.every(e=>e===0||e===1))}is_square(){return this.rows()===this.columns()}submatrix({from_row:t,to_row:e,from_column:r,to_column:n}={}){_t(t)&&(t=0),_t(e)&&(e=this.rows()),_t(r)&&(r=0),_t(n)&&(n=this.columns());const s=this._matrixArray.splice(t,e),a=[];for(const l of s)a.push(l.splice(r,n));return this._newMatrix(a)}swap_rows({row1:t,row2:e}){if(_t(t)||_t(e))return;const r=this._matrixInstance[t],n=this._matrixInstance[e];this._matrixInstance[t]=n,this._matrixInstance[e]=r}transpose(){const t=Wf(this._matrixArray);return this._newMatrix(t)}remove_col({column:t}={}){_t(t)&&(t=this.columns());const e=[];for(const n of this._matrixInstance){const s=n._value.splice(t,1);e.push(s[0])}const r=new Qt(0,void 0,this._errorListener);return r._value=e,r}remove_row({row:t}={}){return _t(t)&&(t=this.rows()),this._matrixInstance.splice(t,1)[0]}eigenvalues(){const t=new uh(new lh(this._matrixArray)),e=new Qt(0,void 0,this._errorListener);return e._value=t.realEigenvalues,e}is_diagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<e;s++)if(n!==s&&r[n][s]!==0)return!1;return!0}is_identity(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<e;s++)if(n!==s&&r[n][s]!==0||n===s&&r[n][s]!==1)return!1;return!0}eigenvectors(){const t=new uh(new lh(this._matrixArray));return this._newMatrix(t.eigenvectorMatrix.to2DArray())}is_symmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=n+1;s<e;s++)if(r[n][s]!==r[s][n])return!1;return!0}swap_columns({column1:t,column2:e}){if(!(_t(t)||_t(e)))for(const r of this._matrixInstance){const n=r._value[t],s=r._value[e];r.set({index:t,value:s}),r.set({index:e,value:n})}}is_stochastic(){const t=this._matrixArray;for(let e=0;e<t.length;e++){let r=0;for(let n=0;n<t[e].length;n++){if(t[e][n]<0)return!1;r+=t[e][n]}if(Math.abs(r-1)>Number.EPSILON)return!1}return!0}is_triangular(){const t=this.rows(),e=this.columns();return t!==e?!1:this._isUpperTriangular(t)||this._isLowerTriangular(t)}elements_count(){return y1(this._matrixArray)}is_antidiagonal(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<t;s++)if(n+s!==t-1&&r[n][s]!==0)return!1;return!0}is_antisymmetric(){const t=this.rows(),e=this.columns();if(t!==e)return!1;const r=this._matrixArray;for(let n=0;n<t;n++)for(let s=0;s<t;s++)if(n!==s&&r[n][s]!==-r[s][n])return!1;return!0}_isUpperTriangular(t){const e=this._matrixArray;for(let r=1;r<t;r++)for(let n=0;n<r;n++)if(e[r][n]!==0)return!1;return!0}_isLowerTriangular(t){const e=this._matrixArray;for(let r=0;r<t-1;r++)for(let n=r+1;n<t;n++)if(e[r][n]!==0)return!1;return!0}_newMatrix(t){const e=new Ga(0,0,void 0,this._errorListener);return e._value=t.map(r=>{const n=new Qt(0,void 0,this._errorListener);return n._value=[...r],n}),e}_matrixRank(t){let e=0;const r=t.length,n=t[0].length,s=[...t].map(a=>[...a]);for(let a=0;a<r&&!(a>=n);a++){let l=a;for(;l<r&&s[l][a]===0;)l++;if(l===r)continue;if(l!==a){const h=s[l];s[l]=s[a],s[a]=h}const c=s[a][a];for(let h=0;h<n;h++)s[a][h]/=c;for(let h=a+1;h<r;h++){const d=s[h][a];s[h]=s[h].map((f,p)=>f-d*s[a][p]),s[h][a]=0}}for(let a=0;a<r;a++)s[a].some(l=>Number(l.toFixed(8))!==0)&&e++;return e}}class Rw{constructor(t){$(this,"_variables");$(this,"_cacheData");this._variables=t,this._cacheData={}}change({timeframe:t},e){if(!t)return!0;const r=tn(t),n=tn(this._variables.timeframe.period);if(r<n)return!0;const s=`change_${e}`,a=this._cacheData[s],l=this._variables.time;if(a){if(a.offset){if(a.currentTime+a.offset<=l)return this._cacheData[s]={currentTime:l,offset:0},!0}else if(a.currentTime+r*1e3<=l)return this._cacheData[s]={currentTime:l,offset:0},!0}else{const c=this._calcTimeOffset(l,t);return this._cacheData[s]={currentTime:l,offset:c},!1}return!1}in_seconds({timeframe:t}={}){return tn(t||this._variables.timeframe.period)}from_seconds({seconds:t=0}){const e=t*1e3,r=ee.duration(e);if(r.years())return"12M";const s=r.asMonths();if(no(s))return`${s}M`;const a=r.asWeeks();if(no(a))return`${a}M`;const l=r.asDays();if(l>=1)return`${Math.ceil(l)}D`;const c=r.asMinutes();if(c>=1)return`${Math.ceil(c)}`;const h=r.asSeconds();return h<=1?"1S":h<=5?"5S":h<=10?"10S":h<=15?"15S":h<=30?"30S":"1"}_calcTimeOffset(t,e){let r=0;if(e.includes("W")){const l=ee(t).day();e="1D",l!==1&&(r=(8-l)*60*60*24*1e3)}else if(e.includes("M")){const l=ee(t).date();e="1D";const c=ee(t).daysInMonth();l!==1&&(r=(c-l+1)*60*60*24*1e3)}const n=this._variables.getTimeTradingday(t,e),s=tn(e)*1e3,a=t-n-Math.floor((t-n)/s)*s;return r?r-a:a}}class Pw{constructor(t,e){$(this,"_errorListener");$(this,"_intlNumberFormatter");$(this,"_precision");this._errorListener=t,this._precision=e,this._intlNumberFormatter=new Intl.NumberFormat("en",{notation:"compact"})}pos({source:t="",str:e=""}){return t==null?void 0:t.indexOf(e)}trim({source:t=""}){return t==null?void 0:t.trim()}lower({source:t=""}){return t==null?void 0:t.toLocaleLowerCase()}match({source:t="",regex:e=""}){const r=t==null?void 0:t.match(new RegExp(e));return r?r[0]:""}split({string:t="",separator:e=""}){const r=t==null?void 0:t.split(e),n=new Qt;return n._value=r||[],n}upper({source:t=""}){return t==null?void 0:t.toLocaleUpperCase()}format({formatString:t=""},e){return this._strFormat(t,e)}length({string:t=""}){return t==null?void 0:t.length}repeat({source:t="",repeat:e,separator:r=""},n){if(_t(e)){this._errorListener.addError(se.arrLenErr,n,Pt.Error);return}return Array.from(new Array(e),()=>t).join(r)}replace({source:t="",target:e="",replacement:r="",occurrence:n}){_t(n)&&(n=0);let s=-1;for(let a=0;a<n+1&&(s=t.indexOf(e,s+1),s!==-1);a++);return s!==-1?t.substring(0,s)+r+t.substring(s+e.length):t}contains({source:t="",str:e=""}){return t==null?void 0:t.includes(e)}endswith({source:t="",str:e=""}){return t==null?void 0:t.endsWith(e)}tonumber({string:t=""}){if(/[^\d.]/.test(t))return;const e=parseFloat(t);return isNaN(e)?void 0:e}tostring({value:t,format:e}){if(t===void 0)return"NaN";if(typeof t=="object"){if(t.isArray)return this._arrToStr(t._value,e);if(t.isMatrix){const r=[];for(const n of t._matrixArray)r.push(this._arrToStr(n,e));return r.join(`
62
+ `)}}if(typeof t=="string")return t;if(typeof t=="boolean")return String(t);if(typeof t=="number")return String(this._toStringFormat(t,e==null?void 0:e.replace(/0/g,"#")))}_arrToStr(t,e){return`[${t.map(n=>typeof n=="number"?this._toStringFormat(n,e):n).toString()}]`}substring({source:t="",begin_pos:e=0,end_pos:r}){return _t(e)&&(e=0),_t(r)&&(r=void 0),t==null?void 0:t.substring(e,r)}startswith({source:t="",str:e=""}){return t==null?void 0:t.startsWith(e)}format_time({time:t,format:e="yyyy-MM-dd'T'HH:mm:ssZ",timezone:r}){return _t(t)&&(t=0),qr(t,r).format(e)}replace_all({source:t="",target:e="",replacement:r=""}){return t==null?void 0:t.replace(new RegExp(e,"g"),r)}_toStringFormat(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case Kt.mintick:return t.toFixed(this._precision);case Kt.percent:return`${t}%`;case Kt.volume:return this._intlNumberFormatter.format(Math.round(t));default:return this._formatOthers(t,e)}}_formatOthers(t,e){var l;let[r,n]=e.split(".");e.split("%").length===2&&(t=t*100);let[s,a=""]=String(t).split(".");if(r.includes("#")){if(r.includes(",")){const c=r.split(","),h=((l=c[c.length-1])==null?void 0:l.replace(/[^#]/g,"").length)||0;h&&(s=s.replace(new RegExp(`\\B(?=(\\d{${h}})+(?!\\d))`,"g"),",")),r=c.join("")}s=r.replace(/#/,s).replace(/#/g,"")}else s=`${r}${s}`;if(n&&n.includes("#")){const c=n.split("#").length-1,h=+`${s}.${a}`;if(!isNaN(h))return`${h.toFixed(c)}${n.replace(/#/g,"")}`;a=`${a.substring(0,c)}${n.replace(/#/g,"")}`}else a=n||"";return a?`${s}.${a}`:s}_formatNumber(t,e){if(!e)return Number(t.toFixed(this._precision));switch(e){case"integer":return String(Math.round(t));case"currency":return`$${t}`;case"percent":return`${t*100}%`;default:return this._formatOthers(t,e)}}_strFormat(t,e){let r=t;for(const[n,s]of e.entries()){if(s===void 0||typeof s=="number"&&isNaN(s)){r="NaN";continue}if(typeof s=="number"){const a=`\\{\\s*${n}\\s*,\\s*number\\s*,\\s*([^\\}]+)\\s*\\}`,l=t.match(new RegExp(a));if(l){const c=l[1];r=r.replace(new RegExp(a,"g"),String(this._formatNumber(s,c)))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(s))}else r=r.replace(new RegExp(`\\{${n}\\}`,"g"),s)}return r}}class zw{constructor(t){$(this,"_errorListener");this._errorListener=t}new(){return new Ha(this._errorListener)}copy({id:t}){return t==null?void 0:t.copy()}get({id:t,key:e}){return t==null?void 0:t.get({key:e})}put({id:t,key:e,value:r}){return t==null?void 0:t.put({key:e,value:r})}keys({id:t}){return t==null?void 0:t.keys()}size({id:t}){return t==null?void 0:t.size()}clear({id:t}){t==null||t.clear()}remove({id:t,key:e}){return t==null?void 0:t.remove({key:e})}values({id:t}){return t==null?void 0:t.values()}put_all({id:t,id2:e}){t==null||t.put_all({id2:e})}contains({id:t,key:e}){return t==null?void 0:t.contains({key:e})}}class Ha{constructor(t){$(this,"_errorListener");$(this,"_mapInstance");this._errorListener=t,this._mapInstance=new Map}get isMap(){return!0}_copyMap(t){const e=new Ha(this._errorListener);return e._mapInstance=new Map(t.entries()),e}copy(){return this._copyMap(this._mapInstance)}get({key:t}){return this._mapInstance.get(t)}put({key:t,value:e}){return this._mapInstance.set(t,e)}keys(){const t=new Qt(0,void 0,this._errorListener);return t._value=[...this._mapInstance.keys()],t}size(){return this._mapInstance.size}clear(){this._mapInstance.clear()}remove({key:t}){const e=this._mapInstance.get(t);return this._mapInstance.delete(t),e||void 0}values(){const t=new Qt(0,void 0,this._errorListener);return t._value=[...this._mapInstance.values()],t}put_all({id2:t}){this._mapInstance=new Map([...this._mapInstance,...t._mapInstance])}contains({key:t}){return this._mapInstance.has(t)}}class kw{constructor(t){$(this,"_variables");this._variables=t}new({price:t,time:e,index:r}){return new Oi(t,r,e)}now({price:t}){const{time:e,bar_index:r}=this._variables;return new Oi(t,r,e)}copy({id:t}){return t==null?void 0:t.copy()}from_index({price:t,index:e}){return new Oi(t,e)}from_time({price:t,time:e}){return new Oi(t,void 0,e)}}class Oi{constructor(t,e,r){$(this,"_index");$(this,"_price");$(this,"_time");this._index=e,this._price=t,this._time=r}get index(){return this._index}set index(t){this._index=t}get price(){return this._price}set price(t){this._price=t}get time(){return this._time}set time(t){this._time=t}copy(){return new Oi(this._price,this._index,this._time)}}class qw{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLabel",{text:"",xloc:De.bar_index,yloc:jr.price,size:ir.normal,style:ve.styleLabelDown,textalign:Wt.alignCenter});this._variables=t,this._errorListener=e}new(t,e){const{time:r,high:n,low:s,bar_index:a}=this._variables,l=`label_${e}_${a}`;ge(t,["color","textcolor"]);const c={...this._defaultLabel,...t,id:l,time:r,high:n,low:s,bar_index:a};t.point&&(c.x=c.xloc===De.bar_index?t.point.index:t.point.time,c.y=t.point.price),c.yloc===jr.abovebar?c.y=n:c.yloc===jr.belowbar&&(c.y=s),this._verfiyArgs(t,e);const h=new _o(l,this._variables,this._errorListener);return e.startsWith("export")||this._variables.label.add(l,c,h),h}_verfiyArgs(t,e){const{xloc:r,yloc:n,style:s,size:a,textalign:l,text_font_family:c}=t,h="label.new";this._paramVerfiy(s,e,h,Object.values(ve),"style"),this._paramVerfiy(r,e,h,Object.values(De),"xloc"),this._paramVerfiy(n,e,h,Object.values(jr),"yloc"),this._paramVerfiy(a,e,h,Object.values(ir),"size"),this._paramVerfiy(l,e,h,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign"),this._paramVerfiy(c,e,h,Object.values(Gn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}label(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}get_x({id:t},e){return t==null?void 0:t.get_x(e)}get_y({id:t},e){return t==null?void 0:t.get_y(e)}set_x({id:t,...e},r){t==null||t.set_x(e,r)}set_y({id:t,...e},r){t==null||t.set_y(e,r)}delete({id:t}){t==null||t.delete()}get_text({id:t},e){return t==null?void 0:t.get_text(e)}set_xy({id:t,...e},r){t==null||t.set_xy(e,r)}set_size({id:t,...e},r){t==null||t.set_size(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}set_yloc({id:t,...e},r){t==null||t.set_yloc(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_tooltip({id:t,...e},r){t==null||t.set_tooltip(e,r)}set_point({id:t,...e},r){t==null||t.set_point(e,r)}set_text({id:t,...e},r){t==null||t.set_text(e,r)}set_textcolor({id:t,...e},r){t==null||t.set_textcolor(e,r)}set_textalign({id:t,...e},r){t==null||t.set_textalign(e,r)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class _o{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_suffix","");this._id=t,this._variables=e,this._errorListener=r}get type(){return Me.LABEL}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.label.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`label_${t}_${e}`,n=this._getLabel(t),s=new _o(r,this._variables,this._errorListener);if(n){const a={...n,id:r,bar_index:e};this._variables.label.add(r,a,s)}return s}get_x(t){var e;return(e=this._getLabel(t))==null?void 0:e.x}get_y(t){var e;return(e=this._getLabel(t))==null?void 0:e.y}set_x({x:t},e){const r=this._getLabel(e);r&&(r.x=t)}set_y({y:t},e){const r=this._getLabel(e);r&&(r.y=t)}delete(){this._variables.label.delete(this._id)}set_xy({x:t,y:e},r){const n=this._getLabel(r);n&&(n.x=t,n.y=e)}get_text(t){var e;return(e=this._getLabel(t))==null?void 0:e.text}set_size({size:t},e){const r=this._getLabel(e);r&&(r.size=t),this._paramVerfiy(t,e,"label.set_size",Object.values(ir),"size")}set_text({text:t},e){const r=this._getLabel(e);r&&(r.text=t)}set_xloc({x:t,xloc:e},r){const n=this._getLabel(r);n&&(n.x=t,n.xloc=e,this._paramVerfiy(e,r,"label.set_xloc",Object.values(De),"xloc"))}set_yloc({yloc:t},e){const r=this._getLabel(e),{high:n,low:s}=this._variables;r&&(r.yloc=t,t===jr.abovebar?r.y=n:t===jr.belowbar&&(r.y=s),this._paramVerfiy(t,e,"label.set_yloc",Object.values(jr),"yloc"))}set_color(t,e){const r=this._getLabel(e);ge(t,["color"]),r&&(r.color=t.color)}set_point({point:t},e){const r=this._getLabel(e);r&&(r.x=r.xloc===De.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,r.y=t==null?void 0:t.price)}set_style({style:t},e){const r=this._getLabel(e);r&&(r.style=t),this._paramVerfiy(t,e,"label.set_style",Object.values(ve),"style")}set_tooltip({tooltip:t},e){const r=this._getLabel(e);r&&(r.tooltip=t)}set_textalign({textalign:t},e){const r=this._getLabel(e);r&&(r.textalign=t),this._paramVerfiy(t,e,"label.set_textalign",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"textalign")}set_textcolor(t,e){const r=this._getLabel(e);ge(t,["textcolor"]),r&&(r.textcolor=t.textcolor)}set_text_font_family({text_font_family:t},e){const r=this._getLabel(e);r&&(r.text_font_family=t),this._paramVerfiy(t,e,"label.set_text_font_family",Object.values(Gn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}_getLabel(t){const e=this._variables.label.get(this._id);return e||console.log(`错误${t}: label 不存在`),e}}const Uw={freq_all:Ur.freqAll,freq_once_per_bar:Ur.freqOncePerBar,freq_once_per_bar_close:Ur.freqOncePerBarClose},Ww={gaps_off:Xi.gapsOff,gaps_on:Xi.gapsOn,lookahead_off:Xi.lookaheadOff,lookahead_on:Xi.lookaheadOn},Bi={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"},ch={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"},jw={friday:6,monday:2,saturday:7,sunday:1,thursday:5,tuesday:3,wednesday:4},fh={all:[Ke.dataWindow,Ke.pane,Ke.priceScale,Ke.statusLine],data_window:[Ke.dataWindow],none:[],pane:[Ke.pane],price_scale:[Ke.priceScale],status_line:[Ke.statusLine]},Vw={both:Wr.both,left:Wr.left,none:Wr.none,right:Wr.right},Yw={inherit:Kt.inherit,mintick:Kt.mintick,percent:Kt.percent,price:Kt.price,volume:Kt.volume},Zw={style_solid:Ms.styleSolid,style_dashed:Ms.styleDashed,style_dotted:Ms.styleDotted},Kw={style_arrowdown:ve.styleArrowdown,style_arrowup:ve.styleArrowup,style_circle:ve.styleCircle,style_cross:ve.styleCross,style_diamond:ve.styleDiamond,style_flag:ve.styleFlag,style_label_center:ve.styleLabelCenter,style_label_down:ve.styleLabelDown,style_label_left:ve.styleLabelLeft,style_label_lower_left:ve.styleLabelLowerLeft,style_label_lower_right:ve.styleLabelLowerRight,style_label_right:ve.styleLabelRight,style_label_up:ve.styleLabelUp,style_label_upper_left:ve.styleLabelUpperLeft,style_label_upper_right:ve.styleLabelUpperRight,style_none:ve.styleNone,style_square:ve.styleSquare,style_text_outline:ve.styleTextOutline,style_triangledown:ve.styleTriangledown,style_triangleup:ve.styleTriangleup,style_xcross:ve.styleXcross},Gw={style_arrow_both:Re.styleArrowBoth,style_arrow_left:Re.styleArrowLeft,style_arrow_right:Re.styleArrowRight,style_dashed:Re.styleDashed,style_dotted:Re.styleDotted,style_solid:Re.styleSolid},Hw={abovebar:ln.abovebar,absolute:ln.absolute,belowbar:ln.belowbar,bottom:ln.bottom,top:ln.top},Jw={e:2.718281828459045,phi:1.618033988749895,pi:3.141592653589793,rphi:.6180339887498948},Xw={style_area:Nr.styleArea,style_areabr:Nr.styleAreabr,style_circles:Nr.styleCircles,style_columns:Nr.styleColumns,style_cross:Nr.styleCross,style_histogram:Nr.styleHistogram,style_line:Nr.styleLine,style_linebr:Nr.styleLinebr,style_stepline:Nr.styleStepline,style_stepline_diamond:Nr.styleSteplineDiamond,style_steplinebr:Nr.styleSteplinebr},Qw={bottom_center:mr.bottomCenter,bottom_left:mr.bottomLeft,bottom_right:mr.bottomRight,middle_center:mr.middleCenter,middle_left:mr.middleLeft,middle_right:mr.middleRight,top_center:mr.topCenter,top_left:mr.topLeft,top_right:mr.topRight},ty={left:Ns.left,none:Ns.none,right:Ns.right},ey={arrowdown:lr.arrowdown,arrowup:lr.arrowup,circle:lr.circle,cross:lr.cross,diamond:lr.diamond,flag:lr.flag,labeldown:lr.labeldown,labelup:lr.labelup,square:lr.square,triangledown:lr.triangledown,triangleup:lr.triangleup,xcross:lr.xcross},ry={auto:ir.auto,huge:ir.huge,large:ir.large,normal:ir.normal,small:ir.small,tiny:ir.tiny},ny={cash:Pe.cash,fixed:Pe.fixed,percent_of_equity:Pe.percentOfEquity,commission:{cash_per_contract:je.cashPerContract,cash_per_order:je.cashPerOrder,percent:je.percent},direction:{all:ce.all,long:ce.long,short:ce.short},oca:{cancel:cn.cancel,none:cn.none,reduce:cn.reduce}},iy={align_bottom:Wt.alignBottom,align_center:Wt.alignCenter,align_left:Wt.alignLeft,align_right:Wt.alignRight,align_top:Wt.alignTop,wrap_auto:Wt.wrapAuto,wrap_none:Wt.wrapNone},sy={bar_index:De.bar_index,bar_time:De.bar_time},oy={abovebar:jr.abovebar,belowbar:jr.belowbar,price:jr.price},ay={actual:Ss.actual,estimate:Ss.estimate,standardized:Ss.standardized};class hh{constructor(){$(this,"adjustment",{dividends:Fs.dividends,none:Fs.none,splits:Fs.splits});$(this,"alert",Uw);$(this,"barmerge",Ww);$(this,"color",Bi);$(this,"currency",ch);$(this,"dayofweek",jw);$(this,"earnings",ay);$(this,"display",fh);$(this,"extend",Vw);$(this,"font",{family_default:Gn.familyDefault,family_monospace:Gn.familyMonospace});$(this,"format",Yw);$(this,"hline",Zw);$(this,"label",Kw);$(this,"line",Gw);$(this,"location",Hw);$(this,"math",Jw);$(this,"order",{ascending:Kn.ascending,descending:Kn.descending});$(this,"plot",Xw);$(this,"position",Qw);$(this,"scale",ty);$(this,"session",{extended:gi.extended,regular:gi.regular});$(this,"shape",ey);$(this,"size",ry);$(this,"splits",{denominator:"denominator",numerator:"numerator"});$(this,"strategy",ny);$(this,"text",iy);$(this,"xloc",sy);$(this,"yloc",oy)}updateData(){}}class uy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultPolyline",{curved:!1,closed:!1,xloc:De.bar_index,line_color:Bi.blue,line_style:Re.styleSolid,line_width:1});this._variables=t,this._errorListener=e}new(t,e){var l;const{bar_index:r}=this._variables,n=`polyline_${e}_${r}`,s=Object.assign({},this._defaultPolyline,t,{id:n,bar_index:r,points:(l=t.points)==null?void 0:l._value.map(c=>({time:c.time,index:c.index,price:c.price}))});ge(s,["line_color","fill_color"]);const a=new dh(n,this._variables);return this._verfiyArgs(t,e),e.startsWith("export")||this._variables.polyline.add(n,s,a),a}_verfiyArgs(t,e){const{line_style:r,xloc:n}=t,s="polyline.new";this._paramVerfiy(r,e,s,Object.values(Re),"line_style"),this._paramVerfiy(n,e,s,Object.values(De),"xloc")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}delete({id:t}){t&&t.delete()}}class dh{constructor(t,e){$(this,"_id");$(this,"_variables");$(this,"_suffix");this._variables=e,this._id=t}get type(){return Me.POLYLINE}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.polyline.get(this._id)}delete(){this._variables.polyline.delete(this._id)}}class ly{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultLine",{xloc:De.bar_index,extend:Wr.none,style:Re.styleSolid});this._variables=t,this._errorListener=e}new({first_point:t,second_point:e,...r},n){const{bar_index:s}=this._variables,a=`line_${n}_${s}`;ge(r,["color"]);const l={...this._defaultLine,...r,id:a,bar_index:s};if(t&&e){const h=l.xloc===De.bar_index?t==null?void 0:t.index:t==null?void 0:t.time,d=l.xloc===De.bar_index?e==null?void 0:e.index:e==null?void 0:e.time;Object.assign(l,{x1:h,y1:t==null?void 0:t.price,x2:d,y2:e==null?void 0:e.price})}this._verfiyArgs(r,n);const c=new mo(a,this._variables,this._errorListener);return n.startsWith("export")||this._variables.line.add(a,l,c),c}_verfiyArgs(t,e){const{extend:r,xloc:n,style:s}=t,a="line.new";this._paramVerfiy(s,e,a,Object.values(Re),"style"),this._paramVerfiy(r,e,a,Object.values(Wr),"extend"),this._paramVerfiy(n,e,a,Object.values(De),"xloc")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}line(t){return t.x}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_x1({id:t},e){return t==null?void 0:t.get_x1(e)}get_x2({id:t},e){return t==null?void 0:t.get_x2(e)}get_y1({id:t},e){return t==null?void 0:t.get_y1(e)}get_y2({id:t},e){return t==null?void 0:t.get_y2(e)}set_x1({id:t,...e},r){t==null||t.set_x1(e,r)}set_x2({id:t,...e},r){t==null||t.set_x2(e,r)}set_y1({id:t,...e},r){t==null||t.set_y1(e,r)}set_y2({id:t,...e},r){t==null||t.set_y2(e,r)}set_xy1({id:t,...e},r){t==null||t.set_xy1(e,r)}set_xy2({id:t,...e},r){t==null||t.set_xy2(e,r)}set_xloc({id:t,...e},r){t==null||t.set_xloc(e,r)}get_price({id:t,...e},r){return t==null?void 0:t.get_price(e,r)}set_color({id:t,...e},r){t==null||t.set_color(e,r)}set_style({id:t,...e},r){t==null||t.set_style(e,r)}set_width({id:t,...e},r){t==null||t.set_width(e,r)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_first_point({id:t,...e},r){t==null||t.set_first_point(e,r)}set_second_point({id:t,...e},r){t==null||t.set_second_point(e,r)}}class mo{constructor(t,e,r){$(this,"_variables");$(this,"_id");$(this,"_suffix","");$(this,"_errorListener");this._id=t,this._variables=e,this._errorListener=r}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get type(){return Me.LINE}get data(){return this._variables.line.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`line_${t}_${e}`,n=this._getLine(t),s=new mo(r,this._variables,this._errorListener);return n&&this._variables.line.add(r,{...n,id:r,bar_index:e,isVar:void 0},s),s}delete(){this._variables.line.delete(this._id)}get_price({x:t},e){const r=this._getLine(e);if(t===void 0)return t;if(r&&r.xloc===De.bar_index){const{x1:n,y1:s,x2:a,y2:l}=r;return n===void 0||a===void 0||s===void 0||l===void 0?void 0:(l-s)/(a-n)*(t-n)+s}}get_x1(t){var e;return(e=this._getLine(t))==null?void 0:e.x1}get_x2(t){var e;return(e=this._getLine(t))==null?void 0:e.x2}get_y1(t){var e;return(e=this._getLine(t))==null?void 0:e.y1}get_y2(t){var e;return(e=this._getLine(t))==null?void 0:e.y2}set_x1({x:t},e){const r=this._getLine(e);r&&(r.x1=t)}set_x2({x:t},e){const r=this._getLine(e);r&&(r.x2=t)}set_y1({y:t},e){const r=this._getLine(e);r&&(r.y1=t)}set_y2({y:t},e){const r=this._getLine(e);r&&(r.y2=t)}set_xy1({x:t,y:e},r){const n=this._getLine(r);n&&(n.x1=t,n.y1=e)}set_xy2({x:t,y:e},r){const n=this._getLine(r);n&&(n.x2=t,n.y2=e)}set_xloc({xloc:t,x1:e,x2:r},n){const s=this._getLine(n);s&&(s.xloc=t,s.x1=e,s.x2=r,this._paramVerfiy(t,n,"line.set_xloc",Object.values(De),"xloc"))}set_color(t,e){const r=this._getLine(e);r&&(ge(t,["color"]),r.color=t.color)}set_style({style:t},e){const r=this._getLine(e);r&&(r.style=t,this._paramVerfiy(t,e,"line.set_style",Object.values(Re),"style"))}set_width({width:t},e){const r=this._getLine(e);r&&(r.width=t)}set_extend({extend:t},e){const r=this._getLine(e);r&&(r.extend=t,this._paramVerfiy(t,e,"line.set_extend",Object.values(Wr),"extend"))}set_first_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},l=r.xloc===De.bar_index?n:s,c=a;l&&(r.x1=l),c&&(r.y1=c)}}set_second_point({point:t},e){const r=this._getLine(e);if(r){const{index:n,time:s,price:a}=t||{},l=r.xloc===De.bar_index?n:s,c=a;l&&(r.x2=l),c&&(r.y2=c)}}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}_getLine(t){const e=this._variables.line.get(this._id);return e||console.log(`${t}: line 不存在`),e}}class cy{constructor(t){$(this,"_variables");this._variables=t}new(t,e){const{line1:r,line2:n}=t,{bar_index:s}=this._variables,a=`linefill_${e}_${s}`,l=r==null?void 0:r.data,c=n==null?void 0:n.data;l&&(l.linefills=l.linefills||[],l.linefills.push(a)),c&&(c.linefills=c.linefills||[],c.linefills.push(a)),ge(t,["color"]);const h=new go(this._variables,a,r,n);return e.startsWith("export")||(l||c)&&this._variables.linefill.add(a,{line1:l,line2:c,color:t.color,id:a,bar_index:s},h),h}delete({id:t}){t==null||t.delete()}get_line1({id:t}){return t==null?void 0:t.get_line1()}get_line2({id:t}){return t==null?void 0:t.get_line2()}set_color({id:t,...e}){t==null||t.set_color(e)}}class go{constructor(t,e,r,n){$(this,"_id");$(this,"_line1");$(this,"_line2");$(this,"_variables");$(this,"_suffix");this._variables=t,this._id=e,this._line1=r,this._line2=n}get type(){return Me.LINEFILL}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.linefill.get(this._id)}linefill(t,e){return t.x?t.x:new go(this._variables,e)}delete(){var e,r;const t=this._variables.linefill.get(this._id);if(t){const{line1:n,line2:s}=t;n&&(n.linefills=(e=n.linefills)==null?void 0:e.filter(a=>a!==this._id)),s&&(s.linefills=(r=s.linefills)==null?void 0:r.filter(a=>a!==this._id))}this._line1=void 0,this._line2=void 0,this._variables.linefill.delete(this._id)}get_line1(){return this._line1}get_line2(){return this._line2}set_color(t){const e=this._variables.linefill.get(this._id);e&&(ge(t,["color"]),e.color=t.color)}}class fy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultBox",{border_color:Bi.blue,border_width:1,bgcolor:Bi.blue,xloc:De.bar_index,extend:Wr.none,style:Re.styleSolid,text:"",text_size:ir.auto,text_color:Bi.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_wrap:Wt.wrapNone});this._variables=t,this._errorListener=e}box({x:t}){return t}new({top_left:t,bottom_right:e,...r},n){const{bar_index:s}=this._variables,a=`box_${n}_${s}`,l={...this._defaultBox,...r,id:a,bar_index:s};if(ge(l,["border_color","bgcolor","text_color"]),t){const{price:h,time:d,index:f}=t;l.top=h,l.left=l.xloc===De.bar_index?f:d}if(e){const{price:h,time:d,index:f}=e;l.bottom=h,l.right=l.xloc===De.bar_index?f:d}this._verfiyArgs(r,n);const c=new vo(this._variables,a,this._errorListener);return n.startsWith("export")||this._variables.box.add(a,l,c),c}_verfiyArgs(t,e){const{border_style:r,extend:n,xloc:s,text_size:a,text_halign:l,text_valign:c,text_wrap:h,text_font_family:d}=t,f="box.new";this._paramVerfiy(r,e,f,[Re.styleDashed,Re.styleDotted,Re.styleSolid],"border_style"),this._paramVerfiy(n,e,f,Object.values(Wr),"extend"),this._paramVerfiy(s,e,f,Object.values(De),"xloc"),this._paramVerfiy(a,e,f,Object.values(ir),"text_size"),this._paramVerfiy(l,e,f,[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"),this._paramVerfiy(c,e,f,[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"),this._paramVerfiy(h,e,f,[Wt.wrapAuto,Wt.wrapNone],"text_wrap"),this._paramVerfiy(d,e,f,Object.values(Gn),"text_font_family")}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}copy({id:t},e){return t==null?void 0:t.copy(e)}delete({id:t}){t==null||t.delete()}get_top({id:t}){return t==null?void 0:t.get_top()}get_bottom({id:t}){return t==null?void 0:t.get_bottom()}get_left({id:t}){return t==null?void 0:t.get_left()}get_right({id:t}){return t==null?void 0:t.get_right()}set_top({id:t,...e}){t==null||t.set_top(e)}set_bottom({id:t,...e}){t==null||t.set_bottom(e)}set_text({id:t,...e}){t==null||t.set_text(e)}set_left({id:t,...e}){t==null||t.set_left(e)}set_right({id:t,...e}){t==null||t.set_right(e)}set_extend({id:t,...e},r){t==null||t.set_extend(e,r)}set_bgcolor({id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({id:t,...e}){t==null||t.set_border_color(e)}set_border_width({id:t,...e}){t==null||t.set_border_width(e)}set_border_style({id:t,...e},r){t==null||t.set_border_style(e,r)}set_lefttop({id:t,...e}){t==null||t.set_lefttop(e)}set_rightbottom({id:t,...e}){t==null||t.set_rightbottom(e)}set_text_size({id:t,...e},r){t==null||t.set_text_size(e,r)}set_text_wrap({id:t,...e},r){t==null||t.set_text_wrap(e,r)}set_text_color({id:t,...e}){t==null||t.set_text_color(e)}set_text_halign({id:t,...e},r){t==null||t.set_text_halign(e,r)}set_text_valign({id:t,...e},r){t==null||t.set_text_valign(e,r)}set_top_left_point({id:t,...e}){t==null||t.set_top_left_point(e)}set_bottom_right_point({id:t,...e}){t==null||t.set_bottom_right_point(e)}set_text_font_family({id:t,...e},r){t==null||t.set_text_font_family(e,r)}}class vo{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_suffix","");this._variables=t,this._id=e,this._errorListener=r}get type(){return Me.BOX}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.box.get(this._id)}copy(t){const{bar_index:e}=this._variables,r=`box_${t}_${e}`,n=this._getBox(),s=new vo(this._variables,r,this._errorListener);return n&&this._variables.box.add(r,{...n,id:r,bar_index:e},s),s}delete(){this._variables.box.delete(this._id)}get_top(){const t=this._getBox();return t&&t.top}set_top({top:t}){const e=this._getBox();e&&(e.top=t)}get_left(){const t=this._getBox();return t&&t.left}set_left({left:t}){const e=this._getBox();e&&(e.left=t)}set_text({text:t}){const e=this._getBox();e&&(e.text=t)}get_right(){const t=this._getBox();return t&&t.right}set_right({right:t}){const e=this._getBox();e&&(e.right=t)}get_bottom(){const t=this._getBox();return t&&t.bottom}set_bottom({bottom:t}){const e=this._getBox();e&&(e.bottom=t)}set_extend({extend:t},e){const r=this._getBox();r&&(r.extend=t,this._paramVerfiy(t,e,"box.set_extend",Object.values(Wr),"extend"))}set_bgcolor({color:t}){const e=this._getBox();e&&(e.bgcolor=t,ge(e,["bgcolor"]))}set_lefttop({left:t,top:e}){const r=this._getBox();r&&(r.left=t,r.top=e)}set_text_size({text_size:t},e){const r=this._getBox();r&&(r.text_size=t,this._paramVerfiy(t,e,"box.set_text_size",Object.values(ir),"text_size"))}set_text_wrap({text_wrap:t},e){const r=this._getBox();r&&(r.text_wrap=t,this._paramVerfiy(t,e,"box.set_text_wrap",[Wt.wrapAuto,Wt.wrapNone],"text_wrap"))}set_text_color({text_color:t}){const e=this._getBox();e&&(e.text_color=t,ge(e,["text_color"]))}set_rightbottom({right:t,bottom:e}){const r=this._getBox();r&&(r.right=t,r.bottom=e)}set_text_halign({text_halign:t},e){const r=this._getBox();r&&(r.text_halign=t,this._paramVerfiy(t,e,"box.set_text_halign",[Wt.alignLeft,Wt.alignCenter,Wt.alignRight],"text_halign"))}set_text_valign({text_valign:t},e){const r=this._getBox();r&&(r.text_valign=t,this._paramVerfiy(t,e,"box.set_text_valign",[Wt.alignBottom,Wt.alignCenter,Wt.alignTop],"text_valign"))}set_top_left_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.top=n,e.left=e.xloc===De.bar_index?r:s}}set_border_color({color:t}){const e=this._getBox();e&&(e.border_color=t,ge(e,["border_color"]))}set_border_style({style:t},e){const r=this._getBox();r&&(r.border_style=t,this._paramVerfiy(t,e,"box.set_border_style",[Re.styleDashed,Re.styleDotted,Re.styleSolid],"style"))}set_border_width({width:t}){const e=this._getBox();e&&(e.border_width=t)}set_bottom_right_point({point:t}){const e=this._getBox();if(e){const{index:r,price:n,time:s}=t||{};e.bottom=n,e.right=e.xloc===De.bar_index?r:s}}set_text_font_family({text_font_family:t},e){const r=this._getBox();r&&(r.text_font_family=t,this._paramVerfiy(t,e,"box.set_text_font_family",Object.values(Gn),"text_font_family"))}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}_getBox(){return this._variables.box.get(this._id)}}class hy{constructor(t,e){$(this,"_variables");$(this,"_errorListener");$(this,"_defaultTable",{position:mr.topLeft,columns:0,rows:0,frame_width:0,border_width:0});this._variables=t,this._errorListener=e}table({x:t}){return t}new(t,e){const{bar_index:r}=this._variables,n=`table_${e}_${r}`,{rows:s}=t;ge(t,["text_color","bgcolor","border_color"]);const a=Array.from(Array(s),()=>[]),l=e.split("_"),c=l.pop(),h=l.pop(),d={...this._defaultTable,...t,cell:a,id:n,bar_index:r,line:h,col:c},f=new ph(this._variables,n,this._errorListener);return this._paramVerfiy(t.position,e,"table.new",Object.values(mr),"position"),e.startsWith("export")||this._variables.table.add(n,d,f),f}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}cell({table_id:t,...e}){t==null||t.cell(e)}cell_set_bgcolor({table_id:t,...e}){t==null||t.cell_set_bgcolor(e)}cell_set_height({table_id:t,...e}){t==null||t.cell_set_height(e)}cell_set_text({table_id:t,...e}){t==null||t.cell_set_text(e)}cell_set_text_color({table_id:t,...e}){t==null||t.cell_set_text_color(e)}cell_set_text_font_family({table_id:t,...e}){t==null||t.cell_set_text_font_family(e)}cell_set_text_halign({table_id:t,...e}){t==null||t.cell_set_text_halign(e)}cell_set_text_valign({table_id:t,...e}){t==null||t.cell_set_text_valign(e)}cell_set_text_size({table_id:t,...e}){t==null||t.cell_set_text_size(e)}cell_set_tooltip({table_id:t,...e}){t==null||t.cell_set_tooltip(e)}cell_set_width({table_id:t,...e}){t==null||t.cell_set_width(e)}clear({table_id:t,...e}){t==null||t.clear(e)}delete({table_id:t}){t==null||t.delete()}merge_cells({table_id:t,...e},r){t==null||t.merge_cells(e,r)}set_bgcolor({table_id:t,...e}){t==null||t.set_bgcolor(e)}set_border_color({table_id:t,...e}){t==null||t.set_border_color(e)}set_border_width({table_id:t,...e}){t==null||t.set_border_width(e)}set_frame_color({table_id:t,...e}){t==null||t.set_frame_color(e)}set_frame_width({table_id:t,...e}){t==null||t.set_frame_width(e)}set_position({table_id:t,...e},r){t==null||t.set_position(e,r)}}class ph{constructor(t,e,r){$(this,"_id");$(this,"_variables");$(this,"_errorListener");$(this,"_suffix","");$(this,"_defaultCell",{column:0,row:0,text:"",text_color:Bi.black,text_halign:Wt.alignCenter,text_valign:Wt.alignCenter,text_size:ir.normal});this._variables=t,this._id=e,this._errorListener=r}get type(){return Me.TABLE}get id(){return this._id}updateId(){const{bar_index:t}=this._variables;if(!this._suffix)this._suffix=`_${t}`,this._id=`${this._id}${this._suffix}`;else{const e=this._id.split("_");e.pop(),this._id=`${e.join("_")}_${t}`}return this._id}get data(){return this._variables.table.get(this._id)}cell(t){const e={...this._defaultCell,...t},{column:r=0,row:n=0}=e,s=this._variables.table.get(this._id);if(s){const a=s.cell||[],l=a[n]||[];l[r]=e,a[n]=l,s.cell=a}}cell_set_bgcolor({column:t=0,row:e=0,bgcolor:r}){const n=this._getTableItem(t,e);n&&(n.bgcolor=r)}cell_set_height({column:t=0,row:e=0,height:r}){const n=this._getTableItem(t,e);n&&(n.height=r)}cell_set_text({column:t=0,row:e=0,text:r}){const n=this._getTableItem(t,e);n&&(n.text=r)}cell_set_text_color({column:t=0,row:e=0,text_color:r}){const n=this._getTableItem(t,e);n&&(n.text_color=r,ge(n,["text_color"]))}cell_set_text_font_family({column:t=0,row:e=0,text_font_family:r}){const n=this._getTableItem(t,e);n&&(n.text_font_family=r)}cell_set_text_halign({column:t=0,row:e=0,text_halign:r}){const n=this._getTableItem(t,e);n&&(n.text_halign=r)}cell_set_text_valign({column:t=0,row:e=0,text_valign:r}){const n=this._getTableItem(t,e);n&&(n.text_valign=r)}cell_set_text_size({column:t=0,row:e=0,text_size:r}){const n=this._getTableItem(t,e);n&&(n.text_size=r)}cell_set_tooltip({column:t=0,row:e=0,tooltip:r}){const n=this._getTableItem(t,e);n&&(n.tooltip=r)}cell_set_width({column:t=0,row:e=0,width:r}){const n=this._getTableItem(t,e);n&&(n.width=r)}clear({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0}){const s=this._variables.table.get(this._id);if(s){const a=s.cell;if(a)for(let l=e;l<=n;l++)for(let c=t;c<=r;c++){const h=a[l];h&&(h[c]=void 0)}}}delete(){this._variables.table.delete(this._id)}merge_cells({start_column:t=0,start_row:e=0,end_column:r=0,end_row:n=0},s){if(t>r||e>n){this._errorListener.addError(se.mergeCellErr,s,Pt.Error);return}const a=this._variables.table.get(this._id);if(!a)return;const l=a.merge_cells||[];l.push({start_column:t,start_row:e,end_column:r,end_row:n}),a.merge_cells=l}set_bgcolor({bgcolor:t}){const e=this._variables.table.get(this._id);e&&(e.bgcolor=t,ge(e,["bgcolor"]))}set_border_color({border_color:t}){const e=this._variables.table.get(this._id);e&&(e.border_color=t,ge(e,["border_color"]))}set_border_width({border_width:t}){const e=this._variables.table.get(this._id);e&&(e.border_width=t)}set_frame_color({frame_color:t}){const e=this._variables.table.get(this._id);e&&(e.frame_color=t)}set_frame_width({frame_width:t}){const e=this._variables.table.get(this._id);e&&(e.frame_width=t)}set_position({position:t},e){const r=this._variables.table.get(this._id);r&&(r.position=t,this._paramVerfiy(t,e,"table.set_position",Object.values(mr),"position"))}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}_getTableItem(t,e){const r=this._variables.table.get(this._id);if(r){const n=r.cell;return n?n[e][t]:void 0}}}class dy{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){return this._verifyTradeNum(t)&&this._strategy.historyOrders[t].commission||0}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.historyOrders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_price}entry_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].in_time}exit_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_index}exit_comment({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_comment:""}exit_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].out_id:""}exit_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_price}exit_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.historyOrders[t].out_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.historyOrders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{out_qty:e=0,direction:r}=this._strategy.historyOrders[t];return r===ce.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.historyOrders.length;return!(t>=e)}}class py{constructor(t){$(this,"_strategy");this._strategy=t}commission({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,original_qty:r=0,commission:n=0}=this._strategy.orders[t];return n*e/r}entry_bar_index({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_index}entry_comment({trade_num:t}){if(!this._verifyTradeNum(t))return"";const{comment:e,id:r}=this._strategy.orders[t];return e||r}entry_id({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].id:""}entry_price({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_price}entry_time({trade_num:t}){if(this._verifyTradeNum(t))return this._strategy.orders[t].in_time}max_drawdown({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss:0}max_drawdown_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].trading_loss_percent:0}max_runup({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit:0}max_runup_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].max_profit_percent:0}profit({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit:0}profit_percent({trade_num:t}){return this._verifyTradeNum(t)?this._strategy.orders[t].profit_percent:0}size({trade_num:t}){if(!this._verifyTradeNum(t))return 0;const{qty:e=0,direction:r}=this._strategy.orders[t];return r===ce.long?e:-e}_verifyTradeNum(t){if(typeof t!="number"||t<0)return!1;const e=this._strategy.orders.length;return!(t>=e)}}class _y{constructor(t,e){$(this,"_strategy");$(this,"_errorListener");this._strategy=t,this._errorListener=e}allow_entry_in({value:t},e){this._paramVerfiy(t,e,"strategy.risk.allow_entry_in",Object.values(ce),"value"),this._strategy.updateRisk({allow_entry_in:t})}max_cons_loss_days({count:t}){this._strategy.updateRisk({max_cons_loss_days:t})}max_drawdown({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_drawdown",[Pe.percentOfEquity,Pe.cash],"type"),e===Pe.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_drawdown:t,max_drawdown_type:e})}max_intraday_filled_orders({count:t}){this._strategy.updateRisk({max_intraday_filled_orders:t})}max_intraday_loss({value:t,type:e},r){this._paramVerfiy(e,r,"strategy.risk.max_intraday_loss",[Pe.percentOfEquity,Pe.cash],"type"),e===Pe.percentOfEquity&&(t=t>100?100:t),this._strategy.updateRisk({max_intraday_loss:t,max_intraday_loss_type:e})}max_position_size({contracts:t}){this._strategy.updateRisk({max_position_size:t})}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}}var my=20,gy=1,ei=1e6,_h=1e6,vy=-7,wy=21,yy=!1,as="[big.js] ",ri=as+"Invalid ",wo=ri+"decimal places",Dy=ri+"rounding mode",mh=as+"Division by zero",ae={},sn=void 0,by=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function gh(){function i(t){var e=this;if(!(e instanceof i))return t===sn?gh():new i(t);if(t instanceof i)e.s=t.s,e.e=t.e,e.c=t.c.slice();else{if(typeof t!="string"){if(i.strict===!0&&typeof t!="bigint")throw TypeError(ri+"value");t=t===0&&1/t<0?"-0":String(t)}xy(e,t)}e.constructor=i}return i.prototype=ae,i.DP=my,i.RM=gy,i.NE=vy,i.PE=wy,i.strict=yy,i.roundDown=0,i.roundHalfUp=1,i.roundHalfEven=2,i.roundUp=3,i}function xy(i,t){var e,r,n;if(!by.test(t))throw Error(ri+"number");for(i.s=t.charAt(0)=="-"?(t=t.slice(1),-1):1,(e=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(e<0&&(e=r),e+=+t.slice(r+1),t=t.substring(0,r)):e<0&&(e=t.length),n=t.length,r=0;r<n&&t.charAt(r)=="0";)++r;if(r==n)i.c=[i.e=0];else{for(;n>0&&t.charAt(--n)=="0";);for(i.e=e-r-1,i.c=[],e=0;r<=n;)i.c[e++]=+t.charAt(r++)}return i}function ni(i,t,e,r){var n=i.c;if(e===sn&&(e=i.constructor.RM),e!==0&&e!==1&&e!==2&&e!==3)throw Error(Dy);if(t<1)r=e===3&&(r||!!n[0])||t===0&&(e===1&&n[0]>=5||e===2&&(n[0]>5||n[0]===5&&(r||n[1]!==sn))),n.length=1,r?(i.e=i.e-t+1,n[0]=1):n[0]=i.e=0;else if(t<n.length){if(r=e===1&&n[t]>=5||e===2&&(n[t]>5||n[t]===5&&(r||n[t+1]!==sn||n[t-1]&1))||e===3&&(r||!!n[0]),n.length=t,r){for(;++n[--t]>9;)if(n[t]=0,t===0){++i.e,n.unshift(1);break}}for(t=n.length;!n[--t];)n.pop()}return i}function ii(i,t,e){var r=i.e,n=i.c.join(""),s=n.length;if(t)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)n="0"+n;n="0."+n}else if(r>0)if(++r>s)for(r-=s;r--;)n+="0";else r<s&&(n=n.slice(0,r)+"."+n.slice(r));else s>1&&(n=n.charAt(0)+"."+n.slice(1));return i.s<0&&e?"-"+n:n}ae.abs=function(){var i=new this.constructor(this);return i.s=1,i},ae.cmp=function(i){var t,e=this,r=e.c,n=(i=new e.constructor(i)).c,s=e.s,a=i.s,l=e.e,c=i.e;if(!r[0]||!n[0])return r[0]?s:n[0]?-a:0;if(s!=a)return s;if(t=s<0,l!=c)return l>c^t?1:-1;for(a=(l=r.length)<(c=n.length)?l:c,s=-1;++s<a;)if(r[s]!=n[s])return r[s]>n[s]^t?1:-1;return l==c?0:l>c^t?1:-1},ae.div=function(i){var t=this,e=t.constructor,r=t.c,n=(i=new e(i)).c,s=t.s==i.s?1:-1,a=e.DP;if(a!==~~a||a<0||a>ei)throw Error(wo);if(!n[0])throw Error(mh);if(!r[0])return i.s=s,i.c=[i.e=0],i;var l,c,h,d,f,p=n.slice(),g=l=n.length,w=r.length,m=r.slice(0,l),y=m.length,v=i,x=v.c=[],b=0,M=a+(v.e=t.e-i.e)+1;for(v.s=s,s=M<0?0:M,p.unshift(0);y++<l;)m.push(0);do{for(h=0;h<10;h++){if(l!=(y=m.length))d=l>y?1:-1;else for(f=-1,d=0;++f<l;)if(n[f]!=m[f]){d=n[f]>m[f]?1:-1;break}if(d<0){for(c=y==l?n:p;y;){if(m[--y]<c[y]){for(f=y;f&&!m[--f];)m[f]=9;--m[f],m[y]+=10}m[y]-=c[y]}for(;!m[0];)m.shift()}else break}x[b++]=d?h:++h,m[0]&&d?m[y]=r[g]||0:m=[r[g]]}while((g++<w||m[0]!==sn)&&s--);return!x[0]&&b!=1&&(x.shift(),v.e--,M--),b>M&&ni(v,M,e.RM,m[0]!==sn),v},ae.eq=function(i){return this.cmp(i)===0},ae.gt=function(i){return this.cmp(i)>0},ae.gte=function(i){return this.cmp(i)>-1},ae.lt=function(i){return this.cmp(i)<0},ae.lte=function(i){return this.cmp(i)<1},ae.minus=ae.sub=function(i){var t,e,r,n,s=this,a=s.constructor,l=s.s,c=(i=new a(i)).s;if(l!=c)return i.s=-c,s.plus(i);var h=s.c.slice(),d=s.e,f=i.c,p=i.e;if(!h[0]||!f[0])return f[0]?i.s=-c:h[0]?i=new a(s):i.s=1,i;if(l=d-p){for((n=l<0)?(l=-l,r=h):(p=d,r=f),r.reverse(),c=l;c--;)r.push(0);r.reverse()}else for(e=((n=h.length<f.length)?h:f).length,l=c=0;c<e;c++)if(h[c]!=f[c]){n=h[c]<f[c];break}if(n&&(r=h,h=f,f=r,i.s=-i.s),(c=(e=f.length)-(t=h.length))>0)for(;c--;)h[t++]=0;for(c=t;e>l;){if(h[--e]<f[e]){for(t=e;t&&!h[--t];)h[t]=9;--h[t],h[e]+=10}h[e]-=f[e]}for(;h[--c]===0;)h.pop();for(;h[0]===0;)h.shift(),--p;return h[0]||(i.s=1,h=[p=0]),i.c=h,i.e=p,i},ae.mod=function(i){var t,e=this,r=e.constructor,n=e.s,s=(i=new r(i)).s;if(!i.c[0])throw Error(mh);return e.s=i.s=1,t=i.cmp(e)==1,e.s=n,i.s=s,t?new r(e):(n=r.DP,s=r.RM,r.DP=r.RM=0,e=e.div(i),r.DP=n,r.RM=s,this.minus(e.times(i)))},ae.neg=function(){var i=new this.constructor(this);return i.s=-i.s,i},ae.plus=ae.add=function(i){var t,e,r,n=this,s=n.constructor;if(i=new s(i),n.s!=i.s)return i.s=-i.s,n.minus(i);var a=n.e,l=n.c,c=i.e,h=i.c;if(!l[0]||!h[0])return h[0]||(l[0]?i=new s(n):i.s=n.s),i;if(l=l.slice(),t=a-c){for(t>0?(c=a,r=h):(t=-t,r=l),r.reverse();t--;)r.push(0);r.reverse()}for(l.length-h.length<0&&(r=h,h=l,l=r),t=h.length,e=0;t;l[t]%=10)e=(l[--t]=l[t]+h[t]+e)/10|0;for(e&&(l.unshift(e),++c),t=l.length;l[--t]===0;)l.pop();return i.c=l,i.e=c,i},ae.pow=function(i){var t=this,e=new t.constructor("1"),r=e,n=i<0;if(i!==~~i||i<-_h||i>_h)throw Error(ri+"exponent");for(n&&(i=-i);i&1&&(r=r.times(t)),i>>=1,!!i;)t=t.times(t);return n?e.div(r):r},ae.prec=function(i,t){if(i!==~~i||i<1||i>ei)throw Error(ri+"precision");return ni(new this.constructor(this),i,t)},ae.round=function(i,t){if(i===sn)i=0;else if(i!==~~i||i<-ei||i>ei)throw Error(wo);return ni(new this.constructor(this),i+this.e+1,t)},ae.sqrt=function(){var i,t,e,r=this,n=r.constructor,s=r.s,a=r.e,l=new n("0.5");if(!r.c[0])return new n(r);if(s<0)throw Error(as+"No square root");s=Math.sqrt(+ii(r,!0,!0)),s===0||s===1/0?(t=r.c.join(""),t.length+a&1||(t+="0"),s=Math.sqrt(t),a=((a+1)/2|0)-(a<0||a&1),i=new n((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+a)):i=new n(s+""),a=i.e+(n.DP+=4);do e=i,i=l.times(e.plus(r.div(e)));while(e.c.slice(0,a).join("")!==i.c.slice(0,a).join(""));return ni(i,(n.DP-=4)+i.e+1,n.RM)},ae.times=ae.mul=function(i){var t,e=this,r=e.constructor,n=e.c,s=(i=new r(i)).c,a=n.length,l=s.length,c=e.e,h=i.e;if(i.s=e.s==i.s?1:-1,!n[0]||!s[0])return i.c=[i.e=0],i;for(i.e=c+h,a<l&&(t=n,n=s,s=t,h=a,a=l,l=h),t=new Array(h=a+l);h--;)t[h]=0;for(c=l;c--;){for(l=0,h=a+c;h>c;)l=t[h]+s[c]*n[h-c-1]+l,t[h--]=l%10,l=l/10|0;t[h]=l}for(l?++i.e:t.shift(),c=t.length;!t[--c];)t.pop();return i.c=t,i},ae.toExponential=function(i,t){var e=this,r=e.c[0];if(i!==sn){if(i!==~~i||i<0||i>ei)throw Error(wo);for(e=ni(new e.constructor(e),++i,t);e.c.length<i;)e.c.push(0)}return ii(e,!0,!!r)},ae.toFixed=function(i,t){var e=this,r=e.c[0];if(i!==sn){if(i!==~~i||i<0||i>ei)throw Error(wo);for(e=ni(new e.constructor(e),i+e.e+1,t),i=i+e.e+1;e.c.length<i;)e.c.push(0)}return ii(e,!1,!!r)},ae[Symbol.for("nodejs.util.inspect.custom")]=ae.toJSON=ae.toString=function(){var i=this,t=i.constructor;return ii(i,i.e<=t.NE||i.e>=t.PE,!!i.c[0])},ae.toNumber=function(){var i=+ii(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(i.toString()))throw Error(as+"Imprecise conversion");return i},ae.toPrecision=function(i,t){var e=this,r=e.constructor,n=e.c[0];if(i!==sn){if(i!==~~i||i<1||i>ei)throw Error(ri+"precision");for(e=ni(new r(e),i,t);e.c.length<i;)e.c.push(0)}return ii(e,i<=e.e||e.e<=r.NE||e.e>=r.PE,!!n)},ae.valueOf=function(){var i=this,t=i.constructor;if(t.strict===!0)throw Error(as+"valueOf disallowed");return ii(i,i.e<=t.NE||i.e>=t.PE,!0)};var Ja=gh();function Ey(i,t){return Ja(i).plus(t).toNumber()}function Xa(i,t){return Ja(i).minus(t).toNumber()}function yo(i,t){return Ja(i).mul(t).toNumber()}let Ay=class{constructor(t,e,r,n,s){$(this,"_variables");$(this,"_options");$(this,"_totalChangeCapital");$(this,"_historyOrder");$(this,"_orders");$(this,"_exitOrders");$(this,"_pendingOrders");$(this,"_mintick");$(this,"_funcOptions");$(this,"_pendingCloseOrders");$(this,"_errorListener");$(this,"_risk");$(this,"_opentrades");$(this,"_closedtrades");$(this,"_riskNamespace");$(this,"_updateOptions",{});$(this,"_id");$(this,"_maxDrawdownVerifyIndex",0);$(this,"calcOnOrderFillsData",{index:-1});this._variables=t,this._errorListener=n,this._options={overlay:!1,format:Kt.inherit,pyramiding:1,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:Pe.fixed,default_qty_value:1,initial_capital:1e6,currency:ch.NONE,slippage:0,commission_type:je.percent,commission_value:0,process_orders_on_close:!1,close_entries_rule:"FIFO",margin_long:0,margin_short:0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,max_polylines_count:50},this._funcOptions=e,this._totalChangeCapital=0,this._orders=[],this._pendingOrders=[],this._historyOrder=[],this._exitOrders=[],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 py(this),this._closedtrades=new dy(this),this._riskNamespace=new _y(this,n),this._id=`strategy_${s}`}get orders(){return[...this._orders]}get historyOrders(){return[...this._historyOrder]}get _freezeCapital(){const{close:t}=this.calcOnOrderFillsData.data||this._variables;return this._orders.reduce((e,r)=>e+t*(r.qty||0),0)}get opentrades(){return this._opentrades}get closedtrades(){return this._closedtrades}get risk(){return this._riskNamespace}get isCalcOnEveryTick(){return this._options.calc_on_every_tick}updateOptions(t){this._updateOptions=t||{},Object.assign(this._options,this._updateOptions)}update(){this._maxConsLossDaysVerify(),this._pendingOrderHandle(),this._maxIntradayFilledOrdersVerify(),this._ordersHandle(),this._exitOrdersHandle(),this._maxDrawdownVerify();const{open:t,close:e,high:r,low:n}=this.calcOnOrderFillsData.data||this._variables;this._variables.strategy.update({open:t,close:e,high:r,low:n}),!this._options.process_orders_on_close&&this._calcLiquidate(),this._calcProfitAndLoss()}calcCurrentOrder(){this._calcProfitAndLoss()}updateRisk(t){Object.assign(this._risk,t)}endExecution(){this._maxIntradayLoss(),this._pendingCloseOrderHandle(),this._options.process_orders_on_close&&this._calcLiquidate()}_maxIntradayLoss(){var g;const{max_intraday_loss:t,max_intraday_loss_type:e,isDisabledOpen:r}=this._risk;if(t===void 0||!e||r)return;const{time_tradingday:n,time:s,strategy:{netprofit:a,initial_capital:l}}=this._variables,{high:c,low:h}=this.calcOnOrderFillsData.data||this._variables;let{preNetprofit:d=0}=this._risk;s===n&&(d=a,this._risk.preNetprofit=a,this._risk.isTemporaryBan=!1);let f=d-a;f+=this._orders.reduce((w,m)=>{const{in_price:y,direction:v,qty:x=0,commission:b=0,original_qty:M=0}=m,E=v===ce.long?1:-1,F=(c-y)*x,N=(h-y)*x,S=E===1?N:-F;return w+S+x/M*b},0);let p=!1;switch(e){case Pe.cash:p=t<f;break;case Pe.percentOfEquity:const w=f/(l+a)*100;p=t<w;break}if(p){this._risk.isTemporaryBan=!0;const w=(g=this._orders[0])==null?void 0:g.direction;this._closeOrders(this._orders,w===ce.long?h:c,"Close Position (Max intraday Loss)",void 0,"close"),this._pendingOrders=[]}}_maxIntradayFilledOrdersVerify(){const{max_intraday_filled_orders:t,intradayOrders:e=0,isDisabledOpen:r}=this._risk;if(t===void 0||r)return;const{time:n,time_tradingday:s}=this._variables,{open:a}=this.calcOnOrderFillsData.data||this._variables;n===s&&(this._risk.intradayOrders=0,this._risk.isTemporaryBan=!1),t<=e&&(this._risk.isTemporaryBan=!0,this._closeOrders(this._orders,a,"Close Position (Max number of filled orders in one day)",void 0,"close"),this._pendingOrders=[])}_maxConsLossDaysVerify(){const{max_cons_loss_days:t,lossDays:e=0,isDisabledOpen:r,totalProfit:n=0}=this._risk;if(t===void 0||r)return;const{time:s,time_tradingday:a,strategy:l}=this._variables,{open:c}=this.calcOnOrderFillsData.data||this._variables;let h=e;if(s===a){const d=l.netprofit+l.openprofit;d<n?h=0:h++,Object.assign(this._risk,{lossDays:h,totalProfit:d})}t<=h&&this._riskTouchOff(c,"Close Position (Max consecutive loss days)")}_maxDrawdownVerify(){const{max_drawdown:t,max_drawdown_type:e,isDisabledOpen:r}=this._risk;if(r)return;const{bar_index:n}=this._variables,{open:s}=this.calcOnOrderFillsData.data||this._variables;if(t!==void 0&&e&&this._maxDrawdownVerifyIndex===n){const{initial_capital:a}=this._options,c=this._orders.reduce((d,f)=>{const{in_price:p,commission:g=0,qty:w=0,original_qty:m=0,direction:y}=f,v=y===ce.long?1:-1,x=(s-p)*v*w;return d+x+g*w/m},0)+this._totalChangeCapital;let h=!1;switch(e){case Pe.percentOfEquity:h=c/a*100<=-t;break;case Pe.cash:h=c<=-t;break}h&&this._riskTouchOff(s,"Close Position (Max Drawdown)")}}_riskTouchOff(t,e){this._risk.isDisabledOpen=!0,this._orders.length&&this._closeOrders(this._orders,t,e,"close"),this._pendingOrders=[]}strategy(t,e){if(!this._variables.bar_index){this._paramVerfiy(t.format,e,"strategy",[Kt.inherit,Kt.price,Kt.percent,Kt.volume],"format"),this._paramVerfiy(t.default_qty_type,e,"strategy",Object.values(Pe),"default_qty_type"),this._paramVerfiy(t.commission_type,e,"strategy",Object.values(je),"commission_type");const r=self==null?void 0:self.workerStorage.get(this._id),n={...this._updateOptions};if(r)for(const s of Object.keys({...r,...t}))t[s]!==r[s]&&delete n[s];self==null||self.workerStorage.set(this._id,t),Object.assign(this._options,t,n),this._variables.updateMaxLength(t),Object.assign(this._funcOptions,{strategy:this._options,userSetStrategyConfig:n,scriptType:"strategy"})}}order(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.order",Object.values(cn),"oca_type"),this._orderHandle(t))}entry(t,e){this._risk.isDisabledOpen||(this._paramVerfiy(t.oca_type,e,"strategy.entry",Object.values(cn),"oca_type"),this._entryHandle(t))}close(t){if(!this._orders.filter(r=>!this._options.process_orders_on_close||r.in_index!==this._variables.bar_index).length)return;const{immediately:e}=t;if(e||this._options.process_orders_on_close){const r=this._pendingCloseOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingCloseOrders.push({...t,place_order_type:"close"})}else{const r=this._pendingOrders.find(n=>n.id===t.id&&n.place_order_type==="close");if(r){Object.assign(r,t);return}this._pendingOrders.push({...t,place_order_type:"close"})}}close_all(t){if(typeof t=="string"&&(t={}),!this._orders.length)return;const{immediately:e}=t;e||this._options.process_orders_on_close?this._pendingCloseOrders.push({...t,place_order_type:"close_all"}):this._pendingOrders.push({...t,place_order_type:"close_all"})}cancel({id:t}){this._pendingOrders=this._pendingOrders.filter(e=>!(e.id===t&&e.place_order_type!=="close"))}cancel_all(){this._pendingOrders=this._pendingOrders.filter(t=>t.place_order_type==="close_all")}exit(t,e){this._exit(t,e)}convert_to_account({value:t}){return t}convert_to_symbol({value:t}){return t}default_entry_qty({fill_price:t}){return t?this._calcDefaultQty(t):0}_calcDefaultQty(t){const{default_qty_type:e=Pe.fixed,default_qty_value:r=1,initial_capital:n,commission_value:s}=this._options;let a=r;switch(e){case Pe.cash:a=r/t;break;case Pe.percentOfEquity:const l=this._getOrderProfit(t),c=n+l+this._totalChangeCapital;s?a=this._getCommQty(c,t):a=c*r/100/t;break}return Vl(a,this._getLen(t))}_getCommQty(t,e){const{commission_type:r,commission_value:n=0,default_qty_value:s=0}=this._options;let a=0;switch(r){case je.percent:a=t*s/(100*e+n*e);break;case je.cashPerContract:a=t*s/(100*e+n);break;case je.cashPerOrder:a=(t-n)*s/100/e}return a}_getLen(t){const e=String(Math.floor(t)).length-2;return e<0?0:e}_getCapital(t,e){const{margin_long:r=0,margin_short:n=0}=this._options;return r<100&&r>0&&t===1?e=e*100/r:n<=100&&n>0&&t===-1&&(e=e*100/n),e}_calcProfitAndLoss(){const{close:t}=this.calcOnOrderFillsData.data||this._variables;for(const e of this._orders){const{in_price:r,qty:n=0,direction:s}=e,a=s===ce.long?1:-1,l=(t-r)*a*n,[c,h]=this._calcProfitAndLossHandle(r,n,a);this._calcOrderPercent(e,l,c,h)}}_calcProfitAndLossHandle(t,e,r){const{high:n,low:s}=this.calcOnOrderFillsData.data||this._variables,a=(n-t)*e,l=(s-t)*e;let c=r===1?a:-l,h=r===1?l:-a;return[c,h]}_calcOrderPercent(t,e,r,n){const{commission_value:s}=this._options,{close:a}=this.calcOnOrderFillsData.data||this._variables,{original_qty:l=0,qty:c=0,in_price:h,max_profit:d=0,trading_loss:f=0}=t;let{commission:p=0}=t,g=h*c;if(s){const w=this._getCommission(a,c);p=p*c/l,r-=p,n-=p,g+=p,e=e-w-p}r=Math.max(r,d,0),n=Math.min(n,f,0),Object.assign(t,{profit:e,total_profit:this._totalChangeCapital+e,total_profit_percent:e/(this._options.initial_capital+this._totalChangeCapital)*100,max_profit:r,trading_loss:n,profit_percent:e/g*100,max_profit_percent:r/g*100,trading_loss_percent:n/g*100})}_calcLiquidate(){if(!this._orders.length)return;const{time:t}=this._variables,{high:e,low:r}=this.calcOnOrderFillsData.data||this._variables,{initial_capital:n,margin_long:s=0,margin_short:a=0}=this._options,l=this._orders[0].direction===ce.long?1:-1;let c=l===1?r:e;if(l===1&&s===100)return;const h=(l===1?s:a)/100;if(h<=0)return;let d=!1;const[f,p]=this._orders.reduce((y,v)=>{let[x,b]=y;const{in_price:M,qty:E=0,in_time:F}=v;F===t&&(d=!0);const N=M*E,S=c*E;return x+=N,b+=S,[x,b]},[0,0]);let g=0,w=0;const m=n+this._totalChangeCapital;if(d&&(g=m-f*h,g<0&&(c=this._orders[0].in_price,w=Math.abs(Math.trunc(g/h/c)*4),w=Math.max(w,1))),g>=0){const y=l*(p-f);if(g=m+y-p*h,g>=0)return;w=Math.abs(Math.trunc(g/h/c)*4)}w<=0||this._marginCallOrders(c,w,"Margin Call")}_marginCallOrders(t,e,r){const{close_entries_rule:n="FIFO"}=this._options;if(n==="FIFO"){this._processOrders(this._orders,t,e*this._orders.length,r,r,!0);return}for(const s of this.orders)s.position_close_type=s.place_order_type,this._processOrder(s,t,e,r,r,!0);this._orders=this._orders.filter(s=>!s.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_orderHandle(t){const{process_orders_on_close:e,slippage:r=0}=this._options,{orders:n,isMarketPrice:s,quantities:a,close:l,price:c,activePrice:h,isTouch:d}=this._orderArgsParse(t),f=t.direction===ce.long?1:-1;if(a<=0)return;let p=a;if((s||d)&&e){const w=d?c:l;if(n.length){const E=this._processOrders(n,w,p,t.id,t.comment,!1,"order");if(E<=0)return;p=E}const m=w+f*r*this._mintick;if(!this._judgeCapitalEnough(p,m,f))return;this._ocaGroupVerify(p,t.oca_name,t.oca_type);const{bar_index:v,time:x}=this._variables,{high:b,low:M}=this.calcOnOrderFillsData.data||this._variables;this._calcCurrentOrder({...t,in_price:m,in_high:b,in_low:M,in_index:v,in_time:x,qty:p,place_order_type:"order"});return}this._judgeCapitalEnough(a,c,f)&&this._addPendingOrders(t,c,p,s,h)}_judgeCapitalEnough(t,e,r){let n=this._freezeCapital;if(this._orders.some(d=>(d.direction===ce.long?1:-1)!==r)&&(n=0),t<=0)return!1;const{margin_long:s=0,margin_short:a=0}=this._options;if(s===0&&r===1||a===0&&r===-1)return!0;const l=this._getOrderProfit(e),h=this._getCapital(r,this._options.initial_capital+l+this._totalChangeCapital)-n;return t*e<=h}_getOrderProfit(t){return this._orders.reduce((e,r)=>{const{in_price:n,qty:s=0,direction:a}=r,l=a===ce.long?1:-1;return e+(t-n)*s*l},0)}_ocaGroupVerify(t,e,r){if(!e||!r||r===cn.none)return!1;let n=!1;switch(r){case cn.cancel:this._pendingOrders=this._pendingOrders.filter(s=>{if(s.oca_name===e)s.isCancel=!0,n=!0;else return!0});break;case cn.reduce:this._pendingOrders=this._pendingOrders.filter(s=>{const{qty:a=0,oca_name:l}=s;if(e===l){const c=a-t;return n=!0,c<=0?(s.isCancel=!0,!1):(s.qty=c,!0)}else return!0});break}return n}_processOrders(t,e,r,n,s,a=!1,l,c){let h=r;for(const d of t)if(d.position_close_type=l||d.place_order_type,d.immediately=c,h=this._processOrder(d,e,h,n,s,a),h<=0)break;return this._orders=this._orders.filter(d=>!d.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),h}_addPendingOrders(t,e,r,n,s){const a=this._pendingOrders.find(l=>l.id===t.id&&!l.isMarketPrice);if(a)Object.assign(a,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:s});else{const l={...t,in_price:e,isMarketPrice:n,qty:r,active_price:s,place_order_type:"order"};this._pendingOrders.push(l)}}_orderArgsParse(t){const{direction:e,qty:r,stop:n}=t;let s=t.limit||0;const{close:a}=this.calcOnOrderFillsData.data||this._variables;let l=a,c=!1,h;const d=e===ce.long?1:-1,f=n&&(n-a)*d>=0,{backtest_fill_limits_assumption:p=0}=this._options;p>0&&s&&(s-=p*this._mintick*d);const g=s&&(s-a)*d<=0;let w=!1;f&&g?(n!==a&&(h=n),l=s):f?(l=n,w=n===a):g?(l=s,w=s===a):c=!0;const m=r!==void 0?Vl(r,this._getLen(l)):this._calcDefaultQty(l);return{orders:this._orders.filter(v=>v.direction!==e),isMarketPrice:c,activePrice:h,quantities:m,close:a,price:l,isTouch:w}}_entryHandle(t){const{process_orders_on_close:e}=this._options,{orders:r,isMarketPrice:n,quantities:s,close:a,price:l,activePrice:c,isTouch:h}=this._orderArgsParse(t);if(s<=0)return;if((n||h)&&e){this._entryOrder(r,h?l:a,s,t);return}this._judgeCapitalEnough(s,a,t.direction===ce.long?1:-1)&&this._addPendingEntry(t,l,s,n,c)}_entryOrder(t,e,r,n){const{time:s,bar_index:a}=this._variables,{high:l,low:c}=this.calcOnOrderFillsData.data||this._variables,{slippage:h=0}=this._options,{oca_name:d,oca_type:f,direction:p,comment:g,id:w}=n,m=p===ce.long?1:-1;if(r=this._getAvailablePositionSize(r,p),r<=0||(e=e+h*this._mintick*m,!this._judgeCapitalEnough(r,e,m)))return;this._closeOrders(t,e,w,g,"entry");const v={...n,in_price:e,qty:r,in_index:a,in_high:l,in_low:c,in_time:s,place_order_type:"entry"},{orders:x}=this._getEntryOrders(p),b=x.length;b&&b>=(this._options.pyramiding||1)||(this._ocaGroupVerify(r,d,f),this._calcCurrentOrder(v))}_getAvailablePositionSize(t,e){const{max_position_size:r,allow_entry_in:n}=this._risk;if(n&&n!==ce.all&&n!==e)return 0;if(r===void 0)return t;const s=this._orders.reduce((a,l)=>a+(l.qty||0),0);return s?s+t>r?0:t:t>r?t-r:0}_getEntryOrders(t){const e=this._pendingOrders.filter(n=>["entry","order"].includes(n.place_order_type)&&n.direction===t),r=this._orders.filter(n=>n.direction===t);return{pendingOrders:e,orders:r}}_addPendingEntry(t,e,r,n,s){if(r=this._getAvailablePositionSize(r,t.direction),r<=0)return;const{pendingOrders:a,orders:l}=this._getEntryOrders(t.direction),c=a.length+l.length,h=a.find(d=>d.id===t.id&&d.place_order_type==="entry");if(h)Object.assign(h,{...t,in_price:e,isMarketPrice:n,qty:r,active_price:s});else if(!c||c<(this._options.pyramiding||1)){const d={...t,in_price:e,isMarketPrice:n,qty:r,active_price:s,place_order_type:"entry"};this._pendingOrders.push(d)}}_closeAllOrders(t,e){const{comment:r,immediately:n}=t,{bar_index:s}=this._variables,a=this._orders.filter(l=>l.in_index!==s);a.length&&(this._closeOrders(a,e,"Close position order",r,"close",n),this._orders=[],this._variables.strategy.updateOrders(this._orders))}_closeOrders(t,e,r,n,s,a){for(const l of t)l.position_close_type=s,l.immediately=a,this._closeOrder(l,e,r,n);this._orders=this._orders.filter(l=>!l.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder)}_closeOrder(t,e,r,n){const{time:s,bar_index:a}=this._variables,{high:l,low:c}=this.calcOnOrderFillsData.data||this._variables,{slippage:h=0}=this._options,{in_price:d,qty:f=0,direction:p}=t,g=p===ce.long?1:-1;e=e-g*h*this._mintick,t.isDeal=!0;const w=(e-d)*g*f,m={...t,out_price:e,out_id:r,out_index:a,out_high:l,out_low:c,out_time:s,out_comment:n,out_qty:f,profit:w};this._calcPercent(m)}_exitOrdersHandle(){if(!this._exitOrders.length)return;const{open:t,low:e,high:r,close:n}=this.calcOnOrderFillsData.data||this._variables,s=[],a=Math.abs(r-t),l=Math.abs(e-t),c=[];for(const h of this._exitOrders){const{stop:d,limit:f,trail_stop_price:p,directionNum:g,id:w,comment:m,active_price:y,trail_offset:v=0,qty:x,comment_loss:b,comment_profit:M,comment_trailing:E,order:F}=h;let N=p,S=a<l||a===l&&g===1,T,A=1,O=m;if(f&&((t-f)*g>=0?(T=t,A=1):e<=f&&r>=f&&(T=f,S&&f>t||!S&&f<t?A=1:A=2),O=M||m),d&&!(N&&(d-N)*g<0)&&((t-d)*g<=0?(T=t,A=1):e<=d&&r>=d&&(T=d,S&&d>t||!S&&d<t?A=1:A=2),O=b||m),T){s.push({order:F,price:T,index:A,isHighFront:S,exitInfo:{id:w,comment:O,qty:x}});continue}if(T=void 0,N)if((N-t)*g>=0)T=t,A=1;else{const[L,q,U]=this._calcTrailStopPrice(N,r,e,n,v,g,S);T=q,A=U||1,h.trail_stop_price=L}if(y&&!T&&y<=r&&y>=e)if(v===0)T=y,S&&y>t||!S&&y<t?A=1:A=2;else{N=Xa(y,yo(v*g,this._mintick));let L=r,q=e;S?y>=t&&y<=r?(L=r,A=1):(S=!1,L=n,A=2):y<t&&y>=e?(q=e,A=1):(S=!0,q=n,A=2);const[U,W,z=1]=this._calcTrailStopPrice(N,L,q,n,v,g,S);delete h.active_price,A<z&&(A=z),h.trail_stop_price=U,T=W}if(T){s.push({order:F,price:T,index:A,isHighFront:S,exitInfo:{id:w,comment:E||m,qty:x}});continue}c.push(h)}this._exitOrders=c,s.sort(({price:h,index:d,isHighFront:f},{price:p,index:g})=>d!==g?d-g:f?d===1?h-p:p-h:d===1?p-h:h-p);for(const h of s){const{order:d,price:f,exitInfo:p}=h;this._processExitOnClose(d,f,p)}}_ordersHandle(){const t=this._orders.filter(r=>r.isMarketPriceLimit||r.isMarketPriceStop);if(!t.length)return;const{open:e}=this.calcOnOrderFillsData.data||this._variables;for(const r of t){const{out_comment:n,out_qty:s,out_id:a}=r;this._processExitOnClose(r,e,{id:a,comment:n,qty:s})}}_calcTrailStopPrice(t,e,r,n,s,a,l){let c=t,h;const d=Xa(a===1?e:r,yo(s*a,this._mintick));let f=1;return a===1?l?(c<d&&(c=d),c>=r&&(f=2,h=c)):c>=r?(f=1,h=c):d>c&&(c=d,d>=n&&(f=3,h=d)):l?c<=e?(f=1,h=c):d<c&&(c=d,d<=n&&(f=3,h=d)):(d<c&&(c=d),c<=e&&(f=2,h=c)),[c,h,f]}_pendingOrderHandle(){if(!this._pendingOrders.length)return;const t=[],e=this._pendingOrders.filter(n=>n.place_order_type==="exit"),r=this._pendingOrders.filter(n=>["close","close_all"].includes(n.place_order_type||""));for(const n of this._pendingOrders){const{isCancel:s,place_order_type:a}=n;if(s)continue;let l;switch(a){case"entry":l=this._entryOrderHandle(n);break;case"order":l=this._orderOrderHandle(n);break}l&&t.push(l)}for(const n of r)switch(n.place_order_type){case"close":const s=this._closeOrderHandle(n);s&&t.push(s);break;case"close_all":const{open:a}=this.calcOnOrderFillsData.data||this._variables;this._closeAllOrders(n,a);break}for(const n of e){const s=this._exitOrderHandle(n);s&&t.push(s)}this._pendingOrders=t}_pendingCloseOrderHandle(){if(!this._pendingCloseOrders.length)return;const t=this._pendingCloseOrders.filter(r=>["close","close_all"].includes(r.place_order_type||"")),{close:e}=this.calcOnOrderFillsData.data||this._variables;this._pendingCloseOrders=[];for(const r of t)switch(r.place_order_type){case"close":const n=this._closeOrderHandle(r,!0);n&&this._pendingCloseOrders.push(n);break;case"close_all":this._closeAllOrders(r,e);break}this._ordersHandle()}_entryOrderHandle(t){const{open:e,low:r,high:n}=this.calcOnOrderFillsData.data||this._variables,{isMarketPrice:s,qty:a=0,in_price:l,direction:c,active_price:h}=t;if(h&&n>=h&&r<=h)return delete t.active_price,t;let d=l;if(s&&(d=e),d<=n&&d>=r){const f=this._orders.filter(p=>p.direction!==c);this._entryOrder(f,d,a,t)}else return t}_orderOrderHandle(t){const{time:e,bar_index:r}=this._variables,{open:n,low:s,high:a}=this.calcOnOrderFillsData.data||this._variables,{slippage:l=0}=this._options,{isMarketPrice:c,qty:h=0,in_price:d,direction:f,comment:p,oca_name:g,oca_type:w,active_price:m,id:y}=t;if(m&&a>=m&&s<=m)return delete t.active_price,t;let v=d,x=h;if(c&&(v=n),v<=a&&v>=s){const b=this._orders.filter(E=>E.direction!==f);if(b.length&&(x=this._processOrders(b,v,h,y,p,!1,"order"),x<=0))return;const M=f===ce.long?1:-1;this._ocaGroupVerify(x,g,w),this._calcCurrentOrder({...t,in_price:v+M*l*this._mintick,in_index:r,in_time:e,in_high:a,in_low:s,qty:x});return}else return t}_closeOrderHandle(t,e){const{id:r,qty:n,qty_percent:s=100,comment:a,immediately:l}=t,{close_entries_rule:c="FIFO"}=this._options;let h=[];if(c==="FIFO"?h=this._orders.filter(g=>g.id===r):h=this._orders.filter(g=>g.id===r&&!g.close_qty),!h.length)return t;let d=0;if(n?d=n:(d=h.reduce((g,w)=>g+(w.qty||0),d),d=s/100*d),d<=0)return;const{open:f,close:p}=this.calcOnOrderFillsData.data||this._variables;if(c==="FIFO")this._processOrders(h,e?p:f,d,`Close entry(s) order ${r}`,a,!1,"close",l);else if(this._processCloseOrders(h,e?p:f,d,`Close entry(s) order ${r}`,a,l))return t}_processCloseOrders(t,e,r,n,s,a){let l=!1;for(const c of t)c.close_qty=r,(c.qty||0)>r&&(l=!0),c.immediately=a,c.position_close_type="close",this._processOrder(c,e,r,n,s);return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_exitOrderHandle(t){const{from_entry:e}=t,r=this._orders.filter(n=>(!e||e===n.id)&&!n.hasExit);if(!(r.length&&!this._ordersToExit(r,t,!0)))return t}_exit(t,e){if(!t.hasOwnProperty("profit")&&!t.hasOwnProperty("loss")&&!t.hasOwnProperty("stop")&&!t.hasOwnProperty("limit")&&(!t.hasOwnProperty("trail_offset")||!t.hasOwnProperty("trail_price")&&!t.hasOwnProperty("trail_points"))){this._errorListener.addError(se.strategyExitErr,e,Pt.Error);return}const{profit:r,loss:n,stop:s,limit:a,trail_offset:l,trail_price:c,trail_points:h,from_entry:d="",id:f}=t;if(this._isNaN(r)&&this._isNaN(n)&&this._isNaN(s)&&this._isNaN(a)&&(this._isNaN(l)||this._isNaN(h)&&this._isNaN(c)))return;const p={...t,place_order_type:"exit"},g=this._orders.filter(y=>(!d||d===y.id)&&!y.hasExit);this._updateExitOrders(p);const w=this._pendingOrders.filter(y=>!d||d===y.id);if(g.length){if(!this._ordersToExit(g,p,!1))return}else if(!w.length)return;const m=this._pendingOrders.find(y=>y.id===f&&y.place_order_type==="exit");m?Object.assign(m,{...t}):this._pendingOrders.push(p)}_updateExitOrders(t){const e=this._exitOrders.filter(r=>r.id===t.id&&(r.from_entry===t.from_entry||!t.from_entry));for(const r of e){const{directionNum:n,order:s}=r,a={...t};if(this._stopProfit(s,n,a)){r.isClose=!0;continue}if(this._stopLoss(s,n,a)){r.isClose=!0;continue}if(this._trailStopLoss(s,n,a)){r.isClose=!0;continue}Object.assign(r,a)}this._exitOrders=this._exitOrders.filter(r=>!r.isClose)}_ordersToExit(t,e,r){const{qty:n,qty_percent:s=100,id:a,comment:l}=e;let c=n,h=!1;e.comment=l||a;const d=t[0],f={...e},{qty:p=0}=d,g=d.direction===ce.long?1:-1;return c=n?n>=p?p:n:s/100*p,f.qty=c,c<p&&(h=!0),this._stopProfit(d,g,f,r)||this._stopLoss(d,g,f,r)||this._trailStopLoss(d,g,f,r)||(this._exitOrders.push({...f,directionNum:g,order:d}),d.hasExit=!0),h}_addExitPendingCloseOrders(t){const e=this._pendingCloseOrders.find(r=>r.id===t.id);e?Object.assign(e,{...t}):this._pendingCloseOrders.push(t)}_stopProfit(t,e,r,n){const{limit:s,profit:a,comment_profit:l,comment:c,id:h}=r;let d=s;const{close:f}=this.calcOnOrderFillsData.data||this._variables,{in_price:p}=t,{process_orders_on_close:g}=this._options;if(!this._isNaN(a)&&this._isNaN(s)&&(d=p+e*a*this._mintick),r.limit=d,!n&&d!==void 0&&(d-f)*e<=0)return t.isMarketPriceLimit=!0,r.comment=l||c,Object.assign(t,{out_comment:r.comment,out_id:h}),g&&this._addExitPendingCloseOrders(r),!0}_stopLoss(t,e,r,n){const{stop:s,loss:a,comment_loss:l,comment:c,id:h}=r;let d=s;const{close:f}=this.calcOnOrderFillsData.data||this._variables,{in_price:p}=t,{process_orders_on_close:g}=this._options;if(!this._isNaN(a)&&this._isNaN(s)&&(d=p-e*a*this._mintick),r.stop=d,!n&&d!==void 0&&(d-f)*e>=0)return t.isMarketPriceStop=!0,r.comment=l||c,Object.assign(t,{out_comment:r.comment,out_id:h}),g&&this._addExitPendingCloseOrders(r),!0}_trailStopLoss(t,e,r,n){const{trail_offset:s,trail_price:a,trail_points:l,comment_trailing:c,comment:h,id:d}=r;if(!this._isNaN(s)){const{close:f}=this.calcOnOrderFillsData.data||this._variables,{in_price:p}=t,{process_orders_on_close:g}=this._options;let w;if(this._isNaN(a)?this._isNaN(l)||(w=Ey(p,yo(l*e,this._mintick))):w=a,r.active_price=w,n)return;if(w!==void 0&&(w-f)*e<=0){const m=Xa(f,yo(s*e,this._mintick));if((m-f)*e>=0)return t.isMarketPriceStop=!0,r.comment=c||h,Object.assign(t,{out_comment:r.comment,out_id:d}),g&&this._addExitPendingCloseOrders(r),!0;r.trail_stop_price=m}}}_processExitOnClose(t,e,r){const{qty:n=0,comment:s,id:a}=r,{close_entries_rule:l="FIFO"}=this._options;if(l==="FIFO")this._processExitOrders(this._orders,e,n,a,s);else{if(t.isDeal)return;this._processOrders([t],e,n,a,s,!1,"exit")}}_processExitOrders(t,e,r,n,s){let a=r,l;for(const c of t)if(l=c,c.position_close_type="exit",a=this._processOrder(c,e,a,n,s),a<=0)break;return this._orders=this._orders.filter(c=>!c.isDeal),this._variables.strategy.updateOrders(this._orders),this._variables.strategy.updateHistoryOrders(this._historyOrder),l}_processOrder(t,e,r,n,s,a=!1){const{time:l,bar_index:c}=this._variables,{low:h,high:d}=this.calcOnOrderFillsData.data||this._variables,{slippage:f=0}=this._options,{in_price:p,qty:g=0,max_profit:w,trading_loss:m,direction:y,commission:v=0,original_qty:x=0}=t,b=y===ce.long?1:-1;if(e=e-b*f*this._mintick,r<g){const M=g-r,E=(e-p)*b*r,F=w!==void 0?w/g*r:void 0,N=m!==void 0?m/g*r:void 0,S=v*M/x;this._calcPercent({...t,out_price:e,last_commission:S,out_id:n,out_index:c,out_high:d,out_low:h,out_time:l,out_comment:s,profit:E,out_qty:r,max_profit:F,trading_loss:N});const T=(e-p)*b*M-S;Object.assign(t,{qty:M,profit:T,max_profit:w!==void 0?w-(F||0):void 0,trading_loss:m!==void 0?m-(N||0):void 0,total_profit:this._totalChangeCapital+T}),r=0}else{t.isDeal=!0;const M=(e-p)*b*g;this._calcPercent({...t,out_price:e,out_id:n,out_index:c,out_high:d,out_low:h,out_time:l,out_comment:s,out_qty:g,profit:M}),r-=g}return a&&(b===1?this._variables.strategy.marginCallLong++:this._variables.strategy.marginCallShort++),r}_calcPercent(t){const{commission_value:e,process_orders_on_close:r}=this._options,{in_price:n,out_qty:s=0,out_price:a=0,original_qty:l=0,direction:c,last_commission:h=0,immediately:d}=t;let{profit:f=0,max_profit:p,trading_loss:g,commission:w=0}=t,m=n*s,y=this._totalChangeCapital+this._options.initial_capital;if(this._totalChangeCapital+=f,e){const v=this._getCommission(a,s);this._totalChangeCapital-=v;let x=w*s/l;m+=x,x+=v,f=f-x,Object.assign(t,{commission:x,profit:f});const b=this._orders.reduce((M,E)=>{const{qty:F=0,original_qty:N=0,commission:S=0}=E;return M+S*F/N},0);y+=b-h}if(p===void 0||g===void 0){const v=c===ce.long?1:-1,x=this._calcProfitAndLossHandle(n,s,v);if(p=x[0],g=x[1],e){const b=w*s/l;p-=b,g-=b}p=Math.max(0,p),g=Math.min(0,g)}Object.assign(t,{max_profit:p,trading_loss:g,total_profit:this._totalChangeCapital,total_profit_percent:f/y*100,profit_percent:f/m*100,max_profit_percent:p/m*100,trading_loss_percent:g/m*100}),this._maxDrawdownVerifyIndex=this._variables.bar_index+(r?1:0),this._risk.intradayOrders+=1,this._historyOrder.push(t),this._calcOrderFillsHandle(n,c,d)}_getCommission(t,e){const{commission_value:r=0,commission_type:n}=this._options,s=t*e;let a=0;switch(n){case je.percent:a=s*r/100;break;case je.cashPerContract:a=e*r;break;case je.cashPerOrder:a=r;break}return a}_calcCurrentOrder(t){const{commission_value:e}=this._options,{in_price:r,qty:n=0,max_profit:s=0,trading_loss:a=0,direction:l,immediately:c}=t;let{profit:h=0}=t,d=r*n;const f=this._totalChangeCapital+this._options.initial_capital;if(e){const p=this._getCommission(r,n);this._totalChangeCapital-=p,h=h-p,d+=p,Object.assign(t,{commission:p,profit:h,total_profit:this._totalChangeCapital})}Object.assign(t,{original_qty:n,total_profit_percent:h/f*100,profit_percent:h/d*100,max_profit_percent:s/d*100,trading_loss_percent:a/d*100,stop:void 0,limit:void 0}),this._risk.intradayOrders+=1,this._orders.push(t),this._variables.strategy.updateOrders(this._orders),e&&this._variables.strategy.updateHistoryOrders(this._historyOrder),this._calcOrderFillsHandle(r,l,c)}_calcOrderFillsHandle(t,e,r=!1){const{calc_on_order_fills:n,process_orders_on_close:s,slippage:a=0}=this._options;if(n){const{open:l,high:c,low:h,close:d}=this._variables,f=e===ce.long?1:-1,p=d-f*a*this._mintick;if((r||s)&&t===p)return;const g=l-f*a*this._mintick;let w={open:l,high:c,low:h,close:d},m=this.calcOnOrderFillsData.index;const y=Math.abs(c-l)<=Math.abs(h-l);switch(m){case-1:t===g?m=0:t>g?y?(m=1,w={open:c,high:c,low:h,close:d}):(m=2,w={open:c,high:c,low:d,close:d}):y?(m=2,w={open:h,high:d,low:h,close:d}):(m=1,w={open:h,high:c,low:h,close:d});break;case 0:t===g?(m=1,y?w={open:c,high:c,low:h,close:d}:w={open:h,high:c,low:h,close:d}):t>g?y?(m=1,w={open:c,high:c,low:h,close:d}):(m=2,w={open:c,high:c,low:d,close:d}):y?(m=2,w={open:h,high:d,low:h,close:d}):(m=1,w={open:h,high:c,low:h,close:d});break;case 1:m=2,y?w={open:h,high:d,low:h,close:d}:w={open:c,high:c,low:d,close:d};break;case 2:m=-1,w=void 0;break}this.calcOnOrderFillsData={tradeData:w,index:m}}}_isNaN(t){return t===void 0||isNaN(t)}_paramVerfiy(t="",e,r,n,s){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}};var vh={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){return function(e,r,n){r.prototype.isBetween=function(s,a,l,c){var h=n(s),d=n(a),f=(c=c||"()")[0]==="(",p=c[1]===")";return(f?this.isAfter(h,l):!this.isBefore(h,l))&&(p?this.isBefore(d,l):!this.isAfter(d,l))||(f?this.isBefore(h,l):!this.isAfter(h,l))&&(p?this.isAfter(d,l):!this.isBefore(d,l))}}})})(vh);var Cy=vh.exports,Fy=Gt(Cy),wh={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){return function(e,r,n){var s=r.prototype,a=function(p){var g,w=p.date,m=p.utc,y={};if(!((g=w)===null||g instanceof Date||g instanceof Array||s.$utils().u(g)||g.constructor.name!=="Object")){if(!Object.keys(w).length)return new Date;var v=m?n.utc():n();Object.keys(w).forEach(function(T){var A,O;y[A=T,O=s.$utils().p(A),O==="date"?"day":O]=w[T]});var x=y.day||(y.year||y.month>=0?1:v.date()),b=y.year||v.year(),M=y.month>=0?y.month:y.year||y.day?0:v.month(),E=y.hour||0,F=y.minute||0,N=y.second||0,S=y.millisecond||0;return m?new Date(Date.UTC(b,M,x,E,F,N,S)):new Date(b,M,x,E,F,N,S)}return w},l=s.parse;s.parse=function(p){p.date=a.bind(this)(p),l.bind(this)(p)};var c=s.set,h=s.add,d=s.subtract,f=function(p,g,w,m){m===void 0&&(m=1);var y=Object.keys(g),v=this;return y.forEach(function(x){v=p.bind(v)(g[x]*m,x)}),v};s.set=function(p,g){return g=g===void 0?p:g,p.constructor.name==="Object"?f.bind(this)(function(w,m){return c.bind(this)(m,w)},g,p):c.bind(this)(p,g)},s.add=function(p,g){return p.constructor.name==="Object"?f.bind(this)(h,p,g):h.bind(this)(p,g)},s.subtract=function(p,g){return p.constructor.name==="Object"?f.bind(this)(h,p,g,-1):d.bind(this)(p,g)}}})})(wh);var My=wh.exports,Ny=Gt(My),yh={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(Yt,function(){var e,r,n=1e3,s=6e4,a=36e5,l=864e5,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,h=31536e6,d=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)?)?$/,p={years:h,months:d,days:l,hours:a,minutes:s,seconds:n,milliseconds:1,weeks:6048e5},g=function(F){return F instanceof M},w=function(F,N,S){return new M(F,S,N.$l)},m=function(F){return r.p(F)+"s"},y=function(F){return F<0},v=function(F){return y(F)?Math.ceil(F):Math.floor(F)},x=function(F){return Math.abs(F)},b=function(F,N){return F?y(F)?{negative:!0,format:""+x(F)+N}:{negative:!1,format:""+F+N}:{negative:!1,format:""}},M=function(){function F(S,T,A){var O=this;if(this.$d={},this.$l=A,S===void 0&&(this.$ms=0,this.parseFromMilliseconds()),T)return w(S*p[m(T)],this);if(typeof S=="number")return this.$ms=S,this.parseFromMilliseconds(),this;if(typeof S=="object")return Object.keys(S).forEach(function(U){O.$d[m(U)]=S[U]}),this.calMilliseconds(),this;if(typeof S=="string"){var L=S.match(f);if(L){var q=L.slice(2).map(function(U){return U!=null?Number(U):0});return this.$d.years=q[0],this.$d.months=q[1],this.$d.weeks=q[2],this.$d.days=q[3],this.$d.hours=q[4],this.$d.minutes=q[5],this.$d.seconds=q[6],this.calMilliseconds(),this}}return this}var N=F.prototype;return N.calMilliseconds=function(){var S=this;this.$ms=Object.keys(this.$d).reduce(function(T,A){return T+(S.$d[A]||0)*p[A]},0)},N.parseFromMilliseconds=function(){var S=this.$ms;this.$d.years=v(S/h),S%=h,this.$d.months=v(S/d),S%=d,this.$d.days=v(S/l),S%=l,this.$d.hours=v(S/a),S%=a,this.$d.minutes=v(S/s),S%=s,this.$d.seconds=v(S/n),S%=n,this.$d.milliseconds=S},N.toISOString=function(){var S=b(this.$d.years,"Y"),T=b(this.$d.months,"M"),A=+this.$d.days||0;this.$d.weeks&&(A+=7*this.$d.weeks);var O=b(A,"D"),L=b(this.$d.hours,"H"),q=b(this.$d.minutes,"M"),U=this.$d.seconds||0;this.$d.milliseconds&&(U+=this.$d.milliseconds/1e3,U=Math.round(1e3*U)/1e3);var W=b(U,"S"),z=S.negative||T.negative||O.negative||L.negative||q.negative||W.negative,K=L.format||q.format||W.format?"T":"",Z=(z?"-":"")+"P"+S.format+T.format+O.format+K+L.format+q.format+W.format;return Z==="P"||Z==="-P"?"P0D":Z},N.toJSON=function(){return this.toISOString()},N.format=function(S){var T=S||"YYYY-MM-DDTHH:mm:ss",A={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return T.replace(c,function(O,L){return L||String(A[O])})},N.as=function(S){return this.$ms/p[m(S)]},N.get=function(S){var T=this.$ms,A=m(S);return A==="milliseconds"?T%=1e3:T=A==="weeks"?v(T/p[A]):this.$d[A],T||0},N.add=function(S,T,A){var O;return O=T?S*p[m(T)]:g(S)?S.$ms:w(S,this).$ms,w(this.$ms+O*(A?-1:1),this)},N.subtract=function(S,T){return this.add(S,T,!0)},N.locale=function(S){var T=this.clone();return T.$l=S,T},N.clone=function(){return w(this.$ms,this)},N.humanize=function(S){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!S)},N.valueOf=function(){return this.asMilliseconds()},N.milliseconds=function(){return this.get("milliseconds")},N.asMilliseconds=function(){return this.as("milliseconds")},N.seconds=function(){return this.get("seconds")},N.asSeconds=function(){return this.as("seconds")},N.minutes=function(){return this.get("minutes")},N.asMinutes=function(){return this.as("minutes")},N.hours=function(){return this.get("hours")},N.asHours=function(){return this.as("hours")},N.days=function(){return this.get("days")},N.asDays=function(){return this.as("days")},N.weeks=function(){return this.get("weeks")},N.asWeeks=function(){return this.as("weeks")},N.months=function(){return this.get("months")},N.asMonths=function(){return this.as("months")},N.years=function(){return this.get("years")},N.asYears=function(){return this.as("years")},F}(),E=function(F,N,S){return F.add(N.years()*S,"y").add(N.months()*S,"M").add(N.days()*S,"d").add(N.hours()*S,"h").add(N.minutes()*S,"m").add(N.seconds()*S,"s").add(N.milliseconds()*S,"ms")};return function(F,N,S){e=S,r=S().$utils(),S.duration=function(O,L){var q=S.locale();return w(O,{$l:q},L)},S.isDuration=g;var T=N.prototype.add,A=N.prototype.subtract;N.prototype.add=function(O,L){return g(O)?E(this,O,1):T.bind(this)(O,L)},N.prototype.subtract=function(O,L){return g(O)?E(this,O,-1):A.bind(this)(O,L)}}})})(yh);var Sy=yh.exports,Oy=Gt(Sy);ee.extend(ql),ee.extend(Fy),ee.extend(Ny),ee.extend(Oy);class Dh{constructor(t,e,r){$(this,"array");$(this,"color");$(this,"math");$(this,"str");$(this,"map");$(this,"matrix");$(this,"timeframe");$(this,"ta");$(this,"input");$(this,"_variables");$(this,"_cacheData");$(this,"_options");$(this,"_errorListener");$(this,"_plots");$(this,"_plotshapes");$(this,"_plotbars");$(this,"_plotchars");$(this,"_plotarrows");$(this,"_plotcandles");$(this,"_alerts");$(this,"_bgColors");$(this,"_hlines");$(this,"_fills");$(this,"chart");$(this,"line");$(this,"label");$(this,"polyline");$(this,"box");$(this,"table");$(this,"linefill");$(this,"log");$(this,"runtime");$(this,"strategy");$(this,"request");$(this,"syminfo");$(this,"_count",0);var s;const n=((s=t.toString().split(".")[1])==null?void 0:s.length)||5;this._variables=e,this._errorListener=new Ly,this.array=new fp(this._errorListener),this.math=new hp(n,this._errorListener),this.color=new R1,this.str=new Pw(this._errorListener,n),this.map=new zw(this._errorListener),this.timeframe=new Rw(e),this.matrix=new Lw(this._errorListener),this.ta=new $1(e,this.math,this.timeframe),this._cacheData={},this._options={},this._bgColors={},this._alerts=new Map,this._hlines=new Map,this._fills=new Map,this.input=new L1(e,this._errorListener,r),this._plots=new Map,this._plotshapes=new Map,this._plotbars=new Map,this._plotcandles=new Map,this._plotchars=new Map,this._plotarrows=new Map,this.chart={point:new kw(e)},this.line=new ly(e,this._errorListener),this.label=new qw(e,this._errorListener),this.polyline=new uy(e,this._errorListener),this.box=new fy(e,this._errorListener),this.table=new hy(e,this._errorListener),this.linefill=new cy(e),this.log=new Ty(e),this.runtime=new $y(this._errorListener),this.strategy=new Ay(this._variables,this._options,t,this._errorListener,r),this.request=new By(this._variables,r),this.syminfo=new Iy}get errors(){return this._errorListener.errors}options(t){if(t.length)return this._getDataOfBarindex(t);const e=this.input.getInputs(),r=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const n=Object.keys(this._bgColors);let s;if(n.length){s={};for(const v of n)s[v]=[...this._bgColors[v].values()]}const a=this._hlines.size?[...this._hlines.values()]:void 0,l=this._fills.size?[...this._fills.values()]:void 0,c=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders,strategySummary:this._variables.strategy.summaryData});const h=this._plots.size>0?[...this._plots.values()]:void 0,d=this._plotbars.size>0?[...this._plotbars.values()]:void 0,f=this._plotshapes.size>0?[...this._plotshapes.values()]:void 0,p=this._plotarrows.size>0?[...this._plotarrows.values()]:void 0,g=this._plotcandles.size>0?[...this._plotcandles.values()]:void 0,w=this._plotchars.size>0?[...this._plotchars.values()]:void 0,m=this._getDraws(),y=this._variables.chart.isUseBgColor;return Object.assign(this._options,{inputs:e,plots:h,draws:m,alerts:r,colors:s,hlines:a,fills:l,logs:c,plotshapes:f,plotarrows:p,plotcandles:g,plotchars:w,plotbars:d,isUseBgColor:y})}_getDataOfBarindex(t){const e=this._alerts.size?[...this._alerts.values()]:void 0;this._alerts.clear();const r=Object.keys(this._bgColors);let n;if(r.length){n={};for(const p of r)n[p]=[...this._bgColors[p].values()].map(g=>{const w=[];for(const m of t){const y=g.colors[m];y&&w.push(y)}return g.colors=w,g})}const s=this._hlines.size?[...this._hlines.values()]:void 0,a=this._fills.size?this._getDataFromBarindex(t,[...this._fills.values()]):void 0,l=this.log.logs.length?this.log.logs:void 0;this.log.clearLogs(),this._options.scriptType==="strategy"&&Object.assign(this._options,{orders:this.strategy.orders,historyOrders:this.strategy.historyOrders});const c=this._getDataFromBarindex(t,[...this._plots.values()]),h=this._plotshapes.size>0?this._getDataFromBarindex(t,[...this._plotshapes.values()]):void 0,d=this._getDrawsFromBarindex(t),f=this._variables.chart.isUseBgColor;return Object.assign(this._options,{plots:c,draws:d,alerts:e,colors:n,hlines:s,fills:a,logs:l,plotshapes:h,isUseBgColor:f})}_getDataFromBarindex(t,e){return e.map(r=>{const n=[];for(const s of t){const a=r.data[s];a&&n.push(a)}return r.data=n,{...r}})}_getDraws(){const{line:t,linefill:e,table:r,box:n,polyline:s,label:a}=this._variables,l={};return t.data.length&&(l.lines=t.data),e.data.length&&(l.linefills=e.data),r.data.length&&(l.tables=r.data),n.data.length&&(l.boxes=n.data),s.data.length&&(l.polylines=s.data),a.data.length&&(l.labels=a.data),Object.keys(l).length?l:void 0}_getDrawsFromBarindex(t){const{line:e,linefill:r,table:n,box:s,polyline:a,label:l}=this._variables,c={};return e.data.length&&(c.lines=e.getValOfBarIndex(t)),r.data.length&&(c.linefills=r.getValOfBarIndex(t)),n.data.length&&(c.tables=n.getValOfBarIndex(t)),s.data.length&&(c.boxes=s.getValOfBarIndex(t)),a.data.length&&(c.polylines=a.getValOfBarIndex(t)),l.data.length&&(c.labels=l.getValOfBarIndex(t)),Object.keys(c).length?c:void 0}updateOptions(t){const{inputs:e,strategy:r}=t;this.input.update(e),r&&this.strategy.updateOptions(r)}update(t){const{barIndex:e}=t;this.strategy.update(),this.math.update(e)}endExecution(){this.strategy.endExecution()}library(t,e){if(!this._variables.bar_index){const r=/^[^\W\d\s][^\W\s]*$/,{title:n}=t;r.test(n)?(cp.includes(n)||lp.includes(n))&&this._errorListener.addError(Ze(se.libraryTitleIsKeywordErr,{name:n}),e,Pt.Error):this._errorListener.addError(se.libraryTitleErr,e,Pt.Error),this._options.scriptType="library",this._options.library=t}}indicator(t,e){if(!this._variables.bar_index){const{format:r}=t;this._paramVerfiy(r,e,"indicator",[Kt.inherit,Kt.percent,Kt.price,Kt.volume]),this._variables.updateMaxLength(t),this._options.scriptType="indicator",this._options.indicator=t}}_paramVerfiy(t="",e,r,n,s="format"){t&&!n.includes(t)&&this._errorListener.addError(Ze(se.paramsErr,{value:t,func:r,param:s,targetVal:`[${n.join(", ")}]`}),e,Pt.Error)}_lineWidthVerify(t,e){const{linewidth:r=1}=t;r<1&&(this._errorListener.addError(ap.lineWidthWarning,e,Pt.Warning),t.linewidth=1)}plot(t,e){const r=["color"];ge(t,r);const{series:n,color:s,...a}=t,{bar_index:l,time:c}=this._variables,h=`plot_${e}`,d=this._plots.get(h),f=(d==null?void 0:d.data)||[],p=n!==void 0&&isNaN(n)?void 0:n;if(f[l]={value:[c,p],itemStyle:{color:s}},this._seriesColorHandle(t,r,d),!d){this._count++,this._lineWidthVerify(a,e),this._paramVerfiy(t.format,e,"plot",[Kt.percent,Kt.price,Kt.volume]);const g=s?[s]:void 0;this._plots.set(h,{editable:!0,...a,colors:g,data:f,id:h,zIndex:this._count})}return{type:"plot",key:h}}plotbar(t,e){const r=["color"];ge(t,r);const{open:n,close:s,low:a,high:l,color:c,...h}=t,{bar_index:d,time:f}=this._variables,p=`plotbar_${e}`,g=this._plotbars.get(p),w=(g==null?void 0:g.data)||[],m=s!==void 0&&isNaN(s)?void 0:s,y=n!==void 0&&isNaN(n)?void 0:n,v=a!==void 0&&isNaN(a)?void 0:a,x=l!==void 0&&isNaN(l)?void 0:l,b=[f,y,m,v,x];if(w[d]={value:b,itemStyle:{color:c}},this._seriesColorHandle(t,r,g),!g){this._count++,this._paramVerfiy(t.format,e,"plotbar",[Kt.percent,Kt.price,Kt.volume]);const M=c?[c]:void 0;this._plotbars.set(p,{editable:!0,...h,colors:M,data:w,id:p,zIndex:this._count})}}_verfiyArgs(t,e,r){const{size:n,format:s,location:a,style:l}=t;this._paramVerfiy(l,r,e,Object.values(lr),"style"),this._paramVerfiy(a,r,e,Object.values(ln),"location"),this._paramVerfiy(n,r,e,Object.values(ir),"size"),this._paramVerfiy(s,r,e,[Kt.percent,Kt.price,Kt.volume],"format")}plotchar(t,e){const r=["color","textcolor"];ge(t,r);const{series:n,color:s,textcolor:a,location:l=ln.abovebar,...c}=t,{bar_index:h,time:d,high:f,low:p}=this._variables,g=`plotchar_${e}`,w=this._plotchars.get(g),m=(w==null?void 0:w.data)||[],y={value:[d,n],itemStyle:{color:s,textcolor:a},low:p,high:f};m[h]=y,this._seriesColorHandle(t,r,w),w||(this._count++,this._verfiyArgs(t,"plotchar",e),this._plotchars.set(g,{editable:!0,...c,location:l,data:m,id:g,zIndex:this._count}))}plotarrow(t,e){const r=["colorup","colordown"];ge(t,r);const{series:n,colorup:s,colordown:a,...l}=t,{bar_index:c,time:h,low:d,high:f}=this._variables,p=`plotarrow_${e}`,g=this._plotarrows.get(p),w=(g==null?void 0:g.data)||[];w[c]={value:[h,n!==void 0&&isNaN(n)?void 0:n],itemStyle:{colorup:s,colordown:a},low:d,high:f},this._seriesColorHandle(t,r,g),g||(this._count++,this._paramVerfiy(t.format,e,"plotarrow",[Kt.percent,Kt.price,Kt.volume]),this._plotarrows.set(p,{editable:!0,...l,data:w,id:p,zIndex:this._count}))}plotshape(t,e){const r=["color","textcolor"];ge(t,r);const{series:n,color:s,textcolor:a,location:l=ln.abovebar,...c}=t,{bar_index:h,time:d,low:f,high:p}=this._variables,g=`plotshape_${e}`,w=this._plotshapes.get(g),m=(w==null?void 0:w.data)||[],y={value:n,color:s,textcolor:a,time:d,low:f,high:p};if(m[h]=y,this._seriesColorHandle(t,r,w),!w){this._count++;const v=s?[s]:void 0;this._verfiyArgs(t,"plotshape",e),this._plotshapes.set(g,{editable:!0,...c,data:m,location:l,id:g,colors:v,zIndex:this._count})}}plotcandle(t,e){const r=["wickcolor","bordercolor","color"];ge(t,r);const{wickcolor:n,bordercolor:s,color:a,close:l,open:c,low:h,high:d,...f}=t,{bar_index:p,time:g}=this._variables,w=`plotcandle_${e}`,m=this._plotcandles.get(w),y=(m==null?void 0:m.data)||[],v=l!==void 0&&isNaN(l)?void 0:l,x=c!==void 0&&isNaN(c)?void 0:c,b=h!==void 0&&isNaN(h)?void 0:h,M=d!==void 0&&isNaN(d)?void 0:d,E=[g,x,v,b,M];y[p]={value:E,wickcolor:n,bordercolor:s,color:a},this._seriesColorHandle(t,r,m),m||(this._count++,this._paramVerfiy(t.format,e,"plotcandle",[Kt.percent,Kt.price,Kt.volume]),this._plotcandles.set(w,{editable:!0,...f,data:y,id:w,zIndex:this._count}))}hline(t,e){const r=`hline_${e}`;ge(t,["color"]),this._verifyDisplay(t.display,"hline",e);const s=t.display&&!t.display.length?Ke.none:Ke.all;return this._hlines.has(r)||(this._count++,this._lineWidthVerify(t,e),this._hlines.set(r,{id:r,linewidth:1,editable:!0,display:s,...t,zIndex:this._count})),{type:"hline",key:r}}fill(t,e){var S,T,A,O,L,q,U,W,z,K;const r=["color","top_color","bottom_color"];ge(t,r);const{color:n,top_color:s,bottom_color:a,seriesColors:l,hline1:c,hline2:h,plot1:d,plot2:f,top_value:p,bottom_value:g,...w}=t,{bar_index:m,time:y}=this._variables,v=`fill_${e}`,x=this._fills.get(v),b=(x==null?void 0:x.data)||[];this._verifyDisplay(t.display,"fill",e);const M=t.display&&!t.display.length?Ke.none:Ke.all;let E,F,N="plot";if(c&&h)E=(S=this._hlines.get(c==null?void 0:c.key))==null?void 0:S.price,F=(T=this._hlines.get(h==null?void 0:h.key))==null?void 0:T.price,N="hline";else{const Z=((A=this._plots.get(d==null?void 0:d.key))==null?void 0:A.data)||[],X=((O=this._plots.get(f==null?void 0:f.key))==null?void 0:O.data)||[];E=(q=(L=Z[m])==null?void 0:L.value)==null?void 0:q[1],F=(W=(U=X[m])==null?void 0:U.value)==null?void 0:W[1]}if(b[m]={time:y,color:n,top_color:s,bottom_color:a,plot1:E,plot2:F,top_value:p,bottom_value:g},this._seriesColorHandle(t,r,x),!x){this._count++;const Z=((z=this._options.indicator)==null?void 0:z.explicit_plot_zorder)||((K=this._options.strategy)==null?void 0:K.explicit_plot_zorder),X=n?[n]:void 0,Q=s?[s]:void 0,ct=a?[a]:void 0;this._fills.set(v,{id:v,colors:X,top_colors:Q,bottom_colors:ct,display:M,data:b,type:N,editable:!0,fillgaps:!1,hline1:c,hline2:h,plot1:d,plot2:f,...w,zIndex:Z?this._count:void 0})}}alert({message:t,freq:e=Ur.freqOncePerBar},r){const{bar_index:n,_isRealTimeBar:s,last_bar_index:a}=this._variables,l=`alert_${r}`,c=this._cacheData[l]||{},h=c.barIndex;if(this._paramVerfiy(e,r,"alert",[Ur.freqAll,Ur.freqOncePerBar,Ur.freqOncePerBarClose]),e===Ur.freqOncePerBar&&n===h){this._alerts.delete(l);return}this._cacheData[l]=c;const d={message:t,freq:e,id:l,type:"alert"};if(s){e!==Ur.freqOncePerBarClose&&this._alerts.set(l,d),c.barIndex=n;return}if(!s&&e===Ur.freqOncePerBarClose&&n===h&&a===n-1){this._alerts.set(l,d),c.barIndex=n;return}this._alerts.delete(l)}alertcondition({condition:t,message:e,title:r},n){const{_isRealTimeBar:s}=this._variables,a=`alertcondition_${n}`;s&&t?this._alerts.set(a,{message:e,title:r,id:a,type:"alertcondition"}):this._alerts.delete(a)}barcolor(t,e){this._setColors(t,"barcolor",e)}bgcolor(t,e){this._setColors(t,"bgcolor",e)}_verifyDisplay(t=fh.all,e,r){t.length&&t.length<4&&this._errorListener.addError(Ze(se.displayErr,{func:e,values:"[display.none, display.all]"}),r,Pt.Error)}_setColors(t,e,r){ge(t,["color"]);const{color:s,...a}=t;this._verifyDisplay(a.display,e,r);const l=t.display&&!t.display.length?Ke.none:Ke.all,{bar_index:c,time:h}=this._variables,d=`${e}_${r}`;this._bgColors[e]||(this._bgColors[e]=new Map);const f=this._bgColors[e].get(d),p=(f==null?void 0:f.colors)||[],g=(f==null?void 0:f.setColors)||[];s&&!g.includes(s)&&g.push(s),p[c]={color:s,time:h},f||this._bgColors[e].set(d,{...a,display:l,colors:p,setColors:g,id:d})}max_bars_back({var:t,num:e,var_name:r}){console.log(t,e,r)}float({x:t}){return t}bool({x:t}){return t||!1}string({x:t}){return t}int({x:t}){return t&&Math.trunc(t)}na({x:t}){return!!(t===void 0||typeof t=="number"&&isNaN(t))}fixnan({source:t},e){return t===void 0||typeof t=="number"&&isNaN(t)?this._cacheData[`fixnan_${e}`]:(this._cacheData[`fixnan_${e}`]=t,t)}nz({source:t,replacement:e}){return t!==void 0&&!(typeof t=="number"&&isNaN(t))?t:e||0}time({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._timeHandle(this._variables.time,s,t,e,r,n)}time_close({timeframe:t="",session:e,timezone:r,bars_back:n=0},s){return this._timeHandle(this._variables.time,s,t,e,r,n,!0)}timestamp(t){const{dateString:e,timezone:r,year:n,month:s,day:a,hour:l=0,minute:c=0,second:h=0}=t;if(e)return ee(e).utc(!/GMT|UTC/.test(e)).valueOf();let d=s-1,f=n;if(d<0){const g=Math.ceil(Math.abs(d/12));d=12*g+d,f=n-g}let p=ee({year:f,month:d,day:a,hour:l,minute:c,second:h});return r&&(p=qr(p.utc(!0).valueOf(),r)),p.utc(!0).valueOf()}weekofyear({time:t,timezone:e}){return qr(t,e).week()}year({time:t,timezone:e}){return qr(t,e).year()}second({time:t,timezone:e}){return qr(t,e).second()}month({time:t,timezone:e}){return qr(t,e).month()+1}minute({time:t,timezone:e}){return qr(t,e).minute()}hour({time:t,timezone:e}){return qr(t,e).hour()}dayofweek({time:t,timezone:e}){return qr(t,e).day()+1}dayofmonth({time:t,timezone:e}){return qr(t,e).date()}_calcTimeOffset(t,e){const r=this._variables.getTimeTradingday(t,this._variables.timeframe.period),n=tn(e)*1e3;return t-r-Math.floor((t-r)/n)*n}_timeHandle(t,e,r="",n,s,a=0,l=!1){const c=r||this._variables.timeframe.period,h=tn(c),d=tn(this._variables.timeframe.period);let f;if(h<=d)f=t,l&&(f+=d*1e3);else{const p=`time_${e}`,g=this._cacheData[p];if(g)g.currentTime+h*1e3-g.offset<=t?(f=t,this._cacheData[p]={currentTime:t,offset:0}):f=g.currentTime;else{const w=this._calcTimeOffset(t,c);this._cacheData[p]={currentTime:t,offset:w},f=t}l&&(f+=h*1e3)}if(n){const{timePeriods:p,weeks:g}=this._parserSession(n,e),w=ee(t).format("YYYY-MM-DD"),m=f;f=void 0;for(const v of p){const[x,b]=v;if(ee(t).isBetween(`${w} ${x}`,`${w} ${b}`,"hour")){ee(m).isBetween(`${w} ${x}`,`${w} ${b}`,"hour")?f=m:f=ee(`${w} ${x}`).valueOf();break}}const y=this._variables.dayofweek;f&&!g.includes(y)&&(f=void 0)}return s&&(f=f&&qr(f,s).valueOf()),f&&f-a*d*1e3}_seriesColorHandle(t,e,r){var n;if(r&&e!=null&&e.length)for(const s of e){if((n=r.gradientColorKeys)!=null&&n.includes(s))continue;const a=t[s];if(!a)continue;const l=r[`${s}s`]||[];l.includes(a)||(l.push(a),r[`${s}s`]=l,l.length>5&&(r[`${s}s`]=[],r.gradientColorKeys=r.gradientColorKeys||[],r.gradientColorKeys.push(s)))}}_parserSession(t,e){const r=t.split(":"),n=r[0],a=(r[1]||"1234567").split("").map(c=>{const h=parseInt(c,10);if(h<1||h>7){this._errorListener.addError(`Invalid day of week: ${c}`,e,Pt.Error);return}return h});return{timePeriods:n.split(",").map(c=>{c===""||c===gi.regular?c="0930-1500":c===gi.extended&&(c="1500-1830");const h=c.split("-");return h.length!==2?(this._errorListener.addError(`Invalid time period: ${c}`,e,Pt.Error),[]):[this._processTime(h[0],e),this._processTime(h[1],e)]}),weeks:a}}_processTime(t,e){const r=parseInt(t.slice(0,2),10),n=parseInt(t.slice(2),10);if(!(r>=0&&r<=23)&&n>=0&&n<=59){this._errorListener.addError("Invalid time: Time must be within 00:00 to 23:59",e,Pt.Error);return}return`${r}:${n}`}}class By{constructor(t,e){$(this,"_variables");$(this,"_scriptId");$(this,"_cacheData");this._variables=t,this._scriptId=e,this._cacheData=new Map}security(t,e){const r=self.workerStorage.get(`request_${this._scriptId}`),{paramsExpr:n=[]}=t,s=this._getRequestData(t,e);if(r!=null&&r.has(e)){const c=r.get(e);return this._runScripts(c,e,!1,n,s)}const a=this._parseExprCode(t),l=this._runScripts(a,e,!0,n,s);return r==null||r.set(e,a),l}_parseExprCode(t){let{expression:e,paramsExpr:r=[]}=t,n=[],s=1;e=jl(e);const a=JSON.parse(e),l=a.pop();let c=(l==null?void 0:l.memberCodes)||{},h=(l==null?void 0:l.depends)||[];if(!h.length)return`return ${l==null?void 0:l.code}`;let d=[],f=[];const p=[];if(this._getDependCodes(h,a,n,d,f,p),n.push(...p),f.length){const m=r.length;let y=[];for(let v=m-1;v>=0;v--){const x=r[v];let b=JSON.parse(jl(x));const M=[];s!==0&&f.length&&(y.unshift("{"),s++),b=b.map(S=>{const{scope:T,code:A,varNames:O,dependSelf:L}=S;return T===2&&!M.includes(O)&&!L&&(S.code=`let ${A}`),O&&M.push(...O.split(", ")),S.memberCodes&&Object.assign(c,{...S.memberCodes}),S});const E=[],F=[];let N=f.map(S=>({...S,isArg:!1,isPreArg:!0}));f=[],this._getDependCodes(N,b,F,d,f,E),y.unshift(...F,...E),n=y.concat(n),y=[]}}for(n.push(`return ${l==null?void 0:l.code}`);s>1;)n.push("}"),s--;n=d.concat(n);let g=n.join(`
63
+ `);const w=[];for(const m of Object.keys(c))g.includes(`$_var.getCacheData("${m}"`)&&w.push(c[m]);return w.length&&(g=`${w.join(`
64
64
  `)}
65
- ${g}`),g}_getRequestData(t,e){let{symbol:r,timeframe:n,calc_bars_count:s}=t;const{__period:a,syminfo:{ticker:l,tickerid:c},mintick:f}=this._variables;if((n===a||n==="")&&(r===l||r===c)){const{close:g,open:w,high:_,low:y,bar_index:v,last_bar_index:x,last_bar_time:b,_isRealTimeBar:M,volume:E,time:F,time_tradingday:N}=this._variables;return{barIndex:v,c:g,o:w,h:_,l:y,volume:E,lastBarIndex:x,lastBarTime:b/1e3,isrealtime:M,time_tradingday:N,time:F/1e3,interval:a,mintick:f}}const d=`${r}--${n||a}`,h=self.workerStorage.get(`request_${this._scriptId}_data`),p=self.workerStorage.get(`request_${this._scriptId}_list`);if(h!=null&&h.has(d)){p==null||p.delete(d);const{index:g=0,periodStamp:w=tn(this._variables.__period)*1e3}=this._cacheData.get(e)||{},_=(h.get(d)||[]).slice(g),y=this._variables.time,v=w+y,x=_.length-1,b={lastBarIndex:_[x].barindex||x,lastBarTime:_[x].time,interval:a,mintick:f};for(const[M,E]of _.entries()){let{time:F,barindex:N}=E;if(F=F*1e3,F>=v){this._cacheData.set(e,{index:M,periodStamp:w});return}if(F>=y)return this._cacheData.set(e,{index:M+1,periodStamp:w}),{...E,barIndex:N||M,...b}}this._cacheData.set(e,{index:_.length,periodStamp:w})}else(p==null?void 0:p.get(d))||p==null||p.set(d,{id:d,calc_bars_count:s,symbol:r,timeframe:n||a})}_getDependCodes(t,e,r,n,s,a){for(const l of t){if(!l.isArg){const c=e.filter(d=>{var h;return(h=d==null?void 0:d.depends)==null?void 0:h.some(p=>p.name===l.name&&p.scope===l.scope&&p.isAgainAssign)});for(const d of c){const{code:h,depends:p}=d;if(!r.includes(h)&&(r.unshift(h),p!=null&&p.length)){for(const g of p)g.memberCode&&a.push(g.memberCode);this._getDependCodes(p,e,r,n,s,a)}}const f=e.find(d=>{var h;return((h=d.varNames)==null?void 0:h.split(", ").includes(l.name))&&(!l.isPreArg||l.isPreArg&&d.methodName===l.functionName)||d.funcName===l.name});if(f){const{code:d,depends:h}=f,p=r.findIndex(g=>g===d);if(p!==-1&&r.splice(p,1),r.unshift(d),h!=null&&h.length){for(const g of h)g.memberCode&&a.push(g.memberCode);this._getDependCodes(h,e,r,n,s,a)}continue}}s.some(c=>c.name===l.name)||s.push(l)}}_runScripts(t,e,r,n,s){const a=`${this._scriptId}_${e}`;let{builtInGather:l,buildinConstants:c,buildInFunctions:f,tradingvueFunc:d}=self.workerStorage.get(a)||{};const{interval:h,mintick:p,...g}=s||{};r&&(l=new bh(a),c=new hh,f=new Dh(this._variables.mintick||1e-5,l,this._scriptId),d=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),l.updateOptions({interval:h,mintick:p||1e-5}),self.workerStorage.set(a,{builtInGather:l,buildinConstants:c,buildInFunctions:f,tradingvueFunc:d})),l.updateData(g),f.update({barIndex:(g==null?void 0:g.barindex)||0});const w=d(l,c,f,n||[],e);return f.endExecution(),w}}let Iy=class{constructor(){}prefix(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[0])||""}ticker(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[1])||""}};class Ty{constructor(t){L(this,"_logs");L(this,"_variables");L(this,"_intlFormat");this._variables=t,this._logs=[],this._intlFormat=new Intl.NumberFormat("en-US")}get logs(){return this._logs}clearLogs(){this._logs=[]}info(t,e,r){this._addLog(t,e,"info",r)}error(t,e,r){this._addLog(t,e,"error",r)}warning(t,e,r){this._addLog(t,e,"warning",r)}_addLog(t,e,r,n){if(typeof e=="string"&&(n=e),n.startsWith("export"))return;const{message:s,formatString:a}=t,{time:l,bar_index:c}=this._variables;let f=s;a&&Array.isArray(e)&&e.length&&(f=a.replace(/{(\d+)}/g,(d,h)=>{let p=e[h];return typeof p=="number"&&(p=this._intlFormat.format(parseFloat(p.toFixed(3)))),typeof p=="object"&&(p.isArray?p=JSON.stringify(p._value):p=p.toString()),p!==void 0?p:d})),f&&this._logs.push({message:`[${ee(l).format()}]: ${f}`,time:l,barIndex:c,type:r})}}class $y{constructor(t){L(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,zt.Error)}}class Ly{constructor(){L(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Qr.flatMap([...this._errors.values()])}addError(t,e,r,n=0){const[s,a]=e.split("_").slice(-2),l=this._errors.get(e),c={message:t,endLineNumber:Number(s),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(s),type:r};l?l.push(c):this._errors.set(e,[c])}}class Ry{constructor(){L(this,"_isMarketOpen");L(this,"_currentBarIndex");L(this,"_totalBarIndex");L(this,"_isRealTimeBar");L(this,"_preBarIndex");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0}update(t,e,r,n){this._preBarIndex=this._currentBarIndex,this._currentBarIndex=t,this._totalBarIndex=e,this._isRealTimeBar=r,this._isMarketOpen=n}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1||this._currentBarIndex===this._totalBarIndex&&!this._isRealTimeBar:this._currentBarIndex===this._totalBarIndex}}class Py{constructor(t){L(this,"_variables");this._variables=t}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const t=tn(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const t=tn(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class zy{constructor(t){L(this,"_orders");L(this,"_historyOrders");L(this,"_options");L(this,"_max_contracts_held_all",0);L(this,"_max_contracts_held_long",0);L(this,"_max_contracts_held_short",0);L(this,"_max_drawdown",0);L(this,"_max_runup",0);L(this,"_max_runup_percent",0);L(this,"_max_drawdown_percent",0);L(this,"_variables");L(this,"_netprofit",0);L(this,"_eventrades",0);L(this,"_avg_trade_percent");L(this,"_closedtrades",0);L(this,"_losstrades",0);L(this,"_grossloss",0);L(this,"_grossloss_percent",0);L(this,"_grossprofit",0);L(this,"_grossprofit_percent",0);L(this,"_wintrades",0);L(this,"_opentrades_capital_held",0);L(this,"_position_avg_price",0);L(this,"_position_size",0);L(this,"_openprofit",0);L(this,"_preMaxNetValue",0);L(this,"_preMinNetValue",0);L(this,"marginCallLong",0);L(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=t}update(t){this._calcMaxDrawdownAndMaxRunup(t)}_calcMaxDrawdownAndMaxRunup(t){if(!this._orders.length&&!this._historyOrders.length)return;let e=0,r=0;const{high:n,low:s,close:a}=t;let l=0;for(const d of this._orders){const{in_price:h,qty:p=0,direction:g}=d,w=g===se.long?1:-1,_=(n-h)*p,y=(s-h)*p,v=w===1?_:-y,x=w===1?-y:_;l+=(a-h)*w*p,e+=x,r+=v}this._openprofit=l;const c=this.initial_capital,f=c+this._netprofit;this._preMinNetValue=this._preMinNetValue||c,this._preMaxNetValue=this._preMaxNetValue||c,e=this._preMaxNetValue-f+Math.max(e,0),r=f-this._preMinNetValue+r,this._max_drawdown<e&&(this._max_drawdown=e,this._max_drawdown_percent=e/c*100),r>this._max_runup&&(this._max_runup=r,this._max_runup_percent=r/(f+r)*100)}updateOrders(t){this._orders=t,this._calcMaxContracts()}_calcMaxContracts(){const t=this._orders.length;if(!t){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[e,r,n,s,a,l,c]=this._orders.reduce(([f,d,h,p,g,w,_],y)=>{const{direction:v,qty:x=0,in_price:b,commission:M=0}=y;return v===se.long?(f+=x,d+=x,w+=x):(f+=x,h+=x,w-=x),p+=x*b,g+=b,_+=M,[f,d,h,p,g,w,_]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-c,this._grossloss=-c),this._position_size=l,this._position_avg_price=a/t,this._opentrades_capital_held=s,this._max_contracts_held_all=Math.max(e,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(n,this._max_contracts_held_short)}updateHistoryOrders(t){this._historyOrders=t;const e=this._historyOrders.length;this._closedtrades=e;const[r,n,s,a]=this._historyOrders.reduce((f,d)=>{let[h,p,g,w]=f;const{profit:_=0,profit_percent:y=0}=d;return h+=_,p+=y,_<0?g+=_:w+=_,[h,p,g,w]},[0,0,0,0]),l=this._orders.reduce((f,d)=>{const{commission:h=0,qty:p=0,original_qty:g=0}=d,w=h*p/g;return f+w},0);this._avg_trade_percent=e?n/e:void 0,this._netprofit=r-l;const c=this.initial_capital+this._netprofit;this._preMaxNetValue=Math.max(this._preMaxNetValue||this.initial_capital,c),this._preMinNetValue=Math.min(this._preMinNetValue||this.initial_capital,c),this._grossloss=s-l,this._grossprofit=a,this._eventrades=this._historyOrders.filter(f=>f.profit===0).length,this._losstrades=this._historyOrders.filter(f=>(f.profit||0)<0).length,this._wintrades=this._historyOrders.filter(f=>(f.profit||0)>0).length}updateStrategyOptions(t){this._options=t}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const t=this._losstrades;return t?Math.abs(this._grossloss/t):void 0}get avg_losing_trade_percent(){const t=this._losstrades;return t?Math.abs(this._grossloss_percent/t):void 0}get avg_trade(){if(this._closedtrades)return this._netprofit/this._closedtrades}get equity(){return this.initial_capital+this._netprofit+this._openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._openprofit}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const t=this._wintrades;return t?Math.abs(this._grossprofit/t):void 0}get avg_winning_trade_percent(){const t=this._wintrades;return t?Math.abs(this._grossprofit_percent/t):void 0}get initial_capital(){var t;return((t=this._options)==null?void 0:t.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss/this.initial_capital*100}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit/this.initial_capital*100}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:t,margin_long:e=0,margin_short:r=0,commission_type:n,commission_value:s=0}=this._options,a=this._orders[0].direction===se.long?1:-1,l=(a===1?e:r)/100;if(l<=0)return;const{close:c}=this._variables,[f,d]=this._orders.reduce((h,p)=>{let[g,w]=h;const{in_price:_,qty:y=0,original_qty:v=0}=p,x=_*y;if(g+=x,s){let b=0;switch(n){case je.percent:b=(x+y*c)*s/100;break;case je.cashPerContract:b=y*s*2;break;case je.cashPerOrder:b=y/v*s+s;break}w+=b}return[g,w]},[0,0]);return(f-(t+this._netprofit-d))*a/this._position_size/(1-a*l)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this._netprofit/this.initial_capital*100}get openprofit_percent(){return this._openprofit/(this.initial_capital+this._netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}get summaryData(){return{position_size:this.position_size,position_avg_price:this.position_avg_price,position_entry_name:this.position_entry_name,openprofit_percent:this.openprofit_percent,netprofit_percent:this.netprofit_percent,max_drawdown_percent:this.max_drawdown_percent,max_runup_percent:this.max_runup_percent,max_drawdown:this.max_drawdown,max_runup:this.max_runup,max_contracts_held_long:this.max_contracts_held_long,max_contracts_held_short:this.max_contracts_held_short,max_contracts_held_all:this.max_contracts_held_all,avg_winning_trade_percent:this.avg_winning_trade_percent,avg_winning_trade:this.avg_winning_trade,avg_trade_percent:this.avg_trade_percent,avg_trade:this.avg_trade,avg_losing_trade:this.avg_losing_trade,avg_losing_trade_percent:this.avg_losing_trade_percent,wintrades:this.wintrades,losstrades:this.losstrades,eventrades:this.eventrades,grossprofit:this.grossprofit,grossprofit_percent:this.grossprofit_percent,grossloss:this.grossloss,grossloss_percent:this.grossloss_percent,openprofit:this.openprofit,initial_capital:this.initial_capital,netprofit:this.netprofit,closedtrades:this.closedtrades,opentrades:this.opentrades,equity:this.equity,margin_call_long:this.marginCallLong,margin_call_short:this.marginCallShort}}_getCommission(t,e){if(!this._options)return 0;const{commission_value:r=0,commission_type:n}=this._options,s=t*e;let a=0;switch(n){case je.percent:a=s*r/100;break;case je.cashPerContract:a=e*r;break;case je.cashPerOrder:a=r;break}return a}}class ky{constructor(t){L(this,"_preAccdist");L(this,"_preNvi");L(this,"_prePvi");L(this,"_preObv");L(this,"_prePvt");L(this,"_preWad");L(this,"_preVwap");L(this,"_preValue");L(this,"_currentData");L(this,"_preData");L(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=t}update(t){this._preValue={},t.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...t}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:t,low:e,high:r,volume:n}=this._currentData;if(r===e)return this._preAccdist;const s=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=s),this._preValue.accdist=s,s}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,s=(2*t-r-e)/((r-e)*n);return this._preValue.iii=s,s}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:t,low:e,high:r,volume:n,open:s}=this._currentData,a=(t-s)/(r-e)*n;return this._preValue.wvad=a,a}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const n=Math.sign(t-r)*e+this._preObv;return!this.isRealTime&&(this._preObv=n),this._preValue.obv=n,n}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:t,high:e}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const n=Math.max(e-t,Math.abs(e-r),Math.abs(t-r));return this._preValue.tr=n,n}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const n=(t-r)/r*e+this._prePvt;return!this.isRealTime&&(this._prePvt=n),this._preValue.pvt=n,n}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:t,high:e,low:r}=this._currentData,{close:n}=this._preData;if(n===void 0)return this._preWad=0,0;const s=Math.max(e,n),a=Math.min(r,n),l=t-n,f=(l>0?t-a:l<0?t-s:0)+this._preWad;return!this.isRealTime&&(this._preWad=f),this._preValue.wad=f,f}get vwap(){var d,h;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:s}=this._preVwap;if(((h=(d=self.workerStorage)==null?void 0:d.get(this._id))==null?void 0:h.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(s=!0,r=n=0),!s)return;const l=t*e+r,c=e+n;!this.isRealTime&&(this._preVwap={sum:l,sumV:c,isReset:s});const f=l/c;return this._preValue.vwap=f,f}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const l=t||1;return n&&e?a=s<r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._preNvi=a),this._preValue.nvi=a,a}_getPvi(){const t=this._prePvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const l=t||1;return n&&e?a=s>r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class qy{constructor(){L(this,"_period");L(this,"_multiplier");L(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=this._transformPeriod(t);const[e,r]=Cs(t);this._multiplier=e,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}_transformPeriod(t){const e=parseInt(t);return t.length>1&&e===1?t.replace("1",""):t}}class Uy{constructor(t){L(this,"_variables");L(this,"_bgColor");L(this,"_fgColor");L(this,"isUseBgColor",!1);this._variables=t}updateOptions(t){t!=null&&t.bg_color&&(this._bgColor=t.bg_color,this._fgColor=this._contrastColor(t.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){return this._variables.time}get right_visible_bar_time(){return this._variables.time}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=parseInt(a,16)/255:s=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}_contrastColor(t){const{r:e,g:r,b:n}=this._parseColor(t);return(299*e+587*r+114*n)/1e3>128?"#000000":"#ffffff"}}class Wy{constructor(t){L(this,"_variables");this._variables=t}get basecurrency(){return""}get country(){}get currency(){return"CNY"}get description(){return""}get employees(){return 100}get expiration_date(){}get industry(){}get minmove(){}get mintick(){return this._variables.mintick}get pointvalue(){}get prefix(){}get pricescale(){}get recommendations_buy(){}get recommendations_buy_strong(){}get recommendations_date(){}get recommendations_hold(){}get recommendations_sell(){}get recommendations_sell_strong(){}get recommendations_total(){}get root(){return""}get sector(){}get session(){return gi.regular}get shareholders(){}get shares_outstanding_float(){}get shares_outstanding_total(){}get target_price_average(){}get target_price_date(){}get target_price_estimates(){}get target_price_high(){}get target_price_low(){}get target_price_median(){}get ticker(){return""}get tickerid(){return""}get timezone(){}get type(){}get volumetype(){return"n/a"}}class jy{constructor(t){L(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class Vy{constructor(t){L(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}ee.extend(sp),ee.extend(ql),ee.extend(np);class bh{constructor(t){L(this,"_cacheData");L(this,"_barIndex");L(this,"_isRealTimeBar");L(this,"_barstate");L(this,"_priceVariables");L(this,"_lastBarIndex");L(this,"_currentBarTime");L(this,"_lastBarTime");L(this,"_period");L(this,"_offsetTime");L(this,"_timeframe");L(this,"_ta");L(this,"_polyline");L(this,"_label");L(this,"_line");L(this,"_linefill");L(this,"_box");L(this,"_table");L(this,"_strategy");L(this,"_session");L(this,"syminfo");L(this,"chart");L(this,"earnings");L(this,"dividends");L(this,"_timeTradingday");L(this,"_mintick");L(this,"_cacheSpace");L(this,"_precision");this._cacheData={varData:{},varNewData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new Ry,this._timeframe=new qy,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new ky(t),this._polyline=new Ii,this._label=new Ii,this._line=new Ii,this._linefill=new Ii,this._box=new Ii,this._table=new Ii,this._strategy=new zy(this),this._session=new Py(this),this.syminfo=new Wy(this),this.chart=new Uy(this),this.earnings=new Vy(this),this.dividends=new jy(this),this._cacheSpace=new Map}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:t,open:e,high:r,low:n}=this._priceVariables;return(t+e+r+n)/4}get hl2(){const{high:t,low:e}=this._priceVariables;return(t+e)/2}get hlc3(){const{close:t,high:e,low:r}=this._priceVariables;return(t+e+r)/3}get hlcc4(){const{close:t,high:e,low:r}=this._priceVariables;return(t*2+e+r)/4}get hour(){return ee(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return ee(this._currentBarTime).minute()}get second(){return ee(this._currentBarTime).second()}get month(){return ee(this._currentBarTime).month()+1}get year(){return ee(this._currentBarTime).year()}get dayofweek(){return ee(this._currentBarTime).day()}get dayofmonth(){return ee(this._currentBarTime).date()}get weekofyear(){return ee(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=Cs(this._period);return this._isRealTimeBar?void 0:ee(this._currentBarTime).add(t,e).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}get precision(){return this._precision}updateMaxLength(t){const{max_lines_count:e,max_labels_count:r,max_boxes_count:n,max_polylines_count:s}=t;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),e&&this._line.setMaxLen(e),s&&this._polyline.setMaxLen(s)}getTimeTradingday(t,e){const[r,n]=Cs(e),s=ee(t);return["M","w","y","d"].includes(n)?s.valueOf():(s.subtract(this._offsetTime,"h"),s.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(t){var l;const{interval:e="1D",offsetTime:r=5,mintick:n,chart:s}=t,a=((l=n.toString().split(".")[1])==null?void 0:l.length)||5;this._precision=a,this._period=e,this._mintick=n,this._offsetTime=r,this._timeframe.update(e),this.chart.updateOptions(s)}updateData(t){const{barIndex:e,c:r,o:n,h:s,l:a,volume:l,time:c,lastBarIndex:f,lastBarTime:d,isrealtime:h,time_tradingday:p}=t;this._priceVariables={close:Number(r),open:Number(n),high:Number(s),low:Number(a),volume:Number(l)},this._isRealTimeBar=h,e>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varNewData={}),this._timeTradingday=p,this._currentBarTime=c*1e3,this._lastBarIndex=f,this._barIndex=e,this._lastBarTime=d*1e3,this._barstate.update(e,f,h,!0),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){const n=this.setCacheData(t,r);return(this._cacheSpace.get(t)||0)<e&&this._cacheSpace.set(t,e),n[n.length-1-e]}setCacheData(t,e){let r=this._cacheData[t]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;r.barIndex===this._barIndex?r.data[r.data.length-1]=e:r.data.push(e);const n=this._cacheSpace.get(t);return n&&r.data.length>n+5&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[t]=r,r.data}getTypeInstance(t,e){return new Qd(t,e)}verifyVarAndVarip(t,e,r){const n=`${t}_${e}`;return r==="var"&&this._cacheData.varData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varData[n]),!0):r==="varip"&&this._cacheData.varipData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varipData[n]),!0):!1}getVarValue(t,e,r){const n=`${t}_${e}`;return r==="var"?this._isRealTimeBar&&this._cacheData.varNewData.hasOwnProperty(n)?this._cacheData.varNewData[n]:this._cacheData.varData[n]:this._cacheData.varipData[n]}setVarValue(t,e,r,n){var l;const s=`${t}_${e}`;let a;switch(typeof r=="object"&&((l=r==null?void 0:r.varipKeys)!=null&&l.length)&&(n="var",a=r.varipKeys),this._chartDrawsHandle(r,this._cacheData.varData[s]||this._cacheData.varipData[s]),n){case"var":if(this._isRealTimeBar){if(this._cacheData.varNewData[s]=r,a&&a.length)for(const c of a)this._cacheData.varData[s][c]=r[c]}else this._cacheData.varData[s]=r;break;case"varip":this._cacheData.varipData[s]=r;break}return r}_upadteChartDraws(t){const e=t==null?void 0:t.id;if(e)switch(t==null?void 0:t.type){case Me.BOX:this._setChartDraw(e,this._box);break;case Me.LINE:this._setChartDraw(e,this._line);break;case Me.POLYLINE:this._setChartDraw(e,this._polyline);break;case Me.LABEL:this._setChartDraw(e,this._label);break;case Me.LINEFILL:this._setChartDraw(e,this._linefill);break;case Me.TABLE:this._setChartDraw(e,this._table);break}}_setChartDraw(t,e){const r=e.getInstance(t),n=e.get(t),s=(r==null?void 0:r.updateId())||t;e.delete(t),e.set(s,n,r)}_chartDrawsHandle(t,e){const r=e==null?void 0:e.id;let n=t==null?void 0:t.id;r!==n&&(n&&t.data&&(t.data.isVar=!0),r&&e.data&&(e.data.isVar=!1))}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Qr.uniq([...t,...e]):typeof t=="number"||typeof e=="number"?Number(t)+Number(e):t+e}sub(t,e){return Array.isArray(t)&&Array.isArray(e)?t.filter(r=>!e.includes(r)):Number(t)-Number(e)}againAssignParse(t,e){var n;if(e)return;const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;if(r)switch(r){case _o.name:case dh.name:case vo.name:case ph.name:case mo.name:case go.name:t==null||t.delete();break}}}class Ii{constructor(t=50){L(this,"_all");L(this,"_allInstance");L(this,"_pseudoArrayAll");L(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Qt,this._maxLength=t}setMaxLen(t){this._maxLength=t}get data(){return[...this._all.values()].slice(-this._maxLength)}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(t,e,r){if(this.set(t,e,r),this._all.size>this._maxLength){const{bar_index:n}=e;for(const[s,a]of this._all){const{isVar:l,id:c,bar_index:f}=a;if(f===n)break;if(l)continue;this.delete(c);break}}}getValOfBarIndex(t){let e=[];const r=[...this._all.keys()];for(const n of t){const s=r.filter(a=>a.endsWith(`_${n}`));for(const a of s){const l=this._all.get(a);l&&e.push(l)}}return e.length?e:void 0}set(t,e,r){this._all.set(t,e),this._allInstance.set(t,r)}get(t){return this._all.get(t)}getInstance(t){return this._allInstance.get(t)}delete(t){this._all.delete(t),this._allInstance.delete(t)}}/**
65
+ ${g}`),g}_getRequestData(t,e){let{symbol:r,timeframe:n,calc_bars_count:s}=t;const{__period:a,syminfo:{ticker:l,tickerid:c},mintick:h}=this._variables;if((n===a||n==="")&&(r===l||r===c)){const{close:g,open:w,high:m,low:y,bar_index:v,last_bar_index:x,last_bar_time:b,_isRealTimeBar:M,volume:E,time:F,time_tradingday:N}=this._variables;return{barIndex:v,c:g,o:w,h:m,l:y,volume:E,lastBarIndex:x,lastBarTime:b/1e3,isrealtime:M,time_tradingday:N,time:F/1e3,interval:a,mintick:h}}const d=`${r}--${n||a}`,f=self.workerStorage.get(`request_${this._scriptId}_data`),p=self.workerStorage.get(`request_${this._scriptId}_list`);if(f!=null&&f.has(d)){p==null||p.delete(d);const{index:g=0,periodStamp:w=tn(this._variables.__period)*1e3}=this._cacheData.get(e)||{},m=(f.get(d)||[]).slice(g),y=this._variables.time,v=w+y,x=m.length-1,b={lastBarIndex:m[x].barindex||x,lastBarTime:m[x].time,interval:a,mintick:h};for(const[M,E]of m.entries()){let{time:F,barindex:N}=E;if(F=F*1e3,F>=v){this._cacheData.set(e,{index:M,periodStamp:w});return}if(F>=y)return this._cacheData.set(e,{index:M+1,periodStamp:w}),{...E,barIndex:N||M,...b}}this._cacheData.set(e,{index:m.length,periodStamp:w})}else(p==null?void 0:p.get(d))||p==null||p.set(d,{id:d,calc_bars_count:s,symbol:r,timeframe:n||a})}_getDependCodes(t,e,r,n,s,a){for(const l of t){if(!l.isArg){const c=e.filter(d=>{var f;return(f=d==null?void 0:d.depends)==null?void 0:f.some(p=>p.name===l.name&&p.scope===l.scope&&p.isAgainAssign)});for(const d of c){const{code:f,depends:p}=d;if(!r.includes(f)&&(r.unshift(f),p!=null&&p.length)){for(const g of p)g.memberCode&&a.push(g.memberCode);this._getDependCodes(p,e,r,n,s,a)}}const h=e.find(d=>{var f;return((f=d.varNames)==null?void 0:f.split(", ").includes(l.name))&&(!l.isPreArg||l.isPreArg&&d.methodName===l.functionName)||d.funcName===l.name});if(h){const{code:d,depends:f}=h,p=r.findIndex(g=>g===d);if(p!==-1&&r.splice(p,1),r.unshift(d),f!=null&&f.length){for(const g of f)g.memberCode&&a.push(g.memberCode);this._getDependCodes(f,e,r,n,s,a)}continue}}s.some(c=>c.name===l.name)||s.push(l)}}_runScripts(t,e,r,n,s){const a=`${this._scriptId}_${e}`;let{builtInGather:l,buildinConstants:c,buildInFunctions:h,tradingvueFunc:d}=self.workerStorage.get(a)||{};const{interval:f,mintick:p,...g}=s||{};r&&(l=new bh(a),c=new hh,h=new Dh(this._variables.mintick||1e-5,l,this._scriptId),d=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",t),l.updateOptions({interval:f,mintick:p||1e-5}),self.workerStorage.set(a,{builtInGather:l,buildinConstants:c,buildInFunctions:h,tradingvueFunc:d})),l.updateData(g),h.update({barIndex:(g==null?void 0:g.barindex)||0});const w=d(l,c,h,n||[],e);return h.endExecution(),w}}let Iy=class{constructor(){}prefix(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[0])||""}ticker(t){var r;const{symbol:e}=t;return((r=e==null?void 0:e.split("."))==null?void 0:r[1])||""}};class Ty{constructor(t){$(this,"_logs");$(this,"_variables");$(this,"_intlFormat");this._variables=t,this._logs=[],this._intlFormat=new Intl.NumberFormat("en-US")}get logs(){return this._logs}clearLogs(){this._logs=[]}info(t,e,r){this._addLog(t,e,"info",r)}error(t,e,r){this._addLog(t,e,"error",r)}warning(t,e,r){this._addLog(t,e,"warning",r)}_addLog(t,e,r,n){if(typeof e=="string"&&(n=e),n.startsWith("export"))return;const{message:s,formatString:a}=t,{time:l,bar_index:c}=this._variables;let h=s;a&&Array.isArray(e)&&e.length&&(h=a.replace(/{(\d+)}/g,(d,f)=>{if(e.length<=Number(f))return d;let p=e[f];return typeof p=="number"&&(p=this._intlFormat.format(parseFloat(p.toFixed(3)))),typeof p=="object"&&(p.isArray?p=JSON.stringify(p._value):p=p.toString()),p!==void 0?p:"na"})),h&&this._logs.push({message:`[${ee(l).format()}]: ${h}`,time:l,barIndex:c,type:r})}}class $y{constructor(t){$(this,"_errorListener");this._errorListener=t}error({message:t},e){e.startsWith("export")||this._errorListener.addError(t,e,Pt.Error)}}class Ly{constructor(){$(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return Qr.flatMap([...this._errors.values()])}addError(t,e,r,n=0){const[s,a]=e.split("_").slice(-2),l=this._errors.get(e),c={message:t,endLineNumber:Number(s),startColumn:Number(a)+1,endColumn:Number(a)+n+1,startLineNumber:Number(s),type:r};l?l.push(c):this._errors.set(e,[c])}}class Ry{constructor(){$(this,"_isMarketOpen");$(this,"_currentBarIndex");$(this,"_totalBarIndex");$(this,"_isRealTimeBar");$(this,"_preBarIndex");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0}update(t,e,r,n){this._preBarIndex=this._currentBarIndex,this._currentBarIndex=t,this._totalBarIndex=e,this._isRealTimeBar=r,this._isMarketOpen=n}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1||this._currentBarIndex===this._totalBarIndex&&!this._isRealTimeBar:this._currentBarIndex===this._totalBarIndex}}class Py{constructor(t){$(this,"_variables");this._variables=t}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const t=tn(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const t=tn(this._variables.timeframe.period);return this._variables.time+t===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class zy{constructor(t){$(this,"_orders");$(this,"_historyOrders");$(this,"_options");$(this,"_max_contracts_held_all",0);$(this,"_max_contracts_held_long",0);$(this,"_max_contracts_held_short",0);$(this,"_max_drawdown",0);$(this,"_max_runup",0);$(this,"_max_runup_percent",0);$(this,"_max_drawdown_percent",0);$(this,"_variables");$(this,"_netprofit",0);$(this,"_eventrades",0);$(this,"_avg_trade_percent");$(this,"_closedtrades",0);$(this,"_losstrades",0);$(this,"_grossloss",0);$(this,"_grossloss_percent",0);$(this,"_grossprofit",0);$(this,"_grossprofit_percent",0);$(this,"_wintrades",0);$(this,"_opentrades_capital_held",0);$(this,"_position_avg_price",0);$(this,"_position_size",0);$(this,"_openprofit",0);$(this,"_preMaxNetValue",0);$(this,"_preMinNetValue",0);$(this,"marginCallLong",0);$(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=t}update(t){this._calcMaxDrawdownAndMaxRunup(t)}_calcMaxDrawdownAndMaxRunup(t){if(!this._orders.length&&!this._historyOrders.length)return;let e=0,r=0;const{high:n,low:s,close:a}=t;let l=0;for(const d of this._orders){const{in_price:f,qty:p=0,direction:g}=d,w=g===ce.long?1:-1,m=(n-f)*p,y=(s-f)*p,v=w===1?m:-y,x=w===1?-y:m;l+=(a-f)*w*p,e+=x,r+=v}this._openprofit=l;const c=this.initial_capital,h=c+this._netprofit;this._preMinNetValue=this._preMinNetValue||c,this._preMaxNetValue=this._preMaxNetValue||c,e=this._preMaxNetValue-h+Math.max(e,0),r=h-this._preMinNetValue+r,this._max_drawdown<e&&(this._max_drawdown=e,this._max_drawdown_percent=e/c*100),r>this._max_runup&&(this._max_runup=r,this._max_runup_percent=r/(h+r)*100)}updateOrders(t){this._orders=t,this._calcMaxContracts()}_calcMaxContracts(){const t=this._orders.length;if(!t){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[e,r,n,s,a,l,c]=this._orders.reduce(([h,d,f,p,g,w,m],y)=>{const{direction:v,qty:x=0,in_price:b,commission:M=0}=y;return v===ce.long?(h+=x,d+=x,w+=x):(h+=x,f+=x,w-=x),p+=x*b,g+=b,m+=M,[h,d,f,p,g,w,m]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-c,this._grossloss=-c),this._position_size=l,this._position_avg_price=a/t,this._opentrades_capital_held=s,this._max_contracts_held_all=Math.max(e,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(n,this._max_contracts_held_short)}updateHistoryOrders(t){this._historyOrders=t;const e=this._historyOrders.length;this._closedtrades=e;const[r,n,s,a]=this._historyOrders.reduce((h,d)=>{let[f,p,g,w]=h;const{profit:m=0,profit_percent:y=0}=d;return f+=m,p+=y,m<0?g+=m:w+=m,[f,p,g,w]},[0,0,0,0]),l=this._orders.reduce((h,d)=>{const{commission:f=0,qty:p=0,original_qty:g=0}=d,w=f*p/g;return h+w},0);this._avg_trade_percent=e?n/e:void 0,this._netprofit=r-l;const c=this.initial_capital+this._netprofit;this._preMaxNetValue=Math.max(this._preMaxNetValue||this.initial_capital,c),this._preMinNetValue=Math.min(this._preMinNetValue||this.initial_capital,c),this._grossloss=s-l,this._grossprofit=a,this._eventrades=this._historyOrders.filter(h=>h.profit===0).length,this._losstrades=this._historyOrders.filter(h=>(h.profit||0)<0).length,this._wintrades=this._historyOrders.filter(h=>(h.profit||0)>0).length}updateStrategyOptions(t){this._options=t}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const t=this._losstrades;return t?Math.abs(this._grossloss/t):void 0}get avg_losing_trade_percent(){const t=this._losstrades;return t?Math.abs(this._grossloss_percent/t):void 0}get avg_trade(){if(this._closedtrades)return this._netprofit/this._closedtrades}get equity(){return this.initial_capital+this._netprofit+this._openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._openprofit}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const t=this._wintrades;return t?Math.abs(this._grossprofit/t):void 0}get avg_winning_trade_percent(){const t=this._wintrades;return t?Math.abs(this._grossprofit_percent/t):void 0}get initial_capital(){var t;return((t=this._options)==null?void 0:t.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss/this.initial_capital*100}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit/this.initial_capital*100}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:t,margin_long:e=0,margin_short:r=0,commission_type:n,commission_value:s=0}=this._options,a=this._orders[0].direction===ce.long?1:-1,l=(a===1?e:r)/100;if(l<=0)return;const{close:c}=this._variables,[h,d]=this._orders.reduce((f,p)=>{let[g,w]=f;const{in_price:m,qty:y=0,original_qty:v=0}=p,x=m*y;if(g+=x,s){let b=0;switch(n){case je.percent:b=(x+y*c)*s/100;break;case je.cashPerContract:b=y*s*2;break;case je.cashPerOrder:b=y/v*s+s;break}w+=b}return[g,w]},[0,0]);return(h-(t+this._netprofit-d))*a/this._position_size/(1-a*l)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this._netprofit/this.initial_capital*100}get openprofit_percent(){return this._openprofit/(this.initial_capital+this._netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}get summaryData(){return{position_size:this.position_size,position_avg_price:this.position_avg_price,position_entry_name:this.position_entry_name,openprofit_percent:this.openprofit_percent,netprofit_percent:this.netprofit_percent,max_drawdown_percent:this.max_drawdown_percent,max_runup_percent:this.max_runup_percent,max_drawdown:this.max_drawdown,max_runup:this.max_runup,max_contracts_held_long:this.max_contracts_held_long,max_contracts_held_short:this.max_contracts_held_short,max_contracts_held_all:this.max_contracts_held_all,avg_winning_trade_percent:this.avg_winning_trade_percent,avg_winning_trade:this.avg_winning_trade,avg_trade_percent:this.avg_trade_percent,avg_trade:this.avg_trade,avg_losing_trade:this.avg_losing_trade,avg_losing_trade_percent:this.avg_losing_trade_percent,wintrades:this.wintrades,losstrades:this.losstrades,eventrades:this.eventrades,grossprofit:this.grossprofit,grossprofit_percent:this.grossprofit_percent,grossloss:this.grossloss,grossloss_percent:this.grossloss_percent,openprofit:this.openprofit,initial_capital:this.initial_capital,netprofit:this.netprofit,closedtrades:this.closedtrades,opentrades:this.opentrades,equity:this.equity,margin_call_long:this.marginCallLong,margin_call_short:this.marginCallShort}}_getCommission(t,e){if(!this._options)return 0;const{commission_value:r=0,commission_type:n}=this._options,s=t*e;let a=0;switch(n){case je.percent:a=s*r/100;break;case je.cashPerContract:a=e*r;break;case je.cashPerOrder:a=r;break}return a}}class ky{constructor(t){$(this,"_preAccdist");$(this,"_preNvi");$(this,"_prePvi");$(this,"_preObv");$(this,"_prePvt");$(this,"_preWad");$(this,"_preVwap");$(this,"_preValue");$(this,"_currentData");$(this,"_preData");$(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=t}update(t){this._preValue={},t.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...t}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:t,low:e,high:r,volume:n}=this._currentData;if(r===e)return this._preAccdist;const s=(t-e-(r-t))/(r-e)*n+this._preAccdist;return!this.isRealTime&&(this._preAccdist=s),this._preValue.accdist=s,s}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:t,low:e,high:r,volume:n}=this._currentData,s=(2*t-r-e)/((r-e)*n);return this._preValue.iii=s,s}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:t,low:e,high:r,volume:n,open:s}=this._currentData,a=(t-s)/(r-e)*n;return this._preValue.wvad=a,a}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const n=Math.sign(t-r)*e+this._preObv;return!this.isRealTime&&(this._preObv=n),this._preValue.obv=n,n}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:t,high:e}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const n=Math.max(e-t,Math.abs(e-r),Math.abs(t-r));return this._preValue.tr=n,n}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:t,volume:e}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const n=(t-r)/r*e+this._prePvt;return!this.isRealTime&&(this._prePvt=n),this._preValue.pvt=n,n}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:t,high:e,low:r}=this._currentData,{close:n}=this._preData;if(n===void 0)return this._preWad=0,0;const s=Math.max(e,n),a=Math.min(r,n),l=t-n,h=(l>0?t-a:l<0?t-s:0)+this._preWad;return!this.isRealTime&&(this._preWad=h),this._preValue.wad=h,h}get vwap(){var d,f;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:t,volume:e}=this._currentData;let{sum:r=0,sumV:n=0,isReset:s}=this._preVwap;if(((f=(d=self.workerStorage)==null?void 0:d.get(this._id))==null?void 0:f.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(s=!0,r=n=0),!s)return;const l=t*e+r,c=e+n;!this.isRealTime&&(this._preVwap={sum:l,sumV:c,isReset:s});const h=l/c;return this._preValue.vwap=h,h}_getNvi(){const t=this._preNvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const l=t||1;return n&&e?a=s<r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._preNvi=a),this._preValue.nvi=a,a}_getPvi(){const t=this._prePvi||1,{close:e=0,volume:r=0}=this._preData,{close:n,volume:s}=this._currentData;let a=1;const l=t||1;return n&&e?a=s>r?l+(n-e)/e*l:l:a=l,!this.isRealTime&&(this._prePvi=a),this._preValue.pvi=a,a}}class qy{constructor(){$(this,"_period");$(this,"_multiplier");$(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(t){if(!t)return;this._period=this._transformPeriod(t);const[e,r]=Cs(t);this._multiplier=e,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}_transformPeriod(t){const e=parseInt(t);return t.length>1&&e===1?t.replace("1",""):t}}class Uy{constructor(t){$(this,"_variables");$(this,"_bgColor");$(this,"_fgColor");$(this,"isUseBgColor",!1);this._variables=t}updateOptions(t){t!=null&&t.bg_color&&(this._bgColor=t.bg_color,this._fgColor=this._contrastColor(t.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){return this._variables.time}get right_visible_bar_time(){return this._variables.time}_parseColor(t){let e,r,n,s;if(t.startsWith("#")){e=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);const a=t.substring(7);a?s=parseInt(a,16)/255:s=1}else{const a=this._parserRgbColor(t);e=a[0]||0,r=a[1]||0,n=a[2]||0,s=a[3]||1}return{r:e,g:r,b:n,a:s}}_parserRgbColor(t){var e;return((e=t.match(/\d+/g))==null?void 0:e.map(Number))||[]}_contrastColor(t){const{r:e,g:r,b:n}=this._parseColor(t);return(299*e+587*r+114*n)/1e3>128?"#000000":"#ffffff"}}class Wy{constructor(t){$(this,"_variables");this._variables=t}get basecurrency(){return""}get country(){}get currency(){return"CNY"}get description(){return""}get employees(){return 100}get expiration_date(){}get industry(){}get minmove(){}get mintick(){return this._variables.mintick}get pointvalue(){}get prefix(){}get pricescale(){}get recommendations_buy(){}get recommendations_buy_strong(){}get recommendations_date(){}get recommendations_hold(){}get recommendations_sell(){}get recommendations_sell_strong(){}get recommendations_total(){}get root(){return""}get sector(){}get session(){return gi.regular}get shareholders(){}get shares_outstanding_float(){}get shares_outstanding_total(){}get target_price_average(){}get target_price_date(){}get target_price_estimates(){}get target_price_high(){}get target_price_low(){}get target_price_median(){}get ticker(){return""}get tickerid(){return""}get timezone(){}get type(){}get volumetype(){return"n/a"}}class jy{constructor(t){$(this,"_variables");this._variables=t}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class Vy{constructor(t){$(this,"_variables");this._variables=t}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}ee.extend(sp),ee.extend(ql),ee.extend(np);class bh{constructor(t){$(this,"_cacheData");$(this,"_barIndex");$(this,"_isRealTimeBar");$(this,"_barstate");$(this,"_priceVariables");$(this,"_lastBarIndex");$(this,"_currentBarTime");$(this,"_lastBarTime");$(this,"_period");$(this,"_offsetTime");$(this,"_timeframe");$(this,"_ta");$(this,"_polyline");$(this,"_label");$(this,"_line");$(this,"_linefill");$(this,"_box");$(this,"_table");$(this,"_strategy");$(this,"_session");$(this,"syminfo");$(this,"chart");$(this,"earnings");$(this,"dividends");$(this,"_timeTradingday");$(this,"_mintick");$(this,"_cacheSpace");$(this,"_precision");this._cacheData={varData:{},varNewData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new Ry,this._timeframe=new qy,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new ky(t),this._polyline=new Ii,this._label=new Ii,this._line=new Ii,this._linefill=new Ii,this._box=new Ii,this._table=new Ii,this._strategy=new zy(this),this._session=new Py(this),this.syminfo=new Wy(this),this.chart=new Uy(this),this.earnings=new Vy(this),this.dividends=new jy(this),this._cacheSpace=new Map}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:t,open:e,high:r,low:n}=this._priceVariables;return(t+e+r+n)/4}get hl2(){const{high:t,low:e}=this._priceVariables;return(t+e)/2}get hlc3(){const{close:t,high:e,low:r}=this._priceVariables;return(t+e+r)/3}get hlcc4(){const{close:t,high:e,low:r}=this._priceVariables;return(t*2+e+r)/4}get hour(){return ee(this._currentBarTime).subtract(this._offsetTime,"hour").hour()}get minute(){return ee(this._currentBarTime).minute()}get second(){return ee(this._currentBarTime).second()}get month(){return ee(this._currentBarTime).month()+1}get year(){return ee(this._currentBarTime).year()}get dayofweek(){return ee(this._currentBarTime).day()}get dayofmonth(){return ee(this._currentBarTime).date()}get weekofyear(){return ee(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[t,e]=Cs(this._period);return this._isRealTimeBar?void 0:ee(this._currentBarTime).add(t,e).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}get precision(){return this._precision}updateMaxLength(t){const{max_lines_count:e,max_labels_count:r,max_boxes_count:n,max_polylines_count:s}=t;n&&this._box.setMaxLen(n),r&&this._label.setMaxLen(r),e&&this._line.setMaxLen(e),s&&this._polyline.setMaxLen(s)}getTimeTradingday(t,e){const[r,n]=Cs(e),s=ee(t);return["M","w","y","d"].includes(n)?s.valueOf():(s.subtract(this._offsetTime,"h"),s.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(t){var l;const{interval:e="1D",offsetTime:r=5,mintick:n,chart:s}=t,a=((l=n.toString().split(".")[1])==null?void 0:l.length)||5;this._precision=a,this._period=e,this._mintick=n,this._offsetTime=r,this._timeframe.update(e),this.chart.updateOptions(s)}updateData(t){const{barIndex:e,c:r,o:n,h:s,l:a,volume:l,time:c,lastBarIndex:h,lastBarTime:d,isrealtime:f,time_tradingday:p}=t;this._priceVariables={close:Number(r),open:Number(n),high:Number(s),low:Number(a),volume:Number(l)},this._isRealTimeBar=f,e>this._barIndex&&this._isRealTimeBar&&(this._cacheData.varNewData={}),this._timeTradingday=p,this._currentBarTime=c*1e3,this._lastBarIndex=h,this._barIndex=e,this._lastBarTime=d*1e3,this._barstate.update(e,h,f,!0),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:e})}getCacheData(t,e,r){const n=this.setCacheData(t,r);return(this._cacheSpace.get(t)||0)<e&&this._cacheSpace.set(t,e),n[n.length-1-e]}setCacheData(t,e){let r=this._cacheData[t]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;r.barIndex===this._barIndex?r.data[r.data.length-1]=e:r.data.push(e);const n=this._cacheSpace.get(t);return n&&r.data.length>n+5&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[t]=r,r.data}getTypeInstance(t,e){return new Qd(t,e)}verifyVarAndVarip(t,e,r){const n=`${t}_${e}`;return r==="var"&&this._cacheData.varData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varData[n]),!0):r==="varip"&&this._cacheData.varipData.hasOwnProperty(n)?(this._upadteChartDraws(this._cacheData.varipData[n]),!0):!1}getVarValue(t,e,r){const n=`${t}_${e}`;return r==="var"?this._isRealTimeBar&&this._cacheData.varNewData.hasOwnProperty(n)?this._cacheData.varNewData[n]:this._cacheData.varData[n]:this._cacheData.varipData[n]}setVarValue(t,e,r,n){var l;const s=`${t}_${e}`;let a;switch(typeof r=="object"&&((l=r==null?void 0:r.varipKeys)!=null&&l.length)&&(n="var",a=r.varipKeys),this._chartDrawsHandle(r,this._cacheData.varData[s]||this._cacheData.varipData[s]),n){case"var":if(this._isRealTimeBar){if(this._cacheData.varNewData[s]=r,a&&a.length)for(const c of a)this._cacheData.varData[s][c]=r[c]}else this._cacheData.varData[s]=r;break;case"varip":this._cacheData.varipData[s]=r;break}return r}_upadteChartDraws(t){const e=t==null?void 0:t.id;if(e)switch(t==null?void 0:t.type){case Me.BOX:this._setChartDraw(e,this._box);break;case Me.LINE:this._setChartDraw(e,this._line);break;case Me.POLYLINE:this._setChartDraw(e,this._polyline);break;case Me.LABEL:this._setChartDraw(e,this._label);break;case Me.LINEFILL:this._setChartDraw(e,this._linefill);break;case Me.TABLE:this._setChartDraw(e,this._table);break}}_setChartDraw(t,e){const r=e.getInstance(t),n=e.get(t),s=(r==null?void 0:r.updateId())||t;e.delete(t),e.set(s,n,r)}_chartDrawsHandle(t,e){const r=e==null?void 0:e.id;let n=t==null?void 0:t.id;r!==n&&(n&&t.data&&(t.data.isVar=!0),r&&e.data&&(e.data.isVar=!1))}add(t,e){return Array.isArray(t)&&Array.isArray(e)?Qr.uniq([...t,...e]):typeof t=="number"||typeof e=="number"?Number(t)+Number(e):t+e}sub(t,e){return Array.isArray(t)&&Array.isArray(e)?t.filter(r=>!e.includes(r)):Number(t)-Number(e)}againAssignParse(t,e){var n;if(e)return;const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;if(r)switch(r){case _o.name:case dh.name:case vo.name:case ph.name:case mo.name:case go.name:t==null||t.delete();break}}}class Ii{constructor(t=50){$(this,"_all");$(this,"_allInstance");$(this,"_pseudoArrayAll");$(this,"_maxLength");this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new Qt,this._maxLength=t}setMaxLen(t){this._maxLength=t}get data(){return[...this._all.values()].slice(-this._maxLength)}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values()],this._pseudoArrayAll}add(t,e,r){if(this.set(t,e,r),this._all.size>this._maxLength){const{bar_index:n}=e;for(const[s,a]of this._all){const{isVar:l,id:c,bar_index:h}=a;if(h===n)break;if(l)continue;this.delete(c);break}}}getValOfBarIndex(t){let e=[];const r=[...this._all.keys()];for(const n of t){const s=r.filter(a=>a.endsWith(`_${n}`));for(const a of s){const l=this._all.get(a);l&&e.push(l)}}return e.length?e:void 0}set(t,e,r){this._all.set(t,e),this._allInstance.set(t,r)}get(t){return this._all.get(t)}getInstance(t){return this._allInstance.get(t)}delete(t){this._all.delete(t),this._allInstance.delete(t)}}/**
66
66
  * @license
67
67
  * Copyright 2019 Google LLC
68
68
  * SPDX-License-Identifier: Apache-2.0
69
- */const xh=Symbol("Comlink.proxy"),Yy=Symbol("Comlink.endpoint"),Zy=Symbol("Comlink.releaseProxy"),Qa=Symbol("Comlink.finalizer"),Do=Symbol("Comlink.thrown"),Eh=i=>typeof i=="object"&&i!==null||typeof i=="function",Ky={canHandle:i=>Eh(i)&&i[xh],serialize(i){const{port1:t,port2:e}=new MessageChannel;return tu(i,t),[e,[e]]},deserialize(i){return i.start(),Xy(i)}},Gy={canHandle:i=>Eh(i)&&Do in i,serialize({value:i}){let t;return i instanceof Error?t={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:t={isError:!1,value:i},[t,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},Ah=new Map([["proxy",Ky],["throw",Gy]]);function Hy(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function tu(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Hy(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(si);let f;try{const d=l.slice(0,-1).reduce((p,g)=>p[g],i),h=l.reduce((p,g)=>p[g],i);switch(a){case"GET":f=h;break;case"SET":d[l.slice(-1)[0]]=si(n.data.value),f=!0;break;case"APPLY":f=h.apply(d,c);break;case"CONSTRUCT":{const p=new h(...c);f=nD(p)}break;case"ENDPOINT":{const{port1:p,port2:g}=new MessageChannel;tu(i,g),f=rD(p,[p])}break;case"RELEASE":f=void 0;break;default:return}}catch(d){f={value:d,[Do]:0}}Promise.resolve(f).catch(d=>({value:d,[Do]:0})).then(d=>{const[h,p]=Ao(d);t.postMessage(Object.assign(Object.assign({},h),{id:s}),p),a==="RELEASE"&&(t.removeEventListener("message",r),Ch(t),Qa in i&&typeof i[Qa]=="function"&&i[Qa]())}).catch(d=>{const[h,p]=Ao({value:new TypeError("Unserializable return value"),[Do]:0});t.postMessage(Object.assign(Object.assign({},h),{id:s}),p)})}),t.start&&t.start()}function Jy(i){return i.constructor.name==="MessagePort"}function Ch(i){Jy(i)&&i.close()}function Xy(i,t){return eu(i,[],t)}function bo(i){if(i)throw new Error("Proxy has been released and is not useable")}function Fh(i){return Ti(i,{type:"RELEASE"}).then(()=>{Ch(i)})}const xo=new WeakMap,Eo="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(xo.get(i)||0)-1;xo.set(i,t),t===0&&Fh(i)});function Qy(i,t){const e=(xo.get(t)||0)+1;xo.set(t,e),Eo&&Eo.register(i,t,i)}function tD(i){Eo&&Eo.unregister(i)}function eu(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(bo(r),a===Zy)return()=>{tD(n),Fh(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const l=Ti(i,{type:"GET",path:t.map(c=>c.toString())}).then(si);return l.then.bind(l)}return eu(i,[...t,a])},set(s,a,l){bo(r);const[c,f]=Ao(l);return Ti(i,{type:"SET",path:[...t,a].map(d=>d.toString()),value:c},f).then(si)},apply(s,a,l){bo(r);const c=t[t.length-1];if(c===Yy)return Ti(i,{type:"ENDPOINT"}).then(si);if(c==="bind")return eu(i,t.slice(0,-1));const[f,d]=Mh(l);return Ti(i,{type:"APPLY",path:t.map(h=>h.toString()),argumentList:f},d).then(si)},construct(s,a){bo(r);const[l,c]=Mh(a);return Ti(i,{type:"CONSTRUCT",path:t.map(f=>f.toString()),argumentList:l},c).then(si)}});return Qy(n,i),n}function eD(i){return Array.prototype.concat.apply([],i)}function Mh(i){const t=i.map(Ao);return[t.map(e=>e[0]),eD(t.map(e=>e[1]))]}const Nh=new WeakMap;function rD(i,t){return Nh.set(i,t),i}function nD(i){return Object.assign(i,{[xh]:!0})}function Ao(i){for(const[t,e]of Ah)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},Nh.get(i)||[]]}function si(i){switch(i.type){case"HANDLER":return Ah.get(i.name).deserialize(i.value);case"RAW":return i.value}}function Ti(i,t,e){return new Promise(r=>{const n=iD();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",s),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},t),e)})}function iD(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class sD{constructor(){L(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}deleteStartwidthKey(t){for(const e of this._cache.keys())e.startsWith(t)&&this._cache.delete(e)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}function oD(i,t,e){var b;const{data:r,isPreParser:n,id:s="default",syminfo:a,interval:l,inputs:c,chart:f,strategy:d,scriptType:h}=t;self.workerStorage||(self.workerStorage=new sD);let{builtInGather:p,buildinConstants:g,buildInFunctions:w,tradingvueFunc:_}=self.workerStorage.get(s)||{},y=[];e&&(p=new bh(s),g=new hh,w=new Dh((a==null?void 0:a.mintick)||1e-5,p,s),_=new Function("$_var","$_const","$_func",i),self.workerStorage.set(s,{builtInGather:p,buildinConstants:g,buildInFunctions:w,tradingvueFunc:_}),self.workerStorage.set(`request_${s}`,new Map),self.workerStorage.set(`request_${s}_data`,new Map),self.workerStorage.set(`request_${s}_list`,new Map));let v=[];if(n)_(p,g,w);else if(r&&r.length){const M=r.length-1;p.updateOptions({interval:l,mintick:(a==null?void 0:a.mintick)||1e-5,chart:f}),w.updateOptions({inputs:c,strategy:d});try{for(const[E,F]of r.entries()){const{barindex:N,isrealtime:S}=F;if(!e&&(N||N===0)&&y.push(N),S&&h===Yl.strategy&&!w.strategy.isCalcOnEveryTick){w.strategy.calcCurrentOrder();continue}if(p.updateData(Object.assign(F,{barIndex:N||E,lastBarIndex:r[M].barindex||M,lastBarTime:r[M].time})),w.update({barIndex:N||E}),_(p,g,w),w.endExecution(),w.strategy.calcOnOrderFillsData.tradeData){for(;w.strategy.calcOnOrderFillsData.tradeData;)w.strategy.calcOnOrderFillsData.data=w.strategy.calcOnOrderFillsData.tradeData,w.strategy.calcOnOrderFillsData.tradeData=void 0,p.updateData(Object.assign(F,{barIndex:N||E,lastBarIndex:r[M].barindex||M,lastBarTime:r[M].time})),w.update({barIndex:N||E}),_(p,g,w),w.endExecution();w.strategy.calcOnOrderFillsData={index:-1}}const T=w.errors;if(T.length&&T.some(C=>C.type===zt.Error))return{status:1,errors:T}}v=[...((b=self.workerStorage.get(`request_${s}_list`))==null?void 0:b.values())||[]],v.length&&self.workerStorage.delete(`request_${s}_list`)}catch(E){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:E==null?void 0:E.message,type:zt.Error}]}}}const x=w.errors;return x.length&&x.some(M=>M.type===zt.Error)?{status:1,errors:x}:{status:0,requestList:v,errors:x,options:{...w.options(y),id:s}}}function aD(i){self==null||self.workerStorage.deleteStartwidthKey(i),self==null||self.workerStorage.delete(`inputs_${i}`),self==null||self.workerStorage.delete(`strategy_${i}`),self==null||self.workerStorage.delete(`request_${i}`),self==null||self.workerStorage.delete(`request_${i}_data`),self==null||self.workerStorage.delete(`request_${i}_list`)}tu({runScript:oD,removeScript:aD})})();
69
+ */const xh=Symbol("Comlink.proxy"),Yy=Symbol("Comlink.endpoint"),Zy=Symbol("Comlink.releaseProxy"),Qa=Symbol("Comlink.finalizer"),Do=Symbol("Comlink.thrown"),Eh=i=>typeof i=="object"&&i!==null||typeof i=="function",Ky={canHandle:i=>Eh(i)&&i[xh],serialize(i){const{port1:t,port2:e}=new MessageChannel;return tu(i,t),[e,[e]]},deserialize(i){return i.start(),Xy(i)}},Gy={canHandle:i=>Eh(i)&&Do in i,serialize({value:i}){let t;return i instanceof Error?t={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:t={isError:!1,value:i},[t,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},Ah=new Map([["proxy",Ky],["throw",Gy]]);function Hy(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function tu(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Hy(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:a,path:l}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(si);let h;try{const d=l.slice(0,-1).reduce((p,g)=>p[g],i),f=l.reduce((p,g)=>p[g],i);switch(a){case"GET":h=f;break;case"SET":d[l.slice(-1)[0]]=si(n.data.value),h=!0;break;case"APPLY":h=f.apply(d,c);break;case"CONSTRUCT":{const p=new f(...c);h=nD(p)}break;case"ENDPOINT":{const{port1:p,port2:g}=new MessageChannel;tu(i,g),h=rD(p,[p])}break;case"RELEASE":h=void 0;break;default:return}}catch(d){h={value:d,[Do]:0}}Promise.resolve(h).catch(d=>({value:d,[Do]:0})).then(d=>{const[f,p]=Ao(d);t.postMessage(Object.assign(Object.assign({},f),{id:s}),p),a==="RELEASE"&&(t.removeEventListener("message",r),Ch(t),Qa in i&&typeof i[Qa]=="function"&&i[Qa]())}).catch(d=>{const[f,p]=Ao({value:new TypeError("Unserializable return value"),[Do]:0});t.postMessage(Object.assign(Object.assign({},f),{id:s}),p)})}),t.start&&t.start()}function Jy(i){return i.constructor.name==="MessagePort"}function Ch(i){Jy(i)&&i.close()}function Xy(i,t){return eu(i,[],t)}function bo(i){if(i)throw new Error("Proxy has been released and is not useable")}function Fh(i){return Ti(i,{type:"RELEASE"}).then(()=>{Ch(i)})}const xo=new WeakMap,Eo="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(xo.get(i)||0)-1;xo.set(i,t),t===0&&Fh(i)});function Qy(i,t){const e=(xo.get(t)||0)+1;xo.set(t,e),Eo&&Eo.register(i,t,i)}function tD(i){Eo&&Eo.unregister(i)}function eu(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(bo(r),a===Zy)return()=>{tD(n),Fh(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const l=Ti(i,{type:"GET",path:t.map(c=>c.toString())}).then(si);return l.then.bind(l)}return eu(i,[...t,a])},set(s,a,l){bo(r);const[c,h]=Ao(l);return Ti(i,{type:"SET",path:[...t,a].map(d=>d.toString()),value:c},h).then(si)},apply(s,a,l){bo(r);const c=t[t.length-1];if(c===Yy)return Ti(i,{type:"ENDPOINT"}).then(si);if(c==="bind")return eu(i,t.slice(0,-1));const[h,d]=Mh(l);return Ti(i,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:h},d).then(si)},construct(s,a){bo(r);const[l,c]=Mh(a);return Ti(i,{type:"CONSTRUCT",path:t.map(h=>h.toString()),argumentList:l},c).then(si)}});return Qy(n,i),n}function eD(i){return Array.prototype.concat.apply([],i)}function Mh(i){const t=i.map(Ao);return[t.map(e=>e[0]),eD(t.map(e=>e[1]))]}const Nh=new WeakMap;function rD(i,t){return Nh.set(i,t),i}function nD(i){return Object.assign(i,{[xh]:!0})}function Ao(i){for(const[t,e]of Ah)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},Nh.get(i)||[]]}function si(i){switch(i.type){case"HANDLER":return Ah.get(i.name).deserialize(i.value);case"RAW":return i.value}}function Ti(i,t,e){return new Promise(r=>{const n=iD();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",s),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},t),e)})}function iD(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class sD{constructor(){$(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}deleteStartwidthKey(t){for(const e of this._cache.keys())e.startsWith(t)&&this._cache.delete(e)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}function oD(i,t,e){var b;const{data:r,isPreParser:n,id:s="default",syminfo:a,interval:l,inputs:c,chart:h,strategy:d,scriptType:f}=t;self.workerStorage||(self.workerStorage=new sD);let{builtInGather:p,buildinConstants:g,buildInFunctions:w,tradingvueFunc:m}=self.workerStorage.get(s)||{},y=[];e&&(p=new bh(s),g=new hh,w=new Dh((a==null?void 0:a.mintick)||1e-5,p,s),m=new Function("$_var","$_const","$_func",i),self.workerStorage.set(s,{builtInGather:p,buildinConstants:g,buildInFunctions:w,tradingvueFunc:m}),self.workerStorage.set(`request_${s}`,new Map),self.workerStorage.set(`request_${s}_data`,new Map),self.workerStorage.set(`request_${s}_list`,new Map));let v=[];if(n)m(p,g,w);else if(r&&r.length){const M=r.length-1;p.updateOptions({interval:l,mintick:(a==null?void 0:a.mintick)||1e-5,chart:h}),w.updateOptions({inputs:c,strategy:d});try{for(const[E,F]of r.entries()){const{barindex:N,isrealtime:S}=F;if(!e&&(N||N===0)&&y.push(N),S&&f===Yl.strategy&&!w.strategy.isCalcOnEveryTick){w.strategy.calcCurrentOrder();continue}if(p.updateData(Object.assign(F,{barIndex:N||E,lastBarIndex:r[M].barindex||M,lastBarTime:r[M].time})),w.update({barIndex:N||E}),m(p,g,w),w.endExecution(),w.strategy.calcOnOrderFillsData.tradeData){for(;w.strategy.calcOnOrderFillsData.tradeData;)w.strategy.calcOnOrderFillsData.data=w.strategy.calcOnOrderFillsData.tradeData,w.strategy.calcOnOrderFillsData.tradeData=void 0,p.updateData(Object.assign(F,{barIndex:N||E,lastBarIndex:r[M].barindex||M,lastBarTime:r[M].time})),w.update({barIndex:N||E}),m(p,g,w),w.endExecution();w.strategy.calcOnOrderFillsData={index:-1}}const T=w.errors;if(T.length&&T.some(A=>A.type===Pt.Error))return{status:1,errors:T}}v=[...((b=self.workerStorage.get(`request_${s}_list`))==null?void 0:b.values())||[]],v.length&&self.workerStorage.delete(`request_${s}_list`)}catch(E){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:E==null?void 0:E.message,type:Pt.Error}]}}}const x=w.errors;return x.length&&x.some(M=>M.type===Pt.Error)?{status:1,errors:x}:{status:0,requestList:v,errors:x,options:{...w.options(y),id:s}}}function aD(i){self==null||self.workerStorage.deleteStartwidthKey(i),self==null||self.workerStorage.delete(`inputs_${i}`),self==null||self.workerStorage.delete(`strategy_${i}`),self==null||self.workerStorage.delete(`request_${i}`),self==null||self.workerStorage.delete(`request_${i}_data`),self==null||self.workerStorage.delete(`request_${i}_list`)}tu({runScript:oD,removeScript:aD})})();