rf-touchstone 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coverage/coverage-badge.svg +4 -4
- package/development.md +49 -25
- package/dist/Touchstone.cjs.js +7 -7
- package/dist/Touchstone.es.js +238 -168
- package/dist/Touchstone.umd.js +7 -7
- package/dist/touchstone.d.ts +125 -19
- package/package.json +23 -21
- package/readme.md +16 -4
package/dist/Touchstone.umd.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(Ae,hr){typeof exports=="object"&&typeof module<"u"?hr(exports):typeof define=="function"&&define.amd?define(["exports"],hr):(Ae=typeof globalThis<"u"?globalThis:Ae||self,hr(Ae.Touchstone={}))})(this,function(Ae){"use strict";function hr(){return hr=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},hr.apply(null,arguments)}var cn={relTol:1e-12,absTol:1e-15,matrix:"Matrix",number:"number",numberFallback:"number",precision:64,predictable:!1,randomSeed:null};function ln(e,r){if(jr(e,r))return e[r];throw typeof e[r]=="function"&&uu(e,r)?new Error('Cannot access method "'+r+'" as a property'):new Error('No access to property "'+r+'"')}function hn(e,r,t){if(jr(e,r))return e[r]=t,t;throw new Error('No access to property "'+r+'"')}function jr(e,r){return!ou(e)&&!Array.isArray(e)?!1:qr(au,r)?!0:!(r in Object.prototype||r in Function.prototype)}function uu(e,r){return e==null||typeof e[r]!="function"||qr(e,r)&&Object.getPrototypeOf&&r in Object.getPrototypeOf(e)?!1:qr(su,r)?!0:!(r in Object.prototype||r in Function.prototype)}function ou(e){return typeof e=="object"&&e&&e.constructor===Object}var au={length:!0,name:!0},su={toString:!0,valueOf:!0,toLocaleString:!0};class fu{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 ln(this.wrappedObject,r)}set(r,t){return hn(this.wrappedObject,r,t),this}has(r){return jr(this.wrappedObject,r)&&r in this.wrappedObject}entries(){return cu(this.keys(),r=>[r,this.get(r)])}forEach(r){for(var t of this.keys())r(this.get(t),t,this)}delete(r){jr(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 cu(e,r){return{next:()=>{var t=e.next();return t.done?t:{value:r(t.value),done:!1}}}}function pe(e){return typeof e=="number"}function Fe(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 lu(e){return typeof e=="bigint"}function pn(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isComplex===!0||!1}function Dn(e){return e&&typeof e=="object"&&Object.getPrototypeOf(e).isFraction===!0||!1}function mn(e){return e&&e.constructor.prototype.isUnit===!0||!1}function Je(e){return typeof e=="string"}var we=Array.isArray;function De(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function et(e){return Array.isArray(e)||De(e)}function hu(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function pu(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function dn(e){return e&&e.constructor.prototype.isRange===!0||!1}function rt(e){return e&&e.constructor.prototype.isIndex===!0||!1}function Du(e){return typeof e=="boolean"}function mu(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function du(e){return e&&e.constructor.prototype.isHelp===!0||!1}function gu(e){return typeof e=="function"}function vu(e){return e instanceof Date}function wu(e){return e instanceof RegExp}function Rt(e){return!!(e&&typeof e=="object"&&e.constructor===Object&&!pn(e)&&!Dn(e))}function yu(e){return e?e instanceof Map||e instanceof fu||typeof e.set=="function"&&typeof e.get=="function"&&typeof e.keys=="function"&&typeof e.has=="function":!1}function Fu(e){return e===null}function Eu(e){return e===void 0}function Au(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function bu(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function Cu(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function _u(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function Bu(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function Nu(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function Mu(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Su(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function xu(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function Tu(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function Iu(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function zu(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ou(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function $u(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function Pu(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function Uu(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function qu(e){return e&&e.constructor.prototype.isChain===!0||!1}function ir(e){var r=typeof e;return r==="object"?e===null?"null":Fe(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(Fe(e))return e;if(Rt(e))return Ru(e,me);if(r==="function")return e;throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e,")"))}function Ru(e,r){var t={};for(var n in e)qr(e,n)&&(t[n]=r(e[n]));return t}function Lu(e,r){for(var t in r)qr(r,t)&&(e[t]=r[t]);return e}function pr(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(!pr(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)||!pr(e[t],r[t]))return!1;for(t in r)if(!(t in e))return!1;return!0}else return e===r}}function qr(e,r){return e&&Object.hasOwnProperty.call(e,r)}function Hu(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 Zu=["Matrix","Array"],Wu=["number","BigNumber","Fraction"],$e=function(r){if(r)throw new Error(`The global config is readonly.
|
|
2
2
|
Please create a mathjs instance if you want to change the default configuration.
|
|
3
3
|
Example:
|
|
4
4
|
|
|
5
5
|
import { create, all } from 'mathjs';
|
|
6
6
|
const mathjs = create(all);
|
|
7
7
|
mathjs.config({ number: 'BigNumber' });
|
|
8
|
-
`);return Object.freeze(an)};hr(Oe,an,{MATRIX_OPTIONS:Ru,NUMBER_OPTIONS:Lu});function Dn(){return!0}function Ge(){return!1}function Cr(){}const mn="Argument is not a typed-function.";function dn(){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:Dn,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 z=0;z<F.length;++z){if(!F[z]||typeof F[z].name!="string"||typeof F[z].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const H=F[z].name;if(n.has(H))throw new TypeError('Duplicate type name "'+H+'"');T.push(H),n.set(H,{name:H,test:F[z].test,isAny:F[z].isAny,index:N+z,conversionsTo:[]})}const $=i.slice(N);i=i.slice(0,N).concat(T).concat($);for(let z=N+T.length;z<i.length;++z)n.get(i[z]).index=z}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(mn);const T=N&&N.exact,$=Array.isArray(_)?_.join(","):_,z=A($),H=d(z);if(!T||H in F.signatures){const se=F._typedFunctionData.signatureMap.get(H);if(se)return se}const U=z.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 ve=z[se],Be=[];let We;for(We of Z){const Re=b(We.params,se);if(!(!Re||ve.restParam&&!Re.restParam)){if(!Re.hasAny){const rr=v(Re);if(ve.types.some(tr=>!rr.has(tr.name)))continue}Be.push(We)}}if(Z=Be,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(z,", ")+"))")}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,z=_?"...":"";return{types:T.map(function(U){return $=U.isAny||$,z+=U.name+"|",{name:U.name,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:null,conversionIndex:-1}}),name:z.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 z=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(z),name:$,hasAny:T,hasConversion:z.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 z=g(T[$].trim());if(z.restParam&&$!==T.length-1)throw new SyntaxError('Unexpected rest parameter "'+T[$]+'": only allowed for the last parameter');if(z.types.length===0)return null;_.push(z)}return _}function y(F){const _=le(F);return _?_.restParam:!1}function w(F){if(!F||F.types.length===0)return Dn;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,z=w(le(F)),H=function(U){for(let Z=$;Z<U.length;Z++)if(!z(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(z){return z.length===0}:F.length===1?(N=w(F[0]),function(z){return N(z[0])&&z.length===1}):F.length===2?(N=w(F[0]),T=w(F[1]),function(z){return N(z[0])&&T(z[1])&&z.length===2}):(_=F.map(w),function(z){for(let H=0;H<_.length;H++)if(!_[H](z[H]))return!1;return z.length===_.length})}function b(F,_){return _<F.length?F[_]:y(F)?le(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 x(F,_){const N=new Set;return F.forEach(T=>{const $=B(T.params,_);let z;for(z of $)N.add(z)}),N.has("any")?["any"]:Array.from(N)}function R(F,_,N){let T,$;const z=F||"unnamed";let H=N,U;for(U=0;U<_.length;U++){const ve=[];if(H.forEach(Be=>{const We=b(Be.params,U),Re=w(We);(U<Be.params.length||y(Be.params))&&Re(_[U])&&ve.push(Be)}),ve.length===0){if($=x(H,U),$.length>0){const Be=h(_[U]);return T=new TypeError("Unexpected type of argument in function "+z+" (expected: "+$.join(" or ")+", actual: "+Be.join(" | ")+", index: "+U+")"),T.data={category:"wrongType",fn:z,index:U,actual:Be,expected:$},T}}else H=ve}const Z=H.map(function(ve){return y(ve.params)?1/0:ve.params.length});if(_.length<Math.min.apply(null,Z))return $=x(H,U),T=new TypeError("Too few arguments in function "+z+" (expected: "+$.join(" or ")+", index: "+_.length+")"),T.data={category:"tooFewArgs",fn:z,index:_.length,expected:$},T;const P=Math.max.apply(null,Z);if(_.length>P)return T=new TypeError("Too many arguments in function "+z+" (expected: "+P+", actual: "+_.length+")"),T.data={category:"tooManyArgs",fn:z,index:_.length,expectedLength:P},T;const se=[];for(let ve=0;ve<_.length;++ve)se.push(h(_[ve]).join("|"));return T=new TypeError('Arguments of type "'+se.join(", ")+'" do not match any of the defined signatures of function '+z+"."),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,$=le(N),z=le(T),H=y(N),U=y(T);if(H&&$.hasAny){if(!U||!z.hasAny)return 1}else if(U&&z.hasAny)return-1;let Z=0,P=0,se;for(se of N)se.hasAny&&++Z,se.hasConversion&&++P;let ve=0,Be=0;for(se of T)se.hasAny&&++ve,se.hasConversion&&++Be;if(Z!==ve)return Z-ve;if(H&&$.hasConversion){if(!U||!z.hasConversion)return 1}else if(U&&z.hasConversion)return-1;if(P!==Be)return P-Be;if(H){if(!U)return 1}else if(U)return-1;const We=(N.length-T.length)*(H?-1:1);if(We!==0)return We;const Re=[];let rr=0;for(let Ur=0;Ur<N.length;++Ur){const It=W(N[Ur],T[Ur]);Re.push(It),rr+=It}if(rr!==0)return rr;let tr;for(tr of Re)if(tr!==0)return tr;return 0}function Q(F){if(F.length===0)return[];const _=F.map(a);F.length>1&&_.sort(($,z)=>$.index-z.index);let N=_[0].conversionsTo;if(F.length===1)return N;N=N.concat([]);const T=new Set(F);for(let $=1;$<_.length;++$){let z;for(z of _[$].conversionsTo)T.has(z.from)||(N.push(z),T.add(z.from))}return N}function X(F,_){let N=_;if(F.some($=>$.hasConversion)){const $=y(F),z=F.map(G);N=function(){const U=[],Z=$?arguments.length-1:arguments.length;for(let P=0;P<Z;P++)U[P]=z[P](arguments[P]);return $&&(U[Z]=arguments[Z].map(z[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 z=[],H=[];switch(F.types.forEach(function(U){U.conversion&&(z.push(a(U.conversion.from).test),H.push(U.conversion.convert))}),H.length){case 0:return function(Z){return Z};case 1:return _=z[0],T=H[0],function(Z){return _(Z)?T(Z):Z};case 2:return _=z[0],N=z[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(z[P](Z))return H[P](Z);return Z}}}function ee(F){function _(N,T,$){if(T<N.length){const z=N[T];let H=[];if(z.restParam){const U=z.types.filter(M);U.length<z.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(z)}else H=z.types.map(function(U){return{types:[U],name:U.name,hasAny:U.isAny,hasConversion:U.conversion,restParam:!1}});return ze(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,ve;for(ve of P)if(Z.has(ve)){se=!0;break}if(!se)return!1}const T=F.length,$=_.length,z=y(F),H=y(_);return z?H?T===$:$>=T:H?T>=$:T===$}function ie(F){return F.map(_=>cr(_)?Qe(_.referToSelf.callback):fr(_)?xe(_.referTo.references,_.referTo.callback):_)}function ce(F,_,N){const T=[];let $;for($ of F){let z=N[$];if(typeof z!="number")throw new TypeError('No definition for referenced signature "'+$+'"');if(z=_[z],typeof z!="function")return!1;T.push(z)}return T}function _e(F,_,N){const T=ie(F),$=new Array(T.length).fill(!1);let z=!0;for(;z;){z=!1;let H=!0;for(let U=0;U<T.length;++U){if($[U])continue;const Z=T[U];if(cr(Z))T[U]=Z.referToSelf.callback(N),T[U].referToSelf=Z.referToSelf,$[U]=!0,H=!1;else if(fr(Z)){const P=ce(Z.referTo.references,T,_);P?(T[U]=Z.referTo.callback.apply(this,P),T[U].referTo=Z.referTo,$[U]=!0,H=!1):z=!0}}if(H&&z)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=[],$={},z=[];let H;for(H in _){if(!Object.prototype.hasOwnProperty.call(_,H))continue;const ue=A(H);if(!ue)continue;N.forEach(function(Xr){if(oe(Xr,ue))throw new TypeError('Conflicting signatures "'+d(Xr)+'" and "'+d(ue)+'".')}),N.push(ue);const Ve=T.length;T.push(_[H]);const Xc=ue.map(E);let zt;for(zt of ee(Xc)){const Xr=d(zt);z.push({params:zt,name:Xr,fn:Ve}),zt.every(Qc=>!Qc.hasConversion)&&($[Xr]=Ve)}}z.sort(O);const U=_e(T,$,kr);let Z;for(Z in $)Object.prototype.hasOwnProperty.call($,Z)&&($[Z]=U[$[Z]]);const P=[],se=new Map;for(Z of z)se.has(Z.name)||(Z.fn=U[Z.fn],P.push(Z),se.set(Z.name,Z));const ve=P[0]&&P[0].params.length<=2&&!y(P[0].params),Be=P[1]&&P[1].params.length<=2&&!y(P[1].params),We=P[2]&&P[2].params.length<=2&&!y(P[2].params),Re=P[3]&&P[3].params.length<=2&&!y(P[3].params),rr=P[4]&&P[4].params.length<=2&&!y(P[4].params),tr=P[5]&&P[5].params.length<=2&&!y(P[5].params),Ur=ve&&Be&&We&&Re&&rr&&tr;for(let ue=0;ue<P.length;++ue)P[ue].test=C(P[ue].params);const It=ve?w(P[0].params[0]):Ge,Ec=Be?w(P[1].params[0]):Ge,Ac=We?w(P[2].params[0]):Ge,bc=Re?w(P[3].params[0]):Ge,Cc=rr?w(P[4].params[0]):Ge,_c=tr?w(P[5].params[0]):Ge,Bc=ve?w(P[0].params[1]):Ge,Nc=Be?w(P[1].params[1]):Ge,Mc=We?w(P[2].params[1]):Ge,Sc=Re?w(P[3].params[1]):Ge,xc=rr?w(P[4].params[1]):Ge,Tc=tr?w(P[5].params[1]):Ge;for(let ue=0;ue<P.length;++ue)P[ue].implementation=X(P[ue].params,P[ue].fn);const Ic=ve?P[0].implementation:Cr,zc=Be?P[1].implementation:Cr,Oc=We?P[2].implementation:Cr,$c=Re?P[3].implementation:Cr,Pc=rr?P[4].implementation:Cr,Uc=tr?P[5].implementation:Cr,qc=ve?P[0].params.length:-1,Rc=Be?P[1].params.length:-1,Lc=We?P[2].params.length:-1,Hc=Re?P[3].params.length:-1,Zc=rr?P[4].params.length:-1,Wc=tr?P[5].params.length:-1,Vc=Ur?6:0,Jc=P.length,Gc=P.map(ue=>ue.test),Yc=P.map(ue=>ue.implementation),kc=function(){for(let Ve=Vc;Ve<Jc;Ve++)if(Gc[Ve](arguments))return Yc[Ve].apply(this,arguments);return o.onMismatch(F,arguments,P)};function kr(ue,Ve){return arguments.length===qc&&It(ue)&&Bc(Ve)?Ic.apply(this,arguments):arguments.length===Rc&&Ec(ue)&&Nc(Ve)?zc.apply(this,arguments):arguments.length===Lc&&Ac(ue)&&Mc(Ve)?Oc.apply(this,arguments):arguments.length===Hc&&bc(ue)&&Sc(Ve)?$c.apply(this,arguments):arguments.length===Zc&&Cc(ue)&&xc(Ve)?Pc.apply(this,arguments):arguments.length===Wc&&_c(ue)&&Tc(Ve)?Uc.apply(this,arguments):kc.apply(this,arguments)}try{Object.defineProperty(kr,"name",{value:F})}catch{}return kr.signatures=$,kr._typedFunctionData={signatures:P,signatureMap:se},kr}function ye(F,_,N){throw R(F,_,N)}function qe(F){return ae(F,0,F.length-1)}function le(F){return F[F.length-1]}function ae(F,_,N){return Array.prototype.slice.call(F,_,N)}function Xe(F,_){for(let N=0;N<F.length;N++)if(_(F[N]))return F[N]}function ze(F,_){return Array.prototype.concat.apply([],F.map(_))}function he(){const F=qe(arguments).map(N=>d(A(N))),_=le(arguments);if(typeof _!="function")throw new TypeError("Callback function expected as last argument");return xe(F,_)}function xe(F,_){return{referTo:{references:F,callback:_}}}function Qe(F){if(typeof F!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:F}}}function fr(F){return F&&typeof F.referTo=="object"&&Array.isArray(F.referTo.references)&&typeof F.referTo.callback=="function"}function cr(F){return F&&typeof F.referToSelf=="object"&&typeof F.referToSelf.callback=="function"}function $r(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 Pr(F){let _;for(const N in F)Object.prototype.hasOwnProperty.call(F,N)&&(D(F[N])||typeof F[N].signature=="string")&&(_=$r(_,F[N].name));return _}function on(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 Fc=o;o=function(F){const _=typeof F=="string",N=_?1:0;let T=_?F:"";const $={};for(let z=N;z<arguments.length;++z){const H=arguments[z];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=Pr(H))),Object.keys(U).length===0){const P=new TypeError("Argument to 'typed' at index "+z+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw P.data={index:z,argument:H},P}_||(T=$r(T,Z)),on($,U)}return Ae(T||"",$)},o.create=dn,o.createCount=Fc.createCount,o.onMismatch=ye,o.throwMismatchError=ye,o.createError=R,o.clear=l,o.clearConversions=f,o.addTypes=c,o._findType=a,o.referTo=he,o.referToSelf=Qe,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 ru(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};ru(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){ru(F);const _=a(F.to),N=Xe(_.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(mn);const N=F._typedFunctionData.signatures;for(let T=0;T<N.length;++T)if(N[T].test(_))return N[T];return null},o}const et=dn();function J(e,r,t,n){function i(u){var o=qu(u,r.map(Wu));return Hu(e,r,u),t(o)}return i.isFactory=!0,i.fn=e,i.dependencies=r.slice().sort(),n&&(i.meta=n),i}function Hu(e,r,t){var n=r.filter(u=>!Zu(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 Zu(e){return e&&e[0]==="?"}function Wu(e){return e&&e[0]==="?"?e.slice(1):e}function de(e){return typeof e=="boolean"?!0:isFinite(e)?e===Math.round(e):!1}var Vu=Math.log10||function(r){return Math.log(r)/Math.LN10};function $t(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(!de(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(!de(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 Pt(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}=gn(r);switch(t){case"fixed":return vn(e,n);case"exponential":return wn(e,n);case"engineering":return Ju(e,n);case"bin":return $t(e,2,i);case"oct":return $t(e,8,i);case"hex":return $t(e,16,i);case"auto":return Gu(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 gn(e){var r="auto",t,n;if(e!==void 0)if(pe(e))t=e;else if(Fe(e))t=e.toNumber();else if(Ot(e))e.precision!==void 0&&(t=yn(e.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),e.wordSize!==void 0&&(n=yn(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 Rr(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 Ju(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Rr(e),n=rt(t,r),i=n.exponent,u=n.coefficients,o=i%3===0?i:i<0?i-3-i%3:i-i%3;if(pe(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=pe(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 vn(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Rr(e),n=typeof r=="number"?rt(t,t.exponent+1+r):t,i=n.coefficients,u=n.exponent+1,o=u+(r||0);return i.length<o&&(i=i.concat(_r(o-i.length))),u<0&&(i=_r(-u+1).concat(i),u=1),u<i.length&&i.splice(u,0,u===0?"0.":"."),n.sign+i.join("")}function wn(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Rr(e),n=r?rt(t,r):t,i=n.coefficients,u=n.exponent;i.length<r&&(i=i.concat(_r(r-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(u>=0?"+":"")+u}function Gu(e,r,t){if(isNaN(e)||!isFinite(e))return String(e);var n=Fn(t?.lowerExp,-3),i=Fn(t?.upperExp,5),u=Rr(e),o=r?rt(u,r):u;if(o.exponent<n||o.exponent>=i)return wn(e,r);var a=o.coefficients,c=o.exponent;a.length<r&&(a=a.concat(_r(r-a.length))),a=a.concat(_r(c-a.length+1+(a.length<r?r-a.length:0))),a=_r(-c).concat(a);var l=c>0?c:0;return l<a.length-1&&a.splice(l+1,0,"."),o.sign+a.join("")}function rt(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 _r(e){for(var r=[],t=0;t<e;t++)r.push(0);return r}function Yu(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}function Ke(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 yn(e,r){if(pe(e))return e;if(Fe(e))return e.toNumber();r()}function Fn(e,r){return pe(e)?e:Fe(e)?e.toNumber():r}var En=function(){return En=et.create,et},ku=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],Xu=J("typed",ku,function(r){var{BigNumber:t,Complex:n,DenseMatrix:i,Fraction:u}=r,o=En();return o.clear(),o.addTypes([{name:"number",test:pe},{name:"Complex",test:cn},{name:"BigNumber",test:Fe},{name:"bigint",test:su},{name:"Fraction",test:ln},{name:"Unit",test:hn},{name:"identifier",test:a=>Je&&/^(?:[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:Je},{name:"Chain",test:$u},{name:"Array",test:we},{name:"Matrix",test:De},{name:"DenseMatrix",test:fu},{name:"SparseMatrix",test:cu},{name:"Range",test:pn},{name:"Index",test:jr},{name:"boolean",test:lu},{name:"ResultSet",test:hu},{name:"Help",test:pu},{name:"function",test:Du},{name:"Date",test:mu},{name:"RegExp",test:du},{name:"null",test:vu},{name:"undefined",test:wu},{name:"AccessorNode",test:yu},{name:"ArrayNode",test:Fu},{name:"AssignmentNode",test:Eu},{name:"BlockNode",test:Au},{name:"ConditionalNode",test:bu},{name:"ConstantNode",test:Cu},{name:"FunctionNode",test:Bu},{name:"FunctionAssignmentNode",test:_u},{name:"IndexNode",test:Nu},{name:"Node",test:Mu},{name:"ObjectNode",test:Su},{name:"OperatorNode",test:xu},{name:"ParenthesisNode",test:Tu},{name:"RangeNode",test:Iu},{name:"RelationalNode",test:zu},{name:"SymbolNode",test:Ou},{name:"Map",test:gu},{name:"Object",test:Ot}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(t||tt(c),Yu(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||nt(c),new n(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return n||nt(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||tt(c),new t(c.toString())}},{from:"bigint",to:"Fraction",convert:function(c){return u||it(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||nt(c),new n(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){u||it(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||tt(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||it(c);try{return new u(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){n||nt(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||tt(c),new t(+c)}},{from:"boolean",to:"bigint",convert:function(c){return BigInt(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return u||it(c),new u(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return i||Qu(),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&&Kr(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&&Kr(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 tt(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function nt(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function Qu(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function it(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}/*!
|
|
8
|
+
`);return Object.freeze(cn)};hr($e,cn,{MATRIX_OPTIONS:Zu,NUMBER_OPTIONS:Wu});function gn(){return!0}function Ye(){return!1}function _r(){}const vn="Argument is not a typed-function.";function wn(){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:gn,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 z=0;z<F.length;++z){if(!F[z]||typeof F[z].name!="string"||typeof F[z].test!="function")throw new TypeError("Object with properties {name: string, test: function} expected");const H=F[z].name;if(n.has(H))throw new TypeError('Duplicate type name "'+H+'"');T.push(H),n.set(H,{name:H,test:F[z].test,isAny:F[z].isAny,index:N+z,conversionsTo:[]})}const $=i.slice(N);i=i.slice(0,N).concat(T).concat($);for(let z=N+T.length;z<i.length;++z)n.get(i[z]).index=z}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(vn);const T=N&&N.exact,$=Array.isArray(_)?_.join(","):_,z=A($),H=d(z);if(!T||H in F.signatures){const se=F._typedFunctionData.signatureMap.get(H);if(se)return se}const U=z.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 ve=z[se],Ne=[];let Ve;for(Ve of Z){const Le=b(Ve.params,se);if(!(!Le||ve.restParam&&!Le.restParam)){if(!Le.hasAny){const tr=v(Le);if(ve.types.some(nr=>!tr.has(nr.name)))continue}Ne.push(Ve)}}if(Z=Ne,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(z,", ")+"))")}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,z=_?"...":"";return{types:T.map(function(U){return $=U.isAny||$,z+=U.name+"|",{name:U.name,typeIndex:U.index,test:U.test,isAny:U.isAny,conversion:null,conversionIndex:-1}}),name:z.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 z=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(z),name:$,hasAny:T,hasConversion:z.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 z=g(T[$].trim());if(z.restParam&&$!==T.length-1)throw new SyntaxError('Unexpected rest parameter "'+T[$]+'": only allowed for the last parameter');if(z.types.length===0)return null;_.push(z)}return _}function y(F){const _=le(F);return _?_.restParam:!1}function w(F){if(!F||F.types.length===0)return gn;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)){_=Re(F).map(w);const $=_.length,z=w(le(F)),H=function(U){for(let Z=$;Z<U.length;Z++)if(!z(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(z){return z.length===0}:F.length===1?(N=w(F[0]),function(z){return N(z[0])&&z.length===1}):F.length===2?(N=w(F[0]),T=w(F[1]),function(z){return N(z[0])&&T(z[1])&&z.length===2}):(_=F.map(w),function(z){for(let H=0;H<_.length;H++)if(!_[H](z[H]))return!1;return z.length===_.length})}function b(F,_){return _<F.length?F[_]:y(F)?le(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 x(F,_){const N=new Set;return F.forEach(T=>{const $=B(T.params,_);let z;for(z of $)N.add(z)}),N.has("any")?["any"]:Array.from(N)}function R(F,_,N){let T,$;const z=F||"unnamed";let H=N,U;for(U=0;U<_.length;U++){const ve=[];if(H.forEach(Ne=>{const Ve=b(Ne.params,U),Le=w(Ve);(U<Ne.params.length||y(Ne.params))&&Le(_[U])&&ve.push(Ne)}),ve.length===0){if($=x(H,U),$.length>0){const Ne=h(_[U]);return T=new TypeError("Unexpected type of argument in function "+z+" (expected: "+$.join(" or ")+", actual: "+Ne.join(" | ")+", index: "+U+")"),T.data={category:"wrongType",fn:z,index:U,actual:Ne,expected:$},T}}else H=ve}const Z=H.map(function(ve){return y(ve.params)?1/0:ve.params.length});if(_.length<Math.min.apply(null,Z))return $=x(H,U),T=new TypeError("Too few arguments in function "+z+" (expected: "+$.join(" or ")+", index: "+_.length+")"),T.data={category:"tooFewArgs",fn:z,index:_.length,expected:$},T;const P=Math.max.apply(null,Z);if(_.length>P)return T=new TypeError("Too many arguments in function "+z+" (expected: "+P+", actual: "+_.length+")"),T.data={category:"tooManyArgs",fn:z,index:_.length,expectedLength:P},T;const se=[];for(let ve=0;ve<_.length;++ve)se.push(h(_[ve]).join("|"));return T=new TypeError('Arguments of type "'+se.join(", ")+'" do not match any of the defined signatures of function '+z+"."),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,$=le(N),z=le(T),H=y(N),U=y(T);if(H&&$.hasAny){if(!U||!z.hasAny)return 1}else if(U&&z.hasAny)return-1;let Z=0,P=0,se;for(se of N)se.hasAny&&++Z,se.hasConversion&&++P;let ve=0,Ne=0;for(se of T)se.hasAny&&++ve,se.hasConversion&&++Ne;if(Z!==ve)return Z-ve;if(H&&$.hasConversion){if(!U||!z.hasConversion)return 1}else if(U&&z.hasConversion)return-1;if(P!==Ne)return P-Ne;if(H){if(!U)return 1}else if(U)return-1;const Ve=(N.length-T.length)*(H?-1:1);if(Ve!==0)return Ve;const Le=[];let tr=0;for(let Ur=0;Ur<N.length;++Ur){const Ut=W(N[Ur],T[Ur]);Le.push(Ut),tr+=Ut}if(tr!==0)return tr;let nr;for(nr of Le)if(nr!==0)return nr;return 0}function Q(F){if(F.length===0)return[];const _=F.map(a);F.length>1&&_.sort(($,z)=>$.index-z.index);let N=_[0].conversionsTo;if(F.length===1)return N;N=N.concat([]);const T=new Set(F);for(let $=1;$<_.length;++$){let z;for(z of _[$].conversionsTo)T.has(z.from)||(N.push(z),T.add(z.from))}return N}function X(F,_){let N=_;if(F.some($=>$.hasConversion)){const $=y(F),z=F.map(J);N=function(){const U=[],Z=$?arguments.length-1:arguments.length;for(let P=0;P<Z;P++)U[P]=z[P](arguments[P]);return $&&(U[Z]=arguments[Z].map(z[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 J(F){let _,N,T,$;const z=[],H=[];switch(F.types.forEach(function(U){U.conversion&&(z.push(a(U.conversion.from).test),H.push(U.conversion.convert))}),H.length){case 0:return function(Z){return Z};case 1:return _=z[0],T=H[0],function(Z){return _(Z)?T(Z):Z};case 2:return _=z[0],N=z[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(z[P](Z))return H[P](Z);return Z}}}function ee(F){function _(N,T,$){if(T<N.length){const z=N[T];let H=[];if(z.restParam){const U=z.types.filter(M);U.length<z.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(z)}else H=z.types.map(function(U){return{types:[U],name:U.name,hasAny:U.isAny,hasConversion:U.conversion,restParam:!1}});return Oe(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,ve;for(ve of P)if(Z.has(ve)){se=!0;break}if(!se)return!1}const T=F.length,$=_.length,z=y(F),H=y(_);return z?H?T===$:$>=T:H?T>=$:T===$}function ie(F){return F.map(_=>lr(_)?Ke(_.referToSelf.callback):cr(_)?Te(_.referTo.references,_.referTo.callback):_)}function ce(F,_,N){const T=[];let $;for($ of F){let z=N[$];if(typeof z!="number")throw new TypeError('No definition for referenced signature "'+$+'"');if(z=_[z],typeof z!="function")return!1;T.push(z)}return T}function Be(F,_,N){const T=ie(F),$=new Array(T.length).fill(!1);let z=!0;for(;z;){z=!1;let H=!0;for(let U=0;U<T.length;++U){if($[U])continue;const Z=T[U];if(lr(Z))T[U]=Z.referToSelf.callback(N),T[U].referToSelf=Z.referToSelf,$[U]=!0,H=!1;else if(cr(Z)){const P=ce(Z.referTo.references,T,_);P?(T[U]=Z.referTo.callback.apply(this,P),T[U].referTo=Z.referTo,$[U]=!0,H=!1):z=!0}}if(H&&z)throw new SyntaxError("Circular reference detected in resolving typed.referTo")}return T}function Ce(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 be(F,_){if(o.createCount++,Object.keys(_).length===0)throw new SyntaxError("No signatures provided");o.warnAgainstDeprecatedThis&&Ce(_);const N=[],T=[],$={},z=[];let H;for(H in _){if(!Object.prototype.hasOwnProperty.call(_,H))continue;const ue=A(H);if(!ue)continue;N.forEach(function(Kr){if(oe(Kr,ue))throw new TypeError('Conflicting signatures "'+d(Kr)+'" and "'+d(ue)+'".')}),N.push(ue);const Ge=T.length;T.push(_[H]);const Qc=ue.map(E);let qt;for(qt of ee(Qc)){const Kr=d(qt);z.push({params:qt,name:Kr,fn:Ge}),qt.every(Kc=>!Kc.hasConversion)&&($[Kr]=Ge)}}z.sort(O);const U=Be(T,$,Qr);let Z;for(Z in $)Object.prototype.hasOwnProperty.call($,Z)&&($[Z]=U[$[Z]]);const P=[],se=new Map;for(Z of z)se.has(Z.name)||(Z.fn=U[Z.fn],P.push(Z),se.set(Z.name,Z));const ve=P[0]&&P[0].params.length<=2&&!y(P[0].params),Ne=P[1]&&P[1].params.length<=2&&!y(P[1].params),Ve=P[2]&&P[2].params.length<=2&&!y(P[2].params),Le=P[3]&&P[3].params.length<=2&&!y(P[3].params),tr=P[4]&&P[4].params.length<=2&&!y(P[4].params),nr=P[5]&&P[5].params.length<=2&&!y(P[5].params),Ur=ve&&Ne&&Ve&&Le&&tr&&nr;for(let ue=0;ue<P.length;++ue)P[ue].test=C(P[ue].params);const Ut=ve?w(P[0].params[0]):Ye,Ac=Ne?w(P[1].params[0]):Ye,bc=Ve?w(P[2].params[0]):Ye,Cc=Le?w(P[3].params[0]):Ye,_c=tr?w(P[4].params[0]):Ye,Bc=nr?w(P[5].params[0]):Ye,Nc=ve?w(P[0].params[1]):Ye,Mc=Ne?w(P[1].params[1]):Ye,Sc=Ve?w(P[2].params[1]):Ye,xc=Le?w(P[3].params[1]):Ye,Tc=tr?w(P[4].params[1]):Ye,Ic=nr?w(P[5].params[1]):Ye;for(let ue=0;ue<P.length;++ue)P[ue].implementation=X(P[ue].params,P[ue].fn);const zc=ve?P[0].implementation:_r,Oc=Ne?P[1].implementation:_r,$c=Ve?P[2].implementation:_r,Pc=Le?P[3].implementation:_r,Uc=tr?P[4].implementation:_r,qc=nr?P[5].implementation:_r,Rc=ve?P[0].params.length:-1,Lc=Ne?P[1].params.length:-1,Hc=Ve?P[2].params.length:-1,Zc=Le?P[3].params.length:-1,Wc=tr?P[4].params.length:-1,Vc=nr?P[5].params.length:-1,Gc=Ur?6:0,Jc=P.length,Yc=P.map(ue=>ue.test),kc=P.map(ue=>ue.implementation),Xc=function(){for(let Ge=Gc;Ge<Jc;Ge++)if(Yc[Ge](arguments))return kc[Ge].apply(this,arguments);return o.onMismatch(F,arguments,P)};function Qr(ue,Ge){return arguments.length===Rc&&Ut(ue)&&Nc(Ge)?zc.apply(this,arguments):arguments.length===Lc&&Ac(ue)&&Mc(Ge)?Oc.apply(this,arguments):arguments.length===Hc&&bc(ue)&&Sc(Ge)?$c.apply(this,arguments):arguments.length===Zc&&Cc(ue)&&xc(Ge)?Pc.apply(this,arguments):arguments.length===Wc&&_c(ue)&&Tc(Ge)?Uc.apply(this,arguments):arguments.length===Vc&&Bc(ue)&&Ic(Ge)?qc.apply(this,arguments):Xc.apply(this,arguments)}try{Object.defineProperty(Qr,"name",{value:F})}catch{}return Qr.signatures=$,Qr._typedFunctionData={signatures:P,signatureMap:se},Qr}function ye(F,_,N){throw R(F,_,N)}function Re(F){return ae(F,0,F.length-1)}function le(F){return F[F.length-1]}function ae(F,_,N){return Array.prototype.slice.call(F,_,N)}function Qe(F,_){for(let N=0;N<F.length;N++)if(_(F[N]))return F[N]}function Oe(F,_){return Array.prototype.concat.apply([],F.map(_))}function he(){const F=Re(arguments).map(N=>d(A(N))),_=le(arguments);if(typeof _!="function")throw new TypeError("Callback function expected as last argument");return Te(F,_)}function Te(F,_){return{referTo:{references:F,callback:_}}}function Ke(F){if(typeof F!="function")throw new TypeError("Callback function expected as first argument");return{referToSelf:{callback:F}}}function cr(F){return F&&typeof F.referTo=="object"&&Array.isArray(F.referTo.references)&&typeof F.referTo.callback=="function"}function lr(F){return F&&typeof F.referToSelf=="object"&&typeof F.referToSelf.callback=="function"}function $r(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 Pr(F){let _;for(const N in F)Object.prototype.hasOwnProperty.call(F,N)&&(D(F[N])||typeof F[N].signature=="string")&&(_=$r(_,F[N].name));return _}function fn(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 Ec=o;o=function(F){const _=typeof F=="string",N=_?1:0;let T=_?F:"";const $={};for(let z=N;z<arguments.length;++z){const H=arguments[z];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=Pr(H))),Object.keys(U).length===0){const P=new TypeError("Argument to 'typed' at index "+z+" is not a (typed) function, nor an object with signatures as keys and functions as values.");throw P.data={index:z,argument:H},P}_||(T=$r(T,Z)),fn($,U)}return be(T||"",$)},o.create=wn,o.createCount=Ec.createCount,o.onMismatch=ye,o.throwMismatchError=ye,o.createError=R,o.clear=l,o.clearConversions=f,o.addTypes=c,o._findType=a,o.referTo=he,o.referToSelf=Ke,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 iu(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};iu(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){iu(F);const _=a(F.to),N=Qe(_.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(vn);const N=F._typedFunctionData.signatures;for(let T=0;T<N.length;++T)if(N[T].test(_))return N[T];return null},o}const tt=wn();function G(e,r,t,n){function i(u){var o=Hu(u,r.map(Ju));return Vu(e,r,u),t(o)}return i.isFactory=!0,i.fn=e,i.dependencies=r.slice().sort(),n&&(i.meta=n),i}function Vu(e,r,t){var n=r.filter(u=>!Gu(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 Gu(e){return e&&e[0]==="?"}function Ju(e){return e&&e[0]==="?"?e.slice(1):e}function de(e){return typeof e=="boolean"?!0:isFinite(e)?e===Math.round(e):!1}var Yu=Math.log10||function(r){return Math.log(r)/Math.LN10};function Lt(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(!de(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(!de(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 Ht(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}=yn(r);switch(t){case"fixed":return Fn(e,n);case"exponential":return En(e,n);case"engineering":return ku(e,n);case"bin":return Lt(e,2,i);case"oct":return Lt(e,8,i);case"hex":return Lt(e,16,i);case"auto":return Xu(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 yn(e){var r="auto",t,n;if(e!==void 0)if(pe(e))t=e;else if(Fe(e))t=e.toNumber();else if(Rt(e))e.precision!==void 0&&(t=An(e.precision,()=>{throw new Error('Option "precision" must be a number or BigNumber')})),e.wordSize!==void 0&&(n=An(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 Rr(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 ku(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Rr(e),n=nt(t,r),i=n.exponent,u=n.coefficients,o=i%3===0?i:i<0?i-3-i%3:i-i%3;if(pe(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=pe(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 Fn(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Rr(e),n=typeof r=="number"?nt(t,t.exponent+1+r):t,i=n.coefficients,u=n.exponent+1,o=u+(r||0);return i.length<o&&(i=i.concat(Br(o-i.length))),u<0&&(i=Br(-u+1).concat(i),u=1),u<i.length&&i.splice(u,0,u===0?"0.":"."),n.sign+i.join("")}function En(e,r){if(isNaN(e)||!isFinite(e))return String(e);var t=Rr(e),n=r?nt(t,r):t,i=n.coefficients,u=n.exponent;i.length<r&&(i=i.concat(Br(r-i.length)));var o=i.shift();return n.sign+o+(i.length>0?"."+i.join(""):"")+"e"+(u>=0?"+":"")+u}function Xu(e,r,t){if(isNaN(e)||!isFinite(e))return String(e);var n=bn(t?.lowerExp,-3),i=bn(t?.upperExp,5),u=Rr(e),o=r?nt(u,r):u;if(o.exponent<n||o.exponent>=i)return En(e,r);var a=o.coefficients,c=o.exponent;a.length<r&&(a=a.concat(Br(r-a.length))),a=a.concat(Br(c-a.length+1+(a.length<r?r-a.length:0))),a=Br(-c).concat(a);var l=c>0?c:0;return l<a.length-1&&a.splice(l+1,0,"."),o.sign+a.join("")}function nt(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 Br(e){for(var r=[],t=0;t<e;t++)r.push(0);return r}function Qu(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}function je(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 An(e,r){if(pe(e))return e;if(Fe(e))return e.toNumber();r()}function bn(e,r){return pe(e)?e:Fe(e)?e.toNumber():r}var Cn=function(){return Cn=tt.create,tt},Ku=["?BigNumber","?Complex","?DenseMatrix","?Fraction"],ju=G("typed",Ku,function(r){var{BigNumber:t,Complex:n,DenseMatrix:i,Fraction:u}=r,o=Cn();return o.clear(),o.addTypes([{name:"number",test:pe},{name:"Complex",test:pn},{name:"BigNumber",test:Fe},{name:"bigint",test:lu},{name:"Fraction",test:Dn},{name:"Unit",test:mn},{name:"identifier",test:a=>Je&&/^(?:[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:Je},{name:"Chain",test:qu},{name:"Array",test:we},{name:"Matrix",test:De},{name:"DenseMatrix",test:hu},{name:"SparseMatrix",test:pu},{name:"Range",test:dn},{name:"Index",test:rt},{name:"boolean",test:Du},{name:"ResultSet",test:mu},{name:"Help",test:du},{name:"function",test:gu},{name:"Date",test:vu},{name:"RegExp",test:wu},{name:"null",test:Fu},{name:"undefined",test:Eu},{name:"AccessorNode",test:Au},{name:"ArrayNode",test:bu},{name:"AssignmentNode",test:Cu},{name:"BlockNode",test:_u},{name:"ConditionalNode",test:Bu},{name:"ConstantNode",test:Nu},{name:"FunctionNode",test:Su},{name:"FunctionAssignmentNode",test:Mu},{name:"IndexNode",test:xu},{name:"Node",test:Tu},{name:"ObjectNode",test:Iu},{name:"OperatorNode",test:zu},{name:"ParenthesisNode",test:Ou},{name:"RangeNode",test:$u},{name:"RelationalNode",test:Pu},{name:"SymbolNode",test:Uu},{name:"Map",test:yu},{name:"Object",test:Rt}]),o.addConversions([{from:"number",to:"BigNumber",convert:function(c){if(t||it(c),Qu(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||ut(c),new n(c,0)}},{from:"BigNumber",to:"Complex",convert:function(c){return n||ut(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||it(c),new t(c.toString())}},{from:"bigint",to:"Fraction",convert:function(c){return u||ot(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||ut(c),new n(c.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(c){u||ot(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||it(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||ot(c);try{return new u(c)}catch{throw new Error('Cannot convert "'+c+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(c){n||ut(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||it(c),new t(+c)}},{from:"boolean",to:"bigint",convert:function(c){return BigInt(+c)}},{from:"boolean",to:"Fraction",convert:function(c){return u||ot(c),new u(+c)}},{from:"boolean",to:"string",convert:function(c){return String(c)}},{from:"Array",to:"Matrix",convert:function(c){return i||eo(),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&&et(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&&et(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 it(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function ut(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function eo(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}function ot(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}/*!
|
|
9
9
|
* decimal.js v10.5.0
|
|
10
10
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
11
11
|
* https://github.com/MikeMcl/decimal.js
|
|
12
12
|
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
13
13
|
* MIT Licence
|
|
14
|
-
*/var Br=9e15,Dr=1e9,Ut="0123456789abcdef",ut="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ot="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",qt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Br,maxE:Br,crypto:!1},An,ar,j=!0,at="[DecimalError] ",mr=at+"Invalid argument: ",bn=at+"Precision limit exceeded",Cn=at+"crypto unavailable",_n="[object Decimal]",$e=Math.floor,Ne=Math.pow,Ku=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,ju=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,eo=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Bn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,je=1e7,K=7,ro=9007199254740991,to=ut.length-1,Rt=ot.length-1,I={toStringTag:_n};I.absoluteValue=I.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Y(e)},I.ceil=function(){return Y(new this.constructor(this),this.e+1,2)},I.clampedTo=I.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(mr+r);return t=n.cmp(e),t<0?e:n.cmp(r)>0?r:new i(n)},I.comparedTo=I.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},I.cosine=I.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=no(n,In(n,t)),n.precision=e,n.rounding=r,Y(ar==2||ar==3?t.neg():t,e,r,!0)):new n(1):new n(NaN)},I.cubeRoot=I.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=Te(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=fe(l.plus(f).times(a),l.plus(c),o+2,1),Te(a.d).slice(0,o)===(t=Te(n.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(Y(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")&&(Y(n,e+1,1),r=!n.times(n).times(n).eq(f));break}return j=!0,Y(n,e,h.rounding,r)},I.decimalPlaces=I.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},I.dividedBy=I.div=function(e){return fe(this,new this.constructor(e))},I.dividedToIntegerBy=I.divToInt=function(e){var r=this,t=r.constructor;return Y(fe(r,new t(e),0,1,1),t.precision,t.rounding)},I.equals=I.eq=function(e){return this.cmp(e)===0},I.floor=function(){return Y(new this.constructor(this),this.e+1,3)},I.greaterThan=I.gt=function(e){return this.cmp(e)>0},I.greaterThanOrEqualTo=I.gte=function(e){var r=this.cmp(e);return r==1||r===0},I.hyperbolicCosine=I.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/ht(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),u=Nr(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 Y(u,o.precision=t,o.rounding=n,!0)},I.hyperbolicSine=I.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=Nr(u,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/ht(5,e)),i=Nr(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,Y(i,r,t,!0)},I.hyperbolicTangent=I.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,fe(t.sinh(),t.cosh(),n.precision=e,n.rounding=r)):new n(t.s)},I.inverseCosine=I.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()?ur(r,n,i):new r(0):new r(NaN):e.isZero()?ur(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))},I.inverseHyperbolicCosine=I.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)},I.inverseHyperbolicSine=I.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())},I.inverseHyperbolicTangent=I.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?Y(new u(i),e,r,!0):(u.precision=t=n-i.e,i=fe(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)},I.inverseSine=I.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=ur(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)))},I.inverseTangent=I.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<=Rt)return o=ur(f,h+4,D).times(.25),o.s=l.s,o}else{if(!l.s)return new f(NaN);if(h+4<=Rt)return o=ur(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,Y(o,f.precision=h,f.rounding=D,!0)},I.isFinite=function(){return!!this.d},I.isInteger=I.isInt=function(){return!!this.d&&$e(this.e/K)>this.d.length-2},I.isNaN=function(){return!this.s},I.isNegative=I.isNeg=function(){return this.s<0},I.isPositive=I.isPos=function(){return this.s>0},I.isZero=function(){return!!this.d&&this.d[0]===0},I.lessThan=I.lt=function(e){return this.cmp(e)<0},I.lessThanOrEqualTo=I.lte=function(e){return this.cmp(e)<1},I.logarithm=I.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=gr(l,a),n=r?ct(f,a+10):gr(e,a),c=fe(o,n,a,1),Lr(c.d,i=h,D))do if(a+=10,o=gr(l,a),n=r?ct(f,a+10):gr(e,a),c=fe(o,n,a,1),!u){+Te(c.d).slice(i+1,i+15)+1==1e14&&(c=Y(c,h+1,0));break}while(Lr(c.d,i+=10,D));return j=!0,Y(c,h,D)},I.minus=I.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?Y(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]=je-1;--l[i],l[n]+=je}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=ft(l,t),j?Y(e,a,c):e):new m(c===3?-0:0)},I.modulo=I.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]?Y(new n(t),n.precision,n.rounding):(j=!1,n.modulo==9?(r=fe(t,e.abs(),0,3,1),r.s*=e.s):r=fe(t,e,0,n.modulo,1),r=r.times(e),j=!0,t.minus(r))},I.naturalExponential=I.exp=function(){return Lt(this)},I.naturalLogarithm=I.ln=function(){return gr(this)},I.negated=I.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Y(e)},I.plus=I.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?Y(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)/je|0,l[i]%=je;for(r&&(l.unshift(r),++n),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=ft(l,n),j?Y(e,a,c):e},I.precision=I.sd=function(e){var r,t=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(mr+e);return t.d?(r=Nn(t.d),e&&t.e+1>r&&(r=t.e+1)):r=NaN,r},I.round=function(){var e=this,r=e.constructor;return Y(new r(e),e.e+1,r.rounding)},I.sine=I.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=uo(n,In(n,t)),n.precision=e,n.rounding=r,Y(ar>2?t.neg():t,e,r,!0)):new n(NaN)},I.squareRoot=I.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=Te(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(fe(o,u,t+2,1)).times(.5),Te(u.d).slice(0,t)===(r=Te(n.d)).slice(0,t))if(r=r.slice(t-3,t+1),r=="9999"||!i&&r=="4999"){if(!i&&(Y(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")&&(Y(n,c+1,1),e=!n.times(n).eq(o));break}return j=!0,Y(n,c,f.rounding,e)},I.tangent=I.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=fe(t,new n(1).minus(t.times(t)).sqrt(),e+10,0),n.precision=e,n.rounding=r,Y(ar==2||ar==4?t.neg():t,e,r,!0)):new n(NaN)},I.times=I.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%je|0,r=a/je|0;u[i]=(u[i]+r)%je|0}for(;!u[--o];)u.pop();return r?++t:u.shift(),e.d=u,e.e=ft(u,t),j?Y(e,h.precision,h.rounding):e},I.toBinary=function(e,r){return Ht(this,2,e,r)},I.toDecimalPlaces=I.toDP=function(e,r){var t=this,n=t.constructor;return t=new n(t),e===void 0?t:(Le(e,0,Dr),r===void 0?r=n.rounding:Le(r,0,8),Y(t,e+t.e+1,r))},I.toExponential=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=ir(n,!0):(Le(e,0,Dr),r===void 0?r=i.rounding:Le(r,0,8),n=Y(new i(n),e+1,r),t=ir(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},I.toFixed=function(e,r){var t,n,i=this,u=i.constructor;return e===void 0?t=ir(i):(Le(e,0,Dr),r===void 0?r=u.rounding:Le(r,0,8),n=Y(new u(i),e+i.e+1,r),t=ir(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t},I.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=Nn(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(mr+a);e=a.gt(r)?u>0?r:l:a}for(j=!1,a=new s(Te(m)),f=s.precision,s.precision=u=m.length*K*2;h=fe(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=fe(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=fe(l,n,u,1).minus(p).abs().cmp(fe(c,t,u,1).minus(p).abs())<1?[l,n]:[c,t],s.precision=f,j=!0,D},I.toHexadecimal=I.toHex=function(e,r){return Ht(this,16,e,r)},I.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:Le(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=fe(t,e,0,r,1).times(e),j=!0,Y(t)):(e.s=t.s,t=e),t},I.toNumber=function(){return+this},I.toOctal=function(e,r){return Ht(this,8,e,r)},I.toPower=I.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 Y(a,n,u);if(r=$e(e.e/K),r>=e.d.length-1&&(t=l<0?-l:l)<=ro)return i=Mn(c,a,t,n),e.s<0?new c(1).div(i):Y(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."+Te(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=Lt(e.times(gr(a,n+t)),n),i.d&&(i=Y(i,n+5,1),Lr(i.d,n,u)&&(r=n+10,i=Y(Lt(e.times(gr(a,r+t)),r),r+5,1),+Te(i.d).slice(n+1,n+15)+1==1e14&&(i=Y(i,n+1,0)))),i.s=o,j=!0,c.rounding=u,Y(i,n,u))},I.toPrecision=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=ir(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Le(e,1,Dr),r===void 0?r=i.rounding:Le(r,0,8),n=Y(new i(n),e,r),t=ir(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+t:t},I.toSignificantDigits=I.toSD=function(e,r){var t=this,n=t.constructor;return e===void 0?(e=n.precision,r=n.rounding):(Le(e,1,Dr),r===void 0?r=n.rounding:Le(r,0,8)),Y(new n(t),e,r)},I.toString=function(){var e=this,r=e.constructor,t=ir(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},I.truncated=I.trunc=function(){return Y(new this.constructor(this),this.e+1,1)},I.valueOf=I.toJSON=function(){var e=this,r=e.constructor,t=ir(e,e.e<=r.toExpNeg||e.e>=r.toExpPos);return e.isNeg()?"-"+t:t};function Te(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+=dr(t)),u+=n;o=e[r],n=o+"",t=K-n.length,t&&(u+=dr(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return u+o}function Le(e,r,t){if(e!==~~e||e<r||e>t)throw Error(mr+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 st(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]+=Ut.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 no(e,r){var t,n,i;if(r.isZero())return r;n=r.d.length,n<32?(t=Math.ceil(n/3),i=(1/ht(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),e.precision+=t,r=Nr(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 fe=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,x,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=je,p=K,f=$e(n.e/p)-$e(i.e/p)),x=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,x==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),x=O.length,B=W.length),b=x,v=W.slice(0,x),A=v.length;A<x;)v[A++]=0;R=O.slice(),R.unshift(0),M=O[0],O[1]>=c/2&&++M;do D=0,l=r(O,v,x,A),l<0?(y=v[0],x!=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,x<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,x,A),l<1&&(D++,t(v,x<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,An=m;else{for(h=1,D=E[0];D>=10;D/=10)h++;g.e=h+f*p-1,Y(g,a?u+g.e+1:u,o,m)}return g}}();function Y(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]==je&&(h[0]=1));break}else{if(h[D]+=a,h[D]!=je)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 ir(e,r,t){if(!e.isFinite())return Tn(e);var n,i=e.e,u=Te(e.d),o=u.length;return r?(t&&(n=t-o)>0?u=u.charAt(0)+"."+u.slice(1)+dr(n):o>1&&(u=u.charAt(0)+"."+u.slice(1)),u=u+(e.e<0?"e":"e+")+e.e):i<0?(u="0."+dr(-i-1)+u,t&&(n=t-o)>0&&(u+=dr(n))):i>=o?(u+=dr(i+1-o),t&&(n=t-i-1)>0&&(u=u+"."+dr(n))):((n=i+1)<o&&(u=u.slice(0,n)+"."+u.slice(n)),t&&(n=t-o)>0&&(i+1===o&&(u+="."),u+=dr(n))),u}function ft(e,r){var t=e[0];for(r*=K;t>=10;t/=10)r++;return r}function ct(e,r,t){if(r>to)throw j=!0,t&&(e.precision=t),Error(bn);return Y(new e(ut),r,1,!0)}function ur(e,r,t){if(r>Rt)throw Error(bn);return Y(new e(ot),r,t,!0)}function Nn(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 dr(e){for(var r="";e--;)r+="0";return r}function Mn(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),zn(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),zn(r.d,o)}return j=!0,u}function Sn(e){return e.d[e.d.length-1]&1}function xn(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 Lt(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=Y(u.times(e),c,1),t=t.times(++f),a=o.plus(fe(u,t,c,1)),Te(a.d).slice(0,c)===Te(o.d).slice(0,c)){for(i=h;i--;)o=Y(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 Y(o,D.precision=m,p,j=!0);else return D.precision=m,o}o=a}}function gr(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=Te(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=Te(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=ct(g,f+2,v).times(u+""),s=gr(new g(n+"."+t.slice(1)),f-m).plus(l),g.precision=v,r==null?Y(s,v,E,j=!0):s;for(h=s,c=o=s=fe(s.minus(1),s.plus(1),f,1),D=Y(s.times(s),f,1),i=3;;){if(o=Y(o.times(D),f,1),l=c.plus(fe(o,new g(i),f,1)),Te(l.d).slice(0,f)===Te(c.d).slice(0,f))if(c=c.times(2),u!==0&&(c=c.plus(ct(g,f+2,v).times(u+""))),c=fe(c,new g(p),f,1),r==null)if(Lr(c.d,f-m,E,a))g.precision=f+=m,l=o=s=fe(h.minus(1),h.plus(1),f,1),D=Y(s.times(s),f,1),i=a=1;else return Y(c,g.precision=v,E,j=!0);else return g.precision=v,c;c=l,i+=2}}function Tn(e){return String(e.s*e.s/0)}function lt(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 io(e,r){var t,n,i,u,o,a,c,l,f;if(r.indexOf("_")>-1){if(r=r.replace(/(\d)_(?=\d)/g,"$1"),Bn.test(r))return lt(e,r)}else if(r==="Infinity"||r==="NaN")return+r||(e.s=NaN),e.e=NaN,e.d=null,e;if(ju.test(r))t=16,r=r.toLowerCase();else if(Ku.test(r))t=2;else if(eo.test(r))t=8;else throw Error(mr+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=Mn(n,new n(t),u,u*2)),l=st(r,t,je),f=l.length-1,u=f;l[u]===0;--u)l.pop();return u<0?new n(e.s*0):(e.e=ft(l,f),e.d=l,j=!1,o&&(e=fe(e,i,a*4)),c&&(e=e.times(Math.abs(c)<54?Ne(2,c):Mr.pow(2,c))),j=!0,e)}function uo(e,r){var t,n=r.d.length;if(n<3)return r.isZero()?r:Nr(e,2,r,r);t=1.4*Math.sqrt(n),t=t>16?16:t|0,r=r.times(1/ht(5,t)),r=Nr(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 Nr(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=fe(a.times(c),new e(r++*r++),l,1),a=i?n.plus(o):n.minus(o),n=fe(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 ht(e,r){for(var t=e;--r;)t*=e;return t}function In(e,r){var t,n=r.s<0,i=ur(e,e.precision,1),u=i.times(.5);if(r=r.abs(),r.lte(u))return ar=n?4:1,r;if(t=r.divToInt(i),t.isZero())ar=n?3:2;else{if(r=r.minus(t.times(i)),r.lte(u))return ar=Sn(t)?n?2:3:n?4:1,r;ar=Sn(t)?n?1:4:n?3:2}return r.minus(i).abs()}function Ht(e,r,t,n){var i,u,o,a,c,l,f,h,D,p=e.constructor,m=t!==void 0;if(m?(Le(t,1,Dr),n===void 0?n=p.rounding:Le(n,0,8)):(t=p.precision,n=p.rounding),!e.isFinite())f=Tn(e);else{for(f=ir(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=st(ir(D),10,i),D.e=D.d.length),h=st(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=fe(e,D,t,n,0,i),h=e.d,u=e.e,l=An),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+=Ut.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=st(f,i,r),c=h.length;!h[c-1];--c);for(o=1,f="1.";o<c;o++)f+=Ut.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 zn(e,r){if(e.length>r)return e.length=r,!0}function oo(e){return new this(e).abs()}function ao(e){return new this(e).acos()}function so(e){return new this(e).acosh()}function fo(e,r){return new this(e).plus(r)}function co(e){return new this(e).asin()}function lo(e){return new this(e).asinh()}function ho(e){return new this(e).atan()}function po(e){return new this(e).atanh()}function Do(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=ur(this,u,1).times(r.s>0?.25:.75),t.s=e.s):!r.d||e.isZero()?(t=r.s<0?ur(this,n,i):new this(0),t.s=e.s):!e.d||r.isZero()?(t=ur(this,u,1).times(.5),t.s=e.s):r.s<0?(this.precision=u,this.rounding=1,t=this.atan(fe(e,r,u,1)),r=ur(this,u,1),this.precision=n,this.rounding=i,t=e.s<0?t.minus(r):t.plus(r)):t=this.atan(fe(e,r,u,1)),t}function mo(e){return new this(e).cbrt()}function go(e){return Y(e=new this(e),e.e+1,2)}function vo(e,r,t){return new this(e).clamp(r,t)}function wo(e){if(!e||typeof e!="object")throw Error(at+"Object expected");var r,t,n,i=e.defaults===!0,u=["precision",1,Dr,"rounding",0,8,"toExpNeg",-Br,0,"toExpPos",0,Br,"maxE",0,Br,"minE",-Br,0,"modulo",0,9];for(r=0;r<u.length;r+=3)if(t=u[r],i&&(this[t]=qt[t]),(n=e[t])!==void 0)if($e(n)===n&&n>=u[r+1]&&n<=u[r+2])this[t]=n;else throw Error(mr+t+": "+n);if(t="crypto",i&&(this[t]=qt[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(Cn);else this[t]=!1;else throw Error(mr+t+": "+n);return this}function yo(e){return new this(e).cos()}function Fo(e){return new this(e).cosh()}function On(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,$n(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 lt(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),Bn.test(u)?lt(l,u):io(l,u);if(c==="bigint")return u<0?(u=-u,l.s=-1):l.s=1,lt(l,u.toString());throw Error(mr+u)}if(i.prototype=I,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=wo,i.clone=On,i.isDecimal=$n,i.abs=oo,i.acos=ao,i.acosh=so,i.add=fo,i.asin=co,i.asinh=lo,i.atan=ho,i.atanh=po,i.atan2=Do,i.cbrt=mo,i.ceil=go,i.clamp=vo,i.cos=yo,i.cosh=Fo,i.div=Eo,i.exp=Ao,i.floor=bo,i.hypot=Co,i.ln=_o,i.log=Bo,i.log10=Mo,i.log2=No,i.max=So,i.min=xo,i.mod=To,i.mul=Io,i.pow=zo,i.random=Oo,i.round=$o,i.sign=Po,i.sin=Uo,i.sinh=qo,i.sqrt=Ro,i.sub=Lo,i.sum=Ho,i.tan=Zo,i.tanh=Wo,i.trunc=Vo,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 Eo(e,r){return new this(e).div(r)}function Ao(e){return new this(e).exp()}function bo(e){return Y(e=new this(e),e.e+1,3)}function Co(){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 $n(e){return e instanceof Mr||e&&e.toStringTag===_n||!1}function _o(e){return new this(e).ln()}function Bo(e,r){return new this(e).log(r)}function No(e){return new this(e).log(2)}function Mo(e){return new this(e).log(10)}function So(){return xn(this,arguments,-1)}function xo(){return xn(this,arguments,1)}function To(e,r){return new this(e).mod(r)}function Io(e,r){return new this(e).mul(r)}function zo(e,r){return new this(e).pow(r)}function Oo(e){var r,t,n,i,u=0,o=new this(1),a=[];if(e===void 0?e=this.precision:Le(e,1,Dr),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(Cn);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 $o(e){return Y(e=new this(e),e.e+1,this.rounding)}function Po(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Uo(e){return new this(e).sin()}function qo(e){return new this(e).sinh()}function Ro(e){return new this(e).sqrt()}function Lo(e,r){return new this(e).sub(r)}function Ho(){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,Y(t,this.precision,this.rounding)}function Zo(e){return new this(e).tan()}function Wo(e){return new this(e).tanh()}function Vo(e){return Y(e=new this(e),e.e+1,1)}I[Symbol.for("nodejs.util.inspect.custom")]=I.toString,I[Symbol.toStringTag]="Decimal";var Mr=I.constructor=On(qt);ut=new Mr(ut),ot=new Mr(ot);var Jo="BigNumber",Go=["?on","config"],Yo=J(Jo,Go,e=>{var{on:r,config:t}=e,n=Mr.clone({precision:t.precision,modulo:Mr.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 Pe=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},Ye=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},ko=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)},Zt=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))},Sr=function(){throw SyntaxError("Invalid Param")};function Wt(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 Xo={re:0,im:0},Fr=function(e,r){const t=Xo;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 S.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 S.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]):Sr();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&&Sr();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&&Sr(),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))&&Sr(),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&&Sr();break;case"number":t.im=0,t.re=e;break;default:Sr()}return isNaN(t.re)||isNaN(t.im),t};function S(e,r){if(!(this instanceof S))return new S(e,r);const t=Fr(e,r);this.re=t.re,this.im=t.im}S.prototype={re:0,im:0,sign:function(){const e=Zt(this.re,this.im);return new S(this.re/e,this.im/e)},add:function(e,r){const t=Fr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?S.NAN:S.INFINITY:new S(this.re+t.re,this.im+t.im)},sub:function(e,r){const t=Fr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?S.NAN:S.INFINITY:new S(this.re-t.re,this.im-t.im)},mul:function(e,r){const t=Fr(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?S.NAN:n||i?S.INFINITY:t.im===0&&this.im===0?new S(this.re*t.re,0):new S(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){const t=Fr(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 S.NAN;if(o||n)return S.INFINITY;if(u||i)return S.ZERO;if(t.im===0)return new S(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 S((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 S((this.re+this.im*a)/c,(this.im-this.re*a)/c)}},pow:function(e,r){const t=Fr(e,r),n=this.re===0&&this.im===0;if(t.re===0&&t.im===0)return S.ONE;if(t.im===0){if(this.im===0&&this.re>0)return new S(Math.pow(this.re,t.re),0);if(this.re===0)switch((t.re%4+4)%4){case 0:return new S(Math.pow(this.im,t.re),0);case 1:return new S(0,Math.pow(this.im,t.re));case 2:return new S(-Math.pow(this.im,t.re),0);case 3:return new S(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return S.ZERO;const u=Math.atan2(this.im,this.re),o=Wt(this.re,this.im);let a=Math.exp(t.re*o-t.im*u),c=t.im*o+t.re*u;return new S(a*Math.cos(c),a*Math.sin(c))},sqrt:function(){const e=this.re,r=this.im;if(r===0)return e>=0?new S(Math.sqrt(e),0):new S(0,Math.sqrt(-e));const t=Zt(e,r);let n=Math.sqrt(.5*(t+Math.abs(e))),i=Math.abs(r)/(2*n);return e>=0?new S(n,r<0?-i:i):new S(i,r<0?-n:n)},exp:function(){const e=Math.exp(this.re);return this.im===0?new S(e,0):new S(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,r=this.im;return new S(Math.expm1(e)*Math.cos(r)+ko(r),Math.exp(e)*Math.sin(r))},log:function(){const e=this.re,r=this.im;return r===0&&e>0?new S(Math.log(e),0):new S(Wt(e,r),Math.atan2(r,e))},abs:function(){return Zt(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,r=this.im;return new S(Math.sin(e)*Pe(r),Math.cos(e)*Ye(r))},cos:function(){const e=this.re,r=this.im;return new S(Math.cos(e)*Pe(r),-Math.sin(e)*Ye(r))},tan:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)+Pe(r);return new S(Math.sin(e)/t,Ye(r)/t)},cot:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)-Pe(r);return new S(-Math.sin(e)/t,Ye(r)/t)},sec:function(){const e=this.re,r=this.im,t=.5*Pe(2*r)+.5*Math.cos(2*e);return new S(Math.cos(e)*Pe(r)/t,Math.sin(e)*Ye(r)/t)},csc:function(){const e=this.re,r=this.im,t=.5*Pe(2*r)-.5*Math.cos(2*e);return new S(Math.sin(e)*Pe(r)/t,-Math.cos(e)*Ye(r)/t)},asin:function(){const e=this.re,r=this.im,t=new S(r*r-e*e+1,-2*e*r).sqrt(),n=new S(t.re-r,t.im+e).log();return new S(n.im,-n.re)},acos:function(){const e=this.re,r=this.im,t=new S(r*r-e*e+1,-2*e*r).sqrt(),n=new S(t.re-r,t.im+e).log();return new S(Math.PI/2-n.im,n.re)},atan:function(){const e=this.re,r=this.im;if(e===0){if(r===1)return new S(0,1/0);if(r===-1)return new S(0,-1/0)}const t=e*e+(1-r)*(1-r),n=new S((1-r*r-e*e)/t,-2*e/t).log();return new S(-.5*n.im,.5*n.re)},acot:function(){const e=this.re,r=this.im;if(r===0)return new S(Math.atan2(1,e),0);const t=e*e+r*r;return t!==0?new S(e/t,-r/t).atan():new S(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 S(0,1/0);const t=e*e+r*r;return t!==0?new S(e/t,-r/t).acos():new S(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 S(Math.PI/2,1/0);const t=e*e+r*r;return t!==0?new S(e/t,-r/t).asin():new S(e!==0?e/0:0,r!==0?-r/0:0).asin()},sinh:function(){const e=this.re,r=this.im;return new S(Ye(e)*Math.cos(r),Pe(e)*Math.sin(r))},cosh:function(){const e=this.re,r=this.im;return new S(Pe(e)*Math.cos(r),Ye(e)*Math.sin(r))},tanh:function(){const e=2*this.re,r=2*this.im,t=Pe(e)+Math.cos(r);return new S(Ye(e)/t,Math.sin(r)/t)},coth:function(){const e=2*this.re,r=2*this.im,t=Pe(e)-Math.cos(r);return new S(Ye(e)/t,-Math.sin(r)/t)},csch:function(){const e=this.re,r=this.im,t=Math.cos(2*r)-Pe(2*e);return new S(-2*Ye(e)*Math.cos(r)/t,2*Pe(e)*Math.sin(r)/t)},sech:function(){const e=this.re,r=this.im,t=Math.cos(2*r)+Pe(2*e);return new S(2*Pe(e)*Math.cos(r)/t,-2*Ye(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 S((i*n-r*r)/u,(r*n+i*r)/u):new S(e!==-1?e/0:0,r!==0?r/0:0),a=o.re;return o.re=Wt(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 S(0,Math.PI/2);const t=e*e+r*r;return t!==0?new S(e/t,-r/t).atanh():new S(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 S(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);const t=e*e+r*r;return t!==0?new S(e/t,-r/t).asinh():new S(e!==0?e/0:0,r!==0?-r/0:0).asinh()},asech:function(){const e=this.re,r=this.im;if(this.isZero())return S.INFINITY;const t=e*e+r*r;return t!==0?new S(e/t,-r/t).acosh():new S(e!==0?e/0:0,r!==0?-r/0:0).acosh()},inverse:function(){if(this.isZero())return S.INFINITY;if(this.isInfinite())return S.ZERO;const e=this.re,r=this.im,t=e*e+r*r;return new S(e/t,-r/t)},conjugate:function(){return new S(this.re,-this.im)},neg:function(){return new S(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new S(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new S(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new S(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,r){const t=Fr(e,r);return Math.abs(t.re-this.re)<=S.EPSILON&&Math.abs(t.im-this.im)<=S.EPSILON},clone:function(){return new S(this.re,this.im)},toString:function(){let e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<S.EPSILON&&(e=0),Math.abs(r)<S.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()}},S.ZERO=new S(0,0),S.ONE=new S(1,0),S.I=new S(0,1),S.PI=new S(Math.PI,0),S.E=new S(Math.E,0),S.INFINITY=new S(1/0,1/0),S.NAN=new S(NaN,NaN),S.EPSILON=1e-15;var Qo="Complex",Ko=[],jo=J(Qo,Ko,()=>(Object.defineProperty(S,"name",{value:"Complex"}),S.prototype.constructor=S,S.prototype.type="Complex",S.prototype.isComplex=!0,S.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},S.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},S.prototype.format=function(e){var r="",t=this.im,n=this.re,i=Pt(this.re,e),u=Pt(this.im,e),o=pe(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},S.fromPolar=function(e){switch(arguments.length){case 1:{var r=arguments[0];if(typeof r=="object")return S(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(pe(t)){if(hn(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),pe(n))return new S({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")}},S.prototype.valueOf=S.prototype.toString,S.fromJSON=function(e){return new S(e)},S.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},S),{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),Vt=BigInt(5),He=BigInt(10),ea=2e3,L={s:re,n:k,d:re};function sr(e,r){try{e=BigInt(e)}catch{throw vr()}return e*r}function er(e){return typeof e=="bigint"?e:Math.floor(e)}function Ee(e,r){if(r===k)throw Jt();const t=Object.create(ke.prototype);t.s=e<k?-re:re,e=e<k?-e:e;const n=Er(e,r);return t.n=e/n,t.d=r/n,t}function xr(e){const r={};let t=e,n=Hr,i=Vt-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 Me=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 vr();if(e%1!==0)throw Pn();t=BigInt(e)}if(typeof r=="bigint")n=r;else{if(isNaN(r))throw vr();if(r%1!==0)throw Pn();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 vr();i=t*n}else if(typeof e=="number"){if(isNaN(e))throw vr();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 vr();if(h[u]==="-"?(i=-re,u++):h[u]==="+"&&u++,h.length===u+1?a=sr(h[u++],i):h[u+1]==="."||h[u]==="."?(h[u]!=="."&&(o=sr(h[u++],i)),u++,(u+1===h.length||h[u+1]==="("&&h[u+3]===")"||h[u+1]==="'"&&h[u+3]==="'")&&(a=sr(h[u],i),l=He**BigInt(h[u].length),u++),(h[u]==="("&&h[u+2]===")"||h[u]==="'"&&h[u+2]==="'")&&(c=sr(h[u+1],i),f=He**BigInt(h[u+1].length)-re,u+=3)):h[u+1]==="/"||h[u+1]===":"?(a=sr(h[u],i),l=sr(h[u+2],re),u+=3):h[u+3]==="/"&&h[u+1]===" "&&(o=sr(h[u],i),a=sr(h[u+2],i),l=sr(h[u+4],re),u+=5),h.length<=u)n=l*f,i=t=c+n*o+f*a;else throw vr()}else if(typeof e=="bigint")t=e,i=e,n=re;else throw vr();if(n===k)throw Jt();L.s=i<k?-re:re,L.n=t<k?-t:t,L.d=n<k?-n:n};function ra(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%Vt===k;r/=Vt);if(r===re)return k;let t=He%r,n=1;for(;t!==re;n++)if(t=t*He%r,n>ea)return k;return BigInt(n)}function na(e,r,t){let n=re,i=ra(He,t,r);for(let u=0;u<300;u++){if(n===i)return BigInt(u);n=n*He%r,i=i*He%r}return 0}function Er(e,r){if(!e)return r;if(!r)return e;for(;;){if(e%=r,!e)return r;if(r%=e,!r)return e}}function ke(e,r){if(Me(e,r),this instanceof ke)e=Er(L.d,L.n),this.s=L.s,this.n=L.n/e,this.d=L.d/e;else return Ee(L.s*L.n,L.d)}var Jt=function(){return new Error("Division by Zero")},vr=function(){return new Error("Invalid argument")},Pn=function(){return new Error("Parameters must be integer")};ke.prototype={s:re,n:k,d:re,abs:function(){return Ee(this.n,this.d)},neg:function(){return Ee(-this.s*this.n,this.d)},add:function(e,r){return Me(e,r),Ee(this.s*this.n*L.d+L.s*this.d*L.n,this.d*L.d)},sub:function(e,r){return Me(e,r),Ee(this.s*this.n*L.d-L.s*this.d*L.n,this.d*L.d)},mul:function(e,r){return Me(e,r),Ee(this.s*L.s*this.n*L.n,this.d*L.d)},div:function(e,r){return Me(e,r),Ee(this.s*L.s*this.n*L.d,this.d*L.n)},clone:function(){return Ee(this.s*this.n,this.d)},mod:function(e,r){if(e===void 0)return Ee(this.s*this.n%this.d,re);if(Me(e,r),k===L.n*this.d)throw Jt();return Ee(this.s*(L.d*this.n)%(L.n*this.d),L.d*this.d)},gcd:function(e,r){return Me(e,r),Ee(Er(L.n,this.n)*Er(L.d,this.d),L.d*this.d)},lcm:function(e,r){return Me(e,r),L.n===k&&this.n===k?Ee(k,re):Ee(L.n*this.n,Er(L.n,this.n)*Er(L.d,this.d))},inverse:function(){return Ee(this.s*this.d,this.n)},pow:function(e,r){if(Me(e,r),L.d===re)return L.s<k?Ee((this.s*this.d)**L.n,this.n**L.n):Ee((this.s*this.n)**L.n,this.d**L.n);if(this.s<k)return null;let t=xr(this.n),n=xr(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?Ee(u,i):Ee(i,u)},log:function(e,r){if(Me(e,r),this.s<=k||L.s<=k)return null;const t={},n=xr(L.n),i=xr(L.d),u=xr(this.n),o=xr(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=Er(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?Ee(a,c):null},equals:function(e,r){return Me(e,r),this.s*this.n*L.d===L.s*L.n*this.d},lt:function(e,r){return Me(e,r),this.s*this.n*L.d<L.s*L.n*this.d},lte:function(e,r){return Me(e,r),this.s*this.n*L.d<=L.s*L.n*this.d},gt:function(e,r){return Me(e,r),this.s*this.n*L.d>L.s*L.n*this.d},gte:function(e,r){return Me(e,r),this.s*this.n*L.d>=L.s*L.n*this.d},compare:function(e,r){Me(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=He**BigInt(e||0),Ee(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=He**BigInt(e||0),Ee(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=He**BigInt(e||0),Ee(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){Me(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++,Ee(this.s*u*L.n,L.d)},divisible:function(e,r){return Me(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=na(r,t,n),u=this.s<k?"-":"";if(u+=er(r/t),r%=t,r*=He,r&&(u+="."),n){for(let o=i;o--;)u+=er(r/t),r%=t,r*=He;u+="(";for(let o=n;o--;)u+=er(r/t),r%=t,r*=He;u+=")"}else for(let o=e;r&&o--;)u+=er(r/t),r%=t,r*=He;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=Ee(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 ia="Fraction",ua=[],oa=J(ia,ua,()=>(Object.defineProperty(ke,"name",{value:"Fraction"}),ke.prototype.constructor=ke,ke.prototype.type="Fraction",ke.prototype.isFraction=!0,ke.prototype.toJSON=function(){return{mathjs:"Fraction",n:String(this.s*this.n),d:String(this.d)}},ke.fromJSON=function(e){return new ke(e)},ke),{isClass:!0}),aa="Matrix",sa=[],fa=J(aa,sa,()=>{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 Gt(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(!de(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 ca(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}=gn(r);switch(t){case"fixed":return ha(e,n);case"exponential":return Un(e,n);case"engineering":return la(e,n);case"bin":return Gt(e,2,i);case"oct":return Gt(e,8,i);case"hex":return Gt(e,16,i);case"auto":{var u=qn(r?.lowerExp,-3),o=qn(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=Un(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 Un(e,r){return r!==void 0?e.toExponential(r-1):e.toExponential()}function ha(e,r){return e.toFixed(r)}function qn(e,r){return pe(e)?e:Fe(e)?e.toNumber():r}function Ce(e,r){var t=pa(e,r);return r&&typeof r=="object"&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function pa(e,r){if(typeof e=="number")return Pt(e,r);if(Fe(e))return ca(e,r);if(Da(e))return!r||r.fraction!=="decimal"?"".concat(e.s*e.n,"/").concat(e.d):e.toString();if(Array.isArray(e))return Hn(e,r);if(Je(e))return Rn(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=>Rn(n)+": "+Ce(e[n],r));return"{"+t.join(", ")+"}"}return String(e)}function Rn(e){for(var r=String(e),t="",n=0;n<r.length;){var i=r.charAt(n);t+=i in Ln?Ln[i]:i,n++}return'"'+t+'"'}var Ln={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Hn(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;i<n;i++)i!==0&&(t+=", "),t+=Hn(e[i],r);return t+="]",t}else return Ce(e,r)}function Da(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 Ar(e,r,t){if(!(this instanceof Ar))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}Ar.prototype=new RangeError,Ar.prototype.constructor=RangeError,Ar.prototype.name="IndexError",Ar.prototype.isIndexError=!0;function Ie(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function Zn(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,"<");Zn(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 Zn(e,r,0)}function pt(e,r){var t=e.isMatrix?e._size:Ie(e),n=r._sourceSize;n.forEach((i,u)=>{if(i!==null&&i!==t[u])throw new ne(i,t[u])})}function ge(e,r){if(e!==void 0){if(!pe(e)||!de(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof r=="number"&&e>=r)throw new Ar(e,r)}}function Tr(e){for(var r=0;r<e._dimensions.length;++r){var t=e._dimensions[r];if(t._data&&we(t._data)){if(t._size[0]===0)return!0}else if(t.isRange){if(t.start===t.end)return!0}else if(Je(t)&&t.length===0)return!0}return!1}function Dt(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(!pe(i)||!de(i)||i<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ce(r)+")")}),(pe(e)||Fe(e))&&(e=[e]);var n=t!==void 0?t:0;return Yt(e,r,0,n),e}function Yt(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),Yt(u,r,l,n);for(i=c;i<a;i++)u=[],e[i]=u,Yt(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 Vn(e,r){var t=da(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=kt(r,n);var i=Jn(r);if(n!==i)throw new ne(i,n,"!=");try{return ma(t,r)}catch(u){throw u instanceof ne?new ne(i,n,"!="):u}}function kt(e,r){var t=Jn(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 Jn(e){return e.reduce((r,t)=>r*t,1)}function ma(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 Gn(e,r,t,n){var i=n||Ie(e);if(t)for(var u=0;u<t;u++)e=[e],i.unshift(1);for(e=Yn(e,r,0);i.length<r;)i.push(1);return e}function Yn(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]=Yn(e[n],r,u)}else for(var o=t;o<r;o++)e=[e];return e}function da(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 mt(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?mt(u,r):r(u);if(t===void 0)t=a;else if(t!==a)return"mixed"}return t}function kn(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]=kn(e[u],r[u],t,n+1);return i}else return e.concat(r)}function Xn(){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 kn(t,n,r,0)},e[0]);throw new Error("Wrong number of arguments in function concat")}function Qn(){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++)Kn(r[h],u);return u}function Kn(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=Ie(e);if(pr(t,r))return e;Kn(t,r);var n=Qn(t,r),i=n.length,u=[...Array(i-t.length).fill(1),...t],o=va(e);t.length<i&&(o=Vn(o,u),t=Ie(o));for(var a=0;a<i;a++)t[a]<n[a]&&(o=ga(o,n[a],a),t=Ie(o));return o}function ga(e,r,t){return Xn(...Array(r).fill(e),t)}function jn(e,r){if(!Array.isArray(e))throw new Error("Array expected");var t=Ie(e);if(r.length!==t.length)throw new ne(r.length,t.length);for(var n=0;n<r.length;n++)ge(r[n],t[n]);return r.reduce((i,u)=>i[u],e)}function ei(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 va(e){return hr([],e)}function dt(e,r,t){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(et.isTypedFunction(e)){var i;if(n)i=1;else{var u=(r.isMatrix?r.size():Ie(r)).map(()=>0),o=r.isMatrix?r.get(u):jn(r,u);i=Fa(e,o,u,r)}var a;if(r.isMatrix&&r.dataType!=="mixed"&&r.dataType!==void 0){var c=wa(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 ri(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 ri(a,h,t,e.name)}}}return n===void 0?{isUnary:ya(e),fn:e}:{isUnary:n,fn:e}}function wa(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 ya(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 Fa(e,r,t,n){for(var i=[r,t,n],u=3;u>0;u--){var o=i.slice(0,u);if(et.resolve(e,o)!==null)return u}}function ri(e,r,t,n){try{return e(...r)}catch(i){Ea(i,r,t,n)}}function Ea(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(nr(r[0]))),r.length>=2&&u.push("index: ".concat(nr(r[1]))),r.length>=3&&u.push("array: ".concat(nr(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 Aa="DenseMatrix",ba=["Matrix"],Ca=J(Aa,ba,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&&!Je(h))throw new Error("Invalid datatype: "+h);if(De(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&&we(f.data)&&we(f.size))this._data=f.data,this._size=f.size,Wn(this._data,this._size),this._datatype=h||f.datatype;else if(we(f))this._data=l(f),this._size=Ie(this._data),Wn(this._data,this._size),this._datatype=h;else{if(f)throw new TypeError("Unsupported type of data ("+nr(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 mt(this._data,nr)},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 jn(this._data,f)},t.prototype.set=function(f,h,D){if(!we(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],ge(s,g.length),g=g[s];return s=f[f.length-1],ge(s,g.length),g[s]=h,this};function n(f,h){if(!jr(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++)ge(m[d],f._size[d]),ge(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=>(ge(E,s.length),m(s[E],d+1))).valueOf():g.map(E=>(ge(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(De(D)?(d=D.size(),D=D.valueOf()):d=Ie(D),s){if(d.length!==0)throw new TypeError("Scalar expected");f.set(h.min(),D,p)}else{if(!pr(d,m))try{d.length===0?D=Xt([D],m):D=Xt(D,m),d=Ie(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=Gn(D,m.length,E,d)}if(!pr(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)=>{ge(v,s.length),m(s[v],d[A[0]],g+1)}):E.forEach((v,A)=>{ge(v,s.length),s[v]=d[A[0]]})}}t.prototype.resize=function(f,h,D){if(!Kr(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;we(p);)p=p[0];return p}return f._size=h.slice(0),f._data=Dt(f._data,f._size,D),f}t.prototype.reshape=function(f,h){var D=h?this.clone():this;D._data=Vn(D._data,f);var p=D._size.reduce((m,s)=>m*s);return D._size=kt(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=dt(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 x=0;x<C.length;x++)A[b]=x,B[x]=s(C[x],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 x=0;x<C.length;x++)B[x]=s(C[x]);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=dt(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 Ce(this._data,f)},t.prototype.toString=function(){return Ce(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(Fe(f)&&(f=f.toNumber()),!pe(f)||!de(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(!we(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(Fe(C)&&(C=C.toNumber()),!pe(C)||!de(C)||C<1)throw new Error("Size values must be positive integers");return C}),D){if(Fe(D)&&(D=D.toNumber()),!pe(D)||!de(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(we(h)){if(h.length!==E)throw new Error("Invalid value array length");v=function(b){return h[b]}}else if(De(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=Fe(v(0))?v(0).mul(0):0);var y=[];if(f.length>0){y=Dt(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(!pe(f)||!de(f)||!pe(h)||!de(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 ge(f,this._size[0]),ge(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 De(f)?l(f.valueOf()):we(f)?f.map(l):f}return t},{isClass:!0});function Ze(e,r,t){if(!t)return De(e)?e.map(i=>r(i),!1,!0):ei(e,r,!0);var n=i=>i===0?i:r(i);return De(e)?e.map(i=>n(i),!1,!0):ei(e,n,!0)}var ti="isInteger",_a=["typed"],Ba=J(ti,_a,e=>{var{typed:r}=e;return r(ti,{number:de,BigNumber:function(n){return n.isInt()},bigint:function(n){return!0},Fraction:function(n){return n.d===1n},"Array | Matrix":r.referToSelf(t=>n=>Ze(n,t))})}),Qt="number",gt="number, number";function ni(e){return Math.abs(e)}ni.signature=Qt;function ii(e,r){return e+r}ii.signature=gt;function ui(e,r){return e-r}ui.signature=gt;function oi(e,r){return e*r}oi.signature=gt;function ai(e){return-e}ai.signature=Qt;function vt(e){return Vu(e)}vt.signature=Qt;function si(e,r){return e*e<1&&r===1/0||e*e>1&&r===-1/0?0:Math.pow(e,r)}si.signature=gt;function Zr(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!de(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(vn(e,r))}var Na=Math.PI,Ma="number";function fi(e){return e>0}fi.signature=Ma;function wr(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 ci="isPositive",Sa=["typed","config"],xa=J(ci,Sa,e=>{var{typed:r,config:t}=e;return r(ci,{number:n=>Ke(n,0,t.relTol,t.absTol)?!1:fi(n),BigNumber:n=>wr(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=>Ze(i,n))})}),li="isZero",Ta=["typed","equalScalar"],Ia=J(li,Ta,e=>{var{typed:r,equalScalar:t}=e;return r(li,{"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=>Ze(i,n))})});function za(e,r,t,n){return Ke(e.re,r.re,t,n)&&Ke(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)})}}),wt="equalScalar",Oa=["typed","config"],$a=J(wt,Oa,e=>{var{typed:r,config:t}=e,n=Wr({typed:r});return r(wt,{"boolean, boolean":function(u,o){return u===o},"number, number":function(u,o){return Ke(u,o,t.relTol,t.absTol)},"BigNumber, BigNumber":function(u,o){return u.eq(o)||wr(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 za(u,o,t.relTol,t.absTol)}},n)});J(wt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(wt,{"number, number":function(i,u){return Ke(i,u,t.relTol,t.absTol)}})});var Pa="SparseMatrix",Ua=["typed","equalScalar","Matrix"],qa=J(Pa,Ua,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&&!Je(d))throw new Error("Invalid datatype: "+d);if(De(s))u(this,s,d);else if(s&&we(s.index)&&we(s.ptr)&&we(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(we(s))o(this,s,d);else{if(s)throw new TypeError("Unsupported type of data ("+nr(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(Je(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(we(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 mt(this._values,nr)},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(!jr(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++)ge(C[v],s._size[v]),ge(b[v],s._size[v]);var B=s._values,M=s._index,x=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=[],X=[];return V.forEach(function(G){for(X.push(Q.length),y=x[G],w=x[G+1];y<w;y++)v=M[y],q[v]===!0&&(Q.push(W[v]),O&&O.push(B[y]))}),X.push(Q.length),new i({values:O,index:Q,ptr:X,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(De(g)?(y=g.size(),g=g.toArray()):y=Ie(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=Gn(g,v.length,C,y)}if(!pr(v,y))throw new ne(v,y,">");if(v.length===1){var b=d.dimension(0);b.forEach(function(x,R){ge(x),s.set([x,0],g[R[0]],E)})}else{var B=d.dimension(0),M=d.dimension(1);B.forEach(function(x,R){ge(x),M.forEach(function(V,q){ge(V),s.set([x,V],g[R[0]][q[0]],E)})})}}return s}i.prototype.get=function(s){if(!we(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];ge(d,this._size[0]),ge(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(!we(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;Je(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]),ge(E,A),ge(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(!Kr(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(!pe(A)||!de(A)||A<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Ce(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;Je(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,x;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,x=s._ptr[M+1]+R;var V=0;for(B=C;B<d;B++,V++)s._values.splice(x+V,0,v),s._index.splice(x+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(x=W;x<O;x++)B=s._index[x],B>d-1&&(s._values.splice(x,1),s._index.splice(x,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(!we(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(!pe(G)||!de(G)||G<=-2||G===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+Ce(s)+")")});var g=this._size[0]*this._size[1];s=kt(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],x=A[B],R=M*v._size[1]+x;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],X=l(W,v._ptr[O],v._ptr[O+1],v._index);h(X,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=dt(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;Je(s._datatype)&&(B=r.find(t,[s._datatype,s._datatype])||t,M=r.convert(0,s._datatype));for(var x=function(ce,_e,be){var Ae=A(ce,_e,be);B(Ae,M)||(w.push(Ae),C.push(_e))},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&&x(s._values[W],O-d,R-E)}else{for(var Q={},X=V;X<q;X++){var G=s._index[X];Q[G]=s._values[X]}for(var ee=d;ee<=g;ee++){var oe=ee in Q?Q[ee]:0;x(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=dt(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={},x=w;x<C;x++){var R=this._index[x];M[R]=this._values[x]}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],x=B;x<M;x++)C=d[x],w[C][b]=s?v?me(s[x]):s[x]: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 ["+Ce(d,s)+" x "+Ce(g,s)+"] density: "+Ce(E,s)+`
|
|
14
|
+
*/var Nr=9e15,Dr=1e9,Zt="0123456789abcdef",at="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",st="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Wt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Nr,maxE:Nr,crypto:!1},_n,sr,j=!0,ft="[DecimalError] ",mr=ft+"Invalid argument: ",Bn=ft+"Precision limit exceeded",Nn=ft+"crypto unavailable",Mn="[object Decimal]",Pe=Math.floor,Me=Math.pow,ro=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,to=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,no=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Sn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,er=1e7,K=7,io=9007199254740991,uo=at.length-1,Vt=st.length-1,I={toStringTag:Mn};I.absoluteValue=I.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Y(e)},I.ceil=function(){return Y(new this.constructor(this),this.e+1,2)},I.clampedTo=I.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(mr+r);return t=n.cmp(e),t<0?e:n.cmp(r)>0?r:new i(n)},I.comparedTo=I.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},I.cosine=I.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=oo(n,$n(n,t)),n.precision=e,n.rounding=r,Y(sr==2||sr==3?t.neg():t,e,r,!0)):new n(1):new n(NaN)},I.cubeRoot=I.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*Me(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=Me(t,1/3),e=Pe((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=fe(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&&(Y(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")&&(Y(n,e+1,1),r=!n.times(n).times(n).eq(f));break}return j=!0,Y(n,e,h.rounding,r)},I.decimalPlaces=I.dp=function(){var e,r=this.d,t=NaN;if(r){if(e=r.length-1,t=(e-Pe(this.e/K))*K,e=r[e],e)for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t},I.dividedBy=I.div=function(e){return fe(this,new this.constructor(e))},I.dividedToIntegerBy=I.divToInt=function(e){var r=this,t=r.constructor;return Y(fe(r,new t(e),0,1,1),t.precision,t.rounding)},I.equals=I.eq=function(e){return this.cmp(e)===0},I.floor=function(){return Y(new this.constructor(this),this.e+1,3)},I.greaterThan=I.gt=function(e){return this.cmp(e)>0},I.greaterThanOrEqualTo=I.gte=function(e){var r=this.cmp(e);return r==1||r===0},I.hyperbolicCosine=I.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/Dt(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),u=Mr(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 Y(u,o.precision=t,o.rounding=n,!0)},I.hyperbolicSine=I.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=Mr(u,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/Dt(5,e)),i=Mr(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,Y(i,r,t,!0)},I.hyperbolicTangent=I.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,fe(t.sinh(),t.cosh(),n.precision=e,n.rounding=r)):new n(t.s)},I.inverseCosine=I.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()?or(r,n,i):new r(0):new r(NaN):e.isZero()?or(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))},I.inverseHyperbolicCosine=I.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)},I.inverseHyperbolicSine=I.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())},I.inverseHyperbolicTangent=I.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?Y(new u(i),e,r,!0):(u.precision=t=n-i.e,i=fe(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)},I.inverseSine=I.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=or(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)))},I.inverseTangent=I.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<=Vt)return o=or(f,h+4,D).times(.25),o.s=l.s,o}else{if(!l.s)return new f(NaN);if(h+4<=Vt)return o=or(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,Y(o,f.precision=h,f.rounding=D,!0)},I.isFinite=function(){return!!this.d},I.isInteger=I.isInt=function(){return!!this.d&&Pe(this.e/K)>this.d.length-2},I.isNaN=function(){return!this.s},I.isNegative=I.isNeg=function(){return this.s<0},I.isPositive=I.isPos=function(){return this.s>0},I.isZero=function(){return!!this.d&&this.d[0]===0},I.lessThan=I.lt=function(e){return this.cmp(e)<0},I.lessThanOrEqualTo=I.lte=function(e){return this.cmp(e)<1},I.logarithm=I.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=gr(l,a),n=r?ht(f,a+10):gr(e,a),c=fe(o,n,a,1),Lr(c.d,i=h,D))do if(a+=10,o=gr(l,a),n=r?ht(f,a+10):gr(e,a),c=fe(o,n,a,1),!u){+Ie(c.d).slice(i+1,i+15)+1==1e14&&(c=Y(c,h+1,0));break}while(Lr(c.d,i+=10,D));return j=!0,Y(c,h,D)},I.minus=I.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?Y(e,a,c):e}if(t=Pe(e.e/K),f=Pe(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]=er-1;--l[i],l[n]+=er}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=lt(l,t),j?Y(e,a,c):e):new m(c===3?-0:0)},I.modulo=I.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]?Y(new n(t),n.precision,n.rounding):(j=!1,n.modulo==9?(r=fe(t,e.abs(),0,3,1),r.s*=e.s):r=fe(t,e,0,n.modulo,1),r=r.times(e),j=!0,t.minus(r))},I.naturalExponential=I.exp=function(){return Gt(this)},I.naturalLogarithm=I.ln=function(){return gr(this)},I.negated=I.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Y(e)},I.plus=I.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?Y(e,a,c):e;if(u=Pe(h.e/K),n=Pe(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)/er|0,l[i]%=er;for(r&&(l.unshift(r),++n),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=lt(l,n),j?Y(e,a,c):e},I.precision=I.sd=function(e){var r,t=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(mr+e);return t.d?(r=xn(t.d),e&&t.e+1>r&&(r=t.e+1)):r=NaN,r},I.round=function(){var e=this,r=e.constructor;return Y(new r(e),e.e+1,r.rounding)},I.sine=I.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=so(n,$n(n,t)),n.precision=e,n.rounding=r,Y(sr>2?t.neg():t,e,r,!0)):new n(NaN)},I.squareRoot=I.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=Pe((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(fe(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&&(Y(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")&&(Y(n,c+1,1),e=!n.times(n).eq(o));break}return j=!0,Y(n,c,f.rounding,e)},I.tangent=I.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=fe(t,new n(1).minus(t.times(t)).sqrt(),e+10,0),n.precision=e,n.rounding=r,Y(sr==2||sr==4?t.neg():t,e,r,!0)):new n(NaN)},I.times=I.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=Pe(f.e/K)+Pe(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%er|0,r=a/er|0;u[i]=(u[i]+r)%er|0}for(;!u[--o];)u.pop();return r?++t:u.shift(),e.d=u,e.e=lt(u,t),j?Y(e,h.precision,h.rounding):e},I.toBinary=function(e,r){return Jt(this,2,e,r)},I.toDecimalPlaces=I.toDP=function(e,r){var t=this,n=t.constructor;return t=new n(t),e===void 0?t:(He(e,0,Dr),r===void 0?r=n.rounding:He(r,0,8),Y(t,e+t.e+1,r))},I.toExponential=function(e,r){var t,n=this,i=n.constructor;return e===void 0?t=ur(n,!0):(He(e,0,Dr),r===void 0?r=i.rounding:He(r,0,8),n=Y(new i(n),e+1,r),t=ur(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},I.toFixed=function(e,r){var t,n,i=this,u=i.constructor;return e===void 0?t=ur(i):(He(e,0,Dr),r===void 0?r=u.rounding:He(r,0,8),n=Y(new u(i),e+i.e+1,r),t=ur(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t},I.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=xn(m)-p.e-1,o=u%K,r.d[0]=Me(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(mr+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=fe(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=fe(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=fe(l,n,u,1).minus(p).abs().cmp(fe(c,t,u,1).minus(p).abs())<1?[l,n]:[c,t],s.precision=f,j=!0,D},I.toHexadecimal=I.toHex=function(e,r){return Jt(this,16,e,r)},I.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:He(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=fe(t,e,0,r,1).times(e),j=!0,Y(t)):(e.s=t.s,t=e),t},I.toNumber=function(){return+this},I.toOctal=function(e,r){return Jt(this,8,e,r)},I.toPower=I.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(Me(+a,l));if(a=new c(a),a.eq(1))return a;if(n=c.precision,u=c.rounding,e.eq(1))return Y(a,n,u);if(r=Pe(e.e/K),r>=e.d.length-1&&(t=l<0?-l:l)<=io)return i=Tn(c,a,t,n),e.s<0?new c(1).div(i):Y(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=Me(+a,l),r=t==0||!isFinite(t)?Pe(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(gr(a,n+t)),n),i.d&&(i=Y(i,n+5,1),Lr(i.d,n,u)&&(r=n+10,i=Y(Gt(e.times(gr(a,r+t)),r),r+5,1),+Ie(i.d).slice(n+1,n+15)+1==1e14&&(i=Y(i,n+1,0)))),i.s=o,j=!0,c.rounding=u,Y(i,n,u))},I.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):(He(e,1,Dr),r===void 0?r=i.rounding:He(r,0,8),n=Y(new i(n),e,r),t=ur(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+t:t},I.toSignificantDigits=I.toSD=function(e,r){var t=this,n=t.constructor;return e===void 0?(e=n.precision,r=n.rounding):(He(e,1,Dr),r===void 0?r=n.rounding:He(r,0,8)),Y(new n(t),e,r)},I.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},I.truncated=I.trunc=function(){return Y(new this.constructor(this),this.e+1,1)},I.valueOf=I.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+=dr(t)),u+=n;o=e[r],n=o+"",t=K-n.length,t&&(u+=dr(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return u+o}function He(e,r,t){if(e!==~~e||e<r||e>t)throw Error(mr+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=Me(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)==Me(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)==Me(10,r-3)-1,o}function ct(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]+=Zt.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 oo(e,r){var t,n,i;if(r.isZero())return r;n=r.d.length,n<32?(t=Math.ceil(n/3),i=(1/Dt(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),e.precision+=t,r=Mr(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 fe=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,x,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=er,p=K,f=Pe(n.e/p)-Pe(i.e/p)),x=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,x==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),x=O.length,B=W.length),b=x,v=W.slice(0,x),A=v.length;A<x;)v[A++]=0;R=O.slice(),R.unshift(0),M=O[0],O[1]>=c/2&&++M;do D=0,l=r(O,v,x,A),l<0?(y=v[0],x!=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,x<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,x,A),l<1&&(D++,t(v,x<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,_n=m;else{for(h=1,D=E[0];D>=10;D/=10)h++;g.e=h+f*p-1,Y(g,a?u+g.e+1:u,o,m)}return g}}();function Y(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/Me(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/Me(10,i-o-1)%10|0}if(n=n||r<0||h[D+1]!==void 0||(o<0?f:f%Me(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/Me(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]=Me(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=Me(10,K-u),h[D]=o>0?(f/Me(10,i-o)%Me(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]==er&&(h[0]=1));break}else{if(h[D]+=a,h[D]!=er)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 On(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)+dr(n):o>1&&(u=u.charAt(0)+"."+u.slice(1)),u=u+(e.e<0?"e":"e+")+e.e):i<0?(u="0."+dr(-i-1)+u,t&&(n=t-o)>0&&(u+=dr(n))):i>=o?(u+=dr(i+1-o),t&&(n=t-i-1)>0&&(u=u+"."+dr(n))):((n=i+1)<o&&(u=u.slice(0,n)+"."+u.slice(n)),t&&(n=t-o)>0&&(i+1===o&&(u+="."),u+=dr(n))),u}function lt(e,r){var t=e[0];for(r*=K;t>=10;t/=10)r++;return r}function ht(e,r,t){if(r>uo)throw j=!0,t&&(e.precision=t),Error(Bn);return Y(new e(at),r,1,!0)}function or(e,r,t){if(r>Vt)throw Error(Bn);return Y(new e(st),r,t,!0)}function xn(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 dr(e){for(var r="";e--;)r+="0";return r}function Tn(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),Pn(u.d,o)&&(i=!0)),t=Pe(t/2),t===0){t=u.d.length-1,i&&u.d[t]===0&&++u.d[t];break}r=r.times(r),Pn(r.d,o)}return j=!0,u}function In(e){return e.d[e.d.length-1]&1}function zn(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(Me(2,h))/Math.LN10*2+5|0,c+=n,t=u=o=new D(1),D.precision=c;;){if(u=Y(u.times(e),c,1),t=t.times(++f),a=o.plus(fe(u,t,c,1)),Ie(a.d).slice(0,c)===Ie(o.d).slice(0,c)){for(i=h;i--;)o=Y(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 Y(o,D.precision=m,p,j=!0);else return D.precision=m,o}o=a}}function gr(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=ht(g,f+2,v).times(u+""),s=gr(new g(n+"."+t.slice(1)),f-m).plus(l),g.precision=v,r==null?Y(s,v,E,j=!0):s;for(h=s,c=o=s=fe(s.minus(1),s.plus(1),f,1),D=Y(s.times(s),f,1),i=3;;){if(o=Y(o.times(D),f,1),l=c.plus(fe(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(ht(g,f+2,v).times(u+""))),c=fe(c,new g(p),f,1),r==null)if(Lr(c.d,f-m,E,a))g.precision=f+=m,l=o=s=fe(h.minus(1),h.plus(1),f,1),D=Y(s.times(s),f,1),i=a=1;else return Y(c,g.precision=v,E,j=!0);else return g.precision=v,c;c=l,i+=2}}function On(e){return String(e.s*e.s/0)}function pt(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 ao(e,r){var t,n,i,u,o,a,c,l,f;if(r.indexOf("_")>-1){if(r=r.replace(/(\d)_(?=\d)/g,"$1"),Sn.test(r))return pt(e,r)}else if(r==="Infinity"||r==="NaN")return+r||(e.s=NaN),e.e=NaN,e.d=null,e;if(to.test(r))t=16,r=r.toLowerCase();else if(ro.test(r))t=2;else if(no.test(r))t=8;else throw Error(mr+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=Tn(n,new n(t),u,u*2)),l=ct(r,t,er),f=l.length-1,u=f;l[u]===0;--u)l.pop();return u<0?new n(e.s*0):(e.e=lt(l,f),e.d=l,j=!1,o&&(e=fe(e,i,a*4)),c&&(e=e.times(Math.abs(c)<54?Me(2,c):Sr.pow(2,c))),j=!0,e)}function so(e,r){var t,n=r.d.length;if(n<3)return r.isZero()?r:Mr(e,2,r,r);t=1.4*Math.sqrt(n),t=t>16?16:t|0,r=r.times(1/Dt(5,t)),r=Mr(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 Mr(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=fe(a.times(c),new e(r++*r++),l,1),a=i?n.plus(o):n.minus(o),n=fe(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 Dt(e,r){for(var t=e;--r;)t*=e;return t}function $n(e,r){var t,n=r.s<0,i=or(e,e.precision,1),u=i.times(.5);if(r=r.abs(),r.lte(u))return sr=n?4:1,r;if(t=r.divToInt(i),t.isZero())sr=n?3:2;else{if(r=r.minus(t.times(i)),r.lte(u))return sr=In(t)?n?2:3:n?4:1,r;sr=In(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?(He(t,1,Dr),n===void 0?n=p.rounding:He(n,0,8)):(t=p.precision,n=p.rounding),!e.isFinite())f=On(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=ct(ur(D),10,i),D.e=D.d.length),h=ct(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=fe(e,D,t,n,0,i),h=e.d,u=e.e,l=_n),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+=Zt.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=ct(f,i,r),c=h.length;!h[c-1];--c);for(o=1,f="1.";o<c;o++)f+=Zt.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 Pn(e,r){if(e.length>r)return e.length=r,!0}function fo(e){return new this(e).abs()}function co(e){return new this(e).acos()}function lo(e){return new this(e).acosh()}function ho(e,r){return new this(e).plus(r)}function po(e){return new this(e).asin()}function Do(e){return new this(e).asinh()}function mo(e){return new this(e).atan()}function go(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=or(this,u,1).times(r.s>0?.25:.75),t.s=e.s):!r.d||e.isZero()?(t=r.s<0?or(this,n,i):new this(0),t.s=e.s):!e.d||r.isZero()?(t=or(this,u,1).times(.5),t.s=e.s):r.s<0?(this.precision=u,this.rounding=1,t=this.atan(fe(e,r,u,1)),r=or(this,u,1),this.precision=n,this.rounding=i,t=e.s<0?t.minus(r):t.plus(r)):t=this.atan(fe(e,r,u,1)),t}function wo(e){return new this(e).cbrt()}function yo(e){return Y(e=new this(e),e.e+1,2)}function Fo(e,r,t){return new this(e).clamp(r,t)}function Eo(e){if(!e||typeof e!="object")throw Error(ft+"Object expected");var r,t,n,i=e.defaults===!0,u=["precision",1,Dr,"rounding",0,8,"toExpNeg",-Nr,0,"toExpPos",0,Nr,"maxE",0,Nr,"minE",-Nr,0,"modulo",0,9];for(r=0;r<u.length;r+=3)if(t=u[r],i&&(this[t]=Wt[t]),(n=e[t])!==void 0)if(Pe(n)===n&&n>=u[r+1]&&n<=u[r+2])this[t]=n;else throw Error(mr+t+": "+n);if(t="crypto",i&&(this[t]=Wt[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(Nn);else this[t]=!1;else throw Error(mr+t+": "+n);return this}function Ao(e){return new this(e).cos()}function bo(e){return new this(e).cosh()}function Un(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,qn(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 pt(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),Sn.test(u)?pt(l,u):ao(l,u);if(c==="bigint")return u<0?(u=-u,l.s=-1):l.s=1,pt(l,u.toString());throw Error(mr+u)}if(i.prototype=I,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=Eo,i.clone=Un,i.isDecimal=qn,i.abs=fo,i.acos=co,i.acosh=lo,i.add=ho,i.asin=po,i.asinh=Do,i.atan=mo,i.atanh=go,i.atan2=vo,i.cbrt=wo,i.ceil=yo,i.clamp=Fo,i.cos=Ao,i.cosh=bo,i.div=Co,i.exp=_o,i.floor=Bo,i.hypot=No,i.ln=Mo,i.log=So,i.log10=To,i.log2=xo,i.max=Io,i.min=zo,i.mod=Oo,i.mul=$o,i.pow=Po,i.random=Uo,i.round=qo,i.sign=Ro,i.sin=Lo,i.sinh=Ho,i.sqrt=Zo,i.sub=Wo,i.sum=Vo,i.tan=Go,i.tanh=Jo,i.trunc=Yo,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 Co(e,r){return new this(e).div(r)}function _o(e){return new this(e).exp()}function Bo(e){return Y(e=new this(e),e.e+1,3)}function No(){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 qn(e){return e instanceof Sr||e&&e.toStringTag===Mn||!1}function Mo(e){return new this(e).ln()}function So(e,r){return new this(e).log(r)}function xo(e){return new this(e).log(2)}function To(e){return new this(e).log(10)}function Io(){return zn(this,arguments,-1)}function zo(){return zn(this,arguments,1)}function Oo(e,r){return new this(e).mod(r)}function $o(e,r){return new this(e).mul(r)}function Po(e,r){return new this(e).pow(r)}function Uo(e){var r,t,n,i,u=0,o=new this(1),a=[];if(e===void 0?e=this.precision:He(e,1,Dr),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(Nn);else for(;u<n;)a[u++]=Math.random()*1e7|0;for(n=a[--u],e%=K,n&&e&&(i=Me(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 qo(e){return Y(e=new this(e),e.e+1,this.rounding)}function Ro(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Lo(e){return new this(e).sin()}function Ho(e){return new this(e).sinh()}function Zo(e){return new this(e).sqrt()}function Wo(e,r){return new this(e).sub(r)}function Vo(){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,Y(t,this.precision,this.rounding)}function Go(e){return new this(e).tan()}function Jo(e){return new this(e).tanh()}function Yo(e){return Y(e=new this(e),e.e+1,1)}I[Symbol.for("nodejs.util.inspect.custom")]=I.toString,I[Symbol.toStringTag]="Decimal";var Sr=I.constructor=Un(Wt);at=new Sr(at),st=new Sr(st);var ko="BigNumber",Xo=["?on","config"],Qo=G(ko,Xo,e=>{var{on:r,config:t}=e,n=Sr.clone({precision:t.precision,modulo:Sr.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 Ue=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},Ko=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)},Yt=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))},xr=function(){throw SyntaxError("Invalid Param")};function kt(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 jo={re:0,im:0},Fr=function(e,r){const t=jo;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 S.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 S.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]):xr();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&&xr();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&&xr(),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))&&xr(),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&&xr();break;case"number":t.im=0,t.re=e;break;default:xr()}return isNaN(t.re)||isNaN(t.im),t};function S(e,r){if(!(this instanceof S))return new S(e,r);const t=Fr(e,r);this.re=t.re,this.im=t.im}S.prototype={re:0,im:0,sign:function(){const e=Yt(this.re,this.im);return new S(this.re/e,this.im/e)},add:function(e,r){const t=Fr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?S.NAN:S.INFINITY:new S(this.re+t.re,this.im+t.im)},sub:function(e,r){const t=Fr(e,r),n=this.isInfinite(),i=!(isFinite(t.re)&&isFinite(t.im));return n||i?n&&i?S.NAN:S.INFINITY:new S(this.re-t.re,this.im-t.im)},mul:function(e,r){const t=Fr(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?S.NAN:n||i?S.INFINITY:t.im===0&&this.im===0?new S(this.re*t.re,0):new S(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,r){const t=Fr(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 S.NAN;if(o||n)return S.INFINITY;if(u||i)return S.ZERO;if(t.im===0)return new S(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 S((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 S((this.re+this.im*a)/c,(this.im-this.re*a)/c)}},pow:function(e,r){const t=Fr(e,r),n=this.re===0&&this.im===0;if(t.re===0&&t.im===0)return S.ONE;if(t.im===0){if(this.im===0&&this.re>0)return new S(Math.pow(this.re,t.re),0);if(this.re===0)switch((t.re%4+4)%4){case 0:return new S(Math.pow(this.im,t.re),0);case 1:return new S(0,Math.pow(this.im,t.re));case 2:return new S(-Math.pow(this.im,t.re),0);case 3:return new S(0,-Math.pow(this.im,t.re))}}if(n&&t.re>0)return S.ZERO;const u=Math.atan2(this.im,this.re),o=kt(this.re,this.im);let a=Math.exp(t.re*o-t.im*u),c=t.im*o+t.re*u;return new S(a*Math.cos(c),a*Math.sin(c))},sqrt:function(){const e=this.re,r=this.im;if(r===0)return e>=0?new S(Math.sqrt(e),0):new S(0,Math.sqrt(-e));const t=Yt(e,r);let n=Math.sqrt(.5*(t+Math.abs(e))),i=Math.abs(r)/(2*n);return e>=0?new S(n,r<0?-i:i):new S(i,r<0?-n:n)},exp:function(){const e=Math.exp(this.re);return this.im===0?new S(e,0):new S(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){const e=this.re,r=this.im;return new S(Math.expm1(e)*Math.cos(r)+Ko(r),Math.exp(e)*Math.sin(r))},log:function(){const e=this.re,r=this.im;return r===0&&e>0?new S(Math.log(e),0):new S(kt(e,r),Math.atan2(r,e))},abs:function(){return Yt(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){const e=this.re,r=this.im;return new S(Math.sin(e)*Ue(r),Math.cos(e)*ke(r))},cos:function(){const e=this.re,r=this.im;return new S(Math.cos(e)*Ue(r),-Math.sin(e)*ke(r))},tan:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)+Ue(r);return new S(Math.sin(e)/t,ke(r)/t)},cot:function(){const e=2*this.re,r=2*this.im,t=Math.cos(e)-Ue(r);return new S(-Math.sin(e)/t,ke(r)/t)},sec:function(){const e=this.re,r=this.im,t=.5*Ue(2*r)+.5*Math.cos(2*e);return new S(Math.cos(e)*Ue(r)/t,Math.sin(e)*ke(r)/t)},csc:function(){const e=this.re,r=this.im,t=.5*Ue(2*r)-.5*Math.cos(2*e);return new S(Math.sin(e)*Ue(r)/t,-Math.cos(e)*ke(r)/t)},asin:function(){const e=this.re,r=this.im,t=new S(r*r-e*e+1,-2*e*r).sqrt(),n=new S(t.re-r,t.im+e).log();return new S(n.im,-n.re)},acos:function(){const e=this.re,r=this.im,t=new S(r*r-e*e+1,-2*e*r).sqrt(),n=new S(t.re-r,t.im+e).log();return new S(Math.PI/2-n.im,n.re)},atan:function(){const e=this.re,r=this.im;if(e===0){if(r===1)return new S(0,1/0);if(r===-1)return new S(0,-1/0)}const t=e*e+(1-r)*(1-r),n=new S((1-r*r-e*e)/t,-2*e/t).log();return new S(-.5*n.im,.5*n.re)},acot:function(){const e=this.re,r=this.im;if(r===0)return new S(Math.atan2(1,e),0);const t=e*e+r*r;return t!==0?new S(e/t,-r/t).atan():new S(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 S(0,1/0);const t=e*e+r*r;return t!==0?new S(e/t,-r/t).acos():new S(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 S(Math.PI/2,1/0);const t=e*e+r*r;return t!==0?new S(e/t,-r/t).asin():new S(e!==0?e/0:0,r!==0?-r/0:0).asin()},sinh:function(){const e=this.re,r=this.im;return new S(ke(e)*Math.cos(r),Ue(e)*Math.sin(r))},cosh:function(){const e=this.re,r=this.im;return new S(Ue(e)*Math.cos(r),ke(e)*Math.sin(r))},tanh:function(){const e=2*this.re,r=2*this.im,t=Ue(e)+Math.cos(r);return new S(ke(e)/t,Math.sin(r)/t)},coth:function(){const e=2*this.re,r=2*this.im,t=Ue(e)-Math.cos(r);return new S(ke(e)/t,-Math.sin(r)/t)},csch:function(){const e=this.re,r=this.im,t=Math.cos(2*r)-Ue(2*e);return new S(-2*ke(e)*Math.cos(r)/t,2*Ue(e)*Math.sin(r)/t)},sech:function(){const e=this.re,r=this.im,t=Math.cos(2*r)+Ue(2*e);return new S(2*Ue(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 S((i*n-r*r)/u,(r*n+i*r)/u):new S(e!==-1?e/0:0,r!==0?r/0:0),a=o.re;return o.re=kt(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 S(0,Math.PI/2);const t=e*e+r*r;return t!==0?new S(e/t,-r/t).atanh():new S(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 S(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);const t=e*e+r*r;return t!==0?new S(e/t,-r/t).asinh():new S(e!==0?e/0:0,r!==0?-r/0:0).asinh()},asech:function(){const e=this.re,r=this.im;if(this.isZero())return S.INFINITY;const t=e*e+r*r;return t!==0?new S(e/t,-r/t).acosh():new S(e!==0?e/0:0,r!==0?-r/0:0).acosh()},inverse:function(){if(this.isZero())return S.INFINITY;if(this.isInfinite())return S.ZERO;const e=this.re,r=this.im,t=e*e+r*r;return new S(e/t,-r/t)},conjugate:function(){return new S(this.re,-this.im)},neg:function(){return new S(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new S(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new S(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new S(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,r){const t=Fr(e,r);return Math.abs(t.re-this.re)<=S.EPSILON&&Math.abs(t.im-this.im)<=S.EPSILON},clone:function(){return new S(this.re,this.im)},toString:function(){let e=this.re,r=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<S.EPSILON&&(e=0),Math.abs(r)<S.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()}},S.ZERO=new S(0,0),S.ONE=new S(1,0),S.I=new S(0,1),S.PI=new S(Math.PI,0),S.E=new S(Math.E,0),S.INFINITY=new S(1/0,1/0),S.NAN=new S(NaN,NaN),S.EPSILON=1e-15;var ea="Complex",ra=[],ta=G(ea,ra,()=>(Object.defineProperty(S,"name",{value:"Complex"}),S.prototype.constructor=S,S.prototype.type="Complex",S.prototype.isComplex=!0,S.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},S.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},S.prototype.format=function(e){var r="",t=this.im,n=this.re,i=Ht(this.re,e),u=Ht(this.im,e),o=pe(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},S.fromPolar=function(e){switch(arguments.length){case 1:{var r=arguments[0];if(typeof r=="object")return S(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(pe(t)){if(mn(n)&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),pe(n))return new S({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")}},S.prototype.valueOf=S.prototype.toString,S.fromJSON=function(e){return new S(e)},S.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},S),{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),Xt=BigInt(5),Ze=BigInt(10),na=2e3,L={s:re,n:k,d:re};function fr(e,r){try{e=BigInt(e)}catch{throw vr()}return e*r}function rr(e){return typeof e=="bigint"?e:Math.floor(e)}function Ee(e,r){if(r===k)throw Qt();const t=Object.create(Xe.prototype);t.s=e<k?-re:re,e=e<k?-e:e;const n=Er(e,r);return t.n=e/n,t.d=r/n,t}function Tr(e){const r={};let t=e,n=Hr,i=Xt-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 Se=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 vr();if(e%1!==0)throw Rn();t=BigInt(e)}if(typeof r=="bigint")n=r;else{if(isNaN(r))throw vr();if(r%1!==0)throw Rn();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 vr();i=t*n}else if(typeof e=="number"){if(isNaN(e))throw vr();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 vr();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 vr()}else if(typeof e=="bigint")t=e,i=e,n=re;else throw vr();if(n===k)throw Qt();L.s=i<k?-re:re,L.n=t<k?-t:t,L.d=n<k?-n:n};function ia(e,r,t){let n=re;for(;r>k;e=e*e%t,r>>=re)r&re&&(n=n*e%t);return n}function ua(e,r){for(;r%Hr===k;r/=Hr);for(;r%Xt===k;r/=Xt);if(r===re)return k;let t=Ze%r,n=1;for(;t!==re;n++)if(t=t*Ze%r,n>na)return k;return BigInt(n)}function oa(e,r,t){let n=re,i=ia(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 Er(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(Se(e,r),this instanceof Xe)e=Er(L.d,L.n),this.s=L.s,this.n=L.n/e,this.d=L.d/e;else return Ee(L.s*L.n,L.d)}var Qt=function(){return new Error("Division by Zero")},vr=function(){return new Error("Invalid argument")},Rn=function(){return new Error("Parameters must be integer")};Xe.prototype={s:re,n:k,d:re,abs:function(){return Ee(this.n,this.d)},neg:function(){return Ee(-this.s*this.n,this.d)},add:function(e,r){return Se(e,r),Ee(this.s*this.n*L.d+L.s*this.d*L.n,this.d*L.d)},sub:function(e,r){return Se(e,r),Ee(this.s*this.n*L.d-L.s*this.d*L.n,this.d*L.d)},mul:function(e,r){return Se(e,r),Ee(this.s*L.s*this.n*L.n,this.d*L.d)},div:function(e,r){return Se(e,r),Ee(this.s*L.s*this.n*L.d,this.d*L.n)},clone:function(){return Ee(this.s*this.n,this.d)},mod:function(e,r){if(e===void 0)return Ee(this.s*this.n%this.d,re);if(Se(e,r),k===L.n*this.d)throw Qt();return Ee(this.s*(L.d*this.n)%(L.n*this.d),L.d*this.d)},gcd:function(e,r){return Se(e,r),Ee(Er(L.n,this.n)*Er(L.d,this.d),L.d*this.d)},lcm:function(e,r){return Se(e,r),L.n===k&&this.n===k?Ee(k,re):Ee(L.n*this.n,Er(L.n,this.n)*Er(L.d,this.d))},inverse:function(){return Ee(this.s*this.d,this.n)},pow:function(e,r){if(Se(e,r),L.d===re)return L.s<k?Ee((this.s*this.d)**L.n,this.n**L.n):Ee((this.s*this.n)**L.n,this.d**L.n);if(this.s<k)return null;let t=Tr(this.n),n=Tr(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?Ee(u,i):Ee(i,u)},log:function(e,r){if(Se(e,r),this.s<=k||L.s<=k)return null;const t={},n=Tr(L.n),i=Tr(L.d),u=Tr(this.n),o=Tr(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=Er(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?Ee(a,c):null},equals:function(e,r){return Se(e,r),this.s*this.n*L.d===L.s*L.n*this.d},lt:function(e,r){return Se(e,r),this.s*this.n*L.d<L.s*L.n*this.d},lte:function(e,r){return Se(e,r),this.s*this.n*L.d<=L.s*L.n*this.d},gt:function(e,r){return Se(e,r),this.s*this.n*L.d>L.s*L.n*this.d},gte:function(e,r){return Se(e,r),this.s*this.n*L.d>=L.s*L.n*this.d},compare:function(e,r){Se(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),Ee(rr(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),Ee(rr(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),Ee(rr(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){Se(e,r);const t=this.n*L.d,n=this.d*L.n,i=t%n;let u=rr(t/n);return i+i>=n&&u++,Ee(this.s*u*L.n,L.d)},divisible:function(e,r){return Se(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=ua(r,t),i=oa(r,t,n),u=this.s<k?"-":"";if(u+=rr(r/t),r%=t,r*=Ze,r&&(u+="."),n){for(let o=i;o--;)u+=rr(r/t),r%=t,r*=Ze;u+="(";for(let o=n;o--;)u+=rr(r/t),r%=t,r*=Ze;u+=")"}else for(let o=e;r&&o--;)u+=rr(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=rr(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=rr(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(rr(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=Ee(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 aa="Fraction",sa=[],fa=G(aa,sa,()=>(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}),ca="Matrix",la=[],ha=G(ca,la,()=>{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 Kt(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(!de(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 pa(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}=yn(r);switch(t){case"fixed":return ma(e,n);case"exponential":return Ln(e,n);case"engineering":return Da(e,n);case"bin":return Kt(e,2,i);case"oct":return Kt(e,8,i);case"hex":return Kt(e,16,i);case"auto":{var u=Hn(r?.lowerExp,-3),o=Hn(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=Ln(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 Da(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 Ln(e,r){return r!==void 0?e.toExponential(r-1):e.toExponential()}function ma(e,r){return e.toFixed(r)}function Hn(e,r){return pe(e)?e:Fe(e)?e.toNumber():r}function _e(e,r){var t=da(e,r);return r&&typeof r=="object"&&"truncate"in r&&t.length>r.truncate?t.substring(0,r.truncate-3)+"...":t}function da(e,r){if(typeof e=="number")return Ht(e,r);if(Fe(e))return pa(e,r);if(ga(e))return!r||r.fraction!=="decimal"?"".concat(e.s*e.n,"/").concat(e.d):e.toString();if(Array.isArray(e))return Vn(e,r);if(Je(e))return Zn(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=>Zn(n)+": "+_e(e[n],r));return"{"+t.join(", ")+"}"}return String(e)}function Zn(e){for(var r=String(e),t="",n=0;n<r.length;){var i=r.charAt(n);t+=i in Wn?Wn[i]:i,n++}return'"'+t+'"'}var Wn={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"};function Vn(e,r){if(Array.isArray(e)){for(var t="[",n=e.length,i=0;i<n;i++)i!==0&&(t+=", "),t+=Vn(e[i],r);return t+="]",t}else return _e(e,r)}function ga(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 Ar(e,r,t){if(!(this instanceof Ar))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}Ar.prototype=new RangeError,Ar.prototype.constructor=RangeError,Ar.prototype.name="IndexError",Ar.prototype.isIndexError=!0;function ze(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function Gn(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,"<");Gn(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 Jn(e,r){var t=r.length===0;if(t){if(Array.isArray(e))throw new ne(e.length,0)}else Gn(e,r,0)}function mt(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 ge(e,r){if(e!==void 0){if(!pe(e)||!de(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||typeof r=="number"&&e>=r)throw new Ar(e,r)}}function Ir(e){for(var r=0;r<e._dimensions.length;++r){var t=e._dimensions[r];if(t._data&&we(t._data)){if(t._size[0]===0)return!0}else if(t.isRange){if(t.start===t.end)return!0}else if(Je(t)&&t.length===0)return!0}return!1}function dt(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(!pe(i)||!de(i)||i<0)throw new TypeError("Invalid size, must contain positive integers (size: "+_e(r)+")")}),(pe(e)||Fe(e))&&(e=[e]);var n=t!==void 0?t:0;return jt(e,r,0,n),e}function jt(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),jt(u,r,l,n);for(i=c;i<a;i++)u=[],e[i]=u,jt(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 Yn(e,r){var t=wa(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=en(r,n);var i=kn(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 en(e,r){var t=kn(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 kn(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 Xn(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=Qn(e,r,0);i.length<r;)i.push(1);return e}function Qn(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]=Qn(e[n],r,u)}else for(var o=t;o<r;o++)e=[e];return e}function wa(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 gt(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?gt(u,r):r(u);if(t===void 0)t=a;else if(t!==a)return"mixed"}return t}function Kn(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]=Kn(e[u],r[u],t,n+1);return i}else return e.concat(r)}function jn(){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 Kn(t,n,r,0)},e[0]);throw new Error("Wrong number of arguments in function concat")}function ei(){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++)ri(r[h],u);return u}function ri(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 rn(e,r){var t=ze(e);if(pr(t,r))return e;ri(t,r);var n=ei(t,r),i=n.length,u=[...Array(i-t.length).fill(1),...t],o=Fa(e);t.length<i&&(o=Yn(o,u),t=ze(o));for(var a=0;a<i;a++)t[a]<n[a]&&(o=ya(o,n[a],a),t=ze(o));return o}function ya(e,r,t){return jn(...Array(r).fill(e),t)}function ti(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++)ge(r[n],t[n]);return r.reduce((i,u)=>i[u],e)}function ni(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 Fa(e){return hr([],e)}function vt(e,r,t){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(tt.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):ti(r,u);i=ba(e,o,u,r)}var a;if(r.isMatrix&&r.dataType!=="mixed"&&r.dataType!==void 0){var c=Ea(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 ii(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 ii(a,h,t,e.name)}}}return n===void 0?{isUnary:Aa(e),fn:e}:{isUnary:n,fn:e}}function Ea(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 Aa(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 ba(e,r,t,n){for(var i=[r,t,n],u=3;u>0;u--){var o=i.slice(0,u);if(tt.resolve(e,o)!==null)return u}}function ii(e,r,t,n){try{return e(...r)}catch(i){Ca(i,r,t,n)}}function Ca(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 _a="DenseMatrix",Ba=["Matrix"],Na=G(_a,Ba,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&&!Je(h))throw new Error("Invalid datatype: "+h);if(De(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&&we(f.data)&&we(f.size))this._data=f.data,this._size=f.size,Jn(this._data,this._size),this._datatype=h||f.datatype;else if(we(f))this._data=l(f),this._size=ze(this._data),Jn(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 gt(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 ti(this._data,f)},t.prototype.set=function(f,h,D){if(!we(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],ge(s,g.length),g=g[s];return s=f[f.length-1],ge(s,g.length),g[s]=h,this};function n(f,h){if(!rt(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++)ge(m[d],f._size[d]),ge(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=>(ge(E,s.length),m(s[E],d+1))).valueOf():g.map(E=>(ge(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(De(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(!pr(d,m))try{d.length===0?D=rn([D],m):D=rn(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=Xn(D,m.length,E,d)}if(!pr(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)=>{ge(v,s.length),m(s[v],d[A[0]],g+1)}):E.forEach((v,A)=>{ge(v,s.length),s[v]=d[A[0]]})}}t.prototype.resize=function(f,h,D){if(!et(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;we(p);)p=p[0];return p}return f._size=h.slice(0),f._data=dt(f._data,f._size,D),f}t.prototype.reshape=function(f,h){var D=h?this.clone():this;D._data=Yn(D._data,f);var p=D._size.reduce((m,s)=>m*s);return D._size=en(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=vt(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 x=0;x<C.length;x++)A[b]=x,B[x]=s(C[x],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 x=0;x<C.length;x++)B[x]=s(C[x]);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=vt(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 _e(this._data,f)},t.prototype.toString=function(){return _e(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(Fe(f)&&(f=f.toNumber()),!pe(f)||!de(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(!we(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(Fe(C)&&(C=C.toNumber()),!pe(C)||!de(C)||C<1)throw new Error("Size values must be positive integers");return C}),D){if(Fe(D)&&(D=D.toNumber()),!pe(D)||!de(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(we(h)){if(h.length!==E)throw new Error("Invalid value array length");v=function(b){return h[b]}}else if(De(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=Fe(v(0))?v(0).mul(0):0);var y=[];if(f.length>0){y=dt(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(!pe(f)||!de(f)||!pe(h)||!de(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 ge(f,this._size[0]),ge(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 De(f)?l(f.valueOf()):we(f)?f.map(l):f}return t},{isClass:!0});function We(e,r,t){if(!t)return De(e)?e.map(i=>r(i),!1,!0):ni(e,r,!0);var n=i=>i===0?i:r(i);return De(e)?e.map(i=>n(i),!1,!0):ni(e,n,!0)}var ui="isInteger",Ma=["typed"],Sa=G(ui,Ma,e=>{var{typed:r}=e;return r(ui,{number:de,BigNumber:function(n){return n.isInt()},bigint:function(n){return!0},Fraction:function(n){return n.d===1n},"Array | Matrix":r.referToSelf(t=>n=>We(n,t))})}),tn="number",wt="number, number";function oi(e){return Math.abs(e)}oi.signature=tn;function ai(e,r){return e+r}ai.signature=wt;function si(e,r){return e-r}si.signature=wt;function fi(e,r){return e*r}fi.signature=wt;function ci(e){return-e}ci.signature=tn;function yt(e){return Yu(e)}yt.signature=tn;function li(e,r){return e*e<1&&r===1/0||e*e>1&&r===-1/0?0:Math.pow(e,r)}li.signature=wt;function Zr(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!de(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(Fn(e,r))}var xa=Math.PI,Ta="number";function hi(e){return e>0}hi.signature=Ta;function wr(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 pi="isPositive",Ia=["typed","config"],za=G(pi,Ia,e=>{var{typed:r,config:t}=e;return r(pi,{number:n=>je(n,0,t.relTol,t.absTol)?!1:hi(n),BigNumber:n=>wr(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=>We(i,n))})}),Di="isZero",Oa=["typed","equalScalar"],$a=G(Di,Oa,e=>{var{typed:r,equalScalar:t}=e;return r(Di,{"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=>We(i,n))})});function Pa(e,r,t,n){return je(e.re,r.re,t,n)&&je(e.im,r.im,t,n)}var Wr=G("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)})}}),Ft="equalScalar",Ua=["typed","config"],qa=G(Ft,Ua,e=>{var{typed:r,config:t}=e,n=Wr({typed:r});return r(Ft,{"boolean, boolean":function(u,o){return u===o},"number, number":function(u,o){return je(u,o,t.relTol,t.absTol)},"BigNumber, BigNumber":function(u,o){return u.eq(o)||wr(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 Pa(u,o,t.relTol,t.absTol)}},n)});G(Ft,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Ft,{"number, number":function(i,u){return je(i,u,t.relTol,t.absTol)}})});var Ra="SparseMatrix",La=["typed","equalScalar","Matrix"],Ha=G(Ra,La,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&&!Je(d))throw new Error("Invalid datatype: "+d);if(De(s))u(this,s,d);else if(s&&we(s.index)&&we(s.ptr)&&we(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(we(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(Je(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(we(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 gt(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(!rt(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++)ge(C[v],s._size[v]),ge(b[v],s._size[v]);var B=s._values,M=s._index,x=s._ptr,R=d.dimension(0),V=d.dimension(1),q=[],W=[];R.forEach(function(J,ee){W[J]=ee[0],q[J]=!0});var O=B?[]:void 0,Q=[],X=[];return V.forEach(function(J){for(X.push(Q.length),y=x[J],w=x[J+1];y<w;y++)v=M[y],q[v]===!0&&(Q.push(W[v]),O&&O.push(B[y]))}),X.push(Q.length),new i({values:O,index:Q,ptr:X,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(De(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=Xn(g,v.length,C,y)}if(!pr(v,y))throw new ne(v,y,">");if(v.length===1){var b=d.dimension(0);b.forEach(function(x,R){ge(x),s.set([x,0],g[R[0]],E)})}else{var B=d.dimension(0),M=d.dimension(1);B.forEach(function(x,R){ge(x),M.forEach(function(V,q){ge(V),s.set([x,V],g[R[0]][q[0]],E)})})}}return s}i.prototype.get=function(s){if(!we(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];ge(d,this._size[0]),ge(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(!we(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;Je(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]),ge(E,A),ge(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(!et(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(!pe(A)||!de(A)||A<0)throw new TypeError("Invalid size, must contain positive integers (size: "+_e(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;Je(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,x;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,x=s._ptr[M+1]+R;var V=0;for(B=C;B<d;B++,V++)s._values.splice(x+V,0,v),s._index.splice(x+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(x=W;x<O;x++)B=s._index[x],B>d-1&&(s._values.splice(x,1),s._index.splice(x,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(!we(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(J){if(!pe(J)||!de(J)||J<=-2||J===0)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+_e(s)+")")});var g=this._size[0]*this._size[1];s=en(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],x=A[B],R=M*v._size[1]+x;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],X=l(W,v._ptr[O],v._ptr[O+1],v._index);h(X,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=vt(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;Je(s._datatype)&&(B=r.find(t,[s._datatype,s._datatype])||t,M=r.convert(0,s._datatype));for(var x=function(ce,Be,Ce){var be=A(ce,Be,Ce);B(be,M)||(w.push(be),C.push(Be))},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&&x(s._values[W],O-d,R-E)}else{for(var Q={},X=V;X<q;X++){var J=s._index[X];Q[J]=s._values[X]}for(var ee=d;ee<=g;ee++){var oe=ee in Q?Q[ee]:0;x(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=vt(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={},x=w;x<C;x++){var R=this._index[x];M[R]=this._values[x]}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],x=B;x<M;x++)C=d[x],w[C][b]=s?v?me(s[x]):s[x]: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 ["+_e(d,s)+" x "+_e(g,s)+"] density: "+_e(E,s)+`
|
|
16
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
|
-
(`+Ce(b,s)+", "+Ce(A,s)+") ==> "+(this._values?Ce(this._values[C],s):"X")}return v},i.prototype.toString=function(){return Ce(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(Fe(s)&&(s=s.toNumber()),!pe(s)||!de(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],x=B;x<M;x++){var R=this._index[x];if(R===b-d+g){y.push(this._values[x]),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(!we(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(Fe(G)&&(G=G.toNumber()),!pe(G)||!de(G)||G<1)throw new Error("Size values must be positive integers");return G}),g){if(Fe(g)&&(g=g.toNumber()),!pe(g)||!de(g))throw new TypeError("The parameter k must be an integer number")}else g=0;var A=t,y=0;Je(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),x;if(we(d)){if(d.length!==M)throw new Error("Invalid value array length");x=function(ee){return d[ee]}}else if(De(d)){var R=d.size();if(R.length!==1||R[0]!==M)throw new Error("Invalid matrix length");x=function(ee){return d.get([ee])}}else x=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 X=x(Q);A(X,y)||(q.push(Q+C),V.push(X))}}return W.push(V.length),new i({values:V,index:q,ptr:W,size:[b,B]})},i.prototype.swapRows=function(s,d){if(!pe(s)||!de(s)||!pe(d)||!de(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 ge(s,this._size[0]),ge(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 x=E?E[b]:void 0;v.splice(B,0,d),E&&E.splice(B,0,x),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}),Ra="number",La=["typed"];function Ha(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 Za(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 Wa=J(Ra,La,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=Ha(i);if(u)return Za(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=>Ze(i,n))});return t.fromJSON=function(n){return parseFloat(n.value)},t}),Va="bignumber",Ja=["typed","BigNumber"],Ga=J(Va,Ja,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=>Ze(i,n))})}),Ya="complex",ka=["typed","Complex"],Xa=J(Ya,ka,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=>Ze(i,n))})}),Qa="fraction",Ka=["typed","Fraction"],ja=J(Qa,Ka,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=>Ze(i,n))})}),hi="matrix",es=["typed","Matrix","DenseMatrix","SparseMatrix"],rs=J(hi,es,e=>{var{typed:r,Matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(hi,{"":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)+".")}}),pi="unaryMinus",ts=["typed"],ns=J(pi,ts,e=>{var{typed:r}=e;return r(pi,{number:ai,"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=>Ze(n,t,!0))})}),Di="abs",is=["typed"],us=J(Di,is,e=>{var{typed:r}=e;return r(Di,{number:ni,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),bigint:t=>t<0n?-t:t,"Array | Matrix":r.referToSelf(t=>n=>Ze(n,t,!0))})}),mi="addScalar",os=["typed"],as=J(mi,os,e=>{var{typed:r}=e;return r(mi,{"number, number":ii,"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})})}),di="subtractScalar",ss=["typed"],fs=J(di,ss,e=>{var{typed:r}=e;return r(di,{"number, number":ui,"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})})}),cs="matAlgo11xS0s",ls=["typed","equalScalar"],gi=J(cs,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],x=a?E(u,c[B]):E(c[B],u);d(x,g)||(A.push(M),v.push(x))}}return y[m]=A.length,i.createSparseMatrix({values:v,index:A,ptr:y,size:[p,m],datatype:s})}}),hs="matAlgo12xSfs",ps=["typed","DenseMatrix"],Vr=J(hs,ps,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})}}),Ds="matAlgo14xDs",ms=["typed"],Kt=J(Ds,ms,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}}),ds="matAlgo03xDSf",gs=["typed"],yt=J(ds,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],x=D[b+1],R=M;R<x;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})}}),vs="matAlgo13xDD",ws=["typed"],ys=J(vs,ws,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(pr(e.size(),r.size()))return[e,r];var t=Qn(e.size(),r.size());return[e,r].map(n=>Fs(n,t))}function Fs(e,r){return pr(e.size(),r)?e:e.create(Xt(e.valueOf(),r),e.datatype())}var Es="matrixAlgorithmSuite",As=["typed","matrix"],Jr=J(Es,As,e=>{var{typed:r,matrix:t}=e,n=ys({typed:r}),i=Kt({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&&Uu(l,a.signatures),l}}),bs="matAlgo01xDSid",Cs=["typed"],_s=J(bs,Cs,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],x=B;x<M;x++)v=h[x],w[v]=o?E(f[x],a[v][A]):E(a[v][A],f[x]),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})}}),Bs="matAlgo04xSidSid",Ns=["typed","equalScalar"],Ms=J(Bs,Ns,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,x=a&&D?[]:void 0,R=[],V=[],q,W,O,Q,X;for(W=0;W<E;W++){B[W]=b.length;var G=W+1;for(Q=l[W],X=l[W+1],O=Q;O<X;O++)q=c[O],b.push(q),R[q]=G,M&&(M[q]=a[O]);for(Q=m[W],X=m[W+1],O=Q;O<X;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,x&&(x[q]=D[O]);if(M&&x)for(O=B[W];O<b.length;)q=b[O],R[q]===G?(C[O]=M[q],O++):V[q]===G?(C[O]=x[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})}}),Ss="matAlgo10xSids",xs=["typed","DenseMatrix"],Ts=J(Ss,xs,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 Is(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 vi="log10",zs=["typed","config","Complex"],Os=vt(16),$s=J(vi,zs,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(vi,{number:function(a){return a>=0||t.predictable?vt(a):u(a)},bigint:Is(Os,vt,t,u),Complex:i,BigNumber:function(a){return!a.isNegative()||t.predictable?a.log():u(a.toNumber())},"Array | Matrix":r.referToSelf(o=>a=>Ze(a,o))})}),Ps="multiplyScalar",Us=["typed"],qs=J(Ps,Us,e=>{var{typed:r}=e;return r("multiplyScalar",{"number, number":oi,"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)})}),wi="multiply",Rs=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Ls=J(wi,Rs,e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,equalScalar:u,dot:o}=e,a=gi({typed:r,equalScalar:u}),c=Kt({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,x=w._size,R=w._datatype||w.getDataType(),V=b[0],q=x[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 X=[],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]));X[G]=ee}return y.createDenseMatrix({data:X,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,x=w._datatype||w.getDataType(),R=b[0],V=b[1],q,W=n,O=i;B&&x&&B===x&&typeof B=="string"&&B!=="mixed"&&(q=B,W=r.find(n,[q,q]),O=r.find(i,[q,q]));for(var Q=[],X=0;X<R;X++){for(var G=C[X],ee=O(G[0],M[0]),oe=1;oe<V;oe++)ee=W(ee,O(G[oe],M[oe]));Q[X]=ee}return y.createDenseMatrix({data:Q,size:[R],datatype:B===y._datatype&&x===w._datatype?q:void 0})}function d(y,w){var C=y._data,b=y._size,B=y._datatype||y.getDataType(),M=w._data,x=w._size,R=w._datatype||w.getDataType(),V=b[0],q=b[1],W=x[1],O,Q=n,X=i;B&&R&&B===R&&typeof B=="string"&&B!=="mixed"&&B!=="mixed"&&(O=B,Q=r.find(n,[O,O]),X=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 ce=X(oe[0],M[0][ie]),_e=1;_e<q;_e++)ce=Q(ce,X(oe[_e],M[_e][ie]));G[ee][ie]=ce}}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,x=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,X=n,G=i,ee=u,oe=0;B&&q&&B===q&&typeof B=="string"&&B!=="mixed"&&(Q=B,X=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=[],ce=[],_e=[],be=w.createSparseMatrix({values:ie,index:ce,ptr:_e,size:[W,O],datatype:B===y._datatype&&q===w._datatype?Q:void 0}),Ae=0;Ae<O;Ae++){_e[Ae]=ce.length;var ye=R[Ae],qe=R[Ae+1];if(qe>ye)for(var le=0,ae=0;ae<W;ae++){for(var Xe=ae+1,ze=void 0,he=ye;he<qe;he++){var xe=x[he];le!==Xe?(ze=G(C[ae][xe],M[he]),le=Xe):ze=X(ze,G(C[ae][xe],M[he]))}le===Xe&&!ee(ze,oe)&&(ce.push(ae),ie.push(ze))}}return _e[O]=ce.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 x=w._data,R=w._datatype||w.getDataType(),V=y._size[0],q=w._size[0],W=[],O=[],Q=[],X,G=n,ee=i,oe=u,ie=0;M&&R&&M===R&&typeof M=="string"&&M!=="mixed"&&(X=M,G=r.find(n,[X,X]),ee=r.find(i,[X,X]),oe=r.find(u,[X,X]),ie=r.convert(0,X));var ce=[],_e=[];Q[0]=0;for(var be=0;be<q;be++){var Ae=x[be];if(!oe(Ae,ie))for(var ye=B[be],qe=B[be+1],le=ye;le<qe;le++){var ae=b[le];_e[ae]?ce[ae]=G(ce[ae],ee(Ae,C[le])):(_e[ae]=!0,O.push(ae),ce[ae]=ee(Ae,C[le]))}}for(var Xe=O.length,ze=0;ze<Xe;ze++){var he=O[ze];W[ze]=ce[he]}return Q[1]=O.length,y.createSparseMatrix({values:W,index:O,ptr:Q,size:[V,1],datatype:M===y._datatype&&R===w._datatype?X: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 x=w._data,R=w._datatype||w.getDataType(),V=y._size[0],q=w._size[0],W=w._size[1],O,Q=n,X=i,G=u,ee=0;M&&R&&M===R&&typeof M=="string"&&M!=="mixed"&&(O=M,Q=r.find(n,[O,O]),X=r.find(i,[O,O]),G=r.find(u,[O,O]),ee=r.convert(0,O));for(var oe=[],ie=[],ce=[],_e=y.createSparseMatrix({values:oe,index:ie,ptr:ce,size:[V,W],datatype:M===y._datatype&&R===w._datatype?O:void 0}),be=[],Ae=[],ye=0;ye<W;ye++){ce[ye]=ie.length;for(var qe=ye+1,le=0;le<q;le++){var ae=x[le][ye];if(!G(ae,ee))for(var Xe=B[le],ze=B[le+1],he=Xe;he<ze;he++){var xe=b[he];Ae[xe]!==qe?(Ae[xe]=qe,ie.push(xe),be[xe]=X(ae,C[he])):be[xe]=Q(be[xe],X(ae,C[he]))}}for(var Qe=ce[ye],fr=ie.length,cr=Qe;cr<fr;cr++){var $r=ie[cr];oe[cr]=be[$r]}}return ce[W]=ie.length,_e}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(),x=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&&x,X,G=n,ee=i;M&&q&&M===q&&typeof M=="string"&&M!=="mixed"&&(X=M,G=r.find(n,[X,X]),ee=r.find(i,[X,X]));for(var oe=Q?[]:void 0,ie=[],ce=[],_e=y.createSparseMatrix({values:oe,index:ie,ptr:ce,size:[W,O],datatype:M===y._datatype&&q===w._datatype?X:void 0}),be=Q?[]:void 0,Ae=[],ye,qe,le,ae,Xe,ze,he,xe,Qe=0;Qe<O;Qe++){ce[Qe]=ie.length;var fr=Qe+1;for(Xe=V[Qe],ze=V[Qe+1],ae=Xe;ae<ze;ae++)if(xe=R[ae],Q)for(qe=B[xe],le=B[xe+1],ye=qe;ye<le;ye++)he=b[ye],Ae[he]!==fr?(Ae[he]=fr,ie.push(he),be[he]=ee(x[ae],C[ye])):be[he]=G(be[he],ee(x[ae],C[ye]));else for(qe=B[xe],le=B[xe+1],ye=qe;ye<le;ye++)he=b[ye],Ae[he]!==fr&&(Ae[he]=fr,ie.push(he));if(Q)for(var cr=ce[Qe],$r=ie.length,Pr=cr;Pr<$r;Pr++){var on=ie[Pr];oe[Pr]=be[on]}}return ce[O]=ie.length,_e}return r(wi,i,{"Array, Array":r.referTo("Matrix, Matrix",y=>(w,C)=>{l(Ie(w),Ie(C));var b=y(t(w),t(C));return De(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})})}),Hs="matAlgo07xSSf",Zs=["typed","SparseMatrix"],Ft=J(Hs,Zs,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 x=0;x<D;x++){var R=w[x]===B?A[x]:s,V=C[x]===B?y[x]:s,q=d(R,V);q!==0&&q!==!1&&(E.push(x),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]}}}),yi="arg",Ws=["typed"],Vs=J(yi,Ws,e=>{var{typed:r}=e;return r(yi,{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=>Ze(n,t))})}),Fi="conj",Js=["typed"],Gs=J(Fi,Js,e=>{var{typed:r}=e;return r(Fi,{"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=>Ze(n,t))})}),Ei="concat",Ys=["typed","matrix","isInteger"],ks=J(Ei,Ys,e=>{var{typed:r,matrix:t,isInteger:n}=e;return r(Ei,{"...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(De(D)&&(f=!0),pe(D)||Fe(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 Ar(c,l+1)}else{var p=me(D).valueOf(),m=Ie(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=Xn(s,h.shift(),c);return f?t(s):s},"...string":function(u){return u.join("")}})}),Ai="getMatrixDataType",Xs=["typed"],Qs=J(Ai,Xs,e=>{var{typed:r}=e;return r(Ai,{Array:function(n){return mt(n,nr)},Matrix:function(n){return n.getDataType()}})}),bi="identity",Ks=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],js=J(bi,Ks,e=>{var{typed:r,config:t,matrix:n,BigNumber:i,DenseMatrix:u,SparseMatrix:o}=e;return r(bi,{"":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=Fe(l)||Fe(f)?i:null;if(Fe(l)&&(l=l.toNumber()),Fe(f)&&(f=f.toNumber()),!de(l)||l<1)throw new Error("Parameters in function identity must be positive integers");if(!de(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=Dt([],s,m),g=l<f?l:f,E=0;E<g;E++)d[E][E]=p;return d}});function Ci(){throw new Error('No "bignumber" implementation available')}function ef(){throw new Error('No "fraction" implementation available')}function _i(){throw new Error('No "matrix" implementation available')}var Bi="range",rf=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq","add","isPositive"],tf=J(Bi,rf,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(Bi,{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):_i():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&&Ci(),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}}}),Ni="size",nf=["typed","config","?matrix"],uf=J(Ni,nf,e=>{var{typed:r,config:t,matrix:n}=e;return r(Ni,{Matrix:function(u){return u.create(u.size(),"number")},Array:Ie,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"):_i()}})}),Mi="subset",of=["typed","matrix","zeros","add"],af=J(Mi,of,e=>{var{typed:r,matrix:t,zeros:n,add:i}=e;return r(Mi,{"Matrix, Index":function(a,c){return Tr(c)?t():(pt(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":ff,"string, Index":sf,"Matrix, Index, any, any":function(a,c,l,f){return Tr(c)?a:(pt(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":Si,"string, Index, string, string":Si,"Object, Index, any":cf});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 sf(e,r){if(!jr(r))throw new TypeError("Index expected");if(Tr(r))return"";if(pt(Array.from(e),r),r.size().length!==1)throw new ne(r.size().length,1);var t=e.length;ge(r.min()[0],t),ge(r.max()[0],t);var n=r.dimension(0),i="";return n.forEach(function(u){i+=e.charAt(u)}),i}function Si(e,r,t,n){if(!r||r.isIndex!==!0)throw new TypeError("Index expected");if(Tr(r))return e;if(pt(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;ge(r.min()[0]),ge(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 ff(e,r){if(!Tr(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 sn(e,t)}}function cf(e,r,t){if(Tr(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 fn(i,n,t),i}var xi="zeros",lf=["typed","config","matrix","BigNumber"],hf=J(xi,lf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(xi,{"":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?Dt(p,c,h):p}}function o(c){var l=!1;return c.forEach(function(f,h,D){Fe(f)&&(l=!0,D[h]=f.toNumber())}),l}function a(c){c.forEach(function(l){if(typeof l!="number"||!de(l)||l<0)throw new Error("Parameters in function zeros must be positive integers")})}}),pf="numeric",Df=["number","?bignumber","?fraction"],mf=J(pf,Df,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):Ci,bigint:o=>BigInt(o),Fraction:n?o=>n(o):ef};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=nr(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)}}),Ti="divideScalar",df=["typed","numeric"],gf=J(Ti,df,e=>{var{typed:r,numeric:t}=e;return r(Ti,{"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)})}),Ii="pow",vf=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],wf=J(Ii,vf,e=>{var{typed:r,config:t,identity:n,multiply:i,matrix:u,inv:o,number:a,fraction:c,Complex:l}=e;return r(Ii,{"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&&!de(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:de(m)||p>=0||t.predictable?si(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(!de(m))throw new TypeError("For A^b, b must be an integer (value is "+m+")");var s=Ie(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))}}),Ir="Number of decimals in function round must be an integer",zi="round",yf=["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],Ff=J(zi,yf,e=>{var{typed:r,config:t,matrix:n,equalScalar:i,zeros:u,BigNumber:o,DenseMatrix:a}=e,c=gi({typed:r,equalScalar:i}),l=Vr({typed:r,DenseMatrix:a}),f=Kt({typed:r});function h(D){return Math.abs(Rr(D).exponent)}return r(zi,{number:function(p){var m=Zr(p,h(t.relTol)),s=Ke(p,m,t.relTol,t.absTol)?m:p;return Zr(s)},"number, number":function(p,m){var s=h(t.relTol);if(m>=s)return Zr(p,m);var d=Zr(p,s),g=Ke(p,d,t.relTol,t.absTol)?d:p;return Zr(g,m)},"number, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Ir);return new o(p).toDecimalPlaces(m.toNumber())},Complex:function(p){return p.round()},"Complex, number":function(p,m){if(m%1)throw new TypeError(Ir);return p.round(m)},"Complex, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Ir);var s=m.toNumber();return p.round(s)},BigNumber:function(p){var m=new o(p).toDecimalPlaces(h(t.relTol)),s=wr(p,m,t.relTol,t.absTol)?m:p;return s.toDecimalPlaces(0)},"BigNumber, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Ir);var s=h(t.relTol);if(m>=s)return p.toDecimalPlaces(m.toNumber());var d=p.toDecimalPlaces(s),g=wr(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(Ir);return p.round(m)},"Fraction, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(Ir);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)=>Ze(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=>Ze(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())})}),Et="smaller",Ef=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],Af=J(Et,Ef,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,c=yt({typed:r}),l=Ft({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)&&!wr(m,s,t.relTol,t.absTol)}return r(Et,bf({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}))}),bf=J(Et,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Et,{"number, number":function(i,u){return i<u&&!Ke(i,u,t.relTol,t.absTol)}})}),At="smallerEq",Cf=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],_f=J(At,Cf,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=yt({typed:r}),c=Ft({typed:r,SparseMatrix:o}),l=Vr({typed:r,DenseMatrix:i}),f=Jr({typed:r,matrix:n,concat:u}),h=Wr({typed:r});return r(At,Bf({typed:r,config:t}),{"boolean, boolean":(D,p)=>D<=p,"BigNumber, BigNumber":function(p,m){return p.lte(m)||wr(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}))}),Bf=J(At,["typed","config"],e=>{var{typed:r,config:t}=e;return r(At,{"number, number":function(i,u){return i<=u||Ke(i,u,t.relTol,t.absTol)}})}),bt="larger",Nf=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],Mf=J(bt,Nf,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,c=yt({typed:r}),l=Ft({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)&&!wr(m,s,t.relTol,t.absTol)}return r(bt,Sf({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}))}),Sf=J(bt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(bt,{"number, number":function(i,u){return i>u&&!Ke(i,u,t.relTol,t.absTol)}})}),Ct="largerEq",xf=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],Tf=J(Ct,xf,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=yt({typed:r}),c=Ft({typed:r,SparseMatrix:o}),l=Vr({typed:r,DenseMatrix:i}),f=Jr({typed:r,matrix:n,concat:u}),h=Wr({typed:r});return r(Ct,If({typed:r,config:t}),{"boolean, boolean":(D,p)=>D>=p,"BigNumber, BigNumber":function(p,m){return p.gte(m)||wr(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}))}),If=J(Ct,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Ct,{"number, number":function(i,u){return i>=u||Ke(i,u,t.relTol,t.absTol)}})}),zf="ImmutableDenseMatrix",Of=["smaller","DenseMatrix"],$f=J(zf,Of,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&&!Je(u))throw new Error("Invalid datatype: "+u);if(De(i)||we(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&&we(i.data)&&we(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 ("+nr(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 De(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}),Pf="Index",Uf=["ImmutableDenseMatrix","getMatrixDataType"],qf=J(Pf,Uf,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=we(c),f=De(c),h=typeof c,D=null;if(pn(c))this._dimensions.push(c),this._isScalar=!1;else if(l||f){var p=void 0;t(c)==="boolean"?(l&&(p=i(Oi(c).valueOf())),f&&(p=i(Oi(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"||!de(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 Oi(e){var r=[];return e.forEach((t,n)=>{t&&r.push(n)}),r}function Rf(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 _t(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:Rf(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}}_t(function(e){return new e(1).exp()},{hasher:Bt}),_t(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Bt});var $i=_t(function(e){return e.acos(-1)},{hasher:Bt});_t(function(e){return $i(e).times(2)},{hasher:Bt});function Bt(e){return e[0].precision}var Pi="add",Lf=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Hf=J(Pi,Lf,e=>{var{typed:r,matrix:t,addScalar:n,equalScalar:i,DenseMatrix:u,SparseMatrix:o,concat:a}=e,c=_s({typed:r}),l=Ms({typed:r,equalScalar:i}),f=Ts({typed:r,DenseMatrix:u}),h=Jr({typed:r,matrix:t,concat:a});return r(Pi,{"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}))}),Ui="dot",Zf=["typed","addScalar","multiplyScalar","conj","size"],Wf=J(Ui,Zf,e=>{var{typed:r,addScalar:t,multiplyScalar:n,conj:i,size:u}=e;return r(Ui,{"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=De(f)?f._data:f,m=De(f)?f._datatype||f.getDataType():void 0,s=De(h)?h._data:h,d=De(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]),x=1;x<D;x++)M=v(M,A(i(p[x][0]),s[x]));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 De(f)?f.size():u(f)}}),qi="index",Vf=["typed","Index"],Jf=J(qi,Vf,e=>{var{typed:r,Index:t}=e;return r(qi,{"...number | string | BigNumber | Range | Array | Matrix":function(i){var u=i.map(function(a){return Fe(a)?a.toNumber():we(a)||De(a)?a.map(function(c){return Fe(c)?c.toNumber():c}):a}),o=new t;return t.apply(o,u),o}})}),Ri="det",Gf=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],Yf=J(Ri,Gf,e=>{var{typed:r,matrix:t,subtractScalar:n,multiply:i,divideScalar:u,isZero:o,unaryMinus:a}=e;return r(Ri,{any:function(f){return me(f)},"Array | Matrix":function(f){var h;switch(De(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: "+Ce(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: "+Ce(h)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ce(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}}),Li="inv",kf=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],Xf=J(Li,kf,e=>{var{typed:r,matrix:t,divideScalar:n,addScalar:i,multiply:u,unaryMinus:o,det:a,identity:c,abs:l}=e;return r(Li,{"Array | Matrix":function(D){var p=De(D)?D.size():Ie(D);switch(p.length){case 1:if(p[0]===1)return De(D)?t([n(1,D.valueOf()[0])]):[n(1,D[0])];throw new RangeError("Matrix must be square (size: "+Ce(p)+")");case 2:{var m=p[0],s=p[1];if(m===s)return De(D)?t(f(D.valueOf(),m,s),D.storage()):f(D,m,s);throw new RangeError("Matrix must be square (size: "+Ce(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+Ce(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 x=A[m],R=y[m];if(m!==w){if(x[w]!==0){for(d=n(o(x[w]),B[w]),s=w;s<p;s++)x[s]=i(x[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++)x[s]=n(x[s],d);for(s=0;s<p;s++)R[s]=n(R[s],d)}}}return y}}}),Qf=Kf("pi",["config","?BigNumber"],e=>{var{config:r,BigNumber:t}=e;return r.number==="BigNumber"?$i(t):Na});function Kf(e,r,t){return J(e,r,t,{recreateOnConfigChange:!0})}var zr=Yo({config:Oe}),Nt=jo({}),Hi=oa({}),jt=fa({}),or=Ca({Matrix:jt}),Mt=Qf({BigNumber:zr,config:Oe}),te=Xu({BigNumber:zr,Complex:Nt,DenseMatrix:or,Fraction:Hi}),en=us({typed:te}),St=as({typed:te}),Zi=Vs({typed:te}),rn=Xa({Complex:Nt,typed:te}),jf=Gs({typed:te}),Gr=$a({config:Oe,typed:te}),ec=Qs({typed:te}),rc=Ba({typed:te}),tc=xa({config:Oe,typed:te}),nc=Ia({equalScalar:Gr,typed:te}),ic=$s({Complex:Nt,config:Oe,typed:te}),Wi=qs({typed:te}),Vi=Wa({typed:te}),br=qa({Matrix:jt,equalScalar:Gr,typed:te}),uc=fs({typed:te}),xt=Ga({BigNumber:zr,typed:te}),Ue=rs({DenseMatrix:or,Matrix:jt,SparseMatrix:br,typed:te}),Ji=hf({BigNumber:zr,config:Oe,matrix:Ue,typed:te}),Yr=ks({isInteger:rc,matrix:Ue,typed:te}),Gi=ja({Fraction:Hi,typed:te}),Yi=js({BigNumber:zr,DenseMatrix:or,SparseMatrix:br,config:Oe,matrix:Ue,typed:te}),oc=Tf({DenseMatrix:or,SparseMatrix:br,concat:Yr,config:Oe,matrix:Ue,typed:te}),ac=mf({bignumber:xt,fraction:Gi,number:Vi}),ki=Ff({BigNumber:zr,DenseMatrix:or,config:Oe,equalScalar:Gr,matrix:Ue,typed:te,zeros:Ji}),sc=uf({matrix:Ue,config:Oe,typed:te}),Xi=Af({DenseMatrix:or,SparseMatrix:br,bignumber:xt,concat:Yr,config:Oe,matrix:Ue,typed:te}),Qi=ns({typed:te}),Tt=Hf({DenseMatrix:or,SparseMatrix:br,addScalar:St,concat:Yr,equalScalar:Gr,matrix:Ue,typed:te}),Ki=gf({numeric:ac,typed:te}),fc=$f({DenseMatrix:or,smaller:Xi}),cc=qf({ImmutableDenseMatrix:fc,getMatrixDataType:ec}),lc=Mf({DenseMatrix:or,SparseMatrix:br,bignumber:xt,concat:Yr,config:Oe,matrix:Ue,typed:te}),hc=_f({DenseMatrix:or,SparseMatrix:br,concat:Yr,config:Oe,matrix:Ue,typed:te}),tn=af({add:Tt,matrix:Ue,typed:te,zeros:Ji}),pc=Wf({addScalar:St,conj:jf,multiplyScalar:Wi,size:sc,typed:te}),nn=Jf({Index:cc,typed:te}),Or=Ls({addScalar:St,dot:pc,equalScalar:Gr,matrix:Ue,multiplyScalar:Wi,typed:te}),un=tf({bignumber:xt,matrix:Ue,add:Tt,config:Oe,isPositive:tc,larger:lc,largerEq:oc,smaller:Xi,smallerEq:hc,typed:te}),Dc=Yf({divideScalar:Ki,isZero:nc,matrix:Ue,multiply:Or,subtractScalar:uc,typed:te,unaryMinus:Qi}),mc=Xf({abs:en,addScalar:St,det:Dc,divideScalar:Ki,identity:Yi,matrix:Ue,multiply:Or,typed:te,unaryMinus:Qi}),dc=wf({Complex:Nt,config:Oe,fraction:Gi,identity:Yi,inv:mc,matrix:Ue,multiply:Or,number:Vi,typed:te});const ji=299792458,yr={Hz:1,kHz:1e3,MHz:1e6,GHz:1e9,THz:1e12},eu={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=yr[t],u=yr[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=yr[this.unit];if(!t)throw new Error(`Multiplier for current unit ${this.unit} not found.`);const n=yr[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=yr[t];if(!n)throw new Error(`Multiplier for source unit ${t} not found.`);const i=yr[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=yr[this.unit];if(!t)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const n=eu[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:ji/u/n})}_setWavelengthFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=eu[t];if(!n)throw new Error(`Wavelength multiplier to meters for source unit ${t} not found.`);const i=yr[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 ji/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 vc=["RI","MA","DB"],wc=["S","Y","Z","G","H"];class yc{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
|
|
19
|
-
`)}}
|
|
17
|
+
(`+_e(b,s)+", "+_e(A,s)+") ==> "+(this._values?_e(this._values[C],s):"X")}return v},i.prototype.toString=function(){return _e(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(Fe(s)&&(s=s.toNumber()),!pe(s)||!de(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],x=B;x<M;x++){var R=this._index[x];if(R===b-d+g){y.push(this._values[x]),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(!we(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(J){if(Fe(J)&&(J=J.toNumber()),!pe(J)||!de(J)||J<1)throw new Error("Size values must be positive integers");return J}),g){if(Fe(g)&&(g=g.toNumber()),!pe(g)||!de(g))throw new TypeError("The parameter k must be an integer number")}else g=0;var A=t,y=0;Je(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),x;if(we(d)){if(d.length!==M)throw new Error("Invalid value array length");x=function(ee){return d[ee]}}else if(De(d)){var R=d.size();if(R.length!==1||R[0]!==M)throw new Error("Invalid matrix length");x=function(ee){return d.get([ee])}}else x=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 X=x(Q);A(X,y)||(q.push(Q+C),V.push(X))}}return W.push(V.length),new i({values:V,index:q,ptr:W,size:[b,B]})},i.prototype.swapRows=function(s,d){if(!pe(s)||!de(s)||!pe(d)||!de(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 ge(s,this._size[0]),ge(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 x=E?E[b]:void 0;v.splice(B,0,d),E&&E.splice(B,0,x),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}),Za="number",Wa=["typed"];function Va(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 Ga(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 Ja=G(Za,Wa,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=Va(i);if(u)return Ga(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=>We(i,n))});return t.fromJSON=function(n){return parseFloat(n.value)},t}),Ya="bignumber",ka=["typed","BigNumber"],Xa=G(Ya,ka,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=>We(i,n))})}),Qa="complex",Ka=["typed","Complex"],ja=G(Qa,Ka,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=>We(i,n))})}),es="fraction",rs=["typed","Fraction"],ts=G(es,rs,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=>We(i,n))})}),mi="matrix",ns=["typed","Matrix","DenseMatrix","SparseMatrix"],is=G(mi,ns,e=>{var{typed:r,Matrix:t,DenseMatrix:n,SparseMatrix:i}=e;return r(mi,{"":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)+".")}}),di="unaryMinus",us=["typed"],os=G(di,us,e=>{var{typed:r}=e;return r(di,{number:ci,"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=>We(n,t,!0))})}),gi="abs",as=["typed"],ss=G(gi,as,e=>{var{typed:r}=e;return r(gi,{number:oi,"Complex | BigNumber | Fraction | Unit":t=>t.abs(),bigint:t=>t<0n?-t:t,"Array | Matrix":r.referToSelf(t=>n=>We(n,t,!0))})}),vi="addScalar",fs=["typed"],cs=G(vi,fs,e=>{var{typed:r}=e;return r(vi,{"number, number":ai,"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})})}),wi="subtractScalar",ls=["typed"],hs=G(wi,ls,e=>{var{typed:r}=e;return r(wi,{"number, number":si,"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})})}),ps="matAlgo11xS0s",Ds=["typed","equalScalar"],yi=G(ps,Ds,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],x=a?E(u,c[B]):E(c[B],u);d(x,g)||(A.push(M),v.push(x))}}return y[m]=A.length,i.createSparseMatrix({values:v,index:A,ptr:y,size:[p,m],datatype:s})}}),ms="matAlgo12xSfs",ds=["typed","DenseMatrix"],Vr=G(ms,ds,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})}}),gs="matAlgo14xDs",vs=["typed"],nn=G(gs,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}}),ws="matAlgo03xDSf",ys=["typed"],Et=G(ws,ys,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],x=D[b+1],R=M;R<x;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})}}),Fs="matAlgo13xDD",Es=["typed"],As=G(Fs,Es,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 xe(e,r){if(pr(e.size(),r.size()))return[e,r];var t=ei(e.size(),r.size());return[e,r].map(n=>bs(n,t))}function bs(e,r){return pr(e.size(),r)?e:e.create(rn(e.valueOf(),r),e.datatype())}var Cs="matrixAlgorithmSuite",_s=["typed","matrix"],Gr=G(Cs,_s,e=>{var{typed:r,matrix:t}=e,n=As({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(...xe(p,m),a),"Array, Array":(p,m)=>n(...xe(t(p),t(m)),a).valueOf(),"Array, DenseMatrix":(p,m)=>n(...xe(t(p),m),a),"DenseMatrix, Array":(p,m)=>n(...xe(p,t(m)),a)},o.SS&&(l["SparseMatrix, SparseMatrix"]=(p,m)=>o.SS(...xe(p,m),a,!1)),o.DS&&(l["DenseMatrix, SparseMatrix"]=(p,m)=>o.DS(...xe(p,m),a,!1),l["Array, SparseMatrix"]=(p,m)=>o.DS(...xe(t(p),m),a,!1)),c&&(l["SparseMatrix, DenseMatrix"]=(p,m)=>c(...xe(m,p),a,!0),l["SparseMatrix, Array"]=(p,m)=>c(...xe(t(m),p),a,!0))):(l={"DenseMatrix, DenseMatrix":r.referToSelf(p=>(m,s)=>n(...xe(m,s),p)),"Array, Array":r.referToSelf(p=>(m,s)=>n(...xe(t(m),t(s)),p).valueOf()),"Array, DenseMatrix":r.referToSelf(p=>(m,s)=>n(...xe(t(m),s),p)),"DenseMatrix, Array":r.referToSelf(p=>(m,s)=>n(...xe(m,t(s)),p))},o.SS&&(l["SparseMatrix, SparseMatrix"]=r.referToSelf(p=>(m,s)=>o.SS(...xe(m,s),p,!1))),o.DS&&(l["DenseMatrix, SparseMatrix"]=r.referToSelf(p=>(m,s)=>o.DS(...xe(m,s),p,!1)),l["Array, SparseMatrix"]=r.referToSelf(p=>(m,s)=>o.DS(...xe(t(m),s),p,!1))),c&&(l["SparseMatrix, DenseMatrix"]=r.referToSelf(p=>(m,s)=>c(...xe(s,m),p,!0)),l["SparseMatrix, Array"]=r.referToSelf(p=>(m,s)=>c(...xe(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&&Lu(l,a.signatures),l}}),Bs="matAlgo01xDSid",Ns=["typed"],Ms=G(Bs,Ns,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],x=B;x<M;x++)v=h[x],w[v]=o?E(f[x],a[v][A]):E(a[v][A],f[x]),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})}}),Ss="matAlgo04xSidSid",xs=["typed","equalScalar"],Ts=G(Ss,xs,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,x=a&&D?[]:void 0,R=[],V=[],q,W,O,Q,X;for(W=0;W<E;W++){B[W]=b.length;var J=W+1;for(Q=l[W],X=l[W+1],O=Q;O<X;O++)q=c[O],b.push(q),R[q]=J,M&&(M[q]=a[O]);for(Q=m[W],X=m[W+1],O=Q;O<X;O++)if(q=p[O],R[q]===J){if(M){var ee=w(M[q],D[O]);A(ee,y)?R[q]=null:M[q]=ee}}else b.push(q),V[q]=J,x&&(x[q]=D[O]);if(M&&x)for(O=B[W];O<b.length;)q=b[O],R[q]===J?(C[O]=M[q],O++):V[q]===J?(C[O]=x[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})}}),Is="matAlgo10xSids",zs=["typed","DenseMatrix"],Os=G(Is,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]=u}return new t({data:g,size:[p,m],datatype:s})}});function $s(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 Fi="log10",Ps=["typed","config","Complex"],Us=yt(16),qs=G(Fi,Ps,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(Fi,{number:function(a){return a>=0||t.predictable?yt(a):u(a)},bigint:$s(Us,yt,t,u),Complex:i,BigNumber:function(a){return!a.isNegative()||t.predictable?a.log():u(a.toNumber())},"Array | Matrix":r.referToSelf(o=>a=>We(a,o))})}),Rs="multiplyScalar",Ls=["typed"],Hs=G(Rs,Ls,e=>{var{typed:r}=e;return r("multiplyScalar",{"number, number":fi,"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)})}),Ei="multiply",Zs=["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],Ws=G(Ei,Zs,e=>{var{typed:r,matrix:t,addScalar:n,multiplyScalar:i,equalScalar:u,dot:o}=e,a=yi({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,x=w._size,R=w._datatype||w.getDataType(),V=b[0],q=x[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 X=[],J=0;J<q;J++){for(var ee=Q(C[0],M[0][J]),oe=1;oe<V;oe++)ee=O(ee,Q(C[oe],M[oe][J]));X[J]=ee}return y.createDenseMatrix({data:X,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,x=w._datatype||w.getDataType(),R=b[0],V=b[1],q,W=n,O=i;B&&x&&B===x&&typeof B=="string"&&B!=="mixed"&&(q=B,W=r.find(n,[q,q]),O=r.find(i,[q,q]));for(var Q=[],X=0;X<R;X++){for(var J=C[X],ee=O(J[0],M[0]),oe=1;oe<V;oe++)ee=W(ee,O(J[oe],M[oe]));Q[X]=ee}return y.createDenseMatrix({data:Q,size:[R],datatype:B===y._datatype&&x===w._datatype?q:void 0})}function d(y,w){var C=y._data,b=y._size,B=y._datatype||y.getDataType(),M=w._data,x=w._size,R=w._datatype||w.getDataType(),V=b[0],q=b[1],W=x[1],O,Q=n,X=i;B&&R&&B===R&&typeof B=="string"&&B!=="mixed"&&B!=="mixed"&&(O=B,Q=r.find(n,[O,O]),X=r.find(i,[O,O]));for(var J=[],ee=0;ee<V;ee++){var oe=C[ee];J[ee]=[];for(var ie=0;ie<W;ie++){for(var ce=X(oe[0],M[0][ie]),Be=1;Be<q;Be++)ce=Q(ce,X(oe[Be],M[Be][ie]));J[ee][ie]=ce}}return y.createDenseMatrix({data:J,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,x=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,X=n,J=i,ee=u,oe=0;B&&q&&B===q&&typeof B=="string"&&B!=="mixed"&&(Q=B,X=r.find(n,[Q,Q]),J=r.find(i,[Q,Q]),ee=r.find(u,[Q,Q]),oe=r.convert(0,Q));for(var ie=[],ce=[],Be=[],Ce=w.createSparseMatrix({values:ie,index:ce,ptr:Be,size:[W,O],datatype:B===y._datatype&&q===w._datatype?Q:void 0}),be=0;be<O;be++){Be[be]=ce.length;var ye=R[be],Re=R[be+1];if(Re>ye)for(var le=0,ae=0;ae<W;ae++){for(var Qe=ae+1,Oe=void 0,he=ye;he<Re;he++){var Te=x[he];le!==Qe?(Oe=J(C[ae][Te],M[he]),le=Qe):Oe=X(Oe,J(C[ae][Te],M[he]))}le===Qe&&!ee(Oe,oe)&&(ce.push(ae),ie.push(Oe))}}return Be[O]=ce.length,Ce}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 x=w._data,R=w._datatype||w.getDataType(),V=y._size[0],q=w._size[0],W=[],O=[],Q=[],X,J=n,ee=i,oe=u,ie=0;M&&R&&M===R&&typeof M=="string"&&M!=="mixed"&&(X=M,J=r.find(n,[X,X]),ee=r.find(i,[X,X]),oe=r.find(u,[X,X]),ie=r.convert(0,X));var ce=[],Be=[];Q[0]=0;for(var Ce=0;Ce<q;Ce++){var be=x[Ce];if(!oe(be,ie))for(var ye=B[Ce],Re=B[Ce+1],le=ye;le<Re;le++){var ae=b[le];Be[ae]?ce[ae]=J(ce[ae],ee(be,C[le])):(Be[ae]=!0,O.push(ae),ce[ae]=ee(be,C[le]))}}for(var Qe=O.length,Oe=0;Oe<Qe;Oe++){var he=O[Oe];W[Oe]=ce[he]}return Q[1]=O.length,y.createSparseMatrix({values:W,index:O,ptr:Q,size:[V,1],datatype:M===y._datatype&&R===w._datatype?X: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 x=w._data,R=w._datatype||w.getDataType(),V=y._size[0],q=w._size[0],W=w._size[1],O,Q=n,X=i,J=u,ee=0;M&&R&&M===R&&typeof M=="string"&&M!=="mixed"&&(O=M,Q=r.find(n,[O,O]),X=r.find(i,[O,O]),J=r.find(u,[O,O]),ee=r.convert(0,O));for(var oe=[],ie=[],ce=[],Be=y.createSparseMatrix({values:oe,index:ie,ptr:ce,size:[V,W],datatype:M===y._datatype&&R===w._datatype?O:void 0}),Ce=[],be=[],ye=0;ye<W;ye++){ce[ye]=ie.length;for(var Re=ye+1,le=0;le<q;le++){var ae=x[le][ye];if(!J(ae,ee))for(var Qe=B[le],Oe=B[le+1],he=Qe;he<Oe;he++){var Te=b[he];be[Te]!==Re?(be[Te]=Re,ie.push(Te),Ce[Te]=X(ae,C[he])):Ce[Te]=Q(Ce[Te],X(ae,C[he]))}}for(var Ke=ce[ye],cr=ie.length,lr=Ke;lr<cr;lr++){var $r=ie[lr];oe[lr]=Ce[$r]}}return ce[W]=ie.length,Be}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(),x=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&&x,X,J=n,ee=i;M&&q&&M===q&&typeof M=="string"&&M!=="mixed"&&(X=M,J=r.find(n,[X,X]),ee=r.find(i,[X,X]));for(var oe=Q?[]:void 0,ie=[],ce=[],Be=y.createSparseMatrix({values:oe,index:ie,ptr:ce,size:[W,O],datatype:M===y._datatype&&q===w._datatype?X:void 0}),Ce=Q?[]:void 0,be=[],ye,Re,le,ae,Qe,Oe,he,Te,Ke=0;Ke<O;Ke++){ce[Ke]=ie.length;var cr=Ke+1;for(Qe=V[Ke],Oe=V[Ke+1],ae=Qe;ae<Oe;ae++)if(Te=R[ae],Q)for(Re=B[Te],le=B[Te+1],ye=Re;ye<le;ye++)he=b[ye],be[he]!==cr?(be[he]=cr,ie.push(he),Ce[he]=ee(x[ae],C[ye])):Ce[he]=J(Ce[he],ee(x[ae],C[ye]));else for(Re=B[Te],le=B[Te+1],ye=Re;ye<le;ye++)he=b[ye],be[he]!==cr&&(be[he]=cr,ie.push(he));if(Q)for(var lr=ce[Ke],$r=ie.length,Pr=lr;Pr<$r;Pr++){var fn=ie[Pr];oe[Pr]=Ce[fn]}}return ce[O]=ie.length,Be}return r(Ei,i,{"Array, Array":r.referTo("Matrix, Matrix",y=>(w,C)=>{l(ze(w),ze(C));var b=y(t(w),t(C));return De(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})})}),Vs="matAlgo07xSSf",Gs=["typed","SparseMatrix"],At=G(Vs,Gs,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 x=0;x<D;x++){var R=w[x]===B?A[x]:s,V=C[x]===B?y[x]:s,q=d(R,V);q!==0&&q!==!1&&(E.push(x),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]}}}),Ai="arg",Js=["typed"],Ys=G(Ai,Js,e=>{var{typed:r}=e;return r(Ai,{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=>We(n,t))})}),bi="conj",ks=["typed"],Xs=G(bi,ks,e=>{var{typed:r}=e;return r(bi,{"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=>We(n,t))})}),Ci="concat",Qs=["typed","matrix","isInteger"],Ks=G(Ci,Qs,e=>{var{typed:r,matrix:t,isInteger:n}=e;return r(Ci,{"...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(De(D)&&(f=!0),pe(D)||Fe(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 Ar(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=jn(s,h.shift(),c);return f?t(s):s},"...string":function(u){return u.join("")}})}),_i="getMatrixDataType",js=["typed"],ef=G(_i,js,e=>{var{typed:r}=e;return r(_i,{Array:function(n){return gt(n,ir)},Matrix:function(n){return n.getDataType()}})}),Bi="identity",rf=["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],tf=G(Bi,rf,e=>{var{typed:r,config:t,matrix:n,BigNumber:i,DenseMatrix:u,SparseMatrix:o}=e;return r(Bi,{"":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=Fe(l)||Fe(f)?i:null;if(Fe(l)&&(l=l.toNumber()),Fe(f)&&(f=f.toNumber()),!de(l)||l<1)throw new Error("Parameters in function identity must be positive integers");if(!de(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=dt([],s,m),g=l<f?l:f,E=0;E<g;E++)d[E][E]=p;return d}});function Ni(){throw new Error('No "bignumber" implementation available')}function nf(){throw new Error('No "fraction" implementation available')}function Mi(){throw new Error('No "matrix" implementation available')}var Si="range",uf=["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq","add","isPositive"],of=G(Si,uf,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(Si,{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):Mi():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&&Ni(),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}}}),xi="size",af=["typed","config","?matrix"],sf=G(xi,af,e=>{var{typed:r,config:t,matrix:n}=e;return r(xi,{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"):Mi()}})}),Ti="subset",ff=["typed","matrix","zeros","add"],cf=G(Ti,ff,e=>{var{typed:r,matrix:t,zeros:n,add:i}=e;return r(Ti,{"Matrix, Index":function(a,c){return Ir(c)?t():(mt(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":hf,"string, Index":lf,"Matrix, Index, any, any":function(a,c,l,f){return Ir(c)?a:(mt(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":Ii,"string, Index, string, string":Ii,"Object, Index, any":pf});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 lf(e,r){if(!rt(r))throw new TypeError("Index expected");if(Ir(r))return"";if(mt(Array.from(e),r),r.size().length!==1)throw new ne(r.size().length,1);var t=e.length;ge(r.min()[0],t),ge(r.max()[0],t);var n=r.dimension(0),i="";return n.forEach(function(u){i+=e.charAt(u)}),i}function Ii(e,r,t,n){if(!r||r.isIndex!==!0)throw new TypeError("Index expected");if(Ir(r))return e;if(mt(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;ge(r.min()[0]),ge(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 hf(e,r){if(!Ir(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 ln(e,t)}}function pf(e,r,t){if(Ir(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 hn(i,n,t),i}var zi="zeros",Df=["typed","config","matrix","BigNumber"],mf=G(zi,Df,e=>{var{typed:r,config:t,matrix:n,BigNumber:i}=e;return r(zi,{"":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?dt(p,c,h):p}}function o(c){var l=!1;return c.forEach(function(f,h,D){Fe(f)&&(l=!0,D[h]=f.toNumber())}),l}function a(c){c.forEach(function(l){if(typeof l!="number"||!de(l)||l<0)throw new Error("Parameters in function zeros must be positive integers")})}}),df="numeric",gf=["number","?bignumber","?fraction"],vf=G(df,gf,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):Ni,bigint:o=>BigInt(o),Fraction:n?o=>n(o):nf};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)}}),Oi="divideScalar",wf=["typed","numeric"],yf=G(Oi,wf,e=>{var{typed:r,numeric:t}=e;return r(Oi,{"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)})}),$i="pow",Ff=["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],Ef=G($i,Ff,e=>{var{typed:r,config:t,identity:n,multiply:i,matrix:u,inv:o,number:a,fraction:c,Complex:l}=e;return r($i,{"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&&!de(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:de(m)||p>=0||t.predictable?li(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(!de(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))}}),zr="Number of decimals in function round must be an integer",Pi="round",Af=["typed","config","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],bf=G(Pi,Af,e=>{var{typed:r,config:t,matrix:n,equalScalar:i,zeros:u,BigNumber:o,DenseMatrix:a}=e,c=yi({typed:r,equalScalar:i}),l=Vr({typed:r,DenseMatrix:a}),f=nn({typed:r});function h(D){return Math.abs(Rr(D).exponent)}return r(Pi,{number:function(p){var m=Zr(p,h(t.relTol)),s=je(p,m,t.relTol,t.absTol)?m:p;return Zr(s)},"number, number":function(p,m){var s=h(t.relTol);if(m>=s)return Zr(p,m);var d=Zr(p,s),g=je(p,d,t.relTol,t.absTol)?d:p;return Zr(g,m)},"number, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(zr);return new o(p).toDecimalPlaces(m.toNumber())},Complex:function(p){return p.round()},"Complex, number":function(p,m){if(m%1)throw new TypeError(zr);return p.round(m)},"Complex, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(zr);var s=m.toNumber();return p.round(s)},BigNumber:function(p){var m=new o(p).toDecimalPlaces(h(t.relTol)),s=wr(p,m,t.relTol,t.absTol)?m:p;return s.toDecimalPlaces(0)},"BigNumber, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(zr);var s=h(t.relTol);if(m>=s)return p.toDecimalPlaces(m.toNumber());var d=p.toDecimalPlaces(s),g=wr(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(zr);return p.round(m)},"Fraction, BigNumber":function(p,m){if(!m.isInteger())throw new TypeError(zr);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)=>We(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=>We(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())})}),bt="smaller",Cf=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],_f=G(bt,Cf,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,c=Et({typed:r}),l=At({typed:r,SparseMatrix:a}),f=Vr({typed:r,DenseMatrix:u}),h=Gr({typed:r,matrix:i,concat:o}),D=Wr({typed:r});function p(m,s){return m.lt(s)&&!wr(m,s,t.relTol,t.absTol)}return r(bt,Bf({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}))}),Bf=G(bt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(bt,{"number, number":function(i,u){return i<u&&!je(i,u,t.relTol,t.absTol)}})}),Ct="smallerEq",Nf=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],Mf=G(Ct,Nf,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=Et({typed:r}),c=At({typed:r,SparseMatrix:o}),l=Vr({typed:r,DenseMatrix:i}),f=Gr({typed:r,matrix:n,concat:u}),h=Wr({typed:r});return r(Ct,Sf({typed:r,config:t}),{"boolean, boolean":(D,p)=>D<=p,"BigNumber, BigNumber":function(p,m){return p.lte(m)||wr(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}))}),Sf=G(Ct,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Ct,{"number, number":function(i,u){return i<=u||je(i,u,t.relTol,t.absTol)}})}),_t="larger",xf=["typed","config","bignumber","matrix","DenseMatrix","concat","SparseMatrix"],Tf=G(_t,xf,e=>{var{typed:r,config:t,bignumber:n,matrix:i,DenseMatrix:u,concat:o,SparseMatrix:a}=e,c=Et({typed:r}),l=At({typed:r,SparseMatrix:a}),f=Vr({typed:r,DenseMatrix:u}),h=Gr({typed:r,matrix:i,concat:o}),D=Wr({typed:r});function p(m,s){return m.gt(s)&&!wr(m,s,t.relTol,t.absTol)}return r(_t,If({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}))}),If=G(_t,["typed","config"],e=>{var{typed:r,config:t}=e;return r(_t,{"number, number":function(i,u){return i>u&&!je(i,u,t.relTol,t.absTol)}})}),Bt="largerEq",zf=["typed","config","matrix","DenseMatrix","concat","SparseMatrix"],Of=G(Bt,zf,e=>{var{typed:r,config:t,matrix:n,DenseMatrix:i,concat:u,SparseMatrix:o}=e,a=Et({typed:r}),c=At({typed:r,SparseMatrix:o}),l=Vr({typed:r,DenseMatrix:i}),f=Gr({typed:r,matrix:n,concat:u}),h=Wr({typed:r});return r(Bt,$f({typed:r,config:t}),{"boolean, boolean":(D,p)=>D>=p,"BigNumber, BigNumber":function(p,m){return p.gte(m)||wr(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}))}),$f=G(Bt,["typed","config"],e=>{var{typed:r,config:t}=e;return r(Bt,{"number, number":function(i,u){return i>=u||je(i,u,t.relTol,t.absTol)}})}),Pf="ImmutableDenseMatrix",Uf=["smaller","DenseMatrix"],qf=G(Pf,Uf,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&&!Je(u))throw new Error("Invalid datatype: "+u);if(De(i)||we(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&&we(i.data)&&we(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 De(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}),Rf="Index",Lf=["ImmutableDenseMatrix","getMatrixDataType"],Hf=G(Rf,Lf,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=we(c),f=De(c),h=typeof c,D=null;if(dn(c))this._dimensions.push(c),this._isScalar=!1;else if(l||f){var p=void 0;t(c)==="boolean"?(l&&(p=i(Ui(c).valueOf())),f&&(p=i(Ui(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"||!de(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 Ui(e){var r=[];return e.forEach((t,n)=>{t&&r.push(n)}),r}function Zf(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 Nt(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:Zf(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}}Nt(function(e){return new e(1).exp()},{hasher:Mt}),Nt(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Mt});var qi=Nt(function(e){return e.acos(-1)},{hasher:Mt});Nt(function(e){return qi(e).times(2)},{hasher:Mt});function Mt(e){return e[0].precision}var Ri="add",Wf=["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix","concat"],Vf=G(Ri,Wf,e=>{var{typed:r,matrix:t,addScalar:n,equalScalar:i,DenseMatrix:u,SparseMatrix:o,concat:a}=e,c=Ms({typed:r}),l=Ts({typed:r,equalScalar:i}),f=Os({typed:r,DenseMatrix:u}),h=Gr({typed:r,matrix:t,concat:a});return r(Ri,{"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}))}),Li="dot",Gf=["typed","addScalar","multiplyScalar","conj","size"],Jf=G(Li,Gf,e=>{var{typed:r,addScalar:t,multiplyScalar:n,conj:i,size:u}=e;return r(Li,{"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=De(f)?f._data:f,m=De(f)?f._datatype||f.getDataType():void 0,s=De(h)?h._data:h,d=De(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]),x=1;x<D;x++)M=v(M,A(i(p[x][0]),s[x]));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 De(f)?f.size():u(f)}}),Hi="index",Yf=["typed","Index"],kf=G(Hi,Yf,e=>{var{typed:r,Index:t}=e;return r(Hi,{"...number | string | BigNumber | Range | Array | Matrix":function(i){var u=i.map(function(a){return Fe(a)?a.toNumber():we(a)||De(a)?a.map(function(c){return Fe(c)?c.toNumber():c}):a}),o=new t;return t.apply(o,u),o}})}),Zi="det",Xf=["typed","matrix","subtractScalar","multiply","divideScalar","isZero","unaryMinus"],Qf=G(Zi,Xf,e=>{var{typed:r,matrix:t,subtractScalar:n,multiply:i,divideScalar:u,isZero:o,unaryMinus:a}=e;return r(Zi,{any:function(f){return me(f)},"Array | Matrix":function(f){var h;switch(De(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: "+_e(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: "+_e(h)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+_e(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}}),Wi="inv",Kf=["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],jf=G(Wi,Kf,e=>{var{typed:r,matrix:t,divideScalar:n,addScalar:i,multiply:u,unaryMinus:o,det:a,identity:c,abs:l}=e;return r(Wi,{"Array | Matrix":function(D){var p=De(D)?D.size():ze(D);switch(p.length){case 1:if(p[0]===1)return De(D)?t([n(1,D.valueOf()[0])]):[n(1,D[0])];throw new RangeError("Matrix must be square (size: "+_e(p)+")");case 2:{var m=p[0],s=p[1];if(m===s)return De(D)?t(f(D.valueOf(),m,s),D.storage()):f(D,m,s);throw new RangeError("Matrix must be square (size: "+_e(p)+")")}default:throw new RangeError("Matrix must be two dimensional (size: "+_e(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 x=A[m],R=y[m];if(m!==w){if(x[w]!==0){for(d=n(o(x[w]),B[w]),s=w;s<p;s++)x[s]=i(x[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++)x[s]=n(x[s],d);for(s=0;s<p;s++)R[s]=n(R[s],d)}}}return y}}}),ec=rc("pi",["config","?BigNumber"],e=>{var{config:r,BigNumber:t}=e;return r.number==="BigNumber"?qi(t):xa});function rc(e,r,t){return G(e,r,t,{recreateOnConfigChange:!0})}var Or=Qo({config:$e}),St=ta({}),Vi=fa({}),un=ha({}),ar=Na({Matrix:un}),Jr=ec({BigNumber:Or,config:$e}),te=ju({BigNumber:Or,Complex:St,DenseMatrix:ar,Fraction:Vi}),xt=ss({typed:te}),Tt=cs({typed:te}),on=Ys({typed:te}),It=ja({Complex:St,typed:te}),tc=Xs({typed:te}),Yr=qa({config:$e,typed:te}),nc=ef({typed:te}),ic=Sa({typed:te}),uc=za({config:$e,typed:te}),oc=$a({equalScalar:Yr,typed:te}),Gi=qs({Complex:St,config:$e,typed:te}),Ji=Hs({typed:te}),Yi=Ja({typed:te}),br=Ha({Matrix:un,equalScalar:Yr,typed:te}),ac=hs({typed:te}),zt=Xa({BigNumber:Or,typed:te}),qe=is({DenseMatrix:ar,Matrix:un,SparseMatrix:br,typed:te}),ki=mf({BigNumber:Or,config:$e,matrix:qe,typed:te}),kr=Ks({isInteger:ic,matrix:qe,typed:te}),Xi=ts({Fraction:Vi,typed:te}),Qi=tf({BigNumber:Or,DenseMatrix:ar,SparseMatrix:br,config:$e,matrix:qe,typed:te}),sc=Of({DenseMatrix:ar,SparseMatrix:br,concat:kr,config:$e,matrix:qe,typed:te}),fc=vf({bignumber:zt,fraction:Xi,number:Yi}),an=bf({BigNumber:Or,DenseMatrix:ar,config:$e,equalScalar:Yr,matrix:qe,typed:te,zeros:ki}),cc=sf({matrix:qe,config:$e,typed:te}),Ki=_f({DenseMatrix:ar,SparseMatrix:br,bignumber:zt,concat:kr,config:$e,matrix:qe,typed:te}),ji=os({typed:te}),Xr=Vf({DenseMatrix:ar,SparseMatrix:br,addScalar:Tt,concat:kr,equalScalar:Yr,matrix:qe,typed:te}),eu=yf({numeric:fc,typed:te}),lc=qf({DenseMatrix:ar,smaller:Ki}),hc=Hf({ImmutableDenseMatrix:lc,getMatrixDataType:nc}),pc=Tf({DenseMatrix:ar,SparseMatrix:br,bignumber:zt,concat:kr,config:$e,matrix:qe,typed:te}),Dc=Mf({DenseMatrix:ar,SparseMatrix:br,concat:kr,config:$e,matrix:qe,typed:te}),Ot=cf({add:Xr,matrix:qe,typed:te,zeros:ki}),mc=Jf({addScalar:Tt,conj:tc,multiplyScalar:Ji,size:cc,typed:te}),$t=kf({Index:hc,typed:te}),Cr=Ws({addScalar:Tt,dot:mc,equalScalar:Yr,matrix:qe,multiplyScalar:Ji,typed:te}),Pt=of({bignumber:zt,matrix:qe,add:Xr,config:$e,isPositive:uc,larger:pc,largerEq:sc,smaller:Ki,smallerEq:Dc,typed:te}),dc=Qf({divideScalar:eu,isZero:oc,matrix:qe,multiply:Cr,subtractScalar:ac,typed:te,unaryMinus:ji}),gc=jf({abs:xt,addScalar:Tt,det:dc,divideScalar:eu,identity:Qi,matrix:qe,multiply:Cr,typed:te,unaryMinus:ji}),ru=Ef({Complex:St,config:$e,fraction:Xi,identity:Qi,inv:gc,matrix:qe,multiply:Cr,number:Yi,typed:te});const vc=["Hz","kHz","MHz","GHz"],sn=299792458,yr={Hz:1,kHz:1e3,MHz:1e6,GHz:1e9,THz:1e12},tu={m:1,cm:.01,mm:.001,um:1e-6,nm:1e-9};class nu{_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=yr[t],u=yr[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=yr[this.unit];if(!t)throw new Error(`Multiplier for current unit ${this.unit} not found.`);const n=yr[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=yr[t];if(!n)throw new Error(`Multiplier for source unit ${t} not found.`);const i=yr[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=yr[this.unit];if(!t)throw new Error(`Frequency multiplier for current unit ${this.unit} not found.`);const n=tu[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:sn/u/n})}_setWavelengthFromTargetUnit(r,t){if(!r){this.f_scaled=[];return}if(r.length===0){this.f_scaled=[];return}const n=tu[t];if(!n)throw new Error(`Wavelength multiplier to meters for source unit ${t} not found.`);const i=yr[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 sn/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 wc=["RI","MA","DB"],yc=["S","Y","Z","G","H"];class Fc{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 nu;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=Ot(a,$t(Cr(Pt(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=Ot(a,$t(Xr(Cr(Pt(0,l),c),(f*t+h)*2+1))),p=Ot(a,$t(Xr(Cr(Pt(0,l),c),(f*t+h)*2+2)));for(let m=0;m<l;m++){let s;switch(this.format){case"RI":s=It(D[m],p[m]);break;case"MA":s=It({r:D[m],phi:p[m]/180*Jr});break;case"DB":s=It({r:ru(10,D[m]/20),phi:p[m]/180*Jr});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=xt(c),f=on(c)/Jr*180;break;case"DB":l=20*Gi(xt(c)),f=on(c)/Jr*180;break;default:throw new Error(`Unknown Touchstone format: ${this.format}`)}u.push(an(l,12).toString(),an(f,12).toString())}t.push(u.join(" "))}return t.push(""),t.join(`
|
|
19
|
+
`)}}Ae.Frequency=nu,Ae.FrequencyUnits=vc,Ae.SPEED_OF_LIGHT=sn,Ae.Touchstone=Fc,Ae.TouchstoneFormats=wc,Ae.TouchstoneParameters=yc,Ae.abs=xt,Ae.add=Xr,Ae.arg=on,Ae.complex=It,Ae.index=$t,Ae.log10=Gi,Ae.multiply=Cr,Ae.pi=Jr,Ae.pow=ru,Ae.range=Pt,Ae.round=an,Ae.subset=Ot,Object.defineProperty(Ae,Symbol.toStringTag,{value:"Module"})});
|