rf-touchstone 0.0.0

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.
@@ -0,0 +1,19 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function nt(){return nt=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},nt.apply(null,arguments)}var ri={relTol:1e-12,absTol:1e-15,matrix:"Matrix",number:"number",numberFallback:"number",precision:64,predictable:!1,randomSeed:null};function ti(e,r){if(it(e,r))return e[r];throw typeof e[r]=="function"&&Tu(e,r)?new Error('Cannot access method "'+r+'" as a property'):new Error('No access to property "'+r+'"')}function ni(e,r,t){if(it(e,r))return e[r]=t,t;throw new Error('No access to property "'+r+'"')}function it(e,r){return!Iu(e)&&!Array.isArray(e)?!1:Rr(zu,r)?!0:!(r in Object.prototype||r in Function.prototype)}function Tu(e,r){return e==null||typeof e[r]!="function"||Rr(e,r)&&Object.getPrototypeOf&&r in Object.getPrototypeOf(e)?!1:Rr(Ou,r)?!0:!(r in Object.prototype||r in Function.prototype)}function Iu(e){return typeof e=="object"&&e&&e.constructor===Object}var zu={length:!0,name:!0},Ou={toString:!0,valueOf:!0,toLocaleString:!0};class $u{constructor(r){this.wrappedObject=r,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).filter(r=>this.has(r)).values()}get(r){return ti(this.wrappedObject,r)}set(r,t){return ni(this.wrappedObject,r,t),this}has(r){return it(this.wrappedObject,r)&&r in this.wrappedObject}entries(){return Pu(this.keys(),r=>[r,this.get(r)])}forEach(r){for(var t of this.keys())r(this.get(t),t,this)}delete(r){it(this.wrappedObject,r)&&delete this.wrappedObject[r]}clear(){for(var r of this.keys())this.delete(r)}get size(){return Object.keys(this.wrappedObject).length}}function Pu(e,r){return{next:()=>{var t=e.next();return t.done?t:{value:r(t.value),done:!1}}}}function de(e){return typeof e=="number"}function Ee(e){return!e||typeof e!="object"||typeof e.constructor!="function"?!1:e.isBigNumber===!0&&typeof e.constructor.prototype=="object"&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal=="function"&&e.constructor.isDecimal(e)===!0}function Uu(e){return typeof e=="bigint"}function ii(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isComplex===!0||!1}function ui(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isFraction===!0||!1}function oi(e){return e&&e.constructor.prototype.isUnit===!0||!1}function Qe(e){return typeof e=="string"}var ye=Array.isArray;function ve(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function ut(e){return Array.isArray(e)||ve(e)}function qu(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Ru(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function ai(e){return e&&e.constructor.prototype.isRange===!0||!1}function yt(e){return e&&e.constructor.prototype.isIndex===!0||!1}function Lu(e){return typeof e=="boolean"}function Hu(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function Zu(e){return e&&e.constructor.prototype.isHelp===!0||!1}function Wu(e){return typeof e=="function"}function Vu(e){return e instanceof Date}function Ju(e){return e instanceof RegExp}function Kt(e){return!!(e&&typeof e=="object"&&e.constructor===Object&&!ii(e)&&!ui(e))}function Gu(e){return e?e instanceof Map||e instanceof $u||typeof e.set=="function"&&typeof e.get=="function"&&typeof e.keys=="function"&&typeof e.has=="function":!1}function Yu(e){return e===null}function ku(e){return e===void 0}function Xu(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Qu(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ku(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function ju(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function eo(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function ro(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function to(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function no(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function io(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function uo(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function oo(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function ao(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function so(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function fo(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function co(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function lo(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function ho(e){return e&&e.constructor.prototype.isChain===!0||!1}function ir(e){var r=typeof e;return r==="object"?e===null?"null":Ee(e)?"BigNumber":e.constructor&&e.constructor.name?e.constructor.name:"Object":r}function me(e){var r=typeof e;if(r==="number"||r==="bigint"||r==="string"||r==="boolean"||e===null||e===void 0)return e;if(typeof e.clone=="function")return e.clone();if(Array.isArray(e))return e.map(function(t){return me(t)});if(e instanceof Date)return new Date(e.valueOf());if(Ee(e))return e;if(Kt(e))return po(e,me);if(r==="function")return e;throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e,")"))}function po(e,r){var t={};for(var n in e)Rr(e,n)&&(t[n]=r(e[n]));return t}function Do(e,r){for(var t in r)Rr(r,t)&&(e[t]=r[t]);return e}function mr(e,r){var t,n,i;if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(n=0,i=e.length;n<i;n++)if(!mr(e[n],r[n]))return!1;return!0}else{if(typeof e=="function")return e===r;if(e instanceof Object){if(Array.isArray(r)||!(r instanceof Object))return!1;for(t in e)if(!(t in r)||!mr(e[t],r[t]))return!1;for(t in r)if(!(t in e))return!1;return!0}else return e===r}}function Rr(e,r){return e&&Object.hasOwnProperty.call(e,r)}function mo(e,r){for(var t={},n=0;n<r.length;n++){var i=r[n],u=e[i];u!==void 0&&(t[i]=u)}return t}var go=["Matrix","Array"],vo=["number","BigNumber","Fraction"],Pe=function(r){if(r)throw new Error(`The global config is readonly.
2
+ Please create a mathjs instance if you want to change the default configuration.
3
+ Example:
4
+
5
+ import { create, all } from 'mathjs';
6
+ const mathjs = create(all);
7
+ mathjs.config({ number: 'BigNumber' });
8
+ `);return Object.freeze(ri)};nt(Pe,ri,{MATRIX_OPTIONS:go,NUMBER_OPTIONS:vo});function an(){return!0}function Ye(){return!1}function _r(){}const sn="Argument is not a typed-function.";function si(){function e(F){return typeof F=="object"&&F!==null&&F.constructor===Object}const r=[{name:"number",test:function(F){return typeof F=="number"}},{name:"string",test:function(F){return typeof F=="string"}},{name:"boolean",test:function(F){return typeof F=="boolean"}},{name:"Function",test:function(F){return typeof F=="function"}},{name:"Array",test:Array.isArray},{name:"Date",test:function(F){return F instanceof Date}},{name:"RegExp",test:function(F){return F instanceof RegExp}},{name:"Object",test:e},{name:"null",test:function(F){return F===null}},{name:"undefined",test:function(F){return F===void 0}}],t={name:"any",test:an,isAny:!0};let n,i,u=0,o={createCount:0};function a(F){const _=n.get(F);if(_)return _;let N='Unknown type "'+F+'"';const T=F.toLowerCase();let $;for($ of i)if($.toLowerCase()===T){N+='. Did you mean "'+$+'" ?';break}throw new TypeError(N)}function c(F){let _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"any";const N=_?a(_).index:i.length,T=[];for(let I=0;I<F.length;++I){if(!F[I]||typeof F[I].name!="string"||typeof F[I].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const H=F[I].name;if(n.has(H))throw new TypeError('Duplicate type name "'+H+'"');T.push(H),n.set(H,{name:H,test:F[I].test,isAny:F[I].isAny,index:N+I,conversionsTo:[]})}const $=i.slice(N);i=i.slice(0,N).concat(T).concat($);for(let I=N+T.length;I<i.length;++I)n.get(i[I]).index=I}function l(){n=new Map,i=[],u=0,c([t],!1)}l(),c(r);function f(){let F;for(F of i)n.get(F).conversionsTo=[];u=0}function h(F){const _=i.filter(N=>{const T=n.get(N);return!T.isAny&&T.test(F)});return _.length?_:["any"]}function D(F){return F&&typeof F=="function"&&"_typedFunctionData"in F}function p(F,_,N){if(!D(F))throw new TypeError(sn);const T=N&&N.exact,$=Array.isArray(_)?_.join(","):_,I=A($),H=d(I);if(!T||H in F.signatures){const se=F._typedFunctionData.signatureMap.get(H);if(se)return se}const U=I.length;let Z;if(T){Z=[];let se;for(se in F.signatures)Z.push(F._typedFunctionData.signatureMap.get(se))}else Z=F._typedFunctionData.signatures;for(let se=0;se<U;++se){const pe=I[se],_e=[];let Le;for(Le of Z){const Re=b(Le.params,se);if(!(!Re||pe.restParam&&!Re.restParam)){if(!Re.hasAny){const Ke=v(Re);if(pe.types.some(je=>!Ke.has(je.name)))continue}_e.push(Le)}}if(Z=_e,Z.length===0)break}let P;for(P of Z)if(P.params.length<=U)return P;throw new TypeError("Signature not found (signature: "+(F.name||"unnamed")+"("+d(I,", ")+"))")}function m(F,_,N){return p(F,_,N).implementation}function s(F,_){const N=a(_);if(N.test(F))return F;const T=N.conversionsTo;if(T.length===0)throw new Error("There are no conversions to "+_+" defined.");for(let $=0;$<T.length;$++)if(a(T[$].from).test(F))return T[$].convert(F);throw new Error("Cannot convert "+F+" to "+_)}function d(F){let _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:",";return F.map(N=>N.name).join(_)}function g(F){const _=F.indexOf("...")===0,T=(_?F.length>3?F.slice(3):"any":F).split("|").map(U=>a(U.trim()));let $=!1,I=_?"...":"";return{types:T.map(function(U){return $=U.isAny||$,I+=U.name+"|",{name:U.name,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:null,conversionIndex:-1}}),name:I.slice(0,-1),hasAny:$,hasConversion:!1,restParam:_}}function E(F){const _=F.types.map(H=>H.name),N=Q(_);let T=F.hasAny,$=F.name;const I=N.map(function(H){const U=a(H.from);return T=U.isAny||T,$+="|"+H.from,{name:H.from,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:H,conversionIndex:H.index}});return{types:F.types.concat(I),name:$,hasAny:T,hasConversion:I.length>0,restParam:F.restParam}}function v(F){return F.typeSet||(F.typeSet=new Set,F.types.forEach(_=>F.typeSet.add(_.name))),F.typeSet}function A(F){const _=[];if(typeof F!="string")throw new TypeError("Signatures must be strings");const N=F.trim();if(N==="")return _;const T=N.split(",");for(let $=0;$<T.length;++$){const I=g(T[$].trim());if(I.restParam&&$!==T.length-1)throw new SyntaxError('Unexpected rest parameter "'+T[$]+'": only allowed for the last parameter');if(I.types.length===0)return null;_.push(I)}return _}function y(F){const _=ce(F);return _?_.restParam:!1}function w(F){if(!F||F.types.length===0)return an;if(F.types.length===1)return a(F.types[0].name).test;if(F.types.length===2){const _=a(F.types[0].name).test,N=a(F.types[1].name).test;return function($){return _($)||N($)}}else{const _=F.types.map(function(N){return a(N.name).test});return function(T){for(let $=0;$<_.length;$++)if(_[$](T))return!0;return!1}}}function C(F){let _,N,T;if(y(F)){_=qe(F).map(w);const $=_.length,I=w(ce(F)),H=function(U){for(let Z=$;Z<U.length;Z++)if(!I(U[Z]))return!1;return!0};return function(Z){for(let P=0;P<_.length;P++)if(!_[P](Z[P]))return!1;return H(Z)&&Z.length>=$+1}}else return F.length===0?function(I){return I.length===0}:F.length===1?(N=w(F[0]),function(I){return N(I[0])&&I.length===1}):F.length===2?(N=w(F[0]),T=w(F[1]),function(I){return N(I[0])&&T(I[1])&&I.length===2}):(_=F.map(w),function(I){for(let H=0;H<_.length;H++)if(!_[H](I[H]))return!1;return I.length===_.length})}function b(F,_){return _<F.length?F[_]:y(F)?ce(F):null}function B(F,_){const N=b(F,_);return N?v(N):new Set}function M(F){return F.conversion===null||F.conversion===void 0}function S(F,_){const N=new Set;return F.forEach(T=>{const $=B(T.params,_);let I;for(I of $)N.add(I)}),N.has("any")?["any"]:Array.from(N)}function R(F,_,N){let T,$;const I=F||"unnamed";let H=N,U;for(U=0;U<_.length;U++){const pe=[];if(H.forEach(_e=>{const Le=b(_e.params,U),Re=w(Le);(U<_e.params.length||y(_e.params))&&Re(_[U])&&pe.push(_e)}),pe.length===0){if($=S(H,U),$.length>0){const _e=h(_[U]);return T=new TypeError("Unexpected type of argument in function "+I+" (expected: "+$.join(" or ")+", actual: "+_e.join(" | ")+", index: "+U+")"),T.data={category:"wrongType",fn:I,index:U,actual:_e,expected:$},T}}else H=pe}const Z=H.map(function(pe){return y(pe.params)?1/0:pe.params.length});if(_.length<Math.min.apply(null,Z))return $=S(H,U),T=new TypeError("Too few arguments in function "+I+" (expected: "+$.join(" or ")+", index: "+_.length+")"),T.data={category:"tooFewArgs",fn:I,index:_.length,expected:$},T;const P=Math.max.apply(null,Z);if(_.length>P)return T=new TypeError("Too many arguments in function "+I+" (expected: "+P+", actual: "+_.length+")"),T.data={category:"tooManyArgs",fn:I,index:_.length,expectedLength:P},T;const se=[];for(let pe=0;pe<_.length;++pe)se.push(h(_[pe]).join("|"));return T=new TypeError('Arguments of type "'+se.join(", ")+'" do not match any of the defined signatures of function '+I+"."),T.data={category:"mismatch",actual:se},T}function V(F){let _=i.length+1;for(let N=0;N<F.types.length;N++)M(F.types[N])&&(_=Math.min(_,F.types[N].typeIndex));return _}function q(F){let _=u+1;for(let N=0;N<F.types.length;N++)M(F.types[N])||(_=Math.min(_,F.types[N].conversionIndex));return _}function W(F,_){if(F.hasAny){if(!_.hasAny)return 1}else if(_.hasAny)return-1;if(F.restParam){if(!_.restParam)return 1}else if(_.restParam)return-1;if(F.hasConversion){if(!_.hasConversion)return 1}else if(_.hasConversion)return-1;const N=V(F)-V(_);if(N<0)return-1;if(N>0)return 1;const T=q(F)-q(_);return T<0?-1:T>0?1:0}function O(F,_){const N=F.params,T=_.params,$=ce(N),I=ce(T),H=y(N),U=y(T);if(H&&$.hasAny){if(!U||!I.hasAny)return 1}else if(U&&I.hasAny)return-1;let Z=0,P=0,se;for(se of N)se.hasAny&&++Z,se.hasConversion&&++P;let pe=0,_e=0;for(se of T)se.hasAny&&++pe,se.hasConversion&&++_e;if(Z!==pe)return Z-pe;if(H&&$.hasConversion){if(!U||!I.hasConversion)return 1}else if(U&&I.hasConversion)return-1;if(P!==_e)return P-_e;if(H){if(!U)return 1}else if(U)return-1;const Le=(N.length-T.length)*(H?-1:1);if(Le!==0)return Le;const Re=[];let Ke=0;for(let Cr=0;Cr<N.length;++Cr){const kr=W(N[Cr],T[Cr]);Re.push(kr),Ke+=kr}if(Ke!==0)return Ke;let je;for(je of Re)if(je!==0)return je;return 0}function Q(F){if(F.length===0)return[];const _=F.map(a);F.length>1&&_.sort(($,I)=>$.index-I.index);let N=_[0].conversionsTo;if(F.length===1)return N;N=N.concat([]);const T=new Set(F);for(let $=1;$<_.length;++$){let I;for(I of _[$].conversionsTo)T.has(I.from)||(N.push(I),T.add(I.from))}return N}function Y(F,_){let N=_;if(F.some($=>$.hasConversion)){const $=y(F),I=F.map(G);N=function(){const U=[],Z=$?arguments.length-1:arguments.length;for(let P=0;P<Z;P++)U[P]=I[P](arguments[P]);return $&&(U[Z]=arguments[Z].map(I[Z])),_.apply(this,U)}}let T=N;if(y(F)){const $=F.length-1;T=function(){return N.apply(this,ae(arguments,0,$).concat([ae(arguments,$)]))}}return T}function G(F){let _,N,T,$;const I=[],H=[];switch(F.types.forEach(function(U){U.conversion&&(I.push(a(U.conversion.from).test),H.push(U.conversion.convert))}),H.length){case 0:return function(Z){return Z};case 1:return _=I[0],T=H[0],function(Z){return _(Z)?T(Z):Z};case 2:return _=I[0],N=I[1],T=H[0],$=H[1],function(Z){return _(Z)?T(Z):N(Z)?$(Z):Z};default:return function(Z){for(let P=0;P<H.length;P++)if(I[P](Z))return H[P](Z);return Z}}}function ee(F){function _(N,T,$){if(T<N.length){const I=N[T];let H=[];if(I.restParam){const U=I.types.filter(M);U.length<I.types.length&&H.push({types:U,name:"..."+U.map(Z=>Z.name).join("|"),hasAny:U.some(Z=>Z.isAny),hasConversion:!1,restParam:!0}),H.push(I)}else H=I.types.map(function(U){return{types:[U],name:U.name,hasAny:U.isAny,hasConversion:U.conversion,restParam:!1}});return Te(H,function(U){return _(N,T+1,$.concat([U]))})}else return[$]}return _(F,0,[])}function oe(F,_){const N=Math.max(F.length,_.length);for(let U=0;U<N;U++){const Z=B(F,U),P=B(_,U);let se=!1,pe;for(pe of P)if(Z.has(pe)){se=!0;break}if(!se)return!1}const T=F.length,$=_.length,I=y(F),H=y(_);return I?H?T===$:$>=T:H?T>=$:T===$}function ie(F){return F.map(_=>sr(_)?Ge(_.referToSelf.callback):ar(_)?Me(_.referTo.references,_.referTo.callback):_)}function fe(F,_,N){const T=[];let $;for($ of F){let I=N[$];if(typeof I!="number")throw new TypeError('No definition for referenced signature "'+$+'"');if(I=_[I],typeof I!="function")return!1;T.push(I)}return T}function Ce(F,_,N){const T=ie(F),$=new Array(T.length).fill(!1);let I=!0;for(;I;){I=!1;let H=!0;for(let U=0;U<T.length;++U){if($[U])continue;const Z=T[U];if(sr(Z))T[U]=Z.referToSelf.callback(N),T[U].referToSelf=Z.referToSelf,$[U]=!0,H=!1;else if(ar(Z)){const P=fe(Z.referTo.references,T,_);P?(T[U]=Z.referTo.callback.apply(this,P),T[U].referTo=Z.referTo,$[U]=!0,H=!1):I=!0}}if(H&&I)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return T}function be(F){const _=/\bthis(\(|\.signatures\b)/;Object.keys(F).forEach(N=>{const T=F[N];if(_.test(T.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function Ae(F,_){if(o.createCount++,Object.keys(_).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&be(_);const N=[],T=[],$={},I=[];let H;for(H in _){if(!Object.prototype.hasOwnProperty.call(_,H))continue;const ue=A(H);if(!ue)continue;N.forEach(function(Ur){if(oe(Ur,ue))throw new TypeError('Conflicting signatures "'+d(Ur)+'" and "'+d(ue)+'".')}),N.push(ue);const He=T.length;T.push(_[H]);const Su=ue.map(E);let Xr;for(Xr of ee(Su)){const Ur=d(Xr);I.push({params:Xr,name:Ur,fn:He}),Xr.every(xu=>!xu.hasConversion)&&($[Ur]=He)}}I.sort(O);const U=Ce(T,$,Pr);let Z;for(Z in $)Object.prototype.hasOwnProperty.call($,Z)&&($[Z]=U[$[Z]]);const P=[],se=new Map;for(Z of I)se.has(Z.name)||(Z.fn=U[Z.fn],P.push(Z),se.set(Z.name,Z));const pe=P[0]&&P[0].params.length<=2&&!y(P[0].params),_e=P[1]&&P[1].params.length<=2&&!y(P[1].params),Le=P[2]&&P[2].params.length<=2&&!y(P[2].params),Re=P[3]&&P[3].params.length<=2&&!y(P[3].params),Ke=P[4]&&P[4].params.length<=2&&!y(P[4].params),je=P[5]&&P[5].params.length<=2&&!y(P[5].params),Cr=pe&&_e&&Le&&Re&&Ke&&je;for(let ue=0;ue<P.length;++ue)P[ue].test=C(P[ue].params);const kr=pe?w(P[0].params[0]):Ye,tu=_e?w(P[1].params[0]):Ye,nu=Le?w(P[2].params[0]):Ye,iu=Re?w(P[3].params[0]):Ye,uu=Ke?w(P[4].params[0]):Ye,ou=je?w(P[5].params[0]):Ye,au=pe?w(P[0].params[1]):Ye,su=_e?w(P[1].params[1]):Ye,fu=Le?w(P[2].params[1]):Ye,cu=Re?w(P[3].params[1]):Ye,lu=Ke?w(P[4].params[1]):Ye,hu=je?w(P[5].params[1]):Ye;for(let ue=0;ue<P.length;++ue)P[ue].implementation=Y(P[ue].params,P[ue].fn);const pu=pe?P[0].implementation:_r,Du=_e?P[1].implementation:_r,mu=Le?P[2].implementation:_r,du=Re?P[3].implementation:_r,gu=Ke?P[4].implementation:_r,vu=je?P[5].implementation:_r,wu=pe?P[0].params.length:-1,yu=_e?P[1].params.length:-1,Fu=Le?P[2].params.length:-1,Eu=Re?P[3].params.length:-1,Au=Ke?P[4].params.length:-1,bu=je?P[5].params.length:-1,Cu=Cr?6:0,_u=P.length,Bu=P.map(ue=>ue.test),Nu=P.map(ue=>ue.implementation),Mu=function(){for(let He=Cu;He<_u;He++)if(Bu[He](arguments))return Nu[He].apply(this,arguments);return o.onMismatch(F,arguments,P)};function Pr(ue,He){return arguments.length===wu&&kr(ue)&&au(He)?pu.apply(this,arguments):arguments.length===yu&&tu(ue)&&su(He)?Du.apply(this,arguments):arguments.length===Fu&&nu(ue)&&fu(He)?mu.apply(this,arguments):arguments.length===Eu&&iu(ue)&&cu(He)?du.apply(this,arguments):arguments.length===Au&&uu(ue)&&lu(He)?gu.apply(this,arguments):arguments.length===bu&&ou(ue)&&hu(He)?vu.apply(this,arguments):Mu.apply(this,arguments)}try{Object.defineProperty(Pr,"name",{value:F})}catch{}return Pr.signatures=$,Pr._typedFunctionData={signatures:P,signatureMap:se},Pr}function we(F,_,N){throw R(F,_,N)}function qe(F){return ae(F,0,F.length-1)}function ce(F){return F[F.length-1]}function ae(F,_,N){return Array.prototype.slice.call(F,_,N)}function Je(F,_){for(let N=0;N<F.length;N++)if(_(F[N]))return F[N]}function Te(F,_){return Array.prototype.concat.apply([],F.map(_))}function le(){const F=qe(arguments).map(N=>d(A(N))),_=ce(arguments);if(typeof _!="function")throw new TypeError("Callback function expected as last argument");return Me(F,_)}function Me(F,_){return{referTo:{references:F,callback:_}}}function Ge(F){if(typeof F!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:F}}}function ar(F){return F&&typeof F.referTo=="object"&&Array.isArray(F.referTo.references)&&typeof F.referTo.callback=="function"}function sr(F){return F&&typeof F.referToSelf=="object"&&typeof F.referToSelf.callback=="function"}function Ar(F,_){if(!F)return _;if(_&&_!==F){const N=new Error("Function names do not match (expected: "+F+", actual: "+_+")");throw N.data={actual:_,expected:F},N}return F}function br(F){let _;for(const N in F)Object.prototype.hasOwnProperty.call(F,N)&&(D(F[N])||typeof F[N].signature=="string")&&(_=Ar(_,F[N].name));return _}function zt(F,_){let N;for(N in _)if(Object.prototype.hasOwnProperty.call(_,N)){if(N in F&&_[N]!==F[N]){const T=new Error('Signature "'+N+'" is defined twice');throw T.data={signature:N,sourceFunction:_[N],destFunction:F[N]},T}F[N]=_[N]}}const ru=o;o=function(F){const _=typeof F=="string",N=_?1:0;let T=_?F:"";const $={};for(let I=N;I<arguments.length;++I){const H=arguments[I];let U={},Z;if(typeof H=="function"?(Z=H.name,typeof H.signature=="string"?U[H.signature]=H:D(H)&&(U=H.signatures)):e(H)&&(U=H,_||(Z=br(H))),Object.keys(U).length===0){const P=new TypeError("Argument to 'typed' at index "+I+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw P.data={index:I,argument:H},P}_||(T=Ar(T,Z)),zt($,U)}return Ae(T||"",$)},o.create=si,o.createCount=ru.createCount,o.onMismatch=we,o.throwMismatchError=we,o.createError=R,o.clear=l,o.clearConversions=f,o.addTypes=c,o._findType=a,o.referTo=le,o.referToSelf=Ge,o.convert=s,o.findSignature=p,o.find=m,o.isTypedFunction=D,o.warnAgainstDeprecatedThis=!0,o.addType=function(F,_){let N="any";_!==!1&&n.has("Object")&&(N="Object"),o.addTypes([F],N)};function on(F){if(!F||typeof F.from!="string"||typeof F.to!="string"||typeof F.convert!="function")throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");if(F.to===F.from)throw new SyntaxError('Illegal to define conversion from "'+F.from+'" to itself.')}return o.addConversion=function(F){let _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{override:!1};on(F);const N=a(F.to),T=N.conversionsTo.find($=>$.from===F.from);if(T)if(_&&_.override)o.removeConversion({from:T.from,to:F.to,convert:T.convert});else throw new Error('There is already a conversion from "'+F.from+'" to "'+N.name+'"');N.conversionsTo.push({from:F.from,convert:F.convert,index:u++})},o.addConversions=function(F,_){F.forEach(N=>o.addConversion(N,_))},o.removeConversion=function(F){on(F);const _=a(F.to),N=Je(_.conversionsTo,$=>$.from===F.from);if(!N)throw new Error("Attempt to remove nonexistent conversion from "+F.from+" to "+F.to);if(N.convert!==F.convert)throw new Error("Conversion to remove does not match existing conversion");const T=_.conversionsTo.indexOf(N);_.conversionsTo.splice(T,1)},o.resolve=function(F,_){if(!D(F))throw new TypeError(sn);const N=F._typedFunctionData.signatures;for(let T=0;T<N.length;++T)if(N[T].test(_))return N[T];return null},o}const ot=si();function J(e,r,t,n){function i(u){var o=mo(u,r.map(Fo));return wo(e,r,u),t(o)}return i.isFactory=!0,i.fn=e,i.dependencies=r.slice().sort(),n&&(i.meta=n),i}function wo(e,r,t){var n=r.filter(u=>!yo(u)).every(u=>t[u]!==void 0);if(!n){var i=r.filter(u=>t[u]===void 0);throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(i.map(u=>'"'.concat(u,'"')).join(", "),"."))}}function yo(e){return e&&e[0]==="?"}function Fo(e){return e&&e[0]==="?"?e.slice(1):e}function ge(e){return typeof e=="boolean"?!0:isFinite(e)?e===Math.round(e):!1}var Eo=Math.log10||function(r){return Math.log(r)/Math.LN10};function Ot(e,r,t){var n={2:"0b",8:"0o",16:"0x"},i=n[r],u="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ge(t))throw new Error("size must be an integer");if(e>2**(t-1)-1||e<-(2**(t-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!ge(e))throw new Error("Value must be an integer");e<0&&(e=e+2**t),u="i".concat(t)}var o="";return e<0&&(e=-e,o="-"),"".concat(o).concat(i).concat(e.toString(r)).concat(u)}function Zt(e,r){if(typeof r=="function")return r(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var{notation:t,precision:n,wordSize:i}=fi(r);switch(t){case"fixed":return ci(e,n);case"exponential":return li(e,n);case"engineering":return Ao(e,n);case"bin":return Ot(e,2,i);case"oct":return Ot(e,8,i);case"hex":return Ot(e,16,i);case"auto":return bo(e,n,r).replace(/((\.\d*?)(0+))($|e)/,function(){var u=arguments[2],o=arguments[4];return u!=="."?u+o:o});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function fi(e){var r="auto",t,n;if(e!==void 0)if(de(e))t=e;else if(Ee(e))t=e.toNumber();else if(Kt(e))e.precision!==void 0&&(t=fn(e.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),e.wordSize!==void 0&&(n=fn(e.wordSize,()=>{throw new Error('Option "wordSize" must be a number or BigNumber')})),e.notation&&(r=e.notation);else throw new Error("Unsupported type of options, number, BigNumber, or object expected");return{notation:r,precision:t,wordSize:n}}function Zr(e){var r=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number "+e);var t=r[1],n=r[2],i=parseFloat(r[4]||"0"),u=n.indexOf(".");i+=u!==-1?u-1:n.length-1;var o=n.replace(".","").replace(/^0*/,function(a){return i-=a.length,""}).replace(/0*$/,"").split("").map(function(a){return parseInt(a)});return o.length===0&&(o.push(0),i++),{sign:t,coefficients:o,exponent:i}}function Ao(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Zr(e),n=Ft(t,r),i=n.exponent,u=n.coefficients,o=i%3===0?i:i<0?i-3-i%3:i-i%3;if(de(r))for(;r>u.length||i-o+1>u.length;)u.push(0);else for(var a=Math.abs(i-o)-(u.length-1),c=0;c<a;c++)u.push(0);for(var l=Math.abs(i-o),f=1;l>0;)f++,l--;var h=u.slice(f).join(""),D=de(r)&&h.length||h.match(/[1-9]/)?"."+h:"",p=u.slice(0,f).join("")+D+"e"+(i>=0?"+":"")+o.toString();return n.sign+p}function ci(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Zr(e),n=typeof r=="number"?Ft(t,t.exponent+1+r):t,i=n.coefficients,u=n.exponent+1,o=u+(r||0);return i.length<o&&(i=i.concat(xr(o-i.length))),u<0&&(i=xr(-u+1).concat(i),u=1),u<i.length&&i.splice(u,0,u===0?"0.":"."),n.sign+i.join("")}function li(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Zr(e),n=r?Ft(t,r):t,i=n.coefficients,u=n.exponent;i.length<r&&(i=i.concat(xr(r-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(u>=0?"+":"")+u}function bo(e,r,t){if(isNaN(e)||!isFinite(e))return String(e);var n=cn(t?.lowerExp,-3),i=cn(t?.upperExp,5),u=Zr(e),o=r?Ft(u,r):u;if(o.exponent<n||o.exponent>=i)return li(e,r);var a=o.coefficients,c=o.exponent;a.length<r&&(a=a.concat(xr(r-a.length))),a=a.concat(xr(c-a.length+1+(a.length<r?r-a.length:0))),a=xr(-c).concat(a);var l=c>0?c:0;return l<a.length-1&&a.splice(l+1,0,"."),o.sign+a.join("")}function Ft(e,r){for(var t={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=t.coefficients;r<=0;)n.unshift(0),t.exponent++,r++;if(n.length>r){var i=n.splice(r,n.length-r);if(i[0]>=5){var u=r-1;for(n[u]++;n[u]===10;)n.pop(),u===0&&(n.unshift(0),t.exponent++,u++),u--,n[u]++}}return t}function xr(e){for(var r=[],t=0;t<e;t++)r.push(0);return r}function Co(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}function tr(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-8,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return isNaN(e)||isNaN(r)?!1:!isFinite(e)||!isFinite(r)?e===r:e===r?!0:Math.abs(e-r)<=Math.max(t*Math.max(Math.abs(e),Math.abs(r)),n)}function fn(e,r){if(de(e))return e;if(Ee(e))return e.toNumber();r()}function cn(e,r){return de(e)?e:Ee(e)?e.toNumber():r}var hi=function(){return hi=ot.create,ot},_o=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],Bo=J("typed",_o,function(r){var{BigNumber:t,Complex:n,DenseMatrix:i,Fraction:u}=r,o=hi();return o.clear(),o.addTypes([{name:"number",test:de},{name:"Complex",test:ii},{name:"BigNumber",test:Ee},{name:"bigint",test:Uu},{name:"Fraction",test:ui},{name:"Unit",test:oi},{name:"identifier",test:a=>Qe&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(a)},{name:"string",test:Qe},{name:"Chain",test:ho},{name:"Array",test:ye},{name:"Matrix",test:ve},{name:"DenseMatrix",test:qu},{name:"SparseMatrix",test:Ru},{name:"Range",test:ai},{name:"Index",test:yt},{name:"boolean",test:Lu},{name:"ResultSet",test:Hu},{name:"Help",test:Zu},{name:"function",test:Wu},{name:"Date",test:Vu},{name:"RegExp",test:Ju},{name:"null",test:Yu},{name:"undefined",test:ku},{name:"AccessorNode",test:Xu},{name:"ArrayNode",test:Qu},{name:"AssignmentNode",test:Ku},{name:"BlockNode",test:ju},{name:"ConditionalNode",test:eo},{name:"ConstantNode",test:ro},{name:"FunctionNode",test:no},{name:"FunctionAssignmentNode",test:to},{name:"IndexNode",test:io},{name:"Node",test:uo},{name:"ObjectNode",test:oo},{name:"OperatorNode",test:ao},{name:"ParenthesisNode",test:so},{name:"RangeNode",test:fo},{name:"RelationalNode",test:co},{name:"SymbolNode",test:lo},{name:"Map",test:Gu},{name:"Object",test:Kt}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(t||Qr(c),Co(c)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+c+"). Use function bignumber(x) to convert to BigNumber.");return new t(c)}},{from:"number",to:"Complex",convert:function(c){return n||Kr(c),new n(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return n||Kr(c),new n(c.toNumber(),0)}},{from:"bigint",to:"number",convert:function(c){if(c>Number.MAX_SAFE_INTEGER)throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: "+c+")");return Number(c)}},{from:"bigint",to:"BigNumber",convert:function(c){return t||Qr(c),new t(c.toString())}},{from:"bigint",to:"Fraction",convert:function(c){return u||jr(c),new u(c)}},{from:"Fraction",to:"BigNumber",convert:function(c){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(c){return n||Kr(c),new n(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){u||jr(c);var l=new u(c);if(l.valueOf()!==c)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+c+"). Use function fraction(x) to convert to Fraction.");return l}},{from:"string",to:"number",convert:function(c){var l=Number(c);if(isNaN(l))throw new Error('Cannot convert "'+c+'" to a number');return l}},{from:"string",to:"BigNumber",convert:function(c){t||Qr(c);try{return new t(c)}catch{throw new Error('Cannot convert "'+c+'" to BigNumber')}}},{from:"string",to:"bigint",convert:function(c){try{return BigInt(c)}catch{throw new Error('Cannot convert "'+c+'" to BigInt')}}},{from:"string",to:"Fraction",convert:function(c){u||jr(c);try{return new u(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){n||Kr(c);try{return new n(c)}catch{throw new Error('Cannot convert "'+c+'" to Complex')}}},{from:"boolean",to:"number",convert:function(c){return+c}},{from:"boolean",to:"BigNumber",convert:function(c){return t||Qr(c),new t(+c)}},{from:"boolean",to:"bigint",convert:function(c){return BigInt(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return u||jr(c),new u(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return i||No(),new i(c)}},{from:"Matrix",to:"Array",convert:function(c){return c.valueOf()}}]),o.onMismatch=(a,c,l)=>{var f=o.createError(a,c,l);if(["wrongType","mismatch"].includes(f.data.category)&&c.length===1&&ut(c[0])&&l.some(D=>!D.params.includes(","))){var h=new TypeError("Function '".concat(a,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(a,")'."));throw h.data=f.data,h}throw f},o.onMismatch=(a,c,l)=>{var f=o.createError(a,c,l);if(["wrongType","mismatch"].includes(f.data.category)&&c.length===1&&ut(c[0])&&l.some(D=>!D.params.includes(","))){var h=new TypeError("Function '".concat(a,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(a,")'."));throw h.data=f.data,h}throw f},o});function Qr(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function Kr(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function No(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function jr(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}/*!
9
+ * decimal.js v10.5.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 Sr=9e15,vr=1e9,Wt="0123456789abcdef",at="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",st="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Vt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Sr,maxE:Sr,crypto:!1},pi,cr,j=!0,Et="[DecimalError] ",dr=Et+"Invalid argument: ",Di=Et+"Precision limit exceeded",mi=Et+"crypto unavailable",di="[object Decimal]",$e=Math.floor,Ne=Math.pow,Mo=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,So=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,xo=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,gi=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,rr=1e7,K=7,To=9007199254740991,Io=at.length-1,Jt=st.length-1,z={toStringTag:di};z.absoluteValue=z.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),X(e)};z.ceil=function(){return X(new this.constructor(this),this.e+1,2)};z.clampedTo=z.clamp=function(e,r){var t,n=this,i=n.constructor;if(e=new i(e),r=new i(r),!e.s||!r.s)return new i(NaN);if(e.gt(r))throw Error(dr+r);return t=n.cmp(e),t<0?e:n.cmp(r)>0?r:new i(n)};z.comparedTo=z.cmp=function(e){var r,t,n,i,u=this,o=u.d,a=(e=new u.constructor(e)).d,c=u.s,l=e.s;if(!o||!a)return!c||!l?NaN:c!==l?c:o===a?0:!o^c<0?1:-1;if(!o[0]||!a[0])return o[0]?c:a[0]?-l:0;if(c!==l)return c;if(u.e!==e.e)return u.e>e.e^c<0?1:-1;for(n=o.length,i=a.length,r=0,t=n<i?n:i;r<t;++r)if(o[r]!==a[r])return o[r]>a[r]^c<0?1:-1;return n===i?0:n>i^c<0?1:-1};z.cosine=z.cos=function(){var e,r,t=this,n=t.constructor;return t.d?t.d[0]?(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+K,n.rounding=1,t=zo(n,Ei(n,t)),n.precision=e,n.rounding=r,X(cr==2||cr==3?t.neg():t,e,r,!0)):new n(1):new n(NaN)};z.cubeRoot=z.cbrt=function(){var e,r,t,n,i,u,o,a,c,l,f=this,h=f.constructor;if(!f.isFinite()||f.isZero())return new h(f);for(j=!1,u=f.s*Ne(f.s*f,1/3),!u||Math.abs(u)==1/0?(t=Ie(f.d),e=f.e,(u=(e-t.length+1)%3)&&(t+=u==1||u==-2?"0":"00"),u=Ne(t,1/3),e=$e((e+1)/3)-(e%3==(e<0?-1:2)),u==1/0?t="5e"+e:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new h(t),n.s=f.s):n=new h(u.toString()),o=(e=h.precision)+3;;)if(a=n,c=a.times(a).times(a),l=c.plus(f),n=he(l.plus(f).times(a),l.plus(c),o+2,1),Ie(a.d).slice(0,o)===(t=Ie(n.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(X(a,e+1,0),a.times(a).times(a).eq(f))){n=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(X(n,e+1,1),r=!n.times(n).times(n).eq(f));break}return j=!0,X(n,e,h.rounding,r)};z.decimalPlaces=z.dp=function(){var e,r=this.d,t=NaN;if(r){if(e=r.length-1,t=(e-$e(this.e/K))*K,e=r[e],e)for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t};z.dividedBy=z.div=function(e){return he(this,new this.constructor(e))};z.dividedToIntegerBy=z.divToInt=function(e){var r=this,t=r.constructor;return X(he(r,new t(e),0,1,1),t.precision,t.rounding)};z.equals=z.eq=function(e){return this.cmp(e)===0};z.floor=function(){return X(new this.constructor(this),this.e+1,3)};z.greaterThan=z.gt=function(e){return this.cmp(e)>0};z.greaterThanOrEqualTo=z.gte=function(e){var r=this.cmp(e);return r==1||r===0};z.hyperbolicCosine=z.cosh=function(){var e,r,t,n,i,u=this,o=u.constructor,a=new o(1);if(!u.isFinite())return new o(u.s?1/0:NaN);if(u.isZero())return a;t=o.precision,n=o.rounding,o.precision=t+Math.max(u.e,u.sd())+4,o.rounding=1,i=u.d.length,i<32?(e=Math.ceil(i/3),r=(1/bt(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),u=Ir(o,1,u.times(r),new o(1),!0);for(var c,l=e,f=new o(8);l--;)c=u.times(u),u=a.minus(c.times(f.minus(c.times(f))));return X(u,o.precision=t,o.rounding=n,!0)};z.hyperbolicSine=z.sinh=function(){var e,r,t,n,i=this,u=i.constructor;if(!i.isFinite()||i.isZero())return new u(i);if(r=u.precision,t=u.rounding,u.precision=r+Math.max(i.e,i.sd())+4,u.rounding=1,n=i.d.length,n<3)i=Ir(u,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/bt(5,e)),i=Ir(u,2,i,i,!0);for(var o,a=new u(5),c=new u(16),l=new u(20);e--;)o=i.times(i),i=i.times(a.plus(o.times(c.times(o).plus(l))))}return u.precision=r,u.rounding=t,X(i,r,t,!0)};z.hyperbolicTangent=z.tanh=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+7,n.rounding=1,he(t.sinh(),t.cosh(),n.precision=e,n.rounding=r)):new n(t.s)};z.inverseCosine=z.acos=function(){var e=this,r=e.constructor,t=e.abs().cmp(1),n=r.precision,i=r.rounding;return t!==-1?t===0?e.isNeg()?nr(r,n,i):new r(0):new r(NaN):e.isZero()?nr(r,n+4,i).times(.5):(r.precision=n+6,r.rounding=1,e=new r(1).minus(e).div(e.plus(1)).sqrt().atan(),r.precision=n,r.rounding=i,e.times(2))};z.inverseHyperbolicCosine=z.acosh=function(){var e,r,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(e=n.precision,r=n.rounding,n.precision=e+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,j=!1,t=t.times(t).minus(1).sqrt().plus(t),j=!0,n.precision=e,n.rounding=r,t.ln()):new n(t)};z.inverseHyperbolicSine=z.asinh=function(){var e,r,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,j=!1,t=t.times(t).plus(1).sqrt().plus(t),j=!0,n.precision=e,n.rounding=r,t.ln())};z.inverseHyperbolicTangent=z.atanh=function(){var e,r,t,n,i=this,u=i.constructor;return i.isFinite()?i.e>=0?new u(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=u.precision,r=u.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?X(new u(i),e,r,!0):(u.precision=t=n-i.e,i=he(i.plus(1),new u(1).minus(i),t+e,1),u.precision=e+4,u.rounding=1,i=i.ln(),u.precision=e,u.rounding=r,i.times(.5))):new u(NaN)};z.inverseSine=z.asin=function(){var e,r,t,n,i=this,u=i.constructor;return i.isZero()?new u(i):(r=i.abs().cmp(1),t=u.precision,n=u.rounding,r!==-1?r===0?(e=nr(u,t+4,n).times(.5),e.s=i.s,e):new u(NaN):(u.precision=t+6,u.rounding=1,i=i.div(new u(1).minus(i.times(i)).sqrt().plus(1)).atan(),u.precision=t,u.rounding=n,i.times(2)))};z.inverseTangent=z.atan=function(){var e,r,t,n,i,u,o,a,c,l=this,f=l.constructor,h=f.precision,D=f.rounding;if(l.isFinite()){if(l.isZero())return new f(l);if(l.abs().eq(1)&&h+4<=Jt)return o=nr(f,h+4,D).times(.25),o.s=l.s,o}else{if(!l.s)return new f(NaN);if(h+4<=Jt)return o=nr(f,h+4,D).times(.5),o.s=l.s,o}for(f.precision=a=h+10,f.rounding=1,t=Math.min(28,a/K+2|0),e=t;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(j=!1,r=Math.ceil(a/K),n=1,c=l.times(l),o=new f(l),i=l;e!==-1;)if(i=i.times(c),u=o.minus(i.div(n+=2)),i=i.times(c),o=u.plus(i.div(n+=2)),o.d[r]!==void 0)for(e=r;o.d[e]===u.d[e]&&e--;);return t&&(o=o.times(2<<t-1)),j=!0,X(o,f.precision=h,f.rounding=D,!0)};z.isFinite=function(){return!!this.d};z.isInteger=z.isInt=function(){return!!this.d&&$e(this.e/K)>this.d.length-2};z.isNaN=function(){return!this.s};z.isNegative=z.isNeg=function(){return this.s<0};z.isPositive=z.isPos=function(){return this.s>0};z.isZero=function(){return!!this.d&&this.d[0]===0};z.lessThan=z.lt=function(e){return this.cmp(e)<0};z.lessThanOrEqualTo=z.lte=function(e){return this.cmp(e)<1};z.logarithm=z.log=function(e){var r,t,n,i,u,o,a,c,l=this,f=l.constructor,h=f.precision,D=f.rounding,p=5;if(e==null)e=new f(10),r=!0;else{if(e=new f(e),t=e.d,e.s<0||!t||!t[0]||e.eq(1))return new f(NaN);r=e.eq(10)}if(t=l.d,l.s<0||!t||!t[0]||l.eq(1))return new f(t&&!t[0]?-1/0:l.s!=1?NaN:t?0:1/0);if(r)if(t.length>1)u=!0;else{for(i=t[0];i%10===0;)i/=10;u=i!==1}if(j=!1,a=h+p,o=Dr(l,a),n=r?ft(f,a+10):Dr(e,a),c=he(o,n,a,1),Lr(c.d,i=h,D))do if(a+=10,o=Dr(l,a),n=r?ft(f,a+10):Dr(e,a),c=he(o,n,a,1),!u){+Ie(c.d).slice(i+1,i+15)+1==1e14&&(c=X(c,h+1,0));break}while(Lr(c.d,i+=10,D));return j=!0,X(c,h,D)};z.minus=z.sub=function(e){var r,t,n,i,u,o,a,c,l,f,h,D,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,D=e.d,a=m.precision,c=m.rounding,!l[0]||!D[0]){if(D[0])e.s=-e.s;else if(l[0])e=new m(p);else return new m(c===3?-0:0);return j?X(e,a,c):e}if(t=$e(e.e/K),f=$e(p.e/K),l=l.slice(),u=f-t,u){for(h=u<0,h?(r=l,u=-u,o=D.length):(r=D,t=f,o=l.length),n=Math.max(Math.ceil(a/K),o)+2,u>n&&(u=n,r.length=1),r.reverse(),n=u;n--;)r.push(0);r.reverse()}else{for(n=l.length,o=D.length,h=n<o,h&&(o=n),n=0;n<o;n++)if(l[n]!=D[n]){h=l[n]<D[n];break}u=0}for(h&&(r=l,l=D,D=r,e.s=-e.s),o=l.length,n=D.length-o;n>0;--n)l[o++]=0;for(n=D.length;n>u;){if(l[--n]<D[n]){for(i=n;i&&l[--i]===0;)l[i]=rr-1;--l[i],l[n]+=rr}l[n]-=D[n]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--t;return l[0]?(e.d=l,e.e=At(l,t),j?X(e,a,c):e):new m(c===3?-0:0)};z.modulo=z.mod=function(e){var r,t=this,n=t.constructor;return e=new n(e),!t.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||t.d&&!t.d[0]?X(new n(t),n.precision,n.rounding):(j=!1,n.modulo==9?(r=he(t,e.abs(),0,3,1),r.s*=e.s):r=he(t,e,0,n.modulo,1),r=r.times(e),j=!0,t.minus(r))};z.naturalExponential=z.exp=function(){return Gt(this)};z.naturalLogarithm=z.ln=function(){return Dr(this)};z.negated=z.neg=function(){var e=new this.constructor(this);return e.s=-e.s,X(e)};z.plus=z.add=function(e){var r,t,n,i,u,o,a,c,l,f,h=this,D=h.constructor;if(e=new D(e),!h.d||!e.d)return!h.s||!e.s?e=new D(NaN):h.d||(e=new D(e.d||h.s===e.s?h:NaN)),e;if(h.s!=e.s)return e.s=-e.s,h.minus(e);if(l=h.d,f=e.d,a=D.precision,c=D.rounding,!l[0]||!f[0])return f[0]||(e=new D(h)),j?X(e,a,c):e;if(u=$e(h.e/K),n=$e(e.e/K),l=l.slice(),i=u-n,i){for(i<0?(t=l,i=-i,o=f.length):(t=f,n=u,o=l.length),u=Math.ceil(a/K),o=u>o?u+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=l.length,i=f.length,o-i<0&&(i=o,t=f,f=l,l=t),r=0;i;)r=(l[--i]=l[i]+f[i]+r)/rr|0,l[i]%=rr;for(r&&(l.unshift(r),++n),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=At(l,n),j?X(e,a,c):e};z.precision=z.sd=function(e){var r,t=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(dr+e);return t.d?(r=vi(t.d),e&&t.e+1>r&&(r=t.e+1)):r=NaN,r};z.round=function(){var e=this,r=e.constructor;return X(new r(e),e.e+1,r.rounding)};z.sine=z.sin=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+Math.max(t.e,t.sd())+K,n.rounding=1,t=$o(n,Ei(n,t)),n.precision=e,n.rounding=r,X(cr>2?t.neg():t,e,r,!0)):new n(NaN)};z.squareRoot=z.sqrt=function(){var e,r,t,n,i,u,o=this,a=o.d,c=o.e,l=o.s,f=o.constructor;if(l!==1||!a||!a[0])return new f(!l||l<0&&(!a||a[0])?NaN:a?o:1/0);for(j=!1,l=Math.sqrt(+o),l==0||l==1/0?(r=Ie(a),(r.length+c)%2==0&&(r+="0"),l=Math.sqrt(r),c=$e((c+1)/2)-(c<0||c%2),l==1/0?r="5e"+c:(r=l.toExponential(),r=r.slice(0,r.indexOf("e")+1)+c),n=new f(r)):n=new f(l.toString()),t=(c=f.precision)+3;;)if(u=n,n=u.plus(he(o,u,t+2,1)).times(.5),Ie(u.d).slice(0,t)===(r=Ie(n.d)).slice(0,t))if(r=r.slice(t-3,t+1),r=="9999"||!i&&r=="4999"){if(!i&&(X(u,c+1,0),u.times(u).eq(o))){n=u;break}t+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(X(n,c+1,1),e=!n.times(n).eq(o));break}return j=!0,X(n,c,f.rounding,e)};z.tangent=z.tan=function(){var e,r,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(e=n.precision,r=n.rounding,n.precision=e+10,n.rounding=1,t=t.sin(),t.s=1,t=he(t,new n(1).minus(t.times(t)).sqrt(),e+10,0),n.precision=e,n.rounding=r,X(cr==2||cr==4?t.neg():t,e,r,!0)):new n(NaN)};z.times=z.mul=function(e){var r,t,n,i,u,o,a,c,l,f=this,h=f.constructor,D=f.d,p=(e=new h(e)).d;if(e.s*=f.s,!D||!D[0]||!p||!p[0])return new h(!e.s||D&&!D[0]&&!p||p&&!p[0]&&!D?NaN:!D||!p?e.s/0:e.s*0);for(t=$e(f.e/K)+$e(e.e/K),c=D.length,l=p.length,c<l&&(u=D,D=p,p=u,o=c,c=l,l=o),u=[],o=c+l,n=o;n--;)u.push(0);for(n=l;--n>=0;){for(r=0,i=c+n;i>n;)a=u[i]+p[n]*D[i-n-1]+r,u[i--]=a%rr|0,r=a/rr|0;u[i]=(u[i]+r)%rr|0}for(;!u[--o];)u.pop();return r?++t:u.shift(),e.d=u,e.e=At(u,t),j?X(e,h.precision,h.rounding):e};z.toBinary=function(e,r){return jt(this,2,e,r)};z.toDecimalPlaces=z.toDP=function(e,r){var t=this,n=t.constructor;return t=new n(t),e===void 0?t:(We(e,0,vr),r===void 0?r=n.rounding:We(r,0,8),X(t,e+t.e+1,r))};z.toExponential=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=ur(n,!0):(We(e,0,vr),r===void 0?r=i.rounding:We(r,0,8),n=X(new i(n),e+1,r),t=ur(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+t:t};z.toFixed=function(e,r){var t,n,i=this,u=i.constructor;return e===void 0?t=ur(i):(We(e,0,vr),r===void 0?r=u.rounding:We(r,0,8),n=X(new u(i),e+i.e+1,r),t=ur(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};z.toFraction=function(e){var r,t,n,i,u,o,a,c,l,f,h,D,p=this,m=p.d,s=p.constructor;if(!m)return new s(p);if(l=t=new s(1),n=c=new s(0),r=new s(n),u=r.e=vi(m)-p.e-1,o=u%K,r.d[0]=Ne(10,o<0?K+o:o),e==null)e=u>0?r:l;else{if(a=new s(e),!a.isInt()||a.lt(l))throw Error(dr+a);e=a.gt(r)?u>0?r:l:a}for(j=!1,a=new s(Ie(m)),f=s.precision,s.precision=u=m.length*K*2;h=he(a,r,0,1,1),i=t.plus(h.times(n)),i.cmp(e)!=1;)t=n,n=i,i=l,l=c.plus(h.times(i)),c=i,i=r,r=a.minus(h.times(i)),a=i;return i=he(e.minus(t),n,0,1,1),c=c.plus(i.times(l)),t=t.plus(i.times(n)),c.s=l.s=p.s,D=he(l,n,u,1).minus(p).abs().cmp(he(c,t,u,1).minus(p).abs())<1?[l,n]:[c,t],s.precision=f,j=!0,D};z.toHexadecimal=z.toHex=function(e,r){return jt(this,16,e,r)};z.toNearest=function(e,r){var t=this,n=t.constructor;if(t=new n(t),e==null){if(!t.d)return t;e=new n(1),r=n.rounding}else{if(e=new n(e),r===void 0?r=n.rounding:We(r,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(j=!1,t=he(t,e,0,r,1).times(e),j=!0,X(t)):(e.s=t.s,t=e),t};z.toNumber=function(){return+this};z.toOctal=function(e,r){return jt(this,8,e,r)};z.toPower=z.pow=function(e){var r,t,n,i,u,o,a=this,c=a.constructor,l=+(e=new c(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new c(Ne(+a,l));if(a=new c(a),a.eq(1))return a;if(n=c.precision,u=c.rounding,e.eq(1))return X(a,n,u);if(r=$e(e.e/K),r>=e.d.length-1&&(t=l<0?-l:l)<=To)return i=wi(c,a,t,n),e.s<0?new c(1).div(i):X(i,n,u);if(o=a.s,o<0){if(r<e.d.length-1)return new c(NaN);if((e.d[r]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=Ne(+a,l),r=t==0||!isFinite(t)?$e(l*(Math.log("0."+Ie(a.d))/Math.LN10+a.e+1)):new c(t+"").e,r>c.maxE+1||r<c.minE-1?new c(r>0?o/0:0):(j=!1,c.rounding=a.s=1,t=Math.min(12,(r+"").length),i=Gt(e.times(Dr(a,n+t)),n),i.d&&(i=X(i,n+5,1),Lr(i.d,n,u)&&(r=n+10,i=X(Gt(e.times(Dr(a,r+t)),r),r+5,1),+Ie(i.d).slice(n+1,n+15)+1==1e14&&(i=X(i,n+1,0)))),i.s=o,j=!0,c.rounding=u,X(i,n,u))};z.toPrecision=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=ur(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(We(e,1,vr),r===void 0?r=i.rounding:We(r,0,8),n=X(new i(n),e,r),t=ur(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+t:t};z.toSignificantDigits=z.toSD=function(e,r){var t=this,n=t.constructor;return e===void 0?(e=n.precision,r=n.rounding):(We(e,1,vr),r===void 0?r=n.rounding:We(r,0,8)),X(new n(t),e,r)};z.toString=function(){var e=this,r=e.constructor,t=ur(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t};z.truncated=z.trunc=function(){return X(new this.constructor(this),this.e+1,1)};z.valueOf=z.toJSON=function(){var e=this,r=e.constructor,t=ur(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()?"-"+t:t};function Ie(e){var r,t,n,i=e.length-1,u="",o=e[0];if(i>0){for(u+=o,r=1;r<i;r++)n=e[r]+"",t=K-n.length,t&&(u+=pr(t)),u+=n;o=e[r],n=o+"",t=K-n.length,t&&(u+=pr(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return u+o}function We(e,r,t){if(e!==~~e||e<r||e>t)throw Error(dr+e)}function Lr(e,r,t,n){var i,u,o,a;for(u=e[0];u>=10;u/=10)--r;return--r<0?(r+=K,i=0):(i=Math.ceil((r+1)/K),r%=K),u=Ne(10,K-r),a=e[i]%u|0,n==null?r<3?(r==0?a=a/100|0:r==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==u||t>3&&a+1==u/2)&&(e[i+1]/u/100|0)==Ne(10,r-2)-1||(a==u/2||a==0)&&(e[i+1]/u/100|0)==0:r<4?(r==0?a=a/1e3|0:r==1?a=a/100|0:r==2&&(a=a/10|0),o=(n||t<4)&&a==9999||!n&&t>3&&a==4999):o=((n||t<4)&&a+1==u||!n&&t>3&&a+1==u/2)&&(e[i+1]/u/1e3|0)==Ne(10,r-3)-1,o}function rt(e,r,t){for(var n,i=[0],u,o=0,a=e.length;o<a;){for(u=i.length;u--;)i[u]*=r;for(i[0]+=Wt.indexOf(e.charAt(o++)),n=0;n<i.length;n++)i[n]>t-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/t|0,i[n]%=t)}return i.reverse()}function zo(e,r){var t,n,i;if(r.isZero())return r;n=r.d.length,n<32?(t=Math.ceil(n/3),i=(1/bt(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),e.precision+=t,r=Ir(e,1,r.times(i),new e(1));for(var u=t;u--;){var o=r.times(r);r=o.times(o).minus(o).times(8).plus(1)}return e.precision-=t,r}var he=function(){function e(n,i,u){var o,a=0,c=n.length;for(n=n.slice();c--;)o=n[c]*i+a,n[c]=o%u|0,a=o/u|0;return a&&n.unshift(a),n}function r(n,i,u,o){var a,c;if(u!=o)c=u>o?1:-1;else for(a=c=0;a<u;a++)if(n[a]!=i[a]){c=n[a]>i[a]?1:-1;break}return c}function t(n,i,u,o){for(var a=0;u--;)n[u]-=a,a=n[u]<i[u]?1:0,n[u]=a*o+n[u]-i[u];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,u,o,a,c){var l,f,h,D,p,m,s,d,g,E,v,A,y,w,C,b,B,M,S,R,V=n.constructor,q=n.s==i.s?1:-1,W=n.d,O=i.d;if(!W||!W[0]||!O||!O[0])return new V(!n.s||!i.s||(W?O&&W[0]==O[0]:!O)?NaN:W&&W[0]==0||!O?q*0:q/0);for(c?(p=1,f=n.e-i.e):(c=rr,p=K,f=$e(n.e/p)-$e(i.e/p)),S=O.length,B=W.length,g=new V(q),E=g.d=[],h=0;O[h]==(W[h]||0);h++);if(O[h]>(W[h]||0)&&f--,u==null?(w=u=V.precision,o=V.rounding):a?w=u+(n.e-i.e)+1:w=u,w<0)E.push(1),m=!0;else{if(w=w/p+2|0,h=0,S==1){for(D=0,O=O[0],w++;(h<B||D)&&w--;h++)C=D*c+(W[h]||0),E[h]=C/O|0,D=C%O|0;m=D||h<B}else{for(D=c/(O[0]+1)|0,D>1&&(O=e(O,D,c),W=e(W,D,c),S=O.length,B=W.length),b=S,v=W.slice(0,S),A=v.length;A<S;)v[A++]=0;R=O.slice(),R.unshift(0),M=O[0],O[1]>=c/2&&++M;do D=0,l=r(O,v,S,A),l<0?(y=v[0],S!=A&&(y=y*c+(v[1]||0)),D=y/M|0,D>1?(D>=c&&(D=c-1),s=e(O,D,c),d=s.length,A=v.length,l=r(s,v,d,A),l==1&&(D--,t(s,S<d?R:O,d,c))):(D==0&&(l=D=1),s=O.slice()),d=s.length,d<A&&s.unshift(0),t(v,s,A,c),l==-1&&(A=v.length,l=r(O,v,S,A),l<1&&(D++,t(v,S<A?R:O,A,c))),A=v.length):l===0&&(D++,v=[0]),E[h++]=D,l&&v[0]?v[A++]=W[b]||0:(v=[W[b]],A=1);while((b++<B||v[0]!==void 0)&&w--);m=v[0]!==void 0}E[0]||E.shift()}if(p==1)g.e=f,pi=m;else{for(h=1,D=E[0];D>=10;D/=10)h++;g.e=h+f*p-1,X(g,a?u+g.e+1:u,o,m)}return g}}();function X(e,r,t,n){var i,u,o,a,c,l,f,h,D,p=e.constructor;e:if(r!=null){if(h=e.d,!h)return e;for(i=1,a=h[0];a>=10;a/=10)i++;if(u=r-i,u<0)u+=K,o=r,f=h[D=0],c=f/Ne(10,i-o-1)%10|0;else if(D=Math.ceil((u+1)/K),a=h.length,D>=a)if(n){for(;a++<=D;)h.push(0);f=c=0,i=1,u%=K,o=u-K+1}else break e;else{for(f=a=h[D],i=1;a>=10;a/=10)i++;u%=K,o=u-K+i,c=o<0?0:f/Ne(10,i-o-1)%10|0}if(n=n||r<0||h[D+1]!==void 0||(o<0?f:f%Ne(10,i-o-1)),l=t<4?(c||n)&&(t==0||t==(e.s<0?3:2)):c>5||c==5&&(t==4||n||t==6&&(u>0?o>0?f/Ne(10,i-o):0:h[D-1])%10&1||t==(e.s<0?8:7)),r<1||!h[0])return h.length=0,l?(r-=e.e+1,h[0]=Ne(10,(K-r%K)%K),e.e=-r||0):h[0]=e.e=0,e;if(u==0?(h.length=D,a=1,D--):(h.length=D+1,a=Ne(10,K-u),h[D]=o>0?(f/Ne(10,i-o)%Ne(10,o)|0)*a:0),l)for(;;)if(D==0){for(u=1,o=h[0];o>=10;o/=10)u++;for(o=h[0]+=a,a=1;o>=10;o/=10)a++;u!=a&&(e.e++,h[0]==rr&&(h[0]=1));break}else{if(h[D]+=a,h[D]!=rr)break;h[D--]=0,a=1}for(u=h.length;h[--u]===0;)h.pop()}return j&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function ur(e,r,t){if(!e.isFinite())return Fi(e);var n,i=e.e,u=Ie(e.d),o=u.length;return r?(t&&(n=t-o)>0?u=u.charAt(0)+"."+u.slice(1)+pr(n):o>1&&(u=u.charAt(0)+"."+u.slice(1)),u=u+(e.e<0?"e":"e+")+e.e):i<0?(u="0."+pr(-i-1)+u,t&&(n=t-o)>0&&(u+=pr(n))):i>=o?(u+=pr(i+1-o),t&&(n=t-i-1)>0&&(u=u+"."+pr(n))):((n=i+1)<o&&(u=u.slice(0,n)+"."+u.slice(n)),t&&(n=t-o)>0&&(i+1===o&&(u+="."),u+=pr(n))),u}function At(e,r){var t=e[0];for(r*=K;t>=10;t/=10)r++;return r}function ft(e,r,t){if(r>Io)throw j=!0,t&&(e.precision=t),Error(Di);return X(new e(at),r,1,!0)}function nr(e,r,t){if(r>Jt)throw Error(Di);return X(new e(st),r,t,!0)}function vi(e){var r=e.length-1,t=r*K+1;if(r=e[r],r){for(;r%10==0;r/=10)t--;for(r=e[0];r>=10;r/=10)t++}return t}function pr(e){for(var r="";e--;)r+="0";return r}function wi(e,r,t,n){var i,u=new e(1),o=Math.ceil(n/K+4);for(j=!1;;){if(t%2&&(u=u.times(r),hn(u.d,o)&&(i=!0)),t=$e(t/2),t===0){t=u.d.length-1,i&&u.d[t]===0&&++u.d[t];break}r=r.times(r),hn(r.d,o)}return j=!0,u}function ln(e){return e.d[e.d.length-1]&1}function yi(e,r,t){for(var n,i,u=new e(r[0]),o=0;++o<r.length;){if(i=new e(r[o]),!i.s){u=i;break}n=u.cmp(i),(n===t||n===0&&u.s===t)&&(u=i)}return u}function Gt(e,r){var t,n,i,u,o,a,c,l=0,f=0,h=0,D=e.constructor,p=D.rounding,m=D.precision;if(!e.d||!e.d[0]||e.e>17)return new D(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(r==null?(j=!1,c=m):c=r,a=new D(.03125);e.e>-2;)e=e.times(a),h+=5;for(n=Math.log(Ne(2,h))/Math.LN10*2+5|0,c+=n,t=u=o=new D(1),D.precision=c;;){if(u=X(u.times(e),c,1),t=t.times(++f),a=o.plus(he(u,t,c,1)),Ie(a.d).slice(0,c)===Ie(o.d).slice(0,c)){for(i=h;i--;)o=X(o.times(o),c,1);if(r==null)if(l<3&&Lr(o.d,c-n,p,l))D.precision=c+=10,t=u=a=new D(1),f=0,l++;else return X(o,D.precision=m,p,j=!0);else return D.precision=m,o}o=a}}function Dr(e,r){var t,n,i,u,o,a,c,l,f,h,D,p=1,m=10,s=e,d=s.d,g=s.constructor,E=g.rounding,v=g.precision;if(s.s<0||!d||!d[0]||!s.e&&d[0]==1&&d.length==1)return new g(d&&!d[0]?-1/0:s.s!=1?NaN:d?0:s);if(r==null?(j=!1,f=v):f=r,g.precision=f+=m,t=Ie(d),n=t.charAt(0),Math.abs(u=s.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)s=s.times(e),t=Ie(s.d),n=t.charAt(0),p++;u=s.e,n>1?(s=new g("0."+t),u++):s=new g(n+"."+t.slice(1))}else return l=ft(g,f+2,v).times(u+""),s=Dr(new g(n+"."+t.slice(1)),f-m).plus(l),g.precision=v,r==null?X(s,v,E,j=!0):s;for(h=s,c=o=s=he(s.minus(1),s.plus(1),f,1),D=X(s.times(s),f,1),i=3;;){if(o=X(o.times(D),f,1),l=c.plus(he(o,new g(i),f,1)),Ie(l.d).slice(0,f)===Ie(c.d).slice(0,f))if(c=c.times(2),u!==0&&(c=c.plus(ft(g,f+2,v).times(u+""))),c=he(c,new g(p),f,1),r==null)if(Lr(c.d,f-m,E,a))g.precision=f+=m,l=o=s=he(h.minus(1),h.plus(1),f,1),D=X(s.times(s),f,1),i=a=1;else return X(c,g.precision=v,E,j=!0);else return g.precision=v,c;c=l,i+=2}}function Fi(e){return String(e.s*e.s/0)}function tt(e,r){var t,n,i;for((t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),n=0;r.charCodeAt(n)===48;n++);for(i=r.length;r.charCodeAt(i-1)===48;--i);if(r=r.slice(n,i),r){if(i-=n,e.e=t=t-n-1,e.d=[],n=(t+1)%K,t<0&&(n+=K),n<i){for(n&&e.d.push(+r.slice(0,n)),i-=K;n<i;)e.d.push(+r.slice(n,n+=K));r=r.slice(n),n=K-r.length}else n-=i;for(;n--;)r+="0";e.d.push(+r),j&&(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 Oo(e,r){var t,n,i,u,o,a,c,l,f;if(r.indexOf("_")>-1){if(r=r.replace(/(\d)_(?=\d)/g,"$1"),gi.test(r))return tt(e,r)}else if(r==="Infinity"||r==="NaN")return+r||(e.s=NaN),e.e=NaN,e.d=null,e;if(So.test(r))t=16,r=r.toLowerCase();else if(Mo.test(r))t=2;else if(xo.test(r))t=8;else throw Error(dr+r);for(u=r.search(/p/i),u>0?(c=+r.slice(u+1),r=r.substring(2,u)):r=r.slice(2),u=r.indexOf("."),o=u>=0,n=e.constructor,o&&(r=r.replace(".",""),a=r.length,u=a-u,i=wi(n,new n(t),u,u*2)),l=rt(r,t,rr),f=l.length-1,u=f;l[u]===0;--u)l.pop();return u<0?new n(e.s*0):(e.e=At(l,f),e.d=l,j=!1,o&&(e=he(e,i,a*4)),c&&(e=e.times(Math.abs(c)<54?Ne(2,c):zr.pow(2,c))),j=!0,e)}function $o(e,r){var t,n=r.d.length;if(n<3)return r.isZero()?r:Ir(e,2,r,r);t=1.4*Math.sqrt(n),t=t>16?16:t|0,r=r.times(1/bt(5,t)),r=Ir(e,2,r,r);for(var i,u=new e(5),o=new e(16),a=new e(20);t--;)i=r.times(r),r=r.times(u.plus(i.times(o.times(i).minus(a))));return r}function Ir(e,r,t,n,i){var u,o,a,c,l=e.precision,f=Math.ceil(l/K);for(j=!1,c=t.times(t),a=new e(n);;){if(o=he(a.times(c),new e(r++*r++),l,1),a=i?n.plus(o):n.minus(o),n=he(o.times(c),new e(r++*r++),l,1),o=a.plus(n),o.d[f]!==void 0){for(u=f;o.d[u]===a.d[u]&&u--;);if(u==-1)break}u=a,a=n,n=o,o=u}return j=!0,o.d.length=f+1,o}function bt(e,r){for(var t=e;--r;)t*=e;return t}function Ei(e,r){var t,n=r.s<0,i=nr(e,e.precision,1),u=i.times(.5);if(r=r.abs(),r.lte(u))return cr=n?4:1,r;if(t=r.divToInt(i),t.isZero())cr=n?3:2;else{if(r=r.minus(t.times(i)),r.lte(u))return cr=ln(t)?n?2:3:n?4:1,r;cr=ln(t)?n?1:4:n?3:2}return r.minus(i).abs()}function jt(e,r,t,n){var i,u,o,a,c,l,f,h,D,p=e.constructor,m=t!==void 0;if(m?(We(t,1,vr),n===void 0?n=p.rounding:We(n,0,8)):(t=p.precision,n=p.rounding),!e.isFinite())f=Fi(e);else{for(f=ur(e),o=f.indexOf("."),m?(i=2,r==16?t=t*4-3:r==8&&(t=t*3-2)):i=r,o>=0&&(f=f.replace(".",""),D=new p(1),D.e=f.length-o,D.d=rt(ur(D),10,i),D.e=D.d.length),h=rt(f,10,i),u=c=h.length;h[--c]==0;)h.pop();if(!h[0])f=m?"0p+0":"0";else{if(o<0?u--:(e=new p(e),e.d=h,e.e=u,e=he(e,D,t,n,0,i),h=e.d,u=e.e,l=pi),o=h[t],a=i/2,l=l||h[t+1]!==void 0,l=n<4?(o!==void 0||l)&&(n===0||n===(e.s<0?3:2)):o>a||o===a&&(n===4||l||n===6&&h[t-1]&1||n===(e.s<0?8:7)),h.length=t,l)for(;++h[--t]>i-1;)h[t]=0,t||(++u,h.unshift(1));for(c=h.length;!h[c-1];--c);for(o=0,f="";o<c;o++)f+=Wt.charAt(h[o]);if(m){if(c>1)if(r==16||r==8){for(o=r==16?4:3,--c;c%o;c++)f+="0";for(h=rt(f,i,r),c=h.length;!h[c-1];--c);for(o=1,f="1.";o<c;o++)f+=Wt.charAt(h[o])}else f=f.charAt(0)+"."+f.slice(1);f=f+(u<0?"p":"p+")+u}else if(u<0){for(;++u;)f="0"+f;f="0."+f}else if(++u>c)for(u-=c;u--;)f+="0";else u<c&&(f=f.slice(0,u)+"."+f.slice(u))}f=(r==16?"0x":r==2?"0b":r==8?"0o":"")+f}return e.s<0?"-"+f:f}function hn(e,r){if(e.length>r)return e.length=r,!0}function Po(e){return new this(e).abs()}function Uo(e){return new this(e).acos()}function qo(e){return new this(e).acosh()}function Ro(e,r){return new this(e).plus(r)}function Lo(e){return new this(e).asin()}function Ho(e){return new this(e).asinh()}function Zo(e){return new this(e).atan()}function Wo(e){return new this(e).atanh()}function Vo(e,r){e=new this(e),r=new this(r);var t,n=this.precision,i=this.rounding,u=n+4;return!e.s||!r.s?t=new this(NaN):!e.d&&!r.d?(t=nr(this,u,1).times(r.s>0?.25:.75),t.s=e.s):!r.d||e.isZero()?(t=r.s<0?nr(this,n,i):new this(0),t.s=e.s):!e.d||r.isZero()?(t=nr(this,u,1).times(.5),t.s=e.s):r.s<0?(this.precision=u,this.rounding=1,t=this.atan(he(e,r,u,1)),r=nr(this,u,1),this.precision=n,this.rounding=i,t=e.s<0?t.minus(r):t.plus(r)):t=this.atan(he(e,r,u,1)),t}function Jo(e){return new this(e).cbrt()}function Go(e){return X(e=new this(e),e.e+1,2)}function Yo(e,r,t){return new this(e).clamp(r,t)}function ko(e){if(!e||typeof e!="object")throw Error(Et+"Object expected");var r,t,n,i=e.defaults===!0,u=["precision",1,vr,"rounding",0,8,"toExpNeg",-Sr,0,"toExpPos",0,Sr,"maxE",0,Sr,"minE",-Sr,0,"modulo",0,9];for(r=0;r<u.length;r+=3)if(t=u[r],i&&(this[t]=Vt[t]),(n=e[t])!==void 0)if($e(n)===n&&n>=u[r+1]&&n<=u[r+2])this[t]=n;else throw Error(dr+t+": "+n);if(t="crypto",i&&(this[t]=Vt[t]),(n=e[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(mi);else this[t]=!1;else throw Error(dr+t+": "+n);return this}function Xo(e){return new this(e).cos()}function Qo(e){return new this(e).cosh()}function Ai(e){var r,t,n;function i(u){var o,a,c,l=this;if(!(l instanceof i))return new i(u);if(l.constructor=i,pn(u)){l.s=u.s,j?!u.d||u.e>i.maxE?(l.e=NaN,l.d=null):u.e<i.minE?(l.e=0,l.d=[0]):(l.e=u.e,l.d=u.d.slice()):(l.e=u.e,l.d=u.d?u.d.slice():u.d);return}if(c=typeof u,c==="number"){if(u===0){l.s=1/u<0?-1:1,l.e=0,l.d=[0];return}if(u<0?(u=-u,l.s=-1):l.s=1,u===~~u&&u<1e7){for(o=0,a=u;a>=10;a/=10)o++;j?o>i.maxE?(l.e=NaN,l.d=null):o<i.minE?(l.e=0,l.d=[0]):(l.e=o,l.d=[u]):(l.e=o,l.d=[u]);return}if(u*0!==0){u||(l.s=NaN),l.e=NaN,l.d=null;return}return tt(l,u.toString())}if(c==="string")return(a=u.charCodeAt(0))===45?(u=u.slice(1),l.s=-1):(a===43&&(u=u.slice(1)),l.s=1),gi.test(u)?tt(l,u):Oo(l,u);if(c==="bigint")return u<0?(u=-u,l.s=-1):l.s=1,tt(l,u.toString());throw Error(dr+u)}if(i.prototype=z,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=ko,i.clone=Ai,i.isDecimal=pn,i.abs=Po,i.acos=Uo,i.acosh=qo,i.add=Ro,i.asin=Lo,i.asinh=Ho,i.atan=Zo,i.atanh=Wo,i.atan2=Vo,i.cbrt=Jo,i.ceil=Go,i.clamp=Yo,i.cos=Xo,i.cosh=Qo,i.div=Ko,i.exp=jo,i.floor=ea,i.hypot=ra,i.ln=ta,i.log=na,i.log10=ua,i.log2=ia,i.max=oa,i.min=aa,i.mod=sa,i.mul=fa,i.pow=ca,i.random=la,i.round=ha,i.sign=pa,i.sin=Da,i.sinh=ma,i.sqrt=da,i.sub=ga,i.sum=va,i.tan=wa,i.tanh=ya,i.trunc=Fa,e===void 0&&(e={}),e&&e.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<n.length;)e.hasOwnProperty(t=n[r++])||(e[t]=this[t]);return i.config(e),i}function Ko(e,r){return new this(e).div(r)}function jo(e){return new this(e).exp()}function ea(e){return X(e=new this(e),e.e+1,3)}function ra(){var e,r,t=new this(0);for(j=!1,e=0;e<arguments.length;)if(r=new this(arguments[e++]),r.d)t.d&&(t=t.plus(r.times(r)));else{if(r.s)return j=!0,new this(1/0);t=r}return j=!0,t.sqrt()}function pn(e){return e instanceof zr||e&&e.toStringTag===di||!1}function ta(e){return new this(e).ln()}function na(e,r){return new this(e).log(r)}function ia(e){return new this(e).log(2)}function ua(e){return new this(e).log(10)}function oa(){return yi(this,arguments,-1)}function aa(){return yi(this,arguments,1)}function sa(e,r){return new this(e).mod(r)}function fa(e,r){return new this(e).mul(r)}function ca(e,r){return new this(e).pow(r)}function la(e){var r,t,n,i,u=0,o=new this(1),a=[];if(e===void 0?e=this.precision:We(e,1,vr),n=Math.ceil(e/K),this.crypto)if(crypto.getRandomValues)for(r=crypto.getRandomValues(new Uint32Array(n));u<n;)i=r[u],i>=429e7?r[u]=crypto.getRandomValues(new Uint32Array(1))[0]:a[u++]=i%1e7;else if(crypto.randomBytes){for(r=crypto.randomBytes(n*=4);u<n;)i=r[u]+(r[u+1]<<8)+(r[u+2]<<16)+((r[u+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(r,u):(a.push(i%1e7),u+=4);u=n/4}else throw Error(mi);else for(;u<n;)a[u++]=Math.random()*1e7|0;for(n=a[--u],e%=K,n&&e&&(i=Ne(10,K-e),a[u]=(n/i|0)*i);a[u]===0;u--)a.pop();if(u<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=K)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<K&&(t-=K-n)}return o.e=t,o.d=a,o}function ha(e){return X(e=new this(e),e.e+1,this.rounding)}function pa(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Da(e){return new this(e).sin()}function ma(e){return new this(e).sinh()}function da(e){return new this(e).sqrt()}function ga(e,r){return new this(e).sub(r)}function va(){var e=0,r=arguments,t=new this(r[e]);for(j=!1;t.s&&++e<r.length;)t=t.plus(r[e]);return j=!0,X(t,this.precision,this.rounding)}function wa(e){return new this(e).tan()}function ya(e){return new this(e).tanh()}function Fa(e){return X(e=new this(e),e.e+1,1)}z[Symbol.for("nodejs.util.inspect.custom")]=z.toString;z[Symbol.toStringTag]="Decimal";var zr=z.constructor=Ai(Vt);at=new zr(at);st=new zr(st);var Ea="BigNumber",Aa=["?on","config"],ba=J(Ea,Aa,e=>{var{on:r,config:t}=e,n=zr.clone({precision:t.precision,modulo:zr.EUCLID});return n.prototype=Object.create(n.prototype),n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(i){return new n(i.value)},r&&r("config",function(i,u){i.precision!==u.precision&&n.config({precision:i.precision})}),n},{isClass:!0});const Oe=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},ke=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},Ca=function(e){const r=Math.PI/4;if(-r>e||e>r)return Math.cos(e)-1;const t=e*e;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},$t=function(e,r){return e=Math.abs(e),r=Math.abs(r),e<r&&([e,r]=[r,e]),e<1e8?Math.sqrt(e*e+r*r):(r/=e,e*Math.sqrt(1+r*r))},Br=function(){throw SyntaxError("Invalid Param")};function Pt(e,r){const t=Math.abs(e),n=Math.abs(r);return e===0?Math.log(n):r===0?Math.log(t):t<3e3&&n<3e3?Math.log(e*e+r*r)*.5:(e=e*.5,r=r*.5,.5*Math.log(e*e+r*r)+Math.LN2)}const _a={re:0,im:0},wr=function(e,r){const t=_a;if(e==null)t.re=t.im=0;else if(r!==void 0)t.re=e,t.im=r;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!isFinite(e.abs)&&isFinite(e.arg))return x.INFINITY;t.re=e.abs*Math.cos(e.arg),t.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!isFinite(e.r)&&isFinite(e.phi))return x.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else e.length===2?(t.re=e[0],t.im=e[1]):Br();break;case"string":t.im=t.re=0;const n=e.replace(/_/g,"").match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);let i=1,u=0;n===null&&Br();for(let o=0;o<n.length;o++){const a=n[o];a===" "||a===" "||a===`
15
+ `||(a==="+"?i++:a==="-"?u++:a==="i"||a==="I"?(i+u===0&&Br(),n[o+1]!==" "&&!isNaN(n[o+1])?(t.im+=parseFloat((u%2?"-":"")+n[o+1]),o++):t.im+=parseFloat((u%2?"-":"")+"1"),i=u=0):((i+u===0||isNaN(a))&&Br(),n[o+1]==="i"||n[o+1]==="I"?(t.im+=parseFloat((u%2?"-":"")+a),o++):t.re+=parseFloat((u%2?"-":"")+a),i=u=0))}i+u>0&&Br();break;case"number":t.im=0,t.re=e;break;default:Br()}return isNaN(t.re)||isNaN(t.im),t};function x(e,r){if(!(this instanceof x))return new x(e,r);const t=wr(e,r);this.re=t.re,this.im=t.im}x.prototype={re:0,im:0,sign:function(){const e=$t(this.re,this.im);return new x(this.re/e,this.im/e)},add:function(e,r){const t=wr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?x.NAN:x.INFINITY:new x(this.re+t.re,this.im+t.im)},sub:function(e,r){const t=wr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?x.NAN:x.INFINITY:new x(this.re-t.re,this.im-t.im)},mul:function(e,r){const t=wr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),u=this.re===0&&this.im===0,o=t.re===0&&t.im===0;return n&&o||i&&u?x.NAN:n||i?x.INFINITY:t.im===0&&this.im===0?new x(this.re*t.re,0):new x(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){const t=wr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im)),u=this.re===0&&this.im===0,o=t.re===0&&t.im===0;if(u&&o||n&&i)return x.NAN;if(o||n)return x.INFINITY;if(u||i)return x.ZERO;if(t.im===0)return new x(this.re/t.re,this.im/t.re);if(Math.abs(t.re)<Math.abs(t.im)){const a=t.re/t.im,c=t.re*a+t.im;return new x((this.re*a+this.im)/c,(this.im*a-this.re)/c)}else{const a=t.im/t.re,c=t.im*a+t.re;return new x((this.re+this.im*a)/c,(this.im-this.re*a)/c)}},pow:function(e,r){const t=wr(e,r),n=this.re===0&&this.im===0;if(t.re===0&&t.im===0)return x.ONE;if(t.im===0){if(this.im===0&&this.re>0)return new x(Math.pow(this.re,t.re),0);if(this.re===0)switch((t.re%4+4)%4){case 0:return new x(Math.pow(this.im,t.re),0);case 1:return new x(0,Math.pow(this.im,t.re));case 2:return new x(-Math.pow(this.im,t.re),0);case 3:return new x(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return x.ZERO;const u=Math.atan2(this.im,this.re),o=Pt(this.re,this.im);let a=Math.exp(t.re*o-t.im*u),c=t.im*o+t.re*u;return new x(a*Math.cos(c),a*Math.sin(c))},sqrt:function(){const e=this.re,r=this.im;if(r===0)return e>=0?new x(Math.sqrt(e),0):new x(0,Math.sqrt(-e));const t=$t(e,r);let n=Math.sqrt(.5*(t+Math.abs(e))),i=Math.abs(r)/(2*n);return e>=0?new x(n,r<0?-i:i):new x(i,r<0?-n:n)},exp:function(){const e=Math.exp(this.re);return this.im===0?new x(e,0):new x(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,r=this.im;return new x(Math.expm1(e)*Math.cos(r)+Ca(r),Math.exp(e)*Math.sin(r))},log:function(){const e=this.re,r=this.im;return r===0&&e>0?new x(Math.log(e),0):new x(Pt(e,r),Math.atan2(r,e))},abs:function(){return $t(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,r=this.im;return new x(Math.sin(e)*Oe(r),Math.cos(e)*ke(r))},cos:function(){const e=this.re,r=this.im;return new x(Math.cos(e)*Oe(r),-Math.sin(e)*ke(r))},tan:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)+Oe(r);return new x(Math.sin(e)/t,ke(r)/t)},cot:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)-Oe(r);return new x(-Math.sin(e)/t,ke(r)/t)},sec:function(){const e=this.re,r=this.im,t=.5*Oe(2*r)+.5*Math.cos(2*e);return new x(Math.cos(e)*Oe(r)/t,Math.sin(e)*ke(r)/t)},csc:function(){const e=this.re,r=this.im,t=.5*Oe(2*r)-.5*Math.cos(2*e);return new x(Math.sin(e)*Oe(r)/t,-Math.cos(e)*ke(r)/t)},asin:function(){const e=this.re,r=this.im,t=new x(r*r-e*e+1,-2*e*r).sqrt(),n=new x(t.re-r,t.im+e).log();return new x(n.im,-n.re)},acos:function(){const e=this.re,r=this.im,t=new x(r*r-e*e+1,-2*e*r).sqrt(),n=new x(t.re-r,t.im+e).log();return new x(Math.PI/2-n.im,n.re)},atan:function(){const e=this.re,r=this.im;if(e===0){if(r===1)return new x(0,1/0);if(r===-1)return new x(0,-1/0)}const t=e*e+(1-r)*(1-r),n=new x((1-r*r-e*e)/t,-2*e/t).log();return new x(-.5*n.im,.5*n.re)},acot:function(){const e=this.re,r=this.im;if(r===0)return new x(Math.atan2(1,e),0);const t=e*e+r*r;return t!==0?new x(e/t,-r/t).atan():new x(e!==0?e/0:0,r!==0?-r/0:0).atan()},asec:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new x(0,1/0);const t=e*e+r*r;return t!==0?new x(e/t,-r/t).acos():new x(e!==0?e/0:0,r!==0?-r/0:0).acos()},acsc:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new x(Math.PI/2,1/0);const t=e*e+r*r;return t!==0?new x(e/t,-r/t).asin():new x(e!==0?e/0:0,r!==0?-r/0:0).asin()},sinh:function(){const e=this.re,r=this.im;return new x(ke(e)*Math.cos(r),Oe(e)*Math.sin(r))},cosh:function(){const e=this.re,r=this.im;return new x(Oe(e)*Math.cos(r),ke(e)*Math.sin(r))},tanh:function(){const e=2*this.re,r=2*this.im,t=Oe(e)+Math.cos(r);return new x(ke(e)/t,Math.sin(r)/t)},coth:function(){const e=2*this.re,r=2*this.im,t=Oe(e)-Math.cos(r);return new x(ke(e)/t,-Math.sin(r)/t)},csch:function(){const e=this.re,r=this.im,t=Math.cos(2*r)-Oe(2*e);return new x(-2*ke(e)*Math.cos(r)/t,2*Oe(e)*Math.sin(r)/t)},sech:function(){const e=this.re,r=this.im,t=Math.cos(2*r)+Oe(2*e);return new x(2*Oe(e)*Math.cos(r)/t,-2*ke(e)*Math.sin(r)/t)},asinh:function(){let e=this.im;this.im=-this.re,this.re=e;const r=this.asin();return this.re=-this.im,this.im=e,e=r.re,r.re=-r.im,r.im=e,r},acosh:function(){const e=this.acos();if(e.im<=0){const r=e.re;e.re=-e.im,e.im=r}else{const r=e.im;e.im=-e.re,e.re=r}return e},atanh:function(){const e=this.re,r=this.im,t=e>1&&r===0,n=1-e,i=1+e,u=n*n+r*r,o=u!==0?new x((i*n-r*r)/u,(r*n+i*r)/u):new x(e!==-1?e/0:0,r!==0?r/0:0),a=o.re;return o.re=Pt(o.re,o.im)/2,o.im=Math.atan2(o.im,a)/2,t&&(o.im=-o.im),o},acoth:function(){const e=this.re,r=this.im;if(e===0&&r===0)return new x(0,Math.PI/2);const t=e*e+r*r;return t!==0?new x(e/t,-r/t).atanh():new x(e!==0?e/0:0,r!==0?-r/0:0).atanh()},acsch:function(){const e=this.re,r=this.im;if(r===0)return new x(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);const t=e*e+r*r;return t!==0?new x(e/t,-r/t).asinh():new x(e!==0?e/0:0,r!==0?-r/0:0).asinh()},asech:function(){const e=this.re,r=this.im;if(this.isZero())return x.INFINITY;const t=e*e+r*r;return t!==0?new x(e/t,-r/t).acosh():new x(e!==0?e/0:0,r!==0?-r/0:0).acosh()},inverse:function(){if(this.isZero())return x.INFINITY;if(this.isInfinite())return x.ZERO;const e=this.re,r=this.im,t=e*e+r*r;return new x(e/t,-r/t)},conjugate:function(){return new x(this.re,-this.im)},neg:function(){return new x(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new x(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new x(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new x(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,r){const t=wr(e,r);return Math.abs(t.re-this.re)<=x.EPSILON&&Math.abs(t.im-this.im)<=x.EPSILON},clone:function(){return new x(this.re,this.im)},toString:function(){let e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<x.EPSILON&&(e=0),Math.abs(r)<x.EPSILON&&(r=0),r===0?t+e:(e!==0?(t+=e,t+=" ",r<0?(r=-r,t+="-"):t+="+",t+=" "):r<0&&(r=-r,t+="-"),r!==1&&(t+=r),t+"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.isFinite()}};x.ZERO=new x(0,0);x.ONE=new x(1,0);x.I=new x(0,1);x.PI=new x(Math.PI,0);x.E=new x(Math.E,0);x.INFINITY=new x(1/0,1/0);x.NAN=new x(NaN,NaN);x.EPSILON=1e-15;var Ba="Complex",Na=[],Ma=J(Ba,Na,()=>(Object.defineProperty(x,"name",{value:"Complex"}),x.prototype.constructor=x,x.prototype.type="Complex",x.prototype.isComplex=!0,x.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},x.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},x.prototype.format=function(e){var r="",t=this.im,n=this.re,i=Zt(this.re,e),u=Zt(this.im,e),o=de(e)?e:e?e.precision:null;if(o!==null){var a=Math.pow(10,-o);Math.abs(n/t)<a&&(n=0),Math.abs(t/n)<a&&(t=0)}return t===0?r=i:n===0?t===1?r="i":t===-1?r="-i":r=u+"i":t<0?t===-1?r=i+" - i":r=i+" - "+u.substring(1)+"i":t===1?r=i+" + i":r=i+" + "+u+"i",r},x.fromPolar=function(e){switch(arguments.length){case 1:{var r=arguments[0];if(typeof r=="object")return x(r);throw new TypeError("Input has to be an object with r and phi keys.")}case 2:{var t=arguments[0],n=arguments[1];if(de(t)){if(oi(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),de(n))return new x({r:t,phi:n});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")}},x.prototype.valueOf=x.prototype.toString,x.fromJSON=function(e){return new x(e)},x.compare=function(e,r){return e.re>r.re?1:e.re<r.re?-1:e.im>r.im?1:e.im<r.im?-1:0},x),{isClass:!0});typeof BigInt>"u"&&(BigInt=function(e){if(isNaN(e))throw new Error("");return e});const k=BigInt(0),re=BigInt(1),Hr=BigInt(2),Yt=BigInt(5),Ze=BigInt(10),Sa=2e3,L={s:re,n:k,d:re};function fr(e,r){try{e=BigInt(e)}catch{throw hr()}return e*r}function er(e){return typeof e=="bigint"?e:Math.floor(e)}function Fe(e,r){if(r===k)throw en();const t=Object.create(Xe.prototype);t.s=e<k?-re:re,e=e<k?-e:e;const n=yr(e,r);return t.n=e/n,t.d=r/n,t}function Nr(e){const r={};let t=e,n=Hr,i=Yt-re;for(;i<=t;){for(;t%n===k;)t/=n,r[n]=(r[n]||k)+re;i+=re+Hr*n++}return t!==e?t>1&&(r[t]=(r[t]||k)+re):r[e]=(r[e]||k)+re,r}const xe=function(e,r){let t=k,n=re,i=re;if(e!=null)if(r!==void 0){if(typeof e=="bigint")t=e;else{if(isNaN(e))throw hr();if(e%1!==0)throw Dn();t=BigInt(e)}if(typeof r=="bigint")n=r;else{if(isNaN(r))throw hr();if(r%1!==0)throw Dn();n=BigInt(r)}i=t*n}else if(typeof e=="object"){if("d"in e&&"n"in e)t=BigInt(e.n),n=BigInt(e.d),"s"in e&&(t*=BigInt(e.s));else if(0 in e)t=BigInt(e[0]),1 in e&&(n=BigInt(e[1]));else if(typeof e=="bigint")t=e;else throw hr();i=t*n}else if(typeof e=="number"){if(isNaN(e))throw hr();if(e<0&&(i=-re,e=-e),e%1===0)t=BigInt(e);else{let u=1,o=0,a=1,c=1,l=1,f=1e7;for(e>=1&&(u=10**Math.floor(1+Math.log10(e)),e/=u);a<=f&&l<=f;){let h=(o+c)/(a+l);if(e===h){a+l<=f?(t=o+c,n=a+l):l>a?(t=c,n=l):(t=o,n=a);break}else e>h?(o+=c,a+=l):(c+=o,l+=a),a>f?(t=c,n=l):(t=o,n=a)}t=BigInt(t)*BigInt(u),n=BigInt(n)}}else if(typeof e=="string"){let u=0,o=k,a=k,c=k,l=re,f=re,h=e.replace(/_/g,"").match(/\d+|./g);if(h===null)throw hr();if(h[u]==="-"?(i=-re,u++):h[u]==="+"&&u++,h.length===u+1?a=fr(h[u++],i):h[u+1]==="."||h[u]==="."?(h[u]!=="."&&(o=fr(h[u++],i)),u++,(u+1===h.length||h[u+1]==="("&&h[u+3]===")"||h[u+1]==="'"&&h[u+3]==="'")&&(a=fr(h[u],i),l=Ze**BigInt(h[u].length),u++),(h[u]==="("&&h[u+2]===")"||h[u]==="'"&&h[u+2]==="'")&&(c=fr(h[u+1],i),f=Ze**BigInt(h[u+1].length)-re,u+=3)):h[u+1]==="/"||h[u+1]===":"?(a=fr(h[u],i),l=fr(h[u+2],re),u+=3):h[u+3]==="/"&&h[u+1]===" "&&(o=fr(h[u],i),a=fr(h[u+2],i),l=fr(h[u+4],re),u+=5),h.length<=u)n=l*f,i=t=c+n*o+f*a;else throw hr()}else if(typeof e=="bigint")t=e,i=e,n=re;else throw hr();if(n===k)throw en();L.s=i<k?-re:re,L.n=t<k?-t:t,L.d=n<k?-n:n};function xa(e,r,t){let n=re;for(;r>k;e=e*e%t,r>>=re)r&re&&(n=n*e%t);return n}function Ta(e,r){for(;r%Hr===k;r/=Hr);for(;r%Yt===k;r/=Yt);if(r===re)return k;let t=Ze%r,n=1;for(;t!==re;n++)if(t=t*Ze%r,n>Sa)return k;return BigInt(n)}function Ia(e,r,t){let n=re,i=xa(Ze,t,r);for(let u=0;u<300;u++){if(n===i)return BigInt(u);n=n*Ze%r,i=i*Ze%r}return 0}function yr(e,r){if(!e)return r;if(!r)return e;for(;;){if(e%=r,!e)return r;if(r%=e,!r)return e}}function Xe(e,r){if(xe(e,r),this instanceof Xe)e=yr(L.d,L.n),this.s=L.s,this.n=L.n/e,this.d=L.d/e;else return Fe(L.s*L.n,L.d)}var en=function(){return new Error("Division by Zero")},hr=function(){return new Error("Invalid argument")},Dn=function(){return new Error("Parameters must be integer")};Xe.prototype={s:re,n:k,d:re,abs:function(){return Fe(this.n,this.d)},neg:function(){return Fe(-this.s*this.n,this.d)},add:function(e,r){return xe(e,r),Fe(this.s*this.n*L.d+L.s*this.d*L.n,this.d*L.d)},sub:function(e,r){return xe(e,r),Fe(this.s*this.n*L.d-L.s*this.d*L.n,this.d*L.d)},mul:function(e,r){return xe(e,r),Fe(this.s*L.s*this.n*L.n,this.d*L.d)},div:function(e,r){return xe(e,r),Fe(this.s*L.s*this.n*L.d,this.d*L.n)},clone:function(){return Fe(this.s*this.n,this.d)},mod:function(e,r){if(e===void 0)return Fe(this.s*this.n%this.d,re);if(xe(e,r),k===L.n*this.d)throw en();return Fe(this.s*(L.d*this.n)%(L.n*this.d),L.d*this.d)},gcd:function(e,r){return xe(e,r),Fe(yr(L.n,this.n)*yr(L.d,this.d),L.d*this.d)},lcm:function(e,r){return xe(e,r),L.n===k&&this.n===k?Fe(k,re):Fe(L.n*this.n,yr(L.n,this.n)*yr(L.d,this.d))},inverse:function(){return Fe(this.s*this.d,this.n)},pow:function(e,r){if(xe(e,r),L.d===re)return L.s<k?Fe((this.s*this.d)**L.n,this.n**L.n):Fe((this.s*this.n)**L.n,this.d**L.n);if(this.s<k)return null;let t=Nr(this.n),n=Nr(this.d),i=re,u=re;for(let o in t)if(o!=="1"){if(o==="0"){i=k;break}if(t[o]*=L.n,t[o]%L.d===k)t[o]/=L.d;else return null;i*=BigInt(o)**t[o]}for(let o in n)if(o!=="1"){if(n[o]*=L.n,n[o]%L.d===k)n[o]/=L.d;else return null;u*=BigInt(o)**n[o]}return L.s<k?Fe(u,i):Fe(i,u)},log:function(e,r){if(xe(e,r),this.s<=k||L.s<=k)return null;const t={},n=Nr(L.n),i=Nr(L.d),u=Nr(this.n),o=Nr(this.d);for(const l in i)n[l]=(n[l]||k)-i[l];for(const l in o)u[l]=(u[l]||k)-o[l];for(const l in n)l!=="1"&&(t[l]=!0);for(const l in u)l!=="1"&&(t[l]=!0);let a=null,c=null;for(const l in t){const f=n[l]||k,h=u[l]||k;if(f===k){if(h!==k)return null;continue}let D=h,p=f;const m=yr(D,p);if(D/=m,p/=m,a===null&&c===null)a=D,c=p;else if(D*c!==a*p)return null}return a!==null&&c!==null?Fe(a,c):null},equals:function(e,r){return xe(e,r),this.s*this.n*L.d===L.s*L.n*this.d},lt:function(e,r){return xe(e,r),this.s*this.n*L.d<L.s*L.n*this.d},lte:function(e,r){return xe(e,r),this.s*this.n*L.d<=L.s*L.n*this.d},gt:function(e,r){return xe(e,r),this.s*this.n*L.d>L.s*L.n*this.d},gte:function(e,r){return xe(e,r),this.s*this.n*L.d>=L.s*L.n*this.d},compare:function(e,r){xe(e,r);let t=this.s*this.n*L.d-L.s*L.n*this.d;return(k<t)-(t<k)},ceil:function(e){return e=Ze**BigInt(e||0),Fe(er(this.s*e*this.n/this.d)+(e*this.n%this.d>k&&this.s>=k?re:k),e)},floor:function(e){return e=Ze**BigInt(e||0),Fe(er(this.s*e*this.n/this.d)-(e*this.n%this.d>k&&this.s<k?re:k),e)},round:function(e){return e=Ze**BigInt(e||0),Fe(er(this.s*e*this.n/this.d)+this.s*((this.s>=k?re:k)+Hr*(e*this.n%this.d)>this.d?re:k),e)},roundTo:function(e,r){xe(e,r);const t=this.n*L.d,n=this.d*L.n,i=t%n;let u=er(t/n);return i+i>=n&&u++,Fe(this.s*u*L.n,L.d)},divisible:function(e,r){return xe(e,r),!(!(L.n*this.d)||this.n*L.d%(L.n*this.d))},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e){let r=this.n,t=this.d;e=e||15;let n=Ta(r,t),i=Ia(r,t,n),u=this.s<k?"-":"";if(u+=er(r/t),r%=t,r*=Ze,r&&(u+="."),n){for(let o=i;o--;)u+=er(r/t),r%=t,r*=Ze;u+="(";for(let o=n;o--;)u+=er(r/t),r%=t,r*=Ze;u+=")"}else for(let o=e;r&&o--;)u+=er(r/t),r%=t,r*=Ze;return u},toFraction:function(e){let r=this.n,t=this.d,n=this.s<k?"-":"";if(t===re)n+=r;else{let i=er(r/t);e&&i>k&&(n+=i,n+=" ",r%=t),n+=r,n+="/",n+=t}return n},toLatex:function(e){let r=this.n,t=this.d,n=this.s<k?"-":"";if(t===re)n+=r;else{let i=er(r/t);e&&i>k&&(n+=i,r%=t),n+="\\frac{",n+=r,n+="}{",n+=t,n+="}"}return n},toContinued:function(){let e=this.n,r=this.d,t=[];do{t.push(er(e/r));let n=e%r;e=r,r=n}while(e!==re);return t},simplify:function(e){const r=BigInt(1/(e||.001)|0),t=this.abs(),n=t.toContinued();for(let i=1;i<n.length;i++){let u=Fe(n[i-1],re);for(let a=i-2;a>=0;a--)u=u.inverse().add(n[a]);let o=u.sub(t);if(o.n*r<o.d)return u.mul(this.s)}return this}};var za="Fraction",Oa=[],$a=J(za,Oa,()=>(Object.defineProperty(Xe,"name",{value:"Fraction"}),Xe.prototype.constructor=Xe,Xe.prototype.type="Fraction",Xe.prototype.isFraction=!0,Xe.prototype.toJSON=function(){return{mathjs:"Fraction",n:String(this.s*this.n),d:String(this.d)}},Xe.fromJSON=function(e){return new Xe(e)},Xe),{isClass:!0}),Pa="Matrix",Ua=[],qa=J(Pa,Ua,()=>{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(r,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(r,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(r){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(r,t,n){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(r,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(r,t){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(r,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(r){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(r){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});function Ut(e,r,t){var n=e.constructor,i=new n(2),u="";if(t){if(t<1)throw new Error("size must be in greater than 0");if(!ge(t))throw new Error("size must be an integer");if(e.greaterThan(i.pow(t-1).sub(1))||e.lessThan(i.pow(t-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(t-1,", 2^").concat(t-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(i.pow(t))),u="i".concat(t)}switch(r){case 2:return"".concat(e.toBinary()).concat(u);case 8:return"".concat(e.toOctal()).concat(u);case 16:return"".concat(e.toHexadecimal()).concat(u);default:throw new Error("Base ".concat(r," not supported "))}}function Ra(e,r){if(typeof r=="function")return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var{notation:t,precision:n,wordSize:i}=fi(r);switch(t){case"fixed":return Ha(e,n);case"exponential":return mn(e,n);case"engineering":return La(e,n);case"bin":return Ut(e,2,i);case"oct":return Ut(e,8,i);case"hex":return Ut(e,16,i);case"auto":{var u=dn(r?.lowerExp,-3),o=dn(r?.upperExp,5);if(e.isZero())return"0";var a,c=e.toSignificantDigits(n),l=c.e;return l>=u&&l<o?a=c.toFixed():a=mn(e,n),a.replace(/((\.\d*?)(0+))($|e)/,function(){var f=arguments[2],h=arguments[4];return f!=="."?f+h:h})}default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function La(e,r){var t=e.e,n=t%3===0?t:t<0?t-3-t%3:t-t%3,i=e.mul(Math.pow(10,-n)),u=i.toPrecision(r);if(u.includes("e")){var o=e.constructor;u=new o(u).toFixed()}return u+"e"+(t>=0?"+":"")+n.toString()}function mn(e,r){return r!==void 0?e.toExponential(r-1):e.toExponential()}function Ha(e,r){return e.toFixed(r)}function dn(e,r){return de(e)?e:Ee(e)?e.toNumber():r}function Be(e,r){var t=Za(e,r);return r&&typeof r=="object"&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function Za(e,r){if(typeof e=="number")return Zt(e,r);if(Ee(e))return Ra(e,r);if(Wa(e))return!r||r.fraction!=="decimal"?"".concat(e.s*e.n,"/").concat(e.d):e.toString();if(Array.isArray(e))return bi(e,r);if(Qe(e))return gn(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(r);if(e&&e.toString(r)!=={}.toString())return e.toString(r);var t=Object.keys(e).map(n=>gn(n)+": "+Be(e[n],r));return"{"+t.join(", ")+"}"}return String(e)}function gn(e){for(var r=String(e),t="",n=0;n<r.length;){var i=r.charAt(n);t+=i in vn?vn[i]:i,n++}return'"'+t+'"'}var vn={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function bi(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;i<n;i++)i!==0&&(t+=", "),t+=bi(e[i],r);return t+="]",t}else return Be(e,r)}function Wa(e){return e&&typeof e=="object"&&typeof e.s=="bigint"&&typeof e.n=="bigint"&&typeof e.d=="bigint"||!1}function ne(e,r,t){if(!(this instanceof ne))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=r,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=new Error().stack}ne.prototype=new RangeError;ne.prototype.constructor=RangeError;ne.prototype.name="DimensionError";ne.prototype.isDimensionError=!0;function Fr(e,r,t){if(!(this instanceof Fr))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=r):(this.min=r,this.max=t),this.min!==void 0&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":this.max!==void 0&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=new Error().stack}Fr.prototype=new RangeError;Fr.prototype.constructor=RangeError;Fr.prototype.name="IndexError";Fr.prototype.isIndexError=!0;function ze(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function Ci(e,r,t){var n,i=e.length;if(i!==r[t])throw new ne(i,r[t]);if(t<r.length-1){var u=t+1;for(n=0;n<i;n++){var o=e[n];if(!Array.isArray(o))throw new ne(r.length-1,r.length,"<");Ci(e[n],r,u)}}else for(n=0;n<i;n++)if(Array.isArray(e[n]))throw new ne(r.length+1,r.length,">")}function wn(e,r){var t=r.length===0;if(t){if(Array.isArray(e))throw new ne(e.length,0)}else Ci(e,r,0)}function ct(e,r){var t=e.isMatrix?e._size:ze(e),n=r._sourceSize;n.forEach((i,u)=>{if(i!==null&&i!==t[u])throw new ne(i,t[u])})}function De(e,r){if(e!==void 0){if(!de(e)||!ge(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof r=="number"&&e>=r)throw new Fr(e,r)}}function Or(e){for(var r=0;r<e._dimensions.length;++r){var t=e._dimensions[r];if(t._data&&ye(t._data)){if(t._size[0]===0)return!0}else if(t.isRange){if(t.start===t.end)return!0}else if(Qe(t)&&t.length===0)return!0}return!1}function lt(e,r,t){if(!Array.isArray(r))throw new TypeError("Array expected");if(r.length===0)throw new Error("Resizing to scalar is not supported");r.forEach(function(i){if(!de(i)||!ge(i)||i<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Be(r)+")")}),(de(e)||Ee(e))&&(e=[e]);var n=t!==void 0?t:0;return kt(e,r,0,n),e}function kt(e,r,t,n){var i,u,o=e.length,a=r[t],c=Math.min(o,a);if(e.length=a,t<r.length-1){var l=t+1;for(i=0;i<c;i++)u=e[i],Array.isArray(u)||(u=[u],e[i]=u),kt(u,r,l,n);for(i=c;i<a;i++)u=[],e[i]=u,kt(u,r,l,n)}else{for(i=0;i<c;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=c;i<a;i++)e[i]=n}}function _i(e,r){var t=Ja(e,!0),n=t.length;if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(r.length===0)throw new ne(0,n,"!=");r=rn(r,n);var i=Bi(r);if(n!==i)throw new ne(i,n,"!=");try{return Va(t,r)}catch(u){throw u instanceof ne?new ne(i,n,"!="):u}}function rn(e,r){var t=Bi(e),n=e.slice(),i=-1,u=e.indexOf(i),o=e.indexOf(i,u+1)>=0;if(o)throw new Error("More than one wildcard in sizes");var a=u>=0,c=r%t===0;if(a)if(c)n[u]=-r/t;else throw new Error("Could not replace wildcard, since "+r+" is no multiple of "+-t);return n}function Bi(e){return e.reduce((r,t)=>r*t,1)}function Va(e,r){for(var t=e,n,i=r.length-1;i>0;i--){var u=r[i];n=[];for(var o=t.length/u,a=0;a<o;a++)n.push(t.slice(a*u,(a+1)*u));t=n}return t}function Ni(e,r,t,n){var i=n||ze(e);if(t)for(var u=0;u<t;u++)e=[e],i.unshift(1);for(e=Mi(e,r,0);i.length<r;)i.push(1);return e}function Mi(e,r,t){var n,i;if(Array.isArray(e)){var u=t+1;for(n=0,i=e.length;n<i;n++)e[n]=Mi(e[n],r,u)}else for(var o=t;o<r;o++)e=[e];return e}function Ja(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!Array.isArray(e))return e;if(typeof r!="boolean")throw new TypeError("Boolean expected for second argument of flatten");var t=[];return r?i(e):n(e),t;function n(u){for(var o=0;o<u.length;o++){var a=u[o];Array.isArray(a)?n(a):t.push(a)}}function i(u){if(Array.isArray(u[0]))for(var o=0;o<u.length;o++)i(u[o]);else for(var a=0;a<u.length;a++)t.push(u[a])}}function Ct(e,r){for(var t,n=0,i=0;i<e.length;i++){var u=e[i],o=Array.isArray(u);if(i===0&&o&&(n=u.length),o&&u.length!==n)return;var a=o?Ct(u,r):r(u);if(t===void 0)t=a;else if(t!==a)return"mixed"}return t}function Si(e,r,t,n){if(n<t){if(e.length!==r.length)throw new ne(e.length,r.length);for(var i=[],u=0;u<e.length;u++)i[u]=Si(e[u],r[u],t,n+1);return i}else return e.concat(r)}function xi(){var e=Array.prototype.slice.call(arguments,0,-1),r=Array.prototype.slice.call(arguments,-1);if(e.length===1)return e[0];if(e.length>1)return e.slice(1).reduce(function(t,n){return Si(t,n,r,0)},e[0]);throw new Error("Wrong number of arguments in function concat")}function Ti(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];for(var n=r.map(D=>D.length),i=Math.max(...n),u=new Array(i).fill(null),o=0;o<r.length;o++)for(var a=r[o],c=n[o],l=0;l<c;l++){var f=i-c+l;a[l]>u[f]&&(u[f]=a[l])}for(var h=0;h<r.length;h++)Ii(r[h],u);return u}function Ii(e,r){for(var t=r.length,n=e.length,i=0;i<n;i++){var u=t-n+i;if(e[i]<r[u]&&e[i]>1||e[i]>r[u])throw new Error("shape mismatch: mismatch is found in arg with shape (".concat(e,") not possible to broadcast dimension ").concat(n," with size ").concat(e[i]," to size ").concat(r[u]))}}function Xt(e,r){var t=ze(e);if(mr(t,r))return e;Ii(t,r);var n=Ti(t,r),i=n.length,u=[...Array(i-t.length).fill(1),...t],o=Ya(e);t.length<i&&(o=_i(o,u),t=ze(o));for(var a=0;a<i;a++)t[a]<n[a]&&(o=Ga(o,n[a],a),t=ze(o));return o}function Ga(e,r,t){return xi(...Array(r).fill(e),t)}function zi(e,r){if(!Array.isArray(e))throw new Error("Array expected");var t=ze(e);if(r.length!==t.length)throw new ne(r.length,t.length);for(var n=0;n<r.length;n++)De(r[n],t[n]);return r.reduce((i,u)=>i[u],e)}function yn(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return[];if(t)return u(e);var n=[];return i(e,0);function i(o,a){if(Array.isArray(o)){for(var c=o.length,l=Array(c),f=0;f<c;f++)n[a]=f,l[f]=i(o[f],a+1);return l}else return r(o,n.slice(0,a),e)}function u(o){if(Array.isArray(o)){for(var a=o.length,c=Array(a),l=0;l<a;l++)c[l]=u(o[l]);return c}else return r(o)}}function Ya(e){return nt([],e)}function ht(e,r,t){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(ot.isTypedFunction(e)){var i;if(n)i=1;else{var u=(r.isMatrix?r.size():ze(r)).map(()=>0),o=r.isMatrix?r.get(u):zi(r,u);i=Qa(e,o,u,r)}var a;if(r.isMatrix&&r.dataType!=="mixed"&&r.dataType!==void 0){var c=ka(e,i);a=c!==void 0?c:e}else a=e;return i>=1&&i<=3?{isUnary:i===1,fn:function(){for(var f=arguments.length,h=new Array(f),D=0;D<f;D++)h[D]=arguments[D];return Fn(a,h.slice(0,i),t,e.name)}}:{isUnary:!1,fn:function(){for(var f=arguments.length,h=new Array(f),D=0;D<f;D++)h[D]=arguments[D];return Fn(a,h,t,e.name)}}}return n===void 0?{isUnary:Xa(e),fn:e}:{isUnary:n,fn:e}}function ka(e,r){var t=[];if(Object.entries(e.signatures).forEach(n=>{var[i,u]=n;i.split(",").length===r&&t.push(u)}),t.length===1)return t[0]}function Xa(e){if(e.length!==1)return!1;var r=e.toString();if(/arguments/.test(r))return!1;var t=r.match(/\(.*?\)/);return!/\.\.\./.test(t)}function Qa(e,r,t,n){for(var i=[r,t,n],u=3;u>0;u--){var o=i.slice(0,u);if(ot.resolve(e,o)!==null)return u}}function Fn(e,r,t,n){try{return e(...r)}catch(i){Ka(i,r,t,n)}}function Ka(e,r,t,n){var i;if(e instanceof TypeError&&((i=e.data)===null||i===void 0?void 0:i.category)==="wrongType"){var u=[];throw u.push("value: ".concat(ir(r[0]))),r.length>=2&&u.push("index: ".concat(ir(r[1]))),r.length>=3&&u.push("array: ".concat(ir(r[2]))),new TypeError("Function ".concat(t," cannot apply callback arguments ")+"".concat(n,"(").concat(u.join(", "),") at index ").concat(JSON.stringify(r[1])))}else throw new TypeError("Function ".concat(t," cannot apply callback arguments ")+"to function ".concat(n,": ").concat(e.message))}var ja="DenseMatrix",es=["Matrix"],rs=J(ja,es,e=>{var{Matrix:r}=e;function t(f,h){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(h&&!Qe(h))throw new Error("Invalid datatype: "+h);if(ve(f))f.type==="DenseMatrix"?(this._data=me(f._data),this._size=me(f._size),this._datatype=h||f._datatype):(this._data=f.toArray(),this._size=f.size(),this._datatype=h||f._datatype);else if(f&&ye(f.data)&&ye(f.size))this._data=f.data,this._size=f.size,wn(this._data,this._size),this._datatype=h||f.datatype;else if(ye(f))this._data=l(f),this._size=ze(this._data),wn(this._data,this._size),this._datatype=h;else{if(f)throw new TypeError("Unsupported type of data ("+ir(f)+")");this._data=[],this._size=[0],this._datatype=h}}t.prototype=new r,t.prototype.createDenseMatrix=function(f,h){return new t(f,h)},Object.defineProperty(t,"name",{value:"DenseMatrix"}),t.prototype.constructor=t,t.prototype.type="DenseMatrix",t.prototype.isDenseMatrix=!0,t.prototype.getDataType=function(){return Ct(this._data,ir)},t.prototype.storage=function(){return"dense"},t.prototype.datatype=function(){return this._datatype},t.prototype.create=function(f,h){return new t(f,h)},t.prototype.subset=function(f,h,D){switch(arguments.length){case 1:return n(this,f);case 2:case 3:return u(this,f,h,D);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(f){return zi(this._data,f)},t.prototype.set=function(f,h,D){if(!ye(f))throw new TypeError("Array expected");if(f.length<this._size.length)throw new ne(f.length,this._size.length,"<");var p,m,s,d=f.map(function(E){return E+1});c(this,d,D);var g=this._data;for(p=0,m=f.length-1;p<m;p++)s=f[p],De(s,g.length),g=g[s];return s=f[f.length-1],De(s,g.length),g[s]=h,this};function n(f,h){if(!yt(h))throw new TypeError("Invalid index");var D=h.isScalar();if(D)return f.get(h.min());var p=h.size();if(p.length!==f._size.length)throw new ne(p.length,f._size.length);for(var m=h.min(),s=h.max(),d=0,g=f._size.length;d<g;d++)De(m[d],f._size[d]),De(s[d],f._size[d]);var E=new t([]),v=i(f._data,h);return E._size=v.size,E._datatype=f._datatype,E._data=v.data,E}function i(f,h){var D=h.size().length-1,p=Array(D);return{data:m(f),size:p};function m(s){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,g=h.dimension(d);return p[d]=g.size()[0],d<D?g.map(E=>(De(E,s.length),m(s[E],d+1))).valueOf():g.map(E=>(De(E,s.length),s[E])).valueOf()}}function u(f,h,D,p){if(!h||h.isIndex!==!0)throw new TypeError("Invalid index");var m=h.size(),s=h.isScalar(),d;if(ve(D)?(d=D.size(),D=D.valueOf()):d=ze(D),s){if(d.length!==0)throw new TypeError("Scalar expected");f.set(h.min(),D,p)}else{if(!mr(d,m))try{d.length===0?D=Xt([D],m):D=Xt(D,m),d=ze(D)}catch{}if(m.length<f._size.length)throw new ne(m.length,f._size.length,"<");if(d.length<m.length){for(var g=0,E=0;m[g]===1&&d[g]===1;)g++;for(;m[g]===1;)E++,g++;D=Ni(D,m.length,E,d)}if(!mr(m,d))throw new ne(m,d,">");var v=h.max().map(function(A){return A+1});c(f,v,p),o(f._data,h,D)}return f}function o(f,h,D){var p=h.size().length-1;m(f,D);function m(s,d){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,E=h.dimension(g);g<p?E.forEach((v,A)=>{De(v,s.length),m(s[v],d[A[0]],g+1)}):E.forEach((v,A)=>{De(v,s.length),s[v]=d[A[0]]})}}t.prototype.resize=function(f,h,D){if(!ut(f))throw new TypeError("Array or Matrix expected");var p=f.valueOf().map(s=>Array.isArray(s)&&s.length===1?s[0]:s),m=D?this.clone():this;return a(m,p,h)};function a(f,h,D){if(h.length===0){for(var p=f._data;ye(p);)p=p[0];return p}return f._size=h.slice(0),f._data=lt(f._data,f._size,D),f}t.prototype.reshape=function(f,h){var D=h?this.clone():this;D._data=_i(D._data,f);var p=D._size.reduce((m,s)=>m*s);return D._size=rn(f,p),D};function c(f,h,D){for(var p=f._size.slice(0),m=!1;p.length<h.length;)p.push(0),m=!0;for(var s=0,d=h.length;s<d;s++)h[s]>p[s]&&(p[s]=h[s],m=!0);m&&a(f,p,D)}t.prototype.clone=function(){var f=new t({data:me(this._data),size:me(this._size),datatype:this._datatype});return f},t.prototype.size=function(){return this._size.slice(0)},t.prototype.map=function(f){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,D=this,p=D._size.length-1;if(p<0)return D.clone();var m=ht(f,D,"map",h),s=m.fn,d=D.create(void 0,D._datatype);if(d._size=D._size,h||m.isUnary)return d._data=w(D._data),d;if(p===0){for(var g=D.valueOf(),E=Array(g.length),v=0;v<g.length;v++)E[v]=s(g[v],[v],D);return d._data=E,d}var A=[];return d._data=y(D._data),d;function y(C){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,B=Array(C.length);if(b<p)for(var M=0;M<C.length;M++)A[b]=M,B[M]=y(C[M],b+1);else for(var S=0;S<C.length;S++)A[b]=S,B[S]=s(C[S],A.slice(),D);return B}function w(C){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,B=Array(C.length);if(b<p)for(var M=0;M<C.length;M++)B[M]=w(C[M],b+1);else for(var S=0;S<C.length;S++)B[S]=s(C[S]);return B}},t.prototype.forEach=function(f){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,D=this,p=D._size.length-1;if(p<0)return;var m=ht(f,D,"map",h),s=m.fn;if(h||m.isUnary){v(D._data);return}if(p===0){for(var d=0;d<D._data.length;d++)s(D._data[d],[d],D);return}var g=[];E(D._data);function E(A){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(y<p)for(var w=0;w<A.length;w++)g[y]=w,E(A[w],y+1);else for(var C=0;C<A.length;C++)g[y]=C,s(A[C],g.slice(),D)}function v(A){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(y<p)for(var w=0;w<A.length;w++)v(A[w],y+1);else for(var C=0;C<A.length;C++)s(A[C])}},t.prototype[Symbol.iterator]=function*(){var f=this._size.length-1;if(!(f<0)){if(f===0){for(var h=0;h<this._data.length;h++)yield{value:this._data[h],index:[h]};return}var D=[],p=function*(s,d){if(d<f)for(var g=0;g<s.length;g++)D[d]=g,yield*p(s[g],d+1);else for(var E=0;E<s.length;E++)D[d]=E,yield{value:s[E],index:D.slice()}};yield*p(this._data,0)}},t.prototype.rows=function(){var f=[],h=this.size();if(h.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");var D=this._data;for(var p of D)f.push(new t([p],this._datatype));return f},t.prototype.columns=function(){var f=this,h=[],D=this.size();if(D.length!==2)throw new TypeError("Rows can only be returned for a 2D matrix.");for(var p=this._data,m=function(g){var E=p.map(v=>[v[g]]);h.push(new t(E,f._datatype))},s=0;s<D[1];s++)m(s);return h},t.prototype.toArray=function(){return me(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(f){return Be(this._data,f)},t.prototype.toString=function(){return Be(this._data)},t.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},t.prototype.diagonal=function(f){if(f){if(Ee(f)&&(f=f.toNumber()),!de(f)||!ge(f))throw new TypeError("The parameter k must be an integer number")}else f=0;for(var h=f>0?f:0,D=f<0?-f:0,p=this._size[0],m=this._size[1],s=Math.min(p-D,m-h),d=[],g=0;g<s;g++)d[g]=this._data[g+D][g+h];return new t({data:d,size:[s],datatype:this._datatype})},t.diagonal=function(f,h,D,p){if(!ye(f))throw new TypeError("Array expected, size parameter");if(f.length!==2)throw new Error("Only two dimensions matrix are supported");if(f=f.map(function(C){if(Ee(C)&&(C=C.toNumber()),!de(C)||!ge(C)||C<1)throw new Error("Size values must be positive integers");return C}),D){if(Ee(D)&&(D=D.toNumber()),!de(D)||!ge(D))throw new TypeError("The parameter k must be an integer number")}else D=0;var m=D>0?D:0,s=D<0?-D:0,d=f[0],g=f[1],E=Math.min(d-s,g-m),v;if(ye(h)){if(h.length!==E)throw new Error("Invalid value array length");v=function(b){return h[b]}}else if(ve(h)){var A=h.size();if(A.length!==1||A[0]!==E)throw new Error("Invalid matrix length");v=function(b){return h.get([b])}}else v=function(){return h};p||(p=Ee(v(0))?v(0).mul(0):0);var y=[];if(f.length>0){y=lt(y,f,p);for(var w=0;w<E;w++)y[w+s][w+m]=v(w)}return new t({data:y,size:[d,g]})},t.fromJSON=function(f){return new t(f)},t.prototype.swapRows=function(f,h){if(!de(f)||!ge(f)||!de(h)||!ge(h))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return De(f,this._size[0]),De(h,this._size[0]),t._swapRows(f,h,this._data),this},t._swapRows=function(f,h,D){var p=D[f];D[f]=D[h],D[h]=p};function l(f){return ve(f)?l(f.valueOf()):ye(f)?f.map(l):f}return t},{isClass:!0});function Ve(e,r,t){if(!t)return ve(e)?e.map(i=>r(i),!1,!0):yn(e,r,!0);var n=i=>i===0?i:r(i);return ve(e)?e.map(i=>n(i),!1,!0):yn(e,n,!0)}var En="isInteger",ts=["typed"],ns=J(En,ts,e=>{var{typed:r}=e;return r(En,{number:ge,BigNumber:function(n){return n.isInt()},bigint:function(n){return!0},Fraction:function(n){return n.d===1n},"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t))})}),tn="number",_t="number, number";function Oi(e){return Math.abs(e)}Oi.signature=tn;function $i(e,r){return e+r}$i.signature=_t;function Pi(e,r){return e-r}Pi.signature=_t;function Ui(e,r){return e*r}Ui.signature=_t;function qi(e){return-e}qi.signature=tn;function pt(e){return Eo(e)}pt.signature=tn;function Ri(e,r){return e*e<1&&r===1/0||e*e>1&&r===-1/0?0:Math.pow(e,r)}Ri.signature=_t;function qr(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!ge(r)||r<0||r>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(ci(e,r))}var is=Math.PI,us="number";function Li(e){return e>0}Li.signature=us;function gr(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-9,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(t<=0)throw new Error("Relative tolerance must be greater than 0");if(n<0)throw new Error("Absolute tolerance must be at least 0");return e.isNaN()||r.isNaN()?!1:!e.isFinite()||!r.isFinite()?e.eq(r):e.eq(r)?!0:e.minus(r).abs().lte(e.constructor.max(e.constructor.max(e.abs(),r.abs()).mul(t),n))}var An="isPositive",os=["typed","config"],as=J(An,os,e=>{var{typed:r,config:t}=e;return r(An,{number:n=>tr(n,0,t.relTol,t.absTol)?!1:Li(n),BigNumber:n=>gr(n,new n.constructor(0),t.relTol,t.absTol)?!1:!n.isNeg()&&!n.isZero()&&!n.isNaN(),bigint:n=>n>0n,Fraction:n=>n.s>0n&&n.n>0n,Unit:r.referToSelf(n=>i=>r.find(n,i.valueType())(i.value)),"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),bn="isZero",ss=["typed","equalScalar"],fs=J(bn,ss,e=>{var{typed:r,equalScalar:t}=e;return r(bn,{"number | BigNumber | Complex | Fraction":n=>t(n,0),bigint:n=>n===0n,Unit:r.referToSelf(n=>i=>r.find(n,i.valueType())(i.value)),"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})});function cs(e,r,t,n){return tr(e.re,r.re,t,n)&&tr(e.im,r.im,t,n)}var Wr=J("compareUnits",["typed"],e=>{var{typed:r}=e;return{"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(!n.equalBase(i))throw new Error("Cannot compare units with different base");return r.find(t,[n.valueType(),i.valueType()])(n.value,i.value)})}}),Dt="equalScalar",ls=["typed","config"],hs=J(Dt,ls,e=>{var{typed:r,config:t}=e,n=Wr({typed:r});return r(Dt,{"boolean, boolean":function(u,o){return u===o},"number, number":function(u,o){return tr(u,o,t.relTol,t.absTol)},"BigNumber, BigNumber":function(u,o){return u.eq(o)||gr(u,o,t.relTol,t.absTol)},"bigint, bigint":function(u,o){return u===o},"Fraction, Fraction":function(u,o){return u.equals(o)},"Complex, Complex":function(u,o){return cs(u,o,t.relTol,t.absTol)}},n)});J(Dt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Dt,{"number, number":function(i,u){return tr(i,u,t.relTol,t.absTol)}})});var ps="SparseMatrix",Ds=["typed","equalScalar","Matrix"],ms=J(ps,Ds,e=>{var{typed:r,equalScalar:t,Matrix:n}=e;function i(s,d){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(d&&!Qe(d))throw new Error("Invalid datatype: "+d);if(ve(s))u(this,s,d);else if(s&&ye(s.index)&&ye(s.ptr)&&ye(s.size))this._values=s.values,this._index=s.index,this._ptr=s.ptr,this._size=s.size,this._datatype=d||s.datatype;else if(ye(s))o(this,s,d);else{if(s)throw new TypeError("Unsupported type of data ("+ir(s)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=d}}function u(s,d,g){d.type==="SparseMatrix"?(s._values=d._values?me(d._values):void 0,s._index=me(d._index),s._ptr=me(d._ptr),s._size=me(d._size),s._datatype=g||d._datatype):o(s,d.valueOf(),g||d._datatype)}function o(s,d,g){s._values=[],s._index=[],s._ptr=[],s._datatype=g;var E=d.length,v=0,A=t,y=0;if(Qe(g)&&(A=r.find(t,[g,g])||t,y=r.convert(0,g)),E>0){var w=0;do{s._ptr.push(s._index.length);for(var C=0;C<E;C++){var b=d[C];if(ye(b)){if(w===0&&v<b.length&&(v=b.length),w<b.length){var B=b[w];A(B,y)||(s._values.push(B),s._index.push(C))}}else w===0&&v<1&&(v=1),A(b,y)||(s._values.push(b),s._index.push(C))}w++}while(w<v)}s._ptr.push(s._index.length),s._size=[E,v]}i.prototype=new n,i.prototype.createSparseMatrix=function(s,d){return new i(s,d)},Object.defineProperty(i,"name",{value:"SparseMatrix"}),i.prototype.constructor=i,i.prototype.type="SparseMatrix",i.prototype.isSparseMatrix=!0,i.prototype.getDataType=function(){return Ct(this._values,ir)},i.prototype.storage=function(){return"sparse"},i.prototype.datatype=function(){return this._datatype},i.prototype.create=function(s,d){return new i(s,d)},i.prototype.density=function(){var s=this._size[0],d=this._size[1];return s!==0&&d!==0?this._index.length/(s*d):0},i.prototype.subset=function(s,d,g){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return a(this,s);case 2:case 3:return c(this,s,d,g);default:throw new SyntaxError("Wrong number of arguments")}};function a(s,d){if(!yt(d))throw new TypeError("Invalid index");var g=d.isScalar();if(g)return s.get(d.min());var E=d.size();if(E.length!==s._size.length)throw new ne(E.length,s._size.length);var v,A,y,w,C=d.min(),b=d.max();for(v=0,A=s._size.length;v<A;v++)De(C[v],s._size[v]),De(b[v],s._size[v]);var B=s._values,M=s._index,S=s._ptr,R=d.dimension(0),V=d.dimension(1),q=[],W=[];R.forEach(function(G,ee){W[G]=ee[0],q[G]=!0});var O=B?[]:void 0,Q=[],Y=[];return V.forEach(function(G){for(Y.push(Q.length),y=S[G],w=S[G+1];y<w;y++)v=M[y],q[v]===!0&&(Q.push(W[v]),O&&O.push(B[y]))}),Y.push(Q.length),new i({values:O,index:Q,ptr:Y,size:E,datatype:s._datatype})}function c(s,d,g,E){if(!d||d.isIndex!==!0)throw new TypeError("Invalid index");var v=d.size(),A=d.isScalar(),y;if(ve(g)?(y=g.size(),g=g.toArray()):y=ze(g),A){if(y.length!==0)throw new TypeError("Scalar expected");s.set(d.min(),g,E)}else{if(v.length!==1&&v.length!==2)throw new ne(v.length,s._size.length,"<");if(y.length<v.length){for(var w=0,C=0;v[w]===1&&y[w]===1;)w++;for(;v[w]===1;)C++,w++;g=Ni(g,v.length,C,y)}if(!mr(v,y))throw new ne(v,y,">");if(v.length===1){var b=d.dimension(0);b.forEach(function(S,R){De(S),s.set([S,0],g[R[0]],E)})}else{var B=d.dimension(0),M=d.dimension(1);B.forEach(function(S,R){De(S),M.forEach(function(V,q){De(V),s.set([S,V],g[R[0]][q[0]],E)})})}}return s}i.prototype.get=function(s){if(!ye(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new ne(s.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var d=s[0],g=s[1];De(d,this._size[0]),De(g,this._size[1]);var E=l(d,this._ptr[g],this._ptr[g+1],this._index);return E<this._ptr[g+1]&&this._index[E]===d?this._values[E]:0},i.prototype.set=function(s,d,g){if(!ye(s))throw new TypeError("Array expected");if(s.length!==this._size.length)throw new ne(s.length,this._size.length);if(!this._values)throw new Error("Cannot invoke set on a Pattern only matrix");var E=s[0],v=s[1],A=this._size[0],y=this._size[1],w=t,C=0;Qe(this._datatype)&&(w=r.find(t,[this._datatype,this._datatype])||t,C=r.convert(0,this._datatype)),(E>A-1||v>y-1)&&(D(this,Math.max(E+1,A),Math.max(v+1,y),g),A=this._size[0],y=this._size[1]),De(E,A),De(v,y);var b=l(E,this._ptr[v],this._ptr[v+1],this._index);return b<this._ptr[v+1]&&this._index[b]===E?w(d,C)?f(b,v,this._values,this._index,this._ptr):this._values[b]=d:w(d,C)||h(b,E,v,d,this._values,this._index,this._ptr),this};function l(s,d,g,E){if(g-d===0)return g;for(var v=d;v<g;v++)if(E[v]===s)return v;return d}function f(s,d,g,E,v){g.splice(s,1),E.splice(s,1);for(var A=d+1;A<v.length;A++)v[A]--}function h(s,d,g,E,v,A,y){v.splice(s,0,E),A.splice(s,0,d);for(var w=g+1;w<y.length;w++)y[w]++}i.prototype.resize=function(s,d,g){if(!ut(s))throw new TypeError("Array or Matrix expected");var E=s.valueOf().map(A=>Array.isArray(A)&&A.length===1?A[0]:A);if(E.length!==2)throw new Error("Only two dimensions matrix are supported");E.forEach(function(A){if(!de(A)||!ge(A)||A<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Be(E)+")")});var v=g?this.clone():this;return D(v,E[0],E[1],d)};function D(s,d,g,E){var v=E||0,A=t,y=0;Qe(s._datatype)&&(A=r.find(t,[s._datatype,s._datatype])||t,y=r.convert(0,s._datatype),v=r.convert(v,s._datatype));var w=!A(v,y),C=s._size[0],b=s._size[1],B,M,S;if(g>b){for(M=b;M<g;M++)if(s._ptr[M]=s._values.length,w)for(B=0;B<C;B++)s._values.push(v),s._index.push(B);s._ptr[g]=s._values.length}else g<b&&(s._ptr.splice(g+1,b-g),s._values.splice(s._ptr[g],s._values.length),s._index.splice(s._ptr[g],s._index.length));if(b=g,d>C){if(w){var R=0;for(M=0;M<b;M++){s._ptr[M]=s._ptr[M]+R,S=s._ptr[M+1]+R;var V=0;for(B=C;B<d;B++,V++)s._values.splice(S+V,0,v),s._index.splice(S+V,0,B),R++}s._ptr[b]=s._values.length}}else if(d<C){var q=0;for(M=0;M<b;M++){s._ptr[M]=s._ptr[M]-q;var W=s._ptr[M],O=s._ptr[M+1]-q;for(S=W;S<O;S++)B=s._index[S],B>d-1&&(s._values.splice(S,1),s._index.splice(S,1),q++)}s._ptr[M]=s._values.length}return s._size[0]=d,s._size[1]=g,s}i.prototype.reshape=function(s,d){if(!ye(s))throw new TypeError("Array expected");if(s.length!==2)throw new Error("Sparse matrices can only be reshaped in two dimensions");s.forEach(function(G){if(!de(G)||!ge(G)||G<=-2||G===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Be(s)+")")});var g=this._size[0]*this._size[1];s=rn(s,g);var E=s[0]*s[1];if(g!==E)throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var v=d?this.clone():this;if(this._size[0]===s[0]&&this._size[1]===s[1])return v;for(var A=[],y=0;y<v._ptr.length;y++)for(var w=0;w<v._ptr[y+1]-v._ptr[y];w++)A.push(y);for(var C=v._values.slice(),b=v._index.slice(),B=0;B<v._index.length;B++){var M=b[B],S=A[B],R=M*v._size[1]+S;A[B]=R%s[1],b[B]=Math.floor(R/s[1])}v._values.length=0,v._index.length=0,v._ptr.length=s[1]+1,v._size=s.slice();for(var V=0;V<v._ptr.length;V++)v._ptr[V]=0;for(var q=0;q<C.length;q++){var W=b[q],O=A[q],Q=C[q],Y=l(W,v._ptr[O],v._ptr[O+1],v._index);h(Y,W,O,Q,v._values,v._index,v._ptr)}return v},i.prototype.clone=function(){var s=new i({values:this._values?me(this._values):void 0,index:me(this._index),ptr:me(this._ptr),size:me(this._size),datatype:this._datatype});return s},i.prototype.size=function(){return this._size.slice(0)},i.prototype.map=function(s,d){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var g=this,E=this._size[0],v=this._size[1],A=ht(s,g,"map"),y=function(C,b,B){return A.fn(C,[b,B],g)};return p(this,0,E-1,0,v-1,y,d)};function p(s,d,g,E,v,A,y){var w=[],C=[],b=[],B=t,M=0;Qe(s._datatype)&&(B=r.find(t,[s._datatype,s._datatype])||t,M=r.convert(0,s._datatype));for(var S=function(fe,Ce,be){var Ae=A(fe,Ce,be);B(Ae,M)||(w.push(Ae),C.push(Ce))},R=E;R<=v;R++){b.push(w.length);var V=s._ptr[R],q=s._ptr[R+1];if(y)for(var W=V;W<q;W++){var O=s._index[W];O>=d&&O<=g&&S(s._values[W],O-d,R-E)}else{for(var Q={},Y=V;Y<q;Y++){var G=s._index[Y];Q[G]=s._values[Y]}for(var ee=d;ee<=g;ee++){var oe=ee in Q?Q[ee]:0;S(oe,ee-d,R-E)}}}return b.push(w.length),new i({values:w,index:C,ptr:b,size:[g-d+1,v-E+1]})}i.prototype.forEach=function(s,d){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var g=this,E=this._size[0],v=this._size[1],A=ht(s,g,"forEach"),y=0;y<v;y++){var w=this._ptr[y],C=this._ptr[y+1];if(d)for(var b=w;b<C;b++){var B=this._index[b];A.fn(this._values[b],[B,y],g)}else{for(var M={},S=w;S<C;S++){var R=this._index[S];M[R]=this._values[S]}for(var V=0;V<E;V++){var q=V in M?M[V]:0;A.fn(q,[V,y],g)}}}},i.prototype[Symbol.iterator]=function*(){if(!this._values)throw new Error("Cannot iterate a Pattern only matrix");for(var s=this._size[1],d=0;d<s;d++)for(var g=this._ptr[d],E=this._ptr[d+1],v=g;v<E;v++){var A=this._index[v];yield{value:this._values[v],index:[A,d]}}},i.prototype.toArray=function(){return m(this._values,this._index,this._ptr,this._size,!0)},i.prototype.valueOf=function(){return m(this._values,this._index,this._ptr,this._size,!1)};function m(s,d,g,E,v){var A=E[0],y=E[1],w=[],C,b;for(C=0;C<A;C++)for(w[C]=[],b=0;b<y;b++)w[C][b]=0;for(b=0;b<y;b++)for(var B=g[b],M=g[b+1],S=B;S<M;S++)C=d[S],w[C][b]=s?v?me(s[S]):s[S]:1;return w}return i.prototype.format=function(s){for(var d=this._size[0],g=this._size[1],E=this.density(),v="Sparse Matrix ["+Be(d,s)+" x "+Be(g,s)+"] density: "+Be(E,s)+`
16
+ `,A=0;A<g;A++)for(var y=this._ptr[A],w=this._ptr[A+1],C=y;C<w;C++){var b=this._index[C];v+=`
17
+ (`+Be(b,s)+", "+Be(A,s)+") ==> "+(this._values?Be(this._values[C],s):"X")}return v},i.prototype.toString=function(){return Be(this.toArray())},i.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(s){if(s){if(Ee(s)&&(s=s.toNumber()),!de(s)||!ge(s))throw new TypeError("The parameter k must be an integer number")}else s=0;var d=s>0?s:0,g=s<0?-s:0,E=this._size[0],v=this._size[1],A=Math.min(E-g,v-d),y=[],w=[],C=[];C[0]=0;for(var b=d;b<v&&y.length<A;b++)for(var B=this._ptr[b],M=this._ptr[b+1],S=B;S<M;S++){var R=this._index[S];if(R===b-d+g){y.push(this._values[S]),w[y.length-1]=R-g;break}}return C.push(y.length),new i({values:y,index:w,ptr:C,size:[A,1]})},i.fromJSON=function(s){return new i(s)},i.diagonal=function(s,d,g,E,v){if(!ye(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(G){if(Ee(G)&&(G=G.toNumber()),!de(G)||!ge(G)||G<1)throw new Error("Size values must be positive integers");return G}),g){if(Ee(g)&&(g=g.toNumber()),!de(g)||!ge(g))throw new TypeError("The parameter k must be an integer number")}else g=0;var A=t,y=0;Qe(v)&&(A=r.find(t,[v,v])||t,y=r.convert(0,v));var w=g>0?g:0,C=g<0?-g:0,b=s[0],B=s[1],M=Math.min(b-C,B-w),S;if(ye(d)){if(d.length!==M)throw new Error("Invalid value array length");S=function(ee){return d[ee]}}else if(ve(d)){var R=d.size();if(R.length!==1||R[0]!==M)throw new Error("Invalid matrix length");S=function(ee){return d.get([ee])}}else S=function(){return d};for(var V=[],q=[],W=[],O=0;O<B;O++){W.push(V.length);var Q=O-w;if(Q>=0&&Q<M){var Y=S(Q);A(Y,y)||(q.push(Q+C),V.push(Y))}}return W.push(V.length),new i({values:V,index:q,ptr:W,size:[b,B]})},i.prototype.swapRows=function(s,d){if(!de(s)||!ge(s)||!de(d)||!ge(d))throw new Error("Row index must be positive integers");if(this._size.length!==2)throw new Error("Only two dimensional matrix is supported");return De(s,this._size[0]),De(d,this._size[0]),i._swapRows(s,d,this._size[1],this._values,this._index,this._ptr),this},i._forEachRow=function(s,d,g,E,v){for(var A=E[s],y=E[s+1],w=A;w<y;w++)v(g[w],d[w])},i._swapRows=function(s,d,g,E,v,A){for(var y=0;y<g;y++){var w=A[y],C=A[y+1],b=l(s,w,C,v),B=l(d,w,C,v);if(b<C&&B<C&&v[b]===s&&v[B]===d){if(E){var M=E[b];E[b]=E[B],E[B]=M}continue}if(b<C&&v[b]===s&&(B>=C||v[B]!==d)){var S=E?E[b]:void 0;v.splice(B,0,d),E&&E.splice(B,0,S),v.splice(B<=b?b+1:b,1),E&&E.splice(B<=b?b+1:b,1);continue}if(B<C&&v[B]===d&&(b>=C||v[b]!==s)){var R=E?E[B]:void 0;v.splice(b,0,s),E&&E.splice(b,0,R),v.splice(b<=B?B+1:B,1),E&&E.splice(b<=B?B+1:B,1)}}},i},{isClass:!0}),ds="number",gs=["typed"];function vs(e){var r=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);if(r){var t={"0b":2,"0o":8,"0x":16}[r[1]],n=r[2],i=r[3];return{input:e,radix:t,integerPart:n,fractionalPart:i}}else return null}function ws(e){for(var r=parseInt(e.integerPart,e.radix),t=0,n=0;n<e.fractionalPart.length;n++){var i=parseInt(e.fractionalPart[n],e.radix);t+=i/Math.pow(e.radix,n+1)}var u=r+t;if(isNaN(u))throw new SyntaxError('String "'+e.input+'" is not a valid number');return u}var ys=J(ds,gs,e=>{var{typed:r}=e,t=r("number",{"":function(){return 0},number:function(i){return i},string:function(i){if(i==="NaN")return NaN;var u=vs(i);if(u)return ws(u);var o=0,a=i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);a&&(o=Number(a[2]),i=a[1]);var c=Number(i);if(isNaN(c))throw new SyntaxError('String "'+i+'" is not a valid number');if(a){if(c>2**o-1)throw new SyntaxError('String "'.concat(i,'" is out of range'));c>=2**(o-1)&&(c=c-2**o)}return c},BigNumber:function(i){return i.toNumber()},bigint:function(i){return Number(i)},Fraction:function(i){return i.valueOf()},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),null:function(i){return 0},"Unit, string | Unit":function(i,u){return i.toNumber(u)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))});return t.fromJSON=function(n){return parseFloat(n.value)},t}),Fs="bignumber",Es=["typed","BigNumber"],As=J(Fs,Es,e=>{var{typed:r,BigNumber:t}=e;return r("bignumber",{"":function(){return new t(0)},number:function(i){return new t(i+"")},string:function(i){var u=i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(u){var o=u[2],a=t(u[1]),c=new t(2).pow(Number(o));if(a.gt(c.sub(1)))throw new SyntaxError('String "'.concat(i,'" is out of range'));var l=new t(2).pow(Number(o)-1);return a.gte(l)?a.sub(c):a}return new t(i)},BigNumber:function(i){return i},bigint:function(i){return new t(i.toString())},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),Fraction:function(i){return new t(String(i.n)).div(String(i.d)).times(String(i.s))},null:function(i){return new t(0)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),bs="complex",Cs=["typed","Complex"],_s=J(bs,Cs,e=>{var{typed:r,Complex:t}=e;return r("complex",{"":function(){return t.ZERO},number:function(i){return new t(i,0)},"number, number":function(i,u){return new t(i,u)},"BigNumber, BigNumber":function(i,u){return new t(i.toNumber(),u.toNumber())},Fraction:function(i){return new t(i.valueOf(),0)},Complex:function(i){return i.clone()},string:function(i){return t(i)},null:function(i){return t(0)},Object:function(i){if("re"in i&&"im"in i)return new t(i.re,i.im);if("r"in i&&"phi"in i||"abs"in i&&"arg"in i)return new t(i);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),Bs="fraction",Ns=["typed","Fraction"],Ms=J(Bs,Ns,e=>{var{typed:r,Fraction:t}=e;return r("fraction",{number:function(i){if(!isFinite(i)||isNaN(i))throw new Error(i+" cannot be represented as a fraction");return new t(i)},string:function(i){return new t(i)},"number, number":function(i,u){return new t(i,u)},"bigint, bigint":function(i,u){return new t(i,u)},null:function(i){return new t(0)},BigNumber:function(i){return new t(i.toString())},bigint:function(i){return new t(i.toString())},Fraction:function(i){return i},Unit:r.referToSelf(n=>i=>{var u=i.clone();return u.value=n(i.value),u}),Object:function(i){return new t(i)},"Array | Matrix":r.referToSelf(n=>i=>Ve(i,n))})}),Cn="matrix",Ss=["typed","Matrix","DenseMatrix","SparseMatrix"],xs=J(Cn,Ss,e=>{var{typed:r,Matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(Cn,{"":function(){return u([])},string:function(a){return u([],a)},"string, string":function(a,c){return u([],a,c)},Array:function(a){return u(a)},Matrix:function(a){return u(a,a.storage())},"Array | Matrix, string":u,"Array | Matrix, string, string":u});function u(o,a,c){if(a==="dense"||a==="default"||a===void 0)return new n(o,c);if(a==="sparse")return new i(o,c);throw new TypeError("Unknown matrix type "+JSON.stringify(a)+".")}}),_n="unaryMinus",Ts=["typed"],Is=J(_n,Ts,e=>{var{typed:r}=e;return r(_n,{number:qi,"Complex | BigNumber | Fraction":t=>t.neg(),bigint:t=>-t,Unit:r.referToSelf(t=>n=>{var i=n.clone();return i.value=r.find(t,i.valueType())(n.value),i}),"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t,!0))})}),Bn="abs",zs=["typed"],Os=J(Bn,zs,e=>{var{typed:r}=e;return r(Bn,{number:Oi,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),bigint:t=>t<0n?-t:t,"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t,!0))})}),Nn="addScalar",$s=["typed"],Ps=J(Nn,$s,e=>{var{typed:r}=e;return r(Nn,{"number, number":$i,"Complex, Complex":function(n,i){return n.add(i)},"BigNumber, BigNumber":function(n,i){return n.plus(i)},"bigint, bigint":function(n,i){return n+i},"Fraction, Fraction":function(n,i){return n.add(i)},"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(i.value===null||i.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(i))throw new Error("Units do not match");var u=n.clone();return u.value=r.find(t,[u.valueType(),i.valueType()])(u.value,i.value),u.fixPrefix=!1,u})})}),Mn="subtractScalar",Us=["typed"],qs=J(Mn,Us,e=>{var{typed:r}=e;return r(Mn,{"number, number":Pi,"Complex, Complex":function(n,i){return n.sub(i)},"BigNumber, BigNumber":function(n,i){return n.minus(i)},"bigint, bigint":function(n,i){return n-i},"Fraction, Fraction":function(n,i){return n.sub(i)},"Unit, Unit":r.referToSelf(t=>(n,i)=>{if(n.value===null||n.value===void 0)throw new Error("Parameter x contains a unit with undefined value");if(i.value===null||i.value===void 0)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(i))throw new Error("Units do not match");var u=n.clone();return u.value=r.find(t,[u.valueType(),i.valueType()])(u.value,i.value),u.fixPrefix=!1,u})})}),Rs="matAlgo11xS0s",Ls=["typed","equalScalar"],Hi=J(Rs,Ls,e=>{var{typed:r,equalScalar:t}=e;return function(i,u,o,a){var c=i._values,l=i._index,f=i._ptr,h=i._size,D=i._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=h[0],m=h[1],s,d=t,g=0,E=o;typeof D=="string"&&(s=D,d=r.find(t,[s,s]),g=r.convert(0,s),u=r.convert(u,s),E=r.find(o,[s,s]));for(var v=[],A=[],y=[],w=0;w<m;w++){y[w]=A.length;for(var C=f[w],b=f[w+1],B=C;B<b;B++){var M=l[B],S=a?E(u,c[B]):E(c[B],u);d(S,g)||(A.push(M),v.push(S))}}return y[m]=A.length,i.createSparseMatrix({values:v,index:A,ptr:y,size:[p,m],datatype:s})}}),Hs="matAlgo12xSfs",Zs=["typed","DenseMatrix"],Vr=J(Hs,Zs,e=>{var{typed:r,DenseMatrix:t}=e;return function(i,u,o,a){var c=i._values,l=i._index,f=i._ptr,h=i._size,D=i._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=h[0],m=h[1],s,d=o;typeof D=="string"&&(s=D,u=r.convert(u,s),d=r.find(o,[s,s]));for(var g=[],E=[],v=[],A=0;A<m;A++){for(var y=A+1,w=f[A],C=f[A+1],b=w;b<C;b++){var B=l[b];E[B]=c[b],v[B]=y}for(var M=0;M<p;M++)A===0&&(g[M]=[]),v[M]===y?g[M][A]=a?d(u,E[M]):d(E[M],u):g[M][A]=a?d(u,0):d(0,u)}return new t({data:g,size:[p,m],datatype:s})}}),Ws="matAlgo14xDs",Vs=["typed"],nn=J(Ws,Vs,e=>{var{typed:r}=e;return function(i,u,o,a){var c=i._data,l=i._size,f=i._datatype,h,D=o;typeof f=="string"&&(h=f,u=r.convert(u,h),D=r.find(o,[h,h]));var p=l.length>0?t(D,0,l,l[0],c,u,a):[];return i.createDenseMatrix({data:p,size:me(l),datatype:h})};function t(n,i,u,o,a,c,l){var f=[];if(i===u.length-1)for(var h=0;h<o;h++)f[h]=l?n(c,a[h]):n(a[h],c);else for(var D=0;D<o;D++)f[D]=t(n,i+1,u,u[i+1],a[D],c,l);return f}}),Js="matAlgo03xDSf",Gs=["typed"],Bt=J(Js,Gs,e=>{var{typed:r}=e;return function(n,i,u,o){var a=n._data,c=n._size,l=n._datatype||n.getDataType(),f=i._values,h=i._index,D=i._ptr,p=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==p.length)throw new ne(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+p+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var s=c[0],d=c[1],g,E=0,v=u;typeof l=="string"&&l===m&&l!=="mixed"&&(g=l,E=r.convert(0,g),v=r.find(u,[g,g]));for(var A=[],y=0;y<s;y++)A[y]=[];for(var w=[],C=[],b=0;b<d;b++){for(var B=b+1,M=D[b],S=D[b+1],R=M;R<S;R++){var V=h[R];w[V]=o?v(f[R],a[V][b]):v(a[V][b],f[R]),C[V]=B}for(var q=0;q<s;q++)C[q]===B?A[q][b]=w[q]:A[q][b]=o?v(E,a[q][b]):v(a[q][b],E)}return n.createDenseMatrix({data:A,size:[s,d],datatype:l===n._datatype&&m===i._datatype?g:void 0})}}),Ys="matAlgo13xDD",ks=["typed"],Xs=J(Ys,ks,e=>{var{typed:r}=e;return function(i,u,o){var a=i._data,c=i._size,l=i._datatype,f=u._data,h=u._size,D=u._datatype,p=[];if(c.length!==h.length)throw new ne(c.length,h.length);for(var m=0;m<c.length;m++){if(c[m]!==h[m])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+h+")");p[m]=c[m]}var s,d=o;typeof l=="string"&&l===D&&(s=l,d=r.find(o,[s,s]));var g=p.length>0?t(d,0,p,p[0],a,f):[];return i.createDenseMatrix({data:g,size:p,datatype:s})};function t(n,i,u,o,a,c){var l=[];if(i===u.length-1)for(var f=0;f<o;f++)l[f]=n(a[f],c[f]);else for(var h=0;h<o;h++)l[h]=t(n,i+1,u,u[i+1],a[h],c[h]);return l}});function Se(e,r){if(mr(e.size(),r.size()))return[e,r];var t=Ti(e.size(),r.size());return[e,r].map(n=>Qs(n,t))}function Qs(e,r){return mr(e.size(),r)?e:e.create(Xt(e.valueOf(),r),e.datatype())}var Ks="matrixAlgorithmSuite",js=["typed","matrix"],Jr=J(Ks,js,e=>{var{typed:r,matrix:t}=e,n=Xs({typed:r}),i=nn({typed:r});return function(o){var a=o.elop,c=o.SD||o.DS,l;a?(l={"DenseMatrix, DenseMatrix":(p,m)=>n(...Se(p,m),a),"Array, Array":(p,m)=>n(...Se(t(p),t(m)),a).valueOf(),"Array, DenseMatrix":(p,m)=>n(...Se(t(p),m),a),"DenseMatrix, Array":(p,m)=>n(...Se(p,t(m)),a)},o.SS&&(l["SparseMatrix, SparseMatrix"]=(p,m)=>o.SS(...Se(p,m),a,!1)),o.DS&&(l["DenseMatrix, SparseMatrix"]=(p,m)=>o.DS(...Se(p,m),a,!1),l["Array, SparseMatrix"]=(p,m)=>o.DS(...Se(t(p),m),a,!1)),c&&(l["SparseMatrix, DenseMatrix"]=(p,m)=>c(...Se(m,p),a,!0),l["SparseMatrix, Array"]=(p,m)=>c(...Se(t(m),p),a,!0))):(l={"DenseMatrix, DenseMatrix":r.referToSelf(p=>(m,s)=>n(...Se(m,s),p)),"Array, Array":r.referToSelf(p=>(m,s)=>n(...Se(t(m),t(s)),p).valueOf()),"Array, DenseMatrix":r.referToSelf(p=>(m,s)=>n(...Se(t(m),s),p)),"DenseMatrix, Array":r.referToSelf(p=>(m,s)=>n(...Se(m,t(s)),p))},o.SS&&(l["SparseMatrix, SparseMatrix"]=r.referToSelf(p=>(m,s)=>o.SS(...Se(m,s),p,!1))),o.DS&&(l["DenseMatrix, SparseMatrix"]=r.referToSelf(p=>(m,s)=>o.DS(...Se(m,s),p,!1)),l["Array, SparseMatrix"]=r.referToSelf(p=>(m,s)=>o.DS(...Se(t(m),s),p,!1))),c&&(l["SparseMatrix, DenseMatrix"]=r.referToSelf(p=>(m,s)=>c(...Se(s,m),p,!0)),l["SparseMatrix, Array"]=r.referToSelf(p=>(m,s)=>c(...Se(t(s),m),p,!0))));var f=o.scalar||"any",h=o.Ds||o.Ss;h&&(a?(l["DenseMatrix,"+f]=(p,m)=>i(p,m,a,!1),l[f+", DenseMatrix"]=(p,m)=>i(m,p,a,!0),l["Array,"+f]=(p,m)=>i(t(p),m,a,!1).valueOf(),l[f+", Array"]=(p,m)=>i(t(m),p,a,!0).valueOf()):(l["DenseMatrix,"+f]=r.referToSelf(p=>(m,s)=>i(m,s,p,!1)),l[f+", DenseMatrix"]=r.referToSelf(p=>(m,s)=>i(s,m,p,!0)),l["Array,"+f]=r.referToSelf(p=>(m,s)=>i(t(m),s,p,!1).valueOf()),l[f+", Array"]=r.referToSelf(p=>(m,s)=>i(t(s),m,p,!0).valueOf())));var D=o.sS!==void 0?o.sS:o.Ss;return a?(o.Ss&&(l["SparseMatrix,"+f]=(p,m)=>o.Ss(p,m,a,!1)),D&&(l[f+", SparseMatrix"]=(p,m)=>D(m,p,a,!0))):(o.Ss&&(l["SparseMatrix,"+f]=r.referToSelf(p=>(m,s)=>o.Ss(m,s,p,!1))),D&&(l[f+", SparseMatrix"]=r.referToSelf(p=>(m,s)=>D(s,m,p,!0)))),a&&a.signatures&&Do(l,a.signatures),l}}),ef="matAlgo01xDSid",rf=["typed"],tf=J(ef,rf,e=>{var{typed:r}=e;return function(n,i,u,o){var a=n._data,c=n._size,l=n._datatype||n.getDataType(),f=i._values,h=i._index,D=i._ptr,p=i._size,m=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(c.length!==p.length)throw new ne(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+p+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var s=c[0],d=c[1],g=typeof l=="string"&&l!=="mixed"&&l===m?l:void 0,E=g?r.find(u,[g,g]):u,v,A,y=[];for(v=0;v<s;v++)y[v]=[];var w=[],C=[];for(A=0;A<d;A++){for(var b=A+1,B=D[A],M=D[A+1],S=B;S<M;S++)v=h[S],w[v]=o?E(f[S],a[v][A]):E(a[v][A],f[S]),C[v]=b;for(v=0;v<s;v++)C[v]===b?y[v][A]=w[v]:y[v][A]=a[v][A]}return n.createDenseMatrix({data:y,size:[s,d],datatype:l===n._datatype&&m===i._datatype?g:void 0})}}),nf="matAlgo04xSidSid",uf=["typed","equalScalar"],of=J(nf,uf,e=>{var{typed:r,equalScalar:t}=e;return function(i,u,o){var a=i._values,c=i._index,l=i._ptr,f=i._size,h=i._datatype||i._data===void 0?i._datatype:i.getDataType(),D=u._values,p=u._index,m=u._ptr,s=u._size,d=u._datatype||u._data===void 0?u._datatype:u.getDataType();if(f.length!==s.length)throw new ne(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 g=f[0],E=f[1],v,A=t,y=0,w=o;typeof h=="string"&&h===d&&h!=="mixed"&&(v=h,A=r.find(t,[v,v]),y=r.convert(0,v),w=r.find(o,[v,v]));var C=a&&D?[]:void 0,b=[],B=[],M=a&&D?[]:void 0,S=a&&D?[]:void 0,R=[],V=[],q,W,O,Q,Y;for(W=0;W<E;W++){B[W]=b.length;var G=W+1;for(Q=l[W],Y=l[W+1],O=Q;O<Y;O++)q=c[O],b.push(q),R[q]=G,M&&(M[q]=a[O]);for(Q=m[W],Y=m[W+1],O=Q;O<Y;O++)if(q=p[O],R[q]===G){if(M){var ee=w(M[q],D[O]);A(ee,y)?R[q]=null:M[q]=ee}}else b.push(q),V[q]=G,S&&(S[q]=D[O]);if(M&&S)for(O=B[W];O<b.length;)q=b[O],R[q]===G?(C[O]=M[q],O++):V[q]===G?(C[O]=S[q],O++):b.splice(O,1)}return B[E]=b.length,i.createSparseMatrix({values:C,index:b,ptr:B,size:[g,E],datatype:h===i._datatype&&d===u._datatype?v:void 0})}}),af="matAlgo10xSids",sf=["typed","DenseMatrix"],ff=J(af,sf,e=>{var{typed:r,DenseMatrix:t}=e;return function(i,u,o,a){var c=i._values,l=i._index,f=i._ptr,h=i._size,D=i._datatype;if(!c)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=h[0],m=h[1],s,d=o;typeof D=="string"&&(s=D,u=r.convert(u,s),d=r.find(o,[s,s]));for(var g=[],E=[],v=[],A=0;A<m;A++){for(var y=A+1,w=f[A],C=f[A+1],b=w;b<C;b++){var B=l[b];E[B]=c[b],v[B]=y}for(var M=0;M<p;M++)A===0&&(g[M]=[]),v[M]===y?g[M][A]=a?d(u,E[M]):d(E[M],u):g[M][A]=u}return new t({data:g,size:[p,m],datatype:s})}});function cf(e,r,t,n){return function(i){if(i>0||t.predictable){if(i<=0)return NaN;var u=i.toString(16),o=u.substring(0,15);return e*(u.length-o.length)+r(+("0x"+o))}return n(i.toNumber())}}var Sn="log10",lf=["typed","config","Complex"],hf=pt(16),pf=J(Sn,lf,e=>{var{typed:r,config:t,Complex:n}=e;function i(o){return o.log().div(Math.LN10)}function u(o){return i(new n(o,0))}return r(Sn,{number:function(a){return a>=0||t.predictable?pt(a):u(a)},bigint:cf(hf,pt,t,u),Complex:i,BigNumber:function(a){return!a.isNegative()||t.predictable?a.log():u(a.toNumber())},"Array | Matrix":r.referToSelf(o=>a=>Ve(a,o))})}),Df="multiplyScalar",mf=["typed"],df=J(Df,mf,e=>{var{typed:r}=e;return r("multiplyScalar",{"number, number":Ui,"Complex, Complex":function(n,i){return n.mul(i)},"BigNumber, BigNumber":function(n,i){return n.times(i)},"bigint, bigint":function(n,i){return n*i},"Fraction, Fraction":function(n,i){return n.mul(i)},"number | Fraction | BigNumber | Complex, Unit":(t,n)=>n.multiply(t),"Unit, number | Fraction | BigNumber | Complex | Unit":(t,n)=>t.multiply(n)})}),xn="multiply",gf=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],vf=J(xn,gf,e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,equalScalar:u,dot:o}=e,a=Hi({typed:r,equalScalar:u}),c=nn({typed:r});function l(y,w){switch(y.length){case 1:switch(w.length){case 1:if(y[0]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(y[0]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+y[0]+") must match Matrix rows ("+w[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+w.length+" dimensions)")}break;case 2:switch(w.length){case 1:if(y[1]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+y[1]+") must match Vector length ("+w[0]+")");break;case 2:if(y[1]!==w[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+y[1]+") must match Matrix B rows ("+w[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+w.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+y.length+" dimensions)")}}function f(y,w,C){if(C===0)throw new Error("Cannot multiply two empty vectors");return o(y,w)}function h(y,w){if(w.storage()!=="dense")throw new Error("Support for SparseMatrix not implemented");return D(y,w)}function D(y,w){var C=y._data,b=y._size,B=y._datatype||y.getDataType(),M=w._data,S=w._size,R=w._datatype||w.getDataType(),V=b[0],q=S[1],W,O=n,Q=i;B&&R&&B===R&&typeof B=="string"&&B!=="mixed"&&(W=B,O=r.find(n,[W,W]),Q=r.find(i,[W,W]));for(var Y=[],G=0;G<q;G++){for(var ee=Q(C[0],M[0][G]),oe=1;oe<V;oe++)ee=O(ee,Q(C[oe],M[oe][G]));Y[G]=ee}return y.createDenseMatrix({data:Y,size:[q],datatype:B===y._datatype&&R===w._datatype?W:void 0})}var p=r("_multiplyMatrixVector",{"DenseMatrix, any":s,"SparseMatrix, any":E}),m=r("_multiplyMatrixMatrix",{"DenseMatrix, DenseMatrix":d,"DenseMatrix, SparseMatrix":g,"SparseMatrix, DenseMatrix":v,"SparseMatrix, SparseMatrix":A});function s(y,w){var C=y._data,b=y._size,B=y._datatype||y.getDataType(),M=w._data,S=w._datatype||w.getDataType(),R=b[0],V=b[1],q,W=n,O=i;B&&S&&B===S&&typeof B=="string"&&B!=="mixed"&&(q=B,W=r.find(n,[q,q]),O=r.find(i,[q,q]));for(var Q=[],Y=0;Y<R;Y++){for(var G=C[Y],ee=O(G[0],M[0]),oe=1;oe<V;oe++)ee=W(ee,O(G[oe],M[oe]));Q[Y]=ee}return y.createDenseMatrix({data:Q,size:[R],datatype:B===y._datatype&&S===w._datatype?q:void 0})}function d(y,w){var C=y._data,b=y._size,B=y._datatype||y.getDataType(),M=w._data,S=w._size,R=w._datatype||w.getDataType(),V=b[0],q=b[1],W=S[1],O,Q=n,Y=i;B&&R&&B===R&&typeof B=="string"&&B!=="mixed"&&B!=="mixed"&&(O=B,Q=r.find(n,[O,O]),Y=r.find(i,[O,O]));for(var G=[],ee=0;ee<V;ee++){var oe=C[ee];G[ee]=[];for(var ie=0;ie<W;ie++){for(var fe=Y(oe[0],M[0][ie]),Ce=1;Ce<q;Ce++)fe=Q(fe,Y(oe[Ce],M[Ce][ie]));G[ee][ie]=fe}}return y.createDenseMatrix({data:G,size:[V,W],datatype:B===y._datatype&&R===w._datatype?O:void 0})}function g(y,w){var C=y._data,b=y._size,B=y._datatype||y.getDataType(),M=w._values,S=w._index,R=w._ptr,V=w._size,q=w._datatype||w._data===void 0?w._datatype:w.getDataType();if(!M)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");var W=b[0],O=V[1],Q,Y=n,G=i,ee=u,oe=0;B&&q&&B===q&&typeof B=="string"&&B!=="mixed"&&(Q=B,Y=r.find(n,[Q,Q]),G=r.find(i,[Q,Q]),ee=r.find(u,[Q,Q]),oe=r.convert(0,Q));for(var ie=[],fe=[],Ce=[],be=w.createSparseMatrix({values:ie,index:fe,ptr:Ce,size:[W,O],datatype:B===y._datatype&&q===w._datatype?Q:void 0}),Ae=0;Ae<O;Ae++){Ce[Ae]=fe.length;var we=R[Ae],qe=R[Ae+1];if(qe>we)for(var ce=0,ae=0;ae<W;ae++){for(var Je=ae+1,Te=void 0,le=we;le<qe;le++){var Me=S[le];ce!==Je?(Te=G(C[ae][Me],M[le]),ce=Je):Te=Y(Te,G(C[ae][Me],M[le]))}ce===Je&&!ee(Te,oe)&&(fe.push(ae),ie.push(Te))}}return Ce[O]=fe.length,be}function E(y,w){var C=y._values,b=y._index,B=y._ptr,M=y._datatype||y._data===void 0?y._datatype:y.getDataType();if(!C)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var S=w._data,R=w._datatype||w.getDataType(),V=y._size[0],q=w._size[0],W=[],O=[],Q=[],Y,G=n,ee=i,oe=u,ie=0;M&&R&&M===R&&typeof M=="string"&&M!=="mixed"&&(Y=M,G=r.find(n,[Y,Y]),ee=r.find(i,[Y,Y]),oe=r.find(u,[Y,Y]),ie=r.convert(0,Y));var fe=[],Ce=[];Q[0]=0;for(var be=0;be<q;be++){var Ae=S[be];if(!oe(Ae,ie))for(var we=B[be],qe=B[be+1],ce=we;ce<qe;ce++){var ae=b[ce];Ce[ae]?fe[ae]=G(fe[ae],ee(Ae,C[ce])):(Ce[ae]=!0,O.push(ae),fe[ae]=ee(Ae,C[ce]))}}for(var Je=O.length,Te=0;Te<Je;Te++){var le=O[Te];W[Te]=fe[le]}return Q[1]=O.length,y.createSparseMatrix({values:W,index:O,ptr:Q,size:[V,1],datatype:M===y._datatype&&R===w._datatype?Y:void 0})}function v(y,w){var C=y._values,b=y._index,B=y._ptr,M=y._datatype||y._data===void 0?y._datatype:y.getDataType();if(!C)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var S=w._data,R=w._datatype||w.getDataType(),V=y._size[0],q=w._size[0],W=w._size[1],O,Q=n,Y=i,G=u,ee=0;M&&R&&M===R&&typeof M=="string"&&M!=="mixed"&&(O=M,Q=r.find(n,[O,O]),Y=r.find(i,[O,O]),G=r.find(u,[O,O]),ee=r.convert(0,O));for(var oe=[],ie=[],fe=[],Ce=y.createSparseMatrix({values:oe,index:ie,ptr:fe,size:[V,W],datatype:M===y._datatype&&R===w._datatype?O:void 0}),be=[],Ae=[],we=0;we<W;we++){fe[we]=ie.length;for(var qe=we+1,ce=0;ce<q;ce++){var ae=S[ce][we];if(!G(ae,ee))for(var Je=B[ce],Te=B[ce+1],le=Je;le<Te;le++){var Me=b[le];Ae[Me]!==qe?(Ae[Me]=qe,ie.push(Me),be[Me]=Y(ae,C[le])):be[Me]=Q(be[Me],Y(ae,C[le]))}}for(var Ge=fe[we],ar=ie.length,sr=Ge;sr<ar;sr++){var Ar=ie[sr];oe[sr]=be[Ar]}}return fe[W]=ie.length,Ce}function A(y,w){var C=y._values,b=y._index,B=y._ptr,M=y._datatype||y._data===void 0?y._datatype:y.getDataType(),S=w._values,R=w._index,V=w._ptr,q=w._datatype||w._data===void 0?w._datatype:w.getDataType(),W=y._size[0],O=w._size[1],Q=C&&S,Y,G=n,ee=i;M&&q&&M===q&&typeof M=="string"&&M!=="mixed"&&(Y=M,G=r.find(n,[Y,Y]),ee=r.find(i,[Y,Y]));for(var oe=Q?[]:void 0,ie=[],fe=[],Ce=y.createSparseMatrix({values:oe,index:ie,ptr:fe,size:[W,O],datatype:M===y._datatype&&q===w._datatype?Y:void 0}),be=Q?[]:void 0,Ae=[],we,qe,ce,ae,Je,Te,le,Me,Ge=0;Ge<O;Ge++){fe[Ge]=ie.length;var ar=Ge+1;for(Je=V[Ge],Te=V[Ge+1],ae=Je;ae<Te;ae++)if(Me=R[ae],Q)for(qe=B[Me],ce=B[Me+1],we=qe;we<ce;we++)le=b[we],Ae[le]!==ar?(Ae[le]=ar,ie.push(le),be[le]=ee(S[ae],C[we])):be[le]=G(be[le],ee(S[ae],C[we]));else for(qe=B[Me],ce=B[Me+1],we=qe;we<ce;we++)le=b[we],Ae[le]!==ar&&(Ae[le]=ar,ie.push(le));if(Q)for(var sr=fe[Ge],Ar=ie.length,br=sr;br<Ar;br++){var zt=ie[br];oe[br]=be[zt]}}return fe[O]=ie.length,Ce}return r(xn,i,{"Array, Array":r.referTo("Matrix, Matrix",y=>(w,C)=>{l(ze(w),ze(C));var b=y(t(w),t(C));return ve(b)?b.valueOf():b}),"Matrix, Matrix":function(w,C){var b=w.size(),B=C.size();return l(b,B),b.length===1?B.length===1?f(w,C,b[0]):h(w,C):B.length===1?p(w,C):m(w,C)},"Matrix, Array":r.referTo("Matrix,Matrix",y=>(w,C)=>y(w,t(C))),"Array, Matrix":r.referToSelf(y=>(w,C)=>y(t(w,C.storage()),C)),"SparseMatrix, any":function(w,C){return a(w,C,i,!1)},"DenseMatrix, any":function(w,C){return c(w,C,i,!1)},"any, SparseMatrix":function(w,C){return a(C,w,i,!0)},"any, DenseMatrix":function(w,C){return c(C,w,i,!0)},"Array, any":function(w,C){return c(t(w),C,i,!1).valueOf()},"any, Array":function(w,C){return c(t(C),w,i,!0).valueOf()},"any, any":i,"any, any, ...any":r.referToSelf(y=>(w,C,b)=>{for(var B=y(w,C),M=0;M<b.length;M++)B=y(B,b[M]);return B})})}),wf="matAlgo07xSSf",yf=["typed","SparseMatrix"],Nt=J(wf,yf,e=>{var{typed:r,SparseMatrix:t}=e;return function(u,o,a){var c=u._size,l=u._datatype||u._data===void 0?u._datatype:u.getDataType(),f=o._size,h=o._datatype||o._data===void 0?o._datatype:o.getDataType();if(c.length!==f.length)throw new ne(c.length,f.length);if(c[0]!==f[0]||c[1]!==f[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+f+")");var D=c[0],p=c[1],m,s=0,d=a;typeof l=="string"&&l===h&&l!=="mixed"&&(m=l,s=r.convert(0,m),d=r.find(a,[m,m]));for(var g=[],E=[],v=new Array(p+1).fill(0),A=[],y=[],w=[],C=[],b=0;b<p;b++){var B=b+1,M=0;n(u,b,w,A,B),n(o,b,C,y,B);for(var S=0;S<D;S++){var R=w[S]===B?A[S]:s,V=C[S]===B?y[S]:s,q=d(R,V);q!==0&&q!==!1&&(E.push(S),g.push(q),M++)}v[b+1]=v[b]+M}return new t({values:g,index:E,ptr:v,size:[D,p],datatype:l===u._datatype&&h===o._datatype?m:void 0})};function n(i,u,o,a,c){for(var l=i._values,f=i._index,h=i._ptr,D=h[u],p=h[u+1];D<p;D++){var m=f[D];o[m]=c,a[m]=l[D]}}}),Tn="arg",Ff=["typed"],Ef=J(Tn,Ff,e=>{var{typed:r}=e;return r(Tn,{number:function(n){return Math.atan2(0,n)},BigNumber:function(n){return n.constructor.atan2(0,n)},Complex:function(n){return n.arg()},"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t))})}),In="conj",Af=["typed"],bf=J(In,Af,e=>{var{typed:r}=e;return r(In,{"number | BigNumber | Fraction":t=>t,Complex:t=>t.conjugate(),Unit:r.referToSelf(t=>n=>new n.constructor(t(n.toNumeric()),n.formatUnits())),"Array | Matrix":r.referToSelf(t=>n=>Ve(n,t))})}),zn="concat",Cf=["typed","matrix","isInteger"],_f=J(zn,Cf,e=>{var{typed:r,matrix:t,isInteger:n}=e;return r(zn,{"...Array | Matrix | number | BigNumber":function(u){var o,a=u.length,c=-1,l,f=!1,h=[];for(o=0;o<a;o++){var D=u[o];if(ve(D)&&(f=!0),de(D)||Ee(D)){if(o!==a-1)throw new Error("Dimension must be specified as last argument");if(l=c,c=D.valueOf(),!n(c))throw new TypeError("Integer number expected for dimension");if(c<0||o>0&&c>l)throw new Fr(c,l+1)}else{var p=me(D).valueOf(),m=ze(p);if(h[o]=p,l=c,c=m.length-1,o>0&&c!==l)throw new ne(l+1,c+1)}}if(h.length===0)throw new SyntaxError("At least one matrix expected");for(var s=h.shift();h.length;)s=xi(s,h.shift(),c);return f?t(s):s},"...string":function(u){return u.join("")}})}),On="getMatrixDataType",Bf=["typed"],Nf=J(On,Bf,e=>{var{typed:r}=e;return r(On,{Array:function(n){return Ct(n,ir)},Matrix:function(n){return n.getDataType()}})}),$n="identity",Mf=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],Sf=J($n,Mf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i,DenseMatrix:u,SparseMatrix:o}=e;return r($n,{"":function(){return t.matrix==="Matrix"?n([]):[]},string:function(f){return n(f)},"number | BigNumber":function(f){return c(f,f,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, string":function(f,h){return c(f,f,h)},"number | BigNumber, number | BigNumber":function(f,h){return c(f,h,t.matrix==="Matrix"?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(f,h,D){return c(f,h,D)},Array:function(f){return a(f)},"Array, string":function(f,h){return a(f,h)},Matrix:function(f){return a(f.valueOf(),f.storage())},"Matrix, string":function(f,h){return a(f.valueOf(),h)}});function a(l,f){switch(l.length){case 0:return f?n(f):[];case 1:return c(l[0],l[0],f);case 2:return c(l[0],l[1],f);default:throw new Error("Vector containing two values expected")}}function c(l,f,h){var D=Ee(l)||Ee(f)?i:null;if(Ee(l)&&(l=l.toNumber()),Ee(f)&&(f=f.toNumber()),!ge(l)||l<1)throw new Error("Parameters in function identity must be positive integers");if(!ge(f)||f<1)throw new Error("Parameters in function identity must be positive integers");var p=D?new i(1):1,m=D?new D(0):0,s=[l,f];if(h){if(h==="sparse")return o.diagonal(s,p,0,m);if(h==="dense")return u.diagonal(s,p,0,m);throw new TypeError('Unknown matrix type "'.concat(h,'"'))}for(var d=lt([],s,m),g=l<f?l:f,E=0;E<g;E++)d[E][E]=p;return d}});function Zi(){throw new Error('No "bignumber" implementation available')}function xf(){throw new Error('No "fraction" implementation available')}function Wi(){throw new Error('No "matrix" implementation available')}var Pn="range",Tf=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq","add","isPositive"],If=J(Pn,Tf,e=>{var{typed:r,config:t,matrix:n,bignumber:i,smaller:u,smallerEq:o,larger:a,largerEq:c,add:l,isPositive:f}=e;return r(Pn,{string:D,"string, boolean":D,number:function(d){throw new TypeError("Too few arguments to function range(): ".concat(d))},boolean:function(d){throw new TypeError("Unexpected type of argument 1 to function range(): ".concat(d,", number|bigint|BigNumber|Fraction"))},"number, number":function(d,g){return h(p(d,g,1,!1))},"number, number, number":function(d,g,E){return h(p(d,g,E,!1))},"number, number, boolean":function(d,g,E){return h(p(d,g,1,E))},"number, number, number, boolean":function(d,g,E,v){return h(p(d,g,E,v))},"bigint, bigint|number":function(d,g){return h(p(d,g,1n,!1))},"number, bigint":function(d,g){return h(p(BigInt(d),g,1n,!1))},"bigint, bigint|number, bigint|number":function(d,g,E){return h(p(d,g,BigInt(E),!1))},"number, bigint, bigint|number":function(d,g,E){return h(p(BigInt(d),g,BigInt(E),!1))},"bigint, bigint|number, boolean":function(d,g,E){return h(p(d,g,1n,E))},"number, bigint, boolean":function(d,g,E){return h(p(BigInt(d),g,1n,E))},"bigint, bigint|number, bigint|number, boolean":function(d,g,E,v){return h(p(d,g,BigInt(E),v))},"number, bigint, bigint|number, boolean":function(d,g,E,v){return h(p(BigInt(d),g,BigInt(E),v))},"BigNumber, BigNumber":function(d,g){var E=d.constructor;return h(p(d,g,new E(1),!1))},"BigNumber, BigNumber, BigNumber":function(d,g,E){return h(p(d,g,E,!1))},"BigNumber, BigNumber, boolean":function(d,g,E){var v=d.constructor;return h(p(d,g,new v(1),E))},"BigNumber, BigNumber, BigNumber, boolean":function(d,g,E,v){return h(p(d,g,E,v))},"Fraction, Fraction":function(d,g){return h(p(d,g,1,!1))},"Fraction, Fraction, Fraction":function(d,g,E){return h(p(d,g,E,!1))},"Fraction, Fraction, boolean":function(d,g,E){return h(p(d,g,1,E))},"Fraction, Fraction, Fraction, boolean":function(d,g,E,v){return h(p(d,g,E,v))},"Unit, Unit, Unit":function(d,g,E){return h(p(d,g,E,!1))},"Unit, Unit, Unit, boolean":function(d,g,E,v){return h(p(d,g,E,v))}});function h(s){return t.matrix==="Matrix"?n?n(s):Wi():s}function D(s,d){var g=m(s);if(!g)throw new SyntaxError('String "'+s+'" is no valid range');return t.number==="BigNumber"?(i===void 0&&Zi(),h(p(i(g.start),i(g.end),i(g.step)))):h(p(g.start,g.end,g.step,d))}function p(s,d,g,E){for(var v=[],A=f(g)?E?o:u:E?c:a,y=s;A(y,d);)v.push(y),y=l(y,g);return v}function m(s){var d=s.split(":"),g=d.map(function(v){return Number(v)}),E=g.some(function(v){return isNaN(v)});if(E)return null;switch(g.length){case 2:return{start:g[0],end:g[1],step:1};case 3:return{start:g[0],end:g[2],step:g[1]};default:return null}}}),Un="size",zf=["typed","config","?matrix"],Of=J(Un,zf,e=>{var{typed:r,config:t,matrix:n}=e;return r(Un,{Matrix:function(u){return u.create(u.size(),"number")},Array:ze,string:function(u){return t.matrix==="Array"?[u.length]:n([u.length],"dense","number")},"number | Complex | BigNumber | Unit | boolean | null":function(u){return t.matrix==="Array"?[]:n?n([],"dense","number"):Wi()}})}),qn="subset",$f=["typed","matrix","zeros","add"],Pf=J(qn,$f,e=>{var{typed:r,matrix:t,zeros:n,add:i}=e;return r(qn,{"Matrix, Index":function(a,c){return Or(c)?t():(ct(a,c),a.subset(c))},"Array, Index":r.referTo("Matrix, Index",function(o){return function(a,c){var l=o(t(a),c);return c.isScalar()?l:l.valueOf()}}),"Object, Index":qf,"string, Index":Uf,"Matrix, Index, any, any":function(a,c,l,f){return Or(c)?a:(ct(a,c),a.clone().subset(c,u(l,c),f))},"Array, Index, any, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,c,l,f){var h=o(t(a),c,l,f);return h.isMatrix?h.valueOf():h}}),"Array, Index, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,c,l){return o(t(a),c,l,void 0).valueOf()}}),"Matrix, Index, any":r.referTo("Matrix, Index, any, any",function(o){return function(a,c,l){return o(a,c,l,void 0)}}),"string, Index, string":Rn,"string, Index, string, string":Rn,"Object, Index, any":Rf});function u(o,a){if(typeof o=="string")throw new Error("can't boradcast a string");if(a._isScalar)return o;var c=a.size();if(c.every(l=>l>0))try{return i(o,n(c))}catch{return o}else return o}});function Uf(e,r){if(!yt(r))throw new TypeError("Index expected");if(Or(r))return"";if(ct(Array.from(e),r),r.size().length!==1)throw new ne(r.size().length,1);var t=e.length;De(r.min()[0],t),De(r.max()[0],t);var n=r.dimension(0),i="";return n.forEach(function(u){i+=e.charAt(u)}),i}function Rn(e,r,t,n){if(!r||r.isIndex!==!0)throw new TypeError("Index expected");if(Or(r))return e;if(ct(Array.from(e),r),r.size().length!==1)throw new ne(r.size().length,1);if(n!==void 0){if(typeof n!="string"||n.length!==1)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=r.dimension(0),u=i.size()[0];if(u!==t.length)throw new ne(i.size()[0],t.length);var o=e.length;De(r.min()[0]),De(r.max()[0]);for(var a=[],c=0;c<o;c++)a[c]=e.charAt(c);if(i.forEach(function(h,D){a[h]=t.charAt(D[0])}),a.length>o)for(var l=o-1,f=a.length;l<f;l++)a[l]||(a[l]=n);return a.join("")}function qf(e,r){if(!Or(r)){if(r.size().length!==1)throw new ne(r.size(),1);var t=r.dimension(0);if(typeof t!="string")throw new TypeError("String expected as index to retrieve an object property");return ti(e,t)}}function Rf(e,r,t){if(Or(r))return e;if(r.size().length!==1)throw new ne(r.size(),1);var n=r.dimension(0);if(typeof n!="string")throw new TypeError("String expected as index to retrieve an object property");var i=me(e);return ni(i,n,t),i}var Ln="zeros",Lf=["typed","config","matrix","BigNumber"],Hf=J(Ln,Lf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(Ln,{"":function(){return t.matrix==="Array"?u([]):u([],"default")},"...number | BigNumber | string":function(l){var f=l[l.length-1];if(typeof f=="string"){var h=l.pop();return u(l,h)}else return t.matrix==="Array"?u(l):u(l,"default")},Array:u,Matrix:function(l){var f=l.storage();return u(l.valueOf(),f)},"Array | Matrix, string":function(l,f){return u(l.valueOf(),f)}});function u(c,l){var f=o(c),h=f?new i(0):0;if(a(c),l){var D=n(l);return c.length>0?D.resize(c,h):D}else{var p=[];return c.length>0?lt(p,c,h):p}}function o(c){var l=!1;return c.forEach(function(f,h,D){Ee(f)&&(l=!0,D[h]=f.toNumber())}),l}function a(c){c.forEach(function(l){if(typeof l!="number"||!ge(l)||l<0)throw new Error("Parameters in function zeros must be positive integers")})}}),Zf="numeric",Wf=["number","?bignumber","?fraction"],Vf=J(Zf,Wf,e=>{var{number:r,bignumber:t,fraction:n}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},u={number:o=>r(o),BigNumber:t?o=>t(o):Zi,bigint:o=>BigInt(o),Fraction:n?o=>n(o):xf};return function(a){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"number",l=arguments.length>2?arguments[2]:void 0;if(l!==void 0)throw new SyntaxError("numeric() takes one or two arguments");var f=ir(a);if(!(f in i))throw new TypeError("Cannot convert "+a+' of type "'+f+'"; valid input types are '+Object.keys(i).join(", "));if(!(c in u))throw new TypeError("Cannot convert "+a+' to type "'+c+'"; valid output types are '+Object.keys(u).join(", "));return c===f?a:u[c](a)}}),Hn="divideScalar",Jf=["typed","numeric"],Gf=J(Hn,Jf,e=>{var{typed:r,numeric:t}=e;return r(Hn,{"number, number":function(i,u){return i/u},"Complex, Complex":function(i,u){return i.div(u)},"BigNumber, BigNumber":function(i,u){return i.div(u)},"bigint, bigint":function(i,u){return i/u},"Fraction, Fraction":function(i,u){return i.div(u)},"Unit, number | Complex | Fraction | BigNumber | Unit":(n,i)=>n.divide(i),"number | Fraction | Complex | BigNumber, Unit":(n,i)=>i.divideInto(n)})}),Zn="pow",Yf=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],kf=J(Zn,Yf,e=>{var{typed:r,config:t,identity:n,multiply:i,matrix:u,inv:o,number:a,fraction:c,Complex:l}=e;return r(Zn,{"number, number":f,"Complex, Complex":function(m,s){return m.pow(s)},"BigNumber, BigNumber":function(m,s){return s.isInteger()||m>=0||t.predictable?m.pow(s):new l(m.toNumber(),0).pow(s.toNumber(),0)},"bigint, bigint":(p,m)=>p**m,"Fraction, Fraction":function(m,s){var d=m.pow(s);if(d!=null)return d;if(t.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return f(m.valueOf(),s.valueOf())},"Array, number":h,"Array, BigNumber":function(m,s){return h(m,s.toNumber())},"Matrix, number":D,"Matrix, BigNumber":function(m,s){return D(m,s.toNumber())},"Unit, number | BigNumber":function(m,s){return m.pow(s)}});function f(p,m){if(t.predictable&&!ge(m)&&p<0)try{var s=c(m),d=a(s);if((m===d||Math.abs((m-d)/m)<1e-14)&&s.d%2n===1n)return(s.n%2n===0n?1:-1)*Math.pow(-p,m)}catch{}return t.predictable&&(p<-1&&m===1/0||p>-1&&p<0&&m===-1/0)?NaN:ge(m)||p>=0||t.predictable?Ri(p,m):p*p<1&&m===1/0||p*p>1&&m===-1/0?0:new l(p,0).pow(m,0)}function h(p,m){if(!ge(m))throw new TypeError("For A^b, b must be an integer (value is "+m+")");var s=ze(p);if(s.length!==2)throw new Error("For A^b, A must be 2 dimensional (A has "+s.length+" dimensions)");if(s[0]!==s[1])throw new Error("For A^b, A must be square (size is "+s[0]+"x"+s[1]+")");if(m<0)try{return h(o(p),-m)}catch(E){throw E.message==="Cannot calculate inverse, determinant is zero"?new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+m+")"):E}for(var d=n(s[0]).valueOf(),g=p;m>=1;)(m&1)===1&&(d=i(g,d)),m>>=1,g=i(g,g);return d}function D(p,m){return u(h(p.valueOf(),m))}}),Mr="Number of decimals in function round must be an integer",Wn="round",Xf=["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],Qf=J(Wn,Xf,e=>{var{typed:r,config:t,matrix:n,equalScalar:i,zeros:u,BigNumber:o,DenseMatrix:a}=e,c=Hi({typed:r,equalScalar:i}),l=Vr({typed:r,DenseMatrix:a}),f=nn({typed:r});function h(D){return Math.abs(Zr(D).exponent)}return r(Wn,{number:function(p){var m=qr(p,h(t.relTol)),s=tr(p,m,t.relTol,t.absTol)?m:p;return qr(s)},"number, number":function(p,m){var s=h(t.relTol);if(m>=s)return qr(p,m);var d=qr(p,s),g=tr(p,d,t.relTol,t.absTol)?d:p;return qr(g,m)},"number, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Mr);return new o(p).toDecimalPlaces(m.toNumber())},Complex:function(p){return p.round()},"Complex, number":function(p,m){if(m%1)throw new TypeError(Mr);return p.round(m)},"Complex, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Mr);var s=m.toNumber();return p.round(s)},BigNumber:function(p){var m=new o(p).toDecimalPlaces(h(t.relTol)),s=gr(p,m,t.relTol,t.absTol)?m:p;return s.toDecimalPlaces(0)},"BigNumber, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Mr);var s=h(t.relTol);if(m>=s)return p.toDecimalPlaces(m.toNumber());var d=p.toDecimalPlaces(s),g=gr(p,d,t.relTol,t.absTol)?d:p;return g.toDecimalPlaces(m.toNumber())},bigint:D=>D,"bigint, number":(D,p)=>D,"bigint, BigNumber":(D,p)=>D,Fraction:function(p){return p.round()},"Fraction, number":function(p,m){if(m%1)throw new TypeError(Mr);return p.round(m)},"Fraction, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Mr);return p.round(m.toNumber())},"Unit, number, Unit":r.referToSelf(D=>function(p,m,s){var d=p.toNumeric(s);return s.multiply(D(d,m))}),"Unit, BigNumber, Unit":r.referToSelf(D=>(p,m,s)=>D(p,m.toNumber(),s)),"Array | Matrix, number | BigNumber, Unit":r.referToSelf(D=>(p,m,s)=>Ve(p,d=>D(d,m,s),!0)),"Array | Matrix | Unit, Unit":r.referToSelf(D=>(p,m)=>D(p,0,m)),"Array | Matrix":r.referToSelf(D=>p=>Ve(p,D,!0)),"SparseMatrix, number | BigNumber":r.referToSelf(D=>(p,m)=>c(p,m,D,!1)),"DenseMatrix, number | BigNumber":r.referToSelf(D=>(p,m)=>f(p,m,D,!1)),"Array, number | BigNumber":r.referToSelf(D=>(p,m)=>f(n(p),m,D,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":r.referToSelf(D=>(p,m)=>i(p,0)?u(m.size(),m.storage()):l(m,p,D,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":r.referToSelf(D=>(p,m)=>i(p,0)?u(m.size(),m.storage()):f(m,p,D,!0)),"number | Complex | BigNumber | Fraction, Array":r.referToSelf(D=>(p,m)=>f(n(m),p,D,!0).valueOf())})}),mt="smaller",Kf=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],jf=J(mt,Kf,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,c=Bt({typed:r}),l=Nt({typed:r,SparseMatrix:a}),f=Vr({typed:r,DenseMatrix:u}),h=Jr({typed:r,matrix:i,concat:o}),D=Wr({typed:r});function p(m,s){return m.lt(s)&&!gr(m,s,t.relTol,t.absTol)}return r(mt,ec({typed:r,config:t}),{"boolean, boolean":(m,s)=>m<s,"BigNumber, BigNumber":p,"bigint, bigint":(m,s)=>m<s,"Fraction, Fraction":(m,s)=>m.compare(s)===-1,"Fraction, BigNumber":function(s,d){return p(n(s),d)},"BigNumber, Fraction":function(s,d){return p(s,n(d))},"Complex, Complex":function(s,d){throw new TypeError("No ordering relation is defined for complex numbers")}},D,h({SS:l,DS:c,Ss:f}))}),ec=J(mt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(mt,{"number, number":function(i,u){return i<u&&!tr(i,u,t.relTol,t.absTol)}})}),dt="smallerEq",rc=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],tc=J(dt,rc,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=Bt({typed:r}),c=Nt({typed:r,SparseMatrix:o}),l=Vr({typed:r,DenseMatrix:i}),f=Jr({typed:r,matrix:n,concat:u}),h=Wr({typed:r});return r(dt,nc({typed:r,config:t}),{"boolean, boolean":(D,p)=>D<=p,"BigNumber, BigNumber":function(p,m){return p.lte(m)||gr(p,m,t.relTol,t.absTol)},"bigint, bigint":(D,p)=>D<=p,"Fraction, Fraction":(D,p)=>D.compare(p)!==1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,f({SS:c,DS:a,Ss:l}))}),nc=J(dt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(dt,{"number, number":function(i,u){return i<=u||tr(i,u,t.relTol,t.absTol)}})}),gt="larger",ic=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],uc=J(gt,ic,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,c=Bt({typed:r}),l=Nt({typed:r,SparseMatrix:a}),f=Vr({typed:r,DenseMatrix:u}),h=Jr({typed:r,matrix:i,concat:o}),D=Wr({typed:r});function p(m,s){return m.gt(s)&&!gr(m,s,t.relTol,t.absTol)}return r(gt,oc({typed:r,config:t}),{"boolean, boolean":(m,s)=>m>s,"BigNumber, BigNumber":p,"bigint, bigint":(m,s)=>m>s,"Fraction, Fraction":(m,s)=>m.compare(s)===1,"Fraction, BigNumber":function(s,d){return p(n(s),d)},"BigNumber, Fraction":function(s,d){return p(s,n(d))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},D,h({SS:l,DS:c,Ss:f}))}),oc=J(gt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(gt,{"number, number":function(i,u){return i>u&&!tr(i,u,t.relTol,t.absTol)}})}),vt="largerEq",ac=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],sc=J(vt,ac,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=Bt({typed:r}),c=Nt({typed:r,SparseMatrix:o}),l=Vr({typed:r,DenseMatrix:i}),f=Jr({typed:r,matrix:n,concat:u}),h=Wr({typed:r});return r(vt,fc({typed:r,config:t}),{"boolean, boolean":(D,p)=>D>=p,"BigNumber, BigNumber":function(p,m){return p.gte(m)||gr(p,m,t.relTol,t.absTol)},"bigint, bigint":function(p,m){return p>=m},"Fraction, Fraction":(D,p)=>D.compare(p)!==-1,"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},h,f({SS:c,DS:a,Ss:l}))}),fc=J(vt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(vt,{"number, number":function(i,u){return i>=u||tr(i,u,t.relTol,t.absTol)}})}),cc="ImmutableDenseMatrix",lc=["smaller","DenseMatrix"],hc=J(cc,lc,e=>{var{smaller:r,DenseMatrix:t}=e;function n(i,u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(u&&!Qe(u))throw new Error("Invalid datatype: "+u);if(ve(i)||ye(i)){var o=new t(i,u);this._data=o._data,this._size=o._size,this._datatype=o._datatype,this._min=null,this._max=null}else if(i&&ye(i.data)&&ye(i.size))this._data=i.data,this._size=i.size,this._datatype=i.datatype,this._min=typeof i.min<"u"?i.min:null,this._max=typeof i.max<"u"?i.max:null;else{if(i)throw new TypeError("Unsupported type of data ("+ir(i)+")");this._data=[],this._size=[0],this._datatype=u,this._min=null,this._max=null}}return n.prototype=new t,n.prototype.type="ImmutableDenseMatrix",n.prototype.isImmutableDenseMatrix=!0,n.prototype.subset=function(i){switch(arguments.length){case 1:{var u=t.prototype.subset.call(this,i);return ve(u)?new n({data:u._data,size:u._size,datatype:u._datatype}):u}case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},n.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},n.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},n.prototype.clone=function(){return new n({data:me(this._data),size:me(this._size),datatype:this._datatype})},n.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.fromJSON=function(i){return new n(i)},n.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},n.prototype.min=function(){if(this._min===null){var i=null;this.forEach(function(u){(i===null||r(u,i))&&(i=u)}),this._min=i!==null?i:void 0}return this._min},n.prototype.max=function(){if(this._max===null){var i=null;this.forEach(function(u){(i===null||r(i,u))&&(i=u)}),this._max=i!==null?i:void 0}return this._max},n},{isClass:!0}),pc="Index",Dc=["ImmutableDenseMatrix","getMatrixDataType"],mc=J(pc,Dc,e=>{var{ImmutableDenseMatrix:r,getMatrixDataType:t}=e;function n(u){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var o=0,a=arguments.length;o<a;o++){var c=arguments[o],l=ye(c),f=ve(c),h=typeof c,D=null;if(ai(c))this._dimensions.push(c),this._isScalar=!1;else if(l||f){var p=void 0;t(c)==="boolean"?(l&&(p=i(Vn(c).valueOf())),f&&(p=i(Vn(c._data).valueOf())),D=c.valueOf().length):p=i(c.valueOf()),this._dimensions.push(p);var m=p.size();(m.length!==1||m[0]!==1||D!==null)&&(this._isScalar=!1)}else if(h==="number")this._dimensions.push(i([c]));else if(h==="bigint")this._dimensions.push(i([Number(c)]));else if(h==="string")this._dimensions.push(c);else throw new TypeError("Dimension must be an Array, Matrix, number, bigint, string, or Range");this._sourceSize.push(D)}}n.prototype.type="Index",n.prototype.isIndex=!0;function i(u){for(var o=0,a=u.length;o<a;o++)if(typeof u[o]!="number"||!ge(u[o]))throw new TypeError("Index parameters must be positive integer numbers");return new r(u)}return n.prototype.clone=function(){var u=new n;return u._dimensions=me(this._dimensions),u._isScalar=this._isScalar,u._sourceSize=this._sourceSize,u},n.create=function(u){var o=new n;return n.apply(o,u),o},n.prototype.size=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var c=this._dimensions[o];u[o]=typeof c=="string"?1:c.size()[0]}return u},n.prototype.max=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var c=this._dimensions[o];u[o]=typeof c=="string"?c:c.max()}return u},n.prototype.min=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var c=this._dimensions[o];u[o]=typeof c=="string"?c:c.min()}return u},n.prototype.forEach=function(u){for(var o=0,a=this._dimensions.length;o<a;o++)u(this._dimensions[o],o,this)},n.prototype.dimension=function(u){return typeof u!="number"?null:this._dimensions[u]||null},n.prototype.isObjectProperty=function(){return this._dimensions.length===1&&typeof this._dimensions[0]=="string"},n.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},n.prototype.isScalar=function(){return this._isScalar},n.prototype.toArray=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var c=this._dimensions[o];u.push(typeof c=="string"?c:c.toArray())}return u},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var u=[],o=0,a=this._dimensions.length;o<a;o++){var c=this._dimensions[o];typeof c=="string"?u.push(JSON.stringify(c)):u.push(c.toString())}return"["+u.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",dimensions:this._dimensions}},n.fromJSON=function(u){return n.create(u.dimensions)},n},{isClass:!0});function Vn(e){var r=[];return e.forEach((t,n)=>{t&&r.push(n)}),r}function dc(e){var r=0,t=1,n=Object.create(null),i=Object.create(null),u=0,o=function(c){var l=i[c];if(l&&(delete n[l],delete i[c],--r,t===l)){if(!r){u=0,t=1;return}for(;!Object.prototype.hasOwnProperty.call(n,++t););}};return e=Math.abs(e),{hit:function(c){var l=i[c],f=++u;if(n[f]=c,i[c]=f,!l)return++r,r<=e?void 0:(c=n[t],o(c),c);if(delete n[l],t===l)for(;!Object.prototype.hasOwnProperty.call(n,++t););},delete:o,clear:function(){r=u=0,t=1,n=Object.create(null),i=Object.create(null)}}}function Mt(e){var{hasher:r,limit:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=t??Number.POSITIVE_INFINITY,r=r??JSON.stringify,function n(){typeof n.cache!="object"&&(n.cache={values:new Map,lru:dc(t||Number.POSITIVE_INFINITY)});for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];var o=r(i);if(n.cache.values.has(o))return n.cache.lru.hit(o),n.cache.values.get(o);var a=e.apply(e,i);return n.cache.values.set(o,a),n.cache.values.delete(n.cache.lru.hit(o)),a}}Mt(function(e){return new e(1).exp()},{hasher:St});Mt(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:St});var Vi=Mt(function(e){return e.acos(-1)},{hasher:St});Mt(function(e){return Vi(e).times(2)},{hasher:St});function St(e){return e[0].precision}var Jn="add",gc=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],vc=J(Jn,gc,e=>{var{typed:r,matrix:t,addScalar:n,equalScalar:i,DenseMatrix:u,SparseMatrix:o,concat:a}=e,c=tf({typed:r}),l=of({typed:r,equalScalar:i}),f=ff({typed:r,DenseMatrix:u}),h=Jr({typed:r,matrix:t,concat:a});return r(Jn,{"any, any":n,"any, any, ...any":r.referToSelf(D=>(p,m,s)=>{for(var d=D(p,m),g=0;g<s.length;g++)d=D(d,s[g]);return d})},h({elop:n,DS:c,SS:l,Ss:f}))}),Gn="dot",wc=["typed","addScalar","multiplyScalar","conj","size"],yc=J(Gn,wc,e=>{var{typed:r,addScalar:t,multiplyScalar:n,conj:i,size:u}=e;return r(Gn,{"Array | DenseMatrix, Array | DenseMatrix":a,"SparseMatrix, SparseMatrix":c});function o(f,h){var D=l(f),p=l(h),m,s;if(D.length===1)m=D[0];else if(D.length===2&&D[1]===1)m=D[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+D.join(", ")+")");if(p.length===1)s=p[0];else if(p.length===2&&p[1]===1)s=p[0];else throw new RangeError("Expected a column vector, instead got a matrix of size ("+p.join(", ")+")");if(m!==s)throw new RangeError("Vectors must have equal length ("+m+" != "+s+")");if(m===0)throw new RangeError("Cannot calculate the dot product of empty vectors");return m}function a(f,h){var D=o(f,h),p=ve(f)?f._data:f,m=ve(f)?f._datatype||f.getDataType():void 0,s=ve(h)?h._data:h,d=ve(h)?h._datatype||h.getDataType():void 0,g=l(f).length===2,E=l(h).length===2,v=t,A=n;if(m&&d&&m===d&&typeof m=="string"&&m!=="mixed"){var y=m;v=r.find(t,[y,y]),A=r.find(n,[y,y])}if(!g&&!E){for(var w=A(i(p[0]),s[0]),C=1;C<D;C++)w=v(w,A(i(p[C]),s[C]));return w}if(!g&&E){for(var b=A(i(p[0]),s[0][0]),B=1;B<D;B++)b=v(b,A(i(p[B]),s[B][0]));return b}if(g&&!E){for(var M=A(i(p[0][0]),s[0]),S=1;S<D;S++)M=v(M,A(i(p[S][0]),s[S]));return M}if(g&&E){for(var R=A(i(p[0][0]),s[0][0]),V=1;V<D;V++)R=v(R,A(i(p[V][0]),s[V][0]));return R}}function c(f,h){o(f,h);for(var D=f._index,p=f._values,m=h._index,s=h._values,d=0,g=t,E=n,v=0,A=0;v<D.length&&A<m.length;){var y=D[v],w=m[A];if(y<w){v++;continue}if(y>w){A++;continue}y===w&&(d=g(d,E(p[v],s[A])),v++,A++)}return d}function l(f){return ve(f)?f.size():u(f)}}),Yn="index",Fc=["typed","Index"],Ec=J(Yn,Fc,e=>{var{typed:r,Index:t}=e;return r(Yn,{"...number | string | BigNumber | Range | Array | Matrix":function(i){var u=i.map(function(a){return Ee(a)?a.toNumber():ye(a)||ve(a)?a.map(function(c){return Ee(c)?c.toNumber():c}):a}),o=new t;return t.apply(o,u),o}})}),kn="det",Ac=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],bc=J(kn,Ac,e=>{var{typed:r,matrix:t,subtractScalar:n,multiply:i,divideScalar:u,isZero:o,unaryMinus:a}=e;return r(kn,{any:function(f){return me(f)},"Array | Matrix":function(f){var h;switch(ve(f)?h=f.size():Array.isArray(f)?(f=t(f),h=f.size()):h=[],h.length){case 0:return me(f);case 1:if(h[0]===1)return me(f.valueOf()[0]);if(h[0]===0)return 1;throw new RangeError("Matrix must be square (size: "+Be(h)+")");case 2:{var D=h[0],p=h[1];if(D===p)return c(f.clone().valueOf(),D);if(p===0)return 1;throw new RangeError("Matrix must be square (size: "+Be(h)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Be(h)+")")}}});function c(l,f,h){if(f===1)return me(l[0][0]);if(f===2)return n(i(l[0][0],l[1][1]),i(l[1][0],l[0][1]));for(var D=!1,p=new Array(f).fill(0).map((C,b)=>b),m=0;m<f;m++){var s=p[m];if(o(l[s][m])){var d=void 0;for(d=m+1;d<f;d++)if(!o(l[p[d]][m])){s=p[d],p[d]=p[m],p[m]=s,D=!D;break}if(d===f)return l[s][m]}for(var g=l[s][m],E=m===0?1:l[p[m-1]][m-1],v=m+1;v<f;v++)for(var A=p[v],y=m+1;y<f;y++)l[A][y]=u(n(i(l[A][y],g),i(l[A][m],l[s][y])),E)}var w=l[p[f-1]][f-1];return D?a(w):w}}),Xn="inv",Cc=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],_c=J(Xn,Cc,e=>{var{typed:r,matrix:t,divideScalar:n,addScalar:i,multiply:u,unaryMinus:o,det:a,identity:c,abs:l}=e;return r(Xn,{"Array | Matrix":function(D){var p=ve(D)?D.size():ze(D);switch(p.length){case 1:if(p[0]===1)return ve(D)?t([n(1,D.valueOf()[0])]):[n(1,D[0])];throw new RangeError("Matrix must be square (size: "+Be(p)+")");case 2:{var m=p[0],s=p[1];if(m===s)return ve(D)?t(f(D.valueOf(),m,s),D.storage()):f(D,m,s);throw new RangeError("Matrix must be square (size: "+Be(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Be(p)+")")}},any:function(D){return n(1,D)}});function f(h,D,p){var m,s,d,g,E;if(D===1){if(g=h[0][0],g===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(1,g)]]}else if(D===2){var v=a(h);if(v===0)throw Error("Cannot calculate inverse, determinant is zero");return[[n(h[1][1],v),n(o(h[0][1]),v)],[n(o(h[1][0]),v),n(h[0][0],v)]]}else{var A=h.concat();for(m=0;m<D;m++)A[m]=A[m].concat();for(var y=c(D).valueOf(),w=0;w<p;w++){var C=l(A[w][w]),b=w;for(m=w+1;m<D;)l(A[m][w])>C&&(C=l(A[m][w]),b=m),m++;if(C===0)throw Error("Cannot calculate inverse, determinant is zero");m=b,m!==w&&(E=A[w],A[w]=A[m],A[m]=E,E=y[w],y[w]=y[m],y[m]=E);var B=A[w],M=y[w];for(m=0;m<D;m++){var S=A[m],R=y[m];if(m!==w){if(S[w]!==0){for(d=n(o(S[w]),B[w]),s=w;s<p;s++)S[s]=i(S[s],u(d,B[s]));for(s=0;s<p;s++)R[s]=i(R[s],u(d,M[s]))}}else{for(d=B[w],s=w;s<p;s++)S[s]=n(S[s],d);for(s=0;s<p;s++)R[s]=n(R[s],d)}}}return y}}}),Bc=Nc("pi",["config","?BigNumber"],e=>{var{config:r,BigNumber:t}=e;return r.number==="BigNumber"?Vi(t):is});function Nc(e,r,t){return J(e,r,t,{recreateOnConfigChange:!0})}var $r=ba({config:Pe}),xt=Ma({}),Ji=$a({}),un=qa({}),or=rs({Matrix:un}),et=Bc({BigNumber:$r,config:Pe}),te=Bo({BigNumber:$r,Complex:xt,DenseMatrix:or,Fraction:Ji}),Qt=Os({typed:te}),Tt=Ps({typed:te}),Qn=Ef({typed:te}),qt=_s({Complex:xt,typed:te}),Mc=bf({typed:te}),Gr=hs({config:Pe,typed:te}),Sc=Nf({typed:te}),xc=ns({typed:te}),Tc=as({config:Pe,typed:te}),Ic=fs({equalScalar:Gr,typed:te}),zc=pf({Complex:xt,config:Pe,typed:te}),Gi=df({typed:te}),Yi=ys({typed:te}),Er=ms({Matrix:un,equalScalar:Gr,typed:te}),Oc=qs({typed:te}),It=As({BigNumber:$r,typed:te}),Ue=xs({DenseMatrix:or,Matrix:un,SparseMatrix:Er,typed:te}),ki=Hf({BigNumber:$r,config:Pe,matrix:Ue,typed:te}),Yr=_f({isInteger:xc,matrix:Ue,typed:te}),Xi=Ms({Fraction:Ji,typed:te}),Qi=Sf({BigNumber:$r,DenseMatrix:or,SparseMatrix:Er,config:Pe,matrix:Ue,typed:te}),$c=sc({DenseMatrix:or,SparseMatrix:Er,concat:Yr,config:Pe,matrix:Ue,typed:te}),Pc=Vf({bignumber:It,fraction:Xi,number:Yi}),Kn=Qf({BigNumber:$r,DenseMatrix:or,config:Pe,equalScalar:Gr,matrix:Ue,typed:te,zeros:ki}),Uc=Of({matrix:Ue,config:Pe,typed:te}),Ki=jf({DenseMatrix:or,SparseMatrix:Er,bignumber:It,concat:Yr,config:Pe,matrix:Ue,typed:te}),ji=Is({typed:te}),wt=vc({DenseMatrix:or,SparseMatrix:Er,addScalar:Tt,concat:Yr,equalScalar:Gr,matrix:Ue,typed:te}),eu=Gf({numeric:Pc,typed:te}),qc=hc({DenseMatrix:or,smaller:Ki}),Rc=mc({ImmutableDenseMatrix:qc,getMatrixDataType:Sc}),Lc=uc({DenseMatrix:or,SparseMatrix:Er,bignumber:It,concat:Yr,config:Pe,matrix:Ue,typed:te}),Hc=tc({DenseMatrix:or,SparseMatrix:Er,concat:Yr,config:Pe,matrix:Ue,typed:te}),Rt=Pf({add:wt,matrix:Ue,typed:te,zeros:ki}),Zc=yc({addScalar:Tt,conj:Mc,multiplyScalar:Gi,size:Uc,typed:te}),Lt=Ec({Index:Rc,typed:te}),Tr=vf({addScalar:Tt,dot:Zc,equalScalar:Gr,matrix:Ue,multiplyScalar:Gi,typed:te}),Ht=If({bignumber:It,matrix:Ue,add:wt,config:Pe,isPositive:Tc,larger:Lc,largerEq:$c,smaller:Ki,smallerEq:Hc,typed:te}),Wc=bc({divideScalar:eu,isZero:Ic,matrix:Ue,multiply:Tr,subtractScalar:Oc,typed:te,unaryMinus:ji}),Vc=_c({abs:Qt,addScalar:Tt,det:Wc,divideScalar:eu,identity:Qi,matrix:Ue,multiply:Tr,typed:te,unaryMinus:ji}),Jc=kf({Complex:xt,config:Pe,fraction:Xi,identity:Qi,inv:Vc,matrix:Ue,multiply:Tr,number:Yi,typed:te});const jn=299792458,lr={Hz:1,kHz:1e3,MHz:1e6,GHz:1e9,THz:1e12},ei={m:1,cm:.01,mm:.001,um:1e-6,nm:1e-9};class Gc{_unit="Hz";set unit(r){if(typeof r!="string")throw new Error(`Unknown frequency unit: ${r}`);const t=this._unit;let n;switch(r.toLowerCase()){case"hz":n="Hz";break;case"khz":n="kHz";break;case"mhz":n="MHz";break;case"ghz":n="GHz";break;default:throw new Error(`Unknown frequency unit: ${r}`)}if(n!==t&&this.f_scaled&&this.f_scaled.length>0){const i=lr[t],u=lr[n];if(i&&u)this.f_scaled=this.f_scaled.map(o=>o*i/u);else throw new Error(`Could not find frequency multipliers (old: ${i}, new: ${u}) for unit conversion`)}this._unit=n}get unit(){return this._unit}_f_scaled=[];set f_scaled(r){if(!Array.isArray(r))throw new Error("Frequency value must be an array");for(const t of r){if(typeof t!="number")throw new Error(`Frequency value must be an array of numbers, but received: ${t}`);if(t<0)throw new Error(`Frequency values cannot be negative, but received: ${t}`)}this._f_scaled=r}get f_scaled(){return this._f_scaled}_getFrequencyInTargetUnit(r){if(!this.f_scaled||this.f_scaled.length===0)return[];const t=lr[this.unit];if(!t)throw new Error(`Multiplier for current unit ${this.unit} not found.`);const n=lr[r];if(!n)throw new Error(`Multiplier for target unit ${r} not found.`);return this.f_scaled.map(i=>i*t/n)}_setFrequencyFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=lr[t];if(!n)throw new Error(`Multiplier for source unit ${t} not found.`);const i=lr[this.unit];if(!i)throw new Error(`Multiplier for current internal unit ${this.unit} not found.`);const u=r.map(o=>o*n/i);this.f_scaled=u}get f_Hz(){return this._getFrequencyInTargetUnit("Hz")}set f_Hz(r){this._setFrequencyFromTargetUnit(r,"Hz")}get f_kHz(){return this._getFrequencyInTargetUnit("kHz")}set f_kHz(r){this._setFrequencyFromTargetUnit(r,"kHz")}get f_MHz(){return this._getFrequencyInTargetUnit("MHz")}set f_MHz(r){this._setFrequencyFromTargetUnit(r,"MHz")}get f_GHz(){return this._getFrequencyInTargetUnit("GHz")}set f_GHz(r){this._setFrequencyFromTargetUnit(r,"GHz")}get f_THz(){return this._getFrequencyInTargetUnit("THz")}set f_THz(r){this._setFrequencyFromTargetUnit(r,"THz")}_getWavelengthInTargetUnit(r){if(!this.f_scaled||this.f_scaled.length===0)return[];const t=lr[this.unit];if(!t)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const n=ei[r];if(!n)throw new Error(`Wavelength multiplier to meters for target wavelength unit ${r} not found.`);return this.f_scaled.map(i=>{const u=i*t;return u===0?1/0:jn/u/n})}_setWavelengthFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=ei[t];if(!n)throw new Error(`Wavelength multiplier to meters for source unit ${t} not found.`);const i=lr[this.unit];if(!i)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const u=r.map(o=>{const a=o*n;if(a===0)throw new Error("Cannot convert zero wavelength to frequency.");return jn/a/i});this.f_scaled=u}get wavelength_m(){return this._getWavelengthInTargetUnit("m")}set wavelength_m(r){this._setWavelengthFromTargetUnit(r,"m")}get wavelength_cm(){return this._getWavelengthInTargetUnit("cm")}set wavelength_cm(r){this._setWavelengthFromTargetUnit(r,"cm")}get wavelength_mm(){return this._getWavelengthInTargetUnit("mm")}set wavelength_mm(r){this._setWavelengthFromTargetUnit(r,"mm")}get wavelength_um(){return this._getWavelengthInTargetUnit("um")}set wavelength_um(r){this._setWavelengthFromTargetUnit(r,"um")}get wavelength_nm(){return this._getWavelengthInTargetUnit("nm")}set wavelength_nm(r){this._setWavelengthFromTargetUnit(r,"nm")}}const Yc=["RI","MA","DB"],kc=["S","Y","Z","G","H"];class Xc{comments=[];_format;set format(r){if(r==null){this._format=void 0;return}if(typeof r!="string")throw new Error(`Unknown Touchstone format: ${r}`);switch(r.toLowerCase()){case"ma":this._format="MA";break;case"db":this._format="DB";break;case"ri":this._format="RI";break;default:throw new Error(`Unknown Touchstone format: ${r}`)}}get format(){return this._format}_parameter;set parameter(r){if(r==null){this._parameter=void 0;return}if(typeof r!="string")throw new Error(`Unknown Touchstone parameter: ${r}`);switch(r.toLowerCase()){case"s":this._parameter="S";break;case"y":this._parameter="Y";break;case"z":this._parameter="Z";break;case"g":this._parameter="G";break;case"h":this._parameter="H";break;default:throw new Error(`Unknown Touchstone parameter: ${r}`)}}get parameter(){return this._parameter}_impedance=50;set impedance(r){if(typeof r=="number"){this._impedance=r;return}if(!Array.isArray(r)||r.length===0)throw new Error(`Unknown Touchstone impedance: ${r}`);for(const t of r)if(typeof t!="number")throw new Error(`Unknown Touchstone impedance: ${r}`);this._impedance=r}get impedance(){return this._impedance}_nports;set nports(r){if(r==null){this._nports=void 0;return}if(typeof r!="number")throw new Error(`Unknown ports number: ${r}`);if(!Number.isInteger(r))throw new Error(`Unknown ports number: ${r}`);if(r<1)throw new Error(`Unknown ports number: ${r}`);this._nports=r}get nports(){return this._nports}frequency;_matrix;set matrix(r){if(r==null){this._matrix=void 0;return}this._matrix=r}get matrix(){return this._matrix}readContent(r,t){this.nports=t;const n=r.split(`
18
+ `).map(f=>f.trim()).filter(f=>f!=="");this.comments=n.filter(f=>f.startsWith("!")).map(f=>f.slice(1).trim()),this.frequency=new Gc;const i=n.filter(f=>f.startsWith("#"));if(i.length===0)throw new Error('Unable to find the option line starting with "#"');if(i.length>1)throw new Error(`Only one option line starting with "#" is supported, but found ${i.length} lines`);const u=i[0].slice(1).trim().split(/\s+/);if(this.frequency.unit=u[0],this.parameter=u[1],this.format=u[2],u.length>=4){if(u[3].toLowerCase()!=="r")throw new Error(`Unknown Touchstone impedance: ${u.slice(3).join(" ")}`);const f=u.slice(4).map(h=>parseFloat(h));if(f.length===0||f.some(Number.isNaN))throw new Error(`Unknown Touchstone impedance: ${u.slice(3).join(" ")}`);if(f.length===1)this.impedance=f[0];else if(f.length===this.nports)this.impedance=f;else throw new Error(`${this.nports}-ports network, but find ${f.length} impedances: [${f}]`)}const a=n.filter(f=>!f.startsWith("!")&&!f.startsWith("#")).map(f=>{const h=f.indexOf("!");return h!==-1?f.substring(0,h).trim():f.trim()}).join(" ").split(/\s+/).map(f=>parseFloat(f)),c=2*Math.pow(this.nports,2)+1;if(a.length%c!==0)throw new Error(`Touchstone invalid data number: ${a.length}, which should be multiple of ${c}`);const l=a.length/c;this.frequency.f_scaled=Rt(a,Lt(Tr(Ht(0,l),c))),this.matrix=new Array(t);for(let f=0;f<t;f++){this.matrix[f]=new Array(t);for(let h=0;h<t;h++)this.matrix[f][h]=new Array(l)}for(let f=0;f<t;f++)for(let h=0;h<t;h++){const D=Rt(a,Lt(wt(Tr(Ht(0,l),c),(f*t+h)*2+1))),p=Rt(a,Lt(wt(Tr(Ht(0,l),c),(f*t+h)*2+2)));for(let m=0;m<l;m++){let s;switch(this.format){case"RI":s=qt(D[m],p[m]);break;case"MA":s=qt({r:D[m],phi:p[m]/180*et});break;case"DB":s=qt({r:Jc(10,D[m]/20),phi:p[m]/180*et});break;default:throw new Error(`Unknown Touchstone format: ${this.format}`)}t===2?this.matrix[h][f][m]=s:this.matrix[f][h][m]=s}}}validate(){if(!this.nports)throw new Error("Number of ports (nports) is not defined");if(!this.frequency)throw new Error("Frequency object is not defined");if(this.frequency.f_scaled.length===0)throw new Error("Frequency points array is empty");if(!this.parameter)throw new Error("Network parameter type is not defined");if(!this.format)throw new Error("Data format (RI/MA/DB) is not defined");if(!this.matrix)throw new Error("Network parameter matrix is not defined");const r=this.frequency.f_scaled.length;if(this.matrix.length!==this.nports)throw new Error(`Touchstone matrix has ${this.matrix.length} rows, but expected ${this.nports}`);for(let t=0;t<this.nports;t++){if(this.matrix[t].length!==this.nports)throw new Error(`Touchstone matrix at row #${t} has ${this.matrix[t].length} columns, but expected ${this.nports}`);for(let n=0;n<this.nports;n++)if(this.matrix[t][n].length!==r)throw new Error(`Touchstone matrix at row #${t} column #${n} has ${this.matrix[t][n].length} points, but expected ${r}`)}}writeContent(){this.validate();const r=this.frequency.f_scaled.length,t=[];this.comments.length>0&&t.push(...this.comments.map(i=>`! ${i}`));let n=`# ${this.frequency.unit} ${this.parameter} ${this.format}`;Array.isArray(this.impedance)?n+=` R ${this.impedance.join(" ")}`:n+=` R ${this.impedance}`,t.push(n);for(let i=0;i<r;i++){const u=[this.frequency.f_scaled[i].toString()];for(let o=0;o<this.nports;o++)for(let a=0;a<this.nports;a++){const c=this.nports===2?this.matrix[a][o][i]:this.matrix[o][a][i];let l,f;switch(this.format){case"RI":l=c.re,f=c.im;break;case"MA":l=Qt(c),f=Qn(c)/et*180;break;case"DB":l=20*zc(Qt(c)),f=Qn(c)/et*180;break;default:throw new Error(`Unknown Touchstone format: ${this.format}`)}u.push(Kn(l,12).toString(),Kn(f,12).toString())}t.push(u.join(" "))}return t.push(""),t.join(`
19
+ `)}}exports.Touchstone=Xc;exports.TouchstoneFormats=Yc;exports.TouchstoneParameters=kc;