@tachybase/plugin-evaluator-mathjs 1.5.1 → 1.6.1

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.
@@ -5,25 +5,8 @@ Example:
5
5
  import { create, all } from 'mathjs';
6
6
  const mathjs = create(all);
7
7
  mathjs.config({ number: 'BigNumber' });
8
- `);return Object.freeze(kr)};ar(oe,kr,{MATRIX_OPTIONS:Rp,NUMBER_OPTIONS:Fp});function Tn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function zp(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var n=e.default;if(typeof n=="function"){var a=function t(){var r=!1;try{r=this instanceof t}catch(i){}return r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};a.prototype=n.prototype}else a={};return Object.defineProperty(a,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),a}var ea={exports:{}},Pp=ea.exports,so;function Up(){return so||(so=1,function(e,n){(function(a,t){e.exports=t()})(Pp,function(){function a(){return!0}function t(){return!1}function r(){}function i(){var l=[{name:"number",test:function(q){return typeof q=="number"}},{name:"string",test:function(q){return typeof q=="string"}},{name:"boolean",test:function(q){return typeof q=="boolean"}},{name:"Function",test:function(q){return typeof q=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(q){return q instanceof Date}},{name:"RegExp",test:function(q){return q instanceof RegExp}},{name:"Object",test:function(q){return typeof q=="object"&&q!==null&&q.constructor===Object}},{name:"null",test:function(q){return q===null}},{name:"undefined",test:function(q){return q===void 0}}],m={name:"any",test:a},f=[],c=[],s={types:l,conversions:c,ignore:f};function o(q){var P=F(s.types,function(L){return L.name===q});if(P)return P;if(q==="any")return m;var Q=F(s.types,function(L){return L.name.toLowerCase()===q.toLowerCase()});throw new TypeError('Unknown type "'+q+'"'+(Q?'. Did you mean "'+Q.name+'"?':""))}function u(q){return q===m?999:s.types.indexOf(q)}function p(q){var P=F(s.types,function(Q){return Q.test(q)});if(P)return P.name;throw new TypeError("Value has unknown type. Value: "+q)}function v(q,P){if(!q.signatures)throw new TypeError("Function is no typed-function");var Q;if(typeof P=="string"){Q=P.split(",");for(var L=0;L<Q.length;L++)Q[L]=Q[L].trim()}else if(Array.isArray(P))Q=P;else throw new TypeError("String array or a comma separated string expected");var se=Q.join(","),fe=q.signatures[se];if(fe)return fe;throw new TypeError("Signature not found (signature: "+(q.name||"unnamed")+"("+Q.join(", ")+"))")}function h(q,P){var Q=p(q);if(P===Q)return q;for(var L=0;L<s.conversions.length;L++){var se=s.conversions[L];if(se.from===Q&&se.to===P)return se.convert(q)}throw new Error("Cannot convert from "+Q+" to "+P)}function b(q){return q.map(function(P){var Q=P.types.map(O);return(P.restParam?"...":"")+Q.join("|")}).join(",")}function w(q,P){var Q=q.indexOf("...")===0,L=Q?q.length>3?q.slice(3):"any":q,se=L.split("|").map(re).filter(ie).filter(te),fe=B(P,se),ge=se.map(function(ve){var Ne=o(ve);return{name:ve,typeIndex:u(Ne),test:Ne.test,conversion:null,conversionIndex:-1}}),pe=fe.map(function(ve){var Ne=o(ve.from);return{name:ve.from,typeIndex:u(Ne),test:Ne.test,conversion:ve,conversionIndex:P.indexOf(ve)}});return{types:ge.concat(pe),restParam:Q}}function N(q,P,Q){var L=[];return q.trim()!==""&&(L=q.split(",").map(re).map(function(se,fe,ge){var pe=w(se,Q);if(pe.restParam&&fe!==ge.length-1)throw new SyntaxError('Unexpected rest parameter "'+se+'": only allowed for the last parameter');return pe})),L.some(ue)?null:{params:L,fn:P}}function g(q){var P=ye(q);return P?P.restParam:!1}function y(q){return q.types.some(function(P){return P.conversion!=null})}function x(q){if(!q||q.types.length===0)return a;if(q.types.length===1)return o(q.types[0].name).test;if(q.types.length===2){var P=o(q.types[0].name).test,Q=o(q.types[1].name).test;return function(fe){return P(fe)||Q(fe)}}else{var L=q.types.map(function(se){return o(se.name).test});return function(fe){for(var ge=0;ge<L.length;ge++)if(L[ge](fe))return!0;return!1}}}function d(q){var P,Q,L;if(g(q)){P=ee(q).map(x);var se=P.length,fe=x(ye(q)),ge=function(pe){for(var ve=se;ve<pe.length;ve++)if(!fe(pe[ve]))return!1;return!0};return function(ve){for(var Ne=0;Ne<P.length;Ne++)if(!P[Ne](ve[Ne]))return!1;return ge(ve)&&ve.length>=se+1}}else return q.length===0?function(ve){return ve.length===0}:q.length===1?(Q=x(q[0]),function(ve){return Q(ve[0])&&ve.length===1}):q.length===2?(Q=x(q[0]),L=x(q[1]),function(ve){return Q(ve[0])&&L(ve[1])&&ve.length===2}):(P=q.map(x),function(ve){for(var Ne=0;Ne<P.length;Ne++)if(!P[Ne](ve[Ne]))return!1;return ve.length===P.length})}function A(q,P){return P<q.params.length?q.params[P]:g(q.params)?ye(q.params):null}function S(q,P,Q){var L=A(q,P),se=L?Q?L.types.filter(M):L.types:[];return se.map(O)}function O(q){return q.name}function M(q){return q.conversion===null||q.conversion===void 0}function _(q,P){var Q=Y(k(q,function(L){return S(L,P,!1)}));return Q.indexOf("any")!==-1?["any"]:Q}function E(q,P,Q){var L,se,fe=q||"unnamed",ge=Q,pe;for(pe=0;pe<P.length;pe++){var ve=ge.filter(function(tr){var Jr=x(A(tr,pe));return(pe<tr.params.length||g(tr.params))&&Jr(P[pe])});if(ve.length===0){if(se=_(ge,pe),se.length>0){var Ne=p(P[pe]);return L=new TypeError("Unexpected type of argument in function "+fe+" (expected: "+se.join(" or ")+", actual: "+Ne+", index: "+pe+")"),L.data={category:"wrongType",fn:fe,index:pe,actual:Ne,expected:se},L}}else ge=ve}var Qe=ge.map(function(tr){return g(tr.params)?1/0:tr.params.length});if(P.length<Math.min.apply(null,Qe))return se=_(ge,pe),L=new TypeError("Too few arguments in function "+fe+" (expected: "+se.join(" or ")+", index: "+P.length+")"),L.data={category:"tooFewArgs",fn:fe,index:P.length,expected:se},L;var cr=Math.max.apply(null,Qe);return P.length>cr?(L=new TypeError("Too many arguments in function "+fe+" (expected: "+cr+", actual: "+P.length+")"),L.data={category:"tooManyArgs",fn:fe,index:P.length,expectedLength:cr},L):(L=new TypeError('Arguments of type "'+P.join(", ")+'" do not match any of the defined signatures of function '+fe+"."),L.data={category:"mismatch",actual:P.map(p)},L)}function $(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])&&(P=Math.min(P,q.types[Q].typeIndex));return P}function z(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])||(P=Math.min(P,q.types[Q].conversionIndex));return P}function I(q,P){var Q;return Q=q.restParam-P.restParam,Q!==0||(Q=y(q)-y(P),Q!==0)||(Q=$(q)-$(P),Q!==0)?Q:z(q)-z(P)}function T(q,P){var Q=Math.min(q.params.length,P.params.length),L,se;if(se=q.params.some(y)-P.params.some(y),se!==0)return se;for(L=0;L<Q;L++)if(se=y(q.params[L])-y(P.params[L]),se!==0)return se;for(L=0;L<Q;L++)if(se=I(q.params[L],P.params[L]),se!==0)return se;return q.params.length-P.params.length}function B(q,P){var Q={};return q.forEach(function(L){P.indexOf(L.from)===-1&&P.indexOf(L.to)!==-1&&!Q[L.from]&&(Q[L.from]=L)}),Object.keys(Q).map(function(L){return Q[L]})}function G(q,P){var Q=P;if(q.some(y)){var L=g(q),se=q.map(D);Q=function(){for(var ve=[],Ne=L?arguments.length-1:arguments.length,Qe=0;Qe<Ne;Qe++)ve[Qe]=se[Qe](arguments[Qe]);return L&&(ve[Ne]=arguments[Ne].map(se[Ne])),P.apply(this,ve)}}var fe=Q;if(g(q)){var ge=q.length-1;fe=function(){return Q.apply(this,we(arguments,0,ge).concat([we(arguments,ge)]))}}return fe}function D(q){var P,Q,L,se,fe=[],ge=[];switch(q.types.forEach(function(pe){pe.conversion&&(fe.push(o(pe.conversion.from).test),ge.push(pe.conversion.convert))}),ge.length){case 0:return function(ve){return ve};case 1:return P=fe[0],L=ge[0],function(ve){return P(ve)?L(ve):ve};case 2:return P=fe[0],Q=fe[1],L=ge[0],se=ge[1],function(ve){return P(ve)?L(ve):Q(ve)?se(ve):ve};default:return function(ve){for(var Ne=0;Ne<ge.length;Ne++)if(fe[Ne](ve))return ge[Ne](ve);return ve}}}function H(q){var P={};return q.forEach(function(Q){Q.params.some(y)||W(Q.params,!0).forEach(function(L){P[b(L)]=Q.fn})}),P}function W(q,P){function Q(L,se,fe){if(se<L.length){var ge=L[se],pe=P?ge.types.filter(M):ge.types,ve;if(ge.restParam){var Ne=pe.filter(M);ve=Ne.length<pe.length?[Ne,pe]:[pe]}else ve=pe.map(function(cr){return[cr]});return k(ve,function(cr){return Q(L,se+1,fe.concat([cr]))})}else{var Qe=fe.map(function(cr,tr){return{types:cr,restParam:tr===L.length-1&&g(L)}});return[Qe]}}return Q(q,0,[])}function j(q,P){for(var Q=Math.max(q.params.length,P.params.length),L=0;L<Q;L++){var se=S(q,L,!0),fe=S(P,L,!0);if(!xe(se,fe))return!1}var ge=q.params.length,pe=P.params.length,ve=g(q.params),Ne=g(P.params);return ve?Ne?ge===pe:pe>=ge:Ne?ge>=pe:ge===pe}function V(q,P){if(Object.keys(P).length===0)throw new SyntaxError("No signatures provided");var Q=[];Object.keys(P).map(function(nr){return N(nr,P[nr],s.conversions)}).filter(ne).forEach(function(nr){var Cr=F(Q,function(vt){return j(vt,nr)});if(Cr)throw new TypeError('Conflicting signatures "'+b(Cr.params)+'" and "'+b(nr.params)+'".');Q.push(nr)});var L=k(Q,function(nr){var Cr=nr?W(nr.params,!1):[];return Cr.map(function(vt){return{params:vt,fn:nr.fn}})}).filter(ne);L.sort(T);var se=L[0]&&L[0].params.length<=2&&!g(L[0].params),fe=L[1]&&L[1].params.length<=2&&!g(L[1].params),ge=L[2]&&L[2].params.length<=2&&!g(L[2].params),pe=L[3]&&L[3].params.length<=2&&!g(L[3].params),ve=L[4]&&L[4].params.length<=2&&!g(L[4].params),Ne=L[5]&&L[5].params.length<=2&&!g(L[5].params),Qe=se&&fe&&ge&&pe&&ve&&Ne,cr=L.map(function(nr){return d(nr.params)}),tr=se?x(L[0].params[0]):t,Jr=fe?x(L[1].params[0]):t,Lr=ge?x(L[2].params[0]):t,Ot=pe?x(L[3].params[0]):t,Ze=ve?x(L[4].params[0]):t,Pt=Ne?x(L[5].params[0]):t,C=se?x(L[0].params[1]):t,X=fe?x(L[1].params[1]):t,ae=ge?x(L[2].params[1]):t,he=pe?x(L[3].params[1]):t,qe=ve?x(L[4].params[1]):t,Ue=Ne?x(L[5].params[1]):t,dr=L.map(function(nr){return G(nr.params,nr.fn)}),to=se?dr[0]:r,W_=fe?dr[1]:r,J_=ge?dr[2]:r,Q_=pe?dr[3]:r,K_=ve?dr[4]:r,j_=Ne?dr[5]:r,e$=se?L[0].params.length:-1,r$=fe?L[1].params.length:-1,t$=ge?L[2].params.length:-1,n$=pe?L[3].params.length:-1,a$=ve?L[4].params.length:-1,i$=Ne?L[5].params.length:-1,o$=Qe?6:0,s$=L.length,u$=function(){for(var Cr=o$;Cr<s$;Cr++)if(cr[Cr](arguments))return dr[Cr].apply(this,arguments);return s.onMismatch(q,arguments,L)},no=function nr(Cr,vt){return arguments.length===e$&&tr(Cr)&&C(vt)?to.apply(nr,arguments):arguments.length===r$&&Jr(Cr)&&X(vt)?W_.apply(nr,arguments):arguments.length===t$&&Lr(Cr)&&ae(vt)?J_.apply(nr,arguments):arguments.length===n$&&Ot(Cr)&&he(vt)?Q_.apply(nr,arguments):arguments.length===a$&&Ze(Cr)&&qe(vt)?K_.apply(nr,arguments):arguments.length===i$&&Pt(Cr)&&Ue(vt)?j_.apply(nr,arguments):u$.apply(nr,arguments)};try{Object.defineProperty(no,"name",{value:q})}catch(nr){}return no.signatures=H(L),no}function K(q,P,Q){throw E(q,P,Q)}function te(q){return s.ignore.indexOf(q)===-1}function re(q){return q.trim()}function ie(q){return!!q}function ne(q){return q!==null}function ue(q){return q.types.length===0}function ee(q){return q.slice(0,q.length-1)}function ye(q){return q[q.length-1]}function we(q,P,Q){return Array.prototype.slice.call(q,P,Q)}function me(q,P){return q.indexOf(P)!==-1}function xe(q,P){for(var Q=0;Q<q.length;Q++)if(me(P,q[Q]))return!0;return!1}function F(q,P){for(var Q=0;Q<q.length;Q++)if(P(q[Q]))return q[Q]}function Y(q){for(var P={},Q=0;Q<q.length;Q++)P[q[Q]]=!0;return Object.keys(P)}function k(q,P){return Array.prototype.concat.apply([],q.map(P))}function U(q){for(var P="",Q=0;Q<q.length;Q++){var L=q[Q];if((typeof L.signatures=="object"||typeof L.signature=="string")&&L.name!==""){if(P==="")P=L.name;else if(P!==L.name){var se=new Error("Function names do not match (expected: "+P+", actual: "+L.name+")");throw se.data={actual:L.name,expected:P},se}}}return P}function J(q){var P,Q={};function L(pe,ve){if(Q.hasOwnProperty(pe)&&ve!==Q[pe])throw P=new Error('Signature "'+pe+'" is defined twice'),P.data={signature:pe},P}for(var se=0;se<q.length;se++){var fe=q[se];if(typeof fe.signatures=="object")for(var ge in fe.signatures)fe.signatures.hasOwnProperty(ge)&&(L(ge,fe.signatures[ge]),Q[ge]=fe.signatures[ge]);else if(typeof fe.signature=="string")L(fe.signature,fe),Q[fe.signature]=fe;else throw P=new TypeError("Function is no typed-function (index: "+se+")"),P.data={index:se},P}return Q}return s=V("typed",{"string, Object":V,Object:function(q){var P=[];for(var Q in q)q.hasOwnProperty(Q)&&P.push(q[Q]);var L=U(P);return V(L,q)},"...Function":function(q){return V(U(q),J(q))},"string, ...Function":function(q,P){return V(q,J(P))}}),s.create=i,s.types=l,s.conversions=c,s.ignore=f,s.onMismatch=K,s.throwMismatchError=K,s.createError=E,s.convert=h,s.find=v,s.addType=function(q,P){if(!q||typeof q.name!="string"||typeof q.test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");if(P!==!1){for(var Q=0;Q<s.types.length;Q++)if(s.types[Q].name==="Object"){s.types.splice(Q,0,q);return}}s.types.push(q)},s.addConversion=function(q){if(!q||typeof q.from!="string"||typeof q.to!="string"||typeof q.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");s.conversions.push(q)},s}return i()})}(ea)),ea.exports}var Lp=Up();const uo=Tn(Lp);function Ae(e){return typeof e=="boolean"?!0:isFinite(e)?e===Math.round(e):!1}var Dt=Math.sign||function(e){return e>0?1:e<0?-1:0},kp=Math.log2||function(n){return Math.log(n)/Math.LN2},Hp=Math.log10||function(n){return Math.log(n)/Math.LN10},Gp=Math.log1p||function(e){return Math.log(e+1)},Vp=Math.cbrt||function(n){if(n===0)return n;var a=n<0,t;return a&&(n=-n),isFinite(n)?(t=Math.exp(Math.log(n)/3),t=(n/(t*t)+2*t)/3):t=n,a?-t:t},Zp=Math.expm1||function(n){return n>=2e-4||n<=-2e-4?Math.exp(n)-1:n+n*n/2+n*n*n/6};function ja(e,n,a){var t={2:"0b",8:"0o",16:"0x"},r=t[n],i="";if(a){if(a<1)throw new Error("size must be in greater than 0");if(!Ae(a))throw new Error("size must be an integer");if(e>en(2,a-1)-1||e<-en(2,a-1))throw new Error("Value must be in range [-2^".concat(a-1,", 2^").concat(a-1,"-1]"));if(!Ae(e))throw new Error("Value must be an integer");e<0&&(e=e+en(2,a)),i="i".concat(a)}var l="";return e<0&&(e=-e,l="-"),"".concat(l).concat(r).concat(e.toString(n)).concat(i)}function Ht(e,n){if(typeof n=="function")return n(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var a="auto",t,r;if(n&&(n.notation&&(a=n.notation),Be(n)?t=n:Be(n.precision)&&(t=n.precision),n.wordSize&&(r=n.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return co(e,t);case"exponential":return fo(e,t);case"engineering":return Xp(e,t);case"bin":return ja(e,2,r);case"oct":return ja(e,8,r);case"hex":return ja(e,16,r);case"auto":return Yp(e,t,n&&n).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],l=arguments[4];return i!=="."?i+l:l});default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ra(e){var n=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!n)throw new SyntaxError("Invalid number "+e);var a=n[1],t=n[2],r=parseFloat(n[4]||"0"),i=t.indexOf(".");r+=i!==-1?i-1:t.length-1;var l=t.replace(".","").replace(/^0*/,function(m){return r-=m.length,""}).replace(/0*$/,"").split("").map(function(m){return parseInt(m)});return l.length===0&&(l.push(0),r++),{sign:a,coefficients:l,exponent:r}}function Xp(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=ta(a,n),r=t.exponent,i=t.coefficients,l=r%3===0?r:r<0?r-3-r%3:r-r%3;if(Be(n))for(;n>i.length||r-l+1>i.length;)i.push(0);else for(var m=Math.abs(r-l)-(i.length-1),f=0;f<m;f++)i.push(0);for(var c=Math.abs(r-l),s=1;c>0;)s++,c--;var o=i.slice(s).join(""),u=Be(n)&&o.length||o.match(/[1-9]/)?"."+o:"",p=i.slice(0,s).join("")+u+"e"+(r>=0?"+":"")+l.toString();return t.sign+p}function co(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=typeof n=="number"?ta(a,a.exponent+1+n):a,r=t.coefficients,i=t.exponent+1,l=i+(n||0);return r.length<l&&(r=r.concat(nn(l-r.length))),i<0&&(r=nn(-i+1).concat(r),i=1),i<r.length&&r.splice(i,0,i===0?"0.":"."),t.sign+r.join("")}function fo(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=n?ta(a,n):a,r=t.coefficients,i=t.exponent;r.length<n&&(r=r.concat(nn(n-r.length)));var l=r.shift();return t.sign+l+(r.length>0?"."+r.join(""):"")+"e"+(i>=0?"+":"")+i}function Yp(e,n,a){if(isNaN(e)||!isFinite(e))return String(e);var t=a&&a.lowerExp!==void 0?a.lowerExp:-3,r=a&&a.upperExp!==void 0?a.upperExp:5,i=ra(e),l=n?ta(i,n):i;if(l.exponent<t||l.exponent>=r)return fo(e,n);var m=l.coefficients,f=l.exponent;m.length<n&&(m=m.concat(nn(n-m.length))),m=m.concat(nn(f-m.length+1+(m.length<n?n-m.length:0))),m=nn(-f).concat(m);var c=f>0?f:0;return c<m.length-1&&m.splice(c+1,0,"."),l.sign+m.join("")}function ta(e,n){for(var a={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},t=a.coefficients;n<=0;)t.unshift(0),a.exponent++,n++;if(t.length>n){var r=t.splice(n,t.length-n);if(r[0]>=5){var i=n-1;for(t[i]++;t[i]===10;)t.pop(),i===0&&(t.unshift(0),a.exponent++,i++),i--,t[i]++}}return a}function nn(e){for(var n=[],a=0;a<e;a++)n.push(0);return n}function Wp(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Jp=Number.EPSILON||2220446049250313e-31;function Rr(e,n,a){if(a==null)return e===n;if(e===n)return!0;if(isNaN(e)||isNaN(n))return!1;if(isFinite(e)&&isFinite(n)){var t=Math.abs(e-n);return t<Jp?!0:t<=Math.max(Math.abs(e),Math.abs(n))*a}return!1}var Qp=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},Kp=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},jp=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},ev=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},rv=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},tv=Math.tanh||function(e){var n=Math.exp(2*e);return(n-1)/(n+1)};function nv(e,n){var a=!0,t=n>0?!0:n<0?!1:1/n===1/0;return a^t?-e:e}function ei(e,n,a){var t=e.constructor,r=new t(2),i="";if(a){if(a<1)throw new Error("size must be in greater than 0");if(!Ae(a))throw new Error("size must be an integer");if(e.greaterThan(r.pow(a-1).sub(1))||e.lessThan(r.pow(a-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(a-1,", 2^").concat(a-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(r.pow(a))),i="i".concat(a)}switch(n){case 2:return"".concat(e.toBinary()).concat(i);case 8:return"".concat(e.toOctal()).concat(i);case 16:return"".concat(e.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(n," not supported "))}}function av(e,n){if(typeof n=="function")return n(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var a="auto",t,r;if(n!==void 0&&(n.notation&&(a=n.notation),typeof n=="number"?t=n:n.precision&&(t=n.precision),n.wordSize&&(r=n.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return ov(e,t);case"exponential":return lo(e,t);case"engineering":return iv(e,t);case"bin":return ei(e,2,r);case"oct":return ei(e,8,r);case"hex":return ei(e,16,r);case"auto":{var i=n&&n.lowerExp!==void 0?n.lowerExp:-3,l=n&&n.upperExp!==void 0?n.upperExp:5;if(e.isZero())return"0";var m,f=e.toSignificantDigits(t),c=f.e;return c>=i&&c<l?m=f.toFixed():m=lo(e,t),m.replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],o=arguments[4];return s!=="."?s+o:o})}default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function iv(e,n){var a=e.e,t=a%3===0?a:a<0?a-3-a%3:a-a%3,r=e.mul(Math.pow(10,-t)),i=r.toPrecision(n);return i.indexOf("e")!==-1&&(i=r.toString()),i+"e"+(a>=0?"+":"")+t.toString()}function lo(e,n){return n!==void 0?e.toExponential(n-1):e.toExponential()}function ov(e,n){return e.toFixed(n)}function sv(e,n){var a=e.length-n.length,t=e.length;return e.substring(a,t)===n}function Re(e,n){var a=uv(e,n);return n&&typeof n=="object"&&"truncate"in n&&a.length>n.truncate?a.substring(0,n.truncate-3)+"...":a}function uv(e,n){if(typeof e=="number")return Ht(e,n);if(_e(e))return av(e,n);if(cv(e))return!n||n.fraction!=="decimal"?e.s*e.n+"/"+e.d:e.toString();if(Array.isArray(e))return mo(e,n);if(_r(e))return'"'+e+'"';if(typeof e=="function")return e.syntax?String(e.syntax):"function";if(e&&typeof e=="object"){if(typeof e.format=="function")return e.format(n);if(e&&e.toString(n)!=={}.toString())return e.toString(n);var a=Object.keys(e).map(t=>'"'+t+'": '+Re(e[t],n));return"{"+a.join(", ")+"}"}return String(e)}function na(e){for(var n=String(e),a="",t=0;t<n.length;){var r=n.charAt(t);r==="\\"?(a+=r,t++,r=n.charAt(t),(r===""||'"\\/bfnrtu'.indexOf(r)===-1)&&(a+="\\"),a+=r):r==='"'?a+='\\"':a+=r,t++}return'"'+a+'"'}function Gr(e){var n=String(e);return n=n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),n}function mo(e,n){if(Array.isArray(e)){for(var a="[",t=e.length,r=0;r<t;r++)r!==0&&(a+=", "),a+=mo(e[r],n);return a+="]",a}else return Re(e,n)}function cv(e){return e&&typeof e=="object"&&typeof e.s=="number"&&typeof e.n=="number"&&typeof e.d=="number"||!1}function an(e,n){if(!_r(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Ke(e)+", index: 0)");if(!_r(n))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Ke(n)+", index: 1)");return e===n?0:e>n?1:-1}function Fe(e,n,a){if(!(this instanceof Fe))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=n,this.relation=a,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(n)?"["+n.join(", ")+"]":n)+")",this.stack=new Error().stack}Fe.prototype=new RangeError,Fe.prototype.constructor=RangeError,Fe.prototype.name="DimensionError",Fe.prototype.isDimensionError=!0;function Kr(e,n,a){if(!(this instanceof Kr))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=n):(this.min=n,this.max=a),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}Kr.prototype=new RangeError,Kr.prototype.constructor=RangeError,Kr.prototype.name="IndexError",Kr.prototype.isIndexError=!0;function Pe(e){for(var n=[];Array.isArray(e);)n.push(e.length),e=e[0];return n}function po(e,n,a){var t,r=e.length;if(r!==n[a])throw new Fe(r,n[a]);if(a<n.length-1){var i=a+1;for(t=0;t<r;t++){var l=e[t];if(!Array.isArray(l))throw new Fe(n.length-1,n.length,"<");po(e[t],n,i)}}else for(t=0;t<r;t++)if(Array.isArray(e[t]))throw new Fe(n.length+1,n.length,">")}function vo(e,n){var a=n.length===0;if(a){if(Array.isArray(e))throw new Fe(e.length,0)}else po(e,n,0)}function We(e,n){if(!Be(e)||!Ae(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof n=="number"&&e>=n)throw new Kr(e,n)}function on(e,n,a){if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(n.length===0)throw new Error("Resizing to scalar is not supported");n.forEach(function(r){if(!Be(r)||!Ae(r)||r<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Re(n)+")")});var t=a!==void 0?a:0;return ri(e,n,0,t),e}function ri(e,n,a,t){var r,i,l=e.length,m=n[a],f=Math.min(l,m);if(e.length=m,a<n.length-1){var c=a+1;for(r=0;r<f;r++)i=e[r],Array.isArray(i)||(i=[i],e[r]=i),ri(i,n,c,t);for(r=f;r<m;r++)i=[],e[r]=i,ri(i,n,c,t)}else{for(r=0;r<f;r++)for(;Array.isArray(e[r]);)e[r]=e[r][0];for(r=f;r<m;r++)e[r]=t}}function ho(e,n){var a=Le(e),t=a.length;if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(n.length===0)throw new Fe(0,t,"!=");n=ti(n,t);var r=go(n);if(t!==r)throw new Fe(r,t,"!=");try{return fv(a,n)}catch(i){throw i instanceof Fe?new Fe(r,t,"!="):i}}function ti(e,n){var a=go(e),t=e.slice(),r=-1,i=e.indexOf(r),l=e.indexOf(r,i+1)>=0;if(l)throw new Error("More than one wildcard in sizes");var m=i>=0,f=n%a===0;if(m)if(f)t[i]=-n/a;else throw new Error("Could not replace wildcard, since "+n+" is no multiple of "+-a);return t}function go(e){return e.reduce((n,a)=>n*a,1)}function fv(e,n){for(var a=e,t,r=n.length-1;r>0;r--){var i=n[r];t=[];for(var l=a.length/i,m=0;m<l;m++)t.push(a.slice(m*i,(m+1)*i));a=t}return a}function aa(e,n){for(var a=Pe(e);Array.isArray(e)&&e.length===1;)e=e[0],a.shift();for(var t=a.length;a[t-1]===1;)t--;return t<a.length&&(e=yo(e,t,0),a.length=t),e}function yo(e,n,a){var t,r;if(a<n){var i=a+1;for(t=0,r=e.length;t<r;t++)e[t]=yo(e[t],n,i)}else for(;Array.isArray(e);)e=e[0];return e}function xo(e,n,a,t){var r=t||Pe(e);if(a)for(var i=0;i<a;i++)e=[e],r.unshift(1);for(e=bo(e,n,0);r.length<n;)r.push(1);return e}function bo(e,n,a){var t,r;if(Array.isArray(e)){var i=a+1;for(t=0,r=e.length;t<r;t++)e[t]=bo(e[t],n,i)}else for(var l=a;l<n;l++)e=[e];return e}function Le(e){if(!Array.isArray(e))return e;var n=[];return e.forEach(function a(t){Array.isArray(t)?t.forEach(a):n.push(t)}),n}function dt(e,n){return Array.prototype.map.call(e,n)}function ia(e,n){Array.prototype.forEach.call(e,n)}function wo(e,n){if(Pe(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,n)}function oa(e,n){if(Pe(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,a=>n.test(a))}function No(e,n){return Array.prototype.join.call(e,n)}function sn(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;var n=[],a=0;n[0]={value:e[0],identifier:0};for(var t=1;t<e.length;t++)e[t]===e[t-1]?a++:a=0,n.push({value:e[t],identifier:a});return n}function sa(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;for(var n=[],a=0;a<e.length;a++)n.push(e[a].value);return n}function Bn(e,n){for(var a,t=0,r=0;r<e.length;r++){var i=e[r],l=Array.isArray(i);if(r===0&&l&&(t=i.length),l&&i.length!==t)return;var m=l?Bn(i,n):n(i);if(a===void 0)a=m;else if(a!==m)return"mixed"}return a}function R(e,n,a,t){function r(i){var l=qp(i,n.map(pv));return lv(e,n,i),a(l)}return r.isFactory=!0,r.fn=e,r.dependencies=n.slice().sort(),t&&(r.meta=t),r}function lv(e,n,a){var t=n.filter(i=>!mv(i)).every(i=>a[i]!==void 0);if(!t){var r=n.filter(i=>a[i]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(r.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function mv(e){return e&&e[0]==="?"}function pv(e){return e&&e[0]==="?"?e.slice(1):e}function Vr(e,n){if(Mo(e)&&ni(e,n))return e[n];throw typeof e[n]=="function"&&ai(e,n)?new Error('Cannot access method "'+n+'" as a property'):new Error('No access to property "'+n+'"')}function un(e,n,a){if(Mo(e)&&ni(e,n))return e[n]=a,a;throw new Error('No access to property "'+n+'"')}function vv(e,n){return n in e}function ni(e,n){return!e||typeof e!="object"?!1:Me(dv,n)?!0:!(n in Object.prototype||n in Function.prototype)}function hv(e,n){if(!ai(e,n))throw new Error('No access to method "'+n+'"')}function ai(e,n){return e==null||typeof e[n]!="function"||Me(e,n)&&Object.getPrototypeOf&&n in Object.getPrototypeOf(e)?!1:Me(gv,n)?!0:!(n in Object.prototype||n in Function.prototype)}function Mo(e){return typeof e=="object"&&e&&e.constructor===Object}var dv={length:!0,name:!0},gv={toString:!0,valueOf:!0,toLocaleString:!0};class ii{constructor(n){this.wrappedObject=n}keys(){return Object.keys(this.wrappedObject)}get(n){return Vr(this.wrappedObject,n)}set(n,a){return un(this.wrappedObject,n,a),this}has(n){return vv(this.wrappedObject,n)}}function gt(){return new Map}function oi(e){if(!e)return gt();if(ua(e))return e;if(Ja(e))return new ii(e);throw new Error("createMap can create maps from objects or Maps")}function yv(e){if(e instanceof ii)return e.wrappedObject;var n={};for(var a of e.keys()){var t=e.get(a);un(n,a,t)}return n}function ua(e){return e?e instanceof Map||e instanceof ii||typeof e.set=="function"&&typeof e.get=="function"&&typeof e.keys=="function"&&typeof e.has=="function":!1}function Ao(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),t=1;t<n;t++)a[t-1]=arguments[t];for(var r of a)if(r){if(ua(r))for(var i of r.keys())e.set(i,r.get(i));else if(Ja(r))for(var l of Object.keys(r))e.set(l,r[l])}return e}var So=function(){return So=uo.create,uo},xv=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],bv=R("typed",xv,function(n){var{BigNumber:a,Complex:t,DenseMatrix:r,Fraction:i}=n,l=So();return l.types=[{name:"number",test:Be},{name:"Complex",test:Or},{name:"BigNumber",test:_e},{name:"Fraction",test:yr},{name:"Unit",test:ht},{name:"string",test:_r},{name:"Chain",test:Qa},{name:"Array",test:Xe},{name:"Matrix",test:Oe},{name:"DenseMatrix",test:Qn},{name:"SparseMatrix",test:Ut},{name:"Range",test:Kn},{name:"Index",test:En},{name:"boolean",test:Mp},{name:"ResultSet",test:oo},{name:"Help",test:Wa},{name:"function",test:Ap},{name:"Date",test:Sp},{name:"RegExp",test:Ep},{name:"null",test:Cp},{name:"undefined",test:Op},{name:"AccessorNode",test:Lt},{name:"ArrayNode",test:Hr},{name:"AssignmentNode",test:Dp},{name:"BlockNode",test:Tp},{name:"ConditionalNode",test:Bp},{name:"ConstantNode",test:Ye},{name:"FunctionNode",test:kt},{name:"FunctionAssignmentNode",test:Cn},{name:"IndexNode",test:tn},{name:"Node",test:Ve},{name:"ObjectNode",test:jn},{name:"OperatorNode",test:$r},{name:"ParenthesisNode",test:On},{name:"RangeNode",test:_p},{name:"SymbolNode",test:xr},{name:"Map",test:ua},{name:"Object",test:Ja}],l.conversions=[{from:"number",to:"BigNumber",convert:function(f){if(a||si(f),Wp(f)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+f+"). Use function bignumber(x) to convert to BigNumber.");return new a(f)}},{from:"number",to:"Complex",convert:function(f){return t||ca(f),new t(f,0)}},{from:"number",to:"string",convert:function(f){return f+""}},{from:"BigNumber",to:"Complex",convert:function(f){return t||ca(f),new t(f.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(f){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(f){return t||ca(f),new t(f.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(f){i||ui(f);var c=new i(f);if(c.valueOf()!==f)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+f+"). Use function fraction(x) to convert to Fraction.");return c}},{from:"string",to:"number",convert:function(f){var c=Number(f);if(isNaN(c))throw new Error('Cannot convert "'+f+'" to a number');return c}},{from:"string",to:"BigNumber",convert:function(f){a||si(f);try{return new a(f)}catch(c){throw new Error('Cannot convert "'+f+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(f){i||ui(f);try{return new i(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(f){t||ca(f);try{return new t(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Complex')}}},{from:"boolean",to:"number",convert:function(f){return+f}},{from:"boolean",to:"BigNumber",convert:function(f){return a||si(f),new a(+f)}},{from:"boolean",to:"Fraction",convert:function(f){return i||ui(f),new i(+f)}},{from:"boolean",to:"string",convert:function(f){return String(f)}},{from:"Array",to:"Matrix",convert:function(f){return r||wv(),new r(f)}},{from:"Matrix",to:"Array",convert:function(f){return f.valueOf()}}],l});function si(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function ca(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function wv(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function ui(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Nv="ResultSet",Mv=[],Av=R(Nv,Mv,()=>{function e(n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=n||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(n){return new e(n.entries)},e},{isClass:!0});/*!
9
- * decimal.js v10.6.0
10
- * An arbitrary-precision Decimal type for JavaScript.
11
- * https://github.com/MikeMcl/decimal.js
12
- * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
13
- * MIT Licence
14
- */var cn=9e15,Tt=1e9,ci="0123456789abcdef",fa="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",la="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",fi={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-cn,maxE:cn,crypto:!1},Eo,yt,$e=!0,ma="[DecimalError] ",Bt=ma+"Invalid argument: ",Co=ma+"Precision limit exceeded",Oo=ma+"crypto unavailable",Do="[object Decimal]",Nr=Math.floor,hr=Math.pow,Sv=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ev=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Cv=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,To=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,jr=1e7,De=7,Ov=9007199254740991,Dv=fa.length-1,li=la.length-1,ce={toStringTag:Do};ce.absoluteValue=ce.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Ee(e)},ce.ceil=function(){return Ee(new this.constructor(this),this.e+1,2)},ce.clampedTo=ce.clamp=function(e,n){var a,t=this,r=t.constructor;if(e=new r(e),n=new r(n),!e.s||!n.s)return new r(NaN);if(e.gt(n))throw Error(Bt+n);return a=t.cmp(e),a<0?e:t.cmp(n)>0?n:new r(t)},ce.comparedTo=ce.cmp=function(e){var n,a,t,r,i=this,l=i.d,m=(e=new i.constructor(e)).d,f=i.s,c=e.s;if(!l||!m)return!f||!c?NaN:f!==c?f:l===m?0:!l^f<0?1:-1;if(!l[0]||!m[0])return l[0]?f:m[0]?-c:0;if(f!==c)return f;if(i.e!==e.e)return i.e>e.e^f<0?1:-1;for(t=l.length,r=m.length,n=0,a=t<r?t:r;n<a;++n)if(l[n]!==m[n])return l[n]>m[n]^f<0?1:-1;return t===r?0:t>r^f<0?1:-1},ce.cosine=ce.cos=function(){var e,n,a=this,t=a.constructor;return a.d?a.d[0]?(e=t.precision,n=t.rounding,t.precision=e+Math.max(a.e,a.sd())+De,t.rounding=1,a=Tv(t,Ro(t,a)),t.precision=e,t.rounding=n,Ee(yt==2||yt==3?a.neg():a,e,n,!0)):new t(1):new t(NaN)},ce.cubeRoot=ce.cbrt=function(){var e,n,a,t,r,i,l,m,f,c,s=this,o=s.constructor;if(!s.isFinite()||s.isZero())return new o(s);for($e=!1,i=s.s*hr(s.s*s,1/3),!i||Math.abs(i)==1/0?(a=br(s.d),e=s.e,(i=(e-a.length+1)%3)&&(a+=i==1||i==-2?"0":"00"),i=hr(a,1/3),e=Nr((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?a="5e"+e:(a=i.toExponential(),a=a.slice(0,a.indexOf("e")+1)+e),t=new o(a),t.s=s.s):t=new o(i.toString()),l=(e=o.precision)+3;;)if(m=t,f=m.times(m).times(m),c=f.plus(s),t=er(c.plus(s).times(m),c.plus(f),l+2,1),br(m.d).slice(0,l)===(a=br(t.d)).slice(0,l))if(a=a.slice(l-3,l+1),a=="9999"||!r&&a=="4999"){if(!r&&(Ee(m,e+1,0),m.times(m).times(m).eq(s))){t=m;break}l+=4,r=1}else{(!+a||!+a.slice(1)&&a.charAt(0)=="5")&&(Ee(t,e+1,1),n=!t.times(t).times(t).eq(s));break}return $e=!0,Ee(t,e,o.rounding,n)},ce.decimalPlaces=ce.dp=function(){var e,n=this.d,a=NaN;if(n){if(e=n.length-1,a=(e-Nr(this.e/De))*De,e=n[e],e)for(;e%10==0;e/=10)a--;a<0&&(a=0)}return a},ce.dividedBy=ce.div=function(e){return er(this,new this.constructor(e))},ce.dividedToIntegerBy=ce.divToInt=function(e){var n=this,a=n.constructor;return Ee(er(n,new a(e),0,1,1),a.precision,a.rounding)},ce.equals=ce.eq=function(e){return this.cmp(e)===0},ce.floor=function(){return Ee(new this.constructor(this),this.e+1,3)},ce.greaterThan=ce.gt=function(e){return this.cmp(e)>0},ce.greaterThanOrEqualTo=ce.gte=function(e){var n=this.cmp(e);return n==1||n===0},ce.hyperbolicCosine=ce.cosh=function(){var e,n,a,t,r,i=this,l=i.constructor,m=new l(1);if(!i.isFinite())return new l(i.s?1/0:NaN);if(i.isZero())return m;a=l.precision,t=l.rounding,l.precision=a+Math.max(i.e,i.sd())+4,l.rounding=1,r=i.d.length,r<32?(e=Math.ceil(r/3),n=(1/ga(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i=fn(l,1,i.times(n),new l(1),!0);for(var f,c=e,s=new l(8);c--;)f=i.times(i),i=m.minus(f.times(s.minus(f.times(s))));return Ee(i,l.precision=a,l.rounding=t,!0)},ce.hyperbolicSine=ce.sinh=function(){var e,n,a,t,r=this,i=r.constructor;if(!r.isFinite()||r.isZero())return new i(r);if(n=i.precision,a=i.rounding,i.precision=n+Math.max(r.e,r.sd())+4,i.rounding=1,t=r.d.length,t<3)r=fn(i,2,r,r,!0);else{e=1.4*Math.sqrt(t),e=e>16?16:e|0,r=r.times(1/ga(5,e)),r=fn(i,2,r,r,!0);for(var l,m=new i(5),f=new i(16),c=new i(20);e--;)l=r.times(r),r=r.times(m.plus(l.times(f.times(l).plus(c))))}return i.precision=n,i.rounding=a,Ee(r,n,a,!0)},ce.hyperbolicTangent=ce.tanh=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+7,t.rounding=1,er(a.sinh(),a.cosh(),t.precision=e,t.rounding=n)):new t(a.s)},ce.inverseCosine=ce.acos=function(){var e=this,n=e.constructor,a=e.abs().cmp(1),t=n.precision,r=n.rounding;return a!==-1?a===0?e.isNeg()?ot(n,t,r):new n(0):new n(NaN):e.isZero()?ot(n,t+4,r).times(.5):(n.precision=t+6,n.rounding=1,e=new n(1).minus(e).div(e.plus(1)).sqrt().atan(),n.precision=t,n.rounding=r,e.times(2))},ce.inverseHyperbolicCosine=ce.acosh=function(){var e,n,a=this,t=a.constructor;return a.lte(1)?new t(a.eq(1)?0:NaN):a.isFinite()?(e=t.precision,n=t.rounding,t.precision=e+Math.max(Math.abs(a.e),a.sd())+4,t.rounding=1,$e=!1,a=a.times(a).minus(1).sqrt().plus(a),$e=!0,t.precision=e,t.rounding=n,a.ln()):new t(a)},ce.inverseHyperbolicSine=ce.asinh=function(){var e,n,a=this,t=a.constructor;return!a.isFinite()||a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+2*Math.max(Math.abs(a.e),a.sd())+6,t.rounding=1,$e=!1,a=a.times(a).plus(1).sqrt().plus(a),$e=!0,t.precision=e,t.rounding=n,a.ln())},ce.inverseHyperbolicTangent=ce.atanh=function(){var e,n,a,t,r=this,i=r.constructor;return r.isFinite()?r.e>=0?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=i.precision,n=i.rounding,t=r.sd(),Math.max(t,e)<2*-r.e-1?Ee(new i(r),e,n,!0):(i.precision=a=t-r.e,r=er(r.plus(1),new i(1).minus(r),a+e,1),i.precision=e+4,i.rounding=1,r=r.ln(),i.precision=e,i.rounding=n,r.times(.5))):new i(NaN)},ce.inverseSine=ce.asin=function(){var e,n,a,t,r=this,i=r.constructor;return r.isZero()?new i(r):(n=r.abs().cmp(1),a=i.precision,t=i.rounding,n!==-1?n===0?(e=ot(i,a+4,t).times(.5),e.s=r.s,e):new i(NaN):(i.precision=a+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=a,i.rounding=t,r.times(2)))},ce.inverseTangent=ce.atan=function(){var e,n,a,t,r,i,l,m,f,c=this,s=c.constructor,o=s.precision,u=s.rounding;if(c.isFinite()){if(c.isZero())return new s(c);if(c.abs().eq(1)&&o+4<=li)return l=ot(s,o+4,u).times(.25),l.s=c.s,l}else{if(!c.s)return new s(NaN);if(o+4<=li)return l=ot(s,o+4,u).times(.5),l.s=c.s,l}for(s.precision=m=o+10,s.rounding=1,a=Math.min(28,m/De+2|0),e=a;e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for($e=!1,n=Math.ceil(m/De),t=1,f=c.times(c),l=new s(c),r=c;e!==-1;)if(r=r.times(f),i=l.minus(r.div(t+=2)),r=r.times(f),l=i.plus(r.div(t+=2)),l.d[n]!==void 0)for(e=n;l.d[e]===i.d[e]&&e--;);return a&&(l=l.times(2<<a-1)),$e=!0,Ee(l,s.precision=o,s.rounding=u,!0)},ce.isFinite=function(){return!!this.d},ce.isInteger=ce.isInt=function(){return!!this.d&&Nr(this.e/De)>this.d.length-2},ce.isNaN=function(){return!this.s},ce.isNegative=ce.isNeg=function(){return this.s<0},ce.isPositive=ce.isPos=function(){return this.s>0},ce.isZero=function(){return!!this.d&&this.d[0]===0},ce.lessThan=ce.lt=function(e){return this.cmp(e)<0},ce.lessThanOrEqualTo=ce.lte=function(e){return this.cmp(e)<1},ce.logarithm=ce.log=function(e){var n,a,t,r,i,l,m,f,c=this,s=c.constructor,o=s.precision,u=s.rounding,p=5;if(e==null)e=new s(10),n=!0;else{if(e=new s(e),a=e.d,e.s<0||!a||!a[0]||e.eq(1))return new s(NaN);n=e.eq(10)}if(a=c.d,c.s<0||!a||!a[0]||c.eq(1))return new s(a&&!a[0]?-1/0:c.s!=1?NaN:a?0:1/0);if(n)if(a.length>1)i=!0;else{for(r=a[0];r%10===0;)r/=10;i=r!==1}if($e=!1,m=o+p,l=$t(c,m),t=n?ha(s,m+10):$t(e,m),f=er(l,t,m,1),_n(f.d,r=o,u))do if(m+=10,l=$t(c,m),t=n?ha(s,m+10):$t(e,m),f=er(l,t,m,1),!i){+br(f.d).slice(r+1,r+15)+1==1e14&&(f=Ee(f,o+1,0));break}while(_n(f.d,r+=10,u));return $e=!0,Ee(f,o,u)},ce.minus=ce.sub=function(e){var n,a,t,r,i,l,m,f,c,s,o,u,p=this,v=p.constructor;if(e=new v(e),!p.d||!e.d)return!p.s||!e.s?e=new v(NaN):p.d?e.s=-e.s:e=new v(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(c=p.d,u=e.d,m=v.precision,f=v.rounding,!c[0]||!u[0]){if(u[0])e.s=-e.s;else if(c[0])e=new v(p);else return new v(f===3?-0:0);return $e?Ee(e,m,f):e}if(a=Nr(e.e/De),s=Nr(p.e/De),c=c.slice(),i=s-a,i){for(o=i<0,o?(n=c,i=-i,l=u.length):(n=u,a=s,l=c.length),t=Math.max(Math.ceil(m/De),l)+2,i>t&&(i=t,n.length=1),n.reverse(),t=i;t--;)n.push(0);n.reverse()}else{for(t=c.length,l=u.length,o=t<l,o&&(l=t),t=0;t<l;t++)if(c[t]!=u[t]){o=c[t]<u[t];break}i=0}for(o&&(n=c,c=u,u=n,e.s=-e.s),l=c.length,t=u.length-l;t>0;--t)c[l++]=0;for(t=u.length;t>i;){if(c[--t]<u[t]){for(r=t;r&&c[--r]===0;)c[r]=jr-1;--c[r],c[t]+=jr}c[t]-=u[t]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--a;return c[0]?(e.d=c,e.e=va(c,a),$e?Ee(e,m,f):e):new v(f===3?-0:0)},ce.modulo=ce.mod=function(e){var n,a=this,t=a.constructor;return e=new t(e),!a.d||!e.s||e.d&&!e.d[0]?new t(NaN):!e.d||a.d&&!a.d[0]?Ee(new t(a),t.precision,t.rounding):($e=!1,t.modulo==9?(n=er(a,e.abs(),0,3,1),n.s*=e.s):n=er(a,e,0,t.modulo,1),n=n.times(e),$e=!0,a.minus(n))},ce.naturalExponential=ce.exp=function(){return mi(this)},ce.naturalLogarithm=ce.ln=function(){return $t(this)},ce.negated=ce.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Ee(e)},ce.plus=ce.add=function(e){var n,a,t,r,i,l,m,f,c,s,o=this,u=o.constructor;if(e=new u(e),!o.d||!e.d)return!o.s||!e.s?e=new u(NaN):o.d||(e=new u(e.d||o.s===e.s?o:NaN)),e;if(o.s!=e.s)return e.s=-e.s,o.minus(e);if(c=o.d,s=e.d,m=u.precision,f=u.rounding,!c[0]||!s[0])return s[0]||(e=new u(o)),$e?Ee(e,m,f):e;if(i=Nr(o.e/De),t=Nr(e.e/De),c=c.slice(),r=i-t,r){for(r<0?(a=c,r=-r,l=s.length):(a=s,t=i,l=c.length),i=Math.ceil(m/De),l=i>l?i+1:l+1,r>l&&(r=l,a.length=1),a.reverse();r--;)a.push(0);a.reverse()}for(l=c.length,r=s.length,l-r<0&&(r=l,a=s,s=c,c=a),n=0;r;)n=(c[--r]=c[r]+s[r]+n)/jr|0,c[r]%=jr;for(n&&(c.unshift(n),++t),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=va(c,t),$e?Ee(e,m,f):e},ce.precision=ce.sd=function(e){var n,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Bt+e);return a.d?(n=Bo(a.d),e&&a.e+1>n&&(n=a.e+1)):n=NaN,n},ce.round=function(){var e=this,n=e.constructor;return Ee(new n(e),e.e+1,n.rounding)},ce.sine=ce.sin=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+Math.max(a.e,a.sd())+De,t.rounding=1,a=_v(t,Ro(t,a)),t.precision=e,t.rounding=n,Ee(yt>2?a.neg():a,e,n,!0)):new t(NaN)},ce.squareRoot=ce.sqrt=function(){var e,n,a,t,r,i,l=this,m=l.d,f=l.e,c=l.s,s=l.constructor;if(c!==1||!m||!m[0])return new s(!c||c<0&&(!m||m[0])?NaN:m?l:1/0);for($e=!1,c=Math.sqrt(+l),c==0||c==1/0?(n=br(m),(n.length+f)%2==0&&(n+="0"),c=Math.sqrt(n),f=Nr((f+1)/2)-(f<0||f%2),c==1/0?n="5e"+f:(n=c.toExponential(),n=n.slice(0,n.indexOf("e")+1)+f),t=new s(n)):t=new s(c.toString()),a=(f=s.precision)+3;;)if(i=t,t=i.plus(er(l,i,a+2,1)).times(.5),br(i.d).slice(0,a)===(n=br(t.d)).slice(0,a))if(n=n.slice(a-3,a+1),n=="9999"||!r&&n=="4999"){if(!r&&(Ee(i,f+1,0),i.times(i).eq(l))){t=i;break}a+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(Ee(t,f+1,1),e=!t.times(t).eq(l));break}return $e=!0,Ee(t,f,s.rounding,e)},ce.tangent=ce.tan=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+10,t.rounding=1,a=a.sin(),a.s=1,a=er(a,new t(1).minus(a.times(a)).sqrt(),e+10,0),t.precision=e,t.rounding=n,Ee(yt==2||yt==4?a.neg():a,e,n,!0)):new t(NaN)},ce.times=ce.mul=function(e){var n,a,t,r,i,l,m,f,c,s=this,o=s.constructor,u=s.d,p=(e=new o(e)).d;if(e.s*=s.s,!u||!u[0]||!p||!p[0])return new o(!e.s||u&&!u[0]&&!p||p&&!p[0]&&!u?NaN:!u||!p?e.s/0:e.s*0);for(a=Nr(s.e/De)+Nr(e.e/De),f=u.length,c=p.length,f<c&&(i=u,u=p,p=i,l=f,f=c,c=l),i=[],l=f+c,t=l;t--;)i.push(0);for(t=c;--t>=0;){for(n=0,r=f+t;r>t;)m=i[r]+p[t]*u[r-t-1]+n,i[r--]=m%jr|0,n=m/jr|0;i[r]=(i[r]+n)%jr|0}for(;!i[--l];)i.pop();return n?++a:i.shift(),e.d=i,e.e=va(i,a),$e?Ee(e,o.precision,o.rounding):e},ce.toBinary=function(e,n){return pi(this,2,e,n)},ce.toDecimalPlaces=ce.toDP=function(e,n){var a=this,t=a.constructor;return a=new t(a),e===void 0?a:(Ir(e,0,Tt),n===void 0?n=t.rounding:Ir(n,0,8),Ee(a,e+a.e+1,n))},ce.toExponential=function(e,n){var a,t=this,r=t.constructor;return e===void 0?a=it(t,!0):(Ir(e,0,Tt),n===void 0?n=r.rounding:Ir(n,0,8),t=Ee(new r(t),e+1,n),a=it(t,!0,e+1)),t.isNeg()&&!t.isZero()?"-"+a:a},ce.toFixed=function(e,n){var a,t,r=this,i=r.constructor;return e===void 0?a=it(r):(Ir(e,0,Tt),n===void 0?n=i.rounding:Ir(n,0,8),t=Ee(new i(r),e+r.e+1,n),a=it(t,!1,e+t.e+1)),r.isNeg()&&!r.isZero()?"-"+a:a},ce.toFraction=function(e){var n,a,t,r,i,l,m,f,c,s,o,u,p=this,v=p.d,h=p.constructor;if(!v)return new h(p);if(c=a=new h(1),t=f=new h(0),n=new h(t),i=n.e=Bo(v)-p.e-1,l=i%De,n.d[0]=hr(10,l<0?De+l:l),e==null)e=i>0?n:c;else{if(m=new h(e),!m.isInt()||m.lt(c))throw Error(Bt+m);e=m.gt(n)?i>0?n:c:m}for($e=!1,m=new h(br(v)),s=h.precision,h.precision=i=v.length*De*2;o=er(m,n,0,1,1),r=a.plus(o.times(t)),r.cmp(e)!=1;)a=t,t=r,r=c,c=f.plus(o.times(r)),f=r,r=n,n=m.minus(o.times(r)),m=r;return r=er(e.minus(a),t,0,1,1),f=f.plus(r.times(c)),a=a.plus(r.times(t)),f.s=c.s=p.s,u=er(c,t,i,1).minus(p).abs().cmp(er(f,a,i,1).minus(p).abs())<1?[c,t]:[f,a],h.precision=s,$e=!0,u},ce.toHexadecimal=ce.toHex=function(e,n){return pi(this,16,e,n)},ce.toNearest=function(e,n){var a=this,t=a.constructor;if(a=new t(a),e==null){if(!a.d)return a;e=new t(1),n=t.rounding}else{if(e=new t(e),n===void 0?n=t.rounding:Ir(n,0,8),!a.d)return e.s?a:e;if(!e.d)return e.s&&(e.s=a.s),e}return e.d[0]?($e=!1,a=er(a,e,0,n,1).times(e),$e=!0,Ee(a)):(e.s=a.s,a=e),a},ce.toNumber=function(){return+this},ce.toOctal=function(e,n){return pi(this,8,e,n)},ce.toPower=ce.pow=function(e){var n,a,t,r,i,l,m=this,f=m.constructor,c=+(e=new f(e));if(!m.d||!e.d||!m.d[0]||!e.d[0])return new f(hr(+m,c));if(m=new f(m),m.eq(1))return m;if(t=f.precision,i=f.rounding,e.eq(1))return Ee(m,t,i);if(n=Nr(e.e/De),n>=e.d.length-1&&(a=c<0?-c:c)<=Ov)return r=_o(f,m,a,t),e.s<0?new f(1).div(r):Ee(r,t,i);if(l=m.s,l<0){if(n<e.d.length-1)return new f(NaN);if((e.d[n]&1)==0&&(l=1),m.e==0&&m.d[0]==1&&m.d.length==1)return m.s=l,m}return a=hr(+m,c),n=a==0||!isFinite(a)?Nr(c*(Math.log("0."+br(m.d))/Math.LN10+m.e+1)):new f(a+"").e,n>f.maxE+1||n<f.minE-1?new f(n>0?l/0:0):($e=!1,f.rounding=m.s=1,a=Math.min(12,(n+"").length),r=mi(e.times($t(m,t+a)),t),r.d&&(r=Ee(r,t+5,1),_n(r.d,t,i)&&(n=t+10,r=Ee(mi(e.times($t(m,n+a)),n),n+5,1),+br(r.d).slice(t+1,t+15)+1==1e14&&(r=Ee(r,t+1,0)))),r.s=l,$e=!0,f.rounding=i,Ee(r,t,i))},ce.toPrecision=function(e,n){var a,t=this,r=t.constructor;return e===void 0?a=it(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(Ir(e,1,Tt),n===void 0?n=r.rounding:Ir(n,0,8),t=Ee(new r(t),e,n),a=it(t,e<=t.e||t.e<=r.toExpNeg,e)),t.isNeg()&&!t.isZero()?"-"+a:a},ce.toSignificantDigits=ce.toSD=function(e,n){var a=this,t=a.constructor;return e===void 0?(e=t.precision,n=t.rounding):(Ir(e,1,Tt),n===void 0?n=t.rounding:Ir(n,0,8)),Ee(new t(a),e,n)},ce.toString=function(){var e=this,n=e.constructor,a=it(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()&&!e.isZero()?"-"+a:a},ce.truncated=ce.trunc=function(){return Ee(new this.constructor(this),this.e+1,1)},ce.valueOf=ce.toJSON=function(){var e=this,n=e.constructor,a=it(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()?"-"+a:a};function br(e){var n,a,t,r=e.length-1,i="",l=e[0];if(r>0){for(i+=l,n=1;n<r;n++)t=e[n]+"",a=De-t.length,a&&(i+=_t(a)),i+=t;l=e[n],t=l+"",a=De-t.length,a&&(i+=_t(a))}else if(l===0)return"0";for(;l%10===0;)l/=10;return i+l}function Ir(e,n,a){if(e!==~~e||e<n||e>a)throw Error(Bt+e)}function _n(e,n,a,t){var r,i,l,m;for(i=e[0];i>=10;i/=10)--n;return--n<0?(n+=De,r=0):(r=Math.ceil((n+1)/De),n%=De),i=hr(10,De-n),m=e[r]%i|0,t==null?n<3?(n==0?m=m/100|0:n==1&&(m=m/10|0),l=a<4&&m==99999||a>3&&m==49999||m==5e4||m==0):l=(a<4&&m+1==i||a>3&&m+1==i/2)&&(e[r+1]/i/100|0)==hr(10,n-2)-1||(m==i/2||m==0)&&(e[r+1]/i/100|0)==0:n<4?(n==0?m=m/1e3|0:n==1?m=m/100|0:n==2&&(m=m/10|0),l=(t||a<4)&&m==9999||!t&&a>3&&m==4999):l=((t||a<4)&&m+1==i||!t&&a>3&&m+1==i/2)&&(e[r+1]/i/1e3|0)==hr(10,n-3)-1,l}function pa(e,n,a){for(var t,r=[0],i,l=0,m=e.length;l<m;){for(i=r.length;i--;)r[i]*=n;for(r[0]+=ci.indexOf(e.charAt(l++)),t=0;t<r.length;t++)r[t]>a-1&&(r[t+1]===void 0&&(r[t+1]=0),r[t+1]+=r[t]/a|0,r[t]%=a)}return r.reverse()}function Tv(e,n){var a,t,r;if(n.isZero())return n;t=n.d.length,t<32?(a=Math.ceil(t/3),r=(1/ga(4,a)).toString()):(a=16,r="2.3283064365386962890625e-10"),e.precision+=a,n=fn(e,1,n.times(r),new e(1));for(var i=a;i--;){var l=n.times(n);n=l.times(l).minus(l).times(8).plus(1)}return e.precision-=a,n}var er=function(){function e(t,r,i){var l,m=0,f=t.length;for(t=t.slice();f--;)l=t[f]*r+m,t[f]=l%i|0,m=l/i|0;return m&&t.unshift(m),t}function n(t,r,i,l){var m,f;if(i!=l)f=i>l?1:-1;else for(m=f=0;m<i;m++)if(t[m]!=r[m]){f=t[m]>r[m]?1:-1;break}return f}function a(t,r,i,l){for(var m=0;i--;)t[i]-=m,m=t[i]<r[i]?1:0,t[i]=m*l+t[i]-r[i];for(;!t[0]&&t.length>1;)t.shift()}return function(t,r,i,l,m,f){var c,s,o,u,p,v,h,b,w,N,g,y,x,d,A,S,O,M,_,E,$=t.constructor,z=t.s==r.s?1:-1,I=t.d,T=r.d;if(!I||!I[0]||!T||!T[0])return new $(!t.s||!r.s||(I?T&&I[0]==T[0]:!T)?NaN:I&&I[0]==0||!T?z*0:z/0);for(f?(p=1,s=t.e-r.e):(f=jr,p=De,s=Nr(t.e/p)-Nr(r.e/p)),_=T.length,O=I.length,w=new $(z),N=w.d=[],o=0;T[o]==(I[o]||0);o++);if(T[o]>(I[o]||0)&&s--,i==null?(d=i=$.precision,l=$.rounding):m?d=i+(t.e-r.e)+1:d=i,d<0)N.push(1),v=!0;else{if(d=d/p+2|0,o=0,_==1){for(u=0,T=T[0],d++;(o<O||u)&&d--;o++)A=u*f+(I[o]||0),N[o]=A/T|0,u=A%T|0;v=u||o<O}else{for(u=f/(T[0]+1)|0,u>1&&(T=e(T,u,f),I=e(I,u,f),_=T.length,O=I.length),S=_,g=I.slice(0,_),y=g.length;y<_;)g[y++]=0;E=T.slice(),E.unshift(0),M=T[0],T[1]>=f/2&&++M;do u=0,c=n(T,g,_,y),c<0?(x=g[0],_!=y&&(x=x*f+(g[1]||0)),u=x/M|0,u>1?(u>=f&&(u=f-1),h=e(T,u,f),b=h.length,y=g.length,c=n(h,g,b,y),c==1&&(u--,a(h,_<b?E:T,b,f))):(u==0&&(c=u=1),h=T.slice()),b=h.length,b<y&&h.unshift(0),a(g,h,y,f),c==-1&&(y=g.length,c=n(T,g,_,y),c<1&&(u++,a(g,_<y?E:T,y,f))),y=g.length):c===0&&(u++,g=[0]),N[o++]=u,c&&g[0]?g[y++]=I[S]||0:(g=[I[S]],y=1);while((S++<O||g[0]!==void 0)&&d--);v=g[0]!==void 0}N[0]||N.shift()}if(p==1)w.e=s,Eo=v;else{for(o=1,u=N[0];u>=10;u/=10)o++;w.e=o+s*p-1,Ee(w,m?i+w.e+1:i,l,v)}return w}}();function Ee(e,n,a,t){var r,i,l,m,f,c,s,o,u,p=e.constructor;e:if(n!=null){if(o=e.d,!o)return e;for(r=1,m=o[0];m>=10;m/=10)r++;if(i=n-r,i<0)i+=De,l=n,s=o[u=0],f=s/hr(10,r-l-1)%10|0;else if(u=Math.ceil((i+1)/De),m=o.length,u>=m)if(t){for(;m++<=u;)o.push(0);s=f=0,r=1,i%=De,l=i-De+1}else break e;else{for(s=m=o[u],r=1;m>=10;m/=10)r++;i%=De,l=i-De+r,f=l<0?0:s/hr(10,r-l-1)%10|0}if(t=t||n<0||o[u+1]!==void 0||(l<0?s:s%hr(10,r-l-1)),c=a<4?(f||t)&&(a==0||a==(e.s<0?3:2)):f>5||f==5&&(a==4||t||a==6&&(i>0?l>0?s/hr(10,r-l):0:o[u-1])%10&1||a==(e.s<0?8:7)),n<1||!o[0])return o.length=0,c?(n-=e.e+1,o[0]=hr(10,(De-n%De)%De),e.e=-n||0):o[0]=e.e=0,e;if(i==0?(o.length=u,m=1,u--):(o.length=u+1,m=hr(10,De-i),o[u]=l>0?(s/hr(10,r-l)%hr(10,l)|0)*m:0),c)for(;;)if(u==0){for(i=1,l=o[0];l>=10;l/=10)i++;for(l=o[0]+=m,m=1;l>=10;l/=10)m++;i!=m&&(e.e++,o[0]==jr&&(o[0]=1));break}else{if(o[u]+=m,o[u]!=jr)break;o[u--]=0,m=1}for(i=o.length;o[--i]===0;)o.pop()}return $e&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function it(e,n,a){if(!e.isFinite())return qo(e);var t,r=e.e,i=br(e.d),l=i.length;return n?(a&&(t=a-l)>0?i=i.charAt(0)+"."+i.slice(1)+_t(t):l>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):r<0?(i="0."+_t(-r-1)+i,a&&(t=a-l)>0&&(i+=_t(t))):r>=l?(i+=_t(r+1-l),a&&(t=a-r-1)>0&&(i=i+"."+_t(t))):((t=r+1)<l&&(i=i.slice(0,t)+"."+i.slice(t)),a&&(t=a-l)>0&&(r+1===l&&(i+="."),i+=_t(t))),i}function va(e,n){var a=e[0];for(n*=De;a>=10;a/=10)n++;return n}function ha(e,n,a){if(n>Dv)throw $e=!0,a&&(e.precision=a),Error(Co);return Ee(new e(fa),n,1,!0)}function ot(e,n,a){if(n>li)throw Error(Co);return Ee(new e(la),n,a,!0)}function Bo(e){var n=e.length-1,a=n*De+1;if(n=e[n],n){for(;n%10==0;n/=10)a--;for(n=e[0];n>=10;n/=10)a++}return a}function _t(e){for(var n="";e--;)n+="0";return n}function _o(e,n,a,t){var r,i=new e(1),l=Math.ceil(t/De+4);for($e=!1;;){if(a%2&&(i=i.times(n),Fo(i.d,l)&&(r=!0)),a=Nr(a/2),a===0){a=i.d.length-1,r&&i.d[a]===0&&++i.d[a];break}n=n.times(n),Fo(n.d,l)}return $e=!0,i}function $o(e){return e.d[e.d.length-1]&1}function Io(e,n,a){for(var t,r,i=new e(n[0]),l=0;++l<n.length;){if(r=new e(n[l]),!r.s){i=r;break}t=i.cmp(r),(t===a||t===0&&i.s===a)&&(i=r)}return i}function mi(e,n){var a,t,r,i,l,m,f,c=0,s=0,o=0,u=e.constructor,p=u.rounding,v=u.precision;if(!e.d||!e.d[0]||e.e>17)return new u(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(n==null?($e=!1,f=v):f=n,m=new u(.03125);e.e>-2;)e=e.times(m),o+=5;for(t=Math.log(hr(2,o))/Math.LN10*2+5|0,f+=t,a=i=l=new u(1),u.precision=f;;){if(i=Ee(i.times(e),f,1),a=a.times(++s),m=l.plus(er(i,a,f,1)),br(m.d).slice(0,f)===br(l.d).slice(0,f)){for(r=o;r--;)l=Ee(l.times(l),f,1);if(n==null)if(c<3&&_n(l.d,f-t,p,c))u.precision=f+=10,a=i=m=new u(1),s=0,c++;else return Ee(l,u.precision=v,p,$e=!0);else return u.precision=v,l}l=m}}function $t(e,n){var a,t,r,i,l,m,f,c,s,o,u,p=1,v=10,h=e,b=h.d,w=h.constructor,N=w.rounding,g=w.precision;if(h.s<0||!b||!b[0]||!h.e&&b[0]==1&&b.length==1)return new w(b&&!b[0]?-1/0:h.s!=1?NaN:b?0:h);if(n==null?($e=!1,s=g):s=n,w.precision=s+=v,a=br(b),t=a.charAt(0),Math.abs(i=h.e)<15e14){for(;t<7&&t!=1||t==1&&a.charAt(1)>3;)h=h.times(e),a=br(h.d),t=a.charAt(0),p++;i=h.e,t>1?(h=new w("0."+a),i++):h=new w(t+"."+a.slice(1))}else return c=ha(w,s+2,g).times(i+""),h=$t(new w(t+"."+a.slice(1)),s-v).plus(c),w.precision=g,n==null?Ee(h,g,N,$e=!0):h;for(o=h,f=l=h=er(h.minus(1),h.plus(1),s,1),u=Ee(h.times(h),s,1),r=3;;){if(l=Ee(l.times(u),s,1),c=f.plus(er(l,new w(r),s,1)),br(c.d).slice(0,s)===br(f.d).slice(0,s))if(f=f.times(2),i!==0&&(f=f.plus(ha(w,s+2,g).times(i+""))),f=er(f,new w(p),s,1),n==null)if(_n(f.d,s-v,N,m))w.precision=s+=v,c=l=h=er(o.minus(1),o.plus(1),s,1),u=Ee(h.times(h),s,1),r=m=1;else return Ee(f,w.precision=g,N,$e=!0);else return w.precision=g,f;f=c,r+=2}}function qo(e){return String(e.s*e.s/0)}function da(e,n){var a,t,r;for((a=n.indexOf("."))>-1&&(n=n.replace(".","")),(t=n.search(/e/i))>0?(a<0&&(a=t),a+=+n.slice(t+1),n=n.substring(0,t)):a<0&&(a=n.length),t=0;n.charCodeAt(t)===48;t++);for(r=n.length;n.charCodeAt(r-1)===48;--r);if(n=n.slice(t,r),n){if(r-=t,e.e=a=a-t-1,e.d=[],t=(a+1)%De,a<0&&(t+=De),t<r){for(t&&e.d.push(+n.slice(0,t)),r-=De;t<r;)e.d.push(+n.slice(t,t+=De));n=n.slice(t),t=De-n.length}else t-=r;for(;t--;)n+="0";e.d.push(+n),$e&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function Bv(e,n){var a,t,r,i,l,m,f,c,s;if(n.indexOf("_")>-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),To.test(n))return da(e,n)}else if(n==="Infinity"||n==="NaN")return+n||(e.s=NaN),e.e=NaN,e.d=null,e;if(Ev.test(n))a=16,n=n.toLowerCase();else if(Sv.test(n))a=2;else if(Cv.test(n))a=8;else throw Error(Bt+n);for(i=n.search(/p/i),i>0?(f=+n.slice(i+1),n=n.substring(2,i)):n=n.slice(2),i=n.indexOf("."),l=i>=0,t=e.constructor,l&&(n=n.replace(".",""),m=n.length,i=m-i,r=_o(t,new t(a),i,i*2)),c=pa(n,a,jr),s=c.length-1,i=s;c[i]===0;--i)c.pop();return i<0?new t(e.s*0):(e.e=va(c,s),e.d=c,$e=!1,l&&(e=er(e,r,m*4)),f&&(e=e.times(Math.abs(f)<54?hr(2,f):It.pow(2,f))),$e=!0,e)}function _v(e,n){var a,t=n.d.length;if(t<3)return n.isZero()?n:fn(e,2,n,n);a=1.4*Math.sqrt(t),a=a>16?16:a|0,n=n.times(1/ga(5,a)),n=fn(e,2,n,n);for(var r,i=new e(5),l=new e(16),m=new e(20);a--;)r=n.times(n),n=n.times(i.plus(r.times(l.times(r).minus(m))));return n}function fn(e,n,a,t,r){var i,l,m,f,c=e.precision,s=Math.ceil(c/De);for($e=!1,f=a.times(a),m=new e(t);;){if(l=er(m.times(f),new e(n++*n++),c,1),m=r?t.plus(l):t.minus(l),t=er(l.times(f),new e(n++*n++),c,1),l=m.plus(t),l.d[s]!==void 0){for(i=s;l.d[i]===m.d[i]&&i--;);if(i==-1)break}i=m,m=t,t=l,l=i}return $e=!0,l.d.length=s+1,l}function ga(e,n){for(var a=e;--n;)a*=e;return a}function Ro(e,n){var a,t=n.s<0,r=ot(e,e.precision,1),i=r.times(.5);if(n=n.abs(),n.lte(i))return yt=t?4:1,n;if(a=n.divToInt(r),a.isZero())yt=t?3:2;else{if(n=n.minus(a.times(r)),n.lte(i))return yt=$o(a)?t?2:3:t?4:1,n;yt=$o(a)?t?1:4:t?3:2}return n.minus(r).abs()}function pi(e,n,a,t){var r,i,l,m,f,c,s,o,u,p=e.constructor,v=a!==void 0;if(v?(Ir(a,1,Tt),t===void 0?t=p.rounding:Ir(t,0,8)):(a=p.precision,t=p.rounding),!e.isFinite())s=qo(e);else{for(s=it(e),l=s.indexOf("."),v?(r=2,n==16?a=a*4-3:n==8&&(a=a*3-2)):r=n,l>=0&&(s=s.replace(".",""),u=new p(1),u.e=s.length-l,u.d=pa(it(u),10,r),u.e=u.d.length),o=pa(s,10,r),i=f=o.length;o[--f]==0;)o.pop();if(!o[0])s=v?"0p+0":"0";else{if(l<0?i--:(e=new p(e),e.d=o,e.e=i,e=er(e,u,a,t,0,r),o=e.d,i=e.e,c=Eo),l=o[a],m=r/2,c=c||o[a+1]!==void 0,c=t<4?(l!==void 0||c)&&(t===0||t===(e.s<0?3:2)):l>m||l===m&&(t===4||c||t===6&&o[a-1]&1||t===(e.s<0?8:7)),o.length=a,c)for(;++o[--a]>r-1;)o[a]=0,a||(++i,o.unshift(1));for(f=o.length;!o[f-1];--f);for(l=0,s="";l<f;l++)s+=ci.charAt(o[l]);if(v){if(f>1)if(n==16||n==8){for(l=n==16?4:3,--f;f%l;f++)s+="0";for(o=pa(s,r,n),f=o.length;!o[f-1];--f);for(l=1,s="1.";l<f;l++)s+=ci.charAt(o[l])}else s=s.charAt(0)+"."+s.slice(1);s=s+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)s="0"+s;s="0."+s}else if(++i>f)for(i-=f;i--;)s+="0";else i<f&&(s=s.slice(0,i)+"."+s.slice(i))}s=(n==16?"0x":n==2?"0b":n==8?"0o":"")+s}return e.s<0?"-"+s:s}function Fo(e,n){if(e.length>n)return e.length=n,!0}function $v(e){return new this(e).abs()}function Iv(e){return new this(e).acos()}function qv(e){return new this(e).acosh()}function Rv(e,n){return new this(e).plus(n)}function Fv(e){return new this(e).asin()}function zv(e){return new this(e).asinh()}function Pv(e){return new this(e).atan()}function Uv(e){return new this(e).atanh()}function Lv(e,n){e=new this(e),n=new this(n);var a,t=this.precision,r=this.rounding,i=t+4;return!e.s||!n.s?a=new this(NaN):!e.d&&!n.d?(a=ot(this,i,1).times(n.s>0?.25:.75),a.s=e.s):!n.d||e.isZero()?(a=n.s<0?ot(this,t,r):new this(0),a.s=e.s):!e.d||n.isZero()?(a=ot(this,i,1).times(.5),a.s=e.s):n.s<0?(this.precision=i,this.rounding=1,a=this.atan(er(e,n,i,1)),n=ot(this,i,1),this.precision=t,this.rounding=r,a=e.s<0?a.minus(n):a.plus(n)):a=this.atan(er(e,n,i,1)),a}function kv(e){return new this(e).cbrt()}function Hv(e){return Ee(e=new this(e),e.e+1,2)}function Gv(e,n,a){return new this(e).clamp(n,a)}function Vv(e){if(!e||typeof e!="object")throw Error(ma+"Object expected");var n,a,t,r=e.defaults===!0,i=["precision",1,Tt,"rounding",0,8,"toExpNeg",-cn,0,"toExpPos",0,cn,"maxE",0,cn,"minE",-cn,0,"modulo",0,9];for(n=0;n<i.length;n+=3)if(a=i[n],r&&(this[a]=fi[a]),(t=e[a])!==void 0)if(Nr(t)===t&&t>=i[n+1]&&t<=i[n+2])this[a]=t;else throw Error(Bt+a+": "+t);if(a="crypto",r&&(this[a]=fi[a]),(t=e[a])!==void 0)if(t===!0||t===!1||t===0||t===1)if(t)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[a]=!0;else throw Error(Oo);else this[a]=!1;else throw Error(Bt+a+": "+t);return this}function Zv(e){return new this(e).cos()}function Xv(e){return new this(e).cosh()}function zo(e){var n,a,t;function r(i){var l,m,f,c=this;if(!(c instanceof r))return new r(i);if(c.constructor=r,Po(i)){c.s=i.s,$e?!i.d||i.e>r.maxE?(c.e=NaN,c.d=null):i.e<r.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(f=typeof i,f==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(l=0,m=i;m>=10;m/=10)l++;$e?l>r.maxE?(c.e=NaN,c.d=null):l<r.minE?(c.e=0,c.d=[0]):(c.e=l,c.d=[i]):(c.e=l,c.d=[i]);return}if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return da(c,i.toString())}if(f==="string")return(m=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(m===43&&(i=i.slice(1)),c.s=1),To.test(i)?da(c,i):Bv(c,i);if(f==="bigint")return i<0?(i=-i,c.s=-1):c.s=1,da(c,i.toString());throw Error(Bt+i)}if(r.prototype=ce,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Vv,r.clone=zo,r.isDecimal=Po,r.abs=$v,r.acos=Iv,r.acosh=qv,r.add=Rv,r.asin=Fv,r.asinh=zv,r.atan=Pv,r.atanh=Uv,r.atan2=Lv,r.cbrt=kv,r.ceil=Hv,r.clamp=Gv,r.cos=Zv,r.cosh=Xv,r.div=Yv,r.exp=Wv,r.floor=Jv,r.hypot=Qv,r.ln=Kv,r.log=jv,r.log10=rh,r.log2=eh,r.max=th,r.min=nh,r.mod=ah,r.mul=ih,r.pow=oh,r.random=sh,r.round=uh,r.sign=ch,r.sin=fh,r.sinh=lh,r.sqrt=mh,r.sub=ph,r.sum=vh,r.tan=hh,r.tanh=dh,r.trunc=gh,e===void 0&&(e={}),e&&e.defaults!==!0)for(t=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<t.length;)e.hasOwnProperty(a=t[n++])||(e[a]=this[a]);return r.config(e),r}function Yv(e,n){return new this(e).div(n)}function Wv(e){return new this(e).exp()}function Jv(e){return Ee(e=new this(e),e.e+1,3)}function Qv(){var e,n,a=new this(0);for($e=!1,e=0;e<arguments.length;)if(n=new this(arguments[e++]),n.d)a.d&&(a=a.plus(n.times(n)));else{if(n.s)return $e=!0,new this(1/0);a=n}return $e=!0,a.sqrt()}function Po(e){return e instanceof It||e&&e.toStringTag===Do||!1}function Kv(e){return new this(e).ln()}function jv(e,n){return new this(e).log(n)}function eh(e){return new this(e).log(2)}function rh(e){return new this(e).log(10)}function th(){return Io(this,arguments,-1)}function nh(){return Io(this,arguments,1)}function ah(e,n){return new this(e).mod(n)}function ih(e,n){return new this(e).mul(n)}function oh(e,n){return new this(e).pow(n)}function sh(e){var n,a,t,r,i=0,l=new this(1),m=[];if(e===void 0?e=this.precision:Ir(e,1,Tt),t=Math.ceil(e/De),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(t));i<t;)r=n[i],r>=429e7?n[i]=crypto.getRandomValues(new Uint32Array(1))[0]:m[i++]=r%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(t*=4);i<t;)r=n[i]+(n[i+1]<<8)+(n[i+2]<<16)+((n[i+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(n,i):(m.push(r%1e7),i+=4);i=t/4}else throw Error(Oo);else for(;i<t;)m[i++]=Math.random()*1e7|0;for(t=m[--i],e%=De,t&&e&&(r=hr(10,De-e),m[i]=(t/r|0)*r);m[i]===0;i--)m.pop();if(i<0)a=0,m=[0];else{for(a=-1;m[0]===0;a-=De)m.shift();for(t=1,r=m[0];r>=10;r/=10)t++;t<De&&(a-=De-t)}return l.e=a,l.d=m,l}function uh(e){return Ee(e=new this(e),e.e+1,this.rounding)}function ch(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function fh(e){return new this(e).sin()}function lh(e){return new this(e).sinh()}function mh(e){return new this(e).sqrt()}function ph(e,n){return new this(e).sub(n)}function vh(){var e=0,n=arguments,a=new this(n[e]);for($e=!1;a.s&&++e<n.length;)a=a.plus(n[e]);return $e=!0,Ee(a,this.precision,this.rounding)}function hh(e){return new this(e).tan()}function dh(e){return new this(e).tanh()}function gh(e){return Ee(e=new this(e),e.e+1,1)}ce[Symbol.for("nodejs.util.inspect.custom")]=ce.toString,ce[Symbol.toStringTag]="Decimal";var It=ce.constructor=zo(fi);fa=new It(fa),la=new It(la);var yh="BigNumber",xh=["?on","config"],bh=R(yh,xh,e=>{var{on:n,config:a}=e,t=It.clone({precision:a.precision,modulo:It.EUCLID});return t.prototype=Object.create(t.prototype),t.prototype.type="BigNumber",t.prototype.isBigNumber=!0,t.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},t.fromJSON=function(r){return new t(r.value)},n&&n("config",function(r,i){r.precision!==i.precision&&t.config({precision:r.precision})}),t},{isClass:!0}),vi={exports:{}};/**
15
- * @license Complex.js v2.1.1 12/05/2020
16
- *
17
- * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
18
- * Dual licensed under the MIT or GPL Version 2 licenses.
19
- **/var Uo;function wh(){return Uo||(Uo=1,function(e,n){(function(a){var t=Math.cosh||function(o){return Math.abs(o)<1e-9?1-o:(Math.exp(o)+Math.exp(-o))*.5},r=Math.sinh||function(o){return Math.abs(o)<1e-9?o:(Math.exp(o)-Math.exp(-o))*.5},i=function(o){var u=Math.PI/4;if(-u>o||o>u)return Math.cos(o)-1;var p=o*o;return p*(p*(p*(p*(p*(p*(p*(p/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},l=function(o,u){var p=Math.abs(o),v=Math.abs(u);return p<3e3&&v<3e3?Math.sqrt(p*p+v*v):(p<v?(p=v,v=o/u):v=u/o,p*Math.sqrt(1+v*v))},m=function(){throw SyntaxError("Invalid Param")};function f(o,u){var p=Math.abs(o),v=Math.abs(u);return o===0?Math.log(v):u===0?Math.log(p):p<3e3&&v<3e3?Math.log(o*o+u*u)*.5:(o=o/2,u=u/2,.5*Math.log(o*o+u*u)+Math.LN2)}var c=function(o,u){var p={re:0,im:0};if(o==null)p.re=p.im=0;else if(u!==void 0)p.re=o,p.im=u;else switch(typeof o){case"object":if("im"in o&&"re"in o)p.re=o.re,p.im=o.im;else if("abs"in o&&"arg"in o){if(!Number.isFinite(o.abs)&&Number.isFinite(o.arg))return s.INFINITY;p.re=o.abs*Math.cos(o.arg),p.im=o.abs*Math.sin(o.arg)}else if("r"in o&&"phi"in o){if(!Number.isFinite(o.r)&&Number.isFinite(o.phi))return s.INFINITY;p.re=o.r*Math.cos(o.phi),p.im=o.r*Math.sin(o.phi)}else o.length===2?(p.re=o[0],p.im=o[1]):m();break;case"string":p.im=p.re=0;var v=o.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),h=1,b=0;v===null&&m();for(var w=0;w<v.length;w++){var N=v[w];N===" "||N===" "||N===`
20
- `||(N==="+"?h++:N==="-"?b++:N==="i"||N==="I"?(h+b===0&&m(),v[w+1]!==" "&&!isNaN(v[w+1])?(p.im+=parseFloat((b%2?"-":"")+v[w+1]),w++):p.im+=parseFloat((b%2?"-":"")+"1"),h=b=0):((h+b===0||isNaN(N))&&m(),v[w+1]==="i"||v[w+1]==="I"?(p.im+=parseFloat((b%2?"-":"")+N),w++):p.re+=parseFloat((b%2?"-":"")+N),h=b=0))}h+b>0&&m();break;case"number":p.im=0,p.re=o;break;default:m()}return isNaN(p.re)||isNaN(p.im),p};function s(o,u){if(!(this instanceof s))return new s(o,u);var p=c(o,u);this.re=p.re,this.im=p.im}s.prototype={re:0,im:0,sign:function(){var o=this.abs();return new s(this.re/o,this.im/o)},add:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:new s(this.re+p.re,this.im+p.im)},sub:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:new s(this.re-p.re,this.im-p.im)},mul:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isZero()||this.isZero()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:p.im===0&&this.im===0?new s(this.re*p.re,0):new s(this.re*p.re-this.im*p.im,this.re*p.im+this.im*p.re)},div:function(o,u){var p=new s(o,u);if(this.isZero()&&p.isZero()||this.isInfinite()&&p.isInfinite())return s.NAN;if(this.isInfinite()||p.isZero())return s.INFINITY;if(this.isZero()||p.isInfinite())return s.ZERO;o=this.re,u=this.im;var v=p.re,h=p.im,b,w;return h===0?new s(o/v,u/v):Math.abs(v)<Math.abs(h)?(w=v/h,b=v*w+h,new s((o*w+u)/b,(u*w-o)/b)):(w=h/v,b=h*w+v,new s((o+u*w)/b,(u-o*w)/b))},pow:function(o,u){var p=new s(o,u);if(o=this.re,u=this.im,p.isZero())return s.ONE;if(p.im===0){if(u===0&&o>0)return new s(Math.pow(o,p.re),0);if(o===0)switch((p.re%4+4)%4){case 0:return new s(Math.pow(u,p.re),0);case 1:return new s(0,Math.pow(u,p.re));case 2:return new s(-Math.pow(u,p.re),0);case 3:return new s(0,-Math.pow(u,p.re))}}if(o===0&&u===0&&p.re>0&&p.im>=0)return s.ZERO;var v=Math.atan2(u,o),h=f(o,u);return o=Math.exp(p.re*h-p.im*v),u=p.im*h+p.re*v,new s(o*Math.cos(u),o*Math.sin(u))},sqrt:function(){var o=this.re,u=this.im,p=this.abs(),v,h;if(o>=0){if(u===0)return new s(Math.sqrt(o),0);v=.5*Math.sqrt(2*(p+o))}else v=Math.abs(u)/Math.sqrt(2*(p-o));return o<=0?h=.5*Math.sqrt(2*(p-o)):h=Math.abs(u)/Math.sqrt(2*(p+o)),new s(v,u<0?-h:h)},exp:function(){var o=Math.exp(this.re);return this.im,new s(o*Math.cos(this.im),o*Math.sin(this.im))},expm1:function(){var o=this.re,u=this.im;return new s(Math.expm1(o)*Math.cos(u)+i(u),Math.exp(o)*Math.sin(u))},log:function(){var o=this.re,u=this.im;return new s(f(o,u),Math.atan2(u,o))},abs:function(){return l(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var o=this.re,u=this.im;return new s(Math.sin(o)*t(u),Math.cos(o)*r(u))},cos:function(){var o=this.re,u=this.im;return new s(Math.cos(o)*t(u),-Math.sin(o)*r(u))},tan:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)+t(u);return new s(Math.sin(o)/p,r(u)/p)},cot:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)-t(u);return new s(-Math.sin(o)/p,r(u)/p)},sec:function(){var o=this.re,u=this.im,p=.5*t(2*u)+.5*Math.cos(2*o);return new s(Math.cos(o)*t(u)/p,Math.sin(o)*r(u)/p)},csc:function(){var o=this.re,u=this.im,p=.5*t(2*u)-.5*Math.cos(2*o);return new s(Math.sin(o)*t(u)/p,-Math.cos(o)*r(u)/p)},asin:function(){var o=this.re,u=this.im,p=new s(u*u-o*o+1,-2*o*u).sqrt(),v=new s(p.re-u,p.im+o).log();return new s(v.im,-v.re)},acos:function(){var o=this.re,u=this.im,p=new s(u*u-o*o+1,-2*o*u).sqrt(),v=new s(p.re-u,p.im+o).log();return new s(Math.PI/2-v.im,v.re)},atan:function(){var o=this.re,u=this.im;if(o===0){if(u===1)return new s(0,1/0);if(u===-1)return new s(0,-1/0)}var p=o*o+(1-u)*(1-u),v=new s((1-u*u-o*o)/p,-2*o/p).log();return new s(-.5*v.im,.5*v.re)},acot:function(){var o=this.re,u=this.im;if(u===0)return new s(Math.atan2(1,o),0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).atan():new s(o!==0?o/0:0,u!==0?-u/0:0).atan()},asec:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(0,1/0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).acos():new s(o!==0?o/0:0,u!==0?-u/0:0).acos()},acsc:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(Math.PI/2,1/0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).asin():new s(o!==0?o/0:0,u!==0?-u/0:0).asin()},sinh:function(){var o=this.re,u=this.im;return new s(r(o)*Math.cos(u),t(o)*Math.sin(u))},cosh:function(){var o=this.re,u=this.im;return new s(t(o)*Math.cos(u),r(o)*Math.sin(u))},tanh:function(){var o=2*this.re,u=2*this.im,p=t(o)+Math.cos(u);return new s(r(o)/p,Math.sin(u)/p)},coth:function(){var o=2*this.re,u=2*this.im,p=t(o)-Math.cos(u);return new s(r(o)/p,-Math.sin(u)/p)},csch:function(){var o=this.re,u=this.im,p=Math.cos(2*u)-t(2*o);return new s(-2*r(o)*Math.cos(u)/p,2*t(o)*Math.sin(u)/p)},sech:function(){var o=this.re,u=this.im,p=Math.cos(2*u)+t(2*o);return new s(2*t(o)*Math.cos(u)/p,-2*r(o)*Math.sin(u)/p)},asinh:function(){var o=this.im;this.im=-this.re,this.re=o;var u=this.asin();return this.re=-this.im,this.im=o,o=u.re,u.re=-u.im,u.im=o,u},acosh:function(){var o=this.acos();if(o.im<=0){var u=o.re;o.re=-o.im,o.im=u}else{var u=o.im;o.im=-o.re,o.re=u}return o},atanh:function(){var o=this.re,u=this.im,p=o>1&&u===0,v=1-o,h=1+o,b=v*v+u*u,w=b!==0?new s((h*v-u*u)/b,(u*v+h*u)/b):new s(o!==-1?o/0:0,u!==0?u/0:0),N=w.re;return w.re=f(w.re,w.im)/2,w.im=Math.atan2(w.im,N)/2,p&&(w.im=-w.im),w},acoth:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(0,Math.PI/2);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).atanh():new s(o!==0?o/0:0,u!==0?-u/0:0).atanh()},acsch:function(){var o=this.re,u=this.im;if(u===0)return new s(o!==0?Math.log(o+Math.sqrt(o*o+1)):1/0,0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).asinh():new s(o!==0?o/0:0,u!==0?-u/0:0).asinh()},asech:function(){var o=this.re,u=this.im;if(this.isZero())return s.INFINITY;var p=o*o+u*u;return p!==0?new s(o/p,-u/p).acosh():new s(o!==0?o/0:0,u!==0?-u/0:0).acosh()},inverse:function(){if(this.isZero())return s.INFINITY;if(this.isInfinite())return s.ZERO;var o=this.re,u=this.im,p=o*o+u*u;return new s(o/p,-u/p)},conjugate:function(){return new s(this.re,-this.im)},neg:function(){return new s(-this.re,-this.im)},ceil:function(o){return o=Math.pow(10,o||0),new s(Math.ceil(this.re*o)/o,Math.ceil(this.im*o)/o)},floor:function(o){return o=Math.pow(10,o||0),new s(Math.floor(this.re*o)/o,Math.floor(this.im*o)/o)},round:function(o){return o=Math.pow(10,o||0),new s(Math.round(this.re*o)/o,Math.round(this.im*o)/o)},equals:function(o,u){var p=new s(o,u);return Math.abs(p.re-this.re)<=s.EPSILON&&Math.abs(p.im-this.im)<=s.EPSILON},clone:function(){return new s(this.re,this.im)},toString:function(){var o=this.re,u=this.im,p="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(o)<s.EPSILON&&(o=0),Math.abs(u)<s.EPSILON&&(u=0),u===0?p+o:(o!==0?(p+=o,p+=" ",u<0?(u=-u,p+="-"):p+="+",p+=" "):u<0&&(u=-u,p+="-"),u!==1&&(p+=u),p+"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())}},s.ZERO=new s(0,0),s.ONE=new s(1,0),s.I=new s(0,1),s.PI=new s(Math.PI,0),s.E=new s(Math.E,0),s.INFINITY=new s(1/0,1/0),s.NAN=new s(NaN,NaN),s.EPSILON=1e-15,Object.defineProperty(s,"__esModule",{value:!0}),s.default=s,s.Complex=s,e.exports=s})()}(vi)),vi.exports}var Nh=wh();const qr=Tn(Nh);var Mh="Complex",Ah=[],Sh=R(Mh,Ah,()=>(qr.prototype.type="Complex",qr.prototype.isComplex=!0,qr.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},qr.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},qr.prototype.format=function(e){var n="",a=this.im,t=this.re,r=Ht(this.re,e),i=Ht(this.im,e),l=Be(e)?e:e?e.precision:null;if(l!==null){var m=Math.pow(10,-l);Math.abs(t/a)<m&&(t=0),Math.abs(a/t)<m&&(a=0)}return a===0?n=r:t===0?a===1?n="i":a===-1?n="-i":n=i+"i":a<0?a===-1?n=r+" - i":n=r+" - "+i.substring(1)+"i":a===1?n=r+" + i":n=r+" + "+i+"i",n},qr.fromPolar=function(e){switch(arguments.length){case 1:{var n=arguments[0];if(typeof n=="object")return qr(n);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var a=arguments[0],t=arguments[1];if(Be(a)){if(ht(t)&&t.hasBase("ANGLE")&&(t=t.toNumber("rad")),Be(t))return new qr({r:a,phi:t});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")}},qr.prototype.valueOf=qr.prototype.toString,qr.fromJSON=function(e){return new qr(e)},qr.compare=function(e,n){return e.re>n.re?1:e.re<n.re?-1:e.im>n.im?1:e.im<n.im?-1:0},qr),{isClass:!0});/**
21
- * @license Fraction.js v4.3.7 31/08/2023
22
- * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
23
- *
24
- * Copyright (c) 2023, Robert Eisele (robert@raw.org)
25
- * Dual licensed under the MIT or GPL Version 2 licenses.
26
- **/var Eh=2e3,Se={s:1,n:0,d:1};function xt(e,n){if(isNaN(e=parseInt(e,10)))throw ya();return e*n}function ur(e,n){if(n===0)throw hi();var a=Object.create(zr.prototype);a.s=e<0?-1:1,e=e<0?-e:e;var t=ln(e,n);return a.n=e/t,a.d=n/t,a}function Lo(e){for(var n={},a=e,t=2,r=4;r<=a;){for(;a%t===0;)a/=t,n[t]=(n[t]||0)+1;r+=1+2*t++}return a!==e?a>1&&(n[a]=(n[a]||0)+1):n[e]=(n[e]||0)+1,n}var Fr=function(e,n){var a=0,t=1,r=1,i=0,l=0,m=0,f=1,c=1,s=0,o=1,u=1,p=1,v=1e7,h;if(e!=null)if(n!==void 0){if(a=e,t=n,r=a*t,a%1!==0||t%1!==0)throw Th()}else switch(typeof e){case"object":{if("d"in e&&"n"in e)a=e.n,t=e.d,"s"in e&&(a*=e.s);else if(0 in e)a=e[0],1 in e&&(t=e[1]);else throw ya();r=a*t;break}case"number":{if(e<0&&(r=e,e=-e),e%1===0)a=e;else if(e>0){for(e>=1&&(c=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)),e/=c);o<=v&&p<=v;)if(h=(s+u)/(o+p),e===h){o+p<=v?(a=s+u,t=o+p):p>o?(a=u,t=p):(a=s,t=o);break}else e>h?(s+=u,o+=p):(u+=s,p+=o),o>v?(a=u,t=p):(a=s,t=o);a*=c}else(isNaN(e)||isNaN(n))&&(t=a=NaN);break}case"string":{if(o=e.match(/\d+|./g),o===null)throw ya();if(o[s]==="-"?(r=-1,s++):o[s]==="+"&&s++,o.length===s+1?l=xt(o[s++],r):o[s+1]==="."||o[s]==="."?(o[s]!=="."&&(i=xt(o[s++],r)),s++,(s+1===o.length||o[s+1]==="("&&o[s+3]===")"||o[s+1]==="'"&&o[s+3]==="'")&&(l=xt(o[s],r),f=Math.pow(10,o[s].length),s++),(o[s]==="("&&o[s+2]===")"||o[s]==="'"&&o[s+2]==="'")&&(m=xt(o[s+1],r),c=Math.pow(10,o[s+1].length)-1,s+=3)):o[s+1]==="/"||o[s+1]===":"?(l=xt(o[s],r),f=xt(o[s+2],1),s+=3):o[s+3]==="/"&&o[s+1]===" "&&(i=xt(o[s],r),l=xt(o[s+2],r),f=xt(o[s+4],1),s+=5),o.length<=s){t=f*c,r=a=m+t*i+c*l;break}}default:throw ya()}if(t===0)throw hi();Se.s=r<0?-1:1,Se.n=Math.abs(a),Se.d=Math.abs(t)};function Ch(e,n,a){for(var t=1;n>0;e=e*e%a,n>>=1)n&1&&(t=t*e%a);return t}function Oh(e,n){for(;n%2===0;n/=2);for(;n%5===0;n/=5);if(n===1)return 0;for(var a=10%n,t=1;a!==1;t++)if(a=a*10%n,t>Eh)return 0;return t}function Dh(e,n,a){for(var t=1,r=Ch(10,a,n),i=0;i<300;i++){if(t===r)return i;t=t*10%n,r=r*10%n}return 0}function ln(e,n){if(!e)return n;if(!n)return e;for(;;){if(e%=n,!e)return n;if(n%=e,!n)return e}}function zr(e,n){if(Fr(e,n),this instanceof zr)e=ln(Se.d,Se.n),this.s=Se.s,this.n=Se.n/e,this.d=Se.d/e;else return ur(Se.s*Se.n,Se.d)}var hi=function(){return new Error("Division by Zero")},ya=function(){return new Error("Invalid argument")},Th=function(){return new Error("Parameters must be integer")};zr.prototype={s:1,n:0,d:1,abs:function(){return ur(this.n,this.d)},neg:function(){return ur(-this.s*this.n,this.d)},add:function(e,n){return Fr(e,n),ur(this.s*this.n*Se.d+Se.s*this.d*Se.n,this.d*Se.d)},sub:function(e,n){return Fr(e,n),ur(this.s*this.n*Se.d-Se.s*this.d*Se.n,this.d*Se.d)},mul:function(e,n){return Fr(e,n),ur(this.s*Se.s*this.n*Se.n,this.d*Se.d)},div:function(e,n){return Fr(e,n),ur(this.s*Se.s*this.n*Se.d,this.d*Se.n)},clone:function(){return ur(this.s*this.n,this.d)},mod:function(e,n){if(isNaN(this.n)||isNaN(this.d))return new zr(NaN);if(e===void 0)return ur(this.s*this.n%this.d,1);if(Fr(e,n),Se.n===0&&this.d===0)throw hi();return ur(this.s*(Se.d*this.n)%(Se.n*this.d),Se.d*this.d)},gcd:function(e,n){return Fr(e,n),ur(ln(Se.n,this.n)*ln(Se.d,this.d),Se.d*this.d)},lcm:function(e,n){return Fr(e,n),Se.n===0&&this.n===0?ur(0,1):ur(Se.n*this.n,ln(Se.n,this.n)*ln(Se.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):ur(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):ur(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):ur(Math.round(e*this.s*this.n/this.d),e)},roundTo:function(e,n){return Fr(e,n),ur(this.s*Math.round(this.n*Se.d/(this.d*Se.n))*Se.n,Se.d)},inverse:function(){return ur(this.s*this.d,this.n)},pow:function(e,n){if(Fr(e,n),Se.d===1)return Se.s<0?ur(Math.pow(this.s*this.d,Se.n),Math.pow(this.n,Se.n)):ur(Math.pow(this.s*this.n,Se.n),Math.pow(this.d,Se.n));if(this.s<0)return null;var a=Lo(this.n),t=Lo(this.d),r=1,i=1;for(var l in a)if(l!=="1"){if(l==="0"){r=0;break}if(a[l]*=Se.n,a[l]%Se.d===0)a[l]/=Se.d;else return null;r*=Math.pow(l,a[l])}for(var l in t)if(l!=="1"){if(t[l]*=Se.n,t[l]%Se.d===0)t[l]/=Se.d;else return null;i*=Math.pow(l,t[l])}return Se.s<0?ur(i,r):ur(r,i)},equals:function(e,n){return Fr(e,n),this.s*this.n*Se.d===Se.s*Se.n*this.d},compare:function(e,n){Fr(e,n);var a=this.s*this.n*Se.d-Se.s*Se.n*this.d;return(0<a)-(a<0)},simplify:function(e){if(isNaN(this.n)||isNaN(this.d))return this;e=e||.001;for(var n=this.abs(),a=n.toContinued(),t=1;t<a.length;t++){for(var r=ur(a[t-1],1),i=t-2;i>=0;i--)r=r.inverse().add(a[i]);if(Math.abs(r.sub(n).valueOf())<e)return r.mul(this.s)}return this},divisible:function(e,n){return Fr(e,n),!(!(Se.n*this.d)||this.n*Se.d%(Se.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(e){var n,a="",t=this.n,r=this.d;return this.s<0&&(a+="-"),r===1?a+=t:(e&&(n=Math.floor(t/r))>0&&(a+=n,a+=" ",t%=r),a+=t,a+="/",a+=r),a},toLatex:function(e){var n,a="",t=this.n,r=this.d;return this.s<0&&(a+="-"),r===1?a+=t:(e&&(n=Math.floor(t/r))>0&&(a+=n,t%=r),a+="\\frac{",a+=t,a+="}{",a+=r,a+="}"),a},toContinued:function(){var e,n=this.n,a=this.d,t=[];if(isNaN(n)||isNaN(a))return t;do t.push(Math.floor(n/a)),e=n%a,n=a,a=e;while(n!==1);return t},toString:function(e){var n=this.n,a=this.d;if(isNaN(n)||isNaN(a))return"NaN";e=e||15;var t=Oh(n,a),r=Dh(n,a,t),i=this.s<0?"-":"";if(i+=n/a|0,n%=a,n*=10,n&&(i+="."),t){for(var l=r;l--;)i+=n/a|0,n%=a,n*=10;i+="(";for(var l=t;l--;)i+=n/a|0,n%=a,n*=10;i+=")"}else for(var l=e;n&&l--;)i+=n/a|0,n%=a,n*=10;return i}};var Bh="Fraction",_h=[],$h=R(Bh,_h,()=>(zr.prototype.type="Fraction",zr.prototype.isFraction=!0,zr.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},zr.fromJSON=function(e){return new zr(e)},zr),{isClass:!0}),Ih="Range",qh=[],Rh=R(Ih,qh,()=>{function e(n,a,t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var r=n!=null,i=a!=null,l=t!=null;if(r){if(_e(n))n=n.toNumber();else if(typeof n!="number")throw new TypeError("Parameter start must be a number")}if(i){if(_e(a))a=a.toNumber();else if(typeof a!="number")throw new TypeError("Parameter end must be a number")}if(l){if(_e(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter step must be a number")}this.start=r?parseFloat(n):0,this.end=i?parseFloat(a):0,this.step=l?parseFloat(t):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(n){if(typeof n!="string")return null;var a=n.split(":"),t=a.map(function(i){return parseFloat(i)}),r=t.some(function(i){return isNaN(i)});if(r)return null;switch(t.length){case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[2],t[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var n=0,a=this.start,t=this.step,r=this.end,i=r-a;return Dt(t)===Dt(i)?n=Math.ceil(i/t):i===0&&(n=0),isNaN(n)&&(n=0),[n]},e.prototype.min=function(){var n=this.size()[0];if(n>0)return this.step>0?this.start:this.start+(n-1)*this.step},e.prototype.max=function(){var n=this.size()[0];if(n>0)return this.step>0?this.start+(n-1)*this.step:this.start},e.prototype.forEach=function(n){var a=this.start,t=this.step,r=this.end,i=0;if(t>0)for(;a<r;)n(a,[i],this),a+=t,i++;else if(t<0)for(;a>r;)n(a,[i],this),a+=t,i++},e.prototype.map=function(n){var a=[];return this.forEach(function(t,r,i){a[r[0]]=n(t,r,i)}),a},e.prototype.toArray=function(){var n=[];return this.forEach(function(a,t){n[t[0]]=a}),n},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(n){var a=Ht(this.start,n);return this.step!==1&&(a+=":"+Ht(this.step,n)),a+=":"+Ht(this.end,n),a},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(n){return new e(n.start,n.end,n.step)},e},{isClass:!0}),Fh="Matrix",zh=[],Ph=R(Fh,zh,()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(n,a){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(n,a,t){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(n){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(n,a,t){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(n,a){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(n,a){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(n,a){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(n){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(n){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e},{isClass:!0}),Uh="DenseMatrix",Lh=["Matrix"],kh=R(Uh,Lh,e=>{var{Matrix:n}=e;function a(s,o){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(o&&!_r(o))throw new Error("Invalid datatype: "+o);if(Oe(s))s.type==="DenseMatrix"?(this._data=Ce(s._data),this._size=Ce(s._size),this._datatype=o||s._datatype):(this._data=s.toArray(),this._size=s.size(),this._datatype=o||s._datatype);else if(s&&Xe(s.data)&&Xe(s.size))this._data=s.data,this._size=s.size,vo(this._data,this._size),this._datatype=o||s.datatype;else if(Xe(s))this._data=c(s),this._size=Pe(this._data),vo(this._data,this._size),this._datatype=o;else{if(s)throw new TypeError("Unsupported type of data ("+Ke(s)+")");this._data=[],this._size=[0],this._datatype=o}}a.prototype=new n,a.prototype.createDenseMatrix=function(s,o){return new a(s,o)},a.prototype.type="DenseMatrix",a.prototype.isDenseMatrix=!0,a.prototype.getDataType=function(){return Bn(this._data,Ke)},a.prototype.storage=function(){return"dense"},a.prototype.datatype=function(){return this._datatype},a.prototype.create=function(s,o){return new a(s,o)},a.prototype.subset=function(s,o,u){switch(arguments.length){case 1:return t(this,s);case 2:case 3:return i(this,s,o,u);default:throw new SyntaxError("Wrong number of arguments")}},a.prototype.get=function(s){if(!Xe(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new Fe(s.length,this._size.length);for(var o=0;o<s.length;o++)We(s[o],this._size[o]);for(var u=this._data,p=0,v=s.length;p<v;p++){var h=s[p];We(h,u.length),u=u[h]}return u},a.prototype.set=function(s,o,u){if(!Xe(s))throw new TypeError("Array expected");if(s.length<this._size.length)throw new Fe(s.length,this._size.length,"<");var p,v,h,b=s.map(function(N){return N+1});f(this,b,u);var w=this._data;for(p=0,v=s.length-1;p<v;p++)h=s[p],We(h,w.length),w=w[h];return h=s[s.length-1],We(h,w.length),w[h]=o,this};function t(s,o){if(!En(o))throw new TypeError("Invalid index");var u=o.isScalar();if(u)return s.get(o.min());var p=o.size();if(p.length!==s._size.length)throw new Fe(p.length,s._size.length);for(var v=o.min(),h=o.max(),b=0,w=s._size.length;b<w;b++)We(v[b],s._size[b]),We(h[b],s._size[b]);return new a(r(s._data,o,p.length,0),s._datatype)}function r(s,o,u,p){var v=p===u-1,h=o.dimension(p);return v?h.map(function(b){return We(b,s.length),s[b]}).valueOf():h.map(function(b){We(b,s.length);var w=s[b];return r(w,o,u,p+1)}).valueOf()}function i(s,o,u,p){if(!o||o.isIndex!==!0)throw new TypeError("Invalid index");var v=o.size(),h=o.isScalar(),b;if(Oe(u)?(b=u.size(),u=u.valueOf()):b=Pe(u),h){if(b.length!==0)throw new TypeError("Scalar expected");s.set(o.min(),u,p)}else{if(v.length<s._size.length)throw new Fe(v.length,s._size.length,"<");if(b.length<v.length){for(var w=0,N=0;v[w]===1&&b[w]===1;)w++;for(;v[w]===1;)N++,w++;u=xo(u,v.length,N,b)}if(!Dn(v,b))throw new Fe(v,b,">");var g=o.max().map(function(d){return d+1});f(s,g,p);var y=v.length,x=0;l(s._data,o,u,y,x)}return s}function l(s,o,u,p,v){var h=v===p-1,b=o.dimension(v);h?b.forEach(function(w,N){We(w),s[w]=u[N[0]]}):b.forEach(function(w,N){We(w),l(s[w],o,u[N[0]],p,v+1)})}a.prototype.resize=function(s,o,u){if(!rn(s))throw new TypeError("Array or Matrix expected");var p=s.valueOf().map(h=>Array.isArray(h)&&h.length===1?h[0]:h),v=u?this.clone():this;return m(v,p,o)};function m(s,o,u){if(o.length===0){for(var p=s._data;Xe(p);)p=p[0];return p}return s._size=o.slice(0),s._data=on(s._data,s._size,u),s}a.prototype.reshape=function(s,o){var u=o?this.clone():this;u._data=ho(u._data,s);var p=u._size.reduce((v,h)=>v*h);return u._size=ti(s,p),u};function f(s,o,u){for(var p=s._size.slice(0),v=!1;p.length<o.length;)p.push(0),v=!0;for(var h=0,b=o.length;h<b;h++)o[h]>p[h]&&(p[h]=o[h],v=!0);v&&m(s,p,u)}a.prototype.clone=function(){var s=new a({data:Ce(this._data),size:Ce(this._size),datatype:this._datatype});return s},a.prototype.size=function(){return this._size.slice(0)},a.prototype.map=function(s){var o=this,u=function h(b,w){return Xe(b)?b.map(function(N,g){return h(N,w.concat(g))}):s(b,w,o)},p=u(this._data,[]),v=this._datatype!==void 0?Bn(p,Ke):void 0;return new a(p,v)},a.prototype.forEach=function(s){var o=this,u=function p(v,h){Xe(v)?v.forEach(function(b,w){p(b,h.concat(w))}):s(v,h,o)};u(this._data,[])},a.prototype[Symbol.iterator]=function*(){var s=function*o(u,p){if(Xe(u))for(var v=0;v<u.length;v++)yield*io(o(u[v],p.concat(v)));else yield{value:u,index:p}};yield*io(s(this._data,[]))},a.prototype.rows=function(){var s=[],o=this.size();if(o.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var u=this._data;for(var p of u)s.push(new a([p],this._datatype));return s},a.prototype.columns=function(){var s=this,o=[],u=this.size();if(u.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var p=this._data,v=function(w){var N=p.map(g=>[g[w]]);o.push(new a(N,s._datatype))},h=0;h<u[1];h++)v(h);return o},a.prototype.toArray=function(){return Ce(this._data)},a.prototype.valueOf=function(){return this._data},a.prototype.format=function(s){return Re(this._data,s)},a.prototype.toString=function(){return Re(this._data)},a.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(s){if(s){if(_e(s)&&(s=s.toNumber()),!Be(s)||!Ae(s))throw new TypeError("The parameter k must be an integer number")}else s=0;for(var o=s>0?s:0,u=s<0?-s:0,p=this._size[0],v=this._size[1],h=Math.min(p-u,v-o),b=[],w=0;w<h;w++)b[w]=this._data[w+u][w+o];return new a({data:b,size:[h],datatype:this._datatype})},a.diagonal=function(s,o,u,p){if(!Xe(s))throw new TypeError("Array expected, size parameter");if(s.length!==2)throw new Error("Only two dimensions matrix are supported");if(s=s.map(function(A){if(_e(A)&&(A=A.toNumber()),!Be(A)||!Ae(A)||A<1)throw new Error("Size values must be positive integers");return A}),u){if(_e(u)&&(u=u.toNumber()),!Be(u)||!Ae(u))throw new TypeError("The parameter k must be an integer number")}else u=0;var v=u>0?u:0,h=u<0?-u:0,b=s[0],w=s[1],N=Math.min(b-h,w-v),g;if(Xe(o)){if(o.length!==N)throw new Error("Invalid value array length");g=function(S){return o[S]}}else if(Oe(o)){var y=o.size();if(y.length!==1||y[0]!==N)throw new Error("Invalid matrix length");g=function(S){return o.get([S])}}else g=function(){return o};p||(p=_e(g(0))?g(0).mul(0):0);var x=[];if(s.length>0){x=on(x,s,p);for(var d=0;d<N;d++)x[d+h][d+v]=g(d)}return new a({data:x,size:[b,w]})},a.fromJSON=function(s){return new a(s)},a.prototype.swapRows=function(s,o){if(!Be(s)||!Ae(s)||!Be(o)||!Ae(o))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return We(s,this._size[0]),We(o,this._size[0]),a._swapRows(s,o,this._data),this},a._swapRows=function(s,o,u){var p=u[s];u[s]=u[o],u[o]=p};function c(s){for(var o=0,u=s.length;o<u;o++){var p=s[o];Xe(p)?s[o]=c(p):p&&p.isMatrix===!0&&(s[o]=c(p.valueOf()))}return s}return a},{isClass:!0}),ko="clone",Hh=["typed"],Gh=R(ko,Hh,e=>{var{typed:n}=e;return n(ko,{any:Ce})});function Ho(e){var n=e.length,a=e[0].length,t,r,i=[];for(r=0;r<a;r++){var l=[];for(t=0;t<n;t++)l.push(e[t][r]);i.push(l)}return i}function mn(e){for(var n=0;n<e.length;n++)if(rn(e[n]))return!0;return!1}function bt(e,n){Oe(e)&&(e=e.valueOf());for(var a=0,t=e.length;a<t;a++){var r=e[a];Array.isArray(r)?bt(r,n):n(r)}}function be(e,n,a){return e&&typeof e.map=="function"?e.map(function(t){return be(t,n)}):n(e)}function xa(e,n,a){var t=Array.isArray(e)?Pe(e):e.size();if(n<0||n>=t.length)throw new Kr(n,t.length);return Oe(e)?e.create(ba(e.valueOf(),n,a)):ba(e,n,a)}function ba(e,n,a){var t,r,i,l;if(n<=0)if(Array.isArray(e[0])){for(l=Ho(e),r=[],t=0;t<l.length;t++)r[t]=ba(l[t],n-1,a);return r}else{for(i=e[0],t=1;t<e.length;t++)i=a(i,e[t]);return i}else{for(r=[],t=0;t<e.length;t++)r[t]=ba(e[t],n-1,a);return r}}function Go(e,n,a,t,r,i,l,m,f,c,s){var o=e._values,u=e._index,p=e._ptr,v,h,b,w;if(t)for(h=p[n],b=p[n+1],v=h;v<b;v++)w=u[v],a[w]!==i?(a[w]=i,l.push(w),t[w]=o[v]):(t[w]=m(t[w],o[v]),r[w]=i);else for(h=p[n],b=p[n+1],v=h;v<b;v++)w=u[v],a[w]!==i?(a[w]=i,l.push(w)):r[w]=i}var Vo="isInteger",Vh=["typed"],Zh=R(Vo,Vh,e=>{var{typed:n}=e;return n(Vo,{number:Ae,BigNumber:function(t){return t.isInt()},Fraction:function(t){return t.d===1&&isFinite(t.n)},"Array | Matrix":function(t){return be(t,this)}})}),et="number",Gt="number, number";function Zo(e){return Math.abs(e)}Zo.signature=et;function Xo(e,n){return e+n}Xo.signature=Gt;function Yo(e,n){return e*n}Yo.signature=Gt;function Wo(e){return-e}Wo.signature=et;function Jo(e){return e}Jo.signature=et;function $n(e){return Vp(e)}$n.signature=et;function Qo(e){return e*e*e}Qo.signature=et;function Ko(e){return Math.exp(e)}Ko.signature=et;function jo(e){return Zp(e)}jo.signature=et;function es(e,n){if(!Ae(e)||!Ae(n))throw new Error("Parameters in function gcd must be integer numbers");for(var a;n!==0;)a=e%n,e=n,n=a;return e<0?-e:e}es.signature=Gt;function rs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Parameters in function lcm must be integer numbers");if(e===0||n===0)return 0;for(var a,t=e*n;n!==0;)a=n,n=e%a,e=a;return Math.abs(t/e)}rs.signature=Gt;function Xh(e,n){return Math.log(e)}function ts(e){return Hp(e)}ts.signature=et;function ns(e){return kp(e)}ns.signature=et;function as(e,n){if(n>0)return e-n*Math.floor(e/n);if(n===0)return e;throw new Error("Cannot calculate mod for a negative divisor")}as.signature=Gt;function is(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,a=n<0;if(a&&(n=-n),n===0)throw new Error("Root must be non-zero");if(e<0&&Math.abs(n)%2!==1)throw new Error("Root must be odd when a is negative.");if(e===0)return a?1/0:0;if(!isFinite(e))return a?0:e;var t=Math.pow(Math.abs(e),1/n);return t=e<0?-t:t,a?1/t:t}function di(e){return Dt(e)}di.signature=et;function os(e){return e*e}os.signature=et;function ss(e,n){var a,t,r,i=0,l=1,m=1,f=0;if(!Ae(e)||!Ae(n))throw new Error("Parameters in function xgcd must be integer numbers");for(;n;)t=Math.floor(e/n),r=e-t*n,a=i,i=l-t*i,l=a,a=m,m=f-t*m,f=a,e=n,n=r;var c;return e<0?c=[-e,-l,-f]:c=[e,e?l:0,f],c}ss.signature=Gt;function us(e,n){return e*e<1&&n===1/0||e*e>1&&n===-1/0?0:Math.pow(e,n)}us.signature=Gt;function cs(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!Ae(n)||n<0||n>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(co(e,n))}var Yh="number",pn="number, number";function fs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitAnd");return e&n}fs.signature=pn;function ls(e){if(!Ae(e))throw new Error("Integer expected in function bitNot");return~e}ls.signature=Yh;function ms(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitOr");return e|n}ms.signature=pn;function ps(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitXor");return e^n}ps.signature=pn;function vs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function leftShift");return e<<n}vs.signature=pn;function hs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function rightArithShift");return e>>n}hs.signature=pn;function ds(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function rightLogShift");return e>>>n}ds.signature=pn;function wt(e,n){if(n<e)return 1;if(n===e)return n;var a=n+e>>1;return wt(e,a)*wt(a+1,n)}function gs(e,n){if(!Ae(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!Ae(n)||n<0)throw new TypeError("Positive integer value expected in function combinations");if(n>e)throw new TypeError("k must be less than or equal to n");for(var a=e-n,t=1,r=n<a?a+1:n+1,i=2,l=n<a?n:a,m=r;m<=e;++m)for(t*=m;i<=l&&t%i===0;)t/=i,++i;return i<=l&&(t/=wt(i,l)),t}gs.signature="number, number";var Wh=Math.PI,Jh=2*Math.PI,Qh=Math.E,Kh=1.618033988749895,jh="number",gi="number, number";function ys(e){return!e}ys.signature=jh;function xs(e,n){return!!(e||n)}xs.signature=gi;function bs(e,n){return!!e!=!!n}bs.signature=gi;function ws(e,n){return!!(e&&n)}ws.signature=gi;function yi(e){var n;if(Ae(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:wt(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*yi(1-e));if(e>=171.35)return 1/0;if(e>85){var a=e*e,t=a*e,r=t*e,i=r*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*a)-139/(51840*t)-571/(2488320*r)+163879/(209018880*i)+5246819/(75246796800*i*e))}--e,n=vn[0];for(var l=1;l<vn.length;++l)n+=vn[l]/(e+l);var m=e+Ns+.5;return Math.sqrt(2*Math.PI)*Math.pow(m,e+.5)*Math.exp(-m)*n}yi.signature="number";var Ns=4.7421875,vn=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Ms=.9189385332046728,ed=5,rd=7,As=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function wa(e){if(e<0)return NaN;if(e===0)return 1/0;if(!isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-wa(1-e);e=e-1;for(var n=e+ed+.5,a=As[0],t=rd-1;t>=1;t--)a+=As[t]/(e+t);return Ms+(e+.5)*Math.log(n)-n+Math.log(a)}wa.signature="number";var Mr="number";function Ss(e){return Qp(e)}Ss.signature=Mr;function Es(e){return Math.atan(1/e)}Es.signature=Mr;function Cs(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}Cs.signature=Mr;function Os(e){return Math.asin(1/e)}Os.signature=Mr;function Ds(e){var n=1/e;return Math.log(n+Math.sqrt(n*n+1))}Ds.signature=Mr;function Ts(e){return Math.acos(1/e)}Ts.signature=Mr;function Bs(e){var n=1/e,a=Math.sqrt(n*n-1);return Math.log(a+n)}Bs.signature=Mr;function _s(e){return Kp(e)}_s.signature=Mr;function $s(e){return jp(e)}$s.signature=Mr;function Is(e){return 1/Math.tan(e)}Is.signature=Mr;function qs(e){var n=Math.exp(2*e);return(n+1)/(n-1)}qs.signature=Mr;function Rs(e){return 1/Math.sin(e)}Rs.signature=Mr;function Fs(e){return e===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*Dt(e)}Fs.signature=Mr;function zs(e){return 1/Math.cos(e)}zs.signature=Mr;function Ps(e){return 2/(Math.exp(e)+Math.exp(-e))}Ps.signature=Mr;function Us(e){return rv(e)}Us.signature=Mr;var Na="number";function Ls(e){return e<0}Ls.signature=Na;function ks(e){return e>0}ks.signature=Na;function Hs(e){return e===0}Hs.signature=Na;function Gs(e){return Number.isNaN(e)}Gs.signature=Na;var Vs="isNegative",td=["typed"],nd=R(Vs,td,e=>{var{typed:n}=e;return n(Vs,{number:Ls,BigNumber:function(t){return t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s<0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Zs="isNumeric",ad=["typed"],id=R(Zs,ad,e=>{var{typed:n}=e;return n(Zs,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(t){return be(t,this)}})}),Xs="hasNumericValue",od=["typed","isNumeric"],sd=R(Xs,od,e=>{var{typed:n,isNumeric:a}=e;return n(Xs,{string:function(r){return r.trim().length>0&&!isNaN(Number(r))},any:function(r){return a(r)}})}),Ys="isPositive",ud=["typed"],cd=R(Ys,ud,e=>{var{typed:n}=e;return n(Ys,{number:ks,BigNumber:function(t){return!t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s>0&&t.n>0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Ws="isZero",fd=["typed"],ld=R(Ws,fd,e=>{var{typed:n}=e;return n(Ws,{number:Hs,BigNumber:function(t){return t.isZero()},Complex:function(t){return t.re===0&&t.im===0},Fraction:function(t){return t.d===1&&t.n===0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Js="isNaN",md=["typed"],pd=R(Js,md,e=>{var{typed:n}=e;return n(Js,{number:Gs,BigNumber:function(t){return t.isNaN()},Fraction:function(t){return!1},Complex:function(t){return t.isNaN()},Unit:function(t){return Number.isNaN(t.value)},"Array | Matrix":function(t){return be(t,Number.isNaN)}})}),Qs="typeOf",vd=["typed"],hd=R(Qs,vd,e=>{var{typed:n}=e;return n(Qs,{any:Ke})});function st(e,n,a){if(a==null)return e.eq(n);if(e.eq(n))return!0;if(e.isNaN()||n.isNaN())return!1;if(e.isFinite()&&n.isFinite()){var t=e.minus(n).abs();if(t.isZero())return!0;var r=e.constructor.max(e.abs(),n.abs());return t.lte(r.times(a))}return!1}function dd(e,n,a){return Rr(e.re,n.re,a)&&Rr(e.im,n.im,a)}var Ma="equalScalar",gd=["typed","config"],yd=R(Ma,gd,e=>{var{typed:n,config:a}=e;return n(Ma,{"boolean, boolean":function(r,i){return r===i},"number, number":function(r,i){return Rr(r,i,a.epsilon)},"BigNumber, BigNumber":function(r,i){return r.eq(i)||st(r,i,a.epsilon)},"Fraction, Fraction":function(r,i){return r.equals(i)},"Complex, Complex":function(r,i){return dd(r,i,a.epsilon)},"Unit, Unit":function(r,i){if(!r.equalBase(i))throw new Error("Cannot compare units with different base");return this(r.value,i.value)}})});R(Ma,["typed","config"],e=>{var{typed:n,config:a}=e;return n(Ma,{"number, number":function(r,i){return Rr(r,i,a.epsilon)}})});var xd="SparseMatrix",bd=["typed","equalScalar","Matrix"],wd=R(xd,bd,e=>{var{typed:n,equalScalar:a,Matrix:t}=e;function r(h,b){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(b&&!_r(b))throw new Error("Invalid datatype: "+b);if(Oe(h))i(this,h,b);else if(h&&Xe(h.index)&&Xe(h.ptr)&&Xe(h.size))this._values=h.values,this._index=h.index,this._ptr=h.ptr,this._size=h.size,this._datatype=b||h.datatype;else if(Xe(h))l(this,h,b);else{if(h)throw new TypeError("Unsupported type of data ("+Ke(h)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=b}}function i(h,b,w){b.type==="SparseMatrix"?(h._values=b._values?Ce(b._values):void 0,h._index=Ce(b._index),h._ptr=Ce(b._ptr),h._size=Ce(b._size),h._datatype=w||b._datatype):l(h,b.valueOf(),w||b._datatype)}function l(h,b,w){h._values=[],h._index=[],h._ptr=[],h._datatype=w;var N=b.length,g=0,y=a,x=0;if(_r(w)&&(y=n.find(a,[w,w])||a,x=n.convert(0,w)),N>0){var d=0;do{h._ptr.push(h._index.length);for(var A=0;A<N;A++){var S=b[A];if(Xe(S)){if(d===0&&g<S.length&&(g=S.length),d<S.length){var O=S[d];y(O,x)||(h._values.push(O),h._index.push(A))}}else d===0&&g<1&&(g=1),y(S,x)||(h._values.push(S),h._index.push(A))}d++}while(d<g)}h._ptr.push(h._index.length),h._size=[N,g]}r.prototype=new t,r.prototype.createSparseMatrix=function(h,b){return new r(h,b)},r.prototype.type="SparseMatrix",r.prototype.isSparseMatrix=!0,r.prototype.getDataType=function(){return Bn(this._values,Ke)},r.prototype.storage=function(){return"sparse"},r.prototype.datatype=function(){return this._datatype},r.prototype.create=function(h,b){return new r(h,b)},r.prototype.density=function(){var h=this._size[0],b=this._size[1];return h!==0&&b!==0?this._index.length/(h*b):0},r.prototype.subset=function(h,b,w){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return m(this,h);case 2:case 3:return f(this,h,b,w);default:throw new SyntaxError("Wrong number of arguments")}};function m(h,b){if(!En(b))throw new TypeError("Invalid index");var w=b.isScalar();if(w)return h.get(b.min());var N=b.size();if(N.length!==h._size.length)throw new Fe(N.length,h._size.length);var g,y,x,d,A=b.min(),S=b.max();for(g=0,y=h._size.length;g<y;g++)We(A[g],h._size[g]),We(S[g],h._size[g]);var O=h._values,M=h._index,_=h._ptr,E=b.dimension(0),$=b.dimension(1),z=[],I=[];E.forEach(function(D,H){I[D]=H[0],z[D]=!0});var T=O?[]:void 0,B=[],G=[];return $.forEach(function(D){for(G.push(B.length),x=_[D],d=_[D+1];x<d;x++)g=M[x],z[g]===!0&&(B.push(I[g]),T&&T.push(O[x]))}),G.push(B.length),new r({values:T,index:B,ptr:G,size:N,datatype:h._datatype})}function f(h,b,w,N){if(!b||b.isIndex!==!0)throw new TypeError("Invalid index");var g=b.size(),y=b.isScalar(),x;if(Oe(w)?(x=w.size(),w=w.toArray()):x=Pe(w),y){if(x.length!==0)throw new TypeError("Scalar expected");h.set(b.min(),w,N)}else{if(g.length!==1&&g.length!==2)throw new Fe(g.length,h._size.length,"<");if(x.length<g.length){for(var d=0,A=0;g[d]===1&&x[d]===1;)d++;for(;g[d]===1;)A++,d++;w=xo(w,g.length,A,x)}if(!Dn(g,x))throw new Fe(g,x,">");if(g.length===1){var S=b.dimension(0);S.forEach(function(_,E){We(_),h.set([_,0],w[E[0]],N)})}else{var O=b.dimension(0),M=b.dimension(1);O.forEach(function(_,E){We(_),M.forEach(function($,z){We($),h.set([_,$],w[E[0]][z[0]],N)})})}}return h}r.prototype.get=function(h){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Fe(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var b=h[0],w=h[1];We(b,this._size[0]),We(w,this._size[1]);var N=c(b,this._ptr[w],this._ptr[w+1],this._index);return N<this._ptr[w+1]&&this._index[N]===b?this._values[N]:0},r.prototype.set=function(h,b,w){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Fe(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var N=h[0],g=h[1],y=this._size[0],x=this._size[1],d=a,A=0;_r(this._datatype)&&(d=n.find(a,[this._datatype,this._datatype])||a,A=n.convert(0,this._datatype)),(N>y-1||g>x-1)&&(u(this,Math.max(N+1,y),Math.max(g+1,x),w),y=this._size[0],x=this._size[1]),We(N,y),We(g,x);var S=c(N,this._ptr[g],this._ptr[g+1],this._index);return S<this._ptr[g+1]&&this._index[S]===N?d(b,A)?s(S,g,this._values,this._index,this._ptr):this._values[S]=b:o(S,N,g,b,this._values,this._index,this._ptr),this};function c(h,b,w,N){if(w-b===0)return w;for(var g=b;g<w;g++)if(N[g]===h)return g;return b}function s(h,b,w,N,g){w.splice(h,1),N.splice(h,1);for(var y=b+1;y<g.length;y++)g[y]--}function o(h,b,w,N,g,y,x){g.splice(h,0,N),y.splice(h,0,b);for(var d=w+1;d<x.length;d++)x[d]++}r.prototype.resize=function(h,b,w){if(!rn(h))throw new TypeError("Array or Matrix expected");var N=h.valueOf().map(y=>Array.isArray(y)&&y.length===1?y[0]:y);if(N.length!==2)throw new Error("Only two dimensions matrix are supported");N.forEach(function(y){if(!Be(y)||!Ae(y)||y<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Re(N)+")")});var g=w?this.clone():this;return u(g,N[0],N[1],b)};function u(h,b,w,N){var g=N||0,y=a,x=0;_r(h._datatype)&&(y=n.find(a,[h._datatype,h._datatype])||a,x=n.convert(0,h._datatype),g=n.convert(g,h._datatype));var d=!y(g,x),A=h._size[0],S=h._size[1],O,M,_;if(w>S){for(M=S;M<w;M++)if(h._ptr[M]=h._values.length,d)for(O=0;O<A;O++)h._values.push(g),h._index.push(O);h._ptr[w]=h._values.length}else w<S&&(h._ptr.splice(w+1,S-w),h._values.splice(h._ptr[w],h._values.length),h._index.splice(h._ptr[w],h._index.length));if(S=w,b>A){if(d){var E=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]+E,_=h._ptr[M+1]+E;var $=0;for(O=A;O<b;O++,$++)h._values.splice(_+$,0,g),h._index.splice(_+$,0,O),E++}h._ptr[S]=h._values.length}}else if(b<A){var z=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]-z;var I=h._ptr[M],T=h._ptr[M+1]-z;for(_=I;_<T;_++)O=h._index[_],O>b-1&&(h._values.splice(_,1),h._index.splice(_,1),z++)}h._ptr[M]=h._values.length}return h._size[0]=b,h._size[1]=w,h}r.prototype.reshape=function(h,b){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");h.forEach(function(D){if(!Be(D)||!Ae(D)||D<=-2||D===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Re(h)+")")});var w=this._size[0]*this._size[1];h=ti(h,w);var N=h[0]*h[1];if(w!==N)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var g=b?this.clone():this;if(this._size[0]===h[0]&&this._size[1]===h[1])return g;for(var y=[],x=0;x<g._ptr.length;x++)for(var d=0;d<g._ptr[x+1]-g._ptr[x];d++)y.push(x);for(var A=g._values.slice(),S=g._index.slice(),O=0;O<g._index.length;O++){var M=S[O],_=y[O],E=M*g._size[1]+_;y[O]=E%h[1],S[O]=Math.floor(E/h[1])}g._values.length=0,g._index.length=0,g._ptr.length=h[1]+1,g._size=h.slice();for(var $=0;$<g._ptr.length;$++)g._ptr[$]=0;for(var z=0;z<A.length;z++){var I=S[z],T=y[z],B=A[z],G=c(I,g._ptr[T],g._ptr[T+1],g._index);o(G,I,T,B,g._values,g._index,g._ptr)}return g},r.prototype.clone=function(){var h=new r({values:this._values?Ce(this._values):void 0,index:Ce(this._index),ptr:Ce(this._ptr),size:Ce(this._size),datatype:this._datatype});return h},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(h,b){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var w=this,N=this._size[0],g=this._size[1],y=function(d,A,S){return h(d,[A,S],w)};return p(this,0,N-1,0,g-1,y,b)};function p(h,b,w,N,g,y,x){var d=[],A=[],S=[],O=a,M=0;_r(h._datatype)&&(O=n.find(a,[h._datatype,h._datatype])||a,M=n.convert(0,h._datatype));for(var _=function(V,K,te){V=y(V,K,te),O(V,M)||(d.push(V),A.push(K))},E=N;E<=g;E++){S.push(d.length);var $=h._ptr[E],z=h._ptr[E+1];if(x)for(var I=$;I<z;I++){var T=h._index[I];T>=b&&T<=w&&_(h._values[I],T-b,E-N)}else{for(var B={},G=$;G<z;G++){var D=h._index[G];B[D]=h._values[G]}for(var H=b;H<=w;H++){var W=H in B?B[H]:0;_(W,H-b,E-N)}}}return S.push(d.length),new r({values:d,index:A,ptr:S,size:[w-b+1,g-N+1]})}r.prototype.forEach=function(h,b){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var w=this,N=this._size[0],g=this._size[1],y=0;y<g;y++){var x=this._ptr[y],d=this._ptr[y+1];if(b)for(var A=x;A<d;A++){var S=this._index[A];h(this._values[A],[S,y],w)}else{for(var O={},M=x;M<d;M++){var _=this._index[M];O[_]=this._values[M]}for(var E=0;E<N;E++){var $=E in O?O[E]:0;h($,[E,y],w)}}}},r.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var h=this._size[1],b=0;b<h;b++)for(var w=this._ptr[b],N=this._ptr[b+1],g=w;g<N;g++){var y=this._index[g];yield{value:this._values[g],index:[y,b]}}},r.prototype.toArray=function(){return v(this._values,this._index,this._ptr,this._size,!0)},r.prototype.valueOf=function(){return v(this._values,this._index,this._ptr,this._size,!1)};function v(h,b,w,N,g){var y=N[0],x=N[1],d=[],A,S;for(A=0;A<y;A++)for(d[A]=[],S=0;S<x;S++)d[A][S]=0;for(S=0;S<x;S++)for(var O=w[S],M=w[S+1],_=O;_<M;_++)A=b[_],d[A][S]=h?g?Ce(h[_]):h[_]:1;return d}return r.prototype.format=function(h){for(var b=this._size[0],w=this._size[1],N=this.density(),g="Sparse Matrix ["+Re(b,h)+" x "+Re(w,h)+"] density: "+Re(N,h)+`
8
+ `);return Object.freeze(kr)};ar(oe,kr,{MATRIX_OPTIONS:Rp,NUMBER_OPTIONS:Fp});function Tn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function zp(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var n=e.default;if(typeof n=="function"){var a=function t(){var r=!1;try{r=this instanceof t}catch(i){}return r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};a.prototype=n.prototype}else a={};return Object.defineProperty(a,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),a}var ea={exports:{}},Pp=ea.exports,so;function Up(){return so||(so=1,function(e,n){(function(a,t){e.exports=t()})(Pp,function(){function a(){return!0}function t(){return!1}function r(){}function i(){var l=[{name:"number",test:function(q){return typeof q=="number"}},{name:"string",test:function(q){return typeof q=="string"}},{name:"boolean",test:function(q){return typeof q=="boolean"}},{name:"Function",test:function(q){return typeof q=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(q){return q instanceof Date}},{name:"RegExp",test:function(q){return q instanceof RegExp}},{name:"Object",test:function(q){return typeof q=="object"&&q!==null&&q.constructor===Object}},{name:"null",test:function(q){return q===null}},{name:"undefined",test:function(q){return q===void 0}}],m={name:"any",test:a},f=[],c=[],s={types:l,conversions:c,ignore:f};function o(q){var P=F(s.types,function(L){return L.name===q});if(P)return P;if(q==="any")return m;var Q=F(s.types,function(L){return L.name.toLowerCase()===q.toLowerCase()});throw new TypeError('Unknown type "'+q+'"'+(Q?'. Did you mean "'+Q.name+'"?':""))}function u(q){return q===m?999:s.types.indexOf(q)}function p(q){var P=F(s.types,function(Q){return Q.test(q)});if(P)return P.name;throw new TypeError("Value has unknown type. Value: "+q)}function v(q,P){if(!q.signatures)throw new TypeError("Function is no typed-function");var Q;if(typeof P=="string"){Q=P.split(",");for(var L=0;L<Q.length;L++)Q[L]=Q[L].trim()}else if(Array.isArray(P))Q=P;else throw new TypeError("String array or a comma separated string expected");var se=Q.join(","),fe=q.signatures[se];if(fe)return fe;throw new TypeError("Signature not found (signature: "+(q.name||"unnamed")+"("+Q.join(", ")+"))")}function h(q,P){var Q=p(q);if(P===Q)return q;for(var L=0;L<s.conversions.length;L++){var se=s.conversions[L];if(se.from===Q&&se.to===P)return se.convert(q)}throw new Error("Cannot convert from "+Q+" to "+P)}function b(q){return q.map(function(P){var Q=P.types.map(O);return(P.restParam?"...":"")+Q.join("|")}).join(",")}function w(q,P){var Q=q.indexOf("...")===0,L=Q?q.length>3?q.slice(3):"any":q,se=L.split("|").map(re).filter(ie).filter(te),fe=B(P,se),ge=se.map(function(ve){var Ne=o(ve);return{name:ve,typeIndex:u(Ne),test:Ne.test,conversion:null,conversionIndex:-1}}),pe=fe.map(function(ve){var Ne=o(ve.from);return{name:ve.from,typeIndex:u(Ne),test:Ne.test,conversion:ve,conversionIndex:P.indexOf(ve)}});return{types:ge.concat(pe),restParam:Q}}function N(q,P,Q){var L=[];return q.trim()!==""&&(L=q.split(",").map(re).map(function(se,fe,ge){var pe=w(se,Q);if(pe.restParam&&fe!==ge.length-1)throw new SyntaxError('Unexpected rest parameter "'+se+'": only allowed for the last parameter');return pe})),L.some(ue)?null:{params:L,fn:P}}function g(q){var P=ye(q);return P?P.restParam:!1}function y(q){return q.types.some(function(P){return P.conversion!=null})}function x(q){if(!q||q.types.length===0)return a;if(q.types.length===1)return o(q.types[0].name).test;if(q.types.length===2){var P=o(q.types[0].name).test,Q=o(q.types[1].name).test;return function(fe){return P(fe)||Q(fe)}}else{var L=q.types.map(function(se){return o(se.name).test});return function(fe){for(var ge=0;ge<L.length;ge++)if(L[ge](fe))return!0;return!1}}}function d(q){var P,Q,L;if(g(q)){P=ee(q).map(x);var se=P.length,fe=x(ye(q)),ge=function(pe){for(var ve=se;ve<pe.length;ve++)if(!fe(pe[ve]))return!1;return!0};return function(ve){for(var Ne=0;Ne<P.length;Ne++)if(!P[Ne](ve[Ne]))return!1;return ge(ve)&&ve.length>=se+1}}else return q.length===0?function(ve){return ve.length===0}:q.length===1?(Q=x(q[0]),function(ve){return Q(ve[0])&&ve.length===1}):q.length===2?(Q=x(q[0]),L=x(q[1]),function(ve){return Q(ve[0])&&L(ve[1])&&ve.length===2}):(P=q.map(x),function(ve){for(var Ne=0;Ne<P.length;Ne++)if(!P[Ne](ve[Ne]))return!1;return ve.length===P.length})}function A(q,P){return P<q.params.length?q.params[P]:g(q.params)?ye(q.params):null}function S(q,P,Q){var L=A(q,P),se=L?Q?L.types.filter(M):L.types:[];return se.map(O)}function O(q){return q.name}function M(q){return q.conversion===null||q.conversion===void 0}function _(q,P){var Q=Y(k(q,function(L){return S(L,P,!1)}));return Q.indexOf("any")!==-1?["any"]:Q}function E(q,P,Q){var L,se,fe=q||"unnamed",ge=Q,pe;for(pe=0;pe<P.length;pe++){var ve=ge.filter(function(tr){var Jr=x(A(tr,pe));return(pe<tr.params.length||g(tr.params))&&Jr(P[pe])});if(ve.length===0){if(se=_(ge,pe),se.length>0){var Ne=p(P[pe]);return L=new TypeError("Unexpected type of argument in function "+fe+" (expected: "+se.join(" or ")+", actual: "+Ne+", index: "+pe+")"),L.data={category:"wrongType",fn:fe,index:pe,actual:Ne,expected:se},L}}else ge=ve}var Qe=ge.map(function(tr){return g(tr.params)?1/0:tr.params.length});if(P.length<Math.min.apply(null,Qe))return se=_(ge,pe),L=new TypeError("Too few arguments in function "+fe+" (expected: "+se.join(" or ")+", index: "+P.length+")"),L.data={category:"tooFewArgs",fn:fe,index:P.length,expected:se},L;var cr=Math.max.apply(null,Qe);return P.length>cr?(L=new TypeError("Too many arguments in function "+fe+" (expected: "+cr+", actual: "+P.length+")"),L.data={category:"tooManyArgs",fn:fe,index:P.length,expectedLength:cr},L):(L=new TypeError('Arguments of type "'+P.join(", ")+'" do not match any of the defined signatures of function '+fe+"."),L.data={category:"mismatch",actual:P.map(p)},L)}function $(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])&&(P=Math.min(P,q.types[Q].typeIndex));return P}function z(q){for(var P=999,Q=0;Q<q.types.length;Q++)M(q.types[Q])||(P=Math.min(P,q.types[Q].conversionIndex));return P}function I(q,P){var Q;return Q=q.restParam-P.restParam,Q!==0||(Q=y(q)-y(P),Q!==0)||(Q=$(q)-$(P),Q!==0)?Q:z(q)-z(P)}function T(q,P){var Q=Math.min(q.params.length,P.params.length),L,se;if(se=q.params.some(y)-P.params.some(y),se!==0)return se;for(L=0;L<Q;L++)if(se=y(q.params[L])-y(P.params[L]),se!==0)return se;for(L=0;L<Q;L++)if(se=I(q.params[L],P.params[L]),se!==0)return se;return q.params.length-P.params.length}function B(q,P){var Q={};return q.forEach(function(L){P.indexOf(L.from)===-1&&P.indexOf(L.to)!==-1&&!Q[L.from]&&(Q[L.from]=L)}),Object.keys(Q).map(function(L){return Q[L]})}function G(q,P){var Q=P;if(q.some(y)){var L=g(q),se=q.map(D);Q=function(){for(var ve=[],Ne=L?arguments.length-1:arguments.length,Qe=0;Qe<Ne;Qe++)ve[Qe]=se[Qe](arguments[Qe]);return L&&(ve[Ne]=arguments[Ne].map(se[Ne])),P.apply(this,ve)}}var fe=Q;if(g(q)){var ge=q.length-1;fe=function(){return Q.apply(this,we(arguments,0,ge).concat([we(arguments,ge)]))}}return fe}function D(q){var P,Q,L,se,fe=[],ge=[];switch(q.types.forEach(function(pe){pe.conversion&&(fe.push(o(pe.conversion.from).test),ge.push(pe.conversion.convert))}),ge.length){case 0:return function(ve){return ve};case 1:return P=fe[0],L=ge[0],function(ve){return P(ve)?L(ve):ve};case 2:return P=fe[0],Q=fe[1],L=ge[0],se=ge[1],function(ve){return P(ve)?L(ve):Q(ve)?se(ve):ve};default:return function(ve){for(var Ne=0;Ne<ge.length;Ne++)if(fe[Ne](ve))return ge[Ne](ve);return ve}}}function H(q){var P={};return q.forEach(function(Q){Q.params.some(y)||W(Q.params,!0).forEach(function(L){P[b(L)]=Q.fn})}),P}function W(q,P){function Q(L,se,fe){if(se<L.length){var ge=L[se],pe=P?ge.types.filter(M):ge.types,ve;if(ge.restParam){var Ne=pe.filter(M);ve=Ne.length<pe.length?[Ne,pe]:[pe]}else ve=pe.map(function(cr){return[cr]});return k(ve,function(cr){return Q(L,se+1,fe.concat([cr]))})}else{var Qe=fe.map(function(cr,tr){return{types:cr,restParam:tr===L.length-1&&g(L)}});return[Qe]}}return Q(q,0,[])}function j(q,P){for(var Q=Math.max(q.params.length,P.params.length),L=0;L<Q;L++){var se=S(q,L,!0),fe=S(P,L,!0);if(!xe(se,fe))return!1}var ge=q.params.length,pe=P.params.length,ve=g(q.params),Ne=g(P.params);return ve?Ne?ge===pe:pe>=ge:Ne?ge>=pe:ge===pe}function V(q,P){if(Object.keys(P).length===0)throw new SyntaxError("No signatures provided");var Q=[];Object.keys(P).map(function(nr){return N(nr,P[nr],s.conversions)}).filter(ne).forEach(function(nr){var Cr=F(Q,function(vt){return j(vt,nr)});if(Cr)throw new TypeError('Conflicting signatures "'+b(Cr.params)+'" and "'+b(nr.params)+'".');Q.push(nr)});var L=k(Q,function(nr){var Cr=nr?W(nr.params,!1):[];return Cr.map(function(vt){return{params:vt,fn:nr.fn}})}).filter(ne);L.sort(T);var se=L[0]&&L[0].params.length<=2&&!g(L[0].params),fe=L[1]&&L[1].params.length<=2&&!g(L[1].params),ge=L[2]&&L[2].params.length<=2&&!g(L[2].params),pe=L[3]&&L[3].params.length<=2&&!g(L[3].params),ve=L[4]&&L[4].params.length<=2&&!g(L[4].params),Ne=L[5]&&L[5].params.length<=2&&!g(L[5].params),Qe=se&&fe&&ge&&pe&&ve&&Ne,cr=L.map(function(nr){return d(nr.params)}),tr=se?x(L[0].params[0]):t,Jr=fe?x(L[1].params[0]):t,Lr=ge?x(L[2].params[0]):t,Ot=pe?x(L[3].params[0]):t,Ze=ve?x(L[4].params[0]):t,Pt=Ne?x(L[5].params[0]):t,C=se?x(L[0].params[1]):t,X=fe?x(L[1].params[1]):t,ae=ge?x(L[2].params[1]):t,he=pe?x(L[3].params[1]):t,qe=ve?x(L[4].params[1]):t,Ue=Ne?x(L[5].params[1]):t,dr=L.map(function(nr){return G(nr.params,nr.fn)}),to=se?dr[0]:r,W_=fe?dr[1]:r,J_=ge?dr[2]:r,Q_=pe?dr[3]:r,K_=ve?dr[4]:r,j_=Ne?dr[5]:r,e$=se?L[0].params.length:-1,r$=fe?L[1].params.length:-1,t$=ge?L[2].params.length:-1,n$=pe?L[3].params.length:-1,a$=ve?L[4].params.length:-1,i$=Ne?L[5].params.length:-1,o$=Qe?6:0,s$=L.length,u$=function(){for(var Cr=o$;Cr<s$;Cr++)if(cr[Cr](arguments))return dr[Cr].apply(this,arguments);return s.onMismatch(q,arguments,L)},no=function nr(Cr,vt){return arguments.length===e$&&tr(Cr)&&C(vt)?to.apply(nr,arguments):arguments.length===r$&&Jr(Cr)&&X(vt)?W_.apply(nr,arguments):arguments.length===t$&&Lr(Cr)&&ae(vt)?J_.apply(nr,arguments):arguments.length===n$&&Ot(Cr)&&he(vt)?Q_.apply(nr,arguments):arguments.length===a$&&Ze(Cr)&&qe(vt)?K_.apply(nr,arguments):arguments.length===i$&&Pt(Cr)&&Ue(vt)?j_.apply(nr,arguments):u$.apply(nr,arguments)};try{Object.defineProperty(no,"name",{value:q})}catch(nr){}return no.signatures=H(L),no}function K(q,P,Q){throw E(q,P,Q)}function te(q){return s.ignore.indexOf(q)===-1}function re(q){return q.trim()}function ie(q){return!!q}function ne(q){return q!==null}function ue(q){return q.types.length===0}function ee(q){return q.slice(0,q.length-1)}function ye(q){return q[q.length-1]}function we(q,P,Q){return Array.prototype.slice.call(q,P,Q)}function me(q,P){return q.indexOf(P)!==-1}function xe(q,P){for(var Q=0;Q<q.length;Q++)if(me(P,q[Q]))return!0;return!1}function F(q,P){for(var Q=0;Q<q.length;Q++)if(P(q[Q]))return q[Q]}function Y(q){for(var P={},Q=0;Q<q.length;Q++)P[q[Q]]=!0;return Object.keys(P)}function k(q,P){return Array.prototype.concat.apply([],q.map(P))}function U(q){for(var P="",Q=0;Q<q.length;Q++){var L=q[Q];if((typeof L.signatures=="object"||typeof L.signature=="string")&&L.name!==""){if(P==="")P=L.name;else if(P!==L.name){var se=new Error("Function names do not match (expected: "+P+", actual: "+L.name+")");throw se.data={actual:L.name,expected:P},se}}}return P}function J(q){var P,Q={};function L(pe,ve){if(Q.hasOwnProperty(pe)&&ve!==Q[pe])throw P=new Error('Signature "'+pe+'" is defined twice'),P.data={signature:pe},P}for(var se=0;se<q.length;se++){var fe=q[se];if(typeof fe.signatures=="object")for(var ge in fe.signatures)fe.signatures.hasOwnProperty(ge)&&(L(ge,fe.signatures[ge]),Q[ge]=fe.signatures[ge]);else if(typeof fe.signature=="string")L(fe.signature,fe),Q[fe.signature]=fe;else throw P=new TypeError("Function is no typed-function (index: "+se+")"),P.data={index:se},P}return Q}return s=V("typed",{"string, Object":V,Object:function(q){var P=[];for(var Q in q)q.hasOwnProperty(Q)&&P.push(q[Q]);var L=U(P);return V(L,q)},"...Function":function(q){return V(U(q),J(q))},"string, ...Function":function(q,P){return V(q,J(P))}}),s.create=i,s.types=l,s.conversions=c,s.ignore=f,s.onMismatch=K,s.throwMismatchError=K,s.createError=E,s.convert=h,s.find=v,s.addType=function(q,P){if(!q||typeof q.name!="string"||typeof q.test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");if(P!==!1){for(var Q=0;Q<s.types.length;Q++)if(s.types[Q].name==="Object"){s.types.splice(Q,0,q);return}}s.types.push(q)},s.addConversion=function(q){if(!q||typeof q.from!="string"||typeof q.to!="string"||typeof q.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");s.conversions.push(q)},s}return i()})}(ea)),ea.exports}var Lp=Up();const uo=Tn(Lp);function Ae(e){return typeof e=="boolean"?!0:isFinite(e)?e===Math.round(e):!1}var Dt=Math.sign||function(e){return e>0?1:e<0?-1:0},kp=Math.log2||function(n){return Math.log(n)/Math.LN2},Hp=Math.log10||function(n){return Math.log(n)/Math.LN10},Gp=Math.log1p||function(e){return Math.log(e+1)},Vp=Math.cbrt||function(n){if(n===0)return n;var a=n<0,t;return a&&(n=-n),isFinite(n)?(t=Math.exp(Math.log(n)/3),t=(n/(t*t)+2*t)/3):t=n,a?-t:t},Zp=Math.expm1||function(n){return n>=2e-4||n<=-2e-4?Math.exp(n)-1:n+n*n/2+n*n*n/6};function ja(e,n,a){var t={2:"0b",8:"0o",16:"0x"},r=t[n],i="";if(a){if(a<1)throw new Error("size must be in greater than 0");if(!Ae(a))throw new Error("size must be an integer");if(e>en(2,a-1)-1||e<-en(2,a-1))throw new Error("Value must be in range [-2^".concat(a-1,", 2^").concat(a-1,"-1]"));if(!Ae(e))throw new Error("Value must be an integer");e<0&&(e=e+en(2,a)),i="i".concat(a)}var l="";return e<0&&(e=-e,l="-"),"".concat(l).concat(r).concat(e.toString(n)).concat(i)}function Ht(e,n){if(typeof n=="function")return n(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var a="auto",t,r;if(n&&(n.notation&&(a=n.notation),Be(n)?t=n:Be(n.precision)&&(t=n.precision),n.wordSize&&(r=n.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return co(e,t);case"exponential":return fo(e,t);case"engineering":return Xp(e,t);case"bin":return ja(e,2,r);case"oct":return ja(e,8,r);case"hex":return ja(e,16,r);case"auto":return Yp(e,t,n&&n).replace(/((\.\d*?)(0+))($|e)/,function(){var i=arguments[2],l=arguments[4];return i!=="."?i+l:l});default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ra(e){var n=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!n)throw new SyntaxError("Invalid number "+e);var a=n[1],t=n[2],r=parseFloat(n[4]||"0"),i=t.indexOf(".");r+=i!==-1?i-1:t.length-1;var l=t.replace(".","").replace(/^0*/,function(m){return r-=m.length,""}).replace(/0*$/,"").split("").map(function(m){return parseInt(m)});return l.length===0&&(l.push(0),r++),{sign:a,coefficients:l,exponent:r}}function Xp(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=ta(a,n),r=t.exponent,i=t.coefficients,l=r%3===0?r:r<0?r-3-r%3:r-r%3;if(Be(n))for(;n>i.length||r-l+1>i.length;)i.push(0);else for(var m=Math.abs(r-l)-(i.length-1),f=0;f<m;f++)i.push(0);for(var c=Math.abs(r-l),s=1;c>0;)s++,c--;var o=i.slice(s).join(""),u=Be(n)&&o.length||o.match(/[1-9]/)?"."+o:"",p=i.slice(0,s).join("")+u+"e"+(r>=0?"+":"")+l.toString();return t.sign+p}function co(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=typeof n=="number"?ta(a,a.exponent+1+n):a,r=t.coefficients,i=t.exponent+1,l=i+(n||0);return r.length<l&&(r=r.concat(nn(l-r.length))),i<0&&(r=nn(-i+1).concat(r),i=1),i<r.length&&r.splice(i,0,i===0?"0.":"."),t.sign+r.join("")}function fo(e,n){if(isNaN(e)||!isFinite(e))return String(e);var a=ra(e),t=n?ta(a,n):a,r=t.coefficients,i=t.exponent;r.length<n&&(r=r.concat(nn(n-r.length)));var l=r.shift();return t.sign+l+(r.length>0?"."+r.join(""):"")+"e"+(i>=0?"+":"")+i}function Yp(e,n,a){if(isNaN(e)||!isFinite(e))return String(e);var t=a&&a.lowerExp!==void 0?a.lowerExp:-3,r=a&&a.upperExp!==void 0?a.upperExp:5,i=ra(e),l=n?ta(i,n):i;if(l.exponent<t||l.exponent>=r)return fo(e,n);var m=l.coefficients,f=l.exponent;m.length<n&&(m=m.concat(nn(n-m.length))),m=m.concat(nn(f-m.length+1+(m.length<n?n-m.length:0))),m=nn(-f).concat(m);var c=f>0?f:0;return c<m.length-1&&m.splice(c+1,0,"."),l.sign+m.join("")}function ta(e,n){for(var a={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},t=a.coefficients;n<=0;)t.unshift(0),a.exponent++,n++;if(t.length>n){var r=t.splice(n,t.length-n);if(r[0]>=5){var i=n-1;for(t[i]++;t[i]===10;)t.pop(),i===0&&(t.unshift(0),a.exponent++,i++),i--,t[i]++}}return a}function nn(e){for(var n=[],a=0;a<e;a++)n.push(0);return n}function Wp(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var Jp=Number.EPSILON||2220446049250313e-31;function Rr(e,n,a){if(a==null)return e===n;if(e===n)return!0;if(isNaN(e)||isNaN(n))return!1;if(isFinite(e)&&isFinite(n)){var t=Math.abs(e-n);return t<Jp?!0:t<=Math.max(Math.abs(e),Math.abs(n))*a}return!1}var Qp=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},Kp=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},jp=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},ev=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},rv=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},tv=Math.tanh||function(e){var n=Math.exp(2*e);return(n-1)/(n+1)};function nv(e,n){var a=!0,t=n>0?!0:n<0?!1:1/n===1/0;return a^t?-e:e}function ei(e,n,a){var t=e.constructor,r=new t(2),i="";if(a){if(a<1)throw new Error("size must be in greater than 0");if(!Ae(a))throw new Error("size must be an integer");if(e.greaterThan(r.pow(a-1).sub(1))||e.lessThan(r.pow(a-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(a-1,", 2^").concat(a-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(r.pow(a))),i="i".concat(a)}switch(n){case 2:return"".concat(e.toBinary()).concat(i);case 8:return"".concat(e.toOctal()).concat(i);case 16:return"".concat(e.toHexadecimal()).concat(i);default:throw new Error("Base ".concat(n," not supported "))}}function av(e,n){if(typeof n=="function")return n(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var a="auto",t,r;if(n!==void 0&&(n.notation&&(a=n.notation),typeof n=="number"?t=n:n.precision&&(t=n.precision),n.wordSize&&(r=n.wordSize,typeof r!="number")))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return ov(e,t);case"exponential":return lo(e,t);case"engineering":return iv(e,t);case"bin":return ei(e,2,r);case"oct":return ei(e,8,r);case"hex":return ei(e,16,r);case"auto":{var i=n&&n.lowerExp!==void 0?n.lowerExp:-3,l=n&&n.upperExp!==void 0?n.upperExp:5;if(e.isZero())return"0";var m,f=e.toSignificantDigits(t),c=f.e;return c>=i&&c<l?m=f.toFixed():m=lo(e,t),m.replace(/((\.\d*?)(0+))($|e)/,function(){var s=arguments[2],o=arguments[4];return s!=="."?s+o:o})}default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function iv(e,n){var a=e.e,t=a%3===0?a:a<0?a-3-a%3:a-a%3,r=e.mul(Math.pow(10,-t)),i=r.toPrecision(n);return i.indexOf("e")!==-1&&(i=r.toString()),i+"e"+(a>=0?"+":"")+t.toString()}function lo(e,n){return n!==void 0?e.toExponential(n-1):e.toExponential()}function ov(e,n){return e.toFixed(n)}function sv(e,n){var a=e.length-n.length,t=e.length;return e.substring(a,t)===n}function Re(e,n){var a=uv(e,n);return n&&typeof n=="object"&&"truncate"in n&&a.length>n.truncate?a.substring(0,n.truncate-3)+"...":a}function uv(e,n){if(typeof e=="number")return Ht(e,n);if(_e(e))return av(e,n);if(cv(e))return!n||n.fraction!=="decimal"?e.s*e.n+"/"+e.d:e.toString();if(Array.isArray(e))return mo(e,n);if(_r(e))return'"'+e+'"';if(typeof e=="function")return e.syntax?String(e.syntax):"function";if(e&&typeof e=="object"){if(typeof e.format=="function")return e.format(n);if(e&&e.toString(n)!=={}.toString())return e.toString(n);var a=Object.keys(e).map(t=>'"'+t+'": '+Re(e[t],n));return"{"+a.join(", ")+"}"}return String(e)}function na(e){for(var n=String(e),a="",t=0;t<n.length;){var r=n.charAt(t);r==="\\"?(a+=r,t++,r=n.charAt(t),(r===""||'"\\/bfnrtu'.indexOf(r)===-1)&&(a+="\\"),a+=r):r==='"'?a+='\\"':a+=r,t++}return'"'+a+'"'}function Gr(e){var n=String(e);return n=n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),n}function mo(e,n){if(Array.isArray(e)){for(var a="[",t=e.length,r=0;r<t;r++)r!==0&&(a+=", "),a+=mo(e[r],n);return a+="]",a}else return Re(e,n)}function cv(e){return e&&typeof e=="object"&&typeof e.s=="number"&&typeof e.n=="number"&&typeof e.d=="number"||!1}function an(e,n){if(!_r(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Ke(e)+", index: 0)");if(!_r(n))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Ke(n)+", index: 1)");return e===n?0:e>n?1:-1}function Fe(e,n,a){if(!(this instanceof Fe))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=n,this.relation=a,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(n)?"["+n.join(", ")+"]":n)+")",this.stack=new Error().stack}Fe.prototype=new RangeError,Fe.prototype.constructor=RangeError,Fe.prototype.name="DimensionError",Fe.prototype.isDimensionError=!0;function Kr(e,n,a){if(!(this instanceof Kr))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=n):(this.min=n,this.max=a),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}Kr.prototype=new RangeError,Kr.prototype.constructor=RangeError,Kr.prototype.name="IndexError",Kr.prototype.isIndexError=!0;function Pe(e){for(var n=[];Array.isArray(e);)n.push(e.length),e=e[0];return n}function po(e,n,a){var t,r=e.length;if(r!==n[a])throw new Fe(r,n[a]);if(a<n.length-1){var i=a+1;for(t=0;t<r;t++){var l=e[t];if(!Array.isArray(l))throw new Fe(n.length-1,n.length,"<");po(e[t],n,i)}}else for(t=0;t<r;t++)if(Array.isArray(e[t]))throw new Fe(n.length+1,n.length,">")}function vo(e,n){var a=n.length===0;if(a){if(Array.isArray(e))throw new Fe(e.length,0)}else po(e,n,0)}function We(e,n){if(!Be(e)||!Ae(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof n=="number"&&e>=n)throw new Kr(e,n)}function on(e,n,a){if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(n.length===0)throw new Error("Resizing to scalar is not supported");n.forEach(function(r){if(!Be(r)||!Ae(r)||r<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Re(n)+")")});var t=a!==void 0?a:0;return ri(e,n,0,t),e}function ri(e,n,a,t){var r,i,l=e.length,m=n[a],f=Math.min(l,m);if(e.length=m,a<n.length-1){var c=a+1;for(r=0;r<f;r++)i=e[r],Array.isArray(i)||(i=[i],e[r]=i),ri(i,n,c,t);for(r=f;r<m;r++)i=[],e[r]=i,ri(i,n,c,t)}else{for(r=0;r<f;r++)for(;Array.isArray(e[r]);)e[r]=e[r][0];for(r=f;r<m;r++)e[r]=t}}function ho(e,n){var a=Le(e),t=a.length;if(!Array.isArray(e)||!Array.isArray(n))throw new TypeError("Array expected");if(n.length===0)throw new Fe(0,t,"!=");n=ti(n,t);var r=go(n);if(t!==r)throw new Fe(r,t,"!=");try{return fv(a,n)}catch(i){throw i instanceof Fe?new Fe(r,t,"!="):i}}function ti(e,n){var a=go(e),t=e.slice(),r=-1,i=e.indexOf(r),l=e.indexOf(r,i+1)>=0;if(l)throw new Error("More than one wildcard in sizes");var m=i>=0,f=n%a===0;if(m)if(f)t[i]=-n/a;else throw new Error("Could not replace wildcard, since "+n+" is no multiple of "+-a);return t}function go(e){return e.reduce((n,a)=>n*a,1)}function fv(e,n){for(var a=e,t,r=n.length-1;r>0;r--){var i=n[r];t=[];for(var l=a.length/i,m=0;m<l;m++)t.push(a.slice(m*i,(m+1)*i));a=t}return a}function aa(e,n){for(var a=Pe(e);Array.isArray(e)&&e.length===1;)e=e[0],a.shift();for(var t=a.length;a[t-1]===1;)t--;return t<a.length&&(e=yo(e,t,0),a.length=t),e}function yo(e,n,a){var t,r;if(a<n){var i=a+1;for(t=0,r=e.length;t<r;t++)e[t]=yo(e[t],n,i)}else for(;Array.isArray(e);)e=e[0];return e}function xo(e,n,a,t){var r=t||Pe(e);if(a)for(var i=0;i<a;i++)e=[e],r.unshift(1);for(e=bo(e,n,0);r.length<n;)r.push(1);return e}function bo(e,n,a){var t,r;if(Array.isArray(e)){var i=a+1;for(t=0,r=e.length;t<r;t++)e[t]=bo(e[t],n,i)}else for(var l=a;l<n;l++)e=[e];return e}function Le(e){if(!Array.isArray(e))return e;var n=[];return e.forEach(function a(t){Array.isArray(t)?t.forEach(a):n.push(t)}),n}function dt(e,n){return Array.prototype.map.call(e,n)}function ia(e,n){Array.prototype.forEach.call(e,n)}function wo(e,n){if(Pe(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,n)}function oa(e,n){if(Pe(e).length!==1)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,a=>n.test(a))}function No(e,n){return Array.prototype.join.call(e,n)}function sn(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;var n=[],a=0;n[0]={value:e[0],identifier:0};for(var t=1;t<e.length;t++)e[t]===e[t-1]?a++:a=0,n.push({value:e[t],identifier:a});return n}function sa(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(e.length===0)return e;for(var n=[],a=0;a<e.length;a++)n.push(e[a].value);return n}function Bn(e,n){for(var a,t=0,r=0;r<e.length;r++){var i=e[r],l=Array.isArray(i);if(r===0&&l&&(t=i.length),l&&i.length!==t)return;var m=l?Bn(i,n):n(i);if(a===void 0)a=m;else if(a!==m)return"mixed"}return a}function R(e,n,a,t){function r(i){var l=qp(i,n.map(pv));return lv(e,n,i),a(l)}return r.isFactory=!0,r.fn=e,r.dependencies=n.slice().sort(),t&&(r.meta=t),r}function lv(e,n,a){var t=n.filter(i=>!mv(i)).every(i=>a[i]!==void 0);if(!t){var r=n.filter(i=>a[i]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(r.map(i=>'"'.concat(i,'"')).join(", "),"."))}}function mv(e){return e&&e[0]==="?"}function pv(e){return e&&e[0]==="?"?e.slice(1):e}function Vr(e,n){if(Mo(e)&&ni(e,n))return e[n];throw typeof e[n]=="function"&&ai(e,n)?new Error('Cannot access method "'+n+'" as a property'):new Error('No access to property "'+n+'"')}function un(e,n,a){if(Mo(e)&&ni(e,n))return e[n]=a,a;throw new Error('No access to property "'+n+'"')}function vv(e,n){return n in e}function ni(e,n){return!e||typeof e!="object"?!1:Me(dv,n)?!0:!(n in Object.prototype||n in Function.prototype)}function hv(e,n){if(!ai(e,n))throw new Error('No access to method "'+n+'"')}function ai(e,n){return e==null||typeof e[n]!="function"||Me(e,n)&&Object.getPrototypeOf&&n in Object.getPrototypeOf(e)?!1:Me(gv,n)?!0:!(n in Object.prototype||n in Function.prototype)}function Mo(e){return typeof e=="object"&&e&&e.constructor===Object}var dv={length:!0,name:!0},gv={toString:!0,valueOf:!0,toLocaleString:!0};class ii{constructor(n){this.wrappedObject=n}keys(){return Object.keys(this.wrappedObject)}get(n){return Vr(this.wrappedObject,n)}set(n,a){return un(this.wrappedObject,n,a),this}has(n){return vv(this.wrappedObject,n)}}function gt(){return new Map}function oi(e){if(!e)return gt();if(ua(e))return e;if(Ja(e))return new ii(e);throw new Error("createMap can create maps from objects or Maps")}function yv(e){if(e instanceof ii)return e.wrappedObject;var n={};for(var a of e.keys()){var t=e.get(a);un(n,a,t)}return n}function ua(e){return e?e instanceof Map||e instanceof ii||typeof e.set=="function"&&typeof e.get=="function"&&typeof e.keys=="function"&&typeof e.has=="function":!1}function Ao(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),t=1;t<n;t++)a[t-1]=arguments[t];for(var r of a)if(r){if(ua(r))for(var i of r.keys())e.set(i,r.get(i));else if(Ja(r))for(var l of Object.keys(r))e.set(l,r[l])}return e}var So=function(){return So=uo.create,uo},xv=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],bv=R("typed",xv,function(n){var{BigNumber:a,Complex:t,DenseMatrix:r,Fraction:i}=n,l=So();return l.types=[{name:"number",test:Be},{name:"Complex",test:Or},{name:"BigNumber",test:_e},{name:"Fraction",test:yr},{name:"Unit",test:ht},{name:"string",test:_r},{name:"Chain",test:Qa},{name:"Array",test:Xe},{name:"Matrix",test:Oe},{name:"DenseMatrix",test:Qn},{name:"SparseMatrix",test:Ut},{name:"Range",test:Kn},{name:"Index",test:En},{name:"boolean",test:Mp},{name:"ResultSet",test:oo},{name:"Help",test:Wa},{name:"function",test:Ap},{name:"Date",test:Sp},{name:"RegExp",test:Ep},{name:"null",test:Cp},{name:"undefined",test:Op},{name:"AccessorNode",test:Lt},{name:"ArrayNode",test:Hr},{name:"AssignmentNode",test:Dp},{name:"BlockNode",test:Tp},{name:"ConditionalNode",test:Bp},{name:"ConstantNode",test:Ye},{name:"FunctionNode",test:kt},{name:"FunctionAssignmentNode",test:Cn},{name:"IndexNode",test:tn},{name:"Node",test:Ve},{name:"ObjectNode",test:jn},{name:"OperatorNode",test:$r},{name:"ParenthesisNode",test:On},{name:"RangeNode",test:_p},{name:"SymbolNode",test:xr},{name:"Map",test:ua},{name:"Object",test:Ja}],l.conversions=[{from:"number",to:"BigNumber",convert:function(f){if(a||si(f),Wp(f)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+f+"). Use function bignumber(x) to convert to BigNumber.");return new a(f)}},{from:"number",to:"Complex",convert:function(f){return t||ca(f),new t(f,0)}},{from:"number",to:"string",convert:function(f){return f+""}},{from:"BigNumber",to:"Complex",convert:function(f){return t||ca(f),new t(f.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(f){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(f){return t||ca(f),new t(f.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(f){i||ui(f);var c=new i(f);if(c.valueOf()!==f)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+f+"). Use function fraction(x) to convert to Fraction.");return c}},{from:"string",to:"number",convert:function(f){var c=Number(f);if(isNaN(c))throw new Error('Cannot convert "'+f+'" to a number');return c}},{from:"string",to:"BigNumber",convert:function(f){a||si(f);try{return new a(f)}catch(c){throw new Error('Cannot convert "'+f+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(f){i||ui(f);try{return new i(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(f){t||ca(f);try{return new t(f)}catch(c){throw new Error('Cannot convert "'+f+'" to Complex')}}},{from:"boolean",to:"number",convert:function(f){return+f}},{from:"boolean",to:"BigNumber",convert:function(f){return a||si(f),new a(+f)}},{from:"boolean",to:"Fraction",convert:function(f){return i||ui(f),new i(+f)}},{from:"boolean",to:"string",convert:function(f){return String(f)}},{from:"Array",to:"Matrix",convert:function(f){return r||wv(),new r(f)}},{from:"Matrix",to:"Array",convert:function(f){return f.valueOf()}}],l});function si(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function ca(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function wv(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function ui(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var Nv="ResultSet",Mv=[],Av=R(Nv,Mv,()=>{function e(n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=n||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(n){return new e(n.entries)},e},{isClass:!0});var cn=9e15,Tt=1e9,ci="0123456789abcdef",fa="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",la="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",fi={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-cn,maxE:cn,crypto:!1},Eo,yt,$e=!0,ma="[DecimalError] ",Bt=ma+"Invalid argument: ",Co=ma+"Precision limit exceeded",Oo=ma+"crypto unavailable",Do="[object Decimal]",Nr=Math.floor,hr=Math.pow,Sv=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ev=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Cv=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,To=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,jr=1e7,De=7,Ov=9007199254740991,Dv=fa.length-1,li=la.length-1,ce={toStringTag:Do};ce.absoluteValue=ce.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Ee(e)},ce.ceil=function(){return Ee(new this.constructor(this),this.e+1,2)},ce.clampedTo=ce.clamp=function(e,n){var a,t=this,r=t.constructor;if(e=new r(e),n=new r(n),!e.s||!n.s)return new r(NaN);if(e.gt(n))throw Error(Bt+n);return a=t.cmp(e),a<0?e:t.cmp(n)>0?n:new r(t)},ce.comparedTo=ce.cmp=function(e){var n,a,t,r,i=this,l=i.d,m=(e=new i.constructor(e)).d,f=i.s,c=e.s;if(!l||!m)return!f||!c?NaN:f!==c?f:l===m?0:!l^f<0?1:-1;if(!l[0]||!m[0])return l[0]?f:m[0]?-c:0;if(f!==c)return f;if(i.e!==e.e)return i.e>e.e^f<0?1:-1;for(t=l.length,r=m.length,n=0,a=t<r?t:r;n<a;++n)if(l[n]!==m[n])return l[n]>m[n]^f<0?1:-1;return t===r?0:t>r^f<0?1:-1},ce.cosine=ce.cos=function(){var e,n,a=this,t=a.constructor;return a.d?a.d[0]?(e=t.precision,n=t.rounding,t.precision=e+Math.max(a.e,a.sd())+De,t.rounding=1,a=Tv(t,Ro(t,a)),t.precision=e,t.rounding=n,Ee(yt==2||yt==3?a.neg():a,e,n,!0)):new t(1):new t(NaN)},ce.cubeRoot=ce.cbrt=function(){var e,n,a,t,r,i,l,m,f,c,s=this,o=s.constructor;if(!s.isFinite()||s.isZero())return new o(s);for($e=!1,i=s.s*hr(s.s*s,1/3),!i||Math.abs(i)==1/0?(a=br(s.d),e=s.e,(i=(e-a.length+1)%3)&&(a+=i==1||i==-2?"0":"00"),i=hr(a,1/3),e=Nr((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?a="5e"+e:(a=i.toExponential(),a=a.slice(0,a.indexOf("e")+1)+e),t=new o(a),t.s=s.s):t=new o(i.toString()),l=(e=o.precision)+3;;)if(m=t,f=m.times(m).times(m),c=f.plus(s),t=er(c.plus(s).times(m),c.plus(f),l+2,1),br(m.d).slice(0,l)===(a=br(t.d)).slice(0,l))if(a=a.slice(l-3,l+1),a=="9999"||!r&&a=="4999"){if(!r&&(Ee(m,e+1,0),m.times(m).times(m).eq(s))){t=m;break}l+=4,r=1}else{(!+a||!+a.slice(1)&&a.charAt(0)=="5")&&(Ee(t,e+1,1),n=!t.times(t).times(t).eq(s));break}return $e=!0,Ee(t,e,o.rounding,n)},ce.decimalPlaces=ce.dp=function(){var e,n=this.d,a=NaN;if(n){if(e=n.length-1,a=(e-Nr(this.e/De))*De,e=n[e],e)for(;e%10==0;e/=10)a--;a<0&&(a=0)}return a},ce.dividedBy=ce.div=function(e){return er(this,new this.constructor(e))},ce.dividedToIntegerBy=ce.divToInt=function(e){var n=this,a=n.constructor;return Ee(er(n,new a(e),0,1,1),a.precision,a.rounding)},ce.equals=ce.eq=function(e){return this.cmp(e)===0},ce.floor=function(){return Ee(new this.constructor(this),this.e+1,3)},ce.greaterThan=ce.gt=function(e){return this.cmp(e)>0},ce.greaterThanOrEqualTo=ce.gte=function(e){var n=this.cmp(e);return n==1||n===0},ce.hyperbolicCosine=ce.cosh=function(){var e,n,a,t,r,i=this,l=i.constructor,m=new l(1);if(!i.isFinite())return new l(i.s?1/0:NaN);if(i.isZero())return m;a=l.precision,t=l.rounding,l.precision=a+Math.max(i.e,i.sd())+4,l.rounding=1,r=i.d.length,r<32?(e=Math.ceil(r/3),n=(1/ga(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i=fn(l,1,i.times(n),new l(1),!0);for(var f,c=e,s=new l(8);c--;)f=i.times(i),i=m.minus(f.times(s.minus(f.times(s))));return Ee(i,l.precision=a,l.rounding=t,!0)},ce.hyperbolicSine=ce.sinh=function(){var e,n,a,t,r=this,i=r.constructor;if(!r.isFinite()||r.isZero())return new i(r);if(n=i.precision,a=i.rounding,i.precision=n+Math.max(r.e,r.sd())+4,i.rounding=1,t=r.d.length,t<3)r=fn(i,2,r,r,!0);else{e=1.4*Math.sqrt(t),e=e>16?16:e|0,r=r.times(1/ga(5,e)),r=fn(i,2,r,r,!0);for(var l,m=new i(5),f=new i(16),c=new i(20);e--;)l=r.times(r),r=r.times(m.plus(l.times(f.times(l).plus(c))))}return i.precision=n,i.rounding=a,Ee(r,n,a,!0)},ce.hyperbolicTangent=ce.tanh=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+7,t.rounding=1,er(a.sinh(),a.cosh(),t.precision=e,t.rounding=n)):new t(a.s)},ce.inverseCosine=ce.acos=function(){var e=this,n=e.constructor,a=e.abs().cmp(1),t=n.precision,r=n.rounding;return a!==-1?a===0?e.isNeg()?ot(n,t,r):new n(0):new n(NaN):e.isZero()?ot(n,t+4,r).times(.5):(n.precision=t+6,n.rounding=1,e=new n(1).minus(e).div(e.plus(1)).sqrt().atan(),n.precision=t,n.rounding=r,e.times(2))},ce.inverseHyperbolicCosine=ce.acosh=function(){var e,n,a=this,t=a.constructor;return a.lte(1)?new t(a.eq(1)?0:NaN):a.isFinite()?(e=t.precision,n=t.rounding,t.precision=e+Math.max(Math.abs(a.e),a.sd())+4,t.rounding=1,$e=!1,a=a.times(a).minus(1).sqrt().plus(a),$e=!0,t.precision=e,t.rounding=n,a.ln()):new t(a)},ce.inverseHyperbolicSine=ce.asinh=function(){var e,n,a=this,t=a.constructor;return!a.isFinite()||a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+2*Math.max(Math.abs(a.e),a.sd())+6,t.rounding=1,$e=!1,a=a.times(a).plus(1).sqrt().plus(a),$e=!0,t.precision=e,t.rounding=n,a.ln())},ce.inverseHyperbolicTangent=ce.atanh=function(){var e,n,a,t,r=this,i=r.constructor;return r.isFinite()?r.e>=0?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=i.precision,n=i.rounding,t=r.sd(),Math.max(t,e)<2*-r.e-1?Ee(new i(r),e,n,!0):(i.precision=a=t-r.e,r=er(r.plus(1),new i(1).minus(r),a+e,1),i.precision=e+4,i.rounding=1,r=r.ln(),i.precision=e,i.rounding=n,r.times(.5))):new i(NaN)},ce.inverseSine=ce.asin=function(){var e,n,a,t,r=this,i=r.constructor;return r.isZero()?new i(r):(n=r.abs().cmp(1),a=i.precision,t=i.rounding,n!==-1?n===0?(e=ot(i,a+4,t).times(.5),e.s=r.s,e):new i(NaN):(i.precision=a+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=a,i.rounding=t,r.times(2)))},ce.inverseTangent=ce.atan=function(){var e,n,a,t,r,i,l,m,f,c=this,s=c.constructor,o=s.precision,u=s.rounding;if(c.isFinite()){if(c.isZero())return new s(c);if(c.abs().eq(1)&&o+4<=li)return l=ot(s,o+4,u).times(.25),l.s=c.s,l}else{if(!c.s)return new s(NaN);if(o+4<=li)return l=ot(s,o+4,u).times(.5),l.s=c.s,l}for(s.precision=m=o+10,s.rounding=1,a=Math.min(28,m/De+2|0),e=a;e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for($e=!1,n=Math.ceil(m/De),t=1,f=c.times(c),l=new s(c),r=c;e!==-1;)if(r=r.times(f),i=l.minus(r.div(t+=2)),r=r.times(f),l=i.plus(r.div(t+=2)),l.d[n]!==void 0)for(e=n;l.d[e]===i.d[e]&&e--;);return a&&(l=l.times(2<<a-1)),$e=!0,Ee(l,s.precision=o,s.rounding=u,!0)},ce.isFinite=function(){return!!this.d},ce.isInteger=ce.isInt=function(){return!!this.d&&Nr(this.e/De)>this.d.length-2},ce.isNaN=function(){return!this.s},ce.isNegative=ce.isNeg=function(){return this.s<0},ce.isPositive=ce.isPos=function(){return this.s>0},ce.isZero=function(){return!!this.d&&this.d[0]===0},ce.lessThan=ce.lt=function(e){return this.cmp(e)<0},ce.lessThanOrEqualTo=ce.lte=function(e){return this.cmp(e)<1},ce.logarithm=ce.log=function(e){var n,a,t,r,i,l,m,f,c=this,s=c.constructor,o=s.precision,u=s.rounding,p=5;if(e==null)e=new s(10),n=!0;else{if(e=new s(e),a=e.d,e.s<0||!a||!a[0]||e.eq(1))return new s(NaN);n=e.eq(10)}if(a=c.d,c.s<0||!a||!a[0]||c.eq(1))return new s(a&&!a[0]?-1/0:c.s!=1?NaN:a?0:1/0);if(n)if(a.length>1)i=!0;else{for(r=a[0];r%10===0;)r/=10;i=r!==1}if($e=!1,m=o+p,l=$t(c,m),t=n?ha(s,m+10):$t(e,m),f=er(l,t,m,1),_n(f.d,r=o,u))do if(m+=10,l=$t(c,m),t=n?ha(s,m+10):$t(e,m),f=er(l,t,m,1),!i){+br(f.d).slice(r+1,r+15)+1==1e14&&(f=Ee(f,o+1,0));break}while(_n(f.d,r+=10,u));return $e=!0,Ee(f,o,u)},ce.minus=ce.sub=function(e){var n,a,t,r,i,l,m,f,c,s,o,u,p=this,v=p.constructor;if(e=new v(e),!p.d||!e.d)return!p.s||!e.s?e=new v(NaN):p.d?e.s=-e.s:e=new v(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(c=p.d,u=e.d,m=v.precision,f=v.rounding,!c[0]||!u[0]){if(u[0])e.s=-e.s;else if(c[0])e=new v(p);else return new v(f===3?-0:0);return $e?Ee(e,m,f):e}if(a=Nr(e.e/De),s=Nr(p.e/De),c=c.slice(),i=s-a,i){for(o=i<0,o?(n=c,i=-i,l=u.length):(n=u,a=s,l=c.length),t=Math.max(Math.ceil(m/De),l)+2,i>t&&(i=t,n.length=1),n.reverse(),t=i;t--;)n.push(0);n.reverse()}else{for(t=c.length,l=u.length,o=t<l,o&&(l=t),t=0;t<l;t++)if(c[t]!=u[t]){o=c[t]<u[t];break}i=0}for(o&&(n=c,c=u,u=n,e.s=-e.s),l=c.length,t=u.length-l;t>0;--t)c[l++]=0;for(t=u.length;t>i;){if(c[--t]<u[t]){for(r=t;r&&c[--r]===0;)c[r]=jr-1;--c[r],c[t]+=jr}c[t]-=u[t]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--a;return c[0]?(e.d=c,e.e=va(c,a),$e?Ee(e,m,f):e):new v(f===3?-0:0)},ce.modulo=ce.mod=function(e){var n,a=this,t=a.constructor;return e=new t(e),!a.d||!e.s||e.d&&!e.d[0]?new t(NaN):!e.d||a.d&&!a.d[0]?Ee(new t(a),t.precision,t.rounding):($e=!1,t.modulo==9?(n=er(a,e.abs(),0,3,1),n.s*=e.s):n=er(a,e,0,t.modulo,1),n=n.times(e),$e=!0,a.minus(n))},ce.naturalExponential=ce.exp=function(){return mi(this)},ce.naturalLogarithm=ce.ln=function(){return $t(this)},ce.negated=ce.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Ee(e)},ce.plus=ce.add=function(e){var n,a,t,r,i,l,m,f,c,s,o=this,u=o.constructor;if(e=new u(e),!o.d||!e.d)return!o.s||!e.s?e=new u(NaN):o.d||(e=new u(e.d||o.s===e.s?o:NaN)),e;if(o.s!=e.s)return e.s=-e.s,o.minus(e);if(c=o.d,s=e.d,m=u.precision,f=u.rounding,!c[0]||!s[0])return s[0]||(e=new u(o)),$e?Ee(e,m,f):e;if(i=Nr(o.e/De),t=Nr(e.e/De),c=c.slice(),r=i-t,r){for(r<0?(a=c,r=-r,l=s.length):(a=s,t=i,l=c.length),i=Math.ceil(m/De),l=i>l?i+1:l+1,r>l&&(r=l,a.length=1),a.reverse();r--;)a.push(0);a.reverse()}for(l=c.length,r=s.length,l-r<0&&(r=l,a=s,s=c,c=a),n=0;r;)n=(c[--r]=c[r]+s[r]+n)/jr|0,c[r]%=jr;for(n&&(c.unshift(n),++t),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=va(c,t),$e?Ee(e,m,f):e},ce.precision=ce.sd=function(e){var n,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Bt+e);return a.d?(n=Bo(a.d),e&&a.e+1>n&&(n=a.e+1)):n=NaN,n},ce.round=function(){var e=this,n=e.constructor;return Ee(new n(e),e.e+1,n.rounding)},ce.sine=ce.sin=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+Math.max(a.e,a.sd())+De,t.rounding=1,a=_v(t,Ro(t,a)),t.precision=e,t.rounding=n,Ee(yt>2?a.neg():a,e,n,!0)):new t(NaN)},ce.squareRoot=ce.sqrt=function(){var e,n,a,t,r,i,l=this,m=l.d,f=l.e,c=l.s,s=l.constructor;if(c!==1||!m||!m[0])return new s(!c||c<0&&(!m||m[0])?NaN:m?l:1/0);for($e=!1,c=Math.sqrt(+l),c==0||c==1/0?(n=br(m),(n.length+f)%2==0&&(n+="0"),c=Math.sqrt(n),f=Nr((f+1)/2)-(f<0||f%2),c==1/0?n="5e"+f:(n=c.toExponential(),n=n.slice(0,n.indexOf("e")+1)+f),t=new s(n)):t=new s(c.toString()),a=(f=s.precision)+3;;)if(i=t,t=i.plus(er(l,i,a+2,1)).times(.5),br(i.d).slice(0,a)===(n=br(t.d)).slice(0,a))if(n=n.slice(a-3,a+1),n=="9999"||!r&&n=="4999"){if(!r&&(Ee(i,f+1,0),i.times(i).eq(l))){t=i;break}a+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(Ee(t,f+1,1),e=!t.times(t).eq(l));break}return $e=!0,Ee(t,f,s.rounding,e)},ce.tangent=ce.tan=function(){var e,n,a=this,t=a.constructor;return a.isFinite()?a.isZero()?new t(a):(e=t.precision,n=t.rounding,t.precision=e+10,t.rounding=1,a=a.sin(),a.s=1,a=er(a,new t(1).minus(a.times(a)).sqrt(),e+10,0),t.precision=e,t.rounding=n,Ee(yt==2||yt==4?a.neg():a,e,n,!0)):new t(NaN)},ce.times=ce.mul=function(e){var n,a,t,r,i,l,m,f,c,s=this,o=s.constructor,u=s.d,p=(e=new o(e)).d;if(e.s*=s.s,!u||!u[0]||!p||!p[0])return new o(!e.s||u&&!u[0]&&!p||p&&!p[0]&&!u?NaN:!u||!p?e.s/0:e.s*0);for(a=Nr(s.e/De)+Nr(e.e/De),f=u.length,c=p.length,f<c&&(i=u,u=p,p=i,l=f,f=c,c=l),i=[],l=f+c,t=l;t--;)i.push(0);for(t=c;--t>=0;){for(n=0,r=f+t;r>t;)m=i[r]+p[t]*u[r-t-1]+n,i[r--]=m%jr|0,n=m/jr|0;i[r]=(i[r]+n)%jr|0}for(;!i[--l];)i.pop();return n?++a:i.shift(),e.d=i,e.e=va(i,a),$e?Ee(e,o.precision,o.rounding):e},ce.toBinary=function(e,n){return pi(this,2,e,n)},ce.toDecimalPlaces=ce.toDP=function(e,n){var a=this,t=a.constructor;return a=new t(a),e===void 0?a:(Ir(e,0,Tt),n===void 0?n=t.rounding:Ir(n,0,8),Ee(a,e+a.e+1,n))},ce.toExponential=function(e,n){var a,t=this,r=t.constructor;return e===void 0?a=it(t,!0):(Ir(e,0,Tt),n===void 0?n=r.rounding:Ir(n,0,8),t=Ee(new r(t),e+1,n),a=it(t,!0,e+1)),t.isNeg()&&!t.isZero()?"-"+a:a},ce.toFixed=function(e,n){var a,t,r=this,i=r.constructor;return e===void 0?a=it(r):(Ir(e,0,Tt),n===void 0?n=i.rounding:Ir(n,0,8),t=Ee(new i(r),e+r.e+1,n),a=it(t,!1,e+t.e+1)),r.isNeg()&&!r.isZero()?"-"+a:a},ce.toFraction=function(e){var n,a,t,r,i,l,m,f,c,s,o,u,p=this,v=p.d,h=p.constructor;if(!v)return new h(p);if(c=a=new h(1),t=f=new h(0),n=new h(t),i=n.e=Bo(v)-p.e-1,l=i%De,n.d[0]=hr(10,l<0?De+l:l),e==null)e=i>0?n:c;else{if(m=new h(e),!m.isInt()||m.lt(c))throw Error(Bt+m);e=m.gt(n)?i>0?n:c:m}for($e=!1,m=new h(br(v)),s=h.precision,h.precision=i=v.length*De*2;o=er(m,n,0,1,1),r=a.plus(o.times(t)),r.cmp(e)!=1;)a=t,t=r,r=c,c=f.plus(o.times(r)),f=r,r=n,n=m.minus(o.times(r)),m=r;return r=er(e.minus(a),t,0,1,1),f=f.plus(r.times(c)),a=a.plus(r.times(t)),f.s=c.s=p.s,u=er(c,t,i,1).minus(p).abs().cmp(er(f,a,i,1).minus(p).abs())<1?[c,t]:[f,a],h.precision=s,$e=!0,u},ce.toHexadecimal=ce.toHex=function(e,n){return pi(this,16,e,n)},ce.toNearest=function(e,n){var a=this,t=a.constructor;if(a=new t(a),e==null){if(!a.d)return a;e=new t(1),n=t.rounding}else{if(e=new t(e),n===void 0?n=t.rounding:Ir(n,0,8),!a.d)return e.s?a:e;if(!e.d)return e.s&&(e.s=a.s),e}return e.d[0]?($e=!1,a=er(a,e,0,n,1).times(e),$e=!0,Ee(a)):(e.s=a.s,a=e),a},ce.toNumber=function(){return+this},ce.toOctal=function(e,n){return pi(this,8,e,n)},ce.toPower=ce.pow=function(e){var n,a,t,r,i,l,m=this,f=m.constructor,c=+(e=new f(e));if(!m.d||!e.d||!m.d[0]||!e.d[0])return new f(hr(+m,c));if(m=new f(m),m.eq(1))return m;if(t=f.precision,i=f.rounding,e.eq(1))return Ee(m,t,i);if(n=Nr(e.e/De),n>=e.d.length-1&&(a=c<0?-c:c)<=Ov)return r=_o(f,m,a,t),e.s<0?new f(1).div(r):Ee(r,t,i);if(l=m.s,l<0){if(n<e.d.length-1)return new f(NaN);if((e.d[n]&1)==0&&(l=1),m.e==0&&m.d[0]==1&&m.d.length==1)return m.s=l,m}return a=hr(+m,c),n=a==0||!isFinite(a)?Nr(c*(Math.log("0."+br(m.d))/Math.LN10+m.e+1)):new f(a+"").e,n>f.maxE+1||n<f.minE-1?new f(n>0?l/0:0):($e=!1,f.rounding=m.s=1,a=Math.min(12,(n+"").length),r=mi(e.times($t(m,t+a)),t),r.d&&(r=Ee(r,t+5,1),_n(r.d,t,i)&&(n=t+10,r=Ee(mi(e.times($t(m,n+a)),n),n+5,1),+br(r.d).slice(t+1,t+15)+1==1e14&&(r=Ee(r,t+1,0)))),r.s=l,$e=!0,f.rounding=i,Ee(r,t,i))},ce.toPrecision=function(e,n){var a,t=this,r=t.constructor;return e===void 0?a=it(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(Ir(e,1,Tt),n===void 0?n=r.rounding:Ir(n,0,8),t=Ee(new r(t),e,n),a=it(t,e<=t.e||t.e<=r.toExpNeg,e)),t.isNeg()&&!t.isZero()?"-"+a:a},ce.toSignificantDigits=ce.toSD=function(e,n){var a=this,t=a.constructor;return e===void 0?(e=t.precision,n=t.rounding):(Ir(e,1,Tt),n===void 0?n=t.rounding:Ir(n,0,8)),Ee(new t(a),e,n)},ce.toString=function(){var e=this,n=e.constructor,a=it(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()&&!e.isZero()?"-"+a:a},ce.truncated=ce.trunc=function(){return Ee(new this.constructor(this),this.e+1,1)},ce.valueOf=ce.toJSON=function(){var e=this,n=e.constructor,a=it(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()?"-"+a:a};function br(e){var n,a,t,r=e.length-1,i="",l=e[0];if(r>0){for(i+=l,n=1;n<r;n++)t=e[n]+"",a=De-t.length,a&&(i+=_t(a)),i+=t;l=e[n],t=l+"",a=De-t.length,a&&(i+=_t(a))}else if(l===0)return"0";for(;l%10===0;)l/=10;return i+l}function Ir(e,n,a){if(e!==~~e||e<n||e>a)throw Error(Bt+e)}function _n(e,n,a,t){var r,i,l,m;for(i=e[0];i>=10;i/=10)--n;return--n<0?(n+=De,r=0):(r=Math.ceil((n+1)/De),n%=De),i=hr(10,De-n),m=e[r]%i|0,t==null?n<3?(n==0?m=m/100|0:n==1&&(m=m/10|0),l=a<4&&m==99999||a>3&&m==49999||m==5e4||m==0):l=(a<4&&m+1==i||a>3&&m+1==i/2)&&(e[r+1]/i/100|0)==hr(10,n-2)-1||(m==i/2||m==0)&&(e[r+1]/i/100|0)==0:n<4?(n==0?m=m/1e3|0:n==1?m=m/100|0:n==2&&(m=m/10|0),l=(t||a<4)&&m==9999||!t&&a>3&&m==4999):l=((t||a<4)&&m+1==i||!t&&a>3&&m+1==i/2)&&(e[r+1]/i/1e3|0)==hr(10,n-3)-1,l}function pa(e,n,a){for(var t,r=[0],i,l=0,m=e.length;l<m;){for(i=r.length;i--;)r[i]*=n;for(r[0]+=ci.indexOf(e.charAt(l++)),t=0;t<r.length;t++)r[t]>a-1&&(r[t+1]===void 0&&(r[t+1]=0),r[t+1]+=r[t]/a|0,r[t]%=a)}return r.reverse()}function Tv(e,n){var a,t,r;if(n.isZero())return n;t=n.d.length,t<32?(a=Math.ceil(t/3),r=(1/ga(4,a)).toString()):(a=16,r="2.3283064365386962890625e-10"),e.precision+=a,n=fn(e,1,n.times(r),new e(1));for(var i=a;i--;){var l=n.times(n);n=l.times(l).minus(l).times(8).plus(1)}return e.precision-=a,n}var er=function(){function e(t,r,i){var l,m=0,f=t.length;for(t=t.slice();f--;)l=t[f]*r+m,t[f]=l%i|0,m=l/i|0;return m&&t.unshift(m),t}function n(t,r,i,l){var m,f;if(i!=l)f=i>l?1:-1;else for(m=f=0;m<i;m++)if(t[m]!=r[m]){f=t[m]>r[m]?1:-1;break}return f}function a(t,r,i,l){for(var m=0;i--;)t[i]-=m,m=t[i]<r[i]?1:0,t[i]=m*l+t[i]-r[i];for(;!t[0]&&t.length>1;)t.shift()}return function(t,r,i,l,m,f){var c,s,o,u,p,v,h,b,w,N,g,y,x,d,A,S,O,M,_,E,$=t.constructor,z=t.s==r.s?1:-1,I=t.d,T=r.d;if(!I||!I[0]||!T||!T[0])return new $(!t.s||!r.s||(I?T&&I[0]==T[0]:!T)?NaN:I&&I[0]==0||!T?z*0:z/0);for(f?(p=1,s=t.e-r.e):(f=jr,p=De,s=Nr(t.e/p)-Nr(r.e/p)),_=T.length,O=I.length,w=new $(z),N=w.d=[],o=0;T[o]==(I[o]||0);o++);if(T[o]>(I[o]||0)&&s--,i==null?(d=i=$.precision,l=$.rounding):m?d=i+(t.e-r.e)+1:d=i,d<0)N.push(1),v=!0;else{if(d=d/p+2|0,o=0,_==1){for(u=0,T=T[0],d++;(o<O||u)&&d--;o++)A=u*f+(I[o]||0),N[o]=A/T|0,u=A%T|0;v=u||o<O}else{for(u=f/(T[0]+1)|0,u>1&&(T=e(T,u,f),I=e(I,u,f),_=T.length,O=I.length),S=_,g=I.slice(0,_),y=g.length;y<_;)g[y++]=0;E=T.slice(),E.unshift(0),M=T[0],T[1]>=f/2&&++M;do u=0,c=n(T,g,_,y),c<0?(x=g[0],_!=y&&(x=x*f+(g[1]||0)),u=x/M|0,u>1?(u>=f&&(u=f-1),h=e(T,u,f),b=h.length,y=g.length,c=n(h,g,b,y),c==1&&(u--,a(h,_<b?E:T,b,f))):(u==0&&(c=u=1),h=T.slice()),b=h.length,b<y&&h.unshift(0),a(g,h,y,f),c==-1&&(y=g.length,c=n(T,g,_,y),c<1&&(u++,a(g,_<y?E:T,y,f))),y=g.length):c===0&&(u++,g=[0]),N[o++]=u,c&&g[0]?g[y++]=I[S]||0:(g=[I[S]],y=1);while((S++<O||g[0]!==void 0)&&d--);v=g[0]!==void 0}N[0]||N.shift()}if(p==1)w.e=s,Eo=v;else{for(o=1,u=N[0];u>=10;u/=10)o++;w.e=o+s*p-1,Ee(w,m?i+w.e+1:i,l,v)}return w}}();function Ee(e,n,a,t){var r,i,l,m,f,c,s,o,u,p=e.constructor;e:if(n!=null){if(o=e.d,!o)return e;for(r=1,m=o[0];m>=10;m/=10)r++;if(i=n-r,i<0)i+=De,l=n,s=o[u=0],f=s/hr(10,r-l-1)%10|0;else if(u=Math.ceil((i+1)/De),m=o.length,u>=m)if(t){for(;m++<=u;)o.push(0);s=f=0,r=1,i%=De,l=i-De+1}else break e;else{for(s=m=o[u],r=1;m>=10;m/=10)r++;i%=De,l=i-De+r,f=l<0?0:s/hr(10,r-l-1)%10|0}if(t=t||n<0||o[u+1]!==void 0||(l<0?s:s%hr(10,r-l-1)),c=a<4?(f||t)&&(a==0||a==(e.s<0?3:2)):f>5||f==5&&(a==4||t||a==6&&(i>0?l>0?s/hr(10,r-l):0:o[u-1])%10&1||a==(e.s<0?8:7)),n<1||!o[0])return o.length=0,c?(n-=e.e+1,o[0]=hr(10,(De-n%De)%De),e.e=-n||0):o[0]=e.e=0,e;if(i==0?(o.length=u,m=1,u--):(o.length=u+1,m=hr(10,De-i),o[u]=l>0?(s/hr(10,r-l)%hr(10,l)|0)*m:0),c)for(;;)if(u==0){for(i=1,l=o[0];l>=10;l/=10)i++;for(l=o[0]+=m,m=1;l>=10;l/=10)m++;i!=m&&(e.e++,o[0]==jr&&(o[0]=1));break}else{if(o[u]+=m,o[u]!=jr)break;o[u--]=0,m=1}for(i=o.length;o[--i]===0;)o.pop()}return $e&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function it(e,n,a){if(!e.isFinite())return qo(e);var t,r=e.e,i=br(e.d),l=i.length;return n?(a&&(t=a-l)>0?i=i.charAt(0)+"."+i.slice(1)+_t(t):l>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):r<0?(i="0."+_t(-r-1)+i,a&&(t=a-l)>0&&(i+=_t(t))):r>=l?(i+=_t(r+1-l),a&&(t=a-r-1)>0&&(i=i+"."+_t(t))):((t=r+1)<l&&(i=i.slice(0,t)+"."+i.slice(t)),a&&(t=a-l)>0&&(r+1===l&&(i+="."),i+=_t(t))),i}function va(e,n){var a=e[0];for(n*=De;a>=10;a/=10)n++;return n}function ha(e,n,a){if(n>Dv)throw $e=!0,a&&(e.precision=a),Error(Co);return Ee(new e(fa),n,1,!0)}function ot(e,n,a){if(n>li)throw Error(Co);return Ee(new e(la),n,a,!0)}function Bo(e){var n=e.length-1,a=n*De+1;if(n=e[n],n){for(;n%10==0;n/=10)a--;for(n=e[0];n>=10;n/=10)a++}return a}function _t(e){for(var n="";e--;)n+="0";return n}function _o(e,n,a,t){var r,i=new e(1),l=Math.ceil(t/De+4);for($e=!1;;){if(a%2&&(i=i.times(n),Fo(i.d,l)&&(r=!0)),a=Nr(a/2),a===0){a=i.d.length-1,r&&i.d[a]===0&&++i.d[a];break}n=n.times(n),Fo(n.d,l)}return $e=!0,i}function $o(e){return e.d[e.d.length-1]&1}function Io(e,n,a){for(var t,r,i=new e(n[0]),l=0;++l<n.length;){if(r=new e(n[l]),!r.s){i=r;break}t=i.cmp(r),(t===a||t===0&&i.s===a)&&(i=r)}return i}function mi(e,n){var a,t,r,i,l,m,f,c=0,s=0,o=0,u=e.constructor,p=u.rounding,v=u.precision;if(!e.d||!e.d[0]||e.e>17)return new u(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(n==null?($e=!1,f=v):f=n,m=new u(.03125);e.e>-2;)e=e.times(m),o+=5;for(t=Math.log(hr(2,o))/Math.LN10*2+5|0,f+=t,a=i=l=new u(1),u.precision=f;;){if(i=Ee(i.times(e),f,1),a=a.times(++s),m=l.plus(er(i,a,f,1)),br(m.d).slice(0,f)===br(l.d).slice(0,f)){for(r=o;r--;)l=Ee(l.times(l),f,1);if(n==null)if(c<3&&_n(l.d,f-t,p,c))u.precision=f+=10,a=i=m=new u(1),s=0,c++;else return Ee(l,u.precision=v,p,$e=!0);else return u.precision=v,l}l=m}}function $t(e,n){var a,t,r,i,l,m,f,c,s,o,u,p=1,v=10,h=e,b=h.d,w=h.constructor,N=w.rounding,g=w.precision;if(h.s<0||!b||!b[0]||!h.e&&b[0]==1&&b.length==1)return new w(b&&!b[0]?-1/0:h.s!=1?NaN:b?0:h);if(n==null?($e=!1,s=g):s=n,w.precision=s+=v,a=br(b),t=a.charAt(0),Math.abs(i=h.e)<15e14){for(;t<7&&t!=1||t==1&&a.charAt(1)>3;)h=h.times(e),a=br(h.d),t=a.charAt(0),p++;i=h.e,t>1?(h=new w("0."+a),i++):h=new w(t+"."+a.slice(1))}else return c=ha(w,s+2,g).times(i+""),h=$t(new w(t+"."+a.slice(1)),s-v).plus(c),w.precision=g,n==null?Ee(h,g,N,$e=!0):h;for(o=h,f=l=h=er(h.minus(1),h.plus(1),s,1),u=Ee(h.times(h),s,1),r=3;;){if(l=Ee(l.times(u),s,1),c=f.plus(er(l,new w(r),s,1)),br(c.d).slice(0,s)===br(f.d).slice(0,s))if(f=f.times(2),i!==0&&(f=f.plus(ha(w,s+2,g).times(i+""))),f=er(f,new w(p),s,1),n==null)if(_n(f.d,s-v,N,m))w.precision=s+=v,c=l=h=er(o.minus(1),o.plus(1),s,1),u=Ee(h.times(h),s,1),r=m=1;else return Ee(f,w.precision=g,N,$e=!0);else return w.precision=g,f;f=c,r+=2}}function qo(e){return String(e.s*e.s/0)}function da(e,n){var a,t,r;for((a=n.indexOf("."))>-1&&(n=n.replace(".","")),(t=n.search(/e/i))>0?(a<0&&(a=t),a+=+n.slice(t+1),n=n.substring(0,t)):a<0&&(a=n.length),t=0;n.charCodeAt(t)===48;t++);for(r=n.length;n.charCodeAt(r-1)===48;--r);if(n=n.slice(t,r),n){if(r-=t,e.e=a=a-t-1,e.d=[],t=(a+1)%De,a<0&&(t+=De),t<r){for(t&&e.d.push(+n.slice(0,t)),r-=De;t<r;)e.d.push(+n.slice(t,t+=De));n=n.slice(t),t=De-n.length}else t-=r;for(;t--;)n+="0";e.d.push(+n),$e&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function Bv(e,n){var a,t,r,i,l,m,f,c,s;if(n.indexOf("_")>-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),To.test(n))return da(e,n)}else if(n==="Infinity"||n==="NaN")return+n||(e.s=NaN),e.e=NaN,e.d=null,e;if(Ev.test(n))a=16,n=n.toLowerCase();else if(Sv.test(n))a=2;else if(Cv.test(n))a=8;else throw Error(Bt+n);for(i=n.search(/p/i),i>0?(f=+n.slice(i+1),n=n.substring(2,i)):n=n.slice(2),i=n.indexOf("."),l=i>=0,t=e.constructor,l&&(n=n.replace(".",""),m=n.length,i=m-i,r=_o(t,new t(a),i,i*2)),c=pa(n,a,jr),s=c.length-1,i=s;c[i]===0;--i)c.pop();return i<0?new t(e.s*0):(e.e=va(c,s),e.d=c,$e=!1,l&&(e=er(e,r,m*4)),f&&(e=e.times(Math.abs(f)<54?hr(2,f):It.pow(2,f))),$e=!0,e)}function _v(e,n){var a,t=n.d.length;if(t<3)return n.isZero()?n:fn(e,2,n,n);a=1.4*Math.sqrt(t),a=a>16?16:a|0,n=n.times(1/ga(5,a)),n=fn(e,2,n,n);for(var r,i=new e(5),l=new e(16),m=new e(20);a--;)r=n.times(n),n=n.times(i.plus(r.times(l.times(r).minus(m))));return n}function fn(e,n,a,t,r){var i,l,m,f,c=e.precision,s=Math.ceil(c/De);for($e=!1,f=a.times(a),m=new e(t);;){if(l=er(m.times(f),new e(n++*n++),c,1),m=r?t.plus(l):t.minus(l),t=er(l.times(f),new e(n++*n++),c,1),l=m.plus(t),l.d[s]!==void 0){for(i=s;l.d[i]===m.d[i]&&i--;);if(i==-1)break}i=m,m=t,t=l,l=i}return $e=!0,l.d.length=s+1,l}function ga(e,n){for(var a=e;--n;)a*=e;return a}function Ro(e,n){var a,t=n.s<0,r=ot(e,e.precision,1),i=r.times(.5);if(n=n.abs(),n.lte(i))return yt=t?4:1,n;if(a=n.divToInt(r),a.isZero())yt=t?3:2;else{if(n=n.minus(a.times(r)),n.lte(i))return yt=$o(a)?t?2:3:t?4:1,n;yt=$o(a)?t?1:4:t?3:2}return n.minus(r).abs()}function pi(e,n,a,t){var r,i,l,m,f,c,s,o,u,p=e.constructor,v=a!==void 0;if(v?(Ir(a,1,Tt),t===void 0?t=p.rounding:Ir(t,0,8)):(a=p.precision,t=p.rounding),!e.isFinite())s=qo(e);else{for(s=it(e),l=s.indexOf("."),v?(r=2,n==16?a=a*4-3:n==8&&(a=a*3-2)):r=n,l>=0&&(s=s.replace(".",""),u=new p(1),u.e=s.length-l,u.d=pa(it(u),10,r),u.e=u.d.length),o=pa(s,10,r),i=f=o.length;o[--f]==0;)o.pop();if(!o[0])s=v?"0p+0":"0";else{if(l<0?i--:(e=new p(e),e.d=o,e.e=i,e=er(e,u,a,t,0,r),o=e.d,i=e.e,c=Eo),l=o[a],m=r/2,c=c||o[a+1]!==void 0,c=t<4?(l!==void 0||c)&&(t===0||t===(e.s<0?3:2)):l>m||l===m&&(t===4||c||t===6&&o[a-1]&1||t===(e.s<0?8:7)),o.length=a,c)for(;++o[--a]>r-1;)o[a]=0,a||(++i,o.unshift(1));for(f=o.length;!o[f-1];--f);for(l=0,s="";l<f;l++)s+=ci.charAt(o[l]);if(v){if(f>1)if(n==16||n==8){for(l=n==16?4:3,--f;f%l;f++)s+="0";for(o=pa(s,r,n),f=o.length;!o[f-1];--f);for(l=1,s="1.";l<f;l++)s+=ci.charAt(o[l])}else s=s.charAt(0)+"."+s.slice(1);s=s+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)s="0"+s;s="0."+s}else if(++i>f)for(i-=f;i--;)s+="0";else i<f&&(s=s.slice(0,i)+"."+s.slice(i))}s=(n==16?"0x":n==2?"0b":n==8?"0o":"")+s}return e.s<0?"-"+s:s}function Fo(e,n){if(e.length>n)return e.length=n,!0}function $v(e){return new this(e).abs()}function Iv(e){return new this(e).acos()}function qv(e){return new this(e).acosh()}function Rv(e,n){return new this(e).plus(n)}function Fv(e){return new this(e).asin()}function zv(e){return new this(e).asinh()}function Pv(e){return new this(e).atan()}function Uv(e){return new this(e).atanh()}function Lv(e,n){e=new this(e),n=new this(n);var a,t=this.precision,r=this.rounding,i=t+4;return!e.s||!n.s?a=new this(NaN):!e.d&&!n.d?(a=ot(this,i,1).times(n.s>0?.25:.75),a.s=e.s):!n.d||e.isZero()?(a=n.s<0?ot(this,t,r):new this(0),a.s=e.s):!e.d||n.isZero()?(a=ot(this,i,1).times(.5),a.s=e.s):n.s<0?(this.precision=i,this.rounding=1,a=this.atan(er(e,n,i,1)),n=ot(this,i,1),this.precision=t,this.rounding=r,a=e.s<0?a.minus(n):a.plus(n)):a=this.atan(er(e,n,i,1)),a}function kv(e){return new this(e).cbrt()}function Hv(e){return Ee(e=new this(e),e.e+1,2)}function Gv(e,n,a){return new this(e).clamp(n,a)}function Vv(e){if(!e||typeof e!="object")throw Error(ma+"Object expected");var n,a,t,r=e.defaults===!0,i=["precision",1,Tt,"rounding",0,8,"toExpNeg",-cn,0,"toExpPos",0,cn,"maxE",0,cn,"minE",-cn,0,"modulo",0,9];for(n=0;n<i.length;n+=3)if(a=i[n],r&&(this[a]=fi[a]),(t=e[a])!==void 0)if(Nr(t)===t&&t>=i[n+1]&&t<=i[n+2])this[a]=t;else throw Error(Bt+a+": "+t);if(a="crypto",r&&(this[a]=fi[a]),(t=e[a])!==void 0)if(t===!0||t===!1||t===0||t===1)if(t)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[a]=!0;else throw Error(Oo);else this[a]=!1;else throw Error(Bt+a+": "+t);return this}function Zv(e){return new this(e).cos()}function Xv(e){return new this(e).cosh()}function zo(e){var n,a,t;function r(i){var l,m,f,c=this;if(!(c instanceof r))return new r(i);if(c.constructor=r,Po(i)){c.s=i.s,$e?!i.d||i.e>r.maxE?(c.e=NaN,c.d=null):i.e<r.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(f=typeof i,f==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(l=0,m=i;m>=10;m/=10)l++;$e?l>r.maxE?(c.e=NaN,c.d=null):l<r.minE?(c.e=0,c.d=[0]):(c.e=l,c.d=[i]):(c.e=l,c.d=[i]);return}if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return da(c,i.toString())}if(f==="string")return(m=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(m===43&&(i=i.slice(1)),c.s=1),To.test(i)?da(c,i):Bv(c,i);if(f==="bigint")return i<0?(i=-i,c.s=-1):c.s=1,da(c,i.toString());throw Error(Bt+i)}if(r.prototype=ce,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Vv,r.clone=zo,r.isDecimal=Po,r.abs=$v,r.acos=Iv,r.acosh=qv,r.add=Rv,r.asin=Fv,r.asinh=zv,r.atan=Pv,r.atanh=Uv,r.atan2=Lv,r.cbrt=kv,r.ceil=Hv,r.clamp=Gv,r.cos=Zv,r.cosh=Xv,r.div=Yv,r.exp=Wv,r.floor=Jv,r.hypot=Qv,r.ln=Kv,r.log=jv,r.log10=rh,r.log2=eh,r.max=th,r.min=nh,r.mod=ah,r.mul=ih,r.pow=oh,r.random=sh,r.round=uh,r.sign=ch,r.sin=fh,r.sinh=lh,r.sqrt=mh,r.sub=ph,r.sum=vh,r.tan=hh,r.tanh=dh,r.trunc=gh,e===void 0&&(e={}),e&&e.defaults!==!0)for(t=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<t.length;)e.hasOwnProperty(a=t[n++])||(e[a]=this[a]);return r.config(e),r}function Yv(e,n){return new this(e).div(n)}function Wv(e){return new this(e).exp()}function Jv(e){return Ee(e=new this(e),e.e+1,3)}function Qv(){var e,n,a=new this(0);for($e=!1,e=0;e<arguments.length;)if(n=new this(arguments[e++]),n.d)a.d&&(a=a.plus(n.times(n)));else{if(n.s)return $e=!0,new this(1/0);a=n}return $e=!0,a.sqrt()}function Po(e){return e instanceof It||e&&e.toStringTag===Do||!1}function Kv(e){return new this(e).ln()}function jv(e,n){return new this(e).log(n)}function eh(e){return new this(e).log(2)}function rh(e){return new this(e).log(10)}function th(){return Io(this,arguments,-1)}function nh(){return Io(this,arguments,1)}function ah(e,n){return new this(e).mod(n)}function ih(e,n){return new this(e).mul(n)}function oh(e,n){return new this(e).pow(n)}function sh(e){var n,a,t,r,i=0,l=new this(1),m=[];if(e===void 0?e=this.precision:Ir(e,1,Tt),t=Math.ceil(e/De),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(t));i<t;)r=n[i],r>=429e7?n[i]=crypto.getRandomValues(new Uint32Array(1))[0]:m[i++]=r%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(t*=4);i<t;)r=n[i]+(n[i+1]<<8)+(n[i+2]<<16)+((n[i+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(n,i):(m.push(r%1e7),i+=4);i=t/4}else throw Error(Oo);else for(;i<t;)m[i++]=Math.random()*1e7|0;for(t=m[--i],e%=De,t&&e&&(r=hr(10,De-e),m[i]=(t/r|0)*r);m[i]===0;i--)m.pop();if(i<0)a=0,m=[0];else{for(a=-1;m[0]===0;a-=De)m.shift();for(t=1,r=m[0];r>=10;r/=10)t++;t<De&&(a-=De-t)}return l.e=a,l.d=m,l}function uh(e){return Ee(e=new this(e),e.e+1,this.rounding)}function ch(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function fh(e){return new this(e).sin()}function lh(e){return new this(e).sinh()}function mh(e){return new this(e).sqrt()}function ph(e,n){return new this(e).sub(n)}function vh(){var e=0,n=arguments,a=new this(n[e]);for($e=!1;a.s&&++e<n.length;)a=a.plus(n[e]);return $e=!0,Ee(a,this.precision,this.rounding)}function hh(e){return new this(e).tan()}function dh(e){return new this(e).tanh()}function gh(e){return Ee(e=new this(e),e.e+1,1)}ce[Symbol.for("nodejs.util.inspect.custom")]=ce.toString,ce[Symbol.toStringTag]="Decimal";var It=ce.constructor=zo(fi);fa=new It(fa),la=new It(la);var yh="BigNumber",xh=["?on","config"],bh=R(yh,xh,e=>{var{on:n,config:a}=e,t=It.clone({precision:a.precision,modulo:It.EUCLID});return t.prototype=Object.create(t.prototype),t.prototype.type="BigNumber",t.prototype.isBigNumber=!0,t.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},t.fromJSON=function(r){return new t(r.value)},n&&n("config",function(r,i){r.precision!==i.precision&&t.config({precision:r.precision})}),t},{isClass:!0}),vi={exports:{}};var Uo;function wh(){return Uo||(Uo=1,function(e,n){(function(a){var t=Math.cosh||function(o){return Math.abs(o)<1e-9?1-o:(Math.exp(o)+Math.exp(-o))*.5},r=Math.sinh||function(o){return Math.abs(o)<1e-9?o:(Math.exp(o)-Math.exp(-o))*.5},i=function(o){var u=Math.PI/4;if(-u>o||o>u)return Math.cos(o)-1;var p=o*o;return p*(p*(p*(p*(p*(p*(p*(p/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},l=function(o,u){var p=Math.abs(o),v=Math.abs(u);return p<3e3&&v<3e3?Math.sqrt(p*p+v*v):(p<v?(p=v,v=o/u):v=u/o,p*Math.sqrt(1+v*v))},m=function(){throw SyntaxError("Invalid Param")};function f(o,u){var p=Math.abs(o),v=Math.abs(u);return o===0?Math.log(v):u===0?Math.log(p):p<3e3&&v<3e3?Math.log(o*o+u*u)*.5:(o=o/2,u=u/2,.5*Math.log(o*o+u*u)+Math.LN2)}var c=function(o,u){var p={re:0,im:0};if(o==null)p.re=p.im=0;else if(u!==void 0)p.re=o,p.im=u;else switch(typeof o){case"object":if("im"in o&&"re"in o)p.re=o.re,p.im=o.im;else if("abs"in o&&"arg"in o){if(!Number.isFinite(o.abs)&&Number.isFinite(o.arg))return s.INFINITY;p.re=o.abs*Math.cos(o.arg),p.im=o.abs*Math.sin(o.arg)}else if("r"in o&&"phi"in o){if(!Number.isFinite(o.r)&&Number.isFinite(o.phi))return s.INFINITY;p.re=o.r*Math.cos(o.phi),p.im=o.r*Math.sin(o.phi)}else o.length===2?(p.re=o[0],p.im=o[1]):m();break;case"string":p.im=p.re=0;var v=o.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),h=1,b=0;v===null&&m();for(var w=0;w<v.length;w++){var N=v[w];N===" "||N===" "||N===`
9
+ `||(N==="+"?h++:N==="-"?b++:N==="i"||N==="I"?(h+b===0&&m(),v[w+1]!==" "&&!isNaN(v[w+1])?(p.im+=parseFloat((b%2?"-":"")+v[w+1]),w++):p.im+=parseFloat((b%2?"-":"")+"1"),h=b=0):((h+b===0||isNaN(N))&&m(),v[w+1]==="i"||v[w+1]==="I"?(p.im+=parseFloat((b%2?"-":"")+N),w++):p.re+=parseFloat((b%2?"-":"")+N),h=b=0))}h+b>0&&m();break;case"number":p.im=0,p.re=o;break;default:m()}return isNaN(p.re)||isNaN(p.im),p};function s(o,u){if(!(this instanceof s))return new s(o,u);var p=c(o,u);this.re=p.re,this.im=p.im}s.prototype={re:0,im:0,sign:function(){var o=this.abs();return new s(this.re/o,this.im/o)},add:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:new s(this.re+p.re,this.im+p.im)},sub:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:new s(this.re-p.re,this.im-p.im)},mul:function(o,u){var p=new s(o,u);return this.isInfinite()&&p.isZero()||this.isZero()&&p.isInfinite()?s.NAN:this.isInfinite()||p.isInfinite()?s.INFINITY:p.im===0&&this.im===0?new s(this.re*p.re,0):new s(this.re*p.re-this.im*p.im,this.re*p.im+this.im*p.re)},div:function(o,u){var p=new s(o,u);if(this.isZero()&&p.isZero()||this.isInfinite()&&p.isInfinite())return s.NAN;if(this.isInfinite()||p.isZero())return s.INFINITY;if(this.isZero()||p.isInfinite())return s.ZERO;o=this.re,u=this.im;var v=p.re,h=p.im,b,w;return h===0?new s(o/v,u/v):Math.abs(v)<Math.abs(h)?(w=v/h,b=v*w+h,new s((o*w+u)/b,(u*w-o)/b)):(w=h/v,b=h*w+v,new s((o+u*w)/b,(u-o*w)/b))},pow:function(o,u){var p=new s(o,u);if(o=this.re,u=this.im,p.isZero())return s.ONE;if(p.im===0){if(u===0&&o>0)return new s(Math.pow(o,p.re),0);if(o===0)switch((p.re%4+4)%4){case 0:return new s(Math.pow(u,p.re),0);case 1:return new s(0,Math.pow(u,p.re));case 2:return new s(-Math.pow(u,p.re),0);case 3:return new s(0,-Math.pow(u,p.re))}}if(o===0&&u===0&&p.re>0&&p.im>=0)return s.ZERO;var v=Math.atan2(u,o),h=f(o,u);return o=Math.exp(p.re*h-p.im*v),u=p.im*h+p.re*v,new s(o*Math.cos(u),o*Math.sin(u))},sqrt:function(){var o=this.re,u=this.im,p=this.abs(),v,h;if(o>=0){if(u===0)return new s(Math.sqrt(o),0);v=.5*Math.sqrt(2*(p+o))}else v=Math.abs(u)/Math.sqrt(2*(p-o));return o<=0?h=.5*Math.sqrt(2*(p-o)):h=Math.abs(u)/Math.sqrt(2*(p+o)),new s(v,u<0?-h:h)},exp:function(){var o=Math.exp(this.re);return this.im,new s(o*Math.cos(this.im),o*Math.sin(this.im))},expm1:function(){var o=this.re,u=this.im;return new s(Math.expm1(o)*Math.cos(u)+i(u),Math.exp(o)*Math.sin(u))},log:function(){var o=this.re,u=this.im;return new s(f(o,u),Math.atan2(u,o))},abs:function(){return l(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var o=this.re,u=this.im;return new s(Math.sin(o)*t(u),Math.cos(o)*r(u))},cos:function(){var o=this.re,u=this.im;return new s(Math.cos(o)*t(u),-Math.sin(o)*r(u))},tan:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)+t(u);return new s(Math.sin(o)/p,r(u)/p)},cot:function(){var o=2*this.re,u=2*this.im,p=Math.cos(o)-t(u);return new s(-Math.sin(o)/p,r(u)/p)},sec:function(){var o=this.re,u=this.im,p=.5*t(2*u)+.5*Math.cos(2*o);return new s(Math.cos(o)*t(u)/p,Math.sin(o)*r(u)/p)},csc:function(){var o=this.re,u=this.im,p=.5*t(2*u)-.5*Math.cos(2*o);return new s(Math.sin(o)*t(u)/p,-Math.cos(o)*r(u)/p)},asin:function(){var o=this.re,u=this.im,p=new s(u*u-o*o+1,-2*o*u).sqrt(),v=new s(p.re-u,p.im+o).log();return new s(v.im,-v.re)},acos:function(){var o=this.re,u=this.im,p=new s(u*u-o*o+1,-2*o*u).sqrt(),v=new s(p.re-u,p.im+o).log();return new s(Math.PI/2-v.im,v.re)},atan:function(){var o=this.re,u=this.im;if(o===0){if(u===1)return new s(0,1/0);if(u===-1)return new s(0,-1/0)}var p=o*o+(1-u)*(1-u),v=new s((1-u*u-o*o)/p,-2*o/p).log();return new s(-.5*v.im,.5*v.re)},acot:function(){var o=this.re,u=this.im;if(u===0)return new s(Math.atan2(1,o),0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).atan():new s(o!==0?o/0:0,u!==0?-u/0:0).atan()},asec:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(0,1/0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).acos():new s(o!==0?o/0:0,u!==0?-u/0:0).acos()},acsc:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(Math.PI/2,1/0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).asin():new s(o!==0?o/0:0,u!==0?-u/0:0).asin()},sinh:function(){var o=this.re,u=this.im;return new s(r(o)*Math.cos(u),t(o)*Math.sin(u))},cosh:function(){var o=this.re,u=this.im;return new s(t(o)*Math.cos(u),r(o)*Math.sin(u))},tanh:function(){var o=2*this.re,u=2*this.im,p=t(o)+Math.cos(u);return new s(r(o)/p,Math.sin(u)/p)},coth:function(){var o=2*this.re,u=2*this.im,p=t(o)-Math.cos(u);return new s(r(o)/p,-Math.sin(u)/p)},csch:function(){var o=this.re,u=this.im,p=Math.cos(2*u)-t(2*o);return new s(-2*r(o)*Math.cos(u)/p,2*t(o)*Math.sin(u)/p)},sech:function(){var o=this.re,u=this.im,p=Math.cos(2*u)+t(2*o);return new s(2*t(o)*Math.cos(u)/p,-2*r(o)*Math.sin(u)/p)},asinh:function(){var o=this.im;this.im=-this.re,this.re=o;var u=this.asin();return this.re=-this.im,this.im=o,o=u.re,u.re=-u.im,u.im=o,u},acosh:function(){var o=this.acos();if(o.im<=0){var u=o.re;o.re=-o.im,o.im=u}else{var u=o.im;o.im=-o.re,o.re=u}return o},atanh:function(){var o=this.re,u=this.im,p=o>1&&u===0,v=1-o,h=1+o,b=v*v+u*u,w=b!==0?new s((h*v-u*u)/b,(u*v+h*u)/b):new s(o!==-1?o/0:0,u!==0?u/0:0),N=w.re;return w.re=f(w.re,w.im)/2,w.im=Math.atan2(w.im,N)/2,p&&(w.im=-w.im),w},acoth:function(){var o=this.re,u=this.im;if(o===0&&u===0)return new s(0,Math.PI/2);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).atanh():new s(o!==0?o/0:0,u!==0?-u/0:0).atanh()},acsch:function(){var o=this.re,u=this.im;if(u===0)return new s(o!==0?Math.log(o+Math.sqrt(o*o+1)):1/0,0);var p=o*o+u*u;return p!==0?new s(o/p,-u/p).asinh():new s(o!==0?o/0:0,u!==0?-u/0:0).asinh()},asech:function(){var o=this.re,u=this.im;if(this.isZero())return s.INFINITY;var p=o*o+u*u;return p!==0?new s(o/p,-u/p).acosh():new s(o!==0?o/0:0,u!==0?-u/0:0).acosh()},inverse:function(){if(this.isZero())return s.INFINITY;if(this.isInfinite())return s.ZERO;var o=this.re,u=this.im,p=o*o+u*u;return new s(o/p,-u/p)},conjugate:function(){return new s(this.re,-this.im)},neg:function(){return new s(-this.re,-this.im)},ceil:function(o){return o=Math.pow(10,o||0),new s(Math.ceil(this.re*o)/o,Math.ceil(this.im*o)/o)},floor:function(o){return o=Math.pow(10,o||0),new s(Math.floor(this.re*o)/o,Math.floor(this.im*o)/o)},round:function(o){return o=Math.pow(10,o||0),new s(Math.round(this.re*o)/o,Math.round(this.im*o)/o)},equals:function(o,u){var p=new s(o,u);return Math.abs(p.re-this.re)<=s.EPSILON&&Math.abs(p.im-this.im)<=s.EPSILON},clone:function(){return new s(this.re,this.im)},toString:function(){var o=this.re,u=this.im,p="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(o)<s.EPSILON&&(o=0),Math.abs(u)<s.EPSILON&&(u=0),u===0?p+o:(o!==0?(p+=o,p+=" ",u<0?(u=-u,p+="-"):p+="+",p+=" "):u<0&&(u=-u,p+="-"),u!==1&&(p+=u),p+"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())}},s.ZERO=new s(0,0),s.ONE=new s(1,0),s.I=new s(0,1),s.PI=new s(Math.PI,0),s.E=new s(Math.E,0),s.INFINITY=new s(1/0,1/0),s.NAN=new s(NaN,NaN),s.EPSILON=1e-15,Object.defineProperty(s,"__esModule",{value:!0}),s.default=s,s.Complex=s,e.exports=s})()}(vi)),vi.exports}var Nh=wh();const qr=Tn(Nh);var Mh="Complex",Ah=[],Sh=R(Mh,Ah,()=>(qr.prototype.type="Complex",qr.prototype.isComplex=!0,qr.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},qr.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},qr.prototype.format=function(e){var n="",a=this.im,t=this.re,r=Ht(this.re,e),i=Ht(this.im,e),l=Be(e)?e:e?e.precision:null;if(l!==null){var m=Math.pow(10,-l);Math.abs(t/a)<m&&(t=0),Math.abs(a/t)<m&&(a=0)}return a===0?n=r:t===0?a===1?n="i":a===-1?n="-i":n=i+"i":a<0?a===-1?n=r+" - i":n=r+" - "+i.substring(1)+"i":a===1?n=r+" + i":n=r+" + "+i+"i",n},qr.fromPolar=function(e){switch(arguments.length){case 1:{var n=arguments[0];if(typeof n=="object")return qr(n);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var a=arguments[0],t=arguments[1];if(Be(a)){if(ht(t)&&t.hasBase("ANGLE")&&(t=t.toNumber("rad")),Be(t))return new qr({r:a,phi:t});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")}},qr.prototype.valueOf=qr.prototype.toString,qr.fromJSON=function(e){return new qr(e)},qr.compare=function(e,n){return e.re>n.re?1:e.re<n.re?-1:e.im>n.im?1:e.im<n.im?-1:0},qr),{isClass:!0});var Eh=2e3,Se={s:1,n:0,d:1};function xt(e,n){if(isNaN(e=parseInt(e,10)))throw ya();return e*n}function ur(e,n){if(n===0)throw hi();var a=Object.create(zr.prototype);a.s=e<0?-1:1,e=e<0?-e:e;var t=ln(e,n);return a.n=e/t,a.d=n/t,a}function Lo(e){for(var n={},a=e,t=2,r=4;r<=a;){for(;a%t===0;)a/=t,n[t]=(n[t]||0)+1;r+=1+2*t++}return a!==e?a>1&&(n[a]=(n[a]||0)+1):n[e]=(n[e]||0)+1,n}var Fr=function(e,n){var a=0,t=1,r=1,i=0,l=0,m=0,f=1,c=1,s=0,o=1,u=1,p=1,v=1e7,h;if(e!=null)if(n!==void 0){if(a=e,t=n,r=a*t,a%1!==0||t%1!==0)throw Th()}else switch(typeof e){case"object":{if("d"in e&&"n"in e)a=e.n,t=e.d,"s"in e&&(a*=e.s);else if(0 in e)a=e[0],1 in e&&(t=e[1]);else throw ya();r=a*t;break}case"number":{if(e<0&&(r=e,e=-e),e%1===0)a=e;else if(e>0){for(e>=1&&(c=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)),e/=c);o<=v&&p<=v;)if(h=(s+u)/(o+p),e===h){o+p<=v?(a=s+u,t=o+p):p>o?(a=u,t=p):(a=s,t=o);break}else e>h?(s+=u,o+=p):(u+=s,p+=o),o>v?(a=u,t=p):(a=s,t=o);a*=c}else(isNaN(e)||isNaN(n))&&(t=a=NaN);break}case"string":{if(o=e.match(/\d+|./g),o===null)throw ya();if(o[s]==="-"?(r=-1,s++):o[s]==="+"&&s++,o.length===s+1?l=xt(o[s++],r):o[s+1]==="."||o[s]==="."?(o[s]!=="."&&(i=xt(o[s++],r)),s++,(s+1===o.length||o[s+1]==="("&&o[s+3]===")"||o[s+1]==="'"&&o[s+3]==="'")&&(l=xt(o[s],r),f=Math.pow(10,o[s].length),s++),(o[s]==="("&&o[s+2]===")"||o[s]==="'"&&o[s+2]==="'")&&(m=xt(o[s+1],r),c=Math.pow(10,o[s+1].length)-1,s+=3)):o[s+1]==="/"||o[s+1]===":"?(l=xt(o[s],r),f=xt(o[s+2],1),s+=3):o[s+3]==="/"&&o[s+1]===" "&&(i=xt(o[s],r),l=xt(o[s+2],r),f=xt(o[s+4],1),s+=5),o.length<=s){t=f*c,r=a=m+t*i+c*l;break}}default:throw ya()}if(t===0)throw hi();Se.s=r<0?-1:1,Se.n=Math.abs(a),Se.d=Math.abs(t)};function Ch(e,n,a){for(var t=1;n>0;e=e*e%a,n>>=1)n&1&&(t=t*e%a);return t}function Oh(e,n){for(;n%2===0;n/=2);for(;n%5===0;n/=5);if(n===1)return 0;for(var a=10%n,t=1;a!==1;t++)if(a=a*10%n,t>Eh)return 0;return t}function Dh(e,n,a){for(var t=1,r=Ch(10,a,n),i=0;i<300;i++){if(t===r)return i;t=t*10%n,r=r*10%n}return 0}function ln(e,n){if(!e)return n;if(!n)return e;for(;;){if(e%=n,!e)return n;if(n%=e,!n)return e}}function zr(e,n){if(Fr(e,n),this instanceof zr)e=ln(Se.d,Se.n),this.s=Se.s,this.n=Se.n/e,this.d=Se.d/e;else return ur(Se.s*Se.n,Se.d)}var hi=function(){return new Error("Division by Zero")},ya=function(){return new Error("Invalid argument")},Th=function(){return new Error("Parameters must be integer")};zr.prototype={s:1,n:0,d:1,abs:function(){return ur(this.n,this.d)},neg:function(){return ur(-this.s*this.n,this.d)},add:function(e,n){return Fr(e,n),ur(this.s*this.n*Se.d+Se.s*this.d*Se.n,this.d*Se.d)},sub:function(e,n){return Fr(e,n),ur(this.s*this.n*Se.d-Se.s*this.d*Se.n,this.d*Se.d)},mul:function(e,n){return Fr(e,n),ur(this.s*Se.s*this.n*Se.n,this.d*Se.d)},div:function(e,n){return Fr(e,n),ur(this.s*Se.s*this.n*Se.d,this.d*Se.n)},clone:function(){return ur(this.s*this.n,this.d)},mod:function(e,n){if(isNaN(this.n)||isNaN(this.d))return new zr(NaN);if(e===void 0)return ur(this.s*this.n%this.d,1);if(Fr(e,n),Se.n===0&&this.d===0)throw hi();return ur(this.s*(Se.d*this.n)%(Se.n*this.d),Se.d*this.d)},gcd:function(e,n){return Fr(e,n),ur(ln(Se.n,this.n)*ln(Se.d,this.d),Se.d*this.d)},lcm:function(e,n){return Fr(e,n),Se.n===0&&this.n===0?ur(0,1):ur(Se.n*this.n,ln(Se.n,this.n)*ln(Se.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):ur(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):ur(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new zr(NaN):ur(Math.round(e*this.s*this.n/this.d),e)},roundTo:function(e,n){return Fr(e,n),ur(this.s*Math.round(this.n*Se.d/(this.d*Se.n))*Se.n,Se.d)},inverse:function(){return ur(this.s*this.d,this.n)},pow:function(e,n){if(Fr(e,n),Se.d===1)return Se.s<0?ur(Math.pow(this.s*this.d,Se.n),Math.pow(this.n,Se.n)):ur(Math.pow(this.s*this.n,Se.n),Math.pow(this.d,Se.n));if(this.s<0)return null;var a=Lo(this.n),t=Lo(this.d),r=1,i=1;for(var l in a)if(l!=="1"){if(l==="0"){r=0;break}if(a[l]*=Se.n,a[l]%Se.d===0)a[l]/=Se.d;else return null;r*=Math.pow(l,a[l])}for(var l in t)if(l!=="1"){if(t[l]*=Se.n,t[l]%Se.d===0)t[l]/=Se.d;else return null;i*=Math.pow(l,t[l])}return Se.s<0?ur(i,r):ur(r,i)},equals:function(e,n){return Fr(e,n),this.s*this.n*Se.d===Se.s*Se.n*this.d},compare:function(e,n){Fr(e,n);var a=this.s*this.n*Se.d-Se.s*Se.n*this.d;return(0<a)-(a<0)},simplify:function(e){if(isNaN(this.n)||isNaN(this.d))return this;e=e||.001;for(var n=this.abs(),a=n.toContinued(),t=1;t<a.length;t++){for(var r=ur(a[t-1],1),i=t-2;i>=0;i--)r=r.inverse().add(a[i]);if(Math.abs(r.sub(n).valueOf())<e)return r.mul(this.s)}return this},divisible:function(e,n){return Fr(e,n),!(!(Se.n*this.d)||this.n*Se.d%(Se.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(e){var n,a="",t=this.n,r=this.d;return this.s<0&&(a+="-"),r===1?a+=t:(e&&(n=Math.floor(t/r))>0&&(a+=n,a+=" ",t%=r),a+=t,a+="/",a+=r),a},toLatex:function(e){var n,a="",t=this.n,r=this.d;return this.s<0&&(a+="-"),r===1?a+=t:(e&&(n=Math.floor(t/r))>0&&(a+=n,t%=r),a+="\\frac{",a+=t,a+="}{",a+=r,a+="}"),a},toContinued:function(){var e,n=this.n,a=this.d,t=[];if(isNaN(n)||isNaN(a))return t;do t.push(Math.floor(n/a)),e=n%a,n=a,a=e;while(n!==1);return t},toString:function(e){var n=this.n,a=this.d;if(isNaN(n)||isNaN(a))return"NaN";e=e||15;var t=Oh(n,a),r=Dh(n,a,t),i=this.s<0?"-":"";if(i+=n/a|0,n%=a,n*=10,n&&(i+="."),t){for(var l=r;l--;)i+=n/a|0,n%=a,n*=10;i+="(";for(var l=t;l--;)i+=n/a|0,n%=a,n*=10;i+=")"}else for(var l=e;n&&l--;)i+=n/a|0,n%=a,n*=10;return i}};var Bh="Fraction",_h=[],$h=R(Bh,_h,()=>(zr.prototype.type="Fraction",zr.prototype.isFraction=!0,zr.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},zr.fromJSON=function(e){return new zr(e)},zr),{isClass:!0}),Ih="Range",qh=[],Rh=R(Ih,qh,()=>{function e(n,a,t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var r=n!=null,i=a!=null,l=t!=null;if(r){if(_e(n))n=n.toNumber();else if(typeof n!="number")throw new TypeError("Parameter start must be a number")}if(i){if(_e(a))a=a.toNumber();else if(typeof a!="number")throw new TypeError("Parameter end must be a number")}if(l){if(_e(t))t=t.toNumber();else if(typeof t!="number")throw new TypeError("Parameter step must be a number")}this.start=r?parseFloat(n):0,this.end=i?parseFloat(a):0,this.step=l?parseFloat(t):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(n){if(typeof n!="string")return null;var a=n.split(":"),t=a.map(function(i){return parseFloat(i)}),r=t.some(function(i){return isNaN(i)});if(r)return null;switch(t.length){case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[2],t[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var n=0,a=this.start,t=this.step,r=this.end,i=r-a;return Dt(t)===Dt(i)?n=Math.ceil(i/t):i===0&&(n=0),isNaN(n)&&(n=0),[n]},e.prototype.min=function(){var n=this.size()[0];if(n>0)return this.step>0?this.start:this.start+(n-1)*this.step},e.prototype.max=function(){var n=this.size()[0];if(n>0)return this.step>0?this.start+(n-1)*this.step:this.start},e.prototype.forEach=function(n){var a=this.start,t=this.step,r=this.end,i=0;if(t>0)for(;a<r;)n(a,[i],this),a+=t,i++;else if(t<0)for(;a>r;)n(a,[i],this),a+=t,i++},e.prototype.map=function(n){var a=[];return this.forEach(function(t,r,i){a[r[0]]=n(t,r,i)}),a},e.prototype.toArray=function(){var n=[];return this.forEach(function(a,t){n[t[0]]=a}),n},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(n){var a=Ht(this.start,n);return this.step!==1&&(a+=":"+Ht(this.step,n)),a+=":"+Ht(this.end,n),a},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(n){return new e(n.start,n.end,n.step)},e},{isClass:!0}),Fh="Matrix",zh=[],Ph=R(Fh,zh,()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(n,a){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(n,a,t){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(n){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(n,a,t){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(n,a){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(n,a){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(n,a){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(n){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(n){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e},{isClass:!0}),Uh="DenseMatrix",Lh=["Matrix"],kh=R(Uh,Lh,e=>{var{Matrix:n}=e;function a(s,o){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(o&&!_r(o))throw new Error("Invalid datatype: "+o);if(Oe(s))s.type==="DenseMatrix"?(this._data=Ce(s._data),this._size=Ce(s._size),this._datatype=o||s._datatype):(this._data=s.toArray(),this._size=s.size(),this._datatype=o||s._datatype);else if(s&&Xe(s.data)&&Xe(s.size))this._data=s.data,this._size=s.size,vo(this._data,this._size),this._datatype=o||s.datatype;else if(Xe(s))this._data=c(s),this._size=Pe(this._data),vo(this._data,this._size),this._datatype=o;else{if(s)throw new TypeError("Unsupported type of data ("+Ke(s)+")");this._data=[],this._size=[0],this._datatype=o}}a.prototype=new n,a.prototype.createDenseMatrix=function(s,o){return new a(s,o)},a.prototype.type="DenseMatrix",a.prototype.isDenseMatrix=!0,a.prototype.getDataType=function(){return Bn(this._data,Ke)},a.prototype.storage=function(){return"dense"},a.prototype.datatype=function(){return this._datatype},a.prototype.create=function(s,o){return new a(s,o)},a.prototype.subset=function(s,o,u){switch(arguments.length){case 1:return t(this,s);case 2:case 3:return i(this,s,o,u);default:throw new SyntaxError("Wrong number of arguments")}},a.prototype.get=function(s){if(!Xe(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new Fe(s.length,this._size.length);for(var o=0;o<s.length;o++)We(s[o],this._size[o]);for(var u=this._data,p=0,v=s.length;p<v;p++){var h=s[p];We(h,u.length),u=u[h]}return u},a.prototype.set=function(s,o,u){if(!Xe(s))throw new TypeError("Array expected");if(s.length<this._size.length)throw new Fe(s.length,this._size.length,"<");var p,v,h,b=s.map(function(N){return N+1});f(this,b,u);var w=this._data;for(p=0,v=s.length-1;p<v;p++)h=s[p],We(h,w.length),w=w[h];return h=s[s.length-1],We(h,w.length),w[h]=o,this};function t(s,o){if(!En(o))throw new TypeError("Invalid index");var u=o.isScalar();if(u)return s.get(o.min());var p=o.size();if(p.length!==s._size.length)throw new Fe(p.length,s._size.length);for(var v=o.min(),h=o.max(),b=0,w=s._size.length;b<w;b++)We(v[b],s._size[b]),We(h[b],s._size[b]);return new a(r(s._data,o,p.length,0),s._datatype)}function r(s,o,u,p){var v=p===u-1,h=o.dimension(p);return v?h.map(function(b){return We(b,s.length),s[b]}).valueOf():h.map(function(b){We(b,s.length);var w=s[b];return r(w,o,u,p+1)}).valueOf()}function i(s,o,u,p){if(!o||o.isIndex!==!0)throw new TypeError("Invalid index");var v=o.size(),h=o.isScalar(),b;if(Oe(u)?(b=u.size(),u=u.valueOf()):b=Pe(u),h){if(b.length!==0)throw new TypeError("Scalar expected");s.set(o.min(),u,p)}else{if(v.length<s._size.length)throw new Fe(v.length,s._size.length,"<");if(b.length<v.length){for(var w=0,N=0;v[w]===1&&b[w]===1;)w++;for(;v[w]===1;)N++,w++;u=xo(u,v.length,N,b)}if(!Dn(v,b))throw new Fe(v,b,">");var g=o.max().map(function(d){return d+1});f(s,g,p);var y=v.length,x=0;l(s._data,o,u,y,x)}return s}function l(s,o,u,p,v){var h=v===p-1,b=o.dimension(v);h?b.forEach(function(w,N){We(w),s[w]=u[N[0]]}):b.forEach(function(w,N){We(w),l(s[w],o,u[N[0]],p,v+1)})}a.prototype.resize=function(s,o,u){if(!rn(s))throw new TypeError("Array or Matrix expected");var p=s.valueOf().map(h=>Array.isArray(h)&&h.length===1?h[0]:h),v=u?this.clone():this;return m(v,p,o)};function m(s,o,u){if(o.length===0){for(var p=s._data;Xe(p);)p=p[0];return p}return s._size=o.slice(0),s._data=on(s._data,s._size,u),s}a.prototype.reshape=function(s,o){var u=o?this.clone():this;u._data=ho(u._data,s);var p=u._size.reduce((v,h)=>v*h);return u._size=ti(s,p),u};function f(s,o,u){for(var p=s._size.slice(0),v=!1;p.length<o.length;)p.push(0),v=!0;for(var h=0,b=o.length;h<b;h++)o[h]>p[h]&&(p[h]=o[h],v=!0);v&&m(s,p,u)}a.prototype.clone=function(){var s=new a({data:Ce(this._data),size:Ce(this._size),datatype:this._datatype});return s},a.prototype.size=function(){return this._size.slice(0)},a.prototype.map=function(s){var o=this,u=function h(b,w){return Xe(b)?b.map(function(N,g){return h(N,w.concat(g))}):s(b,w,o)},p=u(this._data,[]),v=this._datatype!==void 0?Bn(p,Ke):void 0;return new a(p,v)},a.prototype.forEach=function(s){var o=this,u=function p(v,h){Xe(v)?v.forEach(function(b,w){p(b,h.concat(w))}):s(v,h,o)};u(this._data,[])},a.prototype[Symbol.iterator]=function*(){var s=function*o(u,p){if(Xe(u))for(var v=0;v<u.length;v++)yield*io(o(u[v],p.concat(v)));else yield{value:u,index:p}};yield*io(s(this._data,[]))},a.prototype.rows=function(){var s=[],o=this.size();if(o.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var u=this._data;for(var p of u)s.push(new a([p],this._datatype));return s},a.prototype.columns=function(){var s=this,o=[],u=this.size();if(u.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var p=this._data,v=function(w){var N=p.map(g=>[g[w]]);o.push(new a(N,s._datatype))},h=0;h<u[1];h++)v(h);return o},a.prototype.toArray=function(){return Ce(this._data)},a.prototype.valueOf=function(){return this._data},a.prototype.format=function(s){return Re(this._data,s)},a.prototype.toString=function(){return Re(this._data)},a.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(s){if(s){if(_e(s)&&(s=s.toNumber()),!Be(s)||!Ae(s))throw new TypeError("The parameter k must be an integer number")}else s=0;for(var o=s>0?s:0,u=s<0?-s:0,p=this._size[0],v=this._size[1],h=Math.min(p-u,v-o),b=[],w=0;w<h;w++)b[w]=this._data[w+u][w+o];return new a({data:b,size:[h],datatype:this._datatype})},a.diagonal=function(s,o,u,p){if(!Xe(s))throw new TypeError("Array expected, size parameter");if(s.length!==2)throw new Error("Only two dimensions matrix are supported");if(s=s.map(function(A){if(_e(A)&&(A=A.toNumber()),!Be(A)||!Ae(A)||A<1)throw new Error("Size values must be positive integers");return A}),u){if(_e(u)&&(u=u.toNumber()),!Be(u)||!Ae(u))throw new TypeError("The parameter k must be an integer number")}else u=0;var v=u>0?u:0,h=u<0?-u:0,b=s[0],w=s[1],N=Math.min(b-h,w-v),g;if(Xe(o)){if(o.length!==N)throw new Error("Invalid value array length");g=function(S){return o[S]}}else if(Oe(o)){var y=o.size();if(y.length!==1||y[0]!==N)throw new Error("Invalid matrix length");g=function(S){return o.get([S])}}else g=function(){return o};p||(p=_e(g(0))?g(0).mul(0):0);var x=[];if(s.length>0){x=on(x,s,p);for(var d=0;d<N;d++)x[d+h][d+v]=g(d)}return new a({data:x,size:[b,w]})},a.fromJSON=function(s){return new a(s)},a.prototype.swapRows=function(s,o){if(!Be(s)||!Ae(s)||!Be(o)||!Ae(o))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return We(s,this._size[0]),We(o,this._size[0]),a._swapRows(s,o,this._data),this},a._swapRows=function(s,o,u){var p=u[s];u[s]=u[o],u[o]=p};function c(s){for(var o=0,u=s.length;o<u;o++){var p=s[o];Xe(p)?s[o]=c(p):p&&p.isMatrix===!0&&(s[o]=c(p.valueOf()))}return s}return a},{isClass:!0}),ko="clone",Hh=["typed"],Gh=R(ko,Hh,e=>{var{typed:n}=e;return n(ko,{any:Ce})});function Ho(e){var n=e.length,a=e[0].length,t,r,i=[];for(r=0;r<a;r++){var l=[];for(t=0;t<n;t++)l.push(e[t][r]);i.push(l)}return i}function mn(e){for(var n=0;n<e.length;n++)if(rn(e[n]))return!0;return!1}function bt(e,n){Oe(e)&&(e=e.valueOf());for(var a=0,t=e.length;a<t;a++){var r=e[a];Array.isArray(r)?bt(r,n):n(r)}}function be(e,n,a){return e&&typeof e.map=="function"?e.map(function(t){return be(t,n)}):n(e)}function xa(e,n,a){var t=Array.isArray(e)?Pe(e):e.size();if(n<0||n>=t.length)throw new Kr(n,t.length);return Oe(e)?e.create(ba(e.valueOf(),n,a)):ba(e,n,a)}function ba(e,n,a){var t,r,i,l;if(n<=0)if(Array.isArray(e[0])){for(l=Ho(e),r=[],t=0;t<l.length;t++)r[t]=ba(l[t],n-1,a);return r}else{for(i=e[0],t=1;t<e.length;t++)i=a(i,e[t]);return i}else{for(r=[],t=0;t<e.length;t++)r[t]=ba(e[t],n-1,a);return r}}function Go(e,n,a,t,r,i,l,m,f,c,s){var o=e._values,u=e._index,p=e._ptr,v,h,b,w;if(t)for(h=p[n],b=p[n+1],v=h;v<b;v++)w=u[v],a[w]!==i?(a[w]=i,l.push(w),t[w]=o[v]):(t[w]=m(t[w],o[v]),r[w]=i);else for(h=p[n],b=p[n+1],v=h;v<b;v++)w=u[v],a[w]!==i?(a[w]=i,l.push(w)):r[w]=i}var Vo="isInteger",Vh=["typed"],Zh=R(Vo,Vh,e=>{var{typed:n}=e;return n(Vo,{number:Ae,BigNumber:function(t){return t.isInt()},Fraction:function(t){return t.d===1&&isFinite(t.n)},"Array | Matrix":function(t){return be(t,this)}})}),et="number",Gt="number, number";function Zo(e){return Math.abs(e)}Zo.signature=et;function Xo(e,n){return e+n}Xo.signature=Gt;function Yo(e,n){return e*n}Yo.signature=Gt;function Wo(e){return-e}Wo.signature=et;function Jo(e){return e}Jo.signature=et;function $n(e){return Vp(e)}$n.signature=et;function Qo(e){return e*e*e}Qo.signature=et;function Ko(e){return Math.exp(e)}Ko.signature=et;function jo(e){return Zp(e)}jo.signature=et;function es(e,n){if(!Ae(e)||!Ae(n))throw new Error("Parameters in function gcd must be integer numbers");for(var a;n!==0;)a=e%n,e=n,n=a;return e<0?-e:e}es.signature=Gt;function rs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Parameters in function lcm must be integer numbers");if(e===0||n===0)return 0;for(var a,t=e*n;n!==0;)a=n,n=e%a,e=a;return Math.abs(t/e)}rs.signature=Gt;function Xh(e,n){return Math.log(e)}function ts(e){return Hp(e)}ts.signature=et;function ns(e){return kp(e)}ns.signature=et;function as(e,n){if(n>0)return e-n*Math.floor(e/n);if(n===0)return e;throw new Error("Cannot calculate mod for a negative divisor")}as.signature=Gt;function is(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,a=n<0;if(a&&(n=-n),n===0)throw new Error("Root must be non-zero");if(e<0&&Math.abs(n)%2!==1)throw new Error("Root must be odd when a is negative.");if(e===0)return a?1/0:0;if(!isFinite(e))return a?0:e;var t=Math.pow(Math.abs(e),1/n);return t=e<0?-t:t,a?1/t:t}function di(e){return Dt(e)}di.signature=et;function os(e){return e*e}os.signature=et;function ss(e,n){var a,t,r,i=0,l=1,m=1,f=0;if(!Ae(e)||!Ae(n))throw new Error("Parameters in function xgcd must be integer numbers");for(;n;)t=Math.floor(e/n),r=e-t*n,a=i,i=l-t*i,l=a,a=m,m=f-t*m,f=a,e=n,n=r;var c;return e<0?c=[-e,-l,-f]:c=[e,e?l:0,f],c}ss.signature=Gt;function us(e,n){return e*e<1&&n===1/0||e*e>1&&n===-1/0?0:Math.pow(e,n)}us.signature=Gt;function cs(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!Ae(n)||n<0||n>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(co(e,n))}var Yh="number",pn="number, number";function fs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitAnd");return e&n}fs.signature=pn;function ls(e){if(!Ae(e))throw new Error("Integer expected in function bitNot");return~e}ls.signature=Yh;function ms(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitOr");return e|n}ms.signature=pn;function ps(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function bitXor");return e^n}ps.signature=pn;function vs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function leftShift");return e<<n}vs.signature=pn;function hs(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function rightArithShift");return e>>n}hs.signature=pn;function ds(e,n){if(!Ae(e)||!Ae(n))throw new Error("Integers expected in function rightLogShift");return e>>>n}ds.signature=pn;function wt(e,n){if(n<e)return 1;if(n===e)return n;var a=n+e>>1;return wt(e,a)*wt(a+1,n)}function gs(e,n){if(!Ae(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!Ae(n)||n<0)throw new TypeError("Positive integer value expected in function combinations");if(n>e)throw new TypeError("k must be less than or equal to n");for(var a=e-n,t=1,r=n<a?a+1:n+1,i=2,l=n<a?n:a,m=r;m<=e;++m)for(t*=m;i<=l&&t%i===0;)t/=i,++i;return i<=l&&(t/=wt(i,l)),t}gs.signature="number, number";var Wh=Math.PI,Jh=2*Math.PI,Qh=Math.E,Kh=1.618033988749895,jh="number",gi="number, number";function ys(e){return!e}ys.signature=jh;function xs(e,n){return!!(e||n)}xs.signature=gi;function bs(e,n){return!!e!=!!n}bs.signature=gi;function ws(e,n){return!!(e&&n)}ws.signature=gi;function yi(e){var n;if(Ae(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:wt(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*yi(1-e));if(e>=171.35)return 1/0;if(e>85){var a=e*e,t=a*e,r=t*e,i=r*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*a)-139/(51840*t)-571/(2488320*r)+163879/(209018880*i)+5246819/(75246796800*i*e))}--e,n=vn[0];for(var l=1;l<vn.length;++l)n+=vn[l]/(e+l);var m=e+Ns+.5;return Math.sqrt(2*Math.PI)*Math.pow(m,e+.5)*Math.exp(-m)*n}yi.signature="number";var Ns=4.7421875,vn=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Ms=.9189385332046728,ed=5,rd=7,As=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function wa(e){if(e<0)return NaN;if(e===0)return 1/0;if(!isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-wa(1-e);e=e-1;for(var n=e+ed+.5,a=As[0],t=rd-1;t>=1;t--)a+=As[t]/(e+t);return Ms+(e+.5)*Math.log(n)-n+Math.log(a)}wa.signature="number";var Mr="number";function Ss(e){return Qp(e)}Ss.signature=Mr;function Es(e){return Math.atan(1/e)}Es.signature=Mr;function Cs(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}Cs.signature=Mr;function Os(e){return Math.asin(1/e)}Os.signature=Mr;function Ds(e){var n=1/e;return Math.log(n+Math.sqrt(n*n+1))}Ds.signature=Mr;function Ts(e){return Math.acos(1/e)}Ts.signature=Mr;function Bs(e){var n=1/e,a=Math.sqrt(n*n-1);return Math.log(a+n)}Bs.signature=Mr;function _s(e){return Kp(e)}_s.signature=Mr;function $s(e){return jp(e)}$s.signature=Mr;function Is(e){return 1/Math.tan(e)}Is.signature=Mr;function qs(e){var n=Math.exp(2*e);return(n+1)/(n-1)}qs.signature=Mr;function Rs(e){return 1/Math.sin(e)}Rs.signature=Mr;function Fs(e){return e===0?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*Dt(e)}Fs.signature=Mr;function zs(e){return 1/Math.cos(e)}zs.signature=Mr;function Ps(e){return 2/(Math.exp(e)+Math.exp(-e))}Ps.signature=Mr;function Us(e){return rv(e)}Us.signature=Mr;var Na="number";function Ls(e){return e<0}Ls.signature=Na;function ks(e){return e>0}ks.signature=Na;function Hs(e){return e===0}Hs.signature=Na;function Gs(e){return Number.isNaN(e)}Gs.signature=Na;var Vs="isNegative",td=["typed"],nd=R(Vs,td,e=>{var{typed:n}=e;return n(Vs,{number:Ls,BigNumber:function(t){return t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s<0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Zs="isNumeric",ad=["typed"],id=R(Zs,ad,e=>{var{typed:n}=e;return n(Zs,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(t){return be(t,this)}})}),Xs="hasNumericValue",od=["typed","isNumeric"],sd=R(Xs,od,e=>{var{typed:n,isNumeric:a}=e;return n(Xs,{string:function(r){return r.trim().length>0&&!isNaN(Number(r))},any:function(r){return a(r)}})}),Ys="isPositive",ud=["typed"],cd=R(Ys,ud,e=>{var{typed:n}=e;return n(Ys,{number:ks,BigNumber:function(t){return!t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s>0&&t.n>0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Ws="isZero",fd=["typed"],ld=R(Ws,fd,e=>{var{typed:n}=e;return n(Ws,{number:Hs,BigNumber:function(t){return t.isZero()},Complex:function(t){return t.re===0&&t.im===0},Fraction:function(t){return t.d===1&&t.n===0},Unit:function(t){return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Js="isNaN",md=["typed"],pd=R(Js,md,e=>{var{typed:n}=e;return n(Js,{number:Gs,BigNumber:function(t){return t.isNaN()},Fraction:function(t){return!1},Complex:function(t){return t.isNaN()},Unit:function(t){return Number.isNaN(t.value)},"Array | Matrix":function(t){return be(t,Number.isNaN)}})}),Qs="typeOf",vd=["typed"],hd=R(Qs,vd,e=>{var{typed:n}=e;return n(Qs,{any:Ke})});function st(e,n,a){if(a==null)return e.eq(n);if(e.eq(n))return!0;if(e.isNaN()||n.isNaN())return!1;if(e.isFinite()&&n.isFinite()){var t=e.minus(n).abs();if(t.isZero())return!0;var r=e.constructor.max(e.abs(),n.abs());return t.lte(r.times(a))}return!1}function dd(e,n,a){return Rr(e.re,n.re,a)&&Rr(e.im,n.im,a)}var Ma="equalScalar",gd=["typed","config"],yd=R(Ma,gd,e=>{var{typed:n,config:a}=e;return n(Ma,{"boolean, boolean":function(r,i){return r===i},"number, number":function(r,i){return Rr(r,i,a.epsilon)},"BigNumber, BigNumber":function(r,i){return r.eq(i)||st(r,i,a.epsilon)},"Fraction, Fraction":function(r,i){return r.equals(i)},"Complex, Complex":function(r,i){return dd(r,i,a.epsilon)},"Unit, Unit":function(r,i){if(!r.equalBase(i))throw new Error("Cannot compare units with different base");return this(r.value,i.value)}})});R(Ma,["typed","config"],e=>{var{typed:n,config:a}=e;return n(Ma,{"number, number":function(r,i){return Rr(r,i,a.epsilon)}})});var xd="SparseMatrix",bd=["typed","equalScalar","Matrix"],wd=R(xd,bd,e=>{var{typed:n,equalScalar:a,Matrix:t}=e;function r(h,b){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(b&&!_r(b))throw new Error("Invalid datatype: "+b);if(Oe(h))i(this,h,b);else if(h&&Xe(h.index)&&Xe(h.ptr)&&Xe(h.size))this._values=h.values,this._index=h.index,this._ptr=h.ptr,this._size=h.size,this._datatype=b||h.datatype;else if(Xe(h))l(this,h,b);else{if(h)throw new TypeError("Unsupported type of data ("+Ke(h)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=b}}function i(h,b,w){b.type==="SparseMatrix"?(h._values=b._values?Ce(b._values):void 0,h._index=Ce(b._index),h._ptr=Ce(b._ptr),h._size=Ce(b._size),h._datatype=w||b._datatype):l(h,b.valueOf(),w||b._datatype)}function l(h,b,w){h._values=[],h._index=[],h._ptr=[],h._datatype=w;var N=b.length,g=0,y=a,x=0;if(_r(w)&&(y=n.find(a,[w,w])||a,x=n.convert(0,w)),N>0){var d=0;do{h._ptr.push(h._index.length);for(var A=0;A<N;A++){var S=b[A];if(Xe(S)){if(d===0&&g<S.length&&(g=S.length),d<S.length){var O=S[d];y(O,x)||(h._values.push(O),h._index.push(A))}}else d===0&&g<1&&(g=1),y(S,x)||(h._values.push(S),h._index.push(A))}d++}while(d<g)}h._ptr.push(h._index.length),h._size=[N,g]}r.prototype=new t,r.prototype.createSparseMatrix=function(h,b){return new r(h,b)},r.prototype.type="SparseMatrix",r.prototype.isSparseMatrix=!0,r.prototype.getDataType=function(){return Bn(this._values,Ke)},r.prototype.storage=function(){return"sparse"},r.prototype.datatype=function(){return this._datatype},r.prototype.create=function(h,b){return new r(h,b)},r.prototype.density=function(){var h=this._size[0],b=this._size[1];return h!==0&&b!==0?this._index.length/(h*b):0},r.prototype.subset=function(h,b,w){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return m(this,h);case 2:case 3:return f(this,h,b,w);default:throw new SyntaxError("Wrong number of arguments")}};function m(h,b){if(!En(b))throw new TypeError("Invalid index");var w=b.isScalar();if(w)return h.get(b.min());var N=b.size();if(N.length!==h._size.length)throw new Fe(N.length,h._size.length);var g,y,x,d,A=b.min(),S=b.max();for(g=0,y=h._size.length;g<y;g++)We(A[g],h._size[g]),We(S[g],h._size[g]);var O=h._values,M=h._index,_=h._ptr,E=b.dimension(0),$=b.dimension(1),z=[],I=[];E.forEach(function(D,H){I[D]=H[0],z[D]=!0});var T=O?[]:void 0,B=[],G=[];return $.forEach(function(D){for(G.push(B.length),x=_[D],d=_[D+1];x<d;x++)g=M[x],z[g]===!0&&(B.push(I[g]),T&&T.push(O[x]))}),G.push(B.length),new r({values:T,index:B,ptr:G,size:N,datatype:h._datatype})}function f(h,b,w,N){if(!b||b.isIndex!==!0)throw new TypeError("Invalid index");var g=b.size(),y=b.isScalar(),x;if(Oe(w)?(x=w.size(),w=w.toArray()):x=Pe(w),y){if(x.length!==0)throw new TypeError("Scalar expected");h.set(b.min(),w,N)}else{if(g.length!==1&&g.length!==2)throw new Fe(g.length,h._size.length,"<");if(x.length<g.length){for(var d=0,A=0;g[d]===1&&x[d]===1;)d++;for(;g[d]===1;)A++,d++;w=xo(w,g.length,A,x)}if(!Dn(g,x))throw new Fe(g,x,">");if(g.length===1){var S=b.dimension(0);S.forEach(function(_,E){We(_),h.set([_,0],w[E[0]],N)})}else{var O=b.dimension(0),M=b.dimension(1);O.forEach(function(_,E){We(_),M.forEach(function($,z){We($),h.set([_,$],w[E[0]][z[0]],N)})})}}return h}r.prototype.get=function(h){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Fe(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var b=h[0],w=h[1];We(b,this._size[0]),We(w,this._size[1]);var N=c(b,this._ptr[w],this._ptr[w+1],this._index);return N<this._ptr[w+1]&&this._index[N]===b?this._values[N]:0},r.prototype.set=function(h,b,w){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==this._size.length)throw new Fe(h.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var N=h[0],g=h[1],y=this._size[0],x=this._size[1],d=a,A=0;_r(this._datatype)&&(d=n.find(a,[this._datatype,this._datatype])||a,A=n.convert(0,this._datatype)),(N>y-1||g>x-1)&&(u(this,Math.max(N+1,y),Math.max(g+1,x),w),y=this._size[0],x=this._size[1]),We(N,y),We(g,x);var S=c(N,this._ptr[g],this._ptr[g+1],this._index);return S<this._ptr[g+1]&&this._index[S]===N?d(b,A)?s(S,g,this._values,this._index,this._ptr):this._values[S]=b:o(S,N,g,b,this._values,this._index,this._ptr),this};function c(h,b,w,N){if(w-b===0)return w;for(var g=b;g<w;g++)if(N[g]===h)return g;return b}function s(h,b,w,N,g){w.splice(h,1),N.splice(h,1);for(var y=b+1;y<g.length;y++)g[y]--}function o(h,b,w,N,g,y,x){g.splice(h,0,N),y.splice(h,0,b);for(var d=w+1;d<x.length;d++)x[d]++}r.prototype.resize=function(h,b,w){if(!rn(h))throw new TypeError("Array or Matrix expected");var N=h.valueOf().map(y=>Array.isArray(y)&&y.length===1?y[0]:y);if(N.length!==2)throw new Error("Only two dimensions matrix are supported");N.forEach(function(y){if(!Be(y)||!Ae(y)||y<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Re(N)+")")});var g=w?this.clone():this;return u(g,N[0],N[1],b)};function u(h,b,w,N){var g=N||0,y=a,x=0;_r(h._datatype)&&(y=n.find(a,[h._datatype,h._datatype])||a,x=n.convert(0,h._datatype),g=n.convert(g,h._datatype));var d=!y(g,x),A=h._size[0],S=h._size[1],O,M,_;if(w>S){for(M=S;M<w;M++)if(h._ptr[M]=h._values.length,d)for(O=0;O<A;O++)h._values.push(g),h._index.push(O);h._ptr[w]=h._values.length}else w<S&&(h._ptr.splice(w+1,S-w),h._values.splice(h._ptr[w],h._values.length),h._index.splice(h._ptr[w],h._index.length));if(S=w,b>A){if(d){var E=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]+E,_=h._ptr[M+1]+E;var $=0;for(O=A;O<b;O++,$++)h._values.splice(_+$,0,g),h._index.splice(_+$,0,O),E++}h._ptr[S]=h._values.length}}else if(b<A){var z=0;for(M=0;M<S;M++){h._ptr[M]=h._ptr[M]-z;var I=h._ptr[M],T=h._ptr[M+1]-z;for(_=I;_<T;_++)O=h._index[_],O>b-1&&(h._values.splice(_,1),h._index.splice(_,1),z++)}h._ptr[M]=h._values.length}return h._size[0]=b,h._size[1]=w,h}r.prototype.reshape=function(h,b){if(!Xe(h))throw new TypeError("Array expected");if(h.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");h.forEach(function(D){if(!Be(D)||!Ae(D)||D<=-2||D===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Re(h)+")")});var w=this._size[0]*this._size[1];h=ti(h,w);var N=h[0]*h[1];if(w!==N)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var g=b?this.clone():this;if(this._size[0]===h[0]&&this._size[1]===h[1])return g;for(var y=[],x=0;x<g._ptr.length;x++)for(var d=0;d<g._ptr[x+1]-g._ptr[x];d++)y.push(x);for(var A=g._values.slice(),S=g._index.slice(),O=0;O<g._index.length;O++){var M=S[O],_=y[O],E=M*g._size[1]+_;y[O]=E%h[1],S[O]=Math.floor(E/h[1])}g._values.length=0,g._index.length=0,g._ptr.length=h[1]+1,g._size=h.slice();for(var $=0;$<g._ptr.length;$++)g._ptr[$]=0;for(var z=0;z<A.length;z++){var I=S[z],T=y[z],B=A[z],G=c(I,g._ptr[T],g._ptr[T+1],g._index);o(G,I,T,B,g._values,g._index,g._ptr)}return g},r.prototype.clone=function(){var h=new r({values:this._values?Ce(this._values):void 0,index:Ce(this._index),ptr:Ce(this._ptr),size:Ce(this._size),datatype:this._datatype});return h},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(h,b){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var w=this,N=this._size[0],g=this._size[1],y=function(d,A,S){return h(d,[A,S],w)};return p(this,0,N-1,0,g-1,y,b)};function p(h,b,w,N,g,y,x){var d=[],A=[],S=[],O=a,M=0;_r(h._datatype)&&(O=n.find(a,[h._datatype,h._datatype])||a,M=n.convert(0,h._datatype));for(var _=function(V,K,te){V=y(V,K,te),O(V,M)||(d.push(V),A.push(K))},E=N;E<=g;E++){S.push(d.length);var $=h._ptr[E],z=h._ptr[E+1];if(x)for(var I=$;I<z;I++){var T=h._index[I];T>=b&&T<=w&&_(h._values[I],T-b,E-N)}else{for(var B={},G=$;G<z;G++){var D=h._index[G];B[D]=h._values[G]}for(var H=b;H<=w;H++){var W=H in B?B[H]:0;_(W,H-b,E-N)}}}return S.push(d.length),new r({values:d,index:A,ptr:S,size:[w-b+1,g-N+1]})}r.prototype.forEach=function(h,b){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var w=this,N=this._size[0],g=this._size[1],y=0;y<g;y++){var x=this._ptr[y],d=this._ptr[y+1];if(b)for(var A=x;A<d;A++){var S=this._index[A];h(this._values[A],[S,y],w)}else{for(var O={},M=x;M<d;M++){var _=this._index[M];O[_]=this._values[M]}for(var E=0;E<N;E++){var $=E in O?O[E]:0;h($,[E,y],w)}}}},r.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var h=this._size[1],b=0;b<h;b++)for(var w=this._ptr[b],N=this._ptr[b+1],g=w;g<N;g++){var y=this._index[g];yield{value:this._values[g],index:[y,b]}}},r.prototype.toArray=function(){return v(this._values,this._index,this._ptr,this._size,!0)},r.prototype.valueOf=function(){return v(this._values,this._index,this._ptr,this._size,!1)};function v(h,b,w,N,g){var y=N[0],x=N[1],d=[],A,S;for(A=0;A<y;A++)for(d[A]=[],S=0;S<x;S++)d[A][S]=0;for(S=0;S<x;S++)for(var O=w[S],M=w[S+1],_=O;_<M;_++)A=b[_],d[A][S]=h?g?Ce(h[_]):h[_]:1;return d}return r.prototype.format=function(h){for(var b=this._size[0],w=this._size[1],N=this.density(),g="Sparse Matrix ["+Re(b,h)+" x "+Re(w,h)+"] density: "+Re(N,h)+`
27
10
  `,y=0;y<w;y++)for(var x=this._ptr[y],d=this._ptr[y+1],A=x;A<d;A++){var S=this._index[A];g+=`
28
11
  (`+Re(S,h)+", "+Re(y,h)+") ==> "+(this._values?Re(this._values[A],h):"X")}return g},r.prototype.toString=function(){return Re(this.toArray())},r.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},r.prototype.diagonal=function(h){if(h){if(_e(h)&&(h=h.toNumber()),!Be(h)||!Ae(h))throw new TypeError("The parameter k must be an integer number")}else h=0;var b=h>0?h:0,w=h<0?-h:0,N=this._size[0],g=this._size[1],y=Math.min(N-w,g-b),x=[],d=[],A=[];A[0]=0;for(var S=b;S<g&&x.length<y;S++)for(var O=this._ptr[S],M=this._ptr[S+1],_=O;_<M;_++){var E=this._index[_];if(E===S-b+w){x.push(this._values[_]),d[x.length-1]=E-w;break}}return A.push(x.length),new r({values:x,index:d,ptr:A,size:[y,1]})},r.fromJSON=function(h){return new r(h)},r.diagonal=function(h,b,w,N,g){if(!Xe(h))throw new TypeError("Array expected, size parameter");if(h.length!==2)throw new Error("Only two dimensions matrix are supported");if(h=h.map(function(D){if(_e(D)&&(D=D.toNumber()),!Be(D)||!Ae(D)||D<1)throw new Error("Size values must be positive integers");return D}),w){if(_e(w)&&(w=w.toNumber()),!Be(w)||!Ae(w))throw new TypeError("The parameter k must be an integer number")}else w=0;var y=a,x=0;_r(g)&&(y=n.find(a,[g,g])||a,x=n.convert(0,g));var d=w>0?w:0,A=w<0?-w:0,S=h[0],O=h[1],M=Math.min(S-A,O-d),_;if(Xe(b)){if(b.length!==M)throw new Error("Invalid value array length");_=function(H){return b[H]}}else if(Oe(b)){var E=b.size();if(E.length!==1||E[0]!==M)throw new Error("Invalid matrix length");_=function(H){return b.get([H])}}else _=function(){return b};for(var $=[],z=[],I=[],T=0;T<O;T++){I.push($.length);var B=T-d;if(B>=0&&B<M){var G=_(B);y(G,x)||(z.push(B+A),$.push(G))}}return I.push($.length),new r({values:$,index:z,ptr:I,size:[S,O]})},r.prototype.swapRows=function(h,b){if(!Be(h)||!Ae(h)||!Be(b)||!Ae(b))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return We(h,this._size[0]),We(b,this._size[0]),r._swapRows(h,b,this._size[1],this._values,this._index,this._ptr),this},r._forEachRow=function(h,b,w,N,g){for(var y=N[h],x=N[h+1],d=y;d<x;d++)g(w[d],b[d])},r._swapRows=function(h,b,w,N,g,y){for(var x=0;x<w;x++){var d=y[x],A=y[x+1],S=c(h,d,A,g),O=c(b,d,A,g);if(S<A&&O<A&&g[S]===h&&g[O]===b){if(N){var M=N[S];N[S]=N[O],N[O]=M}continue}if(S<A&&g[S]===h&&(O>=A||g[O]!==b)){var _=N?N[S]:void 0;g.splice(O,0,b),N&&N.splice(O,0,_),g.splice(O<=S?S+1:S,1),N&&N.splice(O<=S?S+1:S,1);continue}if(O<A&&g[O]===b&&(S>=A||g[S]!==h)){var E=N?N[O]:void 0;g.splice(S,0,h),N&&N.splice(S,0,E),g.splice(S<=O?O+1:O,1),N&&N.splice(S<=O?O+1:O,1)}}},r},{isClass:!0}),Nd="number",Md=["typed"];function Ad(e){var n=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(n){var a={"0b":2,"0o":8,"0x":16}[n[1]],t=n[2],r=n[3];return{input:e,radix:a,integerPart:t,fractionalPart:r}}else return null}function Sd(e){for(var n=parseInt(e.integerPart,e.radix),a=0,t=0;t<e.fractionalPart.length;t++){var r=parseInt(e.fractionalPart[t],e.radix);a+=r/Math.pow(e.radix,t+1)}var i=n+a;if(isNaN(i))throw new SyntaxError('String "'+e.input+'" is no valid number');return i}var Ed=R(Nd,Md,e=>{var{typed:n}=e,a=n("number",{"":function(){return 0},number:function(r){return r},string:function(r){if(r==="NaN")return NaN;var i=Ad(r);if(i)return Sd(i);var l=0,m=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);m&&(l=Number(m[2]),r=m[1]);var f=Number(r);if(isNaN(f))throw new SyntaxError('String "'+r+'" is no valid number');if(m){if(f>en(2,l)-1)throw new SyntaxError('String "'.concat(r,'" is out of range'));f>=en(2,l-1)&&(f=f-en(2,l))}return f},BigNumber:function(r){return r.toNumber()},Fraction:function(r){return r.valueOf()},Unit:function(r){throw new Error("Second argument with valueless unit expected")},null:function(r){return 0},"Unit, string | Unit":function(r,i){return r.toNumber(i)},"Array | Matrix":function(r){return be(r,this)}});return a.fromJSON=function(t){return parseFloat(t.value)},a}),Ks="string",Cd=["typed"],Od=R(Ks,Cd,e=>{var{typed:n}=e;return n(Ks,{"":function(){return""},number:Ht,null:function(t){return"null"},boolean:function(t){return t+""},string:function(t){return t},"Array | Matrix":function(t){return be(t,this)},any:function(t){return String(t)}})}),js="boolean",Dd=["typed"],Td=R(js,Dd,e=>{var{typed:n}=e;return n(js,{"":function(){return!1},boolean:function(t){return t},number:function(t){return!!t},null:function(t){return!1},BigNumber:function(t){return!t.isZero()},string:function(t){var r=t.toLowerCase();if(r==="true")return!0;if(r==="false")return!1;var i=Number(t);if(t!==""&&!isNaN(i))return!!i;throw new Error('Cannot convert "'+t+'" to a boolean')},"Array | Matrix":function(t){return be(t,this)}})}),Bd="bignumber",_d=["typed","BigNumber"],$d=R(Bd,_d,e=>{var{typed:n,BigNumber:a}=e;return n("bignumber",{"":function(){return new a(0)},number:function(r){return new a(r+"")},string:function(r){var i=r.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(i){var l=i[2],m=a(i[1]),f=new a(2).pow(Number(l));if(m.gt(f.sub(1)))throw new SyntaxError('String "'.concat(r,'" is out of range'));var c=new a(2).pow(Number(l)-1);return m.gte(c)?m.sub(f):m}return new a(r)},BigNumber:function(r){return r},Fraction:function(r){return new a(r.n).div(r.d).times(r.s)},null:function(r){return new a(0)},"Array | Matrix":function(r){return be(r,this)}})}),Id="complex",qd=["typed","Complex"],Rd=R(Id,qd,e=>{var{typed:n,Complex:a}=e;return n("complex",{"":function(){return a.ZERO},number:function(r){return new a(r,0)},"number, number":function(r,i){return new a(r,i)},"BigNumber, BigNumber":function(r,i){return new a(r.toNumber(),i.toNumber())},Fraction:function(r){return new a(r.valueOf(),0)},Complex:function(r){return r.clone()},string:function(r){return a(r)},null:function(r){return a(0)},Object:function(r){if("re"in r&&"im"in r)return new a(r.re,r.im);if("r"in r&&"phi"in r||"abs"in r&&"arg"in r)return new a(r);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(r){return be(r,this)}})}),Fd="fraction",zd=["typed","Fraction"],Pd=R(Fd,zd,e=>{var{typed:n,Fraction:a}=e;return n("fraction",{number:function(r){if(!isFinite(r)||isNaN(r))throw new Error(r+" cannot be represented as a fraction");return new a(r)},string:function(r){return new a(r)},"number, number":function(r,i){return new a(r,i)},null:function(r){return new a(0)},BigNumber:function(r){return new a(r.toString())},Fraction:function(r){return r},Object:function(r){return new a(r)},"Array | Matrix":function(r){return be(r,this)}})}),eu="matrix",Ud=["typed","Matrix","DenseMatrix","SparseMatrix"],Ld=R(eu,Ud,e=>{var{typed:n,Matrix:a,DenseMatrix:t,SparseMatrix:r}=e;return n(eu,{"":function(){return i([])},string:function(m){return i([],m)},"string, string":function(m,f){return i([],m,f)},Array:function(m){return i(m)},Matrix:function(m){return i(m,m.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(l,m,f){if(m==="dense"||m==="default"||m===void 0)return new t(l,f);if(m==="sparse")return new r(l,f);throw new TypeError("Unknown matrix type "+JSON.stringify(m)+".")}}),ru="matrixFromFunction",kd=["typed","matrix","isZero"],Hd=R(ru,kd,e=>{var{typed:n,matrix:a,isZero:t}=e;return n(ru,{"Array | Matrix, function, string, string":function(l,m,f,c){return r(l,m,f,c)},"Array | Matrix, function, string":function(l,m,f){return r(l,m,f)},"Matrix, function":function(l,m){return r(l,m,"dense")},"Array, function":function(l,m){return r(l,m,"dense").toArray()},"Array | Matrix, string, function":function(l,m,f){return r(l,f,m)},"Array | Matrix, string, string, function":function(l,m,f,c){return r(l,c,m,f)}});function r(i,l,m,f){var c;return f!==void 0?c=a(m,f):c=a(m),c.resize(i),c.forEach(function(s,o){var u=l(o);t(u)||c.set(o,u)}),c}}),tu="matrixFromRows",Gd=["typed","matrix","flatten","size"],Vd=R(tu,Gd,e=>{var{typed:n,matrix:a,flatten:t,size:r}=e;return n(tu,{"...Array":function(f){return i(f)},"...Matrix":function(f){return a(i(f.map(c=>c.toArray())))}});function i(m){if(m.length===0)throw new TypeError("At least one row is needed to construct a matrix.");var f=l(m[0]),c=[];for(var s of m){var o=l(s);if(o!==f)throw new TypeError("The vectors had different length: "+(f|0)+" ≠ "+(o|0));c.push(t(s))}return c}function l(m){var f=r(m);if(f.length===1)return f[0];if(f.length===2){if(f[0]===1)return f[1];if(f[1]===1)return f[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),nu="matrixFromColumns",Zd=["typed","matrix","flatten","size"],Xd=R(nu,Zd,e=>{var{typed:n,matrix:a,flatten:t,size:r}=e;return n(nu,{"...Array":function(f){return i(f)},"...Matrix":function(f){return a(i(f.map(c=>c.toArray())))}});function i(m){if(m.length===0)throw new TypeError("At least one column is needed to construct a matrix.");for(var f=l(m[0]),c=[],s=0;s<f;s++)c[s]=[];for(var o of m){var u=l(o);if(u!==f)throw new TypeError("The vectors had different length: "+(f|0)+" ≠ "+(u|0));for(var p=t(o),v=0;v<f;v++)c[v].push(p[v])}return c}function l(m){var f=r(m);if(f.length===1)return f[0];if(f.length===2){if(f[0]===1)return f[1];if(f[1]===1)return f[0];throw new TypeError("At least one of the arguments is not a vector.")}else throw new TypeError("Only one- or two-dimensional vectors are supported.")}}),au="splitUnit",Yd=["typed"],Wd=R(au,Yd,e=>{var{typed:n}=e;return n(au,{"Unit, Array":function(t,r){return t.splitUnit(r)}})}),iu="unaryMinus",Jd=["typed"],Qd=R(iu,Jd,e=>{var{typed:n}=e;return n(iu,{number:Wo,Complex:function(t){return t.neg()},BigNumber:function(t){return t.neg()},Fraction:function(t){return t.neg()},Unit:function(t){var r=t.clone();return r.value=this(t.value),r},"Array | Matrix":function(t){return be(t,this)}})}),ou="unaryPlus",Kd=["typed","config","BigNumber"],jd=R(ou,Kd,e=>{var{typed:n,config:a,BigNumber:t}=e;return n(ou,{number:Jo,Complex:function(i){return i},BigNumber:function(i){return i},Fraction:function(i){return i},Unit:function(i){return i.clone()},"Array | Matrix":function(i){return be(i,this)},"boolean | string":function(i){return a.number==="BigNumber"?new t(+i):+i}})}),su="abs",eg=["typed"],rg=R(su,eg,e=>{var{typed:n}=e;return n(su,{number:Zo,Complex:function(t){return t.abs()},BigNumber:function(t){return t.abs()},Fraction:function(t){return t.abs()},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.abs()}})}),uu="apply",tg=["typed","isInteger"],cu=R(uu,tg,e=>{var{typed:n,isInteger:a}=e;return n(uu,{"Array | Matrix, number | BigNumber, function":function(r,i,l){if(!a(i))throw new TypeError("Integer number expected for dimension");var m=Array.isArray(r)?Pe(r):r.size();if(i<0||i>=m.length)throw new Kr(i,m.length);return Oe(r)?r.create(Aa(r.valueOf(),i,l)):Aa(r,i,l)}})});function Aa(e,n,a){var t,r,i;if(n<=0)if(Array.isArray(e[0])){for(i=ng(e),r=[],t=0;t<i.length;t++)r[t]=Aa(i[t],n-1,a);return r}else return a(e);else{for(r=[],t=0;t<e.length;t++)r[t]=Aa(e[t],n-1,a);return r}}function ng(e){var n=e.length,a=e[0].length,t,r,i=[];for(r=0;r<a;r++){var l=[];for(t=0;t<n;t++)l.push(e[t][r]);i.push(l)}return i}var fu="addScalar",ag=["typed"],ig=R(fu,ag,e=>{var{typed:n}=e;return n(fu,{"number, number":Xo,"Complex, Complex":function(t,r){return t.add(r)},"BigNumber, BigNumber":function(t,r){return t.plus(r)},"Fraction, Fraction":function(t,r){return t.add(r)},"Unit, Unit":function(t,r){if(t.value===null||t.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(r.value===null||r.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!t.equalBase(r))throw new Error("Units do not match");var i=t.clone();return i.value=this(i.value,r.value),i.fixPrefix=!1,i}})}),lu="cbrt",og=["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],sg=R(lu,og,e=>{var{config:n,typed:a,isNegative:t,unaryMinus:r,matrix:i,Complex:l,BigNumber:m,Fraction:f}=e;return a(lu,{number:$n,Complex:c,"Complex, boolean":c,BigNumber:function(u){return u.cbrt()},Unit:s,"Array | Matrix":function(u){return be(u,this)}});function c(o,u){var p=o.arg()/3,v=o.abs(),h=new l($n(v),0).mul(new l(0,p).exp());if(u){var b=[h,new l($n(v),0).mul(new l(0,p+Math.PI*2/3).exp()),new l($n(v),0).mul(new l(0,p-Math.PI*2/3).exp())];return n.matrix==="Array"?b:i(b)}else return h}function s(o){if(o.value&&Or(o.value)){var u=o.clone();return u.value=1,u=u.pow(1/3),u.value=c(o.value),u}else{var p=t(o.value);p&&(o.value=r(o.value));var v;_e(o.value)?v=new m(1).div(3):yr(o.value)?v=new f(1,3):v=1/3;var h=o.pow(v);return p&&(h.value=r(h.value)),h}}}),ug="algorithm11",cg=["typed","equalScalar"],wr=R(ug,cg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=a,w=0,N=l;typeof u=="string"&&(h=u,b=n.find(a,[h,h]),w=n.convert(0,h),i=n.convert(i,h),N=n.find(l,[h,h]));for(var g=[],y=[],x=[],d=0;d<v;d++){x[d]=y.length;for(var A=s[d],S=s[d+1],O=A;O<S;O++){var M=c[O],_=m?N(i,f[O]):N(f[O],i);b(_,w)||(y.push(M),g.push(_))}}return x[v]=y.length,r.createSparseMatrix({values:g,index:y,ptr:x,size:[p,v],datatype:h})}}),fg="algorithm12",lg=["typed","DenseMatrix"],gr=R(fg,lg,e=>{var{typed:n,DenseMatrix:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=l;typeof u=="string"&&(h=u,i=n.convert(i,h),b=n.find(l,[h,h]));for(var w=[],N=[],g=[],y=0;y<v;y++){for(var x=y+1,d=s[y],A=s[y+1],S=d;S<A;S++){var O=c[S];N[O]=f[S],g[O]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),g[M]===x?w[M][y]=m?b(i,N[M]):b(N[M],i):w[M][y]=m?b(i,0):b(0,i)}return new a({data:w,size:[p,v],datatype:h})}}),mg="algorithm14",pg=["typed"],Ge=R(mg,pg,e=>{var{typed:n}=e;return function(r,i,l,m){var f=r._data,c=r._size,s=r._datatype,o,u=l;typeof s=="string"&&(o=s,i=n.convert(i,o),u=n.find(l,[o,o]));var p=c.length>0?a(u,0,c,c[0],f,i,m):[];return r.createDenseMatrix({data:p,size:Ce(c),datatype:o})};function a(t,r,i,l,m,f,c){var s=[];if(r===i.length-1)for(var o=0;o<l;o++)s[o]=c?t(f,m[o]):t(m[o],f);else for(var u=0;u<l;u++)s[u]=a(t,r+1,i,i[r+1],m[u],f,c);return s}}),xi="ceil",vg=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],hg=R(xi,["typed","config","round"],e=>{var{typed:n,config:a,round:t}=e;return n(xi,{number:function(i){return Rr(i,t(i),a.epsilon)?t(i):Math.ceil(i)},"number, number":function(i,l){if(Rr(i,t(i,l),a.epsilon))return t(i,l);var[m,f]="".concat(i,"e").split("e"),c=Math.ceil(Number("".concat(m,"e").concat(Number(f)+l)));return[m,f]="".concat(c,"e").split("e"),Number("".concat(m,"e").concat(Number(f)-l))}})}),dg=R(xi,vg,e=>{var{typed:n,config:a,round:t,matrix:r,equalScalar:i,zeros:l,DenseMatrix:m}=e,f=wr({typed:n,equalScalar:i}),c=gr({typed:n,DenseMatrix:m}),s=Ge({typed:n}),o=hg({typed:n,config:a,round:t});return n("ceil",{number:o.signatures.number,"number,number":o.signatures["number,number"],Complex:function(p){return p.ceil()},"Complex, number":function(p,v){return p.ceil(v)},"Complex, BigNumber":function(p,v){return p.ceil(v.toNumber())},BigNumber:function(p){return st(p,t(p),a.epsilon)?t(p):p.ceil()},"BigNumber, BigNumber":function(p,v){return st(p,t(p,v),a.epsilon)?t(p,v):p.toDecimalPlaces(v.toNumber(),It.ROUND_CEIL)},Fraction:function(p){return p.ceil()},"Fraction, number":function(p,v){return p.ceil(v)},"Fraction, BigNumber":function(p,v){return p.ceil(v.toNumber())},"Array | Matrix":function(p){return be(p,this)},"Array, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(r(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?l(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),mu="cube",gg=["typed"],yg=R(mu,gg,e=>{var{typed:n}=e;return n(mu,{number:Qo,Complex:function(t){return t.mul(t).mul(t)},BigNumber:function(t){return t.times(t).times(t)},Fraction:function(t){return t.pow(3)},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.pow(3)}})}),pu="exp",xg=["typed"],bg=R(pu,xg,e=>{var{typed:n}=e;return n(pu,{number:Ko,Complex:function(t){return t.exp()},BigNumber:function(t){return t.exp()},"Array | Matrix":function(t){return be(t,this)}})}),vu="expm1",wg=["typed","Complex"],Ng=R(vu,wg,e=>{var{typed:n,Complex:a}=e;return n(vu,{number:jo,Complex:function(r){var i=Math.exp(r.re);return new a(i*Math.cos(r.im)-1,i*Math.sin(r.im))},BigNumber:function(r){return r.exp().minus(1)},"Array | Matrix":function(r){return be(r,this)}})}),bi="fix",Mg=["typed","Complex","matrix","ceil","floor","equalScalar","zeros","DenseMatrix"],Ag=R(bi,["typed","ceil","floor"],e=>{var{typed:n,ceil:a,floor:t}=e;return n(bi,{number:function(i){return i>0?t(i):a(i)},"number, number":function(i,l){return i>0?t(i,l):a(i,l)}})}),Sg=R(bi,Mg,e=>{var{typed:n,Complex:a,matrix:t,ceil:r,floor:i,equalScalar:l,zeros:m,DenseMatrix:f}=e,c=gr({typed:n,DenseMatrix:f}),s=Ge({typed:n}),o=Ag({typed:n,ceil:r,floor:i});return n("fix",{number:o.signatures.number,"number, number | BigNumber":o.signatures["number,number"],Complex:function(p){return new a(p.re>0?Math.floor(p.re):Math.ceil(p.re),p.im>0?Math.floor(p.im):Math.ceil(p.im))},"Complex, number":function(p,v){return new a(p.re>0?i(p.re,v):r(p.re,v),p.im>0?i(p.im,v):r(p.im,v))},"Complex, BigNumber":function(p,v){var h=v.toNumber();return new a(p.re>0?i(p.re,h):r(p.re,h),p.im>0?i(p.im,h):r(p.im,h))},BigNumber:function(p){return p.isNegative()?r(p):i(p)},"BigNumber, number | BigNumber":function(p,v){return p.isNegative()?r(p,v):i(p,v)},Fraction:function(p){return p.s<0?p.ceil():p.floor()},"Fraction, number | BigNumber":function(p,v){return p.s<0?r(p,v):i(p,v)},"Array | Matrix":function(p){return be(p,this)},"Array | Matrix, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(t(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return l(p,0)?m(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),wi="floor",Eg=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],Cg=R(wi,["typed","config","round"],e=>{var{typed:n,config:a,round:t}=e;return n(wi,{number:function(i){return Rr(i,t(i),a.epsilon)?t(i):Math.floor(i)},"number, number":function(i,l){if(Rr(i,t(i,l),a.epsilon))return t(i,l);var[m,f]="".concat(i,"e").split("e"),c=Math.floor(Number("".concat(m,"e").concat(Number(f)+l)));return[m,f]="".concat(c,"e").split("e"),Number("".concat(m,"e").concat(Number(f)-l))}})}),Og=R(wi,Eg,e=>{var{typed:n,config:a,round:t,matrix:r,equalScalar:i,zeros:l,DenseMatrix:m}=e,f=wr({typed:n,equalScalar:i}),c=gr({typed:n,DenseMatrix:m}),s=Ge({typed:n}),o=Cg({typed:n,config:a,round:t});return n("floor",{number:o.signatures.number,"number,number":o.signatures["number,number"],Complex:function(p){return p.floor()},"Complex, number":function(p,v){return p.floor(v)},"Complex, BigNumber":function(p,v){return p.floor(v.toNumber())},BigNumber:function(p){return st(p,t(p),a.epsilon)?t(p):p.floor()},"BigNumber, BigNumber":function(p,v){return st(p,t(p,v),a.epsilon)?t(p,v):p.toDecimalPlaces(v.toNumber(),It.ROUND_FLOOR)},Fraction:function(p){return p.floor()},"Fraction, number":function(p,v){return p.floor(v)},"Fraction, BigNumber":function(p,v){return p.floor(v.toNumber())},"Array | Matrix":function(p){return be(p,this)},"Array, number | BigNumber":function(p,v){return be(p,h=>this(h,v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(p,v){return s(r(v),p,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(p,v){return i(p,0)?l(v.size(),v.storage()):v.storage()==="dense"?s(v,p,this,!0):c(v,p,this,!0)}})}),Dg="algorithm01",Tg=["typed"],qt=R(Dg,Tg,e=>{var{typed:n}=e;return function(t,r,i,l){var m=t._data,f=t._size,c=t._datatype,s=r._values,o=r._index,u=r._ptr,p=r._size,v=r._datatype;if(f.length!==p.length)throw new Fe(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=f[0],b=f[1],w=typeof c=="string"&&c===v?c:void 0,N=w?n.find(i,[w,w]):i,g,y,x=[];for(g=0;g<h;g++)x[g]=[];var d=[],A=[];for(y=0;y<b;y++){for(var S=y+1,O=u[y],M=u[y+1],_=O;_<M;_++)g=o[_],d[g]=l?N(s[_],m[g][y]):N(m[g][y],s[_]),A[g]=S;for(g=0;g<h;g++)A[g]===S?x[g][y]=d[g]:x[g][y]=m[g][y]}return t.createDenseMatrix({data:x,size:[h,b],datatype:w})}}),Bg="algorithm04",_g=["typed","equalScalar"],Ni=R(Bg,_g,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=m&&u?[]:void 0,_=m&&u?[]:void 0,E=[],$=[],z,I,T,B,G;for(I=0;I<N;I++){O[I]=S.length;var D=I+1;for(B=c[I],G=c[I+1],T=B;T<G;T++)z=f[T],S.push(z),E[z]=D,M&&(M[z]=m[T]);for(B=v[I],G=v[I+1],T=B;T<G;T++)if(z=p[T],E[z]===D){if(M){var H=d(M[z],u[T]);y(H,x)?E[z]=null:M[z]=H}}else S.push(z),$[z]=D,_&&(_[z]=u[T]);if(M&&_)for(T=O[I];T<S.length;)z=S[T],E[z]===D?(A[T]=M[z],T++):$[z]===D?(A[T]=_[z],T++):S.splice(T,1)}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),$g="algorithm10",Ig=["typed","DenseMatrix"],Vt=R($g,Ig,e=>{var{typed:n,DenseMatrix:a}=e;return function(r,i,l,m){var f=r._values,c=r._index,s=r._ptr,o=r._size,u=r._datatype;if(!f)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=o[0],v=o[1],h,b=l;typeof u=="string"&&(h=u,i=n.convert(i,h),b=n.find(l,[h,h]));for(var w=[],N=[],g=[],y=0;y<v;y++){for(var x=y+1,d=s[y],A=s[y+1],S=d;S<A;S++){var O=c[S];N[O]=f[S],g[O]=x}for(var M=0;M<p;M++)y===0&&(w[M]=[]),g[M]===x?w[M][y]=m?b(i,N[M]):b(N[M],i):w[M][y]=i}return new a({data:w,size:[p,v],datatype:h})}}),qg="algorithm13",Rg=["typed"],je=R(qg,Rg,e=>{var{typed:n}=e;return function(r,i,l){var m=r._data,f=r._size,c=r._datatype,s=i._data,o=i._size,u=i._datatype,p=[];if(f.length!==o.length)throw new Fe(f.length,o.length);for(var v=0;v<f.length;v++){if(f[v]!==o[v])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+o+")");p[v]=f[v]}var h,b=l;typeof c=="string"&&c===u&&(h=c,b=n.find(l,[h,h]));var w=p.length>0?a(b,0,p,p[0],m,s):[];return r.createDenseMatrix({data:w,size:p,datatype:h})};function a(t,r,i,l,m,f){var c=[];if(r===i.length-1)for(var s=0;s<l;s++)c[s]=t(m[s],f[s]);else for(var o=0;o<l;o++)c[o]=a(t,r+1,i,i[r+1],m[o],f[o]);return c}}),hu="gcd",Fg=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],zg=R(hu,Fg,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r,DenseMatrix:i}=e,l=qt({typed:n}),m=Ni({typed:n,equalScalar:t}),f=Vt({typed:n,DenseMatrix:i}),c=je({typed:n}),s=Ge({typed:n});return n(hu,{"number, number":es,"BigNumber, BigNumber":o,"Fraction, Fraction":function(p,v){return p.gcd(v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,this)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return c(p,v,this)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"SparseMatrix, number | BigNumber":function(p,v){return f(p,v,this,!1)},"DenseMatrix, number | BigNumber":function(p,v){return s(p,v,this,!1)},"number | BigNumber, SparseMatrix":function(p,v){return f(v,p,this,!0)},"number | BigNumber, DenseMatrix":function(p,v){return s(v,p,this,!0)},"Array, number | BigNumber":function(p,v){return s(a(p),v,this,!1).valueOf()},"number | BigNumber, Array":function(p,v){return s(a(v),p,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(p,v,h){for(var b=this(p,v),w=0;w<h.length;w++)b=this(b,h[w]);return b}});function o(u,p){if(!u.isInt()||!p.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var v=new r(0);!p.isZero();){var h=u.mod(p);u=p,p=h}return u.lt(v)?u.neg():u}}),Pg="algorithm02",Ug=["typed","equalScalar"],rt=R(Pg,Ug,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l,m){var f=r._data,c=r._size,s=r._datatype,o=i._values,u=i._index,p=i._ptr,v=i._size,h=i._datatype;if(c.length!==v.length)throw new Fe(c.length,v.length);if(c[0]!==v[0]||c[1]!==v[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+v+")");if(!o)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var b=c[0],w=c[1],N,g=a,y=0,x=l;typeof s=="string"&&s===h&&(N=s,g=n.find(a,[N,N]),y=n.convert(0,N),x=n.find(l,[N,N]));for(var d=[],A=[],S=[],O=0;O<w;O++){S[O]=A.length;for(var M=p[O],_=p[O+1],E=M;E<_;E++){var $=u[E],z=m?x(o[E],f[$][O]):x(f[$][O],o[E]);g(z,y)||(A.push($),d.push(z))}}return S[w]=A.length,i.createSparseMatrix({values:d,index:A,ptr:S,size:[b,w],datatype:N})}}),Lg="algorithm06",kg=["typed","equalScalar"],Sa=R(Lg,kg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._size,c=r._datatype,s=i._values,o=i._size,u=i._datatype;if(f.length!==o.length)throw new Fe(f.length,o.length);if(f[0]!==o[0]||f[1]!==o[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+o+")");var p=f[0],v=f[1],h,b=a,w=0,N=l;typeof c=="string"&&c===u&&(h=c,b=n.find(a,[h,h]),w=n.convert(0,h),N=n.find(l,[h,h]));for(var g=m&&s?[]:void 0,y=[],x=[],d=g?[]:void 0,A=[],S=[],O=0;O<v;O++){x[O]=y.length;var M=O+1;if(Go(r,O,A,d,S,M,y,N),Go(i,O,A,d,S,M,y,N),d)for(var _=x[O];_<y.length;){var E=y[_];if(S[E]===M){var $=d[E];b($,w)?y.splice(_,1):(g.push($),_++)}else y.splice(_,1)}else for(var z=x[O];z<y.length;){var I=y[z];S[I]!==M?y.splice(z,1):z++}}return x[v]=y.length,r.createSparseMatrix({values:g,index:y,ptr:x,size:[p,v],datatype:h})}}),du="lcm",Hg=["typed","matrix","equalScalar"],Gg=R(du,Hg,e=>{var{typed:n,matrix:a,equalScalar:t}=e,r=rt({typed:n,equalScalar:t}),i=Sa({typed:n,equalScalar:t}),l=wr({typed:n,equalScalar:t}),m=je({typed:n}),f=Ge({typed:n});return n(du,{"number, number":rs,"BigNumber, BigNumber":c,"Fraction, Fraction":function(o,u){return o.lcm(u)},"SparseMatrix, SparseMatrix":function(o,u){return i(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return r(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return r(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return m(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, number | BigNumber":function(o,u){return l(o,u,this,!1)},"DenseMatrix, number | BigNumber":function(o,u){return f(o,u,this,!1)},"number | BigNumber, SparseMatrix":function(o,u){return l(u,o,this,!0)},"number | BigNumber, DenseMatrix":function(o,u){return f(u,o,this,!0)},"Array, number | BigNumber":function(o,u){return f(a(o),u,this,!1).valueOf()},"number | BigNumber, Array":function(o,u){return f(a(u),o,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(o,u,p){for(var v=this(o,u),h=0;h<p.length;h++)v=this(v,p[h]);return v}});function c(s,o){if(!s.isInt()||!o.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(s.isZero())return s;if(o.isZero())return o;for(var u=s.times(o);!o.isZero();){var p=o;o=s.mod(p),s=p}return u.div(s).abs()}}),gu="log10",Vg=["typed","config","Complex"],Zg=R(gu,Vg,e=>{var{typed:n,config:a,Complex:t}=e;return n(gu,{number:function(i){return i>=0||a.predictable?ts(i):new t(i,0).log().div(Math.LN10)},Complex:function(i){return new t(i).log().div(Math.LN10)},BigNumber:function(i){return!i.isNegative()||a.predictable?i.log():new t(i.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(i){return be(i,this)}})}),yu="log2",Xg=["typed","config","Complex"],Yg=R(yu,Xg,e=>{var{typed:n,config:a,Complex:t}=e;return n(yu,{number:function(l){return l>=0||a.predictable?ns(l):r(new t(l,0))},Complex:r,BigNumber:function(l){return!l.isNegative()||a.predictable?l.log(2):r(new t(l.toNumber(),0))},"Array | Matrix":function(l){return be(l,this)}});function r(i){var l=Math.sqrt(i.re*i.re+i.im*i.im);return new t(Math.log2?Math.log2(l):Math.log(l)/Math.LN2,Math.atan2(i.im,i.re)/Math.LN2)}}),Wg="algorithm03",Jg=["typed"],Dr=R(Wg,Jg,e=>{var{typed:n}=e;return function(t,r,i,l){var m=t._data,f=t._size,c=t._datatype,s=r._values,o=r._index,u=r._ptr,p=r._size,v=r._datatype;if(f.length!==p.length)throw new Fe(f.length,p.length);if(f[0]!==p[0]||f[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+p+")");if(!s)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h=f[0],b=f[1],w,N=0,g=i;typeof c=="string"&&c===v&&(w=c,N=n.convert(0,w),g=n.find(i,[w,w]));for(var y=[],x=0;x<h;x++)y[x]=[];for(var d=[],A=[],S=0;S<b;S++){for(var O=S+1,M=u[S],_=u[S+1],E=M;E<_;E++){var $=o[E];d[$]=l?g(s[E],m[$][S]):g(m[$][S],s[E]),A[$]=O}for(var z=0;z<h;z++)A[z]===O?y[z][S]=d[z]:y[z][S]=l?g(N,m[z][S]):g(m[z][S],N)}return t.createDenseMatrix({data:y,size:[h,b],datatype:w})}}),Qg="algorithm05",Kg=["typed","equalScalar"],Ea=R(Qg,Kg,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=A?[]:void 0,_=A?[]:void 0,E=[],$=[],z,I,T,B;for(I=0;I<N;I++){O[I]=S.length;var G=I+1;for(T=c[I],B=c[I+1];T<B;T++)z=f[T],S.push(z),E[z]=G,M&&(M[z]=m[T]);for(T=v[I],B=v[I+1];T<B;T++)z=p[T],E[z]!==G&&S.push(z),$[z]=G,_&&(_[z]=u[T]);if(A)for(T=O[I];T<S.length;){z=S[T];var D=E[z],H=$[z];if(D===G||H===G){var W=D===G?M[z]:x,j=H===G?_[z]:x,V=d(W,j);y(V,x)?S.splice(T,1):(A.push(V),T++)}}}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),xu="mod",jg=["typed","matrix","equalScalar","DenseMatrix"],ey=R(xu,jg,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=rt({typed:n,equalScalar:t}),l=Dr({typed:n}),m=Ea({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=gr({typed:n,DenseMatrix:r}),s=je({typed:n}),o=Ge({typed:n});return n(xu,{"number, number":as,"BigNumber, BigNumber":function(p,v){if(v.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return v.isZero()?p:p.mod(v)},"Fraction, Fraction":function(p,v){if(v.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return p.compare(0)>=0?p.mod(v):p.mod(v).add(v).mod(v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,this,!1)},"SparseMatrix, DenseMatrix":function(p,v){return i(v,p,this,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,this,!1)},"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,this)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"SparseMatrix, any":function(p,v){return f(p,v,this,!1)},"DenseMatrix, any":function(p,v){return o(p,v,this,!1)},"any, SparseMatrix":function(p,v){return c(v,p,this,!0)},"any, DenseMatrix":function(p,v){return o(v,p,this,!0)},"Array, any":function(p,v){return o(a(p),v,this,!1).valueOf()},"any, Array":function(p,v){return o(a(v),p,this,!0).valueOf()}})}),ry="multiplyScalar",ty=["typed"],ny=R(ry,ty,e=>{var{typed:n}=e;return n("multiplyScalar",{"number, number":Yo,"Complex, Complex":function(t,r){return t.mul(r)},"BigNumber, BigNumber":function(t,r){return t.times(r)},"Fraction, Fraction":function(t,r){return t.mul(r)},"number | Fraction | BigNumber | Complex, Unit":function(t,r){var i=r.clone();return i.value=i.value===null?i._normalize(t):this(i.value,t),i},"Unit, number | Fraction | BigNumber | Complex":function(t,r){var i=t.clone();return i.value=i.value===null?i._normalize(r):this(i.value,r),i},"Unit, Unit":function(t,r){return t.multiply(r)}})}),bu="multiply",ay=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],iy=R(bu,ay,e=>{var{typed:n,matrix:a,addScalar:t,multiplyScalar:r,equalScalar:i,dot:l}=e,m=wr({typed:n,equalScalar:i}),f=Ge({typed:n});function c(x,d){switch(x.length){case 1:switch(d.length){case 1:if(x[0]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(x[0]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+x[0]+") must match Matrix rows ("+d[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+d.length+" dimensions)")}break;case 2:switch(d.length){case 1:if(x[1]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+x[1]+") must match Vector length ("+d[0]+")");break;case 2:if(x[1]!==d[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+x[1]+") must match Matrix B rows ("+d[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+d.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+x.length+" dimensions)")}}function s(x,d,A){if(A===0)throw new Error("Cannot multiply two empty vectors");return l(x,d)}function o(x,d){if(d.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return u(x,d)}function u(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._size,E=d._datatype,$=S[0],z=_[1],I,T=t,B=r;O&&E&&O===E&&typeof O=="string"&&(I=O,T=n.find(t,[I,I]),B=n.find(r,[I,I]));for(var G=[],D=0;D<z;D++){for(var H=B(A[0],M[0][D]),W=1;W<$;W++)H=T(H,B(A[W],M[W][D]));G[D]=H}return x.createDenseMatrix({data:G,size:[z],datatype:I})}var p=n("_multiplyMatrixVector",{"DenseMatrix, any":h,"SparseMatrix, any":N}),v=n("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":b,"DenseMatrix, SparseMatrix":w,"SparseMatrix, DenseMatrix":g,"SparseMatrix, SparseMatrix":y});function h(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._datatype,E=S[0],$=S[1],z,I=t,T=r;O&&_&&O===_&&typeof O=="string"&&(z=O,I=n.find(t,[z,z]),T=n.find(r,[z,z]));for(var B=[],G=0;G<E;G++){for(var D=A[G],H=T(D[0],M[0]),W=1;W<$;W++)H=I(H,T(D[W],M[W]));B[G]=H}return x.createDenseMatrix({data:B,size:[E],datatype:z})}function b(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._data,_=d._size,E=d._datatype,$=S[0],z=S[1],I=_[1],T,B=t,G=r;O&&E&&O===E&&typeof O=="string"&&(T=O,B=n.find(t,[T,T]),G=n.find(r,[T,T]));for(var D=[],H=0;H<$;H++){var W=A[H];D[H]=[];for(var j=0;j<I;j++){for(var V=G(W[0],M[0][j]),K=1;K<z;K++)V=B(V,G(W[K],M[K][j]));D[H][j]=V}}return x.createDenseMatrix({data:D,size:[$,I],datatype:T})}function w(x,d){var A=x._data,S=x._size,O=x._datatype,M=d._values,_=d._index,E=d._ptr,$=d._size,z=d._datatype;if(!M)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var I=S[0],T=$[1],B,G=t,D=r,H=i,W=0;O&&z&&O===z&&typeof O=="string"&&(B=O,G=n.find(t,[B,B]),D=n.find(r,[B,B]),H=n.find(i,[B,B]),W=n.convert(0,B));for(var j=[],V=[],K=[],te=d.createSparseMatrix({values:j,index:V,ptr:K,size:[I,T],datatype:B}),re=0;re<T;re++){K[re]=V.length;var ie=E[re],ne=E[re+1];if(ne>ie)for(var ue=0,ee=0;ee<I;ee++){for(var ye=ee+1,we=void 0,me=ie;me<ne;me++){var xe=_[me];ue!==ye?(we=D(A[ee][xe],M[me]),ue=ye):we=G(we,D(A[ee][xe],M[me]))}ue===ye&&!H(we,W)&&(V.push(ee),j.push(we))}}return K[T]=V.length,te}function N(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype;if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var _=d._data,E=d._datatype,$=x._size[0],z=d._size[0],I=[],T=[],B=[],G,D=t,H=r,W=i,j=0;M&&E&&M===E&&typeof M=="string"&&(G=M,D=n.find(t,[G,G]),H=n.find(r,[G,G]),W=n.find(i,[G,G]),j=n.convert(0,G));var V=[],K=[];B[0]=0;for(var te=0;te<z;te++){var re=_[te];if(!W(re,j))for(var ie=O[te],ne=O[te+1],ue=ie;ue<ne;ue++){var ee=S[ue];K[ee]?V[ee]=D(V[ee],H(re,A[ue])):(K[ee]=!0,T.push(ee),V[ee]=H(re,A[ue]))}}for(var ye=T.length,we=0;we<ye;we++){var me=T[we];I[we]=V[me]}return B[1]=T.length,x.createSparseMatrix({values:I,index:T,ptr:B,size:[$,1],datatype:G})}function g(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype;if(!A)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var _=d._data,E=d._datatype,$=x._size[0],z=d._size[0],I=d._size[1],T,B=t,G=r,D=i,H=0;M&&E&&M===E&&typeof M=="string"&&(T=M,B=n.find(t,[T,T]),G=n.find(r,[T,T]),D=n.find(i,[T,T]),H=n.convert(0,T));for(var W=[],j=[],V=[],K=x.createSparseMatrix({values:W,index:j,ptr:V,size:[$,I],datatype:T}),te=[],re=[],ie=0;ie<I;ie++){V[ie]=j.length;for(var ne=ie+1,ue=0;ue<z;ue++){var ee=_[ue][ie];if(!D(ee,H))for(var ye=O[ue],we=O[ue+1],me=ye;me<we;me++){var xe=S[me];re[xe]!==ne?(re[xe]=ne,j.push(xe),te[xe]=G(ee,A[me])):te[xe]=B(te[xe],G(ee,A[me]))}}for(var F=V[ie],Y=j.length,k=F;k<Y;k++){var U=j[k];W[k]=te[U]}}return V[I]=j.length,K}function y(x,d){var A=x._values,S=x._index,O=x._ptr,M=x._datatype,_=d._values,E=d._index,$=d._ptr,z=d._datatype,I=x._size[0],T=d._size[1],B=A&&_,G,D=t,H=r;M&&z&&M===z&&typeof M=="string"&&(G=M,D=n.find(t,[G,G]),H=n.find(r,[G,G]));for(var W=B?[]:void 0,j=[],V=[],K=x.createSparseMatrix({values:W,index:j,ptr:V,size:[I,T],datatype:G}),te=B?[]:void 0,re=[],ie,ne,ue,ee,ye,we,me,xe,F=0;F<T;F++){V[F]=j.length;var Y=F+1;for(ye=$[F],we=$[F+1],ee=ye;ee<we;ee++)if(xe=E[ee],B)for(ne=O[xe],ue=O[xe+1],ie=ne;ie<ue;ie++)me=S[ie],re[me]!==Y?(re[me]=Y,j.push(me),te[me]=H(_[ee],A[ie])):te[me]=D(te[me],H(_[ee],A[ie]));else for(ne=O[xe],ue=O[xe+1],ie=ne;ie<ue;ie++)me=S[ie],re[me]!==Y&&(re[me]=Y,j.push(me));if(B)for(var k=V[F],U=j.length,J=k;J<U;J++){var q=j[J];W[J]=te[q]}}return V[T]=j.length,K}return n(bu,Ka({"Array, Array":function(d,A){c(Pe(d),Pe(A));var S=this(a(d),a(A));return Oe(S)?S.valueOf():S},"Matrix, Matrix":function(d,A){var S=d.size(),O=A.size();return c(S,O),S.length===1?O.length===1?s(d,A,S[0]):o(d,A):O.length===1?p(d,A):v(d,A)},"Matrix, Array":function(d,A){return this(d,a(A))},"Array, Matrix":function(d,A){return this(a(d,A.storage()),A)},"SparseMatrix, any":function(d,A){return m(d,A,r,!1)},"DenseMatrix, any":function(d,A){return f(d,A,r,!1)},"any, SparseMatrix":function(d,A){return m(A,d,r,!0)},"any, DenseMatrix":function(d,A){return f(A,d,r,!0)},"Array, any":function(d,A){return f(a(d),A,r,!1).valueOf()},"any, Array":function(d,A){return f(a(A),d,r,!0).valueOf()},"any, any":r,"any, any, ...any":function(d,A,S){for(var O=this(d,A),M=0;M<S.length;M++)O=this(O,S[M]);return O}},r.signatures))}),wu="nthRoot",oy=["typed","matrix","equalScalar","BigNumber"],sy=R(wu,oy,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r}=e,i=qt({typed:n}),l=rt({typed:n,equalScalar:t}),m=Sa({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=je({typed:n}),s=Ge({typed:n}),o="Complex number not supported in function nthRoot. Use nthRoots instead.";return n(wu,{number:is,"number, number":is,BigNumber:function(v){return u(v,new r(2))},Complex:function(v){throw new Error(o)},"Complex, number":function(v,h){throw new Error(o)},"BigNumber, BigNumber":u,"Array | Matrix":function(v){return this(v,2)},"SparseMatrix, SparseMatrix":function(v,h){if(h.density()===1)return m(v,h,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){if(h.density()===1)return i(v,h,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(v,h){return c(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return f(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return s(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){if(h.density()===1)return f(h,v,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(v,h){return s(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}});function u(p,v){var h=r.precision,b=r.clone({precision:h+2}),w=new r(0),N=new b(1),g=v.isNegative();if(g&&(v=v.neg()),v.isZero())throw new Error("Root must be non-zero");if(p.isNegative()&&!v.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(p.isZero())return g?new b(1/0):0;if(!p.isFinite())return g?w:p;var y=p.abs().pow(N.div(v));return y=p.isNeg()?y.neg():y,new r((g?N.div(y):y).toPrecision(h))}}),Nu="sign",uy=["typed","BigNumber","Fraction","complex"],cy=R(Nu,uy,e=>{var{typed:n,BigNumber:a,complex:t,Fraction:r}=e;return n(Nu,{number:di,Complex:function(l){return l.im===0?t(di(l.re)):l.sign()},BigNumber:function(l){return new a(l.cmp(0))},Fraction:function(l){return new r(l.s,1)},"Array | Matrix":function(l){return be(l,this)},Unit:function(l){if(!l._isDerived()&&l.units[0].unit.offset!==0)throw new TypeError("sign is ambiguous for units with offset");return this(l.value)}})}),fy="sqrt",ly=["config","typed","Complex"],my=R(fy,ly,e=>{var{config:n,typed:a,Complex:t}=e;return a("sqrt",{number:r,Complex:function(l){return l.sqrt()},BigNumber:function(l){return!l.isNegative()||n.predictable?l.sqrt():r(l.toNumber())},"Array | Matrix":function(l){return be(l,this)},Unit:function(l){return l.pow(.5)}});function r(i){return isNaN(i)?NaN:i>=0||n.predictable?Math.sqrt(i):new t(i,0).sqrt()}}),Mu="square",py=["typed"],vy=R(Mu,py,e=>{var{typed:n}=e;return n(Mu,{number:os,Complex:function(t){return t.mul(t)},BigNumber:function(t){return t.times(t)},Fraction:function(t){return t.mul(t)},"Array | Matrix":function(t){return be(t,this)},Unit:function(t){return t.pow(2)}})}),Au="subtract",hy=["typed","matrix","equalScalar","addScalar","unaryMinus","DenseMatrix"],dy=R(Au,hy,e=>{var{typed:n,matrix:a,equalScalar:t,addScalar:r,unaryMinus:i,DenseMatrix:l}=e,m=qt({typed:n}),f=Dr({typed:n}),c=Ea({typed:n,equalScalar:t}),s=Vt({typed:n,DenseMatrix:l}),o=je({typed:n}),u=Ge({typed:n});return n(Au,{"number, number":function(v,h){return v-h},"Complex, Complex":function(v,h){return v.sub(h)},"BigNumber, BigNumber":function(v,h){return v.minus(h)},"Fraction, Fraction":function(v,h){return v.sub(h)},"Unit, Unit":function(v,h){if(v.value===null)throw new Error("Parameter x contains a unit with undefined value");if(h.value===null)throw new Error("Parameter y contains a unit with undefined value");if(!v.equalBase(h))throw new Error("Units do not match");var b=v.clone();return b.value=this(b.value,h.value),b.fixPrefix=!1,b},"SparseMatrix, SparseMatrix":function(v,h){return Ca(v,h),c(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return Ca(v,h),f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return Ca(v,h),m(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return Ca(v,h),o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, any":function(v,h){return s(v,i(h),r)},"DenseMatrix, any":function(v,h){return u(v,h,this)},"any, SparseMatrix":function(v,h){return s(h,v,this,!0)},"any, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, any":function(v,h){return u(a(v),h,this,!1).valueOf()},"any, Array":function(v,h){return u(a(h),v,this,!0).valueOf()}})});function Ca(e,n){var a=e.size(),t=n.size();if(a.length!==t.length)throw new Fe(a.length,t.length)}var Su="xgcd",gy=["typed","config","matrix","BigNumber"],yy=R(Su,gy,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n(Su,{"number, number":function(m,f){var c=ss(m,f);return a.matrix==="Array"?c:t(c)},"BigNumber, BigNumber":i});function i(l,m){var f,c,s,o=new r(0),u=new r(1),p=o,v=u,h=u,b=o;if(!l.isInt()||!m.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!m.isZero();)c=l.div(m).floor(),s=l.mod(m),f=p,p=v.minus(c.times(p)),v=f,f=h,h=b.minus(c.times(h)),b=f,l=m,m=s;var w;return l.lt(o)?w=[l.neg(),v.neg(),b.neg()]:w=[l,l.isZero()?0:v,b],a.matrix==="Array"?w:t(w)}}),Eu="invmod",xy=["typed","config","BigNumber","xgcd","equal","smaller","mod","add","isInteger"],by=R(Eu,xy,e=>{var{typed:n,config:a,BigNumber:t,xgcd:r,equal:i,smaller:l,mod:m,add:f,isInteger:c}=e;return n(Eu,{"number, number":s,"BigNumber, BigNumber":s});function s(o,u){if(!c(o)||!c(u))throw new Error("Parameters in function invmod must be integer numbers");if(o=m(o,u),i(u,0))throw new Error("Divisor must be non zero");var p=r(o,u);p=p.valueOf();var[v,h]=p;return i(v,t(1))?(h=m(h,u),l(h,t(0))&&(h=f(h,u)),h):NaN}}),wy="algorithm09",Ny=["typed","equalScalar"],Cu=R(wy,Ny,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));var A=m&&u?[]:void 0,S=[],O=[],M=A?[]:void 0,_=[],E,$,z,I,T;for($=0;$<N;$++){O[$]=S.length;var B=$+1;if(M)for(I=v[$],T=v[$+1],z=I;z<T;z++)E=p[z],_[E]=B,M[E]=u[z];for(I=c[$],T=c[$+1],z=I;z<T;z++)if(E=f[z],M){var G=_[E]===B?M[E]:x,D=d(m[z],G);y(D,x)||(S.push(E),A.push(D))}else S.push(E)}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Ou="dotMultiply",My=["typed","matrix","equalScalar","multiplyScalar"],Ay=R(Ou,My,e=>{var{typed:n,matrix:a,equalScalar:t,multiplyScalar:r}=e,i=rt({typed:n,equalScalar:t}),l=Cu({typed:n,equalScalar:t}),m=wr({typed:n,equalScalar:t}),f=je({typed:n}),c=Ge({typed:n});return n(Ou,{"any, any":r,"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,r,!1)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,r,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,r,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,r)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,r,!1)},"DenseMatrix, any":function(o,u){return c(o,u,r,!1)},"any, SparseMatrix":function(o,u){return m(u,o,r,!0)},"any, DenseMatrix":function(o,u){return c(u,o,r,!0)},"Array, any":function(o,u){return c(a(o),u,r,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,r,!0).valueOf()}})});function Sy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitAnd");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);if(e.isZero()||n.eq(-1)||e.eq(n))return e;if(n.isZero()||e.eq(-1))return n;if(!e.isFinite()||!n.isFinite()){if(!e.isFinite()&&!n.isFinite())return e.isNegative()===n.isNegative()?e:new a(0);if(!e.isFinite())return n.isNegative()?e:e.isNegative()?new a(0):n;if(!n.isFinite())return e.isNegative()?n:n.isNegative()?new a(0):e}return Mi(e,n,function(t,r){return t&r})}function In(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var n=e.constructor,a=n.precision;n.config({precision:1e9});var t=e.plus(new n(1));return t.s=-t.s||null,n.config({precision:a}),t}function Ey(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitOr");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);var t=new a(-1);return e.isZero()||n.eq(t)||e.eq(n)?n:n.isZero()||e.eq(t)?e:!e.isFinite()||!n.isFinite()?!e.isFinite()&&!e.isNegative()&&n.isNegative()||e.isNegative()&&!n.isNegative()&&!n.isFinite()?t:e.isNegative()&&n.isNegative()?e.isFinite()?e:n:e.isFinite()?n:e:Mi(e,n,function(r,i){return r|i})}function Mi(e,n,a){var t=e.constructor,r,i,l=+(e.s<0),m=+(n.s<0);if(l){r=Oa(In(e));for(var f=0;f<r.length;++f)r[f]^=1}else r=Oa(e);if(m){i=Oa(In(n));for(var c=0;c<i.length;++c)i[c]^=1}else i=Oa(n);var s,o,u;r.length<=i.length?(s=r,o=i,u=l):(s=i,o=r,u=m);var p=s.length,v=o.length,h=a(l,m)^1,b=new t(h^1),w=new t(1),N=new t(2),g=t.precision;for(t.config({precision:1e9});p>0;)a(s[--p],o[--v])===h&&(b=b.plus(w)),w=w.times(N);for(;v>0;)a(u,o[--v])===h&&(b=b.plus(w)),w=w.times(N);return t.config({precision:g}),h===0&&(b.s=-b.s),b}function Oa(e){for(var n=e.d,a=n[0]+"",t=1;t<n.length;++t){for(var r=n[t]+"",i=7-r.length;i--;)r="0"+r;a+=r}for(var l=a.length;a.charAt(l)==="0";)l--;var m=e.e,f=a.slice(0,l+1||1),c=f.length;if(m>0)if(++m>c)for(m-=c;m--;)f+="0";else m<c&&(f=f.slice(0,m)+"."+f.slice(m));for(var s=[0],o=0;o<f.length;){for(var u=s.length;u--;)s[u]*=10;s[0]+=parseInt(f.charAt(o++));for(var p=0;p<s.length;++p)s[p]>1&&((s[p+1]===null||s[p+1]===void 0)&&(s[p+1]=0),s[p+1]+=s[p]>>1,s[p]&=1)}return s.reverse()}function Cy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function bitXor");var a=e.constructor;if(e.isNaN()||n.isNaN())return new a(NaN);if(e.isZero())return n;if(n.isZero())return e;if(e.eq(n))return new a(0);var t=new a(-1);return e.eq(t)?In(n):n.eq(t)?In(e):!e.isFinite()||!n.isFinite()?!e.isFinite()&&!n.isFinite()?t:new a(e.isNegative()===n.isNegative()?1/0:-1/0):Mi(e,n,function(r,i){return r^i})}function Oy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function leftShift");var a=e.constructor;return e.isNaN()||n.isNaN()||n.isNegative()&&!n.isZero()?new a(NaN):e.isZero()||n.isZero()?e:!e.isFinite()&&!n.isFinite()?new a(NaN):n.lt(55)?e.times(Math.pow(2,n.toNumber())+""):e.times(new a(2).pow(n))}function Dy(e,n){if(e.isFinite()&&!e.isInteger()||n.isFinite()&&!n.isInteger())throw new Error("Integers expected in function rightArithShift");var a=e.constructor;return e.isNaN()||n.isNaN()||n.isNegative()&&!n.isZero()?new a(NaN):e.isZero()||n.isZero()?e:n.isFinite()?n.lt(55)?e.div(Math.pow(2,n.toNumber())+"").floor():e.div(new a(2).pow(n)).floor():e.isNegative()?new a(-1):e.isFinite()?new a(0):new a(NaN)}var Du="bitAnd",Ty=["typed","matrix","equalScalar"],By=R(Du,Ty,e=>{var{typed:n,matrix:a,equalScalar:t}=e,r=rt({typed:n,equalScalar:t}),i=Sa({typed:n,equalScalar:t}),l=wr({typed:n,equalScalar:t}),m=je({typed:n}),f=Ge({typed:n});return n(Du,{"number, number":fs,"BigNumber, BigNumber":Sy,"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this,!1)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),Tu="bitNot",_y=["typed"],$y=R(Tu,_y,e=>{var{typed:n}=e;return n(Tu,{number:ls,BigNumber:In,"Array | Matrix":function(t){return be(t,this)}})}),Bu="bitOr",Iy=["typed","matrix","equalScalar","DenseMatrix"],qy=R(Bu,Iy,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=qt({typed:n}),l=Ni({typed:n,equalScalar:t}),m=Vt({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Bu,{"number, number":ms,"BigNumber, BigNumber":Ey,"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Ry="algorithm07",Fy=["typed","DenseMatrix"],ut=R(Ry,Fy,e=>{var{typed:n,DenseMatrix:a}=e;return function(i,l,m){var f=i._size,c=i._datatype,s=l._size,o=l._datatype;if(f.length!==s.length)throw new Fe(f.length,s.length);if(f[0]!==s[0]||f[1]!==s[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+s+")");var u=f[0],p=f[1],v,h=0,b=m;typeof c=="string"&&c===o&&(v=c,h=n.convert(0,v),b=n.find(m,[v,v]));var w,N,g=[];for(w=0;w<u;w++)g[w]=[];var y=[],x=[],d=[],A=[];for(N=0;N<p;N++){var S=N+1;for(t(i,N,d,y,S),t(l,N,A,x,S),w=0;w<u;w++){var O=d[w]===S?y[w]:h,M=A[w]===S?x[w]:h;g[w][N]=b(O,M)}}return new a({data:g,size:[u,p],datatype:v})};function t(r,i,l,m,f){for(var c=r._values,s=r._index,o=r._ptr,u=o[i],p=o[i+1];u<p;u++){var v=s[u];l[v]=f,m[v]=c[u]}}}),_u="bitXor",zy=["typed","matrix","DenseMatrix"],Py=R(_u,zy,e=>{var{typed:n,matrix:a,DenseMatrix:t}=e,r=Dr({typed:n}),i=ut({typed:n,DenseMatrix:t}),l=gr({typed:n,DenseMatrix:t}),m=je({typed:n}),f=Ge({typed:n});return n(_u,{"number, number":ps,"BigNumber, BigNumber":Cy,"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),$u="arg",Uy=["typed"],Ly=R($u,Uy,e=>{var{typed:n}=e;return n($u,{number:function(t){return Math.atan2(0,t)},BigNumber:function(t){return t.constructor.atan2(0,t)},Complex:function(t){return t.arg()},"Array | Matrix":function(t){return be(t,this)}})}),Iu="conj",ky=["typed"],Hy=R(Iu,ky,e=>{var{typed:n}=e;return n(Iu,{number:function(t){return t},BigNumber:function(t){return t},Complex:function(t){return t.conjugate()},"Array | Matrix":function(t){return be(t,this)}})}),qu="im",Gy=["typed"],Vy=R(qu,Gy,e=>{var{typed:n}=e;return n(qu,{number:function(t){return 0},BigNumber:function(t){return t.mul(0)},Fraction:function(t){return t.mul(0)},Complex:function(t){return t.im},"Array | Matrix":function(t){return be(t,this)}})}),Ru="re",Zy=["typed"],Xy=R(Ru,Zy,e=>{var{typed:n}=e;return n(Ru,{number:function(t){return t},BigNumber:function(t){return t},Fraction:function(t){return t},Complex:function(t){return t.re},"Array | Matrix":function(t){return be(t,this)}})}),Fu="not",Yy=["typed"],Wy=R(Fu,Yy,e=>{var{typed:n}=e;return n(Fu,{number:ys,Complex:function(t){return t.re===0&&t.im===0},BigNumber:function(t){return t.isZero()||t.isNaN()},Unit:function(t){return t.value!==null?this(t.value):!0},"Array | Matrix":function(t){return be(t,this)}})}),zu="or",Jy=["typed","matrix","equalScalar","DenseMatrix"],Qy=R(zu,Jy,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=Ea({typed:n,equalScalar:t}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(zu,{"number, number":xs,"Complex, Complex":function(o,u){return o.re!==0||o.im!==0||u.re!==0||u.im!==0},"BigNumber, BigNumber":function(o,u){return!o.isZero()&&!o.isNaN()||!u.isZero()&&!u.isNaN()},"Unit, Unit":function(o,u){return this(o.value||0,u.value||0)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(a(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Pu="xor",Ky=["typed","matrix","DenseMatrix"],jy=R(Pu,Ky,e=>{var{typed:n,matrix:a,DenseMatrix:t}=e,r=Dr({typed:n}),i=ut({typed:n,DenseMatrix:t}),l=gr({typed:n,DenseMatrix:t}),m=je({typed:n}),f=Ge({typed:n});return n(Pu,{"number, number":bs,"Complex, Complex":function(s,o){return(s.re!==0||s.im!==0)!=(o.re!==0||o.im!==0)},"BigNumber, BigNumber":function(s,o){return(!s.isZero()&&!s.isNaN())!=(!o.isZero()&&!o.isNaN())},"Unit, Unit":function(s,o){return this(s.value||0,o.value||0)},"SparseMatrix, SparseMatrix":function(s,o){return i(s,o,this)},"SparseMatrix, DenseMatrix":function(s,o){return r(o,s,this,!0)},"DenseMatrix, SparseMatrix":function(s,o){return r(s,o,this,!1)},"DenseMatrix, DenseMatrix":function(s,o){return m(s,o,this)},"Array, Array":function(s,o){return this(a(s),a(o)).valueOf()},"Array, Matrix":function(s,o){return this(a(s),o)},"Matrix, Array":function(s,o){return this(s,a(o))},"SparseMatrix, any":function(s,o){return l(s,o,this,!1)},"DenseMatrix, any":function(s,o){return f(s,o,this,!1)},"any, SparseMatrix":function(s,o){return l(o,s,this,!0)},"any, DenseMatrix":function(s,o){return f(o,s,this,!0)},"Array, any":function(s,o){return f(a(s),o,this,!1).valueOf()},"any, Array":function(s,o){return f(a(o),s,this,!0).valueOf()}})}),Uu="concat",e0=["typed","matrix","isInteger"],Lu=R(Uu,e0,e=>{var{typed:n,matrix:a,isInteger:t}=e;return n(Uu,{"...Array | Matrix | number | BigNumber":function(i){var l,m=i.length,f=-1,c,s=!1,o=[];for(l=0;l<m;l++){var u=i[l];if(Oe(u)&&(s=!0),Be(u)||_e(u)){if(l!==m-1)throw new Error("Dimension must be specified as last argument");if(c=f,f=u.valueOf(),!t(f))throw new TypeError("Integer number expected for dimension");if(f<0||l>0&&f>c)throw new Kr(f,c+1)}else{var p=Ce(u).valueOf(),v=Pe(p);if(o[l]=p,c=f,f=v.length-1,l>0&&f!==c)throw new Fe(c+1,f+1)}}if(o.length===0)throw new SyntaxError("At least one matrix expected");for(var h=o.shift();o.length;)h=ku(h,o.shift(),f,0);return s?a(h):h},"...string":function(i){return i.join("")}})});function ku(e,n,a,t){if(t<a){if(e.length!==n.length)throw new Fe(e.length,n.length);for(var r=[],i=0;i<e.length;i++)r[i]=ku(e[i],n[i],a,t+1);return r}else return e.concat(n)}var Hu="column",r0=["typed","Index","matrix","range"],Gu=R(Hu,r0,e=>{var{typed:n,Index:a,matrix:t,range:r}=e;return n(Hu,{"Matrix, number":i,"Array, number":function(m,f){return i(t(Ce(m)),f).valueOf()}});function i(l,m){if(l.size().length!==2)throw new Error("Only two dimensional matrix is supported");We(m,l.size()[1]);var f=r(0,l.size()[0]),c=new a(f,m);return l.subset(c)}}),Vu="count",t0=["typed","size","prod"],n0=R(Vu,t0,e=>{var{typed:n,size:a,prod:t}=e;return n(Vu,{string:function(i){return i.length},"Matrix | Array":function(i){return t(a(i))}})}),Zu="cross",a0=["typed","matrix","subtract","multiply"],i0=R(Zu,a0,e=>{var{typed:n,matrix:a,subtract:t,multiply:r}=e;return n(Zu,{"Matrix, Matrix":function(m,f){return a(i(m.toArray(),f.toArray()))},"Matrix, Array":function(m,f){return a(i(m.toArray(),f))},"Array, Matrix":function(m,f){return a(i(m,f.toArray()))},"Array, Array":i});function i(l,m){var f=Math.max(Pe(l).length,Pe(m).length);l=aa(l),m=aa(m);var c=Pe(l),s=Pe(m);if(c.length!==1||s.length!==1||c[0]!==3||s[0]!==3)throw new RangeError("Vectors with length 3 expected (Size A = ["+c.join(", ")+"], B = ["+s.join(", ")+"])");var o=[t(r(l[1],m[2]),r(l[2],m[1])),t(r(l[2],m[0]),r(l[0],m[2])),t(r(l[0],m[1]),r(l[1],m[0]))];return f>1?[o]:o}}),Xu="diag",o0=["typed","matrix","DenseMatrix","SparseMatrix"],s0=R(Xu,o0,e=>{var{typed:n,matrix:a,DenseMatrix:t,SparseMatrix:r}=e;return n(Xu,{Array:function(c){return i(c,0,Pe(c),null)},"Array, number":function(c,s){return i(c,s,Pe(c),null)},"Array, BigNumber":function(c,s){return i(c,s.toNumber(),Pe(c),null)},"Array, string":function(c,s){return i(c,0,Pe(c),s)},"Array, number, string":function(c,s,o){return i(c,s,Pe(c),o)},"Array, BigNumber, string":function(c,s,o){return i(c,s.toNumber(),Pe(c),o)},Matrix:function(c){return i(c,0,c.size(),c.storage())},"Matrix, number":function(c,s){return i(c,s,c.size(),c.storage())},"Matrix, BigNumber":function(c,s){return i(c,s.toNumber(),c.size(),c.storage())},"Matrix, string":function(c,s){return i(c,0,c.size(),s)},"Matrix, number, string":function(c,s,o){return i(c,s,c.size(),o)},"Matrix, BigNumber, string":function(c,s,o){return i(c,s.toNumber(),c.size(),o)}});function i(f,c,s,o){if(!Ae(c))throw new TypeError("Second parameter in function diag must be an integer");var u=c>0?c:0,p=c<0?-c:0;switch(s.length){case 1:return l(f,c,o,s[0],p,u);case 2:return m(f,c,o,s,p,u)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function l(f,c,s,o,u,p){var v=[o+u,o+p];if(s&&s!=="sparse"&&s!=="dense")throw new TypeError("Unknown matrix type ".concat(s,'"'));var h=s==="sparse"?r.diagonal(v,f,c):t.diagonal(v,f,c);return s!==null?h:h.valueOf()}function m(f,c,s,o,u,p){if(Oe(f)){var v=f.diagonal(c);return s!==null?s!==v.storage()?a(v,s):v:v.valueOf()}for(var h=Math.min(o[0]-u,o[1]-p),b=[],w=0;w<h;w++)b[w]=f[w+u][w+p];return s!==null?a(b):b}});function u0(e){var n=0,a=1,t=Object.create(null),r=Object.create(null),i=0,l=function(f){var c=r[f];if(c&&(delete t[c],delete r[f],--n,a===c)){if(!n){i=0,a=1;return}for(;!hasOwnProperty.call(t,++a););}};return e=Math.abs(e),{hit:function(f){var c=r[f],s=++i;if(t[s]=f,r[f]=s,!c)return++n,n<=e?void 0:(f=t[a],l(f),f);if(delete t[c],a===c)for(;!hasOwnProperty.call(t,++a););},delete:l,clear:function(){n=i=0,a=1,t=Object.create(null),r=Object.create(null)}}}function qn(e){var{hasher:n,limit:a}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return a=a==null?Number.POSITIVE_INFINITY:a,n=n==null?JSON.stringify:n,function t(){typeof t.cache!="object"&&(t.cache={values:new Map,lru:u0(a||Number.POSITIVE_INFINITY)});for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var l=n(r);if(t.cache.values.has(l))return t.cache.lru.hit(l),t.cache.values.get(l);var m=e.apply(e,r);return t.cache.values.set(l,m),t.cache.values.delete(t.cache.lru.hit(l)),m}}function hn(e){return Object.keys(e.signatures||{}).reduce(function(n,a){var t=(a.match(/,/g)||[]).length+1;return Math.max(n,t)},-1)}var c0="filter",f0=["typed"],l0=R(c0,f0,e=>{var{typed:n}=e;return n("filter",{"Array, function":Yu,"Matrix, function":function(t,r){return t.create(Yu(t.toArray(),r))},"Array, RegExp":oa,"Matrix, RegExp":function(t,r){return t.create(oa(t.toArray(),r))}})});function Yu(e,n){var a=hn(n);return wo(e,function(t,r,i){return a===1?n(t):a===2?n(t,[r]):n(t,[r],i)})}var Wu="flatten",m0=["typed","matrix"],p0=R(Wu,m0,e=>{var{typed:n,matrix:a}=e;return n(Wu,{Array:function(r){return Le(Ce(r))},Matrix:function(r){var i=Le(Ce(r.toArray()));return a(i)}})}),Ju="forEach",v0=["typed"],h0=R(Ju,v0,e=>{var{typed:n}=e;return n(Ju,{"Array, function":d0,"Matrix, function":function(t,r){return t.forEach(r)}})});function d0(e,n){var a=hn(n),t=function r(i,l){Array.isArray(i)?ia(i,function(m,f){r(m,l.concat(f))}):a===1?n(i):a===2?n(i,l):n(i,l,e)};t(e,[])}var Qu="getMatrixDataType",g0=["typed"],y0=R(Qu,g0,e=>{var{typed:n}=e;return n(Qu,{Array:function(t){return Bn(t,Ke)},Matrix:function(t){return t.getDataType()}})}),Ku="identity",x0=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],b0=R(Ku,x0,e=>{var{typed:n,config:a,matrix:t,BigNumber:r,DenseMatrix:i,SparseMatrix:l}=e;return n(Ku,{"":function(){return a.matrix==="Matrix"?t([]):[]},string:function(s){return t(s)},"number | BigNumber":function(s){return f(s,s,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(s,o){return f(s,s,o)},"number | BigNumber, number | BigNumber":function(s,o){return f(s,o,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(s,o,u){return f(s,o,u)},Array:function(s){return m(s)},"Array, string":function(s,o){return m(s,o)},Matrix:function(s){return m(s.valueOf(),s.storage())},"Matrix, string":function(s,o){return m(s.valueOf(),o)}});function m(c,s){switch(c.length){case 0:return s?t(s):[];case 1:return f(c[0],c[0],s);case 2:return f(c[0],c[1],s);default:throw new Error("Vector containing two values expected")}}function f(c,s,o){var u=_e(c)||_e(s)?r:null;if(_e(c)&&(c=c.toNumber()),_e(s)&&(s=s.toNumber()),!Ae(c)||c<1)throw new Error("Parameters in function identity must be positive integers");if(!Ae(s)||s<1)throw new Error("Parameters in function identity must be positive integers");var p=u?new r(1):1,v=u?new u(0):0,h=[c,s];if(o){if(o==="sparse")return l.diagonal(h,p,0,v);if(o==="dense")return i.diagonal(h,p,0,v);throw new TypeError('Unknown matrix type "'.concat(o,'"'))}for(var b=on([],h,v),w=c<s?c:s,N=0;N<w;N++)b[N][N]=p;return b}}),ju="kron",w0=["typed","matrix","multiplyScalar"],N0=R(ju,w0,e=>{var{typed:n,matrix:a,multiplyScalar:t}=e;return n(ju,{"Matrix, Matrix":function(l,m){return a(r(l.toArray(),m.toArray()))},"Matrix, Array":function(l,m){return a(r(l.toArray(),m))},"Array, Matrix":function(l,m){return a(r(l,m.toArray()))},"Array, Array":r});function r(i,l){if(Pe(i).length===1&&(i=[i]),Pe(l).length===1&&(l=[l]),Pe(i).length>2||Pe(l).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(i.length)+", y = "+JSON.stringify(l.length)+")");var m=[],f=[];return i.map(function(c){return l.map(function(s){return f=[],m.push(f),c.map(function(o){return s.map(function(u){return f.push(t(o,u))})})})})&&m}}),ec="map",M0=["typed"],A0=R(ec,M0,e=>{var{typed:n}=e;return n(ec,{"Array, function":S0,"Matrix, function":function(t,r){return t.map(r)}})});function S0(e,n){var a=hn(n),t=function r(i,l){if(Array.isArray(i))return i.map(function(c,s){return r(c,l.concat(s))});try{return a===1?n(i):a===2?n(i,l):n(i,l,e)}catch(c){if(c instanceof TypeError&&"data"in c&&c.data.category==="wrongType"){var m="map attempted to call '".concat(c.data.fn,"(").concat(i),f=JSON.stringify(l);throw a===2?m+=","+f:a!==1&&(m+=",".concat(f,",").concat(e)),m+=")' but argument ".concat(c.data.index+1," of type "),m+="".concat(c.data.actual," does not match expected type "),m+=c.data.expected.join(" or "),new TypeError(m)}throw c}};return t(e,[])}var rc="diff",E0=["typed","matrix","subtract","number"],tc=R(rc,E0,e=>{var{typed:n,matrix:a,subtract:t,number:r}=e;return n(rc,{"Array | Matrix":function(s){return Oe(s)?a(l(s.toArray())):l(s)},"Array | Matrix, number":function(s,o){if(!Ae(o))throw new RangeError("Dimension must be a whole number");return Oe(s)?a(i(s.toArray(),o)):i(s,o)},"Array | Matrix, BigNumber":function(s,o){return this(s,r(o))}});function i(c,s){if(Oe(c)&&(c=c.toArray()),!Array.isArray(c))throw RangeError("Array/Matrix does not have that many dimensions");if(s>0){var o=[];return c.forEach(u=>{o.push(i(u,s-1))}),o}else{if(s===0)return l(c);throw RangeError("Cannot have negative dimension")}}function l(c){var s=[],o=c.length;if(o<2)return c;for(var u=1;u<o;u++)s.push(m(c[u-1],c[u]));return s}function m(c,s){Oe(c)&&(c=c.toArray()),Oe(s)&&(s=s.toArray());var o=Array.isArray(c),u=Array.isArray(s);if(o&&u)return f(c,s);if(!o&&!u)return t(s,c);throw TypeError("Cannot calculate difference between 1 array and 1 non-array")}function f(c,s){if(c.length!==s.length)throw RangeError("Not all sub-arrays have the same length");for(var o=[],u=c.length,p=0;p<u;p++)o.push(m(c[p],s[p]));return o}}),C0="ones",O0=["typed","config","matrix","BigNumber"],D0=R(C0,O0,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n("ones",{"":function(){return a.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(c){var s=c[c.length-1];if(typeof s=="string"){var o=c.pop();return i(c,o)}else return a.matrix==="Array"?i(c):i(c,"default")},Array:i,Matrix:function(c){var s=c.storage();return i(c.valueOf(),s)},"Array | Matrix, string":function(c,s){return i(c.valueOf(),s)}});function i(f,c){var s=l(f),o=s?new r(1):1;if(m(f),c){var u=t(c);return f.length>0?u.resize(f,o):u}else{var p=[];return f.length>0?on(p,f,o):p}}function l(f){var c=!1;return f.forEach(function(s,o,u){_e(s)&&(c=!0,u[o]=s.toNumber())}),c}function m(f){f.forEach(function(c){if(typeof c!="number"||!Ae(c)||c<0)throw new Error("Parameters in function ones must be positive integers")})}});function Ai(){throw new Error('No "bignumber" implementation available')}function nc(){throw new Error('No "fraction" implementation available')}function ac(){throw new Error('No "matrix" implementation available')}var ic="range",T0=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],oc=R(ic,T0,e=>{var{typed:n,config:a,matrix:t,bignumber:r,smaller:i,smallerEq:l,larger:m,largerEq:f}=e;return n(ic,{string:s,"string, boolean":s,"number, number":function(w,N){return c(o(w,N,1))},"number, number, number":function(w,N,g){return c(o(w,N,g))},"number, number, boolean":function(w,N,g){return c(g?u(w,N,1):o(w,N,1))},"number, number, number, boolean":function(w,N,g,y){return c(y?u(w,N,g):o(w,N,g))},"BigNumber, BigNumber":function(w,N){var g=w.constructor;return c(p(w,N,new g(1)))},"BigNumber, BigNumber, BigNumber":function(w,N,g){return c(p(w,N,g))},"BigNumber, BigNumber, boolean":function(w,N,g){var y=w.constructor;return c(g?v(w,N,new y(1)):p(w,N,new y(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(w,N,g,y){return c(y?v(w,N,g):p(w,N,g))}});function c(b){return a.matrix==="Matrix"?t?t(b):ac():b}function s(b,w){var N=h(b);if(!N)throw new SyntaxError('String "'+b+'" is no valid range');var g;return a.number==="BigNumber"?(r===void 0&&Ai(),g=w?v:p,c(g(r(N.start),r(N.end),r(N.step)))):(g=w?u:o,c(g(N.start,N.end,N.step)))}function o(b,w,N){var g=[],y=b;if(N>0)for(;i(y,w);)g.push(y),y+=N;else if(N<0)for(;m(y,w);)g.push(y),y+=N;return g}function u(b,w,N){var g=[],y=b;if(N>0)for(;l(y,w);)g.push(y),y+=N;else if(N<0)for(;f(y,w);)g.push(y),y+=N;return g}function p(b,w,N){var g=r(0),y=[],x=b;if(N.gt(g))for(;i(x,w);)y.push(x),x=x.plus(N);else if(N.lt(g))for(;m(x,w);)y.push(x),x=x.plus(N);return y}function v(b,w,N){var g=r(0),y=[],x=b;if(N.gt(g))for(;l(x,w);)y.push(x),x=x.plus(N);else if(N.lt(g))for(;f(x,w);)y.push(x),x=x.plus(N);return y}function h(b){var w=b.split(":"),N=w.map(function(y){return Number(y)}),g=N.some(function(y){return isNaN(y)});if(g)return null;switch(N.length){case 2:return{start:N[0],end:N[1],step:1};case 3:return{start:N[0],end:N[2],step:N[1]};default:return null}}}),sc="reshape",B0=["typed","isInteger","matrix"],_0=R(sc,B0,e=>{var{typed:n,isInteger:a}=e;return n(sc,{"Matrix, Array":function(r,i){return r.reshape(i)},"Array, Array":function(r,i){return i.forEach(function(l){if(!a(l))throw new TypeError("Invalid size for dimension: "+l)}),ho(r,i)}})});function dn(e,n,a,t){if(!(this instanceof dn))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=n,this.min=a,this.max=t,this.message="Wrong number of arguments in function "+e+" ("+n+" provided, "+a+(t!=null?"-"+t:"")+" expected)",this.stack=new Error().stack}dn.prototype=new Error,dn.prototype.constructor=Error,dn.prototype.name="ArgumentsError",dn.prototype.isArgumentsError=!0;var $0="resize",I0=["config","matrix"],q0=R($0,I0,e=>{var{config:n,matrix:a}=e;return function(i,l,m){if(arguments.length!==2&&arguments.length!==3)throw new dn("resize",arguments.length,2,3);if(Oe(l)&&(l=l.valueOf()),_e(l[0])&&(l=l.map(function(s){return _e(s)?s.toNumber():s})),Oe(i))return i.resize(l,m,!0);if(typeof i=="string")return t(i,l,m);var f=Array.isArray(i)?!1:n.matrix!=="Array";if(l.length===0){for(;Array.isArray(i);)i=i[0];return Ce(i)}else{Array.isArray(i)||(i=[i]),i=Ce(i);var c=on(i,l,m);return f?a(c):c}};function t(r,i,l){if(l!==void 0){if(typeof l!="string"||l.length!==1)throw new TypeError("Single character expected as defaultValue")}else l=" ";if(i.length!==1)throw new Fe(i.length,1);var m=i[0];if(typeof m!="number"||!Ae(m))throw new TypeError("Invalid size, must contain positive integers (size: "+Re(i)+")");if(r.length>m)return r.substring(0,m);if(r.length<m){for(var f=r,c=0,s=m-r.length;c<s;c++)f+=l;return f}else return r}}),uc="rotate",R0=["typed","multiply","rotationMatrix"],F0=R(uc,R0,e=>{var{typed:n,multiply:a,rotationMatrix:t}=e;return n(uc,{"Array , number | BigNumber | Complex | Unit":function(l,m){r(l,2);var f=a(t(m),l);return f.toArray()},"Matrix , number | BigNumber | Complex | Unit":function(l,m){return r(l,2),a(t(m),l)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(l,m,f){r(l,3);var c=a(t(m,f),l);return c},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(l,m,f){return r(l,3),a(t(m,f),l)}});function r(i,l){var m=Array.isArray(i)?Pe(i):i.size();if(m.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(l));if(m.length===2&&m[1]!==1)throw new RangeError("Vector must be of dimensions 1x".concat(l));if(m[0]!==l)throw new RangeError("Vector must be of dimensions 1x".concat(l))}}),cc="rotationMatrix",z0=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],P0=R(cc,z0,e=>{var{typed:n,config:a,multiplyScalar:t,addScalar:r,unaryMinus:i,norm:l,BigNumber:m,matrix:f,DenseMatrix:c,SparseMatrix:s,cos:o,sin:u}=e;return n(cc,{"":function(){return a.matrix==="Matrix"?f([]):[]},string:function(g){return f(g)},"number | BigNumber | Complex | Unit":function(g){return p(g,a.matrix==="Matrix"?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(g,y){return p(g,y)},"number | BigNumber | Complex | Unit, Array":function(g,y){var x=f(y);return v(x),w(g,x,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(g,y){v(y);var x=y.storage()||(a.matrix==="Matrix"?"dense":void 0);return w(g,y,x)},"number | BigNumber | Complex | Unit, Array, string":function(g,y,x){var d=f(y);return v(d),w(g,d,x)},"number | BigNumber | Complex | Unit, Matrix, string":function(g,y,x){return v(y),w(g,y,x)}});function p(N,g){var y=_e(N),x=y?new m(-1):-1,d=o(N),A=u(N),S=[[d,t(x,A)],[A,d]];return b(S,g)}function v(N){var g=N.size();if(g.length<1||g[0]!==3)throw new RangeError("Vector must be of dimensions 1x3")}function h(N){return N.reduce((g,y)=>t(g,y))}function b(N,g){if(g){if(g==="sparse")return new s(N);if(g==="dense")return new c(N);throw new TypeError('Unknown matrix type "'.concat(g,'"'))}return N}function w(N,g,y){var x=l(g);if(x===0)throw new RangeError("Rotation around zero vector");var d=_e(N)?m:null,A=d?new d(1):1,S=d?new d(-1):-1,O=d?new d(g.get([0])/x):g.get([0])/x,M=d?new d(g.get([1])/x):g.get([1])/x,_=d?new d(g.get([2])/x):g.get([2])/x,E=o(N),$=r(A,i(E)),z=u(N),I=r(E,h([O,O,$])),T=r(h([O,M,$]),h([S,_,z])),B=r(h([O,_,$]),h([M,z])),G=r(h([O,M,$]),h([_,z])),D=r(E,h([M,M,$])),H=r(h([M,_,$]),h([S,O,z])),W=r(h([O,_,$]),h([S,M,z])),j=r(h([M,_,$]),h([O,z])),V=r(E,h([_,_,$])),K=[[I,T,B],[G,D,H],[W,j,V]];return b(K,y)}}),fc="row",U0=["typed","Index","matrix","range"],lc=R(fc,U0,e=>{var{typed:n,Index:a,matrix:t,range:r}=e;return n(fc,{"Matrix, number":i,"Array, number":function(m,f){return i(t(Ce(m)),f).valueOf()}});function i(l,m){if(l.size().length!==2)throw new Error("Only two dimensional matrix is supported");We(m,l.size()[0]);var f=r(0,l.size()[1]),c=new a(m,f);return l.subset(c)}}),mc="size",L0=["typed","config","?matrix"],k0=R(mc,L0,e=>{var{typed:n,config:a,matrix:t}=e;return n(mc,{Matrix:function(i){return i.create(i.size())},Array:Pe,string:function(i){return a.matrix==="Array"?[i.length]:t([i.length])},"number | Complex | BigNumber | Unit | boolean | null":function(i){return a.matrix==="Array"?[]:t?t([]):ac()}})}),pc="squeeze",H0=["typed","matrix"],G0=R(pc,H0,e=>{var{typed:n,matrix:a}=e;return n(pc,{Array:function(r){return aa(Ce(r))},Matrix:function(r){var i=aa(r.toArray());return Array.isArray(i)?a(i):i},any:function(r){return Ce(r)}})}),vc="subset",V0=["typed","matrix"],hc=R(vc,V0,e=>{var{typed:n,matrix:a}=e;return n(vc,{"Array, Index":function(r,i){var l=a(r),m=l.subset(i);return i.isScalar()?m:m.valueOf()},"Matrix, Index":function(r,i){return r.subset(i)},"Object, Index":X0,"string, Index":Z0,"Array, Index, any":function(r,i,l){return a(Ce(r)).subset(i,l,void 0).valueOf()},"Array, Index, any, any":function(r,i,l,m){return a(Ce(r)).subset(i,l,m).valueOf()},"Matrix, Index, any":function(r,i,l){return r.clone().subset(i,l)},"Matrix, Index, any, any":function(r,i,l,m){return r.clone().subset(i,l,m)},"string, Index, string":dc,"string, Index, string, string":dc,"Object, Index, any":Y0})});function Z0(e,n){if(!En(n))throw new TypeError("Index expected");if(n.size().length!==1)throw new Fe(n.size().length,1);var a=e.length;We(n.min()[0],a),We(n.max()[0],a);var t=n.dimension(0),r="";return t.forEach(function(i){r+=e.charAt(i)}),r}function dc(e,n,a,t){if(!n||n.isIndex!==!0)throw new TypeError("Index expected");if(n.size().length!==1)throw new Fe(n.size().length,1);if(t!==void 0){if(typeof t!="string"||t.length!==1)throw new TypeError("Single character expected as defaultValue")}else t=" ";var r=n.dimension(0),i=r.size()[0];if(i!==a.length)throw new Fe(r.size()[0],a.length);var l=e.length;We(n.min()[0]),We(n.max()[0]);for(var m=[],f=0;f<l;f++)m[f]=e.charAt(f);if(r.forEach(function(o,u){m[o]=a.charAt(u[0])}),m.length>l)for(var c=l-1,s=m.length;c<s;c++)m[c]||(m[c]=t);return m.join("")}function X0(e,n){if(n.size().length!==1)throw new Fe(n.size(),1);var a=n.dimension(0);if(typeof a!="string")throw new TypeError("String expected as index to retrieve an object property");return Vr(e,a)}function Y0(e,n,a){if(n.size().length!==1)throw new Fe(n.size(),1);var t=n.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");var r=Ce(e);return un(r,t,a),r}var W0="transpose",J0=["typed","matrix"],Q0=R(W0,J0,e=>{var{typed:n,matrix:a}=e;return n("transpose",{Array:function(l){return this(a(l)).valueOf()},Matrix:function(l){var m=l.size(),f;switch(m.length){case 1:f=l.clone();break;case 2:{var c=m[0],s=m[1];if(s===0)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+Re(m)+")");switch(l.storage()){case"dense":f=t(l,c,s);break;case"sparse":f=r(l,c,s);break}}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+Re(this._size)+")")}return f},any:function(l){return Ce(l)}});function t(i,l,m){for(var f=i._data,c=[],s,o=0;o<m;o++){s=c[o]=[];for(var u=0;u<l;u++)s[u]=Ce(f[u][o])}return i.createDenseMatrix({data:c,size:[m,l],datatype:i._datatype})}function r(i,l,m){for(var f=i._values,c=i._index,s=i._ptr,o=f?[]:void 0,u=[],p=[],v=[],h=0;h<l;h++)v[h]=0;var b,w,N;for(b=0,w=c.length;b<w;b++)v[c[b]]++;for(var g=0,y=0;y<l;y++)p.push(g),g+=v[y],v[y]=p[y];for(p.push(g),N=0;N<m;N++)for(var x=s[N],d=s[N+1],A=x;A<d;A++){var S=v[c[A]]++;u[S]=N,f&&(o[S]=Ce(f[A]))}return i.createSparseMatrix({values:o,index:u,ptr:p,size:[m,l],datatype:i._datatype})}}),gc="ctranspose",K0=["typed","transpose","conj"],j0=R(gc,K0,e=>{var{typed:n,transpose:a,conj:t}=e;return n(gc,{any:function(i){return t(a(i))}})}),yc="zeros",e1=["typed","config","matrix","BigNumber"],r1=R(yc,e1,e=>{var{typed:n,config:a,matrix:t,BigNumber:r}=e;return n(yc,{"":function(){return a.matrix==="Array"?i([]):i([],"default")},"...number | BigNumber | string":function(c){var s=c[c.length-1];if(typeof s=="string"){var o=c.pop();return i(c,o)}else return a.matrix==="Array"?i(c):i(c,"default")},Array:i,Matrix:function(c){var s=c.storage();return i(c.valueOf(),s)},"Array | Matrix, string":function(c,s){return i(c.valueOf(),s)}});function i(f,c){var s=l(f),o=s?new r(0):0;if(m(f),c){var u=t(c);return f.length>0?u.resize(f,o):u}else{var p=[];return f.length>0?on(p,f,o):p}}function l(f){var c=!1;return f.forEach(function(s,o,u){_e(s)&&(c=!0,u[o]=s.toNumber())}),c}function m(f){f.forEach(function(c){if(typeof c!="number"||!Ae(c)||c<0)throw new Error("Parameters in function zeros must be positive integers")})}}),xc="fft",t1=["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],n1=R(xc,t1,e=>{var{typed:n,matrix:a,addScalar:t,multiplyScalar:r,divideScalar:i,exp:l,tau:m,i:f}=e;return n(xc,{Array:c,Matrix:function(p){return p.create(c(p.toArray()))}});function c(u){var p=Pe(u);return p.length===1?o(u,p[0]):s(u.map(v=>c(v,p.slice(1))),0)}function s(u,p){var v=Pe(u);if(p!==0)return new Array(v[0]).fill(0).map((b,w)=>s(u[w],p-1));if(v.length===1)return o(u);function h(b){var w=Pe(b);return new Array(w[1]).fill(0).map((N,g)=>new Array(w[0]).fill(0).map((y,x)=>b[x][g]))}return h(s(h(u),1))}function o(u){var p=u.length;if(p===1)return[u[0]];if(p%2===0){for(var v=[...o(u.filter((N,g)=>g%2===0)),...o(u.filter((N,g)=>g%2===1))],h=0;h<p/2;h++){var b=v[h],w=r(v[h+p/2],l(r(r(m,f),i(-h,p))));v[h]=t(b,w),v[h+p/2]=t(b,r(-1,w))}return v}throw new Error("Can only calculate FFT of power-of-two size")}}),bc="ifft",a1=["typed","fft","dotDivide","conj"],i1=R(bc,a1,e=>{var{typed:n,fft:a,dotDivide:t,conj:r}=e;return n(bc,{"Array | Matrix":function(l){var m=Oe(l)?l.size():Pe(l);return t(r(a(r(l))),m.reduce((f,c)=>f*c,1))}})}),o1="erf",s1=["typed"],u1=R(o1,s1,e=>{var{typed:n}=e;return n("name",{number:function(l){var m=Math.abs(l);return m>=l1?Dt(l):m<=c1?Dt(l)*a(m):m<=4?Dt(l)*(1-t(m)):Dt(l)*(1-r(m))},"Array | Matrix":function(l){return be(l,this)}});function a(i){var l=i*i,m=Nt[0][4]*l,f=l,c;for(c=0;c<3;c+=1)m=(m+Nt[0][c])*l,f=(f+gn[0][c])*l;return i*(m+Nt[0][3])/(f+gn[0][3])}function t(i){var l=Nt[1][8]*i,m=i,f;for(f=0;f<7;f+=1)l=(l+Nt[1][f])*i,m=(m+gn[1][f])*i;var c=(l+Nt[1][7])/(m+gn[1][7]),s=parseInt(i*16)/16,o=(i-s)*(i+s);return Math.exp(-s*s)*Math.exp(-o)*c}function r(i){var l=1/(i*i),m=Nt[2][5]*l,f=l,c;for(c=0;c<4;c+=1)m=(m+Nt[2][c])*l,f=(f+gn[2][c])*l;var s=l*(m+Nt[2][4])/(f+gn[2][4]);s=(f1-s)/i,l=parseInt(i*16)/16;var o=(i-l)*(i+l);return Math.exp(-l*l)*Math.exp(-o)*s}}),c1=.46875,f1=.5641895835477563,Nt=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],gn=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],l1=Math.pow(2,53),wc="mode",m1=["typed","isNaN","isNumeric"],p1=R(wc,m1,e=>{var{typed:n,isNaN:a,isNumeric:t}=e;return n(wc,{"Array | Matrix":r,"...":function(l){return r(l)}});function r(i){i=Le(i.valueOf());var l=i.length;if(l===0)throw new Error("Cannot calculate mode of an empty array");for(var m={},f=[],c=0,s=0;s<i.length;s++){var o=i[s];if(t(o)&&a(o))throw new Error("Cannot calculate mode of an array containing NaN values");o in m||(m[o]=0),m[o]++,m[o]===c?f.push(o):m[o]>c&&(c=m[o],f=[o])}return f}});function Tr(e,n,a){var t;return String(e).indexOf("Unexpected type")!==-1?(t=arguments.length>2?" (type: "+Ke(a)+", value: "+JSON.stringify(a)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+n+", unexpected type of argument"+t)):String(e).indexOf("complex numbers")!==-1?(t=arguments.length>2?" (type: "+Ke(a)+", value: "+JSON.stringify(a)+")":"",new TypeError("Cannot calculate "+n+", no ordering relation is defined for complex numbers"+t)):e}var Nc="prod",v1=["typed","config","multiplyScalar","numeric"],h1=R(Nc,v1,e=>{var{typed:n,config:a,multiplyScalar:t,numeric:r}=e;return n(Nc,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(m,f){throw new Error("prod(A, dim) is not yet supported")},"...":function(m){return i(m)}});function i(l){var m;if(bt(l,function(f){try{m=m===void 0?f:t(m,f)}catch(c){throw Tr(c,"prod",f)}}),typeof m=="string"&&(m=r(m,a.number)),m===void 0)throw new Error("Cannot calculate prod of an empty array");return m}}),Mc="format",d1=["typed"],g1=R(Mc,d1,e=>{var{typed:n}=e;return n(Mc,{any:Re,"any, Object | function | number":Re})}),Ac="bin",y1=["typed","format"],x1=R(Ac,y1,e=>{var{typed:n,format:a}=e;return n(Ac,{"number | BigNumber":function(r){return a(r,{notation:"bin"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"bin",wordSize:i})}})}),Sc="oct",b1=["typed","format"],w1=R(Sc,b1,e=>{var{typed:n,format:a}=e;return n(Sc,{"number | BigNumber":function(r){return a(r,{notation:"oct"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"oct",wordSize:i})}})}),Ec="hex",N1=["typed","format"],M1=R(Ec,N1,e=>{var{typed:n,format:a}=e;return n(Ec,{"number | BigNumber":function(r){return a(r,{notation:"hex"})},"number | BigNumber, number":function(r,i){return a(r,{notation:"hex",wordSize:i})}})}),Cc="print",A1=["typed"],S1=R(Cc,A1,e=>{var{typed:n}=e;return n(Cc,{"string, Object | Array":Oc,"string, Object | Array, number | Object":Oc})});function Oc(e,n,a){return e.replace(/\$([\w.]+)/g,function(t,r){for(var i=r.split("."),l=n[i.shift()];i.length&&l!==void 0;){var m=i.shift();l=m?l[m]:l+"."}return l!==void 0?_r(l)?l:Re(l,a):t})}var Dc="to",E1=["typed","matrix"],C1=R(Dc,E1,e=>{var{typed:n,matrix:a}=e,t=je({typed:n}),r=Ge({typed:n});return n(Dc,{"Unit, Unit | string":function(l,m){return l.to(m)},"Matrix, Matrix":function(l,m){return t(l,m,this)},"Array, Array":function(l,m){return this(a(l),a(m)).valueOf()},"Array, Matrix":function(l,m){return this(a(l),m)},"Matrix, Array":function(l,m){return this(l,a(m))},"Matrix, any":function(l,m){return r(l,m,this,!1)},"any, Matrix":function(l,m){return r(m,l,this,!0)},"Array, any":function(l,m){return r(a(l),m,this,!1).valueOf()},"any, Array":function(l,m){return r(a(m),l,this,!0).valueOf()}})}),Tc="isPrime",O1=["typed"],D1=R(Tc,O1,e=>{var{typed:n}=e;return n(Tc,{number:function(t){if(t*0!==0)return!1;if(t<=3)return t>1;if(t%2===0||t%3===0)return!1;for(var r=5;r*r<=t;r+=6)if(t%r===0||t%(r+2)===0)return!1;return!0},BigNumber:function(t){if(t.toNumber()*0!==0)return!1;if(t.lte(3))return t.gt(1);if(t.mod(2).eq(0)||t.mod(3).eq(0))return!1;if(t.lt(Math.pow(2,32))){for(var r=t.toNumber(),i=5;i*i<=r;i+=6)if(r%i===0||r%(i+2)===0)return!1;return!0}function l(N,g,y){for(var x=1;!g.eq(0);)g.mod(2).eq(0)?(g=g.div(2),N=N.mul(N).mod(y)):(g=g.sub(1),x=N.mul(x).mod(y));return x}var m=t.constructor.clone({precision:t.toFixed(0).length*2});t=new m(t);for(var f=0,c=t.sub(1);c.mod(2).eq(0);)c=c.div(2),f+=1;var s=null;if(t.lt("3317044064679887385961981"))s=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(N=>N<t);else{var o=Math.min(t.toNumber()-2,Math.floor(2*Math.pow(t.toFixed(0).length*Math.log(10),2)));s=[];for(var u=2;u<=o;u+=1)s.push(o)}for(var p=0;p<s.length;p+=1){var v=s[p],h=l(t.sub(t).add(v),c,t);if(!h.eq(1)){for(var b=0,w=h;!w.eq(t.sub(1));b+=1,w=w.mul(w).mod(t))if(b===f-1)return!1}}return!0},"Array | Matrix":function(t){return be(t,this)}})}),T1="numeric",B1=["number","?bignumber","?fraction"],_1=R(T1,B1,e=>{var{number:n,bignumber:a,fraction:t}=e,r={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:l=>n(l),BigNumber:a?l=>a(l):Ai,Fraction:t?l=>t(l):nc};return function(m,f){var c=Ke(m);if(!(c in r))throw new TypeError("Cannot convert "+m+' of type "'+c+'"; valid input types are '+Object.keys(r).join(", "));if(!(f in i))throw new TypeError("Cannot convert "+m+' to type "'+f+'"; valid output types are '+Object.keys(i).join(", "));return f===c?m:i[f](m)}}),Bc="divideScalar",$1=["typed","numeric"],I1=R(Bc,$1,e=>{var{typed:n,numeric:a}=e;return n(Bc,{"number, number":function(r,i){return r/i},"Complex, Complex":function(r,i){return r.div(i)},"BigNumber, BigNumber":function(r,i){return r.div(i)},"Fraction, Fraction":function(r,i){return r.div(i)},"Unit, number | Fraction | BigNumber":function(r,i){var l=r.clone(),m=a(1,Ke(i));return l.value=this(l.value===null?l._normalize(m):l.value,i),l},"number | Fraction | BigNumber, Unit":function(r,i){var l=i.clone();l=l.pow(-1);var m=a(1,Ke(r));return l.value=this(r,i.value===null?i._normalize(m):i.value),l},"Unit, Unit":function(r,i){return r.divide(i)}})}),_c="pow",q1=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],R1=R(_c,q1,e=>{var{typed:n,config:a,identity:t,multiply:r,matrix:i,inv:l,number:m,fraction:f,Complex:c}=e;return n(_c,{"number, number":s,"Complex, Complex":function(v,h){return v.pow(h)},"BigNumber, BigNumber":function(v,h){return h.isInteger()||v>=0||a.predictable?v.pow(h):new c(v.toNumber(),0).pow(h.toNumber(),0)},"Fraction, Fraction":function(v,h){var b=v.pow(h);if(b!=null)return b;if(a.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return s(v.valueOf(),h.valueOf())},"Array, number":o,"Array, BigNumber":function(v,h){return o(v,h.toNumber())},"Matrix, number":u,"Matrix, BigNumber":function(v,h){return u(v,h.toNumber())},"Unit, number | BigNumber":function(v,h){return v.pow(h)}});function s(p,v){if(a.predictable&&!Ae(v)&&p<0)try{var h=f(v),b=m(h);if((v===b||Math.abs((v-b)/v)<1e-14)&&h.d%2===1)return(h.n%2===0?1:-1)*Math.pow(-p,v)}catch(w){}return a.predictable&&(p<-1&&v===1/0||p>-1&&p<0&&v===-1/0)?NaN:Ae(v)||p>=0||a.predictable?us(p,v):p*p<1&&v===1/0||p*p>1&&v===-1/0?0:new c(p,0).pow(v,0)}function o(p,v){if(!Ae(v))throw new TypeError("For A^b, b must be an integer (value is "+v+")");var h=Pe(p);if(h.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+h.length+" dimensions)");if(h[0]!==h[1])throw new Error("For A^b, A must be square (size is "+h[0]+"x"+h[1]+")");if(v<0)try{return o(l(p),-v)}catch(N){throw N.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 "+v+")"):N}for(var b=t(h[0]).valueOf(),w=p;v>=1;)(v&1)===1&&(b=r(w,b)),v>>=1,w=r(w,w);return b}function u(p,v){return i(o(p.valueOf(),v))}}),yn="Number of decimals in function round must be an integer",$c="round",F1=["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],z1=R($c,F1,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,BigNumber:i,DenseMatrix:l}=e,m=wr({typed:n,equalScalar:t}),f=gr({typed:n,DenseMatrix:l}),c=Ge({typed:n});return n($c,{number:cs,"number, number":cs,"number, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return new i(o).toDecimalPlaces(u.toNumber())},Complex:function(o){return o.round()},"Complex, number":function(o,u){if(u%1)throw new TypeError(yn);return o.round(u)},"Complex, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);var p=u.toNumber();return o.round(p)},BigNumber:function(o){return o.toDecimalPlaces(0)},"BigNumber, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return o.toDecimalPlaces(u.toNumber())},Fraction:function(o){return o.round()},"Fraction, number":function(o,u){if(u%1)throw new TypeError(yn);return o.round(u)},"Fraction, BigNumber":function(o,u){if(!u.isInteger())throw new TypeError(yn);return o.round(u.toNumber())},"Array | Matrix":function(o){return be(o,this)},"SparseMatrix, number | BigNumber":function(o,u){return m(o,u,this,!1)},"DenseMatrix, number | BigNumber":function(o,u){return c(o,u,this,!1)},"Array, number | BigNumber":function(o,u){return c(a(o),u,this,!1).valueOf()},"number | Complex | BigNumber | Fraction, SparseMatrix":function(o,u){return t(o,0)?r(u.size(),u.storage()):f(u,o,this,!0)},"number | Complex | BigNumber | Fraction, DenseMatrix":function(o,u){return t(o,0)?r(u.size(),u.storage()):c(u,o,this,!0)},"number | Complex | BigNumber | Fraction, Array":function(o,u){return c(a(u),o,this,!0).valueOf()}})}),Ic="log",P1=["config","typed","divideScalar","Complex"],U1=R(Ic,P1,e=>{var{typed:n,config:a,divideScalar:t,Complex:r}=e;return n(Ic,{number:function(l){return l>=0||a.predictable?Xh(l):new r(l,0).log()},Complex:function(l){return l.log()},BigNumber:function(l){return!l.isNegative()||a.predictable?l.ln():new r(l.toNumber(),0).log()},"Array | Matrix":function(l){return be(l,this)},"any, any":function(l,m){return t(this(l),this(m))}})}),qc="log1p",L1=["typed","config","divideScalar","log","Complex"],k1=R(qc,L1,e=>{var{typed:n,config:a,divideScalar:t,log:r,Complex:i}=e;return n(qc,{number:function(f){return f>=-1||a.predictable?Gp(f):l(new i(f,0))},Complex:l,BigNumber:function(f){var c=f.plus(1);return!c.isNegative()||a.predictable?c.ln():l(new i(f.toNumber(),0))},"Array | Matrix":function(f){return be(f,this)},"any, any":function(f,c){return t(this(f),r(c))}});function l(m){var f=m.re+1;return new i(Math.log(Math.sqrt(f*f+m.im*m.im)),Math.atan2(m.im,f))}}),Rc="nthRoots",H1=["config","typed","divideScalar","Complex"],G1=R(Rc,H1,e=>{var{typed:n,config:a,divideScalar:t,Complex:r}=e,i=[function(f){return new r(f,0)},function(f){return new r(0,f)},function(f){return new r(-f,0)},function(f){return new r(0,-f)}];function l(m,f){if(f<0)throw new Error("Root must be greater than zero");if(f===0)throw new Error("Root must be non-zero");if(f%1!==0)throw new Error("Root must be an integer");if(m===0||m.abs()===0)return[new r(0,0)];var c=typeof m=="number",s;(c||m.re===0||m.im===0)&&(c?s=2*+(m<0):m.im===0?s=2*+(m.re<0):s=2*+(m.im<0)+1);for(var o=m.arg(),u=m.abs(),p=[],v=Math.pow(u,1/f),h=0;h<f;h++){var b=(s+4*h)/f;if(b===Math.round(b)){p.push(i[b%4](v));continue}p.push(new r({r:v,phi:(o+2*Math.PI*h)/f}))}return p}return n(Rc,{Complex:function(f){return l(f,2)},"Complex, number":l})}),Fc="dotPow",V1=["typed","equalScalar","matrix","pow","DenseMatrix"],Z1=R(Fc,V1,e=>{var{typed:n,equalScalar:a,matrix:t,pow:r,DenseMatrix:i}=e,l=Dr({typed:n}),m=ut({typed:n,DenseMatrix:i}),f=wr({typed:n,equalScalar:a}),c=gr({typed:n,DenseMatrix:i}),s=je({typed:n}),o=Ge({typed:n});return n(Fc,{"any, any":r,"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,r,!1)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,r,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,r,!1)},"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,r)},"Array, Array":function(p,v){return this(t(p),t(v)).valueOf()},"Array, Matrix":function(p,v){return this(t(p),v)},"Matrix, Array":function(p,v){return this(p,t(v))},"SparseMatrix, any":function(p,v){return f(p,v,this,!1)},"DenseMatrix, any":function(p,v){return o(p,v,this,!1)},"any, SparseMatrix":function(p,v){return c(v,p,this,!0)},"any, DenseMatrix":function(p,v){return o(v,p,this,!0)},"Array, any":function(p,v){return o(t(p),v,this,!1).valueOf()},"any, Array":function(p,v){return o(t(v),p,this,!0).valueOf()}})}),zc="dotDivide",X1=["typed","matrix","equalScalar","divideScalar","DenseMatrix"],Y1=R(zc,X1,e=>{var{typed:n,matrix:a,equalScalar:t,divideScalar:r,DenseMatrix:i}=e,l=rt({typed:n,equalScalar:t}),m=Dr({typed:n}),f=ut({typed:n,DenseMatrix:i}),c=wr({typed:n,equalScalar:t}),s=gr({typed:n,DenseMatrix:i}),o=je({typed:n}),u=Ge({typed:n});return n(zc,{"any, any":r,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,r,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,r,!0)},"DenseMatrix, SparseMatrix":function(v,h){return m(v,h,r,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,r)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, any":function(v,h){return c(v,h,r,!1)},"DenseMatrix, any":function(v,h){return u(v,h,r,!1)},"any, SparseMatrix":function(v,h){return s(h,v,r,!0)},"any, DenseMatrix":function(v,h){return u(h,v,r,!0)},"Array, any":function(v,h){return u(a(v),h,r,!1).valueOf()},"any, Array":function(v,h){return u(a(h),v,r,!0).valueOf()}})});function Rn(e){var{DenseMatrix:n}=e;return function(t,r,i){var l=t.size();if(l.length!==2)throw new RangeError("Matrix must be two dimensional (size: "+Re(l)+")");var m=l[0],f=l[1];if(m!==f)throw new RangeError("Matrix must be square (size: "+Re(l)+")");var c=[];if(Oe(r)){var s=r.size(),o=r._data;if(s.length===1){if(s[0]!==m)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var u=0;u<m;u++)c[u]=[o[u]];return new n({data:c,size:[m,1],datatype:r._datatype})}if(s.length===2){if(s[0]!==m||s[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(Qn(r)){if(i){c=[];for(var p=0;p<m;p++)c[p]=[o[p][0]];return new n({data:c,size:[m,1],datatype:r._datatype})}return r}if(Ut(r)){for(var v=0;v<m;v++)c[v]=[0];for(var h=r._values,b=r._index,w=r._ptr,N=w[1],g=w[0];g<N;g++){var y=b[g];c[y][0]=h[g]}return new n({data:c,size:[m,1],datatype:r._datatype})}}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}if(Xe(r)){var x=Pe(r);if(x.length===1){if(x[0]!==m)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var d=0;d<m;d++)c[d]=[r[d]];return new n({data:c,size:[m,1]})}if(x.length===2){if(x[0]!==m||x[1]!==1)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var A=0;A<m;A++)c[A]=[r[A][0]];return new n({data:c,size:[m,1]})}throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.")}}}var Pc="lsolve",W1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],J1=R(Pc,W1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(Pc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.valueOf()}});function c(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=[],w=o._data,N=0;N<h;N++){var g=p[N][0]||0,y=void 0;if(l(g,0))y=0;else{var x=w[N][N];if(l(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=t(g,x);for(var d=N+1;d<v;d++)p[d]=[i(p[d][0]||0,r(y,w[d][N]))]}b[N]=[y]}return new m({data:b,size:[v,1]})}function s(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=[],y=0;y<h;y++){var x=p[y][0]||0;if(l(x,0))g[y]=[0];else{for(var d=0,A=[],S=[],O=N[y],M=N[y+1],_=O;_<M;_++){var E=w[_];E===y?d=b[_]:E>y&&(A.push(b[_]),S.push(E))}if(l(d,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var $=t(x,d),z=0,I=S.length;z<I;z++){var T=S[z];p[T]=[i(p[T][0]||0,r($,A[z]))]}g[y]=[$]}}return new m({data:g,size:[v,1]})}}),Uc="usolve",Q1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],K1=R(Uc,Q1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(Uc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.valueOf()}});function c(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=[],w=o._data,N=h-1;N>=0;N--){var g=p[N][0]||0,y=void 0;if(l(g,0))y=0;else{var x=w[N][N];if(l(x,0))throw new Error("Linear system cannot be solved since matrix is singular");y=t(g,x);for(var d=N-1;d>=0;d--)p[d]=[i(p[d][0]||0,r(y,w[d][N]))]}b[N]=[y]}return new m({data:b,size:[v,1]})}function s(o,u){u=f(o,u,!0);for(var p=u._data,v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=[],y=h-1;y>=0;y--){var x=p[y][0]||0;if(l(x,0))g[y]=[0];else{for(var d=0,A=[],S=[],O=N[y],M=N[y+1],_=M-1;_>=O;_--){var E=w[_];E===y?d=b[_]:E<y&&(A.push(b[_]),S.push(E))}if(l(d,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var $=t(x,d),z=0,I=S.length;z<I;z++){var T=S[z];p[T]=[i(p[T][0],r($,A[z]))]}g[y]=[$]}}return new m({data:g,size:[v,1]})}}),Lc="lsolveAll",j1=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],ex=R(Lc,j1,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(Lc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.map(b=>b.valueOf())}});function c(o,u){for(var p=[f(o,u,!0)._data.map(S=>S[0])],v=o._data,h=o._size[0],b=o._size[1],w=0;w<b;w++)for(var N=p.length,g=0;g<N;g++){var y=p[g];if(l(v[w][w],0))if(l(y[w],0)){if(g===0){var d=[...y];d[w]=1;for(var A=w+1;A<b;A++)d[A]=i(d[A],v[A][w]);p.push(d)}}else{if(g===0)return[];p.splice(g,1),g-=1,N-=1}else{y[w]=t(y[w],v[w][w]);for(var x=w+1;x<b;x++)y[x]=i(y[x],r(y[w],v[x][w]))}}return p.map(S=>new m({data:S.map(O=>[O]),size:[h,1]}))}function s(o,u){for(var p=[f(o,u,!0)._data.map(W=>W[0])],v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=0;g<h;g++)for(var y=p.length,x=0;x<y;x++){for(var d=p[x],A=[],S=[],O=N[g],M=N[g+1],_=0,E=O;E<M;E++){var $=w[E];$===g?_=b[E]:$>g&&(A.push(b[E]),S.push($))}if(l(_,0))if(l(d[g],0)){if(x===0){var B=[...d];B[g]=1;for(var G=0,D=S.length;G<D;G++){var H=S[G];B[H]=i(B[H],A[G])}p.push(B)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{d[g]=t(d[g],_);for(var z=0,I=S.length;z<I;z++){var T=S[z];d[T]=i(d[T],r(d[g],A[z]))}}}return p.map(W=>new m({data:W.map(j=>[j]),size:[v,1]}))}}),kc="usolveAll",rx=["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],tx=R(kc,rx,e=>{var{typed:n,matrix:a,divideScalar:t,multiplyScalar:r,subtract:i,equalScalar:l,DenseMatrix:m}=e,f=Rn({DenseMatrix:m});return n(kc,{"SparseMatrix, Array | Matrix":function(u,p){return s(u,p)},"DenseMatrix, Array | Matrix":function(u,p){return c(u,p)},"Array, Array | Matrix":function(u,p){var v=a(u),h=c(v,p);return h.map(b=>b.valueOf())}});function c(o,u){for(var p=[f(o,u,!0)._data.map(S=>S[0])],v=o._data,h=o._size[0],b=o._size[1],w=b-1;w>=0;w--)for(var N=p.length,g=0;g<N;g++){var y=p[g];if(l(v[w][w],0))if(l(y[w],0)){if(g===0){var d=[...y];d[w]=1;for(var A=w-1;A>=0;A--)d[A]=i(d[A],v[A][w]);p.push(d)}}else{if(g===0)return[];p.splice(g,1),g-=1,N-=1}else{y[w]=t(y[w],v[w][w]);for(var x=w-1;x>=0;x--)y[x]=i(y[x],r(y[w],v[x][w]))}}return p.map(S=>new m({data:S.map(O=>[O]),size:[h,1]}))}function s(o,u){for(var p=[f(o,u,!0)._data.map(W=>W[0])],v=o._size[0],h=o._size[1],b=o._values,w=o._index,N=o._ptr,g=h-1;g>=0;g--)for(var y=p.length,x=0;x<y;x++){for(var d=p[x],A=[],S=[],O=N[g],M=N[g+1],_=0,E=M-1;E>=O;E--){var $=w[E];$===g?_=b[E]:$<g&&(A.push(b[E]),S.push($))}if(l(_,0))if(l(d[g],0)){if(x===0){var B=[...d];B[g]=1;for(var G=0,D=S.length;G<D;G++){var H=S[G];B[H]=i(B[H],A[G])}p.push(B)}}else{if(x===0)return[];p.splice(x,1),x-=1,y-=1}else{d[g]=t(d[g],_);for(var z=0,I=S.length;z<I;z++){var T=S[z];d[T]=i(d[T],r(d[g],A[z]))}}}return p.map(W=>new m({data:W.map(j=>[j]),size:[v,1]}))}}),nx="algorithm08",ax=["typed","equalScalar"],Si=R(nx,ax,e=>{var{typed:n,equalScalar:a}=e;return function(r,i,l){var m=r._values,f=r._index,c=r._ptr,s=r._size,o=r._datatype,u=i._values,p=i._index,v=i._ptr,h=i._size,b=i._datatype;if(s.length!==h.length)throw new Fe(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");if(!m||!u)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var w=s[0],N=s[1],g,y=a,x=0,d=l;typeof o=="string"&&o===b&&(g=o,y=n.find(a,[g,g]),x=n.convert(0,g),d=n.find(l,[g,g]));for(var A=[],S=[],O=[],M=[],_=[],E,$,z,I,T=0;T<N;T++){O[T]=S.length;var B=T+1;for($=c[T],z=c[T+1],E=$;E<z;E++)I=f[E],_[I]=B,M[I]=m[E],S.push(I);for($=v[T],z=v[T+1],E=$;E<z;E++)I=p[E],_[I]===B&&(M[I]=d(M[I],u[E]));for(E=O[T];E<S.length;){I=S[E];var G=M[I];y(G,x)?S.splice(E,1):(A.push(G),E++)}}return O[N]=S.length,r.createSparseMatrix({values:A,index:S,ptr:O,size:[w,N],datatype:g})}}),Hc="leftShift",ix=["typed","matrix","equalScalar","zeros","DenseMatrix"],ox=R(Hc,ix,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=rt({typed:n,equalScalar:t}),f=Si({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Hc,{"number, number":vs,"BigNumber, BigNumber":Oy,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Gc="rightArithShift",sx=["typed","matrix","equalScalar","zeros","DenseMatrix"],ux=R(Gc,sx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=rt({typed:n,equalScalar:t}),f=Si({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Gc,{"number, number":hs,"BigNumber, BigNumber":Dy,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Vc="rightLogShift",cx=["typed","matrix","equalScalar","zeros","DenseMatrix"],fx=R(Vc,cx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,DenseMatrix:i}=e,l=qt({typed:n}),m=rt({typed:n,equalScalar:t}),f=Si({typed:n,equalScalar:t}),c=Vt({typed:n,DenseMatrix:i}),s=wr({typed:n,equalScalar:t}),o=je({typed:n}),u=Ge({typed:n});return n(Vc,{"number, number":ds,"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return m(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return l(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():s(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return t(h,0)?v.clone():u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):c(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return t(v,0)?r(h.size(),h.storage()):u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return this(a(v),h).valueOf()},"number | BigNumber, Array":function(v,h){return this(v,a(h)).valueOf()}})}),Zc="and",lx=["typed","matrix","equalScalar","zeros","not"],mx=R(Zc,lx,e=>{var{typed:n,matrix:a,equalScalar:t,zeros:r,not:i}=e,l=rt({typed:n,equalScalar:t}),m=Sa({typed:n,equalScalar:t}),f=wr({typed:n,equalScalar:t}),c=je({typed:n}),s=Ge({typed:n});return n(Zc,{"number, number":ws,"Complex, Complex":function(u,p){return(u.re!==0||u.im!==0)&&(p.re!==0||p.im!==0)},"BigNumber, BigNumber":function(u,p){return!u.isZero()&&!p.isZero()&&!u.isNaN()&&!p.isNaN()},"Unit, Unit":function(u,p){return this(u.value||0,p.value||0)},"SparseMatrix, SparseMatrix":function(u,p){return m(u,p,this,!1)},"SparseMatrix, DenseMatrix":function(u,p){return l(p,u,this,!0)},"DenseMatrix, SparseMatrix":function(u,p){return l(u,p,this,!1)},"DenseMatrix, DenseMatrix":function(u,p){return c(u,p,this)},"Array, Array":function(u,p){return this(a(u),a(p)).valueOf()},"Array, Matrix":function(u,p){return this(a(u),p)},"Matrix, Array":function(u,p){return this(u,a(p))},"SparseMatrix, any":function(u,p){return i(p)?r(u.size(),u.storage()):f(u,p,this,!1)},"DenseMatrix, any":function(u,p){return i(p)?r(u.size(),u.storage()):s(u,p,this,!1)},"any, SparseMatrix":function(u,p){return i(u)?r(u.size(),u.storage()):f(p,u,this,!0)},"any, DenseMatrix":function(u,p){return i(u)?r(u.size(),u.storage()):s(p,u,this,!0)},"Array, any":function(u,p){return this(a(u),p).valueOf()},"any, Array":function(u,p){return this(u,a(p)).valueOf()}})}),Xc="compare",px=["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],vx=R(Xc,px,e=>{var{typed:n,config:a,equalScalar:t,matrix:r,BigNumber:i,Fraction:l,DenseMatrix:m}=e,f=Dr({typed:n}),c=Ea({typed:n,equalScalar:t}),s=gr({typed:n,DenseMatrix:m}),o=je({typed:n}),u=Ge({typed:n});return n(Xc,{"boolean, boolean":function(v,h){return v===h?0:v>h?1:-1},"number, number":function(v,h){return Rr(v,h,a.epsilon)?0:v>h?1:-1},"BigNumber, BigNumber":function(v,h){return st(v,h,a.epsilon)?new i(0):new i(v.cmp(h))},"Fraction, Fraction":function(v,h){return new l(v.compare(h))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(v,h){if(!v.equalBase(h))throw new Error("Cannot compare units with different base");return this(v.value,h.value)},"SparseMatrix, SparseMatrix":function(v,h){return c(v,h,this)},"SparseMatrix, DenseMatrix":function(v,h){return f(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(r(v),r(h)).valueOf()},"Array, Matrix":function(v,h){return this(r(v),h)},"Matrix, Array":function(v,h){return this(v,r(h))},"SparseMatrix, any":function(v,h){return s(v,h,this,!1)},"DenseMatrix, any":function(v,h){return u(v,h,this,!1)},"any, SparseMatrix":function(v,h){return s(h,v,this,!0)},"any, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, any":function(v,h){return u(r(v),h,this,!1).valueOf()},"any, Array":function(v,h){return u(r(h),v,this,!0).valueOf()}})}),Ei,Yc;function hx(){return Yc||(Yc=1,Ei=function e(n,a){var t=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,r=/(^[ ]*|[ ]*$)/g,i=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,l=/^0x[0-9a-f]+$/i,m=/^0/,f=function(g){return e.insensitive&&(""+g).toLowerCase()||""+g},c=f(n).replace(r,"")||"",s=f(a).replace(r,"")||"",o=c.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),u=s.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=parseInt(c.match(l),16)||o.length!==1&&c.match(i)&&Date.parse(c),v=parseInt(s.match(l),16)||p&&s.match(i)&&Date.parse(s)||null,h,b;if(v){if(p<v)return-1;if(p>v)return 1}for(var w=0,N=Math.max(o.length,u.length);w<N;w++){if(h=!(o[w]||"").match(m)&&parseFloat(o[w])||o[w]||0,b=!(u[w]||"").match(m)&&parseFloat(u[w])||u[w]||0,isNaN(h)!==isNaN(b))return isNaN(h)?1:-1;if(typeof h!=typeof b&&(h+="",b+=""),h<b)return-1;if(h>b)return 1}return 0}),Ei}var dx=hx();const xn=Tn(dx);var Wc="compareNatural",gx=["typed","compare"],yx=R(Wc,gx,e=>{var{typed:n,compare:a}=e,t=a.signatures["boolean,boolean"];return n(Wc,{"any, any":function(f,c){var s=Ke(f),o=Ke(c),u;if((s==="number"||s==="BigNumber"||s==="Fraction")&&(o==="number"||o==="BigNumber"||o==="Fraction"))return u=a(f,c),u.toString()!=="0"?u>0?1:-1:xn(s,o);if(s==="Array"||s==="Matrix"||o==="Array"||o==="Matrix")return u=r(this,f,c),u!==0?u:xn(s,o);if(s!==o)return xn(s,o);if(s==="Complex")return xx(f,c);if(s==="Unit")return f.equalBase(c)?this(f.value,c.value):i(this,f.formatUnits(),c.formatUnits());if(s==="boolean")return t(f,c);if(s==="string")return xn(f,c);if(s==="Object")return l(this,f,c);if(s==="null"||s==="undefined")return 0;throw new TypeError('Unsupported type of value "'+s+'"')}});function r(m,f,c){return Ut(f)&&Ut(c)?i(m,f.toJSON().values,c.toJSON().values):Ut(f)?r(m,f.toArray(),c):Ut(c)?r(m,f,c.toArray()):Qn(f)?r(m,f.toJSON().data,c):Qn(c)?r(m,f,c.toJSON().data):Array.isArray(f)?Array.isArray(c)?i(m,f,c):r(m,f,[c]):r(m,[f],c)}function i(m,f,c){for(var s=0,o=Math.min(f.length,c.length);s<o;s++){var u=m(f[s],c[s]);if(u!==0)return u}return f.length>c.length?1:f.length<c.length?-1:0}function l(m,f,c){var s=Object.keys(f),o=Object.keys(c);s.sort(xn),o.sort(xn);var u=i(m,s,o);if(u!==0)return u;for(var p=0;p<s.length;p++){var v=m(f[s[p]],c[o[p]]);if(v!==0)return v}return 0}});function xx(e,n){return e.re>n.re?1:e.re<n.re?-1:e.im>n.im?1:e.im<n.im?-1:0}var Jc="compareText",bx=["typed","matrix"],wx=R(Jc,bx,e=>{var{typed:n,matrix:a}=e,t=je({typed:n}),r=Ge({typed:n});return n(Jc,{"any, any":an,"DenseMatrix, DenseMatrix":function(l,m){return t(l,m,an)},"Array, Array":function(l,m){return this(a(l),a(m)).valueOf()},"Array, Matrix":function(l,m){return this(a(l),m)},"Matrix, Array":function(l,m){return this(l,a(m))},"DenseMatrix, any":function(l,m){return r(l,m,an,!1)},"any, DenseMatrix":function(l,m){return r(m,l,an,!0)},"Array, any":function(l,m){return r(a(l),m,an,!1).valueOf()},"any, Array":function(l,m){return r(a(m),l,an,!0).valueOf()}})}),Da="equal",Nx=["typed","matrix","equalScalar","DenseMatrix"],Mx=R(Da,Nx,e=>{var{typed:n,matrix:a,equalScalar:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Da,{"any, any":function(o,u){return o===null?u===null:u===null?o===null:o===void 0?u===void 0:u===void 0?o===void 0:t(o,u)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,t)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,t,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,t,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,t)},"Array, Array":function(o,u){return this(a(o),a(u)).valueOf()},"Array, Matrix":function(o,u){return this(a(o),u)},"Matrix, Array":function(o,u){return this(o,a(u))},"SparseMatrix, any":function(o,u){return m(o,u,t,!1)},"DenseMatrix, any":function(o,u){return c(o,u,t,!1)},"any, SparseMatrix":function(o,u){return m(u,o,t,!0)},"any, DenseMatrix":function(o,u){return c(u,o,t,!0)},"Array, any":function(o,u){return c(a(o),u,t,!1).valueOf()},"any, Array":function(o,u){return c(a(u),o,t,!0).valueOf()}})});R(Da,["typed","equalScalar"],e=>{var{typed:n,equalScalar:a}=e;return n(Da,{"any, any":function(r,i){return r===null?i===null:i===null?r===null:r===void 0?i===void 0:i===void 0?r===void 0:a(r,i)}})});var Qc="equalText",Ax=["typed","compareText","isZero"],Sx=R(Qc,Ax,e=>{var{typed:n,compareText:a,isZero:t}=e;return n(Qc,{"any, any":function(i,l){return t(a(i,l))}})}),Kc="smaller",Ex=["typed","config","matrix","DenseMatrix"],Cx=R(Kc,Ex,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(Kc,{"boolean, boolean":function(o,u){return o<u},"number, number":function(o,u){return o<u&&!Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.lt(u)&&!st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)===-1},"Complex, Complex":function(o,u){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),jc="smallerEq",Ox=["typed","config","matrix","DenseMatrix"],Dx=R(jc,Ox,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(jc,{"boolean, boolean":function(o,u){return o<=u},"number, number":function(o,u){return o<=u||Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.lte(u)||st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)!==1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),ef="larger",Tx=["typed","config","matrix","DenseMatrix"],Bx=R(ef,Tx,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(ef,{"boolean, boolean":function(o,u){return o>u},"number, number":function(o,u){return o>u&&!Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.gt(u)&&!st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)===1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),rf="largerEq",_x=["typed","config","matrix","DenseMatrix"],$x=R(rf,_x,e=>{var{typed:n,config:a,matrix:t,DenseMatrix:r}=e,i=Dr({typed:n}),l=ut({typed:n,DenseMatrix:r}),m=gr({typed:n,DenseMatrix:r}),f=je({typed:n}),c=Ge({typed:n});return n(rf,{"boolean, boolean":function(o,u){return o>=u},"number, number":function(o,u){return o>=u||Rr(o,u,a.epsilon)},"BigNumber, BigNumber":function(o,u){return o.gte(u)||st(o,u,a.epsilon)},"Fraction, Fraction":function(o,u){return o.compare(u)!==-1},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(o,u){if(!o.equalBase(u))throw new Error("Cannot compare units with different base");return this(o.value,u.value)},"SparseMatrix, SparseMatrix":function(o,u){return l(o,u,this)},"SparseMatrix, DenseMatrix":function(o,u){return i(u,o,this,!0)},"DenseMatrix, SparseMatrix":function(o,u){return i(o,u,this,!1)},"DenseMatrix, DenseMatrix":function(o,u){return f(o,u,this)},"Array, Array":function(o,u){return this(t(o),t(u)).valueOf()},"Array, Matrix":function(o,u){return this(t(o),u)},"Matrix, Array":function(o,u){return this(o,t(u))},"SparseMatrix, any":function(o,u){return m(o,u,this,!1)},"DenseMatrix, any":function(o,u){return c(o,u,this,!1)},"any, SparseMatrix":function(o,u){return m(u,o,this,!0)},"any, DenseMatrix":function(o,u){return c(u,o,this,!0)},"Array, any":function(o,u){return c(t(o),u,this,!1).valueOf()},"any, Array":function(o,u){return c(t(u),o,this,!0).valueOf()}})}),tf="deepEqual",Ix=["typed","equal"],qx=R(tf,Ix,e=>{var{typed:n,equal:a}=e;return n(tf,{"any, any":function(i,l){return t(i.valueOf(),l.valueOf())}});function t(r,i){if(Array.isArray(r))if(Array.isArray(i)){var l=r.length;if(l!==i.length)return!1;for(var m=0;m<l;m++)if(!t(r[m],i[m]))return!1;return!0}else return!1;else return Array.isArray(i)?!1:a(r,i)}}),Ci="unequal",Rx=["typed","config","equalScalar","matrix","DenseMatrix"],Fx=R(Ci,Rx,e=>{var{typed:n,config:a,equalScalar:t,matrix:r,DenseMatrix:i}=e,l=Dr({typed:n}),m=ut({typed:n,DenseMatrix:i}),f=gr({typed:n,DenseMatrix:i}),c=je({typed:n}),s=Ge({typed:n});return n("unequal",{"any, any":function(p,v){return p===null?v!==null:v===null?p!==null:p===void 0?v!==void 0:v===void 0?p!==void 0:o(p,v)},"SparseMatrix, SparseMatrix":function(p,v){return m(p,v,o)},"SparseMatrix, DenseMatrix":function(p,v){return l(v,p,o,!0)},"DenseMatrix, SparseMatrix":function(p,v){return l(p,v,o,!1)},"DenseMatrix, DenseMatrix":function(p,v){return c(p,v,o)},"Array, Array":function(p,v){return this(r(p),r(v)).valueOf()},"Array, Matrix":function(p,v){return this(r(p),v)},"Matrix, Array":function(p,v){return this(p,r(v))},"SparseMatrix, any":function(p,v){return f(p,v,o,!1)},"DenseMatrix, any":function(p,v){return s(p,v,o,!1)},"any, SparseMatrix":function(p,v){return f(v,p,o,!0)},"any, DenseMatrix":function(p,v){return s(v,p,o,!0)},"Array, any":function(p,v){return s(r(p),v,o,!1).valueOf()},"any, Array":function(p,v){return s(r(v),p,o,!0).valueOf()}});function o(u,p){return!t(u,p)}});R(Ci,["typed","equalScalar"],e=>{var{typed:n,equalScalar:a}=e;return n(Ci,{"any, any":function(r,i){return r===null?i!==null:i===null?r!==null:r===void 0?i!==void 0:i===void 0?r!==void 0:!a(r,i)}})});var nf="partitionSelect",zx=["typed","isNumeric","isNaN","compare"],Px=R(nf,zx,e=>{var{typed:n,isNumeric:a,isNaN:t,compare:r}=e,i=r,l=(c,s)=>-r(c,s);return n(nf,{"Array | Matrix, number":function(s,o){return m(s,o,i)},"Array | Matrix, number, string":function(s,o,u){if(u==="asc")return m(s,o,i);if(u==="desc")return m(s,o,l);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":m});function m(c,s,o){if(!Ae(s)||s<0)throw new Error("k must be a non-negative integer");if(Oe(c)){var u=c.size();if(u.length>1)throw new Error("Only one dimensional matrices supported");return f(c.valueOf(),s,o)}if(Array.isArray(c))return f(c,s,o)}function f(c,s,o){if(s>=c.length)throw new Error("k out of bounds");for(var u=0;u<c.length;u++)if(a(c[u])&&t(c[u]))return c[u];for(var p=0,v=c.length-1;p<v;){for(var h=p,b=v,w=c[Math.floor(Math.random()*(v-p+1))+p];h<b;)if(o(c[h],w)>=0){var N=c[b];c[b]=c[h],c[h]=N,--b}else++h;o(c[h],w)>0&&--h,s<=h?v=h:p=h+1}return c[s]}}),af="sort",Ux=["typed","matrix","compare","compareNatural"],Lx=R(af,Ux,e=>{var{typed:n,matrix:a,compare:t,compareNatural:r}=e,i=t,l=(s,o)=>-t(s,o);return n(af,{Array:function(o){return f(o),o.sort(i)},Matrix:function(o){return c(o),a(o.toArray().sort(i),o.storage())},"Array, function":function(o,u){return f(o),o.sort(u)},"Matrix, function":function(o,u){return c(o),a(o.toArray().sort(u),o.storage())},"Array, string":function(o,u){return f(o),o.sort(m(u))},"Matrix, string":function(o,u){return c(o),a(o.toArray().sort(m(u)),o.storage())}});function m(s){if(s==="asc")return i;if(s==="desc")return l;if(s==="natural")return r;throw new Error('String "asc", "desc", or "natural" expected')}function f(s){if(Pe(s).length!==1)throw new Error("One dimensional array expected")}function c(s){if(s.size().length!==1)throw new Error("One dimensional matrix expected")}}),of="max",kx=["typed","config","numeric","larger"],sf=R(of,kx,e=>{var{typed:n,config:a,numeric:t,larger:r}=e;return n(of,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(f,c){return xa(f,c.valueOf(),i)},"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function max");return l(f)}});function i(m,f){try{return r(m,f)?m:f}catch(c){throw Tr(c,"max",f)}}function l(m){var f;if(bt(m,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||r(c,f))&&(f=c)}catch(s){throw Tr(s,"max",c)}}),f===void 0)throw new Error("Cannot calculate max of an empty array");return typeof f=="string"&&(f=t(f,a.number)),f}}),uf="min",Hx=["typed","config","numeric","smaller"],cf=R(uf,Hx,e=>{var{typed:n,config:a,numeric:t,smaller:r}=e;return n(uf,{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(f,c){return xa(f,c.valueOf(),i)},"...":function(f){if(mn(f))throw new TypeError("Scalar values expected in function min");return l(f)}});function i(m,f){try{return r(m,f)?m:f}catch(c){throw Tr(c,"min",f)}}function l(m){var f;if(bt(m,function(c){try{isNaN(c)&&typeof c=="number"?f=NaN:(f===void 0||r(c,f))&&(f=c)}catch(s){throw Tr(s,"min",c)}}),f===void 0)throw new Error("Cannot calculate min of an empty array");return typeof f=="string"&&(f=t(f,a.number)),f}}),Gx="ImmutableDenseMatrix",Vx=["smaller","DenseMatrix"],Zx=R(Gx,Vx,e=>{var{smaller:n,DenseMatrix:a}=e;function t(r,i){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(i&&!_r(i))throw new Error("Invalid datatype: "+i);if(Oe(r)||Xe(r)){var l=new a(r,i);this._data=l._data,this._size=l._size,this._datatype=l._datatype,this._min=null,this._max=null}else if(r&&Xe(r.data)&&Xe(r.size))this._data=r.data,this._size=r.size,this._datatype=r.datatype,this._min=typeof r.min!="undefined"?r.min:null,this._max=typeof r.max!="undefined"?r.max:null;else{if(r)throw new TypeError("Unsupported type of data ("+Ke(r)+")");this._data=[],this._size=[0],this._datatype=i,this._min=null,this._max=null}}return t.prototype=new a,t.prototype.type="ImmutableDenseMatrix",t.prototype.isImmutableDenseMatrix=!0,t.prototype.subset=function(r){switch(arguments.length){case 1:{var i=a.prototype.subset.call(this,r);return Oe(i)?new t({data:i._data,size:i._size,datatype:i._datatype}):i}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},t.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},t.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},t.prototype.clone=function(){return new t({data:Ce(this._data),size:Ce(this._size),datatype:this._datatype})},t.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.fromJSON=function(r){return new t(r)},t.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},t.prototype.min=function(){if(this._min===null){var r=null;this.forEach(function(i){(r===null||n(i,r))&&(r=i)}),this._min=r!==null?r:void 0}return this._min},t.prototype.max=function(){if(this._max===null){var r=null;this.forEach(function(i){(r===null||n(r,i))&&(r=i)}),this._max=r!==null?r:void 0}return this._max},t},{isClass:!0}),Xx="Index",Yx=["ImmutableDenseMatrix"],Wx=R(Xx,Yx,e=>{var{ImmutableDenseMatrix:n}=e;function a(r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var i=0,l=arguments.length;i<l;i++){var m=arguments[i];if(Kn(m))this._dimensions.push(m),this._isScalar=!1;else if(Array.isArray(m)||Oe(m)){var f=t(m.valueOf());this._dimensions.push(f);var c=f.size();(c.length!==1||c[0]!==1)&&(this._isScalar=!1)}else if(typeof m=="number")this._dimensions.push(t([m]));else if(typeof m=="string")this._dimensions.push(m);else throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range")}}a.prototype.type="Index",a.prototype.isIndex=!0;function t(r){for(var i=0,l=r.length;i<l;i++)if(typeof r[i]!="number"||!Ae(r[i]))throw new TypeError("Index parameters must be positive integer numbers");return new n(r)}return a.prototype.clone=function(){var r=new a;return r._dimensions=Ce(this._dimensions),r._isScalar=this._isScalar,r},a.create=function(r){var i=new a;return a.apply(i,r),i},a.prototype.size=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?1:m.size()[0]}return r},a.prototype.max=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?m:m.max()}return r},a.prototype.min=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r[i]=typeof m=="string"?m:m.min()}return r},a.prototype.forEach=function(r){for(var i=0,l=this._dimensions.length;i<l;i++)r(this._dimensions[i],i,this)},a.prototype.dimension=function(r){return this._dimensions[r]||null},a.prototype.isObjectProperty=function(){return this._dimensions.length===1&&typeof this._dimensions[0]=="string"},a.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},a.prototype.isScalar=function(){return this._isScalar},a.prototype.toArray=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];r.push(typeof m=="string"?m:m.toArray())}return r},a.prototype.valueOf=a.prototype.toArray,a.prototype.toString=function(){for(var r=[],i=0,l=this._dimensions.length;i<l;i++){var m=this._dimensions[i];typeof m=="string"?r.push(JSON.stringify(m)):r.push(m.toString())}return"["+r.join(", ")+"]"},a.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},a.fromJSON=function(r){return a.create(r.dimensions)},a},{isClass:!0}),Jx="FibonacciHeap",Qx=["smaller","larger"],Kx=R(Jx,Qx,e=>{var{smaller:n,larger:a}=e,t=1/Math.log((1+Math.sqrt(5))/2);function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}r.prototype.type="FibonacciHeap",r.prototype.isFibonacciHeap=!0,r.prototype.insert=function(s,o){var u={key:s,value:o,degree:0};if(this._minimum){var p=this._minimum;u.left=p,u.right=p.right,p.right=u,u.right.left=u,n(s,p.key)&&(this._minimum=u)}else u.left=u,u.right=u,this._minimum=u;return this._size++,u},r.prototype.size=function(){return this._size},r.prototype.clear=function(){this._minimum=null,this._size=0},r.prototype.isEmpty=function(){return this._size===0},r.prototype.extractMinimum=function(){var s=this._minimum;if(s===null)return s;for(var o=this._minimum,u=s.degree,p=s.child;u>0;){var v=p.right;p.left.right=p.right,p.right.left=p.left,p.left=o,p.right=o.right,o.right=p,p.right.left=p,p.parent=null,p=v,u--}return s.left.right=s.right,s.right.left=s.left,s===s.right?o=null:(o=s.right,o=c(o,this._size)),this._size--,this._minimum=o,s},r.prototype.remove=function(s){this._minimum=i(this._minimum,s,-1),this.extractMinimum()};function i(s,o,u){o.key=u;var p=o.parent;return p&&n(o.key,p.key)&&(l(s,o,p),m(s,p)),n(o.key,s.key)&&(s=o),s}function l(s,o,u){o.left.right=o.right,o.right.left=o.left,u.degree--,u.child===o&&(u.child=o.right),u.degree===0&&(u.child=null),o.left=s,o.right=s.right,s.right=o,o.right.left=o,o.parent=null,o.mark=!1}function m(s,o){var u=o.parent;u&&(o.mark?(l(s,o,u),m(u)):o.mark=!0)}var f=function(o,u){o.left.right=o.right,o.right.left=o.left,o.parent=u,u.child?(o.left=u.child,o.right=u.child.right,u.child.right=o,o.right.left=o):(u.child=o,o.right=o,o.left=o),u.degree++,o.mark=!1};function c(s,o){var u=Math.floor(Math.log(o)*t)+1,p=new Array(u),v=0,h=s;if(h)for(v++,h=h.right;h!==s;)v++,h=h.right;for(var b;v>0;){for(var w=h.degree,N=h.right;b=p[w],!!b;){if(a(h.key,b.key)){var g=b;b=h,h=g}f(b,h),p[w]=null,w++}p[w]=h,h=N,v--}s=null;for(var y=0;y<u;y++)b=p[y],b&&(s?(b.left.right=b.right,b.right.left=b.left,b.left=s,b.right=s.right,s.right=b,b.right.left=b,n(b.key,s.key)&&(s=b)):s=b);return s}return r},{isClass:!0}),jx="Spa",eb=["addScalar","equalScalar","FibonacciHeap"],rb=R(jx,eb,e=>{var{addScalar:n,equalScalar:a,FibonacciHeap:t}=e;function r(){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new t}return r.prototype.type="Spa",r.prototype.isSpa=!0,r.prototype.set=function(i,l){if(this._values[i])this._values[i].value=l;else{var m=this._heap.insert(i,l);this._values[i]=m}},r.prototype.get=function(i){var l=this._values[i];return l?l.value:0},r.prototype.accumulate=function(i,l){var m=this._values[i];m?m.value=n(m.value,l):(m=this._heap.insert(i,l),this._values[i]=m)},r.prototype.forEach=function(i,l,m){var f=this._heap,c=this._values,s=[],o=f.extractMinimum();for(o&&s.push(o);o&&o.key<=l;)o.key>=i&&(a(o.value,0)||m(o.key,o.value,this)),o=f.extractMinimum(),o&&s.push(o);for(var u=0;u<s.length;u++){var p=s[u];o=f.insert(p.key,p.value),c[o.key]=o}},r.prototype.swap=function(i,l){var m=this._values[i],f=this._values[l];if(!m&&f)m=this._heap.insert(i,f.value),this._heap.remove(f),this._values[i]=m,this._values[l]=void 0;else if(m&&!f)f=this._heap.insert(l,m.value),this._heap.remove(m),this._values[l]=f,this._values[i]=void 0;else if(m&&f){var c=m.value;m.value=f.value,f.value=c}},r},{isClass:!0});function Fn(e){"@babel/helpers - typeof";return Fn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Fn(e)}function tb(e,n){if(Fn(e)!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var t=a.call(e,n);if(Fn(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function nb(e){var n=tb(e,"string");return Fn(n)=="symbol"?n:n+""}function ff(e,n,a){return(n=nb(n))in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}var ab=qn(function(e){return new e(1).exp()},{hasher:Ta}),ib=qn(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Ta}),Oi=qn(function(e){return e.acos(-1)},{hasher:Ta}),ob=qn(function(e){return Oi(e).times(2)},{hasher:Ta});function Ta(e){return e[0].precision}function lf(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),a.push.apply(a,t)}return a}function Di(e){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?lf(Object(a),!0).forEach(function(t){ff(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):lf(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var sb="Unit",ub=["?on","config","addScalar","subtract","multiplyScalar","divideScalar","pow","abs","fix","round","equal","isNumeric","format","number","Complex","BigNumber","Fraction"],cb=R(sb,ub,e=>{var{on:n,config:a,addScalar:t,subtract:r,multiplyScalar:i,divideScalar:l,pow:m,abs:f,fix:c,round:s,equal:o,isNumeric:u,format:p,number:v,Complex:h,BigNumber:b,Fraction:w}=e,N=v;function g(F,Y){if(!(this instanceof g))throw new Error("Constructor must be called with the new operator");if(!(F==null||u(F)||Or(F)))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(Y!==void 0&&(typeof Y!="string"||Y===""))throw new TypeError("Second parameter in Unit constructor must be a string");if(Y!==void 0){var k=g.parse(Y);this.units=k.units,this.dimensions=k.dimensions}else{this.units=[{unit:j,prefix:B.NONE,power:0}],this.dimensions=[];for(var U=0;U<G.length;U++)this.dimensions[U]=0}this.value=F!=null?this._normalize(F):null,this.fixPrefix=!1,this.skipAutomaticSimplification=!0}g.prototype.type="Unit",g.prototype.isUnit=!0;var y,x,d;function A(){for(;d===" "||d===" ";)M()}function S(F){return F>="0"&&F<="9"||F==="."}function O(F){return F>="0"&&F<="9"}function M(){x++,d=y.charAt(x)}function _(F){x=F,d=y.charAt(x)}function E(){var F="",Y=x;if(d==="+"?M():d==="-"&&(F+=d,M()),!S(d))return _(Y),null;if(d==="."){if(F+=d,M(),!O(d))return _(Y),null}else{for(;O(d);)F+=d,M();d==="."&&(F+=d,M())}for(;O(d);)F+=d,M();if(d==="E"||d==="e"){var k="",U=x;if(k+=d,M(),(d==="+"||d==="-")&&(k+=d,M()),!O(d))return _(U),F;for(F=F+k;O(d);)F+=d,M()}return F}function $(){for(var F="";O(d)||g.isValidAlpha(d);)F+=d,M();var Y=F.charAt(0);return g.isValidAlpha(Y)?F:null}function z(F){return d===F?(M(),F):null}g.parse=function(F,Y){if(Y=Y||{},y=F,x=-1,d="",typeof y!="string")throw new TypeError("Invalid argument in Unit.parse, string expected");var k=new g;k.units=[];var U=1,J=!1;M(),A();var q=E(),P=null;if(q){if(a.number==="BigNumber")P=new b(q);else if(a.number==="Fraction")try{P=new w(q)}catch(cr){P=parseFloat(q)}else P=parseFloat(q);A(),z("*")?(U=1,J=!0):z("/")&&(U=-1,J=!0)}for(var Q=[],L=1;;){for(A();d==="(";)Q.push(U),L*=U,U=1,M(),A();var se=void 0;if(d){var fe=d;if(se=$(),se===null)throw new SyntaxError('Unexpected "'+fe+'" in "'+y+'" at index '+x.toString())}else break;var ge=I(se);if(ge===null)throw new SyntaxError('Unit "'+se+'" not found.');var pe=U*L;if(A(),z("^")){A();var ve=E();if(ve===null)throw new SyntaxError('In "'+F+'", "^" must be followed by a floating-point number');pe*=ve}k.units.push({unit:ge.unit,prefix:ge.prefix,power:pe});for(var Ne=0;Ne<G.length;Ne++)k.dimensions[Ne]+=(ge.unit.dimensions[Ne]||0)*pe;for(A();d===")";){if(Q.length===0)throw new SyntaxError('Unmatched ")" in "'+y+'" at index '+x.toString());L/=Q.pop(),M(),A()}if(J=!1,z("*")?(U=1,J=!0):z("/")?(U=-1,J=!0):U=1,ge.unit.base){var Qe=ge.unit.base.key;re.auto[Qe]={unit:ge.unit,prefix:ge.prefix}}}if(A(),d)throw new SyntaxError('Could not parse: "'+F+'"');if(J)throw new SyntaxError('Trailing characters: "'+F+'"');if(Q.length!==0)throw new SyntaxError('Unmatched "(" in "'+y+'"');if(k.units.length===0&&!Y.allowNoUnits)throw new SyntaxError('"'+F+'" contains no units');return k.value=P!==void 0?k._normalize(P):null,k},g.prototype.clone=function(){var F=new g;F.fixPrefix=this.fixPrefix,F.skipAutomaticSimplification=this.skipAutomaticSimplification,F.value=Ce(this.value),F.dimensions=this.dimensions.slice(0),F.units=[];for(var Y=0;Y<this.units.length;Y++){F.units[Y]={};for(var k in this.units[Y])Me(this.units[Y],k)&&(F.units[Y][k]=this.units[Y][k])}return F},g.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},g.prototype._normalize=function(F){if(F==null||this.units.length===0)return F;for(var Y=F,k=g._getNumberConverter(Ke(F)),U=0;U<this.units.length;U++){var J=k(this.units[U].unit.value),q=k(this.units[U].prefix.value),P=k(this.units[U].power);Y=i(Y,m(i(J,q),P))}return Y},g.prototype._denormalize=function(F,Y){if(F==null||this.units.length===0)return F;for(var k=F,U=g._getNumberConverter(Ke(F)),J=0;J<this.units.length;J++){var q=U(this.units[J].unit.value),P=U(this.units[J].prefix.value),Q=U(this.units[J].power);k=l(k,m(i(q,P),Q))}return k};var I=qn(F=>{if(Me(V,F)){var Y=V[F],k=Y.prefixes[""];return{unit:Y,prefix:k}}for(var U in V)if(Me(V,U)&&sv(F,U)){var J=V[U],q=F.length-U.length,P=F.substring(0,q),Q=Me(J.prefixes,P)?J.prefixes[P]:void 0;if(Q!==void 0)return{unit:J,prefix:Q}}return null},{hasher:F=>F[0],limit:100});g.isValuelessUnit=function(F){return I(F)!==null},g.prototype.hasBase=function(F){if(typeof F=="string"&&(F=D[F]),!F)return!1;for(var Y=0;Y<G.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(F.dimensions[Y]||0))>1e-12)return!1;return!0},g.prototype.equalBase=function(F){for(var Y=0;Y<G.length;Y++)if(Math.abs((this.dimensions[Y]||0)-(F.dimensions[Y]||0))>1e-12)return!1;return!0},g.prototype.equals=function(F){return this.equalBase(F)&&o(this.value,F.value)},g.prototype.multiply=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)+(F.dimensions[k]||0);for(var U=0;U<F.units.length;U++){var J=Di({},F.units[U]);Y.units.push(J)}if(this.value!==null||F.value!==null){var q=this.value===null?this._normalize(1):this.value,P=F.value===null?F._normalize(1):F.value;Y.value=i(q,P)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},g.prototype.divide=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)-(F.dimensions[k]||0);for(var U=0;U<F.units.length;U++){var J=Di(Di({},F.units[U]),{},{power:-F.units[U].power});Y.units.push(J)}if(this.value!==null||F.value!==null){var q=this.value===null?this._normalize(1):this.value,P=F.value===null?F._normalize(1):F.value;Y.value=l(q,P)}else Y.value=null;return Y.skipAutomaticSimplification=!1,T(Y)},g.prototype.pow=function(F){for(var Y=this.clone(),k=0;k<G.length;k++)Y.dimensions[k]=(this.dimensions[k]||0)*F;for(var U=0;U<Y.units.length;U++)Y.units[U].power*=F;return Y.value!==null?Y.value=m(Y.value,F):Y.value=null,Y.skipAutomaticSimplification=!1,T(Y)};function T(F){return F.equalBase(D.NONE)&&F.value!==null&&!a.predictable?F.value:F}g.prototype.abs=function(){var F=this.clone();if(F.value!==null)if(F._isDerived()||F.units[0].unit.offset===0)F.value=f(F.value);else{var Y=g._getNumberConverter(Ke(F.value)),k=Y(F.units[0].unit.value),U=Y(F.units[0].unit.offset),J=i(k,U);F.value=r(f(t(F.value,J)),J)}for(var q in F.units)(F.units[q].unit.name==="VA"||F.units[q].unit.name==="VAR")&&(F.units[q].unit=V.W);return F},g.prototype.to=function(F){var Y=this.value===null?this._normalize(1):this.value,k;if(typeof F=="string")k=g.parse(F);else if(ht(F))k=F.clone();else throw new Error("String or Unit expected as parameter");if(!this.equalBase(k))throw new Error("Units do not match ('".concat(k.toString(),"' != '").concat(this.toString(),"')"));if(k.value!==null)throw new Error("Cannot convert to a unit with a value");if(this.value===null||this._isDerived()||this.units[0].unit.offset===k.units[0].unit.offset)k.value=Ce(Y);else{var U=g._getNumberConverter(Ke(Y)),J=U(this.units[0].unit.value),q=U(this.units[0].unit.offset),P=i(J,q),Q=U(k.units[0].unit.value),L=U(k.units[0].unit.offset),se=i(Q,L);k.value=r(t(Y,P),se)}return k.fixPrefix=!0,k.skipAutomaticSimplification=!0,k},g.prototype.toNumber=function(F){return N(this.toNumeric(F))},g.prototype.toNumeric=function(F){var Y;return F?Y=this.to(F):Y=this.clone(),Y._isDerived()||Y.units.length===0?Y._denormalize(Y.value):Y._denormalize(Y.value,Y.units[0].prefix.value)},g.prototype.toString=function(){return this.format()},g.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},g.fromJSON=function(F){var Y=new g(F.value,F.unit);return Y.fixPrefix=F.fixPrefix||!1,Y},g.prototype.valueOf=g.prototype.toString,g.prototype.simplify=function(){var F=this.clone(),Y=[],k;for(var U in ie)if(Me(ie,U)&&F.hasBase(D[U])){k=U;break}if(k==="NONE")F.units=[];else{var J;if(k&&Me(ie,k)&&(J=ie[k]),J)F.units=[{unit:J.unit,prefix:J.prefix,power:1}];else{for(var q=!1,P=0;P<G.length;P++){var Q=G[P];Math.abs(F.dimensions[P]||0)>1e-12&&(Me(ie,Q)?Y.push({unit:ie[Q].unit,prefix:ie[Q].prefix,power:F.dimensions[P]||0}):q=!0)}Y.length<F.units.length&&!q&&(F.units=Y)}}return F},g.prototype.toSI=function(){for(var F=this.clone(),Y=[],k=0;k<G.length;k++){var U=G[k];if(Math.abs(F.dimensions[k]||0)>1e-12)if(Me(re.si,U))Y.push({unit:re.si[U].unit,prefix:re.si[U].prefix,power:F.dimensions[k]||0});else throw new Error("Cannot express custom unit "+U+" in SI units")}return F.units=Y,F.fixPrefix=!0,F.skipAutomaticSimplification=!0,F},g.prototype.formatUnits=function(){for(var F="",Y="",k=0,U=0,J=0;J<this.units.length;J++)this.units[J].power>0?(k++,F+=" "+this.units[J].prefix.name+this.units[J].unit.name,Math.abs(this.units[J].power-1)>1e-15&&(F+="^"+this.units[J].power)):this.units[J].power<0&&U++;if(U>0)for(var q=0;q<this.units.length;q++)this.units[q].power<0&&(k>0?(Y+=" "+this.units[q].prefix.name+this.units[q].unit.name,Math.abs(this.units[q].power+1)>1e-15&&(Y+="^"+-this.units[q].power)):(Y+=" "+this.units[q].prefix.name+this.units[q].unit.name,Y+="^"+this.units[q].power));F=F.substr(1),Y=Y.substr(1),k>1&&U>0&&(F="("+F+")"),U>1&&k>0&&(Y="("+Y+")");var P=F;return k>0&&U>0&&(P+=" / "),P+=Y,P},g.prototype.format=function(F){var Y=this.skipAutomaticSimplification||this.value===null?this.clone():this.simplify(),k=!1;typeof Y.value!="undefined"&&Y.value!==null&&Or(Y.value)&&(k=Math.abs(Y.value.re)<1e-14);for(var U in Y.units)Me(Y.units,U)&&Y.units[U].unit&&(Y.units[U].unit.name==="VA"&&k?Y.units[U].unit=V.VAR:Y.units[U].unit.name==="VAR"&&!k&&(Y.units[U].unit=V.VA));Y.units.length===1&&!Y.fixPrefix&&Math.abs(Y.units[0].power-Math.round(Y.units[0].power))<1e-14&&(Y.units[0].prefix=Y._bestPrefix());var J=Y._denormalize(Y.value),q=Y.value!==null?p(J,F||{}):"",P=Y.formatUnits();return Y.value&&Or(Y.value)&&(q="("+q+")"),P.length>0&&q.length>0&&(q+=" "),q+=P,q},g.prototype._bestPrefix=function(){if(this.units.length!==1)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var F=this.value!==null?f(this.value):0,Y=f(this.units[0].unit.value),k=this.units[0].prefix;if(F===0)return k;var U=this.units[0].power,J=Math.log(F/Math.pow(k.value*Y,U))/Math.LN10-1.2;if(J>-2.200001&&J<1.800001)return k;J=Math.abs(J);var q=this.units[0].unit.prefixes;for(var P in q)if(Me(q,P)){var Q=q[P];if(Q.scientific){var L=Math.abs(Math.log(F/Math.pow(Q.value*Y,U))/Math.LN10-1.2);(L<J||L===J&&Q.name.length<k.name.length)&&(k=Q,J=L)}}return k},g.prototype.splitUnit=function(F){for(var Y=this.clone(),k=[],U=0;U<F.length&&(Y=Y.to(F[U]),U!==F.length-1);U++){var J=Y.toNumeric(),q=s(J),P=void 0,Q=o(q,J);Q?P=q:P=c(Y.toNumeric());var L=new g(P,F[U].toString());k.push(L),Y=r(Y,L)}for(var se=0,fe=0;fe<k.length;fe++)se=t(se,k[fe].value);return o(se,this.value)&&(Y.value=0),k.push(Y),k};var B={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-48,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT_SI:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:"",value:1,scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG_SI:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:"",value:1,scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}},BTU:{"":{name:"",value:1,scientific:!0},MM:{name:"MM",value:1e6,scientific:!0}}};B.SHORTLONG=ar({},B.SHORT,B.LONG),B.BINARY_SHORT=ar({},B.BINARY_SHORT_SI,B.BINARY_SHORT_IEC),B.BINARY_LONG=ar({},B.BINARY_LONG_SI,B.BINARY_LONG_IEC);var G=["MASS","LENGTH","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","ANGLE","BIT"],D={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var H in D)Me(D,H)&&(D[H].key=H);var W={},j={name:"",base:W,value:1,offset:0,dimensions:G.map(F=>0)},V={meter:{name:"meter",base:D.LENGTH,prefixes:B.LONG,value:1,offset:0},inch:{name:"inch",base:D.LENGTH,prefixes:B.NONE,value:.0254,offset:0},foot:{name:"foot",base:D.LENGTH,prefixes:B.NONE,value:.3048,offset:0},yard:{name:"yard",base:D.LENGTH,prefixes:B.NONE,value:.9144,offset:0},mile:{name:"mile",base:D.LENGTH,prefixes:B.NONE,value:1609.344,offset:0},link:{name:"link",base:D.LENGTH,prefixes:B.NONE,value:.201168,offset:0},rod:{name:"rod",base:D.LENGTH,prefixes:B.NONE,value:5.0292,offset:0},chain:{name:"chain",base:D.LENGTH,prefixes:B.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:D.LENGTH,prefixes:B.NONE,value:1e-10,offset:0},m:{name:"m",base:D.LENGTH,prefixes:B.SHORT,value:1,offset:0},in:{name:"in",base:D.LENGTH,prefixes:B.NONE,value:.0254,offset:0},ft:{name:"ft",base:D.LENGTH,prefixes:B.NONE,value:.3048,offset:0},yd:{name:"yd",base:D.LENGTH,prefixes:B.NONE,value:.9144,offset:0},mi:{name:"mi",base:D.LENGTH,prefixes:B.NONE,value:1609.344,offset:0},li:{name:"li",base:D.LENGTH,prefixes:B.NONE,value:.201168,offset:0},rd:{name:"rd",base:D.LENGTH,prefixes:B.NONE,value:5.02921,offset:0},ch:{name:"ch",base:D.LENGTH,prefixes:B.NONE,value:20.1168,offset:0},mil:{name:"mil",base:D.LENGTH,prefixes:B.NONE,value:254e-7,offset:0},m2:{name:"m2",base:D.SURFACE,prefixes:B.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:D.SURFACE,prefixes:B.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:D.SURFACE,prefixes:B.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:D.SURFACE,prefixes:B.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:D.SURFACE,prefixes:B.NONE,value:2589988110336e-6,offset:0},sqrd:{name:"sqrd",base:D.SURFACE,prefixes:B.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:D.SURFACE,prefixes:B.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:D.SURFACE,prefixes:B.NONE,value:64516e-14,offset:0},acre:{name:"acre",base:D.SURFACE,prefixes:B.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:D.SURFACE,prefixes:B.NONE,value:1e4,offset:0},m3:{name:"m3",base:D.VOLUME,prefixes:B.CUBIC,value:1,offset:0},L:{name:"L",base:D.VOLUME,prefixes:B.SHORT,value:.001,offset:0},l:{name:"l",base:D.VOLUME,prefixes:B.SHORT,value:.001,offset:0},litre:{name:"litre",base:D.VOLUME,prefixes:B.LONG,value:.001,offset:0},cuin:{name:"cuin",base:D.VOLUME,prefixes:B.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:D.VOLUME,prefixes:B.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:D.VOLUME,prefixes:B.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:D.VOLUME,prefixes:B.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:D.VOLUME,prefixes:B.NONE,value:15e-6,offset:0},drop:{name:"drop",base:D.VOLUME,prefixes:B.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:D.VOLUME,prefixes:B.NONE,value:5e-8,offset:0},minim:{name:"minim",base:D.VOLUME,prefixes:B.NONE,value:6161152e-14,offset:0},fluiddram:{name:"fluiddram",base:D.VOLUME,prefixes:B.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:D.VOLUME,prefixes:B.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:D.VOLUME,prefixes:B.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:D.VOLUME,prefixes:B.NONE,value:1e-6,offset:0},cup:{name:"cup",base:D.VOLUME,prefixes:B.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:D.VOLUME,prefixes:B.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:D.VOLUME,prefixes:B.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:D.VOLUME,prefixes:B.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:D.VOLUME,prefixes:B.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:D.VOLUME,prefixes:B.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:D.VOLUME,prefixes:B.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:D.VOLUME,prefixes:B.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:D.VOLUME,prefixes:B.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:D.VOLUME,prefixes:B.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:D.VOLUME,prefixes:B.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:D.VOLUME,prefixes:B.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:D.VOLUME,prefixes:B.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:D.VOLUME,prefixes:B.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:D.VOLUME,prefixes:B.NONE,value:.1173478,offset:0},obl:{name:"obl",base:D.VOLUME,prefixes:B.NONE,value:.1589873,offset:0},g:{name:"g",base:D.MASS,prefixes:B.SHORT,value:.001,offset:0},gram:{name:"gram",base:D.MASS,prefixes:B.LONG,value:.001,offset:0},ton:{name:"ton",base:D.MASS,prefixes:B.SHORT,value:907.18474,offset:0},t:{name:"t",base:D.MASS,prefixes:B.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:D.MASS,prefixes:B.LONG,value:1e3,offset:0},grain:{name:"grain",base:D.MASS,prefixes:B.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:D.MASS,prefixes:B.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:D.MASS,prefixes:B.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:D.MASS,prefixes:B.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:D.MASS,prefixes:B.NONE,value:45.359237,offset:0},stick:{name:"stick",base:D.MASS,prefixes:B.NONE,value:.115,offset:0},stone:{name:"stone",base:D.MASS,prefixes:B.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:D.MASS,prefixes:B.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:D.MASS,prefixes:B.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:D.MASS,prefixes:B.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:D.MASS,prefixes:B.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:D.MASS,prefixes:B.NONE,value:45.359237,offset:0},s:{name:"s",base:D.TIME,prefixes:B.SHORT,value:1,offset:0},min:{name:"min",base:D.TIME,prefixes:B.NONE,value:60,offset:0},h:{name:"h",base:D.TIME,prefixes:B.NONE,value:3600,offset:0},second:{name:"second",base:D.TIME,prefixes:B.LONG,value:1,offset:0},sec:{name:"sec",base:D.TIME,prefixes:B.LONG,value:1,offset:0},minute:{name:"minute",base:D.TIME,prefixes:B.NONE,value:60,offset:0},hour:{name:"hour",base:D.TIME,prefixes:B.NONE,value:3600,offset:0},day:{name:"day",base:D.TIME,prefixes:B.NONE,value:86400,offset:0},week:{name:"week",base:D.TIME,prefixes:B.NONE,value:7*86400,offset:0},month:{name:"month",base:D.TIME,prefixes:B.NONE,value:2629800,offset:0},year:{name:"year",base:D.TIME,prefixes:B.NONE,value:31557600,offset:0},decade:{name:"decade",base:D.TIME,prefixes:B.NONE,value:315576e3,offset:0},century:{name:"century",base:D.TIME,prefixes:B.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:D.TIME,prefixes:B.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:D.FREQUENCY,prefixes:B.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:D.FREQUENCY,prefixes:B.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:D.ANGLE,prefixes:B.SHORT,value:1,offset:0},radian:{name:"radian",base:D.ANGLE,prefixes:B.LONG,value:1,offset:0},deg:{name:"deg",base:D.ANGLE,prefixes:B.SHORT,value:null,offset:0},degree:{name:"degree",base:D.ANGLE,prefixes:B.LONG,value:null,offset:0},grad:{name:"grad",base:D.ANGLE,prefixes:B.SHORT,value:null,offset:0},gradian:{name:"gradian",base:D.ANGLE,prefixes:B.LONG,value:null,offset:0},cycle:{name:"cycle",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:D.ANGLE,prefixes:B.NONE,value:null,offset:0},A:{name:"A",base:D.CURRENT,prefixes:B.SHORT,value:1,offset:0},ampere:{name:"ampere",base:D.CURRENT,prefixes:B.LONG,value:1,offset:0},K:{name:"K",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:0},degC:{name:"degC",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:273.15},degF:{name:"degF",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:0},celsius:{name:"celsius",base:D.TEMPERATURE,prefixes:B.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:D.TEMPERATURE,prefixes:B.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:D.AMOUNT_OF_SUBSTANCE,prefixes:B.SHORT,value:1,offset:0},mole:{name:"mole",base:D.AMOUNT_OF_SUBSTANCE,prefixes:B.LONG,value:1,offset:0},cd:{name:"cd",base:D.LUMINOUS_INTENSITY,prefixes:B.SHORT,value:1,offset:0},candela:{name:"candela",base:D.LUMINOUS_INTENSITY,prefixes:B.LONG,value:1,offset:0},N:{name:"N",base:D.FORCE,prefixes:B.SHORT,value:1,offset:0},newton:{name:"newton",base:D.FORCE,prefixes:B.LONG,value:1,offset:0},dyn:{name:"dyn",base:D.FORCE,prefixes:B.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:D.FORCE,prefixes:B.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:D.FORCE,prefixes:B.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:D.FORCE,prefixes:B.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:D.FORCE,prefixes:B.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:D.FORCE,prefixes:B.NONE,value:9.80665,offset:0},J:{name:"J",base:D.ENERGY,prefixes:B.SHORT,value:1,offset:0},joule:{name:"joule",base:D.ENERGY,prefixes:B.SHORT,value:1,offset:0},erg:{name:"erg",base:D.ENERGY,prefixes:B.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:D.ENERGY,prefixes:B.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:D.ENERGY,prefixes:B.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:D.ENERGY,prefixes:B.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:D.ENERGY,prefixes:B.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:D.POWER,prefixes:B.SHORT,value:1,offset:0},watt:{name:"watt",base:D.POWER,prefixes:B.LONG,value:1,offset:0},hp:{name:"hp",base:D.POWER,prefixes:B.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:D.POWER,prefixes:B.SHORT,value:h.I,offset:0},VA:{name:"VA",base:D.POWER,prefixes:B.SHORT,value:1,offset:0},Pa:{name:"Pa",base:D.PRESSURE,prefixes:B.SHORT,value:1,offset:0},psi:{name:"psi",base:D.PRESSURE,prefixes:B.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:D.PRESSURE,prefixes:B.NONE,value:101325,offset:0},bar:{name:"bar",base:D.PRESSURE,prefixes:B.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:D.PRESSURE,prefixes:B.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:D.PRESSURE,prefixes:B.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:D.PRESSURE,prefixes:B.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:D.PRESSURE,prefixes:B.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:D.ELECTRIC_CHARGE,prefixes:B.LONG,value:1,offset:0},C:{name:"C",base:D.ELECTRIC_CHARGE,prefixes:B.SHORT,value:1,offset:0},farad:{name:"farad",base:D.ELECTRIC_CAPACITANCE,prefixes:B.LONG,value:1,offset:0},F:{name:"F",base:D.ELECTRIC_CAPACITANCE,prefixes:B.SHORT,value:1,offset:0},volt:{name:"volt",base:D.ELECTRIC_POTENTIAL,prefixes:B.LONG,value:1,offset:0},V:{name:"V",base:D.ELECTRIC_POTENTIAL,prefixes:B.SHORT,value:1,offset:0},ohm:{name:"ohm",base:D.ELECTRIC_RESISTANCE,prefixes:B.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:D.ELECTRIC_INDUCTANCE,prefixes:B.LONG,value:1,offset:0},H:{name:"H",base:D.ELECTRIC_INDUCTANCE,prefixes:B.SHORT,value:1,offset:0},siemens:{name:"siemens",base:D.ELECTRIC_CONDUCTANCE,prefixes:B.LONG,value:1,offset:0},S:{name:"S",base:D.ELECTRIC_CONDUCTANCE,prefixes:B.SHORT,value:1,offset:0},weber:{name:"weber",base:D.MAGNETIC_FLUX,prefixes:B.LONG,value:1,offset:0},Wb:{name:"Wb",base:D.MAGNETIC_FLUX,prefixes:B.SHORT,value:1,offset:0},tesla:{name:"tesla",base:D.MAGNETIC_FLUX_DENSITY,prefixes:B.LONG,value:1,offset:0},T:{name:"T",base:D.MAGNETIC_FLUX_DENSITY,prefixes:B.SHORT,value:1,offset:0},b:{name:"b",base:D.BIT,prefixes:B.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:D.BIT,prefixes:B.BINARY_LONG,value:1,offset:0},B:{name:"B",base:D.BIT,prefixes:B.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:D.BIT,prefixes:B.BINARY_LONG,value:8,offset:0}},K={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function te(F){if(F.number==="BigNumber"){var Y=Oi(b);V.rad.value=new b(1),V.deg.value=Y.div(180),V.grad.value=Y.div(200),V.cycle.value=Y.times(2),V.arcsec.value=Y.div(648e3),V.arcmin.value=Y.div(10800)}else V.rad.value=1,V.deg.value=Math.PI/180,V.grad.value=Math.PI/200,V.cycle.value=Math.PI*2,V.arcsec.value=Math.PI/648e3,V.arcmin.value=Math.PI/10800;V.radian.value=V.rad.value,V.degree.value=V.deg.value,V.gradian.value=V.grad.value}te(a),n&&n("config",function(F,Y){F.number!==Y.number&&te(F)});var re={si:{NONE:{unit:j,prefix:B.NONE[""]},LENGTH:{unit:V.m,prefix:B.SHORT[""]},MASS:{unit:V.g,prefix:B.SHORT.k},TIME:{unit:V.s,prefix:B.SHORT[""]},CURRENT:{unit:V.A,prefix:B.SHORT[""]},TEMPERATURE:{unit:V.K,prefix:B.SHORT[""]},LUMINOUS_INTENSITY:{unit:V.cd,prefix:B.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:V.mol,prefix:B.SHORT[""]},ANGLE:{unit:V.rad,prefix:B.SHORT[""]},BIT:{unit:V.bits,prefix:B.SHORT[""]},FORCE:{unit:V.N,prefix:B.SHORT[""]},ENERGY:{unit:V.J,prefix:B.SHORT[""]},POWER:{unit:V.W,prefix:B.SHORT[""]},PRESSURE:{unit:V.Pa,prefix:B.SHORT[""]},ELECTRIC_CHARGE:{unit:V.C,prefix:B.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:V.F,prefix:B.SHORT[""]},ELECTRIC_POTENTIAL:{unit:V.V,prefix:B.SHORT[""]},ELECTRIC_RESISTANCE:{unit:V.ohm,prefix:B.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:V.H,prefix:B.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:V.S,prefix:B.SHORT[""]},MAGNETIC_FLUX:{unit:V.Wb,prefix:B.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:V.T,prefix:B.SHORT[""]},FREQUENCY:{unit:V.Hz,prefix:B.SHORT[""]}}};re.cgs=JSON.parse(JSON.stringify(re.si)),re.cgs.LENGTH={unit:V.m,prefix:B.SHORT.c},re.cgs.MASS={unit:V.g,prefix:B.SHORT[""]},re.cgs.FORCE={unit:V.dyn,prefix:B.SHORT[""]},re.cgs.ENERGY={unit:V.erg,prefix:B.NONE[""]},re.us=JSON.parse(JSON.stringify(re.si)),re.us.LENGTH={unit:V.ft,prefix:B.NONE[""]},re.us.MASS={unit:V.lbm,prefix:B.NONE[""]},re.us.TEMPERATURE={unit:V.degF,prefix:B.NONE[""]},re.us.FORCE={unit:V.lbf,prefix:B.NONE[""]},re.us.ENERGY={unit:V.BTU,prefix:B.BTU[""]},re.us.POWER={unit:V.hp,prefix:B.NONE[""]},re.us.PRESSURE={unit:V.psi,prefix:B.NONE[""]},re.auto=JSON.parse(JSON.stringify(re.si));var ie=re.auto;g.setUnitSystem=function(F){if(Me(re,F))ie=re[F];else throw new Error("Unit system "+F+" does not exist. Choices are: "+Object.keys(re).join(", "))},g.getUnitSystem=function(){for(var F in re)if(Me(re,F)&&re[F]===ie)return F},g.typeConverters={BigNumber:function(Y){return new b(Y+"")},Fraction:function(Y){return new w(Y)},Complex:function(Y){return Y},number:function(Y){return Y}},g._getNumberConverter=function(F){if(!g.typeConverters[F])throw new TypeError('Unsupported type "'+F+'"');return g.typeConverters[F]};for(var ne in V)if(Me(V,ne)){var ue=V[ne];ue.dimensions=ue.base.dimensions}for(var ee in K)if(Me(K,ee)){var ye=V[K[ee]],we={};for(var me in ye)Me(ye,me)&&(we[me]=ye[me]);we.name=ee,V[ee]=we}g.isValidAlpha=function(Y){return/^[a-zA-Z]$/.test(Y)};function xe(F){for(var Y=0;Y<F.length;Y++){if(d=F.charAt(Y),Y===0&&!g.isValidAlpha(d))throw new Error('Invalid unit name (must begin with alpha character): "'+F+'"');if(Y>0&&!(g.isValidAlpha(d)||O(d)))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+F+'"')}}return g.createUnit=function(F,Y){if(typeof F!="object")throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(Y&&Y.override){for(var k in F)if(Me(F,k)&&g.deleteUnit(k),F[k].aliases)for(var U=0;U<F[k].aliases.length;U++)g.deleteUnit(F[k].aliases[U])}var J;for(var q in F)Me(F,q)&&(J=g.createUnitSingle(q,F[q]));return J},g.createUnitSingle=function(F,Y,k){if((typeof Y=="undefined"||Y===null)&&(Y={}),typeof F!="string")throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");if(Me(V,F))throw new Error('Cannot create unit "'+F+'": a unit with that name already exists');xe(F);var U=null,J=[],q=0,P,Q,L;if(Y&&Y.type==="Unit")U=Y.clone();else if(typeof Y=="string")Y!==""&&(P=Y);else if(typeof Y=="object")P=Y.definition,Q=Y.prefixes,q=Y.offset,L=Y.baseName,Y.aliases&&(J=Y.aliases.valueOf());else throw new TypeError('Cannot create unit "'+F+'" from "'+Y.toString()+'": expecting "string" or "Unit" or "Object"');if(J){for(var se=0;se<J.length;se++)if(Me(V,J[se]))throw new Error('Cannot create alias "'+J[se]+'": a unit with that name already exists')}if(P&&typeof P=="string"&&!U)try{U=g.parse(P,{allowNoUnits:!0})}catch(C){throw C.message='Could not create unit "'+F+'" from "'+P+'": '+C.message,C}else P&&P.type==="Unit"&&(U=P.clone());J=J||[],q=q||0,Q&&Q.toUpperCase?Q=B[Q.toUpperCase()]||B.NONE:Q=B.NONE;var fe={};if(U){fe={name:F,value:U.value,dimensions:U.dimensions.slice(0),prefixes:Q,offset:q};var Ne=!1;for(var Qe in D)if(Me(D,Qe)){for(var cr=!0,tr=0;tr<G.length;tr++)if(Math.abs((fe.dimensions[tr]||0)-(D[Qe].dimensions[tr]||0))>1e-12){cr=!1;break}if(cr){Ne=!0,fe.base=D[Qe];break}}if(!Ne){L=L||F+"_STUFF";var Jr={dimensions:U.dimensions.slice(0)};Jr.key=L,D[L]=Jr,ie[L]={unit:fe,prefix:B.NONE[""]},fe.base=D[L]}}else{if(L=L||F+"_STUFF",G.indexOf(L)>=0)throw new Error('Cannot create new base unit "'+F+'": a base unit with that name already exists (and cannot be overridden)');G.push(L);for(var ge in D)Me(D,ge)&&(D[ge].dimensions[G.length-1]=0);for(var pe={dimensions:[]},ve=0;ve<G.length;ve++)pe.dimensions[ve]=0;pe.dimensions[G.length-1]=1,pe.key=L,D[L]=pe,fe={name:F,value:1,dimensions:D[L].dimensions.slice(0),prefixes:Q,offset:q,base:D[L]},ie[L]={unit:fe,prefix:B.NONE[""]}}g.UNITS[F]=fe;for(var Lr=0;Lr<J.length;Lr++){var Ot=J[Lr],Ze={};for(var Pt in fe)Me(fe,Pt)&&(Ze[Pt]=fe[Pt]);Ze.name=Ot,g.UNITS[Ot]=Ze}return delete I.cache,new g(null,F)},g.deleteUnit=function(F){delete g.UNITS[F]},g.PREFIXES=B,g.BASE_DIMENSIONS=G,g.BASE_UNITS=D,g.UNIT_SYSTEMS=re,g.UNITS=V,g},{isClass:!0}),mf="unit",fb=["typed","Unit"],lb=R(mf,fb,e=>{var{typed:n,Unit:a}=e;return n(mf,{Unit:function(r){return r.clone()},string:function(r){return a.isValuelessUnit(r)?new a(null,r):a.parse(r,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(r,i){return new a(r,i)},"Array | Matrix":function(r){return be(r,this)}})}),pf="sparse",mb=["typed","SparseMatrix"],pb=R(pf,mb,e=>{var{typed:n,SparseMatrix:a}=e;return n(pf,{"":function(){return new a([])},string:function(r){return new a([],r)},"Array | Matrix":function(r){return new a(r)},"Array | Matrix, string":function(r,i){return new a(r,i)}})}),vf="createUnit",vb=["typed","Unit"],hb=R(vf,vb,e=>{var{typed:n,Unit:a}=e;return n(vf,{"Object, Object":function(r,i){return a.createUnit(r,i)},Object:function(r){return a.createUnit(r,{})},"string, Unit | string | Object, Object":function(r,i,l){var m={};return m[r]=i,a.createUnit(m,l)},"string, Unit | string | Object":function(r,i){var l={};return l[r]=i,a.createUnit(l,{})},string:function(r){var i={};return i[r]={},a.createUnit(i,{})}})}),hf="acos",db=["typed","config","Complex"],gb=R(hf,db,e=>{var{typed:n,config:a,Complex:t}=e;return n(hf,{number:function(i){return i>=-1&&i<=1||a.predictable?Math.acos(i):new t(i,0).acos()},Complex:function(i){return i.acos()},BigNumber:function(i){return i.acos()},"Array | Matrix":function(i){return be(i,this)}})}),df="acosh",yb=["typed","config","Complex"],xb=R(df,yb,e=>{var{typed:n,config:a,Complex:t}=e;return n(df,{number:function(i){return i>=1||a.predictable?Ss(i):i<=-1?new t(Math.log(Math.sqrt(i*i-1)-i),Math.PI):new t(i,0).acosh()},Complex:function(i){return i.acosh()},BigNumber:function(i){return i.acosh()},"Array | Matrix":function(i){return be(i,this)}})}),gf="acot",bb=["typed","BigNumber"],wb=R(gf,bb,e=>{var{typed:n,BigNumber:a}=e;return n(gf,{number:Es,Complex:function(r){return r.acot()},BigNumber:function(r){return new a(1).div(r).atan()},"Array | Matrix":function(r){return be(r,this)}})}),yf="acoth",Nb=["typed","config","Complex","BigNumber"],Mb=R(yf,Nb,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(yf,{number:function(l){return l>=1||l<=-1||a.predictable?Cs(l):new t(l,0).acoth()},Complex:function(l){return l.acoth()},BigNumber:function(l){return new r(1).div(l).atanh()},"Array | Matrix":function(l){return be(l,this)}})}),xf="acsc",Ab=["typed","config","Complex","BigNumber"],Sb=R(xf,Ab,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(xf,{number:function(l){return l<=-1||l>=1||a.predictable?Os(l):new t(l,0).acsc()},Complex:function(l){return l.acsc()},BigNumber:function(l){return new r(1).div(l).asin()},"Array | Matrix":function(l){return be(l,this)}})}),bf="acsch",Eb=["typed","BigNumber"],Cb=R(bf,Eb,e=>{var{typed:n,BigNumber:a}=e;return n(bf,{number:Ds,Complex:function(r){return r.acsch()},BigNumber:function(r){return new a(1).div(r).asinh()},"Array | Matrix":function(r){return be(r,this)}})}),wf="asec",Ob=["typed","config","Complex","BigNumber"],Db=R(wf,Ob,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(wf,{number:function(l){return l<=-1||l>=1||a.predictable?Ts(l):new t(l,0).asec()},Complex:function(l){return l.asec()},BigNumber:function(l){return new r(1).div(l).acos()},"Array | Matrix":function(l){return be(l,this)}})}),Nf="asech",Tb=["typed","config","Complex","BigNumber"],Bb=R(Nf,Tb,e=>{var{typed:n,config:a,Complex:t,BigNumber:r}=e;return n(Nf,{number:function(l){if(l<=1&&l>=-1||a.predictable){var m=1/l;if(m>0||a.predictable)return Bs(l);var f=Math.sqrt(m*m-1);return new t(Math.log(f-m),Math.PI)}return new t(l,0).asech()},Complex:function(l){return l.asech()},BigNumber:function(l){return new r(1).div(l).acosh()},"Array | Matrix":function(l){return be(l,this)}})}),Mf="asin",_b=["typed","config","Complex"],$b=R(Mf,_b,e=>{var{typed:n,config:a,Complex:t}=e;return n(Mf,{number:function(i){return i>=-1&&i<=1||a.predictable?Math.asin(i):new t(i,0).asin()},Complex:function(i){return i.asin()},BigNumber:function(i){return i.asin()},"Array | Matrix":function(i){return be(i,this)}})}),Ib="asinh",qb=["typed"],Rb=R(Ib,qb,e=>{var{typed:n}=e;return n("asinh",{number:_s,Complex:function(t){return t.asinh()},BigNumber:function(t){return t.asinh()},"Array | Matrix":function(t){return be(t,this)}})}),Fb="atan",zb=["typed"],Pb=R(Fb,zb,e=>{var{typed:n}=e;return n("atan",{number:function(t){return Math.atan(t)},Complex:function(t){return t.atan()},BigNumber:function(t){return t.atan()},"Array | Matrix":function(t){return be(t,this)}})}),Af="atan2",Ub=["typed","matrix","equalScalar","BigNumber","DenseMatrix"],Lb=R(Af,Ub,e=>{var{typed:n,matrix:a,equalScalar:t,BigNumber:r,DenseMatrix:i}=e,l=rt({typed:n,equalScalar:t}),m=Dr({typed:n}),f=Cu({typed:n,equalScalar:t}),c=wr({typed:n,equalScalar:t}),s=gr({typed:n,DenseMatrix:i}),o=je({typed:n}),u=Ge({typed:n});return n(Af,{"number, number":Math.atan2,"BigNumber, BigNumber":function(v,h){return r.atan2(v,h)},"SparseMatrix, SparseMatrix":function(v,h){return f(v,h,this,!1)},"SparseMatrix, DenseMatrix":function(v,h){return l(h,v,this,!0)},"DenseMatrix, SparseMatrix":function(v,h){return m(v,h,this,!1)},"DenseMatrix, DenseMatrix":function(v,h){return o(v,h,this)},"Array, Array":function(v,h){return this(a(v),a(h)).valueOf()},"Array, Matrix":function(v,h){return this(a(v),h)},"Matrix, Array":function(v,h){return this(v,a(h))},"SparseMatrix, number | BigNumber":function(v,h){return c(v,h,this,!1)},"DenseMatrix, number | BigNumber":function(v,h){return u(v,h,this,!1)},"number | BigNumber, SparseMatrix":function(v,h){return s(h,v,this,!0)},"number | BigNumber, DenseMatrix":function(v,h){return u(h,v,this,!0)},"Array, number | BigNumber":function(v,h){return u(a(v),h,this,!1).valueOf()},"number | BigNumber, Array":function(v,h){return u(a(h),v,this,!0).valueOf()}})}),Sf="atanh",kb=["typed","config","Complex"],Hb=R(Sf,kb,e=>{var{typed:n,config:a,Complex:t}=e;return n(Sf,{number:function(i){return i<=1&&i>=-1||a.predictable?$s(i):new t(i,0).atanh()},Complex:function(i){return i.atanh()},BigNumber:function(i){return i.atanh()},"Array | Matrix":function(i){return be(i,this)}})}),Ef="cos",Gb=["typed"],Vb=R(Ef,Gb,e=>{var{typed:n}=e;return n(Ef,{number:Math.cos,Complex:function(t){return t.cos()},BigNumber:function(t){return t.cos()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Cf="cosh",Zb=["typed"],Xb=R(Cf,Zb,e=>{var{typed:n}=e;return n(Cf,{number:ev,Complex:function(t){return t.cosh()},BigNumber:function(t){return t.cosh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Of="cot",Yb=["typed","BigNumber"],Wb=R(Of,Yb,e=>{var{typed:n,BigNumber:a}=e;return n(Of,{number:Is,Complex:function(r){return r.cot()},BigNumber:function(r){return new a(1).div(r.tan())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Df="coth",Jb=["typed","BigNumber"],Qb=R(Df,Jb,e=>{var{typed:n,BigNumber:a}=e;return n(Df,{number:qs,Complex:function(r){return r.coth()},BigNumber:function(r){return new a(1).div(r.tanh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Tf="csc",Kb=["typed","BigNumber"],jb=R(Tf,Kb,e=>{var{typed:n,BigNumber:a}=e;return n(Tf,{number:Rs,Complex:function(r){return r.csc()},BigNumber:function(r){return new a(1).div(r.sin())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),Bf="csch",ew=["typed","BigNumber"],rw=R(Bf,ew,e=>{var{typed:n,BigNumber:a}=e;return n(Bf,{number:Fs,Complex:function(r){return r.csch()},BigNumber:function(r){return new a(1).div(r.sinh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),_f="sec",tw=["typed","BigNumber"],nw=R(_f,tw,e=>{var{typed:n,BigNumber:a}=e;return n(_f,{number:zs,Complex:function(r){return r.sec()},BigNumber:function(r){return new a(1).div(r.cos())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),$f="sech",aw=["typed","BigNumber"],iw=R($f,aw,e=>{var{typed:n,BigNumber:a}=e;return n($f,{number:Ps,Complex:function(r){return r.sech()},BigNumber:function(r){return new a(1).div(r.cosh())},Unit:function(r){if(!r.hasBase(r.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(r.value)},"Array | Matrix":function(r){return be(r,this)}})}),If="sin",ow=["typed"],sw=R(If,ow,e=>{var{typed:n}=e;return n(If,{number:Math.sin,Complex:function(t){return t.sin()},BigNumber:function(t){return t.sin()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),qf="sinh",uw=["typed"],cw=R(qf,uw,e=>{var{typed:n}=e;return n(qf,{number:Us,Complex:function(t){return t.sinh()},BigNumber:function(t){return t.sinh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Rf="tan",fw=["typed"],lw=R(Rf,fw,e=>{var{typed:n}=e;return n(Rf,{number:Math.tan,Complex:function(t){return t.tan()},BigNumber:function(t){return t.tan()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),mw="tanh",pw=["typed"],vw=R(mw,pw,e=>{var{typed:n}=e;return n("tanh",{number:tv,Complex:function(t){return t.tanh()},BigNumber:function(t){return t.tanh()},Unit:function(t){if(!t.hasBase(t.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(t.value)},"Array | Matrix":function(t){return be(t,this)}})}),Ff="setCartesian",hw=["typed","size","subset","compareNatural","Index","DenseMatrix"],dw=R(Ff,hw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Ff,{"Array | Matrix, Array | Matrix":function(f,c){var s=[];if(t(a(f),new i(0))!==0&&t(a(c),new i(0))!==0){var o=Le(Array.isArray(f)?f:f.toArray()).sort(r),u=Le(Array.isArray(c)?c:c.toArray()).sort(r);s=[];for(var p=0;p<o.length;p++)for(var v=0;v<u.length;v++)s.push([o[p],u[v]])}return Array.isArray(f)&&Array.isArray(c)?s:new l(s)}})}),zf="setDifference",gw=["typed","size","subset","compareNatural","Index","DenseMatrix"],yw=R(zf,gw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(zf,{"Array | Matrix, Array | Matrix":function(f,c){var s;if(t(a(f),new i(0))===0)s=[];else{if(t(a(c),new i(0))===0)return Le(f.toArray());var o=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),u=sn(Le(Array.isArray(c)?c:c.toArray()).sort(r));s=[];for(var p,v=0;v<o.length;v++){p=!1;for(var h=0;h<u.length;h++)if(r(o[v].value,u[h].value)===0&&o[v].identifier===u[h].identifier){p=!0;break}p||s.push(o[v])}}return Array.isArray(f)&&Array.isArray(c)?sa(s):new l(sa(s))}})}),Pf="setDistinct",xw=["typed","size","subset","compareNatural","Index","DenseMatrix"],bw=R(Pf,xw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Pf,{"Array | Matrix":function(f){var c;if(t(a(f),new i(0))===0)c=[];else{var s=Le(Array.isArray(f)?f:f.toArray()).sort(r);c=[],c.push(s[0]);for(var o=1;o<s.length;o++)r(s[o],s[o-1])!==0&&c.push(s[o])}return Array.isArray(f)?c:new l(c)}})}),Uf="setIntersect",ww=["typed","size","subset","compareNatural","Index","DenseMatrix"],Nw=R(Uf,ww,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i,DenseMatrix:l}=e;return n(Uf,{"Array | Matrix, Array | Matrix":function(f,c){var s;if(t(a(f),new i(0))===0||t(a(c),new i(0))===0)s=[];else{var o=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),u=sn(Le(Array.isArray(c)?c:c.toArray()).sort(r));s=[];for(var p=0;p<o.length;p++)for(var v=0;v<u.length;v++)if(r(o[p].value,u[v].value)===0&&o[p].identifier===u[v].identifier){s.push(o[p]);break}}return Array.isArray(f)&&Array.isArray(c)?sa(s):new l(sa(s))}})}),Lf="setIsSubset",Mw=["typed","size","subset","compareNatural","Index"],Aw=R(Lf,Mw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(Lf,{"Array | Matrix, Array | Matrix":function(m,f){if(t(a(m),new i(0))===0)return!0;if(t(a(f),new i(0))===0)return!1;for(var c=sn(Le(Array.isArray(m)?m:m.toArray()).sort(r)),s=sn(Le(Array.isArray(f)?f:f.toArray()).sort(r)),o,u=0;u<c.length;u++){o=!1;for(var p=0;p<s.length;p++)if(r(c[u].value,s[p].value)===0&&c[u].identifier===s[p].identifier){o=!0;break}if(o===!1)return!1}return!0}})}),kf="setMultiplicity",Sw=["typed","size","subset","compareNatural","Index"],Ew=R(kf,Sw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(kf,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(m,f){if(t(a(f),new i(0))===0)return 0;for(var c=Le(Array.isArray(f)?f:f.toArray()),s=0,o=0;o<c.length;o++)r(c[o],m)===0&&s++;return s}})}),Hf="setPowerset",Cw=["typed","size","subset","compareNatural","Index"],Ow=R(Hf,Cw,e=>{var{typed:n,size:a,subset:t,compareNatural:r,Index:i}=e;return n(Hf,{"Array | Matrix":function(c){if(t(a(c),new i(0))===0)return[];for(var s=Le(Array.isArray(c)?c:c.toArray()).sort(r),o=[],u=0;u.toString(2).length<=s.length;)o.push(l(s,u.toString(2).split("").reverse())),u++;return m(o)}});function l(f,c){for(var s=[],o=0;o<c.length;o++)c[o]==="1"&&s.push(f[o]);return s}function m(f){for(var c=[],s=f.length-1;s>0;s--)for(var o=0;o<s;o++)f[o].length>f[o+1].length&&(c=f[o],f[o]=f[o+1],f[o+1]=c);return f}}),Gf="setSize",Dw=["typed","compareNatural"],Tw=R(Gf,Dw,e=>{var{typed:n,compareNatural:a}=e;return n(Gf,{"Array | Matrix":function(r){return Array.isArray(r)?Le(r).length:Le(r.toArray()).length},"Array | Matrix, boolean":function(r,i){if(i===!1||r.length===0)return Array.isArray(r)?Le(r).length:Le(r.toArray()).length;for(var l=Le(Array.isArray(r)?r:r.toArray()).sort(a),m=1,f=1;f<l.length;f++)a(l[f],l[f-1])!==0&&m++;return m}})}),Vf="setSymDifference",Bw=["typed","size","concat","subset","setDifference","Index"],_w=R(Vf,Bw,e=>{var{typed:n,size:a,concat:t,subset:r,setDifference:i,Index:l}=e;return n(Vf,{"Array | Matrix, Array | Matrix":function(f,c){if(r(a(f),new l(0))===0)return Le(c);if(r(a(c),new l(0))===0)return Le(f);var s=Le(f),o=Le(c);return t(i(s,o),i(o,s))}})}),Zf="setUnion",$w=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],Iw=R(Zf,$w,e=>{var{typed:n,size:a,concat:t,subset:r,setIntersect:i,setSymDifference:l,Index:m}=e;return n(Zf,{"Array | Matrix, Array | Matrix":function(c,s){if(r(a(c),new m(0))===0)return Le(s);if(r(a(s),new m(0))===0)return Le(c);var o=Le(c),u=Le(s);return t(l(o,u),i(o,u))}})}),Xf="add",qw=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],Rw=R(Xf,qw,e=>{var{typed:n,matrix:a,addScalar:t,equalScalar:r,DenseMatrix:i,SparseMatrix:l}=e,m=qt({typed:n}),f=Ni({typed:n,equalScalar:r}),c=Vt({typed:n,DenseMatrix:i}),s=je({typed:n}),o=Ge({typed:n});return n(Xf,Ka({"DenseMatrix, DenseMatrix":function(p,v){return s(p,v,t)},"DenseMatrix, SparseMatrix":function(p,v){return m(p,v,t,!1)},"SparseMatrix, DenseMatrix":function(p,v){return m(v,p,t,!0)},"SparseMatrix, SparseMatrix":function(p,v){return f(p,v,t)},"Array, Array":function(p,v){return this(a(p),a(v)).valueOf()},"Array, Matrix":function(p,v){return this(a(p),v)},"Matrix, Array":function(p,v){return this(p,a(v))},"DenseMatrix, any":function(p,v){return o(p,v,t,!1)},"SparseMatrix, any":function(p,v){return c(p,v,t,!1)},"any, DenseMatrix":function(p,v){return o(v,p,t,!0)},"any, SparseMatrix":function(p,v){return c(v,p,t,!0)},"Array, any":function(p,v){return o(a(p),v,t,!1).valueOf()},"any, Array":function(p,v){return o(a(v),p,t,!0).valueOf()},"any, any":t,"any, any, ...any":function(p,v,h){for(var b=this(p,v),w=0;w<h.length;w++)b=this(b,h[w]);return b}},t.signatures))}),Yf="hypot",Fw=["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],zw=R(Yf,Fw,e=>{var{typed:n,abs:a,addScalar:t,divideScalar:r,multiplyScalar:i,sqrt:l,smaller:m,isPositive:f}=e;return n(Yf,{"... number | BigNumber":c,Array:function(o){return this.apply(this,Le(o))},Matrix:function(o){return this.apply(this,Le(o.toArray()))}});function c(s){for(var o=0,u=0,p=0;p<s.length;p++){var v=a(s[p]);m(u,v)?(o=i(o,i(r(u,v),r(u,v))),o=t(o,1),u=v):o=t(o,f(v)?i(r(v,u),r(v,u)):v)}return i(u,l(o))}}),Wf="norm",Pw=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],Uw=R(Wf,Pw,e=>{var{typed:n,abs:a,add:t,pow:r,conj:i,sqrt:l,multiply:m,equalScalar:f,larger:c,smaller:s,matrix:o,ctranspose:u,eigs:p}=e;return n(Wf,{number:Math.abs,Complex:function(S){return S.abs()},BigNumber:function(S){return S.abs()},boolean:function(S){return Math.abs(S)},Array:function(S){return d(o(S),2)},Matrix:function(S){return d(S,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(S){return this(S)},"Array, number | BigNumber | string":function(S,O){return d(o(S),O)},"Matrix, number | BigNumber | string":function(S,O){return d(S,O)}});function v(A){var S=0;return A.forEach(function(O){var M=a(O);c(M,S)&&(S=M)},!0),S}function h(A){var S;return A.forEach(function(O){var M=a(O);(!S||s(M,S))&&(S=M)},!0),S||0}function b(A,S){if(S===Number.POSITIVE_INFINITY||S==="inf")return v(A);if(S===Number.NEGATIVE_INFINITY||S==="-inf")return h(A);if(S==="fro")return d(A,2);if(typeof S=="number"&&!isNaN(S)){if(!f(S,0)){var O=0;return A.forEach(function(M){O=t(r(a(M),S),O)},!0),r(O,1/S)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}function w(A){var S=0;return A.forEach(function(O,M){S=t(S,m(O,i(O)))}),a(l(S))}function N(A){var S=[],O=0;return A.forEach(function(M,_){var E=_[1],$=t(S[E]||0,a(M));c($,O)&&(O=$),S[E]=$},!0),O}function g(A){var S=A.size();if(S[0]!==S[1])throw new RangeError("Invalid matrix dimensions");var O=u(A),M=m(O,A),_=p(M).values.toArray(),E=_[_.length-1];return a(l(E))}function y(A){var S=[],O=0;return A.forEach(function(M,_){var E=_[0],$=t(S[E]||0,a(M));c($,O)&&(O=$),S[E]=$},!0),O}function x(A,S){if(S===1)return N(A);if(S===Number.POSITIVE_INFINITY||S==="inf")return y(A);if(S==="fro")return w(A);if(S===2)return g(A);throw new Error("Unsupported parameter value "+S)}function d(A,S){var O=A.size();if(O.length===1)return b(A,S);if(O.length===2){if(O[0]&&O[1])return x(A,S);throw new RangeError("Invalid matrix dimensions")}}}),Jf="dot",Lw=["typed","addScalar","multiplyScalar","conj","size"],kw=R(Jf,Lw,e=>{var{typed:n,addScalar:a,multiplyScalar:t,conj:r,size:i}=e;return n(Jf,{"Array | DenseMatrix, Array | DenseMatrix":m,"SparseMatrix, SparseMatrix":f});function l(s,o){var u=c(s),p=c(o),v,h;if(u.length===1)v=u[0];else if(u.length===2&&u[1]===1)v=u[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+u.join(", ")+")");if(p.length===1)h=p[0];else if(p.length===2&&p[1]===1)h=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(v!==h)throw new RangeError("Vectors must have equal length ("+v+" != "+h+")");if(v===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return v}function m(s,o){var u=l(s,o),p=Oe(s)?s._data:s,v=Oe(s)?s._datatype:void 0,h=Oe(o)?o._data:o,b=Oe(o)?o._datatype:void 0,w=c(s).length===2,N=c(o).length===2,g=a,y=t;if(v&&b&&v===b&&typeof v=="string"){var x=v;g=n.find(a,[x,x]),y=n.find(t,[x,x])}if(!w&&!N){for(var d=y(r(p[0]),h[0]),A=1;A<u;A++)d=g(d,y(r(p[A]),h[A]));return d}if(!w&&N){for(var S=y(r(p[0]),h[0][0]),O=1;O<u;O++)S=g(S,y(r(p[O]),h[O][0]));return S}if(w&&!N){for(var M=y(r(p[0][0]),h[0]),_=1;_<u;_++)M=g(M,y(r(p[_][0]),h[_]));return M}if(w&&N){for(var E=y(r(p[0][0]),h[0][0]),$=1;$<u;$++)E=g(E,y(r(p[$][0]),h[$][0]));return E}}function f(s,o){l(s,o);for(var u=s._index,p=s._values,v=o._index,h=o._values,b=0,w=a,N=t,g=0,y=0;g<u.length&&y<v.length;){var x=u[g],d=v[y];if(x<d){g++;continue}if(x>d){y++;continue}x===d&&(b=w(b,N(p[g],h[y])),g++,y++)}return b}function c(s){return Oe(s)?s.size():i(s)}}),Hw="trace",Gw=["typed","matrix","add"],Vw=R(Hw,Gw,e=>{var{typed:n,matrix:a,add:t}=e;return n("trace",{Array:function(m){return r(a(m))},SparseMatrix:i,DenseMatrix:r,any:Ce});function r(l){var m=l._size,f=l._data;switch(m.length){case 1:if(m[0]===1)return Ce(f[0]);throw new RangeError("Matrix must be square (size: "+Re(m)+")");case 2:{var c=m[0],s=m[1];if(c===s){for(var o=0,u=0;u<c;u++)o=t(o,f[u][u]);return o}else throw new RangeError("Matrix must be square (size: "+Re(m)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Re(m)+")")}}function i(l){var m=l._values,f=l._index,c=l._ptr,s=l._size,o=s[0],u=s[1];if(o===u){var p=0;if(m.length>0)for(var v=0;v<u;v++)for(var h=c[v],b=c[v+1],w=h;w<b;w++){var N=f[w];if(N===v){p=t(p,m[w]);break}if(N>v)break}return p}throw new RangeError("Matrix must be square (size: "+Re(s)+")")}}),Qf="index",Zw=["typed","Index"],Xw=R(Qf,Zw,e=>{var{typed:n,Index:a}=e;return n(Qf,{"...number | string | BigNumber | Range | Array | Matrix":function(r){var i=r.map(function(m){return _e(m)?m.toNumber():Array.isArray(m)||Oe(m)?m.map(function(f){return _e(f)?f.toNumber():f}):m}),l=new a;return a.apply(l,i),l}})}),Kf=new Set(["end"]),Yw="Node",Ww=["mathWithTransform"],Jw=R(Yw,Ww,e=>{var{mathWithTransform:n}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator")}a.prototype.evaluate=function(r){return this.compile().evaluate(r)},a.prototype.type="Node",a.prototype.isNode=!0,a.prototype.comment="",a.prototype.compile=function(){var r=this._compile(n,{}),i={},l=null;function m(f){var c=oi(f);return t(c),r(c,i,l)}return{evaluate:m}},a.prototype._compile=function(r,i){throw new Error("Method _compile should be implemented by type "+this.type)},a.prototype.forEach=function(r){throw new Error("Cannot run forEach on a Node interface")},a.prototype.map=function(r){throw new Error("Cannot run map on a Node interface")},a.prototype._ifNode=function(r){if(!Ve(r))throw new TypeError("Callback function must return a Node");return r},a.prototype.traverse=function(r){r(this,null,null);function i(l,m){l.forEach(function(f,c,s){m(f,c,s),i(f,m)})}i(this,r)},a.prototype.transform=function(r){function i(l,m,f){var c=r(l,m,f);return c!==l?c:l.map(i)}return i(this,null,null)},a.prototype.filter=function(r){var i=[];return this.traverse(function(l,m,f){r(l,m,f)&&i.push(l)}),i},a.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},a.prototype.cloneDeep=function(){return this.map(function(r){return r.cloneDeep()})},a.prototype.equals=function(r){return r?Dn(this,r):!1},a.prototype.toString=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this._toString(r)},a.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},a.prototype.toHTML=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this.toHTML(r)},a.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},a.prototype.toTex=function(r){var i=this._getCustomString(r);return typeof i!="undefined"?i:this._toTex(r)},a.prototype._toTex=function(r){throw new Error("_toTex not implemented for "+this.type)},a.prototype._getCustomString=function(r){if(r&&typeof r=="object")switch(typeof r.handler){case"object":case"undefined":return;case"function":return r.handler(this,r);default:throw new TypeError("Object or function expected as callback")}},a.prototype.getIdentifier=function(){return this.type},a.prototype.getContent=function(){return this};function t(r){for(var i of[...Kf])if(r.has(i))throw new Error('Scope contains an illegal symbol, "'+i+'" is a reserved keyword')}return a},{isClass:!0,isNode:!0});function Br(e){return e&&e.isIndexError?new Kr(e.index+1,e.min+1,e.max!==void 0?e.max+1:void 0):e}function jf(e){var{subset:n}=e;return function(t,r){try{if(Array.isArray(t))return n(t,r);if(t&&typeof t.subset=="function")return t.subset(r);if(typeof t=="string")return n(t,r);if(typeof t=="object"){if(!r.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Vr(t,r.getObjectProperty())}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(i){throw Br(i)}}}var Qw="AccessorNode",Kw=["subset","Node"],jw=R(Qw,Kw,e=>{var{subset:n,Node:a}=e,t=jf({subset:n});function r(l,m){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Ve(l))throw new TypeError('Node expected for parameter "object"');if(!tn(m))throw new TypeError('IndexNode expected for parameter "index"');this.object=l||null,this.index=m,Object.defineProperty(this,"name",{get:(function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}).bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}r.prototype=new a,r.prototype.type="AccessorNode",r.prototype.isAccessorNode=!0,r.prototype._compile=function(l,m){var f=this.object._compile(l,m),c=this.index._compile(l,m);if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(u,p,v){return Vr(f(u,p,v),s)}}else return function(u,p,v){var h=f(u,p,v),b=c(u,p,h);return t(h,b)}},r.prototype.forEach=function(l){l(this.object,"object",this),l(this.index,"index",this)},r.prototype.map=function(l){return new r(this._ifNode(l(this.object,"object",this)),this._ifNode(l(this.index,"index",this)))},r.prototype.clone=function(){return new r(this.object,this.index)},r.prototype._toString=function(l){var m=this.object.toString(l);return i(this.object)&&(m="("+m+")"),m+this.index.toString(l)},r.prototype.toHTML=function(l){var m=this.object.toHTML(l);return i(this.object)&&(m='<span class="math-parenthesis math-round-parenthesis">(</span>'+m+'<span class="math-parenthesis math-round-parenthesis">)</span>'),m+this.index.toHTML(l)},r.prototype._toTex=function(l){var m=this.object.toTex(l);return i(this.object)&&(m="\\left(' + object + '\\right)"),m+this.index.toTex(l)},r.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},r.fromJSON=function(l){return new r(l.object,l.index)};function i(l){return!(Lt(l)||Hr(l)||Ye(l)||kt(l)||jn(l)||On(l)||xr(l))}return r},{isClass:!0,isNode:!0}),eN="ArrayNode",rN=["Node"],tN=R(eN,rN,e=>{var{Node:n}=e;function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=t||[],!Array.isArray(this.items)||!this.items.every(Ve))throw new TypeError("Array containing Nodes expected")}return a.prototype=new n,a.prototype.type="ArrayNode",a.prototype.isArrayNode=!0,a.prototype._compile=function(t,r){var i=dt(this.items,function(f){return f._compile(t,r)}),l=t.config.matrix!=="Array";if(l){var m=t.matrix;return function(c,s,o){return m(dt(i,function(u){return u(c,s,o)}))}}else return function(c,s,o){return dt(i,function(u){return u(c,s,o)})}},a.prototype.forEach=function(t){for(var r=0;r<this.items.length;r++){var i=this.items[r];t(i,"items["+r+"]",this)}},a.prototype.map=function(t){for(var r=[],i=0;i<this.items.length;i++)r[i]=this._ifNode(t(this.items[i],"items["+i+"]",this));return new a(r)},a.prototype.clone=function(){return new a(this.items.slice(0))},a.prototype._toString=function(t){var r=this.items.map(function(i){return i.toString(t)});return"["+r.join(", ")+"]"},a.prototype.toJSON=function(){return{mathjs:"ArrayNode",items:this.items}},a.fromJSON=function(t){return new a(t.items)},a.prototype.toHTML=function(t){var r=this.items.map(function(i){return i.toHTML(t)});return'<span class="math-parenthesis math-square-parenthesis">[</span>'+r.join('<span class="math-separator">,</span>')+'<span class="math-parenthesis math-square-parenthesis">]</span>'},a.prototype._toTex=function(t){function r(i,l){var m=i.some(Hr)&&!i.every(Hr),f=l||m,c=f?"&":"\\\\",s=i.map(function(o){return o.items?r(o.items,!l):o.toTex(t)}).join(c);return m||!f||f&&!l?"\\begin{bmatrix}"+s+"\\end{bmatrix}":s}return r(this.items,!1)},a},{isClass:!0,isNode:!0});function nN(e){var{subset:n,matrix:a}=e;return function(r,i,l){try{if(Array.isArray(r))return a(r).subset(i,l).valueOf();if(r&&typeof r.subset=="function")return r.subset(i,l);if(typeof r=="string")return n(r,i,l);if(typeof r=="object"){if(!i.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return un(r,i.getObjectProperty(),l),r}else throw new TypeError("Cannot apply index: unsupported type of object")}catch(m){throw Br(m)}}}var ct=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Je(e,n){var a=e;n!=="keep"&&(a=e.getContent());for(var t=a.getIdentifier(),r=0;r<ct.length;r++)if(t in ct[r])return r;return null}function zn(e,n){var a=e;n!=="keep"&&(a=e.getContent());var t=a.getIdentifier(),r=Je(a,n);if(r===null)return null;var i=ct[r][t];if(Me(i,"associativity")){if(i.associativity==="left")return"left";if(i.associativity==="right")return"right";throw Error("'"+t+"' has the invalid associativity '"+i.associativity+"'.")}return null}function Ti(e,n,a){var t=a!=="keep"?e.getContent():e,r=a!=="keep"?e.getContent():n,i=t.getIdentifier(),l=r.getIdentifier(),m=Je(t,a);if(m===null)return null;var f=ct[m][i];if(Me(f,"associativeWith")&&f.associativeWith instanceof Array){for(var c=0;c<f.associativeWith.length;c++)if(f.associativeWith[c]===l)return!0;return!1}return null}var aN="AssignmentNode",iN=["subset","?matrix","Node"],oN=R(aN,iN,e=>{var{subset:n,matrix:a,Node:t}=e,r=jf({subset:n}),i=nN({subset:n,matrix:a});function l(f,c,s){if(!(this instanceof l))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=f,this.index=s?c:null,this.value=s||c,!xr(f)&&!Lt(f))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(xr(f)&&f.name==="end")throw new Error('Cannot assign to symbol "end"');if(this.index&&!tn(this.index))throw new TypeError('IndexNode expected as "index"');if(!Ve(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:(function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}).bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}l.prototype=new t,l.prototype.type="AssignmentNode",l.prototype.isAssignmentNode=!0,l.prototype._compile=function(f,c){var s=this.object._compile(f,c),o=this.index?this.index._compile(f,c):null,u=this.value._compile(f,c),p=this.object.name;if(this.index)if(this.index.isObjectProperty()){var v=this.index.getObjectProperty();return function(g,y,x){var d=s(g,y,x),A=u(g,y,x);return un(d,v,A),A}}else{if(xr(this.object))return function(g,y,x){var d=s(g,y,x),A=u(g,y,x),S=o(g,y,d);return g.set(p,i(d,S,A)),A};var h=this.object.object._compile(f,c);if(this.object.index.isObjectProperty()){var b=this.object.index.getObjectProperty();return function(g,y,x){var d=h(g,y,x),A=Vr(d,b),S=o(g,y,A),O=u(g,y,x);return un(d,b,i(A,S,O)),O}}else{var w=this.object.index._compile(f,c);return function(g,y,x){var d=h(g,y,x),A=w(g,y,d),S=r(d,A),O=o(g,y,S),M=u(g,y,x);return i(d,A,i(S,O,M)),M}}}else{if(!xr(this.object))throw new TypeError("SymbolNode expected as object");return function(g,y,x){var d=u(g,y,x);return g.set(p,d),d}}},l.prototype.forEach=function(f){f(this.object,"object",this),this.index&&f(this.index,"index",this),f(this.value,"value",this)},l.prototype.map=function(f){var c=this._ifNode(f(this.object,"object",this)),s=this.index?this._ifNode(f(this.index,"index",this)):null,o=this._ifNode(f(this.value,"value",this));return new l(c,s,o)},l.prototype.clone=function(){return new l(this.object,this.index,this.value)};function m(f,c){c||(c="keep");var s=Je(f,c),o=Je(f.value,c);return c==="all"||o!==null&&o<=s}return l.prototype._toString=function(f){var c=this.object.toString(f),s=this.index?this.index.toString(f):"",o=this.value.toString(f);return m(this,f&&f.parenthesis)&&(o="("+o+")"),c+s+" = "+o},l.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},l.fromJSON=function(f){return new l(f.object,f.index,f.value)},l.prototype.toHTML=function(f){var c=this.object.toHTML(f),s=this.index?this.index.toHTML(f):"",o=this.value.toHTML(f);return m(this,f&&f.parenthesis)&&(o='<span class="math-paranthesis math-round-parenthesis">(</span>'+o+'<span class="math-paranthesis math-round-parenthesis">)</span>'),c+s+'<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>'+o},l.prototype._toTex=function(f){var c=this.object.toTex(f),s=this.index?this.index.toTex(f):"",o=this.value.toTex(f);return m(this,f&&f.parenthesis)&&(o="\\left(".concat(o,"\\right)")),c+s+":="+o},l},{isClass:!0,isNode:!0}),sN="BlockNode",uN=["ResultSet","Node"],cN=R(sN,uN,e=>{var{ResultSet:n,Node:a}=e;function t(r){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(r))throw new Error("Array expected");this.blocks=r.map(function(i){var l=i&&i.node,m=i&&i.visible!==void 0?i.visible:!0;if(!Ve(l))throw new TypeError('Property "node" must be a Node');if(typeof m!="boolean")throw new TypeError('Property "visible" must be a boolean');return{node:l,visible:m}})}return t.prototype=new a,t.prototype.type="BlockNode",t.prototype.isBlockNode=!0,t.prototype._compile=function(r,i){var l=dt(this.blocks,function(m){return{evaluate:m.node._compile(r,i),visible:m.visible}});return function(f,c,s){var o=[];return ia(l,function(p){var v=p.evaluate(f,c,s);p.visible&&o.push(v)}),new n(o)}},t.prototype.forEach=function(r){for(var i=0;i<this.blocks.length;i++)r(this.blocks[i].node,"blocks["+i+"].node",this)},t.prototype.map=function(r){for(var i=[],l=0;l<this.blocks.length;l++){var m=this.blocks[l],f=this._ifNode(r(m.node,"blocks["+l+"].node",this));i[l]={node:f,visible:m.visible}}return new t(i)},t.prototype.clone=function(){var r=this.blocks.map(function(i){return{node:i.node,visible:i.visible}});return new t(r)},t.prototype._toString=function(r){return this.blocks.map(function(i){return i.node.toString(r)+(i.visible?"":";")}).join(`
29
12
  `)},t.prototype.toJSON=function(){return{mathjs:"BlockNode",blocks:this.blocks}},t.fromJSON=function(r){return new t(r.blocks)},t.prototype.toHTML=function(r){return this.blocks.map(function(i){return i.node.toHTML(r)+(i.visible?"":'<span class="math-separator">;</span>')}).join('<span class="math-separator"><br /></span>')},t.prototype._toTex=function(r){return this.blocks.map(function(i){return i.node.toTex(r)+(i.visible?"":";")}).join(`\\;\\;