mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
2 lines • 1.05 MB
JavaScript
/*! For license information please see mathjslab.node.cjs2022.js.LICENSE.txt */
(()=>{var __webpack_modules__={3110(t,e,r){var s;!function(){"use strict";var i,n,a,o=9e15,l=1e9,c="0123456789abcdef",u="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",h="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",d={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-o,maxE:o,crypto:!1},m=!0,p="[DecimalError] ",f=p+"Invalid argument: ",g=p+"Precision limit exceeded",y=p+"crypto unavailable",x="[object Decimal]",C=Math.floor,E=Math.pow,A=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,_=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,S=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,T=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=1e7,b=u.length-1,M=h.length-1,N={toStringTag:x};function I(t){var e,r,s,i=t.length-1,n="",a=t[0];if(i>0){for(n+=a,e=1;e<i;e++)(r=7-(s=t[e]+"").length)&&(n+=$(r)),n+=s;(r=7-(s=(a=t[e])+"").length)&&(n+=$(r))}else if(0===a)return"0";for(;a%10==0;)a/=10;return n+a}function w(t,e,r){if(t!==~~t||t<e||t>r)throw Error(f+t)}function L(t,e,r,s){var i,n,a,o;for(n=t[0];n>=10;n/=10)--e;return--e<0?(e+=7,i=0):(i=Math.ceil((e+1)/7),e%=7),n=E(10,7-e),o=t[i]%n|0,null==s?e<3?(0==e?o=o/100|0:1==e&&(o=o/10|0),a=r<4&&99999==o||r>3&&49999==o||5e4==o||0==o):a=(r<4&&o+1==n||r>3&&o+1==n/2)&&(t[i+1]/n/100|0)==E(10,e-2)-1||(o==n/2||0==o)&&!(t[i+1]/n/100|0):e<4?(0==e?o=o/1e3|0:1==e?o=o/100|0:2==e&&(o=o/10|0),a=(s||r<4)&&9999==o||!s&&r>3&&4999==o):a=((s||r<4)&&o+1==n||!s&&r>3&&o+1==n/2)&&(t[i+1]/n/1e3|0)==E(10,e-3)-1,a}function R(t,e,r){for(var s,i,n=[0],a=0,o=t.length;a<o;){for(i=n.length;i--;)n[i]*=e;for(n[0]+=c.indexOf(t.charAt(a++)),s=0;s<n.length;s++)n[s]>r-1&&(void 0===n[s+1]&&(n[s+1]=0),n[s+1]+=n[s]/r|0,n[s]%=r)}return n.reverse()}N.absoluteValue=N.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),D(t)},N.ceil=function(){return D(new this.constructor(this),this.e+1,2)},N.clampedTo=N.clamp=function(t,e){var r=this,s=r.constructor;if(t=new s(t),e=new s(e),!t.s||!e.s)return new s(NaN);if(t.gt(e))throw Error(f+e);return r.cmp(t)<0?t:r.cmp(e)>0?e:new s(r)},N.comparedTo=N.cmp=function(t){var e,r,s,i,n=this,a=n.d,o=(t=new n.constructor(t)).d,l=n.s,c=t.s;if(!a||!o)return l&&c?l!==c?l:a===o?0:!a^l<0?1:-1:NaN;if(!a[0]||!o[0])return a[0]?l:o[0]?-c:0;if(l!==c)return l;if(n.e!==t.e)return n.e>t.e^l<0?1:-1;for(e=0,r=(s=a.length)<(i=o.length)?s:i;e<r;++e)if(a[e]!==o[e])return a[e]>o[e]^l<0?1:-1;return s===i?0:s>i^l<0?1:-1},N.cosine=N.cos=function(){var t,e,r=this,s=r.constructor;return r.d?r.d[0]?(t=s.precision,e=s.rounding,s.precision=t+Math.max(r.e,r.sd())+7,s.rounding=1,r=function(t,e){var r,s,i;if(e.isZero())return e;(s=e.d.length)<32?i=(1/J(4,r=Math.ceil(s/3))).toString():(r=16,i="2.3283064365386962890625e-10"),t.precision+=r,e=K(t,1,e.times(i),new t(1));for(var n=r;n--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return t.precision-=r,e}(s,Z(s,r)),s.precision=t,s.rounding=e,D(2==a||3==a?r.neg():r,t,e,!0)):new s(1):new s(NaN)},N.cubeRoot=N.cbrt=function(){var t,e,r,s,i,n,a,o,l,c,u=this,h=u.constructor;if(!u.isFinite()||u.isZero())return new h(u);for(m=!1,(n=u.s*E(u.s*u,1/3))&&Math.abs(n)!=1/0?s=new h(n.toString()):(r=I(u.d),(n=((t=u.e)-r.length+1)%3)&&(r+=1==n||-2==n?"0":"00"),n=E(r,1/3),t=C((t+1)/3)-(t%3==(t<0?-1:2)),(s=new h(r=n==1/0?"5e"+t:(r=n.toExponential()).slice(0,r.indexOf("e")+1)+t)).s=u.s),a=(t=h.precision)+3;;)if(c=(l=(o=s).times(o).times(o)).plus(u),s=O(c.plus(u).times(o),c.plus(l),a+2,1),I(o.d).slice(0,a)===(r=I(s.d)).slice(0,a)){if("9999"!=(r=r.slice(a-3,a+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(D(s,t+1,1),e=!s.times(s).times(s).eq(u));break}if(!i&&(D(o,t+1,0),o.times(o).times(o).eq(u))){s=o;break}a+=4,i=1}return m=!0,D(s,t,h.rounding,e)},N.decimalPlaces=N.dp=function(){var t,e=this.d,r=NaN;if(e){if(r=7*((t=e.length-1)-C(this.e/7)),t=e[t])for(;t%10==0;t/=10)r--;r<0&&(r=0)}return r},N.dividedBy=N.div=function(t){return O(this,new this.constructor(t))},N.dividedToIntegerBy=N.divToInt=function(t){var e=this.constructor;return D(O(this,new e(t),0,1,1),e.precision,e.rounding)},N.equals=N.eq=function(t){return 0===this.cmp(t)},N.floor=function(){return D(new this.constructor(this),this.e+1,3)},N.greaterThan=N.gt=function(t){return this.cmp(t)>0},N.greaterThanOrEqualTo=N.gte=function(t){var e=this.cmp(t);return 1==e||0===e},N.hyperbolicCosine=N.cosh=function(){var t,e,r,s,i,n=this,a=n.constructor,o=new a(1);if(!n.isFinite())return new a(n.s?1/0:NaN);if(n.isZero())return o;r=a.precision,s=a.rounding,a.precision=r+Math.max(n.e,n.sd())+4,a.rounding=1,(i=n.d.length)<32?e=(1/J(4,t=Math.ceil(i/3))).toString():(t=16,e="2.3283064365386962890625e-10"),n=K(a,1,n.times(e),new a(1),!0);for(var l,c=t,u=new a(8);c--;)l=n.times(n),n=o.minus(l.times(u.minus(l.times(u))));return D(n,a.precision=r,a.rounding=s,!0)},N.hyperbolicSine=N.sinh=function(){var t,e,r,s,i=this,n=i.constructor;if(!i.isFinite()||i.isZero())return new n(i);if(e=n.precision,r=n.rounding,n.precision=e+Math.max(i.e,i.sd())+4,n.rounding=1,(s=i.d.length)<3)i=K(n,2,i,i,!0);else{t=(t=1.4*Math.sqrt(s))>16?16:0|t,i=K(n,2,i=i.times(1/J(5,t)),i,!0);for(var a,o=new n(5),l=new n(16),c=new n(20);t--;)a=i.times(i),i=i.times(o.plus(a.times(l.times(a).plus(c))))}return n.precision=e,n.rounding=r,D(i,e,r,!0)},N.hyperbolicTangent=N.tanh=function(){var t,e,r=this,s=r.constructor;return r.isFinite()?r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+7,s.rounding=1,O(r.sinh(),r.cosh(),s.precision=t,s.rounding=e)):new s(r.s)},N.inverseCosine=N.acos=function(){var t=this,e=t.constructor,r=t.abs().cmp(1),s=e.precision,i=e.rounding;return-1!==r?0===r?t.isNeg()?V(e,s,i):new e(0):new e(NaN):t.isZero()?V(e,s+4,i).times(.5):(e.precision=s+6,e.rounding=1,t=new e(1).minus(t).div(t.plus(1)).sqrt().atan(),e.precision=s,e.rounding=i,t.times(2))},N.inverseHyperbolicCosine=N.acosh=function(){var t,e,r=this,s=r.constructor;return r.lte(1)?new s(r.eq(1)?0:NaN):r.isFinite()?(t=s.precision,e=s.rounding,s.precision=t+Math.max(Math.abs(r.e),r.sd())+4,s.rounding=1,m=!1,r=r.times(r).minus(1).sqrt().plus(r),m=!0,s.precision=t,s.rounding=e,r.ln()):new s(r)},N.inverseHyperbolicSine=N.asinh=function(){var t,e,r=this,s=r.constructor;return!r.isFinite()||r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+2*Math.max(Math.abs(r.e),r.sd())+6,s.rounding=1,m=!1,r=r.times(r).plus(1).sqrt().plus(r),m=!0,s.precision=t,s.rounding=e,r.ln())},N.inverseHyperbolicTangent=N.atanh=function(){var t,e,r,s,i=this,n=i.constructor;return i.isFinite()?i.e>=0?new n(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=n.precision,e=n.rounding,s=i.sd(),Math.max(s,t)<2*-i.e-1?D(new n(i),t,e,!0):(n.precision=r=s-i.e,i=O(i.plus(1),new n(1).minus(i),r+t,1),n.precision=t+4,n.rounding=1,i=i.ln(),n.precision=t,n.rounding=e,i.times(.5))):new n(NaN)},N.inverseSine=N.asin=function(){var t,e,r,s,i=this,n=i.constructor;return i.isZero()?new n(i):(e=i.abs().cmp(1),r=n.precision,s=n.rounding,-1!==e?0===e?((t=V(n,r+4,s).times(.5)).s=i.s,t):new n(NaN):(n.precision=r+6,n.rounding=1,i=i.div(new n(1).minus(i.times(i)).sqrt().plus(1)).atan(),n.precision=r,n.rounding=s,i.times(2)))},N.inverseTangent=N.atan=function(){var t,e,r,s,i,n,a,o,l,c=this,u=c.constructor,h=u.precision,d=u.rounding;if(c.isFinite()){if(c.isZero())return new u(c);if(c.abs().eq(1)&&h+4<=M)return(a=V(u,h+4,d).times(.25)).s=c.s,a}else{if(!c.s)return new u(NaN);if(h+4<=M)return(a=V(u,h+4,d).times(.5)).s=c.s,a}for(u.precision=o=h+10,u.rounding=1,t=r=Math.min(28,o/7+2|0);t;--t)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(m=!1,e=Math.ceil(o/7),s=1,l=c.times(c),a=new u(c),i=c;-1!==t;)if(i=i.times(l),n=a.minus(i.div(s+=2)),i=i.times(l),void 0!==(a=n.plus(i.div(s+=2))).d[e])for(t=e;a.d[t]===n.d[t]&&t--;);return r&&(a=a.times(2<<r-1)),m=!0,D(a,u.precision=h,u.rounding=d,!0)},N.isFinite=function(){return!!this.d},N.isInteger=N.isInt=function(){return!!this.d&&C(this.e/7)>this.d.length-2},N.isNaN=function(){return!this.s},N.isNegative=N.isNeg=function(){return this.s<0},N.isPositive=N.isPos=function(){return this.s>0},N.isZero=function(){return!!this.d&&0===this.d[0]},N.lessThan=N.lt=function(t){return this.cmp(t)<0},N.lessThanOrEqualTo=N.lte=function(t){return this.cmp(t)<1},N.logarithm=N.log=function(t){var e,r,s,i,n,a,o,l,c=this,u=c.constructor,h=u.precision,d=u.rounding;if(null==t)t=new u(10),e=!0;else{if(r=(t=new u(t)).d,t.s<0||!r||!r[0]||t.eq(1))return new u(NaN);e=t.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new u(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(e)if(r.length>1)n=!0;else{for(i=r[0];i%10==0;)i/=10;n=1!==i}if(m=!1,a=z(c,o=h+5),s=e?P(u,o+10):z(t,o),L((l=O(a,s,o,1)).d,i=h,d))do{if(a=z(c,o+=10),s=e?P(u,o+10):z(t,o),l=O(a,s,o,1),!n){+I(l.d).slice(i+1,i+15)+1==1e14&&(l=D(l,h+1,0));break}}while(L(l.d,i+=10,d));return m=!0,D(l,h,d)},N.minus=N.sub=function(t){var e,r,s,i,n,a,o,l,c,u,h,d,p=this,f=p.constructor;if(t=new f(t),!p.d||!t.d)return p.s&&t.s?p.d?t.s=-t.s:t=new f(t.d||p.s!==t.s?p:NaN):t=new f(NaN),t;if(p.s!=t.s)return t.s=-t.s,p.plus(t);if(c=p.d,d=t.d,o=f.precision,l=f.rounding,!c[0]||!d[0]){if(d[0])t.s=-t.s;else{if(!c[0])return new f(3===l?-0:0);t=new f(p)}return m?D(t,o,l):t}if(r=C(t.e/7),u=C(p.e/7),c=c.slice(),n=u-r){for((h=n<0)?(e=c,n=-n,a=d.length):(e=d,r=u,a=c.length),n>(s=Math.max(Math.ceil(o/7),a)+2)&&(n=s,e.length=1),e.reverse(),s=n;s--;)e.push(0);e.reverse()}else{for((h=(s=c.length)<(a=d.length))&&(a=s),s=0;s<a;s++)if(c[s]!=d[s]){h=c[s]<d[s];break}n=0}for(h&&(e=c,c=d,d=e,t.s=-t.s),a=c.length,s=d.length-a;s>0;--s)c[a++]=0;for(s=d.length;s>n;){if(c[--s]<d[s]){for(i=s;i&&0===c[--i];)c[i]=v-1;--c[i],c[s]+=v}c[s]-=d[s]}for(;0===c[--a];)c.pop();for(;0===c[0];c.shift())--r;return c[0]?(t.d=c,t.e=k(c,r),m?D(t,o,l):t):new f(3===l?-0:0)},N.modulo=N.mod=function(t){var e,r=this,s=r.constructor;return t=new s(t),!r.d||!t.s||t.d&&!t.d[0]?new s(NaN):!t.d||r.d&&!r.d[0]?D(new s(r),s.precision,s.rounding):(m=!1,9==s.modulo?(e=O(r,t.abs(),0,3,1)).s*=t.s:e=O(r,t,0,s.modulo,1),e=e.times(t),m=!0,r.minus(e))},N.naturalExponential=N.exp=function(){return j(this)},N.naturalLogarithm=N.ln=function(){return z(this)},N.negated=N.neg=function(){var t=new this.constructor(this);return t.s=-t.s,D(t)},N.plus=N.add=function(t){var e,r,s,i,n,a,o,l,c,u,h=this,d=h.constructor;if(t=new d(t),!h.d||!t.d)return h.s&&t.s?h.d||(t=new d(t.d||h.s===t.s?h:NaN)):t=new d(NaN),t;if(h.s!=t.s)return t.s=-t.s,h.minus(t);if(c=h.d,u=t.d,o=d.precision,l=d.rounding,!c[0]||!u[0])return u[0]||(t=new d(h)),m?D(t,o,l):t;if(n=C(h.e/7),s=C(t.e/7),c=c.slice(),i=n-s){for(i<0?(r=c,i=-i,a=u.length):(r=u,s=n,a=c.length),i>(a=(n=Math.ceil(o/7))>a?n+1:a+1)&&(i=a,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((a=c.length)-(i=u.length)<0&&(i=a,r=u,u=c,c=r),e=0;i;)e=(c[--i]=c[i]+u[i]+e)/v|0,c[i]%=v;for(e&&(c.unshift(e),++s),a=c.length;0==c[--a];)c.pop();return t.d=c,t.e=k(c,s),m?D(t,o,l):t},N.precision=N.sd=function(t){var e,r=this;if(void 0!==t&&t!==!!t&&1!==t&&0!==t)throw Error(f+t);return r.d?(e=U(r.d),t&&r.e+1>e&&(e=r.e+1)):e=NaN,e},N.round=function(){var t=this,e=t.constructor;return D(new e(t),t.e+1,e.rounding)},N.sine=N.sin=function(){var t,e,r=this,s=r.constructor;return r.isFinite()?r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+Math.max(r.e,r.sd())+7,s.rounding=1,r=function(t,e){var r,s=e.d.length;if(s<3)return e.isZero()?e:K(t,2,e,e);r=(r=1.4*Math.sqrt(s))>16?16:0|r,e=K(t,2,e=e.times(1/J(5,r)),e);for(var i,n=new t(5),a=new t(16),o=new t(20);r--;)i=e.times(e),e=e.times(n.plus(i.times(a.times(i).minus(o))));return e}(s,Z(s,r)),s.precision=t,s.rounding=e,D(a>2?r.neg():r,t,e,!0)):new s(NaN)},N.squareRoot=N.sqrt=function(){var t,e,r,s,i,n,a=this,o=a.d,l=a.e,c=a.s,u=a.constructor;if(1!==c||!o||!o[0])return new u(!c||c<0&&(!o||o[0])?NaN:o?a:1/0);for(m=!1,0==(c=Math.sqrt(+a))||c==1/0?(((e=I(o)).length+l)%2==0&&(e+="0"),c=Math.sqrt(e),l=C((l+1)/2)-(l<0||l%2),s=new u(e=c==1/0?"5e"+l:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+l)):s=new u(c.toString()),r=(l=u.precision)+3;;)if(s=(n=s).plus(O(a,n,r+2,1)).times(.5),I(n.d).slice(0,r)===(e=I(s.d)).slice(0,r)){if("9999"!=(e=e.slice(r-3,r+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(D(s,l+1,1),t=!s.times(s).eq(a));break}if(!i&&(D(n,l+1,0),n.times(n).eq(a))){s=n;break}r+=4,i=1}return m=!0,D(s,l,u.rounding,t)},N.tangent=N.tan=function(){var t,e,r=this,s=r.constructor;return r.isFinite()?r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+10,s.rounding=1,(r=r.sin()).s=1,r=O(r,new s(1).minus(r.times(r)).sqrt(),t+10,0),s.precision=t,s.rounding=e,D(2==a||4==a?r.neg():r,t,e,!0)):new s(NaN)},N.times=N.mul=function(t){var e,r,s,i,n,a,o,l,c,u=this,h=u.constructor,d=u.d,p=(t=new h(t)).d;if(t.s*=u.s,!(d&&d[0]&&p&&p[0]))return new h(!t.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:d&&p?0*t.s:t.s/0);for(r=C(u.e/7)+C(t.e/7),(l=d.length)<(c=p.length)&&(n=d,d=p,p=n,a=l,l=c,c=a),n=[],s=a=l+c;s--;)n.push(0);for(s=c;--s>=0;){for(e=0,i=l+s;i>s;)o=n[i]+p[s]*d[i-s-1]+e,n[i--]=o%v|0,e=o/v|0;n[i]=(n[i]+e)%v|0}for(;!n[--a];)n.pop();return e?++r:n.shift(),t.d=n,t.e=k(n,r),m?D(t,h.precision,h.rounding):t},N.toBinary=function(t,e){return X(this,2,t,e)},N.toDecimalPlaces=N.toDP=function(t,e){var r=this,s=r.constructor;return r=new s(r),void 0===t?r:(w(t,0,l),void 0===e?e=s.rounding:w(e,0,8),D(r,t+r.e+1,e))},N.toExponential=function(t,e){var r,s=this,i=s.constructor;return void 0===t?r=F(s,!0):(w(t,0,l),void 0===e?e=i.rounding:w(e,0,8),r=F(s=D(new i(s),t+1,e),!0,t+1)),s.isNeg()&&!s.isZero()?"-"+r:r},N.toFixed=function(t,e){var r,s,i=this,n=i.constructor;return void 0===t?r=F(i):(w(t,0,l),void 0===e?e=n.rounding:w(e,0,8),r=F(s=D(new n(i),t+i.e+1,e),!1,t+s.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},N.toFraction=function(t){var e,r,s,i,n,a,o,l,c,u,h,d,p=this,g=p.d,y=p.constructor;if(!g)return new y(p);if(c=r=new y(1),s=l=new y(0),a=(n=(e=new y(s)).e=U(g)-p.e-1)%7,e.d[0]=E(10,a<0?7+a:a),null==t)t=n>0?e:c;else{if(!(o=new y(t)).isInt()||o.lt(c))throw Error(f+o);t=o.gt(e)?n>0?e:c:o}for(m=!1,o=new y(I(g)),u=y.precision,y.precision=n=7*g.length*2;h=O(o,e,0,1,1),1!=(i=r.plus(h.times(s))).cmp(t);)r=s,s=i,i=c,c=l.plus(h.times(i)),l=i,i=e,e=o.minus(h.times(i)),o=i;return i=O(t.minus(r),s,0,1,1),l=l.plus(i.times(c)),r=r.plus(i.times(s)),l.s=c.s=p.s,d=O(c,s,n,1).minus(p).abs().cmp(O(l,r,n,1).minus(p).abs())<1?[c,s]:[l,r],y.precision=u,m=!0,d},N.toHexadecimal=N.toHex=function(t,e){return X(this,16,t,e)},N.toNearest=function(t,e){var r=this,s=r.constructor;if(r=new s(r),null==t){if(!r.d)return r;t=new s(1),e=s.rounding}else{if(t=new s(t),void 0===e?e=s.rounding:w(e,0,8),!r.d)return t.s?r:t;if(!t.d)return t.s&&(t.s=r.s),t}return t.d[0]?(m=!1,r=O(r,t,0,e,1).times(t),m=!0,D(r)):(t.s=r.s,r=t),r},N.toNumber=function(){return+this},N.toOctal=function(t,e){return X(this,8,t,e)},N.toPower=N.pow=function(t){var e,r,s,i,n,a,o=this,l=o.constructor,c=+(t=new l(t));if(!(o.d&&t.d&&o.d[0]&&t.d[0]))return new l(E(+o,c));if((o=new l(o)).eq(1))return o;if(s=l.precision,n=l.rounding,t.eq(1))return D(o,s,n);if((e=C(t.e/7))>=t.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=B(l,o,r,s),t.s<0?new l(1).div(i):D(i,s,n);if((a=o.s)<0){if(e<t.d.length-1)return new l(NaN);if(1&t.d[e]||(a=1),0==o.e&&1==o.d[0]&&1==o.d.length)return o.s=a,o}return(e=0!=(r=E(+o,c))&&isFinite(r)?new l(r+"").e:C(c*(Math.log("0."+I(o.d))/Math.LN10+o.e+1)))>l.maxE+1||e<l.minE-1?new l(e>0?a/0:0):(m=!1,l.rounding=o.s=1,r=Math.min(12,(e+"").length),(i=j(t.times(z(o,s+r)),s)).d&&L((i=D(i,s+5,1)).d,s,n)&&(e=s+10,+I((i=D(j(t.times(z(o,e+r)),e),e+5,1)).d).slice(s+1,s+15)+1==1e14&&(i=D(i,s+1,0))),i.s=a,m=!0,l.rounding=n,D(i,s,n))},N.toPrecision=function(t,e){var r,s=this,i=s.constructor;return void 0===t?r=F(s,s.e<=i.toExpNeg||s.e>=i.toExpPos):(w(t,1,l),void 0===e?e=i.rounding:w(e,0,8),r=F(s=D(new i(s),t,e),t<=s.e||s.e<=i.toExpNeg,t)),s.isNeg()&&!s.isZero()?"-"+r:r},N.toSignificantDigits=N.toSD=function(t,e){var r=this.constructor;return void 0===t?(t=r.precision,e=r.rounding):(w(t,1,l),void 0===e?e=r.rounding:w(e,0,8)),D(new r(this),t,e)},N.toString=function(){var t=this,e=t.constructor,r=F(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+r:r},N.truncated=N.trunc=function(){return D(new this.constructor(this),this.e+1,1)},N.valueOf=N.toJSON=function(){var t=this,e=t.constructor,r=F(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+r:r};var O=function(){function t(t,e,r){var s,i=0,n=t.length;for(t=t.slice();n--;)s=t[n]*e+i,t[n]=s%r|0,i=s/r|0;return i&&t.unshift(i),t}function e(t,e,r,s){var i,n;if(r!=s)n=r>s?1:-1;else for(i=n=0;i<r;i++)if(t[i]!=e[i]){n=t[i]>e[i]?1:-1;break}return n}function r(t,e,r,s){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*s+t[r]-e[r];for(;!t[0]&&t.length>1;)t.shift()}return function(s,i,a,o,l,c){var u,h,d,m,p,f,g,y,x,E,A,_,S,T,b,M,N,I,w,L,R=s.constructor,O=s.s==i.s?1:-1,F=s.d,k=i.d;if(!(F&&F[0]&&k&&k[0]))return new R(s.s&&i.s&&(F?!k||F[0]!=k[0]:k)?F&&0==F[0]||!k?0*O:O/0:NaN);for(c?(p=1,h=s.e-i.e):(c=v,p=7,h=C(s.e/p)-C(i.e/p)),w=k.length,N=F.length,E=(x=new R(O)).d=[],d=0;k[d]==(F[d]||0);d++);if(k[d]>(F[d]||0)&&h--,null==a?(T=a=R.precision,o=R.rounding):T=l?a+(s.e-i.e)+1:a,T<0)E.push(1),f=!0;else{if(T=T/p+2|0,d=0,1==w){for(m=0,k=k[0],T++;(d<N||m)&&T--;d++)b=m*c+(F[d]||0),E[d]=b/k|0,m=b%k|0;f=m||d<N}else{for((m=c/(k[0]+1)|0)>1&&(k=t(k,m,c),F=t(F,m,c),w=k.length,N=F.length),M=w,_=(A=F.slice(0,w)).length;_<w;)A[_++]=0;(L=k.slice()).unshift(0),I=k[0],k[1]>=c/2&&++I;do{m=0,(u=e(k,A,w,_))<0?(S=A[0],w!=_&&(S=S*c+(A[1]||0)),(m=S/I|0)>1?(m>=c&&(m=c-1),1==(u=e(g=t(k,m,c),A,y=g.length,_=A.length))&&(m--,r(g,w<y?L:k,y,c))):(0==m&&(u=m=1),g=k.slice()),(y=g.length)<_&&g.unshift(0),r(A,g,_,c),-1==u&&(u=e(k,A,w,_=A.length))<1&&(m++,r(A,w<_?L:k,_,c)),_=A.length):0===u&&(m++,A=[0]),E[d++]=m,u&&A[0]?A[_++]=F[M]||0:(A=[F[M]],_=1)}while((M++<N||void 0!==A[0])&&T--);f=void 0!==A[0]}E[0]||E.shift()}if(1==p)x.e=h,n=f;else{for(d=1,m=E[0];m>=10;m/=10)d++;x.e=d+h*p-1,D(x,l?a+x.e+1:a,o,f)}return x}}();function D(t,e,r,s){var i,n,a,o,l,c,u,h,d,p=t.constructor;t:if(null!=e){if(!(h=t.d))return t;for(i=1,o=h[0];o>=10;o/=10)i++;if((n=e-i)<0)n+=7,a=e,l=(u=h[d=0])/E(10,i-a-1)%10|0;else if((d=Math.ceil((n+1)/7))>=(o=h.length)){if(!s)break t;for(;o++<=d;)h.push(0);u=l=0,i=1,a=(n%=7)-7+1}else{for(u=o=h[d],i=1;o>=10;o/=10)i++;l=(a=(n%=7)-7+i)<0?0:u/E(10,i-a-1)%10|0}if(s=s||e<0||void 0!==h[d+1]||(a<0?u:u%E(10,i-a-1)),c=r<4?(l||s)&&(0==r||r==(t.s<0?3:2)):l>5||5==l&&(4==r||s||6==r&&(n>0?a>0?u/E(10,i-a):0:h[d-1])%10&1||r==(t.s<0?8:7)),e<1||!h[0])return h.length=0,c?(e-=t.e+1,h[0]=E(10,(7-e%7)%7),t.e=-e||0):h[0]=t.e=0,t;if(0==n?(h.length=d,o=1,d--):(h.length=d+1,o=E(10,7-n),h[d]=a>0?(u/E(10,i-a)%E(10,a)|0)*o:0),c)for(;;){if(0==d){for(n=1,a=h[0];a>=10;a/=10)n++;for(a=h[0]+=o,o=1;a>=10;a/=10)o++;n!=o&&(t.e++,h[0]==v&&(h[0]=1));break}if(h[d]+=o,h[d]!=v)break;h[d--]=0,o=1}for(n=h.length;0===h[--n];)h.pop()}return m&&(t.e>p.maxE?(t.d=null,t.e=NaN):t.e<p.minE&&(t.e=0,t.d=[0])),t}function F(t,e,r){if(!t.isFinite())return G(t);var s,i=t.e,n=I(t.d),a=n.length;return e?(r&&(s=r-a)>0?n=n.charAt(0)+"."+n.slice(1)+$(s):a>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(t.e<0?"e":"e+")+t.e):i<0?(n="0."+$(-i-1)+n,r&&(s=r-a)>0&&(n+=$(s))):i>=a?(n+=$(i+1-a),r&&(s=r-i-1)>0&&(n=n+"."+$(s))):((s=i+1)<a&&(n=n.slice(0,s)+"."+n.slice(s)),r&&(s=r-a)>0&&(i+1===a&&(n+="."),n+=$(s))),n}function k(t,e){var r=t[0];for(e*=7;r>=10;r/=10)e++;return e}function P(t,e,r){if(e>b)throw m=!0,r&&(t.precision=r),Error(g);return D(new t(u),e,1,!0)}function V(t,e,r){if(e>M)throw Error(g);return D(new t(h),e,r,!0)}function U(t){var e=t.length-1,r=7*e+1;if(e=t[e]){for(;e%10==0;e/=10)r--;for(e=t[0];e>=10;e/=10)r++}return r}function $(t){for(var e="";t--;)e+="0";return e}function B(t,e,r,s){var i,n=new t(1),a=Math.ceil(s/7+4);for(m=!1;;){if(r%2&&Y((n=n.times(e)).d,a)&&(i=!0),0===(r=C(r/2))){r=n.d.length-1,i&&0===n.d[r]&&++n.d[r];break}Y((e=e.times(e)).d,a)}return m=!0,n}function H(t){return 1&t.d[t.d.length-1]}function q(t,e,r){for(var s,i,n=new t(e[0]),a=0;++a<e.length;){if(!(i=new t(e[a])).s){n=i;break}((s=n.cmp(i))===r||0===s&&n.s===r)&&(n=i)}return n}function j(t,e){var r,s,i,n,a,o,l,c=0,u=0,h=0,d=t.constructor,p=d.rounding,f=d.precision;if(!t.d||!t.d[0]||t.e>17)return new d(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:NaN);for(null==e?(m=!1,l=f):l=e,o=new d(.03125);t.e>-2;)t=t.times(o),h+=5;for(l+=s=Math.log(E(2,h))/Math.LN10*2+5|0,r=n=a=new d(1),d.precision=l;;){if(n=D(n.times(t),l,1),r=r.times(++u),I((o=a.plus(O(n,r,l,1))).d).slice(0,l)===I(a.d).slice(0,l)){for(i=h;i--;)a=D(a.times(a),l,1);if(null!=e)return d.precision=f,a;if(!(c<3&&L(a.d,l-s,p,c)))return D(a,d.precision=f,p,m=!0);d.precision=l+=10,r=n=o=new d(1),u=0,c++}a=o}}function z(t,e){var r,s,i,n,a,o,l,c,u,h,d,p=1,f=t,g=f.d,y=f.constructor,x=y.rounding,C=y.precision;if(f.s<0||!g||!g[0]||!f.e&&1==g[0]&&1==g.length)return new y(g&&!g[0]?-1/0:1!=f.s?NaN:g?0:f);if(null==e?(m=!1,u=C):u=e,y.precision=u+=10,s=(r=I(g)).charAt(0),!(Math.abs(n=f.e)<15e14))return c=P(y,u+2,C).times(n+""),f=z(new y(s+"."+r.slice(1)),u-10).plus(c),y.precision=C,null==e?D(f,C,x,m=!0):f;for(;s<7&&1!=s||1==s&&r.charAt(1)>3;)s=(r=I((f=f.times(t)).d)).charAt(0),p++;for(n=f.e,s>1?(f=new y("0."+r),n++):f=new y(s+"."+r.slice(1)),h=f,l=a=f=O(f.minus(1),f.plus(1),u,1),d=D(f.times(f),u,1),i=3;;){if(a=D(a.times(d),u,1),I((c=l.plus(O(a,new y(i),u,1))).d).slice(0,u)===I(l.d).slice(0,u)){if(l=l.times(2),0!==n&&(l=l.plus(P(y,u+2,C).times(n+""))),l=O(l,new y(p),u,1),null!=e)return y.precision=C,l;if(!L(l.d,u-10,x,o))return D(l,y.precision=C,x,m=!0);y.precision=u+=10,c=a=f=O(h.minus(1),h.plus(1),u,1),d=D(f.times(f),u,1),i=o=1}l=c,i+=2}}function G(t){return String(t.s*t.s/0)}function W(t,e){var r,s,i;for((r=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(r<0&&(r=s),r+=+e.slice(s+1),e=e.substring(0,s)):r<0&&(r=e.length),s=0;48===e.charCodeAt(s);s++);for(i=e.length;48===e.charCodeAt(i-1);--i);if(e=e.slice(s,i)){if(i-=s,t.e=r=r-s-1,t.d=[],s=(r+1)%7,r<0&&(s+=7),s<i){for(s&&t.d.push(+e.slice(0,s)),i-=7;s<i;)t.d.push(+e.slice(s,s+=7));s=7-(e=e.slice(s)).length}else s-=i;for(;s--;)e+="0";t.d.push(+e),m&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function Q(t,e){var r,s,n,a,o,l,c,u,h;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),T.test(e))return W(t,e)}else if("Infinity"===e||"NaN"===e)return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(_.test(e))r=16,e=e.toLowerCase();else if(A.test(e))r=2;else{if(!S.test(e))throw Error(f+e);r=8}for((a=e.search(/p/i))>0?(c=+e.slice(a+1),e=e.substring(2,a)):e=e.slice(2),o=(a=e.indexOf("."))>=0,s=t.constructor,o&&(a=(l=(e=e.replace(".","")).length)-a,n=B(s,new s(r),a,2*a)),a=h=(u=R(e,r,v)).length-1;0===u[a];--a)u.pop();return a<0?new s(0*t.s):(t.e=k(u,h),t.d=u,m=!1,o&&(t=O(t,n,4*l)),c&&(t=t.times(Math.abs(c)<54?E(2,c):i.pow(2,c))),m=!0,t)}function K(t,e,r,s,i){var n,a,o,l,c=t.precision,u=Math.ceil(c/7);for(m=!1,l=r.times(r),o=new t(s);;){if(a=O(o.times(l),new t(e++*e++),c,1),o=i?s.plus(a):s.minus(a),s=O(a.times(l),new t(e++*e++),c,1),void 0!==(a=o.plus(s)).d[u]){for(n=u;a.d[n]===o.d[n]&&n--;);if(-1==n)break}n=o,o=s,s=a,a=n}return m=!0,a.d.length=u+1,a}function J(t,e){for(var r=t;--e;)r*=t;return r}function Z(t,e){var r,s=e.s<0,i=V(t,t.precision,1),n=i.times(.5);if((e=e.abs()).lte(n))return a=s?4:1,e;if((r=e.divToInt(i)).isZero())a=s?3:2;else{if((e=e.minus(r.times(i))).lte(n))return a=H(r)?s?2:3:s?4:1,e;a=H(r)?s?1:4:s?3:2}return e.minus(i).abs()}function X(t,e,r,s){var i,a,o,u,h,d,m,p,f,g=t.constructor,y=void 0!==r;if(y?(w(r,1,l),void 0===s?s=g.rounding:w(s,0,8)):(r=g.precision,s=g.rounding),t.isFinite()){for(y?(i=2,16==e?r=4*r-3:8==e&&(r=3*r-2)):i=e,(o=(m=F(t)).indexOf("."))>=0&&(m=m.replace(".",""),(f=new g(1)).e=m.length-o,f.d=R(F(f),10,i),f.e=f.d.length),a=h=(p=R(m,10,i)).length;0==p[--h];)p.pop();if(p[0]){if(o<0?a--:((t=new g(t)).d=p,t.e=a,p=(t=O(t,f,r,s,0,i)).d,a=t.e,d=n),o=p[r],u=i/2,d=d||void 0!==p[r+1],d=s<4?(void 0!==o||d)&&(0===s||s===(t.s<0?3:2)):o>u||o===u&&(4===s||d||6===s&&1&p[r-1]||s===(t.s<0?8:7)),p.length=r,d)for(;++p[--r]>i-1;)p[r]=0,r||(++a,p.unshift(1));for(h=p.length;!p[h-1];--h);for(o=0,m="";o<h;o++)m+=c.charAt(p[o]);if(y){if(h>1)if(16==e||8==e){for(o=16==e?4:3,--h;h%o;h++)m+="0";for(h=(p=R(m,i,e)).length;!p[h-1];--h);for(o=1,m="1.";o<h;o++)m+=c.charAt(p[o])}else m=m.charAt(0)+"."+m.slice(1);m=m+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)m="0"+m;m="0."+m}else if(++a>h)for(a-=h;a--;)m+="0";else a<h&&(m=m.slice(0,a)+"."+m.slice(a))}else m=y?"0p+0":"0";m=(16==e?"0x":2==e?"0b":8==e?"0o":"")+m}else m=G(t);return t.s<0?"-"+m:m}function Y(t,e){if(t.length>e)return t.length=e,!0}function tt(t){return new this(t).abs()}function et(t){return new this(t).acos()}function rt(t){return new this(t).acosh()}function st(t,e){return new this(t).plus(e)}function it(t){return new this(t).asin()}function nt(t){return new this(t).asinh()}function at(t){return new this(t).atan()}function ot(t){return new this(t).atanh()}function lt(t,e){t=new this(t),e=new this(e);var r,s=this.precision,i=this.rounding,n=s+4;return t.s&&e.s?t.d||e.d?!e.d||t.isZero()?(r=e.s<0?V(this,s,i):new this(0)).s=t.s:!t.d||e.isZero()?(r=V(this,n,1).times(.5)).s=t.s:e.s<0?(this.precision=n,this.rounding=1,r=this.atan(O(t,e,n,1)),e=V(this,n,1),this.precision=s,this.rounding=i,r=t.s<0?r.minus(e):r.plus(e)):r=this.atan(O(t,e,n,1)):(r=V(this,n,1).times(e.s>0?.25:.75)).s=t.s:r=new this(NaN),r}function ct(t){return new this(t).cbrt()}function ut(t){return D(t=new this(t),t.e+1,2)}function ht(t,e,r){return new this(t).clamp(e,r)}function dt(t){if(!t||"object"!=typeof t)throw Error(p+"Object expected");var e,r,s,i=!0===t.defaults,n=["precision",1,l,"rounding",0,8,"toExpNeg",-o,0,"toExpPos",0,o,"maxE",0,o,"minE",-o,0,"modulo",0,9];for(e=0;e<n.length;e+=3)if(r=n[e],i&&(this[r]=d[r]),void 0!==(s=t[r])){if(!(C(s)===s&&s>=n[e+1]&&s<=n[e+2]))throw Error(f+r+": "+s);this[r]=s}if(r="crypto",i&&(this[r]=d[r]),void 0!==(s=t[r])){if(!0!==s&&!1!==s&&0!==s&&1!==s)throw Error(f+r+": "+s);if(s){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(y);this[r]=!0}else this[r]=!1}return this}function mt(t){return new this(t).cos()}function pt(t){return new this(t).cosh()}function ft(t,e){return new this(t).div(e)}function gt(t){return new this(t).exp()}function yt(t){return D(t=new this(t),t.e+1,3)}function xt(){var t,e,r=new this(0);for(m=!1,t=0;t<arguments.length;)if((e=new this(arguments[t++])).d)r.d&&(r=r.plus(e.times(e)));else{if(e.s)return m=!0,new this(1/0);r=e}return m=!0,r.sqrt()}function Ct(t){return t instanceof i||t&&t.toStringTag===x||!1}function Et(t){return new this(t).ln()}function At(t,e){return new this(t).log(e)}function _t(t){return new this(t).log(2)}function St(t){return new this(t).log(10)}function Tt(){return q(this,arguments,-1)}function vt(){return q(this,arguments,1)}function bt(t,e){return new this(t).mod(e)}function Mt(t,e){return new this(t).mul(e)}function Nt(t,e){return new this(t).pow(e)}function It(t){var e,r,s,i,n=0,a=new this(1),o=[];if(void 0===t?t=this.precision:w(t,1,l),s=Math.ceil(t/7),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(s));n<s;)(i=e[n])>=429e7?e[n]=crypto.getRandomValues(new Uint32Array(1))[0]:o[n++]=i%1e7;else{if(!crypto.randomBytes)throw Error(y);for(e=crypto.randomBytes(s*=4);n<s;)(i=e[n]+(e[n+1]<<8)+(e[n+2]<<16)+((127&e[n+3])<<24))>=214e7?crypto.randomBytes(4).copy(e,n):(o.push(i%1e7),n+=4);n=s/4}else for(;n<s;)o[n++]=1e7*Math.random()|0;for(t%=7,(s=o[--n])&&t&&(i=E(10,7-t),o[n]=(s/i|0)*i);0===o[n];n--)o.pop();if(n<0)r=0,o=[0];else{for(r=-1;0===o[0];r-=7)o.shift();for(s=1,i=o[0];i>=10;i/=10)s++;s<7&&(r-=7-s)}return a.e=r,a.d=o,a}function wt(t){return D(t=new this(t),t.e+1,this.rounding)}function Lt(t){return(t=new this(t)).d?t.d[0]?t.s:0*t.s:t.s||NaN}function Rt(t){return new this(t).sin()}function Ot(t){return new this(t).sinh()}function Dt(t){return new this(t).sqrt()}function Ft(t,e){return new this(t).sub(e)}function kt(){var t=0,e=arguments,r=new this(e[t]);for(m=!1;r.s&&++t<e.length;)r=r.plus(e[t]);return m=!0,D(r,this.precision,this.rounding)}function Pt(t){return new this(t).tan()}function Vt(t){return new this(t).tanh()}function Ut(t){return D(t=new this(t),t.e+1,1)}(i=function t(e){var r,s,i;function n(t){var e,r,s,i=this;if(!(i instanceof n))return new n(t);if(i.constructor=n,Ct(t))return i.s=t.s,void(m?!t.d||t.e>n.maxE?(i.e=NaN,i.d=null):t.e<n.minE?(i.e=0,i.d=[0]):(i.e=t.e,i.d=t.d.slice()):(i.e=t.e,i.d=t.d?t.d.slice():t.d));if("number"==(s=typeof t)){if(0===t)return i.s=1/t<0?-1:1,i.e=0,void(i.d=[0]);if(t<0?(t=-t,i.s=-1):i.s=1,t===~~t&&t<1e7){for(e=0,r=t;r>=10;r/=10)e++;return void(m?e>n.maxE?(i.e=NaN,i.d=null):e<n.minE?(i.e=0,i.d=[0]):(i.e=e,i.d=[t]):(i.e=e,i.d=[t]))}return 0*t!=0?(t||(i.s=NaN),i.e=NaN,void(i.d=null)):W(i,t.toString())}if("string"===s)return 45===(r=t.charCodeAt(0))?(t=t.slice(1),i.s=-1):(43===r&&(t=t.slice(1)),i.s=1),T.test(t)?W(i,t):Q(i,t);if("bigint"===s)return t<0?(t=-t,i.s=-1):i.s=1,W(i,t.toString());throw Error(f+t)}if(n.prototype=N,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=dt,n.clone=t,n.isDecimal=Ct,n.abs=tt,n.acos=et,n.acosh=rt,n.add=st,n.asin=it,n.asinh=nt,n.atan=at,n.atanh=ot,n.atan2=lt,n.cbrt=ct,n.ceil=ut,n.clamp=ht,n.cos=mt,n.cosh=pt,n.div=ft,n.exp=gt,n.floor=yt,n.hypot=xt,n.ln=Et,n.log=At,n.log10=St,n.log2=_t,n.max=Tt,n.min=vt,n.mod=bt,n.mul=Mt,n.pow=Nt,n.random=It,n.round=wt,n.sign=Lt,n.sin=Rt,n.sinh=Ot,n.sqrt=Dt,n.sub=Ft,n.sum=kt,n.tan=Pt,n.tanh=Vt,n.trunc=Ut,void 0===e&&(e={}),e&&!0!==e.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<i.length;)e.hasOwnProperty(s=i[r++])||(e[s]=this[s]);return n.config(e),n}(d)).prototype.constructor=i,i.default=i.Decimal=i,u=new i(u),h=new i(h),void 0===(s=function(){return i}.call(e,r,e,t))||(t.exports=s)}()},6109(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AST=void 0;const s=r(5956),i=r(845),n=r(1271),a=r(7679),o=["+","-",".*","*","./","/",".\\","\\",".^","^",".**","**","<","<=","==",">=",">","!=","~=","&","|","&&","||","=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","()","!","~","+_","-_","++_","--_",".'","'","_++","_--"],l=["+","-",".*","*","./","/",".\\","\\",".^","^",".**","**","<","<=","==",">=",">","!=","~=","&","|","&&","||","=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="],c=["()","!","~","+_","-_","++_","--_"],u=[".'","'","_++","_--"];class h{static nodeString=s.CharString.create;static nodeNumber=i.Complex.parse;static firstRow=a.MultiArray.firstRow;static appendRow=a.MultiArray.appendRow;static emptyArray=a.MultiArray.emptyArray;static reload=()=>{h.nodeString=s.CharString.create,h.nodeNumber=i.Complex.parse,h.firstRow=a.MultiArray.firstRow,h.appendRow=a.MultiArray.appendRow,h.emptyArray=a.MultiArray.emptyArray};static nodeCopy=t=>Object.assign({},t);static isNodeBase=t=>{if("object"!=typeof t||null===t||!("type"in t))return!1;const e=Reflect.get(t,"type");return"string"==typeof e||"number"==typeof e};static isNodeIdentifier=t=>h.isNodeBase(t)&&"IDENT"===t.type&&"string"==typeof Reflect.get(t,"id");static isNodeList=t=>h.isNodeBase(t)&&"LIST"===t.type&&Array.isArray(Reflect.get(t,"list"));static isNodeCmdWList=t=>h.isNodeBase(t)&&"CMDWLIST"===t.type&&"string"==typeof Reflect.get(t,"id")&&Array.isArray(Reflect.get(t,"args"));static isNodeIndexExpr=t=>h.isNodeBase(t)&&"IDX"===t.type&&("()"===Reflect.get(t,"delim")||"{}"===Reflect.get(t,"delim"))&&Array.isArray(Reflect.get(t,"args"));static isNodeSuperclassConstructor=t=>h.isNodeBase(t)&&"SUPERCLASS_CTOR"===t.type&&h.isNodeIdentifier(Reflect.get(t,"superclass"))&&Array.isArray(Reflect.get(t,"args"));static isNodeRange=t=>h.isNodeBase(t)&&"RANGE"===t.type&&"start_"in t&&"stop_"in t;static isNodeColon=t=>h.isNodeBase(t)&&":"===t.type;static isNodeEndRange=t=>h.isNodeBase(t)&&"ENDRANGE"===t.type;static isNodeIndirectRef=t=>h.isNodeBase(t)&&"."===t.type&&Array.isArray(Reflect.get(t,"field"));static isNodeReturnList=t=>h.isNodeBase(t)&&"RETLIST"===t.type&&"function"==typeof Reflect.get(t,"selector")&&"function"==typeof Reflect.get(t,"handler");static isNodeIgnoredTarget=t=>h.isNodeBase(t)&&"<~>"===t.type;static isNodeOperation=t=>h.isNodeBase(t)&&o.includes(t.type);static isNodeBinaryOperation=t=>h.isNodeOperation(t)&&l.includes(t.type)&&"left"in t&&"right"in t;static isNodePrefixOperation=t=>h.isNodeOperation(t)&&c.includes(t.type)&&"right"in t;static isNodePostfixOperation=t=>h.isNodeOperation(t)&&u.includes(t.type)&&"left"in t;static isNodeFunctionReturn=t=>h.isNodeIdentifier(t)||h.isNodeIgnoredTarget(t);static isNodeDeclarationElement=t=>h.isNodeIdentifier(t)||h.isNodeDefaultedParameter(t);static isNodeDefaultedParameter=t=>h.isNodeBinaryOperation(t)&&"="===t.type&&h.isNodeIdentifier(t.left);static isNodeFunctionParameter=t=>h.isNodeIdentifier(t)||h.isNodeIgnoredTarget(t)||h.isNodeDefaultedParameter(t);static isNodeAssignmentTarget=t=>h.isNodeIdentifier(t)||h.isNodeIgnoredTarget(t)||h.isNodeIndexExpr(t)||h.isNodeIndirectRef(t)||a.MultiArray.isInstanceOf(t);static isNodeDeclaration=t=>h.isNodeBase(t)&&("GLOBAL"===t.type||"PERSIST"===t.type);static isNodeImport=t=>h.isNodeBase(t)&&"IMPORT"===t.type&&Array.isArray(t.imports);static isNodeStatement=t=>h.isNodeDeclaration(t)||h.isNodeImport(t)||h.isNodeBase(t)&&("RETURN"===t.type||"BREAK"===t.type||"CONTINUE"===t.type||"IF"===t.type||"SWITCH"===t.type||"WHILE"===t.type||"DO_UNTIL"===t.type||"FOR"===t.type||"SPMD"===t.type||"TRY"===t.type||"UNWIND_PROTECT"===t.type)||h.isNodeFunctionDefinition(t)||h.isNodeClassDef(t);static isNodeClassMember=t=>h.isNodeClassSection(t)||h.isNodeClassAttribute(t)||h.isNodeClassProperty(t)||h.isNodeClassEvent(t)||h.isNodeClassEnumeration(t);static isNodeProgramElement=t=>h.isStrictNodeExpr(t)||h.isNodeStatement(t)||h.isNodeClassMember(t);static isNodeFunctionDefinition=t=>h.isNodeBase(t)&&"FCNDEF"===t.type;static isNodeClassDef=t=>h.isNodeBase(t)&&"CLASSDEF"===t.type;static isNodeMetaClass=t=>h.isNodeBase(t)&&"METACLASS"===t.type&&h.isNodeIdentifier(t.className);static isRuntimeExpressionValue=t=>null!=t&&(a.MultiArray.isInstanceOf(t)||i.Complex.isInstanceOf(t)||s.CharString.isInstanceOf(t)||"object"==typeof t&&"number"==typeof t.type);static isStrictNodeExpr=t=>h.isRuntimeExpressionValue(t)||h.isNodeBase(t)&&("VOID"===t.type||h.isNodeIdentifier(t)||h.isNodeCmdWList(t)||h.isNodeIndexExpr(t)||h.isNodeSuperclassConstructor(t)||h.isNodeMetaClass(t)||h.isNodeRange(t)||h.isNodeColon(t)||h.isNodeEndRange(t)||h.isNodeOperation(t)||h.isNodeIgnoredTarget(t)||h.isNodeIndirectRef(t)||h.isNodeImport(t)||h.isNodeReturnList(t));static isExpressionBoundaryValue=t=>h.isStrictNodeExpr(t)||h.isNodeList(t);static requireStrictNodeExpr=(t,e="expression")=>{if(!h.isStrictNodeExpr(t))throw new TypeError(`${e} is not an expression node.`);return t};static isNodeArguments=t=>h.isNodeBase(t)&&"ARGS"===t.type&&Array.isArray(t.validation);static isNodeArgumentValidation=t=>h.isNodeBase(t)&&"ARGVALID"===t.type&&"name"in t&&Array.isArray(t.size);static isNodeSwitchCase=t=>h.isNodeBase(t)&&"CASE"===t.type;static isNodeClassSection=t=>h.isNodeBase(t)&&"CLASS_SECTION"===t.type;static isNodeClassAttribute=t=>h.isNodeBase(t)&&"CLASS_ATTRIBUTE"===t.type;static isNodeClassProperty=t=>h.isNodeBase(t)&&"CLASS_PROPERTY"===t.type;static isNodeClassEvent=t=>h.isNodeBase(t)&&"CLASS_EVENT"===t.type;static isNodeClassEnumeration=t=>h.isNodeBase(t)&&"CLASS_ENUMERATION"===t.type;static nodeVoid=()=>({type:"VOID",omitAnswer:!0,omitOutput:!0});static nodeIdentifier=t=>({type:"IDENT",id:t.replace(/(\r\n|[\n\r])|[\ ]/gm,""),omitAnswer:!1,omitOutput:!1});static nodeMetaClass=t=>{const e={type:"METACLASS",className:t,omitAnswer:!1,omitOutput:!1};return e.className.parent=e,e};static factoryExpression=(t,e,r=!1)=>r&&h.isNodeList(t)?t:h.requireStrictNodeExpr(t,e);static factoryExpressionList=(t,e)=>t?t.list.map((t,r)=>h.factoryExpression(t,`${e}${r+1}`)):[];static factoryCommandWordList=(t,e)=>t?t.list.map((t,r)=>{if(!s.CharString.isInstanceOf(t))throw new TypeError(`${e}${r+1} is not a command word.`);return t}):[];static factoryNodeList=(t,e,r)=>t.list.map((t,s)=>{if(!e(t))throw new TypeError(`${r}${s+1} has invalid node type.`);return t});static factoryProgramElementList=(t,e)=>h.factoryNodeList(t,h.isNodeProgramElement,e);static factoryArrayElementList=(t,e)=>h.factoryExpressionList(t,e);static factoryArgumentClass=(t,e)=>{if(null===t||h.isNodeList(t)&&0===t.list.length)return t;if(!h.isNodeIdentifier(t)&&!h.isNodeMetaClass(t))throw new TypeError(`${e} has invalid node type.`);return t};static nodeCmdWList=(t,e)=>{const r={type:"CMDWLIST",id:t.id,args:h.factoryCommandWordList(e,"command argument ")};return t.parent=r,r.args.forEach(t=>{t.parent=r}),r.omitAnswer=!0,r.omitOutput=!1,r};static nodeIndexExpr=(t,e=null,r="()")=>{const s={type:"IDX",expr:h.factoryExpression(t,"indexed expression"),args:h.factoryExpressionList(e,"index argument "),delim:r,omitAnswer:!1,omitOutput:!1};return s.expr.parent=s,s.args.forEach((t,e)=>{h.isNodeBase(t)&&(t.parent=s,t.index=e)}),s};static nodeSuperclassConstructor=(t,e,r=null)=>{const s={type:"SUPERCLASS_CTOR",instance:h.factoryExpression(t,"superclass constructor instance"),superclass:e,args:h.factoryExpressionList(r,"superclass constructor argument "),omitAnswer:!1,omitOutput:!1};return s.instance.parent=s,s.superclass.parent=s,s.args.forEach(t=>{h.isNodeBase(t)&&(t.parent=s)}),s};static nodeRange=(t,e,r)=>{const s={type:"RANGE",start_:h.factoryExpression(t,"range start"),stop_:h.factoryExpression(e,"range stop"),stride_:r?h.factoryExpression(r,"range stride"):null,omitAnswer:!1,omitOutput:!1};return s.start_.parent=s,s.stop_.parent=s,r&&(s.stride_.parent=s),s};static nodeColon=()=>({type:":",omitAnswer:!1,omitOutput:!1});static nodeEndRange=()=>({type:"ENDRANGE",omitAnswer:!1,omitOutput:!1});static omitAnswerNodeOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","++_","--_","_++","_--"]);static assignmentNodeOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="]);static anonymousFunctionForbiddenOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","++_","--_","_++","_--"]);static assertAnonymousFunctionExpression=t=>{if(h.isNodeOperation(t)&&h.anonymousFunctionForbiddenOperation.has(t.type))throw new SyntaxError("anonymous function bodies cannot contain assignment, increment, or decrement operators.");h.isNodeBinaryOperation(t)?(h.assertAnonymousFunctionExpression(t.left),h.assertAnonymousFunctionExpression(t.right)):h.isNodePrefixOperation(t)?h.assertAnonymousFunctionExpression(t.right):h.isNodePostfixOperation(t)?h.assertAnonymousFunctionExpression(t.left):h.isNodeIndexExpr(t)?(h.assertAnonymousFunctionExpression(t.expr),t.args.forEach(h.assertAnonymousFunctionExpression)):h.isNodeSuperclassConstructor(t)?(h.assertAnonymousFunctionExpression(t.instance),t.args.forEach(h.assertAnonymousFunctionExpression)):h.isNodeRange(t)?(h.assertAnonymousFunctionExpression(t.start_),h.assertAnonymousFunctionExpression(t.stop_),t.stride_&&h.assertAnonymousFunctionExpression(t.stride_)):h.isNodeIndirectRef(t)?(h.assertAnonymousFunctionExpression(t.obj),t.field.forEach(t=>{"string"!=typeof t&&h.assertAnonymousFunctionExpression(t)})):h.isNodeList(t)?t.list.forEach(h.assertAnonymousFunctionExpression):a.MultiArray.isInstanceOf(t)?a.MultiArray.linearize(t).forEach(h.assertAnonymousFunctionExpression):n.FunctionHandle.isInstanceOf(t)&&t.expression&&h.assertAnonymousFunctionExpression(t.expression)};static assertFunctionSignatureList=(t,e,r,s)=>{const i=new Set;t.forEach((n,a)=>{if(h.isNodeIgnoredTarget(n))return;let o;if(h.isNodeDefaultedParameter(n)){if("parameter"!==r||"anonymous function"===s)throw new SyntaxError(`invalid ${r} list in ${s}.`);o=n.left.id}else{if(!h.isNodeIdentifier(n))throw new SyntaxError(`invalid ${r} list in ${s}.`);o=n.id}if(i.has(o))throw new SyntaxError(`duplicate ${r} name '${o}' in ${s}.`);if(i.add(o),o===e&&a!==t.length-1)throw new SyntaxError(`${e} must be the last ${r} in ${s}.`);if(h.isNodeDefaultedParameter(n)&&o===e)throw new SyntaxError(`${e} default value is not supported in ${s}.`)})};static assertAnonymousFunctionParameters=t=>{h.assertFunctionSignatureList(t,"varargin","parameter","anonymous function")};static nodeOperation=(t,e,r)=>{let s;switch(t){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":if(void 0===r)throw new TypeError(`right operand for ${t} is missing.`);s={type:t,left:h.factoryExpression(e,`left operand for ${t}`),right:h.factoryExpression(r,`right operand for ${t}`,h.assignmentNodeOperation.has(t))},s.left.parent=s,s.right.parent=s;break;case"()":case"!":case"~":case"+_":case"-_":case"++_":case"--_":s={type:t,right:h.factoryExpression(e,`operand for ${t}`)},s.right.parent=s;break;case".'":case"'":case"_++":case"_--":s={type:t,left:h.factoryExpression(e,`operand for ${t}`)},s.left.parent=s;break;default:s={type:`INVALID:${t}`}}return s.omitAnswer=h.omitAnswerNodeOperation.has(s.type),s.omitOutput=!1,s};static nodeDefaultedParameter=(t,e)=>{const r=h.nodeOperation("=",t,e);if(!h.isNodeDefaultedParameter(r))throw new TypeError("defaulted parameter has invalid node type.");return r};static nodeIgnoredTarget=()=>({type:"<~>",omitAnswer:!0,omitOutput:!1});static nodeListFirst=t=>{const e={type:"LIST",list:t?[t]:[],omitAnswer:!1,omitOutput:!1};return t&&(e.list[0].parent=e),e};static appendNodeList=(t,e)=>(e.parent=t,t.list.push(e),t);static nodeList=t=>{const e={type:"LIST",list:t,omitAnswer:!1,omitOutput:!1};return e.list.forEach(t=>t.parent=e),e};static nodeFirstRow=(t=null,e)=>t?h.firstRow(h.factoryArrayElementList(t,"array element "),e):h.emptyArray(e);static nodeAppendRow=(t,e=null)=>e?h.appendRow(t,h.factoryArrayElementList(e,"array element ")):t;static nodeIndirectRef=(t,e)=>{if(h.isNodeIndirectRef(t))return t.field.push("string"==typeof e?e:h.factoryExpression(e,"indirect reference field")),"string"!=typeof e&&(e.parent=t),t;{const r={type:".",obj:h.factoryExpression(t,"indirect reference object"),field:["string"==typeof e?e:h.factoryExpression(e,"indirect reference field")],omitAnswer:!1,omitOutput:!1};return r.obj.parent=r,"string"!=typeof e&&(e.parent=r),r}};static nodeReturnList=(t,e)=>({type:"RETLIST",selector:t,...void 0===e?{handler:t=>({length:t})}:"function"==typeof e?{handler:e}:e});static nodeCommaSeparatedReturnList=(t,e,r)=>{const s=h.nodeReturnList(e,r);return s.commaSeparated=!0,s.returnListLength=t,s};static nodeBoundedReturnList=(t,e,r,s)=>h.nodeReturnList((r,i)=>(h.throwErrorIfGreaterThanReturnList(t,r.length,s),e(r,i)),e=>(h.throwErrorIfGreaterThanReturnList(t,e,s),r?r(e):{length:e}));static ensureReturnList=t=>{if(h.isNodeReturnList(t))return t;const e=t;return h.nodeReturnList((t,r)=>{if(0===r)return e;throw h.throwErrorIfGreaterThanReturnList(1,r+1),new EvalError("unreachable return-list selector branch.")})};static throwErrorIfGreaterThanReturnList=(t,e,r)=>{if(e>t){const e=`element number ${t+1} undefined in return list`;throw r&&r(e),new EvalError(e)}};static reduceToFirstIfReturnList=t=>{if(h.isNodeReturnList(t)){const e=t.selector(t.handler(1),0);return e.parent=t.parent,e}return t};static throwInvalidCallError=(t,e=!0,r)=>{if(e){const e=`Invalid call to ${t}. Type 'help ${t}' to see correct usage.`;throw r&&r(e),new SyntaxError(e)}};static nodeFunctionHandle=(t=null,e=null,r=null)=>{const s=e?h.factoryNodeList(e,h.isNodeFunctionParameter,"function handle parameter "):[],i=r?h.factoryExpression(r,"function handle expression"):null;t||(h.assertAnonymousFunctionParameters(s),i&&h.assertAnonymousFunctionExpression(i));const a=n.FunctionHandle.create(t?t.id:void 0,s,i);return a.parameter.forEach(t=>{t.parent=a}),a.expression&&(a.expression.parent=a),a};static nodeFunctionDefinition=(t,e,r,s,i)=>{const n=h.factoryNodeList(e,h.isNodeFunctionReturn,"function return "),a=h.factoryNodeList(r,h.isNodeFunctionParameter,"function parameter "),o=h.factoryNodeList(s,h.isNodeArguments,"function arguments block "),l=h.factoryNodeList(i,h.isNodeProgramElement,"function statement "),c={type:"FCNDEF",id:t.id,mapper:1===a.length&&1===n.length,ev:new Array(a.length).fill(!0),func:null,return:e,parameter:r,arguments:s,statements:i,omitAnswer:!0,omitOutput:!0};return c.return.parent=c,c.parameter.parent=c,c.arguments.parent=c,c.statements.parent=c,n.forEach(t=>t.parent=c),a.forEach(t=>t.parent=c),o.forEach(t=>t.parent=c),l.forEach(t=>t.parent=c),c};static nodeClassAttributeTable=t=>{const e={};for(const r of t)e[r.id]??=[],e[r.id].push(r);return e};static nodeClassSectionMemberGuard=t=>{switch(t){case"PROPERTIES":return h.isNodeClassProperty;case"METHODS":return h.isNodeFunctionDefinition;case"EVENTS":return h.isNodeClassEvent;case"ENUMERATION":return h.isNodeClassEnumeration;default:return t=>!1}};static nodeArgumentValidation=(t,e,r=null,s,i=null)=>{const n={type:"ARGVALID",name:h.factoryExpression(t,"argument validation name"),size:h.factoryExpressionList(e,"argument validation size "),class:h.factoryArgumentClass(r,"argument validation class"),functions:h.factoryExpressionList(s,"argument validation function "),default:i?h.factoryExpression(i,"argument validation default"):null,omitAnswer:!0,omitOutput:!0};return n.name.parent=n,n.size.forEach(t=>{h.isNodeBase(t)&&(t.parent=n)}),n.class&&(n.class.parent=n),n.functions.forEach(t=>{h.isNodeBase(t)&&(t.parent=n)}),n.default&&(n.default.parent=n),n};static nodeArguments=(t,e)=>{const r=t?h.isNodeList(t)?h.factoryNodeList(t,h.isNodeIdentifier,"arguments block attribute "):[t]:[],s={type:"ARGS",attribute:r[0]??null,attributes:r,validation:h.factoryNodeList(e,h.isNodeArgumentValidation,"arguments validation "),omitAnswer:!0,omitOutput:!0};return s.attributes.forEach(t=>t.parent=s),s.validation.forEach(t=>t.parent=s),s};static nodeDeclarationFirst=t=>({type:t,list:[],omitAnswer:!0,omitOutput:!0});static nodeReturn=()=>({type:"RETURN",omitAnswer:!0,omitOutput:!0});static nodeBreak=()=>({type:"BREAK",omitAnswer:!0,omitOutput:!0});static nodeContinue=()=>({type:"CONTINUE",omitAnswer:!0,omitOutput:!0});static getDeclarationNode=t=>"node"in t?t.node:t;static nodeAppendDeclaration=(t,e)=>{const r=h.getDeclarationNode(e);if(!h.isNodeDeclarationElement(r))throw new TypeError("declaration entry has invalid node type.");return r.parent=t,t.list.push(r),t};static nodeImport=()=>({type:"IMPORT",imports:[]});static nodeImportFirst=t=>{const e=h.nodeImport();return e.omitAnswer=!0,e.omitOutput=!0,h.nodeAppendImport(e,t)};static nodeAppendImport=(t,e)=>(e.parent=t,e.index=t.imports.length,t.imports.push(e),t);static nodeIfBegin=(t,e)=>{h.factoryProgramElementList(e,"if body ");const r={type:"IF",expression:[h.factoryExpression(t,"if condition")],then:[e],else:null,omitAnswer:!0,omitOutput:!0};return r.expression[0].parent=r,r.then[0].parent=r,r};static nodeIfAppendElse=(t,e)=>(h.factoryProgramElementList(e.else,"else body "),t.else=e.else,t.else.parent=t,t);static nodeIfAppendElseIf=(t,e)=>(h.factoryProgramElementList(e.then,"elseif body "),e.expression.parent=t,t.expression.push(e.expression),e.then.parent=t,t.then.push(e.then),t);static nodeElseIf=(t,e)=>{h.factoryProgramElementList(e,"elseif body ");const r={type:"ELSEIF",expression:h.factoryExpression(t,"elseif condition"),then:e,omitAnswer:!0,omitOutput:!0};return r.expression.parent=r,r.then.parent=r,r};static nodeElse=t=>{h.factoryProgramElementList(t,"else body ");const e={type:"ELSE",else:t,omitAnswer:!0,omitOutput:!0};return e.else.parent=e,e};static nodeSwitch=(t,e,r=null)=>{r&&h.factoryProgramEl